Brian Carlstrom | 6449c62 | 2014-02-10 23:48:36 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 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_COMPILER_DRIVER_COMPILER_OPTIONS_H_ |
| 18 | #define ART_COMPILER_DRIVER_COMPILER_OPTIONS_H_ |
| 19 | |
| 20 | namespace art { |
| 21 | |
| 22 | class CompilerOptions { |
| 23 | public: |
| 24 | enum CompilerFilter { |
Jeff Hao | 4a200f5 | 2014-04-01 14:58:49 -0700 | [diff] [blame] | 25 | kVerifyNone, // Skip verification and compile nothing except JNI stubs. |
| 26 | kInterpretOnly, // Compile nothing except JNI stubs. |
Brian Carlstrom | 6449c62 | 2014-02-10 23:48:36 -0800 | [diff] [blame] | 27 | kSpace, // Maximize space savings. |
| 28 | kBalanced, // Try to get the best performance return on compilation investment. |
| 29 | kSpeed, // Maximize runtime performance. |
| 30 | kEverything // Force compilation (Note: excludes compilaton of class initializers). |
| 31 | }; |
| 32 | |
| 33 | // Guide heuristics to determine whether to compile method if profile data not available. |
Dave Allison | 39c3bfb | 2014-01-28 18:33:52 -0800 | [diff] [blame] | 34 | #if ART_SMALL_MODE |
Calin Juravle | c1b643c | 2014-05-30 23:44:11 +0100 | [diff] [blame] | 35 | static const CompilerFilter kDefaultCompilerFilter = kInterpretOnly; |
Dave Allison | 39c3bfb | 2014-01-28 18:33:52 -0800 | [diff] [blame] | 36 | #else |
Brian Carlstrom | 6449c62 | 2014-02-10 23:48:36 -0800 | [diff] [blame] | 37 | static const CompilerFilter kDefaultCompilerFilter = kSpeed; |
Dave Allison | 39c3bfb | 2014-01-28 18:33:52 -0800 | [diff] [blame] | 38 | #endif |
Brian Carlstrom | 6449c62 | 2014-02-10 23:48:36 -0800 | [diff] [blame] | 39 | static const size_t kDefaultHugeMethodThreshold = 10000; |
| 40 | static const size_t kDefaultLargeMethodThreshold = 600; |
| 41 | static const size_t kDefaultSmallMethodThreshold = 60; |
| 42 | static const size_t kDefaultTinyMethodThreshold = 20; |
| 43 | static const size_t kDefaultNumDexMethodsThreshold = 900; |
Calin Juravle | c1b643c | 2014-05-30 23:44:11 +0100 | [diff] [blame] | 44 | static constexpr double kDefaultTopKProfileThreshold = 90.0; |
Alex Light | 78382fa | 2014-06-06 15:45:32 -0700 | [diff] [blame] | 45 | static const bool kDefaultIncludeDebugSymbols = kIsDebugBuild; |
Brian Carlstrom | 6449c62 | 2014-02-10 23:48:36 -0800 | [diff] [blame] | 46 | |
| 47 | CompilerOptions() : |
| 48 | compiler_filter_(kDefaultCompilerFilter), |
| 49 | huge_method_threshold_(kDefaultHugeMethodThreshold), |
| 50 | large_method_threshold_(kDefaultLargeMethodThreshold), |
| 51 | small_method_threshold_(kDefaultSmallMethodThreshold), |
| 52 | tiny_method_threshold_(kDefaultTinyMethodThreshold), |
Mark Mendell | ae9fd93 | 2014-02-10 16:14:35 -0800 | [diff] [blame] | 53 | num_dex_methods_threshold_(kDefaultNumDexMethodsThreshold), |
Calin Juravle | c1b643c | 2014-05-30 23:44:11 +0100 | [diff] [blame] | 54 | generate_gdb_information_(false), |
Alex Light | 78382fa | 2014-06-06 15:45:32 -0700 | [diff] [blame] | 55 | top_k_profile_threshold_(kDefaultTopKProfileThreshold), |
Andreas Gampe | 5655e84 | 2014-06-17 16:36:07 -0700 | [diff] [blame^] | 56 | include_debug_symbols_(kDefaultIncludeDebugSymbols), |
| 57 | explicit_null_checks_(true), |
| 58 | explicit_so_checks_(true), |
| 59 | explicit_suspend_checks_(true) |
Brian Carlstrom | 6449c62 | 2014-02-10 23:48:36 -0800 | [diff] [blame] | 60 | #ifdef ART_SEA_IR_MODE |
| 61 | , sea_ir_mode_(false) |
| 62 | #endif |
| 63 | {} |
| 64 | |
| 65 | CompilerOptions(CompilerFilter compiler_filter, |
| 66 | size_t huge_method_threshold, |
| 67 | size_t large_method_threshold, |
| 68 | size_t small_method_threshold, |
| 69 | size_t tiny_method_threshold, |
Mark Mendell | ae9fd93 | 2014-02-10 16:14:35 -0800 | [diff] [blame] | 70 | size_t num_dex_methods_threshold, |
Calin Juravle | c1b643c | 2014-05-30 23:44:11 +0100 | [diff] [blame] | 71 | bool generate_gdb_information, |
Alex Light | 78382fa | 2014-06-06 15:45:32 -0700 | [diff] [blame] | 72 | double top_k_profile_threshold, |
Andreas Gampe | 5655e84 | 2014-06-17 16:36:07 -0700 | [diff] [blame^] | 73 | bool include_debug_symbols, |
| 74 | bool explicit_null_checks, |
| 75 | bool explicit_so_checks, |
| 76 | bool explicit_suspend_checks |
Brian Carlstrom | 6449c62 | 2014-02-10 23:48:36 -0800 | [diff] [blame] | 77 | #ifdef ART_SEA_IR_MODE |
| 78 | , bool sea_ir_mode |
| 79 | #endif |
| 80 | ) : // NOLINT(whitespace/parens) |
| 81 | compiler_filter_(compiler_filter), |
| 82 | huge_method_threshold_(huge_method_threshold), |
| 83 | large_method_threshold_(large_method_threshold), |
| 84 | small_method_threshold_(small_method_threshold), |
| 85 | tiny_method_threshold_(tiny_method_threshold), |
Mark Mendell | ae9fd93 | 2014-02-10 16:14:35 -0800 | [diff] [blame] | 86 | num_dex_methods_threshold_(num_dex_methods_threshold), |
Calin Juravle | c1b643c | 2014-05-30 23:44:11 +0100 | [diff] [blame] | 87 | generate_gdb_information_(generate_gdb_information), |
Alex Light | 78382fa | 2014-06-06 15:45:32 -0700 | [diff] [blame] | 88 | top_k_profile_threshold_(top_k_profile_threshold), |
Andreas Gampe | 5655e84 | 2014-06-17 16:36:07 -0700 | [diff] [blame^] | 89 | include_debug_symbols_(include_debug_symbols), |
| 90 | explicit_null_checks_(explicit_null_checks), |
| 91 | explicit_so_checks_(explicit_so_checks), |
| 92 | explicit_suspend_checks_(explicit_suspend_checks) |
Brian Carlstrom | 6449c62 | 2014-02-10 23:48:36 -0800 | [diff] [blame] | 93 | #ifdef ART_SEA_IR_MODE |
| 94 | , sea_ir_mode_(sea_ir_mode) |
| 95 | #endif |
| 96 | {} |
| 97 | |
| 98 | CompilerFilter GetCompilerFilter() const { |
| 99 | return compiler_filter_; |
| 100 | } |
| 101 | |
| 102 | void SetCompilerFilter(CompilerFilter compiler_filter) { |
| 103 | compiler_filter_ = compiler_filter; |
| 104 | } |
| 105 | |
Jeff Hao | 4a200f5 | 2014-04-01 14:58:49 -0700 | [diff] [blame] | 106 | bool IsCompilationEnabled() const { |
| 107 | return ((compiler_filter_ != CompilerOptions::kVerifyNone) && |
| 108 | (compiler_filter_ != CompilerOptions::kInterpretOnly)); |
| 109 | } |
| 110 | |
| 111 | bool IsVerificationEnabled() const { |
| 112 | return (compiler_filter_ != CompilerOptions::kVerifyNone); |
| 113 | } |
| 114 | |
Brian Carlstrom | 6449c62 | 2014-02-10 23:48:36 -0800 | [diff] [blame] | 115 | size_t GetHugeMethodThreshold() const { |
| 116 | return huge_method_threshold_; |
| 117 | } |
| 118 | |
| 119 | size_t GetLargeMethodThreshold() const { |
| 120 | return large_method_threshold_; |
| 121 | } |
| 122 | |
| 123 | size_t GetSmallMethodThreshold() const { |
| 124 | return small_method_threshold_; |
| 125 | } |
| 126 | |
| 127 | size_t GetTinyMethodThreshold() const { |
| 128 | return tiny_method_threshold_; |
| 129 | } |
| 130 | |
| 131 | bool IsHugeMethod(size_t num_dalvik_instructions) const { |
| 132 | return num_dalvik_instructions > huge_method_threshold_; |
| 133 | } |
| 134 | |
| 135 | bool IsLargeMethod(size_t num_dalvik_instructions) const { |
| 136 | return num_dalvik_instructions > large_method_threshold_; |
| 137 | } |
| 138 | |
| 139 | bool IsSmallMethod(size_t num_dalvik_instructions) const { |
| 140 | return num_dalvik_instructions > small_method_threshold_; |
| 141 | } |
| 142 | |
| 143 | bool IsTinyMethod(size_t num_dalvik_instructions) const { |
| 144 | return num_dalvik_instructions > tiny_method_threshold_; |
| 145 | } |
| 146 | |
| 147 | size_t GetNumDexMethodsThreshold() const { |
| 148 | return num_dex_methods_threshold_; |
| 149 | } |
| 150 | |
Calin Juravle | c1b643c | 2014-05-30 23:44:11 +0100 | [diff] [blame] | 151 | double GetTopKProfileThreshold() const { |
| 152 | return top_k_profile_threshold_; |
| 153 | } |
| 154 | |
Alex Light | 78382fa | 2014-06-06 15:45:32 -0700 | [diff] [blame] | 155 | bool GetIncludeDebugSymbols() const { |
| 156 | return include_debug_symbols_; |
| 157 | } |
| 158 | |
Andreas Gampe | 5655e84 | 2014-06-17 16:36:07 -0700 | [diff] [blame^] | 159 | bool GetExplicitNullChecks() const { |
| 160 | return explicit_null_checks_; |
| 161 | } |
| 162 | |
| 163 | void SetExplicitNullChecks(bool new_val) { |
| 164 | explicit_null_checks_ = new_val; |
| 165 | } |
| 166 | |
| 167 | bool GetExplicitStackOverflowChecks() const { |
| 168 | return explicit_so_checks_; |
| 169 | } |
| 170 | |
| 171 | void SetExplicitStackOverflowChecks(bool new_val) { |
| 172 | explicit_so_checks_ = new_val; |
| 173 | } |
| 174 | |
| 175 | bool GetExplicitSuspendChecks() const { |
| 176 | return explicit_suspend_checks_; |
| 177 | } |
| 178 | |
| 179 | void SetExplicitSuspendChecks(bool new_val) { |
| 180 | explicit_suspend_checks_ = new_val; |
| 181 | } |
| 182 | |
Brian Carlstrom | 6449c62 | 2014-02-10 23:48:36 -0800 | [diff] [blame] | 183 | #ifdef ART_SEA_IR_MODE |
| 184 | bool GetSeaIrMode(); |
| 185 | #endif |
| 186 | |
Mark Mendell | ae9fd93 | 2014-02-10 16:14:35 -0800 | [diff] [blame] | 187 | bool GetGenerateGDBInformation() const { |
| 188 | return generate_gdb_information_; |
| 189 | } |
| 190 | |
Brian Carlstrom | 6449c62 | 2014-02-10 23:48:36 -0800 | [diff] [blame] | 191 | private: |
| 192 | CompilerFilter compiler_filter_; |
| 193 | size_t huge_method_threshold_; |
| 194 | size_t large_method_threshold_; |
| 195 | size_t small_method_threshold_; |
| 196 | size_t tiny_method_threshold_; |
| 197 | size_t num_dex_methods_threshold_; |
Mark Mendell | ae9fd93 | 2014-02-10 16:14:35 -0800 | [diff] [blame] | 198 | bool generate_gdb_information_; |
Calin Juravle | c1b643c | 2014-05-30 23:44:11 +0100 | [diff] [blame] | 199 | // When using a profile file only the top K% of the profiled samples will be compiled. |
| 200 | double top_k_profile_threshold_; |
Alex Light | 78382fa | 2014-06-06 15:45:32 -0700 | [diff] [blame] | 201 | bool include_debug_symbols_; |
Andreas Gampe | 5655e84 | 2014-06-17 16:36:07 -0700 | [diff] [blame^] | 202 | bool explicit_null_checks_; |
| 203 | bool explicit_so_checks_; |
| 204 | bool explicit_suspend_checks_; |
Brian Carlstrom | 6449c62 | 2014-02-10 23:48:36 -0800 | [diff] [blame] | 205 | #ifdef ART_SEA_IR_MODE |
| 206 | bool sea_ir_mode_; |
| 207 | #endif |
| 208 | }; |
| 209 | |
| 210 | } // namespace art |
| 211 | |
| 212 | #endif // ART_COMPILER_DRIVER_COMPILER_OPTIONS_H_ |