Support for promoting Method* and compiler temps

This CL completes the support for allowing compiler-generated
data to be treated as a Dalvik register and become subject to
the normal register promotion and live temp tracking machinery.

Also:
   o Removes some vestigal and useless Method* loads from
     range argument setup.
   o Changes the Method* pseudo vReg number from -1 to -2 to
     avoid a conflict with the 0xffff marker in the register map.
   o Removes some experimental code for CSE at the basic block
     level.

Change-Id: I112a8bbe20f95a8d789f63908c84e5fa167c74ac
diff --git a/src/compiler/codegen/CodegenFactory.cc b/src/compiler/codegen/CodegenFactory.cc
index 5f525a7..e1df1a5 100644
--- a/src/compiler/codegen/CodegenFactory.cc
+++ b/src/compiler/codegen/CodegenFactory.cc
@@ -302,5 +302,10 @@
     return loadValue(cUnit, cUnit->regLocation[cUnit->methodSReg], kCoreReg);
 }
 
+bool methodStarInReg(CompilationUnit* cUnit)
+{
+     return (cUnit->regLocation[cUnit->methodSReg].location == kLocPhysReg);
+}
+
 
 }  // namespace art
diff --git a/src/compiler/codegen/CodegenUtil.cc b/src/compiler/codegen/CodegenUtil.cc
index 8b324ed..d4b8eea 100644
--- a/src/compiler/codegen/CodegenUtil.cc
+++ b/src/compiler/codegen/CodegenUtil.cc
@@ -326,18 +326,29 @@
     }
 }
 
