Use CodeItemAccessor helpers for method verifier
Create a code_item_accessor_ in the verifier and replace the existing
code_item field. Added some handling in DexFile to deal with
try/catch items.
Bug: 63756964
Test: test-art-host
Change-Id: I4e073c9cb29f94518f0016fccbe1628185884df4
diff --git a/runtime/code_item_accessors.h b/runtime/code_item_accessors.h
index fdc8ac5..aa1305a 100644
--- a/runtime/code_item_accessors.h
+++ b/runtime/code_item_accessors.h
@@ -50,6 +50,11 @@
return insns_;
}
+ // Return the instruction for a dex pc.
+ const Instruction& InstructionAt(uint32_t dex_pc) const {
+ return *Instruction::At(insns_ + dex_pc);
+ }
+
// Return true if the accessor has a code item.
bool HasCodeItem() const {
return Insns() != nullptr;
@@ -98,12 +103,19 @@
return tries_size_;
}
+ IterationRange<const DexFile::TryItem*> TryItems() const;
+
+ const uint8_t* GetCatchHandlerData(size_t offset = 0) const;
+
+ const DexFile::TryItem* FindTryItem(uint32_t try_dex_pc) const;
+
// CreateNullable allows ArtMethods that have a null code item.
ALWAYS_INLINE static CodeItemDataAccessor CreateNullable(ArtMethod* method)
REQUIRES_SHARED(Locks::mutator_lock_);
- ALWAYS_INLINE static CodeItemDataAccessor CreateNullable(const DexFile* dex_file,
- const DexFile::CodeItem* code_item);
+ ALWAYS_INLINE static CodeItemDataAccessor CreateNullable(
+ const DexFile* dex_file,
+ const DexFile::CodeItem* code_item);
protected:
CodeItemDataAccessor() = default;