Repository navigation
Inline stack switching - #680
Merged
Merged
Conversation
linxuanm
marked this pull request as ready for review
September 5, 2026 17:51
linxuanm
marked this pull request as draft
September 16, 2026 18:03
linxuanm
force-pushed
the
inline-stack-switching
branch
from
September 23, 2026 16:26
a11dcff to
369c040
Compare
linxuanm
marked this pull request as ready for review
September 23, 2026 18:07
Each `resume` site now records a per-pc handler table (suspend clauses first, then switch clauses) built by the code validator and stored in `FuncHandlerInfo.resume_sites`. When the interpreter or SPC resumes a continuation it publishes that table and its tier on the parent `NativeStack`, and the table is cleared when the child returns, is unwound, or suspends. The SPC fills in each suspend clause's stub address after compilation so generated code can redirect a parent frame without a runtime call. Continuations are now consumed directly from their value-stack slot instead of being popped into an XMM register, and the stack state store is a byte store so it does not clobber the neighbouring byte fields. `NativeStack` shadow-checks every runtime handler lookup against the published table so mismatches fail loudly while the tables are new.
`suspend` compiled by the SPC no longer calls into the runtime. The generated code walks the parent chain comparing the tag against each stack's published handler table, redirects the handling frame to the matching clause (its SPC stub, or the interpreter suspend entry with the frame's ip and stp rewritten), copies the payload and the continuation onto the handler's value stack, marks the current stack suspended and enters the handler stack directly.
`switch` compiled by the SPC consumes the target continuation, finds the switch clause in the published handler tables, splices the target's stack chain under that handler in place of the current chain (including the return route through the parent's rsp pointer), passes the payload and the continuation of the current stack to the target and enters it, all without a runtime call.
linxuanm
force-pushed
the
inline-stack-switching
branch
from
October 13, 2026 18:05
a3e836b to
ab1ff15
Compare
Contributor
Author
|
I just rebased + inlined assembly helpers! |
titzer
approved these changes
Oct 19, 2026
titzer
left a comment
Owner
There was a problem hiding this comment.
I'm going to merge and refactor this under a working tree.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.