dart-sdk/runtime/vm/flag_list.h

258 lines
17 KiB
C
Raw Normal View History

// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
#ifndef RUNTIME_VM_FLAG_LIST_H_
#define RUNTIME_VM_FLAG_LIST_H_
2019-12-16 18:32:23 +00:00
#include "platform/thread_sanitizer.h"
// Don't use USING_PRODUCT outside of this file.
#if defined(PRODUCT)
#define USING_PRODUCT true
#else
#define USING_PRODUCT false
#endif
#if defined(DART_PRECOMPILED_RUNTIME)
constexpr bool kDartPrecompiledRuntime = true;
#else
constexpr bool kDartPrecompiledRuntime = false;
#endif
2019-12-16 18:32:23 +00:00
#if defined(USING_THREAD_SANITIZER)
// TODO(39611): Address races in the background compiler.
constexpr bool kDartUseBackgroundCompilation = false;
#else
constexpr bool kDartUseBackgroundCompilation = true;
#endif
// The disassembler might be force included even in product builds so we need
// to conditionally make these into product flags to make the disassembler
// usable in product mode.
#if defined(FORCE_INCLUDE_DISASSEMBLER)
#define DISASSEMBLE_FLAGS(P, R, C, D) \
P(disassemble, bool, false, "Disassemble dart code.") \
P(disassemble_optimized, bool, false, "Disassemble optimized code.") \
P(disassemble_relative, bool, false, "Use offsets instead of absolute PCs") \
[vm/compiler] Add initial partial TTSes for implemented types. Previously, no optimized TTSes were generated for implemented types, and so they always fell back to the default TTS, which mostly depends on calling the runtime and cached checks in SubtypeTestCaches. Now, optimized TTSes are generated that check for certain compatible implementing classes before falling back on the runtime/STC. More specifically, the optimized TTSes for implemented types checks for the following cases: 1) The implemented type is instantiated and the checked class implements an instantiated subtype of the implemented type. The only check required is a class id match. 2) The instance type arguments of the checked class are compatible with the type arguments of the checked type. That is, given the following declarations, where Base, Impl1, and Impl2 have the same number of parent type arguments: ``` case Impl1<K, V> implements Base<K, V> case Impl2<V> implements Base<String, V> ``` then the generated optimized TTS for Base<S, T>, where S and T are either type parameters or instantiated types, checks for instances of Base and Impl1, comparing the type arguments of the instance to S and T. The generated TTS does not currently check for Impl2, and thus when given an instance of Impl2, it falls back to the old runtime checking/SubtypeTestCache behavior. This compatibility restriction allows us to perform the same checks on the loaded instance type arguments as is done for non-implemented types, where the checked classes are subclasses and so naturally compatible in this manner. Note that two implementing classes whose instance type arguments are compatible may store their instance type arguments at different field offsets. Thus, we also split the classes being checked into groups that share the same instance type arguments field offset, and load the instance type arguments differently for each checked group. This CL also removes now-unused code in the HierarchyInfo class. TEST=vm/cc/TTS_{Generic,}SubtypeRangeCheck Cq-Include-Trybots: luci.dart.try:vm-kernel-linux-release-x64-try,vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-nnbd-linux-release-x64-try,vm-kernel-nnbd-linux-release-x64-try,vm-kernel-linux-product-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-linux-release-simarm-try,vm-kernel-linux-release-simarm64-try,vm-kernel-precomp-linux-release-simarm64-try,vm-kernel-precomp-linux-release-simarm-try,vm-kernel-precomp-linux-release-simarm_x64-try Change-Id: I4c3aa23db2e75adbad9c15727b491669b2f3a189 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209540 Reviewed-by: Martin Kustermann <kustermann@google.com> Reviewed-by: Alexander Markov <alexmarkov@google.com> Commit-Queue: Tess Strickland <sstrickl@google.com>
2021-08-16 13:02:34 +00:00
P(disassemble_stubs, bool, false, "Disassemble generated stubs.") \
P(support_disassembler, bool, true, "Support the disassembler.")
#else
#define DISASSEMBLE_FLAGS(P, R, C, D) \
R(disassemble, false, bool, false, "Disassemble dart code.") \
R(disassemble_optimized, false, bool, false, "Disassemble optimized code.") \
R(disassemble_relative, false, bool, false, \
"Use offsets instead of absolute PCs") \
[vm/compiler] Add initial partial TTSes for implemented types. Previously, no optimized TTSes were generated for implemented types, and so they always fell back to the default TTS, which mostly depends on calling the runtime and cached checks in SubtypeTestCaches. Now, optimized TTSes are generated that check for certain compatible implementing classes before falling back on the runtime/STC. More specifically, the optimized TTSes for implemented types checks for the following cases: 1) The implemented type is instantiated and the checked class implements an instantiated subtype of the implemented type. The only check required is a class id match. 2) The instance type arguments of the checked class are compatible with the type arguments of the checked type. That is, given the following declarations, where Base, Impl1, and Impl2 have the same number of parent type arguments: ``` case Impl1<K, V> implements Base<K, V> case Impl2<V> implements Base<String, V> ``` then the generated optimized TTS for Base<S, T>, where S and T are either type parameters or instantiated types, checks for instances of Base and Impl1, comparing the type arguments of the instance to S and T. The generated TTS does not currently check for Impl2, and thus when given an instance of Impl2, it falls back to the old runtime checking/SubtypeTestCache behavior. This compatibility restriction allows us to perform the same checks on the loaded instance type arguments as is done for non-implemented types, where the checked classes are subclasses and so naturally compatible in this manner. Note that two implementing classes whose instance type arguments are compatible may store their instance type arguments at different field offsets. Thus, we also split the classes being checked into groups that share the same instance type arguments field offset, and load the instance type arguments differently for each checked group. This CL also removes now-unused code in the HierarchyInfo class. TEST=vm/cc/TTS_{Generic,}SubtypeRangeCheck Cq-Include-Trybots: luci.dart.try:vm-kernel-linux-release-x64-try,vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-nnbd-linux-release-x64-try,vm-kernel-nnbd-linux-release-x64-try,vm-kernel-linux-product-x64-try,vm-kernel-precomp-linux-product-x64-try,vm-kernel-linux-release-simarm-try,vm-kernel-linux-release-simarm64-try,vm-kernel-precomp-linux-release-simarm64-try,vm-kernel-precomp-linux-release-simarm-try,vm-kernel-precomp-linux-release-simarm_x64-try Change-Id: I4c3aa23db2e75adbad9c15727b491669b2f3a189 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/209540 Reviewed-by: Martin Kustermann <kustermann@google.com> Reviewed-by: Alexander Markov <alexmarkov@google.com> Commit-Queue: Tess Strickland <sstrickl@google.com>
2021-08-16 13:02:34 +00:00
R(disassemble_stubs, false, bool, false, "Disassemble generated stubs.") \
R(support_disassembler, false, bool, true, "Support the disassembler.")
#endif
#if defined(INCLUDE_IL_PRINTER)
constexpr bool FLAG_support_il_printer = true;
#else
constexpr bool FLAG_support_il_printer = false;
#endif // defined(INCLUDE_IL_PRINTER)
// List of VM-global (i.e. non-isolate specific) flags.
//
// The value used for those flags at snapshot generation time needs to be the
// same as during runtime. Currently, only boolean flags are supported.
//
// The syntax used is the same as that for FLAG_LIST below, as these flags are
// automatically included in FLAG_LIST.
#define VM_GLOBAL_FLAG_LIST(P, R, C, D) \
P(code_comments, bool, false, "Include comments into code and disassembly.") \
[vm/aot] Drop more Function objects not needed at runtime when possible. Before, use of a function in the static calls table of a Code object would cause it to be retained. Now, like dispatch table use, we only retain such functions if there are other uses like dynamic function lookup that needs the function object or if the --retain-function-objects flag is enabled. In most modes, --retain-function-objects is enabled by default. It is only disabled by default in product mode when --dwarf-stack-traces is enabled, since otherwise the removed function objects may be needed for debugging platforms like the Observatory or when creating symbolic stack traces. Changes on flutter gallery in release mode: Default: arm7: isolate: +6.65%, total: +1.30% arm8: isolate: +6.67%, total: +1.28% (The increase is due to changing back to all function objects being retained as the default when using symbolic stack traces.) With --no-retain-function-objects: arm7: isolate: -9.95%, total: -1.73% arm8: isolate: -10.04%, total: -1.77% (This measures how much dropping static call function objects when possible affects the size compared to just dropping function objects for dispatch table entries when possible.) Bug: https://github.com/dart-lang/sdk/issues/41052 Change-Id: I3c834b14b0c58ccfdbaca3f154df536df29c13ef Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-linux-product-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/142146 Commit-Queue: Tess Strickland <sstrickl@google.com> Reviewed-by: Ryan Macnak <rmacnak@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-04-16 14:26:04 +00:00
P(dwarf_stack_traces_mode, bool, false, \
"Use --[no-]dwarf-stack-traces instead.") \
P(lazy_async_stacks, bool, true, "Reconstruct async stacks from listeners") \
[vm] Reland "Remove non-covariant checks from closure bodies (part 1)" Also relands the followup CLs: "Perform non-covariant checks when dynamically invoking callables." "Use AreValidArguments so that names are checked as well." Original description of first CL: This change only affects compilation when running in non-precompiled mode with --no-lazy-dispatchers enabled. Instead of always compiling in non-covariant checks, even for closures not called dynamically, remove the non-covariant checks from the closure and instead do the non-covariant checks for dynamic calls during the NoSuchMethodForCallStub fallback by calling Function::DoArgumentTypesMatch. Adds two overloads for Function::DoArgumentTypesMatch, one which takes a function type argument vector and one which takes neither an instantiator type argument vector or a function type argument vector. For the versions that are not explicitly passed a type argument vector, an appropriate one is constructed using the arguments. If there is not enough information in the arguments, then we fall back to assuming the empty type argument vector for the instantiator case and instantiating to bounds in the function type argument case. Fixes Function::DoArgumentTypesMatch to handle generic functions and to check arguments appropriately according to the active null safety mode. For generic functions, the provided or resulting function type vector has non-covariant checks performed against the type parameter bounds. This change uncovered one test that was incorrectly passing in strong mode, see https://github.com/dart-lang/sdk/issues/42688 for details. Original description of second CL: The VM only does this when the callable function does not expect dynamic invocations. Otherwise, performing the checks would be redundant, as the function body already contains the appropriate non-covariant checks. Third CL had no additional description. Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-debug-x64-try,vm-dartkb-linux-release-x64-try,vm-kernel-reload-linux-release-x64-try, vm-kernel-reload-rollback-linux-debug-x64-try Bug: https://github.com/dart-lang/sdk/issues/40813 Change-Id: I1a3e9c1865103a8d716e1cad814267caffaaadf2 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/154688 Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-07-21 10:00:41 +00:00
P(lazy_dispatchers, bool, true, "Generate dispatchers lazily") \
P(use_bare_instructions, bool, true, "Enable bare instructions mode.") \
R(dedup_instructions, true, bool, false, \
"Canonicalize instructions when precompiling.")
// List of all flags in the VM.
// Flags can be one of four categories:
// * P roduct flags: Can be set in any of the deployment modes, including in
// production.
// * R elease flags: Generally available flags except when building product.
// * pre C ompile flags: Generally available flags except when building product
// or precompiled runtime.
// * D ebug flags: Can only be set in debug VMs, which also have C++ assertions
// enabled.
//
// Usage:
// P(name, type, default_value, comment)
// R(name, product_value, type, default_value, comment)
// C(name, precompiled_value, product_value, type, default_value, comment)
// D(name, type, default_value, comment)
#define FLAG_LIST(P, R, C, D) \
VM_GLOBAL_FLAG_LIST(P, R, C, D) \
DISASSEMBLE_FLAGS(P, R, C, D) \
P(abort_on_oom, bool, false, \
"Abort if memory allocation fails - use only with --old-gen-heap-size") \
C(async_debugger, false, false, bool, true, \
"Debugger support async functions.") \
P(async_igoto_threshold, int, 5, \
"Number of continuations after which igoto-based async is used." \
"-1 means never.") \
2019-12-16 18:32:23 +00:00
P(background_compilation, bool, kDartUseBackgroundCompilation, \
"Run optimizing compilation in background") \
P(check_token_positions, bool, false, \
"Check validity of token positions while compiling flow graphs") \
P(collect_dynamic_function_names, bool, true, \
"Collects all dynamic function names to identify unique targets") \
P(compactor_tasks, int, 2, \
"The number of tasks to use for parallel compaction.") \
P(concurrent_mark, bool, true, "Concurrent mark for old generation.") \
P(concurrent_sweep, bool, true, "Concurrent sweep for old generation.") \
C(deoptimize_alot, false, false, bool, false, \
"Deoptimizes we are about to return to Dart code from native entries.") \
C(deoptimize_every, 0, 0, int, 0, \
"Deoptimize on every N stack overflow checks") \
P(deoptimize_on_runtime_call_every, int, 0, \
"Deoptimize functions on every runtime call.") \
R(dump_megamorphic_stats, false, bool, false, \
"Dump megamorphic cache statistics") \
R(dump_symbol_stats, false, bool, false, "Dump symbol table statistics") \
R(enable_asserts, false, bool, false, "Enable assert statements.") \
2021-05-10 10:34:49 +00:00
P(inline_alloc, bool, true, "Whether to use inline allocation fast paths.") \
R(null_assertions, false, bool, false, \
"Enable null assertions for parameters.") \
R(strict_null_safety_checks, false, bool, false, \
"Enable strict type checks for non-nullable types and required " \
"parameters.") \
P(enable_mirrors, bool, true, \
"Disable to make importing dart:mirrors an error.") \
P(enable_ffi, bool, true, "Disable to make importing dart:ffi an error.") \
P(fields_may_be_reset, bool, false, \
"Don't optimize away static field initialization") \
P(force_clone_compiler_objects, bool, false, \
"Force cloning of objects needed in compiler (ICData and Field).") \
P(getter_setter_ratio, int, 13, \
"Ratio of getter/setter usage used for double field unboxing heuristics") \
P(guess_icdata_cid, bool, true, \
"Artificially create type feedback for arithmetic etc. operations") \
P(huge_method_cutoff_in_tokens, int, 20000, \
"Huge method cutoff in tokens: Disables optimizations for huge methods.") \
P(idle_timeout_micros, int, 1000 * kMicrosecondsPerMillisecond, \
"Consider thread pool isolates for idle tasks after this long.") \
P(idle_duration_micros, int, 500 * kMicrosecondsPerMillisecond, \
"Allow idle tasks to run for this long.") \
P(interpret_irregexp, bool, false, "Use irregexp bytecode interpreter") \
P(link_natives_lazily, bool, false, "Link native calls lazily") \
R(log_marker_tasks, false, bool, false, \
"Log debugging information for old gen GC marking tasks.") \
P(scavenger_tasks, int, 2, \
"The number of tasks to spawn during scavenging (0 means " \
"perform all marking on main thread).") \
P(marker_tasks, int, 2, \
"The number of tasks to spawn during old gen GC marking (0 means " \
"perform all marking on main thread).") \
P(max_polymorphic_checks, int, 4, \
"Maximum number of polymorphic check, otherwise it is megamorphic.") \
P(max_equality_polymorphic_checks, int, 32, \
"Maximum number of polymorphic checks in equality operator,") \
P(new_gen_semi_max_size, int, kDefaultNewGenSemiMaxSize, \
"Max size of new gen semi space in MB") \
P(new_gen_semi_initial_size, int, (kWordSize <= 4) ? 1 : 2, \
"Initial size of new gen semi space in MB") \
P(optimization_counter_threshold, int, 30000, \
"Function's usage-counter value before it is optimized, -1 means never") \
R(randomize_optimization_counter, false, bool, false, \
"Randomize optimization counter thresholds on a per-function basis (for " \
"testing).") \
P(optimization_level, int, 2, \
"Optimization level: 1 (favor size), 2 (default), 3 (favor speed)") \
P(old_gen_heap_size, int, kDefaultMaxOldGenHeapSize, \
"Max size of old gen heap size in MB, or 0 for unlimited," \
"e.g: --old_gen_heap_size=1024 allows up to 1024MB old gen heap") \
R(pause_isolates_on_start, false, bool, false, \
"Pause isolates before starting.") \
R(pause_isolates_on_exit, false, bool, false, "Pause isolates exiting.") \
R(pause_isolates_on_unhandled_exceptions, false, bool, false, \
"Pause isolates on unhandled exceptions.") \
P(polymorphic_with_deopt, bool, true, \
"Polymorphic calls with deoptimization / megamorphic call") \
P(precompiled_mode, bool, false, "Precompilation compiler mode") \
P(print_snapshot_sizes, bool, false, "Print sizes of generated snapshots.") \
P(print_snapshot_sizes_verbose, bool, false, \
"Print cluster sizes of generated snapshots.") \
R(print_ssa_liveranges, false, bool, false, \
"Print live ranges after allocation.") \
R(print_stacktrace_at_api_error, false, bool, false, \
"Attempt to print a native stack trace when an API error is created.") \
D(print_variable_descriptors, bool, false, \
"Print variable descriptors in disassembly.") \
R(profiler, false, bool, false, "Enable the profiler.") \
R(profiler_native_memory, false, bool, false, \
"Enable native memory statistic collection.") \
P(reorder_basic_blocks, bool, true, "Reorder basic blocks") \
C(stress_async_stacks, false, false, bool, false, \
"Stress test async stack traces") \
P(use_table_dispatch, bool, true, "Enable dispatch table based calls.") \
[vm/aot] Drop more Function objects not needed at runtime when possible. Before, use of a function in the static calls table of a Code object would cause it to be retained. Now, like dispatch table use, we only retain such functions if there are other uses like dynamic function lookup that needs the function object or if the --retain-function-objects flag is enabled. In most modes, --retain-function-objects is enabled by default. It is only disabled by default in product mode when --dwarf-stack-traces is enabled, since otherwise the removed function objects may be needed for debugging platforms like the Observatory or when creating symbolic stack traces. Changes on flutter gallery in release mode: Default: arm7: isolate: +6.65%, total: +1.30% arm8: isolate: +6.67%, total: +1.28% (The increase is due to changing back to all function objects being retained as the default when using symbolic stack traces.) With --no-retain-function-objects: arm7: isolate: -9.95%, total: -1.73% arm8: isolate: -10.04%, total: -1.77% (This measures how much dropping static call function objects when possible affects the size compared to just dropping function objects for dispatch table entries when possible.) Bug: https://github.com/dart-lang/sdk/issues/41052 Change-Id: I3c834b14b0c58ccfdbaca3f154df536df29c13ef Cq-Include-Trybots: luci.dart.try:vm-kernel-precomp-linux-release-x64-try,vm-kernel-precomp-linux-product-x64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/142146 Commit-Queue: Tess Strickland <sstrickl@google.com> Reviewed-by: Ryan Macnak <rmacnak@google.com> Reviewed-by: Martin Kustermann <kustermann@google.com>
2020-04-16 14:26:04 +00:00
P(retain_function_objects, bool, true, \
"Serialize function objects for all code objects even if not otherwise " \
"needed in the precompiled runtime.") \
P(retain_code_objects, bool, true, \
"Serialize all code objects even if not otherwise " \
"needed in the precompiled runtime.") \
P(enable_isolate_groups, bool, true, "Enable isolate group support.") \
P(show_invisible_frames, bool, false, \
"Show invisible frames in stack traces.") \
D(trace_cha, bool, false, "Trace CHA operations") \
R(trace_field_guards, false, bool, false, "Trace changes in field's cids.") \
D(trace_ic, bool, false, "Trace IC handling") \
D(trace_ic_miss_in_optimized, bool, false, \
"Trace IC miss in optimized code") \
C(trace_irregexp, false, false, bool, false, "Trace irregexps.") \
D(trace_intrinsified_natives, bool, false, \
"Report if any of the intrinsified natives are called") \
D(trace_isolates, bool, false, "Trace isolate creation and shut down.") \
D(trace_handles, bool, false, "Traces allocation of handles.") \
D(trace_kernel_binary, bool, false, "Trace Kernel reader/writer.") \
D(trace_natives, bool, false, "Trace invocation of natives") \
D(trace_optimization, bool, false, "Print optimization details.") \
R(trace_profiler, false, bool, false, "Profiler trace") \
D(trace_profiler_verbose, bool, false, "Verbose profiler trace") \
D(trace_runtime_calls, bool, false, "Trace runtime calls.") \
R(trace_ssa_allocator, false, bool, false, \
"Trace register allocation over SSA.") \
P(trace_strong_mode_types, bool, false, \
"Trace optimizations based on strong mode types.") \
D(trace_type_checks, bool, false, "Trace runtime type checks.") \
D(trace_patching, bool, false, "Trace patching of code.") \
D(trace_optimized_ic_calls, bool, false, \
"Trace IC calls in optimized code.") \
D(trace_zones, bool, false, "Traces allocation sizes in the zone.") \
P(truncating_left_shift, bool, true, \
"Optimize left shift to truncate if possible") \
P(use_compactor, bool, false, "Compact the heap during old-space GC.") \
P(use_cha_deopt, bool, true, \
"Use class hierarchy analysis even if it can cause deoptimization.") \
P(use_field_guards, bool, true, "Use field guards and track field types") \
C(use_osr, false, true, bool, true, "Use OSR") \
2021-05-10 10:34:49 +00:00
P(use_slow_path, bool, false, "Whether to avoid inlined fast paths.") \
R(verbose_gc, false, bool, false, "Enables verbose GC.") \
R(verbose_gc_hdr, 40, int, 40, "Print verbose GC header interval.") \
R(verify_after_gc, false, bool, false, \
"Enables heap verification after GC.") \
R(verify_before_gc, false, bool, false, \
"Enables heap verification before GC.") \
R(verify_store_buffer, false, bool, false, \
"Enables store buffer verification before and after scavenges.") \
P(enable_slow_path_sharing, bool, true, "Enable sharing of slow-path code.") \
P(shared_slow_path_triggers_gc, bool, false, \
"TESTING: slow-path triggers a GC.") \
P(enable_multiple_entrypoints, bool, true, \
"Enable multiple entrypoints per-function and related optimizations.") \
P(enable_testing_pragmas, bool, false, \
"Enable magical pragmas for testing purposes. Use at your own risk!") \
R(eliminate_type_checks, true, bool, true, \
"Eliminate type checks when allowed by static type analysis.") \
D(support_rr, bool, false, "Support running within RR.") \
P(verify_entry_points, bool, false, \
"Throw API error on invalid member access throuh native API. See " \
"entry_point_pragma.md")
#endif // RUNTIME_VM_FLAG_LIST_H_