blob: fb3341ba718f6c5785a5cd1849a0f13942c357f3 [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.
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 Allison39c3bfb2014-01-28 18:33:52 -080034#if ART_SMALL_MODE
Calin Juravlec1b643c2014-05-30 23:44:11 +010035 static const CompilerFilter kDefaultCompilerFilter = kInterpretOnly;
Dave Allison39c3bfb2014-01-28 18:33:52 -080036#else
Brian Carlstrom6449c622014-02-10 23:48:36 -080037 static const CompilerFilter kDefaultCompilerFilter = kSpeed;
Dave Allison39c3bfb2014-01-28 18:33:52 -080038#endif
Brian Carlstrom6449c622014-02-10 23:48:36 -080039 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;
Calin Juravlec1b643c2014-05-30 23:44:11 +010044 static constexpr double kDefaultTopKProfileThreshold = 90.0;
Alex Light78382fa2014-06-06 15:45:32 -070045 static const bool kDefaultIncludeDebugSymbols = kIsDebugBuild;
Brian Carlstrom6449c622014-02-10 23:48:36 -080046
47 CompilerOptions() :
48 compiler_filter_(kDefaultCompilerFilter),
49 huge_method_threshold_(kDefaultHugeMethodThreshold),
50 large_method_threshold_(kDefaultLargeMethodThreshold),
51 small_method_threshold_(kDefaultSmallMethodThreshold),
52 tiny_method_threshold_(kDefaultTinyMethodThreshold),
Mark Mendellae9fd932014-02-10 16:14:35 -080053 num_dex_methods_threshold_(kDefaultNumDexMethodsThreshold),
Calin Juravlec1b643c2014-05-30 23:44:11 +010054 generate_gdb_information_(false),
Alex Light78382fa2014-06-06 15:45:32 -070055 top_k_profile_threshold_(kDefaultTopKProfileThreshold),
Andreas Gampe5655e842014-06-17 16:36:07 -070056 include_debug_symbols_(kDefaultIncludeDebugSymbols),
57 explicit_null_checks_(true),
58 explicit_so_checks_(true),
59 explicit_suspend_checks_(true)
Brian Carlstrom6449c622014-02-10 23:48:36 -080060#ifdef ART_SEA_IR_MODE
61 , sea_ir_mode_(false)
62#endif
63 {}
64
65 CompilerOptions(CompilerFilter compiler_filter,
66 size_t huge_method_threshold,
67 size_t large_method_threshold,
68 size_t small_method_threshold,
69 size_t tiny_method_threshold,
Mark Mendellae9fd932014-02-10 16:14:35 -080070 size_t num_dex_methods_threshold,
Calin Juravlec1b643c2014-05-30 23:44:11 +010071 bool generate_gdb_information,
Alex Light78382fa2014-06-06 15:45:32 -070072 double top_k_profile_threshold,
Andreas Gampe5655e842014-06-17 16:36:07 -070073 bool include_debug_symbols,
74 bool explicit_null_checks,
75 bool explicit_so_checks,
76 bool explicit_suspend_checks
Brian Carlstrom6449c622014-02-10 23:48:36 -080077#ifdef ART_SEA_IR_MODE
78 , bool sea_ir_mode
79#endif
80 ) : // NOLINT(whitespace/parens)
81 compiler_filter_(compiler_filter),
82 huge_method_threshold_(huge_method_threshold),
83 large_method_threshold_(large_method_threshold),
84 small_method_threshold_(small_method_threshold),
85 tiny_method_threshold_(tiny_method_threshold),
Mark Mendellae9fd932014-02-10 16:14:35 -080086 num_dex_methods_threshold_(num_dex_methods_threshold),
Calin Juravlec1b643c2014-05-30 23:44:11 +010087 generate_gdb_information_(generate_gdb_information),
Alex Light78382fa2014-06-06 15:45:32 -070088 top_k_profile_threshold_(top_k_profile_threshold),
Andreas Gampe5655e842014-06-17 16:36:07 -070089 include_debug_symbols_(include_debug_symbols),
90 explicit_null_checks_(explicit_null_checks),
91 explicit_so_checks_(explicit_so_checks),
92 explicit_suspend_checks_(explicit_suspend_checks)
Brian Carlstrom6449c622014-02-10 23:48:36 -080093#ifdef ART_SEA_IR_MODE
94 , sea_ir_mode_(sea_ir_mode)
95#endif
96 {}
97
98 CompilerFilter GetCompilerFilter() const {
99 return compiler_filter_;
100 }
101
102 void SetCompilerFilter(CompilerFilter compiler_filter) {
103 compiler_filter_ = compiler_filter;
104 }
105
Jeff Hao4a200f52014-04-01 14:58:49 -0700106 bool IsCompilationEnabled() const {
107 return ((compiler_filter_ != CompilerOptions::kVerifyNone) &&
108 (compiler_filter_ != CompilerOptions::kInterpretOnly));
109 }
110
111 bool IsVerificationEnabled() const {
112 return (compiler_filter_ != CompilerOptions::kVerifyNone);
113 }
114
Brian Carlstrom6449c622014-02-10 23:48:36 -0800115 size_t GetHugeMethodThreshold() const {
116 return huge_method_threshold_;
117 }
118
119 size_t GetLargeMethodThreshold() const {
120 return large_method_threshold_;
121 }
122
123 size_t GetSmallMethodThreshold() const {
124 return small_method_threshold_;
125 }
126
127 size_t GetTinyMethodThreshold() const {
128 return tiny_method_threshold_;
129 }
130
131 bool IsHugeMethod(size_t num_dalvik_instructions) const {
132 return num_dalvik_instructions > huge_method_threshold_;
133 }
134
135 bool IsLargeMethod(size_t num_dalvik_instructions) const {
136 return num_dalvik_instructions > large_method_threshold_;
137 }
138
139 bool IsSmallMethod(size_t num_dalvik_instructions) const {
140 return num_dalvik_instructions > small_method_threshold_;
141 }
142
143 bool IsTinyMethod(size_t num_dalvik_instructions) const {
144 return num_dalvik_instructions > tiny_method_threshold_;
145 }
146
147 size_t GetNumDexMethodsThreshold() const {
148 return num_dex_methods_threshold_;
149 }
150
Calin Juravlec1b643c2014-05-30 23:44:11 +0100151 double GetTopKProfileThreshold() const {
152 return top_k_profile_threshold_;
153 }
154
Alex Light78382fa2014-06-06 15:45:32 -0700155 bool GetIncludeDebugSymbols() const {
156 return include_debug_symbols_;
157 }
158
Andreas Gampe5655e842014-06-17 16:36:07 -0700159 bool GetExplicitNullChecks() const {
160 return explicit_null_checks_;
161 }
162
163 void SetExplicitNullChecks(bool new_val) {
164 explicit_null_checks_ = new_val;
165 }
166
167 bool GetExplicitStackOverflowChecks() const {
168 return explicit_so_checks_;
169 }
170
171 void SetExplicitStackOverflowChecks(bool new_val) {
172 explicit_so_checks_ = new_val;
173 }
174
175 bool GetExplicitSuspendChecks() const {
176 return explicit_suspend_checks_;
177 }
178
179 void SetExplicitSuspendChecks(bool new_val) {
180 explicit_suspend_checks_ = new_val;
181 }
182
Brian Carlstrom6449c622014-02-10 23:48:36 -0800183#ifdef ART_SEA_IR_MODE
184 bool GetSeaIrMode();
185#endif
186
Mark Mendellae9fd932014-02-10 16:14:35 -0800187 bool GetGenerateGDBInformation() const {
188 return generate_gdb_information_;
189 }
190
Brian Carlstrom6449c622014-02-10 23:48:36 -0800191 private:
192 CompilerFilter compiler_filter_;
193 size_t huge_method_threshold_;
194 size_t large_method_threshold_;
195 size_t small_method_threshold_;
196 size_t tiny_method_threshold_;
197 size_t num_dex_methods_threshold_;
Mark Mendellae9fd932014-02-10 16:14:35 -0800198 bool generate_gdb_information_;
Calin Juravlec1b643c2014-05-30 23:44:11 +0100199 // When using a profile file only the top K% of the profiled samples will be compiled.
200 double top_k_profile_threshold_;
Alex Light78382fa2014-06-06 15:45:32 -0700201 bool include_debug_symbols_;
Andreas Gampe5655e842014-06-17 16:36:07 -0700202 bool explicit_null_checks_;
203 bool explicit_so_checks_;
204 bool explicit_suspend_checks_;
Brian Carlstrom6449c622014-02-10 23:48:36 -0800205#ifdef ART_SEA_IR_MODE
206 bool sea_ir_mode_;
207#endif
208};
209
210} // namespace art
211
212#endif // ART_COMPILER_DRIVER_COMPILER_OPTIONS_H_