Skip to content

Commit 121bc55

Browse files
committed
POP_JUMP_IF_FALSE, POP_JUMP_IF_TRUE
1 parent cdfbacb commit 121bc55

File tree

3 files changed

+24
-30
lines changed

3 files changed

+24
-30
lines changed

Python/bytecodes.c

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1932,9 +1932,7 @@ dummy_func(
19321932
CHECK_EVAL_BREAKER();
19331933
}
19341934

1935-
// stack effect: (__0 -- )
1936-
inst(POP_JUMP_IF_FALSE) {
1937-
PyObject *cond = POP();
1935+
inst(POP_JUMP_IF_FALSE, (cond -- )) {
19381936
if (Py_IsTrue(cond)) {
19391937
_Py_DECREF_NO_DEALLOC(cond);
19401938
}
@@ -1945,19 +1943,16 @@ dummy_func(
19451943
else {
19461944
int err = PyObject_IsTrue(cond);
19471945
Py_DECREF(cond);
1948-
if (err > 0)
1949-
;
1950-
else if (err == 0) {
1946+
if (err == 0) {
19511947
JUMPBY(oparg);
19521948
}
1953-
else
1954-
goto error;
1949+
else {
1950+
ERROR_IF(err < 0, error);
1951+
}
19551952
}
19561953
}
19571954

1958-
// stack effect: (__0 -- )
1959-
inst(POP_JUMP_IF_TRUE) {
1960-
PyObject *cond = POP();
1955+
inst(POP_JUMP_IF_TRUE, (cond -- )) {
19611956
if (Py_IsFalse(cond)) {
19621957
_Py_DECREF_NO_DEALLOC(cond);
19631958
}
@@ -1971,10 +1966,9 @@ dummy_func(
19711966
if (err > 0) {
19721967
JUMPBY(oparg);
19731968
}
1974-
else if (err == 0)
1975-
;
1976-
else
1977-
goto error;
1969+
else {
1970+
ERROR_IF(err < 0, error);
1971+
}
19781972
}
19791973
}
19801974

Python/generated_cases.c.h

Lines changed: 11 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: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,9 @@ _PyOpcode_num_popped(int opcode, int oparg) {
233233
case JUMP_BACKWARD:
234234
return 0;
235235
case POP_JUMP_IF_FALSE:
236-
return -1;
236+
return 1;
237237
case POP_JUMP_IF_TRUE:
238-
return -1;
238+
return 1;
239239
case POP_JUMP_IF_NOT_NONE:
240240
return 1;
241241
case POP_JUMP_IF_NONE:
@@ -579,9 +579,9 @@ _PyOpcode_num_pushed(int opcode, int oparg) {
579579
case JUMP_BACKWARD:
580580
return 0;
581581
case POP_JUMP_IF_FALSE:
582-
return -1;
582+
return 0;
583583
case POP_JUMP_IF_TRUE:
584-
return -1;
584+
return 0;
585585
case POP_JUMP_IF_NOT_NONE:
586586
return 0;
587587
case POP_JUMP_IF_NONE:

0 commit comments

Comments
 (0)