Commit 0c9c0adf authored by Ross McIlroy's avatar Ross McIlroy Committed by Commit Bot

[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 <rmcilroy@chromium.org>
Reviewed-by: 's avatarRoss McIlroy <rmcilroy@chromium.org>
Reviewed-by: 's avatarDan Elphick <delphick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#56852}
parent 2dc302ae
...@@ -903,7 +903,6 @@ DEFINE_BOOL(trace_deopt, false, "trace optimize function deoptimization") ...@@ -903,7 +903,6 @@ DEFINE_BOOL(trace_deopt, false, "trace optimize function deoptimization")
DEFINE_BOOL(trace_file_names, false, DEFINE_BOOL(trace_file_names, false,
"include file names in trace-opt/trace-deopt output") "include file names in trace-opt/trace-deopt output")
DEFINE_BOOL(trace_interrupts, false, "trace interrupts when they are handled") 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_opt, false, "always try to optimize functions")
DEFINE_BOOL(always_osr, false, "always try to OSR functions") DEFINE_BOOL(always_osr, false, "always try to OSR functions")
DEFINE_BOOL(prepare_always_opt, false, "prepare for turning on always opt") DEFINE_BOOL(prepare_always_opt, false, "prepare for turning on always opt")
...@@ -1161,6 +1160,9 @@ DEFINE_SIZE_T(mock_arraybuffer_allocator_limit, 0, ...@@ -1161,6 +1160,9 @@ DEFINE_SIZE_T(mock_arraybuffer_allocator_limit, 0,
#define V8_LITE_BOOL false #define V8_LITE_BOOL false
#endif #endif
// Enable recompilation of function with optimized code.
DEFINE_BOOL(opt, !V8_LITE_BOOL, "use adaptive optimizations")
// Favor memory over execution speed. // Favor memory over execution speed.
DEFINE_BOOL(optimize_for_size, V8_LITE_BOOL, DEFINE_BOOL(optimize_for_size, V8_LITE_BOOL,
"Enables optimizations which favor memory size over execution " "Enables optimizations which favor memory size over execution "
...@@ -1468,6 +1470,10 @@ DEFINE_BOOL(unbox_double_fields, V8_DOUBLE_FIELDS_UNBOXING, ...@@ -1468,6 +1470,10 @@ DEFINE_BOOL(unbox_double_fields, V8_DOUBLE_FIELDS_UNBOXING,
"enable in-object double fields unboxing (64-bit only)") "enable in-object double fields unboxing (64-bit only)")
DEFINE_IMPLICATION(unbox_double_fields, track_double_fields) 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... // Cleanup...
#undef FLAG_FULL #undef FLAG_FULL
#undef FLAG_READONLY #undef FLAG_READONLY
......
...@@ -322,6 +322,9 @@ RUNTIME_FUNCTION(Runtime_GetOptimizationStatus) { ...@@ -322,6 +322,9 @@ RUNTIME_FUNCTION(Runtime_GetOptimizationStatus) {
HandleScope scope(isolate); HandleScope scope(isolate);
DCHECK(args.length() == 1 || args.length() == 2); DCHECK(args.length() == 1 || args.length() == 2);
int status = 0; int status = 0;
if (FLAG_lite_mode) {
status |= static_cast<int>(OptimizationStatus::kLiteMode);
}
if (!isolate->use_optimizer()) { if (!isolate->use_optimizer()) {
status |= static_cast<int>(OptimizationStatus::kNeverOptimize); status |= static_cast<int>(OptimizationStatus::kNeverOptimize);
} }
......
...@@ -775,6 +775,7 @@ enum class OptimizationStatus { ...@@ -775,6 +775,7 @@ enum class OptimizationStatus {
kOptimizingConcurrently = 1 << 9, kOptimizingConcurrently = 1 << 9,
kIsExecuting = 1 << 10, kIsExecuting = 1 << 10,
kTopmostFrameIsTurboFanned = 1 << 11, kTopmostFrameIsTurboFanned = 1 << 11,
kLiteMode = 1 << 12,
}; };
Smi* SmiLexicographicCompare(Smi* x_value, Smi* y_value); Smi* SmiLexicographicCompare(Smi* x_value, Smi* y_value);
......
...@@ -2963,8 +2963,10 @@ TEST(ReleaseOverReservedPages) { ...@@ -2963,8 +2963,10 @@ TEST(ReleaseOverReservedPages) {
if (FLAG_never_compact) return; if (FLAG_never_compact) return;
FLAG_trace_gc = true; FLAG_trace_gc = true;
// The optimizer can allocate stuff, messing up the test. // The optimizer can allocate stuff, messing up the test.
#ifndef V8_LITE_MODE
FLAG_opt = false; FLAG_opt = false;
FLAG_always_opt = false; FLAG_always_opt = false;
#endif // V8_LITE_MODE
// - Parallel compaction increases fragmentation, depending on how existing // - Parallel compaction increases fragmentation, depending on how existing
// memory is distributed. Since this is non-deterministic because of // memory is distributed. Since this is non-deterministic because of
// concurrent sweeping, we disable it for this test. // concurrent sweeping, we disable it for this test.
...@@ -3305,7 +3307,10 @@ UNINITIALIZED_TEST(ReleaseStackTraceData) { ...@@ -3305,7 +3307,10 @@ UNINITIALIZED_TEST(ReleaseStackTraceData) {
// See: https://codereview.chromium.org/181833004/ // See: https://codereview.chromium.org/181833004/
return; 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; FLAG_concurrent_recompilation = false;
v8::Isolate::CreateParams create_params; v8::Isolate::CreateParams create_params;
create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
...@@ -3359,7 +3364,9 @@ UNINITIALIZED_TEST(ReleaseStackTraceData) { ...@@ -3359,7 +3364,9 @@ UNINITIALIZED_TEST(ReleaseStackTraceData) {
TEST(Regress169928) { TEST(Regress169928) {
FLAG_allow_natives_syntax = true; FLAG_allow_natives_syntax = true;
#ifndef V8_LITE_MODE
FLAG_opt = false; FLAG_opt = false;
#endif // V8_LITE_MODE
CcTest::InitializeVM(); CcTest::InitializeVM();
Isolate* isolate = CcTest::i_isolate(); Isolate* isolate = CcTest::i_isolate();
LocalContext env; LocalContext env;
......
...@@ -23024,7 +23024,9 @@ void TestStubCache(bool primary) { ...@@ -23024,7 +23024,9 @@ void TestStubCache(bool primary) {
} else { } else {
i::FLAG_test_secondary_stub_cache = true; i::FLAG_test_secondary_stub_cache = true;
} }
#ifndef V8_LITE_MODE
i::FLAG_opt = false; i::FLAG_opt = false;
#endif // V8_LITE_MODE
v8::Isolate::CreateParams create_params; v8::Isolate::CreateParams create_params;
create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
...@@ -23964,7 +23966,9 @@ TEST(AccessCheckThrows) { ...@@ -23964,7 +23966,9 @@ TEST(AccessCheckThrows) {
TEST(AccessCheckInIC) { TEST(AccessCheckInIC) {
i::FLAG_native_code_counters = true; i::FLAG_native_code_counters = true;
#ifndef V8_LITE_MODE
i::FLAG_opt = false; i::FLAG_opt = false;
#endif // V8_LITE_MODE
v8::Isolate::CreateParams create_params; v8::Isolate::CreateParams create_params;
create_params.array_buffer_allocator = CcTest::array_buffer_allocator(); create_params.array_buffer_allocator = CcTest::array_buffer_allocator();
...@@ -26599,6 +26603,7 @@ TEST(StringConcatOverflow) { ...@@ -26599,6 +26603,7 @@ TEST(StringConcatOverflow) {
} }
TEST(TurboAsmDisablesNeuter) { TEST(TurboAsmDisablesNeuter) {
#ifndef V8_LITE_MODE
i::FLAG_opt = true; i::FLAG_opt = true;
i::FLAG_allow_natives_syntax = true; i::FLAG_allow_natives_syntax = true;
v8::V8::Initialize(); v8::V8::Initialize();
...@@ -26635,6 +26640,7 @@ TEST(TurboAsmDisablesNeuter) { ...@@ -26635,6 +26640,7 @@ TEST(TurboAsmDisablesNeuter) {
result = CompileRun(store).As<v8::ArrayBuffer>(); result = CompileRun(store).As<v8::ArrayBuffer>();
CHECK(!result->IsNeuterable()); CHECK(!result->IsNeuterable());
#endif // V8_LITE_MODE
} }
......
...@@ -1097,7 +1097,9 @@ TEST(BoundFunctionCall) { ...@@ -1097,7 +1097,9 @@ TEST(BoundFunctionCall) {
// This tests checks distribution of the samples through the source lines. // This tests checks distribution of the samples through the source lines.
static void TickLines(bool optimize) { static void TickLines(bool optimize) {
if (!optimize) i::FLAG_opt = false; #ifndef V8_LITE_MODE
FLAG_opt = optimize;
#endif // V8_LITE_MODE
CcTest::InitializeVM(); CcTest::InitializeVM();
LocalContext env; LocalContext env;
i::FLAG_allow_natives_syntax = true; i::FLAG_allow_natives_syntax = true;
......
...@@ -252,7 +252,7 @@ TEST(FlagsRemoveIncomplete) { ...@@ -252,7 +252,7 @@ TEST(FlagsRemoveIncomplete) {
// if the list of arguments ends unexpectedly. // if the list of arguments ends unexpectedly.
SetFlagsToDefault(); SetFlagsToDefault();
int argc = 3; 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, CHECK_EQ(2, FlagList::SetFlagsFromCommandLine(&argc,
const_cast<char **>(argv), const_cast<char **>(argv),
true)); true));
......
...@@ -711,6 +711,7 @@ TEST(LineNumber) { ...@@ -711,6 +711,7 @@ TEST(LineNumber) {
} }
TEST(BailoutReason) { TEST(BailoutReason) {
#ifndef V8_LITE_MODE
i::FLAG_allow_natives_syntax = true; i::FLAG_allow_natives_syntax = true;
i::FLAG_always_opt = false; i::FLAG_always_opt = false;
i::FLAG_opt = true; i::FLAG_opt = true;
...@@ -752,6 +753,7 @@ TEST(BailoutReason) { ...@@ -752,6 +753,7 @@ TEST(BailoutReason) {
current = PickChild(current, "Debugger"); current = PickChild(current, "Debugger");
CHECK(const_cast<v8::CpuProfileNode*>(current)); CHECK(const_cast<v8::CpuProfileNode*>(current));
CHECK(!strcmp("Optimization disabled for test", current->GetBailoutReason())); CHECK(!strcmp("Optimization disabled for test", current->GetBailoutReason()));
#endif // V8_LITE_MODE
} }
} // namespace test_profile_generator } // namespace test_profile_generator
......
...@@ -2234,10 +2234,8 @@ TEST(CodeSerializerIsolatesEager) { ...@@ -2234,10 +2234,8 @@ TEST(CodeSerializerIsolatesEager) {
TEST(CodeSerializerAfterExecute) { TEST(CodeSerializerAfterExecute) {
// We test that no compilations happen when running this code. Forcing // We test that no compilations happen when running this code. Forcing
// to always optimize breaks this test. // to always optimize breaks this test.
bool prev_opt_value = FLAG_opt;
bool prev_always_opt_value = FLAG_always_opt; bool prev_always_opt_value = FLAG_always_opt;
FLAG_always_opt = false; FLAG_always_opt = false;
FLAG_opt = false;
const char* source = "function f() { return 'abc'; }; f() + 'def'"; const char* source = "function f() { return 'abc'; }; f() + 'def'";
v8::ScriptCompiler::CachedData* cache = v8::ScriptCompiler::CachedData* cache =
CompileRunAndProduceCache(source, CodeCacheType::kAfterExecute); CompileRunAndProduceCache(source, CodeCacheType::kAfterExecute);
...@@ -2290,7 +2288,6 @@ TEST(CodeSerializerAfterExecute) { ...@@ -2290,7 +2288,6 @@ TEST(CodeSerializerAfterExecute) {
// Restore the flags. // Restore the flags.
FLAG_always_opt = prev_always_opt_value; FLAG_always_opt = prev_always_opt_value;
FLAG_opt = prev_opt_value;
} }
TEST(CodeSerializerFlagChange) { TEST(CodeSerializerFlagChange) {
......
...@@ -9,6 +9,10 @@ ...@@ -9,6 +9,10 @@
'debugger/wasm-imports': [SKIP], 'debugger/wasm-imports': [SKIP],
# https://crbug.com/v8/7932 # https://crbug.com/v8/7932
'runtime/command-line-api-without-side-effects': [SKIP], '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 }], # ALWAYS
############################################################################## ##############################################################################
......
...@@ -5,6 +5,11 @@ ...@@ -5,6 +5,11 @@
// Flags: --allow-natives-syntax --no-always-opt --opt // Flags: --allow-natives-syntax --no-always-opt --opt
// Files: test/mjsunit/code-coverage-utils.js // Files: test/mjsunit/code-coverage-utils.js
if (isNeverOptimizeLiteMode()) {
print("Warning: skipping test that requires optimization in Lite mode.");
quit(0);
}
%DebugToggleBlockCoverage(true); %DebugToggleBlockCoverage(true);
TestCoverage( TestCoverage(
......
...@@ -27,6 +27,11 @@ ...@@ -27,6 +27,11 @@
// Flags: --allow-natives-syntax --opt --no-always-opt // Flags: --allow-natives-syntax --opt --no-always-opt
if (isNeverOptimizeLiteMode()) {
print("Warning: skipping test that requires optimization in Lite mode.");
quit(0);
}
function f() { function f() {
Array.prototype[10] = 2; Array.prototype[10] = 2;
var arr = new Array(); var arr = new Array();
......
...@@ -166,8 +166,12 @@ var V8OptimizationStatus = { ...@@ -166,8 +166,12 @@ var V8OptimizationStatus = {
kOptimizingConcurrently: 1 << 9, kOptimizingConcurrently: 1 << 9,
kIsExecuting: 1 << 10, kIsExecuting: 1 << 10,
kTopmostFrameIsTurboFanned: 1 << 11, 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. // Returns true if --no-opt mode is on.
var isNeverOptimize; var isNeverOptimize;
...@@ -653,6 +657,12 @@ var prettyPrinted; ...@@ -653,6 +657,12 @@ var prettyPrinted;
fun, sync_opt, name_opt, skip_if_maybe_deopted = true) { fun, sync_opt, name_opt, skip_if_maybe_deopted = true) {
if (sync_opt === undefined) sync_opt = ""; if (sync_opt === undefined) sync_opt = "";
var opt_status = OptimizationStatus(fun, 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 // Tests that use assertOptimized() do not make sense if --no-opt
// option is provided. Such tests must add --opt to flags comment. // option is provided. Such tests must add --opt to flags comment.
assertFalse((opt_status & V8OptimizationStatus.kNeverOptimize) !== 0, assertFalse((opt_status & V8OptimizationStatus.kNeverOptimize) !== 0,
...@@ -668,6 +678,11 @@ var prettyPrinted; ...@@ -668,6 +678,11 @@ var prettyPrinted;
assertTrue((opt_status & V8OptimizationStatus.kOptimized) !== 0, name_opt); 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() { isNeverOptimize = function isNeverOptimize() {
var opt_status = OptimizationStatus(undefined, ""); var opt_status = OptimizationStatus(undefined, "");
return (opt_status & V8OptimizationStatus.kNeverOptimize) !== 0; return (opt_status & V8OptimizationStatus.kNeverOptimize) !== 0;
......
...@@ -145,7 +145,7 @@ ...@@ -145,7 +145,7 @@
'regress/regress-634-debug': [PASS, ['mode == release', SKIP]], 'regress/regress-634-debug': [PASS, ['mode == release', SKIP]],
# BUG(v8:2989). # 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. # 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]], 'math-floor-of-div-nosudiv': [PASS, SLOW, ['arch not in [arm, arm64, android_arm, android_arm64]', SKIP]],
......
...@@ -28,7 +28,11 @@ ...@@ -28,7 +28,11 @@
// Flags: --use-osr --allow-natives-syntax --ignition-osr --opt // Flags: --use-osr --allow-natives-syntax --ignition-osr --opt
// Flags: --no-always-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()); assertFalse(isAlwaysOptimize());
function f() { function f() {
......
...@@ -21,7 +21,12 @@ ...@@ -21,7 +21,12 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // 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 ArgumentsObjectChange() {
function f(x) { function f(x) {
......
...@@ -6,6 +6,10 @@ ...@@ -6,6 +6,10 @@
// Flags: --opt --no-always-opt --turbo-filter=* // Flags: --opt --no-always-opt --turbo-filter=*
// If we are always or never optimizing it is useless. // 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(isAlwaysOptimize());
assertFalse(isNeverOptimize()); assertFalse(isNeverOptimize());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment