diff options
| author | 2018-01-04 17:59:31 +0000 | |
|---|---|---|
| committer | 2018-01-04 17:59:31 +0000 | |
| commit | a61e97fd3cae77ec62c3f3bbe944a7eb4bfa87bf (patch) | |
| tree | ba69bf3d1292afd424838e462562a84f0a7760e1 /compiler | |
| parent | 6cd0005698181e4cef2247b632d396e605d58fa3 (diff) | |
| parent | 73f21d45a41aaad1a02eecdf3bbdbf78ef599d5e (diff) | |
Merge "Remove CodeItem accessor functions"
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/dex/dex_to_dex_compiler.cc | 7 | ||||
| -rw-r--r-- | compiler/dex/dex_to_dex_decompiler_test.cc | 6 | ||||
| -rw-r--r-- | compiler/driver/compiler_driver.cc | 9 | ||||
| -rw-r--r-- | compiler/driver/dex_compilation_unit.cc | 4 | ||||
| -rw-r--r-- | compiler/driver/dex_compilation_unit.h | 7 | ||||
| -rw-r--r-- | compiler/optimizing/code_generator.cc | 4 |
6 files changed, 25 insertions, 12 deletions
diff --git a/compiler/dex/dex_to_dex_compiler.cc b/compiler/dex/dex_to_dex_compiler.cc index ead909af9a..7e41c53128 100644 --- a/compiler/dex/dex_to_dex_compiler.cc +++ b/compiler/dex/dex_to_dex_compiler.cc @@ -114,7 +114,8 @@ class DexCompiler { void DexCompiler::Compile() { DCHECK_EQ(dex_to_dex_compilation_level_, DexToDexCompilationLevel::kOptimize); - IterationRange<DexInstructionIterator> instructions = unit_.GetCodeItem()->Instructions(); + IterationRange<DexInstructionIterator> instructions(unit_.GetCodeItemAccessor().begin(), + unit_.GetCodeItemAccessor().end()); for (DexInstructionIterator it = instructions.begin(); it != instructions.end(); ++it) { const uint32_t dex_pc = it.DexPc(); Instruction* inst = const_cast<Instruction*>(&it.Inst()); @@ -364,7 +365,7 @@ CompiledMethod* ArtCompileDEX( if (kIsDebugBuild) { // Double check that the counts line up with the size of the quicken info. size_t quicken_count = 0; - for (const DexInstructionPcPair& pair : code_item->Instructions()) { + for (const DexInstructionPcPair& pair : unit.GetCodeItemAccessor()) { if (QuickenInfoTable::NeedsIndexForInstruction(&pair.Inst())) { ++quicken_count; } @@ -376,7 +377,7 @@ CompiledMethod* ArtCompileDEX( // Dex pc is not serialized, only used for checking the instructions. Since we access the // array based on the index of the quickened instruction, the indexes must line up perfectly. // The reader side uses the NeedsIndexForInstruction function too. - const Instruction& inst = code_item->InstructionAt(info.dex_pc); + const Instruction& inst = unit.GetCodeItemAccessor().InstructionAt(info.dex_pc); CHECK(QuickenInfoTable::NeedsIndexForInstruction(&inst)) << inst.Opcode(); // Add the index. quicken_data.push_back(static_cast<uint8_t>(info.dex_member_index >> 0)); diff --git a/compiler/dex/dex_to_dex_decompiler_test.cc b/compiler/dex/dex_to_dex_decompiler_test.cc index 979c4c4ce2..89a63c01b4 100644 --- a/compiler/dex/dex_to_dex_decompiler_test.cc +++ b/compiler/dex/dex_to_dex_decompiler_test.cc @@ -99,8 +99,10 @@ class DexToDexDecompilerTest : public CommonCompilerTest { if (compiled_method != nullptr) { table = compiled_method->GetVmapTable(); } - optimizer::ArtDecompileDEX( - *it.GetMethodCodeItem(), table, /* decompile_return_instruction */ true); + optimizer::ArtDecompileDEX(updated_dex_file, + *it.GetMethodCodeItem(), + table, + /* decompile_return_instruction */ true); it.Next(); } DCHECK(!it.HasNext()); diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc index 68f963e3ab..5d4ed4676b 100644 --- a/compiler/driver/compiler_driver.cc +++ b/compiler/driver/compiler_driver.cc @@ -702,6 +702,7 @@ void CompilerDriver::Resolve(jobject class_loader, // stable order. static void ResolveConstStrings(Handle<mirror::DexCache> dex_cache, + const DexFile* dex_file, const DexFile::CodeItem* code_item) REQUIRES_SHARED(Locks::mutator_lock_) { if (code_item == nullptr) { @@ -710,7 +711,7 @@ static void ResolveConstStrings(Handle<mirror::DexCache> dex_cache, } ClassLinker* const class_linker = Runtime::Current()->GetClassLinker(); - for (const DexInstructionPcPair& inst : code_item->Instructions()) { + for (const DexInstructionPcPair& inst : CodeItemInstructionAccessor(dex_file, code_item)) { switch (inst->Opcode()) { case Instruction::CONST_STRING: case Instruction::CONST_STRING_JUMBO: { @@ -772,7 +773,7 @@ static void ResolveConstStrings(CompilerDriver* driver, continue; } previous_method_idx = method_idx; - ResolveConstStrings(dex_cache, it.GetMethodCodeItem()); + ResolveConstStrings(dex_cache, dex_file, it.GetMethodCodeItem()); it.Next(); } DCHECK(!it.HasNext()); @@ -2352,9 +2353,7 @@ class InitializeClassVisitor : public CompilationVisitor { // Intern strings seen in <clinit>. ArtMethod* clinit = klass->FindClassInitializer(class_linker->GetImagePointerSize()); if (clinit != nullptr) { - const DexFile::CodeItem* code_item = clinit->GetCodeItem(); - DCHECK(code_item != nullptr); - for (const DexInstructionPcPair& inst : code_item->Instructions()) { + for (const DexInstructionPcPair& inst : clinit->DexInstructions()) { if (inst->Opcode() == Instruction::CONST_STRING) { ObjPtr<mirror::String> s = class_linker->ResolveString( dex::StringIndex(inst->VRegB_21c()), dex_cache); diff --git a/compiler/driver/dex_compilation_unit.cc b/compiler/driver/dex_compilation_unit.cc index 7e8e812c4a..76e1299cc9 100644 --- a/compiler/driver/dex_compilation_unit.cc +++ b/compiler/driver/dex_compilation_unit.cc @@ -16,6 +16,7 @@ #include "dex_compilation_unit.h" +#include "code_item_accessors-inl.h" #include "mirror/dex_cache.h" #include "utils.h" @@ -38,7 +39,8 @@ DexCompilationUnit::DexCompilationUnit(Handle<mirror::ClassLoader> class_loader, dex_method_idx_(method_idx), access_flags_(access_flags), verified_method_(verified_method), - dex_cache_(dex_cache) { + dex_cache_(dex_cache), + code_item_accessor_(&dex_file, code_item) { } const std::string& DexCompilationUnit::GetSymbol() { diff --git a/compiler/driver/dex_compilation_unit.h b/compiler/driver/dex_compilation_unit.h index 24a9a5b653..cdc505fbf5 100644 --- a/compiler/driver/dex_compilation_unit.h +++ b/compiler/driver/dex_compilation_unit.h @@ -20,6 +20,7 @@ #include <stdint.h> #include "base/arena_object.h" +#include "code_item_accessors.h" #include "dex_file.h" #include "handle.h" #include "jni.h" @@ -112,6 +113,10 @@ class DexCompilationUnit : public DeletableArenaObject<kArenaAllocMisc> { return dex_cache_; } + const CodeItemDataAccessor& GetCodeItemAccessor() const { + return code_item_accessor_; + } + private: const Handle<mirror::ClassLoader> class_loader_; @@ -127,6 +132,8 @@ class DexCompilationUnit : public DeletableArenaObject<kArenaAllocMisc> { const Handle<mirror::DexCache> dex_cache_; + const CodeItemDataAccessor code_item_accessor_; + std::string symbol_; }; diff --git a/compiler/optimizing/code_generator.cc b/compiler/optimizing/code_generator.cc index dee74e96dc..729b08e92d 100644 --- a/compiler/optimizing/code_generator.cc +++ b/compiler/optimizing/code_generator.cc @@ -45,6 +45,7 @@ #include "base/casts.h" #include "bytecode_utils.h" #include "class_linker.h" +#include "code_item_accessors-inl.h" #include "compiled_method.h" #include "dex/verified_method.h" #include "driver/compiler_driver.h" @@ -910,7 +911,8 @@ static void CheckLoopEntriesCanBeUsedForOsr(const HGraph& graph, } ArenaVector<size_t> covered( loop_headers.size(), 0, graph.GetAllocator()->Adapter(kArenaAllocMisc)); - for (const DexInstructionPcPair& pair : code_item.Instructions()) { + for (const DexInstructionPcPair& pair : CodeItemInstructionAccessor(&graph.GetDexFile(), + &code_item)) { const uint32_t dex_pc = pair.DexPc(); const Instruction& instruction = pair.Inst(); if (instruction.IsBranch()) { |