bpo-47009: Let PRECALL_NO_KW_LIST_APPEND do its own POP_TOP (GH-32239)

This commit is contained in:
Dennis Sweeney 2022-04-05 06:18:30 -04:00 committed by GitHub
parent 96e09837fb
commit 6c6e0408a6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 5 deletions

View file

@ -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;
}