Use vdex's quickening info when decoding a quickened instruction.
bug: 74521989
Test: test.py, 678-quickening
Change-Id: I3a85cc6014afcf11889941dcd15b90d4296b8408
diff --git a/runtime/common_throws.cc b/runtime/common_throws.cc
index 7484dd9..945442d 100644
--- a/runtime/common_throws.cc
+++ b/runtime/common_throws.cc
@@ -34,6 +34,7 @@
#include "nativehelper/scoped_local_ref.h"
#include "obj_ptr-inl.h"
#include "thread.h"
+#include "vdex_file.h"
#include "verifier/method_verifier.h"
#include "well_known_classes.h"
@@ -608,13 +609,10 @@
break;
case Instruction::INVOKE_VIRTUAL_QUICK:
case Instruction::INVOKE_VIRTUAL_RANGE_QUICK: {
- // Since we replaced the method index, we ask the verifier to tell us which
- // method is invoked at this location.
- ArtMethod* invoked_method =
- verifier::MethodVerifier::FindInvokedMethodAtDexPc(method, throw_dex_pc);
- if (invoked_method != nullptr) {
+ uint16_t method_idx = method->GetIndexFromQuickening(throw_dex_pc);
+ if (method_idx != DexFile::kDexNoIndex16) {
// NPE with precise message.
- ThrowNullPointerExceptionForMethodAccess(invoked_method, kVirtual);
+ ThrowNullPointerExceptionForMethodAccess(method_idx, kVirtual);
} else {
// NPE with imprecise message.
ThrowNullPointerException("Attempt to invoke a virtual method on a null object reference");
@@ -641,17 +639,13 @@
case Instruction::IGET_SHORT_QUICK:
case Instruction::IGET_WIDE_QUICK:
case Instruction::IGET_OBJECT_QUICK: {
- // Since we replaced the field index, we ask the verifier to tell us which
- // field is accessed at this location.
- ArtField* field =
- verifier::MethodVerifier::FindAccessedFieldAtDexPc(method, throw_dex_pc);
- if (field != nullptr) {
- // NPE with precise message.
- ThrowNullPointerExceptionForFieldAccess(field, true /* read */);
- } else {
- // NPE with imprecise message.
- ThrowNullPointerException("Attempt to read from a field on a null object reference");
- }
+ uint16_t field_idx = method->GetIndexFromQuickening(throw_dex_pc);
+ ArtField* field = nullptr;
+ CHECK_NE(field_idx, DexFile::kDexNoIndex16);
+ field = Runtime::Current()->GetClassLinker()->ResolveField(
+ field_idx, method, /* is_static */ false);
+ Thread::Current()->ClearException(); // Resolution may fail, ignore.
+ ThrowNullPointerExceptionForFieldAccess(field, true /* read */);
break;
}
case Instruction::IPUT:
@@ -661,8 +655,8 @@
case Instruction::IPUT_BYTE:
case Instruction::IPUT_CHAR:
case Instruction::IPUT_SHORT: {
- ArtField* field =
- Runtime::Current()->GetClassLinker()->ResolveField(instr.VRegC_22c(), method, false);
+ ArtField* field = Runtime::Current()->GetClassLinker()->ResolveField(
+ instr.VRegC_22c(), method, /* is_static */ false);
Thread::Current()->ClearException(); // Resolution may fail, ignore.
ThrowNullPointerExceptionForFieldAccess(field, false /* write */);
break;
@@ -674,17 +668,13 @@
case Instruction::IPUT_SHORT_QUICK:
case Instruction::IPUT_WIDE_QUICK:
case Instruction::IPUT_OBJECT_QUICK: {
- // Since we replaced the field index, we ask the verifier to tell us which
- // field is accessed at this location.
- ArtField* field =
- verifier::MethodVerifier::FindAccessedFieldAtDexPc(method, throw_dex_pc);
- if (field != nullptr) {
- // NPE with precise message.
- ThrowNullPointerExceptionForFieldAccess(field, false /* write */);
- } else {
- // NPE with imprecise message.
- ThrowNullPointerException("Attempt to write to a field on a null object reference");
- }
+ uint16_t field_idx = method->GetIndexFromQuickening(throw_dex_pc);
+ ArtField* field = nullptr;
+ CHECK_NE(field_idx, DexFile::kDexNoIndex16);
+ field = Runtime::Current()->GetClassLinker()->ResolveField(
+ field_idx, method, /* is_static */ false);
+ Thread::Current()->ClearException(); // Resolution may fail, ignore.
+ ThrowNullPointerExceptionForFieldAccess(field, false /* write */);
break;
}
case Instruction::AGET: