8000 GH-100982: Add `COMPARE_AND_BRANCH` instruction by markshannon · Pull Request #100983 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

GH-100982: Add COMPARE_AND_BRANCH instruction #100983

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Prev Previous commit
Next Next commit
Revert change to COMPARE_AND_BRANCH classification.
  • Loading branch information
markshannon committed Jan 12, 2023
commit 7d3350885163d11068eb3268bb12e87e2ea9c052
4 changes: 2 additions & 2 deletions Include/internal/pycore_opcode.h

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

2 changes: 1 addition & 1 deletion Lib/opcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def pseudo_op(name, op, real_ops):
def_op('DELETE_DEREF', 139)
hasfree.append(139)
jrel_op('JUMP_BACKWARD', 140) # Number of words to skip (backwards)
jrel_op('COMPARE_AND_BRANCH', 141) # Comparison and jump
def_op('COMPARE_AND_BRANCH', 141) # Comparison and jump
hascompare.append(141)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This opcode needs to be in hasjrel as well.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is that dis sees COMPARE_AND_BRANCH, then POP_JUMP_IF_. The POP_JUMP_IF_ is where we jump from.
So marking COMPARE_AND_BRANCH as a jump confuses dis, it thinks the operator is a jump offset. COMPARE_AND_BRANCH is effectively a superinstruction.

I could special case COMPARE_AND_BRANCH in dis, but I think it might be better to wait for proper support for longer instructions.


def_op('CALL_FUNCTION_EX', 142) # Flags
Expand Down
0