v8/test/mjsunit/regress/regress-store-transition-dict.js
Igor Sheludko 78c6bbd930 [ic] Use Map as transition handlers instead of StoreHandler objects.
This eases transition handlers caching and avoids memory overhead of
respective StoreHandler objects. In addition, it allows to use such
transition handlers on runtime side to make Object.assign implementation
a bit faster.

Bug: v8:5988
Change-Id: Iba660a11d4b300cd5f80615fb7e2608e53da8fee
Reviewed-on: https://chromium-review.googlesource.com/931701
Reviewed-by: Toon Verwaest <verwaest@chromium.org>
Commit-Queue: Igor Sheludko <ishell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#52187}
2018-03-23 15:37:40 +00:00

85 lines
1.6 KiB
JavaScript

// Copyright 2018 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --allow-natives-syntax
(function() {
function SetX(o, v) {
o.x = v;
}
function SetY(o, v) {
o.y = v;
}
var p = {};
function Create() {
var o = {__proto__:p, b:1, a:2};
delete o.b;
assertFalse(%HasFastProperties(o));
return o;
}
for (var i = 0; i < 10; i++) {
var o = Create();
SetX(o, 13);
SetY(o, 13);
}
Object.defineProperty(p, "x", {value:42, configurable: true, writable: false});
for (var i = 0; i < 10; i++) {
var o = Create();
SetY(o, 13);
}
var o = Create();
assertEquals(42, o.x);
SetX(o, 13);
assertEquals(42, o.x);
})();
(function() {
var p1 = {a:10};
Object.defineProperty(p1, "x", {value:42, configurable: true, writable: false});
var p2 = {__proto__: p1, x:153};
for (var i = 0; i < 2000; i++) {
p1["p" + i] = 0;
p2["p" + i] = 0;
}
assertFalse(%HasFastProperties(p1));
assertFalse(%HasFastProperties(p2));
function GetX(o) {
return o.x;
}
function SetX(o, v) {
o.x = v;
}
function Create() {
var o = {__proto__:p2, b:1, a:2};
return o;
}
for (var i = 0; i < 10; i++) {
var o = Create();
assertEquals(153, GetX(o));
SetX(o, 13);
assertEquals(13, GetX(o));
}
delete p2.x;
assertFalse(%HasFastProperties(p1));
assertFalse(%HasFastProperties(p2));
var o = Create();
assertEquals(42, GetX(o));
SetX(o, 13);
assertEquals(42, GetX(o));
})();