blob: 52248a6c5a4e618ee43f2dad9efa5ee2b82768cf [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.
Dave Allison39c3bfb2014-01-28 18:33:52 -080027 kProfiled, // Compile based on profile.
Brian Carlstrom6449c622014-02-10 23:48:36 -080028 kSpace, // Maximize space savings.
29 kBalanced, // Try to get the best performance return on compilation investment.
30 kSpeed, // Maximize runtime performance.
31 kEverything // Force compilation (Note: excludes compilaton of class initializers).
32 };
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
36 static const CompilerFilter kDefaultCompilerFilter = kProfiled;
37#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;
45
46 CompilerOptions() :
47 compiler_filter_(kDefaultCompilerFilter),
48 huge_method_threshold_(kDefaultHugeMethodThreshold),
49 large_method_threshold_(kDefaultLargeMethodThreshold),
50 small_method_threshold_(kDefaultSmallMethodThreshold),
51 tiny_method_threshold_(kDefaultTinyMethodThreshold),
Mark Mendellae9fd932014-02-10 16:14:35 -080052 num_dex_methods_threshold_(kDefaultNumDexMethodsThreshold),
Dave Allisonf9487c02014-04-08 23:08:12 +000053 generate_gdb_information_(false),
54 generate_helper_trampolines_(false)
Brian Carlstrom6449c622014-02-10 23:48:36 -080055#ifdef ART_SEA_IR_MODE
56 , sea_ir_mode_(false)
57#endif
58 {}
59
60 CompilerOptions(CompilerFilter compiler_filter,
61 size_t huge_method_threshold,
62 size_t large_method_threshold,
63 size_t small_method_threshold,
64 size_t tiny_method_threshold,
Mark Mendellae9fd932014-02-10 16:14:35 -080065 size_t num_dex_methods_threshold,
Dave Allisonf9487c02014-04-08 23:08:12 +000066 bool generate_gdb_information,
67 bool generate_helper_trampolines
Brian Carlstrom6449c622014-02-10 23:48:36 -080068#ifdef ART_SEA_IR_MODE
69 , bool sea_ir_mode
70#endif
71 ) : // NOLINT(whitespace/parens)
72 compiler_filter_(compiler_filter),
73 huge_method_threshold_(huge_method_threshold),
74 large_method_threshold_(large_method_threshold),
75 small_method_threshold_(small_method_threshold),
76 tiny_method_threshold_(tiny_method_threshold),
Mark Mendellae9fd932014-02-10 16:14:35 -080077 num_dex_methods_threshold_(num_dex_methods_threshold),
Dave Allisonf9487c02014-04-08 23:08:12 +000078 generate_gdb_information_(generate_gdb_information),
79 generate_helper_trampolines_(generate_helper_trampolines)
Brian Carlstrom6449c622014-02-10 23:48:36 -080080#ifdef ART_SEA_IR_MODE
81 , sea_ir_mode_(sea_ir_mode)
82#endif
83 {}
84
85 CompilerFilter GetCompilerFilter() const {
86 return compiler_filter_;
87 }
88
89 void SetCompilerFilter(CompilerFilter compiler_filter) {
90 compiler_filter_ = compiler_filter;
91 }
92
Jeff Hao4a200f52014-04-01 14:58:49 -070093 bool IsCompilationEnabled() const {
94 return ((compiler_filter_ != CompilerOptions::kVerifyNone) &&
95 (compiler_filter_ != CompilerOptions::kInterpretOnly));
96 }
97
98 bool IsVerificationEnabled() const {
99 return (compiler_filter_ != CompilerOptions::kVerifyNone);
100 }
101
Brian Carlstrom6449c622014-02-10 23:48:36 -0800102 size_t GetHugeMethodThreshold() const {
103 return huge_method_threshold_;
104 }
105
106 size_t GetLargeMethodThreshold() const {
107 return large_method_threshold_;
108 }
109
110 size_t GetSmallMethodThreshold() const {
111 return small_method_threshold_;
112 }
113
114 size_t GetTinyMethodThreshold() const {
115 return tiny_method_threshold_;
116 }
117
118 bool IsHugeMethod(size_t num_dalvik_instructions) const {
119 return num_dalvik_instructions > huge_method_threshold_;
120 }
121
122 bool IsLargeMethod(size_t num_dalvik_instructions) const {
123 return num_dalvik_instructions > large_method_threshold_;
124 }
125
126 bool IsSmallMethod(size_t num_dalvik_instructions) const {
127 return num_dalvik_instructions > small_method_threshold_;
128 }
129
130 bool IsTinyMethod(size_t num_dalvik_instructions) const {
131 return num_dalvik_instructions > tiny_method_threshold_;
132 }
133
134 size_t GetNumDexMethodsThreshold() const {
135 return num_dex_methods_threshold_;
136 }
137
138#ifdef ART_SEA_IR_MODE
139 bool GetSeaIrMode();
140#endif
141
Mark Mendellae9fd932014-02-10 16:14:35 -0800142 bool GetGenerateGDBInformation() const {
143 return generate_gdb_information_;
144 }
145
Dave Allisonf9487c02014-04-08 23:08:12 +0000146 bool GenerateHelperTrampolines() const {
147 return generate_helper_trampolines_;
148 }
149
Brian Carlstrom6449c622014-02-10 23:48:36 -0800150 private:
151 CompilerFilter compiler_filter_;
152 size_t huge_method_threshold_;
153 size_t large_method_threshold_;
154 size_t small_method_threshold_;
155 size_t tiny_method_threshold_;
156 size_t num_dex_methods_threshold_;
Mark Mendellae9fd932014-02-10 16:14:35 -0800157 bool generate_gdb_information_;
Dave Allisonf9487c02014-04-08 23:08:12 +0000158 bool generate_helper_trampolines_;
Brian Carlstrom6449c622014-02-10 23:48:36 -0800159
160#ifdef ART_SEA_IR_MODE
161 bool sea_ir_mode_;
162#endif
163};
164
165} // namespace art
166
167#endif // ART_COMPILER_DRIVER_COMPILER_OPTIONS_H_