Skip to content
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

GH-100982: Add COMPARE_AND_BRANCH instruction #100983

Merged

Conversation

markshannon
Copy link
Member

@markshannon markshannon commented Jan 12, 2023

@@ -189,7 +189,8 @@ 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)

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.

Lib/importlib/_bootstrap_external.py Show resolved Hide resolved
@markshannon markshannon merged commit 7b14c2e into python:main Jan 16, 2023
@markshannon markshannon deleted the compare-and-branch-instruction-2 branch September 26, 2023 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants