From 0c9c0adf6212c77cb0c8a40417c2987e402f8a03 Mon Sep 17 00:00:00 2001 From: Ross McIlroy Date: Mon, 22 Oct 2018 12:45:45 +0100 Subject: [PATCH] [Lite] Disable optimization for Lite mode. BUG=v8:8293 Cq-Include-Trybots: luci.chromium.try:linux_chromium_headless_rel;master.tryserver.blink:linux_trusty_blink_rel Change-Id: Ic0e12cbcea76f76fce543714dee972c784095143 Reviewed-on: https://chromium-review.googlesource.com/c/1290795 Commit-Queue: Ross McIlroy Reviewed-by: Ross McIlroy Reviewed-by: Dan Elphick Cr-Commit-Position: refs/heads/master@{#56852} --- src/flag-definitions.h | 8 +++++++- src/runtime/runtime-test.cc | 3 +++ src/runtime/runtime.h | 1 + test/cctest/heap/test-heap.cc | 9 ++++++++- test/cctest/test-api.cc | 6 ++++++ test/cctest/test-cpu-profiler.cc | 4 +++- test/cctest/test-flags.cc | 2 +- test/cctest/test-profile-generator.cc | 2 ++ test/cctest/test-serialize.cc | 3 --- test/inspector/inspector.status | 4 ++++ test/mjsunit/code-coverage-block-opt.js | 5 +++++ .../native-context-specialization-hole-check.js | 5 +++++ test/mjsunit/mjsunit.js | 15 +++++++++++++++ test/mjsunit/mjsunit.status | 2 +- test/mjsunit/regress/regress-2618.js | 6 +++++- test/mjsunit/regress/regress-2989.js | 7 ++++++- test/mjsunit/shared-function-tier-up-turbo.js | 4 ++++ 17 files changed, 76 insertions(+), 10 deletions(-) diff --git a/src/flag-definitions.h b/src/flag-definitions.h index 922744de91..a850be1056 100644 --- a/src/flag-definitions.h +++ b/src/flag-definitions.h @@ -903,7 +903,6 @@ DEFINE_BOOL(trace_deopt, false, "trace optimize function deoptimization") DEFINE_BOOL(trace_file_names, false, "include file names in trace-opt/trace-deopt output") DEFINE_BOOL(trace_interrupts, false, "trace interrupts when they are handled") -DEFINE_BOOL(opt, true, "use adaptive optimizations") DEFINE_BOOL(always_opt, false, "always try to optimize functions") DEFINE_BOOL(always_osr, false, "always try to OSR functions") DEFINE_BOOL(prepare_always_opt, false, "prepare for turning on always opt") @@ -1161,6 +1160,9 @@ DEFINE_SIZE_T(mock_arraybuffer_allocator_limit, 0, #define V8_LITE_BOOL false #endif +// Enable recompilation of function with optimized code. +DEFINE_BOOL(opt, !V8_LITE_BOOL, "use adaptive optimizations") + // Favor memory over execution speed. DEFINE_BOOL(optimize_for_size, V8_LITE_BOOL, "Enables optimizations which favor memory size over execution " @@ -1468,6 +1470,10 @@ DEFINE_BOOL(unbox_double_fields, V8_DOUBLE_FIELDS_UNBOXING, "enable in-object double fields unboxing (64-bit only)") DEFINE_IMPLICATION(unbox_double_fields, track_double_fields) +DEFINE_BOOL(lite_mode, V8_LITE_BOOL, + "enables trade-off of performance for memory savings " + "(Lite mode only)") + // Cleanup... #undef FLAG_FULL #undef FLAG_READONLY diff --git a/src/runtime/runtime-test.cc b/src/runtime/runtime-test.cc index 7334ec07ad..deb7adbc57 100644 --- a/src/runtime/runtime-test.cc +++ b/src/runtime/runtime-test.cc @@ -322,6 +322,9 @@ RUNTIME_FUNCTION(Runtime_GetOptimizationStatus) { HandleScope scope(isolate); DCHECK(args.length() == 1 || args.length() == 2); int status = 0; + if (FLAG_lite_mode) { + status |= static_cast(OptimizationStatus::kLiteMode); + } if (!isolate->use_optimizer()) { status |= static_cast(OptimizationStatus::kNeverOptimize); } diff --git a/src/runtime/runtime.h b/src/runtime/runtime.h index 304d15b12a..decb00dee2 100644 --- a/src/runtime/runtime.h +++ b/src/runtime/runtime.h @@ -775,6 +775,7 @@ enum class OptimizationStatus { kOptimizingConcurrently = 1 << 9, kIsExecuting = 1 << 10, kTopmostFrameIsTurboFanned = 1 << 11, + kLiteMode = 1 << 12, }; Smi* SmiLexicographicCompare(Smi* x_value, Smi* y_value); diff --git a/test/cctest/heap/test-heap.cc b/test/cctest/heap/test-heap.cc index 4e281dc374..f40a3a4e74 100644 --- a/test/cctest/heap/test-heap.cc +++ b/test/cctest/heap/test-heap.cc @@ -2963,8 +2963,10 @@ TEST(ReleaseOverReservedPages) { if (FLAG_never_compact) return; FLAG_trace_gc = true; // The optimizer can allocate stuff, messing up the test. +#ifndef V8_LITE_MODE FLAG_opt = false; FLAG_always_opt = false; +#endif // V8_LITE_MODE // - Parallel compaction increases fragmentation, depending on how existing // memory is distributed. Since this is non-deterministic because of // concurrent sweeping, we disable it for this test. @@ -3305,7 +3307,10 @@ UNINITIALIZED_TEST(ReleaseStackTraceData) { // See: https://codereview.chromium.org/181833004/ return; } - FLAG_use_ic = false; // ICs retain objects. +#ifndef V8_LITE_MODE + // ICs retain objects. + FLAG_use_ic = false; +#endif // V8_LITE_MODE FLAG_concurrent_recompilation = false; v8::Isolate::CreateParams create_params; create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); @@ -3359,7 +3364,9 @@ UNINITIALIZED_TEST(ReleaseStackTraceData) { TEST(Regress169928) { FLAG_allow_natives_syntax = true; +#ifndef V8_LITE_MODE FLAG_opt = false; +#endif // V8_LITE_MODE CcTest::InitializeVM(); Isolate* isolate = CcTest::i_isolate(); LocalContext env; diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc index 4e4679634c..2e5152caef 100644 --- a/test/cctest/test-api.cc +++ b/test/cctest/test-api.cc @@ -23024,7 +23024,9 @@ void TestStubCache(bool primary) { } else { i::FLAG_test_secondary_stub_cache = true; } +#ifndef V8_LITE_MODE i::FLAG_opt = false; +#endif // V8_LITE_MODE v8::Isolate::CreateParams create_params; create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); @@ -23964,7 +23966,9 @@ TEST(AccessCheckThrows) { TEST(AccessCheckInIC) { i::FLAG_native_code_counters = true; +#ifndef V8_LITE_MODE i::FLAG_opt = false; +#endif // V8_LITE_MODE v8::Isolate::CreateParams create_params; create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); @@ -26599,6 +26603,7 @@ TEST(StringConcatOverflow) { } TEST(TurboAsmDisablesNeuter) { +#ifndef V8_LITE_MODE i::FLAG_opt = true; i::FLAG_allow_natives_syntax = true; v8::V8::Initialize(); @@ -26635,6 +26640,7 @@ TEST(TurboAsmDisablesNeuter) { result = CompileRun(store).As(); CHECK(!result->IsNeuterable()); +#endif // V8_LITE_MODE } diff --git a/test/cctest/test-cpu-profiler.cc b/test/cctest/test-cpu-profiler.cc index 2c8ac93940..b59c47fed7 100644 --- a/test/cctest/test-cpu-profiler.cc +++ b/test/cctest/test-cpu-profiler.cc @@ -1097,7 +1097,9 @@ TEST(BoundFunctionCall) { // This tests checks distribution of the samples through the source lines. static void TickLines(bool optimize) { - if (!optimize) i::FLAG_opt = false; +#ifndef V8_LITE_MODE + FLAG_opt = optimize; +#endif // V8_LITE_MODE CcTest::InitializeVM(); LocalContext env; i::FLAG_allow_natives_syntax = true; diff --git a/test/cctest/test-flags.cc b/test/cctest/test-flags.cc index 20db9547e9..e285afee29 100644 --- a/test/cctest/test-flags.cc +++ b/test/cctest/test-flags.cc @@ -252,7 +252,7 @@ TEST(FlagsRemoveIncomplete) { // if the list of arguments ends unexpectedly. SetFlagsToDefault(); int argc = 3; - const char* argv[] = {"", "--opt", "--expose-natives-as"}; + const char* argv[] = {"", "--testing-bool-flag", "--expose-natives-as"}; CHECK_EQ(2, FlagList::SetFlagsFromCommandLine(&argc, const_cast(argv), true)); diff --git a/test/cctest/test-profile-generator.cc b/test/cctest/test-profile-generator.cc index c4ad1babc5..dd39e4fd31 100644 --- a/test/cctest/test-profile-generator.cc +++ b/test/cctest/test-profile-generator.cc @@ -711,6 +711,7 @@ TEST(LineNumber) { } TEST(BailoutReason) { +#ifndef V8_LITE_MODE i::FLAG_allow_natives_syntax = true; i::FLAG_always_opt = false; i::FLAG_opt = true; @@ -752,6 +753,7 @@ TEST(BailoutReason) { current = PickChild(current, "Debugger"); CHECK(const_cast(current)); CHECK(!strcmp("Optimization disabled for test", current->GetBailoutReason())); +#endif // V8_LITE_MODE } } // namespace test_profile_generator diff --git a/test/cctest/test-serialize.cc b/test/cctest/test-serialize.cc index 9d78b11d01..59ec30ed79 100644 --- a/test/cctest/test-serialize.cc +++ b/test/cctest/test-serialize.cc @@ -2234,10 +2234,8 @@ TEST(CodeSerializerIsolatesEager) { TEST(CodeSerializerAfterExecute) { // We test that no compilations happen when running this code. Forcing // to always optimize breaks this test. - bool prev_opt_value = FLAG_opt; bool prev_always_opt_value = FLAG_always_opt; FLAG_always_opt = false; - FLAG_opt = false; const char* source = "function f() { return 'abc'; }; f() + 'def'"; v8::ScriptCompiler::CachedData* cache = CompileRunAndProduceCache(source, CodeCacheType::kAfterExecute); @@ -2290,7 +2288,6 @@ TEST(CodeSerializerAfterExecute) { // Restore the flags. FLAG_always_opt = prev_always_opt_value; - FLAG_opt = prev_opt_value; } TEST(CodeSerializerFlagChange) { diff --git a/test/inspector/inspector.status b/test/inspector/inspector.status index ba44927d11..af69fc1ca5 100644 --- a/test/inspector/inspector.status +++ b/test/inspector/inspector.status @@ -9,6 +9,10 @@ 'debugger/wasm-imports': [SKIP], # https://crbug.com/v8/7932 'runtime/command-line-api-without-side-effects': [SKIP], + + # Require optimization, so can't be run on Lite mode. + 'cpu-profiler/coverage-block': [PASS, ['lite_mode == True', SKIP]], + 'cpu-profiler/coverage': [PASS, ['lite_mode == True', SKIP]], }], # ALWAYS ############################################################################## diff --git a/test/mjsunit/code-coverage-block-opt.js b/test/mjsunit/code-coverage-block-opt.js index e02775bd45..3031e8913a 100644 --- a/test/mjsunit/code-coverage-block-opt.js +++ b/test/mjsunit/code-coverage-block-opt.js @@ -5,6 +5,11 @@ // Flags: --allow-natives-syntax --no-always-opt --opt // Files: test/mjsunit/code-coverage-utils.js +if (isNeverOptimizeLiteMode()) { + print("Warning: skipping test that requires optimization in Lite mode."); + quit(0); +} + %DebugToggleBlockCoverage(true); TestCoverage( diff --git a/test/mjsunit/compiler/native-context-specialization-hole-check.js b/test/mjsunit/compiler/native-context-specialization-hole-check.js index 1256f453eb..7f4db56483 100644 --- a/test/mjsunit/compiler/native-context-specialization-hole-check.js +++ b/test/mjsunit/compiler/native-context-specialization-hole-check.js @@ -27,6 +27,11 @@ // Flags: --allow-natives-syntax --opt --no-always-opt +if (isNeverOptimizeLiteMode()) { + print("Warning: skipping test that requires optimization in Lite mode."); + quit(0); +} + function f() { Array.prototype[10] = 2; var arr = new Array(); diff --git a/test/mjsunit/mjsunit.js b/test/mjsunit/mjsunit.js index 59923a4247..41f2caee7a 100644 --- a/test/mjsunit/mjsunit.js +++ b/test/mjsunit/mjsunit.js @@ -166,8 +166,12 @@ var V8OptimizationStatus = { kOptimizingConcurrently: 1 << 9, kIsExecuting: 1 << 10, kTopmostFrameIsTurboFanned: 1 << 11, + kLiteMode: 1 << 12, }; +// Returns true if --lite-mode is on and we can't ever turn on optimization. +var isNeverOptimizeLiteMode; + // Returns true if --no-opt mode is on. var isNeverOptimize; @@ -653,6 +657,12 @@ var prettyPrinted; fun, sync_opt, name_opt, skip_if_maybe_deopted = true) { if (sync_opt === undefined) sync_opt = ""; var opt_status = OptimizationStatus(fun, sync_opt); + // 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) { + print("Warning: Test uses assertOptimized in Lite mode, skipping test."); + quit(0); + } // Tests that use assertOptimized() do not make sense if --no-opt // option is provided. Such tests must add --opt to flags comment. assertFalse((opt_status & V8OptimizationStatus.kNeverOptimize) !== 0, @@ -668,6 +678,11 @@ var prettyPrinted; assertTrue((opt_status & V8OptimizationStatus.kOptimized) !== 0, name_opt); } + isNeverOptimizeLiteMode = function isNeverOptimizeLiteMode() { + var opt_status = OptimizationStatus(undefined, ""); + return (opt_status & V8OptimizationStatus.kLiteMode) !== 0; + } + isNeverOptimize = function isNeverOptimize() { var opt_status = OptimizationStatus(undefined, ""); return (opt_status & V8OptimizationStatus.kNeverOptimize) !== 0; diff --git a/test/mjsunit/mjsunit.status b/test/mjsunit/mjsunit.status index 3f2eb96a67..3d5fac9b26 100644 --- a/test/mjsunit/mjsunit.status +++ b/test/mjsunit/mjsunit.status @@ -145,7 +145,7 @@ 'regress/regress-634-debug': [PASS, ['mode == release', SKIP]], # BUG(v8:2989). - 'regress/regress-2989': [FAIL, NO_VARIANTS], + 'regress/regress-2989': [FAIL, NO_VARIANTS, ['lite_mode == True', SKIP]], # This test variant makes only sense on arm. 'math-floor-of-div-nosudiv': [PASS, SLOW, ['arch not in [arm, arm64, android_arm, android_arm64]', SKIP]], diff --git a/test/mjsunit/regress/regress-2618.js b/test/mjsunit/regress/regress-2618.js index 8e539fffa4..9feb911c81 100644 --- a/test/mjsunit/regress/regress-2618.js +++ b/test/mjsunit/regress/regress-2618.js @@ -28,7 +28,11 @@ // Flags: --use-osr --allow-natives-syntax --ignition-osr --opt // Flags: --no-always-opt -// Can't OSR with always-opt. +// Can't OSR with always-opt or in Lite mode. +if (isNeverOptimizeLiteMode()) { + print("Warning: skipping test that requires optimization in Lite mode."); + quit(0); +} assertFalse(isAlwaysOptimize()); function f() { diff --git a/test/mjsunit/regress/regress-2989.js b/test/mjsunit/regress/regress-2989.js index 49c4a1cb03..d11e352105 100644 --- a/test/mjsunit/regress/regress-2989.js +++ b/test/mjsunit/regress/regress-2989.js @@ -21,7 +21,12 @@ // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -// Flags: --allow-natives-syntax +// Flags: --allow-natives-syntax --opt + +if (isNeverOptimizeLiteMode()) { + print("Warning: skipping test that requires optimization in Lite mode."); + quit(0); +} (function ArgumentsObjectChange() { function f(x) { diff --git a/test/mjsunit/shared-function-tier-up-turbo.js b/test/mjsunit/shared-function-tier-up-turbo.js index f8e9117785..0d23b4f843 100644 --- a/test/mjsunit/shared-function-tier-up-turbo.js +++ b/test/mjsunit/shared-function-tier-up-turbo.js @@ -6,6 +6,10 @@ // Flags: --opt --no-always-opt --turbo-filter=* // If we are always or never optimizing it is useless. +if (isNeverOptimizeLiteMode()) { + print("Warning: skipping test that requires optimization in Lite mode."); + quit(0); +} assertFalse(isAlwaysOptimize()); assertFalse(isNeverOptimize());