16449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom/*
26449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom * Copyright (C) 2014 The Android Open Source Project
36449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom *
46449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom * Licensed under the Apache License, Version 2.0 (the "License");
56449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom * you may not use this file except in compliance with the License.
66449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom * You may obtain a copy of the License at
76449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom *
86449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom *      http://www.apache.org/licenses/LICENSE-2.0
96449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom *
106449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom * Unless required by applicable law or agreed to in writing, software
116449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom * distributed under the License is distributed on an "AS IS" BASIS,
126449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
136449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom * See the License for the specific language governing permissions and
146449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom * limitations under the License.
156449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom */
166449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom
176449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom#ifndef ART_COMPILER_DRIVER_COMPILER_OPTIONS_H_
186449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom#define ART_COMPILER_DRIVER_COMPILER_OPTIONS_H_
196449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom
20dbfe254f5ca96f6c5b2284478597d6140c01a394Andreas Gampe#include <ostream>
21c7dd295a4e0cc1d15c0c96088e55a85389bade74Ian Rogers#include <string>
22c7dd295a4e0cc1d15c0c96088e55a85389bade74Ian Rogers#include <vector>
23c7dd295a4e0cc1d15c0c96088e55a85389bade74Ian Rogers
24c7dd295a4e0cc1d15c0c96088e55a85389bade74Ian Rogers#include "base/macros.h"
257bcfcb80a31f57a84d754e00bca8698829365208Andreas Gampe#include "compiler_filter.h"
266a3c1fcb4ba42ad4d5d142c17a3712a6ddd3866fIan Rogers#include "globals.h"
27abbb0f76b07417f13f712f54d5afddb72e3b9931Nicolas Geoffray#include "utils.h"
28c7dd295a4e0cc1d15c0c96088e55a85389bade74Ian Rogers
296449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstromnamespace art {
306449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom
31c7dd295a4e0cc1d15c0c96088e55a85389bade74Ian Rogersclass CompilerOptions FINAL {
326449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom public:
336449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom  // Guide heuristics to determine whether to compile method if profile data not available.
347bcfcb80a31f57a84d754e00bca8698829365208Andreas Gampe  static const CompilerFilter::Filter kDefaultCompilerFilter = CompilerFilter::kSpeed;
356449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom  static const size_t kDefaultHugeMethodThreshold = 10000;
366449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom  static const size_t kDefaultLargeMethodThreshold = 600;
376449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom  static const size_t kDefaultSmallMethodThreshold = 60;
386449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom  static const size_t kDefaultTinyMethodThreshold = 20;
396449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom  static const size_t kDefaultNumDexMethodsThreshold = 900;
40c1b643cc6ac45dbd0eabdcd7425c7e86006c27d6Calin Juravle  static constexpr double kDefaultTopKProfileThreshold = 90.0;
413e09eebe1ffd38b12d67c90cfe609d27453469ffDavid Srbecky  static const bool kDefaultGenerateDebugInfo = false;
425b1c2ca30dad519be285f0a1e839c23cc4e3a51dDavid Srbecky  static const bool kDefaultGenerateMiniDebugInfo = false;
4353cb16b98acf3cf6f3a1e2204ad4958ecf1b5a3cAlex Light  static const bool kDefaultIncludePatchInformation = false;
44ec74835a7e4f2660250a2f3f9508cbbe5269e49aCalin Juravle  static const size_t kDefaultInlineDepthLimit = 3;
455949fa0cb9a8d26ac20b9b02065a63b4b20443beNicolas Geoffray  static const size_t kDefaultInlineMaxCodeUnits = 32;
46abbb0f76b07417f13f712f54d5afddb72e3b9931Nicolas Geoffray  static constexpr size_t kUnsetInlineDepthLimit = -1;
47abbb0f76b07417f13f712f54d5afddb72e3b9931Nicolas Geoffray  static constexpr size_t kUnsetInlineMaxCodeUnits = -1;
486449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom
49a215b95d03cfe713018a245553b74d7eeee813dfRoland Levillain  // Default inlining settings when the space filter is used.
50a215b95d03cfe713018a245553b74d7eeee813dfRoland Levillain  static constexpr size_t kSpaceFilterInlineDepthLimit = 3;
51a215b95d03cfe713018a245553b74d7eeee813dfRoland Levillain  static constexpr size_t kSpaceFilterInlineMaxCodeUnits = 10;
52a215b95d03cfe713018a245553b74d7eeee813dfRoland Levillain
535bdab12d8b48ca4c395d9d2c506ebff0df01b734Mathieu Chartier  CompilerOptions();
54b163bb742a099c1808907b513ae39068b63b1692Vladimir Marko  ~CompilerOptions();
556449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom
567bcfcb80a31f57a84d754e00bca8698829365208Andreas Gampe  CompilerOptions(CompilerFilter::Filter compiler_filter,
576449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom                  size_t huge_method_threshold,
586449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom                  size_t large_method_threshold,
596449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom                  size_t small_method_threshold,
606449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom                  size_t tiny_method_threshold,
61ae9fd93c39a341e2dffe15c61cc7d9e841fa92c4Mark Mendell                  size_t num_dex_methods_threshold,
62ec74835a7e4f2660250a2f3f9508cbbe5269e49aCalin Juravle                  size_t inline_depth_limit,
63ec74835a7e4f2660250a2f3f9508cbbe5269e49aCalin Juravle                  size_t inline_max_code_units,
6447496c293b2b79c9747eeebafe444715202e7fc6Vladimir Marko                  const std::vector<const DexFile*>* no_inline_from,
6553cb16b98acf3cf6f3a1e2204ad4958ecf1b5a3cAlex Light                  bool include_patch_information,
6678382fa44ee505cf16835e4d22515e7252a90864Alex Light                  double top_k_profile_threshold,
677b2f09eb6b5c74ffc38bd70f0aa74b8f8112e394Andreas Gampe                  bool debuggable,
688363c772581bf00ebcdc2e38391b4bfae51beb75David Srbecky                  bool generate_debug_info,
6969dfe51b684dd9d510dbcb63295fe180f998efdeDave Allison                  bool implicit_null_checks,
7069dfe51b684dd9d510dbcb63295fe180f998efdeDave Allison                  bool implicit_so_checks,
71d6dee676acdd1ab0aa4e5ba6834ee7c40a6dd8abIgor Murashkin                  bool implicit_suspend_checks,
72c7dd295a4e0cc1d15c0c96088e55a85389bade74Ian Rogers                  bool compile_pic,
73dbfe254f5ca96f6c5b2284478597d6140c01a394Andreas Gampe                  const std::vector<std::string>* verbose_methods,
746cf49e57ad7a61e1fffd5b1dfae9179c3ca5703dAndreas Gampe                  std::ostream* init_failure_output,
75c903b6af634927479915eaa9516d493eea23f911Nicolas Geoffray                  bool abort_on_hard_verifier_failure,
76c903b6af634927479915eaa9516d493eea23f911Nicolas Geoffray                  const std::string& dump_cfg_file_name,
77ace0dc1dd5480ad458e622085e51583653853fb9Andreas Gampe                  bool dump_cfg_append,
78ace0dc1dd5480ad458e622085e51583653853fb9Andreas Gampe                  bool force_determinism);
796449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom
807bcfcb80a31f57a84d754e00bca8698829365208Andreas Gampe  CompilerFilter::Filter GetCompilerFilter() const {
816449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom    return compiler_filter_;
826449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom  }
836449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom
847bcfcb80a31f57a84d754e00bca8698829365208Andreas Gampe  void SetCompilerFilter(CompilerFilter::Filter compiler_filter) {
856449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom    compiler_filter_ = compiler_filter;
866449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom  }
876449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom
88e86deeffad79c00ed2ebede04f4adc348bda790cMathieu Chartier  bool VerifyAtRuntime() const {
897bcfcb80a31f57a84d754e00bca8698829365208Andreas Gampe    return compiler_filter_ == CompilerFilter::kVerifyAtRuntime;
90e86deeffad79c00ed2ebede04f4adc348bda790cMathieu Chartier  }
91e86deeffad79c00ed2ebede04f4adc348bda790cMathieu Chartier
928c185bf0c6f18a5349bc87a7e3751ba06d90f461Vladimir Marko  bool IsBytecodeCompilationEnabled() const {
938c185bf0c6f18a5349bc87a7e3751ba06d90f461Vladimir Marko    return CompilerFilter::IsBytecodeCompilationEnabled(compiler_filter_);
948c185bf0c6f18a5349bc87a7e3751ba06d90f461Vladimir Marko  }
958c185bf0c6f18a5349bc87a7e3751ba06d90f461Vladimir Marko
968c185bf0c6f18a5349bc87a7e3751ba06d90f461Vladimir Marko  bool IsJniCompilationEnabled() const {
978c185bf0c6f18a5349bc87a7e3751ba06d90f461Vladimir Marko    return CompilerFilter::IsJniCompilationEnabled(compiler_filter_);
984a200f56b7075309316b04d550c9cc50f8314eddJeff Hao  }
994a200f56b7075309316b04d550c9cc50f8314eddJeff Hao
1004a200f56b7075309316b04d550c9cc50f8314eddJeff Hao  bool IsVerificationEnabled() const {
1017bcfcb80a31f57a84d754e00bca8698829365208Andreas Gampe    return CompilerFilter::IsVerificationEnabled(compiler_filter_);
102e86deeffad79c00ed2ebede04f4adc348bda790cMathieu Chartier  }
103e86deeffad79c00ed2ebede04f4adc348bda790cMathieu Chartier
104e86deeffad79c00ed2ebede04f4adc348bda790cMathieu Chartier  bool NeverVerify() const {
1057bcfcb80a31f57a84d754e00bca8698829365208Andreas Gampe    return compiler_filter_ == CompilerFilter::kVerifyNone;
106ce4b0ba4d762775a86b3529ac76cb89199c0cc1eDavid Brazdil  }
107ce4b0ba4d762775a86b3529ac76cb89199c0cc1eDavid Brazdil
108a807780b1d8ee01dfb03923c673621b4c81ac858Mathieu Chartier  bool VerifyOnlyProfile() const {
1097bcfcb80a31f57a84d754e00bca8698829365208Andreas Gampe    return compiler_filter_ == CompilerFilter::kVerifyProfile;
110a807780b1d8ee01dfb03923c673621b4c81ac858Mathieu Chartier  }
111a807780b1d8ee01dfb03923c673621b4c81ac858Mathieu Chartier
1126449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom  size_t GetHugeMethodThreshold() const {
1136449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom    return huge_method_threshold_;
1146449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom  }
1156449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom
1166449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom  size_t GetLargeMethodThreshold() const {
1176449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom    return large_method_threshold_;
1186449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom  }
1196449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom
1206449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom  size_t GetSmallMethodThreshold() const {
1216449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom    return small_method_threshold_;
1226449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom  }
1236449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom
1246449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom  size_t GetTinyMethodThreshold() const {
1256449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom    return tiny_method_threshold_;
1266449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom  }
1276449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom
1286449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom  bool IsHugeMethod(size_t num_dalvik_instructions) const {
1296449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom    return num_dalvik_instructions > huge_method_threshold_;
1306449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom  }
1316449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom
1326449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom  bool IsLargeMethod(size_t num_dalvik_instructions) const {
1336449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom    return num_dalvik_instructions > large_method_threshold_;
1346449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom  }
1356449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom
1366449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom  bool IsSmallMethod(size_t num_dalvik_instructions) const {
1376449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom    return num_dalvik_instructions > small_method_threshold_;
1386449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom  }
1396449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom
1406449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom  bool IsTinyMethod(size_t num_dalvik_instructions) const {
1416449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom    return num_dalvik_instructions > tiny_method_threshold_;
1426449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom  }
1436449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom
1446449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom  size_t GetNumDexMethodsThreshold() const {
1456449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom    return num_dex_methods_threshold_;
1466449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom  }
1476449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom
148ec74835a7e4f2660250a2f3f9508cbbe5269e49aCalin Juravle  size_t GetInlineDepthLimit() const {
149ec74835a7e4f2660250a2f3f9508cbbe5269e49aCalin Juravle    return inline_depth_limit_;
150ec74835a7e4f2660250a2f3f9508cbbe5269e49aCalin Juravle  }
1513f41a0193eadf037b4003c1996151f386ca07b13Andreas Gampe  void SetInlineDepthLimit(size_t limit) {
1523f41a0193eadf037b4003c1996151f386ca07b13Andreas Gampe    inline_depth_limit_ = limit;
1533f41a0193eadf037b4003c1996151f386ca07b13Andreas Gampe  }
154ec74835a7e4f2660250a2f3f9508cbbe5269e49aCalin Juravle
155ec74835a7e4f2660250a2f3f9508cbbe5269e49aCalin Juravle  size_t GetInlineMaxCodeUnits() const {
156ec74835a7e4f2660250a2f3f9508cbbe5269e49aCalin Juravle    return inline_max_code_units_;
157ec74835a7e4f2660250a2f3f9508cbbe5269e49aCalin Juravle  }
1583f41a0193eadf037b4003c1996151f386ca07b13Andreas Gampe  void SetInlineMaxCodeUnits(size_t units) {
1593f41a0193eadf037b4003c1996151f386ca07b13Andreas Gampe    inline_max_code_units_ = units;
1603f41a0193eadf037b4003c1996151f386ca07b13Andreas Gampe  }
161ec74835a7e4f2660250a2f3f9508cbbe5269e49aCalin Juravle
162c1b643cc6ac45dbd0eabdcd7425c7e86006c27d6Calin Juravle  double GetTopKProfileThreshold() const {
163c1b643cc6ac45dbd0eabdcd7425c7e86006c27d6Calin Juravle    return top_k_profile_threshold_;
164c1b643cc6ac45dbd0eabdcd7425c7e86006c27d6Calin Juravle  }
165c1b643cc6ac45dbd0eabdcd7425c7e86006c27d6Calin Juravle
1667b2f09eb6b5c74ffc38bd70f0aa74b8f8112e394Andreas Gampe  bool GetDebuggable() const {
1677b2f09eb6b5c74ffc38bd70f0aa74b8f8112e394Andreas Gampe    return debuggable_;
1687b2f09eb6b5c74ffc38bd70f0aa74b8f8112e394Andreas Gampe  }
1697b2f09eb6b5c74ffc38bd70f0aa74b8f8112e394Andreas Gampe
1700cf4493166ff28518c8eafa2d0463f6e817cce75David Srbecky  bool GetNativeDebuggable() const {
171346dc993615487e9c645a515dfcbf9a6488f36feDavid Srbecky    return GetDebuggable() && GetGenerateDebugInfo();
1720cf4493166ff28518c8eafa2d0463f6e817cce75David Srbecky  }
1730cf4493166ff28518c8eafa2d0463f6e817cce75David Srbecky
1745b1c2ca30dad519be285f0a1e839c23cc4e3a51dDavid Srbecky  // This flag controls whether the compiler collects debugging information.
1755b1c2ca30dad519be285f0a1e839c23cc4e3a51dDavid Srbecky  // The other flags control how the information is written to disk.
1765b1c2ca30dad519be285f0a1e839c23cc4e3a51dDavid Srbecky  bool GenerateAnyDebugInfo() const {
1775b1c2ca30dad519be285f0a1e839c23cc4e3a51dDavid Srbecky    return GetGenerateDebugInfo() || GetGenerateMiniDebugInfo();
1785b1c2ca30dad519be285f0a1e839c23cc4e3a51dDavid Srbecky  }
1795b1c2ca30dad519be285f0a1e839c23cc4e3a51dDavid Srbecky
1808363c772581bf00ebcdc2e38391b4bfae51beb75David Srbecky  bool GetGenerateDebugInfo() const {
1818363c772581bf00ebcdc2e38391b4bfae51beb75David Srbecky    return generate_debug_info_;
1828dc7324da5bd0f2afd2ab558ab04882329a61fe8David Srbecky  }
1838dc7324da5bd0f2afd2ab558ab04882329a61fe8David Srbecky
1845b1c2ca30dad519be285f0a1e839c23cc4e3a51dDavid Srbecky  bool GetGenerateMiniDebugInfo() const {
1855b1c2ca30dad519be285f0a1e839c23cc4e3a51dDavid Srbecky    return generate_mini_debug_info_;
1865b1c2ca30dad519be285f0a1e839c23cc4e3a51dDavid Srbecky  }
1875b1c2ca30dad519be285f0a1e839c23cc4e3a51dDavid Srbecky
18869dfe51b684dd9d510dbcb63295fe180f998efdeDave Allison  bool GetImplicitNullChecks() const {
18969dfe51b684dd9d510dbcb63295fe180f998efdeDave Allison    return implicit_null_checks_;
1905655e84e8d71697d8ef3ea901a0b853af42c559eAndreas Gampe  }
1915655e84e8d71697d8ef3ea901a0b853af42c559eAndreas Gampe
19269dfe51b684dd9d510dbcb63295fe180f998efdeDave Allison  bool GetImplicitStackOverflowChecks() const {
19369dfe51b684dd9d510dbcb63295fe180f998efdeDave Allison    return implicit_so_checks_;
1945655e84e8d71697d8ef3ea901a0b853af42c559eAndreas Gampe  }
1955655e84e8d71697d8ef3ea901a0b853af42c559eAndreas Gampe
19669dfe51b684dd9d510dbcb63295fe180f998efdeDave Allison  bool GetImplicitSuspendChecks() const {
19769dfe51b684dd9d510dbcb63295fe180f998efdeDave Allison    return implicit_suspend_checks_;
1985655e84e8d71697d8ef3ea901a0b853af42c559eAndreas Gampe  }
1995655e84e8d71697d8ef3ea901a0b853af42c559eAndreas Gampe
20053cb16b98acf3cf6f3a1e2204ad4958ecf1b5a3cAlex Light  bool GetIncludePatchInformation() const {
20153cb16b98acf3cf6f3a1e2204ad4958ecf1b5a3cAlex Light    return include_patch_information_;
20253cb16b98acf3cf6f3a1e2204ad4958ecf1b5a3cAlex Light  }
20353cb16b98acf3cf6f3a1e2204ad4958ecf1b5a3cAlex Light
204d6dee676acdd1ab0aa4e5ba6834ee7c40a6dd8abIgor Murashkin  // Should the code be compiled as position independent?
205d6dee676acdd1ab0aa4e5ba6834ee7c40a6dd8abIgor Murashkin  bool GetCompilePic() const {
206d6dee676acdd1ab0aa4e5ba6834ee7c40a6dd8abIgor Murashkin    return compile_pic_;
207d6dee676acdd1ab0aa4e5ba6834ee7c40a6dd8abIgor Murashkin  }
208d6dee676acdd1ab0aa4e5ba6834ee7c40a6dd8abIgor Murashkin
209c7dd295a4e0cc1d15c0c96088e55a85389bade74Ian Rogers  bool HasVerboseMethods() const {
210c7dd295a4e0cc1d15c0c96088e55a85389bade74Ian Rogers    return verbose_methods_ != nullptr && !verbose_methods_->empty();
211c7dd295a4e0cc1d15c0c96088e55a85389bade74Ian Rogers  }
212c7dd295a4e0cc1d15c0c96088e55a85389bade74Ian Rogers
213c7dd295a4e0cc1d15c0c96088e55a85389bade74Ian Rogers  bool IsVerboseMethod(const std::string& pretty_method) const {
214c7dd295a4e0cc1d15c0c96088e55a85389bade74Ian Rogers    for (const std::string& cur_method : *verbose_methods_) {
215c7dd295a4e0cc1d15c0c96088e55a85389bade74Ian Rogers      if (pretty_method.find(cur_method) != std::string::npos) {
216c7dd295a4e0cc1d15c0c96088e55a85389bade74Ian Rogers        return true;
217c7dd295a4e0cc1d15c0c96088e55a85389bade74Ian Rogers      }
218c7dd295a4e0cc1d15c0c96088e55a85389bade74Ian Rogers    }
219c7dd295a4e0cc1d15c0c96088e55a85389bade74Ian Rogers    return false;
220c7dd295a4e0cc1d15c0c96088e55a85389bade74Ian Rogers  }
221c7dd295a4e0cc1d15c0c96088e55a85389bade74Ian Rogers
222dbfe254f5ca96f6c5b2284478597d6140c01a394Andreas Gampe  std::ostream* GetInitFailureOutput() const {
223abbb0f76b07417f13f712f54d5afddb72e3b9931Nicolas Geoffray    return init_failure_output_.get();
224dbfe254f5ca96f6c5b2284478597d6140c01a394Andreas Gampe  }
225dbfe254f5ca96f6c5b2284478597d6140c01a394Andreas Gampe
2266cf49e57ad7a61e1fffd5b1dfae9179c3ca5703dAndreas Gampe  bool AbortOnHardVerifierFailure() const {
2276cf49e57ad7a61e1fffd5b1dfae9179c3ca5703dAndreas Gampe    return abort_on_hard_verifier_failure_;
2286cf49e57ad7a61e1fffd5b1dfae9179c3ca5703dAndreas Gampe  }
2296cf49e57ad7a61e1fffd5b1dfae9179c3ca5703dAndreas Gampe
23047496c293b2b79c9747eeebafe444715202e7fc6Vladimir Marko  const std::vector<const DexFile*>* GetNoInlineFromDexFile() const {
231dcdc85bbd569f0ee66c331b4219c19304a616214Jeff Hao    return no_inline_from_;
232dcdc85bbd569f0ee66c331b4219c19304a616214Jeff Hao  }
233dcdc85bbd569f0ee66c331b4219c19304a616214Jeff Hao
234abbb0f76b07417f13f712f54d5afddb72e3b9931Nicolas Geoffray  bool ParseCompilerOption(const StringPiece& option, UsageFn Usage);
235abbb0f76b07417f13f712f54d5afddb72e3b9931Nicolas Geoffray
236c903b6af634927479915eaa9516d493eea23f911Nicolas Geoffray  const std::string& GetDumpCfgFileName() const {
237c903b6af634927479915eaa9516d493eea23f911Nicolas Geoffray    return dump_cfg_file_name_;
238c903b6af634927479915eaa9516d493eea23f911Nicolas Geoffray  }
239c903b6af634927479915eaa9516d493eea23f911Nicolas Geoffray
240c903b6af634927479915eaa9516d493eea23f911Nicolas Geoffray  bool GetDumpCfgAppend() const {
241c903b6af634927479915eaa9516d493eea23f911Nicolas Geoffray    return dump_cfg_append_;
242c903b6af634927479915eaa9516d493eea23f911Nicolas Geoffray  }
243c903b6af634927479915eaa9516d493eea23f911Nicolas Geoffray
244ace0dc1dd5480ad458e622085e51583653853fb9Andreas Gampe  bool IsForceDeterminism() const {
245ace0dc1dd5480ad458e622085e51583653853fb9Andreas Gampe    return force_determinism_;
246ace0dc1dd5480ad458e622085e51583653853fb9Andreas Gampe  }
247ace0dc1dd5480ad458e622085e51583653853fb9Andreas Gampe
2486449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom private:
249abbb0f76b07417f13f712f54d5afddb72e3b9931Nicolas Geoffray  void ParseDumpInitFailures(const StringPiece& option, UsageFn Usage);
250abbb0f76b07417f13f712f54d5afddb72e3b9931Nicolas Geoffray  void ParseDumpCfgPasses(const StringPiece& option, UsageFn Usage);
251abbb0f76b07417f13f712f54d5afddb72e3b9931Nicolas Geoffray  void ParseInlineMaxCodeUnits(const StringPiece& option, UsageFn Usage);
252abbb0f76b07417f13f712f54d5afddb72e3b9931Nicolas Geoffray  void ParseInlineDepthLimit(const StringPiece& option, UsageFn Usage);
253abbb0f76b07417f13f712f54d5afddb72e3b9931Nicolas Geoffray  void ParseNumDexMethods(const StringPiece& option, UsageFn Usage);
254abbb0f76b07417f13f712f54d5afddb72e3b9931Nicolas Geoffray  void ParseTinyMethodMax(const StringPiece& option, UsageFn Usage);
255abbb0f76b07417f13f712f54d5afddb72e3b9931Nicolas Geoffray  void ParseSmallMethodMax(const StringPiece& option, UsageFn Usage);
256abbb0f76b07417f13f712f54d5afddb72e3b9931Nicolas Geoffray  void ParseLargeMethodMax(const StringPiece& option, UsageFn Usage);
257abbb0f76b07417f13f712f54d5afddb72e3b9931Nicolas Geoffray  void ParseHugeMethodMax(const StringPiece& option, UsageFn Usage);
258abbb0f76b07417f13f712f54d5afddb72e3b9931Nicolas Geoffray
2597bcfcb80a31f57a84d754e00bca8698829365208Andreas Gampe  CompilerFilter::Filter compiler_filter_;
260abbb0f76b07417f13f712f54d5afddb72e3b9931Nicolas Geoffray  size_t huge_method_threshold_;
261abbb0f76b07417f13f712f54d5afddb72e3b9931Nicolas Geoffray  size_t large_method_threshold_;
262abbb0f76b07417f13f712f54d5afddb72e3b9931Nicolas Geoffray  size_t small_method_threshold_;
263abbb0f76b07417f13f712f54d5afddb72e3b9931Nicolas Geoffray  size_t tiny_method_threshold_;
264abbb0f76b07417f13f712f54d5afddb72e3b9931Nicolas Geoffray  size_t num_dex_methods_threshold_;
265abbb0f76b07417f13f712f54d5afddb72e3b9931Nicolas Geoffray  size_t inline_depth_limit_;
266abbb0f76b07417f13f712f54d5afddb72e3b9931Nicolas Geoffray  size_t inline_max_code_units_;
267dcdc85bbd569f0ee66c331b4219c19304a616214Jeff Hao
26847496c293b2b79c9747eeebafe444715202e7fc6Vladimir Marko  // Dex files from which we should not inline code.
26947496c293b2b79c9747eeebafe444715202e7fc6Vladimir Marko  // This is usually a very short list (i.e. a single dex file), so we
27047496c293b2b79c9747eeebafe444715202e7fc6Vladimir Marko  // prefer vector<> over a lookup-oriented container, such as set<>.
27147496c293b2b79c9747eeebafe444715202e7fc6Vladimir Marko  const std::vector<const DexFile*>* no_inline_from_;
272dcdc85bbd569f0ee66c331b4219c19304a616214Jeff Hao
273abbb0f76b07417f13f712f54d5afddb72e3b9931Nicolas Geoffray  bool include_patch_information_;
274c1b643cc6ac45dbd0eabdcd7425c7e86006c27d6Calin Juravle  // When using a profile file only the top K% of the profiled samples will be compiled.
275abbb0f76b07417f13f712f54d5afddb72e3b9931Nicolas Geoffray  double top_k_profile_threshold_;
276abbb0f76b07417f13f712f54d5afddb72e3b9931Nicolas Geoffray  bool debuggable_;
277abbb0f76b07417f13f712f54d5afddb72e3b9931Nicolas Geoffray  bool generate_debug_info_;
2785b1c2ca30dad519be285f0a1e839c23cc4e3a51dDavid Srbecky  bool generate_mini_debug_info_;
279abbb0f76b07417f13f712f54d5afddb72e3b9931Nicolas Geoffray  bool implicit_null_checks_;
280abbb0f76b07417f13f712f54d5afddb72e3b9931Nicolas Geoffray  bool implicit_so_checks_;
281abbb0f76b07417f13f712f54d5afddb72e3b9931Nicolas Geoffray  bool implicit_suspend_checks_;
282abbb0f76b07417f13f712f54d5afddb72e3b9931Nicolas Geoffray  bool compile_pic_;
283c7dd295a4e0cc1d15c0c96088e55a85389bade74Ian Rogers
284c7dd295a4e0cc1d15c0c96088e55a85389bade74Ian Rogers  // Vector of methods to have verbose output enabled for.
285abbb0f76b07417f13f712f54d5afddb72e3b9931Nicolas Geoffray  const std::vector<std::string>* verbose_methods_;
286c7dd295a4e0cc1d15c0c96088e55a85389bade74Ian Rogers
2876cf49e57ad7a61e1fffd5b1dfae9179c3ca5703dAndreas Gampe  // Abort compilation with an error if we find a class that fails verification with a hard
2886cf49e57ad7a61e1fffd5b1dfae9179c3ca5703dAndreas Gampe  // failure.
289abbb0f76b07417f13f712f54d5afddb72e3b9931Nicolas Geoffray  bool abort_on_hard_verifier_failure_;
2906cf49e57ad7a61e1fffd5b1dfae9179c3ca5703dAndreas Gampe
291dbfe254f5ca96f6c5b2284478597d6140c01a394Andreas Gampe  // Log initialization of initialization failures to this stream if not null.
292abbb0f76b07417f13f712f54d5afddb72e3b9931Nicolas Geoffray  std::unique_ptr<std::ostream> init_failure_output_;
293abbb0f76b07417f13f712f54d5afddb72e3b9931Nicolas Geoffray
294c903b6af634927479915eaa9516d493eea23f911Nicolas Geoffray  std::string dump_cfg_file_name_;
295c903b6af634927479915eaa9516d493eea23f911Nicolas Geoffray  bool dump_cfg_append_;
296c903b6af634927479915eaa9516d493eea23f911Nicolas Geoffray
297ace0dc1dd5480ad458e622085e51583653853fb9Andreas Gampe  // Whether the compiler should trade performance for determinism to guarantee exactly reproducable
298ace0dc1dd5480ad458e622085e51583653853fb9Andreas Gampe  // outcomes.
299ace0dc1dd5480ad458e622085e51583653853fb9Andreas Gampe  bool force_determinism_;
300ace0dc1dd5480ad458e622085e51583653853fb9Andreas Gampe
301abbb0f76b07417f13f712f54d5afddb72e3b9931Nicolas Geoffray  friend class Dex2Oat;
302dbfe254f5ca96f6c5b2284478597d6140c01a394Andreas Gampe
303c7dd295a4e0cc1d15c0c96088e55a85389bade74Ian Rogers  DISALLOW_COPY_AND_ASSIGN(CompilerOptions);
3046449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom};
3056449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom
3066449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom}  // namespace art
3076449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom
3086449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom#endif  // ART_COMPILER_DRIVER_COMPILER_OPTIONS_H_
309