Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
123 changes: 10 additions & 113 deletions Modules/_testinternalcapi/interpreter.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@

int Test_EvalFrame_Resumes, Test_EvalFrame_Loads;

static int
stop_tracing_and_jit(PyThreadState *tstate, _PyInterpreterFrame *frame)

Check warning on line 15 in Modules/_testinternalcapi/interpreter.c

View workflow job for this annotation

GitHub Actions / Address sanitizer (ubuntu-24.04)

‘stop_tracing_and_jit’ defined but not used [-Wunused-function]

Check warning on line 15 in Modules/_testinternalcapi/interpreter.c

View workflow job for this annotation

GitHub Actions / Hypothesis tests on Ubuntu

‘stop_tracing_and_jit’ defined but not used [-Wunused-function]

Check warning on line 15 in Modules/_testinternalcapi/interpreter.c

View workflow job for this annotation

GitHub Actions / Cross build Linux

‘stop_tracing_and_jit’ defined but not used [-Wunused-function]

Check warning on line 15 in Modules/_testinternalcapi/interpreter.c

View workflow job for this annotation

GitHub Actions / Cross build Linux

‘stop_tracing_and_jit’ defined but not used [-Wunused-function]

Check warning on line 15 in Modules/_testinternalcapi/interpreter.c

View workflow job for this annotation

GitHub Actions / Ubuntu (free-threading) / build and test (ubuntu-24.04-arm)

‘stop_tracing_and_jit’ defined but not used [-Wunused-function]

Check warning on line 15 in Modules/_testinternalcapi/interpreter.c

View workflow job for this annotation

GitHub Actions / Ubuntu / build and test (ubuntu-24.04)

‘stop_tracing_and_jit’ defined but not used [-Wunused-function]

Check warning on line 15 in Modules/_testinternalcapi/interpreter.c

View workflow job for this annotation

GitHub Actions / Ubuntu / build and test (ubuntu-24.04-arm)

‘stop_tracing_and_jit’ defined but not used [-Wunused-function]

Check warning on line 15 in Modules/_testinternalcapi/interpreter.c

View workflow job for this annotation

GitHub Actions / Ubuntu (free-threading) / build and test (ubuntu-24.04)

‘stop_tracing_and_jit’ defined but not used [-Wunused-function]

Check warning on line 15 in Modules/_testinternalcapi/interpreter.c

View workflow job for this annotation

GitHub Actions / Ubuntu (bolt) / build and test (ubuntu-24.04)

‘stop_tracing_and_jit’ defined but not used [-Wunused-function]
{
(void)(tstate);
(void)(frame);
return 0;
}

_PyJitEntryFuncPtr _Py_jit_entry;

#if _Py_TAIL_CALL_INTERP
#include "test_targets.h"
#include "test_cases.c.h"
Expand Down Expand Up @@ -78,12 +88,6 @@
frame->previous = &entry.frame;
tstate->current_frame = frame;
entry.frame.localsplus[0] = PyStackRef_NULL;
#ifdef _Py_TIER2
if (tstate->current_executor != NULL) {
entry.frame.localsplus[0] = PyStackRef_FromPyObjectNew(tstate->current_executor);
tstate->current_executor = NULL;
}
#endif

/* support for generator.throw() */
if (throwflag) {
Expand Down Expand Up @@ -119,11 +123,6 @@
#endif
}

#if defined(_Py_TIER2) && !defined(_Py_JIT)
/* Tier 2 interpreter state */
_PyExecutorObject *current_executor = NULL;
const _PyUOpInstruction *next_uop = NULL;
#endif
#if _Py_TAIL_CALL_INTERP
# if Py_STATS
return _TAIL_CALL_start_frame(frame, NULL, tstate, NULL, instruction_funcptr_handler_table, 0, lastopcode);
Expand All @@ -136,108 +135,6 @@
#endif


#ifdef _Py_TIER2

// Tier 2 is also here!
enter_tier_two:

#ifdef _Py_JIT
assert(0);
#else

#undef LOAD_IP
#define LOAD_IP(UNUSED) (void)0

#ifdef Py_STATS
// Disable these macros that apply to Tier 1 stats when we are in Tier 2
#undef STAT_INC
#define STAT_INC(opname, name) ((void)0)
#undef STAT_DEC
#define STAT_DEC(opname, name) ((void)0)
#endif

#undef ENABLE_SPECIALIZATION
#define ENABLE_SPECIALIZATION 0
#undef ENABLE_SPECIALIZATION_FT
#define ENABLE_SPECIALIZATION_FT 0

; // dummy statement after a label, before a declaration
uint16_t uopcode;
#ifdef Py_STATS
int lastuop = 0;
uint64_t trace_uop_execution_counter = 0;
#endif

assert(next_uop->opcode == _START_EXECUTOR);
tier2_dispatch:
for (;;) {
uopcode = next_uop->opcode;
#ifdef Py_DEBUG
if (frame->lltrace >= 3) {
dump_stack(frame, stack_pointer);
if (next_uop->opcode == _START_EXECUTOR) {
printf("%4d uop: ", 0);
}
else {
printf("%4d uop: ", (int)(next_uop - current_executor->trace));
}
_PyUOpPrint(next_uop);
printf("\n");
}
#endif
next_uop++;
OPT_STAT_INC(uops_executed);
UOP_STAT_INC(uopcode, execution_count);
UOP_PAIR_INC(uopcode, lastuop);
#ifdef Py_STATS
trace_uop_execution_counter++;
((_PyUOpInstruction *)next_uop)[-1].execution_count++;
#endif

switch (uopcode) {

#include "executor_cases.c.h"

default:
#ifdef Py_DEBUG
{
printf("Unknown uop: ");
_PyUOpPrint(&next_uop[-1]);
printf(" @ %d\n", (int)(next_uop - current_executor->trace - 1));
Py_FatalError("Unknown uop");
}
#else
Py_UNREACHABLE();
#endif

}
}

jump_to_error_target:
#ifdef Py_DEBUG
if (frame->lltrace >= 2) {
printf("Error: [UOp ");
_PyUOpPrint(&next_uop[-1]);
printf(" @ %d -> %s]\n",
(int)(next_uop - current_executor->trace - 1),
_PyOpcode_OpName[frame->instr_ptr->op.code]);
}
#endif
assert(next_uop[-1].format == UOP_FORMAT_JUMP);
uint16_t target = uop_get_error_target(&next_uop[-1]);
next_uop = current_executor->trace + target;
goto tier2_dispatch;

jump_to_jump_target:
assert(next_uop[-1].format == UOP_FORMAT_JUMP);
target = uop_get_jump_target(&next_uop[-1]);
next_uop = current_executor->trace + target;
goto tier2_dispatch;

#endif // _Py_JIT

#endif // _Py_TIER2

early_exit:
assert(_PyErr_Occurred(tstate));
_Py_LeaveRecursiveCallPy(tstate);
Expand Down
Loading