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 { |
| 25 | kInterpretOnly, // Compile nothing. |
| 26 | kSpace, // Maximize space savings. |
| 27 | kBalanced, // Try to get the best performance return on compilation investment. |
| 28 | kSpeed, // Maximize runtime performance. |
| 29 | kEverything // Force compilation (Note: excludes compilaton of class initializers). |
| 30 | }; |
| 31 | |
| 32 | // Guide heuristics to determine whether to compile method if profile data not available. |
| 33 | static const CompilerFilter kDefaultCompilerFilter = kSpeed; |
| 34 | static const size_t kDefaultHugeMethodThreshold = 10000; |
| 35 | static const size_t kDefaultLargeMethodThreshold = 600; |
| 36 | static const size_t kDefaultSmallMethodThreshold = 60; |
| 37 | static const size_t kDefaultTinyMethodThreshold = 20; |
| 38 | static const size_t kDefaultNumDexMethodsThreshold = 900; |
| 39 | |
| 40 | CompilerOptions() : |
| 41 | compiler_filter_(kDefaultCompilerFilter), |
| 42 | huge_method_threshold_(kDefaultHugeMethodThreshold), |
| 43 | large_method_threshold_(kDefaultLargeMethodThreshold), |
| 44 | small_method_threshold_(kDefaultSmallMethodThreshold), |
| 45 | tiny_method_threshold_(kDefaultTinyMethodThreshold), |
| 46 | num_dex_methods_threshold_(kDefaultNumDexMethodsThreshold) |
| 47 | #ifdef ART_SEA_IR_MODE |
| 48 | , sea_ir_mode_(false) |
| 49 | #endif |
| 50 | {} |
| 51 | |
| 52 | CompilerOptions(CompilerFilter compiler_filter, |
| 53 | size_t huge_method_threshold, |
| 54 | size_t large_method_threshold, |
| 55 | size_t small_method_threshold, |
| 56 | size_t tiny_method_threshold, |
| 57 | size_t num_dex_methods_threshold |
| 58 | #ifdef ART_SEA_IR_MODE |
| 59 | , bool sea_ir_mode |
| 60 | #endif |
| 61 | ) : // NOLINT(whitespace/parens) |
| 62 | compiler_filter_(compiler_filter), |
| 63 | huge_method_threshold_(huge_method_threshold), |
| 64 | large_method_threshold_(large_method_threshold), |
| 65 | small_method_threshold_(small_method_threshold), |
| 66 | tiny_method_threshold_(tiny_method_threshold), |
| 67 | num_dex_methods_threshold_(num_dex_methods_threshold) |
| 68 | #ifdef ART_SEA_IR_MODE |
| 69 | , sea_ir_mode_(sea_ir_mode) |
| 70 | #endif |
| 71 | {} |
| 72 | |
| 73 | CompilerFilter GetCompilerFilter() const { |
| 74 | return compiler_filter_; |
| 75 | } |
| 76 | |
| 77 | void SetCompilerFilter(CompilerFilter compiler_filter) { |
| 78 | compiler_filter_ = compiler_filter; |
| 79 | } |
| 80 | |
| 81 | size_t GetHugeMethodThreshold() const { |
| 82 | return huge_method_threshold_; |
| 83 | } |
| 84 | |
| 85 | size_t GetLargeMethodThreshold() const { |
| 86 | return large_method_threshold_; |
| 87 | } |
| 88 | |
| 89 | size_t GetSmallMethodThreshold() const { |
| 90 | return small_method_threshold_; |
| 91 | } |
| 92 | |
| 93 | size_t GetTinyMethodThreshold() const { |
| 94 | return tiny_method_threshold_; |
| 95 | } |
| 96 | |
| 97 | bool IsHugeMethod(size_t num_dalvik_instructions) const { |
| 98 | return num_dalvik_instructions > huge_method_threshold_; |
| 99 | } |
| 100 | |
| 101 | bool IsLargeMethod(size_t num_dalvik_instructions) const { |
| 102 | return num_dalvik_instructions > large_method_threshold_; |
| 103 | } |
| 104 | |
| 105 | bool IsSmallMethod(size_t num_dalvik_instructions) const { |
| 106 | return num_dalvik_instructions > small_method_threshold_; |
| 107 | } |
| 108 | |
| 109 | bool IsTinyMethod(size_t num_dalvik_instructions) const { |
| 110 | return num_dalvik_instructions > tiny_method_threshold_; |
| 111 | } |
| 112 | |
| 113 | size_t GetNumDexMethodsThreshold() const { |
| 114 | return num_dex_methods_threshold_; |
| 115 | } |
| 116 | |
| 117 | #ifdef ART_SEA_IR_MODE |
| 118 | bool GetSeaIrMode(); |
| 119 | #endif |
| 120 | |
| 121 | private: |
| 122 | CompilerFilter compiler_filter_; |
| 123 | size_t huge_method_threshold_; |
| 124 | size_t large_method_threshold_; |
| 125 | size_t small_method_threshold_; |
| 126 | size_t tiny_method_threshold_; |
| 127 | size_t num_dex_methods_threshold_; |
| 128 | |
| 129 | #ifdef ART_SEA_IR_MODE |
| 130 | bool sea_ir_mode_; |
| 131 | #endif |
| 132 | }; |
| 133 | |
| 134 | } // namespace art |
| 135 | |
| 136 | #endif // ART_COMPILER_DRIVER_COMPILER_OPTIONS_H_ |