FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-131798: JIT: optimize _LOAD_COMMON_CONSTANT by trdthg · Pull Request #146104 · python/cpython · GitHub

Repository navigation

gh-131798: JIT: optimize _LOAD_COMMON_CONSTANT - #146104

Merged
Fidget-Spinner merged 1 commit into
python:mainfrom
trdthg:trdthg/feature/jit-load-common-constant
Mar 19, 2026
Merged

Fidget-Spinner merged 1 commit into
python:mainfrom
trdthg:trdthg/feature/jit-load-common-constant

Conversation

trdthg commented Mar 18, 2026 •
edited
Loading

Copy link
Copy Markdown
Contributor

Try to learn and make a small contribution :D

bedevere-app Bot commented Mar 18, 2026

Copy link
Copy Markdown

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

python-cla-bot Bot commented Mar 18, 2026 •
edited
Loading

Copy link
Copy Markdown

All commit authors signed the Contributor License Agreement.

Fidget-Spinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Thanks, this LGTM! Please remove the news entry, we don't need it as it's not a user facing code.

trdthg force-pushed the trdthg/feature/jit-load-common-constant branch from 068d2bb to 19fc90f Compare March 18, 2026 11:40

bedevere-app Bot commented Mar 18, 2026

Copy link
Copy Markdown

Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool.

If this change has little impact on Python users, wait for a maintainer to apply the skip news label instead.

Copy link
Copy Markdown
Member

_LOAD_COMMON_CONSTANT x86_64 dissasembly in jit_stencils-x86_64-unknown-linux-gnu.h:

    // 0000000000000000 <_JIT_ENTRY>:
    // 0: 49 8b 47 10                   movq    0x10(%r15), %rax
    // 4: 48 b9 00 00 00 00 00 00 00 00 movabsq $0x0, %rcx
    // 0000000000000006:  R_X86_64_64  _JIT_OPARG
    // e: 0f b7 c9                      movzwl  %cx, %ecx
    // 11: 48 8b bc c8 60 68 03 00       movq    0x36860(%rax,%rcx,8), %rdi
    // 19: 8b 07                         movl    (%rdi), %eax
    // 1b: 85 c0                         testl   %eax, %eax
    // 1d: 78 06                         js      0x25 <_JIT_ENTRY+0x25>
    // 1f: ff c0                         incl    %eax
    // 21: 89 07                         movl    %eax, (%rdi)
    // 23: eb 04                         jmp     0x29 <_JIT_ENTRY+0x29>
    // 25: 48 83 cf 01                   orq     $0x1, %rdi

I think this is prior to our CFG optimizations in the backend, so it's not 100% accurate, but pretty close.

_LOAD_CONST_INLINE_BORROW:

    // 
    // _LOAD_CONST_INLINE_BORROW_r01.o:       file format elf64-x86-64
    // 
    // Disassembly of section .text:
    // 
    // 0000000000000000 <_JIT_ENTRY>:
    // 0: 48 bf 00 00 00 00 00 00 00 00 movabsq $0x0, %rdi
    // 0000000000000002:  R_X86_64_64  _JIT_OPERAND0
    // a: 48 83 cf 01                   orq     $0x1, %rdi

This is a really nice reduction. Good job!

Comment thread Lib/test/test_capi/test_opt.py Outdated
trdthg force-pushed the trdthg/feature/jit-load-common-constant branch from 19fc90f to b37ec56 Compare March 18, 2026 12:30

Copy link
Copy Markdown
Member

We generally don't force push, because all PRs in CPython are squash-merged. So just push normal commits, thanks!

Fidget-Spinner left a comment •
edited
Loading

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Once again, LGTM. Thanks for this!

Fidget-Spinner merged commit 98977ca into python:main Mar 19, 2026
66 checks passed
ljfp pushed a commit to ljfp/cpython that referenced this pull request Apr 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL