blob: 3a50bfdb83113e25be39a468c049ab68fd22fefa [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).
Igor Murashkind6dee672014-10-16 18:36:16 -070031 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),
Igor Murashkind6dee672014-10-16 18:36:16 -070062 implicit_suspend_checks_(false),
63 compile_pic_(false)
Brian Carlstrom6449c622014-02-10 23:48:36 -080064#ifdef ART_SEA_IR_MODE
65 , sea_ir_mode_(false)
66#endif
67 {}
68
69 CompilerOptions(CompilerFilter compiler_filter,
70 size_t huge_method_threshold,
71 size_t large_method_threshold,
72 size_t small_method_threshold,
73 size_t tiny_method_threshold,
Mark Mendellae9fd932014-02-10 16:14:35 -080074 size_t num_dex_methods_threshold,
Calin Juravlec1b643c2014-05-30 23:44:11 +010075 bool generate_gdb_information,
Alex Light53cb16b2014-06-12 11:26:29 -070076 bool include_patch_information,
Alex Light78382fa2014-06-06 15:45:32 -070077 double top_k_profile_threshold,
Andreas Gampe5655e842014-06-17 16:36:07 -070078 bool include_debug_symbols,
Dave Allison69dfe512014-07-11 17:11:58 +000079 bool implicit_null_checks,
80 bool implicit_so_checks,
Igor Murashkind6dee672014-10-16 18:36:16 -070081 bool implicit_suspend_checks,
82 bool compile_pic
Brian Carlstrom6449c622014-02-10 23:48:36 -080083#ifdef ART_SEA_IR_MODE
84 , bool sea_ir_mode
85#endif
86 ) : // NOLINT(whitespace/parens)
87 compiler_filter_(compiler_filter),
88 huge_method_threshold_(huge_method_threshold),
89 large_method_threshold_(large_method_threshold),
90 small_method_threshold_(small_method_threshold),
91 tiny_method_threshold_(tiny_method_threshold),
Mark Mendellae9fd932014-02-10 16:14:35 -080092 num_dex_methods_threshold_(num_dex_methods_threshold),
Calin Juravlec1b643c2014-05-30 23:44:11 +010093 generate_gdb_information_(generate_gdb_information),
Alex Light53cb16b2014-06-12 11:26:29 -070094 include_patch_information_(include_patch_information),
Alex Light78382fa2014-06-06 15:45:32 -070095 top_k_profile_threshold_(top_k_profile_threshold),
Andreas Gampe5655e842014-06-17 16:36:07 -070096 include_debug_symbols_(include_debug_symbols),
Dave Allison69dfe512014-07-11 17:11:58 +000097 implicit_null_checks_(implicit_null_checks),
98 implicit_so_checks_(implicit_so_checks),
Igor Murashkind6dee672014-10-16 18:36:16 -070099 implicit_suspend_checks_(implicit_suspend_checks),
100 compile_pic_(compile_pic)
Brian Carlstrom6449c622014-02-10 23:48:36 -0800101#ifdef ART_SEA_IR_MODE
102 , sea_ir_mode_(sea_ir_mode)
103#endif
104 {}
105
106 CompilerFilter GetCompilerFilter() const {
107 return compiler_filter_;
108 }
109
110 void SetCompilerFilter(CompilerFilter compiler_filter) {
111 compiler_filter_ = compiler_filter;
112 }
113
Jeff Hao4a200f52014-04-01 14:58:49 -0700114 bool IsCompilationEnabled() const {
115 return ((compiler_filter_ != CompilerOptions::kVerifyNone) &&
116 (compiler_filter_ != CompilerOptions::kInterpretOnly));
117 }
118
119 bool IsVerificationEnabled() const {
120 return (compiler_filter_ != CompilerOptions::kVerifyNone);
121 }
122
Brian Carlstrom6449c622014-02-10 23:48:36 -0800123 size_t GetHugeMethodThreshold() const {
124 return huge_method_threshold_;
125 }
126
127 size_t GetLargeMethodThreshold() const {
128 return large_method_threshold_;
129 }
130
131 size_t GetSmallMethodThreshold() const {
132 return small_method_threshold_;
133 }
134
135 size_t GetTinyMethodThreshold() const {
136 return tiny_method_threshold_;
137 }
138
139 bool IsHugeMethod(size_t num_dalvik_instructions) const {
140 return num_dalvik_instructions > huge_method_threshold_;
141 }
142
143 bool IsLargeMethod(size_t num_dalvik_instructions) const {
144 return num_dalvik_instructions > large_method_threshold_;
145 }
146
147 bool IsSmallMethod(size_t num_dalvik_instructions) const {
148 return num_dalvik_instructions > small_method_threshold_;
149 }
150
151 bool IsTinyMethod(size_t num_dalvik_instructions) const {
152 return num_dalvik_instructions > tiny_method_threshold_;
153 }
154
155 size_t GetNumDexMethodsThreshold() const {
156 return num_dex_methods_threshold_;
157 }
158
Calin Juravlec1b643c2014-05-30 23:44:11 +0100159 double GetTopKProfileThreshold() const {
160 return top_k_profile_threshold_;
161 }
162
Alex Light78382fa2014-06-06 15:45:32 -0700163 bool GetIncludeDebugSymbols() const {
164 return include_debug_symbols_;
165 }
166
Dave Allison69dfe512014-07-11 17:11:58 +0000167 bool GetImplicitNullChecks() const {
168 return implicit_null_checks_;
Andreas Gampe5655e842014-06-17 16:36:07 -0700169 }
170
Dave Allison69dfe512014-07-11 17:11:58 +0000171 void SetImplicitNullChecks(bool new_val) {
172 implicit_null_checks_ = new_val;
Andreas Gampe5655e842014-06-17 16:36:07 -0700173 }
174
Dave Allison69dfe512014-07-11 17:11:58 +0000175 bool GetImplicitStackOverflowChecks() const {
176 return implicit_so_checks_;
Andreas Gampe5655e842014-06-17 16:36:07 -0700177 }
178
Dave Allison69dfe512014-07-11 17:11:58 +0000179 void SetImplicitStackOverflowChecks(bool new_val) {
180 implicit_so_checks_ = new_val;
Andreas Gampe5655e842014-06-17 16:36:07 -0700181 }
182
Dave Allison69dfe512014-07-11 17:11:58 +0000183 bool GetImplicitSuspendChecks() const {
184 return implicit_suspend_checks_;
Andreas Gampe5655e842014-06-17 16:36:07 -0700185 }
186
Dave Allison69dfe512014-07-11 17:11:58 +0000187 void SetImplicitSuspendChecks(bool new_val) {
188 implicit_suspend_checks_ = new_val;
Andreas Gampe5655e842014-06-17 16:36:07 -0700189 }
190
Brian Carlstrom6449c622014-02-10 23:48:36 -0800191#ifdef ART_SEA_IR_MODE
192 bool GetSeaIrMode();
193#endif
194
Mark Mendellae9fd932014-02-10 16:14:35 -0800195 bool GetGenerateGDBInformation() const {
196 return generate_gdb_information_;
197 }
198
Alex Light53cb16b2014-06-12 11:26:29 -0700199 bool GetIncludePatchInformation() const {
200 return include_patch_information_;
201 }
202
Igor Murashkind6dee672014-10-16 18:36:16 -0700203 // Should the code be compiled as position independent?
204 bool GetCompilePic() const {
205 return compile_pic_;
206 }
207
Brian Carlstrom6449c622014-02-10 23:48:36 -0800208 private:
209 CompilerFilter compiler_filter_;
210 size_t huge_method_threshold_;
211 size_t large_method_threshold_;
212 size_t small_method_threshold_;
213 size_t tiny_method_threshold_;
214 size_t num_dex_methods_threshold_;
Mark Mendellae9fd932014-02-10 16:14:35 -0800215 bool generate_gdb_information_;
Alex Light53cb16b2014-06-12 11:26:29 -0700216 bool include_patch_information_;
Calin Juravlec1b643c2014-05-30 23:44:11 +0100217 // When using a profile file only the top K% of the profiled samples will be compiled.
218 double top_k_profile_threshold_;
Alex Light78382fa2014-06-06 15:45:32 -0700219 bool include_debug_symbols_;
Dave Allison69dfe512014-07-11 17:11:58 +0000220 bool implicit_null_checks_;
221 bool implicit_so_checks_;
222 bool implicit_suspend_checks_;
Igor Murashkind6dee672014-10-16 18:36:16 -0700223 bool compile_pic_;
Brian Carlstrom6449c622014-02-10 23:48:36 -0800224#ifdef ART_SEA_IR_MODE
225 bool sea_ir_mode_;
226#endif
227};
228
229} // namespace art
230
231#endif // ART_COMPILER_DRIVER_COMPILER_OPTIONS_H_