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-100923: Embed jump mask in COMPARE_OP oparg #100924

Merged
merged 10 commits into from
Jan 11, 2023

Conversation

markshannon
Copy link
Member

@markshannon markshannon commented Jan 10, 2023

@markshannon markshannon changed the title Embed jump mask in COMPARE_OP oparg GH-100923: Embed jump mask in COMPARE_OP oparg Jan 10, 2023
Lib/importlib/_bootstrap_external.py Outdated Show resolved Hide resolved
Python/bytecodes.c Outdated Show resolved Hide resolved
Python/compile.c Outdated Show resolved Hide resolved
@sweeneyde
Copy link
Member

Can the mask be added at compile time to avoid mutating the logical code?

def f():
    ...
c0 = f.__code__.replace()
# ... run the code here ...
c1 = f.__code__

assert c0 == c1              # fails?
assert hash(c0) == hash(c1)  # fails?

@sweeneyde
Copy link
Member

Oh I see, the work is being done in PyCode_Quicken, which is already called on every code object, so we should be okay.

@markshannon
Copy link
Member Author

Yes, the plan is to move PyCode_Quicken into the compiler. faster-cpython/ideas#530

Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
Python/compile.c Outdated Show resolved Hide resolved
Co-authored-by: Irit Katriel <1055913+iritkatriel@users.noreply.github.com>
@markshannon markshannon merged commit 6e4e14d into python:main Jan 11, 2023
@markshannon markshannon deleted the embed-mask-in-compare-oparg branch January 11, 2023 21:00
@esc
Copy link
Contributor

esc commented Sep 25, 2023

I just stumbled upon this. It seems like this PR didn't update the docs, as:

https://docs.python.org/3.12/library/dis.html#opcode-COMPARE_OP

Reads:

Screenshot 2023-09-25 at 18 24 05

Perhaps the new masking mechanism could be included here? Or maybe it will suffice to update the docs to say cmp_op[opname>>4]? Would be happy to try to submit a PR if that is welcome.

@brandtbucher
Copy link
Member

That issue is being covered in #107457.

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.

6 participants