Skip to content

Commit

Permalink
GH-106529: Define POP_JUMP_IF_NONE in terms of POP_JUMP_IF_TRUE (GH-1…
Browse files Browse the repository at this point in the history
  • Loading branch information
markshannon committed Jul 11, 2023
1 parent 1f2921b commit c0c041a
Show file tree
Hide file tree
Showing 4 changed files with 281 additions and 235 deletions.
16 changes: 7 additions & 9 deletions Python/bytecodes.c
Expand Up @@ -2282,22 +2282,20 @@ dummy_func(
JUMPBY(oparg * Py_IsTrue(cond));
}

inst(POP_JUMP_IF_NOT_NONE, (value -- )) {
if (!Py_IsNone(value)) {
DECREF_INPUTS();
JUMPBY(oparg);
}
}

inst(POP_JUMP_IF_NONE, (value -- )) {
op(IS_NONE, (value -- b)) {
if (Py_IsNone(value)) {
JUMPBY(oparg);
b = Py_True;
}
else {
b = Py_False;
DECREF_INPUTS();
}
}

macro(POP_JUMP_IF_NONE) = IS_NONE + POP_JUMP_IF_TRUE;

macro(POP_JUMP_IF_NOT_NONE) = IS_NONE + POP_JUMP_IF_FALSE;

inst(JUMP_BACKWARD_NO_INTERRUPT, (--)) {
/* This bytecode is used in the `yield from` or `await` loop.
* If there is an interrupt, we want it handled in the innermost
Expand Down
114 changes: 66 additions & 48 deletions Python/executor_cases.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit c0c041a

Please sign in to comment.