diff options
author | buzbee <buzbee@google.com> | 2010-12-15 16:32:35 -0800 |
---|---|---|
committer | buzbee <buzbee@google.com> | 2010-12-17 12:13:59 -0800 |
commit | 2e152baec01433de9c63633ebc6f4adf1cea3a87 (patch) | |
tree | ab5329129870bdd66296d776374d9e4bed05e8e6 /vm/compiler/Compiler.c | |
parent | 08c2f9fc9cd7c1cb36c31d6f15b4d13a7cc15432 (diff) | |
download | android_dalvik-2e152baec01433de9c63633ebc6f4adf1cea3a87.tar.gz android_dalvik-2e152baec01433de9c63633ebc6f4adf1cea3a87.tar.bz2 android_dalvik-2e152baec01433de9c63633ebc6f4adf1cea3a87.zip |
[JIT] Trace profiling support
In preparation for method compilation, this CL causes all traces to
include two entry points: profiling and non-profiling. For now, the
profiling entry will only be used if dalvik is run with -Xjitprofile,
and largely works like it did before. The difference is that profiling
support no longer requires the "assert" build - it's always there now.
This will enable us to do a form of sampling profiling of
traces in order to identify hot methods or hot trace groups,
while keeping the overhead low by only switching profiling on periodically.
To turn the periodic profiling on and off, we simply unchain all existing
translations and set the appropriate global profile state. The underlying
translation lookup and chaining utilties will examine the profile state to
determine which entry point to use (i.e. - profiling or non-profiling) while
the traces naturally rechain during further execution.
Change-Id: I9ee33e69e33869b9fab3a57e88f9bc524175172b
Diffstat (limited to 'vm/compiler/Compiler.c')
-rw-r--r-- | vm/compiler/Compiler.c | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/vm/compiler/Compiler.c b/vm/compiler/Compiler.c index c8ff62ee3..adb58dd4b 100644 --- a/vm/compiler/Compiler.c +++ b/vm/compiler/Compiler.c @@ -332,6 +332,7 @@ static bool compilerThreadStartup(void) { JitEntry *pJitTable = NULL; unsigned char *pJitProfTable = NULL; + JitTraceProfCounters *pJitTraceProfCounters = NULL; unsigned int i; if (!dvmCompilerArchInit()) @@ -398,6 +399,15 @@ static bool compilerThreadStartup(void) /* Is chain field wide enough for termination pattern? */ assert(pJitTable[0].u.info.chain == gDvmJit.jitTableSize); + /* Allocate the trace profiling structure */ + pJitTraceProfCounters = (JitTraceProfCounters*) + calloc(1, sizeof(*pJitTraceProfCounters)); + if (!pJitTraceProfCounters) { + LOGE("jit trace prof counters allocation failed\n"); + dvmUnlockMutex(&gDvmJit.tableLock); + goto fail; + } + gDvmJit.pJitEntryTable = pJitTable; gDvmJit.jitTableMask = gDvmJit.jitTableSize - 1; gDvmJit.jitTableEntriesUsed = 0; @@ -409,6 +419,7 @@ static bool compilerThreadStartup(void) */ gDvmJit.pProfTable = dvmDebuggerOrProfilerActive() ? NULL : pJitProfTable; gDvmJit.pProfTableCopy = pJitProfTable; + gDvmJit.pJitTraceProfCounters = pJitTraceProfCounters; dvmUnlockMutex(&gDvmJit.tableLock); /* Signal running threads to refresh their cached pJitTable pointers */ @@ -620,27 +631,19 @@ static void *compilerThreadStart(void *arg) if (gDvmJit.haltCompilerThread) { LOGD("Compiler shutdown in progress - discarding request"); } else if (!gDvmJit.codeCacheFull) { - bool compileOK = false; jmp_buf jmpBuf; work.bailPtr = &jmpBuf; bool aborted = setjmp(jmpBuf); if (!aborted) { - compileOK = dvmCompilerDoWork(&work); - } - if (aborted || !compileOK) { -#if 0 // for x86 JIT testing - dvmJitSetCodeAddr(work.pc, - dvmCompilerGetInterpretTemplate(), - work.result.instructionSet); -#endif - dvmCompilerArenaReset(); - } else if (!work.result.discardResult && - work.result.codeAddress) { - /* Make sure that proper code addr is installed */ - assert(work.result.codeAddress != NULL); - dvmJitSetCodeAddr(work.pc, work.result.codeAddress, - work.result.instructionSet); + bool codeCompiled = dvmCompilerDoWork(&work); + if (codeCompiled && !work.result.discardResult && + work.result.codeAddress) { + dvmJitSetCodeAddr(work.pc, work.result.codeAddress, + work.result.instructionSet, + work.result.profileCodeSize); + } } + dvmCompilerArenaReset(); } free(work.info); #if defined(WITH_JIT_TUNING) @@ -697,7 +700,8 @@ void dvmCompilerShutdown(void) gDvmJit.pProfTable = NULL; gDvmJit.pProfTableCopy = NULL; - if (gDvm.verboseShutdown) { + if (gDvm.verboseShutdown || + gDvmJit.profileMode == kTraceProfilingContinuous) { dvmCompilerDumpStats(); while (gDvmJit.compilerQueueLength) sleep(5); |