1491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom/* 2491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom * Copyright (C) 2011 The Android Open Source Project 3491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom * 4491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom * Licensed under the Apache License, Version 2.0 (the "License"); 5491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom * you may not use this file except in compliance with the License. 6491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom * You may obtain a copy of the License at 7491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom * 8491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom * http://www.apache.org/licenses/LICENSE-2.0 9491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom * 10491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom * Unless required by applicable law or agreed to in writing, software 11491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom * distributed under the License is distributed on an "AS IS" BASIS, 12491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom * See the License for the specific language governing permissions and 14491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom * limitations under the License. 15491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom */ 16491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom 17491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom#ifndef ART_RUNTIME_PARSED_OPTIONS_H_ 18491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom#define ART_RUNTIME_PARSED_OPTIONS_H_ 19491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom 20491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom#include <string> 21e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers#include <vector> 22491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom 23e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers#include <jni.h> 24e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers 25e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers#include "globals.h" 26576ca0cd692c0b6ae70e776de91015b8ff000a08Ian Rogers#include "gc/collector_type.h" 27e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers#include "instruction_set.h" 28e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers#include "profiler_options.h" 29491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom 30491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstromnamespace art { 31491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom 32e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogersclass CompilerCallbacks; 33e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogersclass DexFile; 34e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers 35e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogerstypedef std::vector<std::pair<std::string, const void*>> RuntimeOptions; 36e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers 37491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstromclass ParsedOptions { 38491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom public: 39491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom // returns null if problem parsing and ignore_unrecognized is false 40e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers static ParsedOptions* Create(const RuntimeOptions& options, bool ignore_unrecognized); 41491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom 42491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom const std::vector<const DexFile*>* boot_class_path_; 43491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom std::string boot_class_path_string_; 44491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom std::string class_path_string_; 45491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom std::string image_; 46491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom bool check_jni_; 47491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom std::string jni_trace_; 48ccdd4a5be1db2588767ed230b7064e5fe802ce8dCalin Juravle std::string native_bridge_library_filename_; 49491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom CompilerCallbacks* compiler_callbacks_; 50491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom bool is_zygote_; 51a59dd80f9f48cb750d329d4d4af2d99d72b484d1Alex Light bool must_relocate_; 529c290012b7f505ae1943ab87236f775b97a46e2dNicolas Geoffray bool dex2oat_enabled_; 53507e6180ad271eb719c67ce7394852c731d975a5Alex Light bool image_dex2oat_enabled_; 54a59dd80f9f48cb750d329d4d4af2d99d72b484d1Alex Light std::string patchoat_executable_; 55491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom bool interpreter_only_; 56491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom bool is_explicit_gc_disabled_; 57491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom bool use_tlab_; 58491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom bool verify_pre_gc_heap_; 596f365cc033654a5a3b45eaa1379d4b5f156b0ceeMathieu Chartier bool verify_pre_sweeping_heap_; 60491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom bool verify_post_gc_heap_; 61491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom bool verify_pre_gc_rosalloc_; 626f365cc033654a5a3b45eaa1379d4b5f156b0ceeMathieu Chartier bool verify_pre_sweeping_rosalloc_; 63491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom bool verify_post_gc_rosalloc_; 6439d921865c207bd315daa372759e75b454cbcae1Andreas Gampe unsigned int long_pause_log_threshold_; 6539d921865c207bd315daa372759e75b454cbcae1Andreas Gampe unsigned int long_gc_log_threshold_; 66491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom bool dump_gc_performance_on_shutdown_; 67491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom bool ignore_max_footprint_; 68491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom size_t heap_initial_size_; 69491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom size_t heap_maximum_size_; 70491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom size_t heap_growth_limit_; 71491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom size_t heap_min_free_; 72491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom size_t heap_max_free_; 734c5a469683e433f126c9863cd393747d2e7c4a29Mathieu Chartier size_t heap_non_moving_space_capacity_; 74491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom double heap_target_utilization_; 752f8da3e9ff60e5cb2a3fdf57dbcb67f513b9c2c2Mathieu Chartier double foreground_heap_growth_multiplier_; 7639d921865c207bd315daa372759e75b454cbcae1Andreas Gampe unsigned int parallel_gc_threads_; 7739d921865c207bd315daa372759e75b454cbcae1Andreas Gampe unsigned int conc_gc_threads_; 78491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom gc::CollectorType collector_type_; 79491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom gc::CollectorType background_collector_type_; 80491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom size_t stack_size_; 8139d921865c207bd315daa372759e75b454cbcae1Andreas Gampe unsigned int max_spins_before_thin_lock_inflation_; 82491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom bool low_memory_mode_; 8339d921865c207bd315daa372759e75b454cbcae1Andreas Gampe unsigned int lock_profiling_threshold_; 84491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom std::string stack_trace_file_; 85491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom bool method_trace_; 86491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom std::string method_trace_file_; 8739d921865c207bd315daa372759e75b454cbcae1Andreas Gampe unsigned int method_trace_file_size_; 88491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom bool (*hook_is_sensitive_thread_)(); 89491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom jint (*hook_vfprintf_)(FILE* stream, const char* format, va_list ap); 90491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom void (*hook_exit_)(jint status); 91491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom void (*hook_abort_)(); 92491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom std::vector<std::string> properties_; 9312e6d7446384a7a5fbec25fe116bbb271c62842eTsu Chiang Chuang std::string compiler_executable_; 94491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom std::vector<std::string> compiler_options_; 95491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom std::vector<std::string> image_compiler_options_; 96c1b643cc6ac45dbd0eabdcd7425c7e86006c27d6Calin Juravle ProfilerOptions profiler_options_; 97491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom std::string profile_output_filename_; 98e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers TraceClockSource profile_clock_source_; 994a200f56b7075309316b04d550c9cc50f8314eddJeff Hao bool verify_; 10011d9f06a96a6909905c248ed684366190140095cNarayan Kamath InstructionSet image_isa_; 101491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom 102f37a88b8e6db6c587fa449a12e40cb46be1689fcZuo Wang // Whether or not we use homogeneous space compaction to avoid OOM errors. If enabled, 103f37a88b8e6db6c587fa449a12e40cb46be1689fcZuo Wang // the heap will attempt to create an extra space which enables compacting from a malloc space to 104f37a88b8e6db6c587fa449a12e40cb46be1689fcZuo Wang // another malloc space when we are about to throw OOM. 105f37a88b8e6db6c587fa449a12e40cb46be1689fcZuo Wang bool use_homogeneous_space_compaction_for_oom_; 106f37a88b8e6db6c587fa449a12e40cb46be1689fcZuo Wang // Minimal interval allowed between two homogeneous space compactions caused by OOM. 107f37a88b8e6db6c587fa449a12e40cb46be1689fcZuo Wang uint64_t min_interval_homogeneous_space_compaction_by_oom_; 1080025a86411145eb7cd4971f9234fc21c7b4aced1Nicolas Geoffray 109491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom private: 110491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom ParsedOptions() {} 111491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom 112491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom void Usage(const char* fmt, ...); 113491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom void UsageMessage(FILE* stream, const char* fmt, ...); 114491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom void UsageMessageV(FILE* stream, const char* fmt, va_list ap); 115491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom 116491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom void Exit(int status); 117491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom void Abort(); 118491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom 119e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers bool Parse(const RuntimeOptions& options, bool ignore_unrecognized); 1206f365cc033654a5a3b45eaa1379d4b5f156b0ceeMathieu Chartier bool ParseXGcOption(const std::string& option); 121491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom bool ParseStringAfterChar(const std::string& option, char after_char, std::string* parsed_value); 122491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom bool ParseInteger(const std::string& option, char after_char, int* parsed_value); 123491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom bool ParseUnsignedInteger(const std::string& option, char after_char, unsigned int* parsed_value); 124491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom bool ParseDouble(const std::string& option, char after_char, double min, double max, 125491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom double* parsed_value); 126491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom}; 127491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom 128491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom} // namespace art 129491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom 130491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom#endif // ART_RUNTIME_PARSED_OPTIONS_H_ 131