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

Fix tailcall regression with compiled F# #41206

Merged
merged 2 commits into from
Aug 25, 2020
Merged

Conversation

jkotas
Copy link
Member

@jkotas jkotas commented Aug 22, 2020

Fixes #40864

@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label Aug 22, 2020
@jkotas
Copy link
Member Author

jkotas commented Aug 22, 2020

@AndyAyersMS Is it possible to trigger the tailcall stress runs from the CI?

@AndyAyersMS
Copy link
Member

Yes, it is one of the variations in runtime-coreclr jitstress.

@jakobbotsch
Copy link
Member

Nice! And a negative line diff.

You can take InstantiatingStub1 test from jakobbotsch@b1b668a, it is essentially Andy's example slightly modified and should pass with this change. The InstantiatingStub2 test goes through ldftn so that one will need to be removed.

@jkotas jkotas marked this pull request as ready for review August 23, 2020 01:05
@erozenfeld
Copy link
Member

@jkotas Once #41059 is merged, it would be good to rebase this one and run runtime-coreclr jitstress and runtime-coreclr libraries-jitstress on top of that change. #41059 forces all tail calls under tailcallstress to be helper-based calls. I'm just waiting for someone to review a test change in System.Threading.Threads.Tests.ThreadTests.ConstructorTest there. Can you review it?

@jkotas jkotas force-pushed the issue-40864 branch 2 times, most recently from 7c00593 to 3425dc3 Compare August 24, 2020 00:20
@jkotas
Copy link
Member Author

jkotas commented Aug 24, 2020

@dotnet/jit-contrib This is blocked on #41059. Ready for review otherwise.

Copy link
Member

@jakobbotsch jakobbotsch left a comment

Choose a reason for hiding this comment

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

LGTM. Nice to see the optimizations also, that should remove a function call from the hot path.

@erozenfeld
Copy link
Member

@jkotas #41059 has been merged.

Copy link
Member

@AndyAyersMS AndyAyersMS left a comment

Choose a reason for hiding this comment

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

Changes LGTM.

Should we also make updates to the design doc?

@jkotas
Copy link
Member Author

jkotas commented Aug 25, 2020

design doc

I have read the design doc and I believe everything in the doc is still accurate. I like that the design doc is focused on the concept and it does not go into explaining every detail.

Let me know if there is a specific fact that you would like to see captured.

jkotas and others added 2 commits August 24, 2020 22:49
This change skips instantiating stubs for direct tailcalls and instead passes the inst argument directly to the target method.

Fixes dotnet#40864
pCode->EmitCALL(METHOD__STUBHELPERS__NEXT_CALL_RETURN_ADDRESS, 0, 1);
// All arguments are loaded on the stack, it is safe to disable the GC reporting of ArgBuffer now.
// This is optimization to avoid extending argument lifetime unnecessarily.
// We still need to report the inst argument of shared generic code to prevent it from being unloaded. The inst
Copy link
Member Author

@jkotas jkotas Aug 25, 2020

Choose a reason for hiding this comment

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

FYI: I have noticed that nothing guarantees that the tailcall target function pointer is kept alive and thus it may be unloaded. It would be a very corner-case situation that is unlikely to be ever hit in a real-world. I have opened #41314 on it.

@erozenfeld
Copy link
Member

@jkotas I recommend also running runtime-coreclr libraries-jitstress.

@jkotas
Copy link
Member Author

jkotas commented Aug 25, 2020

The test failure is #40916. libraries-jitstress and jitstress optional runs passed.

@jkotas jkotas merged commit e94dc2f into dotnet:master Aug 25, 2020
@jkotas jkotas deleted the issue-40864 branch August 25, 2020 14:18
@jkotas
Copy link
Member Author

jkotas commented Aug 25, 2020

/backport to release/5.0

@github-actions
Copy link
Contributor

Started backporting to release/5.0: https://github.com/dotnet/runtime/actions/runs/223822150

@ghost ghost locked as resolved and limited conversation to collaborators Dec 7, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tailcall regression with compiled F#
5 participants