]> granicus.if.org Git - python/commitdiff
SF patch #884022: dynamic execution profiling vs opcode prediction
authorRaymond Hettinger <python@rcn.com>
Sun, 8 Feb 2004 19:59:27 +0000 (19:59 +0000)
committerRaymond Hettinger <python@rcn.com>
Sun, 8 Feb 2004 19:59:27 +0000 (19:59 +0000)
(Contributed by Andrew I MacIntyre.)

disables opcode prediction when dynamic execution
profiling is in effect, so the profiling counters at
the top of the main interpreter loop in eval_frame()
are updated for each opcode.

Python/ceval.c

index c6e04702443e23e13c042b864aeb7d184a32bfd3..f2d79e77dfb72aaf1cdfc67a5edd2a91b19e3bc5 100644 (file)
@@ -645,9 +645,18 @@ eval_frame(PyFrameObject *f)
 
        A successful prediction saves a trip through the eval-loop including
        its two unpredictable branches, the HASARG test and the switch-case.
+
+        If collecting opcode statistics, turn off prediction so that 
+       statistics are accurately maintained (the predictions bypass 
+       the opcode frequency counter updates).
 */
 
+#ifdef DYNAMIC_EXECUTION_PROFILE
+#define PREDICT(op)            if (0) goto PRED_##op
+#else
 #define PREDICT(op)            if (*next_instr == op) goto PRED_##op
+#endif
+
 #define PREDICTED(op)          PRED_##op: next_instr++
 #define PREDICTED_WITH_ARG(op) PRED_##op: oparg = (next_instr[2]<<8) + \
                                next_instr[1]; next_instr += 3