summaryrefslogtreecommitdiffstats
path: root/Python/optimizer_bytecodes.c
diff options
context:
space:
mode:
authorTomas R. <tomas.roun8@gmail.com>2025-04-24 22:55:03 (GMT)
committerGitHub <noreply@github.com>2025-04-24 22:55:03 (GMT)
commit08e3389e8c433c16895127e8b745093f071b21b9 (patch)
treeb6d4616f165052023760cfaf08b001eff2bb73b5 /Python/optimizer_bytecodes.c
parent15ff60aff0ca28b23c89cb1c0fc8f1f8997ed035 (diff)
downloadcpython-08e3389e8c433c16895127e8b745093f071b21b9.zip
cpython-08e3389e8c433c16895127e8b745093f071b21b9.tar.gz
cpython-08e3389e8c433c16895127e8b745093f071b21b9.tar.bz2
GH-131798: Split up and optimize CALL_TUPLE_1 in the JIT (GH-132851)
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 4f96140..ff2830d 100644
--- a/Python/optimizer_bytecodes.c
+++ b/Python/optimizer_bytecodes.c
@@ -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);