Misc fixes, new compiler unit tests
Fixed disassembly logging, miscellaneous codegen bugs and added a
set of unit tests (most of which fail because array allocation isn't quite
there yet in the codegen).
Failing tests conditionally compiled out for now.
Change-Id: I39c148f9a7686fac21c844a7a7f5ec86d4e0e1c5
diff --git a/src/compiler/codegen/arm/ArchUtility.cc b/src/compiler/codegen/arm/ArchUtility.cc
index 2f3af44..21ed8aa 100644
--- a/src/compiler/codegen/arm/ArchUtility.cc
+++ b/src/compiler/codegen/arm/ArchUtility.cc
@@ -308,8 +308,6 @@
ArmLIR* lir = (ArmLIR*) arg;
if (lir->flags.isNop)
return;
- char buf[256];
- char opName[256];
int offset = lir->generic.offset;
int dest = lir->operands[0];
const bool dumpNop = false;
@@ -361,16 +359,19 @@
default:
if (lir->flags.isNop && !dumpNop) {
break;
+ } else {
+ // TODO: rewrite using string
+ char opOperands[256];
+ char opName[256];
+ buildInsnString(EncodingMap[lir->opcode].name, lir, opName,
+ baseAddr, 256);
+ buildInsnString(EncodingMap[lir->opcode].fmt, lir, opOperands,
+ baseAddr, 256);
+ char tBuf[256];
+ snprintf(tBuf, 256, "%p (%04x): %-8s%s%s", baseAddr + offset, offset,
+ opName, opOperands, lir->flags.isNop ? "(nop)" : "");
+ LOG(INFO) << tBuf;
}
- buildInsnString(EncodingMap[lir->opcode].name, lir, opName,
- baseAddr, 256);
- buildInsnString(EncodingMap[lir->opcode].fmt, lir, buf, baseAddr,
- 256);
- char buf[100];
- snprintf(buf, 100, "%p (%04x): %-8s%s%s",
- baseAddr + offset, offset, opName, buf,
- lir->flags.isNop ? "(nop)" : "");
- LOG(INFO) << buf;
break;
}
@@ -450,7 +451,7 @@
std::string descriptor = method->GetDeclaringClass()->GetDescriptor()->
ToModifiedUtf8();
- char buf[100];
+ char buf[256];
LOG(INFO) << "*/";
sprintf(buf,"\n u1 %s%s_%s_code[] = {", descriptor.c_str(),
name.c_str(), signature.c_str());
@@ -458,8 +459,9 @@
if (buf[i] == ';') buf[i] = '_';
LOG(INFO) << buf;
strcpy(buf," ");
- for (int i = 0; i < cUnit->totalSize/2; i++) {
- sprintf(buf+strlen(buf),"0x%04x,", cUnit->codeBuffer[i]);
+ u1* pLiterals = (u1*)&cUnit->codeBuffer[0];
+ for (int i = 0; i < cUnit->totalSize; i++) {
+ sprintf(buf+strlen(buf),"0x%02x,", pLiterals[i]);
if (++linebreak == 8) {
linebreak = 0;
LOG(INFO) << buf;
diff --git a/src/compiler/codegen/arm/ArmRallocUtil.cc b/src/compiler/codegen/arm/ArmRallocUtil.cc
index 0a0c9bc..400fff6 100644
--- a/src/compiler/codegen/arm/ArmRallocUtil.cc
+++ b/src/compiler/codegen/arm/ArmRallocUtil.cc
@@ -60,12 +60,16 @@
sReg = DECODE_REG(
oatConvertSSARegToDalvik(cUnit, ssaRep->defs[0]));
counts[sReg].doubleStart = true;
+ }
+ if (attrs & DF_DA_WIDE) {
cUnit->regLocation[ssaRep->defs[0]].wide = true;
}
if ((attrs & (DF_UA_WIDE|DF_FP_A)) == (DF_UA_WIDE|DF_FP_A)) {
sReg = DECODE_REG(
oatConvertSSARegToDalvik(cUnit, ssaRep->uses[first]));
counts[sReg].doubleStart = true;
+ }
+ if (attrs & DF_UA_WIDE) {
cUnit->regLocation[ssaRep->uses[first]].wide = true;
first += 2;
}
@@ -73,6 +77,8 @@
sReg = DECODE_REG(
oatConvertSSARegToDalvik(cUnit, ssaRep->uses[first]));
counts[sReg].doubleStart = true;
+ }
+ if (attrs & DF_UB_WIDE) {
cUnit->regLocation[ssaRep->uses[first]].wide = true;
first += 2;
}
@@ -80,6 +86,8 @@
sReg = DECODE_REG(
oatConvertSSARegToDalvik(cUnit, ssaRep->uses[first]));
counts[sReg].doubleStart = true;
+ }
+ if (attrs & DF_UC_WIDE) {
cUnit->regLocation[ssaRep->uses[first]].wide = true;
}
}
diff --git a/src/compiler/codegen/arm/MethodCodegenDriver.cc b/src/compiler/codegen/arm/MethodCodegenDriver.cc
index b8dcdb2..fd1b8a7 100644
--- a/src/compiler/codegen/arm/MethodCodegenDriver.cc
+++ b/src/compiler/codegen/arm/MethodCodegenDriver.cc
@@ -28,15 +28,16 @@
Class* classPtr = cUnit->method->GetDeclaringClass()->GetDexCache()->
GetResolvedClass(mir->dalvikInsn.vC);
if (classPtr == NULL) {
- LOG(FATAL) << "Unexpected null passPtr";
+ LOG(FATAL) << "Unexpected null classPtr";
} else {
loadValueDirectFixed(cUnit, rlSrc, r1); /* get Len */
loadConstant(cUnit, r0, (int)classPtr);
}
- // FIXME: need this to throw errNegativeArraySize
+ UNIMPLEMENTED(WARNING) << "Support for throwing errNegativeArraySize";
genRegImmCheck(cUnit, kArmCondMi, r1, 0, mir->offset, NULL);
loadWordDisp(cUnit, rSELF, OFFSETOF_MEMBER(Thread, pArtAllocArrayByClass),
rLR);
+ UNIMPLEMENTED(WARNING) << "Need NoThrow wrapper";
newLIR1(cUnit, kThumbBlxR, rLR); // (arrayClass, length, allocFlags)
storeValue(cUnit, rlDest, retLoc);
}
@@ -63,7 +64,7 @@
Class* classPtr = cUnit->method->GetDeclaringClass()->GetDexCache()->
GetResolvedClass(typeIndex);
if (classPtr == NULL) {
- LOG(FATAL) << "Unexpected null passPtr";
+ LOG(FATAL) << "Unexpected null classPtr";
} else {
loadConstant(cUnit, r0, (int)classPtr);
loadConstant(cUnit, r1, elems);
@@ -897,7 +898,7 @@
rlResult = oatEvalLoc(cUnit, rlDest, kAnyReg, true);
loadConstantValueWide(cUnit, rlResult.lowReg, rlResult.highReg,
0, mir->dalvikInsn.vB);
- storeValue(cUnit, rlDest, rlResult);
+ storeValueWide(cUnit, rlDest, rlResult);
break;
case OP_CONST_WIDE_HIGH16:
diff --git a/src/compiler/codegen/arm/Thumb2/Gen.cc b/src/compiler/codegen/arm/Thumb2/Gen.cc
index 1a126e4..d8ecc84 100644
--- a/src/compiler/codegen/arm/Thumb2/Gen.cc
+++ b/src/compiler/codegen/arm/Thumb2/Gen.cc
@@ -1335,18 +1335,18 @@
switch( mir->dalvikInsn.opcode) {
case OP_SHL_LONG:
case OP_SHL_LONG_2ADDR:
+ UNIMPLEMENTED(FATAL) << "Need SHL_LONG helper";
//genDispatchToHandler(cUnit, TEMPLATE_SHL_LONG);
- assert(0); // unimp
break;
case OP_SHR_LONG:
case OP_SHR_LONG_2ADDR:
+ UNIMPLEMENTED(FATAL) << "Need SHR_LONG helper";
//genDispatchToHandler(cUnit, TEMPLATE_SHR_LONG);
- assert(0); // unimp
break;
case OP_USHR_LONG:
case OP_USHR_LONG_2ADDR:
+ UNIMPLEMENTED(FATAL) << "Need USHR_LONG helper";
//genDispatchToHandler(cUnit, TEMPLATE_USHR_LONG);
- assert(0); // unimp
break;
default:
return true;