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. |
Dave Allison | 39c3bfb | 2014-01-28 18:33:52 -0800 | [diff] [blame] | 26 | kProfiled, // Compile based on profile. |
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 |
| 35 | static const CompilerFilter kDefaultCompilerFilter = kProfiled; |
| 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; |
| 44 | |
| 45 | CompilerOptions() : |
| 46 | compiler_filter_(kDefaultCompilerFilter), |
| 47 | huge_method_threshold_(kDefaultHugeMethodThreshold), |
| 48 | large_method_threshold_(kDefaultLargeMethodThreshold), |
| 49 | small_method_threshold_(kDefaultSmallMethodThreshold), |
| 50 | tiny_method_threshold_(kDefaultTinyMethodThreshold), |
Mark Mendell | ae9fd93 | 2014-02-10 16:14:35 -0800 | [diff] [blame] | 51 | num_dex_methods_threshold_(kDefaultNumDexMethodsThreshold), |
| 52 | generate_gdb_information_(false) |
Brian Carlstrom | 6449c62 | 2014-02-10 23:48:36 -0800 | [diff] [blame] | 53 | #ifdef ART_SEA_IR_MODE |
| 54 | , sea_ir_mode_(false) |
| 55 | #endif |
| 56 | {} |
| 57 | |
| 58 | CompilerOptions(CompilerFilter compiler_filter, |
| 59 | size_t huge_method_threshold, |
| 60 | size_t large_method_threshold, |
| 61 | size_t small_method_threshold, |
| 62 | size_t tiny_method_threshold, |
Mark Mendell | ae9fd93 | 2014-02-10 16:14:35 -0800 | [diff] [blame] | 63 | size_t num_dex_methods_threshold, |
| 64 | bool generate_gdb_information |
Brian Carlstrom | 6449c62 | 2014-02-10 23:48:36 -0800 | [diff] [blame] | 65 | #ifdef ART_SEA_IR_MODE |
| 66 | , bool sea_ir_mode |
| 67 | #endif |
| 68 | ) : // NOLINT(whitespace/parens) |
| 69 | compiler_filter_(compiler_filter), |
| 70 | huge_method_threshold_(huge_method_threshold), |
| 71 | large_method_threshold_(large_method_threshold), |
| 72 | small_method_threshold_(small_method_threshold), |
| 73 | tiny_method_threshold_(tiny_method_threshold), |
Mark Mendell | ae9fd93 | 2014-02-10 16:14:35 -0800 | [diff] [blame] | 74 | num_dex_methods_threshold_(num_dex_methods_threshold), |
| 75 | generate_gdb_information_(generate_gdb_information) |
Brian Carlstrom | 6449c62 | 2014-02-10 23:48:36 -0800 | [diff] [blame] | 76 | #ifdef ART_SEA_IR_MODE |
| 77 | , sea_ir_mode_(sea_ir_mode) |
| 78 | #endif |
| 79 | {} |
| 80 | |
| 81 | CompilerFilter GetCompilerFilter() const { |
| 82 | return compiler_filter_; |
| 83 | } |
| 84 | |
| 85 | void SetCompilerFilter(CompilerFilter compiler_filter) { |
| 86 | compiler_filter_ = compiler_filter; |
| 87 | } |
| 88 | |
| 89 | size_t GetHugeMethodThreshold() const { |
| 90 | return huge_method_threshold_; |
| 91 | } |
| 92 | |
| 93 | size_t GetLargeMethodThreshold() const { |
| 94 | return large_method_threshold_; |
| 95 | } |
| 96 | |
| 97 | size_t GetSmallMethodThreshold() const { |
| 98 | return small_method_threshold_; |
| 99 | } |
| 100 | |
| 101 | size_t GetTinyMethodThreshold() const { |
| 102 | return tiny_method_threshold_; |
| 103 | } |
| 104 | |
| 105 | bool IsHugeMethod(size_t num_dalvik_instructions) const { |
| 106 | return num_dalvik_instructions > huge_method_threshold_; |
| 107 | } |
| 108 | |
| 109 | bool IsLargeMethod(size_t num_dalvik_instructions) const { |
| 110 | return num_dalvik_instructions > large_method_threshold_; |
| 111 | } |
| 112 | |
| 113 | bool IsSmallMethod(size_t num_dalvik_instructions) const { |
| 114 | return num_dalvik_instructions > small_method_threshold_; |
| 115 | } |
| 116 | |
| 117 | bool IsTinyMethod(size_t num_dalvik_instructions) const { |
| 118 | return num_dalvik_instructions > tiny_method_threshold_; |
| 119 | } |
| 120 | |
| 121 | size_t GetNumDexMethodsThreshold() const { |
| 122 | return num_dex_methods_threshold_; |
| 123 | } |
| 124 | |
| 125 | #ifdef ART_SEA_IR_MODE |
| 126 | bool GetSeaIrMode(); |
| 127 | #endif |
| 128 | |
Mark Mendell | ae9fd93 | 2014-02-10 16:14:35 -0800 | [diff] [blame] | 129 | bool GetGenerateGDBInformation() const { |
| 130 | return generate_gdb_information_; |
| 131 | } |
| 132 | |
Brian Carlstrom | 6449c62 | 2014-02-10 23:48:36 -0800 | [diff] [blame] | 133 | private: |
| 134 | CompilerFilter compiler_filter_; |
| 135 | size_t huge_method_threshold_; |
| 136 | size_t large_method_threshold_; |
| 137 | size_t small_method_threshold_; |
| 138 | size_t tiny_method_threshold_; |
| 139 | size_t num_dex_methods_threshold_; |
Mark Mendell | ae9fd93 | 2014-02-10 16:14:35 -0800 | [diff] [blame] | 140 | bool generate_gdb_information_; |
Brian Carlstrom | 6449c62 | 2014-02-10 23:48:36 -0800 | [diff] [blame] | 141 | |
| 142 | #ifdef ART_SEA_IR_MODE |
| 143 | bool sea_ir_mode_; |
| 144 | #endif |
| 145 | }; |
| 146 | |
| 147 | } // namespace art |
| 148 | |
| 149 | #endif // ART_COMPILER_DRIVER_COMPILER_OPTIONS_H_ |