Reviewers: Igor Sheludko,

Message:
PTAL

Description:
Always set the class name on installed functions if the target is the JSGlobal

BUG=

Please review this at https://codereview.chromium.org/261963003/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+32, -41 lines):
  M src/bootstrapper.cc


Index: src/bootstrapper.cc
diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc
index e4730b868b8cbc23fd7e684620975a77ad776671..95dbe09e153683d86434178f9ecee5c2292eba39 100644
--- a/src/bootstrapper.cc
+++ b/src/bootstrapper.cc
@@ -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,7 +1065,7 @@ 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);
   }

@@ -1262,9 +1261,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,
@@ -1287,22 +1286,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);
@@ -1318,12 +1314,10 @@ void Genesis::InitializeExperimentalGlobal() {
   if (FLAG_harmony_weak_collections) {
     // -- 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);
   }

   if (FLAG_harmony_generators) {
@@ -1331,13 +1325,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.
@@ -1577,8 +1571,7 @@ Handle<JSFunction> Genesis::InstallInternalArray(
   // 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);
+      isolate()->initial_object_prototype(), Builtins::kInternalArrayCode);
   Handle<JSObject> prototype =
       factory()->NewJSObject(isolate()->object_function(), TENURED);
   Accessors::FunctionSetPrototype(array_function, prototype);
@@ -1674,7 +1667,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);
@@ -1799,7 +1792,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);
@@ -1858,12 +1851,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


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to