Skip to content

Commit 26d328b

Browse files
authored
GH-117121: Add pystats to JIT builds (GH-117346)
1 parent 14f1ca7 commit 26d328b

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

Python/ceval.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -990,7 +990,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
990990
#define DPRINTF(level, ...)
991991
#endif
992992

993-
OPT_STAT_INC(traces_executed);
993+
; // dummy statement after a label, before a declaration
994994
uint16_t uopcode;
995995
#ifdef Py_STATS
996996
uint64_t trace_uop_execution_counter = 0;

Python/ceval_macros.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,7 @@ stack_pointer = _PyFrame_GetStackPointer(frame);
392392
#ifdef _Py_JIT
393393
#define GOTO_TIER_TWO(EXECUTOR) \
394394
do { \
395+
OPT_STAT_INC(traces_executed); \
395396
jit_func jitted = (EXECUTOR)->jit_code; \
396397
next_instr = jitted(frame, stack_pointer, tstate); \
397398
Py_DECREF(tstate->previous_executor); \
@@ -406,6 +407,7 @@ do { \
406407
#else
407408
#define GOTO_TIER_TWO(EXECUTOR) \
408409
do { \
410+
OPT_STAT_INC(traces_executed); \
409411
next_uop = (EXECUTOR)->trace; \
410412
assert(next_uop->opcode == _START_EXECUTOR || next_uop->opcode == _COLD_EXIT); \
411413
goto enter_tier_two; \

Tools/jit/template.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
#undef GOTO_TIER_TWO
4444
#define GOTO_TIER_TWO(EXECUTOR) \
4545
do { \
46+
OPT_STAT_INC(traces_executed); \
4647
__attribute__((musttail)) \
4748
return ((jit_func)((EXECUTOR)->jit_code))(frame, stack_pointer, tstate); \
4849
} while (0)
@@ -88,6 +89,10 @@ _JIT_ENTRY(_PyInterpreterFrame *frame, PyObject **stack_pointer, PyThreadState *
8889
PATCH_VALUE(uint64_t, _operand, _JIT_OPERAND)
8990
PATCH_VALUE(uint32_t, _target, _JIT_TARGET)
9091
PATCH_VALUE(uint16_t, _exit_index, _JIT_EXIT_INDEX)
92+
93+
OPT_STAT_INC(uops_executed);
94+
UOP_STAT_INC(opcode, execution_count);
95+
9196
// The actual instruction definitions (only one will be used):
9297
if (opcode == _JUMP_TO_TOP) {
9398
CHECK_EVAL_BREAKER();
@@ -106,9 +111,11 @@ _JIT_ENTRY(_PyInterpreterFrame *frame, PyObject **stack_pointer, PyThreadState *
106111
GOTO_TIER_ONE(NULL);
107112
exit_to_tier1:
108113
tstate->previous_executor = (PyObject *)current_executor;
114+
UOP_STAT_INC(opcode, miss);
109115
GOTO_TIER_ONE(_PyCode_CODE(_PyFrame_GetCode(frame)) + _target);
110116
exit_to_trace:
111117
{
118+
UOP_STAT_INC(opcode, miss);
112119
_PyExitData *exit = &current_executor->exits[_exit_index];
113120
Py_INCREF(exit->executor);
114121
tstate->previous_executor = (PyObject *)current_executor;

0 commit comments

Comments
 (0)