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. |
Dave Allison | 39c3bfb | 2014-01-28 18:33:52 -0800 | [diff] [blame] | 27 | kProfiled, // Compile based on profile. |
Brian Carlstrom | 6449c62 | 2014-02-10 23:48:36 -0800 | [diff] [blame] | 28 | kSpace, // Maximize space savings. |
| 29 | kBalanced, // Try to get the best performance return on compilation investment. |
| 30 | kSpeed, // Maximize runtime performance. |
| 31 | kEverything // Force compilation (Note: excludes compilaton of class initializers). |
| 32 | }; |
| 33 | |
| 34 | // 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] | 35 | #if ART_SMALL_MODE |
| 36 | static const CompilerFilter kDefaultCompilerFilter = kProfiled; |
| 37 | #else |
Brian Carlstrom | 6449c62 | 2014-02-10 23:48:36 -0800 | [diff] [blame] | 38 | static const CompilerFilter kDefaultCompilerFilter = kSpeed; |
Dave Allison | 39c3bfb | 2014-01-28 18:33:52 -0800 | [diff] [blame] | 39 | #endif |
Brian Carlstrom | 6449c62 | 2014-02-10 23:48:36 -0800 | [diff] [blame] | 40 | static const size_t kDefaultHugeMethodThreshold = 10000; |
| 41 | static const size_t kDefaultLargeMethodThreshold = 600; |
| 42 | static const size_t kDefaultSmallMethodThreshold = 60; |
| 43 | static const size_t kDefaultTinyMethodThreshold = 20; |
| 44 | static const size_t kDefaultNumDexMethodsThreshold = 900; |
| 45 | |
| 46 | CompilerOptions() : |
| 47 | compiler_filter_(kDefaultCompilerFilter), |
| 48 | huge_method_threshold_(kDefaultHugeMethodThreshold), |
| 49 | large_method_threshold_(kDefaultLargeMethodThreshold), |
| 50 | small_method_threshold_(kDefaultSmallMethodThreshold), |
| 51 | tiny_method_threshold_(kDefaultTinyMethodThreshold), |
Mark Mendell | ae9fd93 | 2014-02-10 16:14:35 -0800 | [diff] [blame] | 52 | num_dex_methods_threshold_(kDefaultNumDexMethodsThreshold), |
Dave Allison | d6ed642 | 2014-04-09 23:36:15 +0000 | [diff] [blame^] | 53 | generate_gdb_information_(false) |
Brian Carlstrom | 6449c62 | 2014-02-10 23:48:36 -0800 | [diff] [blame] | 54 | #ifdef ART_SEA_IR_MODE |
| 55 | , sea_ir_mode_(false) |
| 56 | #endif |
| 57 | {} |
| 58 | |
| 59 | CompilerOptions(CompilerFilter compiler_filter, |
| 60 | size_t huge_method_threshold, |
| 61 | size_t large_method_threshold, |
| 62 | size_t small_method_threshold, |
| 63 | size_t tiny_method_threshold, |
Mark Mendell | ae9fd93 | 2014-02-10 16:14:35 -0800 | [diff] [blame] | 64 | size_t num_dex_methods_threshold, |
Dave Allison | d6ed642 | 2014-04-09 23:36:15 +0000 | [diff] [blame^] | 65 | bool generate_gdb_information |
Brian Carlstrom | 6449c62 | 2014-02-10 23:48:36 -0800 | [diff] [blame] | 66 | #ifdef ART_SEA_IR_MODE |
| 67 | , bool sea_ir_mode |
| 68 | #endif |
| 69 | ) : // NOLINT(whitespace/parens) |
| 70 | compiler_filter_(compiler_filter), |
| 71 | huge_method_threshold_(huge_method_threshold), |
| 72 | large_method_threshold_(large_method_threshold), |
| 73 | small_method_threshold_(small_method_threshold), |
| 74 | tiny_method_threshold_(tiny_method_threshold), |
Mark Mendell | ae9fd93 | 2014-02-10 16:14:35 -0800 | [diff] [blame] | 75 | num_dex_methods_threshold_(num_dex_methods_threshold), |
Dave Allison | d6ed642 | 2014-04-09 23:36:15 +0000 | [diff] [blame^] | 76 | generate_gdb_information_(generate_gdb_information) |
Brian Carlstrom | 6449c62 | 2014-02-10 23:48:36 -0800 | [diff] [blame] | 77 | #ifdef ART_SEA_IR_MODE |
| 78 | , sea_ir_mode_(sea_ir_mode) |
| 79 | #endif |
| 80 | {} |
| 81 | |
| 82 | CompilerFilter GetCompilerFilter() const { |
| 83 | return compiler_filter_; |
| 84 | } |
| 85 | |
| 86 | void SetCompilerFilter(CompilerFilter compiler_filter) { |
| 87 | compiler_filter_ = compiler_filter; |
| 88 | } |
| 89 | |
Jeff Hao | 4a200f5 | 2014-04-01 14:58:49 -0700 | [diff] [blame] | 90 | bool IsCompilationEnabled() const { |
| 91 | return ((compiler_filter_ != CompilerOptions::kVerifyNone) && |
| 92 | (compiler_filter_ != CompilerOptions::kInterpretOnly)); |
| 93 | } |
| 94 | |
| 95 | bool IsVerificationEnabled() const { |
| 96 | return (compiler_filter_ != CompilerOptions::kVerifyNone); |
| 97 | } |
| 98 | |
Brian Carlstrom | 6449c62 | 2014-02-10 23:48:36 -0800 | [diff] [blame] | 99 | size_t GetHugeMethodThreshold() const { |
| 100 | return huge_method_threshold_; |
| 101 | } |
| 102 | |
| 103 | size_t GetLargeMethodThreshold() const { |
| 104 | return large_method_threshold_; |
| 105 | } |
| 106 | |
| 107 | size_t GetSmallMethodThreshold() const { |
| 108 | return small_method_threshold_; |
| 109 | } |
| 110 | |
| 111 | size_t GetTinyMethodThreshold() const { |
| 112 | return tiny_method_threshold_; |
| 113 | } |
| 114 | |
| 115 | bool IsHugeMethod(size_t num_dalvik_instructions) const { |
| 116 | return num_dalvik_instructions > huge_method_threshold_; |
| 117 | } |
| 118 | |
| 119 | bool IsLargeMethod(size_t num_dalvik_instructions) const { |
| 120 | return num_dalvik_instructions > large_method_threshold_; |
| 121 | } |
| 122 | |
| 123 | bool IsSmallMethod(size_t num_dalvik_instructions) const { |
| 124 | return num_dalvik_instructions > small_method_threshold_; |
| 125 | } |
| 126 | |
| 127 | bool IsTinyMethod(size_t num_dalvik_instructions) const { |
| 128 | return num_dalvik_instructions > tiny_method_threshold_; |
| 129 | } |
| 130 | |
| 131 | size_t GetNumDexMethodsThreshold() const { |
| 132 | return num_dex_methods_threshold_; |
| 133 | } |
| 134 | |
| 135 | #ifdef ART_SEA_IR_MODE |
| 136 | bool GetSeaIrMode(); |
| 137 | #endif |
| 138 | |
Mark Mendell | ae9fd93 | 2014-02-10 16:14:35 -0800 | [diff] [blame] | 139 | bool GetGenerateGDBInformation() const { |
| 140 | return generate_gdb_information_; |
| 141 | } |
| 142 | |
Brian Carlstrom | 6449c62 | 2014-02-10 23:48:36 -0800 | [diff] [blame] | 143 | private: |
| 144 | CompilerFilter compiler_filter_; |
| 145 | size_t huge_method_threshold_; |
| 146 | size_t large_method_threshold_; |
| 147 | size_t small_method_threshold_; |
| 148 | size_t tiny_method_threshold_; |
| 149 | size_t num_dex_methods_threshold_; |
Mark Mendell | ae9fd93 | 2014-02-10 16:14:35 -0800 | [diff] [blame] | 150 | bool generate_gdb_information_; |
Brian Carlstrom | 6449c62 | 2014-02-10 23:48:36 -0800 | [diff] [blame] | 151 | |
| 152 | #ifdef ART_SEA_IR_MODE |
| 153 | bool sea_ir_mode_; |
| 154 | #endif |
| 155 | }; |
| 156 | |
| 157 | } // namespace art |
| 158 | |
| 159 | #endif // ART_COMPILER_DRIVER_COMPILER_OPTIONS_H_ |