Skip to content

Conversation

@visitorckw
Copy link
Collaborator

@visitorckw visitorckw commented Dec 11, 2025

Despite using attribute((musttail)), the compiler may still emit full stack frames and spill callee-saved registers in complex handlers (e.g., do_lw), undermining the benefits of the threaded interpreter.

Integrate Clang's attribute((preserve_none)) (available since Clang 19.1.0) into the MUST_TAIL macro. This attribute modifies the calling convention to avoid preserving registers, thereby minimizing stack setup and register pressure during instruction dispatch.

This ensures more consistent tail call optimization and reduces overhead in the interpreter loop.

Closes: #601


Summary by cubic

Extend MUST_TAIL to include preserve_none when available, so tail-call dispatch avoids stack frames and callee-saved spills. This makes tail calls more reliable and reduces interpreter loop overhead, especially in complex handlers.

Written for commit d8382ab. Summary will update automatically on new commits.

Despite using __attribute__((musttail)), the compiler may still emit
full stack frames and spill callee-saved registers in complex handlers
(e.g., do_lw), undermining the benefits of the threaded interpreter.

Integrate Clang's __attribute__((preserve_none)) (available since
Clang 19.1.0) into the MUST_TAIL macro. This attribute modifies the
calling convention to avoid preserving registers, thereby minimizing
stack setup and register pressure during instruction dispatch.

This ensures more consistent tail call optimization and reduces overhead
in the interpreter loop.

Closes: sysprog21#601
Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

No issues found across 1 file

@jserv jserv added this to the release-2025.2 milestone Dec 12, 2025
@jserv jserv merged commit e861541 into sysprog21:master Dec 12, 2025
13 of 20 checks passed
@jserv
Copy link
Contributor

jserv commented Dec 12, 2025

Thank @visitorckw for contributing!

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.

Suggest using preserve_none to improve tail call optimization in interpreter

2 participants