+#define BSZ 100
 void oatDumpPromotionMap(CompilationUnit *cUnit)
 {
-    for (int i = 0; i < cUnit->numDalvikRegisters; i++) {
+    int numRegs = cUnit->numDalvikRegisters + cUnit->numCompilerTemps + 1;
+    for (int i = 0; i < numRegs; i++) {
         PromotionMap vRegMap = cUnit->promotionMap[i];
-        char buf[100];
+        char buf[BSZ];
         if (vRegMap.fpLocation == kLocPhysReg) {
             snprintf(buf, 100, " : s%d", vRegMap.fpReg & FP_REG_MASK);
         } else {
             buf[0] = 0;
         }
-        char buf2[100];
-        snprintf(buf2, 100, "V[%02d] -> %s%d%s", i,
+        char buf2[BSZ];
+        char buf3[BSZ];
+        if (i < cUnit->numDalvikRegisters) {
+            snprintf(buf3, BSZ, "%02d", i);
+        } else if (i == cUnit->methodSReg) {
+            strncpy(buf3, "Method*", BSZ);
+        } else {
+            snprintf(buf3, BSZ, "ct%d", i - cUnit->numDalvikRegisters);
+        }
+
+        snprintf(buf2, BSZ, "V[%s] -> %s%d%s", buf3,
                  vRegMap.coreLocation == kLocPhysReg ?
                  "r" : "SP+", vRegMap.coreLocation == kLocPhysReg ?
                  vRegMap.coreReg : oatSRegOffset(cUnit, i), buf);
@@ -345,17 +356,6 @@
     }
 }
 
-void oatDumpFullPromotionMap(CompilationUnit *cUnit)
-{
-    for (int i = 0; i < cUnit->numDalvikRegisters; i++) {
-        PromotionMap vRegMap = cUnit->promotionMap[i];
-        LOG(INFO) << i << " -> " << "CL:" << (int)vRegMap.coreLocation <<
-            ", CR:" << (int)vRegMap.coreReg << ", FL:" <<
-            (int)vRegMap.fpLocation << ", FR:" << (int)vRegMap.fpReg <<
-            ", - " << (int)vRegMap.firstInPair;
-    }
-}
-
 /* Dump instructions and constant pool contents */
 void oatCodegenDump(CompilationUnit* cUnit)
 {
diff --git a/src/compiler/codegen/CompilerCodegen.h b/src/compiler/codegen/CompilerCodegen.h
index 571d6da..1137db3 100644
--- a/src/compiler/codegen/CompilerCodegen.h
+++ b/src/compiler/codegen/CompilerCodegen.h
@@ -39,7 +39,6 @@
 /* Implemented in the codegen/<target>/ArchUtility.c */
 void oatCodegenDump(CompilationUnit* cUnit);
 void oatDumpPromotionMap(CompilationUnit* cUnit);
-void oatDumpFullPromotionMap(CompilationUnit* cUnit);
 std::string buildInsnString(const char* fmt, LIR* lir,
                             unsigned char* baseAddr);
 
diff --git a/src/compiler/codegen/GenInvoke.cc b/src/compiler/codegen/GenInvoke.cc
index 90e2267..c2023ff 100644
--- a/src/compiler/codegen/GenInvoke.cc
+++ b/src/compiler/codegen/GenInvoke.cc
@@ -33,6 +33,23 @@
  */
 void flushIns(CompilationUnit* cUnit)
 {
+    /*
+     * Dummy up a RegLocation for the incoming Method*
+     * It will attempt to keep rARG0 live (or copy it to home location
+     * if promoted).
+     */
+    RegLocation rlSrc = cUnit->regLocation[cUnit->methodSReg];
+    RegLocation rlMethod = cUnit->regLocation[cUnit->methodSReg];
+    rlSrc.location = kLocPhysReg;
+    rlSrc.lowReg = rARG0;
+    rlSrc.home = false;
+    oatMarkLive(cUnit, rlSrc.lowReg, rlSrc.sRegLow);
+    storeValue(cUnit, rlMethod, rlSrc);
+    // If Method* has been promoted, explicitly flush
+    if (rlMethod.location == kLocPhysReg) {
+        storeWordDisp(cUnit, rSP, 0, rARG0);
+    }
+
     if (cUnit->numIns == 0)
         return;
     int firstArgReg = rARG1;
@@ -161,6 +178,7 @@
     } else {
         switch(state) {
         case 0:  // Get the current Method* [sets rARG0]
+            // TUNING: we can save a reg copy if Method* has been promoted
             loadCurrMethodDirect(cUnit, rARG0);
             break;
         case 1:  // Get method->dex_cache_resolved_methods_
@@ -537,8 +555,6 @@
     opRegRegImm(cUnit, kOpAdd, rARG1, rSP, startOffset);
     callRuntimeHelperRegRegImm(cUnit, OFFSETOF_MEMBER(Thread, pMemcpy),
                                rARG0, rARG1, (numArgs - 3) * 4);
-    // Restore Method*
-    loadCurrMethodDirect(cUnit, rARG0);
 #else
     if (numArgs >= 20) {
         // Generate memcpy
@@ -546,8 +562,6 @@
         opRegRegImm(cUnit, kOpAdd, rARG1, rSP, startOffset);
         callRuntimeHelperRegRegImm(cUnit, OFFSETOF_MEMBER(Thread, pMemcpy),
                                    rARG0, rARG1, (numArgs - 3) * 4);
-        // Restore Method*
-        loadCurrMethodDirect(cUnit, rARG0);
     } else {
         // Use vldm/vstm pair using rARG3 as a temp
         int regsLeft = std::min(numArgs - 3, 16);
diff --git a/src/compiler/codegen/Ralloc.h b/src/compiler/codegen/Ralloc.h
index aa5439a..2169082 100644
--- a/src/compiler/codegen/Ralloc.h
+++ b/src/compiler/codegen/Ralloc.h
@@ -233,7 +233,7 @@
 extern bool oatIsFPReg(int reg);
 extern uint32_t oatFPRegMask(void);
 extern void oatAdjustSpillMask(CompilationUnit* cUnit);
-void oatMarkPreservedSingle(CompilationUnit* cUnit, int sReg, int reg);
+void oatMarkPreservedSingle(CompilationUnit* cUnit, int vReg, int reg);
 void oatRegCopy(CompilationUnit* cUnit, int rDest, int rSrc);
 
 }  // namespace art
diff --git a/src/compiler/codegen/RallocUtil.cc b/src/compiler/codegen/RallocUtil.cc
index c08b2e8..ffff7d2 100644
--- a/src/compiler/codegen/RallocUtil.cc
+++ b/src/compiler/codegen/RallocUtil.cc
@@ -153,17 +153,28 @@
                     sReg);
 }
 
-/* Sanity check */
-bool validSreg(CompilationUnit* cUnit, int sReg)
+/*
+ * SSA names associated with the initial definitions of Dalvik
+ * registers are the same as the Dalvik register number (and
+ * thus take the same position in the promotionMap.  However,
+ * the special Method* and compiler temp resisters use negative
+ * vReg numbers to distinquish them and can have an arbitrary
+ * ssa name (above the last original Dalvik register).  This function
+ * maps SSA names to positions in the promotionMap array.
+ */
+int SRegToPMap(CompilationUnit* cUnit, int sReg)
 {
-    bool res = ((-(cUnit->numCompilerTemps + 1) <= sReg) &&
-                (sReg < cUnit->numDalvikRegisters));
-    if (!res) {
-        LOG(WARNING) << "Bad sreg: " << sReg;
-        LOG(WARNING) << "  low = " << -(cUnit->numCompilerTemps + 1);
-        LOG(WARNING) << "  high = " << cUnit->numRegs;
+    DCHECK_LT(sReg, cUnit->numSSARegs);
+    DCHECK_GE(sReg, 0);
+    int vReg = SRegToVReg(cUnit, sReg);
+    if (vReg >= 0) {
+        DCHECK_LT(vReg, cUnit->numDalvikRegisters);
+        return vReg;
+    } else {
+        int pos = std::abs(vReg) - std::abs(SSA_METHOD_BASEREG);
+        DCHECK_LE(pos, cUnit->numCompilerTemps);
+        return cUnit->numDalvikRegisters + pos;
     }
-    return res;
 }
 
 /* Reserve a callee-save register.  Return -1 if none available */
@@ -173,16 +184,15 @@
     RegisterInfo* coreRegs = cUnit->regPool->coreRegs;
     for (int i = 0; i < cUnit->regPool->numCoreRegs; i++) {
         if (!coreRegs[i].isTemp && !coreRegs[i].inUse) {
+            int vReg = SRegToVReg(cUnit, sReg);
+            int pMapIdx = SRegToPMap(cUnit, sReg);
             res = coreRegs[i].reg;
             coreRegs[i].inUse = true;
             cUnit->coreSpillMask |= (1 << res);
-            cUnit->coreVmapTable.push_back(sReg);
+            cUnit->coreVmapTable.push_back(vReg);
             cUnit->numCoreSpills++;
-            //  Should be promoting based on initial sReg set
-            DCHECK_EQ(sReg, SRegToVReg(cUnit, sReg));
-            DCHECK(validSreg(cUnit,sReg));
-            cUnit->promotionMap[sReg].coreLocation = kLocPhysReg;
-            cUnit->promotionMap[sReg].coreReg = res;
+            cUnit->promotionMap[pMapIdx].coreLocation = kLocPhysReg;
+            cUnit->promotionMap[pMapIdx].coreReg = res;
             break;
         }
     }
@@ -201,14 +211,13 @@
     for (int i = 0; i < cUnit->regPool->numFPRegs; i++) {
         if (!FPRegs[i].isTemp && !FPRegs[i].inUse &&
             ((FPRegs[i].reg & 0x1) == 0) == even) {
+            int vReg = SRegToVReg(cUnit, sReg);
+            int pMapIdx = SRegToPMap(cUnit, sReg);
             res = FPRegs[i].reg;
             FPRegs[i].inUse = true;
-            //  Should be promoting based on initial sReg set
-            DCHECK_EQ(sReg, SRegToVReg(cUnit, sReg));
-            oatMarkPreservedSingle(cUnit, sReg, res);
-            DCHECK(validSreg(cUnit,sReg));
-            cUnit->promotionMap[sReg].fpLocation = kLocPhysReg;
-            cUnit->promotionMap[sReg].fpReg = res;
+            oatMarkPreservedSingle(cUnit, vReg, res);
+            cUnit->promotionMap[pMapIdx].fpLocation = kLocPhysReg;
+            cUnit->promotionMap[pMapIdx].fpReg = res;
             break;
         }
     }
@@ -226,12 +235,11 @@
 int allocPreservedDouble(CompilationUnit* cUnit, int sReg)
 {
     int res = -1; // Assume failure
-    //  Should be promoting based on initial sReg set
-    DCHECK_EQ(sReg, SRegToVReg(cUnit, sReg));
-    DCHECK(validSreg(cUnit,sReg+1));
-    if (cUnit->promotionMap[sReg+1].fpLocation == kLocPhysReg) {
+    int vReg = SRegToVReg(cUnit, sReg);
+    int pMapIdx = SRegToPMap(cUnit, sReg);
+    if (cUnit->promotionMap[pMapIdx+1].fpLocation == kLocPhysReg) {
         // Upper reg is already allocated.  Can we fit?
-        int highReg = cUnit->promotionMap[sReg+1].fpReg;
+        int highReg = cUnit->promotionMap[pMapIdx+1].fpReg;
         if ((highReg & 1) == 0) {
             // High reg is even - fail.
             return res;
@@ -246,7 +254,7 @@
         res = p->reg;
         p->inUse = true;
         DCHECK_EQ((res & 1), 0);
-        oatMarkPreservedSingle(cUnit, sReg, res);
+        oatMarkPreservedSingle(cUnit, vReg, res);
     } else {
         RegisterInfo* FPRegs = cUnit->regPool->FPRegs;
         for (int i = 0; i < cUnit->regPool->numFPRegs; i++) {
@@ -257,21 +265,19 @@
                 (FPRegs[i].reg + 1) == FPRegs[i+1].reg) {
                 res = FPRegs[i].reg;
                 FPRegs[i].inUse = true;
-                oatMarkPreservedSingle(cUnit, sReg, res);
+                oatMarkPreservedSingle(cUnit, vReg, res);
                 FPRegs[i+1].inUse = true;
                 DCHECK_EQ(res + 1, FPRegs[i+1].reg);
-                oatMarkPreservedSingle(cUnit, sReg+1, res+1);
+                oatMarkPreservedSingle(cUnit, vReg+1, res+1);
                 break;
             }
         }
     }
     if (res != -1) {
-        DCHECK(validSreg(cUnit,sReg));
-        cUnit->promotionMap[sReg].fpLocation = kLocPhysReg;
-        cUnit->promotionMap[sReg].fpReg = res;
-        DCHECK(validSreg(cUnit,sReg+1));
-        cUnit->promotionMap[sReg+1].fpLocation = kLocPhysReg;
-        cUnit->promotionMap[sReg+1].fpReg = res + 1;
+        cUnit->promotionMap[pMapIdx].fpLocation = kLocPhysReg;
+        cUnit->promotionMap[pMapIdx].fpReg = res;
+        cUnit->promotionMap[pMapIdx+1].fpLocation = kLocPhysReg;
+        cUnit->promotionMap[pMapIdx+1].fpReg = res + 1;
     }
     return res;
 }
@@ -1051,18 +1057,15 @@
     for (int i = 0; i < cUnit->numSSARegs;) {
         RegLocation loc = cUnit->regLocation[i];
         RefCounts* counts = loc.fp ? fpCounts : coreCounts;
-        int vReg = SRegToVReg(cUnit, loc.sRegLow);
-        if (vReg < 0) {
-            vReg = cUnit->numDalvikRegisters - (vReg + 1);
-        }
+        int pMapIdx = SRegToPMap(cUnit, loc.sRegLow);
         if (loc.defined) {
-            counts[vReg].count += cUnit->useCounts.elemList[i];
+            counts[pMapIdx].count += cUnit->useCounts.elemList[i];
         }
         if (loc.wide) {
             if (loc.defined) {
                 if (loc.fp) {
-                    counts[vReg].doubleStart = true;
-                counts[vReg+1].count += cUnit->useCounts.elemList[i+1];
+                    counts[pMapIdx].doubleStart = true;
+                counts[pMapIdx+1].count += cUnit->useCounts.elemList[i+1];
                 }
             }
             i += 2;
@@ -1120,10 +1123,16 @@
     for (int i = 0; i < dalvikRegs; i++) {
         coreRegs[i].sReg = fpRegs[i].sReg = i;
     }
-    // Set ssa names for Method* and compiler temps
-    for (int i = 0; i < regBias; i++) {
-        coreRegs[dalvikRegs + i].sReg = fpRegs[dalvikRegs + i].sReg = (-1 - i);
+    // Set ssa name for Method*
+    coreRegs[dalvikRegs].sReg = cUnit->methodSReg;
+    fpRegs[dalvikRegs].sReg = cUnit->methodSReg;  // For consistecy
+    // Set ssa names for compilerTemps
+    for (int i = 1; i <= cUnit->numCompilerTemps; i++) {
+        CompilerTemp* ct = (CompilerTemp*)cUnit->compilerTemps.elemList[i];
+        coreRegs[dalvikRegs + i].sReg = ct->sReg;
+        fpRegs[dalvikRegs + i].sReg = ct->sReg;
     }
+
     GrowableListIterator iterator;
     oatGrowableListIteratorInit(&cUnit->blockList, &iterator);
     while (true) {
@@ -1156,8 +1165,8 @@
     if (!(cUnit->disableOpt & (1 << kPromoteRegs))) {
         // Promote fpRegs
         for (int i = 0; (i < numRegs) && (fpRegs[i].count > 0); i++) {
-            DCHECK(validSreg(cUnit,fpRegs[i].sReg));
-            if (cUnit->promotionMap[fpRegs[i].sReg].fpLocation != kLocPhysReg) {
+            int pMapIdx = SRegToPMap(cUnit, fpRegs[i].sReg);
+            if (cUnit->promotionMap[pMapIdx].fpLocation != kLocPhysReg) {
                 int reg = oatAllocPreservedFPReg(cUnit, fpRegs[i].sReg,
                     fpRegs[i].doubleStart);
                 if (reg < 0) {
@@ -1168,8 +1177,8 @@
 
         // Promote core regs
         for (int i = 0; (i < numRegs) && (coreRegs[i].count > 0); i++) {
-            DCHECK(validSreg(cUnit,coreRegs[i].sReg));
-            if (cUnit->promotionMap[coreRegs[i].sReg].coreLocation !=
+            int pMapIdx = SRegToPMap(cUnit, coreRegs[i].sReg);
+            if (cUnit->promotionMap[pMapIdx].coreLocation !=
                     kLocPhysReg) {
                 int reg = oatAllocPreservedCoreReg(cUnit, coreRegs[i].sReg);
                 if (reg < 0) {
@@ -1182,20 +1191,18 @@
     // Now, update SSA names to new home locations
     for (int i = 0; i < cUnit->numSSARegs; i++) {
         RegLocation *curr = &cUnit->regLocation[i];
-        int baseVReg = SRegToVReg(cUnit, curr->sRegLow);
+        int pMapIdx = SRegToPMap(cUnit, curr->sRegLow);
         if (!curr->wide) {
             if (curr->fp) {
-                DCHECK(validSreg(cUnit,baseVReg));
-                if (cUnit->promotionMap[baseVReg].fpLocation == kLocPhysReg) {
+                if (cUnit->promotionMap[pMapIdx].fpLocation == kLocPhysReg) {
                     curr->location = kLocPhysReg;
-                    curr->lowReg = cUnit->promotionMap[baseVReg].fpReg;
+                    curr->lowReg = cUnit->promotionMap[pMapIdx].fpReg;
                     curr->home = true;
                 }
             } else {
-                DCHECK(validSreg(cUnit,baseVReg));
-                if (cUnit->promotionMap[baseVReg].coreLocation == kLocPhysReg) {
+                if (cUnit->promotionMap[pMapIdx].coreLocation == kLocPhysReg) {
                     curr->location = kLocPhysReg;
-                    curr->lowReg = cUnit->promotionMap[baseVReg].coreReg;
+                    curr->lowReg = cUnit->promotionMap[pMapIdx].coreReg;
                     curr->home = true;
                 }
             }
@@ -1205,13 +1212,11 @@
                 continue;
             }
             if (curr->fp) {
-                DCHECK(validSreg(cUnit,baseVReg));
-                DCHECK(validSreg(cUnit,baseVReg+1));
-                if ((cUnit->promotionMap[baseVReg].fpLocation == kLocPhysReg) &&
-                    (cUnit->promotionMap[baseVReg+1].fpLocation ==
+                if ((cUnit->promotionMap[pMapIdx].fpLocation == kLocPhysReg) &&
+                    (cUnit->promotionMap[pMapIdx+1].fpLocation ==
                     kLocPhysReg)) {
-                    int lowReg = cUnit->promotionMap[baseVReg].fpReg;
-                    int highReg = cUnit->promotionMap[baseVReg+1].fpReg;
+                    int lowReg = cUnit->promotionMap[pMapIdx].fpReg;
+                    int highReg = cUnit->promotionMap[pMapIdx+1].fpReg;
                     // Doubles require pair of singles starting at even reg
                     if (((lowReg & 0x1) == 0) && ((lowReg + 1) == highReg)) {
                         curr->location = kLocPhysReg;
@@ -1221,14 +1226,12 @@
                     }
                 }
             } else {
-                DCHECK(validSreg(cUnit,baseVReg));
-                DCHECK(validSreg(cUnit,baseVReg+1));
-                if ((cUnit->promotionMap[baseVReg].coreLocation == kLocPhysReg)
-                     && (cUnit->promotionMap[baseVReg+1].coreLocation ==
+                if ((cUnit->promotionMap[pMapIdx].coreLocation == kLocPhysReg)
+                     && (cUnit->promotionMap[pMapIdx+1].coreLocation ==
                      kLocPhysReg)) {
                     curr->location = kLocPhysReg;
-                    curr->lowReg = cUnit->promotionMap[baseVReg].coreReg;
-                    curr->highReg = cUnit->promotionMap[baseVReg+1].coreReg;
+                    curr->lowReg = cUnit->promotionMap[pMapIdx].coreReg;
+                    curr->highReg = cUnit->promotionMap[pMapIdx+1].coreReg;
                     curr->home = true;
                 }
             }
diff --git a/src/compiler/codegen/arm/ArchFactory.cc b/src/compiler/codegen/arm/ArchFactory.cc
index da5de52..c24b856 100644
--- a/src/compiler/codegen/arm/ArchFactory.cc
+++ b/src/compiler/codegen/arm/ArchFactory.cc
@@ -107,20 +107,6 @@
                  cUnit->frameSize - (spillCount * 4));
     }
 
-    /*
-     * Dummy up a RegLocation for the incoming Method*
-     * It will attempt to keep r0 live (or copy it to home location
-     * if promoted).
-     */
-    RegLocation rlSrc = cUnit->regLocation[cUnit->methodSReg];
-    RegLocation rlMethod = cUnit->regLocation[cUnit->methodSReg];
-    rlSrc.location = kLocPhysReg;
-    rlSrc.lowReg = r0;
-    rlSrc.home = false;
-    oatMarkLive(cUnit, rlSrc.lowReg, rlSrc.sRegLow);
-    storeValue(cUnit, rlMethod, rlSrc);
-
-    /* Flush the rest of the ins */
     flushIns(cUnit);
 
     if (cUnit->genDebugger) {
diff --git a/src/compiler/codegen/arm/ArmRallocUtil.cc b/src/compiler/codegen/arm/ArmRallocUtil.cc
index e7627f2..89bff5e 100644
--- a/src/compiler/codegen/arm/ArmRallocUtil.cc
+++ b/src/compiler/codegen/arm/ArmRallocUtil.cc
@@ -45,7 +45,7 @@
  * include any holes in the mask.  Associate holes with
  * Dalvik register INVALID_VREG (0xFFFFU).
  */
-void oatMarkPreservedSingle(CompilationUnit* cUnit, int sReg, int reg)
+void oatMarkPreservedSingle(CompilationUnit* cUnit, int vReg, int reg)
 {
     DCHECK_GE(reg, FP_REG_MASK + FP_CALLEE_SAVE_BASE);
     reg = (reg & FP_REG_MASK) - FP_CALLEE_SAVE_BASE;
@@ -55,7 +55,7 @@
         cUnit->fpVmapTable.push_back(INVALID_VREG);
     }
     // Add the current mapping
-    cUnit->fpVmapTable[reg] = sReg;
+    cUnit->fpVmapTable[reg] = vReg;
     // Size of fpVmapTable is high-water mark, use to set mask
     cUnit->numFPSpills = cUnit->fpVmapTable.size();
     cUnit->fpSpillMask = ((1 << cUnit->numFPSpills) - 1) << FP_CALLEE_SAVE_BASE;
diff --git a/src/compiler/codegen/mips/ArchFactory.cc b/src/compiler/codegen/mips/ArchFactory.cc
index 9050cf9..b7f055d 100644
--- a/src/compiler/codegen/mips/ArchFactory.cc
+++ b/src/compiler/codegen/mips/ArchFactory.cc
@@ -185,7 +185,7 @@
         opRegImm(cUnit, kOpSub, rSP,
                  cUnit->frameSize - (spillCount * 4));
     }
-    storeBaseDisp(cUnit, rSP, 0, rARG0, kWord);
+
     flushIns(cUnit);
 
     if (cUnit->genDebugger) {
diff --git a/src/compiler/codegen/x86/ArchFactory.cc b/src/compiler/codegen/x86/ArchFactory.cc
index be0c9f4..efa54e0 100644
--- a/src/compiler/codegen/x86/ArchFactory.cc
+++ b/src/compiler/codegen/x86/ArchFactory.cc
@@ -164,8 +164,7 @@
         // Remember branch target - will process later
         oatInsertGrowableList(cUnit, &cUnit->throwLaunchpads, (intptr_t)tgt);
     }
-    /* Spill Method* */
-    storeBaseDisp(cUnit, rSP, 0, rARG0, kWord);
+
     flushIns(cUnit);
 
     if (cUnit->genDebugger) {
diff --git a/src/compiler/codegen/x86/X86RallocUtil.cc b/src/compiler/codegen/x86/X86RallocUtil.cc
index 466faa4..156a2d5 100644
--- a/src/compiler/codegen/x86/X86RallocUtil.cc
+++ b/src/compiler/codegen/x86/X86RallocUtil.cc
@@ -39,7 +39,7 @@
  * include any holes in the mask.  Associate holes with
  * Dalvik register INVALID_VREG (0xFFFFU).
  */
-void oatMarkPreservedSingle(CompilationUnit* cUnit, int sReg, int reg)
+void oatMarkPreservedSingle(CompilationUnit* cUnit, int vReg, int reg)
 {
     UNIMPLEMENTED(WARNING) << "oatMarkPreservedSingle";
 #if 0