summaryrefslogtreecommitdiffstats
path: root/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'runtime')
-rw-r--r--runtime/verifier/method_verifier.cc6
-rw-r--r--runtime/verifier/method_verifier.h6
2 files changed, 11 insertions, 1 deletions
diff --git a/runtime/verifier/method_verifier.cc b/runtime/verifier/method_verifier.cc
index 89f5115..1f7dd58 100644
--- a/runtime/verifier/method_verifier.cc
+++ b/runtime/verifier/method_verifier.cc
@@ -400,6 +400,7 @@ MethodVerifier::MethodVerifier(Thread* self,
monitor_enter_dex_pcs_(nullptr),
have_pending_hard_failure_(false),
have_pending_runtime_throw_failure_(false),
+ have_any_pending_runtime_throw_failure_(false),
new_instance_count_(0),
monitor_enter_count_(0),
can_load_classes_(can_load_classes),
@@ -1636,6 +1637,7 @@ bool MethodVerifier::CodeFlowVerifyInstruction(uint32_t* start_guess) {
} else if (kIsDebugBuild) {
saved_line_->FillWithGarbage();
}
+ DCHECK(!have_pending_runtime_throw_failure_); // Per-instruction flag, should not be set here.
// We need to ensure the work line is consistent while performing validation. When we spot a
@@ -2936,6 +2938,10 @@ bool MethodVerifier::CodeFlowVerifyInstruction(uint32_t* start_guess) {
} else if (have_pending_runtime_throw_failure_) {
/* checking interpreter will throw, mark following code as unreachable */
opcode_flags = Instruction::kThrow;
+ have_any_pending_runtime_throw_failure_ = true;
+ // Reset the pending_runtime_throw flag. The flag is a global to decouple Fail and is per
+ // instruction.
+ have_pending_runtime_throw_failure_ = false;
}
/*
* If we didn't just set the result register, clear it out. This ensures that you can only use
diff --git a/runtime/verifier/method_verifier.h b/runtime/verifier/method_verifier.h
index 204b18e..62800fb 100644
--- a/runtime/verifier/method_verifier.h
+++ b/runtime/verifier/method_verifier.h
@@ -245,7 +245,7 @@ class MethodVerifier {
bool HasVirtualOrInterfaceInvokes() const;
bool HasFailures() const;
bool HasInstructionThatWillThrow() const {
- return have_pending_runtime_throw_failure_;
+ return have_any_pending_runtime_throw_failure_;
}
const RegType& ResolveCheckedClass(uint32_t class_idx)
@@ -720,8 +720,12 @@ class MethodVerifier {
// would fail at runtime throwing an exception. Such an instruction causes the following code
// to be unreachable. This is set by Fail and used to ensure we don't process unreachable
// instructions that would hard fail the verification.
+ // Note: this flag is reset after processing each instruction.
bool have_pending_runtime_throw_failure_;
+ // A version of the above that is not reset and thus captures if there were *any* throw failures.
+ bool have_any_pending_runtime_throw_failure_;
+
// Info message log use primarily for verifier diagnostics.
std::ostringstream info_messages_;