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