Repository navigation
jit: restore all callee-saved registers in conditional block epilogues - #105
Merged
GloriousTacoo merged 2 commits intoOct 28, 2026
Merged
GloriousTacoo merged 2 commits into
GloriousTacoo merged 2 commits into
Conversation
terminate_block_conditional() and the AL (always) case of translate_b_cond() emitted a taken-branch epilogue that popped only RBP, while the function prologue pushes RBP, R12, R13, R14 and R15. The taken path therefore returned with RSP 32 bytes below where the caller expects it, and ret consumed a saved register instead of the return address (crash on the first taken conditional branch, and on every AL-flag branch). Both epilogues now pop R15, R14, R13, R12 and then RBP. is_dirty is also cleared after the first register flush so the second flush does not re-emit the same stores, keeping the jcc offset exact. Signed-off-by: GabrielGonHo <195778548+GabrielGonHo@users.noreply.github.com>
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.
Description
The function prologue in �al_tier1_compiler_translate() pushes five callee-saved registers (RBP, R12, R13, R14, R15), but two epilogues only popped one of them:
The taken path therefore returned with RSP 32 bytes below where the caller expects it, and
et consumed a saved register instead of the return address. The first taken conditional branch (and every AL-flag branch) crashed. The fallthrough epilogue and erminate_block() already pop all five, so this was an oversight in the two taken paths.
Both epilogues now pop R15, R14, R13, R12, then RBP.
A second issue in erminate_block_conditional(): lush_dirty_registers() was called three times without ever clearing compiler->is_dirty, so the second and third calls re-pushed and re-emitted the same stores (the second batch landed after the fallthrough
et, and the jcc offset only accounted for one batch). is_dirty is now cleared after the first flush, making the later flushes no-ops and the jcc offset exact.
Type of Change
Testing
et of the taken path.