Always set the class name on installed functions if the target is the JSGlobal
BUG= R=ishell@chromium.org Review URL: https://codereview.chromium.org/261963003 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@21238 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
parent
b136448957
commit
f55eeec3ee
@ -351,8 +351,7 @@ static Handle<JSFunction> InstallFunction(Handle<JSObject> target,
|
||||
InstanceType type,
|
||||
int instance_size,
|
||||
MaybeHandle<JSObject> maybe_prototype,
|
||||
Builtins::Name call,
|
||||
bool set_instance_class_name) {
|
||||
Builtins::Name call) {
|
||||
Isolate* isolate = target->GetIsolate();
|
||||
Factory* factory = isolate->factory();
|
||||
Handle<String> internalized_name = factory->InternalizeUtf8String(name);
|
||||
@ -371,7 +370,7 @@ static Handle<JSFunction> InstallFunction(Handle<JSObject> target,
|
||||
}
|
||||
JSObject::SetLocalPropertyIgnoreAttributes(
|
||||
target, internalized_name, function, attributes).Check();
|
||||
if (set_instance_class_name) {
|
||||
if (target->IsJSGlobalObject()) {
|
||||
function->shared()->set_instance_class_name(*internalized_name);
|
||||
}
|
||||
function->shared()->set_native(true);
|
||||
@ -834,17 +833,17 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global,
|
||||
inner_global, object_name,
|
||||
isolate->object_function(), DONT_ENUM).Check();
|
||||
|
||||
Handle<JSObject> global = Handle<JSObject>(native_context()->global_object());
|
||||
Handle<JSObject> global(native_context()->global_object());
|
||||
|
||||
// Install global Function object
|
||||
InstallFunction(global, "Function", JS_FUNCTION_TYPE, JSFunction::kSize,
|
||||
empty_function, Builtins::kIllegal, true);
|
||||
empty_function, Builtins::kIllegal);
|
||||
|
||||
{ // --- A r r a y ---
|
||||
Handle<JSFunction> array_function =
|
||||
InstallFunction(global, "Array", JS_ARRAY_TYPE, JSArray::kSize,
|
||||
isolate->initial_object_prototype(),
|
||||
Builtins::kArrayCode, true);
|
||||
Builtins::kArrayCode);
|
||||
array_function->shared()->DontAdaptArguments();
|
||||
array_function->shared()->set_function_data(Smi::FromInt(kArrayCode));
|
||||
|
||||
@ -888,7 +887,7 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global,
|
||||
Handle<JSFunction> number_fun =
|
||||
InstallFunction(global, "Number", JS_VALUE_TYPE, JSValue::kSize,
|
||||
isolate->initial_object_prototype(),
|
||||
Builtins::kIllegal, true);
|
||||
Builtins::kIllegal);
|
||||
native_context()->set_number_function(*number_fun);
|
||||
}
|
||||
|
||||
@ -896,7 +895,7 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global,
|
||||
Handle<JSFunction> boolean_fun =
|
||||
InstallFunction(global, "Boolean", JS_VALUE_TYPE, JSValue::kSize,
|
||||
isolate->initial_object_prototype(),
|
||||
Builtins::kIllegal, true);
|
||||
Builtins::kIllegal);
|
||||
native_context()->set_boolean_function(*boolean_fun);
|
||||
}
|
||||
|
||||
@ -904,7 +903,7 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global,
|
||||
Handle<JSFunction> string_fun =
|
||||
InstallFunction(global, "String", JS_VALUE_TYPE, JSValue::kSize,
|
||||
isolate->initial_object_prototype(),
|
||||
Builtins::kIllegal, true);
|
||||
Builtins::kIllegal);
|
||||
string_fun->shared()->set_construct_stub(
|
||||
isolate->builtins()->builtin(Builtins::kStringConstructCode));
|
||||
native_context()->set_string_function(*string_fun);
|
||||
@ -929,7 +928,7 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global,
|
||||
Handle<JSFunction> date_fun =
|
||||
InstallFunction(global, "Date", JS_DATE_TYPE, JSDate::kSize,
|
||||
isolate->initial_object_prototype(),
|
||||
Builtins::kIllegal, true);
|
||||
Builtins::kIllegal);
|
||||
|
||||
native_context()->set_date_function(*date_fun);
|
||||
}
|
||||
@ -940,7 +939,7 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global,
|
||||
Handle<JSFunction> regexp_fun =
|
||||
InstallFunction(global, "RegExp", JS_REGEXP_TYPE, JSRegExp::kSize,
|
||||
isolate->initial_object_prototype(),
|
||||
Builtins::kIllegal, true);
|
||||
Builtins::kIllegal);
|
||||
native_context()->set_regexp_function(*regexp_fun);
|
||||
|
||||
ASSERT(regexp_fun->has_initial_map());
|
||||
@ -1042,7 +1041,7 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global,
|
||||
global, "ArrayBuffer", JS_ARRAY_BUFFER_TYPE,
|
||||
JSArrayBuffer::kSizeWithInternalFields,
|
||||
isolate->initial_object_prototype(),
|
||||
Builtins::kIllegal, true);
|
||||
Builtins::kIllegal);
|
||||
native_context()->set_array_buffer_fun(*array_buffer_fun);
|
||||
}
|
||||
|
||||
@ -1066,18 +1065,16 @@ void Genesis::InitializeGlobal(Handle<GlobalObject> inner_global,
|
||||
global, "DataView", JS_DATA_VIEW_TYPE,
|
||||
JSDataView::kSizeWithInternalFields,
|
||||
isolate->initial_object_prototype(),
|
||||
Builtins::kIllegal, true);
|
||||
Builtins::kIllegal);
|
||||
native_context()->set_data_view_fun(*data_view_fun);
|
||||
}
|
||||
|
||||
// -- W e a k M a p
|
||||
InstallFunction(global, "WeakMap", JS_WEAK_MAP_TYPE, JSWeakMap::kSize,
|
||||
isolate->initial_object_prototype(),
|
||||
Builtins::kIllegal, true);
|
||||
isolate->initial_object_prototype(), Builtins::kIllegal);
|
||||
// -- W e a k S e t
|
||||
InstallFunction(global, "WeakSet", JS_WEAK_SET_TYPE, JSWeakSet::kSize,
|
||||
isolate->initial_object_prototype(),
|
||||
Builtins::kIllegal, true);
|
||||
isolate->initial_object_prototype(), Builtins::kIllegal);
|
||||
|
||||
{ // --- arguments_boilerplate_
|
||||
// Make sure we can recognize argument objects at runtime.
|
||||
@ -1271,9 +1268,9 @@ void Genesis::InstallTypedArray(
|
||||
Handle<JSFunction>* fun,
|
||||
Handle<Map>* external_map) {
|
||||
Handle<JSObject> global = Handle<JSObject>(native_context()->global_object());
|
||||
Handle<JSFunction> result = InstallFunction(global, name, JS_TYPED_ARRAY_TYPE,
|
||||
JSTypedArray::kSize, isolate()->initial_object_prototype(),
|
||||
Builtins::kIllegal, true);
|
||||
Handle<JSFunction> result = InstallFunction(
|
||||
global, name, JS_TYPED_ARRAY_TYPE, JSTypedArray::kSize,
|
||||
isolate()->initial_object_prototype(), Builtins::kIllegal);
|
||||
|
||||
Handle<Map> initial_map = isolate()->factory()->NewMap(
|
||||
JS_TYPED_ARRAY_TYPE,
|
||||
@ -1296,22 +1293,19 @@ void Genesis::InitializeExperimentalGlobal() {
|
||||
|
||||
if (FLAG_harmony_symbols) {
|
||||
// --- S y m b o l ---
|
||||
Handle<JSFunction> symbol_fun =
|
||||
InstallFunction(global, "Symbol", JS_VALUE_TYPE, JSValue::kSize,
|
||||
isolate()->initial_object_prototype(),
|
||||
Builtins::kIllegal, true);
|
||||
Handle<JSFunction> symbol_fun = InstallFunction(
|
||||
global, "Symbol", JS_VALUE_TYPE, JSValue::kSize,
|
||||
isolate()->initial_object_prototype(), Builtins::kIllegal);
|
||||
native_context()->set_symbol_function(*symbol_fun);
|
||||
}
|
||||
|
||||
if (FLAG_harmony_collections) {
|
||||
// -- M a p
|
||||
InstallFunction(global, "Map", JS_MAP_TYPE, JSMap::kSize,
|
||||
isolate()->initial_object_prototype(),
|
||||
Builtins::kIllegal, true);
|
||||
isolate()->initial_object_prototype(), Builtins::kIllegal);
|
||||
// -- S e t
|
||||
InstallFunction(global, "Set", JS_SET_TYPE, JSSet::kSize,
|
||||
isolate()->initial_object_prototype(),
|
||||
Builtins::kIllegal, true);
|
||||
isolate()->initial_object_prototype(), Builtins::kIllegal);
|
||||
{ // -- S e t I t e r a t o r
|
||||
Handle<Map> map = isolate()->factory()->NewMap(
|
||||
JS_SET_ITERATOR_TYPE, JSSetIterator::kSize);
|
||||
@ -1329,13 +1323,13 @@ void Genesis::InitializeExperimentalGlobal() {
|
||||
Handle<JSObject> builtins(native_context()->builtins());
|
||||
Handle<JSObject> generator_object_prototype =
|
||||
factory()->NewJSObject(isolate()->object_function(), TENURED);
|
||||
Handle<JSFunction> generator_function_prototype =
|
||||
InstallFunction(builtins, "GeneratorFunctionPrototype",
|
||||
JS_FUNCTION_TYPE, JSFunction::kHeaderSize,
|
||||
generator_object_prototype, Builtins::kIllegal, false);
|
||||
Handle<JSFunction> generator_function_prototype = InstallFunction(
|
||||
builtins, "GeneratorFunctionPrototype", JS_FUNCTION_TYPE,
|
||||
JSFunction::kHeaderSize, generator_object_prototype,
|
||||
Builtins::kIllegal);
|
||||
InstallFunction(builtins, "GeneratorFunction",
|
||||
JS_FUNCTION_TYPE, JSFunction::kSize,
|
||||
generator_function_prototype, Builtins::kIllegal, false);
|
||||
generator_function_prototype, Builtins::kIllegal);
|
||||
|
||||
// Create maps for generator functions and their prototypes. Store those
|
||||
// maps in the native context.
|
||||
@ -1574,13 +1568,11 @@ Handle<JSFunction> Genesis::InstallInternalArray(
|
||||
// doesn't inherit from Object.prototype.
|
||||
// To be used only for internal work by builtins. Instances
|
||||
// must not be leaked to user code.
|
||||
Handle<JSFunction> array_function = InstallFunction(
|
||||
builtins, name, JS_ARRAY_TYPE, JSArray::kSize,
|
||||
isolate()->initial_object_prototype(), Builtins::kInternalArrayCode,
|
||||
true);
|
||||
Handle<JSObject> prototype =
|
||||
factory()->NewJSObject(isolate()->object_function(), TENURED);
|
||||
Accessors::FunctionSetPrototype(array_function, prototype);
|
||||
Handle<JSFunction> array_function = InstallFunction(
|
||||
builtins, name, JS_ARRAY_TYPE, JSArray::kSize,
|
||||
prototype, Builtins::kInternalArrayCode);
|
||||
|
||||
InternalArrayConstructorStub internal_array_constructor_stub(isolate());
|
||||
Handle<Code> code = internal_array_constructor_stub.GetCode();
|
||||
@ -1673,7 +1665,7 @@ bool Genesis::InstallNatives() {
|
||||
// Builtin functions for Script.
|
||||
Handle<JSFunction> script_fun = InstallFunction(
|
||||
builtins, "Script", JS_VALUE_TYPE, JSValue::kSize,
|
||||
isolate()->initial_object_prototype(), Builtins::kIllegal, false);
|
||||
isolate()->initial_object_prototype(), Builtins::kIllegal);
|
||||
Handle<JSObject> prototype =
|
||||
factory()->NewJSObject(isolate()->object_function(), TENURED);
|
||||
Accessors::FunctionSetPrototype(script_fun, prototype);
|
||||
@ -1798,7 +1790,7 @@ bool Genesis::InstallNatives() {
|
||||
// objects, that JavaScript code may not access.
|
||||
Handle<JSFunction> opaque_reference_fun = InstallFunction(
|
||||
builtins, "OpaqueReference", JS_VALUE_TYPE, JSValue::kSize,
|
||||
isolate()->initial_object_prototype(), Builtins::kIllegal, false);
|
||||
isolate()->initial_object_prototype(), Builtins::kIllegal);
|
||||
Handle<JSObject> prototype =
|
||||
factory()->NewJSObject(isolate()->object_function(), TENURED);
|
||||
Accessors::FunctionSetPrototype(opaque_reference_fun, prototype);
|
||||
@ -1857,12 +1849,10 @@ bool Genesis::InstallNatives() {
|
||||
// Install the call and the apply functions.
|
||||
Handle<JSFunction> call =
|
||||
InstallFunction(proto, "call", JS_OBJECT_TYPE, JSObject::kHeaderSize,
|
||||
MaybeHandle<JSObject>(),
|
||||
Builtins::kFunctionCall, false);
|
||||
MaybeHandle<JSObject>(), Builtins::kFunctionCall);
|
||||
Handle<JSFunction> apply =
|
||||
InstallFunction(proto, "apply", JS_OBJECT_TYPE, JSObject::kHeaderSize,
|
||||
MaybeHandle<JSObject>(),
|
||||
Builtins::kFunctionApply, false);
|
||||
MaybeHandle<JSObject>(), Builtins::kFunctionApply);
|
||||
|
||||
// Make sure that Function.prototype.call appears to be compiled.
|
||||
// The code will never be called, but inline caching for call will
|
||||
|
Loading…
Reference in New Issue
Block a user