Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@jaykrell
Copy link
Contributor

No description provided.

@jaykrell jaykrell requested review from kumpera and vargaz as code owners March 13, 2018 19:37
@jaykrell
Copy link
Contributor Author

Passing through r11 was an attempt to fix the F# regression, but it doesn't fix it.
It still seems like a good idea.
There is larger "problem", significantly whittled away here, that call has a lot of handling that tailcall lacks. Possibly I should refactor more significantly though, and reuse emit_call_body?

Copy link
Contributor

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.

Copy link
Contributor Author

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.

@vargaz
Copy link
Contributor

vargaz commented Mar 13, 2018

The is_supported_tail_call () changes look ok, could you put it into another PR?

@jaykrell
Copy link
Contributor Author

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?).

@jaykrell
Copy link
Contributor Author

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.

@vargaz
Copy link
Contributor

vargaz commented Mar 13, 2018

Currently, verbose_level==1 only prints out about 2 lines per method, everything else is at a higher level.

Copy link
Contributor

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 ?

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.

@jaykrell
Copy link
Contributor Author

Moved method-to-ir.c to #7608

@jaykrell
Copy link
Contributor Author

On the alignment thing..well..my asserts are a start but really miss stuff.
When I hardcode aligned to true, it fails, but not clearly in an interesting way.

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.
The alignment I added to tailcall, btw, I didn't find via assertion failure or disassembly/print of actual values, but the code sure looks wrong, and the fix is based on call -- part of what I was saying where tailcall kind of a pale impersonation of call. It must be different of course, and I suppose it will always be a small subset, but it also seemed/seems to be missing pieces.

I guess remove the assert for now?

frame #2: 0x0000000101f19a80 monosigabrt_signal_handler(_dummy=6, _info=0x00007fff5df1df18, context=0x00007fff5df1df80) at mini-posix.c:209 frame #3: 0x00007fffdf9b7b3a libsystem_platform.dylib_sigtramp + 26
frame #4: 0x00007fffdf8d6d43 libsystem_kernel.dylib__pthread_kill + 11 frame #5: 0x00007fffdf9c4457 libsystem_pthread.dylibpthread_kill + 90
frame #6: 0x00007fffdf83c420 libsystem_c.dylibabort + 129 frame #7: 0x00000001021b8044 monomono_log_write_logfile(log_domain=0x0000000000000000, level=G_LOG_LEVEL_ERROR, hdr=0, message="* Assertion at mini-amd64.c:214, condition !aligned || ((gsize)(code + 1) % 4) == 0' not met\n") at mono-log-common.c:135 frame #8: 0x00000001021adfac monostructured_log_adapter(log_domain=0x0000000000000000, log_level=G_LOG_LEVEL_ERROR, message="* Assertion at mini-amd64.c:214, condition !aligned || ((gsize)(code + 1) % 4) == 0' not met\n", user_data=0x0000000000000000) at mono-logger.c:458 frame #9: 0x00000001021dd2cd monomonoeg_g_logv(log_domain=0x0000000000000000, log_level=G_LOG_LEVEL_ERROR, format="* Assertion at %s:%d, condition %s' not met\n", args=0x00007fff5df1e3b0) at goutput.c:115 frame #10: 0x00000001021dd6c4 monomonoeg_assertion_message(format="* Assertion at %s:%d, condition %s' not met\n") at goutput.c:135 frame #11: 0x0000000101e83d96 monoamd64_patch_aligned(code="?, target=0x00000001025cecd6, aligned=1) at mini-amd64.c:214
frame #12: 0x0000000101ee97bf monoamd64_patch(code="?, target=0x00000001025cecd6) at mini-amd64.c:226 frame #13: 0x0000000101eec41a monomono_arch_patch_code_new(cfg=0x00007f8534800000, domain=0x00007f8531c10170, code="UH\x8b?H??L\x89e?L?m?L?u?L?}?L\x8b?L??H?U\xa8L\x8b?H?E\xb8", ji=0x00007f853480d210, target=0x00000001025cecd6) at mini-amd64.c:6670 frame #14: 0x0000000101ce805c monomono_codegen(cfg=0x00007f8534800000) at mini.c:2351

@jaykrell
Copy link
Contributor Author

Ping? Maybe I should write a varargs tailcall..

@luhenry
Copy link
Contributor

luhenry commented Mar 19, 2018

@vargaz is that PR good to go? Please approve if so. Thank you.

@jaykrell jaykrell merged commit b6f56a1 into mono:master Mar 19, 2018
@jaykrell jaykrell requested a review from lateralusX March 19, 2018 21:54
@jaykrell
Copy link
Contributor Author

@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

@jaykrell
Copy link
Contributor Author

picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
… 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants