summaryrefslogtreecommitdiff
path: root/dex2oat
diff options
context:
space:
mode:
author Nicolas Geoffray <ngeoffray@google.com> 2025-02-17 14:21:07 +0000
committer Nicolas Geoffray <ngeoffray@google.com> 2025-02-18 07:19:47 -0800
commitcb3c3b2819f326d54a6bd960a9a82c5290aa69b0 (patch)
tree1b71adef87aeebc9bdf92f6c66330c3a31fa1877 /dex2oat
parentb4d4a7c4c368272c4368db35ddffbd8fcab544fb (diff)
Do not inline a method that was marked as un-compilable.
The compiler may have internally mark a method as not compilable. Do not clear the verification results from the compiler callbacks, we still need them during compilation. Test: 860-vdex-failure Bug: 395243275 Change-Id: I79ba61eb8a7ba6729b22c4c27fa83d8373fce03a
Diffstat (limited to 'dex2oat')
-rw-r--r--dex2oat/common_compiler_driver_test.cc18
-rw-r--r--dex2oat/common_compiler_driver_test.h1
-rw-r--r--dex2oat/common_transaction_test.cc1
-rw-r--r--dex2oat/dex/quick_compiler_callbacks.cc7
-rw-r--r--dex2oat/dex/quick_compiler_callbacks.h1
-rw-r--r--dex2oat/dex2oat.cc1
-rw-r--r--dex2oat/verifier_deps_test.cc1
7 files changed, 11 insertions, 19 deletions
diff --git a/dex2oat/common_compiler_driver_test.cc b/dex2oat/common_compiler_driver_test.cc
index 81e06b2345..7ce5e94bcd 100644
--- a/dex2oat/common_compiler_driver_test.cc
+++ b/dex2oat/common_compiler_driver_test.cc
@@ -28,7 +28,7 @@
namespace art {
-CommonCompilerDriverTest::CommonCompilerDriverTest() : inaccessible_page_(nullptr) {}
+CommonCompilerDriverTest::CommonCompilerDriverTest() {}
CommonCompilerDriverTest::~CommonCompilerDriverTest() {}
void CommonCompilerDriverTest::CompileAll(jobject class_loader,
@@ -44,13 +44,7 @@ void CommonCompilerDriverTest::CompileAll(jobject class_loader,
timings,
&compiler_options_->image_classes_);
- // Verification results in the `callback_` should not be used during compilation.
- down_cast<QuickCompilerCallbacks*>(callbacks_.get())->SetVerificationResults(
- reinterpret_cast<VerificationResults*>(inaccessible_page_));
compiler_driver_->CompileAll(class_loader, dex_files, timings);
- down_cast<QuickCompilerCallbacks*>(callbacks_.get())->SetVerificationResults(
- verification_results_.get());
-
compiler_driver_->FreeThreadPools();
}
@@ -107,19 +101,9 @@ void CommonCompilerDriverTest::SetUp() {
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.
- const size_t page_size = MemMap::GetPageSize();
- inaccessible_page_ = mmap(nullptr, page_size, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
- CHECK(inaccessible_page_ != MAP_FAILED) << strerror(errno);
}
void CommonCompilerDriverTest::TearDown() {
- if (inaccessible_page_ != nullptr) {
- munmap(inaccessible_page_, MemMap::GetPageSize());
- inaccessible_page_ = nullptr;
- }
image_reservation_.Reset();
compiler_driver_.reset();
verification_results_.reset();
diff --git a/dex2oat/common_compiler_driver_test.h b/dex2oat/common_compiler_driver_test.h
index b49d18fa10..36090c0644 100644
--- a/dex2oat/common_compiler_driver_test.h
+++ b/dex2oat/common_compiler_driver_test.h
@@ -68,7 +68,6 @@ class CommonCompilerDriverTest : public CommonCompilerTest {
private:
MemMap image_reservation_;
- void* inaccessible_page_;
};
} // namespace art
diff --git a/dex2oat/common_transaction_test.cc b/dex2oat/common_transaction_test.cc
index d24acd575d..cd0671de4d 100644
--- a/dex2oat/common_transaction_test.cc
+++ b/dex2oat/common_transaction_test.cc
@@ -33,6 +33,7 @@ class CommonTransactionTestCompilerCallbacks : public CompilerCallbacks {
void AddUncompilableMethod([[maybe_unused]] MethodReference ref) override {}
void AddUncompilableClass([[maybe_unused]] ClassReference ref) override {}
void ClassRejected([[maybe_unused]] ClassReference ref) override {}
+ bool IsUncompilableMethod([[maybe_unused]] MethodReference ref) override { return false; }
verifier::VerifierDeps* GetVerifierDeps() const override { return nullptr; }
diff --git a/dex2oat/dex/quick_compiler_callbacks.cc b/dex2oat/dex/quick_compiler_callbacks.cc
index 6261cc27c5..ee055fbfd9 100644
--- a/dex2oat/dex/quick_compiler_callbacks.cc
+++ b/dex2oat/dex/quick_compiler_callbacks.cc
@@ -45,6 +45,13 @@ void QuickCompilerCallbacks::ClassRejected(ClassReference ref) {
}
}
+bool QuickCompilerCallbacks::IsUncompilableMethod(MethodReference ref) {
+ if (verification_results_ != nullptr) {
+ return verification_results_->IsUncompilableMethod(ref);
+ }
+ return false;
+}
+
ClassStatus QuickCompilerCallbacks::GetPreviousClassState(ClassReference ref) {
// If we don't have class unloading enabled in the compiler, we will never see class that were
// previously verified. Return false to avoid overhead from the lookup in the compiler driver.
diff --git a/dex2oat/dex/quick_compiler_callbacks.h b/dex2oat/dex/quick_compiler_callbacks.h
index bb5bed38a2..9e82f2b99b 100644
--- a/dex2oat/dex/quick_compiler_callbacks.h
+++ b/dex2oat/dex/quick_compiler_callbacks.h
@@ -37,6 +37,7 @@ class QuickCompilerCallbacks final : public CompilerCallbacks {
void AddUncompilableMethod(MethodReference ref) override;
void AddUncompilableClass(ClassReference ref) override;
+ bool IsUncompilableMethod(MethodReference ref) override;
void ClassRejected(ClassReference ref) override;
diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc
index 0f377719a7..344c9406f2 100644
--- a/dex2oat/dex2oat.cc
+++ b/dex2oat/dex2oat.cc
@@ -1990,7 +1990,6 @@ class Dex2Oat final {
dex_files,
timings_,
&compiler_options_->image_classes_);
- callbacks_->SetVerificationResults(nullptr); // Should not be needed anymore.
driver_->CompileAll(class_loader, dex_files, timings_);
driver_->FreeThreadPools();
return class_loader;
diff --git a/dex2oat/verifier_deps_test.cc b/dex2oat/verifier_deps_test.cc
index 828691d3e2..bffb3bccc5 100644
--- a/dex2oat/verifier_deps_test.cc
+++ b/dex2oat/verifier_deps_test.cc
@@ -55,6 +55,7 @@ class VerifierDepsCompilerCallbacks : public CompilerCallbacks {
void AddUncompilableMethod([[maybe_unused]] MethodReference ref) override {}
void AddUncompilableClass([[maybe_unused]] ClassReference ref) override {}
void ClassRejected([[maybe_unused]] ClassReference ref) override {}
+ bool IsUncompilableMethod([[maybe_unused]] MethodReference ref) override { return false; }
verifier::VerifierDeps* GetVerifierDeps() const override { return deps_; }
void SetVerifierDeps(verifier::VerifierDeps* deps) override { deps_ = deps; }