Conversation
Contributor
|
Tagging subscribers to this area: @BrzVlad, @janvorli, @kg |
jkotas
reviewed
Aug 19, 2025
BrzVlad
reviewed
Aug 20, 2025
d4f78ae to
097ccd9
Compare
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR implements tailcall support for the CoreCLR interpreter, enabling proper tail call optimization for CALL and CALLVIRT operations. The implementation reuses the current stack frame for tail calls instead of creating a new one, which is essential for proper tail call semantics.
Key changes:
- Adds new tail call opcodes (INTOP_CALL_TAIL, INTOP_CALLVIRT_TAIL, INTOP_CALLI_TAIL)
- Implements tail call logic that reuses the current stack frame by copying arguments and reinitializing the frame
- Updates the InterpMethod structure to track argument size needed for tail call argument copying
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/coreclr/vm/interpexec.cpp | Implements tail call execution logic and adds isTailcall flag handling |
| src/coreclr/interpreter/intops.def | Defines new tail call opcodes |
| src/coreclr/interpreter/interpretershared.h | Adds argsSize field to InterpMethod for tail call argument copying |
| src/coreclr/interpreter/compiler.cpp | Updates compiler to emit tail call opcodes and pass argsSize to InterpMethod constructor |
Don't assert on tail calli, just do a non-tail call for now so the application will at least run (but potentially run out of stack) Cleanup fixme comments
Member
Author
|
Rebased and verified that tailcall.cmd still passes in InterpModes 1 and 2 (in addition to |
davidwrighton
approved these changes
Aug 22, 2025
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
This PR currently implements tailcalls for CALL and CALLVIRT. The opcode for tail position calli is also generated but not implemented since it wasn't immediately obvious how to implement it (it doesn't look like the mono interpreter has an opcode for it.)