Move instruction_set_ to CompilerOptions.
Removes CompilerDriver dependency from ImageWriter and
several other classes.
Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Test: Pixel 2 XL boots.
Test: m test-art-target-gtest
Test: testrunner.py --target --optimizing
Change-Id: I3c5b8ff73732128b9c4fad9405231a216ea72465
diff --git a/compiler/driver/compiled_method_storage_test.cc b/compiler/driver/compiled_method_storage_test.cc
index 42fbba5..aed04f9 100644
--- a/compiler/driver/compiled_method_storage_test.cc
+++ b/compiler/driver/compiled_method_storage_test.cc
@@ -31,8 +31,6 @@
CompilerDriver driver(&compiler_options,
&verification_results,
Compiler::kOptimizing,
- /* instruction_set_ */ InstructionSet::kNone,
- /* instruction_set_features */ nullptr,
/* image_classes */ nullptr,
/* thread_count */ 1u,
/* swap_fd */ -1,
diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc
index 66a8a57..7c13894 100644
--- a/compiler/driver/compiler_driver.cc
+++ b/compiler/driver/compiler_driver.cc
@@ -261,8 +261,6 @@
const CompilerOptions* compiler_options,
VerificationResults* verification_results,
Compiler::Kind compiler_kind,
- InstructionSet instruction_set,
- const InstructionSetFeatures* instruction_set_features,
HashSet<std::string>* image_classes,
size_t thread_count,
int swap_fd,
@@ -271,9 +269,6 @@
verification_results_(verification_results),
compiler_(Compiler::Create(this, compiler_kind)),
compiler_kind_(compiler_kind),
- instruction_set_(
- instruction_set == InstructionSet::kArm ? InstructionSet::kThumb2 : instruction_set),
- instruction_set_features_(instruction_set_features),
requires_constructor_barrier_lock_("constructor barrier lock"),
non_relative_linker_patch_count_(0u),
image_classes_(std::move(image_classes)),
@@ -309,13 +304,15 @@
}
-#define CREATE_TRAMPOLINE(type, abi, offset) \
- if (Is64BitInstructionSet(instruction_set_)) { \
- return CreateTrampoline64(instruction_set_, abi, \
- type ## _ENTRYPOINT_OFFSET(PointerSize::k64, offset)); \
- } else { \
- return CreateTrampoline32(instruction_set_, abi, \
- type ## _ENTRYPOINT_OFFSET(PointerSize::k32, offset)); \
+#define CREATE_TRAMPOLINE(type, abi, offset) \
+ if (Is64BitInstructionSet(GetCompilerOptions().GetInstructionSet())) { \
+ return CreateTrampoline64(GetCompilerOptions().GetInstructionSet(), \
+ abi, \
+ type ## _ENTRYPOINT_OFFSET(PointerSize::k64, offset)); \
+ } else { \
+ return CreateTrampoline32(GetCompilerOptions().GetInstructionSet(), \
+ abi, \
+ type ## _ENTRYPOINT_OFFSET(PointerSize::k32, offset)); \
}
std::unique_ptr<const std::vector<uint8_t>> CompilerDriver::CreateJniDlsymLookup() const {
@@ -601,7 +598,7 @@
if ((access_flags & kAccNative) != 0) {
// Are we extracting only and have support for generic JNI down calls?
if (!driver->GetCompilerOptions().IsJniCompilationEnabled() &&
- InstructionSetHasGenericJniStub(driver->GetInstructionSet())) {
+ InstructionSetHasGenericJniStub(driver->GetCompilerOptions().GetInstructionSet())) {
// Leaving this empty will trigger the generic JNI version
} else {
// Query any JNI optimization annotations such as @FastNative or @CriticalNative.
@@ -2146,8 +2143,9 @@
mirror::Class::SetStatus(klass, ClassStatus::kVerified, soa.Self());
// Mark methods as pre-verified. If we don't do this, the interpreter will run with
// access checks.
- klass->SetSkipAccessChecksFlagOnAllMethods(
- GetInstructionSetPointerSize(manager_->GetCompiler()->GetInstructionSet()));
+ InstructionSet instruction_set =
+ manager_->GetCompiler()->GetCompilerOptions().GetInstructionSet();
+ klass->SetSkipAccessChecksFlagOnAllMethods(GetInstructionSetPointerSize(instruction_set));
klass->SetVerificationAttempted();
}
// Record the final class status if necessary.
diff --git a/compiler/driver/compiler_driver.h b/compiler/driver/compiler_driver.h
index 54e1f37..8739dc3 100644
--- a/compiler/driver/compiler_driver.h
+++ b/compiler/driver/compiler_driver.h
@@ -97,8 +97,6 @@
CompilerDriver(const CompilerOptions* compiler_options,
VerificationResults* verification_results,
Compiler::Kind compiler_kind,
- InstructionSet instruction_set,
- const InstructionSetFeatures* instruction_set_features,
HashSet<std::string>* image_classes,
size_t thread_count,
int swap_fd,
@@ -129,14 +127,6 @@
VerificationResults* GetVerificationResults() const;
- InstructionSet GetInstructionSet() const {
- return instruction_set_;
- }
-
- const InstructionSetFeatures* GetInstructionSetFeatures() const {
- return instruction_set_features_;
- }
-
const CompilerOptions& GetCompilerOptions() const {
return *compiler_options_;
}
@@ -451,9 +441,6 @@
std::unique_ptr<Compiler> compiler_;
Compiler::Kind compiler_kind_;
- const InstructionSet instruction_set_;
- const InstructionSetFeatures* const instruction_set_features_;
-
// All class references that require constructor barriers. If the class reference is not in the
// set then the result has not yet been computed.
mutable ReaderWriterMutex requires_constructor_barrier_lock_ DEFAULT_MUTEX_ACQUIRED_AFTER;
diff --git a/compiler/driver/compiler_options.cc b/compiler/driver/compiler_options.cc
index cc1af3e..62d547d 100644
--- a/compiler/driver/compiler_options.cc
+++ b/compiler/driver/compiler_options.cc
@@ -20,6 +20,8 @@
#include "android-base/stringprintf.h"
+#include "arch/instruction_set.h"
+#include "arch/instruction_set_features.h"
#include "base/runtime_debug.h"
#include "base/variant_map.h"
#include "cmdline_parser.h"
@@ -37,13 +39,14 @@
tiny_method_threshold_(kDefaultTinyMethodThreshold),
num_dex_methods_threshold_(kDefaultNumDexMethodsThreshold),
inline_max_code_units_(kUnsetInlineMaxCodeUnits),
+ instruction_set_(kRuntimeISA == InstructionSet::kArm ? InstructionSet::kThumb2 : kRuntimeISA),
+ instruction_set_features_(nullptr),
no_inline_from_(),
dex_files_for_oat_file_(),
image_classes_(),
boot_image_(false),
core_image_(false),
app_image_(false),
- top_k_profile_threshold_(kDefaultTopKProfileThreshold),
debuggable_(false),
generate_debug_info_(kDefaultGenerateDebugInfo),
generate_mini_debug_info_(kDefaultGenerateMiniDebugInfo),
@@ -55,6 +58,7 @@
dump_timings_(false),
dump_pass_timings_(false),
dump_stats_(false),
+ top_k_profile_threshold_(kDefaultTopKProfileThreshold),
verbose_methods_(),
abort_on_hard_verifier_failure_(false),
abort_on_soft_verifier_failure_(false),
diff --git a/compiler/driver/compiler_options.h b/compiler/driver/compiler_options.h
index 908ff33..601c914 100644
--- a/compiler/driver/compiler_options.h
+++ b/compiler/driver/compiler_options.h
@@ -17,6 +17,7 @@
#ifndef ART_COMPILER_DRIVER_COMPILER_OPTIONS_H_
#define ART_COMPILER_DRIVER_COMPILER_OPTIONS_H_
+#include <memory>
#include <ostream>
#include <string>
#include <vector>
@@ -30,11 +31,17 @@
namespace art {
+namespace jit {
+class JitCompiler;
+} // namespace jit
+
namespace verifier {
class VerifierDepsTest;
} // namespace verifier
class DexFile;
+enum class InstructionSet;
+class InstructionSetFeatures;
class CompilerOptions FINAL {
public:
@@ -231,6 +238,15 @@
return abort_on_soft_verifier_failure_;
}
+ InstructionSet GetInstructionSet() const {
+ return instruction_set_;
+ }
+
+ const InstructionSetFeatures* GetInstructionSetFeatures() const {
+ return instruction_set_features_.get();
+ }
+
+
const std::vector<const DexFile*>& GetNoInlineFromDexFile() const {
return no_inline_from_;
}
@@ -312,6 +328,9 @@
size_t num_dex_methods_threshold_;
size_t inline_max_code_units_;
+ InstructionSet instruction_set_;
+ std::unique_ptr<const InstructionSetFeatures> instruction_set_features_;
+
// Dex files from which we should not inline code. Does not own the dex files.
// This is usually a very short list (i.e. a single dex file), so we
// prefer vector<> over a lookup-oriented container, such as set<>.
@@ -327,8 +346,6 @@
bool boot_image_;
bool core_image_;
bool app_image_;
- // When using a profile file only the top K% of the profiled samples will be compiled.
- double top_k_profile_threshold_;
bool debuggable_;
bool generate_debug_info_;
bool generate_mini_debug_info_;
@@ -341,6 +358,9 @@
bool dump_pass_timings_;
bool dump_stats_;
+ // When using a profile file only the top K% of the profiled samples will be compiled.
+ double top_k_profile_threshold_;
+
// Vector of methods to have verbose output enabled for.
std::vector<std::string> verbose_methods_;
@@ -380,6 +400,7 @@
friend class Dex2Oat;
friend class DexToDexDecompilerTest;
friend class CommonCompilerTest;
+ friend class jit::JitCompiler;
friend class verifier::VerifierDepsTest;
template <class Base>