From 72621c9d3c175b0f9b239de5b0bcd83c7e5984e8 Mon Sep 17 00:00:00 2001 From: Ben Cheng Date: Wed, 10 Mar 2010 13:12:55 -0800 Subject: [PATCH] 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 --- vm/compiler/Compiler.c | 8 ++++++++ vm/interp/Jit.c | 26 ++++++++++++-------------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/vm/compiler/Compiler.c b/vm/compiler/Compiler.c index e9b30de2b..0380e02d2 100644 --- a/vm/compiler/Compiler.c +++ b/vm/compiler/Compiler.c @@ -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; diff --git a/vm/interp/Jit.c b/vm/interp/Jit.c index 185182f53..1d7961e18 100644 --- a/vm/interp/Jit.c +++ b/vm/interp/Jit.c @@ -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, -- 2.11.0