aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Python/bytecodes.c
diff options
context:
space:
mode:
authorDiego Russo <diego.russo@arm.com>2025-05-19 15:48:55 -0400
committerGitHub <noreply@github.com>2025-05-19 15:48:55 -0400
commit42d03f393313d8a228a45dad1d0897ea99f5ec89 (patch)
treef736d4fbdff627bc2497d58a9f2103a93f467398 /Python/bytecodes.c
parent92f85ff3a07335e32a0e00a55b7b6aaf3657019b (diff)
downloadcpython-42d03f393313d8a228a45dad1d0897ea99f5ec89.tar.gz
cpython-42d03f393313d8a228a45dad1d0897ea99f5ec89.zip
GH-131798: Split CALL_LIST_APPEND into several uops (GH-134240)
Diffstat (limited to 'Python/bytecodes.c')
-rw-r--r--Python/bytecodes.c27
1 files changed, 21 insertions, 6 deletions
diff --git a/Python/bytecodes.c b/Python/bytecodes.c
index 42e4f581894..c10327916fc 100644
--- a/Python/bytecodes.c
+++ b/Python/bytecodes.c
@@ -4041,6 +4041,11 @@ dummy_func(
DEOPT_IF(!PyStackRef_IsNull(null));
}
+ op(_GUARD_NOS_NOT_NULL, (nos, unused -- nos, unused)) {
+ PyObject *o = PyStackRef_AsPyObjectBorrow(nos);
+ EXIT_IF(o == NULL);
+ }
+
op(_GUARD_THIRD_NULL, (null, unused, unused -- null, unused, unused)) {
DEOPT_IF(!PyStackRef_IsNull(null));
}
@@ -4394,16 +4399,26 @@ dummy_func(
_GUARD_CALLABLE_ISINSTANCE +
_CALL_ISINSTANCE;
+ macro(CALL_LIST_APPEND) =
+ unused/1 +
+ unused/2 +
+ _GUARD_CALLABLE_LIST_APPEND +
+ _GUARD_NOS_NOT_NULL +
+ _GUARD_NOS_LIST +
+ _CALL_LIST_APPEND;
+
+ op(_GUARD_CALLABLE_LIST_APPEND, (callable, unused, unused -- callable, unused, unused)){
+ PyObject *callable_o = PyStackRef_AsPyObjectBorrow(callable);
+ PyInterpreterState *interp = tstate->interp;
+ DEOPT_IF(callable_o != interp->callable_cache.list_append);
+ }
+
// This is secretly a super-instruction
- inst(CALL_LIST_APPEND, (unused/1, unused/2, callable, self, arg -- )) {
+ op(_CALL_LIST_APPEND, (callable, self, arg -- )) {
assert(oparg == 1);
- PyObject *callable_o = PyStackRef_AsPyObjectBorrow(callable);
PyObject *self_o = PyStackRef_AsPyObjectBorrow(self);
- PyInterpreterState *interp = tstate->interp;
- DEOPT_IF(callable_o != interp->callable_cache.list_append);
- DEOPT_IF(self_o == NULL);
- DEOPT_IF(!PyList_Check(self_o));
+ DEOPT_IF(!PyList_CheckExact(self_o));
DEOPT_IF(!LOCK_OBJECT(self_o));
STAT_INC(CALL, hit);
int err = _PyList_AppendTakeRef((PyListObject *)self_o, PyStackRef_AsPyObjectSteal(arg));