[Python-checkins] bpo-47009: Let PRECALL_NO_KW_LIST_APPEND do its own POP_TOP (GH-32239)
markshannon
webhook-mailer at python.org
Tue Apr 5 06:18:54 EDT 2022
https://github.com/python/cpython/commit/6c6e0408a663c1f53dad403f54a18d444da39cb7
commit: 6c6e0408a663c1f53dad403f54a18d444da39cb7
branch: main
author: Dennis Sweeney <36520290+sweeneyde at users.noreply.github.com>
committer: markshannon <mark at hotpy.org>
date: 2022-04-05T11:18:30+01:00
summary:
bpo-47009: Let PRECALL_NO_KW_LIST_APPEND do its own POP_TOP (GH-32239)
files:
M Python/ceval.c
M Python/specialize.c
diff --git a/Python/ceval.c b/Python/ceval.c
index 68d2920727ab0..ce4abd5da2414 100644
--- a/Python/ceval.c
+++ b/Python/ceval.c
@@ -5040,15 +5040,15 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
PyObject *list = SECOND();
DEOPT_IF(!PyList_Check(list), PRECALL);
STAT_INC(PRECALL, hit);
- SKIP_CALL();
+ // PRECALL + CALL + POP_TOP
+ JUMPBY(INLINE_CACHE_ENTRIES_PRECALL + 1 + INLINE_CACHE_ENTRIES_CALL + 1);
+ assert(next_instr[-1] == POP_TOP);
PyObject *arg = POP();
if (_PyList_AppendTakeRef((PyListObject *)list, arg) < 0) {
goto error;
}
+ STACK_SHRINK(2);
Py_DECREF(list);
- STACK_SHRINK(1);
- Py_INCREF(Py_None);
- SET_TOP(Py_None);
Py_DECREF(callable);
NOTRACE_DISPATCH();
}
diff --git a/Python/specialize.c b/Python/specialize.c
index 08c69041e78b0..36b05026489cf 100644
--- a/Python/specialize.c
+++ b/Python/specialize.c
@@ -1435,7 +1435,10 @@ specialize_method_descriptor(PyMethodDescrObject *descr, _Py_CODEUNIT *instr,
}
PyInterpreterState *interp = _PyInterpreterState_GET();
PyObject *list_append = interp->callable_cache.list_append;
- if ((PyObject *)descr == list_append && oparg == 1) {
+ _Py_CODEUNIT next = instr[INLINE_CACHE_ENTRIES_PRECALL + 1
+ + INLINE_CACHE_ENTRIES_CALL + 1];
+ bool pop = (_Py_OPCODE(next) == POP_TOP);
+ if ((PyObject *)descr == list_append && oparg == 1 && pop) {
_Py_SET_OPCODE(*instr, PRECALL_NO_KW_LIST_APPEND);
return 0;
}
More information about the Python-checkins
mailing list