Skip to content

gh-71316: Update dis documentation to include changes to jump arguments #95798

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

Conversation

Christopher-Chianelli
Copy link
Contributor

@Christopher-Chianelli Christopher-Chianelli commented Aug 8, 2022

Since 3.10, the instruction offset is used instead of the byte
offset. Thus, for jump instructions, the argument is half
of what it would of been in 3.9. For instance, this code:

def test(x):
return 1 if x else 0

in 3.9 disassembles into

4 0 LOAD_FAST 0 (x)
2 POP_JUMP_IF_FALSE 8
4 LOAD_CONST 1 (1)
6 RETURN_VALUE
>> 8 LOAD_CONST 2 (0)
10 RETURN_VALUE

but in 3.10 disassembles into

4 0 LOAD_FAST 0 (x)
2 POP_JUMP_IF_FALSE 4 (to 8)
4 LOAD_CONST 1 (1)
6 RETURN_VALUE
>> 8 LOAD_CONST 2 (0)
10 RETURN_VALUE

Since 3.10, the instruction offset is used instead of the byte
offset. Thus, for jump instructions, the argument is half
of what it would of been in 3.9. For instance, this code:

def test(x):
    return 1 if x else 0

in 3.9 disassembles into

  4           0 LOAD_FAST                0 (x)
              2 POP_JUMP_IF_FALSE        8
              4 LOAD_CONST               1 (1)
              6 RETURN_VALUE
        >>    8 LOAD_CONST               2 (0)
             10 RETURN_VALUE

but in 3.10 disassembles into

  4           0 LOAD_FAST                0 (x)
              2 POP_JUMP_IF_FALSE        4 (to 8)
              4 LOAD_CONST               1 (1)
              6 RETURN_VALUE
        >>    8 LOAD_CONST               2 (0)
             10 RETURN_VALUE
@bedevere-bot bedevere-bot added docs Documentation in the Doc dir skip news awaiting review labels Aug 8, 2022
@ghost
Copy link

ghost commented Aug 8, 2022

All commit authors signed the Contributor License Agreement.
CLA signed

@iritkatriel iritkatriel changed the title Update dis documentation to include changes to jump arguments gh-71316: Update dis documentation to include changes to jump arguments Oct 7, 2022
@iritkatriel
Copy link
Member

This is related to #71316.

CC @markshannon .

@iritkatriel iritkatriel added needs backport to 3.10 only security fixes needs backport to 3.11 only security fixes labels Oct 7, 2022
@miss-islington
Copy link
Contributor

Thanks @Christopher-Chianelli for the PR, and @iritkatriel for merging it 🌮🎉.. I'm working now to backport this PR to: 3.10, 3.11.
🐍🍒⛏🤖

@bedevere-bot
Copy link

GH-98028 is a backport of this pull request to the 3.11 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.11 only security fixes label Oct 7, 2022
@miss-islington
Copy link
Contributor

Sorry, @Christopher-Chianelli and @iritkatriel, I could not cleanly backport this to 3.10 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker 6592a62ec2939323b895c85780da7fd73a640da3 3.10

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Oct 7, 2022
…rguments (pythonGH-95798)

(cherry picked from commit 6592a62)

Co-authored-by: Christopher Chianelli <[email protected]>
miss-islington added a commit that referenced this pull request Oct 7, 2022
…ts (GH-95798)

(cherry picked from commit 6592a62)

Co-authored-by: Christopher Chianelli <[email protected]>
Christopher-Chianelli added a commit to Christopher-Chianelli/cpython that referenced this pull request Oct 7, 2022
… jump arguments (pythonGH-95798).

(cherry picked from commit 6592a62)

Co-authored-by: Christopher Chianelli <[email protected]>
Christopher-Chianelli added a commit to Christopher-Chianelli/cpython that referenced this pull request Oct 7, 2022
… jump arguments (pythonGH-95798).

(cherry picked from commit 6592a62)

Co-authored-by: Christopher Chianelli <[email protected]>
@bedevere-bot
Copy link

GH-98029 is a backport of this pull request to the 3.10 branch.

@bedevere-bot bedevere-bot removed the needs backport to 3.10 only security fixes label Oct 7, 2022
iritkatriel pushed a commit to iritkatriel/cpython that referenced this pull request Oct 7, 2022
iritkatriel pushed a commit to iritkatriel/cpython that referenced this pull request Oct 7, 2022
iritkatriel pushed a commit that referenced this pull request Oct 7, 2022
…arguments (GH-95798). (GH-98029)

(cherry picked from commit 6592a62)

Co-authored-by: Christopher Chianelli <[email protected]>
mpage pushed a commit to mpage/cpython that referenced this pull request Oct 11, 2022
pablogsal pushed a commit that referenced this pull request Oct 22, 2022
…ts (GH-95798)

(cherry picked from commit 6592a62)

Co-authored-by: Christopher Chianelli <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir skip news
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants