[Flags] Make Lite mode a runtime flag.

BUG=v8:8395

Change-Id: Ic6fb17c25ab3625721998898de2c05ee9b1bab0d
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1593299
Commit-Queue: Ross McIlroy <rmcilroy@chromium.org>
Commit-Queue: Dan Elphick <delphick@chromium.org>
Auto-Submit: Ross McIlroy <rmcilroy@chromium.org>
Reviewed-by: Dan Elphick <delphick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#61177}
diff --git a/src/flag-definitions.h b/src/flag-definitions.h
index c008f0b..2247487 100644
--- a/src/flag-definitions.h
+++ b/src/flag-definitions.h
@@ -296,6 +296,15 @@
 #define V8_LITE_BOOL false
 #endif
 
+DEFINE_BOOL(lite_mode, V8_LITE_BOOL,
+            "enables trade-off of performance for memory savings")
+
+// Lite mode implies other flags to trade-off performance for memory.
+DEFINE_IMPLICATION(lite_mode, jitless)
+DEFINE_IMPLICATION(lite_mode, lazy_feedback_allocation)
+DEFINE_IMPLICATION(lite_mode, enable_lazy_source_positions)
+DEFINE_IMPLICATION(lite_mode, optimize_for_size)
+
 #ifdef V8_ENABLE_FUTURE
 #define FUTURE_BOOL true
 #else
@@ -355,6 +364,28 @@
 DEFINE_INT(interrupt_budget, 144 * KB,
            "interrupt budget which should be used for the profiler counter")
 
+// Flags for jitless
+DEFINE_BOOL(jitless, V8_LITE_BOOL,
+            "Disable runtime allocation of executable memory.")
+
+// Jitless V8 has a few implications:
+DEFINE_NEG_IMPLICATION(jitless, opt)
+// Field representation tracking is only used by TurboFan.
+DEFINE_NEG_IMPLICATION(jitless, track_field_types)
+DEFINE_NEG_IMPLICATION(jitless, track_heap_object_fields)
+// Regexps are interpreted.
+DEFINE_IMPLICATION(jitless, regexp_interpret_all)
+// asm.js validation is disabled since it triggers wasm code generation.
+DEFINE_NEG_IMPLICATION(jitless, validate_asm)
+// Wasm is put into interpreter-only mode. We repeat flag implications down
+// here to ensure they're applied correctly by setting the --jitless flag.
+DEFINE_IMPLICATION(jitless, wasm_interpret_all)
+DEFINE_NEG_IMPLICATION(jitless, asm_wasm_lazy_compilation)
+DEFINE_NEG_IMPLICATION(jitless, wasm_lazy_compilation)
+// --jitless also implies --no-expose-wasm, see InitializeOncePerProcessImpl.
+
+// Flags for inline caching and feedback vectors.
+DEFINE_BOOL(use_ic, true, "use inline caching")
 DEFINE_INT(budget_for_feedback_vector_allocation, 1 * KB,
            "The budget in amount of bytecode executed by a function before we "
            "decide to allocate feedback vectors")
@@ -371,7 +402,7 @@
             "the same object")
 DEFINE_BOOL(print_bytecode, false,
             "print bytecode generated by ignition interpreter")
-DEFINE_BOOL(enable_lazy_source_positions, V8_LITE_BOOL,
+DEFINE_BOOL(enable_lazy_source_positions, false,
             "skip generating source positions during initial compile but "
             "regenerate when actually required")
 DEFINE_STRING(print_bytecode_filter, "*",
@@ -427,6 +458,7 @@
 DEFINE_BOOL(print_deopt_stress, false, "print number of possible deopt points")
 
 // Flags for TurboFan.
+DEFINE_BOOL(opt, true, "use adaptive optimizations")
 DEFINE_BOOL(turbo_sp_frame_access, false,
             "use stack pointer-relative access to frame wherever possible")
 DEFINE_BOOL(turbo_control_flow_aware_allocation, true,
@@ -545,6 +577,12 @@
     stress_gc_during_compilation, false,
     "simulate GC/compiler thread race related to https://crbug.com/v8/8520")
 
+// Favor memory over execution speed.
+DEFINE_BOOL(optimize_for_size, false,
+            "Enables optimizations which favor memory size over execution "
+            "speed")
+DEFINE_VALUE_IMPLICATION(optimize_for_size, max_semi_space_size, 1)
+
 #ifdef DISABLE_UNTRUSTED_CODE_MITIGATIONS
 #define V8_DEFAULT_UNTRUSTED_CODE_MITIGATIONS false
 #else
@@ -1195,50 +1233,6 @@
               "OOM for testing.")
 
 //
-// Flags only available in non-Lite modes.
-//
-#undef FLAG
-#ifdef V8_LITE_MODE
-#define FLAG FLAG_READONLY
-#else
-#define FLAG FLAG_FULL
-#endif
-
-DEFINE_BOOL(jitless, V8_LITE_BOOL,
-            "Disable runtime allocation of executable memory.")
-
-// Jitless V8 has a few implications:
-#ifndef V8_LITE_MODE
-// Optimizations (i.e. jitting) are disabled.
-DEFINE_NEG_IMPLICATION(jitless, opt)
-#endif
-// Field representation tracking is only used by TurboFan.
-DEFINE_NEG_IMPLICATION(jitless, track_field_types)
-DEFINE_NEG_IMPLICATION(jitless, track_heap_object_fields)
-// Regexps are interpreted.
-DEFINE_IMPLICATION(jitless, regexp_interpret_all)
-// asm.js validation is disabled since it triggers wasm code generation.
-DEFINE_NEG_IMPLICATION(jitless, validate_asm)
-// Wasm is put into interpreter-only mode. We repeat flag implications down
-// here to ensure they're applied correctly by setting the --jitless flag.
-DEFINE_IMPLICATION(jitless, wasm_interpret_all)
-DEFINE_NEG_IMPLICATION(jitless, asm_wasm_lazy_compilation)
-DEFINE_NEG_IMPLICATION(jitless, wasm_lazy_compilation)
-// --jitless also implies --no-expose-wasm, see InitializeOncePerProcessImpl.
-
-// Enable recompilation of function with optimized code.
-DEFINE_BOOL(opt, !V8_LITE_BOOL, "use adaptive optimizations")
-
-// Enable use of inline caches to optimize object access operations.
-DEFINE_BOOL(use_ic, true, "use inline caching")
-
-// Favor memory over execution speed.
-DEFINE_BOOL(optimize_for_size, V8_LITE_BOOL,
-            "Enables optimizations which favor memory size over execution "
-            "speed")
-DEFINE_VALUE_IMPLICATION(optimize_for_size, max_semi_space_size, 1)
-
-//
 // GDB JIT integration flags.
 //
 #undef FLAG
@@ -1541,11 +1535,6 @@
 DEFINE_BOOL(raw_heap_snapshots, V8_ENABLE_RAW_HEAP_SNAPSHOTS_BOOL,
             "enable raw heap snapshots contain garbage collection internals")
 
-DEFINE_BOOL(lite_mode, V8_LITE_BOOL,
-            "enables trade-off of performance for memory savings "
-            "(Lite mode only)")
-DEFINE_IMPLICATION(lite_mode, lazy_feedback_allocation)
-
 // Cleanup...
 #undef FLAG_FULL
 #undef FLAG_READONLY