diff options
author | Vladimir Marko <vmarko@google.com> | 2018-11-30 17:01:50 +0000 |
---|---|---|
committer | Vladimir Marko <vmarko@google.com> | 2018-12-06 16:26:43 +0000 |
commit | 2afaff7e9171992b0e2e95d0f485782d28e1b9dc (patch) | |
tree | 96c7ea4a13e8a9a191d58002de89fb005231980e /compiler/common_compiler_test.cc | |
parent | 6a98f89c4ad645b04d6c80d3d7e260c59bf6f193 (diff) |
Refactor CompilerDriver::CompileAll().
Treat verification results and image classes as mutable
only in CompilerDriver::PreCompile(), and treat them as
immutable during compilation, accessed through the
CompilerOptions. This severs the dependency of the inliner
on the CompilerDriver.
Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Change-Id: I594a0213ca6a5003c19b4bd488af98db4358d51d
Diffstat (limited to 'compiler/common_compiler_test.cc')
-rw-r--r-- | compiler/common_compiler_test.cc | 50 |
1 files changed, 47 insertions, 3 deletions
diff --git a/compiler/common_compiler_test.cc b/compiler/common_compiler_test.cc index 66421e2562..be6da714eb 100644 --- a/compiler/common_compiler_test.cc +++ b/compiler/common_compiler_test.cc @@ -22,6 +22,7 @@ #include "art_field-inl.h" #include "art_method-inl.h" #include "base/callee_save_type.h" +#include "base/casts.h" #include "base/enums.h" #include "base/utils.h" #include "class_linker.h" @@ -152,6 +153,10 @@ void CommonCompilerTest::SetUp() { CreateCompilerDriver(); } + // Note: We cannot use MemMap because some tests tear down the Runtime and destroy + // the gMaps, so when destroying the MemMap, the test would crash. + inaccessible_page_ = mmap(nullptr, kPageSize, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0); + CHECK(inaccessible_page_ != MAP_FAILED) << strerror(errno); } void CommonCompilerTest::ApplyInstructionSet() { @@ -190,9 +195,7 @@ void CommonCompilerTest::CreateCompilerDriver() { 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)); } @@ -222,6 +225,10 @@ void CommonCompilerTest::TearDown() { verification_results_.reset(); compiler_options_.reset(); image_reservation_.Reset(); + if (inaccessible_page_ != nullptr) { + munmap(inaccessible_page_, kPageSize); + inaccessible_page_ = nullptr; + } CommonRuntimeTest::TearDown(); } @@ -267,8 +274,16 @@ void CommonCompilerTest::CompileMethod(ArtMethod* method) { compiler_driver_->InitializeThreadPools(); - compiler_driver_->PreCompile(class_loader, dex_files, &timings); + compiler_driver_->PreCompile(class_loader, + dex_files, + &timings, + &compiler_options_->image_classes_, + verification_results_.get()); + // Verification results in the `callback_` should not be used during compilation. + down_cast<QuickCompilerCallbacks*>(callbacks_.get())->SetVerificationResults( + reinterpret_cast<VerificationResults*>(inaccessible_page_)); + compiler_options_->verification_results_ = verification_results_.get(); compiler_driver_->CompileOne(self, class_loader, *dex_file, @@ -279,6 +294,9 @@ void CommonCompilerTest::CompileMethod(ArtMethod* method) { code_item, dex_cache, h_class_loader); + compiler_options_->verification_results_ = nullptr; + down_cast<QuickCompilerCallbacks*>(callbacks_.get())->SetVerificationResults( + verification_results_.get()); compiler_driver_->FreeThreadPools(); @@ -334,6 +352,32 @@ void CommonCompilerTest::ReserveImageSpace() { CHECK(image_reservation_.IsValid()) << error_msg; } +void CommonCompilerTest::CompileAll(jobject class_loader, + const std::vector<const DexFile*>& dex_files, + TimingLogger* timings) { + TimingLogger::ScopedTiming t(__FUNCTION__, timings); + SetDexFilesForOatFile(dex_files); + + compiler_driver_->InitializeThreadPools(); + + compiler_driver_->PreCompile(class_loader, + dex_files, + timings, + &compiler_options_->image_classes_, + verification_results_.get()); + + // Verification results in the `callback_` should not be used during compilation. + down_cast<QuickCompilerCallbacks*>(callbacks_.get())->SetVerificationResults( + reinterpret_cast<VerificationResults*>(inaccessible_page_)); + compiler_options_->verification_results_ = verification_results_.get(); + compiler_driver_->CompileAll(class_loader, dex_files, timings); + compiler_options_->verification_results_ = nullptr; + down_cast<QuickCompilerCallbacks*>(callbacks_.get())->SetVerificationResults( + verification_results_.get()); + + compiler_driver_->FreeThreadPools(); +} + void CommonCompilerTest::UnreserveImageSpace() { image_reservation_.Reset(); } |