Defer reporting of certain verifier failures.

The verifier currently reports all failures immediately.  Certain failures,
such as the failure to resolve a method, or the determination that access
to a field is not allowed, are supposed to deferred until the first time
that executing code does something that could cause the resolution.

With this change, several kinds of verification failures are deferred.
This is done by making a writable copy of the bytecode and replacing the
failing instruction with an "always throw" opcode.

Gory details:
- Added throw-verification-error instruction.  Implemented in "portable"
  and ARM interpreters.  x86 uses portable form through stub.
- Added a function that creates a copy of a DexCode area and makes the
  bytecodes writable.
- Added code that replaces a single instruction with an "always throw".
- Replaced runtime check for abstract/interface in new-instance with a
  check at verification time.
- Added a test to exercise the deferred error mechanism.
- Minor cleanups (replaced tab, bad valgrind command, ...).
diff --git a/vm/oo/Class.c b/vm/oo/Class.c
index 59a6365..6369d9b 100644
--- a/vm/oo/Class.c
+++ b/vm/oo/Class.c
@@ -1962,9 +1962,11 @@
         int directMethodCount = clazz->directMethodCount;
         clazz->directMethods = NULL;
         clazz->directMethodCount = -1;
+        dvmLinearReadWrite(clazz->classLoader, directMethods);
         for (i = 0; i < directMethodCount; i++) {
             freeMethodInnards(&directMethods[i]);
         }
+        dvmLinearReadOnly(clazz->classLoader, directMethods);
         dvmLinearFree(clazz->classLoader, directMethods);
     }
     if (clazz->virtualMethods != NULL) {
@@ -1972,9 +1974,11 @@
         int virtualMethodCount = clazz->virtualMethodCount;
         clazz->virtualMethodCount = -1;
         clazz->virtualMethods = NULL;
+        dvmLinearReadWrite(clazz->classLoader, virtualMethods);
         for (i = 0; i < virtualMethodCount; i++) {
             freeMethodInnards(&virtualMethods[i]);
         }
+        dvmLinearReadOnly(clazz->classLoader, virtualMethods);
         dvmLinearFree(clazz->classLoader, virtualMethods);
     }
 
@@ -2023,6 +2027,14 @@
         dvmFreeRegisterMap((RegisterMap*) pMap);
         meth->registerMap = NULL;
     }
+
+    /*
+     * We may have copied the instructions.
+     */
+    if (IS_METHOD_FLAG_SET(meth, METHOD_ISWRITABLE)) {
+        DexCode* methodDexCode = (DexCode*) dvmGetMethodCode(meth);
+        dvmLinearFree(meth->clazz->classLoader, methodDexCode);
+    }
 }
 
 /*
@@ -2099,6 +2111,55 @@
 }
 
 /*
+ * We usually map bytecode directly out of the DEX file, which is mapped
+ * shared read-only.  If we want to be able to modify it, we have to make
+ * a new copy.
+ *
+ * Once copied, the code will be in the LinearAlloc region, which may be
+ * marked read-only.
+ *
+ * The bytecode instructions are embedded inside a DexCode structure, so we
+ * need to copy all of that.  (The dvmGetMethodCode function backs up the
+ * instruction pointer to find the start of the DexCode.)
+ */
+void dvmMakeCodeReadWrite(Method* meth)
+{
+    DexCode* methodDexCode = (DexCode*) dvmGetMethodCode(meth);
+
+    if (IS_METHOD_FLAG_SET(meth, METHOD_ISWRITABLE)) {
+        dvmLinearReadWrite(meth->clazz->classLoader, methodDexCode);
+        return;
+    }
+
+    assert(!dvmIsNativeMethod(meth) && !dvmIsAbstractMethod(meth));
+
+    size_t dexCodeSize = dexGetDexCodeSize(methodDexCode);
+    LOGD("Making a copy of %s.%s code (%d bytes)\n",
+        meth->clazz->descriptor, meth->name, dexCodeSize);
+
+    DexCode* newCode =
+        (DexCode*) dvmLinearAlloc(meth->clazz->classLoader, dexCodeSize);
+    memcpy(newCode, methodDexCode, dexCodeSize);
+
+    meth->insns = newCode->insns;
+    SET_METHOD_FLAG(meth, METHOD_ISWRITABLE);
+}
+
+/*
+ * Mark the bytecode read-only.
+ *
+ * If the contents of the DexCode haven't actually changed, we could revert
+ * to the original shared page.
+ */
+void dvmMakeCodeReadOnly(Method* meth)
+{
+    DexCode* methodDexCode = (DexCode*) dvmGetMethodCode(meth);
+    LOGV("+++ marking %p read-only\n", methodDexCode);
+    dvmLinearReadOnly(meth->clazz->classLoader, methodDexCode);
+}
+
+
+/*
  * jniArgInfo (32-bit int) layout:
  *   SRRRHHHH HHHHHHHH HHHHHHHH HHHHHHHH
  *