-
Notifications
You must be signed in to change notification settings - Fork 3.8k
[Tailcall] Cleanup, handle varargs, cleanup varargs handling, be sure not to use unsupported tailcall_membase, pass r11 through, align patches. #7600
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
Conversation
|
Passing through r11 was an attempt to fix the F# regression, but it doesn't fix it. |
mono/mini/method-to-ir.c
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
verbose level==1 is for very high level stuff, >= 2 should be ok.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. I “need” another flag perhaps.
|
The is_supported_tail_call () changes look ok, could you put it into another PR? |
|
Yes I can definitely split it up. I like extra verbose— it is, you know, one line per rare instruction (or maybe more due to inline checks?). |
|
I’m not sure more refactoring is needed, in that tailcall is only currently for patchinfo method, not abs, but still to debug. Ok on the r11 & varargs & abi work? Certainly can split up. |
|
Currently, verbose_level==1 only prints out about 2 lines per method, everything else is at a higher level. |
mono/mini/mini-amd64.c
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this new argument needed ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We frequently patch during initial codegen when alignment doesn’t matter, code not yet running. And also patch later when running and alignment matters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Granted: which instructions patched when? I didn’t check. I can try always asserting & no new param.
mono/mini/mini-amd64.c
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Last param should be false here but probably does not matter.
|
Moved method-to-ir.c to #7608 |
|
On the alignment thing..well..my asserts are a start but really miss stuff. I think as well, the running-ness of code is subject to race conditions. Not just in the obvious way that code is usually not running, but in the sense that the JIT can be running on multiple threads, and therefore JIT code in varying order, therefore might have resolved targets when it JITs, or not until it runs. So, I think there is "something" to do here, but my fix is perhaps not it, incomplete, wrong, etc. I guess remove the assert for now? frame #2: 0x0000000101f19a80 mono |
… opcode == CALLVIRT.
Let R11 through tailcall. Assert alignment when patching.
… function and remove for NT. Tailcall needs a third instance, and it likely gets in the way of NT tailcall, where it is not needed.
very similar to call rip+32 and call [rip + 32]. This might be useful.
|
Ping? Maybe I should write a varargs tailcall.. |
|
@vargaz is that PR good to go? Please approve if so. Thank you. |
|
@lateralusX fixed some NT/amd64 ABI violation fixes -- epilogue must adjust rsp, restore nonvolatiles, and transfer control (jmp, ret, iret). It cannot mov once it starts the nonvolatile restore -- it must be recognized by the unwinder, as seen here: https://github.com/dotnet/coreclr/blob/master/src/unwinder/amd64/unwinder_amd64.cpp#L460 |
|
See here also for the ABI violation fixed: |
… not to use unsupported tailcall_membase, pass r11 through, align patches. (mono/mono#7600) * [Tailcall] Cleanup is_supported_tail_call to only check virtual_, not opcode == CALLVIRT. * [Tailcall] Generate tailcall address earlier to honor NT ABI. Let R11 through tailcall. Assert alignment when patching. * [Tailcall] Factor out two copies of SysV varargs handling to a helper function and remove for NT. Tailcall needs a third instance, and it likely gets in the way of NT tailcall, where it is not needed. * [Tailcall] Teach amd64_patch how to patch jmp rip+32 and jmp [rip + 32] very similar to call rip+32 and call [rip + 32]. This might be useful. * [Tailcall] Fix varargs handling of tailcalls. * Remove new asserts and just leave comments. * [Tailcall] No need to free RAX on non-reg calls. Commit migrated from mono/mono@b6f56a1
No description provided.