Reviewers: Toon Verwaest,

Message:
PTAL.

cctests pass on Linux in ia32.{release,optdebug,debug}.

Description:
Reland "Avoid some unnecessary fast-properties map creations."

This relands commit ea74f0f85a7730879a2f17721629f93525886092.

The revert was due to failures in cctest/test-heap/ReleaseOverReservedPages,
caused by apparent changes to memory layout and fragmentation of the
first page. Eliminating a situation in messages.js where this CL has had
an effect on map transitions seems to solve the issue.

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

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

Affected files (+8, -8 lines):
  M src/messages.js
  M src/objects.cc
  M src/runtime/runtime-object.cc
  M test/mjsunit/object-freeze.js
  M test/mjsunit/regress/regress-crbug-137689.js


Index: src/messages.js
diff --git a/src/messages.js b/src/messages.js
index b15ccc6e42a04b469d69ba4aa89a51ec4f27fd83..049cecde445d595cc2353ed2860df8254507d14b 100644
--- a/src/messages.js
+++ b/src/messages.js
@@ -1224,7 +1224,6 @@ function SetUpError() {
         // Define all the expected properties directly on the error
         // object. This avoids going through getters and setters defined
         // on prototype objects.
-        %AddNamedProperty(this, 'stack', UNDEFINED, DONT_ENUM);
         if (!IS_UNDEFINED(m)) {
           %AddNamedProperty(this, 'message', ToString(m), DONT_ENUM);
         }
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index ab13412f52989ecc7eb9e6510ab6d46afe0a9e73..cc9482b01fb93f3f2c0531c2cd02473c864d353b 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -9505,13 +9505,17 @@ void JSObject::OptimizeAsPrototype(Handle<JSObject> object,
     JSObject::NormalizeProperties(object, KEEP_INOBJECT_PROPERTIES, 0,
                                   "NormalizeAsPrototype");
   }
+  bool has_just_copied_map = false;
   if (!object->HasFastProperties()) {
     JSObject::MigrateSlowToFast(object, 0, "OptimizeAsPrototype");
+    has_just_copied_map = true;
   }
   if (mode == FAST_PROTOTYPE && object->HasFastProperties() &&
       !object->map()->is_prototype_map()) {
- Handle<Map> new_map = Map::Copy(handle(object->map()), "CopyAsPrototype");
-    JSObject::MigrateToMap(object, new_map);
+    if (!has_just_copied_map) {
+ Handle<Map> new_map = Map::Copy(handle(object->map()), "CopyAsPrototype");
+      JSObject::MigrateToMap(object, new_map);
+    }
     object->map()->set_is_prototype_map(true);
   }
 }
Index: src/runtime/runtime-object.cc
diff --git a/src/runtime/runtime-object.cc b/src/runtime/runtime-object.cc
index b2a736d7a5bb41e07532366ac815da3693bcbace..524c88451dad3e773ab20065e03e083ed5c8a89b 100644
--- a/src/runtime/runtime-object.cc
+++ b/src/runtime/runtime-object.cc
@@ -1455,10 +1455,8 @@ RUNTIME_FUNCTION(Runtime_DefineAccessorPropertyUnchecked) { RUNTIME_ASSERT((unchecked & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0);
   PropertyAttributes attr = static_cast<PropertyAttributes>(unchecked);

-  bool fast = obj->HasFastProperties();
   RETURN_FAILURE_ON_EXCEPTION(
       isolate, JSObject::DefineAccessor(obj, name, getter, setter, attr));
-  if (fast) JSObject::MigrateSlowToFast(obj, 0, "RuntimeDefineAccessor");
   return isolate->heap()->undefined_value();
 }

Index: test/mjsunit/object-freeze.js
diff --git a/test/mjsunit/object-freeze.js b/test/mjsunit/object-freeze.js
index 4144936d06437396b5625f5a51493c45db42732d..a48251304d85c536c055261c88867f623df97d99 100644
--- a/test/mjsunit/object-freeze.js
+++ b/test/mjsunit/object-freeze.js
@@ -303,7 +303,7 @@ assertTrue(Object.isFrozen(Object.freeze(function(){"use strict";})));

 // Also test a simpler case
 obj = {};
-Object.defineProperty(obj, 'accessor', {
+Object.defineProperty(obj, 'accessor2', {
   get: function() { return 42 },
   set: function() { accessorDidRun = true },
   configurable: true,
Index: test/mjsunit/regress/regress-crbug-137689.js
diff --git a/test/mjsunit/regress/regress-crbug-137689.js b/test/mjsunit/regress/regress-crbug-137689.js index 0ff0c4e76bafdb3f1795f6bb9216674049419420..ef79d240f8926a39c3fffe31c5f9b7de3a521a48 100644
--- a/test/mjsunit/regress/regress-crbug-137689.js
+++ b/test/mjsunit/regress/regress-crbug-137689.js
@@ -44,5 +44,4 @@ assertTrue(%HaveSameMap(o, o2));

 Object.defineProperty(o, "foo", { set: setter, configurable: true });
 Object.defineProperty(o2, "foo", { set: setter, configurable: true });
-// TODO(ishell): this should eventually become assertTrue().
-assertFalse(%HaveSameMap(o, o2));
+assertTrue(%HaveSameMap(o, o2));


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