Revision: 20719
Author:   [email protected]
Date:     Mon Apr 14 11:43:40 2014 UTC
Log:      Revert "Handlify Runtime::InitializeIntrinsicFunctionNames."

This reverts r20718.

[email protected]

Review URL: https://codereview.chromium.org/236343005
http://code.google.com/p/v8/source/detail?r=20719

Modified:
 /branches/bleeding_edge/src/factory.cc
 /branches/bleeding_edge/src/heap.cc
 /branches/bleeding_edge/src/objects.cc
 /branches/bleeding_edge/src/objects.h
 /branches/bleeding_edge/src/runtime.cc
 /branches/bleeding_edge/src/runtime.h

=======================================
--- /branches/bleeding_edge/src/factory.cc      Mon Apr 14 11:32:12 2014 UTC
+++ /branches/bleeding_edge/src/factory.cc      Mon Apr 14 11:43:40 2014 UTC
@@ -1316,6 +1316,17 @@
   module->set_scope_info(*scope_info);
   return module;
 }
+
+
+// TODO(mstarzinger): Temporary wrapper until handlified.
+static Handle<NameDictionary> NameDictionaryAdd(Handle<NameDictionary> dict,
+                                                Handle<Name> name,
+                                                Handle<Object> value,
+                                                PropertyDetails details) {
+  CALL_HEAP_FUNCTION(dict->GetIsolate(),
+                     dict->Add(*name, *value, details),
+                     NameDictionary);
+}


 static Handle<GlobalObject> NewGlobalObjectFromMap(Isolate* isolate,
@@ -1360,7 +1371,7 @@
     Handle<Name> name(descs->GetKey(i));
     Handle<Object> value(descs->GetCallbacksObject(i), isolate());
     Handle<PropertyCell> cell = NewPropertyCell(value);
-    NameDictionary::Add(dictionary, name, cell, d);
+    NameDictionaryAdd(dictionary, name, cell, d);
   }

   // Allocate the global object and initialize it with the backing store.
=======================================
--- /branches/bleeding_edge/src/heap.cc Mon Apr 14 11:32:12 2014 UTC
+++ /branches/bleeding_edge/src/heap.cc Mon Apr 14 11:43:40 2014 UTC
@@ -2996,6 +2996,10 @@
         NameDictionary::Allocate(this, Runtime::kNumFunctions);
     if (!maybe_obj->ToObject(&obj)) return false;
   }
+ { MaybeObject* maybe_obj = Runtime::InitializeIntrinsicFunctionNames(this, + obj);
+    if (!maybe_obj->ToObject(&obj)) return false;
+  }
   set_intrinsic_function_names(NameDictionary::cast(obj));

   { MaybeObject* maybe_obj = AllocateInitialNumberStringCache();
@@ -6176,11 +6180,6 @@
   array_buffers_list_ = undefined_value();
   allocation_sites_list_ = undefined_value();
   weak_object_to_code_table_ = undefined_value();
-
-  HandleScope scope(isolate());
-  Runtime::InitializeIntrinsicFunctionNames(
-      isolate(), handle(intrinsic_function_names(), isolate()));
-
   return true;
 }

=======================================
--- /branches/bleeding_edge/src/objects.cc      Mon Apr 14 11:32:12 2014 UTC
+++ /branches/bleeding_edge/src/objects.cc      Mon Apr 14 11:43:40 2014 UTC
@@ -631,6 +631,17 @@
     property_dictionary->ValueAtPut(result->GetDictionaryEntry(), *value);
   }
 }
+
+
+// TODO(mstarzinger): Temporary wrapper until handlified.
+static Handle<NameDictionary> NameDictionaryAdd(Handle<NameDictionary> dict,
+                                                Handle<Name> name,
+                                                Handle<Object> value,
+                                                PropertyDetails details) {
+  CALL_HEAP_FUNCTION(dict->GetIsolate(),
+                     dict->Add(*name, *value, details),
+                     NameDictionary);
+}


 void JSObject::SetNormalizedProperty(Handle<JSObject> object,
@@ -653,7 +664,7 @@
     }

     property_dictionary =
- NameDictionary::Add(property_dictionary, name, store_value, details);
+        NameDictionaryAdd(property_dictionary, name, store_value, details);
     object->set_properties(*property_dictionary);
     return;
   }
@@ -1933,8 +1944,7 @@
     value = cell;
   }
   PropertyDetails details = PropertyDetails(attributes, NORMAL, 0);
-  Handle<NameDictionary> result =
-      NameDictionary::Add(dict, name, value, details);
+ Handle<NameDictionary> result = NameDictionaryAdd(dict, name, value, details);
   if (*dict != *result) object->set_properties(*result);
 }

@@ -4493,7 +4503,7 @@
         Handle<Object> value(descs->GetConstant(i), isolate);
         PropertyDetails d = PropertyDetails(
             details.attributes(), NORMAL, i + 1);
-        dictionary = NameDictionary::Add(dictionary, key, value, d);
+        dictionary = NameDictionaryAdd(dictionary, key, value, d);
         break;
       }
       case FIELD: {
@@ -4502,7 +4512,7 @@
             object->RawFastPropertyAt(descs->GetFieldIndex(i)), isolate);
         PropertyDetails d =
             PropertyDetails(details.attributes(), NORMAL, i + 1);
-        dictionary = NameDictionary::Add(dictionary, key, value, d);
+        dictionary = NameDictionaryAdd(dictionary, key, value, d);
         break;
       }
       case CALLBACKS: {
@@ -4510,7 +4520,7 @@
         Handle<Object> value(descs->GetCallbacksObject(i), isolate);
         PropertyDetails d = PropertyDetails(
             details.attributes(), CALLBACKS, i + 1);
-        dictionary = NameDictionary::Add(dictionary, key, value, d);
+        dictionary = NameDictionaryAdd(dictionary, key, value, d);
         break;
       }
       case INTERCEPTOR:
@@ -14296,17 +14306,6 @@

 template
 int HashTable<SeededNumberDictionaryShape, uint32_t>::FindEntry(uint32_t);
-
-
-Handle<NameDictionary> NameDictionary::Add(Handle<NameDictionary> dict,
-                                           Handle<Name> name,
-                                           Handle<Object> value,
-                                           PropertyDetails details) {
-  CALL_HEAP_FUNCTION(dict->GetIsolate(),
-                     Handle<Dictionary>::cast(dict)->Add(
-                         *name, *value, details),
-                     NameDictionary);
-}


 Handle<Object> JSObject::PrepareSlowElementsForSort(
@@ -14840,7 +14839,7 @@
         isolate->factory()->the_hole_value());
     PropertyDetails details(NONE, NORMAL, 0);
     details = details.AsDeleted();
-    Handle<NameDictionary> dictionary = NameDictionary::Add(
+    Handle<NameDictionary> dictionary = NameDictionaryAdd(
         handle(global->property_dictionary()), name, cell, details);
     global->set_properties(*dictionary);
     return cell;
=======================================
--- /branches/bleeding_edge/src/objects.h       Mon Apr 14 11:32:12 2014 UTC
+++ /branches/bleeding_edge/src/objects.h       Mon Apr 14 11:43:40 2014 UTC
@@ -4093,12 +4093,6 @@
   // Find entry for key, otherwise return kNotFound. Optimized version of
   // HashTable::FindEntry.
   int FindEntry(Name* key);
-
-  // TODO(mstarzinger): Temporary wrapper until handlified.
-  static Handle<NameDictionary> Add(Handle<NameDictionary> dict,
-                                    Handle<Name> name,
-                                    Handle<Object> value,
-                                    PropertyDetails details);
 };


=======================================
--- /branches/bleeding_edge/src/runtime.cc      Mon Apr 14 11:32:12 2014 UTC
+++ /branches/bleeding_edge/src/runtime.cc      Mon Apr 14 11:43:40 2014 UTC
@@ -15089,21 +15089,31 @@
 #undef F


-void Runtime::InitializeIntrinsicFunctionNames(Isolate* isolate,
- Handle<NameDictionary> dict) {
-  ASSERT(dict->NumberOfElements() == 0);
-  HandleScope scope(isolate);
+MaybeObject* Runtime::InitializeIntrinsicFunctionNames(Heap* heap,
+ Object* dictionary) {
+  ASSERT(dictionary != NULL);
+  ASSERT(NameDictionary::cast(dictionary)->NumberOfElements() == 0);
   for (int i = 0; i < kNumFunctions; ++i) {
     const char* name = kIntrinsicFunctions[i].name;
     if (name == NULL) continue;
-    Handle<NameDictionary> new_dict = NameDictionary::Add(
-        dict,
-        isolate->factory()->InternalizeUtf8String(name),
-        Handle<Smi>(Smi::FromInt(i), isolate),
-        PropertyDetails(NONE, NORMAL, Representation::None()));
-    // The dictionary does not need to grow.
-    CHECK(new_dict.is_identical_to(dict));
+    Object* name_string;
+    { MaybeObject* maybe_name_string =
+          heap->InternalizeUtf8String(name);
+ if (!maybe_name_string->ToObject(&name_string)) return maybe_name_string;
+    }
+    NameDictionary* name_dictionary = NameDictionary::cast(dictionary);
+    { MaybeObject* maybe_dictionary = name_dictionary->Add(
+          String::cast(name_string),
+          Smi::FromInt(i),
+          PropertyDetails(NONE, NORMAL, Representation::None()));
+      if (!maybe_dictionary->ToObject(&dictionary)) {
+        // Non-recoverable failure.  Calling code must restart heap
+        // initialization.
+        return maybe_dictionary;
+      }
+    }
   }
+  return dictionary;
 }


=======================================
--- /branches/bleeding_edge/src/runtime.h       Mon Apr 14 11:32:12 2014 UTC
+++ /branches/bleeding_edge/src/runtime.h       Mon Apr 14 11:43:40 2014 UTC
@@ -798,8 +798,11 @@

   // Add internalized strings for all the intrinsic function names to a
   // StringDictionary.
-  static void InitializeIntrinsicFunctionNames(Isolate* isolate,
- Handle<NameDictionary> dict);
+  // Returns failure if an allocation fails.  In this case, it must be
+  // retried with a new, empty StringDictionary, not with the same one.
+  // Alternatively, heap initialization can be completely restarted.
+  MUST_USE_RESULT static MaybeObject* InitializeIntrinsicFunctionNames(
+      Heap* heap, Object* dictionary);

// Get the intrinsic function with the given name, which must be internalized.
   static const Function* FunctionForName(Handle<String> name);

--
--
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