diff options
| author | 2014-08-29 16:01:25 -0700 | |
|---|---|---|
| committer | 2014-08-29 16:01:56 -0700 | |
| commit | 313f40345a2bbea299a035d4176272d1a6622afd (patch) | |
| tree | a13c7bb3dd29430544e75d36bf4f0057eb93b5b4 | |
| parent | 6b8e3b906dd310c649ffb4b73dc46a78b64f4a0f (diff) | |
ART: Initialize fields of ParsedOptions
Avoids certain paths where we touched uninitialized fields.
Bug: 17330858
Change-Id: Ia68161b12eefefacad6fc524f487f8e2caf6342a
| -rw-r--r-- | runtime/parsed_options.cc | 158 | ||||
| -rw-r--r-- | runtime/parsed_options.h | 2 |
2 files changed, 81 insertions, 79 deletions
diff --git a/runtime/parsed_options.cc b/runtime/parsed_options.cc index 7ac5bceda2..0a59d85bd8 100644 --- a/runtime/parsed_options.cc +++ b/runtime/parsed_options.cc @@ -30,6 +30,85 @@ namespace art { +ParsedOptions::ParsedOptions() + : + boot_class_path_(nullptr), + check_jni_(kIsDebugBuild), // -Xcheck:jni is off by default for regular + // builds but on by default in debug builds. + force_copy_(false), + compiler_callbacks_(nullptr), + is_zygote_(false), + must_relocate_(kDefaultMustRelocate), + dex2oat_enabled_(true), + image_dex2oat_enabled_(true), + interpreter_only_(kPoisonHeapReferences), // kPoisonHeapReferences currently works with + // the interpreter only. + // TODO: make it work with the compiler. + is_explicit_gc_disabled_(false), + use_tlab_(false), + verify_pre_gc_heap_(false), + verify_pre_sweeping_heap_(kIsDebugBuild), // Pre sweeping is the one that usually fails + // if the GC corrupted the heap. + verify_post_gc_heap_(false), + verify_pre_gc_rosalloc_(kIsDebugBuild), + verify_pre_sweeping_rosalloc_(false), + verify_post_gc_rosalloc_(false), + long_pause_log_threshold_(gc::Heap::kDefaultLongPauseLogThreshold), + long_gc_log_threshold_(gc::Heap::kDefaultLongGCLogThreshold), + dump_gc_performance_on_shutdown_(false), + ignore_max_footprint_(false), + heap_initial_size_(gc::Heap::kDefaultInitialSize), + heap_maximum_size_(gc::Heap::kDefaultMaximumSize), + heap_growth_limit_(0), // 0 means no growth limit. + heap_min_free_(gc::Heap::kDefaultMinFree), + heap_max_free_(gc::Heap::kDefaultMaxFree), + heap_non_moving_space_capacity_(gc::Heap::kDefaultNonMovingSpaceCapacity), + heap_target_utilization_(gc::Heap::kDefaultTargetUtilization), + foreground_heap_growth_multiplier_(gc::Heap::kDefaultHeapGrowthMultiplier), + parallel_gc_threads_(1), + conc_gc_threads_(1), // Only the main GC thread, no workers. + collector_type_( // The default GC type is set in makefiles. +#if ART_DEFAULT_GC_TYPE_IS_CMS + gc::kCollectorTypeCMS), +#elif ART_DEFAULT_GC_TYPE_IS_SS + gc::kCollectorTypeSS), +#elif ART_DEFAULT_GC_TYPE_IS_GSS + gc::kCollectorTypeGSS), +#else + gc::kCollectorTypeCMS), +#error "ART default GC type must be set" +#endif + background_collector_type_(gc::kCollectorTypeHomogeneousSpaceCompact), + // If background_collector_type_ is + // kCollectorTypeNone, it defaults to the + // collector_type_ after parsing options. If + // you set this to kCollectorTypeHSpaceCompact + // then we will do an hspace compaction when + // we transition to background instead of a + // normal collector transition. + stack_size_(0), // 0 means default. + max_spins_before_thin_lock_inflation_(Monitor::kDefaultMaxSpinsBeforeThinLockInflation), + low_memory_mode_(false), + lock_profiling_threshold_(0), + method_trace_(false), + method_trace_file_("/data/method-trace-file.bin"), + method_trace_file_size_(10 * MB), + hook_is_sensitive_thread_(nullptr), + hook_vfprintf_(vfprintf), + hook_exit_(exit), + hook_abort_(nullptr), // We don't call abort(3) by default; see + // Runtime::Abort. + profile_clock_source_(kDefaultTraceClockSource), + verify_(true), + image_isa_(kRuntimeISA), + use_homogeneous_space_compaction_for_oom_(false), // If we are using homogeneous space + // compaction then default background + // compaction to off since homogeneous + // space compactions when we transition + // to not jank perceptible. + min_interval_homogeneous_space_compaction_by_oom_(MsToNs(100 * 1000)) // 100s. + {} + ParsedOptions* ParsedOptions::Create(const RuntimeOptions& options, bool ignore_unrecognized) { std::unique_ptr<ParsedOptions> parsed(new ParsedOptions()); if (parsed->Parse(options, ignore_unrecognized)) { @@ -175,77 +254,9 @@ bool ParsedOptions::Parse(const RuntimeOptions& options, bool ignore_unrecognize if (class_path_string != NULL) { class_path_string_ = class_path_string; } - // -Xcheck:jni is off by default for regular builds but on by default in debug builds. - check_jni_ = kIsDebugBuild; - force_copy_ = false; - - heap_initial_size_ = gc::Heap::kDefaultInitialSize; - heap_maximum_size_ = gc::Heap::kDefaultMaximumSize; - heap_min_free_ = gc::Heap::kDefaultMinFree; - heap_max_free_ = gc::Heap::kDefaultMaxFree; - heap_non_moving_space_capacity_ = gc::Heap::kDefaultNonMovingSpaceCapacity; - heap_target_utilization_ = gc::Heap::kDefaultTargetUtilization; - foreground_heap_growth_multiplier_ = gc::Heap::kDefaultHeapGrowthMultiplier; - heap_growth_limit_ = 0; // 0 means no growth limit . + // Default to number of processors minus one since the main GC thread also does work. parallel_gc_threads_ = sysconf(_SC_NPROCESSORS_CONF) - 1; - // Only the main GC thread, no workers. - conc_gc_threads_ = 0; - // The default GC type is set in makefiles. -#if ART_DEFAULT_GC_TYPE_IS_CMS - collector_type_ = gc::kCollectorTypeCMS; -#elif ART_DEFAULT_GC_TYPE_IS_SS - collector_type_ = gc::kCollectorTypeSS; -#elif ART_DEFAULT_GC_TYPE_IS_GSS - collector_type_ = gc::kCollectorTypeGSS; -#else -#error "ART default GC type must be set" -#endif - // If we are using homogeneous space compaction then default background compaction to off since - // homogeneous space compactions when we transition to not jank perceptible. - use_homogeneous_space_compaction_for_oom_ = false; - // If background_collector_type_ is kCollectorTypeNone, it defaults to the collector_type_ after - // parsing options. If you set this to kCollectorTypeHSpaceCompact then we will do an hspace - // compaction when we transition to background instead of a normal collector transition. - background_collector_type_ = gc::kCollectorTypeHomogeneousSpaceCompact; - stack_size_ = 0; // 0 means default. - max_spins_before_thin_lock_inflation_ = Monitor::kDefaultMaxSpinsBeforeThinLockInflation; - low_memory_mode_ = false; - use_tlab_ = false; - min_interval_homogeneous_space_compaction_by_oom_ = MsToNs(100 * 1000); // 100s. - verify_pre_gc_heap_ = false; - // Pre sweeping is the one that usually fails if the GC corrupted the heap. - verify_pre_sweeping_heap_ = kIsDebugBuild; - verify_post_gc_heap_ = false; - verify_pre_gc_rosalloc_ = kIsDebugBuild; - verify_pre_sweeping_rosalloc_ = false; - verify_post_gc_rosalloc_ = false; - - compiler_callbacks_ = nullptr; - is_zygote_ = false; - must_relocate_ = kDefaultMustRelocate; - dex2oat_enabled_ = true; - image_dex2oat_enabled_ = true; - if (kPoisonHeapReferences) { - // kPoisonHeapReferences currently works only with the interpreter only. - // TODO: make it work with the compiler. - interpreter_only_ = true; - } else { - interpreter_only_ = false; - } - is_explicit_gc_disabled_ = false; - - long_pause_log_threshold_ = gc::Heap::kDefaultLongPauseLogThreshold; - long_gc_log_threshold_ = gc::Heap::kDefaultLongGCLogThreshold; - dump_gc_performance_on_shutdown_ = false; - ignore_max_footprint_ = false; - - lock_profiling_threshold_ = 0; - hook_is_sensitive_thread_ = NULL; - - hook_vfprintf_ = vfprintf; - hook_exit_ = exit; - hook_abort_ = NULL; // We don't call abort(3) by default; see Runtime::Abort. // gLogVerbosity.class_linker = true; // TODO: don't check this in! // gLogVerbosity.compiler = true; // TODO: don't check this in! @@ -261,15 +272,6 @@ bool ParsedOptions::Parse(const RuntimeOptions& options, bool ignore_unrecognize // gLogVerbosity.threads = true; // TODO: don't check this in! // gLogVerbosity.verifier = true; // TODO: don't check this in! - method_trace_ = false; - method_trace_file_ = "/data/method-trace-file.bin"; - method_trace_file_size_ = 10 * MB; - - profile_clock_source_ = kDefaultTraceClockSource; - - verify_ = true; - image_isa_ = kRuntimeISA; - for (size_t i = 0; i < options.size(); ++i) { if (true && options[0].first == "-Xzygote") { LOG(INFO) << "option[" << i << "]=" << options[i].first; diff --git a/runtime/parsed_options.h b/runtime/parsed_options.h index c1474656f2..3839e19940 100644 --- a/runtime/parsed_options.h +++ b/runtime/parsed_options.h @@ -108,7 +108,7 @@ class ParsedOptions { uint64_t min_interval_homogeneous_space_compaction_by_oom_; private: - ParsedOptions() {} + ParsedOptions(); void Usage(const char* fmt, ...); void UsageMessage(FILE* stream, const char* fmt, ...); |