Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: python/cpython
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: main
Choose a base ref
...
head repository: nelhage/cpython
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: computed-goto-nomerge
Choose a head ref
Checking mergeability… Don’t worry, you can still create the pull request.
  • 1 commit
  • 1 file changed
  • 1 contributor

Commits on Feb 11, 2025

  1. Prevent the compiler from merging computed-goto dispatches

    When compiling the computed-goto interpreter, every opcode
    implementation ends with an identical chunk of code, generated by the
    `DISPATCH()` macro. In some cases, the compiler is able to notice
    this, and replaces the code in one or more opcodes with a jump into
    the tail portion of a different opcode.
    
    However, we specifically **don't** want that to happen; the entire
    premise of using computed gotos is to lift more information into the
    instruction pointer in order to give the hardware branch-target-
    predictor more information to work with! In my preliminary tests, this
    tail-merging of opcode implementations explains most of the
    performance improvement of the new tail-call interpreter (#128718) --
    compilers are much less willing to merge code across functions, and so
    the tail-call interpreter preserves all (or at least more) of the
    individual `DISPATCH` sites.
    
    This change attempts to prevent the merging of `DISPATCH` calls, by
    adding an (empty) `__asm__ volatile`, which acts as an opaque barrier
    to the optimizer, preventing it from considering all of these
    sequences as identical.
    nelhage committed Feb 11, 2025
    Configuration menu
    Copy the full SHA
    4603470 View commit details
    Browse the repository at this point in the history
Loading