Brian Carlstrom | 491ca9e | 2014-03-02 18:24:38 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2011 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef ART_RUNTIME_PARSED_OPTIONS_H_ |
| 18 | #define ART_RUNTIME_PARSED_OPTIONS_H_ |
| 19 | |
| 20 | #include <string> |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 21 | #include <vector> |
Brian Carlstrom | 491ca9e | 2014-03-02 18:24:38 -0800 | [diff] [blame] | 22 | |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 23 | #include <jni.h> |
| 24 | |
| 25 | #include "globals.h" |
Ian Rogers | 576ca0c | 2014-06-06 15:58:22 -0700 | [diff] [blame] | 26 | #include "gc/collector_type.h" |
Mathieu Chartier | 2dbe627 | 2014-09-16 10:43:23 -0700 | [diff] [blame] | 27 | #include "gc/space/large_object_space.h" |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 28 | #include "instruction_set.h" |
| 29 | #include "profiler_options.h" |
Brian Carlstrom | 491ca9e | 2014-03-02 18:24:38 -0800 | [diff] [blame] | 30 | |
| 31 | namespace art { |
| 32 | |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 33 | class CompilerCallbacks; |
| 34 | class DexFile; |
| 35 | |
| 36 | typedef std::vector<std::pair<std::string, const void*>> RuntimeOptions; |
| 37 | |
Brian Carlstrom | 491ca9e | 2014-03-02 18:24:38 -0800 | [diff] [blame] | 38 | class ParsedOptions { |
| 39 | public: |
| 40 | // returns null if problem parsing and ignore_unrecognized is false |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 41 | static ParsedOptions* Create(const RuntimeOptions& options, bool ignore_unrecognized); |
Brian Carlstrom | 491ca9e | 2014-03-02 18:24:38 -0800 | [diff] [blame] | 42 | |
| 43 | const std::vector<const DexFile*>* boot_class_path_; |
| 44 | std::string boot_class_path_string_; |
| 45 | std::string class_path_string_; |
Brian Carlstrom | 491ca9e | 2014-03-02 18:24:38 -0800 | [diff] [blame] | 46 | std::string image_; |
| 47 | bool check_jni_; |
Ian Rogers | 68d8b42 | 2014-07-17 11:09:10 -0700 | [diff] [blame] | 48 | bool force_copy_; |
Brian Carlstrom | 491ca9e | 2014-03-02 18:24:38 -0800 | [diff] [blame] | 49 | std::string jni_trace_; |
Calin Juravle | a68629e | 2014-08-22 12:53:59 +0100 | [diff] [blame] | 50 | std::string native_bridge_library_filename_; |
Brian Carlstrom | 491ca9e | 2014-03-02 18:24:38 -0800 | [diff] [blame] | 51 | CompilerCallbacks* compiler_callbacks_; |
| 52 | bool is_zygote_; |
Alex Light | a59dd80 | 2014-07-02 16:28:08 -0700 | [diff] [blame] | 53 | bool must_relocate_; |
Nicolas Geoffray | 4fcdc94 | 2014-07-22 10:48:00 +0100 | [diff] [blame] | 54 | bool dex2oat_enabled_; |
Alex Light | 64ad14d | 2014-08-19 14:23:13 -0700 | [diff] [blame] | 55 | bool image_dex2oat_enabled_; |
Alex Light | a59dd80 | 2014-07-02 16:28:08 -0700 | [diff] [blame] | 56 | std::string patchoat_executable_; |
Brian Carlstrom | 491ca9e | 2014-03-02 18:24:38 -0800 | [diff] [blame] | 57 | bool interpreter_only_; |
| 58 | bool is_explicit_gc_disabled_; |
| 59 | bool use_tlab_; |
| 60 | bool verify_pre_gc_heap_; |
Mathieu Chartier | 6f365cc | 2014-04-23 12:42:27 -0700 | [diff] [blame] | 61 | bool verify_pre_sweeping_heap_; |
Brian Carlstrom | 491ca9e | 2014-03-02 18:24:38 -0800 | [diff] [blame] | 62 | bool verify_post_gc_heap_; |
| 63 | bool verify_pre_gc_rosalloc_; |
Mathieu Chartier | 6f365cc | 2014-04-23 12:42:27 -0700 | [diff] [blame] | 64 | bool verify_pre_sweeping_rosalloc_; |
Brian Carlstrom | 491ca9e | 2014-03-02 18:24:38 -0800 | [diff] [blame] | 65 | bool verify_post_gc_rosalloc_; |
Andreas Gampe | 39d9218 | 2014-03-05 16:46:44 -0800 | [diff] [blame] | 66 | unsigned int long_pause_log_threshold_; |
| 67 | unsigned int long_gc_log_threshold_; |
Brian Carlstrom | 491ca9e | 2014-03-02 18:24:38 -0800 | [diff] [blame] | 68 | bool dump_gc_performance_on_shutdown_; |
| 69 | bool ignore_max_footprint_; |
| 70 | size_t heap_initial_size_; |
| 71 | size_t heap_maximum_size_; |
| 72 | size_t heap_growth_limit_; |
| 73 | size_t heap_min_free_; |
| 74 | size_t heap_max_free_; |
Mathieu Chartier | 6a7824d | 2014-08-22 14:53:04 -0700 | [diff] [blame] | 75 | size_t heap_non_moving_space_capacity_; |
Mathieu Chartier | 2dbe627 | 2014-09-16 10:43:23 -0700 | [diff] [blame] | 76 | gc::space::LargeObjectSpaceType large_object_space_type_; |
| 77 | size_t large_object_threshold_; |
Brian Carlstrom | 491ca9e | 2014-03-02 18:24:38 -0800 | [diff] [blame] | 78 | double heap_target_utilization_; |
Mathieu Chartier | 2f8da3e | 2014-04-15 15:37:02 -0700 | [diff] [blame] | 79 | double foreground_heap_growth_multiplier_; |
Andreas Gampe | 39d9218 | 2014-03-05 16:46:44 -0800 | [diff] [blame] | 80 | unsigned int parallel_gc_threads_; |
| 81 | unsigned int conc_gc_threads_; |
Brian Carlstrom | 491ca9e | 2014-03-02 18:24:38 -0800 | [diff] [blame] | 82 | gc::CollectorType collector_type_; |
| 83 | gc::CollectorType background_collector_type_; |
| 84 | size_t stack_size_; |
Andreas Gampe | 39d9218 | 2014-03-05 16:46:44 -0800 | [diff] [blame] | 85 | unsigned int max_spins_before_thin_lock_inflation_; |
Brian Carlstrom | 491ca9e | 2014-03-02 18:24:38 -0800 | [diff] [blame] | 86 | bool low_memory_mode_; |
Andreas Gampe | 39d9218 | 2014-03-05 16:46:44 -0800 | [diff] [blame] | 87 | unsigned int lock_profiling_threshold_; |
Brian Carlstrom | 491ca9e | 2014-03-02 18:24:38 -0800 | [diff] [blame] | 88 | std::string stack_trace_file_; |
| 89 | bool method_trace_; |
| 90 | std::string method_trace_file_; |
Andreas Gampe | 39d9218 | 2014-03-05 16:46:44 -0800 | [diff] [blame] | 91 | unsigned int method_trace_file_size_; |
Brian Carlstrom | 491ca9e | 2014-03-02 18:24:38 -0800 | [diff] [blame] | 92 | bool (*hook_is_sensitive_thread_)(); |
| 93 | jint (*hook_vfprintf_)(FILE* stream, const char* format, va_list ap); |
| 94 | void (*hook_exit_)(jint status); |
| 95 | void (*hook_abort_)(); |
| 96 | std::vector<std::string> properties_; |
Tsu Chiang Chuang | 12e6d74 | 2014-05-22 10:22:25 -0700 | [diff] [blame] | 97 | std::string compiler_executable_; |
Brian Carlstrom | 491ca9e | 2014-03-02 18:24:38 -0800 | [diff] [blame] | 98 | std::vector<std::string> compiler_options_; |
| 99 | std::vector<std::string> image_compiler_options_; |
Calin Juravle | c1b643c | 2014-05-30 23:44:11 +0100 | [diff] [blame] | 100 | ProfilerOptions profiler_options_; |
Brian Carlstrom | 491ca9e | 2014-03-02 18:24:38 -0800 | [diff] [blame] | 101 | std::string profile_output_filename_; |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 102 | TraceClockSource profile_clock_source_; |
Jeff Hao | 4a200f5 | 2014-04-01 14:58:49 -0700 | [diff] [blame] | 103 | bool verify_; |
Narayan Kamath | 11d9f06 | 2014-04-23 20:24:57 +0100 | [diff] [blame] | 104 | InstructionSet image_isa_; |
Brian Carlstrom | 491ca9e | 2014-03-02 18:24:38 -0800 | [diff] [blame] | 105 | |
Zuo Wang | f37a88b | 2014-07-10 04:26:41 -0700 | [diff] [blame] | 106 | // Whether or not we use homogeneous space compaction to avoid OOM errors. If enabled, |
| 107 | // the heap will attempt to create an extra space which enables compacting from a malloc space to |
| 108 | // another malloc space when we are about to throw OOM. |
| 109 | bool use_homogeneous_space_compaction_for_oom_; |
| 110 | // Minimal interval allowed between two homogeneous space compactions caused by OOM. |
| 111 | uint64_t min_interval_homogeneous_space_compaction_by_oom_; |
Nicolas Geoffray | 0025a86 | 2014-07-11 08:26:40 +0000 | [diff] [blame] | 112 | |
Brian Carlstrom | 491ca9e | 2014-03-02 18:24:38 -0800 | [diff] [blame] | 113 | private: |
Andreas Gampe | 313f403 | 2014-08-29 16:01:25 -0700 | [diff] [blame] | 114 | ParsedOptions(); |
Brian Carlstrom | 491ca9e | 2014-03-02 18:24:38 -0800 | [diff] [blame] | 115 | |
| 116 | void Usage(const char* fmt, ...); |
| 117 | void UsageMessage(FILE* stream, const char* fmt, ...); |
| 118 | void UsageMessageV(FILE* stream, const char* fmt, va_list ap); |
| 119 | |
| 120 | void Exit(int status); |
| 121 | void Abort(); |
| 122 | |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 123 | bool Parse(const RuntimeOptions& options, bool ignore_unrecognized); |
Mathieu Chartier | 6f365cc | 2014-04-23 12:42:27 -0700 | [diff] [blame] | 124 | bool ParseXGcOption(const std::string& option); |
Brian Carlstrom | 491ca9e | 2014-03-02 18:24:38 -0800 | [diff] [blame] | 125 | bool ParseStringAfterChar(const std::string& option, char after_char, std::string* parsed_value); |
| 126 | bool ParseInteger(const std::string& option, char after_char, int* parsed_value); |
| 127 | bool ParseUnsignedInteger(const std::string& option, char after_char, unsigned int* parsed_value); |
| 128 | bool ParseDouble(const std::string& option, char after_char, double min, double max, |
| 129 | double* parsed_value); |
| 130 | }; |
| 131 | |
| 132 | } // namespace art |
| 133 | |
| 134 | #endif // ART_RUNTIME_PARSED_OPTIONS_H_ |