diff options
author | 2017-09-23 16:11:06 -0700 | |
---|---|---|
committer | 2017-09-27 11:51:53 -0700 | |
commit | 1d2d4ff8570bb88d9d2d4633706fd7f6fb18d75e (patch) | |
tree | cbe67e8e9214828656314117121e8ce906a762ab /compiler/driver/compiler_driver.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/driver/compiler_driver.cc')
-rw-r--r-- | compiler/driver/compiler_driver.cc | 31 |
1 files changed, 10 insertions, 21 deletions
diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc index 03d8ef5915..7573367788 100644 --- a/compiler/driver/compiler_driver.cc +++ b/compiler/driver/compiler_driver.cc @@ -762,18 +762,14 @@ static void ResolveConstStrings(Handle<mirror::DexCache> dex_cache, return; } - const uint16_t* code_ptr = code_item->insns_; - const uint16_t* code_end = code_item->insns_ + code_item->insns_size_in_code_units_; ClassLinker* const class_linker = Runtime::Current()->GetClassLinker(); - - while (code_ptr < code_end) { - const Instruction* inst = Instruction::At(code_ptr); - switch (inst->Opcode()) { + for (const Instruction& inst : code_item->Instructions()) { + switch (inst.Opcode()) { case Instruction::CONST_STRING: case Instruction::CONST_STRING_JUMBO: { - dex::StringIndex string_index((inst->Opcode() == Instruction::CONST_STRING) - ? inst->VRegB_21c() - : inst->VRegB_31c()); + dex::StringIndex string_index((inst.Opcode() == Instruction::CONST_STRING) + ? inst.VRegB_21c() + : inst.VRegB_31c()); mirror::String* string = class_linker->ResolveString(dex_file, string_index, dex_cache); CHECK(string != nullptr) << "Could not allocate a string when forcing determinism"; break; @@ -782,8 +778,6 @@ static void ResolveConstStrings(Handle<mirror::DexCache> dex_cache, default: break; } - - code_ptr += inst->SizeInCodeUnits(); } } @@ -2439,21 +2433,16 @@ class InitializeClassVisitor : public CompilationVisitor { if (clinit != nullptr) { const DexFile::CodeItem* code_item = clinit->GetCodeItem(); DCHECK(code_item != nullptr); - const Instruction* inst = Instruction::At(code_item->insns_); - - const uint32_t insns_size = code_item->insns_size_in_code_units_; - for (uint32_t dex_pc = 0; dex_pc < insns_size;) { - if (inst->Opcode() == Instruction::CONST_STRING) { + for (const Instruction& inst : code_item->Instructions()) { + if (inst.Opcode() == Instruction::CONST_STRING) { ObjPtr<mirror::String> s = class_linker->ResolveString( - *dex_file, dex::StringIndex(inst->VRegB_21c()), h_dex_cache); + *dex_file, dex::StringIndex(inst.VRegB_21c()), h_dex_cache); CHECK(s != nullptr); - } else if (inst->Opcode() == Instruction::CONST_STRING_JUMBO) { + } else if (inst.Opcode() == Instruction::CONST_STRING_JUMBO) { ObjPtr<mirror::String> s = class_linker->ResolveString( - *dex_file, dex::StringIndex(inst->VRegB_31c()), h_dex_cache); + *dex_file, dex::StringIndex(inst.VRegB_31c()), h_dex_cache); CHECK(s != nullptr); } - dex_pc += inst->SizeInCodeUnits(); - inst = inst->Next(); } } } |