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; |
Alex Light | 53cb16b | 2014-06-12 11:26:29 -0700 | [diff] [blame] | 46 | static const bool kDefaultIncludePatchInformation = false; |
Brian Carlstrom | 6449c62 | 2014-02-10 23:48:36 -0800 | [diff] [blame] | 47 | |
| 48 | CompilerOptions() : |
| 49 | compiler_filter_(kDefaultCompilerFilter), |
| 50 | huge_method_threshold_(kDefaultHugeMethodThreshold), |
| 51 | large_method_threshold_(kDefaultLargeMethodThreshold), |
| 52 | small_method_threshold_(kDefaultSmallMethodThreshold), |
| 53 | tiny_method_threshold_(kDefaultTinyMethodThreshold), |
Mark Mendell | ae9fd93 | 2014-02-10 16:14:35 -0800 | [diff] [blame] | 54 | num_dex_methods_threshold_(kDefaultNumDexMethodsThreshold), |
Calin Juravle | c1b643c | 2014-05-30 23:44:11 +0100 | [diff] [blame] | 55 | generate_gdb_information_(false), |
Alex Light | 53cb16b | 2014-06-12 11:26:29 -0700 | [diff] [blame] | 56 | include_patch_information_(kDefaultIncludePatchInformation), |
Alex Light | 78382fa | 2014-06-06 15:45:32 -0700 | [diff] [blame] | 57 | top_k_profile_threshold_(kDefaultTopKProfileThreshold), |
Andreas Gampe | 5655e84 | 2014-06-17 16:36:07 -0700 | [diff] [blame] | 58 | include_debug_symbols_(kDefaultIncludeDebugSymbols), |
Dave Allison | 69dfe51 | 2014-07-11 17:11:58 +0000 | [diff] [blame^] | 59 | implicit_null_checks_(false), |
| 60 | implicit_so_checks_(false), |
| 61 | implicit_suspend_checks_(false) |
Brian Carlstrom | 6449c62 | 2014-02-10 23:48:36 -0800 | [diff] [blame] | 62 | #ifdef ART_SEA_IR_MODE |
| 63 | , sea_ir_mode_(false) |
| 64 | #endif |
| 65 | {} |
| 66 | |
| 67 | CompilerOptions(CompilerFilter compiler_filter, |
| 68 | size_t huge_method_threshold, |
| 69 | size_t large_method_threshold, |
| 70 | size_t small_method_threshold, |
| 71 | size_t tiny_method_threshold, |
Mark Mendell | ae9fd93 | 2014-02-10 16:14:35 -0800 | [diff] [blame] | 72 | size_t num_dex_methods_threshold, |
Calin Juravle | c1b643c | 2014-05-30 23:44:11 +0100 | [diff] [blame] | 73 | bool generate_gdb_information, |
Alex Light | 53cb16b | 2014-06-12 11:26:29 -0700 | [diff] [blame] | 74 | bool include_patch_information, |
Alex Light | 78382fa | 2014-06-06 15:45:32 -0700 | [diff] [blame] | 75 | double top_k_profile_threshold, |
Andreas Gampe | 5655e84 | 2014-06-17 16:36:07 -0700 | [diff] [blame] | 76 | bool include_debug_symbols, |
Dave Allison | 69dfe51 | 2014-07-11 17:11:58 +0000 | [diff] [blame^] | 77 | bool implicit_null_checks, |
| 78 | bool implicit_so_checks, |
| 79 | bool implicit_suspend_checks |
Brian Carlstrom | 6449c62 | 2014-02-10 23:48:36 -0800 | [diff] [blame] | 80 | #ifdef ART_SEA_IR_MODE |
| 81 | , bool sea_ir_mode |
| 82 | #endif |
| 83 | ) : // NOLINT(whitespace/parens) |
| 84 | compiler_filter_(compiler_filter), |
| 85 | huge_method_threshold_(huge_method_threshold), |
| 86 | large_method_threshold_(large_method_threshold), |
| 87 | small_method_threshold_(small_method_threshold), |
| 88 | tiny_method_threshold_(tiny_method_threshold), |
Mark Mendell | ae9fd93 | 2014-02-10 16:14:35 -0800 | [diff] [blame] | 89 | num_dex_methods_threshold_(num_dex_methods_threshold), |
Calin Juravle | c1b643c | 2014-05-30 23:44:11 +0100 | [diff] [blame] | 90 | generate_gdb_information_(generate_gdb_information), |
Alex Light | 53cb16b | 2014-06-12 11:26:29 -0700 | [diff] [blame] | 91 | include_patch_information_(include_patch_information), |
Alex Light | 78382fa | 2014-06-06 15:45:32 -0700 | [diff] [blame] | 92 | top_k_profile_threshold_(top_k_profile_threshold), |
Andreas Gampe | 5655e84 | 2014-06-17 16:36:07 -0700 | [diff] [blame] | 93 | include_debug_symbols_(include_debug_symbols), |
Dave Allison | 69dfe51 | 2014-07-11 17:11:58 +0000 | [diff] [blame^] | 94 | implicit_null_checks_(implicit_null_checks), |
| 95 | implicit_so_checks_(implicit_so_checks), |
| 96 | implicit_suspend_checks_(implicit_suspend_checks) |
Brian Carlstrom | 6449c62 | 2014-02-10 23:48:36 -0800 | [diff] [blame] | 97 | #ifdef ART_SEA_IR_MODE |
| 98 | , sea_ir_mode_(sea_ir_mode) |
| 99 | #endif |
| 100 | {} |
| 101 | |
| 102 | CompilerFilter GetCompilerFilter() const { |
| 103 | return compiler_filter_; |
| 104 | } |
| 105 | |
| 106 | void SetCompilerFilter(CompilerFilter compiler_filter) { |
| 107 | compiler_filter_ = compiler_filter; |
| 108 | } |
| 109 | |
Jeff Hao | 4a200f5 | 2014-04-01 14:58:49 -0700 | [diff] [blame] | 110 | bool IsCompilationEnabled() const { |
| 111 | return ((compiler_filter_ != CompilerOptions::kVerifyNone) && |
| 112 | (compiler_filter_ != CompilerOptions::kInterpretOnly)); |
| 113 | } |
| 114 | |
| 115 | bool IsVerificationEnabled() const { |
| 116 | return (compiler_filter_ != CompilerOptions::kVerifyNone); |
| 117 | } |
| 118 | |
Brian Carlstrom | 6449c62 | 2014-02-10 23:48:36 -0800 | [diff] [blame] | 119 | size_t GetHugeMethodThreshold() const { |
| 120 | return huge_method_threshold_; |
| 121 | } |
| 122 | |
| 123 | size_t GetLargeMethodThreshold() const { |
| 124 | return large_method_threshold_; |
| 125 | } |
| 126 | |
| 127 | size_t GetSmallMethodThreshold() const { |
| 128 | return small_method_threshold_; |
| 129 | } |
| 130 | |
| 131 | size_t GetTinyMethodThreshold() const { |
| 132 | return tiny_method_threshold_; |
| 133 | } |
| 134 | |
| 135 | bool IsHugeMethod(size_t num_dalvik_instructions) const { |
| 136 | return num_dalvik_instructions > huge_method_threshold_; |
| 137 | } |
| 138 | |
| 139 | bool IsLargeMethod(size_t num_dalvik_instructions) const { |
| 140 | return num_dalvik_instructions > large_method_threshold_; |
| 141 | } |
| 142 | |
| 143 | bool IsSmallMethod(size_t num_dalvik_instructions) const { |
| 144 | return num_dalvik_instructions > small_method_threshold_; |
| 145 | } |
| 146 | |
| 147 | bool IsTinyMethod(size_t num_dalvik_instructions) const { |
| 148 | return num_dalvik_instructions > tiny_method_threshold_; |
| 149 | } |
| 150 | |
| 151 | size_t GetNumDexMethodsThreshold() const { |
| 152 | return num_dex_methods_threshold_; |
| 153 | } |
| 154 | |
Calin Juravle | c1b643c | 2014-05-30 23:44:11 +0100 | [diff] [blame] | 155 | double GetTopKProfileThreshold() const { |
| 156 | return top_k_profile_threshold_; |
| 157 | } |
| 158 | |
Alex Light | 78382fa | 2014-06-06 15:45:32 -0700 | [diff] [blame] | 159 | bool GetIncludeDebugSymbols() const { |
| 160 | return include_debug_symbols_; |
| 161 | } |
| 162 | |
Dave Allison | 69dfe51 | 2014-07-11 17:11:58 +0000 | [diff] [blame^] | 163 | bool GetImplicitNullChecks() const { |
| 164 | return implicit_null_checks_; |
Andreas Gampe | 5655e84 | 2014-06-17 16:36:07 -0700 | [diff] [blame] | 165 | } |
| 166 | |
Dave Allison | 69dfe51 | 2014-07-11 17:11:58 +0000 | [diff] [blame^] | 167 | void SetImplicitNullChecks(bool new_val) { |
| 168 | implicit_null_checks_ = new_val; |
Andreas Gampe | 5655e84 | 2014-06-17 16:36:07 -0700 | [diff] [blame] | 169 | } |
| 170 | |
Dave Allison | 69dfe51 | 2014-07-11 17:11:58 +0000 | [diff] [blame^] | 171 | bool GetImplicitStackOverflowChecks() const { |
| 172 | return implicit_so_checks_; |
Andreas Gampe | 5655e84 | 2014-06-17 16:36:07 -0700 | [diff] [blame] | 173 | } |
| 174 | |
Dave Allison | 69dfe51 | 2014-07-11 17:11:58 +0000 | [diff] [blame^] | 175 | void SetImplicitStackOverflowChecks(bool new_val) { |
| 176 | implicit_so_checks_ = new_val; |
Andreas Gampe | 5655e84 | 2014-06-17 16:36:07 -0700 | [diff] [blame] | 177 | } |
| 178 | |
Dave Allison | 69dfe51 | 2014-07-11 17:11:58 +0000 | [diff] [blame^] | 179 | bool GetImplicitSuspendChecks() const { |
| 180 | return implicit_suspend_checks_; |
Andreas Gampe | 5655e84 | 2014-06-17 16:36:07 -0700 | [diff] [blame] | 181 | } |
| 182 | |
Dave Allison | 69dfe51 | 2014-07-11 17:11:58 +0000 | [diff] [blame^] | 183 | void SetImplicitSuspendChecks(bool new_val) { |
| 184 | implicit_suspend_checks_ = new_val; |
Andreas Gampe | 5655e84 | 2014-06-17 16:36:07 -0700 | [diff] [blame] | 185 | } |
| 186 | |
Brian Carlstrom | 6449c62 | 2014-02-10 23:48:36 -0800 | [diff] [blame] | 187 | #ifdef ART_SEA_IR_MODE |
| 188 | bool GetSeaIrMode(); |
| 189 | #endif |
| 190 | |
Mark Mendell | ae9fd93 | 2014-02-10 16:14:35 -0800 | [diff] [blame] | 191 | bool GetGenerateGDBInformation() const { |
| 192 | return generate_gdb_information_; |
| 193 | } |
| 194 | |
Alex Light | 53cb16b | 2014-06-12 11:26:29 -0700 | [diff] [blame] | 195 | bool GetIncludePatchInformation() const { |
| 196 | return include_patch_information_; |
| 197 | } |
| 198 | |
Brian Carlstrom | 6449c62 | 2014-02-10 23:48:36 -0800 | [diff] [blame] | 199 | private: |
| 200 | CompilerFilter compiler_filter_; |
| 201 | size_t huge_method_threshold_; |
| 202 | size_t large_method_threshold_; |
| 203 | size_t small_method_threshold_; |
| 204 | size_t tiny_method_threshold_; |
| 205 | size_t num_dex_methods_threshold_; |
Mark Mendell | ae9fd93 | 2014-02-10 16:14:35 -0800 | [diff] [blame] | 206 | bool generate_gdb_information_; |
Alex Light | 53cb16b | 2014-06-12 11:26:29 -0700 | [diff] [blame] | 207 | bool include_patch_information_; |
Calin Juravle | c1b643c | 2014-05-30 23:44:11 +0100 | [diff] [blame] | 208 | // When using a profile file only the top K% of the profiled samples will be compiled. |
| 209 | double top_k_profile_threshold_; |
Alex Light | 78382fa | 2014-06-06 15:45:32 -0700 | [diff] [blame] | 210 | bool include_debug_symbols_; |
Dave Allison | 69dfe51 | 2014-07-11 17:11:58 +0000 | [diff] [blame^] | 211 | bool implicit_null_checks_; |
| 212 | bool implicit_so_checks_; |
| 213 | bool implicit_suspend_checks_; |
Brian Carlstrom | 6449c62 | 2014-02-10 23:48:36 -0800 | [diff] [blame] | 214 | #ifdef ART_SEA_IR_MODE |
| 215 | bool sea_ir_mode_; |
| 216 | #endif |
| 217 | }; |
| 218 | |
| 219 | } // namespace art |
| 220 | |
| 221 | #endif // ART_COMPILER_DRIVER_COMPILER_OPTIONS_H_ |