From f55eeec3ee9d435ebce3e1110349afae49b147fe Mon Sep 17 00:00:00 2001 From: "verwaest@chromium.org" Date: Fri, 9 May 2014 17:21:51 +0000 Subject: [PATCH] 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 --- src/bootstrapper.cc | 78 +++++++++++++++++++++++------------------------------ 1 file changed, 34 insertions(+), 44 deletions(-) diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc index fe65e42..f464bdb 100644 --- a/src/bootstrapper.cc +++ b/src/bootstrapper.cc @@ -351,8 +351,7 @@ static Handle InstallFunction(Handle target, InstanceType type, int instance_size, MaybeHandle maybe_prototype, - Builtins::Name call, - bool set_instance_class_name) { + Builtins::Name call) { Isolate* isolate = target->GetIsolate(); Factory* factory = isolate->factory(); Handle internalized_name = factory->InternalizeUtf8String(name); @@ -371,7 +370,7 @@ static Handle InstallFunction(Handle 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 inner_global, inner_global, object_name, isolate->object_function(), DONT_ENUM).Check(); - Handle global = Handle(native_context()->global_object()); + Handle 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 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 inner_global, Handle 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 inner_global, Handle 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 inner_global, Handle 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 inner_global, Handle 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 inner_global, Handle 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 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 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* fun, Handle* external_map) { Handle global = Handle(native_context()->global_object()); - Handle result = InstallFunction(global, name, JS_TYPED_ARRAY_TYPE, - JSTypedArray::kSize, isolate()->initial_object_prototype(), - Builtins::kIllegal, true); + Handle result = InstallFunction( + global, name, JS_TYPED_ARRAY_TYPE, JSTypedArray::kSize, + isolate()->initial_object_prototype(), Builtins::kIllegal); Handle 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 symbol_fun = - InstallFunction(global, "Symbol", JS_VALUE_TYPE, JSValue::kSize, - isolate()->initial_object_prototype(), - Builtins::kIllegal, true); + Handle 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 = isolate()->factory()->NewMap( JS_SET_ITERATOR_TYPE, JSSetIterator::kSize); @@ -1329,13 +1323,13 @@ void Genesis::InitializeExperimentalGlobal() { Handle builtins(native_context()->builtins()); Handle generator_object_prototype = factory()->NewJSObject(isolate()->object_function(), TENURED); - Handle generator_function_prototype = - InstallFunction(builtins, "GeneratorFunctionPrototype", - JS_FUNCTION_TYPE, JSFunction::kHeaderSize, - generator_object_prototype, Builtins::kIllegal, false); + Handle 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 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 array_function = InstallFunction( - builtins, name, JS_ARRAY_TYPE, JSArray::kSize, - isolate()->initial_object_prototype(), Builtins::kInternalArrayCode, - true); Handle prototype = factory()->NewJSObject(isolate()->object_function(), TENURED); - Accessors::FunctionSetPrototype(array_function, prototype); + Handle array_function = InstallFunction( + builtins, name, JS_ARRAY_TYPE, JSArray::kSize, + prototype, Builtins::kInternalArrayCode); InternalArrayConstructorStub internal_array_constructor_stub(isolate()); Handle code = internal_array_constructor_stub.GetCode(); @@ -1673,7 +1665,7 @@ bool Genesis::InstallNatives() { // Builtin functions for Script. Handle script_fun = InstallFunction( builtins, "Script", JS_VALUE_TYPE, JSValue::kSize, - isolate()->initial_object_prototype(), Builtins::kIllegal, false); + isolate()->initial_object_prototype(), Builtins::kIllegal); Handle 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 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 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 call = InstallFunction(proto, "call", JS_OBJECT_TYPE, JSObject::kHeaderSize, - MaybeHandle(), - Builtins::kFunctionCall, false); + MaybeHandle(), Builtins::kFunctionCall); Handle apply = InstallFunction(proto, "apply", JS_OBJECT_TYPE, JSObject::kHeaderSize, - MaybeHandle(), - Builtins::kFunctionApply, false); + MaybeHandle(), Builtins::kFunctionApply); // Make sure that Function.prototype.call appears to be compiled. // The code will never be called, but inline caching for call will -- 2.7.4