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

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

Open
markshannon opened this issue May 31, 2024 · 2 comments
Open

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

markshannon opened this issue May 31, 2024 · 2 comments
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs)

Comments

@markshannon
Copy link
Member

markshannon commented May 31, 2024

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

@Eclips4 Eclips4 added the interpreter-core (Objects, Python, Grammar, and Parser dirs) label May 31, 2024
@python python deleted a comment from Renatoff67 May 31, 2024
@markshannon
Copy link
Member Author

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

@colesbury
Copy link
Contributor

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

markshannon added a commit that referenced this issue Oct 7, 2024
* Spill the evaluation around escaping calls in the generated interpreter and JIT. 

* The code generator tracks live, cached values so they can be saved to memory when needed.

* Spills the stack pointer around escaping calls, so that the exact stack is visible to the cycle GC.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
interpreter-core (Objects, Python, Grammar, and Parser dirs)
Projects
None yet
Development

No branches or pull requests

3 participants