From 099f438647f350bccb2ac0bdca17a4eabcc4a4e1 Mon Sep 17 00:00:00 2001 From: Leszek Swirski Date: Wed, 2 Nov 2022 17:57:25 +0100 Subject: [PATCH] [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 Commit-Queue: Tobias Tebbi Reviewed-by: Tobias Tebbi Cr-Commit-Position: refs/heads/main@{#84080} --- .../mjsunit/compiler/array-multiple-receiver-maps.js | 8 ++++---- test/mjsunit/compiler/regress-905555-2.js | 2 +- test/mjsunit/compiler/stress-deopt-count-1.js | 4 ++-- test/mjsunit/compiler/stress-deopt-count-2.js | 12 ++++++------ .../mjsunit/concurrent-initial-prototype-change-1.js | 2 +- test/mjsunit/es6/array-iterator-turbo.js | 12 ++++++------ test/mjsunit/mjsunit.js | 2 ++ 7 files changed, 22 insertions(+), 20 deletions(-) diff --git a/test/mjsunit/compiler/array-multiple-receiver-maps.js b/test/mjsunit/compiler/array-multiple-receiver-maps.js index 56c505a9e4..0f8efd9c0c 100644 --- a/test/mjsunit/compiler/array-multiple-receiver-maps.js +++ b/test/mjsunit/compiler/array-multiple-receiver-maps.js @@ -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); } } diff --git a/test/mjsunit/compiler/regress-905555-2.js b/test/mjsunit/compiler/regress-905555-2.js index 593a1728bc..e656a26dc8 100644 --- a/test/mjsunit/compiler/regress-905555-2.js +++ b/test/mjsunit/compiler/regress-905555-2.js @@ -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); diff --git a/test/mjsunit/compiler/stress-deopt-count-1.js b/test/mjsunit/compiler/stress-deopt-count-1.js index 1dab8631eb..4caa55ece6 100644 --- a/test/mjsunit/compiler/stress-deopt-count-1.js +++ b/test/mjsunit/compiler/stress-deopt-count-1.js @@ -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); diff --git a/test/mjsunit/compiler/stress-deopt-count-2.js b/test/mjsunit/compiler/stress-deopt-count-2.js index 3ddf05cc83..b64d0f9530 100644 --- a/test/mjsunit/compiler/stress-deopt-count-2.js +++ b/test/mjsunit/compiler/stress-deopt-count-2.js @@ -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); diff --git a/test/mjsunit/concurrent-initial-prototype-change-1.js b/test/mjsunit/concurrent-initial-prototype-change-1.js index 6660e7a779..0486d8d3a5 100644 --- a/test/mjsunit/concurrent-initial-prototype-change-1.js +++ b/test/mjsunit/concurrent-initial-prototype-change-1.js @@ -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); diff --git a/test/mjsunit/es6/array-iterator-turbo.js b/test/mjsunit/es6/array-iterator-turbo.js index 8df9ccaa56..6f82f09c78 100644 --- a/test/mjsunit/es6/array-iterator-turbo.js +++ b/test/mjsunit/es6/array-iterator-turbo.js @@ -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); diff --git a/test/mjsunit/mjsunit.js b/test/mjsunit/mjsunit.js index 6a2180bf69..8c791ddba6 100644 --- a/test/mjsunit/mjsunit.js +++ b/test/mjsunit/mjsunit.js @@ -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) {