Skip to content

Spill the stack pointer across calls in the interpreter. #119866

Description

@markshannon

For performance we keep the stack pointer in a register, however this means that the stack pointer is invisible to debuggers and other tools. If we spill the stack pointer across "escaping" calls, then most of the time we want to inspect the evaluation the stack pointer should be in memory.
Spilling the stack pointer is also a necessary precursor to deferred reference counting: faster-cpython/ideas#677, #117139, as it means there is no need to redundantly set the unused part of the stack to NULL.

Since the C compiler needs to spill values around calls, manually spilling the stack pointer has quite a low cost. It limits the freedom of the C compiler to allocate registers, but not that much.

Linked PRs

Activity

  1. deleted a comment from Renatoff67 on May 31, 2024
  2. markshannon commented on Jun 6, 2024

    @markshannon
    MemberAuthor

    Benchmarking shows negligible slowdown even when spilling the stack pointer on all escaping calls.

  3. colesbury commented on Aug 13, 2024

    @colesbury
    Contributor

    @markshannon, are you still planning to work on this? If not, I can take a look at it.

  4. added a commit that references this issue on Oct 7, 2024
  5. added a commit that references this issue on Mar 26, 2025
  6. added a commit that references this issue on Apr 1, 2025
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)

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions