From 3b3929fdc76740ee22d737410db8e5c5b640d321 Mon Sep 17 00:00:00 2001 From: "jkummerow@chromium.org" Date: Tue, 11 Nov 2014 15:40:51 +0000 Subject: [PATCH] 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. R=verwaest@chromium.org Review URL: https://codereview.chromium.org/714883003 Cr-Commit-Position: refs/heads/master@{#25266} git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@25266 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/messages.js | 1 - src/objects.cc | 8 ++++++-- src/runtime/runtime-object.cc | 2 -- test/mjsunit/object-freeze.js | 2 +- test/mjsunit/regress/regress-crbug-137689.js | 3 +-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/messages.js b/src/messages.js index b15ccc6..049cecd 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); } diff --git a/src/objects.cc b/src/objects.cc index a01cf0f..01b4a1a 100644 --- a/src/objects.cc +++ b/src/objects.cc @@ -9609,13 +9609,17 @@ void JSObject::OptimizeAsPrototype(Handle 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 new_map = Map::Copy(handle(object->map()), "CopyAsPrototype"); - JSObject::MigrateToMap(object, new_map); + if (!has_just_copied_map) { + Handle new_map = Map::Copy(handle(object->map()), "CopyAsPrototype"); + JSObject::MigrateToMap(object, new_map); + } object->map()->set_is_prototype_map(true); } } diff --git a/src/runtime/runtime-object.cc b/src/runtime/runtime-object.cc index c83b247..fc97d6b 100644 --- a/src/runtime/runtime-object.cc +++ b/src/runtime/runtime-object.cc @@ -1454,10 +1454,8 @@ RUNTIME_FUNCTION(Runtime_DefineAccessorPropertyUnchecked) { RUNTIME_ASSERT((unchecked & ~(READ_ONLY | DONT_ENUM | DONT_DELETE)) == 0); PropertyAttributes attr = static_cast(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(); } diff --git a/test/mjsunit/object-freeze.js b/test/mjsunit/object-freeze.js index 4144936..a482513 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, diff --git a/test/mjsunit/regress/regress-crbug-137689.js b/test/mjsunit/regress/regress-crbug-137689.js index 0ff0c4e..ef79d24 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)); -- 2.7.4