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> 21 #include <vector> 22 23 #include <jni.h> 24 25 #include "globals.h" 26 #include "gc/collector_type.h" 27 #include "instruction_set.h" 28 #include "profiler_options.h" 29 30 namespace art { 31 32 class CompilerCallbacks; 33 class DexFile; 34 35 typedef std::vector<std::pair<std::string, const void*>> RuntimeOptions; 36 37 class ParsedOptions { 38 public: 39 // returns null if problem parsing and ignore_unrecognized is false 40 static ParsedOptions* Create(const RuntimeOptions& options, bool ignore_unrecognized); 41 42 const std::vector<const DexFile*>* boot_class_path_; 43 std::string boot_class_path_string_; 44 std::string class_path_string_; 45 std::string image_; 46 bool check_jni_; 47 std::string jni_trace_; 48 std::string native_bridge_library_filename_; 49 CompilerCallbacks* compiler_callbacks_; 50 bool is_zygote_; 51 bool must_relocate_; 52 bool dex2oat_enabled_; 53 bool image_dex2oat_enabled_; 54 std::string patchoat_executable_; 55 bool interpreter_only_; 56 bool is_explicit_gc_disabled_; 57 bool use_tlab_; 58 bool verify_pre_gc_heap_; 59 bool verify_pre_sweeping_heap_; 60 bool verify_post_gc_heap_; 61 bool verify_pre_gc_rosalloc_; 62 bool verify_pre_sweeping_rosalloc_; 63 bool verify_post_gc_rosalloc_; 64 unsigned int long_pause_log_threshold_; 65 unsigned int long_gc_log_threshold_; 66 bool dump_gc_performance_on_shutdown_; 67 bool ignore_max_footprint_; 68 size_t heap_initial_size_; 69 size_t heap_maximum_size_; 70 size_t heap_growth_limit_; 71 size_t heap_min_free_; 72 size_t heap_max_free_; 73 size_t heap_non_moving_space_capacity_; 74 double heap_target_utilization_; 75 double foreground_heap_growth_multiplier_; 76 unsigned int parallel_gc_threads_; 77 unsigned int conc_gc_threads_; 78 gc::CollectorType collector_type_; 79 gc::CollectorType background_collector_type_; 80 size_t stack_size_; 81 unsigned int max_spins_before_thin_lock_inflation_; 82 bool low_memory_mode_; 83 unsigned int lock_profiling_threshold_; 84 std::string stack_trace_file_; 85 bool method_trace_; 86 std::string method_trace_file_; 87 unsigned int method_trace_file_size_; 88 bool (*hook_is_sensitive_thread_)(); 89 jint (*hook_vfprintf_)(FILE* stream, const char* format, va_list ap); 90 void (*hook_exit_)(jint status); 91 void (*hook_abort_)(); 92 std::vector<std::string> properties_; 93 std::string compiler_executable_; 94 std::vector<std::string> compiler_options_; 95 std::vector<std::string> image_compiler_options_; 96 ProfilerOptions profiler_options_; 97 std::string profile_output_filename_; 98 TraceClockSource profile_clock_source_; 99 bool verify_; 100 InstructionSet image_isa_; 101 102 // Whether or not we use homogeneous space compaction to avoid OOM errors. If enabled, 103 // the heap will attempt to create an extra space which enables compacting from a malloc space to 104 // another malloc space when we are about to throw OOM. 105 bool use_homogeneous_space_compaction_for_oom_; 106 // Minimal interval allowed between two homogeneous space compactions caused by OOM. 107 uint64_t min_interval_homogeneous_space_compaction_by_oom_; 108 109 private: ParsedOptions()110 ParsedOptions() {} 111 112 void Usage(const char* fmt, ...); 113 void UsageMessage(FILE* stream, const char* fmt, ...); 114 void UsageMessageV(FILE* stream, const char* fmt, va_list ap); 115 116 void Exit(int status); 117 void Abort(); 118 119 bool Parse(const RuntimeOptions& options, bool ignore_unrecognized); 120 bool ParseXGcOption(const std::string& option); 121 bool ParseStringAfterChar(const std::string& option, char after_char, std::string* parsed_value); 122 bool ParseInteger(const std::string& option, char after_char, int* parsed_value); 123 bool ParseUnsignedInteger(const std::string& option, char after_char, unsigned int* parsed_value); 124 bool ParseDouble(const std::string& option, char after_char, double min, double max, 125 double* parsed_value); 126 }; 127 128 } // namespace art 129 130 #endif // ART_RUNTIME_PARSED_OPTIONS_H_ 131