Collect more JIT stats in the assert build.
New stuff includes breakdown of callsite types (ie monomorphic vs polymorphic
vs monoporphic resolved to native), total time spent in JIT'ing, and average
JIT time per compilation.
Example output:
D/dalvikvm( 840): 4042 compilations using 1976 + 329108 bytes
D/dalvikvm( 840): Compiler arena uses 10 blocks (8100 bytes each)
D/dalvikvm( 840): Compiler work queue length is 0/36
D/dalvikvm( 840): size if 8192, entries used is 4137
D/dalvikvm( 840): JIT: 4137 traces, 8192 slots, 1099 chains, 40 thresh, Non-blocking
D/dalvikvm( 840): JIT: Lookups: 1128780 hits, 168564 misses; 179520 normal, 6 punt
D/dalvikvm( 840): JIT: noChainExit: 528464 IC miss, 194708 interp callsite, 0 switch overflow
D/dalvikvm( 840): JIT: Invoke: 507 mono, 988 poly, 72 native, 1038 return
D/dalvikvm( 840): JIT: Total compilation time: 2342 ms
D/dalvikvm( 840): JIT: Avg unit compilation time: 579 us
D/dalvikvm( 840): JIT: 3357 Translation chains, 97 interp stubs
D/dalvikvm( 840): dalvik.vm.jit.op = 0-2,4-5,7-8,a-c,e-16,19-1a,1c-23,26,28-29,2b-2f,31-3d,44-4b,4d-51,60,62-63,68-69,70-72,76-78,7b,81-82,84,87,89,8d-93,95-98,a1,a3,a6,a8-a9,b0-b3,b5-b6,bb-bf,c6-c8,d0,d2-d6,d8,da-e2,ee-f0,f2-fb,
D/dalvikvm( 840): Code size stats: 50666/105126 (compiled/total Dalvik), 329108 (native)
diff --git a/vm/compiler/Compiler.c b/vm/compiler/Compiler.c
index de5d4cc..13749ac 100644
--- a/vm/compiler/Compiler.c
+++ b/vm/compiler/Compiler.c
@@ -457,6 +457,9 @@
do {
CompilerWorkOrder work = workDequeue();
dvmUnlockMutex(&gDvmJit.compilerLock);
+#if defined(JIT_STATS)
+ u8 startTime = dvmGetRelativeTimeUsec();
+#endif
/*
* Check whether there is a suspend request on me. This
* is necessary to allow a clean shutdown.
@@ -486,6 +489,9 @@
}
}
free(work.info);
+#if defined(JIT_STATS)
+ gDvmJit.jitTime += dvmGetRelativeTimeUsec() - startTime;
+#endif
dvmLockMutex(&gDvmJit.compilerLock);
} while (workQueueLength() != 0);
}
diff --git a/vm/compiler/codegen/arm/CodegenDriver.c b/vm/compiler/codegen/arm/CodegenDriver.c
index 78c52ee..a496152 100644
--- a/vm/compiler/codegen/arm/CodegenDriver.c
+++ b/vm/compiler/codegen/arm/CodegenDriver.c
@@ -840,7 +840,7 @@
static void genReturnCommon(CompilationUnit *cUnit, MIR *mir)
{
genDispatchToHandler(cUnit, TEMPLATE_RETURN);
-#if defined(INVOKE_STATS)
+#if defined(JIT_STATS)
gDvmJit.returnOp++;
#endif
int dPC = (int) (cUnit->method->insns + mir->offset);
@@ -1010,13 +1010,13 @@
*/
if (dvmIsNativeMethod(calleeMethod)) {
genDispatchToHandler(cUnit, TEMPLATE_INVOKE_METHOD_NATIVE);
-#if defined(INVOKE_STATS)
+#if defined(JIT_STATS)
gDvmJit.invokeNative++;
#endif
} else {
genDispatchToHandler(cUnit, TEMPLATE_INVOKE_METHOD_CHAIN);
-#if defined(INVOKE_STATS)
- gDvmJit.invokeChain++;
+#if defined(JIT_STATS)
+ gDvmJit.invokeMonomorphic++;
#endif
/* Branch to the chaining cell */
genUnconditionalBranch(cUnit, &labelList[bb->taken->id]);
@@ -1137,8 +1137,8 @@
* r4PC = callsiteDPC,
*/
genDispatchToHandler(cUnit, TEMPLATE_INVOKE_METHOD_NO_OPT);
-#if defined(INVOKE_STATS)
- gDvmJit.invokePredictedChain++;
+#if defined(JIT_STATS)
+ gDvmJit.invokePolymorphic++;
#endif
/* Handle exceptions using the interpreter */
genTrap(cUnit, mir->offset, pcrLabel);
@@ -2829,8 +2829,8 @@
* r4PC = callsiteDPC,
*/
genDispatchToHandler(cUnit, TEMPLATE_INVOKE_METHOD_NO_OPT);
-#if defined(INVOKE_STATS)
- gDvmJit.invokePredictedChain++;
+#if defined(JIT_STATS)
+ gDvmJit.invokePolymorphic++;
#endif
/* Handle exceptions using the interpreter */
genTrap(cUnit, mir->offset, pcrLabel);
@@ -3823,7 +3823,7 @@
jitToInterpEntries.dvmJitToInterpNoChain), r2);
opRegReg(cUnit, kOpAdd, r1, r1);
opRegRegReg(cUnit, kOpAdd, r4PC, r0, r1);
-#if defined(EXIT_STATS)
+#if defined(JIT_STATS)
loadConstant(cUnit, r0, kSwitchOverflow);
#endif
opReg(cUnit, kOpBlx, r2);
diff --git a/vm/compiler/template/armv5te/TEMPLATE_INVOKE_METHOD_NATIVE.S b/vm/compiler/template/armv5te/TEMPLATE_INVOKE_METHOD_NATIVE.S
index be14a5c..0dbd6c0 100644
--- a/vm/compiler/template/armv5te/TEMPLATE_INVOKE_METHOD_NATIVE.S
+++ b/vm/compiler/template/armv5te/TEMPLATE_INVOKE_METHOD_NATIVE.S
@@ -64,7 +64,7 @@
@ continue executing the next instruction through the interpreter
ldr r1, .LdvmJitToInterpTraceSelectNoChain @ defined in footer.S
add rPC, r0, #6 @ reconstruct new rPC (advance 6 bytes)
-#if defined(EXIT_STATS)
+#if defined(JIT_STATS)
mov r0, #kCallsiteInterpreted
#endif
mov pc, r1
diff --git a/vm/compiler/template/armv5te/TEMPLATE_INVOKE_METHOD_NO_OPT.S b/vm/compiler/template/armv5te/TEMPLATE_INVOKE_METHOD_NO_OPT.S
index c08e556..facce51 100644
--- a/vm/compiler/template/armv5te/TEMPLATE_INVOKE_METHOD_NO_OPT.S
+++ b/vm/compiler/template/armv5te/TEMPLATE_INVOKE_METHOD_NO_OPT.S
@@ -48,7 +48,7 @@
str rFP, [r2, #offThread_curFrame] @ self->curFrame = newFp
@ Start executing the callee
-#if defined(EXIT_STATS)
+#if defined(JIT_STATS)
mov r0, #kInlineCacheMiss
#endif
mov pc, r10 @ dvmJitToInterpTraceSelectNoChain
diff --git a/vm/compiler/template/armv5te/TEMPLATE_MONITOR_ENTER.S b/vm/compiler/template/armv5te/TEMPLATE_MONITOR_ENTER.S
index bf073cb..b1ab44e 100644
--- a/vm/compiler/template/armv5te/TEMPLATE_MONITOR_ENTER.S
+++ b/vm/compiler/template/armv5te/TEMPLATE_MONITOR_ENTER.S
@@ -19,7 +19,7 @@
ldr r2, .LdvmJitToInterpNoChain
str r0, [rGLUE, #offGlue_pJitProfTable]
@ Bail to interpreter - no chain [note - r4 still contains rPC]
-#if defined(EXIT_STATS)
+#if defined(JIT_STATS)
mov r0, #kHeavyweightMonitor
#endif
bx r2
diff --git a/vm/compiler/template/armv5te/TEMPLATE_MONITOR_ENTER_DEBUG.S b/vm/compiler/template/armv5te/TEMPLATE_MONITOR_ENTER_DEBUG.S
index 31f57c4..6acf992 100644
--- a/vm/compiler/template/armv5te/TEMPLATE_MONITOR_ENTER_DEBUG.S
+++ b/vm/compiler/template/armv5te/TEMPLATE_MONITOR_ENTER_DEBUG.S
@@ -26,7 +26,7 @@
bx r2
1:
@ Bail to interpreter - no chain [note - r4 still contains rPC]
-#if defined(EXIT_STATS)
+#if defined(JIT_STATS)
mov r0, #kHeavyweightMonitor
#endif
ldr pc, .LdvmJitToInterpNoChain
diff --git a/vm/compiler/template/armv5te/TEMPLATE_RETURN.S b/vm/compiler/template/armv5te/TEMPLATE_RETURN.S
index aa9884a..502c493 100644
--- a/vm/compiler/template/armv5te/TEMPLATE_RETURN.S
+++ b/vm/compiler/template/armv5te/TEMPLATE_RETURN.S
@@ -38,7 +38,7 @@
str r9, [r3, #offThread_inJitCodeCache] @ in code cache or not
cmp r9, #0 @ chaining cell exists?
blxne r9 @ jump to the chaining cell
-#if defined(EXIT_STATS)
+#if defined(JIT_STATS)
mov r0, #kCallsiteInterpreted
#endif
mov pc, r1 @ callsite is interpreted
diff --git a/vm/compiler/template/armv5te/footer.S b/vm/compiler/template/armv5te/footer.S
index 8937495..8d1c8c2 100644
--- a/vm/compiler/template/armv5te/footer.S
+++ b/vm/compiler/template/armv5te/footer.S
@@ -50,7 +50,7 @@
@ continue executing the next instruction through the interpreter
ldr r1, .LdvmJitToInterpTraceSelectNoChain @ defined in footer.S
add rPC, r0, #6 @ reconstruct new rPC (advance 6 bytes)
-#if defined(EXIT_STATS)
+#if defined(JIT_STATS)
mov r0, #kCallsiteInterpreted
#endif
mov pc, r1
diff --git a/vm/compiler/template/out/CompilerTemplateAsm-armv5te-vfp.S b/vm/compiler/template/out/CompilerTemplateAsm-armv5te-vfp.S
index ac3455a..9c1e788 100644
--- a/vm/compiler/template/out/CompilerTemplateAsm-armv5te-vfp.S
+++ b/vm/compiler/template/out/CompilerTemplateAsm-armv5te-vfp.S
@@ -212,7 +212,7 @@
str r9, [r3, #offThread_inJitCodeCache] @ in code cache or not
cmp r9, #0 @ chaining cell exists?
blxne r9 @ jump to the chaining cell
-#if defined(EXIT_STATS)
+#if defined(JIT_STATS)
mov r0, #kCallsiteInterpreted
#endif
mov pc, r1 @ callsite is interpreted
@@ -278,7 +278,7 @@
str rFP, [r2, #offThread_curFrame] @ self->curFrame = newFp
@ Start executing the callee
-#if defined(EXIT_STATS)
+#if defined(JIT_STATS)
mov r0, #kInlineCacheMiss
#endif
mov pc, r10 @ dvmJitToInterpTraceSelectNoChain
@@ -455,7 +455,7 @@
@ continue executing the next instruction through the interpreter
ldr r1, .LdvmJitToInterpTraceSelectNoChain @ defined in footer.S
add rPC, r0, #6 @ reconstruct new rPC (advance 6 bytes)
-#if defined(EXIT_STATS)
+#if defined(JIT_STATS)
mov r0, #kCallsiteInterpreted
#endif
mov pc, r1
@@ -1393,7 +1393,7 @@
ldr r2, .LdvmJitToInterpNoChain
str r0, [rGLUE, #offGlue_pJitProfTable]
@ Bail to interpreter - no chain [note - r4 still contains rPC]
-#if defined(EXIT_STATS)
+#if defined(JIT_STATS)
mov r0, #kHeavyweightMonitor
#endif
bx r2
@@ -1432,7 +1432,7 @@
bx r2
1:
@ Bail to interpreter - no chain [note - r4 still contains rPC]
-#if defined(EXIT_STATS)
+#if defined(JIT_STATS)
mov r0, #kHeavyweightMonitor
#endif
ldr pc, .LdvmJitToInterpNoChain
@@ -1491,7 +1491,7 @@
@ continue executing the next instruction through the interpreter
ldr r1, .LdvmJitToInterpTraceSelectNoChain @ defined in footer.S
add rPC, r0, #6 @ reconstruct new rPC (advance 6 bytes)
-#if defined(EXIT_STATS)
+#if defined(JIT_STATS)
mov r0, #kCallsiteInterpreted
#endif
mov pc, r1
diff --git a/vm/compiler/template/out/CompilerTemplateAsm-armv5te.S b/vm/compiler/template/out/CompilerTemplateAsm-armv5te.S
index 4863141..e73d940 100644
--- a/vm/compiler/template/out/CompilerTemplateAsm-armv5te.S
+++ b/vm/compiler/template/out/CompilerTemplateAsm-armv5te.S
@@ -212,7 +212,7 @@
str r9, [r3, #offThread_inJitCodeCache] @ in code cache or not
cmp r9, #0 @ chaining cell exists?
blxne r9 @ jump to the chaining cell
-#if defined(EXIT_STATS)
+#if defined(JIT_STATS)
mov r0, #kCallsiteInterpreted
#endif
mov pc, r1 @ callsite is interpreted
@@ -278,7 +278,7 @@
str rFP, [r2, #offThread_curFrame] @ self->curFrame = newFp
@ Start executing the callee
-#if defined(EXIT_STATS)
+#if defined(JIT_STATS)
mov r0, #kInlineCacheMiss
#endif
mov pc, r10 @ dvmJitToInterpTraceSelectNoChain
@@ -455,7 +455,7 @@
@ continue executing the next instruction through the interpreter
ldr r1, .LdvmJitToInterpTraceSelectNoChain @ defined in footer.S
add rPC, r0, #6 @ reconstruct new rPC (advance 6 bytes)
-#if defined(EXIT_STATS)
+#if defined(JIT_STATS)
mov r0, #kCallsiteInterpreted
#endif
mov pc, r1
@@ -1121,7 +1121,7 @@
ldr r2, .LdvmJitToInterpNoChain
str r0, [rGLUE, #offGlue_pJitProfTable]
@ Bail to interpreter - no chain [note - r4 still contains rPC]
-#if defined(EXIT_STATS)
+#if defined(JIT_STATS)
mov r0, #kHeavyweightMonitor
#endif
bx r2
@@ -1160,7 +1160,7 @@
bx r2
1:
@ Bail to interpreter - no chain [note - r4 still contains rPC]
-#if defined(EXIT_STATS)
+#if defined(JIT_STATS)
mov r0, #kHeavyweightMonitor
#endif
ldr pc, .LdvmJitToInterpNoChain
@@ -1219,7 +1219,7 @@
@ continue executing the next instruction through the interpreter
ldr r1, .LdvmJitToInterpTraceSelectNoChain @ defined in footer.S
add rPC, r0, #6 @ reconstruct new rPC (advance 6 bytes)
-#if defined(EXIT_STATS)
+#if defined(JIT_STATS)
mov r0, #kCallsiteInterpreted
#endif
mov pc, r1
diff --git a/vm/compiler/template/out/CompilerTemplateAsm-armv7-a.S b/vm/compiler/template/out/CompilerTemplateAsm-armv7-a.S
index 0b06826..737ea5f 100644
--- a/vm/compiler/template/out/CompilerTemplateAsm-armv7-a.S
+++ b/vm/compiler/template/out/CompilerTemplateAsm-armv7-a.S
@@ -212,7 +212,7 @@
str r9, [r3, #offThread_inJitCodeCache] @ in code cache or not
cmp r9, #0 @ chaining cell exists?
blxne r9 @ jump to the chaining cell
-#if defined(EXIT_STATS)
+#if defined(JIT_STATS)
mov r0, #kCallsiteInterpreted
#endif
mov pc, r1 @ callsite is interpreted
@@ -278,7 +278,7 @@
str rFP, [r2, #offThread_curFrame] @ self->curFrame = newFp
@ Start executing the callee
-#if defined(EXIT_STATS)
+#if defined(JIT_STATS)
mov r0, #kInlineCacheMiss
#endif
mov pc, r10 @ dvmJitToInterpTraceSelectNoChain
@@ -455,7 +455,7 @@
@ continue executing the next instruction through the interpreter
ldr r1, .LdvmJitToInterpTraceSelectNoChain @ defined in footer.S
add rPC, r0, #6 @ reconstruct new rPC (advance 6 bytes)
-#if defined(EXIT_STATS)
+#if defined(JIT_STATS)
mov r0, #kCallsiteInterpreted
#endif
mov pc, r1
@@ -1393,7 +1393,7 @@
ldr r2, .LdvmJitToInterpNoChain
str r0, [rGLUE, #offGlue_pJitProfTable]
@ Bail to interpreter - no chain [note - r4 still contains rPC]
-#if defined(EXIT_STATS)
+#if defined(JIT_STATS)
mov r0, #kHeavyweightMonitor
#endif
bx r2
@@ -1432,7 +1432,7 @@
bx r2
1:
@ Bail to interpreter - no chain [note - r4 still contains rPC]
-#if defined(EXIT_STATS)
+#if defined(JIT_STATS)
mov r0, #kHeavyweightMonitor
#endif
ldr pc, .LdvmJitToInterpNoChain
@@ -1491,7 +1491,7 @@
@ continue executing the next instruction through the interpreter
ldr r1, .LdvmJitToInterpTraceSelectNoChain @ defined in footer.S
add rPC, r0, #6 @ reconstruct new rPC (advance 6 bytes)
-#if defined(EXIT_STATS)
+#if defined(JIT_STATS)
mov r0, #kCallsiteInterpreted
#endif
mov pc, r1