summaryrefslogtreecommitdiff
path: root/compiler/driver
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/driver')
-rw-r--r--compiler/driver/compiler_driver.cc9
-rw-r--r--compiler/driver/dex_compilation_unit.cc4
-rw-r--r--compiler/driver/dex_compilation_unit.h7
3 files changed, 14 insertions, 6 deletions
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_;
};