Uh oh!
There was an error while loading. Please reload this page.
[interp] Implement tailcalls - #118901
Conversation
Tagging subscribers to this area: @BrzVlad, @janvorli, @kg |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
d4f78ae to
097ccd9CompareThere 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 |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
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
kg
commented
Aug 21, 2025
Rebased and verified that tailcall.cmd still passes in InterpModes 1 and 2 (in addition to |
Uh oh!
There was an error while loading. Please reload this page.
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.)