summaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'runtime')
-rw-r--r--runtime/compiler_callbacks.h5
-rw-r--r--runtime/noop_compiler_callbacks.h4
-rw-r--r--runtime/verifier/class_verifier.cc14
-rw-r--r--runtime/verifier/method_verifier.cc15
-rw-r--r--runtime/verifier/method_verifier.h4
5 files changed, 15 insertions, 27 deletions
diff --git a/runtime/compiler_callbacks.h b/runtime/compiler_callbacks.h
index 18632dc6c6..23379a9550 100644
--- a/runtime/compiler_callbacks.h
+++ b/runtime/compiler_callbacks.h
@@ -19,6 +19,7 @@
#include "base/locks.h"
#include "dex/class_reference.h"
+#include "dex/method_reference.h"
#include "class_status.h"
namespace art {
@@ -33,7 +34,6 @@ class Class;
namespace verifier {
-class MethodVerifier;
class VerifierDeps;
} // namespace verifier
@@ -47,8 +47,7 @@ class CompilerCallbacks {
virtual ~CompilerCallbacks() { }
- virtual void MethodVerified(verifier::MethodVerifier* verifier)
- REQUIRES_SHARED(Locks::mutator_lock_) = 0;
+ virtual void AddUncompilableMethod(MethodReference ref) = 0;
virtual void ClassRejected(ClassReference ref) = 0;
virtual verifier::VerifierDeps* GetVerifierDeps() const = 0;
diff --git a/runtime/noop_compiler_callbacks.h b/runtime/noop_compiler_callbacks.h
index 439f4856a6..f415831fee 100644
--- a/runtime/noop_compiler_callbacks.h
+++ b/runtime/noop_compiler_callbacks.h
@@ -26,9 +26,7 @@ class NoopCompilerCallbacks final : public CompilerCallbacks {
NoopCompilerCallbacks() : CompilerCallbacks(CompilerCallbacks::CallbackMode::kCompileApp) {}
~NoopCompilerCallbacks() {}
- void MethodVerified(verifier::MethodVerifier* verifier ATTRIBUTE_UNUSED) override {
- }
-
+ void AddUncompilableMethod(MethodReference ref ATTRIBUTE_UNUSED) override {}
void ClassRejected(ClassReference ref ATTRIBUTE_UNUSED) override {}
verifier::VerifierDeps* GetVerifierDeps() const override { return nullptr; }
diff --git a/runtime/verifier/class_verifier.cc b/runtime/verifier/class_verifier.cc
index 1c8142b642..6a189a29c7 100644
--- a/runtime/verifier/class_verifier.cc
+++ b/runtime/verifier/class_verifier.cc
@@ -54,8 +54,13 @@ static bool gPrintedDxMonitorText = false;
static void UpdateMethodFlags(uint32_t method_index,
Handle<mirror::Class> klass,
Handle<mirror::DexCache> dex_cache,
+ CompilerCallbacks* callbacks,
int error_types)
REQUIRES_SHARED(Locks::mutator_lock_) {
+ if (callbacks != nullptr && !CanCompilerHandleVerificationFailure(error_types)) {
+ MethodReference ref(dex_cache->GetDexFile(), method_index);
+ callbacks->AddUncompilableMethod(ref);
+ }
if (klass == nullptr) {
DCHECK(Runtime::Current()->IsAotCompiler());
// Flags will be set at runtime.
@@ -130,7 +135,6 @@ FailureKind ClassVerifier::VerifyClass(Thread* self,
class_def,
method.GetCodeItem(),
method.GetAccessFlags(),
- callbacks,
allow_soft_failures,
log_level,
/*need_precise_constants=*/ false,
@@ -150,7 +154,7 @@ FailureKind ClassVerifier::VerifyClass(Thread* self,
*error += " ";
*error += hard_failure_msg;
} else if (result.kind != FailureKind::kNoFailure) {
- UpdateMethodFlags(method.GetIndex(), klass, dex_cache, result.types);
+ UpdateMethodFlags(method.GetIndex(), klass, dex_cache, callbacks, result.types);
if ((result.types & VerifyError::VERIFY_ERROR_LOCKING) != 0) {
// Print a warning about expected slow-down.
// Use a string temporary to print one contiguous warning.
@@ -174,6 +178,12 @@ FailureKind ClassVerifier::VerifyClass(Thread* self,
<< ", class: " << PrettyDescriptor(dex_file->GetClassDescriptor(class_def));
GetMetrics()->ClassVerificationCount()->AddOne();
+
+ if (failure_data.kind == verifier::FailureKind::kHardFailure && callbacks != nullptr) {
+ ClassReference ref(dex_file, dex_file->GetIndexForClassDef(class_def));
+ callbacks->ClassRejected(ref);
+ }
+
return failure_data.kind;
}
diff --git a/runtime/verifier/method_verifier.cc b/runtime/verifier/method_verifier.cc
index ced62bea1a..fea4d8a21a 100644
--- a/runtime/verifier/method_verifier.cc
+++ b/runtime/verifier/method_verifier.cc
@@ -35,7 +35,6 @@
#include "base/utils.h"
#include "class_linker.h"
#include "class_root-inl.h"
-#include "compiler_callbacks.h"
#include "dex/class_accessor-inl.h"
#include "dex/descriptors_names.h"
#include "dex/dex_file-inl.h"
@@ -5040,7 +5039,6 @@ MethodVerifier::FailureData MethodVerifier::VerifyMethod(Thread* self,
const dex::ClassDef& class_def,
const dex::CodeItem* code_item,
uint32_t method_access_flags,
- CompilerCallbacks* callbacks,
bool allow_soft_failures,
HardFailLogMode log_level,
bool need_precise_constants,
@@ -5059,7 +5057,6 @@ MethodVerifier::FailureData MethodVerifier::VerifyMethod(Thread* self,
class_def,
code_item,
method_access_flags,
- callbacks,
allow_soft_failures,
log_level,
need_precise_constants,
@@ -5078,7 +5075,6 @@ MethodVerifier::FailureData MethodVerifier::VerifyMethod(Thread* self,
class_def,
code_item,
method_access_flags,
- callbacks,
allow_soft_failures,
log_level,
need_precise_constants,
@@ -5117,7 +5113,6 @@ MethodVerifier::FailureData MethodVerifier::VerifyMethod(Thread* self,
const dex::ClassDef& class_def,
const dex::CodeItem* code_item,
uint32_t method_access_flags,
- CompilerCallbacks* callbacks,
bool allow_soft_failures,
HardFailLogMode log_level,
bool need_precise_constants,
@@ -5151,11 +5146,6 @@ MethodVerifier::FailureData MethodVerifier::VerifyMethod(Thread* self,
// to hard fail.
CHECK(!verifier.flags_.have_pending_hard_failure_);
- if (code_item != nullptr && callbacks != nullptr) {
- // Let the interested party know that the method was verified.
- callbacks->MethodVerified(&verifier);
- }
-
if (verifier.failures_.size() != 0) {
if (VLOG_IS_ON(verifier)) {
verifier.DumpFailures(VLOG_STREAM(verifier) << "Soft verification failures in "
@@ -5209,11 +5199,6 @@ MethodVerifier::FailureData MethodVerifier::VerifyMethod(Thread* self,
}
result.kind = FailureKind::kHardFailure;
- if (callbacks != nullptr) {
- // Let the interested party know that we failed the class.
- ClassReference ref(dex_file, dex_file->GetIndexForClassDef(class_def));
- callbacks->ClassRejected(ref);
- }
if (kVerifierDebug || VLOG_IS_ON(verifier)) {
LOG(ERROR) << verifier.info_messages_.str();
verifier.Dump(LOG_STREAM(ERROR));
diff --git a/runtime/verifier/method_verifier.h b/runtime/verifier/method_verifier.h
index 0e59251a15..858be17dbc 100644
--- a/runtime/verifier/method_verifier.h
+++ b/runtime/verifier/method_verifier.h
@@ -39,7 +39,6 @@
namespace art {
class ClassLinker;
-class CompilerCallbacks;
class DexFile;
class Instruction;
struct ReferenceMap2Visitor;
@@ -178,7 +177,6 @@ class MethodVerifier {
void VisitRoots(RootVisitor* visitor, const RootInfo& roots)
REQUIRES_SHARED(Locks::mutator_lock_);
- // Accessors used by the compiler via CompilerCallback
const CodeItemDataAccessor& CodeItem() const {
return code_item_accessor_;
}
@@ -257,7 +255,6 @@ class MethodVerifier {
const dex::ClassDef& class_def_idx,
const dex::CodeItem* code_item,
uint32_t method_access_flags,
- CompilerCallbacks* callbacks,
bool allow_soft_failures,
HardFailLogMode log_level,
bool need_precise_constants,
@@ -278,7 +275,6 @@ class MethodVerifier {
const dex::ClassDef& class_def_idx,
const dex::CodeItem* code_item,
uint32_t method_access_flags,
- CompilerCallbacks* callbacks,
bool allow_soft_failures,
HardFailLogMode log_level,
bool need_precise_constants,