Restore card marking, minor tuning

Restore GC card marks that were mistakenly dropped during an
earlier retructuring.  Add debugging to code to gather opcode
frequency statics.  Minor tuning for code size.

Change-Id: I117f62c29e29250277166e7f005706e27998f77a
diff --git a/src/compiler/codegen/GenCommon.cc b/src/compiler/codegen/GenCommon.cc
index 52ff3d7..cc0d624 100644
--- a/src/compiler/codegen/GenCommon.cc
+++ b/src/compiler/codegen/GenCommon.cc
@@ -1049,6 +1049,9 @@
             if (isVolatile) {
                 oatGenMemBarrier(cUnit, kSY);
             }
+            if (isObject) {
+                markGCCard(cUnit, rlSrc.lowReg, rlObj.lowReg);
+            }
         }
     } else {
         int setterOffset = isLongOrDouble ? OFFSETOF_MEMBER(Thread, pSet64Instance) :
@@ -1434,6 +1437,7 @@
     }
     storeBaseIndexed(cUnit, regPtr, rlIndex.lowReg, rlSrc.lowReg,
                      scale, kWord);
+    markGCCard(cUnit, rlSrc.lowReg, rlArray.lowReg);
 }
 
 /*
diff --git a/src/compiler/codegen/RallocUtil.cc b/src/compiler/codegen/RallocUtil.cc
index ffff7d2..b3fa739 100644
--- a/src/compiler/codegen/RallocUtil.cc
+++ b/src/compiler/codegen/RallocUtil.cc
@@ -1100,6 +1100,7 @@
     int regBias = cUnit->numCompilerTemps + 1;
     int dalvikRegs = cUnit->numDalvikRegisters;
     int numRegs = dalvikRegs + regBias;
+    const int promotionThreshold = 2;
 
     // Allow target code to add any special registers
     oatAdjustSpillMask(cUnit);
@@ -1164,7 +1165,8 @@
 
     if (!(cUnit->disableOpt & (1 << kPromoteRegs))) {
         // Promote fpRegs
-        for (int i = 0; (i < numRegs) && (fpRegs[i].count > 0); i++) {
+        for (int i = 0; (i < numRegs) &&
+                        (fpRegs[i].count >= promotionThreshold ); i++) {
             int pMapIdx = SRegToPMap(cUnit, fpRegs[i].sReg);
             if (cUnit->promotionMap[pMapIdx].fpLocation != kLocPhysReg) {
                 int reg = oatAllocPreservedFPReg(cUnit, fpRegs[i].sReg,
@@ -1176,7 +1178,8 @@
         }
 
         // Promote core regs
-        for (int i = 0; (i < numRegs) && (coreRegs[i].count > 0); i++) {
+        for (int i = 0; (i < numRegs) &&
+                        (coreRegs[i].count > promotionThreshold); i++) {
             int pMapIdx = SRegToPMap(cUnit, coreRegs[i].sReg);
             if (cUnit->promotionMap[pMapIdx].coreLocation !=
                     kLocPhysReg) {
@@ -1186,8 +1189,17 @@
                 }
             }
         }
+    } else if (cUnit->qdMode) {
+        oatAllocPreservedCoreReg(cUnit, cUnit->methodSReg);
+        for (int i = 0; i < numRegs; i++) {
+            int reg = oatAllocPreservedCoreReg(cUnit, i);
+            if (reg < 0) {
+               break;  // No more left
+            }
+        }
     }
 
+
     // Now, update SSA names to new home locations
     for (int i = 0; i < cUnit->numSSARegs; i++) {
         RegLocation *curr = &cUnit->regLocation[i];