blob: 20c6bc8e4e859111dc90c7fe5db26835e129b1e4 [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 Allisond6ed6422014-04-09 23:36:15 +000053 generate_gdb_information_(false)
Brian Carlstrom6449c622014-02-10 23:48:36 -080054#ifdef ART_SEA_IR_MODE
55 , sea_ir_mode_(false)
56#endif
57 {}
58
59 CompilerOptions(CompilerFilter compiler_filter,
60 size_t huge_method_threshold,
61 size_t large_method_threshold,
62 size_t small_method_threshold,
63 size_t tiny_method_threshold,
Mark Mendellae9fd932014-02-10 16:14:35 -080064 size_t num_dex_methods_threshold,
Dave Allisond6ed6422014-04-09 23:36:15 +000065 bool generate_gdb_information
Brian Carlstrom6449c622014-02-10 23:48:36 -080066#ifdef ART_SEA_IR_MODE
67 , bool sea_ir_mode
68#endif
69 ) : // NOLINT(whitespace/parens)
70 compiler_filter_(compiler_filter),
71 huge_method_threshold_(huge_method_threshold),
72 large_method_threshold_(large_method_threshold),
73 small_method_threshold_(small_method_threshold),
74 tiny_method_threshold_(tiny_method_threshold),
Mark Mendellae9fd932014-02-10 16:14:35 -080075 num_dex_methods_threshold_(num_dex_methods_threshold),
Dave Allisond6ed6422014-04-09 23:36:15 +000076 generate_gdb_information_(generate_gdb_information)
Brian Carlstrom6449c622014-02-10 23:48:36 -080077#ifdef ART_SEA_IR_MODE
78 , sea_ir_mode_(sea_ir_mode)
79#endif
80 {}
81
82 CompilerFilter GetCompilerFilter() const {
83 return compiler_filter_;
84 }
85
86 void SetCompilerFilter(CompilerFilter compiler_filter) {
87 compiler_filter_ = compiler_filter;
88 }
89
Jeff Hao4a200f52014-04-01 14:58:49 -070090 bool IsCompilationEnabled() const {
91 return ((compiler_filter_ != CompilerOptions::kVerifyNone) &&
92 (compiler_filter_ != CompilerOptions::kInterpretOnly));
93 }
94
95 bool IsVerificationEnabled() const {
96 return (compiler_filter_ != CompilerOptions::kVerifyNone);
97 }
98
Brian Carlstrom6449c622014-02-10 23:48:36 -080099 size_t GetHugeMethodThreshold() const {
100 return huge_method_threshold_;
101 }
102
103 size_t GetLargeMethodThreshold() const {
104 return large_method_threshold_;
105 }
106
107 size_t GetSmallMethodThreshold() const {
108 return small_method_threshold_;
109 }
110
111 size_t GetTinyMethodThreshold() const {
112 return tiny_method_threshold_;
113 }
114
115 bool IsHugeMethod(size_t num_dalvik_instructions) const {
116 return num_dalvik_instructions > huge_method_threshold_;
117 }
118
119 bool IsLargeMethod(size_t num_dalvik_instructions) const {
120 return num_dalvik_instructions > large_method_threshold_;
121 }
122
123 bool IsSmallMethod(size_t num_dalvik_instructions) const {
124 return num_dalvik_instructions > small_method_threshold_;
125 }
126
127 bool IsTinyMethod(size_t num_dalvik_instructions) const {
128 return num_dalvik_instructions > tiny_method_threshold_;
129 }
130
131 size_t GetNumDexMethodsThreshold() const {
132 return num_dex_methods_threshold_;
133 }
134
135#ifdef ART_SEA_IR_MODE
136 bool GetSeaIrMode();
137#endif
138
Mark Mendellae9fd932014-02-10 16:14:35 -0800139 bool GetGenerateGDBInformation() const {
140 return generate_gdb_information_;
141 }
142
Brian Carlstrom6449c622014-02-10 23:48:36 -0800143 private:
144 CompilerFilter compiler_filter_;
145 size_t huge_method_threshold_;
146 size_t large_method_threshold_;
147 size_t small_method_threshold_;
148 size_t tiny_method_threshold_;
149 size_t num_dex_methods_threshold_;
Mark Mendellae9fd932014-02-10 16:14:35 -0800150 bool generate_gdb_information_;
Brian Carlstrom6449c622014-02-10 23:48:36 -0800151
152#ifdef ART_SEA_IR_MODE
153 bool sea_ir_mode_;
154#endif
155};
156
157} // namespace art
158
159#endif // ART_COMPILER_DRIVER_COMPILER_OPTIONS_H_