Skip to content

Commit 6dc906f

Browse files
committed
gh-131798: Add JIT path for _BUILD_STRING
Signed-off-by: Manjusaka <[email protected]>
1 parent 2ff5eb8 commit 6dc906f

File tree

2 files changed

+45
-8
lines changed

2 files changed

+45
-8
lines changed

Python/optimizer_bytecodes.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -919,6 +919,27 @@ dummy_func(void) {
919919
tup = sym_new_tuple(ctx, oparg, values);
920920
}
921921

922+
op(_BUILD_SLICE, (value -- slice)) {
923+
if (sym_is_const(ctx, value)) {
924+
PyObject *val = sym_get_const(ctx, value);
925+
slice = sym_new_const(ctx, val);
926+
Py_DecRef(val);
927+
}
928+
else {
929+
slice = sym_new_type(ctx, &PySlice_Type);
930+
}
931+
}
932+
op(_BUILD_STRING, (value -- str)) {
933+
if (sym_is_const(ctx, value)) {
934+
PyObject *val = sym_get_const(ctx, value);
935+
str = sym_new_const(ctx, val);
936+
Py_DecRef(val);
937+
}
938+
else {
939+
str = sym_new_type(ctx, &PyUnicode_Type);
940+
}
941+
}
942+
922943
op(_UNPACK_SEQUENCE_TWO_TUPLE, (seq -- val1, val0)) {
923944
val0 = sym_tuple_getitem(ctx, seq, 0);
924945
val1 = sym_tuple_getitem(ctx, seq, 1);

Python/optimizer_cases.c.h

Lines changed: 24 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)