summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorMark Shannon <mark@hotpy.org>2023-09-04 10:36:57 (GMT)
committerGitHub <noreply@github.com>2023-09-04 10:36:57 (GMT)
commit5a3672cb39544de72963cccde9799313bab14d07 (patch)
treecbe84705916dd4bbfb369139be6df6b1a18414e9 /Python
parent074ac1f72e392a576516639f650bac0519d1cb52 (diff)
downloadcpython-5a3672cb39544de72963cccde9799313bab14d07.zip
cpython-5a3672cb39544de72963cccde9799313bab14d07.tar.gz
cpython-5a3672cb39544de72963cccde9799313bab14d07.tar.bz2
GH-108614: Remove `TIER_ONE` and `TIER_TWO` from `_PUSH_FRAME` (GH-108725)
Diffstat (limited to 'Python')
-rw-r--r--Python/bytecodes.c20
-rw-r--r--Python/executor.c1
-rw-r--r--Python/executor_cases.c.h20
-rw-r--r--Python/generated_cases.c.h40
4 files changed, 44 insertions, 37 deletions
diff --git a/Python/bytecodes.c b/Python/bytecodes.c
index 7f39839..fae1da3 100644
--- a/Python/bytecodes.c
+++ b/Python/bytecodes.c
@@ -2974,6 +2974,7 @@ dummy_func(
PyFunctionObject *func = (PyFunctionObject *)callable;
PyCodeObject *code = (PyCodeObject *)func->func_code;
DEOPT_IF(!_PyThreadState_HasStackSpace(tstate, code->co_framesize), CALL);
+ DEOPT_IF(tstate->py_recursion_remaining <= 1, CALL);
}
op(_INIT_CALL_PY_EXACT_ARGS, (callable, self_or_null, args[oparg] -- new_frame: _PyInterpreterFrame*)) {
@@ -2998,18 +2999,19 @@ dummy_func(
// Eventually this should be the only occurrence of this code.
frame->return_offset = 0;
assert(tstate->interp->eval_frame == NULL);
- _PyFrame_SetStackPointer(frame, stack_pointer);
+ STORE_SP();
new_frame->previous = frame;
CALL_STAT_INC(inlined_py_calls);
frame = tstate->current_frame = new_frame;
- #if TIER_ONE
- goto start_frame;
- #endif
- #if TIER_TWO
- ERROR_IF(_Py_EnterRecursivePy(tstate), exit_unwind);
- stack_pointer = _PyFrame_GetStackPointer(frame);
- ip_offset = (_Py_CODEUNIT *)_PyFrame_GetCode(frame)->co_code_adaptive;
- #endif
+ tstate->py_recursion_remaining--;
+ LOAD_SP();
+ LOAD_IP();
+#if LLTRACE && TIER_ONE
+ lltrace = maybe_lltrace_resume_frame(frame, &entry_frame, GLOBALS());
+ if (lltrace < 0) {
+ goto exit_unwind;
+ }
+#endif
}
macro(CALL_BOUND_METHOD_EXACT_ARGS) =
diff --git a/Python/executor.c b/Python/executor.c
index 9b3262e..ac91042 100644
--- a/Python/executor.c
+++ b/Python/executor.c
@@ -109,7 +109,6 @@ pop_3_error:
pop_2_error:
STACK_SHRINK(1);
pop_1_error:
-pop_1_exit_unwind:
STACK_SHRINK(1);
error:
// On ERROR_IF we return NULL as the frame.
diff --git a/Python/executor_cases.c.h b/Python/executor_cases.c.h
index e63a36d..0d5606f 100644
--- a/Python/executor_cases.c.h
+++ b/Python/executor_cases.c.h
@@ -2245,6 +2245,7 @@
PyFunctionObject *func = (PyFunctionObject *)callable;
PyCodeObject *code = (PyCodeObject *)func->func_code;
DEOPT_IF(!_PyThreadState_HasStackSpace(tstate, code->co_framesize), CALL);
+ DEOPT_IF(tstate->py_recursion_remaining <= 1, CALL);
break;
}
@@ -2281,18 +2282,19 @@
// Eventually this should be the only occurrence of this code.
frame->return_offset = 0;
assert(tstate->interp->eval_frame == NULL);
- _PyFrame_SetStackPointer(frame, stack_pointer);
+ STORE_SP();
new_frame->previous = frame;
CALL_STAT_INC(inlined_py_calls);
frame = tstate->current_frame = new_frame;
- #if TIER_ONE
- goto start_frame;
- #endif
- #if TIER_TWO
- if (_Py_EnterRecursivePy(tstate)) goto pop_1_exit_unwind;
- stack_pointer = _PyFrame_GetStackPointer(frame);
- ip_offset = (_Py_CODEUNIT *)_PyFrame_GetCode(frame)->co_code_adaptive;
- #endif
+ tstate->py_recursion_remaining--;
+ LOAD_SP();
+ LOAD_IP();
+#if LLTRACE && TIER_ONE
+ lltrace = maybe_lltrace_resume_frame(frame, &entry_frame, GLOBALS());
+ if (lltrace < 0) {
+ goto exit_unwind;
+ }
+#endif
break;
}
diff --git a/Python/generated_cases.c.h b/Python/generated_cases.c.h
index a7bf20b..34cea84 100644
--- a/Python/generated_cases.c.h
+++ b/Python/generated_cases.c.h
@@ -3843,6 +3843,7 @@
PyFunctionObject *func = (PyFunctionObject *)callable;
PyCodeObject *code = (PyCodeObject *)func->func_code;
DEOPT_IF(!_PyThreadState_HasStackSpace(tstate, code->co_framesize), CALL);
+ DEOPT_IF(tstate->py_recursion_remaining <= 1, CALL);
}
// _INIT_CALL_PY_EXACT_ARGS
args = stack_pointer - oparg;
@@ -3878,18 +3879,19 @@
// Eventually this should be the only occurrence of this code.
frame->return_offset = 0;
assert(tstate->interp->eval_frame == NULL);
- _PyFrame_SetStackPointer(frame, stack_pointer);
+ STORE_SP();
new_frame->previous = frame;
CALL_STAT_INC(inlined_py_calls);
frame = tstate->current_frame = new_frame;
- #if TIER_ONE
- goto start_frame;
- #endif
- #if TIER_TWO
- if (_Py_EnterRecursivePy(tstate)) goto pop_1_exit_unwind;
- stack_pointer = _PyFrame_GetStackPointer(frame);
- ip_offset = (_Py_CODEUNIT *)_PyFrame_GetCode(frame)->co_code_adaptive;
- #endif
+ tstate->py_recursion_remaining--;
+ LOAD_SP();
+ LOAD_IP();
+ #if LLTRACE && TIER_ONE
+ lltrace = maybe_lltrace_resume_frame(frame, &entry_frame, GLOBALS());
+ if (lltrace < 0) {
+ goto exit_unwind;
+ }
+ #endif
}
DISPATCH();
}
@@ -3920,6 +3922,7 @@
PyFunctionObject *func = (PyFunctionObject *)callable;
PyCodeObject *code = (PyCodeObject *)func->func_code;
DEOPT_IF(!_PyThreadState_HasStackSpace(tstate, code->co_framesize), CALL);
+ DEOPT_IF(tstate->py_recursion_remaining <= 1, CALL);
}
// _INIT_CALL_PY_EXACT_ARGS
args = stack_pointer - oparg;
@@ -3955,18 +3958,19 @@
// Eventually this should be the only occurrence of this code.
frame->return_offset = 0;
assert(tstate->interp->eval_frame == NULL);
- _PyFrame_SetStackPointer(frame, stack_pointer);
+ STORE_SP();
new_frame->previous = frame;
CALL_STAT_INC(inlined_py_calls);
frame = tstate->current_frame = new_frame;
- #if TIER_ONE
- goto start_frame;
- #endif
- #if TIER_TWO
- if (_Py_EnterRecursivePy(tstate)) goto pop_1_exit_unwind;
- stack_pointer = _PyFrame_GetStackPointer(frame);
- ip_offset = (_Py_CODEUNIT *)_PyFrame_GetCode(frame)->co_code_adaptive;
- #endif
+ tstate->py_recursion_remaining--;
+ LOAD_SP();
+ LOAD_IP();
+ #if LLTRACE && TIER_ONE
+ lltrace = maybe_lltrace_resume_frame(frame, &entry_frame, GLOBALS());
+ if (lltrace < 0) {
+ goto exit_unwind;
+ }
+ #endif
}
DISPATCH();
}