gh-145866: Convert DICT_MERGE to leave its inputs on the stack to be cleaned up by _POP_TOP (GH-146329)

This commit is contained in:
Neko Asakura 2026-03-24 06:31:41 -04:00 committed by GitHub
parent 07a555d4fc
commit 6d73bc2267
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 1236 additions and 1199 deletions

View file

@ -2324,7 +2324,7 @@ dummy_func(
PyStackRef_CLOSE(update);
}
inst(DICT_MERGE, (callable, unused, unused, dict, unused[oparg - 1], update -- callable, unused, unused, dict, unused[oparg - 1])) {
op(_DICT_MERGE, (callable, unused, unused, dict, unused[oparg - 1], update -- callable, unused, unused, dict, unused[oparg - 1], u)) {
PyObject *callable_o = PyStackRef_AsPyObjectBorrow(callable);
PyObject *dict_o = PyStackRef_AsPyObjectBorrow(dict);
PyObject *update_o = PyStackRef_AsPyObjectBorrow(update);
@ -2332,12 +2332,14 @@ dummy_func(
int err = _PyDict_MergeEx(dict_o, update_o, 2);
if (err < 0) {
_PyEval_FormatKwargsError(tstate, callable_o, update_o);
PyStackRef_CLOSE(update);
ERROR_IF(true);
ERROR_NO_POP();
}
PyStackRef_CLOSE(update);
u = update;
DEAD(update);
}
macro(DICT_MERGE) = _DICT_MERGE + POP_TOP;
inst(MAP_ADD, (dict_st, unused[oparg - 1], key, value -- dict_st, unused[oparg - 1])) {
PyObject *dict = PyStackRef_AsPyObjectBorrow(dict_st);
assert(PyDict_CheckExact(dict));