2018-02-20 10:43:36 +00:00
|
|
|
// 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.
|
|
|
|
|
|
|
|
Debug = debug.Debug
|
|
|
|
|
|
|
|
// Test that the side-effect check is not bypassed in optimized code.
|
|
|
|
|
|
|
|
var exception = null;
|
|
|
|
var counter = 0;
|
|
|
|
|
|
|
|
function f1() {
|
|
|
|
counter++;
|
|
|
|
}
|
|
|
|
|
|
|
|
function wrapper1() {
|
|
|
|
for (var i = 0; i < 4; i++) {
|
|
|
|
// Get this function optimized before calling to increment.
|
|
|
|
// Check that that call performs the necessary side-effect checks.
|
2022-02-21 14:01:31 +00:00
|
|
|
%OptimizeOsr();
|
2019-06-18 16:03:44 +00:00
|
|
|
%PrepareFunctionForOptimization(wrapper1);
|
2018-02-20 10:43:36 +00:00
|
|
|
}
|
|
|
|
f1();
|
|
|
|
}
|
2019-05-03 14:32:12 +00:00
|
|
|
%PrepareFunctionForOptimization(wrapper1);
|
2018-02-20 10:43:36 +00:00
|
|
|
|
|
|
|
function f2() {
|
|
|
|
counter++;
|
|
|
|
}
|
|
|
|
|
|
|
|
function wrapper2(call) {
|
|
|
|
if (call) f2();
|
|
|
|
}
|
|
|
|
|
|
|
|
function listener(event, exec_state, event_data, data) {
|
|
|
|
if (event != Debug.DebugEvent.Break) return;
|
|
|
|
try {
|
|
|
|
function success(expectation, source) {
|
|
|
|
assertEquals(expectation,
|
|
|
|
exec_state.frame(0).evaluate(source, true).value());
|
|
|
|
}
|
|
|
|
function fail(source) {
|
|
|
|
assertThrows(() => exec_state.frame(0).evaluate(source, true),
|
|
|
|
EvalError);
|
|
|
|
}
|
|
|
|
wrapper1();
|
|
|
|
wrapper1();
|
|
|
|
fail("wrapper1()");
|
|
|
|
|
2019-04-29 13:14:40 +00:00
|
|
|
%PrepareFunctionForOptimization(wrapper2);
|
2018-02-20 10:43:36 +00:00
|
|
|
wrapper2(true);
|
|
|
|
wrapper2(false);
|
|
|
|
wrapper2(true);
|
|
|
|
%OptimizeFunctionOnNextCall(wrapper2);
|
|
|
|
wrapper2(false);
|
|
|
|
fail("wrapper2(true)");
|
2019-04-29 13:14:40 +00:00
|
|
|
fail("%PrepareFunctionForOptimization(wrapper2); "+
|
|
|
|
"%OptimizeFunctionOnNextCall(wrapper2); wrapper2(true)");
|
2018-02-20 10:43:36 +00:00
|
|
|
|
2019-04-29 13:14:40 +00:00
|
|
|
%PrepareFunctionForOptimization(wrapper2);
|
2021-08-10 08:33:17 +00:00
|
|
|
%DisableOptimizationFinalization();
|
2018-02-20 10:43:36 +00:00
|
|
|
%OptimizeFunctionOnNextCall(wrapper2, "concurrent");
|
|
|
|
wrapper2(false);
|
2021-08-10 08:33:17 +00:00
|
|
|
fail("%FinalizeOptimization();" +
|
2018-02-20 10:43:36 +00:00
|
|
|
"wrapper2(true);");
|
|
|
|
} catch (e) {
|
|
|
|
exception = e;
|
|
|
|
print(e, e.stack);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// Add the debug event listener.
|
|
|
|
Debug.setListener(listener);
|
|
|
|
|
|
|
|
function f() {
|
|
|
|
debugger;
|
|
|
|
};
|
|
|
|
|
|
|
|
f();
|
|
|
|
|
|
|
|
assertNull(exception);
|