diff options
author | Nicolas Geoffray <ngeoffray@google.com> | 2014-09-17 10:03:58 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2014-09-17 10:03:58 +0000 |
commit | 7d029af44c45c56b3b7a271c54434c2dcec1e219 (patch) | |
tree | 91eac51207931dc9ff99bb0f93a184e0032d1480 /compiler | |
parent | 97ca64b01e14de77ba14067b26069405d0dba0bf (diff) | |
parent | 88157efc1e16707d4ae10775d4acb15121c50fe7 (diff) | |
download | art-7d029af44c45c56b3b7a271c54434c2dcec1e219.zip art-7d029af44c45c56b3b7a271c54434c2dcec1e219.tar.gz art-7d029af44c45c56b3b7a271c54434c2dcec1e219.tar.bz2 |
Merge "Add the "time" compilation filter and output compilation stats."
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/dex/mir_analysis.cc | 1 | ||||
-rw-r--r-- | compiler/driver/compiler_options.h | 3 | ||||
-rw-r--r-- | compiler/optimizing/optimizing_compiler.cc | 35 |
3 files changed, 34 insertions, 5 deletions
diff --git a/compiler/dex/mir_analysis.cc b/compiler/dex/mir_analysis.cc index b265ee7..9fa5fac 100644 --- a/compiler/dex/mir_analysis.cc +++ b/compiler/dex/mir_analysis.cc @@ -1094,6 +1094,7 @@ bool MIRGraph::SkipCompilation(std::string* skip_message) { default_cutoff = compiler_options.GetSmallMethodThreshold(); break; case CompilerOptions::kSpeed: + case CompilerOptions::kTime: small_cutoff = compiler_options.GetHugeMethodThreshold(); default_cutoff = compiler_options.GetHugeMethodThreshold(); break; diff --git a/compiler/driver/compiler_options.h b/compiler/driver/compiler_options.h index c0f91d1..eb3de97 100644 --- a/compiler/driver/compiler_options.h +++ b/compiler/driver/compiler_options.h @@ -27,7 +27,8 @@ class CompilerOptions { kSpace, // Maximize space savings. kBalanced, // Try to get the best performance return on compilation investment. kSpeed, // Maximize runtime performance. - kEverything // Force compilation (Note: excludes compilaton of class initializers). + kEverything, // Force compilation (Note: excludes compilation of class initializers). + kTime // Compile methods, but minimize compilation time. }; // Guide heuristics to determine whether to compile method if profile data not available. diff --git a/compiler/optimizing/optimizing_compiler.cc b/compiler/optimizing/optimizing_compiler.cc index 75f4155..a539192 100644 --- a/compiler/optimizing/optimizing_compiler.cc +++ b/compiler/optimizing/optimizing_compiler.cc @@ -38,7 +38,7 @@ namespace art { */ class CodeVectorAllocator FINAL : public CodeAllocator { public: - CodeVectorAllocator() { } + CodeVectorAllocator() {} virtual uint8_t* Allocate(size_t size) { size_ = size; @@ -70,6 +70,7 @@ static const char* kStringFilter = ""; class OptimizingCompiler FINAL : public Compiler { public: explicit OptimizingCompiler(CompilerDriver* driver); + ~OptimizingCompiler(); bool CanCompileMethod(uint32_t method_idx, const DexFile& dex_file, CompilationUnit* cu) const OVERRIDE; @@ -113,6 +114,13 @@ class OptimizingCompiler FINAL : public Compiler { void UnInit() const OVERRIDE; private: + // Whether we should run any optimization or register allocation. If false, will + // just run the code generation after the graph was built. + const bool run_optimizations_; + mutable AtomicInteger total_compiled_methods_; + mutable AtomicInteger unoptimized_compiled_methods_; + mutable AtomicInteger optimized_compiled_methods_; + std::unique_ptr<std::ostream> visualizer_output_; // Delegate to another compiler in case the optimizing compiler cannot compile a method. @@ -122,8 +130,16 @@ class OptimizingCompiler FINAL : public Compiler { DISALLOW_COPY_AND_ASSIGN(OptimizingCompiler); }; -OptimizingCompiler::OptimizingCompiler(CompilerDriver* driver) : Compiler(driver, 100), - delegate_(Create(driver, Compiler::Kind::kQuick)) { +static const int kMaximumCompilationTimeBeforeWarning = 100; /* ms */ + +OptimizingCompiler::OptimizingCompiler(CompilerDriver* driver) + : Compiler(driver, kMaximumCompilationTimeBeforeWarning), + run_optimizations_( + driver->GetCompilerOptions().GetCompilerFilter() != CompilerOptions::kTime), + total_compiled_methods_(0), + unoptimized_compiled_methods_(0), + optimized_compiled_methods_(0), + delegate_(Create(driver, Compiler::Kind::kQuick)) { if (kIsVisualizerEnabled) { visualizer_output_.reset(new std::ofstream("art.cfg")); } @@ -137,6 +153,14 @@ void OptimizingCompiler::UnInit() const { delegate_->UnInit(); } +OptimizingCompiler::~OptimizingCompiler() { + size_t unoptimized_percent = (unoptimized_compiled_methods_ * 100 / total_compiled_methods_); + size_t optimized_percent = (optimized_compiled_methods_ * 100 / total_compiled_methods_); + LOG(INFO) << "Compiled " << total_compiled_methods_ << " methods: " + << unoptimized_percent << "% (" << unoptimized_compiled_methods_ << ") unoptimized, " + << optimized_percent << "% (" << optimized_compiled_methods_ << ") optimized."; +} + bool OptimizingCompiler::CanCompileMethod(uint32_t method_idx, const DexFile& dex_file, CompilationUnit* cu) const { return delegate_->CanCompileMethod(method_idx, dex_file, cu); @@ -173,6 +197,7 @@ CompiledMethod* OptimizingCompiler::TryCompile(const DexFile::CodeItem* code_ite uint32_t method_idx, jobject class_loader, const DexFile& dex_file) const { + total_compiled_methods_++; InstructionSet instruction_set = GetCompilerDriver()->GetInstructionSet(); // Always use the thumb2 assembler: some runtime functionality (like implicit stack // overflow checks) assume thumb2. @@ -222,7 +247,8 @@ CompiledMethod* OptimizingCompiler::TryCompile(const DexFile::CodeItem* code_ite CodeVectorAllocator allocator; - if (RegisterAllocator::CanAllocateRegistersFor(*graph, instruction_set)) { + if (run_optimizations_ && RegisterAllocator::CanAllocateRegistersFor(*graph, instruction_set)) { + optimized_compiled_methods_++; graph->BuildDominatorTree(); graph->TransformToSSA(); visualizer.DumpGraph("ssa"); @@ -262,6 +288,7 @@ CompiledMethod* OptimizingCompiler::TryCompile(const DexFile::CodeItem* code_ite LOG(FATAL) << "Could not allocate registers in optimizing compiler"; return nullptr; } else { + unoptimized_compiled_methods_++; codegen->CompileBaseline(&allocator); // Run these phases to get some test coverage. |