Tear down the code cache when it is full and restart from scratch.

Because the code cache may be wiped out after safe points now the patching of
inline cache for predicted chains is done through the compiler thread's work
queue.
diff --git a/vm/interp/Jit.c b/vm/interp/Jit.c
index ef0dab4..d31826a 100644
--- a/vm/interp/Jit.c
+++ b/vm/interp/Jit.c
@@ -386,7 +386,7 @@
             res = false;
             goto done;
         }
-        memset(pJitProfTable,gDvmJit.threshold,JIT_PROF_SIZE);
+        memset(pJitProfTable, gDvmJit.threshold, JIT_PROF_SIZE);
         for (i=0; i < gDvmJit.jitTableSize; i++) {
            pJitTable[i].u.info.chain = gDvmJit.jitTableSize;
         }
@@ -890,7 +890,7 @@
         if (gDvmJit.pJitEntryTable[idx].dPC == NULL) {
             /*
              * Initialize codeAddress and allocate the slot.  Must
-             * happen in this order (ince dPC is set, the entry is live.
+             * happen in this order (since dPC is set, the entry is live.
              */
             gDvmJit.pJitEntryTable[idx].dPC = dPC;
             gDvmJit.jitTableEntriesUsed++;
@@ -986,7 +986,7 @@
                 dvmJitStopTranslationRequests();
             } else if (slot->u.info.traceConstruction) {
                 /*
-                 * Trace already request in progress, but most likely it
+                 * Trace request already in progress, but most likely it
                  * aborted without cleaning up.  Assume the worst and
                  * mark trace head as untranslatable.  If we're wrong,
                  * the compiler thread will correct the entry when the
@@ -1121,6 +1121,24 @@
 }
 
 /*
+ * Reset the JitTable to the initial clean state.
+ */
+void dvmJitResetTable(void)
+{
+    JitEntry *jitEntry = gDvmJit.pJitEntryTable;
+    unsigned int size = gDvmJit.jitTableSize;
+    unsigned int i;
+
+    dvmLockMutex(&gDvmJit.tableLock);
+    memset((void *) jitEntry, 0, sizeof(JitEntry) * size);
+    for (i=0; i< size; i++) {
+        jitEntry[i].u.info.chain = size;  /* Initialize chain termination */
+    }
+    gDvmJit.jitTableEntriesUsed = 0;
+    dvmUnlockMutex(&gDvmJit.tableLock);
+}
+
+/*
  * Float/double conversion requires clamping to min and max of integer form.  If
  * target doesn't support this normally, use these.
  */