165e725da8
This is a reland of 5dde281c87
,
after also fixing the ic-migrated-... test, in which an object died
too early.
Original change's description:
> [compiler] Fix a few test flakes and reenable the tests
>
> Bug: v8:12173
> Change-Id: I2983be9133f8ff4d1740e8eba05a3c29d603dfc3
> Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3168270
> Auto-Submit: Georg Neis <neis@chromium.org>
> Reviewed-by: Maya Lekova <mslekova@chromium.org>
> Commit-Queue: Maya Lekova <mslekova@chromium.org>
> Commit-Queue: Georg Neis <neis@chromium.org>
> Cr-Commit-Position: refs/heads/main@{#76939}
Bug: v8:12173
Change-Id: If385e5c826b8470ef67f12705c5171f330f6cd57
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3171353
Auto-Submit: Georg Neis <neis@chromium.org>
Reviewed-by: Maya Lekova <mslekova@chromium.org>
Commit-Queue: Georg Neis <neis@chromium.org>
Cr-Commit-Position: refs/heads/main@{#76946}
63 lines
1.9 KiB
JavaScript
63 lines
1.9 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
|
|
|
|
function TestMapConstructorEntrySideEffect(ctor) {
|
|
const originalPrototypeSet = ctor.prototype.set;
|
|
const k1 = {};
|
|
const k2 = {};
|
|
let callCount = 0;
|
|
const input = [
|
|
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);
|