OSDN Git Service

Pad the page containing ARM code in the JIT code cache to work around a CPU bug.
authorBen Cheng <bccheng@android.com>
Wed, 10 Mar 2010 21:12:55 +0000 (13:12 -0800)
committerBen Cheng <bccheng@android.com>
Wed, 10 Mar 2010 21:18:35 +0000 (13:18 -0800)
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

vm/compiler/Compiler.c
vm/interp/Jit.c

index e9b30de..0380e02 100644 (file)
@@ -156,6 +156,14 @@ bool dvmCompilerSetupCodeCache(void)
            (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;
 
index 185182f..1d7961e 100644 (file)
@@ -409,23 +409,21 @@ void dvmJitStats()
             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,