Skip to content

Commit 72ab5b1

Browse files
committed
Modernize CALL_NO_KW_TUPLE_1
1 parent e437dfd commit 72ab5b1

File tree

3 files changed

+22
-27
lines changed

3 files changed

+22
-27
lines changed

Python/bytecodes.c

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2562,24 +2562,17 @@ dummy_func(
25622562
CHECK_EVAL_BREAKER();
25632563
}
25642564

2565-
// stack effect: (__0, __array[oparg] -- )
2566-
inst(CALL_NO_KW_TUPLE_1) {
2565+
inst(CALL_NO_KW_TUPLE_1, (unused/1, unused/2, unused/1, null, callable, args[oparg] -- res)) {
25672566
assert(kwnames == NULL);
25682567
assert(oparg == 1);
2569-
DEOPT_IF(is_method(stack_pointer, 1), CALL);
2570-
PyObject *callable = PEEK(2);
2568+
DEOPT_IF(null != NULL, CALL);
25712569
DEOPT_IF(callable != (PyObject *)&PyTuple_Type, CALL);
25722570
STAT_INC(CALL, hit);
2573-
PyObject *arg = TOP();
2574-
PyObject *res = PySequence_Tuple(arg);
2571+
PyObject *arg = args[0];
2572+
res = PySequence_Tuple(arg);
25752573
Py_DECREF(arg);
2576-
Py_DECREF(&PyTuple_Type);
2577-
STACK_SHRINK(2);
2578-
SET_TOP(res);
2579-
if (res == NULL) {
2580-
goto error;
2581-
}
2582-
JUMPBY(INLINE_CACHE_ENTRIES_CALL);
2574+
Py_DECREF(&PyTuple_Type); // I.e., tuple
2575+
ERROR_IF(res == NULL, error);
25832576
CHECK_EVAL_BREAKER();
25842577
}
25852578

Python/generated_cases.c.h

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

Python/opcode_metadata.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ _PyOpcode_num_popped(int opcode, int oparg, bool jump) {
299299
case CALL_NO_KW_STR_1:
300300
return oparg + 2;
301301
case CALL_NO_KW_TUPLE_1:
302-
return -1;
302+
return oparg + 2;
303303
case CALL_BUILTIN_CLASS:
304304
return -1;
305305
case CALL_NO_KW_BUILTIN_O:
@@ -645,7 +645,7 @@ _PyOpcode_num_pushed(int opcode, int oparg, bool jump) {
645645
case CALL_NO_KW_STR_1:
646646
return 1;
647647
case CALL_NO_KW_TUPLE_1:
648-
return -1;
648+
return 1;
649649
case CALL_BUILTIN_CLASS:
650650
return -1;
651651
case CALL_NO_KW_BUILTIN_O:
@@ -848,7 +848,7 @@ struct opcode_metadata {
848848
[CALL_PY_WITH_DEFAULTS] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IBC000 },
849849
[CALL_NO_KW_TYPE_1] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IBC000 },
850850
[CALL_NO_KW_STR_1] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IBC000 },
851-
[CALL_NO_KW_TUPLE_1] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IB },
851+
[CALL_NO_KW_TUPLE_1] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IBC000 },
852852
[CALL_BUILTIN_CLASS] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IB },
853853
[CALL_NO_KW_BUILTIN_O] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IB },
854854
[CALL_NO_KW_BUILTIN_FAST] = { DIR_NONE, DIR_NONE, DIR_NONE, true, INSTR_FMT_IB },

0 commit comments

Comments
 (0)