Skip to content

Commit 949b5ec

Browse files
gh-142913: Remove JIT interpreter for interpreter generator tests (GH-143944)
1 parent 3199cfc commit 949b5ec

File tree

2 files changed

+13
-113
lines changed

2 files changed

+13
-113
lines changed

Modules/_testinternalcapi/interpreter.c

Lines changed: 12 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,18 @@
1111

1212
int Test_EvalFrame_Resumes, Test_EvalFrame_Loads;
1313

14+
#ifdef _Py_TIER2
15+
static int
16+
stop_tracing_and_jit(PyThreadState *tstate, _PyInterpreterFrame *frame)
17+
{
18+
(void)(tstate);
19+
(void)(frame);
20+
return 0;
21+
}
22+
#endif
23+
24+
_PyJitEntryFuncPtr _Py_jit_entry;
25+
1426
#if _Py_TAIL_CALL_INTERP
1527
#include "test_targets.h"
1628
#include "test_cases.c.h"
@@ -78,12 +90,6 @@ Test_EvalFrame(PyThreadState *tstate, _PyInterpreterFrame *frame, int throwflag)
7890
frame->previous = &entry.frame;
7991
tstate->current_frame = frame;
8092
entry.frame.localsplus[0] = PyStackRef_NULL;
81-
#ifdef _Py_TIER2
82-
if (tstate->current_executor != NULL) {
83-
entry.frame.localsplus[0] = PyStackRef_FromPyObjectNew(tstate->current_executor);
84-
tstate->current_executor = NULL;
85-
}
86-
#endif
8793

8894
/* support for generator.throw() */
8995
if (throwflag) {
@@ -119,11 +125,6 @@ Test_EvalFrame(PyThreadState *tstate, _PyInterpreterFrame *frame, int throwflag)
119125
#endif
120126
}
121127

122-
#if defined(_Py_TIER2) && !defined(_Py_JIT)
123-
/* Tier 2 interpreter state */
124-
_PyExecutorObject *current_executor = NULL;
125-
const _PyUOpInstruction *next_uop = NULL;
126-
#endif
127128
#if _Py_TAIL_CALL_INTERP
128129
# if Py_STATS
129130
return _TAIL_CALL_start_frame(frame, NULL, tstate, NULL, instruction_funcptr_handler_table, 0, lastopcode);
@@ -136,108 +137,6 @@ Test_EvalFrame(PyThreadState *tstate, _PyInterpreterFrame *frame, int throwflag)
136137
#endif
137138

138139

139-
#ifdef _Py_TIER2
140-
141-
// Tier 2 is also here!
142-
enter_tier_two:
143-
144-
#ifdef _Py_JIT
145-
assert(0);
146-
#else
147-
148-
#undef LOAD_IP
149-
#define LOAD_IP(UNUSED) (void)0
150-
151-
#ifdef Py_STATS
152-
// Disable these macros that apply to Tier 1 stats when we are in Tier 2
153-
#undef STAT_INC
154-
#define STAT_INC(opname, name) ((void)0)
155-
#undef STAT_DEC
156-
#define STAT_DEC(opname, name) ((void)0)
157-
#endif
158-
159-
#undef ENABLE_SPECIALIZATION
160-
#define ENABLE_SPECIALIZATION 0
161-
#undef ENABLE_SPECIALIZATION_FT
162-
#define ENABLE_SPECIALIZATION_FT 0
163-
164-
; // dummy statement after a label, before a declaration
165-
uint16_t uopcode;
166-
#ifdef Py_STATS
167-
int lastuop = 0;
168-
uint64_t trace_uop_execution_counter = 0;
169-
#endif
170-
171-
assert(next_uop->opcode == _START_EXECUTOR);
172-
tier2_dispatch:
173-
for (;;) {
174-
uopcode = next_uop->opcode;
175-
#ifdef Py_DEBUG
176-
if (frame->lltrace >= 3) {
177-
dump_stack(frame, stack_pointer);
178-
if (next_uop->opcode == _START_EXECUTOR) {
179-
printf("%4d uop: ", 0);
180-
}
181-
else {
182-
printf("%4d uop: ", (int)(next_uop - current_executor->trace));
183-
}
184-
_PyUOpPrint(next_uop);
185-
printf("\n");
186-
}
187-
#endif
188-
next_uop++;
189-
OPT_STAT_INC(uops_executed);
190-
UOP_STAT_INC(uopcode, execution_count);
191-
UOP_PAIR_INC(uopcode, lastuop);
192-
#ifdef Py_STATS
193-
trace_uop_execution_counter++;
194-
((_PyUOpInstruction *)next_uop)[-1].execution_count++;
195-
#endif
196-
197-
switch (uopcode) {
198-
199-
#include "executor_cases.c.h"
200-
201-
default:
202-
#ifdef Py_DEBUG
203-
{
204-
printf("Unknown uop: ");
205-
_PyUOpPrint(&next_uop[-1]);
206-
printf(" @ %d\n", (int)(next_uop - current_executor->trace - 1));
207-
Py_FatalError("Unknown uop");
208-
}
209-
#else
210-
Py_UNREACHABLE();
211-
#endif
212-
213-
}
214-
}
215-
216-
jump_to_error_target:
217-
#ifdef Py_DEBUG
218-
if (frame->lltrace >= 2) {
219-
printf("Error: [UOp ");
220-
_PyUOpPrint(&next_uop[-1]);
221-
printf(" @ %d -> %s]\n",
222-
(int)(next_uop - current_executor->trace - 1),
223-
_PyOpcode_OpName[frame->instr_ptr->op.code]);
224-
}
225-
#endif
226-
assert(next_uop[-1].format == UOP_FORMAT_JUMP);
227-
uint16_t target = uop_get_error_target(&next_uop[-1]);
228-
next_uop = current_executor->trace + target;
229-
goto tier2_dispatch;
230-
231-
jump_to_jump_target:
232-
assert(next_uop[-1].format == UOP_FORMAT_JUMP);
233-
target = uop_get_jump_target(&next_uop[-1]);
234-
next_uop = current_executor->trace + target;
235-
goto tier2_dispatch;
236-
237-
#endif // _Py_JIT
238-
239-
#endif // _Py_TIER2
240-
241140
early_exit:
242141
assert(_PyErr_Occurred(tstate));
243142
_Py_LeaveRecursiveCallPy(tstate);

Tools/c-analyzer/cpython/_parser.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ def format_tsv_lines(lines):
8383
'Python/opcode_targets.h',
8484
'Modules/_testinternalcapi/test_targets.h',
8585
'Modules/_testinternalcapi/test_cases.c.h',
86+
'Modules/_testinternalcapi/interpreter.c',
8687
# XXX: Throws errors if PY_VERSION_HEX is not mocked out
8788
'Modules/clinic/_testclinic_depr.c.h',
8889

0 commit comments

Comments
 (0)