File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -1534,6 +1534,26 @@ _Py_uop_frame_new(
15341534 frame -> locals [i ] = local ;
15351535 }
15361536
1537+ /* CPython guarantees that *args is always a tuple and **kwargs is always
1538+ * a dict. Mark their slots with the correct types so the JIT optimizer
1539+ * can specialise TO_BOOL (and other ops) on them without needing runtime
1540+ * type guards. */
1541+ if (co -> co_flags & (CO_VARARGS | CO_VARKEYWORDS )) {
1542+ int total_args = co -> co_argcount + co -> co_kwonlyargcount ;
1543+ int slot = total_args ;
1544+ if (co -> co_flags & CO_VARARGS ) {
1545+ /* *args lives at slot `total_args` and is always a tuple. */
1546+ assert (slot < co -> co_nlocalsplus );
1547+ frame -> locals [slot ] = _Py_uop_sym_new_type (ctx , & PyTuple_Type );
1548+ slot ++ ;
1549+ }
1550+ if (co -> co_flags & CO_VARKEYWORDS ) {
1551+ /* **kwargs lives at the next slot and is always a dict. */
1552+ assert (slot < co -> co_nlocalsplus );
1553+ frame -> locals [slot ] = _Py_uop_sym_new_type (ctx , & PyDict_Type );
1554+ }
1555+ }
1556+
15371557 frame -> callable = _Py_uop_sym_new_not_null (ctx );
15381558
15391559 /* Most optimizations rely on code objects being immutable (including sys._getframe modifications),
You can’t perform that action at this time.
0 commit comments