Skip to content

Commit 78e20c4

Browse files
committed
JUMP_IF_TRUE_OR_POP
1 parent 253ec9b commit 78e20c4

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

Python/bytecodes.c

+4-5
Original file line numberDiff line numberDiff line change
@@ -2017,24 +2017,23 @@ dummy_func(
20172017
}
20182018
}
20192019

2020-
// error: JUMP_IF_TRUE_OR_POP stack effect depends on jump flag
2021-
inst(JUMP_IF_TRUE_OR_POP) {
2022-
PyObject *cond = TOP();
2020+
inst(JUMP_IF_TRUE_OR_POP, (cond -- cond if (jump))) {
2021+
bool jump = false;
20232022
int err;
20242023
if (Py_IsFalse(cond)) {
2025-
STACK_SHRINK(1);
20262024
_Py_DECREF_NO_DEALLOC(cond);
20272025
}
20282026
else if (Py_IsTrue(cond)) {
20292027
JUMPBY(oparg);
2028+
jump = true;
20302029
}
20312030
else {
20322031
err = PyObject_IsTrue(cond);
20332032
if (err > 0) {
20342033
JUMPBY(oparg);
2034+
jump = true;
20352035
}
20362036
else if (err == 0) {
2037-
STACK_SHRINK(1);
20382037
Py_DECREF(cond);
20392038
}
20402039
else {

Python/generated_cases.c.h

+6-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/opcode_metadata.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ _PyOpcode_num_popped(int opcode, int oparg, bool jump) {
243243
case JUMP_IF_FALSE_OR_POP:
244244
return 1;
245245
case JUMP_IF_TRUE_OR_POP:
246-
return -1;
246+
return 1;
247247
case JUMP_BACKWARD_NO_INTERRUPT:
248248
return 0;
249249
case GET_LEN:
@@ -589,7 +589,7 @@ _PyOpcode_num_pushed(int opcode, int oparg, bool jump) {
589589
case JUMP_IF_FALSE_OR_POP:
590590
return (jump ? 1 : 0);
591591
case JUMP_IF_TRUE_OR_POP:
592-
return -1;
592+
return (jump ? 1 : 0);
593593
case JUMP_BACKWARD_NO_INTERRUPT:
594594
return 0;
595595
case GET_LEN:

0 commit comments

Comments
 (0)