gh-134584 : Optimize and eliminate redundant ref-counting for MAKE_FUNCTION in the JIT (GH-144963)

This commit is contained in:
Sacul 2026-04-09 22:22:53 +08:00 committed by GitHub
parent 2acb8d9257
commit 38d3aef375
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 1152 additions and 1107 deletions

View file

@ -5511,20 +5511,25 @@ dummy_func(
_DO_CALL_FUNCTION_EX +
_CHECK_PERIODIC_AT_END;
inst(MAKE_FUNCTION, (codeobj_st -- func)) {
op(_MAKE_FUNCTION, (codeobj_st -- func, co)) {
PyObject *codeobj = PyStackRef_AsPyObjectBorrow(codeobj_st);
PyFunctionObject *func_obj = (PyFunctionObject *)
PyFunction_New(codeobj, GLOBALS());
PyStackRef_CLOSE(codeobj_st);
ERROR_IF(func_obj == NULL);
if (func_obj == NULL) {
ERROR_NO_POP();
}
co = codeobj_st;
DEAD(codeobj_st);
_PyFunction_SetVersion(
func_obj, ((PyCodeObject *)codeobj)->co_version);
func = PyStackRef_FromPyObjectSteal((PyObject *)func_obj);
}
macro(MAKE_FUNCTION) = _MAKE_FUNCTION + POP_TOP;
inst(SET_FUNCTION_ATTRIBUTE, (attr_st, func_in -- func_out)) {
PyObject *func = PyStackRef_AsPyObjectBorrow(func_in);
PyObject *attr = PyStackRef_AsPyObjectSteal(attr_st);