GH-131798: Split up and optimize CALL_STR_1 in the JIT (GH-132849)

This commit is contained in:
Tomas R. 2025-04-24 21:54:46 +02:00 committed by GitHub
parent c7a7aa9a57
commit 0a387b311e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 276 additions and 161 deletions

View file

@ -855,6 +855,16 @@ dummy_func(void) {
}
}
op(_CALL_STR_1, (unused, unused, arg -- res)) {
if (sym_matches_type(arg, &PyUnicode_Type)) {
// e.g. str('foo') or str(foo) where foo is known to be a string
res = arg;
}
else {
res = sym_new_type(ctx, &PyUnicode_Type);
}
}
op(_GUARD_IS_TRUE_POP, (flag -- )) {
if (sym_is_const(ctx, flag)) {
PyObject *value = sym_get_const(ctx, flag);
@ -1021,6 +1031,13 @@ dummy_func(void) {
sym_set_const(callable, (PyObject *)&PyType_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);
}
sym_set_const(callable, (PyObject *)&PyUnicode_Type);
}
// END BYTECODES //
}