Skip to content

Commit 6c35aa0

Browse files
committed
separate forward/backward jump implementations
1 parent 3c709be commit 6c35aa0

File tree

1 file changed

+53
-20
lines changed

1 file changed

+53
-20
lines changed

Python/ceval.c

Lines changed: 53 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3941,61 +3941,70 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
39413941

39423942
TARGET(POP_JUMP_BACKWARD_IF_FALSE) {
39433943
PREDICTED(POP_JUMP_BACKWARD_IF_FALSE);
3944-
oparg = -oparg;
3945-
JUMP_TO_INSTRUCTION(POP_JUMP_FORWARD_IF_FALSE);
3946-
}
3947-
3948-
TARGET(POP_JUMP_FORWARD_IF_FALSE) {
3949-
PREDICTED(POP_JUMP_FORWARD_IF_FALSE);
39503944
PyObject *cond = POP();
3951-
int err;
39523945
if (Py_IsTrue(cond)) {
39533946
Py_DECREF(cond);
39543947
DISPATCH();
39553948
}
39563949
if (Py_IsFalse(cond)) {
39573950
Py_DECREF(cond);
3958-
JUMPBY(oparg);
3951+
JUMPBY(-oparg);
39593952
CHECK_EVAL_BREAKER();
39603953
DISPATCH();
39613954
}
3962-
err = PyObject_IsTrue(cond);
3955+
int err = PyObject_IsTrue(cond);
39633956
Py_DECREF(cond);
39643957
if (err > 0)
39653958
;
39663959
else if (err == 0) {
3967-
JUMPBY(oparg);
3960+
JUMPBY(-oparg);
39683961
CHECK_EVAL_BREAKER();
39693962
}
39703963
else
39713964
goto error;
39723965
DISPATCH();
39733966
}
39743967

3975-
TARGET(POP_JUMP_BACKWARD_IF_TRUE) {
3976-
PREDICTED(POP_JUMP_BACKWARD_IF_TRUE);
3977-
oparg = -oparg;
3978-
JUMP_TO_INSTRUCTION(POP_JUMP_FORWARD_IF_TRUE);
3968+
TARGET(POP_JUMP_FORWARD_IF_FALSE) {
3969+
PREDICTED(POP_JUMP_FORWARD_IF_FALSE);
3970+
PyObject *cond = POP();
3971+
if (Py_IsTrue(cond)) {
3972+
Py_DECREF(cond);
3973+
}
3974+
else if (Py_IsFalse(cond)) {
3975+
Py_DECREF(cond);
3976+
JUMPBY(oparg);
3977+
}
3978+
else {
3979+
int err = PyObject_IsTrue(cond);
3980+
Py_DECREF(cond);
3981+
if (err > 0)
3982+
;
3983+
else if (err == 0) {
3984+
JUMPBY(oparg);
3985+
}
3986+
else
3987+
goto error;
3988+
}
3989+
DISPATCH();
39793990
}
39803991

3981-
TARGET(POP_JUMP_FORWARD_IF_TRUE) {
3982-
PREDICTED(POP_JUMP_FORWARD_IF_TRUE);
3992+
TARGET(POP_JUMP_BACKWARD_IF_TRUE) {
39833993
PyObject *cond = POP();
3984-
int err;
39853994
if (Py_IsFalse(cond)) {
39863995
Py_DECREF(cond);
39873996
DISPATCH();
39883997
}
39893998
if (Py_IsTrue(cond)) {
39903999
Py_DECREF(cond);
3991-
JUMPBY(oparg);
4000+
JUMPBY(-oparg);
39924001
CHECK_EVAL_BREAKER();
39934002
DISPATCH();
39944003
}
3995-
err = PyObject_IsTrue(cond);
4004+
int err = PyObject_IsTrue(cond);
39964005
Py_DECREF(cond);
39974006
if (err > 0) {
3998-
JUMPBY(oparg);
4007+
JUMPBY(-oparg);
39994008
CHECK_EVAL_BREAKER();
40004009
}
40014010
else if (err == 0)
@@ -4005,6 +4014,30 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, _PyInterpreterFrame *frame, int
40054014
DISPATCH();
40064015
}
40074016

4017+
TARGET(POP_JUMP_FORWARD_IF_TRUE) {
4018+
PyObject *cond = POP();
4019+
if (Py_IsFalse(cond)) {
4020+
Py_DECREF(cond);
4021+
}
4022+
else if (Py_IsTrue(cond)) {
4023+
Py_DECREF(cond);
4024+
JUMPBY(oparg);
4025+
}
4026+
else {
4027+
int err = PyObject_IsTrue(cond);
4028+
Py_DECREF(cond);
4029+
if (err > 0) {
4030+
JUMPBY(oparg);
4031+
CHECK_EVAL_BREAKER();
4032+
}
4033+
else if (err == 0)
4034+
;
4035+
else
4036+
goto error;
4037+
}
4038+
DISPATCH();
4039+
}
4040+
40084041
TARGET(POP_JUMP_BACKWARD_IF_NOT_NONE) {
40094042
PyObject *value = POP();
40104043
if (!Py_IsNone(value)) {

0 commit comments

Comments
 (0)