node/deps/v8/test/mjsunit/const-tracking-let-invalidate-maglev-representations.js
Michaël Zasso 1d29d81c69 deps: update V8 to 12.3.219.16
PR-URL: https://github.com/nodejs/node/pull/52293
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
2024-04-19 08:39:47 +00:00

67 lines
1.5 KiB
JavaScript

// Copyright 2024 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: --const-tracking-let --allow-natives-syntax
// Flags: --turbofan --no-always-turbofan --maglev --no-stress-maglev
// Flags: --sparkplug --no-always-sparkplug
let val1 = 0;
let val2 = 0;
function read1() {
return val1;
}
function read2() {
return val2;
}
%PrepareFunctionForOptimization(read1);
%PrepareFunctionForOptimization(read2);
read1();
read2();
%OptimizeFunctionOnNextCall(read1);
%OptimizeFunctionOnNextCall(read2);
assertEquals(0, read1());
assertOptimized(read1);
assertEquals(0, read2());
assertOptimized(read2);
function write1(value) {
// The representation of the value we're writing is kTagged
val1 = value;
}
%PrepareFunctionForOptimization(write1);
write1(0);
%OptimizeMaglevOnNextCall(write1);
assertOptimized(read1);
// This deopts `write1`, then invalidates the constness which deopts `read1`.
write1(10);
assertUnoptimized(write1);
assertUnoptimized(read1);
assertEquals(10, read1());
function write2(value) {
// The representation of the value we're writing is kInt32.
val2 = value + 1;
}
%PrepareFunctionForOptimization(write2);
write2(-1);
%OptimizeMaglevOnNextCall(write2);
assertOptimized(read2);
// This deopts `write2`, then invalidates the constness which deopts `read2`.
write2(10);
assertUnoptimized(write2);
assertUnoptimized(read2);
assertEquals(11, read2());