1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 // This file defines all of the flags.  It is separated into different section,
6 // for Debug, Release, Logging and Profiling, etc.  To add a new flag, find the
7 // correct section, and use one of the DEFINE_ macros, without a trailing ';'.
8 //
9 // This include does not have a guard, because it is a template-style include,
10 // which can be included multiple times in different modes.  It expects to have
11 // a mode defined before it's included.  The modes are FLAG_MODE_... below:
12 //
13 // PRESUBMIT_INTENTIONALLY_MISSING_INCLUDE_GUARD
14 
15 #define DEFINE_IMPLICATION(whenflag, thenflag) \
16   DEFINE_VALUE_IMPLICATION(whenflag, thenflag, true)
17 
18 // A weak implication will be overwritten by a normal implication or by an
19 // explicit flag.
20 #define DEFINE_WEAK_IMPLICATION(whenflag, thenflag) \
21   DEFINE_WEAK_VALUE_IMPLICATION(whenflag, thenflag, true)
22 
23 #define DEFINE_NEG_IMPLICATION(whenflag, thenflag) \
24   DEFINE_VALUE_IMPLICATION(whenflag, thenflag, false)
25 
26 #define DEFINE_NEG_NEG_IMPLICATION(whenflag, thenflag) \
27   DEFINE_NEG_VALUE_IMPLICATION(whenflag, thenflag, false)
28 
29 // We want to declare the names of the variables for the header file.  Normally
30 // this will just be an extern declaration, but for a readonly flag we let the
31 // compiler make better optimizations by giving it the value.
32 #if defined(FLAG_MODE_DECLARE)
33 #define FLAG_FULL(ftype, ctype, nam, def, cmt) \
34   V8_EXPORT_PRIVATE extern ctype FLAG_##nam;
35 #define FLAG_READONLY(ftype, ctype, nam, def, cmt) \
36   static constexpr ctype FLAG_##nam = def;
37 
38 // We want to supply the actual storage and value for the flag variable in the
39 // .cc file.  We only do this for writable flags.
40 #elif defined(FLAG_MODE_DEFINE)
41 #ifdef USING_V8_SHARED
42 #define FLAG_FULL(ftype, ctype, nam, def, cmt) \
43   V8_EXPORT_PRIVATE extern ctype FLAG_##nam;
44 #else
45 #define FLAG_FULL(ftype, ctype, nam, def, cmt) \
46   V8_EXPORT_PRIVATE ctype FLAG_##nam = def;
47 #endif
48 
49 // We need to define all of our default values so that the Flag structure can
50 // access them by pointer.  These are just used internally inside of one .cc,
51 // for MODE_META, so there is no impact on the flags interface.
52 #elif defined(FLAG_MODE_DEFINE_DEFAULTS)
53 #define FLAG_FULL(ftype, ctype, nam, def, cmt) \
54   static constexpr ctype FLAGDEFAULT_##nam = def;
55 
56 // We want to write entries into our meta data table, for internal parsing and
57 // printing / etc in the flag parser code.  We only do this for writable flags.
58 #elif defined(FLAG_MODE_META)
59 #define FLAG_FULL(ftype, ctype, nam, def, cmt) \
60   {Flag::TYPE_##ftype, #nam, &FLAG_##nam, &FLAGDEFAULT_##nam, cmt, false},
61 #define FLAG_ALIAS(ftype, ctype, alias, nam)                     \
62   {Flag::TYPE_##ftype,  #alias, &FLAG_##nam, &FLAGDEFAULT_##nam, \
63     "alias for --" #nam, false},
64 
65 // We produce the code to set flags when it is implied by another flag.
66 #elif defined(FLAG_MODE_DEFINE_IMPLICATIONS)
67 #define DEFINE_VALUE_IMPLICATION(whenflag, thenflag, value)                   \
68   changed |= TriggerImplication(FLAG_##whenflag, #whenflag, &FLAG_##thenflag, \
69                                 value, false);
70 
71 // A weak implication will be overwritten by a normal implication or by an
72 // explicit flag.
73 #define DEFINE_WEAK_VALUE_IMPLICATION(whenflag, thenflag, value)              \
74   changed |= TriggerImplication(FLAG_##whenflag, #whenflag, &FLAG_##thenflag, \
75                                 value, true);
76 
77 #define DEFINE_GENERIC_IMPLICATION(whenflag, statement) \
78   if (FLAG_##whenflag) statement;
79 
80 #define DEFINE_NEG_VALUE_IMPLICATION(whenflag, thenflag, value)                \
81   changed |= TriggerImplication(!FLAG_##whenflag, #whenflag, &FLAG_##thenflag, \
82                                 value, false);
83 
84 // We apply a generic macro to the flags.
85 #elif defined(FLAG_MODE_APPLY)
86 
87 #define FLAG_FULL FLAG_MODE_APPLY
88 
89 #else
90 #error No mode supplied when including flags.defs
91 #endif
92 
93 // Dummy defines for modes where it is not relevant.
94 #ifndef FLAG_FULL
95 #define FLAG_FULL(ftype, ctype, nam, def, cmt)
96 #endif
97 
98 #ifndef FLAG_READONLY
99 #define FLAG_READONLY(ftype, ctype, nam, def, cmt)
100 #endif
101 
102 #ifndef FLAG_ALIAS
103 #define FLAG_ALIAS(ftype, ctype, alias, nam)
104 #endif
105 
106 #ifndef DEFINE_VALUE_IMPLICATION
107 #define DEFINE_VALUE_IMPLICATION(whenflag, thenflag, value)
108 #endif
109 
110 #ifndef DEFINE_WEAK_VALUE_IMPLICATION
111 #define DEFINE_WEAK_VALUE_IMPLICATION(whenflag, thenflag, value)
112 #endif
113 
114 #ifndef DEFINE_GENERIC_IMPLICATION
115 #define DEFINE_GENERIC_IMPLICATION(whenflag, statement)
116 #endif
117 
118 #ifndef DEFINE_NEG_VALUE_IMPLICATION
119 #define DEFINE_NEG_VALUE_IMPLICATION(whenflag, thenflag, value)
120 #endif
121 
122 #define COMMA ,
123 
124 #ifdef FLAG_MODE_DECLARE
125 
126 struct MaybeBoolFlag {
CreateMaybeBoolFlag127   static MaybeBoolFlag Create(bool has_value, bool value) {
128     MaybeBoolFlag flag;
129     flag.has_value = has_value;
130     flag.value = value;
131     return flag;
132   }
133   bool has_value;
134   bool value;
135 
136   bool operator!=(const MaybeBoolFlag& other) const {
137     return has_value != other.has_value || value != other.value;
138   }
139 };
140 #endif
141 
142 #ifdef DEBUG
143 #define DEBUG_BOOL true
144 #else
145 #define DEBUG_BOOL false
146 #endif
147 
148 #ifdef V8_COMPRESS_POINTERS
149 #define COMPRESS_POINTERS_BOOL true
150 #else
151 #define COMPRESS_POINTERS_BOOL false
152 #endif
153 
154 #ifdef V8_MAP_PACKING
155 #define V8_MAP_PACKING_BOOL true
156 #else
157 #define V8_MAP_PACKING_BOOL false
158 #endif
159 
160 #ifdef V8_COMPRESS_POINTERS_IN_ISOLATE_CAGE
161 #define COMPRESS_POINTERS_IN_ISOLATE_CAGE_BOOL true
162 #else
163 #define COMPRESS_POINTERS_IN_ISOLATE_CAGE_BOOL false
164 #endif
165 
166 #ifdef V8_COMPRESS_POINTERS_IN_SHARED_CAGE
167 #define COMPRESS_POINTERS_IN_SHARED_CAGE_BOOL true
168 #else
169 #define COMPRESS_POINTERS_IN_SHARED_CAGE_BOOL false
170 #endif
171 
172 #ifdef V8_HEAP_SANDBOX
173 #define V8_HEAP_SANDBOX_BOOL true
174 #else
175 #define V8_HEAP_SANDBOX_BOOL false
176 #endif
177 
178 #ifdef V8_VIRTUAL_MEMORY_CAGE
179 #define V8_VIRTUAL_MEMORY_CAGE_BOOL true
180 #else
181 #define V8_VIRTUAL_MEMORY_CAGE_BOOL false
182 #endif
183 
184 // D8's MultiMappedAllocator is only available on Linux, and only if the virtual
185 // memory cage is not enabled.
186 #if V8_OS_LINUX && !V8_VIRTUAL_MEMORY_CAGE_BOOL
187 #define MULTI_MAPPED_ALLOCATOR_AVAILABLE true
188 #else
189 #define MULTI_MAPPED_ALLOCATOR_AVAILABLE false
190 #endif
191 
192 #ifdef V8_ENABLE_CONTROL_FLOW_INTEGRITY
193 #define ENABLE_CONTROL_FLOW_INTEGRITY_BOOL true
194 #else
195 #define ENABLE_CONTROL_FLOW_INTEGRITY_BOOL false
196 #endif
197 
198 #if V8_TARGET_ARCH_IA32 || V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_ARM64 ||     \
199     V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_RISCV64 || V8_TARGET_ARCH_MIPS64 || \
200     V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_LOONG64
201 #define ENABLE_SPARKPLUG true
202 #else
203 // TODO(v8:11421): Enable Sparkplug for other architectures
204 #define ENABLE_SPARKPLUG false
205 #endif
206 
207 #if ENABLE_SPARKPLUG && !defined(ANDROID)
208 // Enable Sparkplug by default on desktop-only.
209 #define ENABLE_SPARKPLUG_BY_DEFAULT true
210 #else
211 #define ENABLE_SPARKPLUG_BY_DEFAULT false
212 #endif
213 
214 #if defined(V8_OS_MACOSX) && defined(V8_HOST_ARCH_ARM64)
215 // Must be enabled on M1.
216 #define MUST_WRITE_PROTECT_CODE_MEMORY true
217 #else
218 #define MUST_WRITE_PROTECT_CODE_MEMORY false
219 #endif
220 
221 // Supported ARM configurations are:
222 //  "armv6":       ARMv6 + VFPv2
223 //  "armv7":       ARMv7 + VFPv3-D32 + NEON
224 //  "armv7+sudiv": ARMv7 + VFPv4-D32 + NEON + SUDIV
225 //  "armv8":       ARMv8 (including all of the above)
226 #if !defined(ARM_TEST_NO_FEATURE_PROBE) ||                            \
227     (defined(CAN_USE_ARMV8_INSTRUCTIONS) &&                           \
228      defined(CAN_USE_ARMV7_INSTRUCTIONS) && defined(CAN_USE_SUDIV) && \
229      defined(CAN_USE_NEON) && defined(CAN_USE_VFP3_INSTRUCTIONS))
230 #define ARM_ARCH_DEFAULT "armv8"
231 #elif defined(CAN_USE_ARMV7_INSTRUCTIONS) && defined(CAN_USE_SUDIV) && \
232     defined(CAN_USE_NEON) && defined(CAN_USE_VFP3_INSTRUCTIONS)
233 #define ARM_ARCH_DEFAULT "armv7+sudiv"
234 #elif defined(CAN_USE_ARMV7_INSTRUCTIONS) && defined(CAN_USE_NEON) && \
235     defined(CAN_USE_VFP3_INSTRUCTIONS)
236 #define ARM_ARCH_DEFAULT "armv7"
237 #else
238 #define ARM_ARCH_DEFAULT "armv6"
239 #endif
240 
241 #ifdef V8_OS_WIN
242 #define ENABLE_LOG_COLOUR false
243 #else
244 #define ENABLE_LOG_COLOUR true
245 #endif
246 
247 #define DEFINE_BOOL(nam, def, cmt) FLAG(BOOL, bool, nam, def, cmt)
248 #define DEFINE_BOOL_READONLY(nam, def, cmt) \
249   FLAG_READONLY(BOOL, bool, nam, def, cmt)
250 #define DEFINE_MAYBE_BOOL(nam, cmt) \
251   FLAG(MAYBE_BOOL, MaybeBoolFlag, nam, {false COMMA false}, cmt)
252 #define DEFINE_INT(nam, def, cmt) FLAG(INT, int, nam, def, cmt)
253 #define DEFINE_UINT(nam, def, cmt) FLAG(UINT, unsigned int, nam, def, cmt)
254 #define DEFINE_UINT_READONLY(nam, def, cmt) \
255   FLAG_READONLY(UINT, unsigned int, nam, def, cmt)
256 #define DEFINE_UINT64(nam, def, cmt) FLAG(UINT64, uint64_t, nam, def, cmt)
257 #define DEFINE_FLOAT(nam, def, cmt) FLAG(FLOAT, double, nam, def, cmt)
258 #define DEFINE_SIZE_T(nam, def, cmt) FLAG(SIZE_T, size_t, nam, def, cmt)
259 #define DEFINE_STRING(nam, def, cmt) FLAG(STRING, const char*, nam, def, cmt)
260 #define DEFINE_ALIAS_BOOL(alias, nam) FLAG_ALIAS(BOOL, bool, alias, nam)
261 #define DEFINE_ALIAS_INT(alias, nam) FLAG_ALIAS(INT, int, alias, nam)
262 #define DEFINE_ALIAS_FLOAT(alias, nam) FLAG_ALIAS(FLOAT, double, alias, nam)
263 #define DEFINE_ALIAS_SIZE_T(alias, nam) FLAG_ALIAS(SIZE_T, size_t, alias, nam)
264 #define DEFINE_ALIAS_STRING(alias, nam) \
265   FLAG_ALIAS(STRING, const char*, alias, nam)
266 
267 #ifdef DEBUG
268 #define DEFINE_DEBUG_BOOL DEFINE_BOOL
269 #else
270 #define DEFINE_DEBUG_BOOL DEFINE_BOOL_READONLY
271 #endif
272 
273 //
274 // Flags in all modes.
275 //
276 #define FLAG FLAG_FULL
277 
278 // ATTENTION: This is set to true by default in d8. But for API compatibility,
279 // it generally defaults to false.
280 DEFINE_BOOL(abort_on_contradictory_flags, false,
281             "Disallow flags or implications overriding each other.")
282 // This implication is also hard-coded into the flags processing to make sure it
283 // becomes active before we even process subsequent flags.
284 DEFINE_NEG_IMPLICATION(fuzzing, abort_on_contradictory_flags)
285 // This is not really a flag, it affects the interpretation of the next flag but
286 // doesn't become permanently true when specified. This only works for flags
287 // defined in this file, but not for d8 flags defined in src/d8/d8.cc.
288 DEFINE_BOOL(allow_overwriting_for_next_flag, false,
289             "temporary disable flag contradiction to allow overwriting just "
290             "the next flag")
291 
292 // Flags for language modes and experimental language features.
293 DEFINE_BOOL(use_strict, false, "enforce strict mode")
294 
295 DEFINE_BOOL(harmony, false, "enable all completed harmony features")
296 DEFINE_BOOL(harmony_shipping, true, "enable all shipped harmony features")
297 
298 // Update bootstrapper.cc whenever adding a new feature flag.
299 
300 // Features that are still work in progress (behind individual flags).
301 #define HARMONY_INPROGRESS_BASE(V)                                             \
302   V(harmony_weak_refs_with_cleanup_some,                                       \
303     "harmony weak references with FinalizationRegistry.prototype.cleanupSome") \
304   V(harmony_import_assertions, "harmony import assertions")                    \
305   V(harmony_rab_gsab,                                                          \
306     "harmony ResizableArrayBuffer / GrowableSharedArrayBuffer")                \
307   V(harmony_array_find_last, "harmony array find last helpers")
308 
309 #ifdef V8_INTL_SUPPORT
310 #define HARMONY_INPROGRESS(V) HARMONY_INPROGRESS_BASE(V)
311 #else
312 #define HARMONY_INPROGRESS(V) HARMONY_INPROGRESS_BASE(V)
313 #endif
314 
315 // Features that are complete (but still behind --harmony/es-staging flag).
316 #define HARMONY_STAGED_BASE(V)
317 
318 #ifdef V8_INTL_SUPPORT
319 #define HARMONY_STAGED(V)                                 \
320   HARMONY_STAGED_BASE(V)                                  \
321   V(harmony_intl_best_fit_matcher, "Intl BestFitMatcher") \
322   V(harmony_intl_enumeration, "Intl Enumberation API")    \
323   V(harmony_intl_locale_info, "Intl locale info")
324 #else
325 #define HARMONY_STAGED(V) HARMONY_STAGED_BASE(V)
326 #endif
327 
328 // Features that are shipping (turned on by default, but internal flag remains).
329 #define HARMONY_SHIPPING_BASE(V)                                            \
330   V(harmony_sharedarraybuffer, "harmony sharedarraybuffer")                 \
331   V(harmony_atomics, "harmony atomics")                                     \
332   V(harmony_private_brand_checks, "harmony private brand checks")           \
333   V(harmony_top_level_await, "harmony top level await")                     \
334   V(harmony_relative_indexing_methods, "harmony relative indexing methods") \
335   V(harmony_error_cause, "harmony error cause property")                    \
336   V(harmony_object_has_own, "harmony Object.hasOwn")                        \
337   V(harmony_class_static_blocks, "harmony static initializer blocks")
338 
339 #ifdef V8_INTL_SUPPORT
340 #define HARMONY_SHIPPING(V)                               \
341   HARMONY_SHIPPING_BASE(V)                                \
342   V(harmony_intl_dateformat_day_period,                   \
343     "Add dayPeriod option to DateTimeFormat")             \
344   V(harmony_intl_displaynames_v2, "Intl.DisplayNames v2") \
345   V(harmony_intl_more_timezone,                           \
346     "Extend Intl.DateTimeFormat timeZoneName Option")
347 #else
348 #define HARMONY_SHIPPING(V) HARMONY_SHIPPING_BASE(V)
349 #endif
350 
351 // Once a shipping feature has proved stable in the wild, it will be dropped
352 // from HARMONY_SHIPPING, all occurrences of the FLAG_ variable are removed,
353 // and associated tests are moved from the harmony directory to the appropriate
354 // esN directory.
355 
356 #define FLAG_INPROGRESS_FEATURES(id, description) \
357   DEFINE_BOOL(id, false, "enable " #description " (in progress)")
358 HARMONY_INPROGRESS(FLAG_INPROGRESS_FEATURES)
359 #undef FLAG_INPROGRESS_FEATURES
360 
361 #define FLAG_STAGED_FEATURES(id, description)    \
362   DEFINE_BOOL(id, false, "enable " #description) \
363   DEFINE_IMPLICATION(harmony, id)
364 HARMONY_STAGED(FLAG_STAGED_FEATURES)
365 #undef FLAG_STAGED_FEATURES
366 
367 #define FLAG_SHIPPING_FEATURES(id, description) \
368   DEFINE_BOOL(id, true, "enable " #description) \
369   DEFINE_NEG_NEG_IMPLICATION(harmony_shipping, id)
370 HARMONY_SHIPPING(FLAG_SHIPPING_FEATURES)
371 #undef FLAG_SHIPPING_FEATURES
372 
373 DEFINE_BOOL(builtin_subclassing, true,
374             "subclassing support in built-in methods")
375 
376 // If the following flag is set to `true`, the SharedArrayBuffer constructor is
377 // enabled per context depending on the callback set via
378 // `SetSharedArrayBufferConstructorEnabledCallback`. If no callback is set, the
379 // SharedArrayBuffer constructor is disabled.
380 DEFINE_BOOL(enable_sharedarraybuffer_per_context, false,
381             "enable the SharedArrayBuffer constructor per context")
382 
383 #ifdef V8_INTL_SUPPORT
384 DEFINE_BOOL(icu_timezone_data, true, "get information about timezones from ICU")
385 #endif
386 
387 #ifdef V8_ENABLE_DOUBLE_CONST_STORE_CHECK
388 #define V8_ENABLE_DOUBLE_CONST_STORE_CHECK_BOOL true
389 #else
390 #define V8_ENABLE_DOUBLE_CONST_STORE_CHECK_BOOL false
391 #endif
392 
393 #ifdef V8_LITE_MODE
394 #define V8_LITE_BOOL true
395 #else
396 #define V8_LITE_BOOL false
397 #endif
398 
399 #ifdef V8_ENABLE_LAZY_SOURCE_POSITIONS
400 #define V8_LAZY_SOURCE_POSITIONS_BOOL true
401 #else
402 #define V8_LAZY_SOURCE_POSITIONS_BOOL false
403 #endif
404 
405 #ifdef V8_SHARED_RO_HEAP
406 #define V8_SHARED_RO_HEAP_BOOL true
407 #else
408 #define V8_SHARED_RO_HEAP_BOOL false
409 #endif
410 
411 DEFINE_BOOL(stress_snapshot, false,
412             "disables sharing of the read-only heap for testing")
413 // Incremental marking is incompatible with the stress_snapshot mode;
414 // specifically, serialization may clear bytecode arrays from shared function
415 // infos which the MarkCompactCollector (running concurrently) may still need.
416 // See also https://crbug.com/v8/10882.
417 //
418 // Note: This is not an issue in production because we don't clear SFI's
419 // there (that only happens in mksnapshot and in --stress-snapshot mode).
420 DEFINE_NEG_IMPLICATION(stress_snapshot, incremental_marking)
421 
422 DEFINE_BOOL(lite_mode, V8_LITE_BOOL,
423             "enables trade-off of performance for memory savings")
424 
425 // Lite mode implies other flags to trade-off performance for memory.
426 DEFINE_IMPLICATION(lite_mode, jitless)
427 DEFINE_IMPLICATION(lite_mode, lazy_feedback_allocation)
428 DEFINE_IMPLICATION(lite_mode, optimize_for_size)
429 
430 #ifdef V8_ENABLE_THIRD_PARTY_HEAP
431 #define V8_ENABLE_THIRD_PARTY_HEAP_BOOL true
432 #else
433 #define V8_ENABLE_THIRD_PARTY_HEAP_BOOL false
434 #endif
435 
436 DEFINE_NEG_IMPLICATION(enable_third_party_heap, inline_new)
437 DEFINE_NEG_IMPLICATION(enable_third_party_heap, allocation_site_pretenuring)
438 DEFINE_NEG_IMPLICATION(enable_third_party_heap, turbo_allocation_folding)
439 DEFINE_NEG_IMPLICATION(enable_third_party_heap, concurrent_recompilation)
440 DEFINE_NEG_IMPLICATION(enable_third_party_heap, concurrent_inlining)
441 DEFINE_NEG_IMPLICATION(enable_third_party_heap,
442                        finalize_streaming_on_background)
443 DEFINE_NEG_IMPLICATION(enable_third_party_heap, use_marking_progress_bar)
444 DEFINE_NEG_IMPLICATION(enable_third_party_heap, move_object_start)
445 DEFINE_NEG_IMPLICATION(enable_third_party_heap, concurrent_marking)
446 
447 DEFINE_BOOL_READONLY(enable_third_party_heap, V8_ENABLE_THIRD_PARTY_HEAP_BOOL,
448                      "Use third-party heap")
449 
450 #ifdef V8_ALLOCATION_FOLDING
451 #define V8_ALLOCATION_FOLDING_BOOL true
452 #else
453 #define V8_ALLOCATION_FOLDING_BOOL false
454 #endif
455 
456 DEFINE_BOOL_READONLY(enable_allocation_folding, V8_ALLOCATION_FOLDING_BOOL,
457                      "Use allocation folding globally")
458 DEFINE_NEG_NEG_IMPLICATION(enable_allocation_folding, turbo_allocation_folding)
459 
460 #ifdef V8_DISABLE_WRITE_BARRIERS
461 #define V8_DISABLE_WRITE_BARRIERS_BOOL true
462 #else
463 #define V8_DISABLE_WRITE_BARRIERS_BOOL false
464 #endif
465 
466 DEFINE_BOOL_READONLY(disable_write_barriers, V8_DISABLE_WRITE_BARRIERS_BOOL,
467                      "disable write barriers when GC is non-incremental "
468                      "and heap contains single generation.")
469 
470 // Disable incremental marking barriers
471 DEFINE_NEG_IMPLICATION(disable_write_barriers, incremental_marking)
472 
473 #ifdef V8_ENABLE_UNCONDITIONAL_WRITE_BARRIERS
474 #define V8_ENABLE_UNCONDITIONAL_WRITE_BARRIERS_BOOL true
475 #else
476 #define V8_ENABLE_UNCONDITIONAL_WRITE_BARRIERS_BOOL false
477 #endif
478 
479 DEFINE_BOOL_READONLY(enable_unconditional_write_barriers,
480                      V8_ENABLE_UNCONDITIONAL_WRITE_BARRIERS_BOOL,
481                      "always use full write barriers")
482 
483 #ifdef V8_ENABLE_SINGLE_GENERATION
484 #define V8_SINGLE_GENERATION_BOOL true
485 #else
486 #define V8_SINGLE_GENERATION_BOOL false
487 #endif
488 
489 DEFINE_BOOL_READONLY(
490     single_generation, V8_SINGLE_GENERATION_BOOL,
491     "allocate all objects from young generation to old generation")
492 
493 #ifdef V8_ENABLE_CONSERVATIVE_STACK_SCANNING
494 #define V8_ENABLE_CONSERVATIVE_STACK_SCANNING_BOOL true
495 #else
496 #define V8_ENABLE_CONSERVATIVE_STACK_SCANNING_BOOL false
497 #endif
498 DEFINE_BOOL_READONLY(conservative_stack_scanning,
499                      V8_ENABLE_CONSERVATIVE_STACK_SCANNING_BOOL,
500                      "use conservative stack scanning")
501 
502 #ifdef V8_ENABLE_FUTURE
503 #define FUTURE_BOOL true
504 #else
505 #define FUTURE_BOOL false
506 #endif
507 DEFINE_BOOL(future, FUTURE_BOOL,
508             "Implies all staged features that we want to ship in the "
509             "not-too-far future")
510 
511 #if ENABLE_SPARKPLUG
512 DEFINE_WEAK_IMPLICATION(future, sparkplug)
513 DEFINE_WEAK_IMPLICATION(future, flush_baseline_code)
514 #endif
515 #if V8_SHORT_BUILTIN_CALLS
516 DEFINE_WEAK_IMPLICATION(future, short_builtin_calls)
517 #endif
518 #if !MUST_WRITE_PROTECT_CODE_MEMORY
519 DEFINE_WEAK_VALUE_IMPLICATION(future, write_protect_code_memory, false)
520 #endif
521 
522 // Flags for jitless
523 DEFINE_BOOL(jitless, V8_LITE_BOOL,
524             "Disable runtime allocation of executable memory.")
525 
526 // Jitless V8 has a few implications:
527 DEFINE_NEG_IMPLICATION(jitless, opt)
528 // Field type tracking is only used by TurboFan.
529 DEFINE_NEG_IMPLICATION(jitless, track_field_types)
530 // Regexps are interpreted.
531 DEFINE_IMPLICATION(jitless, regexp_interpret_all)
532 #if ENABLE_SPARKPLUG
533 // No Sparkplug compilation.
534 DEFINE_NEG_IMPLICATION(jitless, sparkplug)
535 DEFINE_NEG_IMPLICATION(jitless, always_sparkplug)
536 #endif
537 
538 #ifndef V8_TARGET_ARCH_ARM
539 // Unsupported on arm. See https://crbug.com/v8/8713.
540 DEFINE_NEG_IMPLICATION(jitless, interpreted_frames_native_stack)
541 #endif
542 
543 DEFINE_BOOL(assert_types, false,
544             "generate runtime type assertions to test the typer")
545 
546 DEFINE_BOOL(trace_compilation_dependencies, false, "trace code dependencies")
547 // Depend on --trace-deopt-verbose for reporting dependency invalidations.
548 DEFINE_IMPLICATION(trace_compilation_dependencies, trace_deopt_verbose)
549 
550 #ifdef V8_ALLOCATION_SITE_TRACKING
551 #define V8_ALLOCATION_SITE_TRACKING_BOOL true
552 #else
553 #define V8_ALLOCATION_SITE_TRACKING_BOOL false
554 #endif
555 
556 DEFINE_BOOL_READONLY(allocation_site_tracking, V8_ALLOCATION_SITE_TRACKING_BOOL,
557                      "Enable allocation site tracking")
558 DEFINE_NEG_NEG_IMPLICATION(allocation_site_tracking,
559                            allocation_site_pretenuring)
560 
561 // Flags for experimental implementation features.
562 DEFINE_BOOL(allocation_site_pretenuring, true,
563             "pretenure with allocation sites")
564 DEFINE_BOOL(page_promotion, true, "promote pages based on utilization")
565 DEFINE_BOOL_READONLY(always_promote_young_mc, true,
566                      "always promote young objects during mark-compact")
567 DEFINE_INT(page_promotion_threshold, 70,
568            "min percentage of live bytes on a page to enable fast evacuation")
569 DEFINE_BOOL(trace_pretenuring, false,
570             "trace pretenuring decisions of HAllocate instructions")
571 DEFINE_BOOL(trace_pretenuring_statistics, false,
572             "trace allocation site pretenuring statistics")
573 DEFINE_BOOL(track_field_types, true, "track field types")
574 DEFINE_BOOL(trace_block_coverage, false,
575             "trace collected block coverage information")
576 DEFINE_BOOL(trace_protector_invalidation, false,
577             "trace protector cell invalidations")
578 DEFINE_BOOL(trace_web_snapshot, false, "trace web snapshot deserialization")
579 
580 DEFINE_BOOL(feedback_normalization, false,
581             "feed back normalization to constructors")
582 // TODO(jkummerow): This currently adds too much load on the stub cache.
583 DEFINE_BOOL_READONLY(internalize_on_the_fly, true,
584                      "internalize string keys for generic keyed ICs on the fly")
585 
586 // Flag for sealed, frozen elements kind instead of dictionary elements kind
587 DEFINE_BOOL_READONLY(enable_sealed_frozen_elements_kind, true,
588                      "Enable sealed, frozen elements kind")
589 
590 // Flags for data representation optimizations
591 DEFINE_BOOL(unbox_double_arrays, true, "automatically unbox arrays of doubles")
592 DEFINE_BOOL_READONLY(string_slices, true, "use string slices")
593 
594 DEFINE_INT(ticks_before_optimization, 3,
595            "the number of times we have to go through the interrupt budget "
596            "before considering this function for optimization")
597 DEFINE_INT(bytecode_size_allowance_per_tick, 1100,
598            "increases the number of ticks required for optimization by "
599            "bytecode.length/X")
600 DEFINE_INT(interrupt_budget, 132 * KB,
601            "interrupt budget which should be used for the profiler counter")
602 DEFINE_INT(
603     max_bytecode_size_for_early_opt, 81,
604     "Maximum bytecode length for a function to be optimized on the first tick")
605 
606 // Flags for inline caching and feedback vectors.
607 DEFINE_BOOL(use_ic, true, "use inline caching")
608 DEFINE_INT(budget_for_feedback_vector_allocation, 940,
609            "The budget in amount of bytecode executed by a function before we "
610            "decide to allocate feedback vectors")
611 DEFINE_INT(scale_factor_for_feedback_allocation, 8,
612            "scale bytecode size for feedback vector allocation.")
613 DEFINE_BOOL(feedback_allocation_on_bytecode_size, true,
614             "Instead of a fixed budget for lazy feedback vector allocation, "
615             "scale it based in the bytecode size.")
616 DEFINE_IMPLICATION(sparkplug, feedback_allocation_on_bytecode_size)
617 DEFINE_BOOL(lazy_feedback_allocation, true, "Allocate feedback vectors lazily")
618 
619 // Flags for Ignition.
620 DEFINE_BOOL(ignition_elide_noneffectful_bytecodes, true,
621             "elide bytecodes which won't have any external effect")
622 DEFINE_BOOL(ignition_reo, true, "use ignition register equivalence optimizer")
623 DEFINE_BOOL(ignition_filter_expression_positions, true,
624             "filter expression positions before the bytecode pipeline")
625 DEFINE_BOOL(ignition_share_named_property_feedback, true,
626             "share feedback slots when loading the same named property from "
627             "the same object")
628 DEFINE_BOOL(print_bytecode, false,
629             "print bytecode generated by ignition interpreter")
630 DEFINE_BOOL(enable_lazy_source_positions, V8_LAZY_SOURCE_POSITIONS_BOOL,
631             "skip generating source positions during initial compile but "
632             "regenerate when actually required")
633 DEFINE_BOOL(stress_lazy_source_positions, false,
634             "collect lazy source positions immediately after lazy compile")
635 DEFINE_STRING(print_bytecode_filter, "*",
636               "filter for selecting which functions to print bytecode")
637 #ifdef V8_TRACE_UNOPTIMIZED
638 DEFINE_BOOL(trace_unoptimized, false,
639             "trace the bytecodes executed by all unoptimized execution")
640 DEFINE_BOOL(trace_ignition, false,
641             "trace the bytecodes executed by the ignition interpreter")
642 DEFINE_BOOL(trace_baseline_exec, false,
643             "trace the bytecodes executed by the baseline code")
644 DEFINE_WEAK_IMPLICATION(trace_unoptimized, trace_ignition)
645 DEFINE_WEAK_IMPLICATION(trace_unoptimized, trace_baseline_exec)
646 #endif
647 #ifdef V8_TRACE_FEEDBACK_UPDATES
648 DEFINE_BOOL(
649     trace_feedback_updates, false,
650     "trace updates to feedback vectors during ignition interpreter execution.")
651 #endif
652 DEFINE_BOOL(trace_ignition_codegen, false,
653             "trace the codegen of ignition interpreter bytecode handlers")
654 DEFINE_STRING(
655     trace_ignition_dispatches_output_file, nullptr,
656     "write the bytecode handler dispatch table to the specified file (d8 only) "
657     "(requires building with v8_enable_ignition_dispatch_counting)")
658 
659 DEFINE_BOOL(trace_track_allocation_sites, false,
660             "trace the tracking of allocation sites")
661 DEFINE_BOOL(trace_migration, false, "trace object migration")
662 DEFINE_BOOL(trace_generalization, false, "trace map generalization")
663 
664 // Flags for TurboProp.
665 DEFINE_BOOL(turboprop, false, "enable experimental turboprop mid-tier compiler")
666 DEFINE_BOOL(turboprop_mid_tier_reg_alloc, true,
667             "enable mid-tier register allocator for turboprop")
668 DEFINE_BOOL(
669     turboprop_as_toptier, false,
670     "enable experimental turboprop compiler without further tierup to turbofan")
671 DEFINE_IMPLICATION(turboprop_as_toptier, turboprop)
672 DEFINE_WEAK_VALUE_IMPLICATION(turboprop, interrupt_budget, 115 * KB)
673 DEFINE_UINT_READONLY(max_minimorphic_map_checks, 4,
674                      "max number of map checks to perform in minimorphic state")
675 DEFINE_INT(turboprop_inline_scaling_factor, 4,
676            "scale factor for reduction in bytecode that can be inline for "
677            "TurboProp compared to TurboFan")
678 // The scale factor determines the interrupt budget when tiering up from
679 // Turboprop to TurboFan.
680 DEFINE_INT(interrupt_budget_scale_factor_for_top_tier, 20,
681            "scale factor for profiler ticks when tiering up from midtier")
682 
683 // Flags for Sparkplug
684 #undef FLAG
685 #if ENABLE_SPARKPLUG
686 #define FLAG FLAG_FULL
687 #else
688 #define FLAG FLAG_READONLY
689 #endif
690 DEFINE_BOOL(sparkplug, ENABLE_SPARKPLUG_BY_DEFAULT,
691             "enable Sparkplug baseline compiler")
692 DEFINE_BOOL(always_sparkplug, false, "directly tier up to Sparkplug code")
693 DEFINE_BOOL(sparkplug_on_heap, false, "compile Sparkplug code directly on heap")
694 #if ENABLE_SPARKPLUG
695 DEFINE_IMPLICATION(always_sparkplug, sparkplug)
696 DEFINE_BOOL(baseline_batch_compilation, true, "batch compile Sparkplug code")
697 #else
698 DEFINE_BOOL(baseline_batch_compilation, false, "batch compile Sparkplug code")
699 #endif
700 DEFINE_STRING(sparkplug_filter, "*", "filter for Sparkplug baseline compiler")
701 DEFINE_BOOL(sparkplug_needs_short_builtins, false,
702             "only enable Sparkplug baseline compiler when "
703             "--short-builtin-calls are also enabled")
704 DEFINE_INT(baseline_batch_compilation_threshold, 4 * KB,
705            "the estimated instruction size of a batch to trigger compilation")
706 DEFINE_BOOL(trace_baseline, false, "trace baseline compilation")
707 DEFINE_BOOL(trace_baseline_batch_compilation, false,
708             "trace baseline batch compilation")
709 
710 #undef FLAG
711 #define FLAG FLAG_FULL
712 
713 #if !defined(V8_OS_MACOSX) || !defined(V8_HOST_ARCH_ARM64)
714 DEFINE_BOOL(write_code_using_rwx, true,
715             "flip permissions to rwx to write page instead of rw")
716 DEFINE_NEG_IMPLICATION(jitless, write_code_using_rwx)
717 #else
718 DEFINE_BOOL_READONLY(write_code_using_rwx, false,
719                      "flip permissions to rwx to write page instead of rw")
720 #endif
721 
722 // Flags for concurrent recompilation.
723 DEFINE_BOOL(concurrent_recompilation, true,
724             "optimizing hot functions asynchronously on a separate thread")
725 DEFINE_BOOL(trace_concurrent_recompilation, false,
726             "track concurrent recompilation")
727 DEFINE_INT(concurrent_recompilation_queue_length, 8,
728            "the length of the concurrent compilation queue")
729 DEFINE_INT(concurrent_recompilation_delay, 0,
730            "artificial compilation delay in ms")
731 DEFINE_BOOL(concurrent_inlining, true,
732             "run optimizing compiler's inlining phase on a separate thread")
733 DEFINE_BOOL(
734     stress_concurrent_inlining, false,
735     "create additional concurrent optimization jobs but throw away result")
736 DEFINE_IMPLICATION(stress_concurrent_inlining, concurrent_inlining)
737 DEFINE_NEG_IMPLICATION(stress_concurrent_inlining, lazy_feedback_allocation)
738 DEFINE_WEAK_VALUE_IMPLICATION(stress_concurrent_inlining, interrupt_budget,
739                               15 * KB)
740 DEFINE_BOOL(stress_concurrent_inlining_attach_code, false,
741             "create additional concurrent optimization jobs")
742 DEFINE_IMPLICATION(stress_concurrent_inlining_attach_code,
743                    stress_concurrent_inlining)
744 DEFINE_INT(max_serializer_nesting, 25,
745            "maximum levels for nesting child serializers")
746 DEFINE_BOOL(trace_heap_broker_verbose, false,
747             "trace the heap broker verbosely (all reports)")
748 DEFINE_BOOL(trace_heap_broker_memory, false,
749             "trace the heap broker memory (refs analysis and zone numbers)")
750 DEFINE_BOOL(trace_heap_broker, false,
751             "trace the heap broker (reports on missing data only)")
752 DEFINE_IMPLICATION(trace_heap_broker_verbose, trace_heap_broker)
753 DEFINE_IMPLICATION(trace_heap_broker_memory, trace_heap_broker)
754 DEFINE_IMPLICATION(trace_heap_broker, trace_pending_allocations)
755 
756 // Flags for stress-testing the compiler.
757 DEFINE_INT(stress_runs, 0, "number of stress runs")
758 DEFINE_INT(deopt_every_n_times, 0,
759            "deoptimize every n times a deopt point is passed")
760 DEFINE_BOOL(print_deopt_stress, false, "print number of possible deopt points")
761 
762 // Flags for TurboFan.
763 DEFINE_BOOL(opt, true, "use adaptive optimizations")
764 DEFINE_BOOL(turbo_sp_frame_access, false,
765             "use stack pointer-relative access to frame wherever possible")
766 DEFINE_BOOL(
767     stress_turbo_late_spilling, false,
768     "optimize placement of all spill instructions, not just loop-top phis")
769 
770 DEFINE_STRING(turbo_filter, "*", "optimization filter for TurboFan compiler")
771 DEFINE_BOOL(trace_turbo, false, "trace generated TurboFan IR")
772 DEFINE_STRING(trace_turbo_path, nullptr,
773               "directory to dump generated TurboFan IR to")
774 DEFINE_STRING(trace_turbo_filter, "*",
775               "filter for tracing turbofan compilation")
776 DEFINE_BOOL(trace_turbo_graph, false, "trace generated TurboFan graphs")
777 DEFINE_BOOL(trace_turbo_scheduled, false, "trace TurboFan IR with schedule")
778 DEFINE_IMPLICATION(trace_turbo_scheduled, trace_turbo_graph)
779 DEFINE_STRING(trace_turbo_cfg_file, nullptr,
780               "trace turbo cfg graph (for C1 visualizer) to a given file name")
781 DEFINE_BOOL(trace_turbo_types, true, "trace TurboFan's types")
782 DEFINE_BOOL(trace_turbo_scheduler, false, "trace TurboFan's scheduler")
783 DEFINE_BOOL(trace_turbo_reduction, false, "trace TurboFan's various reducers")
784 DEFINE_BOOL(trace_turbo_trimming, false, "trace TurboFan's graph trimmer")
785 DEFINE_BOOL(trace_turbo_jt, false, "trace TurboFan's jump threading")
786 DEFINE_BOOL(trace_turbo_ceq, false, "trace TurboFan's control equivalence")
787 DEFINE_BOOL(trace_turbo_loop, false, "trace TurboFan's loop optimizations")
788 DEFINE_BOOL(trace_turbo_alloc, false, "trace TurboFan's register allocator")
789 DEFINE_BOOL(trace_all_uses, false, "trace all use positions")
790 DEFINE_BOOL(trace_representation, false, "trace representation types")
791 DEFINE_BOOL(
792     trace_turbo_stack_accesses, false,
793     "trace stack load/store counters for optimized code in run-time (x64 only)")
794 DEFINE_BOOL(turbo_verify, DEBUG_BOOL, "verify TurboFan graphs at each phase")
795 DEFINE_STRING(turbo_verify_machine_graph, nullptr,
796               "verify TurboFan machine graph before instruction selection")
797 #ifdef ENABLE_VERIFY_CSA
798 DEFINE_BOOL(verify_csa, DEBUG_BOOL,
799             "verify TurboFan machine graph of code stubs")
800 #else
801 // Define the flag as read-only-false so that code still compiles even in the
802 // non-ENABLE_VERIFY_CSA configuration.
803 DEFINE_BOOL_READONLY(verify_csa, false,
804                      "verify TurboFan machine graph of code stubs")
805 #endif
806 DEFINE_BOOL(trace_verify_csa, false, "trace code stubs verification")
807 DEFINE_STRING(csa_trap_on_node, nullptr,
808               "trigger break point when a node with given id is created in "
809               "given stub. The format is: StubName,NodeId")
810 DEFINE_BOOL_READONLY(fixed_array_bounds_checks, true,
811                      "enable FixedArray bounds checks")
812 DEFINE_BOOL(turbo_stats, false, "print TurboFan statistics")
813 DEFINE_BOOL(turbo_stats_nvp, false,
814             "print TurboFan statistics in machine-readable format")
815 DEFINE_BOOL(turbo_stats_wasm, false,
816             "print TurboFan statistics of wasm compilations")
817 DEFINE_BOOL(turbo_splitting, true, "split nodes during scheduling in TurboFan")
818 DEFINE_BOOL(function_context_specialization, false,
819             "enable function context specialization in TurboFan")
820 DEFINE_BOOL(turbo_inlining, true, "enable inlining in TurboFan")
821 DEFINE_INT(max_inlined_bytecode_size, 460,
822            "maximum size of bytecode for a single inlining")
823 DEFINE_INT(max_inlined_bytecode_size_cumulative, 920,
824            "maximum cumulative size of bytecode considered for inlining")
825 DEFINE_INT(max_inlined_bytecode_size_absolute, 4600,
826            "maximum absolute size of bytecode considered for inlining")
827 DEFINE_FLOAT(
828     reserve_inline_budget_scale_factor, 1.2,
829     "scale factor of bytecode size used to calculate the inlining budget")
830 DEFINE_INT(max_inlined_bytecode_size_small, 27,
831            "maximum size of bytecode considered for small function inlining")
832 DEFINE_INT(max_optimized_bytecode_size, 60 * KB,
833            "maximum bytecode size to "
834            "be considered for optimization; too high values may cause "
835            "the compiler to hit (release) assertions")
836 DEFINE_FLOAT(min_inlining_frequency, 0.15, "minimum frequency for inlining")
837 DEFINE_BOOL(polymorphic_inlining, true, "polymorphic inlining")
838 DEFINE_BOOL(stress_inline, false,
839             "set high thresholds for inlining to inline as much as possible")
840 DEFINE_VALUE_IMPLICATION(stress_inline, max_inlined_bytecode_size, 999999)
841 DEFINE_VALUE_IMPLICATION(stress_inline, max_inlined_bytecode_size_cumulative,
842                          999999)
843 DEFINE_VALUE_IMPLICATION(stress_inline, max_inlined_bytecode_size_absolute,
844                          999999)
845 DEFINE_VALUE_IMPLICATION(stress_inline, min_inlining_frequency, 0)
846 DEFINE_IMPLICATION(stress_inline, polymorphic_inlining)
847 DEFINE_BOOL(trace_turbo_inlining, false, "trace TurboFan inlining")
848 DEFINE_BOOL(turbo_inline_array_builtins, true,
849             "inline array builtins in TurboFan code")
850 DEFINE_BOOL(use_osr, true, "use on-stack replacement")
851 DEFINE_BOOL(trace_osr, false, "trace on-stack replacement")
852 DEFINE_BOOL(analyze_environment_liveness, true,
853             "analyze liveness of environment slots and zap dead values")
854 DEFINE_BOOL(trace_environment_liveness, false,
855             "trace liveness of local variable slots")
856 DEFINE_BOOL(turbo_load_elimination, true, "enable load elimination in TurboFan")
857 DEFINE_BOOL(trace_turbo_load_elimination, false,
858             "trace TurboFan load elimination")
859 DEFINE_BOOL(turbo_profiling, false, "enable basic block profiling in TurboFan")
860 DEFINE_BOOL(turbo_profiling_verbose, false,
861             "enable basic block profiling in TurboFan, and include each "
862             "function's schedule and disassembly in the output")
863 DEFINE_IMPLICATION(turbo_profiling_verbose, turbo_profiling)
864 DEFINE_BOOL(turbo_profiling_log_builtins, false,
865             "emit data about basic block usage in builtins to v8.log (requires "
866             "that V8 was built with v8_enable_builtins_profiling=true)")
867 DEFINE_BOOL(turbo_verify_allocation, DEBUG_BOOL,
868             "verify register allocation in TurboFan")
869 DEFINE_BOOL(turbo_move_optimization, true, "optimize gap moves in TurboFan")
870 DEFINE_BOOL(turbo_jt, true, "enable jump threading in TurboFan")
871 DEFINE_BOOL(turbo_loop_peeling, true, "TurboFan loop peeling")
872 DEFINE_BOOL(turbo_loop_variable, true, "TurboFan loop variable optimization")
873 DEFINE_BOOL(turbo_loop_rotation, true, "TurboFan loop rotation")
874 DEFINE_BOOL(turbo_cf_optimization, true, "optimize control flow in TurboFan")
875 DEFINE_BOOL(turbo_escape, true, "enable escape analysis")
876 DEFINE_BOOL(turbo_allocation_folding, true, "TurboFan allocation folding")
877 DEFINE_BOOL(turbo_instruction_scheduling, false,
878             "enable instruction scheduling in TurboFan")
879 DEFINE_BOOL(turbo_stress_instruction_scheduling, false,
880             "randomly schedule instructions to stress dependency tracking")
881 DEFINE_IMPLICATION(turbo_stress_instruction_scheduling,
882                    turbo_instruction_scheduling)
883 DEFINE_BOOL(turbo_store_elimination, true,
884             "enable store-store elimination in TurboFan")
885 DEFINE_BOOL(trace_store_elimination, false, "trace store elimination")
886 DEFINE_BOOL(turbo_rewrite_far_jumps, true,
887             "rewrite far to near jumps (ia32,x64)")
888 DEFINE_BOOL(
889     stress_gc_during_compilation, false,
890     "simulate GC/compiler thread race related to https://crbug.com/v8/8520")
891 DEFINE_BOOL(turbo_fast_api_calls, false, "enable fast API calls from TurboFan")
892 DEFINE_INT(reuse_opt_code_count, 0,
893            "don't discard optimized code for the specified number of deopts.")
894 DEFINE_BOOL(turbo_dynamic_map_checks, false,
895             "use dynamic map checks when generating code for property accesses "
896             "if all handlers in an IC are the same for turboprop")
897 DEFINE_BOOL(turbo_compress_translation_arrays, false,
898             "compress translation arrays (experimental)")
899 DEFINE_BOOL(turbo_inline_js_wasm_calls, true, "inline JS->Wasm calls")
900 
901 DEFINE_BOOL(turbo_optimize_apply, true, "optimize Function.prototype.apply")
902 
903 DEFINE_BOOL(turbo_collect_feedback_in_generic_lowering, true,
904             "enable experimental feedback collection in generic lowering.")
905 DEFINE_BOOL(isolate_script_cache_ageing, true,
906             "enable ageing of the isolate script cache.")
907 
908 DEFINE_FLOAT(script_delay, 0, "busy wait [ms] on every Script::Run")
909 DEFINE_FLOAT(script_delay_once, 0, "busy wait [ms] on the first Script::Run")
910 DEFINE_FLOAT(script_delay_fraction, 0.0,
911              "busy wait after each Script::Run by the given fraction of the "
912              "run's duration")
913 
914 // Favor memory over execution speed.
915 DEFINE_BOOL(optimize_for_size, false,
916             "Enables optimizations which favor memory size over execution "
917             "speed")
918 DEFINE_VALUE_IMPLICATION(optimize_for_size, max_semi_space_size, 1)
919 
920 // Flags for WebAssembly.
921 #if V8_ENABLE_WEBASSEMBLY
922 
923 DEFINE_BOOL(wasm_generic_wrapper, true,
924             "allow use of the generic js-to-wasm wrapper instead of "
925             "per-signature wrappers")
926 DEFINE_BOOL(expose_wasm, true, "expose wasm interface to JavaScript")
927 DEFINE_INT(wasm_num_compilation_tasks, 128,
928            "maximum number of parallel compilation tasks for wasm")
929 DEFINE_VALUE_IMPLICATION(single_threaded, wasm_num_compilation_tasks, 0)
930 DEFINE_DEBUG_BOOL(trace_wasm_native_heap, false,
931                   "trace wasm native heap events")
932 DEFINE_BOOL(wasm_write_protect_code_memory, false,
933             "write protect code memory on the wasm native heap with mprotect")
934 DEFINE_WEAK_IMPLICATION(future, wasm_write_protect_code_memory)
935 DEFINE_BOOL(wasm_memory_protection_keys, false,
936             "protect wasm code memory with PKU if available, no protection "
937             "without support; fallback to mprotect by adding "
938             "--wasm-write-protect-code-memory")
939 DEFINE_WEAK_IMPLICATION(future, wasm_memory_protection_keys)
940 DEFINE_DEBUG_BOOL(trace_wasm_serialization, false,
941                   "trace serialization/deserialization")
942 DEFINE_BOOL(wasm_async_compilation, true,
943             "enable actual asynchronous compilation for WebAssembly.compile")
944 DEFINE_NEG_IMPLICATION(single_threaded, wasm_async_compilation)
945 DEFINE_BOOL(wasm_test_streaming, false,
946             "use streaming compilation instead of async compilation for tests")
947 DEFINE_UINT(wasm_max_mem_pages, v8::internal::wasm::kV8MaxWasmMemoryPages,
948             "maximum number of 64KiB memory pages per wasm memory")
949 DEFINE_UINT(wasm_max_table_size, v8::internal::wasm::kV8MaxWasmTableSize,
950             "maximum table size of a wasm instance")
951 DEFINE_UINT(wasm_max_code_space, v8::internal::kMaxWasmCodeMB,
952             "maximum committed code space for wasm (in MB)")
953 DEFINE_BOOL(wasm_tier_up, true,
954             "enable tier up to the optimizing compiler (requires --liftoff to "
955             "have an effect)")
956 DEFINE_BOOL(wasm_dynamic_tiering, false,
957             "enable dynamic tier up to the optimizing compiler")
958 DEFINE_INT(
959     wasm_caching_threshold, 1000000,
960     "the amount of wasm top tier code that triggers the next caching event")
961 DEFINE_DEBUG_BOOL(trace_wasm_decoder, false, "trace decoding of wasm code")
962 DEFINE_DEBUG_BOOL(trace_wasm_compiler, false, "trace compiling of wasm code")
963 DEFINE_DEBUG_BOOL(trace_wasm_interpreter, false,
964                   "trace interpretation of wasm code")
965 DEFINE_DEBUG_BOOL(trace_wasm_streaming, false,
966                   "trace streaming compilation of wasm code")
967 DEFINE_BOOL(liftoff, true,
968             "enable Liftoff, the baseline compiler for WebAssembly")
969 DEFINE_BOOL(liftoff_only, false,
970             "disallow TurboFan compilation for WebAssembly (for testing)")
971 DEFINE_IMPLICATION(liftoff_only, liftoff)
972 DEFINE_NEG_IMPLICATION(liftoff_only, wasm_tier_up)
973 DEFINE_NEG_IMPLICATION(fuzzing, liftoff_only)
974 DEFINE_DEBUG_BOOL(
975     enable_testing_opcode_in_wasm, false,
976     "enables a testing opcode in wasm that is only implemented in TurboFan")
977 // We can't tier up (from Liftoff to TurboFan) in single-threaded mode, hence
978 // disable tier up in that configuration for now.
979 DEFINE_NEG_IMPLICATION(single_threaded, wasm_tier_up)
980 DEFINE_DEBUG_BOOL(trace_liftoff, false,
981                   "trace Liftoff, the baseline compiler for WebAssembly")
982 DEFINE_BOOL(trace_wasm_memory, false,
983             "print all memory updates performed in wasm code")
984 // Fuzzers use {wasm_tier_mask_for_testing} and {wasm_debug_mask_for_testing}
985 // together with {liftoff} and {no_wasm_tier_up} to force some functions to be
986 // compiled with TurboFan or for debug.
987 DEFINE_INT(wasm_tier_mask_for_testing, 0,
988            "bitmask of functions to compile with TurboFan instead of Liftoff")
989 DEFINE_INT(wasm_debug_mask_for_testing, 0,
990            "bitmask of functions to compile for debugging, only applies if the "
991            "tier is Liftoff")
992 
993 DEFINE_BOOL(validate_asm, true, "validate asm.js modules before compiling")
994 // asm.js validation is disabled since it triggers wasm code generation.
995 // --jitless also implies --no-expose-wasm, see InitializeOncePerProcessImpl.
996 DEFINE_NEG_IMPLICATION(jitless, validate_asm)
997 DEFINE_BOOL(suppress_asm_messages, false,
998             "don't emit asm.js related messages (for golden file testing)")
999 DEFINE_BOOL(trace_asm_time, false, "print asm.js timing info to the console")
1000 DEFINE_BOOL(trace_asm_scanner, false,
1001             "print tokens encountered by asm.js scanner")
1002 DEFINE_BOOL(trace_asm_parser, false, "verbose logging of asm.js parse failures")
1003 DEFINE_BOOL(stress_validate_asm, false, "try to validate everything as asm.js")
1004 
1005 DEFINE_DEBUG_BOOL(dump_wasm_module, false, "dump wasm module bytes")
1006 DEFINE_STRING(dump_wasm_module_path, nullptr,
1007               "directory to dump wasm modules to")
1008 
1009 // Declare command-line flags for Wasm features. Warning: avoid using these
1010 // flags directly in the implementation. Instead accept wasm::WasmFeatures
1011 // for configurability.
1012 #include "src/wasm/wasm-feature-flags.h"
1013 
1014 #define DECL_WASM_FLAG(feat, desc, val)      \
1015   DEFINE_BOOL(experimental_wasm_##feat, val, \
1016               "enable prototype " desc " for wasm")
1017 FOREACH_WASM_FEATURE_FLAG(DECL_WASM_FLAG)
1018 #undef DECL_WASM_FLAG
1019 
1020 DEFINE_IMPLICATION(experimental_wasm_gc, experimental_wasm_typed_funcref)
1021 DEFINE_IMPLICATION(experimental_wasm_typed_funcref, experimental_wasm_reftypes)
1022 
1023 DEFINE_BOOL(wasm_gc_js_interop, false, "experimental WasmGC-JS interop")
1024 
1025 DEFINE_BOOL(wasm_staging, false, "enable staged wasm features")
1026 
1027 #define WASM_STAGING_IMPLICATION(feat, desc, val) \
1028   DEFINE_IMPLICATION(wasm_staging, experimental_wasm_##feat)
1029 FOREACH_WASM_STAGING_FEATURE_FLAG(WASM_STAGING_IMPLICATION)
1030 #undef WASM_STAGING_IMPLICATION
1031 
1032 DEFINE_BOOL(wasm_opt, true, "enable wasm optimization")
1033 DEFINE_BOOL(
1034     wasm_bounds_checks, true,
1035     "enable bounds checks (disable for performance testing only)")
1036 DEFINE_BOOL(wasm_stack_checks, true,
1037             "enable stack checks (disable for performance testing only)")
1038 DEFINE_BOOL(
1039     wasm_enforce_bounds_checks, false,
1040     "enforce explicit bounds check even if the trap handler is available")
1041 // "no bounds checks" implies "no enforced bounds checks".
1042 DEFINE_NEG_NEG_IMPLICATION(wasm_bounds_checks, wasm_enforce_bounds_checks)
1043 DEFINE_BOOL(wasm_math_intrinsics, true,
1044             "intrinsify some Math imports into wasm")
1045 
1046 DEFINE_BOOL(
1047     wasm_inlining, false,
1048     "enable inlining of wasm functions into wasm functions (experimental)")
1049 DEFINE_BOOL(wasm_loop_unrolling, true,
1050             "enable loop unrolling for wasm functions")
1051 DEFINE_BOOL(wasm_fuzzer_gen_test, false,
1052             "generate a test case when running a wasm fuzzer")
1053 DEFINE_IMPLICATION(wasm_fuzzer_gen_test, single_threaded)
1054 DEFINE_BOOL(print_wasm_code, false, "print WebAssembly code")
1055 DEFINE_INT(print_wasm_code_function_index, -1,
1056            "print WebAssembly code for function at index")
1057 DEFINE_BOOL(print_wasm_stub_code, false, "print WebAssembly stub code")
1058 DEFINE_BOOL(asm_wasm_lazy_compilation, false,
1059             "enable lazy compilation for asm-wasm modules")
1060 DEFINE_IMPLICATION(validate_asm, asm_wasm_lazy_compilation)
1061 DEFINE_BOOL(wasm_lazy_compilation, false,
1062             "enable lazy compilation for all wasm modules")
1063 DEFINE_DEBUG_BOOL(trace_wasm_lazy_compilation, false,
1064                   "trace lazy compilation of wasm functions")
1065 DEFINE_BOOL(wasm_lazy_validation, false,
1066             "enable lazy validation for lazily compiled wasm functions")
1067 DEFINE_BOOL(wasm_simd_ssse3_codegen, false, "allow wasm SIMD SSSE3 codegen")
1068 
1069 DEFINE_BOOL(wasm_code_gc, true, "enable garbage collection of wasm code")
1070 DEFINE_BOOL(trace_wasm_code_gc, false, "trace garbage collection of wasm code")
1071 DEFINE_BOOL(stress_wasm_code_gc, false,
1072             "stress test garbage collection of wasm code")
1073 DEFINE_INT(wasm_max_initial_code_space_reservation, 0,
1074            "maximum size of the initial wasm code space reservation (in MB)")
1075 
1076 DEFINE_BOOL(experimental_wasm_allow_huge_modules, false,
1077             "allow wasm modules bigger than 1GB, but below ~2GB")
1078 
1079 DEFINE_BOOL(trace_wasm, false, "trace wasm function calls")
1080 
1081 // Flags for Wasm GDB remote debugging.
1082 #ifdef V8_ENABLE_WASM_GDB_REMOTE_DEBUGGING
1083 #define DEFAULT_WASM_GDB_REMOTE_PORT 8765
1084 DEFINE_BOOL(wasm_gdb_remote, false,
1085             "enable GDB-remote for WebAssembly debugging")
1086 DEFINE_NEG_IMPLICATION(wasm_gdb_remote, wasm_tier_up)
1087 DEFINE_INT(wasm_gdb_remote_port, DEFAULT_WASM_GDB_REMOTE_PORT,
1088            "default port for WebAssembly debugging with LLDB.")
1089 DEFINE_BOOL(wasm_pause_waiting_for_debugger, false,
1090             "pause at the first Webassembly instruction waiting for a debugger "
1091             "to attach")
1092 DEFINE_BOOL(trace_wasm_gdb_remote, false, "trace Webassembly GDB-remote server")
1093 #endif  // V8_ENABLE_WASM_GDB_REMOTE_DEBUGGING
1094 
1095 // wasm instance management
1096 DEFINE_DEBUG_BOOL(trace_wasm_instances, false,
1097                   "trace creation and collection of wasm instances")
1098 
1099 #endif  // V8_ENABLE_WEBASSEMBLY
1100 
1101 DEFINE_INT(stress_sampling_allocation_profiler, 0,
1102            "Enables sampling allocation profiler with X as a sample interval")
1103 
1104 // Garbage collections flags.
1105 DEFINE_BOOL(lazy_new_space_shrinking, false,
1106             "Enables the lazy new space shrinking strategy")
1107 DEFINE_SIZE_T(min_semi_space_size, 0,
1108               "min size of a semi-space (in MBytes), the new space consists of "
1109               "two semi-spaces")
1110 DEFINE_SIZE_T(max_semi_space_size, 0,
1111               "max size of a semi-space (in MBytes), the new space consists of "
1112               "two semi-spaces")
1113 DEFINE_INT(semi_space_growth_factor, 2, "factor by which to grow the new space")
1114 DEFINE_SIZE_T(max_old_space_size, 0, "max size of the old space (in Mbytes)")
1115 DEFINE_SIZE_T(
1116     max_heap_size, 0,
1117     "max size of the heap (in Mbytes) "
1118     "both max_semi_space_size and max_old_space_size take precedence. "
1119     "All three flags cannot be specified at the same time.")
1120 DEFINE_SIZE_T(initial_heap_size, 0, "initial size of the heap (in Mbytes)")
1121 DEFINE_BOOL(huge_max_old_generation_size, true,
1122             "Increase max size of the old space to 4 GB for x64 systems with"
1123             "the physical memory bigger than 16 GB")
1124 DEFINE_SIZE_T(initial_old_space_size, 0, "initial old space size (in Mbytes)")
1125 DEFINE_BOOL(global_gc_scheduling, true,
1126             "enable GC scheduling based on global memory")
1127 DEFINE_BOOL(gc_global, false, "always perform global GCs")
1128 DEFINE_INT(random_gc_interval, 0,
1129            "Collect garbage after random(0, X) allocations. It overrides "
1130            "gc_interval.")
1131 DEFINE_INT(gc_interval, -1, "garbage collect after <n> allocations")
1132 DEFINE_INT(retain_maps_for_n_gc, 2,
1133            "keeps maps alive for <n> old space garbage collections")
1134 DEFINE_BOOL(trace_gc, false,
1135             "print one trace line following each garbage collection")
1136 DEFINE_BOOL(trace_gc_nvp, false,
1137             "print one detailed trace line in name=value format "
1138             "after each garbage collection")
1139 DEFINE_BOOL(trace_gc_ignore_scavenger, false,
1140             "do not print trace line after scavenger collection")
1141 DEFINE_BOOL(trace_idle_notification, false,
1142             "print one trace line following each idle notification")
1143 DEFINE_BOOL(trace_idle_notification_verbose, false,
1144             "prints the heap state used by the idle notification")
1145 DEFINE_BOOL(trace_gc_verbose, false,
1146             "print more details following each garbage collection")
1147 DEFINE_IMPLICATION(trace_gc_verbose, trace_gc)
1148 DEFINE_BOOL(trace_gc_freelists, false,
1149             "prints details of each freelist before and after "
1150             "each major garbage collection")
1151 DEFINE_BOOL(trace_gc_freelists_verbose, false,
1152             "prints details of freelists of each page before and after "
1153             "each major garbage collection")
1154 DEFINE_IMPLICATION(trace_gc_freelists_verbose, trace_gc_freelists)
1155 DEFINE_BOOL(trace_evacuation_candidates, false,
1156             "Show statistics about the pages evacuation by the compaction")
1157 DEFINE_BOOL(
1158     trace_allocations_origins, false,
1159     "Show statistics about the origins of allocations. "
1160     "Combine with --no-inline-new to track allocations from generated code")
1161 DEFINE_BOOL(trace_pending_allocations, false,
1162             "trace calls to Heap::IsAllocationPending that return true")
1163 
1164 DEFINE_INT(trace_allocation_stack_interval, -1,
1165            "print stack trace after <n> free-list allocations")
1166 DEFINE_INT(trace_duplicate_threshold_kb, 0,
1167            "print duplicate objects in the heap if their size is more than "
1168            "given threshold")
1169 DEFINE_BOOL(trace_fragmentation, false, "report fragmentation for old space")
1170 DEFINE_BOOL(trace_fragmentation_verbose, false,
1171             "report fragmentation for old space (detailed)")
1172 DEFINE_BOOL(minor_mc_trace_fragmentation, false,
1173             "trace fragmentation after marking")
1174 DEFINE_BOOL(trace_evacuation, false, "report evacuation statistics")
1175 DEFINE_BOOL(trace_mutator_utilization, false,
1176             "print mutator utilization, allocation speed, gc speed")
1177 DEFINE_BOOL(incremental_marking, true, "use incremental marking")
1178 DEFINE_BOOL(incremental_marking_wrappers, true,
1179             "use incremental marking for marking wrappers")
1180 DEFINE_BOOL(incremental_marking_task, true, "use tasks for incremental marking")
1181 DEFINE_INT(incremental_marking_soft_trigger, 0,
1182            "threshold for starting incremental marking via a task in percent "
1183            "of available space: limit - size")
1184 DEFINE_INT(incremental_marking_hard_trigger, 0,
1185            "threshold for starting incremental marking immediately in percent "
1186            "of available space: limit - size")
1187 DEFINE_BOOL(trace_unmapper, false, "Trace the unmapping")
1188 DEFINE_BOOL(parallel_scavenge, true, "parallel scavenge")
1189 DEFINE_BOOL(scavenge_task, true, "schedule scavenge tasks")
1190 DEFINE_INT(scavenge_task_trigger, 80,
1191            "scavenge task trigger in percent of the current heap limit")
1192 DEFINE_BOOL(scavenge_separate_stack_scanning, false,
1193             "use a separate phase for stack scanning in scavenge")
1194 DEFINE_BOOL(trace_parallel_scavenge, false, "trace parallel scavenge")
1195 #if MUST_WRITE_PROTECT_CODE_MEMORY
1196 DEFINE_BOOL_READONLY(write_protect_code_memory, true,
1197                      "write protect code memory")
1198 #else
1199 DEFINE_BOOL(write_protect_code_memory, true, "write protect code memory")
1200 #endif
1201 #if defined(V8_ATOMIC_MARKING_STATE) && defined(V8_ATOMIC_OBJECT_FIELD_WRITES)
1202 #define V8_CONCURRENT_MARKING_BOOL true
1203 #else
1204 #define V8_CONCURRENT_MARKING_BOOL false
1205 #endif
1206 DEFINE_BOOL(concurrent_marking, V8_CONCURRENT_MARKING_BOOL,
1207             "use concurrent marking")
1208 DEFINE_BOOL(concurrent_array_buffer_sweeping, true,
1209             "concurrently sweep array buffers")
1210 DEFINE_BOOL(stress_concurrent_allocation, false,
1211             "start background threads that allocate memory")
1212 DEFINE_BOOL(parallel_marking, V8_CONCURRENT_MARKING_BOOL,
1213             "use parallel marking in atomic pause")
1214 DEFINE_INT(ephemeron_fixpoint_iterations, 10,
1215            "number of fixpoint iterations it takes to switch to linear "
1216            "ephemeron algorithm")
1217 DEFINE_BOOL(trace_concurrent_marking, false, "trace concurrent marking")
1218 DEFINE_BOOL(concurrent_sweeping, true, "use concurrent sweeping")
1219 DEFINE_BOOL(parallel_compaction, true, "use parallel compaction")
1220 DEFINE_BOOL(parallel_pointer_update, true,
1221             "use parallel pointer update during compaction")
1222 DEFINE_BOOL(detect_ineffective_gcs_near_heap_limit, true,
1223             "trigger out-of-memory failure to avoid GC storm near heap limit")
1224 DEFINE_BOOL(trace_incremental_marking, false,
1225             "trace progress of the incremental marking")
1226 DEFINE_BOOL(trace_stress_marking, false, "trace stress marking progress")
1227 DEFINE_BOOL(trace_stress_scavenge, false, "trace stress scavenge progress")
1228 DEFINE_BOOL(track_gc_object_stats, false,
1229             "track object counts and memory usage")
1230 DEFINE_BOOL(trace_gc_object_stats, false,
1231             "trace object counts and memory usage")
1232 DEFINE_BOOL(trace_zone_stats, false, "trace zone memory usage")
1233 DEFINE_GENERIC_IMPLICATION(
1234     trace_zone_stats,
1235     TracingFlags::zone_stats.store(
1236         v8::tracing::TracingCategoryObserver::ENABLED_BY_NATIVE))
1237 DEFINE_SIZE_T(
1238     zone_stats_tolerance, 1 * MB,
1239     "report a tick only when allocated zone memory changes by this amount")
1240 DEFINE_BOOL(trace_zone_type_stats, false, "trace per-type zone memory usage")
1241 DEFINE_GENERIC_IMPLICATION(
1242     trace_zone_type_stats,
1243     TracingFlags::zone_stats.store(
1244         v8::tracing::TracingCategoryObserver::ENABLED_BY_NATIVE))
1245 DEFINE_BOOL(track_retaining_path, false,
1246             "enable support for tracking retaining path")
1247 DEFINE_DEBUG_BOOL(trace_backing_store, false, "trace backing store events")
1248 DEFINE_INT(gc_stats, 0, "Used by tracing internally to enable gc statistics")
1249 DEFINE_IMPLICATION(trace_gc_object_stats, track_gc_object_stats)
1250 DEFINE_GENERIC_IMPLICATION(
1251     track_gc_object_stats,
1252     TracingFlags::gc_stats.store(
1253         v8::tracing::TracingCategoryObserver::ENABLED_BY_NATIVE))
1254 DEFINE_GENERIC_IMPLICATION(
1255     trace_gc_object_stats,
1256     TracingFlags::gc_stats.store(
1257         v8::tracing::TracingCategoryObserver::ENABLED_BY_NATIVE))
1258 DEFINE_NEG_IMPLICATION(trace_gc_object_stats, incremental_marking)
1259 DEFINE_NEG_IMPLICATION(track_retaining_path, parallel_marking)
1260 DEFINE_NEG_IMPLICATION(track_retaining_path, concurrent_marking)
1261 DEFINE_BOOL(track_detached_contexts, true,
1262             "track native contexts that are expected to be garbage collected")
1263 DEFINE_BOOL(trace_detached_contexts, false,
1264             "trace native contexts that are expected to be garbage collected")
1265 DEFINE_IMPLICATION(trace_detached_contexts, track_detached_contexts)
1266 #ifdef VERIFY_HEAP
1267 DEFINE_BOOL(verify_heap, false, "verify heap pointers before and after GC")
1268 DEFINE_BOOL(verify_heap_skip_remembered_set, false,
1269             "disable remembered set verification")
1270 #endif
1271 DEFINE_BOOL(move_object_start, true, "enable moving of object starts")
1272 DEFINE_BOOL(memory_reducer, true, "use memory reducer")
1273 DEFINE_BOOL(memory_reducer_for_small_heaps, true,
1274             "use memory reducer for small heaps")
1275 DEFINE_INT(heap_growing_percent, 0,
1276            "specifies heap growing factor as (1 + heap_growing_percent/100)")
1277 DEFINE_INT(v8_os_page_size, 0, "override OS page size (in KBytes)")
1278 DEFINE_BOOL(allocation_buffer_parking, true, "allocation buffer parking")
1279 DEFINE_BOOL(always_compact, false, "Perform compaction on every full GC")
1280 DEFINE_BOOL(never_compact, false,
1281             "Never perform compaction on full GC - testing only")
1282 DEFINE_BOOL(compact_code_space, true, "Compact code space on full collections")
1283 DEFINE_BOOL(flush_baseline_code, false,
1284             "flush of baseline code when it has not been executed recently")
1285 DEFINE_BOOL(flush_bytecode, true,
1286             "flush of bytecode when it has not been executed recently")
1287 DEFINE_BOOL(stress_flush_code, false, "stress code flushing")
1288 DEFINE_BOOL(trace_flush_bytecode, false, "trace bytecode flushing")
1289 DEFINE_BOOL(use_marking_progress_bar, true,
1290             "Use a progress bar to scan large objects in increments when "
1291             "incremental marking is active.")
1292 DEFINE_BOOL(stress_per_context_marking_worklist, false,
1293             "Use per-context worklist for marking")
1294 DEFINE_BOOL(force_marking_deque_overflows, false,
1295             "force overflows of marking deque by reducing it's size "
1296             "to 64 words")
1297 DEFINE_BOOL(stress_compaction, false,
1298             "stress the GC compactor to flush out bugs (implies "
1299             "--force_marking_deque_overflows)")
1300 DEFINE_BOOL(stress_compaction_random, false,
1301             "Stress GC compaction by selecting random percent of pages as "
1302             "evacuation candidates. It overrides stress_compaction.")
1303 DEFINE_BOOL(stress_incremental_marking, false,
1304             "force incremental marking for small heaps and run it more often")
1305 
1306 DEFINE_BOOL(fuzzer_gc_analysis, false,
1307             "prints number of allocations and enables analysis mode for gc "
1308             "fuzz testing, e.g. --stress-marking, --stress-scavenge")
1309 DEFINE_INT(stress_marking, 0,
1310            "force marking at random points between 0 and X (inclusive) percent "
1311            "of the regular marking start limit")
1312 DEFINE_INT(stress_scavenge, 0,
1313            "force scavenge at random points between 0 and X (inclusive) "
1314            "percent of the new space capacity")
1315 DEFINE_VALUE_IMPLICATION(fuzzer_gc_analysis, stress_marking, 99)
1316 DEFINE_VALUE_IMPLICATION(fuzzer_gc_analysis, stress_scavenge, 99)
1317 DEFINE_BOOL(
1318     reclaim_unmodified_wrappers, true,
1319     "reclaim otherwise unreachable unmodified wrapper objects when possible")
1320 
1321 // These flags will be removed after experiments. Do not rely on them.
1322 DEFINE_BOOL(gc_experiment_less_compaction, false,
1323             "less compaction in non-memory reducing mode")
1324 
1325 DEFINE_BOOL(disable_abortjs, false, "disables AbortJS runtime function")
1326 
1327 DEFINE_BOOL(randomize_all_allocations, false,
1328             "randomize virtual memory reservations by ignoring any hints "
1329             "passed when allocating pages")
1330 
1331 DEFINE_BOOL(manual_evacuation_candidates_selection, false,
1332             "Test mode only flag. It allows an unit test to select evacuation "
1333             "candidates pages (requires --stress_compaction).")
1334 DEFINE_BOOL(fast_promotion_new_space, false,
1335             "fast promote new space on high survival rates")
1336 
1337 DEFINE_BOOL(clear_free_memory, false, "initialize free memory with 0")
1338 
1339 DEFINE_BOOL(crash_on_aborted_evacuation, false,
1340             "crash when evacuation of page fails")
1341 
1342 DEFINE_BOOL_READONLY(
1343     young_generation_large_objects, true,
1344     "allocates large objects by default in the young generation large "
1345     "object space")
1346 
1347 // assembler-ia32.cc / assembler-arm.cc / assembler-arm64.cc / assembler-x64.cc
1348 #ifdef V8_ENABLE_DEBUG_CODE
1349 DEFINE_BOOL(debug_code, DEBUG_BOOL,
1350             "generate extra code (assertions) for debugging")
1351 #else
1352 DEFINE_BOOL_READONLY(debug_code, false, "")
1353 #endif
1354 #ifdef V8_CODE_COMMENTS
1355 DEFINE_BOOL(code_comments, false,
1356             "emit comments in code disassembly; for more readable source "
1357             "positions you should add --no-concurrent_recompilation")
1358 #else
1359 DEFINE_BOOL_READONLY(code_comments, false, "")
1360 #endif
1361 DEFINE_BOOL(enable_sse3, true, "enable use of SSE3 instructions if available")
1362 DEFINE_BOOL(enable_ssse3, true, "enable use of SSSE3 instructions if available")
1363 DEFINE_BOOL(enable_sse4_1, true,
1364             "enable use of SSE4.1 instructions if available")
1365 DEFINE_BOOL(enable_sse4_2, true,
1366             "enable use of SSE4.2 instructions if available")
1367 DEFINE_BOOL(enable_sahf, true,
1368             "enable use of SAHF instruction if available (X64 only)")
1369 DEFINE_BOOL(enable_avx, true, "enable use of AVX instructions if available")
1370 DEFINE_BOOL(enable_avx2, true, "enable use of AVX2 instructions if available")
1371 DEFINE_BOOL(enable_fma3, true, "enable use of FMA3 instructions if available")
1372 DEFINE_BOOL(enable_bmi1, true, "enable use of BMI1 instructions if available")
1373 DEFINE_BOOL(enable_bmi2, true, "enable use of BMI2 instructions if available")
1374 DEFINE_BOOL(enable_lzcnt, true, "enable use of LZCNT instruction if available")
1375 DEFINE_BOOL(enable_popcnt, true,
1376             "enable use of POPCNT instruction if available")
1377 DEFINE_STRING(arm_arch, ARM_ARCH_DEFAULT,
1378               "generate instructions for the selected ARM architecture if "
1379               "available: armv6, armv7, armv7+sudiv or armv8")
1380 DEFINE_BOOL(force_long_branches, false,
1381             "force all emitted branches to be in long mode (MIPS/PPC only)")
1382 DEFINE_STRING(mcpu, "auto", "enable optimization for specific cpu")
1383 DEFINE_BOOL(partial_constant_pool, true,
1384             "enable use of partial constant pools (X64 only)")
1385 DEFINE_STRING(sim_arm64_optional_features, "none",
1386               "enable optional features on the simulator for testing: none or "
1387               "all")
1388 
1389 #if defined(V8_TARGET_ARCH_RISCV64)
1390 DEFINE_BOOL(riscv_trap_to_simulator_debugger, false,
1391             "enable simulator trap to debugger")
1392 DEFINE_BOOL(riscv_debug, false, "enable debug prints")
1393 
1394 DEFINE_BOOL(riscv_constant_pool, true,
1395             "enable constant pool (RISCV only)")
1396 
1397 DEFINE_BOOL(riscv_c_extension, false,
1398             "enable compressed extension isa variant (RISCV only)")
1399 #endif
1400 
1401 // Controlling source positions for Torque/CSA code.
1402 DEFINE_BOOL(enable_source_at_csa_bind, false,
1403             "Include source information in the binary at CSA bind locations.")
1404 
1405 // Deprecated ARM flags (replaced by arm_arch).
1406 DEFINE_MAYBE_BOOL(enable_armv7, "deprecated (use --arm_arch instead)")
1407 DEFINE_MAYBE_BOOL(enable_vfp3, "deprecated (use --arm_arch instead)")
1408 DEFINE_MAYBE_BOOL(enable_32dregs, "deprecated (use --arm_arch instead)")
1409 DEFINE_MAYBE_BOOL(enable_neon, "deprecated (use --arm_arch instead)")
1410 DEFINE_MAYBE_BOOL(enable_sudiv, "deprecated (use --arm_arch instead)")
1411 DEFINE_MAYBE_BOOL(enable_armv8, "deprecated (use --arm_arch instead)")
1412 
1413 // regexp-macro-assembler-*.cc
1414 DEFINE_BOOL(enable_regexp_unaligned_accesses, true,
1415             "enable unaligned accesses for the regexp engine")
1416 
1417 // api.cc
1418 DEFINE_BOOL(script_streaming, true, "enable parsing on background")
1419 DEFINE_BOOL(stress_background_compile, false,
1420             "stress test parsing on background")
1421 DEFINE_BOOL(
1422     finalize_streaming_on_background, true,
1423     "perform the script streaming finalization on the background thread")
1424 DEFINE_BOOL(concurrent_cache_deserialization, true,
1425             "enable deserializing code caches on background")
1426 // TODO(leszeks): Parallel compile tasks currently don't support off-thread
1427 // finalization.
1428 DEFINE_NEG_IMPLICATION(parallel_compile_tasks, finalize_streaming_on_background)
1429 DEFINE_BOOL(disable_old_api_accessors, false,
1430             "Disable old-style API accessors whose setters trigger through the "
1431             "prototype chain")
1432 DEFINE_BOOL(
1433     embedder_instance_types, false,
1434     "enable type checks based on instance types provided by the embedder")
1435 
1436 // bootstrapper.cc
1437 DEFINE_BOOL(expose_gc, false, "expose gc extension")
1438 DEFINE_STRING(expose_gc_as, nullptr,
1439               "expose gc extension under the specified name")
1440 DEFINE_IMPLICATION(expose_gc_as, expose_gc)
1441 DEFINE_BOOL(expose_externalize_string, false,
1442             "expose externalize string extension")
1443 DEFINE_BOOL(expose_trigger_failure, false, "expose trigger-failure extension")
1444 DEFINE_BOOL(expose_ignition_statistics, false,
1445             "expose ignition-statistics extension (requires building with "
1446             "v8_enable_ignition_dispatch_counting)")
1447 DEFINE_INT(stack_trace_limit, 10, "number of stack frames to capture")
1448 DEFINE_BOOL(builtins_in_stack_traces, false,
1449             "show built-in functions in stack traces")
1450 DEFINE_BOOL(experimental_stack_trace_frames, false,
1451             "enable experimental frames (API/Builtins) and stack trace layout")
1452 DEFINE_BOOL(disallow_code_generation_from_strings, false,
1453             "disallow eval and friends")
1454 DEFINE_BOOL(expose_async_hooks, false, "expose async_hooks object")
1455 DEFINE_STRING(expose_cputracemark_as, nullptr,
1456               "expose cputracemark extension under the specified name")
1457 #ifdef ENABLE_VTUNE_TRACEMARK
1458 DEFINE_BOOL(enable_vtune_domain_support, true, "enable vtune domain support")
1459 #endif  // ENABLE_VTUNE_TRACEMARK
1460 
1461 // builtins.cc
1462 DEFINE_BOOL(allow_unsafe_function_constructor, false,
1463             "allow invoking the function constructor without security checks")
1464 DEFINE_BOOL(force_slow_path, false, "always take the slow path for builtins")
1465 DEFINE_BOOL(test_small_max_function_context_stub_size, false,
1466             "enable testing the function context size overflow path "
1467             "by making the maximum size smaller")
1468 
1469 DEFINE_BOOL(inline_new, true, "use fast inline allocation")
1470 DEFINE_NEG_NEG_IMPLICATION(inline_new, turbo_allocation_folding)
1471 
1472 // bytecode-generator.cc
1473 DEFINE_INT(switch_table_spread_threshold, 3,
1474            "allow the jump table used for switch statements to span a range "
1475            "of integers roughly equal to this number times the number of "
1476            "clauses in the switch")
1477 DEFINE_INT(switch_table_min_cases, 6,
1478            "the number of Smi integer cases present in the switch statement "
1479            "before using the jump table optimization")
1480 
1481 // codegen-ia32.cc / codegen-arm.cc
1482 DEFINE_BOOL(trace, false, "trace javascript function calls")
1483 
1484 // codegen.cc
1485 DEFINE_BOOL(lazy, true, "use lazy compilation")
1486 DEFINE_BOOL(lazy_eval, true, "use lazy compilation during eval")
1487 DEFINE_BOOL(lazy_streaming, true,
1488             "use lazy compilation during streaming compilation")
1489 DEFINE_BOOL(max_lazy, false, "ignore eager compilation hints")
1490 DEFINE_IMPLICATION(max_lazy, lazy)
1491 DEFINE_BOOL(trace_opt, false, "trace optimized compilation")
1492 DEFINE_BOOL(trace_opt_verbose, false,
1493             "extra verbose optimized compilation tracing")
1494 DEFINE_IMPLICATION(trace_opt_verbose, trace_opt)
1495 DEFINE_BOOL(trace_opt_stats, false, "trace optimized compilation statistics")
1496 DEFINE_BOOL(trace_deopt, false, "trace deoptimization")
1497 DEFINE_BOOL(log_deopt, false, "log deoptimization")
1498 DEFINE_BOOL(trace_deopt_verbose, false, "extra verbose deoptimization tracing")
1499 DEFINE_IMPLICATION(trace_deopt_verbose, trace_deopt)
1500 DEFINE_BOOL(trace_file_names, false,
1501             "include file names in trace-opt/trace-deopt output")
1502 DEFINE_BOOL(always_opt, false, "always try to optimize functions")
1503 DEFINE_IMPLICATION(always_opt, opt)
1504 DEFINE_BOOL(always_osr, false, "always try to OSR functions")
1505 DEFINE_BOOL(prepare_always_opt, false, "prepare for turning on always opt")
1506 
1507 DEFINE_BOOL(trace_serializer, false, "print code serializer trace")
1508 #ifdef DEBUG
1509 DEFINE_BOOL(external_reference_stats, false,
1510             "print statistics on external references used during serialization")
1511 #endif  // DEBUG
1512 
1513 // compilation-cache.cc
1514 DEFINE_BOOL(compilation_cache, true, "enable compilation cache")
1515 
1516 DEFINE_BOOL(cache_prototype_transitions, true, "cache prototype transitions")
1517 
1518 // lazy-compile-dispatcher.cc
1519 DEFINE_BOOL(parallel_compile_tasks, false, "enable parallel compile tasks")
1520 DEFINE_BOOL(lazy_compile_dispatcher, false, "enable compiler dispatcher")
1521 DEFINE_IMPLICATION(parallel_compile_tasks, lazy_compile_dispatcher)
1522 DEFINE_BOOL(trace_compiler_dispatcher, false,
1523             "trace compiler dispatcher activity")
1524 
1525 // cpu-profiler.cc
1526 DEFINE_INT(cpu_profiler_sampling_interval, 1000,
1527            "CPU profiler sampling interval in microseconds")
1528 
1529 // debugger
1530 DEFINE_BOOL(
1531     trace_side_effect_free_debug_evaluate, false,
1532     "print debug messages for side-effect-free debug-evaluate for testing")
1533 DEFINE_BOOL(hard_abort, true, "abort by crashing")
1534 
1535 // disassembler
1536 DEFINE_BOOL(log_colour, ENABLE_LOG_COLOUR,
1537             "When logging, try to use coloured output.")
1538 
1539 // inspector
1540 DEFINE_BOOL(expose_inspector_scripts, false,
1541             "expose injected-script-source.js for debugging")
1542 
1543 // execution.cc
1544 DEFINE_INT(stack_size, V8_DEFAULT_STACK_SIZE_KB,
1545            "default size of stack region v8 is allowed to use (in kBytes)")
1546 
1547 // frames.cc
1548 DEFINE_INT(max_stack_trace_source_length, 300,
1549            "maximum length of function source code printed in a stack trace.")
1550 
1551 // execution.cc, messages.cc
1552 DEFINE_BOOL(clear_exceptions_on_js_entry, false,
1553             "clear pending exceptions when entering JavaScript")
1554 
1555 // counters.cc
1556 DEFINE_INT(histogram_interval, 600000,
1557            "time interval in ms for aggregating memory histograms")
1558 
1559 // heap-snapshot-generator.cc
1560 DEFINE_BOOL(heap_profiler_trace_objects, false,
1561             "Dump heap object allocations/movements/size_updates")
1562 DEFINE_BOOL(heap_profiler_use_embedder_graph, true,
1563             "Use the new EmbedderGraph API to get embedder nodes")
1564 DEFINE_INT(heap_snapshot_string_limit, 1024,
1565            "truncate strings to this length in the heap snapshot")
1566 DEFINE_BOOL(heap_profiler_show_hidden_objects, false,
1567             "use 'native' rather than 'hidden' node type in snapshot")
1568 
1569 // sampling-heap-profiler.cc
1570 DEFINE_BOOL(sampling_heap_profiler_suppress_randomness, false,
1571             "Use constant sample intervals to eliminate test flakiness")
1572 
1573 // v8.cc
1574 DEFINE_BOOL(use_idle_notification, true,
1575             "Use idle notification to reduce memory footprint.")
1576 // ic.cc
1577 DEFINE_BOOL(log_ic, false,
1578             "Log inline cache state transitions for tools/ic-processor")
1579 DEFINE_IMPLICATION(log_ic, log_code)
1580 DEFINE_GENERIC_IMPLICATION(
1581     log_ic, TracingFlags::ic_stats.store(
1582                 v8::tracing::TracingCategoryObserver::ENABLED_BY_NATIVE))
1583 DEFINE_BOOL_READONLY(fast_map_update, false,
1584                      "enable fast map update by caching the migration target")
1585 DEFINE_INT(max_valid_polymorphic_map_count, 4,
1586            "maximum number of valid maps to track in POLYMORPHIC state")
1587 
1588 DEFINE_BOOL(native_code_counters, DEBUG_BOOL,
1589             "generate extra code for manipulating stats counters")
1590 
1591 DEFINE_BOOL(super_ic, true, "use an IC for super property loads")
1592 
1593 DEFINE_BOOL(enable_mega_dom_ic, false, "use MegaDOM IC state for API objects")
1594 
1595 // objects.cc
1596 DEFINE_BOOL(trace_prototype_users, false,
1597             "Trace updates to prototype user tracking")
1598 DEFINE_BOOL(trace_for_in_enumerate, false, "Trace for-in enumerate slow-paths")
1599 DEFINE_BOOL(log_maps, false, "Log map creation")
1600 DEFINE_BOOL(log_maps_details, true, "Also log map details")
1601 DEFINE_IMPLICATION(log_maps, log_code)
1602 
1603 // parser.cc
1604 DEFINE_BOOL(allow_natives_syntax, false, "allow natives syntax")
1605 DEFINE_BOOL(allow_natives_for_differential_fuzzing, false,
1606             "allow only natives explicitly allowlisted for differential "
1607             "fuzzers")
1608 DEFINE_IMPLICATION(allow_natives_for_differential_fuzzing, allow_natives_syntax)
1609 DEFINE_IMPLICATION(allow_natives_for_differential_fuzzing, fuzzing)
1610 DEFINE_BOOL(parse_only, false, "only parse the sources")
1611 
1612 // simulator-arm.cc, simulator-arm64.cc and simulator-mips.cc
1613 #ifdef USE_SIMULATOR
1614 DEFINE_BOOL(trace_sim, false, "Trace simulator execution")
1615 DEFINE_BOOL(debug_sim, false, "Enable debugging the simulator")
1616 DEFINE_BOOL(check_icache, false,
1617             "Check icache flushes in ARM and MIPS simulator")
1618 DEFINE_INT(stop_sim_at, 0, "Simulator stop after x number of instructions")
1619 #if defined(V8_TARGET_ARCH_ARM64) || defined(V8_TARGET_ARCH_MIPS64) ||  \
1620     defined(V8_TARGET_ARCH_PPC64) || defined(V8_TARGET_ARCH_RISCV64) || \
1621     defined(V8_TARGET_ARCH_LOONG64)
1622 DEFINE_INT(sim_stack_alignment, 16,
1623            "Stack alignment in bytes in simulator. This must be a power of two "
1624            "and it must be at least 16. 16 is default.")
1625 #else
1626 DEFINE_INT(sim_stack_alignment, 8,
1627            "Stack alingment in bytes in simulator (4 or 8, 8 is default)")
1628 #endif
1629 DEFINE_INT(sim_stack_size, 2 * MB / KB,
1630            "Stack size of the ARM64, MIPS, MIPS64 and PPC64 simulator "
1631            "in kBytes (default is 2 MB)")
1632 DEFINE_BOOL(trace_sim_messages, false,
1633             "Trace simulator debug messages. Implied by --trace-sim.")
1634 #endif  // USE_SIMULATOR
1635 
1636 #if defined V8_TARGET_ARCH_ARM64
1637 // pointer-auth-arm64.cc
1638 DEFINE_BOOL(sim_abort_on_bad_auth, true,
1639             "Stop execution when a pointer authentication fails in the "
1640             "ARM64 simulator.")
1641 #endif
1642 
1643 // isolate.cc
1644 DEFINE_BOOL(async_stack_traces, true,
1645             "include async stack traces in Error.stack")
1646 DEFINE_BOOL(stack_trace_on_illegal, false,
1647             "print stack trace when an illegal exception is thrown")
1648 DEFINE_BOOL(abort_on_uncaught_exception, false,
1649             "abort program (dump core) when an uncaught exception is thrown")
1650 DEFINE_BOOL(correctness_fuzzer_suppressions, false,
1651             "Suppress certain unspecified behaviors to ease correctness "
1652             "fuzzing: Abort program when the stack overflows or a string "
1653             "exceeds maximum length (as opposed to throwing RangeError). "
1654             "Use a fixed suppression string for error messages.")
1655 DEFINE_BOOL(randomize_hashes, true,
1656             "randomize hashes to avoid predictable hash collisions "
1657             "(with snapshots this option cannot override the baked-in seed)")
1658 DEFINE_BOOL(rehash_snapshot, true,
1659             "rehash strings from the snapshot to override the baked-in seed")
1660 DEFINE_UINT64(hash_seed, 0,
1661               "Fixed seed to use to hash property keys (0 means random)"
1662               "(with snapshots this option cannot override the baked-in seed)")
1663 DEFINE_INT(random_seed, 0,
1664            "Default seed for initializing random generator "
1665            "(0, the default, means to use system random).")
1666 DEFINE_INT(fuzzer_random_seed, 0,
1667            "Default seed for initializing fuzzer random generator "
1668            "(0, the default, means to use v8's random number generator seed).")
1669 DEFINE_BOOL(trace_rail, false, "trace RAIL mode")
1670 DEFINE_BOOL(print_all_exceptions, false,
1671             "print exception object and stack trace on each thrown exception")
1672 DEFINE_BOOL(
1673     detailed_error_stack_trace, false,
1674     "includes arguments for each function call in the error stack frames array")
1675 DEFINE_BOOL(adjust_os_scheduling_parameters, true,
1676             "adjust OS specific scheduling params for the isolate")
1677 DEFINE_BOOL(experimental_flush_embedded_blob_icache, true,
1678             "Used in an experiment to evaluate icache flushing on certain CPUs")
1679 
1680 // Flags for short builtin calls feature
1681 #undef FLAG
1682 #if V8_SHORT_BUILTIN_CALLS
1683 #define FLAG FLAG_FULL
1684 #define V8_SHORT_BUILTIN_CALLS_BOOL true
1685 #else
1686 #define FLAG FLAG_READONLY
1687 #define V8_SHORT_BUILTIN_CALLS_BOOL false
1688 #endif
1689 
1690 DEFINE_BOOL(short_builtin_calls, V8_SHORT_BUILTIN_CALLS_BOOL,
1691             "Put embedded builtins code into the code range for shorter "
1692             "builtin calls/jumps if system has >=4GB memory")
1693 
1694 #undef FLAG
1695 #define FLAG FLAG_FULL
1696 
1697 // runtime.cc
1698 DEFINE_BOOL(runtime_call_stats, false, "report runtime call counts and times")
1699 DEFINE_GENERIC_IMPLICATION(
1700     runtime_call_stats,
1701     TracingFlags::runtime_stats.store(
1702         v8::tracing::TracingCategoryObserver::ENABLED_BY_NATIVE))
1703 DEFINE_BOOL(rcs, false, "report runtime call counts and times")
1704 DEFINE_IMPLICATION(rcs, runtime_call_stats)
1705 
1706 DEFINE_BOOL(rcs_cpu_time, false,
1707             "report runtime times in cpu time (the default is wall time)")
1708 DEFINE_IMPLICATION(rcs_cpu_time, rcs)
1709 
1710 // snapshot-common.cc
1711 DEFINE_BOOL(skip_snapshot_checksum, false,
1712             "Skip snapshot checksum calculation when deserializing an Isolate.")
1713 DEFINE_BOOL(profile_deserialization, false,
1714             "Print the time it takes to deserialize the snapshot.")
1715 DEFINE_BOOL(serialization_statistics, false,
1716             "Collect statistics on serialized objects.")
1717 // Regexp
1718 DEFINE_BOOL(regexp_optimization, true, "generate optimized regexp code")
1719 DEFINE_BOOL(regexp_interpret_all, false, "interpret all regexp code")
1720 #ifdef V8_TARGET_BIG_ENDIAN
1721 #define REGEXP_PEEPHOLE_OPTIMIZATION_BOOL false
1722 #else
1723 #define REGEXP_PEEPHOLE_OPTIMIZATION_BOOL true
1724 #endif
1725 DEFINE_BOOL(regexp_tier_up, true,
1726             "enable regexp interpreter and tier up to the compiler after the "
1727             "number of executions set by the tier up ticks flag")
1728 DEFINE_NEG_IMPLICATION(regexp_interpret_all, regexp_tier_up)
1729 DEFINE_INT(regexp_tier_up_ticks, 1,
1730            "set the number of executions for the regexp interpreter before "
1731            "tiering-up to the compiler")
1732 DEFINE_BOOL(regexp_peephole_optimization, REGEXP_PEEPHOLE_OPTIMIZATION_BOOL,
1733             "enable peephole optimization for regexp bytecode")
1734 DEFINE_BOOL(trace_regexp_peephole_optimization, false,
1735             "trace regexp bytecode peephole optimization")
1736 DEFINE_BOOL(trace_regexp_bytecodes, false, "trace regexp bytecode execution")
1737 DEFINE_BOOL(trace_regexp_assembler, false,
1738             "trace regexp macro assembler calls.")
1739 DEFINE_BOOL(trace_regexp_parser, false, "trace regexp parsing")
1740 DEFINE_BOOL(trace_regexp_tier_up, false, "trace regexp tiering up execution")
1741 DEFINE_BOOL(trace_regexp_graph, false, "trace the regexp graph")
1742 
1743 DEFINE_BOOL(enable_experimental_regexp_engine, false,
1744             "recognize regexps with 'l' flag, run them on experimental engine")
1745 DEFINE_BOOL(default_to_experimental_regexp_engine, false,
1746             "run regexps with the experimental engine where possible")
1747 DEFINE_IMPLICATION(default_to_experimental_regexp_engine,
1748                    enable_experimental_regexp_engine)
1749 DEFINE_BOOL(trace_experimental_regexp_engine, false,
1750             "trace execution of experimental regexp engine")
1751 
1752 DEFINE_BOOL(enable_experimental_regexp_engine_on_excessive_backtracks, false,
1753             "fall back to a breadth-first regexp engine on excessive "
1754             "backtracking")
1755 DEFINE_UINT(regexp_backtracks_before_fallback, 50000,
1756             "number of backtracks during regexp execution before fall back "
1757             "to experimental engine if "
1758             "enable_experimental_regexp_engine_on_excessive_backtracks is set")
1759 
1760 // Testing flags test/cctest/test-{flags,api,serialization}.cc
1761 DEFINE_BOOL(testing_bool_flag, true, "testing_bool_flag")
1762 DEFINE_MAYBE_BOOL(testing_maybe_bool_flag, "testing_maybe_bool_flag")
1763 DEFINE_INT(testing_int_flag, 13, "testing_int_flag")
1764 DEFINE_FLOAT(testing_float_flag, 2.5, "float-flag")
1765 DEFINE_STRING(testing_string_flag, "Hello, world!", "string-flag")
1766 DEFINE_INT(testing_prng_seed, 42, "Seed used for threading test randomness")
1767 
1768 // Test flag for a check in %OptimizeFunctionOnNextCall
1769 DEFINE_BOOL(
1770     testing_d8_test_runner, false,
1771     "test runner turns on this flag to enable a check that the function was "
1772     "prepared for optimization before marking it for optimization")
1773 
1774 DEFINE_BOOL(
1775     fuzzing, false,
1776     "Fuzzers use this flag to signal that they are ... fuzzing. This causes "
1777     "intrinsics to fail silently (e.g. return undefined) on invalid usage.")
1778 
1779 // mksnapshot.cc
1780 DEFINE_STRING(embedded_src, nullptr,
1781               "Path for the generated embedded data file. (mksnapshot only)")
1782 DEFINE_STRING(
1783     embedded_variant, nullptr,
1784     "Label to disambiguate symbols in embedded data file. (mksnapshot only)")
1785 DEFINE_STRING(startup_src, nullptr,
1786               "Write V8 startup as C++ src. (mksnapshot only)")
1787 DEFINE_STRING(startup_blob, nullptr,
1788               "Write V8 startup blob file. (mksnapshot only)")
1789 DEFINE_STRING(target_arch, nullptr,
1790               "The mksnapshot target arch. (mksnapshot only)")
1791 DEFINE_STRING(target_os, nullptr, "The mksnapshot target os. (mksnapshot only)")
1792 DEFINE_BOOL(target_is_simulator, false,
1793             "Instruct mksnapshot that the target is meant to run in the "
1794             "simulator and it can generate simulator-specific instructions. "
1795             "(mksnapshot only)")
1796 DEFINE_STRING(turbo_profiling_log_file, nullptr,
1797               "Path of the input file containing basic block counters for "
1798               "builtins. (mksnapshot only)")
1799 
1800 // On some platforms, the .text section only has execute permissions.
1801 DEFINE_BOOL(text_is_readable, true,
1802             "Whether the .text section of binary can be read")
1803 DEFINE_NEG_NEG_IMPLICATION(text_is_readable, partial_constant_pool)
1804 
1805 //
1806 // Minor mark compact collector flags.
1807 //
1808 #ifdef ENABLE_MINOR_MC
1809 DEFINE_BOOL(trace_minor_mc_parallel_marking, false,
1810             "trace parallel marking for the young generation")
1811 DEFINE_BOOL(minor_mc, false, "perform young generation mark compact GCs")
1812 #else
1813 DEFINE_BOOL_READONLY(minor_mc, false,
1814                      "perform young generation mark compact GCs")
1815 #endif  // ENABLE_MINOR_MC
1816 
1817 //
1818 // Dev shell flags
1819 //
1820 
1821 DEFINE_BOOL(help, false, "Print usage message, including flags, on console")
1822 DEFINE_BOOL(print_flag_values, false, "Print all flag values of V8")
1823 
1824 DEFINE_BOOL(dump_counters, false, "Dump counters on exit")
1825 DEFINE_BOOL(slow_histograms, false,
1826             "Enable slow histograms with more overhead.")
1827 DEFINE_IMPLICATION(dump_counters, slow_histograms)
1828 
1829 DEFINE_BOOL(dump_counters_nvp, false,
1830             "Dump counters as name-value pairs on exit")
1831 DEFINE_BOOL(use_external_strings, false, "Use external strings for source code")
1832 DEFINE_STRING(map_counters, "", "Map counters to a file")
1833 DEFINE_BOOL(mock_arraybuffer_allocator, false,
1834             "Use a mock ArrayBuffer allocator for testing.")
1835 DEFINE_SIZE_T(mock_arraybuffer_allocator_limit, 0,
1836               "Memory limit for mock ArrayBuffer allocator used to simulate "
1837               "OOM for testing.")
1838 #if MULTI_MAPPED_ALLOCATOR_AVAILABLE
1839 DEFINE_BOOL(multi_mapped_mock_allocator, false,
1840             "Use a multi-mapped mock ArrayBuffer allocator for testing.")
1841 #endif
1842 
1843 //
1844 // GDB JIT integration flags.
1845 //
1846 #undef FLAG
1847 #ifdef ENABLE_GDB_JIT_INTERFACE
1848 #define FLAG FLAG_FULL
1849 #else
1850 #define FLAG FLAG_READONLY
1851 #endif
1852 
1853 DEFINE_BOOL(gdbjit, false, "enable GDBJIT interface")
1854 DEFINE_BOOL(gdbjit_full, false, "enable GDBJIT interface for all code objects")
1855 DEFINE_BOOL(gdbjit_dump, false, "dump elf objects with debug info to disk")
1856 DEFINE_STRING(gdbjit_dump_filter, "",
1857               "dump only objects containing this substring")
1858 
1859 #ifdef ENABLE_GDB_JIT_INTERFACE
1860 DEFINE_IMPLICATION(gdbjit_full, gdbjit)
1861 DEFINE_IMPLICATION(gdbjit_dump, gdbjit)
1862 #endif
1863 DEFINE_NEG_IMPLICATION(gdbjit, compact_code_space)
1864 
1865 //
1866 // Debug only flags
1867 //
1868 #undef FLAG
1869 #ifdef DEBUG
1870 #define FLAG FLAG_FULL
1871 #else
1872 #define FLAG FLAG_READONLY
1873 #endif
1874 
1875 // checks.cc
1876 #ifdef ENABLE_SLOW_DCHECKS
1877 DEFINE_BOOL(enable_slow_asserts, true,
1878             "enable asserts that are slow to execute")
1879 #endif
1880 
1881 // codegen-ia32.cc / codegen-arm.cc / macro-assembler-*.cc
1882 DEFINE_BOOL(print_ast, false, "print source AST")
1883 DEFINE_BOOL(trap_on_abort, false, "replace aborts by breakpoints")
1884 
1885 // compiler.cc
1886 DEFINE_BOOL(print_scopes, false, "print scopes")
1887 
1888 // contexts.cc
1889 DEFINE_BOOL(trace_contexts, false, "trace contexts operations")
1890 
1891 // heap.cc
1892 DEFINE_BOOL(gc_verbose, false, "print stuff during garbage collection")
1893 DEFINE_BOOL(code_stats, false, "report code statistics after GC")
1894 DEFINE_BOOL(print_handles, false, "report handles after GC")
1895 DEFINE_BOOL(check_handle_count, false,
1896             "Check that there are not too many handles at GC")
1897 DEFINE_BOOL(print_global_handles, false, "report global handles after GC")
1898 
1899 // TurboFan debug-only flags.
1900 DEFINE_BOOL(trace_turbo_escape, false, "enable tracing in escape analysis")
1901 
1902 // objects.cc
1903 DEFINE_BOOL(trace_module_status, false,
1904             "Trace status transitions of ECMAScript modules")
1905 DEFINE_BOOL(trace_normalization, false,
1906             "prints when objects are turned into dictionaries.")
1907 
1908 // runtime.cc
1909 DEFINE_BOOL(trace_lazy, false, "trace lazy compilation")
1910 
1911 // spaces.cc
1912 DEFINE_BOOL(trace_isolates, false, "trace isolate state changes")
1913 
1914 // Regexp
1915 DEFINE_BOOL(regexp_possessive_quantifier, false,
1916             "enable possessive quantifier syntax for testing")
1917 
1918 // Debugger
1919 DEFINE_BOOL(print_break_location, false, "print source location on debug break")
1920 
1921 //
1922 // Logging and profiling flags
1923 //
1924 // Logging flag dependencies are are also set separately in
1925 // V8::InitializeOncePerProcessImpl. Please add your flag to the log_all_flags
1926 // list in v8.cc to properly set FLAG_log and automatically enable it with
1927 // --log-all.
1928 #undef FLAG
1929 #define FLAG FLAG_FULL
1930 
1931 // log.cc
1932 DEFINE_STRING(logfile, "v8.log",
1933               "Specify the name of the log file, use '-' for console, '+' for "
1934               "a temporary file.")
1935 DEFINE_BOOL(logfile_per_isolate, true, "Separate log files for each isolate.")
1936 
1937 DEFINE_BOOL(log, false,
1938             "Minimal logging (no API, code, GC, suspect, or handles samples).")
1939 DEFINE_BOOL(log_all, false, "Log all events to the log file.")
1940 
1941 DEFINE_BOOL(log_api, false, "Log API events to the log file.")
1942 DEFINE_BOOL(log_code, false,
1943             "Log code events to the log file without profiling.")
1944 DEFINE_BOOL(log_code_disassemble, false,
1945             "Log all disassembled code to the log file.")
1946 DEFINE_IMPLICATION(log_code_disassemble, log_code)
1947 DEFINE_BOOL(log_handles, false, "Log global handle events.")
1948 DEFINE_BOOL(log_suspect, false, "Log suspect operations.")
1949 DEFINE_BOOL(log_source_code, false, "Log source code.")
1950 DEFINE_BOOL(log_function_events, false,
1951             "Log function events "
1952             "(parse, compile, execute) separately.")
1953 
1954 DEFINE_BOOL(detailed_line_info, false,
1955             "Always generate detailed line information for CPU profiling.")
1956 
1957 #if defined(ANDROID)
1958 // Phones and tablets have processors that are much slower than desktop
1959 // and laptop computers for which current heuristics are tuned.
1960 #define DEFAULT_PROF_SAMPLING_INTERVAL 5000
1961 #else
1962 #define DEFAULT_PROF_SAMPLING_INTERVAL 1000
1963 #endif
1964 DEFINE_INT(prof_sampling_interval, DEFAULT_PROF_SAMPLING_INTERVAL,
1965            "Interval for --prof samples (in microseconds).")
1966 #undef DEFAULT_PROF_SAMPLING_INTERVAL
1967 
1968 DEFINE_BOOL(prof_cpp, false, "Like --prof, but ignore generated code.")
1969 DEFINE_BOOL(prof_browser_mode, true,
1970             "Used with --prof, turns on browser-compatible mode for profiling.")
1971 
1972 DEFINE_BOOL(prof, false,
1973             "Log statistical profiling information (implies --log-code).")
1974 DEFINE_IMPLICATION(prof, prof_cpp)
1975 DEFINE_IMPLICATION(prof, log_code)
1976 
1977 DEFINE_BOOL(ll_prof, false, "Enable low-level linux profiler.")
1978 
1979 #if V8_OS_LINUX
1980 #define DEFINE_PERF_PROF_BOOL(nam, cmt) DEFINE_BOOL(nam, false, cmt)
1981 #define DEFINE_PERF_PROF_IMPLICATION DEFINE_IMPLICATION
1982 #else
1983 #define DEFINE_PERF_PROF_BOOL(nam, cmt) DEFINE_BOOL_READONLY(nam, false, cmt)
1984 #define DEFINE_PERF_PROF_IMPLICATION(...)
1985 #endif
1986 
1987 DEFINE_PERF_PROF_BOOL(perf_basic_prof,
1988                       "Enable perf linux profiler (basic support).")
1989 DEFINE_NEG_IMPLICATION(perf_basic_prof, compact_code_space)
1990 DEFINE_PERF_PROF_BOOL(
1991     perf_basic_prof_only_functions,
1992     "Only report function code ranges to perf (i.e. no stubs).")
1993 DEFINE_PERF_PROF_IMPLICATION(perf_basic_prof_only_functions, perf_basic_prof)
1994 DEFINE_PERF_PROF_BOOL(
1995     perf_prof, "Enable perf linux profiler (experimental annotate support).")
1996 DEFINE_PERF_PROF_BOOL(
1997     perf_prof_annotate_wasm,
1998     "Used with --perf-prof, load wasm source map and provide annotate "
1999     "support (experimental).")
2000 DEFINE_PERF_PROF_BOOL(
2001     perf_prof_delete_file,
2002     "Remove the perf file right after creating it (for testing only).")
2003 DEFINE_NEG_IMPLICATION(perf_prof, compact_code_space)
2004 // TODO(v8:8462) Remove implication once perf supports remapping.
2005 #if !MUST_WRITE_PROTECT_CODE_MEMORY
2006 DEFINE_NEG_IMPLICATION(perf_prof, write_protect_code_memory)
2007 #endif
2008 #if V8_ENABLE_WEBASSEMBLY
2009 DEFINE_NEG_IMPLICATION(perf_prof, wasm_write_protect_code_memory)
2010 #endif  // V8_ENABLE_WEBASSEMBLY
2011 
2012 // --perf-prof-unwinding-info is available only on selected architectures.
2013 #if !V8_TARGET_ARCH_ARM && !V8_TARGET_ARCH_ARM64 && !V8_TARGET_ARCH_X64 && \
2014     !V8_TARGET_ARCH_S390X && !V8_TARGET_ARCH_PPC64
2015 #undef DEFINE_PERF_PROF_BOOL
2016 #define DEFINE_PERF_PROF_BOOL(nam, cmt) DEFINE_BOOL_READONLY(nam, false, cmt)
2017 #undef DEFINE_PERF_PROF_IMPLICATION
2018 #define DEFINE_PERF_PROF_IMPLICATION(...)
2019 #endif
2020 
2021 DEFINE_PERF_PROF_BOOL(
2022     perf_prof_unwinding_info,
2023     "Enable unwinding info for perf linux profiler (experimental).")
2024 DEFINE_PERF_PROF_IMPLICATION(perf_prof, perf_prof_unwinding_info)
2025 
2026 #undef DEFINE_PERF_PROF_BOOL
2027 #undef DEFINE_PERF_PROF_IMPLICATION
2028 
2029 DEFINE_STRING(gc_fake_mmap, "/tmp/__v8_gc__",
2030               "Specify the name of the file for fake gc mmap used in ll_prof")
2031 DEFINE_BOOL(log_internal_timer_events, false, "Time internal events.")
2032 DEFINE_IMPLICATION(log_internal_timer_events, prof)
2033 
2034 DEFINE_BOOL(redirect_code_traces, false,
2035             "output deopt information and disassembly into file "
2036             "code-<pid>-<isolate id>.asm")
2037 DEFINE_STRING(redirect_code_traces_to, nullptr,
2038               "output deopt information and disassembly into the given file")
2039 
2040 DEFINE_BOOL(print_opt_source, false,
2041             "print source code of optimized and inlined functions")
2042 
2043 DEFINE_BOOL(vtune_prof_annotate_wasm, false,
2044             "Used when v8_enable_vtunejit is enabled, load wasm source map and "
2045             "provide annotate support (experimental).")
2046 
2047 DEFINE_BOOL(win64_unwinding_info, true, "Enable unwinding info for Windows/x64")
2048 
2049 #ifdef V8_TARGET_ARCH_ARM
2050 // Unsupported on arm. See https://crbug.com/v8/8713.
2051 DEFINE_BOOL_READONLY(
2052     interpreted_frames_native_stack, false,
2053     "Show interpreted frames on the native stack (useful for external "
2054     "profilers).")
2055 #else
2056 DEFINE_BOOL(interpreted_frames_native_stack, false,
2057             "Show interpreted frames on the native stack (useful for external "
2058             "profilers).")
2059 #endif
2060 
2061 DEFINE_BOOL(enable_system_instrumentation, false,
2062             "Enable platform-specific profiling.")
2063 
2064 #ifndef V8_TARGET_ARCH_ARM
2065 DEFINE_IMPLICATION(enable_system_instrumentation,
2066                    interpreted_frames_native_stack)
2067 #endif
2068 
2069 //
2070 // Disassembler only flags
2071 //
2072 #undef FLAG
2073 #ifdef ENABLE_DISASSEMBLER
2074 #define FLAG FLAG_FULL
2075 #else
2076 #define FLAG FLAG_READONLY
2077 #endif
2078 
2079 // elements.cc
2080 DEFINE_BOOL(trace_elements_transitions, false, "trace elements transitions")
2081 
2082 DEFINE_BOOL(trace_creation_allocation_sites, false,
2083             "trace the creation of allocation sites")
2084 
2085 DEFINE_BOOL(print_code, false, "print generated code")
2086 DEFINE_BOOL(print_opt_code, false, "print optimized code")
2087 DEFINE_STRING(print_opt_code_filter, "*", "filter for printing optimized code")
2088 DEFINE_BOOL(print_code_verbose, false, "print more information for code")
2089 DEFINE_BOOL(print_builtin_code, false, "print generated code for builtins")
2090 DEFINE_STRING(print_builtin_code_filter, "*",
2091               "filter for printing builtin code")
2092 DEFINE_BOOL(print_regexp_code, false, "print generated regexp code")
2093 DEFINE_BOOL(print_regexp_bytecode, false, "print generated regexp bytecode")
2094 DEFINE_BOOL(print_builtin_size, false, "print code size for builtins")
2095 
2096 #ifdef ENABLE_DISASSEMBLER
2097 DEFINE_BOOL(print_all_code, false, "enable all flags related to printing code")
2098 DEFINE_IMPLICATION(print_all_code, print_code)
2099 DEFINE_IMPLICATION(print_all_code, print_opt_code)
2100 DEFINE_IMPLICATION(print_all_code, print_code_verbose)
2101 DEFINE_IMPLICATION(print_all_code, print_builtin_code)
2102 DEFINE_IMPLICATION(print_all_code, print_regexp_code)
2103 #endif
2104 
2105 #undef FLAG
2106 #define FLAG FLAG_FULL
2107 
2108 //
2109 // Predictable mode related flags.
2110 //
2111 
2112 DEFINE_BOOL(predictable, false, "enable predictable mode")
2113 DEFINE_NEG_IMPLICATION(predictable, memory_reducer)
2114 // TODO(v8:11848): These flags were recursively implied via --single-threaded
2115 // before. Audit them, and remove any unneeded implications.
2116 DEFINE_IMPLICATION(predictable, single_threaded_gc)
2117 DEFINE_NEG_IMPLICATION(predictable, concurrent_recompilation)
2118 DEFINE_NEG_IMPLICATION(predictable, lazy_compile_dispatcher)
2119 DEFINE_NEG_IMPLICATION(predictable, stress_concurrent_inlining)
2120 
2121 DEFINE_BOOL(predictable_gc_schedule, false,
2122             "Predictable garbage collection schedule. Fixes heap growing, "
2123             "idle, and memory reducing behavior.")
2124 DEFINE_VALUE_IMPLICATION(predictable_gc_schedule, min_semi_space_size, 4)
2125 DEFINE_VALUE_IMPLICATION(predictable_gc_schedule, max_semi_space_size, 4)
2126 DEFINE_VALUE_IMPLICATION(predictable_gc_schedule, heap_growing_percent, 30)
2127 DEFINE_NEG_IMPLICATION(predictable_gc_schedule, memory_reducer)
2128 
2129 //
2130 // Threading related flags.
2131 //
2132 
2133 DEFINE_BOOL(single_threaded, false, "disable the use of background tasks")
2134 DEFINE_IMPLICATION(single_threaded, single_threaded_gc)
2135 DEFINE_NEG_IMPLICATION(single_threaded, concurrent_recompilation)
2136 DEFINE_NEG_IMPLICATION(single_threaded, lazy_compile_dispatcher)
2137 DEFINE_NEG_IMPLICATION(single_threaded, stress_concurrent_inlining)
2138 
2139 //
2140 // Parallel and concurrent GC (Orinoco) related flags.
2141 //
2142 DEFINE_BOOL(single_threaded_gc, false, "disable the use of background gc tasks")
2143 DEFINE_NEG_IMPLICATION(single_threaded_gc, concurrent_marking)
2144 DEFINE_NEG_IMPLICATION(single_threaded_gc, concurrent_sweeping)
2145 DEFINE_NEG_IMPLICATION(single_threaded_gc, parallel_compaction)
2146 DEFINE_NEG_IMPLICATION(single_threaded_gc, parallel_marking)
2147 DEFINE_NEG_IMPLICATION(single_threaded_gc, parallel_pointer_update)
2148 DEFINE_NEG_IMPLICATION(single_threaded_gc, parallel_scavenge)
2149 DEFINE_NEG_IMPLICATION(single_threaded_gc, concurrent_array_buffer_sweeping)
2150 DEFINE_NEG_IMPLICATION(single_threaded_gc, stress_concurrent_allocation)
2151 
2152 #undef FLAG
2153 
2154 #ifdef VERIFY_PREDICTABLE
2155 #define FLAG FLAG_FULL
2156 #else
2157 #define FLAG FLAG_READONLY
2158 #endif
2159 
2160 DEFINE_BOOL(verify_predictable, false,
2161             "this mode is used for checking that V8 behaves predictably")
2162 DEFINE_IMPLICATION(verify_predictable, predictable)
2163 DEFINE_INT(dump_allocations_digest_at_alloc, -1,
2164            "dump allocations digest each n-th allocation")
2165 
2166 //
2167 // Read-only flags
2168 //
2169 #undef FLAG
2170 #define FLAG FLAG_READONLY
2171 
2172 // assembler.h
2173 DEFINE_BOOL(enable_embedded_constant_pool, V8_EMBEDDED_CONSTANT_POOL,
2174             "enable use of embedded constant pools (PPC only)")
2175 
2176 // Cleanup...
2177 #undef FLAG_FULL
2178 #undef FLAG_READONLY
2179 #undef FLAG
2180 #undef FLAG_ALIAS
2181 
2182 #undef DEFINE_BOOL
2183 #undef DEFINE_MAYBE_BOOL
2184 #undef DEFINE_DEBUG_BOOL
2185 #undef DEFINE_INT
2186 #undef DEFINE_STRING
2187 #undef DEFINE_FLOAT
2188 #undef DEFINE_IMPLICATION
2189 #undef DEFINE_WEAK_IMPLICATION
2190 #undef DEFINE_NEG_IMPLICATION
2191 #undef DEFINE_NEG_VALUE_IMPLICATION
2192 #undef DEFINE_VALUE_IMPLICATION
2193 #undef DEFINE_WEAK_VALUE_IMPLICATION
2194 #undef DEFINE_GENERIC_IMPLICATION
2195 #undef DEFINE_ALIAS_BOOL
2196 #undef DEFINE_ALIAS_INT
2197 #undef DEFINE_ALIAS_STRING
2198 #undef DEFINE_ALIAS_FLOAT
2199 
2200 #undef FLAG_MODE_DECLARE
2201 #undef FLAG_MODE_DEFINE
2202 #undef FLAG_MODE_DEFINE_DEFAULTS
2203 #undef FLAG_MODE_META
2204 #undef FLAG_MODE_DEFINE_IMPLICATIONS
2205 #undef FLAG_MODE_APPLY
2206 
2207 #undef COMMA
2208