v8/test/mjsunit/es6/collections-constructor-with-modified-protoype.js
Mythri A 3329cbc8eb Enable FLAG_feedback_allocation_on_bytecode_size
This flag enables feedback allocation heuristics to be based on the
function size. The threshold for feedback allocation is set to
12 * bytecode size to roughly mimic the allocation after 12 invocations.

We tried 4 * bytecode size earlier and there were few memory regressions
on real world pages. Speedometer improved by ~1% [1, 2]. This time
trying with a higher factor this time to see if we still have
speedometer improvements without any memory regressions.

[1] https://bugs.chromium.org/p/chromium/issues/detail?id=1177124
[2] https://bugs.chromium.org/p/chromium/issues/detail?id=1177241

Change-Id: I39c7d4aaf90b948b07419e4598e2193b8355c067
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2752150
Commit-Queue: Mythri Alle <mythria@chromium.org>
Reviewed-by: Ross McIlroy <rmcilroy@chromium.org>
Reviewed-by: Toon Verwaest <verwaest@chromium.org>
Cr-Commit-Position: refs/heads/master@{#73369}
2021-03-12 14:25:52 +00:00

81 lines
2.4 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 --opt --no-lazy-feedback-allocation
function TestSetPrototypeModified(ctor) {
const originalPrototypeAdd = ctor.prototype.add;
const k1 = {};
const k2 = {};
const entries = [k1, k2];
let addCount = 0;
ctor.prototype.add = function(value) {
addCount++;
originalPrototypeAdd.call(this, value);
entries.length = 1;
};
const set = new ctor(entries);
assertEquals(1, addCount);
assertTrue(set.has(k1));
assertFalse(set.has(k2));
ctor.prototype.add = originalPrototypeAdd;
}
%PrepareFunctionForOptimization(TestSetPrototypeModified);
TestSetPrototypeModified(Set);
TestSetPrototypeModified(Set);
TestSetPrototypeModified(Set);
%OptimizeFunctionOnNextCall(TestSetPrototypeModified);
TestSetPrototypeModified(Set);
assertOptimized(TestSetPrototypeModified);
%DeoptimizeFunction(TestSetPrototypeModified);
%PrepareFunctionForOptimization(TestSetPrototypeModified);
TestSetPrototypeModified(WeakSet);
TestSetPrototypeModified(WeakSet);
TestSetPrototypeModified(WeakSet);
%OptimizeFunctionOnNextCall(TestSetPrototypeModified);
TestSetPrototypeModified(WeakSet);
assertOptimized(TestSetPrototypeModified);
%DeoptimizeFunction(TestSetPrototypeModified);
function TestMapPrototypeModified(ctor) {
const originalPrototypeSet = ctor.prototype.set;
const k1 = {};
const k2 = {};
const entries = [[k1, 1], [k2, 2]];
let setCount = 0;
ctor.prototype.set = function(key, value) {
setCount++;
originalPrototypeSet.call(this, key, value);
entries.length = 1;
};
const map = new ctor(entries);
assertEquals(1, setCount);
assertTrue(map.has(k1));
assertFalse(map.has(k2));
ctor.prototype.set = originalPrototypeSet;
}
%PrepareFunctionForOptimization(TestMapPrototypeModified);
TestMapPrototypeModified(Map);
TestMapPrototypeModified(Map);
TestMapPrototypeModified(Map);
%OptimizeFunctionOnNextCall(TestMapPrototypeModified);
TestMapPrototypeModified(Map);
assertOptimized(TestMapPrototypeModified);
%DeoptimizeFunction(TestMapPrototypeModified);
%PrepareFunctionForOptimization(TestMapPrototypeModified);
TestMapPrototypeModified(WeakMap);
TestMapPrototypeModified(WeakMap);
TestMapPrototypeModified(WeakMap);
%OptimizeFunctionOnNextCall(TestMapPrototypeModified);
TestMapPrototypeModified(WeakMap);
assertOptimized(TestMapPrototypeModified);