2020-03-05 10:49:19 -08:00
|
|
|
// Copyright 2019 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.
|
|
|
|
|
2022-09-21 13:28:42 +02:00
|
|
|
// Flags: --allow-natives-syntax --turbofan --no-always-turbofan
|
2020-03-05 10:49:19 -08:00
|
|
|
|
|
|
|
let g = 0;
|
|
|
|
|
|
|
|
function f(x) {
|
|
|
|
let y = BigInt.asUintN(64, 15n);
|
|
|
|
// Introduce a side effect to force the construction of a FrameState that
|
|
|
|
// captures the value of y.
|
|
|
|
g = 42;
|
|
|
|
try {
|
|
|
|
return x + y;
|
|
|
|
} catch(_) {
|
|
|
|
return y;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
%PrepareFunctionForOptimization(f);
|
|
|
|
assertEquals(16n, f(1n));
|
|
|
|
assertEquals(17n, f(2n));
|
|
|
|
%OptimizeFunctionOnNextCall(f);
|
|
|
|
assertEquals(16n, f(1n));
|
|
|
|
assertOptimized(f);
|
|
|
|
assertEquals(15n, f(0));
|
2021-11-21 15:58:15 +01:00
|
|
|
if (%Is64Bit()) {
|
|
|
|
assertUnoptimized(f);
|
|
|
|
}
|