ART: Save work-line for pending runtime failure
When we detect a pending runtime failure, we'll handle it as a
generic throw, no matter the instruction type. But we won't have
saved the work-line, which means we'll try to merge garbage into
the handler's line.
Copy the work-line when we set the failure.
Bug: 19634276
Change-Id: I54df9e9492cd48802f93e2f1938adaadc55c9bd5
diff --git a/runtime/verifier/method_verifier.cc b/runtime/verifier/method_verifier.cc
index a48735b..b3f686d 100644
--- a/runtime/verifier/method_verifier.cc
+++ b/runtime/verifier/method_verifier.cc
@@ -572,6 +572,17 @@
// If we fail again at runtime, mark that this instruction would throw and force this
// method to be executed using the interpreter with checks.
have_pending_runtime_throw_failure_ = true;
+
+ // We need to save the work_line if the instruction wasn't throwing before. Otherwise we'll
+ // try to merge garbage.
+ // Note: this assumes that Fail is called before we do any work_line modifications.
+ const uint16_t* insns = code_item_->insns_ + work_insn_idx_;
+ const Instruction* inst = Instruction::At(insns);
+ int opcode_flags = Instruction::FlagsOf(inst->Opcode());
+
+ if ((opcode_flags & Instruction::kThrow) == 0 && CurrentInsnFlags()->IsInTry()) {
+ saved_line_->CopyFromLine(work_line_.get());
+ }
}
break;
// Indication that verification should be retried at runtime.