blob: eb3de975d2319a156fbd1a89cf932e313520fc2e [file] [log] [blame]
Brian Carlstrom6449c622014-02-10 23:48:36 -08001/*
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
20namespace art {
21
22class CompilerOptions {
23 public:
24 enum CompilerFilter {
Jeff Hao4a200f52014-04-01 14:58:49 -070025 kVerifyNone, // Skip verification and compile nothing except JNI stubs.
26 kInterpretOnly, // Compile nothing except JNI stubs.
Brian Carlstrom6449c622014-02-10 23:48:36 -080027 kSpace, // Maximize space savings.
28 kBalanced, // Try to get the best performance return on compilation investment.
29 kSpeed, // Maximize runtime performance.
Nicolas Geoffray88157ef2014-09-12 10:29:53 +010030 kEverything, // Force compilation (Note: excludes compilation of class initializers).
31 kTime // Compile methods, but minimize compilation time.
Brian Carlstrom6449c622014-02-10 23:48:36 -080032 };
33
34 // Guide heuristics to determine whether to compile method if profile data not available.
Dave Allison39c3bfb2014-01-28 18:33:52 -080035#if ART_SMALL_MODE
Calin Juravlec1b643c2014-05-30 23:44:11 +010036 static const CompilerFilter kDefaultCompilerFilter = kInterpretOnly;
Dave Allison39c3bfb2014-01-28 18:33:52 -080037#else
Brian Carlstrom6449c622014-02-10 23:48:36 -080038 static const CompilerFilter kDefaultCompilerFilter = kSpeed;
Dave Allison39c3bfb2014-01-28 18:33:52 -080039#endif
Brian Carlstrom6449c622014-02-10 23:48:36 -080040 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;
Calin Juravlec1b643c2014-05-30 23:44:11 +010045 static constexpr double kDefaultTopKProfileThreshold = 90.0;
Alex Light78382fa2014-06-06 15:45:32 -070046 static const bool kDefaultIncludeDebugSymbols = kIsDebugBuild;
Alex Light53cb16b2014-06-12 11:26:29 -070047 static const bool kDefaultIncludePatchInformation = false;
Brian Carlstrom6449c622014-02-10 23:48:36 -080048
49 CompilerOptions() :
50 compiler_filter_(kDefaultCompilerFilter),
51 huge_method_threshold_(kDefaultHugeMethodThreshold),
52 large_method_threshold_(kDefaultLargeMethodThreshold),
53 small_method_threshold_(kDefaultSmallMethodThreshold),
54 tiny_method_threshold_(kDefaultTinyMethodThreshold),
Mark Mendellae9fd932014-02-10 16:14:35 -080055 num_dex_methods_threshold_(kDefaultNumDexMethodsThreshold),
Calin Juravlec1b643c2014-05-30 23:44:11 +010056 generate_gdb_information_(false),
Alex Light53cb16b2014-06-12 11:26:29 -070057 include_patch_information_(kDefaultIncludePatchInformation),
Alex Light78382fa2014-06-06 15:45:32 -070058 top_k_profile_threshold_(kDefaultTopKProfileThreshold),
Andreas Gampe5655e842014-06-17 16:36:07 -070059 include_debug_symbols_(kDefaultIncludeDebugSymbols),
Dave Allison69dfe512014-07-11 17:11:58 +000060 implicit_null_checks_(false),
61 implicit_so_checks_(false),
62 implicit_suspend_checks_(false)
Brian Carlstrom6449c622014-02-10 23:48:36 -080063#ifdef ART_SEA_IR_MODE
64 , sea_ir_mode_(false)
65#endif
66 {}
67
68 CompilerOptions(CompilerFilter compiler_filter,
69 size_t huge_method_threshold,
70 size_t large_method_threshold,
71 size_t small_method_threshold,
72 size_t tiny_method_threshold,
Mark Mendellae9fd932014-02-10 16:14:35 -080073 size_t num_dex_methods_threshold,
Calin Juravlec1b643c2014-05-30 23:44:11 +010074 bool generate_gdb_information,
Alex Light53cb16b2014-06-12 11:26:29 -070075 bool include_patch_information,
Alex Light78382fa2014-06-06 15:45:32 -070076 double top_k_profile_threshold,
Andreas Gampe5655e842014-06-17 16:36:07 -070077 bool include_debug_symbols,
Dave Allison69dfe512014-07-11 17:11:58 +000078 bool implicit_null_checks,
79 bool implicit_so_checks,
80 bool implicit_suspend_checks
Brian Carlstrom6449c622014-02-10 23:48:36 -080081#ifdef ART_SEA_IR_MODE
82 , bool sea_ir_mode
83#endif
84 ) : // NOLINT(whitespace/parens)
85 compiler_filter_(compiler_filter),
86 huge_method_threshold_(huge_method_threshold),
87 large_method_threshold_(large_method_threshold),
88 small_method_threshold_(small_method_threshold),
89 tiny_method_threshold_(tiny_method_threshold),
Mark Mendellae9fd932014-02-10 16:14:35 -080090 num_dex_methods_threshold_(num_dex_methods_threshold),
Calin Juravlec1b643c2014-05-30 23:44:11 +010091 generate_gdb_information_(generate_gdb_information),
Alex Light53cb16b2014-06-12 11:26:29 -070092 include_patch_information_(include_patch_information),
Alex Light78382fa2014-06-06 15:45:32 -070093 top_k_profile_threshold_(top_k_profile_threshold),
Andreas Gampe5655e842014-06-17 16:36:07 -070094 include_debug_symbols_(include_debug_symbols),
Dave Allison69dfe512014-07-11 17:11:58 +000095 implicit_null_checks_(implicit_null_checks),
96 implicit_so_checks_(implicit_so_checks),
97 implicit_suspend_checks_(implicit_suspend_checks)
Brian Carlstrom6449c622014-02-10 23:48:36 -080098#ifdef ART_SEA_IR_MODE
99 , sea_ir_mode_(sea_ir_mode)
100#endif
101 {}
102
103 CompilerFilter GetCompilerFilter() const {
104 return compiler_filter_;
105 }
106
107 void SetCompilerFilter(CompilerFilter compiler_filter) {
108 compiler_filter_ = compiler_filter;
109 }
110
Jeff Hao4a200f52014-04-01 14:58:49 -0700111 bool IsCompilationEnabled() const {
112 return ((compiler_filter_ != CompilerOptions::kVerifyNone) &&
113 (compiler_filter_ != CompilerOptions::kInterpretOnly));
114 }
115
116 bool IsVerificationEnabled() const {
117 return (compiler_filter_ != CompilerOptions::kVerifyNone);
118 }
119
Brian Carlstrom6449c622014-02-10 23:48:36 -0800120 size_t GetHugeMethodThreshold() const {
121 return huge_method_threshold_;
122 }
123
124 size_t GetLargeMethodThreshold() const {
125 return large_method_threshold_;
126 }
127
128 size_t GetSmallMethodThreshold() const {
129 return small_method_threshold_;
130 }
131
132 size_t GetTinyMethodThreshold() const {
133 return tiny_method_threshold_;
134 }
135
136 bool IsHugeMethod(size_t num_dalvik_instructions) const {
137 return num_dalvik_instructions > huge_method_threshold_;
138 }
139
140 bool IsLargeMethod(size_t num_dalvik_instructions) const {
141 return num_dalvik_instructions > large_method_threshold_;
142 }
143
144 bool IsSmallMethod(size_t num_dalvik_instructions) const {
145 return num_dalvik_instructions > small_method_threshold_;
146 }
147
148 bool IsTinyMethod(size_t num_dalvik_instructions) const {
149 return num_dalvik_instructions > tiny_method_threshold_;
150 }
151
152 size_t GetNumDexMethodsThreshold() const {
153 return num_dex_methods_threshold_;
154 }
155
Calin Juravlec1b643c2014-05-30 23:44:11 +0100156 double GetTopKProfileThreshold() const {
157 return top_k_profile_threshold_;
158 }
159
Alex Light78382fa2014-06-06 15:45:32 -0700160 bool GetIncludeDebugSymbols() const {
161 return include_debug_symbols_;
162 }
163
Dave Allison69dfe512014-07-11 17:11:58 +0000164 bool GetImplicitNullChecks() const {
165 return implicit_null_checks_;
Andreas Gampe5655e842014-06-17 16:36:07 -0700166 }
167
Dave Allison69dfe512014-07-11 17:11:58 +0000168 void SetImplicitNullChecks(bool new_val) {
169 implicit_null_checks_ = new_val;
Andreas Gampe5655e842014-06-17 16:36:07 -0700170 }
171
Dave Allison69dfe512014-07-11 17:11:58 +0000172 bool GetImplicitStackOverflowChecks() const {
173 return implicit_so_checks_;
Andreas Gampe5655e842014-06-17 16:36:07 -0700174 }
175
Dave Allison69dfe512014-07-11 17:11:58 +0000176 void SetImplicitStackOverflowChecks(bool new_val) {
177 implicit_so_checks_ = new_val;
Andreas Gampe5655e842014-06-17 16:36:07 -0700178 }
179
Dave Allison69dfe512014-07-11 17:11:58 +0000180 bool GetImplicitSuspendChecks() const {
181 return implicit_suspend_checks_;
Andreas Gampe5655e842014-06-17 16:36:07 -0700182 }
183
Dave Allison69dfe512014-07-11 17:11:58 +0000184 void SetImplicitSuspendChecks(bool new_val) {
185 implicit_suspend_checks_ = new_val;
Andreas Gampe5655e842014-06-17 16:36:07 -0700186 }
187
Brian Carlstrom6449c622014-02-10 23:48:36 -0800188#ifdef ART_SEA_IR_MODE
189 bool GetSeaIrMode();
190#endif
191
Mark Mendellae9fd932014-02-10 16:14:35 -0800192 bool GetGenerateGDBInformation() const {
193 return generate_gdb_information_;
194 }
195
Alex Light53cb16b2014-06-12 11:26:29 -0700196 bool GetIncludePatchInformation() const {
197 return include_patch_information_;
198 }
199
Brian Carlstrom6449c622014-02-10 23:48:36 -0800200 private:
201 CompilerFilter compiler_filter_;
202 size_t huge_method_threshold_;
203 size_t large_method_threshold_;
204 size_t small_method_threshold_;
205 size_t tiny_method_threshold_;
206 size_t num_dex_methods_threshold_;
Mark Mendellae9fd932014-02-10 16:14:35 -0800207 bool generate_gdb_information_;
Alex Light53cb16b2014-06-12 11:26:29 -0700208 bool include_patch_information_;
Calin Juravlec1b643c2014-05-30 23:44:11 +0100209 // When using a profile file only the top K% of the profiled samples will be compiled.
210 double top_k_profile_threshold_;
Alex Light78382fa2014-06-06 15:45:32 -0700211 bool include_debug_symbols_;
Dave Allison69dfe512014-07-11 17:11:58 +0000212 bool implicit_null_checks_;
213 bool implicit_so_checks_;
214 bool implicit_suspend_checks_;
Brian Carlstrom6449c622014-02-10 23:48:36 -0800215#ifdef ART_SEA_IR_MODE
216 bool sea_ir_mode_;
217#endif
218};
219
220} // namespace art
221
222#endif // ART_COMPILER_DRIVER_COMPILER_OPTIONS_H_