summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Droettboom <mdboom@gmail.com>2024-03-28 22:23:08 (GMT)
committerGitHub <noreply@github.com>2024-03-28 22:23:08 (GMT)
commit26d328b2ba26374fb8d9ffe8215ecef7c5e3f7a2 (patch)
tree67be3e047975a457cacc7bb96d0329067f555b06
parent14f1ca7d5363386163839b31ce987423daecc3de (diff)
downloadcpython-26d328b2ba26374fb8d9ffe8215ecef7c5e3f7a2.zip
cpython-26d328b2ba26374fb8d9ffe8215ecef7c5e3f7a2.tar.gz
cpython-26d328b2ba26374fb8d9ffe8215ecef7c5e3f7a2.tar.bz2
GH-117121: Add pystats to JIT builds (GH-117346)
-rw-r--r--Python/ceval.c2
-rw-r--r--Python/ceval_macros.h2
-rw-r--r--Tools/jit/template.c7
3 files changed, 10 insertions, 1 deletions
diff --git a/Python/ceval.c b/Python/ceval.c
index cd51011..d34db61 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -990,7 +990,7 @@ enter_tier_two:
#define DPRINTF(level, ...)
#endif
- OPT_STAT_INC(traces_executed);
+ ; // dummy statement after a label, before a declaration
uint16_t uopcode;
#ifdef Py_STATS
uint64_t trace_uop_execution_counter = 0;
diff --git a/Python/ceval_macros.h b/Python/ceval_macros.h
index f2536ed..1194c11 100644
--- a/Python/ceval_macros.h
+++ b/Python/ceval_macros.h
@@ -392,6 +392,7 @@ stack_pointer = _PyFrame_GetStackPointer(frame);
#ifdef _Py_JIT
#define GOTO_TIER_TWO(EXECUTOR) \
do { \
+ OPT_STAT_INC(traces_executed); \
jit_func jitted = (EXECUTOR)->jit_code; \
next_instr = jitted(frame, stack_pointer, tstate); \
Py_DECREF(tstate->previous_executor); \
@@ -406,6 +407,7 @@ do { \
#else
#define GOTO_TIER_TWO(EXECUTOR) \
do { \
+ OPT_STAT_INC(traces_executed); \
next_uop = (EXECUTOR)->trace; \
assert(next_uop->opcode == _START_EXECUTOR || next_uop->opcode == _COLD_EXIT); \
goto enter_tier_two; \
diff --git a/Tools/jit/template.c b/Tools/jit/template.c
index 9b4fc2a..f8be4d7 100644
--- a/Tools/jit/template.c
+++ b/Tools/jit/template.c
@@ -43,6 +43,7 @@
#undef GOTO_TIER_TWO
#define GOTO_TIER_TWO(EXECUTOR) \
do { \
+ OPT_STAT_INC(traces_executed); \
__attribute__((musttail)) \
return ((jit_func)((EXECUTOR)->jit_code))(frame, stack_pointer, tstate); \
} while (0)
@@ -88,6 +89,10 @@ _JIT_ENTRY(_PyInterpreterFrame *frame, PyObject **stack_pointer, PyThreadState *
PATCH_VALUE(uint64_t, _operand, _JIT_OPERAND)
PATCH_VALUE(uint32_t, _target, _JIT_TARGET)
PATCH_VALUE(uint16_t, _exit_index, _JIT_EXIT_INDEX)
+
+ OPT_STAT_INC(uops_executed);
+ UOP_STAT_INC(opcode, execution_count);
+
// The actual instruction definitions (only one will be used):
if (opcode == _JUMP_TO_TOP) {
CHECK_EVAL_BREAKER();
@@ -106,9 +111,11 @@ error_tier_two:
GOTO_TIER_ONE(NULL);
exit_to_tier1:
tstate->previous_executor = (PyObject *)current_executor;
+ UOP_STAT_INC(opcode, miss);
GOTO_TIER_ONE(_PyCode_CODE(_PyFrame_GetCode(frame)) + _target);
exit_to_trace:
{
+ UOP_STAT_INC(opcode, miss);
_PyExitData *exit = &current_executor->exits[_exit_index];
Py_INCREF(exit->executor);
tstate->previous_executor = (PyObject *)current_executor;