gh-148171: Convert CALL_BUILTIN_FAST to leave inputs on the stack for refcount elimination in JIT (GH-148172)

This commit is contained in:
Ken Jin 2026-04-10 23:11:18 +08:00 committed by GitHub
parent aea0b91d65
commit 266247c9a6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 1199 additions and 1103 deletions

View file

@ -763,22 +763,14 @@ dummy_func(void) {
value = PyJitRef_Borrow(sym_new_const(ctx, ptr));
}
op(_POP_TOP_OPARG, (args[oparg] --)) {
for (int i = oparg-1; i >= 0; i--) {
optimize_pop_top(ctx, this_instr, args[i]);
}
}
op(_POP_TOP, (value -- )) {
PyTypeObject *typ = sym_get_type(value);
if (PyJitRef_IsBorrowed(value) ||
sym_is_immortal(PyJitRef_Unwrap(value)) ||
sym_is_null(value)) {
ADD_OP(_POP_TOP_NOP, 0, 0);
}
else if (typ == &PyLong_Type) {
ADD_OP(_POP_TOP_INT, 0, 0);
}
else if (typ == &PyFloat_Type) {
ADD_OP(_POP_TOP_FLOAT, 0, 0);
}
else if (typ == &PyUnicode_Type) {
ADD_OP(_POP_TOP_UNICODE, 0, 0);
}
optimize_pop_top(ctx, this_instr, value);
}
op(_POP_TOP_INT, (value --)) {
@ -1348,6 +1340,10 @@ dummy_func(void) {
}
}
op(_CALL_BUILTIN_FAST, (callable, self_or_null, args[oparg] -- callable, self_or_null, args[oparg])) {
callable = sym_new_not_null(ctx);
}
op(_GUARD_CALLABLE_METHOD_DESCRIPTOR_O, (callable, self_or_null, args[oparg] -- callable, self_or_null, args[oparg])) {
PyObject *callable_o = sym_get_const(ctx, callable);
if (callable_o && sym_matches_type(callable, &PyMethodDescr_Type) &&