Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace tailcall dispatcher with C# version once there is function pointer support #35559

Closed
jakobbotsch opened this issue Apr 28, 2020 · 0 comments · Fixed by #38938
Closed
Assignees
Milestone

Comments

@jakobbotsch
Copy link
Member

Currently the helper-based tailcall support dynamically emits a dispatcher that uses calli:

// This creates the dispatcher used to dispatch sequences of tailcalls. In C#
// code it is the following function. Once C# gets function pointer support this
// function can be put in System.Private.CoreLib.
// private static unsafe void DispatchTailCalls(
// IntPtr callersRetAddrSlot, IntPtr callTarget, IntPtr retVal)
// {
// IntPtr callersRetAddr;
// TailCallTls* tls = GetTailCallInfo(callersRetAddrSlot, &callersRetAddr);
// PortableTailCallFrame* prevFrame = tls->Frame;
// if (callersRetAddr == prevFrame->TailCallAwareReturnAddress)
// {
// prevFrame->NextCall = callTarget;
// return;
// }
//
// PortableTailCallFrame newFrame;
// newFrame.Prev = prevFrame;
//
// try
// {
// tls->Frame = &newFrame;
//
// do
// {
// newFrame.NextCall = IntPtr.Zero;
// var fptr = (func* void(IntPtr, IntPtr, void*))callTarget;
// fptr(tls->ArgBuffer, retVal, &newFrame.TailCallAwareReturnAddress);
// callTarget = newFrame.NextCall;
// } while (callTarget != IntPtr.Zero);
// }
// finally
// {
// tls->Frame = prevFrame;
// }
// }

This dispatcher can be put in System.Private.CoreLib once there is function pointer support.

@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added area-Infrastructure-coreclr untriaged New issue has not been triaged by the area owner labels Apr 28, 2020
@jkotas jkotas added this to the 5.0 milestone Apr 28, 2020
@mangod9 mangod9 removed the untriaged New issue has not been triaged by the area owner label May 1, 2020
jakobbotsch added a commit to jakobbotsch/runtime that referenced this issue Jul 8, 2020
jkotas pushed a commit that referenced this issue Jul 10, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants