Reviewers: rossberg, rafaelw,

Message:
This is the third and last in a row of CLs. This one now finally gets rid of one
pesky call to JSObject::SetLocalPropertyIgnoreAttributesTrampoline.

rossberg@: PTAL.
rafaelw@: FYI.

Description:
Handlify Heap::AllocateFunctionPrototype method.

[email protected]
BUG=v8:2877

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

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

Affected files (+26, -43 lines):
  M src/factory.cc
  M src/heap.h
  M src/heap.cc


Index: src/factory.cc
diff --git a/src/factory.cc b/src/factory.cc
index 69a41692c4fa991a290d9cc19db5f9f03d3a4ff6..6ec223569e6c6f2cbbb5e0840a484f1e86b8efdd 100644
--- a/src/factory.cc
+++ b/src/factory.cc
@@ -573,10 +573,32 @@ Handle<Map> Factory::NewMap(InstanceType type,


Handle<JSObject> Factory::NewFunctionPrototype(Handle<JSFunction> function) {
-  CALL_HEAP_FUNCTION(
-      isolate(),
-      isolate()->heap()->AllocateFunctionPrototype(*function),
-      JSObject);
+ // Make sure to use globals from the function's context, since the function
+  // can be from a different context.
+  Handle<Context> native_context(function->context()->native_context());
+  Handle<Map> new_map;
+  if (function->shared()->is_generator()) {
+ // Generator prototypes can share maps since they don't have "constructor"
+    // properties.
+    new_map = handle(native_context->generator_object_prototype_map());
+  } else {
+ // Each function prototype gets a fresh map to avoid unwanted sharing of
+    // maps between prototypes of different constructors.
+    Handle<JSFunction> object_function(native_context->object_function());
+    ASSERT(object_function->has_initial_map());
+    new_map = Map::Copy(handle(object_function->initial_map()));
+  }
+
+  Handle<JSObject> prototype = NewJSObjectFromMap(new_map);
+
+  if (!function->shared()->is_generator()) {
+    JSObject::SetLocalPropertyIgnoreAttributes(prototype,
+                                               constructor_string(),
+                                               function,
+                                               DONT_ENUM);
+  }
+
+  return prototype;
 }


Index: src/heap.cc
diff --git a/src/heap.cc b/src/heap.cc
index 5f9bd38f07d9ccaf29d81252a5d873f6fbf7bc08..2f630333aad8a97219e479adcc3d5ae03c2c4642 100644
--- a/src/heap.cc
+++ b/src/heap.cc
@@ -4354,39 +4354,6 @@ void Heap::InitializeFunction(JSFunction* function,
 }


-MaybeObject* Heap::AllocateFunctionPrototype(JSFunction* function) {
- // Make sure to use globals from the function's context, since the function
-  // can be from a different context.
-  Context* native_context = function->context()->native_context();
-  Map* new_map;
-  if (function->shared()->is_generator()) {
- // Generator prototypes can share maps since they don't have "constructor"
-    // properties.
-    new_map = native_context->generator_object_prototype_map();
-  } else {
- // Each function prototype gets a fresh map to avoid unwanted sharing of
-    // maps between prototypes of different constructors.
-    JSFunction* object_function = native_context->object_function();
-    ASSERT(object_function->has_initial_map());
-    MaybeObject* maybe_map = object_function->initial_map()->Copy();
-    if (!maybe_map->To(&new_map)) return maybe_map;
-  }
-
-  Object* prototype;
-  MaybeObject* maybe_prototype = AllocateJSObjectFromMap(new_map);
-  if (!maybe_prototype->ToObject(&prototype)) return maybe_prototype;
-
-  if (!function->shared()->is_generator()) {
-    MaybeObject* maybe_failure =
- JSObject::cast(prototype)->SetLocalPropertyIgnoreAttributesTrampoline(
-            constructor_string(), function, DONT_ENUM);
-    if (maybe_failure->IsFailure()) return maybe_failure;
-  }
-
-  return prototype;
-}
-
-
 MaybeObject* Heap::AllocateFunction(Map* function_map,
                                     SharedFunctionInfo* shared,
                                     Object* prototype,
Index: src/heap.h
diff --git a/src/heap.h b/src/heap.h
index 7e9cb4751634d68935403f26bf2d623a7e554c73..82c256154c109b6df67d21111c0a9780855ae637 100644
--- a/src/heap.h
+++ b/src/heap.h
@@ -665,12 +665,6 @@ class Heap {
   MUST_USE_RESULT MaybeObject* CopyJSObject(JSObject* source,
                                             AllocationSite* site = NULL);

-  // Allocates the function prototype.
- // Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
-  // failed.
-  // Please note this does not perform a garbage collection.
- MUST_USE_RESULT MaybeObject* AllocateFunctionPrototype(JSFunction* function);
-
   // Allocates a JS ArrayBuffer object.
// Returns Failure::RetryAfterGC(requested_bytes, space) if the allocation
   // failed.


--
--
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/groups/opt_out.

Reply via email to