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/compiler/dex/verified_method.cc b/compiler/dex/verified_method.cc
index df75e07..524b0a6 100644
--- a/compiler/dex/verified_method.cc
+++ b/compiler/dex/verified_method.cc
@@ -20,6 +20,7 @@
#include <memory>
#include "base/logging.h"
+#include "code_item_accessors-inl.h"
#include "dex_file.h"
#include "dex_instruction-inl.h"
#include "runtime.h"
@@ -64,7 +65,7 @@
if (method_verifier->HasFailures()) {
return;
}
- for (const DexInstructionPcPair& pair : method_verifier->CodeItem()->Instructions()) {
+ for (const DexInstructionPcPair& pair : method_verifier->CodeItem()) {
const Instruction& inst = pair.Inst();
const Instruction::Code code = inst.Opcode();
if (code == Instruction::CHECK_CAST) {
diff --git a/compiler/optimizing/block_builder.cc b/compiler/optimizing/block_builder.cc
index 595dd4d..2432f13 100644
--- a/compiler/optimizing/block_builder.cc
+++ b/compiler/optimizing/block_builder.cc
@@ -269,7 +269,9 @@
// loop for synchronized blocks.
if (ContainsElement(throwing_blocks_, block)) {
// Try to find a TryItem covering the block.
- const int32_t try_item_idx = DexFile::FindTryItem(code_item_, block->GetDexPc());
+ const int32_t try_item_idx = DexFile::FindTryItem(DexFile::GetTryItems(code_item_, 0u),
+ code_item_.tries_size_,
+ block->GetDexPc());
if (try_item_idx != -1) {
// Block throwing and in a TryItem. Store the try block information.
try_block_info.Put(block->GetBlockId(), DexFile::GetTryItems(code_item_, try_item_idx));