summaryrefslogtreecommitdiffstats
path: root/Python/optimizer_bytecodes.c
diff options
context:
space:
mode:
authorTomas R. <tomas.roun8@gmail.com>2025-04-24 19:54:46 (GMT)
committerGitHub <noreply@github.com>2025-04-24 19:54:46 (GMT)
commit0a387b311e617a9a614c593551d3c04a37331e53 (patch)
tree825bd410f95ff8a77fb138188014fb5b2e0d8be3 /Python/optimizer_bytecodes.c
parentc7a7aa9a57c25ef2666f7dbf62edab882747af6b (diff)
downloadcpython-0a387b311e617a9a614c593551d3c04a37331e53.zip
cpython-0a387b311e617a9a614c593551d3c04a37331e53.tar.gz
cpython-0a387b311e617a9a614c593551d3c04a37331e53.tar.bz2
GH-131798: Split up and optimize CALL_STR_1 in the JIT (GH-132849)
Diffstat (limited to 'Python/optimizer_bytecodes.c')
-rw-r--r--Python/optimizer_bytecodes.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/Python/optimizer_bytecodes.c b/Python/optimizer_bytecodes.c
index a14d5c0..4f96140 100644
--- a/Python/optimizer_bytecodes.c
+++ b/Python/optimizer_bytecodes.c
@@ -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 //
}