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), |
| 56 | include_debug_symbols_(kDefaultIncludeDebugSymbols) |
Brian Carlstrom | 6449c62 | 2014-02-10 23:48:36 -0800 | [diff] [blame] | 57 | #ifdef ART_SEA_IR_MODE |
| 58 | , sea_ir_mode_(false) |
| 59 | #endif |
| 60 | {} |
| 61 | |
| 62 | CompilerOptions(CompilerFilter compiler_filter, |
| 63 | size_t huge_method_threshold, |
| 64 | size_t large_method_threshold, |
| 65 | size_t small_method_threshold, |
| 66 | size_t tiny_method_threshold, |
Mark Mendell | ae9fd93 | 2014-02-10 16:14:35 -0800 | [diff] [blame] | 67 | size_t num_dex_methods_threshold, |
Calin Juravle | c1b643c | 2014-05-30 23:44:11 +0100 | [diff] [blame] | 68 | bool generate_gdb_information, |
Alex Light | 78382fa | 2014-06-06 15:45:32 -0700 | [diff] [blame] | 69 | double top_k_profile_threshold, |
| 70 | bool include_debug_symbols |
Brian Carlstrom | 6449c62 | 2014-02-10 23:48:36 -0800 | [diff] [blame] | 71 | #ifdef ART_SEA_IR_MODE |
| 72 | , bool sea_ir_mode |
| 73 | #endif |
| 74 | ) : // NOLINT(whitespace/parens) |
| 75 | compiler_filter_(compiler_filter), |
| 76 | huge_method_threshold_(huge_method_threshold), |
| 77 | large_method_threshold_(large_method_threshold), |
| 78 | small_method_threshold_(small_method_threshold), |
| 79 | tiny_method_threshold_(tiny_method_threshold), |
Mark Mendell | ae9fd93 | 2014-02-10 16:14:35 -0800 | [diff] [blame] | 80 | num_dex_methods_threshold_(num_dex_methods_threshold), |
Calin Juravle | c1b643c | 2014-05-30 23:44:11 +0100 | [diff] [blame] | 81 | generate_gdb_information_(generate_gdb_information), |
Alex Light | 78382fa | 2014-06-06 15:45:32 -0700 | [diff] [blame] | 82 | top_k_profile_threshold_(top_k_profile_threshold), |
| 83 | include_debug_symbols_(include_debug_symbols) |
Brian Carlstrom | 6449c62 | 2014-02-10 23:48:36 -0800 | [diff] [blame] | 84 | #ifdef ART_SEA_IR_MODE |
| 85 | , sea_ir_mode_(sea_ir_mode) |
| 86 | #endif |
| 87 | {} |
| 88 | |
| 89 | CompilerFilter GetCompilerFilter() const { |
| 90 | return compiler_filter_; |
| 91 | } |
| 92 | |
| 93 | void SetCompilerFilter(CompilerFilter compiler_filter) { |
| 94 | compiler_filter_ = compiler_filter; |
| 95 | } |
| 96 | |
Jeff Hao | 4a200f5 | 2014-04-01 14:58:49 -0700 | [diff] [blame] | 97 | bool IsCompilationEnabled() const { |
| 98 | return ((compiler_filter_ != CompilerOptions::kVerifyNone) && |
| 99 | (compiler_filter_ != CompilerOptions::kInterpretOnly)); |
| 100 | } |
| 101 | |
| 102 | bool IsVerificationEnabled() const { |
| 103 | return (compiler_filter_ != CompilerOptions::kVerifyNone); |
| 104 | } |
| 105 | |
Brian Carlstrom | 6449c62 | 2014-02-10 23:48:36 -0800 | [diff] [blame] | 106 | size_t GetHugeMethodThreshold() const { |
| 107 | return huge_method_threshold_; |
| 108 | } |
| 109 | |
| 110 | size_t GetLargeMethodThreshold() const { |
| 111 | return large_method_threshold_; |
| 112 | } |
| 113 | |
| 114 | size_t GetSmallMethodThreshold() const { |
| 115 | return small_method_threshold_; |
| 116 | } |
| 117 | |
| 118 | size_t GetTinyMethodThreshold() const { |
| 119 | return tiny_method_threshold_; |
| 120 | } |
| 121 | |
| 122 | bool IsHugeMethod(size_t num_dalvik_instructions) const { |
| 123 | return num_dalvik_instructions > huge_method_threshold_; |
| 124 | } |
| 125 | |
| 126 | bool IsLargeMethod(size_t num_dalvik_instructions) const { |
| 127 | return num_dalvik_instructions > large_method_threshold_; |
| 128 | } |
| 129 | |
| 130 | bool IsSmallMethod(size_t num_dalvik_instructions) const { |
| 131 | return num_dalvik_instructions > small_method_threshold_; |
| 132 | } |
| 133 | |
| 134 | bool IsTinyMethod(size_t num_dalvik_instructions) const { |
| 135 | return num_dalvik_instructions > tiny_method_threshold_; |
| 136 | } |
| 137 | |
| 138 | size_t GetNumDexMethodsThreshold() const { |
| 139 | return num_dex_methods_threshold_; |
| 140 | } |
| 141 | |
Calin Juravle | c1b643c | 2014-05-30 23:44:11 +0100 | [diff] [blame] | 142 | double GetTopKProfileThreshold() const { |
| 143 | return top_k_profile_threshold_; |
| 144 | } |
| 145 | |
Alex Light | 78382fa | 2014-06-06 15:45:32 -0700 | [diff] [blame] | 146 | bool GetIncludeDebugSymbols() const { |
| 147 | return include_debug_symbols_; |
| 148 | } |
| 149 | |
Brian Carlstrom | 6449c62 | 2014-02-10 23:48:36 -0800 | [diff] [blame] | 150 | #ifdef ART_SEA_IR_MODE |
| 151 | bool GetSeaIrMode(); |
| 152 | #endif |
| 153 | |
Mark Mendell | ae9fd93 | 2014-02-10 16:14:35 -0800 | [diff] [blame] | 154 | bool GetGenerateGDBInformation() const { |
| 155 | return generate_gdb_information_; |
| 156 | } |
| 157 | |
Brian Carlstrom | 6449c62 | 2014-02-10 23:48:36 -0800 | [diff] [blame] | 158 | private: |
| 159 | CompilerFilter compiler_filter_; |
| 160 | size_t huge_method_threshold_; |
| 161 | size_t large_method_threshold_; |
| 162 | size_t small_method_threshold_; |
| 163 | size_t tiny_method_threshold_; |
| 164 | size_t num_dex_methods_threshold_; |
Mark Mendell | ae9fd93 | 2014-02-10 16:14:35 -0800 | [diff] [blame] | 165 | bool generate_gdb_information_; |
Calin Juravle | c1b643c | 2014-05-30 23:44:11 +0100 | [diff] [blame] | 166 | // When using a profile file only the top K% of the profiled samples will be compiled. |
| 167 | double top_k_profile_threshold_; |
Alex Light | 78382fa | 2014-06-06 15:45:32 -0700 | [diff] [blame] | 168 | bool include_debug_symbols_; |
Brian Carlstrom | 6449c62 | 2014-02-10 23:48:36 -0800 | [diff] [blame] | 169 | #ifdef ART_SEA_IR_MODE |
| 170 | bool sea_ir_mode_; |
| 171 | #endif |
| 172 | }; |
| 173 | |
| 174 | } // namespace art |
| 175 | |
| 176 | #endif // ART_COMPILER_DRIVER_COMPILER_OPTIONS_H_ |