GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Refactor the JIT uops · Issue #148211 · python/cpython

Refactor the JIT uops #148211

New issue
Copy link
New issue
Copy link
Closed
Closed
Refactor the JIT uops#148211
Copy link
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-JITtype-featureA feature request or enhancementA feature request or enhancementtype-refactorCode refactoring (with no changes in behavior)Code refactoring (with no changes in behavior)

Description

@Fidget-Spinner
Fidget-Spinner
opened on Apr 7, 2026
Issue body actions

Feature or enhancement

Proposal:

The JIT optimizer initially only allowed a inplace op rewrites. This led to us contorting the JIT uops to fit that.

Now that the JIT optimizer allows more than one op to be written at once, we should clean up and de-duplicate all the composite uops.

E.g.

REPLACE_OP(_POP_TOP_LOAD_CONST_INLINE_BORROW, ..)

should become

ADD_OP(_POP_TOP, ...)
ADD_OP(_LOAD_CONST_INLINE_BORROW, ...)

and _POP_TOP_LOAD_CONST_INLINE_BORROW should then be completely removed from the JIT uops and bytecodes.c. This will allow us to de-duplicate and refactor the code greatly, while making the existing optimizations also more effective as we don't have to do as much repeated work.

Has this already been discussed elsewhere?

This is a minor feature, which does not need previous discussion elsewhere

Links to previous discussion of this feature:

No response

Linked PRs

  • gh-148211: decompose _POP_TOP_LOAD_CONST_INLINE(_BORROW) in JIT #148230
  • gh-148211: refactor bool to explicit uops in JIT #148258
  • gh-148211: decompose _INSERT_1_LOAD_CONST_INLINE(_BORROW) in JIT #148283
  • gh-148211: decompose [_POP_CALL_X/_SHUFFLE_2]_LOAD_CONST_INLINE_BORROW in JIT #148313
  • gh-148211: decompose [_POP_TWO/_INSERT_2]_LOAD_CONST_INLINE_BORROW in JIT #148357
  • gh-148211: decompose _POP_TWO/_POP_CALL(_ONE/_TWO) in JIT #148377
  • gh-148211: decompose _SHUFFLE_3_LOAD_CONST_INLINE_BORROW in JIT #148816

Activity

