summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Andreas Gampe <agampe@google.com> 2017-08-31 10:36:31 -0700
committer Andreas Gampe <agampe@google.com> 2017-09-05 10:57:39 -0700
commit5d3b002b9a244b5dc25fe97fedcb92851d9073f7 (patch)
tree46203949455b1087fe36158da75af3af3db127aa
parentee5303f76ef167714a6a04d3abc502584ac5e103 (diff)
ART: Change CanAssumeVerified to GetPreviousClassState
Return any stored class state instead of a bool to allow more recognized states in the future. Bug: 63467744 Bug: 65318848 Test: m test-art-host Change-Id: Id097273a41e09ee77c8d53377ad9beb09104a944
-rw-r--r--compiler/dex/quick_compiler_callbacks.cc10
-rw-r--r--compiler/dex/quick_compiler_callbacks.h2
-rw-r--r--compiler/driver/compiler_driver.cc6
-rw-r--r--compiler/driver/compiler_driver.h2
-rw-r--r--compiler/driver/compiler_driver_test.cc8
-rw-r--r--runtime/aot_class_linker.cc6
-rw-r--r--runtime/compiler_callbacks.h7
7 files changed, 17 insertions, 24 deletions
diff --git a/compiler/dex/quick_compiler_callbacks.cc b/compiler/dex/quick_compiler_callbacks.cc
index c7e9f4fc07..23511e55fc 100644
--- a/compiler/dex/quick_compiler_callbacks.cc
+++ b/compiler/dex/quick_compiler_callbacks.cc
@@ -34,17 +34,21 @@ void QuickCompilerCallbacks::ClassRejected(ClassReference ref) {
}
}
-bool QuickCompilerCallbacks::CanAssumeVerified(ClassReference ref) {
+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.
if (!does_class_unloading_) {
- return false;
+ return ClassStatus::kStatusNotReady;
}
DCHECK(compiler_driver_ != nullptr);
// In the case of the quicken filter: avoiding verification of quickened instructions, which the
// verifier doesn't currently support.
// In the case of the verify filter, avoiding verifiying twice.
- return compiler_driver_->CanAssumeVerified(ref);
+ ClassStatus status;
+ if (!compiler_driver_->GetCompiledClass(ref, &status)) {
+ return ClassStatus::kStatusNotReady;
+ }
+ return status;
}
} // namespace art
diff --git a/compiler/dex/quick_compiler_callbacks.h b/compiler/dex/quick_compiler_callbacks.h
index 578aff45e5..45456f2a1c 100644
--- a/compiler/dex/quick_compiler_callbacks.h
+++ b/compiler/dex/quick_compiler_callbacks.h
@@ -54,7 +54,7 @@ class QuickCompilerCallbacks FINAL : public CompilerCallbacks {
verification_results_ = verification_results;
}
- bool CanAssumeVerified(ClassReference ref) OVERRIDE;
+ ClassStatus GetPreviousClassState(ClassReference ref) OVERRIDE;
void SetDoesClassUnloading(bool does_class_unloading, CompilerDriver* compiler_driver)
OVERRIDE {
diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc
index ee36a92c17..18b54eefba 100644
--- a/compiler/driver/compiler_driver.cc
+++ b/compiler/driver/compiler_driver.cc
@@ -3053,10 +3053,4 @@ void CompilerDriver::SetDexFilesForOatFile(const std::vector<const DexFile*>& de
}
}
-bool CompilerDriver::CanAssumeVerified(ClassReference ref) const {
- mirror::Class::Status existing = mirror::Class::kStatusNotReady;
- compiled_classes_.Get(DexFileReference(ref.first, ref.second), &existing);
- return existing >= mirror::Class::kStatusVerified;
-}
-
} // namespace art
diff --git a/compiler/driver/compiler_driver.h b/compiler/driver/compiler_driver.h
index 11808c1be4..d08d9d7940 100644
--- a/compiler/driver/compiler_driver.h
+++ b/compiler/driver/compiler_driver.h
@@ -379,8 +379,6 @@ class CompilerDriver {
return profile_compilation_info_;
}
- bool CanAssumeVerified(ClassReference ref) const;
-
// 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) {
diff --git a/compiler/driver/compiler_driver_test.cc b/compiler/driver/compiler_driver_test.cc
index 392d57c0f2..278358b250 100644
--- a/compiler/driver/compiler_driver_test.cc
+++ b/compiler/driver/compiler_driver_test.cc
@@ -369,8 +369,6 @@ TEST_F(CompilerDriverVerifyTest, VerifyCompilation) {
// Test that a class of status kStatusRetryVerificationAtRuntime is indeed recorded that way in the
// driver.
-// Test that checks that classes can be assumed as verified if unloading mode is enabled and
-// the class status is at least verified.
TEST_F(CompilerDriverVerifyTest, RetryVerifcationStatusCheckVerified) {
Thread* const self = Thread::Current();
jobject class_loader;
@@ -401,12 +399,6 @@ TEST_F(CompilerDriverVerifyTest, RetryVerifcationStatusCheckVerified) {
mirror::Class::Status status = {};
ASSERT_TRUE(compiler_driver_->GetCompiledClass(ref, &status));
EXPECT_EQ(status, expected_status);
-
- // Check that we can assume verified if we are a status that is at least verified.
- if (status >= mirror::Class::kStatusVerified) {
- // Check that the class can be assumed as verified in the compiler driver.
- EXPECT_TRUE(callbacks_->CanAssumeVerified(ref)) << status;
- }
}
}
diff --git a/runtime/aot_class_linker.cc b/runtime/aot_class_linker.cc
index 9396565eee..d07a0fd9dd 100644
--- a/runtime/aot_class_linker.cc
+++ b/runtime/aot_class_linker.cc
@@ -17,6 +17,7 @@
#include "aot_class_linker.h"
#include "class_reference.h"
+#include "class_status.h"
#include "compiler_callbacks.h"
#include "handle_scope-inl.h"
#include "mirror/class-inl.h"
@@ -75,8 +76,9 @@ verifier::FailureKind AotClassLinker::PerformClassVerification(Thread* self,
std::string* error_msg) {
Runtime* const runtime = Runtime::Current();
CompilerCallbacks* callbacks = runtime->GetCompilerCallbacks();
- if (callbacks->CanAssumeVerified(ClassReference(&klass->GetDexFile(),
- klass->GetDexClassDefIndex()))) {
+ ClassStatus old_status = callbacks->GetPreviousClassState(
+ ClassReference(&klass->GetDexFile(), klass->GetDexClassDefIndex()));
+ if (old_status >= ClassStatus::kStatusVerified) {
return verifier::FailureKind::kNoFailure;
}
return ClassLinker::PerformClassVerification(self, klass, log_level, error_msg);
diff --git a/runtime/compiler_callbacks.h b/runtime/compiler_callbacks.h
index c51bb5e176..9b227141e0 100644
--- a/runtime/compiler_callbacks.h
+++ b/runtime/compiler_callbacks.h
@@ -19,6 +19,7 @@
#include "base/mutex.h"
#include "class_reference.h"
+#include "class_status.h"
namespace art {
@@ -51,8 +52,10 @@ class CompilerCallbacks {
virtual verifier::VerifierDeps* GetVerifierDeps() const = 0;
virtual void SetVerifierDeps(verifier::VerifierDeps* deps ATTRIBUTE_UNUSED) {}
- virtual bool CanAssumeVerified(ClassReference ref ATTRIBUTE_UNUSED) {
- return false;
+ // Return the class status of a previous stage of the compilation. This can be used, for example,
+ // when class unloading is enabled during multidex compilation.
+ virtual ClassStatus GetPreviousClassState(ClassReference ref ATTRIBUTE_UNUSED) {
+ return ClassStatus::kStatusNotReady;
}
virtual void SetDoesClassUnloading(bool does_class_unloading ATTRIBUTE_UNUSED,