1// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2// for details. All rights reserved. Use of this source code is governed by a
3// BSD-style license that can be found in the LICENSE file.
4
5#ifndef RUNTIME_VM_FLAG_LIST_H_
6#define RUNTIME_VM_FLAG_LIST_H_
7
8#include "platform/thread_sanitizer.h"
9
10// Don't use USING_PRODUCT outside of this file.
11#if defined(PRODUCT)
12#define USING_PRODUCT true
13#else
14#define USING_PRODUCT false
15#endif
16
17#if defined(DART_PRECOMPILED_RUNTIME)
18constexpr bool kDartPrecompiledRuntime = true;
19#else
20constexpr bool kDartPrecompiledRuntime = false;
21#endif
22
23#if defined(DART_USE_BYTECODE)
24constexpr bool kDartUseBytecode = true;
25#else
26constexpr bool kDartUseBytecode = false;
27#endif
28
29#if defined(USING_THREAD_SANITIZER)
30// TODO(39611): Address races in the background compiler.
31constexpr bool kDartUseBackgroundCompilation = false;
32#else
33constexpr bool kDartUseBackgroundCompilation = true;
34#endif
35
36// The disassembler might be force included even in product builds so we need
37// to conditionally make these into product flags to make the disassembler
38// usable in product mode.
39#if defined(FORCE_INCLUDE_DISASSEMBLER)
40#define DISASSEMBLE_FLAGS(P, R, C, D) \
41 P(disassemble, bool, false, "Disassemble dart code.") \
42 P(disassemble_optimized, bool, false, "Disassemble optimized code.") \
43 P(disassemble_relative, bool, false, "Use offsets instead of absolute PCs") \
44 P(support_disassembler, bool, true, "Support the disassembler.")
45#else
46#define DISASSEMBLE_FLAGS(P, R, C, D) \
47 R(disassemble, false, bool, false, "Disassemble dart code.") \
48 R(disassemble_optimized, false, bool, false, "Disassemble optimized code.") \
49 R(disassemble_relative, false, bool, false, \
50 "Use offsets instead of absolute PCs") \
51 R(support_disassembler, false, bool, true, "Support the disassembler.")
52#endif
53
54// List of VM-global (i.e. non-isolate specific) flags.
55//
56// The value used for those flags at snapshot generation time needs to be the
57// same as during runtime. Currently, only boolean flags are supported.
58//
59// The syntax used is the same as that for FLAG_LIST below, as these flags are
60// automatically included in FLAG_LIST.
61#define VM_GLOBAL_FLAG_LIST(P, R, C, D) \
62 P(dwarf_stack_traces_mode, bool, false, \
63 "Use --[no-]dwarf-stack-traces instead.") \
64 P(causal_async_stacks, bool, !USING_PRODUCT, "Improved async stacks") \
65 P(lazy_async_stacks, bool, false, "Reconstruct async stacks from listeners") \
66 P(lazy_dispatchers, bool, true, "Generate dispatchers lazily") \
67 P(use_bare_instructions, bool, true, "Enable bare instructions mode.") \
68 R(dedup_instructions, true, bool, false, \
69 "Canonicalize instructions when precompiling.")
70
71// List of all flags in the VM.
72// Flags can be one of four categories:
73// * P roduct flags: Can be set in any of the deployment modes, including in
74// production.
75// * R elease flags: Generally available flags except when building product.
76// * pre C ompile flags: Generally available flags except when building product
77// or precompiled runtime.
78// * D ebug flags: Can only be set in debug VMs, which also have C++ assertions
79// enabled.
80//
81// Usage:
82// P(name, type, default_value, comment)
83// R(name, product_value, type, default_value, comment)
84// C(name, precompiled_value, product_value, type, default_value, comment)
85// D(name, type, default_value, comment)
86#define FLAG_LIST(P, R, C, D) \
87 VM_GLOBAL_FLAG_LIST(P, R, C, D) \
88 DISASSEMBLE_FLAGS(P, R, C, D) \
89 P(abort_on_oom, bool, false, \
90 "Abort if memory allocation fails - use only with --old-gen-heap-size") \
91 C(async_debugger, false, false, bool, true, \
92 "Debugger support async functions.") \
93 P(async_igoto_threshold, int, 5, \
94 "Number of continuations after which igoto-based async is used." \
95 "-1 means never.") \
96 P(background_compilation, bool, kDartUseBackgroundCompilation, \
97 "Run optimizing compilation in background") \
98 R(code_comments, false, bool, false, \
99 "Include comments into code and disassembly.") \
100 P(collect_code, bool, false, "Attempt to GC infrequently used code.") \
101 P(collect_dynamic_function_names, bool, true, \
102 "Collects all dynamic function names to identify unique targets") \
103 P(compactor_tasks, int, 2, \
104 "The number of tasks to use for parallel compaction.") \
105 P(compilation_counter_threshold, int, 10, \
106 "Function's usage-counter value before interpreted function is compiled, " \
107 "-1 means never") \
108 P(concurrent_mark, bool, true, "Concurrent mark for old generation.") \
109 P(concurrent_sweep, bool, true, "Concurrent sweep for old generation.") \
110 C(deoptimize_alot, false, false, bool, false, \
111 "Deoptimizes we are about to return to Dart code from native entries.") \
112 C(deoptimize_every, 0, 0, int, 0, \
113 "Deoptimize on every N stack overflow checks") \
114 R(disable_alloc_stubs_after_gc, false, bool, false, "Stress testing flag.") \
115 R(dump_megamorphic_stats, false, bool, false, \
116 "Dump megamorphic cache statistics") \
117 R(dump_symbol_stats, false, bool, false, "Dump symbol table statistics") \
118 R(enable_asserts, false, bool, false, "Enable assert statements.") \
119 R(null_assertions, false, bool, false, \
120 "Enable null assertions for parameters.") \
121 P(enable_kernel_expression_compilation, bool, true, \
122 "Compile expressions with the Kernel front-end.") \
123 P(enable_mirrors, bool, true, \
124 "Disable to make importing dart:mirrors an error.") \
125 P(enable_ffi, bool, true, "Disable to make importing dart:ffi an error.") \
126 P(fields_may_be_reset, bool, false, \
127 "Don't optimize away static field initialization") \
128 C(force_clone_compiler_objects, false, false, bool, false, \
129 "Force cloning of objects needed in compiler (ICData and Field).") \
130 P(getter_setter_ratio, int, 13, \
131 "Ratio of getter/setter usage used for double field unboxing heuristics") \
132 P(guess_icdata_cid, bool, true, \
133 "Artificially create type feedback for arithmetic etc. operations") \
134 P(huge_method_cutoff_in_tokens, int, 20000, \
135 "Huge method cutoff in tokens: Disables optimizations for huge methods.") \
136 P(idle_timeout_micros, int, 1000 * kMicrosecondsPerMillisecond, \
137 "Consider thread pool isolates for idle tasks after this long.") \
138 P(idle_duration_micros, int, 500 * kMicrosecondsPerMillisecond, \
139 "Allow idle tasks to run for this long.") \
140 P(interpret_irregexp, bool, false, "Use irregexp bytecode interpreter") \
141 P(link_natives_lazily, bool, false, "Link native calls lazily") \
142 R(log_marker_tasks, false, bool, false, \
143 "Log debugging information for old gen GC marking tasks.") \
144 P(scavenger_tasks, int, 2, \
145 "The number of tasks to spawn during scavenging (0 means " \
146 "perform all marking on main thread).") \
147 P(marker_tasks, int, 2, \
148 "The number of tasks to spawn during old gen GC marking (0 means " \
149 "perform all marking on main thread).") \
150 P(max_polymorphic_checks, int, 4, \
151 "Maximum number of polymorphic check, otherwise it is megamorphic.") \
152 P(max_equality_polymorphic_checks, int, 32, \
153 "Maximum number of polymorphic checks in equality operator,") \
154 P(new_gen_semi_max_size, int, (kWordSize <= 4) ? 8 : 16, \
155 "Max size of new gen semi space in MB") \
156 P(new_gen_semi_initial_size, int, (kWordSize <= 4) ? 1 : 2, \
157 "Initial size of new gen semi space in MB") \
158 P(optimization_counter_threshold, int, 30000, \
159 "Function's usage-counter value before it is optimized, -1 means never") \
160 R(randomize_optimization_counter, false, bool, false, \
161 "Randomize optimization counter thresholds on a per-function basis (for " \
162 "testing).") \
163 P(optimization_level, int, 2, \
164 "Optimization level: 1 (favor size), 2 (default), 3 (favor speed)") \
165 P(old_gen_heap_size, int, kDefaultMaxOldGenHeapSize, \
166 "Max size of old gen heap size in MB, or 0 for unlimited," \
167 "e.g: --old_gen_heap_size=1024 allows up to 1024MB old gen heap") \
168 R(pause_isolates_on_start, false, bool, false, \
169 "Pause isolates before starting.") \
170 R(pause_isolates_on_exit, false, bool, false, "Pause isolates exiting.") \
171 R(pause_isolates_on_unhandled_exceptions, false, bool, false, \
172 "Pause isolates on unhandled exceptions.") \
173 P(polymorphic_with_deopt, bool, true, \
174 "Polymorphic calls with deoptimization / megamorphic call") \
175 P(precompiled_mode, bool, false, "Precompilation compiler mode") \
176 P(print_snapshot_sizes, bool, false, "Print sizes of generated snapshots.") \
177 P(print_snapshot_sizes_verbose, bool, false, \
178 "Print cluster sizes of generated snapshots.") \
179 P(print_benchmarking_metrics, bool, false, \
180 "Print additional memory and latency metrics for benchmarking.") \
181 R(print_ssa_liveranges, false, bool, false, \
182 "Print live ranges after allocation.") \
183 R(print_stacktrace_at_api_error, false, bool, false, \
184 "Attempt to print a native stack trace when an API error is created.") \
185 D(print_variable_descriptors, bool, false, \
186 "Print variable descriptors in disassembly.") \
187 R(profiler, false, bool, false, "Enable the profiler.") \
188 R(profiler_native_memory, false, bool, false, \
189 "Enable native memory statistic collection.") \
190 P(reorder_basic_blocks, bool, true, "Reorder basic blocks") \
191 C(stress_async_stacks, false, false, bool, false, \
192 "Stress test async stack traces") \
193 P(use_table_dispatch, bool, true, "Enable dispatch table based calls.") \
194 P(retain_function_objects, bool, true, \
195 "Serialize function objects for all code objects even if not otherwise " \
196 "needed in the precompiled runtime.") \
197 P(enable_isolate_groups, bool, false, "Enable isolate group support.") \
198 P(show_invisible_frames, bool, false, \
199 "Show invisible frames in stack traces.") \
200 R(show_invisible_isolates, false, bool, false, \
201 "Show invisible isolates in the vm-service.") \
202 R(support_il_printer, false, bool, true, "Support the IL printer.") \
203 D(trace_cha, bool, false, "Trace CHA operations") \
204 R(trace_field_guards, false, bool, false, "Trace changes in field's cids.") \
205 D(trace_ic, bool, false, "Trace IC handling") \
206 D(trace_ic_miss_in_optimized, bool, false, \
207 "Trace IC miss in optimized code") \
208 C(trace_irregexp, false, false, bool, false, "Trace irregexps.") \
209 D(trace_intrinsified_natives, bool, false, \
210 "Report if any of the intrinsified natives are called") \
211 D(trace_isolates, bool, false, "Trace isolate creation and shut down.") \
212 D(trace_handles, bool, false, "Traces allocation of handles.") \
213 D(trace_kernel_binary, bool, false, "Trace Kernel reader/writer.") \
214 D(trace_natives, bool, false, "Trace invocation of natives") \
215 D(trace_optimization, bool, false, "Print optimization details.") \
216 R(trace_profiler, false, bool, false, "Profiler trace") \
217 D(trace_profiler_verbose, bool, false, "Verbose profiler trace") \
218 D(trace_runtime_calls, bool, false, "Trace runtime calls.") \
219 R(trace_ssa_allocator, false, bool, false, \
220 "Trace register allocation over SSA.") \
221 P(trace_strong_mode_types, bool, false, \
222 "Trace optimizations based on strong mode types.") \
223 D(trace_type_checks, bool, false, "Trace runtime type checks.") \
224 D(trace_patching, bool, false, "Trace patching of code.") \
225 D(trace_optimized_ic_calls, bool, false, \
226 "Trace IC calls in optimized code.") \
227 D(trace_zones, bool, false, "Traces allocation sizes in the zone.") \
228 P(truncating_left_shift, bool, true, \
229 "Optimize left shift to truncate if possible") \
230 P(use_bytecode_compiler, bool, kDartUseBytecode, "Compile from bytecode") \
231 P(use_compactor, bool, false, "Compact the heap during old-space GC.") \
232 P(use_cha_deopt, bool, true, \
233 "Use class hierarchy analysis even if it can cause deoptimization.") \
234 P(use_field_guards, bool, true, "Use field guards and track field types") \
235 C(use_osr, false, true, bool, true, "Use OSR") \
236 R(verbose_gc, false, bool, false, "Enables verbose GC.") \
237 R(verbose_gc_hdr, 40, int, 40, "Print verbose GC header interval.") \
238 R(verify_after_gc, false, bool, false, \
239 "Enables heap verification after GC.") \
240 R(verify_before_gc, false, bool, false, \
241 "Enables heap verification before GC.") \
242 R(verify_store_buffer, false, bool, false, \
243 "Enables store buffer verification before and after scavenges.") \
244 P(enable_slow_path_sharing, bool, true, "Enable sharing of slow-path code.") \
245 P(shared_slow_path_triggers_gc, bool, false, \
246 "TESTING: slow-path triggers a GC.") \
247 P(enable_multiple_entrypoints, bool, true, \
248 "Enable multiple entrypoints per-function and related optimizations.") \
249 P(enable_testing_pragmas, bool, false, \
250 "Enable magical pragmas for testing purposes. Use at your own risk!") \
251 R(eliminate_type_checks, true, bool, true, \
252 "Eliminate type checks when allowed by static type analysis.") \
253 P(enable_interpreter, bool, false, "Enable interpreting kernel bytecode.") \
254 D(support_rr, bool, false, "Support running within RR.") \
255 P(verify_entry_points, bool, false, \
256 "Throw API error on invalid member access throuh native API. See " \
257 "entry_point_pragma.md")
258
259#endif // RUNTIME_VM_FLAG_LIST_H_
260