Pad the page containing ARM code in the JIT code cache to work around a CPU bug.

Bug: 2501147

Verified with seeing the following line in the log. The 4096 number confirms
that the ARM handler code is using a full page.

D/dalvikvm(  369): 21 compilations using 4096 + 1288 bytes

Change-Id: I89e1473ce9a4353f58f740e1c86d358d3fec33b2
diff --git a/vm/compiler/Compiler.c b/vm/compiler/Compiler.c
index e9b30de..0380e02 100644
--- a/vm/compiler/Compiler.c
+++ b/vm/compiler/Compiler.c
@@ -156,6 +156,14 @@
            (void *) dvmCompilerTemplateStart,
            templateSize);
 
+    /*
+     * Work around a CPU bug by keeping the 32-bit ARM handler code in its own
+     * page.
+     */
+    if (dvmCompilerInstructionSet() == DALVIK_JIT_THUMB2) {
+        templateSize = (templateSize + 4095) & ~4095;
+    }
+
     gDvmJit.templateSize = templateSize;
     gDvmJit.codeCacheByteUsed = templateSize;
 
diff --git a/vm/interp/Jit.c b/vm/interp/Jit.c
index 185182f..1d7961e 100644
--- a/vm/interp/Jit.c
+++ b/vm/interp/Jit.c
@@ -409,23 +409,21 @@
             if (gDvmJit.pJitEntryTable[i].u.info.chain != gDvmJit.jitTableSize)
                 chains++;
         }
-        LOGD("size if %d, entries used is %d",
+        LOGD("JIT: table size is %d, entries used is %d",
              gDvmJit.jitTableSize,  gDvmJit.jitTableEntriesUsed);
-        LOGD(
-         "JIT: %d traces, %d slots, %d chains, %d thresh, %s",
-         hit, not_hit + hit, chains, gDvmJit.threshold,
-         gDvmJit.blockingMode ? "Blocking" : "Non-blocking");
+        LOGD("JIT: %d traces, %d slots, %d chains, %d thresh, %s",
+             hit, not_hit + hit, chains, gDvmJit.threshold,
+             gDvmJit.blockingMode ? "Blocking" : "Non-blocking");
 
 #if defined(JIT_STATS)
-        LOGD(
-         "JIT: Lookups: %d hits, %d misses; %d normal, %d punt",
-         gDvmJit.addrLookupsFound, gDvmJit.addrLookupsNotFound,
-         gDvmJit.normalExit, gDvmJit.puntExit);
-        LOGD(
-         "JIT: noChainExit: %d IC miss, %d interp callsite, %d switch overflow",
-         gDvmJit.noChainExit[kInlineCacheMiss],
-         gDvmJit.noChainExit[kCallsiteInterpreted],
-         gDvmJit.noChainExit[kSwitchOverflow]);
+        LOGD("JIT: Lookups: %d hits, %d misses; %d normal, %d punt",
+             gDvmJit.addrLookupsFound, gDvmJit.addrLookupsNotFound,
+             gDvmJit.normalExit, gDvmJit.puntExit);
+        LOGD("JIT: noChainExit: %d IC miss, %d interp callsite, "
+             "%d switch overflow",
+             gDvmJit.noChainExit[kInlineCacheMiss],
+             gDvmJit.noChainExit[kCallsiteInterpreted],
+             gDvmJit.noChainExit[kSwitchOverflow]);
 
         LOGD("JIT: Invoke: %d mono, %d poly, %d native, %d return",
              gDvmJit.invokeMonomorphic, gDvmJit.invokePolymorphic,