blob: 39738ab0498b51d43e7dbfdf89b2be038c6b5b65 [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 {
25 kInterpretOnly, // Compile nothing.
26 kSpace, // Maximize space savings.
27 kBalanced, // Try to get the best performance return on compilation investment.
28 kSpeed, // Maximize runtime performance.
29 kEverything // Force compilation (Note: excludes compilaton of class initializers).
30 };
31
32 // Guide heuristics to determine whether to compile method if profile data not available.
33 static const CompilerFilter kDefaultCompilerFilter = kSpeed;
34 static const size_t kDefaultHugeMethodThreshold = 10000;
35 static const size_t kDefaultLargeMethodThreshold = 600;
36 static const size_t kDefaultSmallMethodThreshold = 60;
37 static const size_t kDefaultTinyMethodThreshold = 20;
38 static const size_t kDefaultNumDexMethodsThreshold = 900;
39
40 CompilerOptions() :
41 compiler_filter_(kDefaultCompilerFilter),
42 huge_method_threshold_(kDefaultHugeMethodThreshold),
43 large_method_threshold_(kDefaultLargeMethodThreshold),
44 small_method_threshold_(kDefaultSmallMethodThreshold),
45 tiny_method_threshold_(kDefaultTinyMethodThreshold),
Mark Mendellae9fd932014-02-10 16:14:35 -080046 num_dex_methods_threshold_(kDefaultNumDexMethodsThreshold),
47 generate_gdb_information_(false)
Brian Carlstrom6449c622014-02-10 23:48:36 -080048#ifdef ART_SEA_IR_MODE
49 , sea_ir_mode_(false)
50#endif
51 {}
52
53 CompilerOptions(CompilerFilter compiler_filter,
54 size_t huge_method_threshold,
55 size_t large_method_threshold,
56 size_t small_method_threshold,
57 size_t tiny_method_threshold,
Mark Mendellae9fd932014-02-10 16:14:35 -080058 size_t num_dex_methods_threshold,
59 bool generate_gdb_information
Brian Carlstrom6449c622014-02-10 23:48:36 -080060#ifdef ART_SEA_IR_MODE
61 , bool sea_ir_mode
62#endif
63 ) : // NOLINT(whitespace/parens)
64 compiler_filter_(compiler_filter),
65 huge_method_threshold_(huge_method_threshold),
66 large_method_threshold_(large_method_threshold),
67 small_method_threshold_(small_method_threshold),
68 tiny_method_threshold_(tiny_method_threshold),
Mark Mendellae9fd932014-02-10 16:14:35 -080069 num_dex_methods_threshold_(num_dex_methods_threshold),
70 generate_gdb_information_(generate_gdb_information)
Brian Carlstrom6449c622014-02-10 23:48:36 -080071#ifdef ART_SEA_IR_MODE
72 , sea_ir_mode_(sea_ir_mode)
73#endif
74 {}
75
76 CompilerFilter GetCompilerFilter() const {
77 return compiler_filter_;
78 }
79
80 void SetCompilerFilter(CompilerFilter compiler_filter) {
81 compiler_filter_ = compiler_filter;
82 }
83
84 size_t GetHugeMethodThreshold() const {
85 return huge_method_threshold_;
86 }
87
88 size_t GetLargeMethodThreshold() const {
89 return large_method_threshold_;
90 }
91
92 size_t GetSmallMethodThreshold() const {
93 return small_method_threshold_;
94 }
95
96 size_t GetTinyMethodThreshold() const {
97 return tiny_method_threshold_;
98 }
99
100 bool IsHugeMethod(size_t num_dalvik_instructions) const {
101 return num_dalvik_instructions > huge_method_threshold_;
102 }
103
104 bool IsLargeMethod(size_t num_dalvik_instructions) const {
105 return num_dalvik_instructions > large_method_threshold_;
106 }
107
108 bool IsSmallMethod(size_t num_dalvik_instructions) const {
109 return num_dalvik_instructions > small_method_threshold_;
110 }
111
112 bool IsTinyMethod(size_t num_dalvik_instructions) const {
113 return num_dalvik_instructions > tiny_method_threshold_;
114 }
115
116 size_t GetNumDexMethodsThreshold() const {
117 return num_dex_methods_threshold_;
118 }
119
120#ifdef ART_SEA_IR_MODE
121 bool GetSeaIrMode();
122#endif
123
Mark Mendellae9fd932014-02-10 16:14:35 -0800124 bool GetGenerateGDBInformation() const {
125 return generate_gdb_information_;
126 }
127
Brian Carlstrom6449c622014-02-10 23:48:36 -0800128 private:
129 CompilerFilter compiler_filter_;
130 size_t huge_method_threshold_;
131 size_t large_method_threshold_;
132 size_t small_method_threshold_;
133 size_t tiny_method_threshold_;
134 size_t num_dex_methods_threshold_;
Mark Mendellae9fd932014-02-10 16:14:35 -0800135 bool generate_gdb_information_;
Brian Carlstrom6449c622014-02-10 23:48:36 -0800136
137#ifdef ART_SEA_IR_MODE
138 bool sea_ir_mode_;
139#endif
140};
141
142} // namespace art
143
144#endif // ART_COMPILER_DRIVER_COMPILER_OPTIONS_H_