Next
  1. Fidget-Spinner
    added
    type-featureA feature request or enhancementA feature request or enhancement
    on Apr 7, 2026
  2. Fidget-Spinner commented on Apr 7, 2026

    @Fidget-Spinner
    Fidget-Spinner
    on Apr 7, 2026
    MemberAuthor
    More actions

    @NekoAsakura would you like to work on this?

  3. Fidget-Spinner
    added
    topic-JIT
    type-refactorCode refactoring (with no changes in behavior)Code refactoring (with no changes in behavior)
    on Apr 7, 2026
  4. NekoAsakura commented on Apr 7, 2026

    @NekoAsakura
    NekoAsakura
    on Apr 7, 2026
    Member
    More actions

    Of course! Pls assign it to me <3

  5. Fidget-Spinner commented on Apr 7, 2026

    @Fidget-Spinner
    Fidget-Spinner
    on Apr 7, 2026
    MemberAuthor
    More actions

    @NekoAsakura I don't think we assign things here to non-coreteam, but feel free to comment which ops you are taking op (this is a big issue), and I'll make sure to deconflict. Thanks a lot!

  6. NekoAsakura commented on Apr 7, 2026

    @NekoAsakura
    NekoAsakura
    on Apr 7, 2026
    Member
    More actions

    Uh, I just meant an oral assignment, similar to what you did in #145866 (comment), but no worries!

    I've had a look through composite uops. These are some straightforward POP + LOAD_CONST fusions that can be cleanly decomposed:

    • _POP_TOP_LOAD_CONST_INLINE
    • _POP_TOP_LOAD_CONST_INLINE_BORROW
    • _POP_TWO_LOAD_CONST_INLINE_BORROW
    • _POP_CALL_LOAD_CONST_INLINE_BORROW
    • _POP_CALL_ONE_LOAD_CONST_INLINE_BORROW
    • _POP_CALL_TWO_LOAD_CONST_INLINE_BORROW

    Happy to take the first three in one PR and leave the rest for anyone else who fancies having a go. Sound alright?

  7. Fidget-Spinner commented on Apr 7, 2026

    @Fidget-Spinner
    Fidget-Spinner
    on Apr 7, 2026
    MemberAuthor
    More actions

    Sounds good, thanks for taking these up!

  8. NekoAsakura
    added a commit that references this issue on Apr 7, 2026

    pythongh-148211: decompose `_POP_TOP_LOAD_CONST_INLINE(_BORROW)` in JIT

    0c407bd
  9. NekoAsakura commented on Apr 7, 2026

    @NekoAsakura
    NekoAsakura
    on Apr 7, 2026
    Member
    More actions

    A bit more:

    • _INSERT_1_LOAD_CONST_INLINE
    • _INSERT_1_LOAD_CONST_INLINE_BORROW
    • _LOAD_CONST_UNDER_INLINE
    • _LOAD_CONST_UNDER_INLINE_BORROW
  10. NekoAsakura
    added 3 commits that reference this issue on Apr 8, 2026

    Merge branch 'main' into pythongh-148211/decompose-pop-top

    81d854d

    Merge branch 'main' into pythongh-148211/decompose-pop-top

    a8abce8

    pythongh-148211: decompose `_POP_TOP_LOAD_CONST_INLINE(_BORROW)` in JIT

    d6e454a
  11. Fidget-Spinner
    added a commit that references this issue on Apr 8, 2026

    gh-148211: decompose `_POP_TOP_LOAD_CONST_INLINE(_BORROW)` in JIT (GH…

    d2fa4b2
  12. markshannon commented on Apr 8, 2026

    @markshannon
    markshannon
    on Apr 8, 2026
    Member
    More actions

    I've noticed that some of the optimizer functions are gaining boolean parameters for whether to pop, or insert. To read the code requires constant reference to the function being called.

    For future PRs consider using prefix and/or postfix instructions as arguments, to improve clarity.
    optimize_thing(POP_TOP, value, NOP) is easier to follow than optimize_thing(value, true, false)

    Reacted by Ken Jin and Neko Asakura
  13. 20 remaining items

  14. Fidget-Spinner
    added a commit that references this issue on Apr 11, 2026

    gh-148211: decompose `[_POP_TWO/_INSERT_2]_LOAD_CONST_INLINE_BORROW` …

    72006a7
  15. NekoAsakura
    added 2 commits that reference this issue on Apr 11, 2026

    pythongh-148211: decompose / in JIT

    efab98f

    pythongh-148211: decompose `_POP_TWO/_POP_CALL(_ONE/_TWO)` in JIT

    e290c86
  16. Fidget-Spinner
    added a commit that references this issue on Apr 11, 2026

    gh-148211: decompose `_POP_TWO/_POP_CALL(_ONE/_TWO)` in JIT (GH-148377)

    9831dea
  17. Fidget-Spinner commented on Apr 11, 2026

    @Fidget-Spinner
    Fidget-Spinner
    on Apr 11, 2026
    MemberAuthor
    More actions

    Thanks to a lot of effort from @NekoAsakura , this is done. Thanks a lot for cleaning up the JIT!

  18. Fidget-Spinner
    closed this as completedon Apr 11, 2026
  19. NekoAsakura
    added 2 commits that reference this issue on Apr 20, 2026

    pythongh-148211: decompose `_SHUFFLE_3_LOAD_CONST_INLINE_BORROW` in JIT

    5fa6b83

    Merge branch 'main' into pythongh-148211/decompose-shuffle-3

    b319e64
  20. ljfp
    added 6 commits that reference this issue on Apr 25, 2026

    pythongh-148211: decompose `_POP_TOP_LOAD_CONST_INLINE(_BORROW)` in J…

    7f7ba3d

    pythongh-148211: refactor bool to explicit uops in JIT (pythonGH-148258)

    6eea19b

    pythongh-148211: decompose `_INSERT_1_LOAD_CONST_INLINE(_BORROW)` in …

    79174f9

    pythongh-148211: decompose `[_POP_CALL_X/_SHUFFLE_2]_LOAD_CONST_INLIN…

    c354488

    pythongh-148211: decompose `[_POP_TWO/_INSERT_2]_LOAD_CONST_INLINE_BO…

    ee7689d

    pythongh-148211: decompose `_POP_TWO/_POP_CALL(_ONE/_TWO)` in JIT (py…

    e2c9b33
  21. markshannon
    added a commit that references this issue on Apr 28, 2026

    gh-148211: decompose `_SHUFFLE_3_LOAD_CONST_INLINE_BORROW` in JIT (GH…

    2b6a137
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-JITtype-featureA feature request or enhancementA feature request or enhancementtype-refactorCode refactoring (with no changes in behavior)Code refactoring (with no changes in behavior)

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.