Skip to content

Add stack reconstruction methods for inlined contexts and wrap reconstruction points in SPC#595

Open
matthew-mojira wants to merge 8 commits intotitzer:masterfrom
matthew-mojira:pr/reconstruction
Open

Add stack reconstruction methods for inlined contexts and wrap reconstruction points in SPC#595
matthew-mojira wants to merge 8 commits intotitzer:masterfrom
matthew-mojira:pr/reconstruction

Conversation

@matthew-mojira
Copy link
Contributor

@matthew-mojira matthew-mojira commented Mar 23, 2026

This commit contains:

  • SinglePassCompiler.emitReconstructStackFrames which is the general purpose stack reconstruction method. It is called from withReconstructedInlinedFrames which wraps stack reconstruction (only needed if in an inlined context) around a piece of compiler code.
  • X86_64SpcModuleCode.reconstructInlinedFramesForTrap which reconstructs stack frames by bumping rsp and inserting fid and pc in the case of a hardware trap (which bypasses the usual stack reconstruction point for traps).
  • SPC code that requires the stack to be reconstructed around that point is wrapped with withReconstructedInlinedFrames

@matthew-mojira matthew-mojira marked this pull request as ready for review March 23, 2026 07:08
@matthew-mojira
Copy link
Contributor Author

I had "fun" using lambdas to make withReconstructedInlinedFrames feel like a syntax object.

@matthew-mojira matthew-mojira changed the title Reconstruct stack frames Add stack reconstruction methods for inlined contexts and wrap reconstruction points in SPC Mar 23, 2026
// Save mem0 base
masm.emit_mov_m_r(ValueKind.REF, frame.mem0_base_slot, mem_reg);

// use same vfp for all frames
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably not right; you probably need to compute the right VFP for each frame as some delta from the current VFP.

Copy link
Contributor Author

@matthew-mojira matthew-mojira Mar 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in e4b2d4a. Does this make sense?

@matthew-mojira
Copy link
Contributor Author

Sneaking in another change in 9bf2aeb to actually increment the metrics added in this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants