Minor tweaks.

Clean up replaceFailingInstruction() a little.  In particular, use
the appropriate method for extracting the opcode, and assert that
the instruction we're replacing was marked "can throw" (if it wasn't,
the list of predecessors in the catch handler will be wrong).  Also
remove a declaration that became redundant when we started replacing
instructions in place (as opposed to making a copy of the method body).

Strip out a bit of stale #if 0 code.

Change-Id: Iccf80647237672e2da4b1b46ca9627ae3344704d
diff --git a/dexopt/OptMain.c b/dexopt/OptMain.c
index 194a62b..765fd7f 100644
--- a/dexopt/OptMain.c
+++ b/dexopt/OptMain.c
@@ -549,17 +549,6 @@
     }
 #endif
 
-    //dvmLinearAllocDump(NULL);
-
-#if 0
-    {
-        extern int gDvm__totalInstr, gDvm__gcInstr, gDvm__gcData,
-               gDvm__gcSimpleData;
-        LOGI("GC DATA: totinst=%d, gcinst=%d, gcdata=%d simpled=%d\n",
-            gDvm__totalInstr, gDvm__gcInstr, gDvm__gcData, gDvm__gcSimpleData);
-    }
-#endif
-
     free(bootClassPath);
     LOGV("DexOpt command complete (result=%d)\n", result);
     return result;
diff --git a/vm/analysis/CodeVerify.c b/vm/analysis/CodeVerify.c
index aa41d82..f817a0e 100644
--- a/vm/analysis/CodeVerify.c
+++ b/vm/analysis/CodeVerify.c
@@ -55,14 +55,8 @@
 # define DEAD_CODE_SCAN  false
 #endif
 
-static bool gDebugVerbose = false;      // TODO: remove this
+static bool gDebugVerbose = false;
 
-#if 0
-int gDvm__totalInstr = 0;
-int gDvm__gcInstr = 0;
-int gDvm__gcData = 0;
-int gDvm__gcSimpleData = 0;
-#endif
 
 /*
  * Selectively enable verbose debug logging -- use this to activate
@@ -3178,22 +3172,19 @@
     int insnIdx, VerifyError failure)
 {
     VerifyErrorRefType refType;
-    const u2* oldInsns = meth->insns + insnIdx;
-    u2 oldInsn = *oldInsns;
+    u2* oldInsns = (u2*) meth->insns + insnIdx;
     bool result = false;
 
     if (gDvm.optimizing)
         LOGD("Weird: RFI during dexopt?");
 
-    //LOGD("  was 0x%04x\n", oldInsn);
-    u2* newInsns = (u2*) meth->insns + insnIdx;
-
     /*
      * Generate the new instruction out of the old.
      *
      * First, make sure this is an instruction we're expecting to stomp on.
      */
-    switch (oldInsn & 0xff) {
+    Opcode opcode = dexOpcodeFromCodeUnit(*oldInsns);
+    switch (opcode) {
     case OP_CONST_CLASS:                // insn[1] == class ref, 2 bytes
     case OP_CHECK_CAST:
     case OP_INSTANCE_OF:
@@ -3250,11 +3241,12 @@
 
     default:
         /* could handle this in a generic way, but this is probably safer */
-        LOG_VFY("GLITCH: verifier asked to replace opcode 0x%02x\n",
-            oldInsn & 0xff);
+        LOG_VFY("GLITCH: verifier asked to replace opcode 0x%02x\n", opcode);
         goto bail;
     }
 
+    assert((dexGetFlagsFromOpcode(opcode) & kInstrCanThrow) != 0);
+
     /* write a NOP over the third code unit, if necessary */
     int width = dvmInsnGetWidth(insnFlags, insnIdx);
     switch (width) {
@@ -3262,8 +3254,7 @@
         /* nothing to do */
         break;
     case 3:
-        dvmDexChangeDex2(meth->clazz->pDvmDex, newInsns+2, OP_NOP);
-        //newInsns[2] = OP_NOP;
+        dvmDexChangeDex2(meth->clazz->pDvmDex, oldInsns+2, OP_NOP);
         break;
     default:
         /* whoops */
@@ -3275,8 +3266,7 @@
     /* encode the opcode, with the failure code in the high byte */
     u2 newVal = OP_THROW_VERIFICATION_ERROR |
         (failure << 8) | (refType << (8 + kVerifyErrorRefTypeShift));
-    //newInsns[0] = newVal;
-    dvmDexChangeDex2(meth->clazz->pDvmDex, newInsns, newVal);
+    dvmDexChangeDex2(meth->clazz->pDvmDex, oldInsns, newVal);
 
     result = true;