Fix portable path.
Change-Id: Ie5d64bd851a6ad55d4eef051704916c8318fa2f9
diff --git a/src/compiler/codegen/codegen_util.cc b/src/compiler/codegen/codegen_util.cc
index 77a2269..389a413 100644
--- a/src/compiler/codegen/codegen_util.cc
+++ b/src/compiler/codegen/codegen_util.cc
@@ -34,9 +34,9 @@
int& field_offset, bool& is_volatile, bool is_put)
{
OatCompilationUnit m_unit(cu->class_loader, cu->class_linker,
- *cu->dex_file,
- cu->code_item, cu->method_idx,
- cu->access_flags);
+ *cu->dex_file, cu->code_item,
+ cu->class_def_idx, cu->method_idx,
+ cu->access_flags);
return cu->compiler->ComputeInstanceFieldInfo(field_idx, &m_unit,
field_offset, is_volatile, is_put);
}
diff --git a/src/compiler/codegen/gen_common.cc b/src/compiler/codegen/gen_common.cc
index 275aee5..57cf2a5 100644
--- a/src/compiler/codegen/gen_common.cc
+++ b/src/compiler/codegen/gen_common.cc
@@ -370,8 +370,8 @@
bool is_volatile;
bool is_referrers_class;
- OatCompilationUnit m_unit(cu->class_loader, cu->class_linker, *cu->dex_file,
- cu->code_item, cu->method_idx, cu->access_flags);
+ OatCompilationUnit m_unit(cu->class_loader, cu->class_linker, *cu->dex_file, cu->code_item,
+ cu->class_def_idx, cu->method_idx, cu->access_flags);
bool fast_path =
cu->compiler->ComputeStaticFieldInfo(field_idx, &m_unit,
@@ -463,9 +463,9 @@
bool is_referrers_class;
OatCompilationUnit m_unit(cu->class_loader, cu->class_linker,
- *cu->dex_file,
- cu->code_item, cu->method_idx,
- cu->access_flags);
+ *cu->dex_file, cu->code_item,
+ cu->class_def_idx, cu->method_idx,
+ cu->access_flags);
bool fast_path =
cu->compiler->ComputeStaticFieldInfo(field_idx, &m_unit,
diff --git a/src/compiler/codegen/gen_invoke.cc b/src/compiler/codegen/gen_invoke.cc
index f354152..a153719 100644
--- a/src/compiler/codegen/gen_invoke.cc
+++ b/src/compiler/codegen/gen_invoke.cc
@@ -1219,9 +1219,9 @@
LockCallTemps(cu);
OatCompilationUnit m_unit(cu->class_loader, cu->class_linker,
- *cu->dex_file,
- cu->code_item, cu->method_idx,
- cu->access_flags);
+ *cu->dex_file, cu->code_item,
+ cu->class_def_idx, cu->method_idx,
+ cu->access_flags);
uint32_t dex_method_idx = info->index;
int vtable_idx;
diff --git a/src/compiler/codegen/mir_to_gbc.cc b/src/compiler/codegen/mir_to_gbc.cc
index 766a630..e38977a 100644
--- a/src/compiler/codegen/mir_to_gbc.cc
+++ b/src/compiler/codegen/mir_to_gbc.cc
@@ -53,15 +53,13 @@
static void SetVregOnValue(CompilationUnit* cu, llvm::Value* val, int s_reg)
{
// Set vreg for debugging
- if (cu->compiler->IsDebuggingSupported()) {
- greenland::IntrinsicHelper::IntrinsicId id =
- greenland::IntrinsicHelper::SetVReg;
- llvm::Function* func = cu->intrinsic_helper->GetIntrinsicFunction(id);
- int v_reg = SRegToVReg(cu, s_reg);
- llvm::Value* table_slot = cu->irb->getInt32(v_reg);
- llvm::Value* args[] = { table_slot, val };
- cu->irb->CreateCall(func, args);
- }
+ greenland::IntrinsicHelper::IntrinsicId id =
+ greenland::IntrinsicHelper::SetVReg;
+ llvm::Function* func = cu->intrinsic_helper->GetIntrinsicFunction(id);
+ int v_reg = SRegToVReg(cu, s_reg);
+ llvm::Value* table_slot = cu->irb->getInt32(v_reg);
+ llvm::Value* args[] = { table_slot, val };
+ cu->irb->CreateCall(func, args);
}
// Replace the placeholder value with the real definition
@@ -1799,33 +1797,44 @@
if (bb->block_type == kEntryBlock) {
SetMethodInfo(cu);
- bool *can_be_ref = static_cast<bool*>(NewMem(cu, sizeof(bool) * cu->num_dalvik_registers,
- true, kAllocMisc));
- for (int i = 0; i < cu->num_ssa_regs; i++) {
- int v_reg = SRegToVReg(cu, i);
- if (v_reg > SSA_METHOD_BASEREG) {
- can_be_ref[SRegToVReg(cu, i)] |= cu->reg_location[i].ref;
- }
+
+ { // Allocate shadowframe.
+ greenland::IntrinsicHelper::IntrinsicId id =
+ greenland::IntrinsicHelper::AllocaShadowFrame;
+ llvm::Function* func = cu->intrinsic_helper->GetIntrinsicFunction(id);
+ llvm::Value* entries = cu->irb->getInt32(cu->num_dalvik_registers);
+ cu->irb->CreateCall(func, entries);
}
- for (int i = 0; i < cu->num_dalvik_registers; i++) {
- if (can_be_ref[i]) {
- cu->num_shadow_frame_entries++;
+
+ { // Store arguments to vregs.
+ uint16_t arg_reg = cu->num_regs;
+
+ llvm::Function::arg_iterator arg_iter(cu->func->arg_begin());
+ llvm::Function::arg_iterator arg_end(cu->func->arg_end());
+
+ const char* shorty = cu->shorty;
+ uint32_t shorty_size = strlen(shorty);
+ CHECK_GE(shorty_size, 1u);
+
+ ++arg_iter; // skip method object
+
+ if ((cu->access_flags & kAccStatic) == 0) {
+ SetVregOnValue(cu, arg_iter, arg_reg);
+ ++arg_iter;
+ ++arg_reg;
}
- }
- if (cu->num_shadow_frame_entries > 0) {
- cu->shadow_map = static_cast<int*>(NewMem(cu, sizeof(int) * cu->num_shadow_frame_entries,
- true, kAllocMisc));
- for (int i = 0, j = 0; i < cu->num_dalvik_registers; i++) {
- if (can_be_ref[i]) {
- cu->shadow_map[j++] = i;
+
+ for (uint32_t i = 1; i < shorty_size; ++i, ++arg_iter) {
+ SetVregOnValue(cu, arg_iter, arg_reg);
+
+ ++arg_reg;
+ if (shorty[i] == 'J' || shorty[i] == 'D') {
+ // Wide types, such as long and double, are using a pair of registers
+ // to store the value, so we have to increase arg_reg again.
+ ++arg_reg;
}
}
}
- greenland::IntrinsicHelper::IntrinsicId id =
- greenland::IntrinsicHelper::AllocaShadowFrame;
- llvm::Function* func = cu->intrinsic_helper->GetIntrinsicFunction(id);
- llvm::Value* entries = cu->irb->getInt32(cu->num_shadow_frame_entries);
- cu->irb->CreateCall(func, entries);
} else if (bb->block_type == kExitBlock) {
/*
* Because of the differences between how MIR/LIR and llvm handle exit
diff --git a/src/compiler/compiler_ir.h b/src/compiler/compiler_ir.h
index 15d1ed9..aca32d5 100644
--- a/src/compiler/compiler_ir.h
+++ b/src/compiler/compiler_ir.h
@@ -355,8 +355,6 @@
entry_bb(NULL),
entryTarget_bb(NULL),
temp_name(0),
- num_shadow_frame_entries(0),
- shadow_map(NULL),
#ifndef NDEBUG
live_sreg(0),
#endif
@@ -520,8 +518,6 @@
SafeMap<llvm::BasicBlock*, LIR*> block_to_label_map; // llvm bb -> LIR label.
SafeMap<int32_t, llvm::BasicBlock*> id_to_block_map; // block id -> llvm bb.
SafeMap<llvm::Value*, RegLocation> loc_map; // llvm Value to loc rec.
- int num_shadow_frame_entries;
- int* shadow_map;
std::set<llvm::BasicBlock*> llvm_blocks;
#ifndef NDEBUG
/*
diff --git a/src/compiler/dataflow.cc b/src/compiler/dataflow.cc
index a129382..16065ab 100644
--- a/src/compiler/dataflow.cc
+++ b/src/compiler/dataflow.cc
@@ -2266,9 +2266,9 @@
return false;
}
OatCompilationUnit m_unit(cu->class_loader, cu->class_linker,
- *cu->dex_file,
- cu->code_item, cu->method_idx,
- cu->access_flags);
+ *cu->dex_file, cu->code_item,
+ cu->class_def_idx, cu->method_idx,
+ cu->access_flags);
// TODO: add a flag so we don't counts the stats for this twice
uint32_t dex_method_idx = mir->dalvikInsn.vB;
int vtable_idx;
diff --git a/src/compiler_llvm/compiler_llvm.cc b/src/compiler_llvm/compiler_llvm.cc
index 29c381d..c807b3d 100644
--- a/src/compiler_llvm/compiler_llvm.cc
+++ b/src/compiler_llvm/compiler_llvm.cc
@@ -45,7 +45,7 @@
const CompilerBackend compilerBackend,
const DexFile::CodeItem* code_item,
uint32_t access_flags, InvokeType invoke_type,
- uint32_t method_idx, jobject class_loader,
+ uint32_t class_def_idx, uint32_t method_idx, jobject class_loader,
const DexFile& dex_file,
LLVMInfo* llvm_info);
}
@@ -165,23 +165,13 @@
return method_compiler->Compile();
} else {
-#if 1
- /*
- * FIXME: temporary workaround
- * Until Portable/llvm is fixed, use Iceland.
- */
- UniquePtr<MethodCompiler> method_compiler(
- new MethodCompiler(cunit.get(), compiler_, oat_compilation_unit));
-
- return method_compiler->Compile();
-#endif
-
// TODO: consolidate ArtCompileMethods
CompileOneMethod(*compiler_,
kPortable,
oat_compilation_unit->GetCodeItem(),
oat_compilation_unit->access_flags_,
invoke_type,
+ oat_compilation_unit->GetClassDefIndex(),
oat_compilation_unit->GetDexMethodIndex(),
oat_compilation_unit->GetClassLoader(),
*oat_compilation_unit->GetDexFile(),
@@ -281,7 +271,7 @@
art::OatCompilationUnit oat_compilation_unit(
class_loader, class_linker, dex_file, code_item,
- method_idx, access_flags);
+ class_def_idx, method_idx, access_flags);
art::compiler_llvm::CompilerLLVM* compiler_llvm = ContextOf(compiler);
art::CompiledMethod* result = compiler_llvm->CompileDexMethod(&oat_compilation_unit, invoke_type);
return result;
@@ -294,7 +284,7 @@
art::OatCompilationUnit oat_compilation_unit(
NULL, class_linker, dex_file, NULL,
- method_idx, access_flags);
+ 0, method_idx, access_flags);
art::compiler_llvm::CompilerLLVM* compiler_llvm = ContextOf(compiler);
art::CompiledMethod* result = compiler_llvm->CompileNativeMethod(&oat_compilation_unit);
diff --git a/src/oat_compilation_unit.h b/src/oat_compilation_unit.h
index 97815ac..ec7c9a3 100644
--- a/src/oat_compilation_unit.h
+++ b/src/oat_compilation_unit.h
@@ -31,15 +31,17 @@
class OatCompilationUnit {
public:
OatCompilationUnit(jobject class_loader, ClassLinker* class_linker, const DexFile& dex_file,
- const DexFile::CodeItem* code_item, uint32_t method_idx, uint32_t access_flags)
+ const DexFile::CodeItem* code_item, uint32_t class_def_idx,
+ uint32_t method_idx, uint32_t access_flags)
: class_loader_(class_loader), class_linker_(class_linker), dex_file_(&dex_file),
- code_item_(code_item), method_idx_(method_idx), access_flags_(access_flags) {
+ code_item_(code_item), class_def_idx_(class_def_idx), method_idx_(method_idx),
+ access_flags_(access_flags) {
}
OatCompilationUnit* GetCallee(uint32_t callee_method_idx,
uint32_t callee_access_flags) {
return new OatCompilationUnit(class_loader_, class_linker_, *dex_file_, NULL,
- callee_method_idx, callee_access_flags);
+ 0, callee_method_idx, callee_access_flags);
}
jobject GetClassLoader() const {
@@ -54,6 +56,10 @@
return dex_file_;
}
+ uint32_t GetClassDefIndex() const {
+ return class_def_idx_;
+ }
+
uint32_t GetDexMethodIndex() const {
return method_idx_;
}
@@ -83,6 +89,7 @@
const DexFile* const dex_file_;
const DexFile::CodeItem* const code_item_;
+ const uint32_t class_def_idx_;
const uint32_t method_idx_;
const uint32_t access_flags_;
};