diff options
Diffstat (limited to 'compiler/dex/quick')
| -rw-r--r-- | compiler/dex/quick/quick_compiler.cc | 72 | ||||
| -rw-r--r-- | compiler/dex/quick/quick_compiler.h | 60 | ||||
| -rw-r--r-- | compiler/dex/quick/quick_compiler_factory.h | 29 |
3 files changed, 117 insertions, 44 deletions
diff --git a/compiler/dex/quick/quick_compiler.cc b/compiler/dex/quick/quick_compiler.cc index 3a34fcde94..909077eca2 100644 --- a/compiler/dex/quick/quick_compiler.cc +++ b/compiler/dex/quick/quick_compiler.cc @@ -29,6 +29,8 @@ #include "dex/dex_flags.h" #include "dex/mir_graph.h" #include "dex/pass_driver_me_opts.h" +#include "dex/pass_driver_me_post_opt.h" +#include "dex/pass_manager.h" #include "dex/quick/mir_to_lir.h" #include "driver/compiler_driver.h" #include "driver/compiler_options.h" @@ -47,48 +49,6 @@ namespace art { -class QuickCompiler FINAL : public Compiler { - public: - explicit QuickCompiler(CompilerDriver* driver) : Compiler(driver, 100) {} - - void Init() OVERRIDE; - - void UnInit() const OVERRIDE; - - bool CanCompileMethod(uint32_t method_idx, const DexFile& dex_file, CompilationUnit* cu) const - OVERRIDE; - - 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 OVERRIDE; - - CompiledMethod* JniCompile(uint32_t access_flags, - uint32_t method_idx, - const DexFile& dex_file) const OVERRIDE; - - uintptr_t GetEntryPointOf(mirror::ArtMethod* method) const OVERRIDE - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - - bool WriteElf(art::File* file, - OatWriter* oat_writer, - const std::vector<const art::DexFile*>& dex_files, - const std::string& android_root, - bool is_host) const - OVERRIDE - SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); - - Mir2Lir* GetCodeGenerator(CompilationUnit* cu, void* compilation_unit) const; - - void InitCompilationUnit(CompilationUnit& cu) const OVERRIDE; - - private: - DISALLOW_COPY_AND_ASSIGN(QuickCompiler); -}; - static_assert(0U == static_cast<size_t>(kNone), "kNone not 0"); static_assert(1U == static_cast<size_t>(kArm), "kArm not 1"); static_assert(2U == static_cast<size_t>(kArm64), "kArm64 not 2"); @@ -730,7 +690,7 @@ CompiledMethod* QuickCompiler::Compile(const DexFile::CodeItem* code_item, } /* Create the pass driver and launch it */ - PassDriverMEOpts pass_driver(&cu); + PassDriverMEOpts pass_driver(GetPreOptPassManager(), &cu); pass_driver.Launch(); /* For non-leaf methods check if we should skip compilation when the profiler is enabled. */ @@ -850,8 +810,34 @@ Mir2Lir* QuickCompiler::GetCodeGenerator(CompilationUnit* cu, void* compilation_ return mir_to_lir; } +QuickCompiler::QuickCompiler(CompilerDriver* driver) : Compiler(driver, 100) { + const auto& compiler_options = driver->GetCompilerOptions(); + auto* pass_manager_options = compiler_options.GetPassManagerOptions(); + pre_opt_pass_manager_.reset(new PassManager(*pass_manager_options)); + CHECK(pre_opt_pass_manager_.get() != nullptr); + PassDriverMEOpts::SetupPasses(pre_opt_pass_manager_.get()); + pre_opt_pass_manager_->CreateDefaultPassList(); + if (pass_manager_options->GetPrintPassOptions()) { + PassDriverMEOpts::PrintPassOptions(pre_opt_pass_manager_.get()); + } + // TODO: Different options for pre vs post opts? + post_opt_pass_manager_.reset(new PassManager(PassManagerOptions())); + CHECK(post_opt_pass_manager_.get() != nullptr); + PassDriverMEPostOpt::SetupPasses(post_opt_pass_manager_.get()); + post_opt_pass_manager_->CreateDefaultPassList(); + if (pass_manager_options->GetPrintPassOptions()) { + PassDriverMEPostOpt::PrintPassOptions(post_opt_pass_manager_.get()); + } +} + +QuickCompiler::~QuickCompiler() { +} Compiler* CreateQuickCompiler(CompilerDriver* driver) { + return QuickCompiler::Create(driver); +} + +Compiler* QuickCompiler::Create(CompilerDriver* driver) { return new QuickCompiler(driver); } diff --git a/compiler/dex/quick/quick_compiler.h b/compiler/dex/quick/quick_compiler.h index 10de5fbca4..5153a9e82e 100644 --- a/compiler/dex/quick/quick_compiler.h +++ b/compiler/dex/quick/quick_compiler.h @@ -17,12 +17,70 @@ #ifndef ART_COMPILER_DEX_QUICK_QUICK_COMPILER_H_ #define ART_COMPILER_DEX_QUICK_QUICK_COMPILER_H_ +#include "compiler.h" + namespace art { class Compiler; class CompilerDriver; +class Mir2Lir; +class PassManager; + +class QuickCompiler : public Compiler { + public: + virtual ~QuickCompiler(); + + void Init() OVERRIDE; + + void UnInit() const OVERRIDE; + + bool CanCompileMethod(uint32_t method_idx, const DexFile& dex_file, CompilationUnit* cu) const + OVERRIDE; + + 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 OVERRIDE; + + CompiledMethod* JniCompile(uint32_t access_flags, + uint32_t method_idx, + const DexFile& dex_file) const OVERRIDE; + + uintptr_t GetEntryPointOf(mirror::ArtMethod* method) const OVERRIDE + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + + bool WriteElf(art::File* file, + OatWriter* oat_writer, + const std::vector<const art::DexFile*>& dex_files, + const std::string& android_root, + bool is_host) const + OVERRIDE + SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); + + Mir2Lir* GetCodeGenerator(CompilationUnit* cu, void* compilation_unit) const; + + void InitCompilationUnit(CompilationUnit& cu) const OVERRIDE; + + static Compiler* Create(CompilerDriver* driver); + + const PassManager* GetPreOptPassManager() const { + return pre_opt_pass_manager_.get(); + } + const PassManager* GetPostOptPassManager() const { + return post_opt_pass_manager_.get(); + } + + protected: + explicit QuickCompiler(CompilerDriver* driver); -Compiler* CreateQuickCompiler(CompilerDriver* driver); + private: + std::unique_ptr<PassManager> pre_opt_pass_manager_; + std::unique_ptr<PassManager> post_opt_pass_manager_; + DISALLOW_COPY_AND_ASSIGN(QuickCompiler); +}; } // namespace art diff --git a/compiler/dex/quick/quick_compiler_factory.h b/compiler/dex/quick/quick_compiler_factory.h new file mode 100644 index 0000000000..31ee1cf93b --- /dev/null +++ b/compiler/dex/quick/quick_compiler_factory.h @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2015 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef ART_COMPILER_DEX_QUICK_QUICK_COMPILER_FACTORY_H_ +#define ART_COMPILER_DEX_QUICK_QUICK_COMPILER_FACTORY_H_ + +namespace art { + +class Compiler; +class CompilerDriver; + +Compiler* CreateQuickCompiler(CompilerDriver* driver); + +} // namespace art + +#endif // ART_COMPILER_DEX_QUICK_QUICK_COMPILER_FACTORY_H_ |