Reviewers: Igor Sheludko,

Message:
PTAL

Description:
Only force creating initial maps when we have prototypes.

BUG=

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

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

Affected files (+7, -6 lines):
  M src/factory.cc


Index: src/factory.cc
diff --git a/src/factory.cc b/src/factory.cc
index bf0e7d0382b1d03265108bfb13dc492d9dafb363..af1e2a4a7c0351c35d3f2b5e496b55560ee91486 100644
--- a/src/factory.cc
+++ b/src/factory.cc
@@ -1240,11 +1240,10 @@ Handle<JSFunction> Factory::NewFunction(MaybeHandle<Object> maybe_prototype,
   // Allocate the function
   Handle<JSFunction> function = NewFunction(name, code, maybe_prototype);

-  Handle<Object> prototype;
-  if (maybe_prototype.ToHandle(&prototype) &&
-      (force_initial_map ||
-       type != JS_OBJECT_TYPE ||
-       instance_size != JSObject::kHeaderSize)) {
+  if (force_initial_map ||
+      type != JS_OBJECT_TYPE ||
+      instance_size != JSObject::kHeaderSize) {
+    Handle<Object> prototype = maybe_prototype.ToHandleChecked();
     Handle<Map> initial_map = NewMap(type, instance_size);
     if (prototype->IsJSObject()) {
       JSObject::SetLocalPropertyIgnoreAttributes(
@@ -2133,7 +2132,7 @@ Handle<JSFunction> Factory::CreateApiFunction(

   Handle<JSFunction> result = NewFunction(
       maybe_prototype, Factory::empty_string(), type,
-      instance_size, code, true);
+      instance_size, code, !obj->remove_prototype());

   result->shared()->set_length(obj->length());
   Handle<Object> class_name(obj->class_name(), isolate());
@@ -2147,6 +2146,8 @@ Handle<JSFunction> Factory::CreateApiFunction(

   if (obj->remove_prototype()) {
     ASSERT(result->shared()->IsApiFunction());
+    ASSERT(!result->has_initial_map());
+    ASSERT(!result->has_prototype());
     return result;
   }
   // Down from here is only valid for API functions that can be used as a


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