gh-129989: Properly disable tailcall interp in configure (GH-129991)

Co-authored-by: Zanie Blue <contact@zanie.dev>
This commit is contained in:
Ken Jin 2025-02-16 03:01:24 +08:00 committed by GitHub
parent c26bed1160
commit 359c7dde3b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 287 additions and 286 deletions

View file

@ -304,7 +304,7 @@ class TestGeneratedCases(unittest.TestCase):
"""
output = """
TARGET(OP) {
#if defined(Py_TAIL_CALL_INTERP)
#if Py_TAIL_CALL_INTERP
int opcode = OP;
(void)(opcode);
#endif
@ -326,7 +326,7 @@ class TestGeneratedCases(unittest.TestCase):
"""
output = """
TARGET(OP) {
#if defined(Py_TAIL_CALL_INTERP)
#if Py_TAIL_CALL_INTERP
int opcode = OP;
(void)(opcode);
#endif
@ -351,7 +351,7 @@ class TestGeneratedCases(unittest.TestCase):
"""
output = """
TARGET(OP) {
#if defined(Py_TAIL_CALL_INTERP)
#if Py_TAIL_CALL_INTERP
int opcode = OP;
(void)(opcode);
#endif
@ -377,7 +377,7 @@ class TestGeneratedCases(unittest.TestCase):
"""
output = """
TARGET(OP) {
#if defined(Py_TAIL_CALL_INTERP)
#if Py_TAIL_CALL_INTERP
int opcode = OP;
(void)(opcode);
#endif
@ -404,7 +404,7 @@ class TestGeneratedCases(unittest.TestCase):
"""
output = """
TARGET(OP) {
#if defined(Py_TAIL_CALL_INTERP)
#if Py_TAIL_CALL_INTERP
int opcode = OP;
(void)(opcode);
#endif
@ -434,7 +434,7 @@ class TestGeneratedCases(unittest.TestCase):
"""
output = """
TARGET(OP) {
#if defined(Py_TAIL_CALL_INTERP)
#if Py_TAIL_CALL_INTERP
int opcode = OP;
(void)(opcode);
#endif
@ -466,7 +466,7 @@ class TestGeneratedCases(unittest.TestCase):
"""
output = """
TARGET(OP1) {
#if defined(Py_TAIL_CALL_INTERP)
#if Py_TAIL_CALL_INTERP
int opcode = OP1;
(void)(opcode);
#endif
@ -481,7 +481,7 @@ class TestGeneratedCases(unittest.TestCase):
}
TARGET(OP3) {
#if defined(Py_TAIL_CALL_INTERP)
#if Py_TAIL_CALL_INTERP
int opcode = OP3;
(void)(opcode);
#endif
@ -519,7 +519,7 @@ class TestGeneratedCases(unittest.TestCase):
"""
output = """
TARGET(A) {
#if defined(Py_TAIL_CALL_INTERP)
#if Py_TAIL_CALL_INTERP
int opcode = A;
(void)(opcode);
#endif
@ -540,7 +540,7 @@ class TestGeneratedCases(unittest.TestCase):
}
TARGET(B) {
#if defined(Py_TAIL_CALL_INTERP)
#if Py_TAIL_CALL_INTERP
int opcode = B;
(void)(opcode);
#endif
@ -581,7 +581,7 @@ class TestGeneratedCases(unittest.TestCase):
"""
output = """
TARGET(OP) {
#if defined(Py_TAIL_CALL_INTERP)
#if Py_TAIL_CALL_INTERP
int opcode = OP;
(void)(opcode);
#endif
@ -604,7 +604,7 @@ class TestGeneratedCases(unittest.TestCase):
"""
output = """
TARGET(OP) {
#if defined(Py_TAIL_CALL_INTERP)
#if Py_TAIL_CALL_INTERP
int opcode = OP;
(void)(opcode);
#endif
@ -631,7 +631,7 @@ class TestGeneratedCases(unittest.TestCase):
"""
output = """
TARGET(OP) {
#if defined(Py_TAIL_CALL_INTERP)
#if Py_TAIL_CALL_INTERP
int opcode = OP;
(void)(opcode);
#endif
@ -666,7 +666,7 @@ class TestGeneratedCases(unittest.TestCase):
"""
output = """
TARGET(OP) {
#if defined(Py_TAIL_CALL_INTERP)
#if Py_TAIL_CALL_INTERP
int opcode = OP;
(void)(opcode);
#endif
@ -697,7 +697,7 @@ class TestGeneratedCases(unittest.TestCase):
"""
output = """
TARGET(OP) {
#if defined(Py_TAIL_CALL_INTERP)
#if Py_TAIL_CALL_INTERP
int opcode = OP;
(void)(opcode);
#endif
@ -728,7 +728,7 @@ class TestGeneratedCases(unittest.TestCase):
"""
output = """
TARGET(OP) {
#if defined(Py_TAIL_CALL_INTERP)
#if Py_TAIL_CALL_INTERP
int opcode = OP;
(void)(opcode);
#endif
@ -763,7 +763,7 @@ class TestGeneratedCases(unittest.TestCase):
"""
output = """
TARGET(OP) {
#if defined(Py_TAIL_CALL_INTERP)
#if Py_TAIL_CALL_INTERP
int opcode = OP;
(void)(opcode);
#endif
@ -804,7 +804,7 @@ class TestGeneratedCases(unittest.TestCase):
}
TARGET(OP1) {
#if defined(Py_TAIL_CALL_INTERP)
#if Py_TAIL_CALL_INTERP
int opcode = OP1;
(void)(opcode);
#endif
@ -826,7 +826,7 @@ class TestGeneratedCases(unittest.TestCase):
}
TARGET(OP3) {
#if defined(Py_TAIL_CALL_INTERP)
#if Py_TAIL_CALL_INTERP
int opcode = OP3;
(void)(opcode);
#endif
@ -861,7 +861,7 @@ class TestGeneratedCases(unittest.TestCase):
"""
output = """
TARGET(OP) {
#if defined(Py_TAIL_CALL_INTERP)
#if Py_TAIL_CALL_INTERP
int opcode = OP;
(void)(opcode);
#endif
@ -887,7 +887,7 @@ class TestGeneratedCases(unittest.TestCase):
"""
output = """
TARGET(OP1) {
#if defined(Py_TAIL_CALL_INTERP)
#if Py_TAIL_CALL_INTERP
int opcode = OP1;
(void)(opcode);
#endif
@ -910,7 +910,7 @@ class TestGeneratedCases(unittest.TestCase):
"""
output = """
TARGET(OP1) {
#if defined(Py_TAIL_CALL_INTERP)
#if Py_TAIL_CALL_INTERP
int opcode = OP1;
(void)(opcode);
#endif
@ -936,7 +936,7 @@ class TestGeneratedCases(unittest.TestCase):
"""
output = """
TARGET(OP1) {
#if defined(Py_TAIL_CALL_INTERP)
#if Py_TAIL_CALL_INTERP
int opcode = OP1;
(void)(opcode);
#endif
@ -947,7 +947,7 @@ class TestGeneratedCases(unittest.TestCase):
}
TARGET(OP2) {
#if defined(Py_TAIL_CALL_INTERP)
#if Py_TAIL_CALL_INTERP
int opcode = OP2;
(void)(opcode);
#endif
@ -968,7 +968,7 @@ class TestGeneratedCases(unittest.TestCase):
"""
output = """
TARGET(OP) {
#if defined(Py_TAIL_CALL_INTERP)
#if Py_TAIL_CALL_INTERP
int opcode = OP;
(void)(opcode);
#endif
@ -995,7 +995,7 @@ class TestGeneratedCases(unittest.TestCase):
"""
output = """
TARGET(OP) {
#if defined(Py_TAIL_CALL_INTERP)
#if Py_TAIL_CALL_INTERP
int opcode = OP;
(void)(opcode);
#endif
@ -1027,7 +1027,7 @@ class TestGeneratedCases(unittest.TestCase):
"""
output = """
TARGET(OP) {
#if defined(Py_TAIL_CALL_INTERP)
#if Py_TAIL_CALL_INTERP
int opcode = OP;
(void)(opcode);
#endif
@ -1055,7 +1055,7 @@ class TestGeneratedCases(unittest.TestCase):
"""
output = """
TARGET(OP) {
#if defined(Py_TAIL_CALL_INTERP)
#if Py_TAIL_CALL_INTERP
int opcode = OP;
(void)(opcode);
#endif
@ -1085,7 +1085,7 @@ class TestGeneratedCases(unittest.TestCase):
"""
output = """
TARGET(OP) {
#if defined(Py_TAIL_CALL_INTERP)
#if Py_TAIL_CALL_INTERP
int opcode = OP;
(void)(opcode);
#endif
@ -1130,7 +1130,7 @@ class TestGeneratedCases(unittest.TestCase):
"""
output = """
TARGET(M) {
#if defined(Py_TAIL_CALL_INTERP)
#if Py_TAIL_CALL_INTERP
int opcode = M;
(void)(opcode);
#endif
@ -1178,7 +1178,7 @@ class TestGeneratedCases(unittest.TestCase):
"""
output = """
TARGET(M) {
#if defined(Py_TAIL_CALL_INTERP)
#if Py_TAIL_CALL_INTERP
int opcode = M;
(void)(opcode);
#endif
@ -1215,7 +1215,7 @@ class TestGeneratedCases(unittest.TestCase):
"""
output = """
TARGET(OP) {
#if defined(Py_TAIL_CALL_INTERP)
#if Py_TAIL_CALL_INTERP
int opcode = OP;
(void)(opcode);
#endif
@ -1240,7 +1240,7 @@ class TestGeneratedCases(unittest.TestCase):
"""
output = """
TARGET(M) {
#if defined(Py_TAIL_CALL_INTERP)
#if Py_TAIL_CALL_INTERP
int opcode = M;
(void)(opcode);
#endif
@ -1261,7 +1261,7 @@ class TestGeneratedCases(unittest.TestCase):
"""
output = """
TARGET(OP) {
#if defined(Py_TAIL_CALL_INTERP)
#if Py_TAIL_CALL_INTERP
int opcode = OP;
(void)(opcode);
#endif
@ -1283,7 +1283,7 @@ class TestGeneratedCases(unittest.TestCase):
"""
output = """
TARGET(M) {
#if defined(Py_TAIL_CALL_INTERP)
#if Py_TAIL_CALL_INTERP
int opcode = M;
(void)(opcode);
#endif
@ -1323,7 +1323,7 @@ class TestGeneratedCases(unittest.TestCase):
"""
output = """
TARGET(OP) {
#if defined(Py_TAIL_CALL_INTERP)
#if Py_TAIL_CALL_INTERP
int opcode = OP;
(void)(opcode);
#endif
@ -1349,7 +1349,7 @@ class TestGeneratedCases(unittest.TestCase):
"""
output = """
TARGET(OP) {
#if defined(Py_TAIL_CALL_INTERP)
#if Py_TAIL_CALL_INTERP
int opcode = OP;
(void)(opcode);
#endif
@ -1391,7 +1391,7 @@ class TestGeneratedCases(unittest.TestCase):
"""
output = """
TARGET(INST) {
#if defined(Py_TAIL_CALL_INTERP)
#if Py_TAIL_CALL_INTERP
int opcode = INST;
(void)(opcode);
#endif
@ -1421,7 +1421,7 @@ class TestGeneratedCases(unittest.TestCase):
"""
output = """
TARGET(TEST) {
#if defined(Py_TAIL_CALL_INTERP)
#if Py_TAIL_CALL_INTERP
int opcode = TEST;
(void)(opcode);
#endif
@ -1465,7 +1465,7 @@ class TestGeneratedCases(unittest.TestCase):
"""
output = """
TARGET(TEST) {
#if defined(Py_TAIL_CALL_INTERP)
#if Py_TAIL_CALL_INTERP
int opcode = TEST;
(void)(opcode);
#endif
@ -1508,7 +1508,7 @@ class TestGeneratedCases(unittest.TestCase):
"""
output = """
TARGET(TEST) {
#if defined(Py_TAIL_CALL_INTERP)
#if Py_TAIL_CALL_INTERP
int opcode = TEST;
(void)(opcode);
#endif
@ -1560,7 +1560,7 @@ class TestGeneratedCases(unittest.TestCase):
"""
output = """
TARGET(TEST) {
#if defined(Py_TAIL_CALL_INTERP)
#if Py_TAIL_CALL_INTERP
int opcode = TEST;
(void)(opcode);
#endif
@ -1612,7 +1612,7 @@ class TestGeneratedCases(unittest.TestCase):
output = """
TARGET(TEST) {
#if defined(Py_TAIL_CALL_INTERP)
#if Py_TAIL_CALL_INTERP
int opcode = TEST;
(void)(opcode);
#endif
@ -1657,7 +1657,7 @@ class TestGeneratedCases(unittest.TestCase):
"""
output = """
TARGET(OP1) {
#if defined(Py_TAIL_CALL_INTERP)
#if Py_TAIL_CALL_INTERP
int opcode = OP1;
(void)(opcode);
#endif
@ -1668,7 +1668,7 @@ class TestGeneratedCases(unittest.TestCase):
}
TARGET(OP2) {
#if defined(Py_TAIL_CALL_INTERP)
#if Py_TAIL_CALL_INTERP
int opcode = OP2;
(void)(opcode);
#endif
@ -1730,7 +1730,7 @@ class TestGeneratedCases(unittest.TestCase):
output = """
TARGET(BALANCED) {
#if defined(Py_TAIL_CALL_INTERP)
#if Py_TAIL_CALL_INTERP
int opcode = BALANCED;
(void)(opcode);
#endif
@ -1756,7 +1756,7 @@ class TestGeneratedCases(unittest.TestCase):
output = """
TARGET(BALANCED) {
#if defined(Py_TAIL_CALL_INTERP)
#if Py_TAIL_CALL_INTERP
int opcode = BALANCED;
(void)(opcode);
#endif
@ -1778,7 +1778,7 @@ class TestGeneratedCases(unittest.TestCase):
output = """
TARGET(BALANCED) {
#if defined(Py_TAIL_CALL_INTERP)
#if Py_TAIL_CALL_INTERP
int opcode = BALANCED;
(void)(opcode);
#endif
@ -1803,7 +1803,7 @@ class TestGeneratedCases(unittest.TestCase):
output = """
TARGET(BALANCED) {
#if defined(Py_TAIL_CALL_INTERP)
#if Py_TAIL_CALL_INTERP
int opcode = BALANCED;
(void)(opcode);
#endif
@ -1829,7 +1829,7 @@ class TestGeneratedCases(unittest.TestCase):
output = """
TARGET(OP) {
#if defined(Py_TAIL_CALL_INTERP)
#if Py_TAIL_CALL_INTERP
int opcode = OP;
(void)(opcode);
#endif
@ -1868,7 +1868,7 @@ class TestGeneratedCases(unittest.TestCase):
"""
output = """
TARGET(OP) {
#if defined(Py_TAIL_CALL_INTERP)
#if Py_TAIL_CALL_INTERP
int opcode = OP;
(void)(opcode);
#endif
@ -1906,7 +1906,7 @@ class TestGeneratedCases(unittest.TestCase):
"""
output = """
TARGET(OP) {
#if defined(Py_TAIL_CALL_INTERP)
#if Py_TAIL_CALL_INTERP
int opcode = OP;
(void)(opcode);
#endif
@ -1941,7 +1941,7 @@ class TestGeneratedCases(unittest.TestCase):
"""
output = """
TARGET(OP) {
#if defined(Py_TAIL_CALL_INTERP)
#if Py_TAIL_CALL_INTERP
int opcode = OP;
(void)(opcode);
#endif

View file

@ -0,0 +1 @@
Fix a bug where the tailcall interpreter was enabled when ``--without-tail-call-interp`` was provided to the configure script.

View file

@ -5234,7 +5234,7 @@ dummy_func(
}
#endif
RELOAD_STACK();
#ifdef Py_TAIL_CALL_INTERP
#if Py_TAIL_CALL_INTERP
int opcode;
#endif
DISPATCH();
@ -5278,7 +5278,7 @@ dummy_func(
assert(!_PyErr_Occurred(tstate));
#endif
RELOAD_STACK();
#ifdef Py_TAIL_CALL_INTERP
#if Py_TAIL_CALL_INTERP
int opcode;
#endif
DISPATCH();

View file

@ -779,7 +779,7 @@ _PyObjectArray_Free(PyObject **array, PyObject **scratch)
/* This setting is reversed below following _PyEval_EvalFrameDefault */
#endif
#ifdef Py_TAIL_CALL_INTERP
#if Py_TAIL_CALL_INTERP
#include "opcode_targets.h"
#include "generated_cases.c.h"
#endif
@ -790,7 +790,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
_Py_EnsureTstateNotNULL(tstate);
CALL_STAT_INC(pyeval_calls);
#if USE_COMPUTED_GOTOS && !defined(Py_TAIL_CALL_INTERP)
#if USE_COMPUTED_GOTOS && !Py_TAIL_CALL_INTERP
/* Import the static jump table */
#include "opcode_targets.h"
#endif
@ -863,7 +863,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
next_instr = frame->instr_ptr;
monitor_throw(tstate, frame, next_instr);
stack_pointer = _PyFrame_GetStackPointer(frame);
#ifdef Py_TAIL_CALL_INTERP
#if Py_TAIL_CALL_INTERP
return _TAIL_CALL_error(frame, stack_pointer, tstate, next_instr, 0);
#else
goto error;
@ -876,7 +876,7 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
const _PyUOpInstruction *next_uop = NULL;
#endif
#ifdef Py_TAIL_CALL_INTERP
#if Py_TAIL_CALL_INTERP
return _TAIL_CALL_start_frame(frame, NULL, tstate, NULL, 0);
#else
goto start_frame;

View file

@ -73,7 +73,7 @@
#define TAIL_CALL_PARAMS _PyInterpreterFrame *frame, _PyStackRef *stack_pointer, PyThreadState *tstate, _Py_CODEUNIT *next_instr, int oparg
#define TAIL_CALL_ARGS frame, stack_pointer, tstate, next_instr, oparg
#ifdef Py_TAIL_CALL_INTERP
#if Py_TAIL_CALL_INTERP
// Note: [[clang::musttail]] works for GCC 15, but not __attribute__((musttail)) at the moment.
# define Py_MUSTTAIL [[clang::musttail]]
# define Py_PRESERVE_NONE_CC __attribute__((preserve_none))

File diff suppressed because it is too large Load diff

View file

@ -1,4 +1,4 @@
#ifndef Py_TAIL_CALL_INTERP
#if !Py_TAIL_CALL_INTERP
static void *opcode_targets[256] = {
&&TARGET_CACHE,
&&TARGET_BINARY_SLICE,

View file

@ -26,7 +26,7 @@ def write_opcode_targets(analysis: Analysis, out: CWriter) -> None:
for name, op in analysis.opmap.items():
if op < 256:
targets[op] = f"&&TARGET_{name},\n"
out.emit("#ifndef Py_TAIL_CALL_INTERP\n")
out.emit("#if !Py_TAIL_CALL_INTERP\n")
out.emit("static void *opcode_targets[256] = {\n")
for target in targets:
out.emit(target)

View file

@ -229,7 +229,7 @@ def generate_tier1_cases(
out.emit(f"TARGET({name}) {{\n")
# We need to ifdef it because this breaks platforms
# without computed gotos/tail calling.
out.emit(f"#if defined(Py_TAIL_CALL_INTERP)\n")
out.emit(f"#if Py_TAIL_CALL_INTERP\n")
out.emit(f"int opcode = {name};\n")
out.emit(f"(void)(opcode);\n")
out.emit(f"#endif\n")