0f88153075
In general, deleting a property from a fast-properties object
requires transitioning the object to dictionary mode. However,
when the most-recently-added property is deleted, we can simply
roll back the last map transition that the object went through.
This is a performance experiment: it should make things faster,
but if it turns out to have more negative than positive impact,
we will have to revert it.
TBR=bmeurer@chromium.org (just adding a comment)
Previously reviewed at https://codereview.chromium.org/2830093002
Previously landed as 98acfb36e1
/ r44799
Review-Url: https://codereview.chromium.org/2840583002
Cr-Commit-Position: refs/heads/master@{#44808}
57 lines
1.4 KiB
JavaScript
57 lines
1.4 KiB
JavaScript
// Copyright 2014 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
|
|
|
|
// Test loading existent and nonexistent properties from dictionary
|
|
// mode objects.
|
|
|
|
function SlowObject() {
|
|
this.foo = 1;
|
|
this.bar = 2;
|
|
this.qux = 3;
|
|
this.z = 4;
|
|
delete this.qux;
|
|
assertFalse(%HasFastProperties(this));
|
|
}
|
|
function SlowObjectWithBaz() {
|
|
var o = new SlowObject();
|
|
o.baz = 4;
|
|
return o;
|
|
}
|
|
|
|
function Load(o) {
|
|
return o.baz;
|
|
}
|
|
|
|
for (var i = 0; i < 10; i++) {
|
|
var o1 = new SlowObject();
|
|
var o2 = SlowObjectWithBaz();
|
|
assertEquals(undefined, Load(o1));
|
|
assertEquals(4, Load(o2));
|
|
}
|
|
|
|
// Test objects getting optimized as fast prototypes.
|
|
|
|
function SlowPrototype() {
|
|
this.foo = 1;
|
|
}
|
|
SlowPrototype.prototype.bar = 2;
|
|
SlowPrototype.prototype.baz = 3;
|
|
SlowPrototype.prototype.z = 4;
|
|
delete SlowPrototype.prototype.baz;
|
|
assertFalse(%HasFastProperties(SlowPrototype.prototype));
|
|
var slow_proto = new SlowPrototype;
|
|
// ICs make prototypes fast.
|
|
function ic() { return slow_proto.bar; }
|
|
ic();
|
|
ic();
|
|
assertTrue(%HasFastProperties(slow_proto.__proto__));
|
|
|
|
// Prototypes stay fast even after deleting properties.
|
|
assertTrue(%HasFastProperties(SlowPrototype.prototype));
|
|
var fast_proto = new SlowPrototype();
|
|
assertTrue(%HasFastProperties(SlowPrototype.prototype));
|
|
assertTrue(%HasFastProperties(fast_proto.__proto__));
|