[test] Fix assertOptimized function name printing

In assertOptimized and assertUnoptimized, we can optionally pass in the
function name. We also used to pass in an optional 'sync' parameter, to
decide whether to wait for background compilations to finish before
checking state.

The sync parameter was removed in favour of explicit intrinsics, so fix
callers of assertOptimized to no longer try to set it. Also, use
function.name as the function name when no name was passed.

Change-Id: I8e98d4d02e2d097d059989ad78bf46b97b57bdca
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4000480
Auto-Submit: Leszek Swirski <leszeks@chromium.org>
Commit-Queue: Tobias Tebbi <tebbi@chromium.org>
Reviewed-by: Tobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/main@{#84080}
This commit is contained in:
Leszek Swirski 2022-11-02 17:57:25 +01:00 committed by V8 LUCI CQ
parent f8e7c7ad7a
commit 099f438647
7 changed files with 22 additions and 20 deletions

View File

@ -35,7 +35,7 @@ function runTest(f, message, mkICTraining, deoptArg, speculationCheck) {
for (let a of t3) {
message += " for args " + JSON.stringify(a) + " should have been optimized";
f(a.arr, () => a.el);
assertOptimized(f, undefined, message);
assertOptimized(f, message);
}
} else {
// Trigger deopt, causing no-speculation bit to be set.
@ -46,18 +46,18 @@ function runTest(f, message, mkICTraining, deoptArg, speculationCheck) {
message_unoptimized = message + " should have been unoptimized"
message_optimized = message + " should have been optimized"
f(a1.darr, () => a1.del);
assertUnoptimized(f, undefined, message_unoptimized);
assertUnoptimized(f, message_unoptimized);
if (speculationCheck) {
%PrepareFunctionForOptimization(f);
%OptimizeFunctionOnNextCall(f);
f(a2.darr, () => a2.del);
assertUnoptimized(f, undefined, message_unoptimized);
assertUnoptimized(f, message_unoptimized);
}
%PrepareFunctionForOptimization(f);
%OptimizeFunctionOnNextCall(f);
// No speculation should protect against further deopts.
f(a3.darr, () => a3.del);
assertOptimized(f, undefined, message_optimized);
assertOptimized(f, message_optimized);
}
}

View File

@ -22,6 +22,6 @@ delete this.global;
%FinalizeOptimization();
// boom should be deoptimized because the global property cell has changed.
assertUnoptimized(boom, "sync");
assertUnoptimized(boom);
assertThrows(boom);

View File

@ -15,7 +15,7 @@ f(0);
%OptimizeFunctionOnNextCall(f);
f(1);
assertOptimized(f, undefined, undefined, false);
assertOptimized(f, undefined, false);
f(1);
assertOptimized(f, undefined, undefined, false);
assertOptimized(f, undefined, false);

View File

@ -18,33 +18,33 @@ f(1);
// stress_deopt_count == 6
f(1);
assertOptimized(f, undefined, undefined, false);
assertOptimized(f, undefined, false);
// stress_deopt_count == 4
f(1);
assertOptimized(f, undefined, undefined, false);
assertOptimized(f, undefined, false);
// stress_deopt_count == 2
f(1);
// deopt & counter reset
assertUnoptimized(f, undefined, undefined, false);
assertUnoptimized(f, undefined, false);
// stress_deopt_count == 6
%PrepareFunctionForOptimization(f);
%OptimizeFunctionOnNextCall(f);
f(1);
assertOptimized(f, undefined, undefined, false);
assertOptimized(f, undefined, false);
// stress_deopt_count == 4
f(1);
assertOptimized(f, undefined, undefined, false);
assertOptimized(f, undefined, false);
// stress_deopt_count == 2
f(1);
// deopt & counter reset
assertUnoptimized(f, undefined, undefined, false);
assertUnoptimized(f, undefined, false);

View File

@ -52,6 +52,6 @@ assertUnoptimized(f1);
// Sync with background thread to conclude optimization, which bails out
// due to map dependency.
%FinalizeOptimization();
assertUnoptimized(f1, "sync");
assertUnoptimized(f1);
// Clear type info for stress runs.
%ClearFunctionFeedback(f1);

View File

@ -107,13 +107,13 @@ let tests = {
%OptimizeFunctionOnNextCall(fn);
fn(array);
assertOptimized(fn, '', key);
assertOptimized(fn, key);
assertEquals(expected, fn(array), key);
assertOptimized(fn, '', key);
assertOptimized(fn, key);
// Check no deopt when another array with the same map is used
assertTrue(%HaveSameMap(array, array2), key);
assertOptimized(fn, '', key);
assertOptimized(fn, key);
assertEquals(expected2, fn(array2), key);
// CheckMaps bailout
@ -121,7 +121,7 @@ let tests = {
[1, 2, 3], 2, { enumerable: false, configurable: false,
get() { return 7; } });
fn(newArray);
assertUnoptimized(fn, '', key);
assertUnoptimized(fn, key);
}
},
@ -210,12 +210,12 @@ let tests = {
%OptimizeFunctionOnNextCall(sum);
assertEquals(expected, sum(array), key);
assertOptimized(sum, '', key);
assertOptimized(sum, key);
// Not deoptimized when called on typed array of same type / map
assertTrue(%HaveSameMap(array, array2));
assertEquals(expected2, sum(array2), key);
assertOptimized(sum, '', key);
assertOptimized(sum, key);
// Throw when detached
let clone = new array.constructor(array);

View File

@ -734,6 +734,7 @@ var prettyPrinted;
assertUnoptimized = function assertUnoptimized(
fun, name_opt, skip_if_maybe_deopted = true) {
var opt_status = OptimizationStatus(fun);
name_opt = name_opt ?? fun.name;
// Tests that use assertUnoptimized() do not make sense if --always-turbofan
// option is provided. Such tests must add --no-always-turbofan to flags comment.
assertFalse((opt_status & V8OptimizationStatus.kAlwaysOptimize) !== 0,
@ -753,6 +754,7 @@ var prettyPrinted;
assertOptimized = function assertOptimized(
fun, name_opt, skip_if_maybe_deopted = true) {
var opt_status = OptimizationStatus(fun);
name_opt = name_opt ?? fun.name;
// Tests that use assertOptimized() do not make sense for Lite mode where
// optimization is always disabled, explicitly exit the test with a warning.
if (opt_status & V8OptimizationStatus.kLiteMode) {