v8/test/mjsunit/es6/map-constructor-entry-side-effect2.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

63 lines
1.9 KiB
JavaScript
Raw Normal View History

// 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
function TestMapConstructorEntrySideEffect(ctor) {
const originalPrototypeSet = ctor.prototype.set;
const k1 = {};
const k2 = {};
let callCount = 0;
const input = [
Revert "Reland: ScopeInfo, SharedFunctionInfo never-ever serialized" This reverts commit d3cacbbbd54c5ee5ab109dc5a80ce58e281a5bc8. Reason for revert: Breaks gc stress again - https://ci.chromium.org/ui/p/v8/builders/ci/V8%20Linux%20-%20gc%20stress/34248/overview Original change's description: > Reland: ScopeInfo, SharedFunctionInfo never-ever serialized > > This relands squashed CLs: > > 59b9aaf7db3c369d864683c0e7e0967480841b15 > 8f84d0bb8f51898894d99338549cf053e0a9abef > > The revert was at crrev.com/c/2996198. > > Changed: Fixed a test in which bytecode flushing caused a behavioral > change between serialized- and unserialized SFI Refs. The serialized > SFI ref kept bytecode alive while unserialized SFIs allow flushing. > The test was fixed by adding a %PrepareFunctionForOptimization > annotation. > > No-Presubmit: true > No-Tree-Checks: true > No-Try: true > Bug: v8:7790, v8:11939 > Change-Id: I170f8085bd7454a2a5f2bb03c8824e2862857827 > Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2999089 > Commit-Queue: Jakob Gruber <jgruber@chromium.org> > Auto-Submit: Jakob Gruber <jgruber@chromium.org> > Reviewed-by: Georg Neis <neis@chromium.org> > Cr-Commit-Position: refs/heads/master@{#75504} Bug: v8:7790, v8:11939 Change-Id: Icf8858fda38e4ce28080dc254beb7a42444e9784 No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2999868 Auto-Submit: Maya Lekova <mslekova@chromium.org> Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com> Cr-Commit-Position: refs/heads/master@{#75507}
2021-07-01 13:20:07 +00:00
Object.defineProperty([, 1], "0", {
get() {
// Verify continuation retains original set function
ctor.prototype.set = () => {
callCount++;
};
return k1;
}
}),
[k2, 2]
];
const col = new ctor(input);
assertEquals(0, callCount);
if ('size' in col) assertEquals(2, col.size);
assertTrue(col.has(k1));
assertTrue(col.has(k2));
const col2 = new ctor(input);
assertEquals(2, callCount);
if ('size' in col) assertEquals(0, col2.size);
assertFalse(col2.has(k1));
assertFalse(col2.has(k2));
ctor.prototype.set = originalPrototypeSet;
}
// Forbid inlining these helper functions to avoid deopt surprises.
%NeverOptimizeFunction(assertEquals);
%NeverOptimizeFunction(assertFalse);
%NeverOptimizeFunction(assertTrue);
%PrepareFunctionForOptimization(TestMapConstructorEntrySideEffect);
TestMapConstructorEntrySideEffect(Map);
TestMapConstructorEntrySideEffect(Map);
TestMapConstructorEntrySideEffect(Map);
%OptimizeFunctionOnNextCall(TestMapConstructorEntrySideEffect);
TestMapConstructorEntrySideEffect(Map);
assertOptimized(TestMapConstructorEntrySideEffect);
// This call would deopt
TestMapConstructorEntrySideEffect(WeakMap);
%PrepareFunctionForOptimization(TestMapConstructorEntrySideEffect);
TestMapConstructorEntrySideEffect(WeakMap);
TestMapConstructorEntrySideEffect(WeakMap);
%OptimizeFunctionOnNextCall(TestMapConstructorEntrySideEffect);
TestMapConstructorEntrySideEffect(WeakMap);
assertOptimized(TestMapConstructorEntrySideEffect);