Special-case Object.<init> invoke
Identify direct invokes to Object.<init> and handle them similar
to the old-word OP_INVOKE_OBJECT_INIT_xxx. Also, added missing
null check for range-style invoke-direct and invoke-interface.
Change-Id: I5789db4e85609b780063c4788fa40d627a6988c4
diff --git a/src/compiler/codegen/arm/MethodCodegenDriver.cc b/src/compiler/codegen/arm/MethodCodegenDriver.cc
index 922e25b..fb665e6 100644
--- a/src/compiler/codegen/arm/MethodCodegenDriver.cc
+++ b/src/compiler/codegen/arm/MethodCodegenDriver.cc
@@ -817,8 +817,6 @@
callState = loadArgRegs(cUnit, mir, dInsn, callState, nextCallInsn,
rollback, skipThis);
- //TODO: better to move this into CallInsn lists
- // Load direct & need a "this" null check?
if (pcrLabel) {
*pcrLabel = genNullCheck(cUnit, oatSSASrc(mir,0), r1, mir);
}
@@ -920,6 +918,9 @@
rollback, skipThis);
callState = nextCallInsn(cUnit, mir, dInsn, callState, rollback);
+ if (pcrLabel) {
+ *pcrLabel = genNullCheck(cUnit, oatSSASrc(mir,0), r1, mir);
+ }
return callState;
}
@@ -947,6 +948,24 @@
// Explicit register usage
oatLockCallTemps(cUnit);
+ // Is this the special "Ljava/lang/Object;.<init>:()V" case?
+ if (mir->dalvikInsn.opcode == OP_INVOKE_DIRECT) {
+ int idx = mir->dalvikInsn.vB;
+ Method* target = cUnit->method->GetDexCacheResolvedMethods()->Get(idx);
+ if (target) {
+ if (PrettyMethod(target) == "java.lang.Object.<init>()V") {
+ RegLocation rlArg = oatGetSrc(cUnit, mir, 0);
+ loadValueDirectFixed(cUnit, rlArg, r0);
+ loadWordDisp(cUnit, rSELF,
+ OFFSETOF_MEMBER(Thread, pObjectInit), rLR);
+ genNullCheck(cUnit, oatSSASrc(mir,0), r0, mir);
+ opReg(cUnit, kOpBlx, rLR);
+ oatClobberCalleeSave(cUnit);
+ return;
+ }
+ }
+ }
+
if (range) {
callState = genDalvikArgsRange(cUnit, mir, dInsn, callState, pNullCk,
nextCallInsn, NULL, false);