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-115999: Enable specialization of CALL instructions in free-threaded builds #127123

Open
wants to merge 24 commits into
base: main
Choose a base branch
from

Commits on Nov 20, 2024

  1. Configuration menu
    Copy the full SHA
    6d9b6a2 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    30e25d2 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    92160de View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    4754921 View commit details
    Browse the repository at this point in the history
  5. Remove unneeded code

    mpage committed Nov 20, 2024
    Configuration menu
    Copy the full SHA
    6a20bb0 View commit details
    Browse the repository at this point in the history
  6. Enable almost all specializations of CALL

    _CALL_ALLOC_AND_ENTER_INIT will be addressed in a separate PR
    mpage committed Nov 20, 2024
    Configuration menu
    Copy the full SHA
    ea7206d View commit details
    Browse the repository at this point in the history
  7. Regen files

    mpage committed Nov 20, 2024
    Configuration menu
    Copy the full SHA
    d5375f1 View commit details
    Browse the repository at this point in the history
  8. Fix implementation of CALL_LIST_APPEND in free-threaded builds

    This needs to acquire a critical section on the list.
    mpage committed Nov 20, 2024
    Configuration menu
    Copy the full SHA
    a2ca192 View commit details
    Browse the repository at this point in the history
  9. Configuration menu
    Copy the full SHA
    2ab08f2 View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    3534246 View commit details
    Browse the repository at this point in the history
  11. Make CALL_ALLOC_AND_ENTER_INIT thread-safe

    - Modify `get_init_for_simple_managed_python_class` to return both init
      as well as the type version at the time of lookup.
    - Modify caching logic to verify that the current version of the type
      matches the version at the time of lookup. This prevents potentially
      caching a stale value if we race with an update to __init__.
    - Only cache __init__ functions that are deferred in free-threaded builds.
      This ensures that the borrowed reference to __init__ that is stored in
      the cache is valid if the type version guard in _CHECK_AND_ALLOCATE_OBJECT
      passes:
      1. The type version is cleared before the reference in the MRO to __init__
         is destroyed.
      2. If the reference in (1) was the last reference then the __init__ method
         will be queued for deletion the next time GC runs.
      3. GC requires stopping the world, which forces a synchronizes-with operation
         between all threads.
      4. If the GC collects the cached __init__, then type's version will have been
         updated *and* the update will be visible to all threads, so the guard
         cannot pass.
    - There are no escaping calls in between loading from the specialization cache
      and pushing the frame. This is a requirement for the default build.
    mpage committed Nov 20, 2024
    Configuration menu
    Copy the full SHA
    acda1c6 View commit details
    Browse the repository at this point in the history
  12. Regenerate files

    mpage committed Nov 20, 2024
    Configuration menu
    Copy the full SHA
    fdfa678 View commit details
    Browse the repository at this point in the history
  13. Configuration menu
    Copy the full SHA
    ad2e15c View commit details
    Browse the repository at this point in the history
  14. Configuration menu
    Copy the full SHA
    0003d00 View commit details
    Browse the repository at this point in the history
  15. Undo refactor

    mpage committed Nov 20, 2024
    Configuration menu
    Copy the full SHA
    8ebd331 View commit details
    Browse the repository at this point in the history
  16. Configuration menu
    Copy the full SHA
    4c1ad6c View commit details
    Browse the repository at this point in the history

Commits on Nov 21, 2024

  1. Configuration menu
    Copy the full SHA
    57ba52d View commit details
    Browse the repository at this point in the history
  2. Remove unused define

    mpage committed Nov 21, 2024
    Configuration menu
    Copy the full SHA
    8ebd73d View commit details
    Browse the repository at this point in the history
  3. Enable tests

    mpage committed Nov 21, 2024
    Configuration menu
    Copy the full SHA
    8651ebe View commit details
    Browse the repository at this point in the history

Commits on Nov 22, 2024

  1. Configuration menu
    Copy the full SHA
    4c7837f View commit details
    Browse the repository at this point in the history

Commits on Nov 25, 2024

  1. Configuration menu
    Copy the full SHA
    4b0a850 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    d8a67c2 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    3e8d85e View commit details
    Browse the repository at this point in the history

Commits on Nov 26, 2024

  1. Fix issue with _CREATE_INIT_FRAME

    Fix a bug in `_CREATE_INIT_FRAME` where the frame is pushed to the stack on failure.
    `_CREATE_INIT_FRAME` pushes a pointer to the new frame onto the stack for consumption
    by the next uop. When pushing the frame fails, we do not want to push the result (NULL)
    to the stack because it is not a valid stackref and will be exposed to the generic
    error handling code in the interpreter loop. This worked in default builds because
    `PyStackRef_NULL` is `NULL` in default builds, which is not the case in free-threaded
    builds.
    mpage committed Nov 26, 2024
    Configuration menu
    Copy the full SHA
    de0e2ee View commit details
    Browse the repository at this point in the history