Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a721698

Browse files
committed
SF patch #884022: dynamic execution profiling vs opcode prediction
(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.
1 parent ce9b471 commit a721698

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

Python/ceval.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,9 +645,18 @@ eval_frame(PyFrameObject *f)
645645
646646
A successful prediction saves a trip through the eval-loop including
647647
its two unpredictable branches, the HASARG test and the switch-case.
648+
649+
If collecting opcode statistics, turn off prediction so that
650+
statistics are accurately maintained (the predictions bypass
651+
the opcode frequency counter updates).
648652
*/
649653

654+
#ifdef DYNAMIC_EXECUTION_PROFILE
655+
#define PREDICT(op) if (0) goto PRED_##op
656+
#else
650657
#define PREDICT(op) if (*next_instr == op) goto PRED_##op
658+
#endif
659+
651660
#define PREDICTED(op) PRED_##op: next_instr++
652661
#define PREDICTED_WITH_ARG(op) PRED_##op: oparg = (next_instr[2]<<8) + \
653662
next_instr[1]; next_instr += 3

0 commit comments

Comments
 (0)