Refactor DexInstructionIterator
Add a way to get the dex PC for the "for each" use case.
Bug: 67104794
Test: test-art-host
Change-Id: I144c459c9a2a03ec8d56842280338d1f7ce1caf0
diff --git a/compiler/dex/inline_method_analyser.cc b/compiler/dex/inline_method_analyser.cc
index 925863e..518b0ec 100644
--- a/compiler/dex/inline_method_analyser.cc
+++ b/compiler/dex/inline_method_analyser.cc
@@ -302,7 +302,8 @@
uint16_t this_vreg = code_item->registers_size_ - code_item->ins_size_;
uint16_t zero_vreg_mask = 0u;
- for (const Instruction& instruction : code_item->Instructions()) {
+ for (const DexInstructionPcPair& pair : code_item->Instructions()) {
+ const Instruction& instruction = pair.Inst();
if (instruction.Opcode() == Instruction::RETURN_VOID) {
break;
} else if (instruction.Opcode() == Instruction::INVOKE_DIRECT) {
diff --git a/compiler/dex/verified_method.cc b/compiler/dex/verified_method.cc
index 9c5b632..df75e07 100644
--- a/compiler/dex/verified_method.cc
+++ b/compiler/dex/verified_method.cc
@@ -64,12 +64,11 @@
if (method_verifier->HasFailures()) {
return;
}
- IterationRange<DexInstructionIterator> instructions = method_verifier->CodeItem()->Instructions();
- for (auto it = instructions.begin(); it != instructions.end(); ++it) {
- const Instruction& inst = *it;
+ for (const DexInstructionPcPair& pair : method_verifier->CodeItem()->Instructions()) {
+ const Instruction& inst = pair.Inst();
const Instruction::Code code = inst.Opcode();
if (code == Instruction::CHECK_CAST) {
- const uint32_t dex_pc = it.GetDexPC(instructions.begin());
+ const uint32_t dex_pc = pair.DexPc();
if (!method_verifier->GetInstructionFlags(dex_pc).IsVisited()) {
// Do not attempt to quicken this instruction, it's unreachable anyway.
continue;