diff options
author | 2018-11-07 15:39:48 +0000 | |
---|---|---|
committer | 2018-11-08 10:26:57 +0000 | |
commit | 1a2a5cd58b7b667b664a7c20a4887a6cd89b4776 (patch) | |
tree | 8f92ca17ba6f8324881f52aa741ad5ed0f87016a | |
parent | a5175541c197e7bf9b03651ea5da4e64a2ac2d27 (diff) |
Move profile compilation info to CompilerOptions.
Remove one HInliner dependency on the CompilerDriver.
Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Change-Id: If6f0ab864095641b5697c8c6f5100520f91d5e53
-rw-r--r-- | compiler/common_compiler_test.cc | 4 | ||||
-rw-r--r-- | compiler/driver/compiled_method_storage_test.cc | 3 | ||||
-rw-r--r-- | compiler/driver/compiler_driver.cc | 26 | ||||
-rw-r--r-- | compiler/driver/compiler_driver.h | 10 | ||||
-rw-r--r-- | compiler/driver/compiler_options.cc | 1 | ||||
-rw-r--r-- | compiler/driver/compiler_options.h | 8 | ||||
-rw-r--r-- | compiler/jit/jit_compiler.cc | 3 | ||||
-rw-r--r-- | compiler/optimizing/inliner.cc | 4 | ||||
-rw-r--r-- | dex2oat/dex2oat.cc | 4 |
9 files changed, 33 insertions, 30 deletions
diff --git a/compiler/common_compiler_test.cc b/compiler/common_compiler_test.cc index fc8cd528fa..599f4aa189 100644 --- a/compiler/common_compiler_test.cc +++ b/compiler/common_compiler_test.cc @@ -188,13 +188,13 @@ void CommonCompilerTest::CreateCompilerDriver() { compiler_options_->compile_pic_ = false; // Non-PIC boot image is a test configuration. compiler_options_->SetCompilerFilter(GetCompilerFilter()); compiler_options_->image_classes_.swap(*GetImageClasses()); + compiler_options_->profile_compilation_info_ = GetProfileCompilationInfo(); compiler_driver_.reset(new CompilerDriver(compiler_options_.get(), verification_results_.get(), compiler_kind_, &compiler_options_->image_classes_, number_of_threads_, - /* swap_fd */ -1, - GetProfileCompilationInfo())); + /* swap_fd */ -1)); } void CommonCompilerTest::SetUpRuntimeOptions(RuntimeOptions* options) { diff --git a/compiler/driver/compiled_method_storage_test.cc b/compiler/driver/compiled_method_storage_test.cc index 5e2f444a24..8b35bd3cb1 100644 --- a/compiler/driver/compiled_method_storage_test.cc +++ b/compiler/driver/compiled_method_storage_test.cc @@ -33,8 +33,7 @@ TEST(CompiledMethodStorage, Deduplicate) { Compiler::kOptimizing, /* image_classes */ nullptr, /* thread_count */ 1u, - /* swap_fd */ -1, - /* profile_compilation_info */ nullptr); + /* swap_fd */ -1); CompiledMethodStorage* storage = driver.GetCompiledMethodStorage(); ASSERT_TRUE(storage->DedupeEnabled()); // The default. diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc index 8c276bb706..f8e2dff25a 100644 --- a/compiler/driver/compiler_driver.cc +++ b/compiler/driver/compiler_driver.cc @@ -248,8 +248,7 @@ CompilerDriver::CompilerDriver( Compiler::Kind compiler_kind, HashSet<std::string>* image_classes, size_t thread_count, - int swap_fd, - const ProfileCompilationInfo* profile_compilation_info) + int swap_fd) : compiler_options_(compiler_options), verification_results_(verification_results), compiler_(Compiler::Create(this, compiler_kind)), @@ -261,7 +260,6 @@ CompilerDriver::CompilerDriver( stats_(new AOTCompilationStats), compiler_context_(nullptr), compiled_method_storage_(swap_fd), - profile_compilation_info_(profile_compilation_info), max_arena_alloc_(0), dex_to_dex_compiler_(this) { DCHECK(compiler_options_ != nullptr); @@ -731,9 +729,11 @@ void CompilerDriver::ResolveConstStrings(const std::vector<const DexFile*>& dex_ continue; } + const ProfileCompilationInfo* profile_compilation_info = + GetCompilerOptions().GetProfileCompilationInfo(); const bool is_startup_class = - profile_compilation_info_ != nullptr && - profile_compilation_info_->ContainsClass(*dex_file, accessor.GetClassIdx()); + profile_compilation_info != nullptr && + profile_compilation_info->ContainsClass(*dex_file, accessor.GetClassIdx()); for (const ClassAccessor::Method& method : accessor.GetMethods()) { const bool is_clinit = (method.GetAccessFlags() & kAccConstructor) != 0 && @@ -741,8 +741,8 @@ void CompilerDriver::ResolveConstStrings(const std::vector<const DexFile*>& dex_ const bool is_startup_clinit = is_startup_class && is_clinit; if (only_startup_strings && - profile_compilation_info_ != nullptr && - (!profile_compilation_info_->GetMethodHotness(method.GetReference()).IsStartup() && + profile_compilation_info != nullptr && + (!profile_compilation_info->GetMethodHotness(method.GetReference()).IsStartup() && !is_startup_clinit)) { continue; } @@ -981,12 +981,14 @@ bool CompilerDriver::ShouldCompileBasedOnProfile(const MethodReference& method_r return true; } // If we are using a profile filter but do not have a profile compilation info, compile nothing. - if (profile_compilation_info_ == nullptr) { + const ProfileCompilationInfo* profile_compilation_info = + GetCompilerOptions().GetProfileCompilationInfo(); + if (profile_compilation_info == nullptr) { return false; } // Compile only hot methods, it is the profile saver's job to decide what startup methods to mark // as hot. - bool result = profile_compilation_info_->GetMethodHotness(method_ref).IsHot(); + bool result = profile_compilation_info->GetMethodHotness(method_ref).IsHot(); if (kDebugProfileGuidedCompilation) { LOG(INFO) << "[ProfileGuidedCompilation] " @@ -2644,10 +2646,12 @@ void CompilerDriver::Compile(jobject class_loader, const std::vector<const DexFile*>& dex_files, TimingLogger* timings) { if (kDebugProfileGuidedCompilation) { + const ProfileCompilationInfo* profile_compilation_info = + GetCompilerOptions().GetProfileCompilationInfo(); LOG(INFO) << "[ProfileGuidedCompilation] " << - ((profile_compilation_info_ == nullptr) + ((profile_compilation_info == nullptr) ? "null" - : profile_compilation_info_->DumpInfo(dex_files)); + : profile_compilation_info->DumpInfo(dex_files)); } dex_to_dex_compiler_.ClearState(); diff --git a/compiler/driver/compiler_driver.h b/compiler/driver/compiler_driver.h index f42e555410..b0f2dac683 100644 --- a/compiler/driver/compiler_driver.h +++ b/compiler/driver/compiler_driver.h @@ -99,8 +99,7 @@ class CompilerDriver { Compiler::Kind compiler_kind, HashSet<std::string>* image_classes, size_t thread_count, - int swap_fd, - const ProfileCompilationInfo* profile_compilation_info); + int swap_fd); ~CompilerDriver(); @@ -266,10 +265,6 @@ class CompilerDriver { return &compiled_method_storage_; } - const ProfileCompilationInfo* GetProfileCompilationInfo() const { - return profile_compilation_info_; - } - // Is `boot_image_filename` the name of a core image (small boot // image used for ART testing only)? static bool IsCoreImageFilename(const std::string& boot_image_filename) { @@ -419,9 +414,6 @@ class CompilerDriver { CompiledMethodStorage compiled_method_storage_; - // Info for profile guided compilation. - const ProfileCompilationInfo* const profile_compilation_info_; - size_t max_arena_alloc_; // Compiler for dex to dex (quickening). diff --git a/compiler/driver/compiler_options.cc b/compiler/driver/compiler_options.cc index 6b0e45629b..be8e10e41e 100644 --- a/compiler/driver/compiler_options.cc +++ b/compiler/driver/compiler_options.cc @@ -60,6 +60,7 @@ CompilerOptions::CompilerOptions() dump_pass_timings_(false), dump_stats_(false), top_k_profile_threshold_(kDefaultTopKProfileThreshold), + profile_compilation_info_(nullptr), 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 4a6bbfaae6..77f84820e5 100644 --- a/compiler/driver/compiler_options.h +++ b/compiler/driver/compiler_options.h @@ -42,6 +42,7 @@ class VerifierDepsTest; class DexFile; enum class InstructionSet; class InstructionSetFeatures; +class ProfileCompilationInfo; class CompilerOptions final { public: @@ -218,6 +219,10 @@ class CompilerOptions final { return compile_pic_; } + const ProfileCompilationInfo* GetProfileCompilationInfo() const { + return profile_compilation_info_; + } + bool HasVerboseMethods() const { return !verbose_methods_.empty(); } @@ -370,6 +375,9 @@ class CompilerOptions final { // When using a profile file only the top K% of the profiled samples will be compiled. double top_k_profile_threshold_; + // Info for profile guided compilation. + const ProfileCompilationInfo* profile_compilation_info_; + // Vector of methods to have verbose output enabled for. std::vector<std::string> verbose_methods_; diff --git a/compiler/jit/jit_compiler.cc b/compiler/jit/jit_compiler.cc index bc8641a114..f22f61fa21 100644 --- a/compiler/jit/jit_compiler.cc +++ b/compiler/jit/jit_compiler.cc @@ -151,8 +151,7 @@ JitCompiler::JitCompiler() { Compiler::kOptimizing, /* image_classes */ nullptr, /* thread_count */ 1, - /* swap_fd */ -1, - /* profile_compilation_info */ nullptr)); + /* swap_fd */ -1)); // Disable dedupe so we can remove compiled methods. compiler_driver_->SetDedupeEnabled(false); diff --git a/compiler/optimizing/inliner.cc b/compiler/optimizing/inliner.cc index f56f9cb84f..c1daf95727 100644 --- a/compiler/optimizing/inliner.cc +++ b/compiler/optimizing/inliner.cc @@ -680,7 +680,7 @@ HInliner::InlineCacheType HInliner::GetInlineCacheAOT( /*out*/Handle<mirror::ObjectArray<mirror::Class>>* inline_cache) REQUIRES_SHARED(Locks::mutator_lock_) { DCHECK(Runtime::Current()->IsAotCompiler()); - const ProfileCompilationInfo* pci = compiler_driver_->GetProfileCompilationInfo(); + const ProfileCompilationInfo* pci = codegen_->GetCompilerOptions().GetProfileCompilationInfo(); if (pci == nullptr) { return kInlineCacheNoData; } @@ -1647,7 +1647,7 @@ bool HInliner::TryPatternSubstitution(HInvoke* invoke_instruction, } } if (needs_constructor_barrier) { - // See CompilerDriver::RequiresConstructorBarrier for more details. + // See DexCompilationUnit::RequiresConstructorBarrier for more details. DCHECK(obj != nullptr) << "only non-static methods can have a constructor fence"; HConstructorFence* constructor_fence = diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc index f0f2b3e397..db610f1f4f 100644 --- a/dex2oat/dex2oat.cc +++ b/dex2oat/dex2oat.cc @@ -1792,14 +1792,14 @@ class Dex2Oat final { compiler_options_->no_inline_from_.swap(no_inline_from_dex_files); } } + compiler_options_->profile_compilation_info_ = profile_compilation_info_.get(); driver_.reset(new CompilerDriver(compiler_options_.get(), verification_results_.get(), compiler_kind_, &compiler_options_->image_classes_, thread_count_, - swap_fd_, - profile_compilation_info_.get())); + swap_fd_)); if (!IsBootImage()) { driver_->SetClasspathDexFiles(class_loader_context_->FlattenOpenedDexFiles()); } |