diff options
author | 2017-09-23 16:11:06 -0700 | |
---|---|---|
committer | 2017-09-27 11:51:53 -0700 | |
commit | 1d2d4ff8570bb88d9d2d4633706fd7f6fb18d75e (patch) | |
tree | cbe67e8e9214828656314117121e8ce906a762ab /compiler/dex/verified_method.cc | |
parent | e5b35ed787fbfb388d162361310bae5b0e7682a7 (diff) |
Add DexInstructionIterator and use it a few places
Motivation:
Want to start abstracting away dex specific functionality to enable
CompactDex. Adding an iterator will enable CompactDex iteration to
work differently than normal dex iteration.
Will eventually replace CodeItemIterator.
Bug: 63756964
Test: test-art-host
Change-Id: I90e67c1a994b7698aaac0523a82816b0a003fbdc
Diffstat (limited to 'compiler/dex/verified_method.cc')
-rw-r--r-- | compiler/dex/verified_method.cc | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/compiler/dex/verified_method.cc b/compiler/dex/verified_method.cc index e46dc597fa..9c5b63232e 100644 --- a/compiler/dex/verified_method.cc +++ b/compiler/dex/verified_method.cc @@ -64,24 +64,21 @@ void VerifiedMethod::GenerateSafeCastSet(verifier::MethodVerifier* method_verifi if (method_verifier->HasFailures()) { return; } - const DexFile::CodeItem* code_item = method_verifier->CodeItem(); - const Instruction* inst = Instruction::At(code_item->insns_); - const Instruction* end = Instruction::At(code_item->insns_ + - code_item->insns_size_in_code_units_); - - for (; inst < end; inst = inst->Next()) { - Instruction::Code code = inst->Opcode(); + IterationRange<DexInstructionIterator> instructions = method_verifier->CodeItem()->Instructions(); + for (auto it = instructions.begin(); it != instructions.end(); ++it) { + const Instruction& inst = *it; + const Instruction::Code code = inst.Opcode(); if (code == Instruction::CHECK_CAST) { - uint32_t dex_pc = inst->GetDexPc(code_item->insns_); + const uint32_t dex_pc = it.GetDexPC(instructions.begin()); if (!method_verifier->GetInstructionFlags(dex_pc).IsVisited()) { // Do not attempt to quicken this instruction, it's unreachable anyway. continue; } const verifier::RegisterLine* line = method_verifier->GetRegLine(dex_pc); const verifier::RegType& reg_type(line->GetRegisterType(method_verifier, - inst->VRegA_21c())); + inst.VRegA_21c())); const verifier::RegType& cast_type = - method_verifier->ResolveCheckedClass(dex::TypeIndex(inst->VRegB_21c())); + method_verifier->ResolveCheckedClass(dex::TypeIndex(inst.VRegB_21c())); // Pass null for the method verifier to not record the VerifierDeps dependency // if the types are not assignable. if (cast_type.IsStrictlyAssignableFrom(reg_type, /* method_verifier */ nullptr)) { |