From be1fcdc9d2ffb0d26159994d037e34b2f9e117ec Mon Sep 17 00:00:00 2001 From: Maya Lekova Date: Thu, 26 Aug 2021 14:15:57 +0200 Subject: [PATCH] [test] Introduce a d8-only flag for fast calls This CL introduces a d8-only flag --expose-fast-api which enables the test FastCAPI object if the --turbo-fast-api-calls flag is enabled. It also disables --stress-snapshot, which is incompatible with fast calls. Bug: v8:12137 Change-Id: I01e8321726b78be660fd6554225999bfc94006c3 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3117485 Reviewed-by: Toon Verwaest Reviewed-by: Leszek Swirski Commit-Queue: Maya Lekova Cr-Commit-Position: refs/heads/main@{#76505} --- src/d8/d8.cc | 10 +++++++++- src/d8/d8.h | 1 + test/mjsunit/compiler/fast-api-calls.js | 2 +- test/mjsunit/compiler/fast-api-helpers.js | 2 +- test/mjsunit/compiler/fast-api-interface-types.js | 2 +- test/mjsunit/compiler/fast-api-sequences-x64.js | 2 +- test/mjsunit/compiler/fast-api-sequences.js | 2 +- test/mjsunit/compiler/regress-crbug-1201011.js | 2 +- test/mjsunit/compiler/regress-crbug-1201057.js | 2 +- test/mjsunit/compiler/regress-crbug-1201082.js | 2 +- test/mjsunit/compiler/regress-crbug-1223107.js | 2 +- test/mjsunit/compiler/regress-crbug-1241464.js | 2 +- tools/testrunner/local/variants.py | 2 +- 13 files changed, 21 insertions(+), 12 deletions(-) diff --git a/src/d8/d8.cc b/src/d8/d8.cc index 6d77d2d25a..06057d195f 100644 --- a/src/d8/d8.cc +++ b/src/d8/d8.cc @@ -3007,7 +3007,7 @@ Local Shell::CreateD8Template(Isolate* isolate) { // Correctness fuzzing will attempt to compare results of tests with and // without turbo_fast_api_calls, so we don't expose the fast_c_api // constructor when --correctness_fuzzer_suppressions is on. - if (i::FLAG_turbo_fast_api_calls && + if (options.expose_fast_api && i::FLAG_turbo_fast_api_calls && !i::FLAG_correctness_fuzzer_suppressions) { test_template->Set(isolate, "FastCAPI", Shell::CreateTestFastCApiTemplate(isolate)); @@ -4397,6 +4397,9 @@ bool Shell::SetOptions(int argc, char* argv[]) { options.wasm_trap_handler = false; argv[i] = nullptr; #endif // V8_ENABLE_WEBASSEMBLY + } else if (strcmp(argv[i], "--expose-fast-api") == 0) { + options.expose_fast_api = true; + argv[i] = nullptr; } } @@ -4424,6 +4427,11 @@ bool Shell::SetOptions(int argc, char* argv[]) { options.multi_mapped_mock_allocator = i::FLAG_multi_mapped_mock_allocator; #endif + if (i::FLAG_stress_snapshot && options.expose_fast_api && + check_d8_flag_contradictions) { + FATAL("Flag --expose-fast-api is incompatible with --stress-snapshot."); + } + // Set up isolated source groups. options.isolate_sources = new SourceGroup[options.num_isolates]; SourceGroup* current = options.isolate_sources; diff --git a/src/d8/d8.h b/src/d8/d8.h index e42fb8acb3..77b3ca6679 100644 --- a/src/d8/d8.h +++ b/src/d8/d8.h @@ -443,6 +443,7 @@ class ShellOptions { #if V8_ENABLE_WEBASSEMBLY DisallowReassignment wasm_trap_handler = {"wasm-trap-handler", true}; #endif // V8_ENABLE_WEBASSEMBLY + DisallowReassignment expose_fast_api = {"expose-fast-api", false}; }; class Shell : public i::AllStatic { diff --git a/test/mjsunit/compiler/fast-api-calls.js b/test/mjsunit/compiler/fast-api-calls.js index bdda760c19..7484ac17a2 100644 --- a/test/mjsunit/compiler/fast-api-calls.js +++ b/test/mjsunit/compiler/fast-api-calls.js @@ -5,7 +5,7 @@ // This file excercises basic fast API calls and enables fuzzing of this // functionality. -// Flags: --turbo-fast-api-calls --allow-natives-syntax --opt +// Flags: --turbo-fast-api-calls --expose-fast-api --allow-natives-syntax --opt // --always-opt is disabled because we rely on particular feedback for // optimizing to the fastest path. // Flags: --no-always-opt diff --git a/test/mjsunit/compiler/fast-api-helpers.js b/test/mjsunit/compiler/fast-api-helpers.js index 587cfbc539..2989eab8c9 100644 --- a/test/mjsunit/compiler/fast-api-helpers.js +++ b/test/mjsunit/compiler/fast-api-helpers.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --turbo-fast-api-calls --allow-natives-syntax --opt +// Flags: --turbo-fast-api-calls --expose-fast-api --allow-natives-syntax --opt // Helper for sequence tests. function optimize_and_check(func, fast_count, slow_count, expected) { diff --git a/test/mjsunit/compiler/fast-api-interface-types.js b/test/mjsunit/compiler/fast-api-interface-types.js index 33a17ebe04..13da7b0cc8 100644 --- a/test/mjsunit/compiler/fast-api-interface-types.js +++ b/test/mjsunit/compiler/fast-api-interface-types.js @@ -4,7 +4,7 @@ // This file interface types used with fast API calls. -// Flags: --turbo-fast-api-calls --allow-natives-syntax --opt +// Flags: --turbo-fast-api-calls --expose-fast-api --allow-natives-syntax --opt // Flags: --no-always-opt // Flags: --deopt-every-n-times=0 diff --git a/test/mjsunit/compiler/fast-api-sequences-x64.js b/test/mjsunit/compiler/fast-api-sequences-x64.js index 7bc8db4ec7..543d80b6c5 100644 --- a/test/mjsunit/compiler/fast-api-sequences-x64.js +++ b/test/mjsunit/compiler/fast-api-sequences-x64.js @@ -4,7 +4,7 @@ // This file adds x64 specific tests to the ones in fast-api-sequence.js. -// Flags: --turbo-fast-api-calls --allow-natives-syntax --opt +// Flags: --turbo-fast-api-calls --expose-fast-api --allow-natives-syntax --opt // --always-opt is disabled because we rely on particular feedback for // optimizing to the fastest path. // Flags: --no-always-opt diff --git a/test/mjsunit/compiler/fast-api-sequences.js b/test/mjsunit/compiler/fast-api-sequences.js index f37c68cb5e..0adb64f762 100644 --- a/test/mjsunit/compiler/fast-api-sequences.js +++ b/test/mjsunit/compiler/fast-api-sequences.js @@ -4,7 +4,7 @@ // This file excercises sequences support for fast API calls. -// Flags: --turbo-fast-api-calls --allow-natives-syntax --opt +// Flags: --turbo-fast-api-calls --expose-fast-api --allow-natives-syntax --opt // --always-opt is disabled because we rely on particular feedback for // optimizing to the fastest path. // Flags: --no-always-opt diff --git a/test/mjsunit/compiler/regress-crbug-1201011.js b/test/mjsunit/compiler/regress-crbug-1201011.js index f521a60b85..9086fa794b 100644 --- a/test/mjsunit/compiler/regress-crbug-1201011.js +++ b/test/mjsunit/compiler/regress-crbug-1201011.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --turbo-fast-api-calls +// Flags: --turbo-fast-api-calls --expose-fast-api const fast_c_api = new d8.test.FastCAPI(); function foo(obj) { diff --git a/test/mjsunit/compiler/regress-crbug-1201057.js b/test/mjsunit/compiler/regress-crbug-1201057.js index 7afaaa6e38..4315175ad5 100644 --- a/test/mjsunit/compiler/regress-crbug-1201057.js +++ b/test/mjsunit/compiler/regress-crbug-1201057.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --turbo-fast-api-calls +// Flags: --turbo-fast-api-calls --expose-fast-api const fast_c_api = new d8.test.FastCAPI(); const fast_obj = Object.create(fast_c_api); diff --git a/test/mjsunit/compiler/regress-crbug-1201082.js b/test/mjsunit/compiler/regress-crbug-1201082.js index 2ec25b3a15..142d0d7861 100644 --- a/test/mjsunit/compiler/regress-crbug-1201082.js +++ b/test/mjsunit/compiler/regress-crbug-1201082.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --turbo-fast-api-calls +// Flags: --turbo-fast-api-calls --expose-fast-api const fast_c_api = new d8.test.FastCAPI(); function foo(obj) { diff --git a/test/mjsunit/compiler/regress-crbug-1223107.js b/test/mjsunit/compiler/regress-crbug-1223107.js index 1cec034063..fa2d62a673 100644 --- a/test/mjsunit/compiler/regress-crbug-1223107.js +++ b/test/mjsunit/compiler/regress-crbug-1223107.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --turbo-fast-api-calls --allow-natives-syntax --opt +// Flags: --turbo-fast-api-calls --expose-fast-api --allow-natives-syntax --opt const fast_c_api = new d8.test.FastCAPI(); assertThrows(() => {fast_c_api.add_all_sequence()}); diff --git a/test/mjsunit/compiler/regress-crbug-1241464.js b/test/mjsunit/compiler/regress-crbug-1241464.js index 3dbdd0d653..45af9bf375 100644 --- a/test/mjsunit/compiler/regress-crbug-1241464.js +++ b/test/mjsunit/compiler/regress-crbug-1241464.js @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -// Flags: --turbo-fast-api-calls +// Flags: --turbo-fast-api-calls --expose-fast-api (function() { const fast_c_api = new d8.test.FastCAPI(); diff --git a/tools/testrunner/local/variants.py b/tools/testrunner/local/variants.py index 24d1208925..07955a29e4 100644 --- a/tools/testrunner/local/variants.py +++ b/tools/testrunner/local/variants.py @@ -64,7 +64,7 @@ INCOMPATIBLE_FLAGS_PER_VARIANT = { # serialized to the snapshot, so we don't have a # SerializeInternalFieldsCallback for it, so they are incompatible with # stress_snapshot. - "stress_snapshot": ["--turbo-fast-api-calls"], + "stress_snapshot": ["--expose-fast-api"], "stress": ["--always-opt", "--no-always-opt", "--max-inlined-bytecode-size=*", "--max-inlined-bytecode-size-cumulative=*", "--stress-inline",