diff options
-rw-r--r-- | compiler/compiled_method.cc | 42 | ||||
-rw-r--r-- | compiler/compiled_method.h | 8 | ||||
-rw-r--r-- | compiler/compiler.cc | 64 | ||||
-rw-r--r-- | compiler/compiler.h | 34 | ||||
-rw-r--r-- | compiler/compilers.cc | 75 | ||||
-rw-r--r-- | compiler/compilers.h | 24 | ||||
-rw-r--r-- | compiler/dex/frontend.cc | 8 | ||||
-rw-r--r-- | compiler/dex/quick/codegen_util.cc | 2 | ||||
-rw-r--r-- | compiler/driver/compiler_driver.cc | 15 | ||||
-rw-r--r-- | compiler/jni/quick/jni_compiler.cc | 8 | ||||
-rw-r--r-- | compiler/llvm/compiler_llvm.cc | 24 | ||||
-rw-r--r-- | compiler/optimizing/optimizing_compiler.cc | 10 |
12 files changed, 152 insertions, 162 deletions
diff --git a/compiler/compiled_method.cc b/compiler/compiled_method.cc index 59ed827..7441dac 100644 --- a/compiler/compiled_method.cc +++ b/compiler/compiled_method.cc @@ -138,7 +138,7 @@ void CompiledCode::AddOatdataOffsetToCompliledCodeOffset(uint32_t offset) { oatdata_offsets_to_compiled_code_offset_.push_back(offset); } -CompiledMethod::CompiledMethod(CompilerDriver& driver, +CompiledMethod::CompiledMethod(CompilerDriver* driver, InstructionSet instruction_set, const std::vector<uint8_t>& quick_code, const size_t frame_size_in_bytes, @@ -148,48 +148,48 @@ CompiledMethod::CompiledMethod(CompilerDriver& driver, const std::vector<uint8_t>& vmap_table, const std::vector<uint8_t>& native_gc_map, const std::vector<uint8_t>* cfi_info) - : CompiledCode(&driver, instruction_set, quick_code), frame_size_in_bytes_(frame_size_in_bytes), + : CompiledCode(driver, instruction_set, quick_code), frame_size_in_bytes_(frame_size_in_bytes), core_spill_mask_(core_spill_mask), fp_spill_mask_(fp_spill_mask), - mapping_table_(driver.DeduplicateMappingTable(mapping_table)), - vmap_table_(driver.DeduplicateVMapTable(vmap_table)), - gc_map_(driver.DeduplicateGCMap(native_gc_map)), - cfi_info_(driver.DeduplicateCFIInfo(cfi_info)) { + mapping_table_(driver->DeduplicateMappingTable(mapping_table)), + vmap_table_(driver->DeduplicateVMapTable(vmap_table)), + gc_map_(driver->DeduplicateGCMap(native_gc_map)), + cfi_info_(driver->DeduplicateCFIInfo(cfi_info)) { } -CompiledMethod::CompiledMethod(CompilerDriver& driver, +CompiledMethod::CompiledMethod(CompilerDriver* driver, InstructionSet instruction_set, const std::vector<uint8_t>& code, const size_t frame_size_in_bytes, const uint32_t core_spill_mask, const uint32_t fp_spill_mask) - : CompiledCode(&driver, instruction_set, code), + : CompiledCode(driver, instruction_set, code), frame_size_in_bytes_(frame_size_in_bytes), core_spill_mask_(core_spill_mask), fp_spill_mask_(fp_spill_mask), - mapping_table_(driver.DeduplicateMappingTable(std::vector<uint8_t>())), - vmap_table_(driver.DeduplicateVMapTable(std::vector<uint8_t>())), - gc_map_(driver.DeduplicateGCMap(std::vector<uint8_t>())), + mapping_table_(driver->DeduplicateMappingTable(std::vector<uint8_t>())), + vmap_table_(driver->DeduplicateVMapTable(std::vector<uint8_t>())), + gc_map_(driver->DeduplicateGCMap(std::vector<uint8_t>())), cfi_info_(nullptr) { } // Constructs a CompiledMethod for the Portable compiler. -CompiledMethod::CompiledMethod(CompilerDriver& driver, InstructionSet instruction_set, +CompiledMethod::CompiledMethod(CompilerDriver* driver, InstructionSet instruction_set, const std::string& code, const std::vector<uint8_t>& gc_map, const std::string& symbol) - : CompiledCode(&driver, instruction_set, code, symbol), + : CompiledCode(driver, instruction_set, code, symbol), frame_size_in_bytes_(kStackAlignment), core_spill_mask_(0), - fp_spill_mask_(0), gc_map_(driver.DeduplicateGCMap(gc_map)) { - mapping_table_ = driver.DeduplicateMappingTable(std::vector<uint8_t>()); - vmap_table_ = driver.DeduplicateVMapTable(std::vector<uint8_t>()); + fp_spill_mask_(0), gc_map_(driver->DeduplicateGCMap(gc_map)) { + mapping_table_ = driver->DeduplicateMappingTable(std::vector<uint8_t>()); + vmap_table_ = driver->DeduplicateVMapTable(std::vector<uint8_t>()); } -CompiledMethod::CompiledMethod(CompilerDriver& driver, InstructionSet instruction_set, +CompiledMethod::CompiledMethod(CompilerDriver* driver, InstructionSet instruction_set, const std::string& code, const std::string& symbol) - : CompiledCode(&driver, instruction_set, code, symbol), + : CompiledCode(driver, instruction_set, code, symbol), frame_size_in_bytes_(kStackAlignment), core_spill_mask_(0), fp_spill_mask_(0) { - mapping_table_ = driver.DeduplicateMappingTable(std::vector<uint8_t>()); - vmap_table_ = driver.DeduplicateVMapTable(std::vector<uint8_t>()); - gc_map_ = driver.DeduplicateGCMap(std::vector<uint8_t>()); + mapping_table_ = driver->DeduplicateMappingTable(std::vector<uint8_t>()); + vmap_table_ = driver->DeduplicateVMapTable(std::vector<uint8_t>()); + gc_map_ = driver->DeduplicateGCMap(std::vector<uint8_t>()); } } // namespace art diff --git a/compiler/compiled_method.h b/compiler/compiled_method.h index 90ae6ee..844b53c 100644 --- a/compiler/compiled_method.h +++ b/compiler/compiled_method.h @@ -102,7 +102,7 @@ class CompiledCode { class CompiledMethod : public CompiledCode { public: // Constructs a CompiledMethod for the non-LLVM compilers. - CompiledMethod(CompilerDriver& driver, + CompiledMethod(CompilerDriver* driver, InstructionSet instruction_set, const std::vector<uint8_t>& quick_code, const size_t frame_size_in_bytes, @@ -114,7 +114,7 @@ class CompiledMethod : public CompiledCode { const std::vector<uint8_t>* cfi_info); // Constructs a CompiledMethod for the QuickJniCompiler. - CompiledMethod(CompilerDriver& driver, + CompiledMethod(CompilerDriver* driver, InstructionSet instruction_set, const std::vector<uint8_t>& quick_code, const size_t frame_size_in_bytes, @@ -122,11 +122,11 @@ class CompiledMethod : public CompiledCode { const uint32_t fp_spill_mask); // Constructs a CompiledMethod for the Portable compiler. - CompiledMethod(CompilerDriver& driver, InstructionSet instruction_set, const std::string& code, + CompiledMethod(CompilerDriver* driver, InstructionSet instruction_set, const std::string& code, const std::vector<uint8_t>& gc_map, const std::string& symbol); // Constructs a CompiledMethod for the Portable JniCompiler. - CompiledMethod(CompilerDriver& driver, InstructionSet instruction_set, const std::string& code, + CompiledMethod(CompilerDriver* driver, InstructionSet instruction_set, const std::string& code, const std::string& symbol); ~CompiledMethod() {} diff --git a/compiler/compiler.cc b/compiler/compiler.cc index c88c38e..a832c31 100644 --- a/compiler/compiler.cc +++ b/compiler/compiler.cc @@ -27,8 +27,7 @@ namespace art { #ifdef ART_SEA_IR_MODE -extern "C" art::CompiledMethod* SeaIrCompileMethod(art::CompilerDriver& driver, - const art::DexFile::CodeItem* code_item, +extern "C" art::CompiledMethod* SeaIrCompileMethod(const art::DexFile::CodeItem* code_item, uint32_t access_flags, art::InvokeType invoke_type, uint16_t class_def_idx, @@ -38,8 +37,7 @@ extern "C" art::CompiledMethod* SeaIrCompileMethod(art::CompilerDriver& driver, #endif -CompiledMethod* Compiler::TryCompileWithSeaIR(art::CompilerDriver& driver, - const art::DexFile::CodeItem* code_item, +CompiledMethod* Compiler::TryCompileWithSeaIR(const art::DexFile::CodeItem* code_item, uint32_t access_flags, art::InvokeType invoke_type, uint16_t class_def_idx, @@ -47,13 +45,10 @@ CompiledMethod* Compiler::TryCompileWithSeaIR(art::CompilerDriver& driver, jobject class_loader, const art::DexFile& dex_file) { #ifdef ART_SEA_IR_MODE - bool use_sea = Runtime::Current()->IsSeaIRMode(); - use_sea = use_sea && - (std::string::npos != PrettyMethod(method_idx, dex_file).find("fibonacci")); + bool use_sea = (std::string::npos != PrettyMethod(method_idx, dex_file).find("fibonacci")); if (use_sea) { LOG(INFO) << "Using SEA IR to compile..." << std::endl; - return SeaIrCompileMethod(compiler, - code_item, + return SeaIrCompileMethod(code_item, access_flags, invoke_type, class_def_idx, @@ -68,11 +63,11 @@ CompiledMethod* Compiler::TryCompileWithSeaIR(art::CompilerDriver& driver, #ifdef ART_USE_PORTABLE_COMPILER -extern "C" void ArtInitCompilerContext(art::CompilerDriver& driver); +extern "C" void ArtInitCompilerContext(art::CompilerDriver* driver); -extern "C" void ArtUnInitCompilerContext(art::CompilerDriver& driver); +extern "C" void ArtUnInitCompilerContext(art::CompilerDriver* driver); -extern "C" art::CompiledMethod* ArtCompileMethod(art::CompilerDriver& driver, +extern "C" art::CompiledMethod* ArtCompileMethod(art::CompilerDriver* driver, const art::DexFile::CodeItem* code_item, uint32_t access_flags, art::InvokeType invoke_type, @@ -81,45 +76,45 @@ extern "C" art::CompiledMethod* ArtCompileMethod(art::CompilerDriver& driver, jobject class_loader, const art::DexFile& dex_file); -extern "C" art::CompiledMethod* ArtLLVMJniCompileMethod(art::CompilerDriver& driver, +extern "C" art::CompiledMethod* ArtLLVMJniCompileMethod(art::CompilerDriver* driver, uint32_t access_flags, uint32_t method_idx, const art::DexFile& dex_file); -extern "C" void compilerLLVMSetBitcodeFileName(art::CompilerDriver& driver, +extern "C" void compilerLLVMSetBitcodeFileName(art::CompilerDriver* driver, std::string const& filename); -class LLVMCompiler : public Compiler { +class LLVMCompiler FINAL : public Compiler { public: - LLVMCompiler() : Compiler(1000) {} + explicit LLVMCompiler(CompilerDriver* driver) : Compiler(driver, 1000) {} - void Init(CompilerDriver& driver) const { - ArtInitCompilerContext(driver); + void Init() const OVERRIDE { + ArtInitCompilerContext(GetCompilerDriver()); } - void UnInit(CompilerDriver& driver) const { - ArtUnInitCompilerContext(driver); + void UnInit() const OVERRIDE { + ArtUnInitCompilerContext(GetCompilerDriver()); } - CompiledMethod* Compile(CompilerDriver& driver, - const DexFile::CodeItem* code_item, + CompiledMethod* Compile(const DexFile::CodeItem* code_item, uint32_t access_flags, InvokeType invoke_type, uint16_t class_def_idx, uint32_t method_idx, jobject class_loader, - const DexFile& dex_file) const { - CompiledMethod* method = TryCompileWithSeaIR(driver, - code_item, + const DexFile& dex_file) const OVERRIDE { + CompiledMethod* method = TryCompileWithSeaIR(code_item, access_flags, invoke_type, class_def_idx, method_idx, class_loader, dex_file); - if (method != nullptr) return method; + if (method != nullptr) { + return method; + } - return ArtCompileMethod(compiler, + return ArtCompileMethod(GetCompilerDriver(), code_item, access_flags, invoke_type, @@ -129,11 +124,10 @@ class LLVMCompiler : public Compiler { dex_file); } - CompiledMethod* JniCompile(CompilerDriver& driver, - uint32_t access_flags, + CompiledMethod* JniCompile(uint32_t access_flags, uint32_t method_idx, - const DexFile& dex_file) const { - return ArtLLVMJniCompileMethod(driver, access_flags, method_idx, dex_file); + const DexFile& dex_file) const OVERRIDE { + return ArtLLVMJniCompileMethod(GetCompilerDriver(), access_flags, method_idx, dex_file); } uintptr_t GetEntryPointOf(mirror::ArtMethod* method) const { @@ -182,17 +176,17 @@ class LLVMCompiler : public Compiler { }; #endif -Compiler* Compiler::Create(Compiler::Kind kind) { +Compiler* Compiler::Create(CompilerDriver* driver, Compiler::Kind kind) { switch (kind) { case kQuick: - return new QuickCompiler(); + return new QuickCompiler(driver); break; case kOptimizing: - return new OptimizingCompiler(); + return new OptimizingCompiler(driver); break; case kPortable: #ifdef ART_USE_PORTABLE_COMPILER - return new LLVMCompiler(); + return new LLVMCompiler(driver); #else LOG(FATAL) << "Portable compiler not compiled"; #endif diff --git a/compiler/compiler.h b/compiler/compiler.h index 2357297..4caebf3 100644 --- a/compiler/compiler.h +++ b/compiler/compiler.h @@ -41,18 +41,13 @@ class Compiler { kPortable }; - explicit Compiler(uint64_t warning) - : maximum_compilation_time_before_warning_(warning) { - } - - static Compiler* Create(Kind kind); + static Compiler* Create(CompilerDriver* driver, Kind kind); - virtual void Init(CompilerDriver& driver) const = 0; + virtual void Init() const = 0; - virtual void UnInit(CompilerDriver& driver) const = 0; + virtual void UnInit() const = 0; - virtual CompiledMethod* Compile(CompilerDriver& driver, - const DexFile::CodeItem* code_item, + virtual CompiledMethod* Compile(const DexFile::CodeItem* code_item, uint32_t access_flags, InvokeType invoke_type, uint16_t class_def_idx, @@ -60,8 +55,7 @@ class Compiler { jobject class_loader, const DexFile& dex_file) const = 0; - static CompiledMethod* TryCompileWithSeaIR(art::CompilerDriver& driver, - const art::DexFile::CodeItem* code_item, + static CompiledMethod* TryCompileWithSeaIR(const art::DexFile::CodeItem* code_item, uint32_t access_flags, art::InvokeType invoke_type, uint16_t class_def_idx, @@ -69,8 +63,7 @@ class Compiler { jobject class_loader, const art::DexFile& dex_file); - virtual CompiledMethod* JniCompile(CompilerDriver& driver, - uint32_t access_flags, + virtual CompiledMethod* JniCompile(uint32_t access_flags, uint32_t method_idx, const DexFile& dex_file) const = 0; @@ -81,11 +74,10 @@ class Compiler { OatWriter* oat_writer, const std::vector<const art::DexFile*>& dex_files, const std::string& android_root, - bool is_host, const CompilerDriver& driver) const + bool is_host) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) = 0; - virtual Backend* GetCodeGenerator(CompilationUnit* cu, - void* compilation_unit) const = 0; + virtual Backend* GetCodeGenerator(CompilationUnit* cu, void* compilation_unit) const = 0; uint64_t GetMaximumCompilationTimeBeforeWarning() const { return maximum_compilation_time_before_warning_; @@ -117,7 +109,17 @@ class Compiler { return nullptr; } + protected: + explicit Compiler(CompilerDriver* driver, uint64_t warning) : + driver_(driver), maximum_compilation_time_before_warning_(warning) { + } + + CompilerDriver* GetCompilerDriver() const { + return driver_; + } + private: + CompilerDriver* const driver_; const uint64_t maximum_compilation_time_before_warning_; DISALLOW_COPY_AND_ASSIGN(Compiler); diff --git a/compiler/compilers.cc b/compiler/compilers.cc index 1237e70..188ce6f 100644 --- a/compiler/compilers.cc +++ b/compiler/compilers.cc @@ -22,9 +22,9 @@ namespace art { -extern "C" void ArtInitQuickCompilerContext(art::CompilerDriver& driver); -extern "C" void ArtUnInitQuickCompilerContext(art::CompilerDriver& driver); -extern "C" art::CompiledMethod* ArtQuickCompileMethod(art::CompilerDriver& driver, +extern "C" void ArtInitQuickCompilerContext(art::CompilerDriver* driver); +extern "C" void ArtUnInitQuickCompilerContext(art::CompilerDriver* driver); +extern "C" art::CompiledMethod* ArtQuickCompileMethod(art::CompilerDriver* driver, const art::DexFile::CodeItem* code_item, uint32_t access_flags, art::InvokeType invoke_type, @@ -33,40 +33,40 @@ extern "C" art::CompiledMethod* ArtQuickCompileMethod(art::CompilerDriver& drive jobject class_loader, const art::DexFile& dex_file); -extern "C" art::CompiledMethod* ArtQuickJniCompileMethod(art::CompilerDriver& driver, +extern "C" art::CompiledMethod* ArtQuickJniCompileMethod(art::CompilerDriver* driver, uint32_t access_flags, uint32_t method_idx, const art::DexFile& dex_file); // Hack for CFI CIE initialization extern std::vector<uint8_t>* X86CFIInitialization(); -void QuickCompiler::Init(CompilerDriver& driver) const { - ArtInitQuickCompilerContext(driver); +void QuickCompiler::Init() const { + ArtInitQuickCompilerContext(GetCompilerDriver()); } -void QuickCompiler::UnInit(CompilerDriver& driver) const { - ArtUnInitQuickCompilerContext(driver); +void QuickCompiler::UnInit() const { + ArtUnInitQuickCompilerContext(GetCompilerDriver()); } -CompiledMethod* QuickCompiler::Compile(CompilerDriver& driver, - const DexFile::CodeItem* code_item, - uint32_t access_flags, - InvokeType invoke_type, - uint16_t class_def_idx, - uint32_t method_idx, - jobject class_loader, - const DexFile& dex_file) const { - CompiledMethod* method = TryCompileWithSeaIR(driver, - code_item, +CompiledMethod* QuickCompiler::Compile(const DexFile::CodeItem* code_item, + uint32_t access_flags, + InvokeType invoke_type, + uint16_t class_def_idx, + uint32_t method_idx, + jobject class_loader, + const DexFile& dex_file) const { + CompiledMethod* method = TryCompileWithSeaIR(code_item, access_flags, invoke_type, class_def_idx, method_idx, class_loader, dex_file); - if (method != nullptr) return method; + if (method != nullptr) { + return method; + } - return ArtQuickCompileMethod(driver, + return ArtQuickCompileMethod(GetCompilerDriver(), code_item, access_flags, invoke_type, @@ -76,11 +76,10 @@ CompiledMethod* QuickCompiler::Compile(CompilerDriver& driver, dex_file); } -CompiledMethod* QuickCompiler::JniCompile(CompilerDriver& driver, - uint32_t access_flags, +CompiledMethod* QuickCompiler::JniCompile(uint32_t access_flags, uint32_t method_idx, const DexFile& dex_file) const { - return ArtQuickJniCompileMethod(driver, access_flags, method_idx, dex_file); + return ArtQuickJniCompileMethod(GetCompilerDriver(), access_flags, method_idx, dex_file); } uintptr_t QuickCompiler::GetEntryPointOf(mirror::ArtMethod* method) const { @@ -88,11 +87,12 @@ uintptr_t QuickCompiler::GetEntryPointOf(mirror::ArtMethod* method) const { } bool QuickCompiler::WriteElf(art::File* file, - OatWriter* oat_writer, - const std::vector<const art::DexFile*>& dex_files, - const std::string& android_root, - bool is_host, const CompilerDriver& driver) const { - return art::ElfWriterQuick::Create(file, oat_writer, dex_files, android_root, is_host, driver); + OatWriter* oat_writer, + const std::vector<const art::DexFile*>& dex_files, + const std::string& android_root, + bool is_host) const { + return art::ElfWriterQuick::Create(file, oat_writer, dex_files, android_root, is_host, + *GetCompilerDriver()); } Backend* QuickCompiler::GetCodeGenerator(CompilationUnit* cu, void* compilation_unit) const { @@ -134,22 +134,21 @@ std::vector<uint8_t>* QuickCompiler::GetCallFrameInformationInitialization( return nullptr; } -CompiledMethod* OptimizingCompiler::Compile(CompilerDriver& driver, - const DexFile::CodeItem* code_item, +CompiledMethod* OptimizingCompiler::Compile(const DexFile::CodeItem* code_item, uint32_t access_flags, InvokeType invoke_type, uint16_t class_def_idx, uint32_t method_idx, jobject class_loader, const DexFile& dex_file) const { - CompiledMethod* method = TryCompile( - driver, code_item, access_flags, invoke_type, class_def_idx, method_idx, - class_loader, dex_file); - if (method != nullptr) return method; - - return QuickCompiler::Compile( - driver, code_item, access_flags, invoke_type, class_def_idx, method_idx, - class_loader, dex_file); + CompiledMethod* method = TryCompile(code_item, access_flags, invoke_type, class_def_idx, + method_idx, class_loader, dex_file); + if (method != nullptr) { + return method; + } + + return QuickCompiler::Compile(code_item, access_flags, invoke_type, class_def_idx, method_idx, + class_loader, dex_file); } } // namespace art diff --git a/compiler/compilers.h b/compiler/compilers.h index 255dd23..3ca78c9 100644 --- a/compiler/compilers.h +++ b/compiler/compilers.h @@ -23,14 +23,13 @@ namespace art { class QuickCompiler : public Compiler { public: - QuickCompiler() : Compiler(100) {} + explicit QuickCompiler(CompilerDriver* driver) : Compiler(driver, 100) {} - void Init(CompilerDriver& driver) const OVERRIDE; + void Init() const OVERRIDE; - void UnInit(CompilerDriver& driver) const OVERRIDE; + void UnInit() const OVERRIDE; - CompiledMethod* Compile(CompilerDriver& driver, - const DexFile::CodeItem* code_item, + CompiledMethod* Compile(const DexFile::CodeItem* code_item, uint32_t access_flags, InvokeType invoke_type, uint16_t class_def_idx, @@ -38,8 +37,7 @@ class QuickCompiler : public Compiler { jobject class_loader, const DexFile& dex_file) const OVERRIDE; - CompiledMethod* JniCompile(CompilerDriver& driver, - uint32_t access_flags, + CompiledMethod* JniCompile(uint32_t access_flags, uint32_t method_idx, const DexFile& dex_file) const OVERRIDE; @@ -50,7 +48,7 @@ class QuickCompiler : public Compiler { OatWriter* oat_writer, const std::vector<const art::DexFile*>& dex_files, const std::string& android_root, - bool is_host, const CompilerDriver& driver) const + bool is_host) const OVERRIDE SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); @@ -73,12 +71,11 @@ class QuickCompiler : public Compiler { DISALLOW_COPY_AND_ASSIGN(QuickCompiler); }; -class OptimizingCompiler : public QuickCompiler { +class OptimizingCompiler FINAL : public QuickCompiler { public: - OptimizingCompiler() { } + explicit OptimizingCompiler(CompilerDriver* driver) : QuickCompiler(driver) { } - CompiledMethod* Compile(CompilerDriver& driver, - const DexFile::CodeItem* code_item, + CompiledMethod* Compile(const DexFile::CodeItem* code_item, uint32_t access_flags, InvokeType invoke_type, uint16_t class_def_idx, @@ -86,8 +83,7 @@ class OptimizingCompiler : public QuickCompiler { jobject class_loader, const DexFile& dex_file) const OVERRIDE; - CompiledMethod* TryCompile(CompilerDriver& driver, - const DexFile::CodeItem* code_item, + CompiledMethod* TryCompile(const DexFile::CodeItem* code_item, uint32_t access_flags, InvokeType invoke_type, uint16_t class_def_idx, diff --git a/compiler/dex/frontend.cc b/compiler/dex/frontend.cc index 1a9379a..5e13722 100644 --- a/compiler/dex/frontend.cc +++ b/compiler/dex/frontend.cc @@ -30,12 +30,12 @@ namespace art { -extern "C" void ArtInitQuickCompilerContext(art::CompilerDriver& driver) { - CHECK(driver.GetCompilerContext() == NULL); +extern "C" void ArtInitQuickCompilerContext(art::CompilerDriver* driver) { + CHECK(driver->GetCompilerContext() == nullptr); } -extern "C" void ArtUnInitQuickCompilerContext(art::CompilerDriver& driver) { - CHECK(driver.GetCompilerContext() == NULL); +extern "C" void ArtUnInitQuickCompilerContext(art::CompilerDriver* driver) { + CHECK(driver->GetCompilerContext() == nullptr); } /* Default optimizer/debug setting for the compiler. */ diff --git a/compiler/dex/quick/codegen_util.cc b/compiler/dex/quick/codegen_util.cc index de13a2e..fbf8a0c 100644 --- a/compiler/dex/quick/codegen_util.cc +++ b/compiler/dex/quick/codegen_util.cc @@ -1027,7 +1027,7 @@ CompiledMethod* Mir2Lir::GetCompiledMethod() { UniquePtr<std::vector<uint8_t> > cfi_info(ReturnCallFrameInformation()); CompiledMethod* result = - new CompiledMethod(*cu_->compiler_driver, cu_->instruction_set, code_buffer_, frame_size_, + new CompiledMethod(cu_->compiler_driver, cu_->instruction_set, code_buffer_, frame_size_, core_spill_mask_, fp_spill_mask_, encoded_mapping_table_, vmap_encoder.GetData(), native_gc_map_, cfi_info.get()); return result; diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc index e5decc5..6817f14 100644 --- a/compiler/driver/compiler_driver.cc +++ b/compiler/driver/compiler_driver.cc @@ -336,7 +336,7 @@ CompilerDriver::CompilerDriver(const CompilerOptions* compiler_options, : profile_ok_(false), compiler_options_(compiler_options), verification_results_(verification_results), method_inliner_map_(method_inliner_map), - compiler_(Compiler::Create(compiler_kind)), + compiler_(Compiler::Create(this, compiler_kind)), instruction_set_(instruction_set), instruction_set_features_(instruction_set_features), freezing_constructor_lock_("freezing constructor lock"), @@ -374,7 +374,7 @@ CompilerDriver::CompilerDriver(const CompilerOptions* compiler_options, dex_to_dex_compiler_ = reinterpret_cast<DexToDexCompilerFn>(ArtCompileDEX); - compiler_->Init(*this); + compiler_->Init(); CHECK(!Runtime::Current()->IsStarted()); if (!image_) { @@ -433,7 +433,7 @@ CompilerDriver::~CompilerDriver() { STLDeleteElements(&classes_to_patch_); } CHECK_PTHREAD_CALL(pthread_key_delete, (tls_key_), "delete tls key"); - compiler_->UnInit(*this); + compiler_->UnInit(); } CompilerTls* CompilerDriver::GetTls() { @@ -1874,7 +1874,7 @@ void CompilerDriver::CompileMethod(const DexFile::CodeItem* code_item, uint32_t (instruction_set_ == kX86_64 || instruction_set_ == kArm64)) { // Leaving this empty will trigger the generic JNI version } else { - compiled_method = compiler_->JniCompile(*this, access_flags, method_idx, dex_file); + compiled_method = compiler_->JniCompile(access_flags, method_idx, dex_file); CHECK(compiled_method != NULL); } } else if ((access_flags & kAccAbstract) != 0) { @@ -1883,9 +1883,8 @@ void CompilerDriver::CompileMethod(const DexFile::CodeItem* code_item, uint32_t bool compile = verification_results_->IsCandidateForCompilation(method_ref, access_flags); if (compile) { // NOTE: if compiler declines to compile this method, it will return NULL. - compiled_method = compiler_->Compile( - *this, code_item, access_flags, invoke_type, class_def_idx, - method_idx, class_loader, dex_file); + compiled_method = compiler_->Compile(code_item, access_flags, invoke_type, class_def_idx, + method_idx, class_loader, dex_file); } if (compiled_method == nullptr && dex_to_dex_compilation_level != kDontDexToDexCompile) { // TODO: add a command-line option to disable DEX-to-DEX compilation ? @@ -1983,7 +1982,7 @@ bool CompilerDriver::WriteElf(const std::string& android_root, OatWriter* oat_writer, art::File* file) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { - return compiler_->WriteElf(file, oat_writer, dex_files, android_root, is_host, *this); + return compiler_->WriteElf(file, oat_writer, dex_files, android_root, is_host); } void CompilerDriver::InstructionSetToLLVMTarget(InstructionSet instruction_set, std::string* target_triple, diff --git a/compiler/jni/quick/jni_compiler.cc b/compiler/jni/quick/jni_compiler.cc index 9f439eb..5a22170 100644 --- a/compiler/jni/quick/jni_compiler.cc +++ b/compiler/jni/quick/jni_compiler.cc @@ -52,7 +52,7 @@ static void SetNativeParameter(Assembler* jni_asm, // registers, a reference to the method object is supplied as part of this // convention. // -CompiledMethod* ArtJniCompileMethodInternal(CompilerDriver& compiler, +CompiledMethod* ArtJniCompileMethodInternal(CompilerDriver* driver, uint32_t access_flags, uint32_t method_idx, const DexFile& dex_file) { const bool is_native = (access_flags & kAccNative) != 0; @@ -60,7 +60,7 @@ CompiledMethod* ArtJniCompileMethodInternal(CompilerDriver& compiler, const bool is_static = (access_flags & kAccStatic) != 0; const bool is_synchronized = (access_flags & kAccSynchronized) != 0; const char* shorty = dex_file.GetMethodShorty(dex_file.GetMethodId(method_idx)); - InstructionSet instruction_set = compiler.GetInstructionSet(); + InstructionSet instruction_set = driver->GetInstructionSet(); if (instruction_set == kThumb2) { instruction_set = kArm; } @@ -423,7 +423,7 @@ CompiledMethod* ArtJniCompileMethodInternal(CompilerDriver& compiler, std::vector<uint8_t> managed_code(cs); MemoryRegion code(&managed_code[0], managed_code.size()); __ FinalizeInstructions(code); - return new CompiledMethod(compiler, + return new CompiledMethod(driver, instruction_set, managed_code, frame_size, @@ -536,7 +536,7 @@ static void SetNativeParameter(Assembler* jni_asm, } // namespace art -extern "C" art::CompiledMethod* ArtQuickJniCompileMethod(art::CompilerDriver& compiler, +extern "C" art::CompiledMethod* ArtQuickJniCompileMethod(art::CompilerDriver* compiler, uint32_t access_flags, uint32_t method_idx, const art::DexFile& dex_file) { return ArtJniCompileMethodInternal(compiler, access_flags, method_idx, dex_file); diff --git a/compiler/llvm/compiler_llvm.cc b/compiler/llvm/compiler_llvm.cc index 2812700..df895ee 100644 --- a/compiler/llvm/compiler_llvm.cc +++ b/compiler/llvm/compiler_llvm.cc @@ -175,8 +175,8 @@ CompileNativeMethod(DexCompilationUnit* dex_compilation_unit) { } // namespace llvm } // namespace art -static art::llvm::CompilerLLVM* ContextOf(art::CompilerDriver& driver) { - void *compiler_context = driver.GetCompilerContext(); +static art::llvm::CompilerLLVM* ContextOf(art::CompilerDriver* driver) { + void *compiler_context = driver->GetCompilerContext(); CHECK(compiler_context != NULL); return reinterpret_cast<art::llvm::CompilerLLVM*>(compiler_context); } @@ -187,20 +187,20 @@ static art::llvm::CompilerLLVM* ContextOf(const art::CompilerDriver& driver) { return reinterpret_cast<art::llvm::CompilerLLVM*>(compiler_context); } -extern "C" void ArtInitCompilerContext(art::CompilerDriver& driver) { - CHECK(driver.GetCompilerContext() == NULL); +extern "C" void ArtInitCompilerContext(art::CompilerDriver* driver) { + CHECK(driver->GetCompilerContext() == nullptr); - art::llvm::CompilerLLVM* compiler_llvm = new art::llvm::CompilerLLVM(&driver, - driver.GetInstructionSet()); + art::llvm::CompilerLLVM* compiler_llvm = new art::llvm::CompilerLLVM(driver, + driver->GetInstructionSet()); - driver.SetCompilerContext(compiler_llvm); + driver->SetCompilerContext(compiler_llvm); } -extern "C" void ArtUnInitCompilerContext(art::CompilerDriver& driver) { +extern "C" void ArtUnInitCompilerContext(art::CompilerDriver* driver) { delete ContextOf(driver); - driver.SetCompilerContext(NULL); + driver->SetCompilerContext(nullptr); } -extern "C" art::CompiledMethod* ArtCompileMethod(art::CompilerDriver& driver, +extern "C" art::CompiledMethod* ArtCompileMethod(art::CompilerDriver* driver, const art::DexFile::CodeItem* code_item, uint32_t access_flags, art::InvokeType invoke_type, @@ -213,13 +213,13 @@ extern "C" art::CompiledMethod* ArtCompileMethod(art::CompilerDriver& driver, art::DexCompilationUnit dex_compilation_unit( NULL, class_loader, class_linker, dex_file, code_item, - class_def_idx, method_idx, access_flags, driver.GetVerifiedMethod(&dex_file, method_idx)); + class_def_idx, method_idx, access_flags, driver->GetVerifiedMethod(&dex_file, method_idx)); art::llvm::CompilerLLVM* compiler_llvm = ContextOf(driver); art::CompiledMethod* result = compiler_llvm->CompileDexMethod(&dex_compilation_unit, invoke_type); return result; } -extern "C" art::CompiledMethod* ArtLLVMJniCompileMethod(art::CompilerDriver& driver, +extern "C" art::CompiledMethod* ArtLLVMJniCompileMethod(art::CompilerDriver* driver, uint32_t access_flags, uint32_t method_idx, const art::DexFile& dex_file) { art::ClassLinker *class_linker = art::Runtime::Current()->GetClassLinker(); diff --git a/compiler/optimizing/optimizing_compiler.cc b/compiler/optimizing/optimizing_compiler.cc index 9438890..b2c3c2d 100644 --- a/compiler/optimizing/optimizing_compiler.cc +++ b/compiler/optimizing/optimizing_compiler.cc @@ -50,8 +50,7 @@ class CodeVectorAllocator FINAL : public CodeAllocator { }; -CompiledMethod* OptimizingCompiler::TryCompile(CompilerDriver& driver, - const DexFile::CodeItem* code_item, +CompiledMethod* OptimizingCompiler::TryCompile(const DexFile::CodeItem* code_item, uint32_t access_flags, InvokeType invoke_type, uint16_t class_def_idx, @@ -60,7 +59,8 @@ CompiledMethod* OptimizingCompiler::TryCompile(CompilerDriver& driver, const DexFile& dex_file) const { DexCompilationUnit dex_compilation_unit( nullptr, class_loader, art::Runtime::Current()->GetClassLinker(), dex_file, code_item, - class_def_idx, method_idx, access_flags, driver.GetVerifiedMethod(&dex_file, method_idx)); + class_def_idx, method_idx, access_flags, + GetCompilerDriver()->GetVerifiedMethod(&dex_file, method_idx)); // For testing purposes, we put a special marker on method names that should be compiled // with this compiler. This makes sure we're not regressing. @@ -77,7 +77,7 @@ CompiledMethod* OptimizingCompiler::TryCompile(CompilerDriver& driver, return nullptr; } - InstructionSet instruction_set = driver.GetInstructionSet(); + InstructionSet instruction_set = GetCompilerDriver()->GetInstructionSet(); // The optimizing compiler currently does not have a Thumb2 assembler. if (instruction_set == kThumb2) { instruction_set = kArm; @@ -104,7 +104,7 @@ CompiledMethod* OptimizingCompiler::TryCompile(CompilerDriver& driver, graph->BuildDominatorTree(); graph->TransformToSSA(); - return new CompiledMethod(driver, + return new CompiledMethod(GetCompilerDriver(), instruction_set, allocator.GetMemory(), codegen->GetFrameSize(), |