GH-131798: Split up and optimize CALL_TUPLE_1 in the JIT (GH-132851)

This commit is contained in:
Tomas R. 2025-04-25 00:55:03 +02:00 committed by GitHub
parent 15ff60aff0
commit 08e3389e8c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 277 additions and 161 deletions

View file

@ -967,6 +967,16 @@ dummy_func(void) {
}
}
op(_CALL_TUPLE_1, (callable, null, arg -- res)) {
if (sym_matches_type(arg, &PyTuple_Type)) {
// e.g. tuple((1, 2)) or tuple(foo) where foo is known to be a tuple
res = arg;
}
else {
res = sym_new_type(ctx, &PyTuple_Type);
}
}
op(_GUARD_TOS_LIST, (tos -- tos)) {
if (sym_matches_type(tos, &PyList_Type)) {
REPLACE_OP(this_instr, _NOP, 0, 0);
@ -1031,6 +1041,13 @@ dummy_func(void) {
sym_set_const(callable, (PyObject *)&PyType_Type);
}
op(_GUARD_CALLABLE_TUPLE_1, (callable, unused, unused -- callable, unused, unused)) {
if (sym_get_const(ctx, callable) == (PyObject *)&PyTuple_Type) {
REPLACE_OP(this_instr, _NOP, 0, 0);
}
sym_set_const(callable, (PyObject *)&PyTuple_Type);
}
op(_GUARD_CALLABLE_STR_1, (callable, unused, unused -- callable, unused, unused)) {
if (sym_get_const(ctx, callable) == (PyObject *)&PyUnicode_Type) {
REPLACE_OP(this_instr, _NOP, 0, 0);