summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Vaibhav Devmurari <vdevmurari@google.com> 2024-03-07 13:29:48 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2024-03-07 13:29:48 +0000
commitf66031b556c386f582eab39b5c616104d77fc375 (patch)
treeff692b41c6022bdb576bcf5090b89a452608db9b
parent3370f9fc477f0b25c4c6b10321b3f8e46903ad4f (diff)
Revert "Remove Compiler::Kind"
This reverts commit 3370f9fc477f0b25c4c6b10321b3f8e46903ad4f. Reason for revert: Build failure: b/328584377 Change-Id: I078c00e2df24950a156cd0c3ac6d78778f6ac2ba
-rw-r--r--compiler/common_compiler_test.cc11
-rw-r--r--compiler/common_compiler_test.h5
-rw-r--r--compiler/compiler.cc15
-rw-r--r--compiler/compiler.h8
-rw-r--r--compiler/jit/jit_compiler.cc3
-rw-r--r--dex2oat/common_compiler_driver_test.cc1
-rw-r--r--dex2oat/dex2oat.cc9
-rw-r--r--dex2oat/dex2oat_options.cc7
-rw-r--r--dex2oat/dex2oat_options.def1
-rw-r--r--dex2oat/driver/compiler_driver.cc4
-rw-r--r--dex2oat/driver/compiler_driver.h6
11 files changed, 62 insertions, 8 deletions
diff --git a/compiler/common_compiler_test.cc b/compiler/common_compiler_test.cc
index 8c05888215..d2cf3aef3c 100644
--- a/compiler/common_compiler_test.cc
+++ b/compiler/common_compiler_test.cc
@@ -255,6 +255,14 @@ void CommonCompilerTestImpl::SetUpRuntimeOptionsImpl() {
ApplyInstructionSet();
}
+Compiler::Kind CommonCompilerTestImpl::GetCompilerKind() const {
+ return compiler_kind_;
+}
+
+void CommonCompilerTestImpl::SetCompilerKind(Compiler::Kind compiler_kind) {
+ compiler_kind_ = compiler_kind;
+}
+
void CommonCompilerTestImpl::TearDown() {
code_and_metadata_.clear();
compiler_options_.reset();
@@ -270,7 +278,8 @@ void CommonCompilerTestImpl::CompileMethod(ArtMethod* method) {
DCHECK(!Runtime::Current()->IsStarted());
Thread* self = Thread::Current();
StackHandleScope<2> hs(self);
- std::unique_ptr<Compiler> compiler(Compiler::Create(*compiler_options_, &storage));
+ std::unique_ptr<Compiler> compiler(
+ Compiler::Create(*compiler_options_, &storage, compiler_kind_));
const DexFile& dex_file = *method->GetDexFile();
Handle<mirror::DexCache> dex_cache =
hs.NewHandle(GetClassLinker()->FindDexCache(self, dex_file));
diff --git a/compiler/common_compiler_test.h b/compiler/common_compiler_test.h
index 30d5734ba3..89f3fb40ad 100644
--- a/compiler/common_compiler_test.h
+++ b/compiler/common_compiler_test.h
@@ -60,6 +60,9 @@ class EXPORT CommonCompilerTestImpl {
void SetUpRuntimeOptionsImpl();
+ Compiler::Kind GetCompilerKind() const;
+ void SetCompilerKind(Compiler::Kind compiler_kind);
+
virtual CompilerFilter::Filter GetCompilerFilter() const {
return CompilerFilter::kDefaultCompilerFilter;
}
@@ -73,6 +76,8 @@ class EXPORT CommonCompilerTestImpl {
void ClearBootImageOption();
+ Compiler::Kind compiler_kind_ = Compiler::kOptimizing;
+
InstructionSet instruction_set_ =
(kRuntimeISA == InstructionSet::kArm) ? InstructionSet::kThumb2 : kRuntimeISA;
// Take the default set of instruction features from the build.
diff --git a/compiler/compiler.cc b/compiler/compiler.cc
index 9cbd65d89d..0e040ac54a 100644
--- a/compiler/compiler.cc
+++ b/compiler/compiler.cc
@@ -27,11 +27,22 @@
namespace art HIDDEN {
-Compiler* Compiler::Create(const CompilerOptions& compiler_options, CompiledCodeStorage* storage) {
+Compiler* Compiler::Create(const CompilerOptions& compiler_options,
+ CompiledCodeStorage* storage,
+ Compiler::Kind kind) {
// Check that oat version when runtime was compiled matches the oat version of the compiler.
constexpr std::array<uint8_t, 4> compiler_oat_version = OatHeader::kOatVersion;
OatHeader::CheckOatVersion(compiler_oat_version);
- return CreateOptimizingCompiler(compiler_options, storage);
+ switch (kind) {
+ case kQuick:
+ // TODO: Remove Quick in options.
+ case kOptimizing:
+ return CreateOptimizingCompiler(compiler_options, storage);
+
+ default:
+ LOG(FATAL) << "UNREACHABLE";
+ UNREACHABLE();
+ }
}
bool Compiler::IsPathologicalCase(const dex::CodeItem& code_item,
diff --git a/compiler/compiler.h b/compiler/compiler.h
index 843bbbb083..6c317f7e02 100644
--- a/compiler/compiler.h
+++ b/compiler/compiler.h
@@ -48,8 +48,14 @@ class Thread;
class Compiler {
public:
+ enum Kind {
+ kQuick,
+ kOptimizing
+ };
+
EXPORT static Compiler* Create(const CompilerOptions& compiler_options,
- CompiledCodeStorage* storage);
+ CompiledCodeStorage* storage,
+ Kind kind);
virtual bool CanCompileMethod(uint32_t method_idx, const DexFile& dex_file) const = 0;
diff --git a/compiler/jit/jit_compiler.cc b/compiler/jit/jit_compiler.cc
index 051368cc8a..c14d5d37e8 100644
--- a/compiler/jit/jit_compiler.cc
+++ b/compiler/jit/jit_compiler.cc
@@ -165,7 +165,8 @@ std::vector<uint8_t> JitCompiler::PackElfFileForJIT(ArrayRef<const JITCodeEntry*
JitCompiler::JitCompiler() {
compiler_options_.reset(new CompilerOptions());
ParseCompilerOptions();
- compiler_.reset(Compiler::Create(*compiler_options_, /*storage=*/ nullptr));
+ compiler_.reset(
+ Compiler::Create(*compiler_options_, /*storage=*/ nullptr, Compiler::kOptimizing));
}
JitCompiler::~JitCompiler() {
diff --git a/dex2oat/common_compiler_driver_test.cc b/dex2oat/common_compiler_driver_test.cc
index 81e06b2345..91fa859c92 100644
--- a/dex2oat/common_compiler_driver_test.cc
+++ b/dex2oat/common_compiler_driver_test.cc
@@ -89,6 +89,7 @@ void CommonCompilerDriverTest::CreateCompilerDriver() {
compiler_options_->profile_compilation_info_ = GetProfileCompilationInfo();
compiler_driver_.reset(new CompilerDriver(compiler_options_.get(),
verification_results_.get(),
+ compiler_kind_,
number_of_threads_,
/* swap_fd= */ -1));
}
diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc
index 6d33be3d97..c76929c030 100644
--- a/dex2oat/dex2oat.cc
+++ b/dex2oat/dex2oat.cc
@@ -510,7 +510,9 @@ class OatKeyValueStore : public SafeMap<std::string, std::string> {
class Dex2Oat final {
public:
explicit Dex2Oat(TimingLogger* timings)
- : key_value_store_(nullptr),
+ : compiler_kind_(Compiler::kOptimizing),
+ // Take the default set of instruction features from the build.
+ key_value_store_(nullptr),
verification_results_(nullptr),
runtime_(nullptr),
thread_count_(sysconf(_SC_NPROCESSORS_CONF)),
@@ -1117,6 +1119,9 @@ class Dex2Oat final {
compact_dex_level_ = CompactDexLevel::kCompactDexLevelNone;
}
+ AssignIfExists(args, M::Backend, &compiler_kind_);
+ parser_options->requested_specific_compiler = args.Exists(M::Backend);
+
AssignIfExists(args, M::TargetInstructionSet, &compiler_options_->instruction_set_);
// arm actually means thumb2.
if (compiler_options_->instruction_set_ == InstructionSet::kArm) {
@@ -1905,6 +1910,7 @@ class Dex2Oat final {
driver_.reset(new CompilerDriver(compiler_options_.get(),
verification_results_.get(),
+ compiler_kind_,
thread_count_,
swap_fd_));
@@ -2902,6 +2908,7 @@ class Dex2Oat final {
}
std::unique_ptr<CompilerOptions> compiler_options_;
+ Compiler::Kind compiler_kind_;
std::unique_ptr<OatKeyValueStore> key_value_store_;
diff --git a/dex2oat/dex2oat_options.cc b/dex2oat/dex2oat_options.cc
index adeecccc5e..7386fe15f6 100644
--- a/dex2oat/dex2oat_options.cc
+++ b/dex2oat/dex2oat_options.cc
@@ -339,6 +339,12 @@ Parser CreateDex2oatArgumentParser() {
"Eg: --android-root=out/host/linux-x86\n"
"Default: $ANDROID_ROOT")
.IntoKey(M::AndroidRoot)
+ .Define("--compiler-backend=_")
+ .WithType<Compiler::Kind>()
+ .WithValueMap({{"Quick", Compiler::Kind::kQuick},
+ {"Optimizing", Compiler::Kind::kOptimizing}})
+ .WithHelp("Select a compiler backend set. Default: optimizing")
+ .IntoKey(M::Backend)
.Define("--host")
.WithHelp("Run in host mode")
.IntoKey(M::Host)
@@ -457,7 +463,6 @@ Parser CreateDex2oatArgumentParser() {
.Ignore({
"--comments=_",
"--cache-info-fd=_", // Handled in mark_compact.cc.
- "--compiler-backend",
});
// clang-format on
diff --git a/dex2oat/dex2oat_options.def b/dex2oat/dex2oat_options.def
index 9a05d2b4df..7c071dc898 100644
--- a/dex2oat/dex2oat_options.def
+++ b/dex2oat/dex2oat_options.def
@@ -66,6 +66,7 @@ DEX2OAT_OPTIONS_KEY (std::string, AndroidRoot)
DEX2OAT_OPTIONS_KEY (InstructionSet, TargetInstructionSet)
DEX2OAT_OPTIONS_KEY (std::string, TargetInstructionSetVariant)
DEX2OAT_OPTIONS_KEY (std::string, TargetInstructionSetFeatures)
+DEX2OAT_OPTIONS_KEY (Compiler::Kind, Backend)
DEX2OAT_OPTIONS_KEY (std::vector<std::string>, Profile)
DEX2OAT_OPTIONS_KEY (std::vector<int>, ProfileFd)
DEX2OAT_OPTIONS_KEY (Unit, Host)
diff --git a/dex2oat/driver/compiler_driver.cc b/dex2oat/driver/compiler_driver.cc
index 731a57e140..39a68537e2 100644
--- a/dex2oat/driver/compiler_driver.cc
+++ b/dex2oat/driver/compiler_driver.cc
@@ -254,11 +254,13 @@ class CompilerDriver::AOTCompilationStats {
CompilerDriver::CompilerDriver(
const CompilerOptions* compiler_options,
const VerificationResults* verification_results,
+ Compiler::Kind compiler_kind,
size_t thread_count,
int swap_fd)
: compiler_options_(compiler_options),
verification_results_(verification_results),
compiler_(),
+ compiler_kind_(compiler_kind),
number_of_soft_verifier_failures_(0),
had_hard_verifier_failure_(false),
parallel_thread_count_(thread_count),
@@ -268,7 +270,7 @@ CompilerDriver::CompilerDriver(
DCHECK(compiler_options_ != nullptr);
compiled_method_storage_.SetDedupeEnabled(compiler_options_->DeduplicateCode());
- compiler_.reset(Compiler::Create(*compiler_options, &compiled_method_storage_));
+ compiler_.reset(Compiler::Create(*compiler_options, &compiled_method_storage_, compiler_kind));
}
CompilerDriver::~CompilerDriver() {
diff --git a/dex2oat/driver/compiler_driver.h b/dex2oat/driver/compiler_driver.h
index c57e4cf371..7985771246 100644
--- a/dex2oat/driver/compiler_driver.h
+++ b/dex2oat/driver/compiler_driver.h
@@ -86,6 +86,7 @@ class CompilerDriver {
// classes.
CompilerDriver(const CompilerOptions* compiler_options,
const VerificationResults* verification_results,
+ Compiler::Kind compiler_kind,
size_t thread_count,
int swap_fd);
@@ -213,6 +214,10 @@ class CompilerDriver {
number_of_soft_verifier_failures_++;
}
+ Compiler::Kind GetCompilerKind() {
+ return compiler_kind_;
+ }
+
CompiledMethodStorage* GetCompiledMethodStorage() {
return &compiled_method_storage_;
}
@@ -298,6 +303,7 @@ class CompilerDriver {
const VerificationResults* const verification_results_;
std::unique_ptr<Compiler> compiler_;
+ Compiler::Kind compiler_kind_;
// All class references that this compiler has compiled. Indexed by class defs.
using ClassStateTable = AtomicDexRefMap<ClassReference, ClassStatus>;