-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Mono: correctly handle new 0x09 ("unmanaged") calling convention in metadata #38480
Comments
A MethodRefSig or a StandaloneSig can have the calling convention "unmanaged" which is the default platform calling convention with optional modifiers encoded in the modopts of the return type. See dotnet/roslyn#39865 (comment) and dotnet/runtime#34805 Contributes to dotnet/runtime#38480
An initial attempt is at lambdageek/mono@8684def |
Related CoreCLR PR #39030 Need to handle, in particular the case where |
ikvm changes: |
monodis prints: |
@lambdageek is there anything else to be done? |
I guess the initial work was covered by #38728? So if we're updated in ikdasm and monodis, I guess we're good? |
I'm closing this unless anyone knows of remaining work. The issue's topics seem to be covered. cc: @vargaz |
@CoffeeFlux I dont' think this is done - we still need to land lambdageek/mono@8684def or something like it in order to handle the 0x09 "unmanaged" value. This wasn't in #38728. |
One thing I missed initially is that |
- Add `mono_marshal_get_native_func_wrapper_indirect` This will be used to add a wrapper around `calli <sig>` indirect calls where `sig` has an unmanaged calling convention. We need to do a GC transition before calling an unmanaged function from managed. So this wrapper does it. This is reusing much of the code implemented for `mono_marshal_get_native_func_wrapper_aot` which is used for delegates. - Treat CallConv bit 0x09 as `MONO_CALL_UNMANAGED_MD` This is the C#9 function pointers "unmanaged"+ext calling convention. Additional calling convention details are encoded in the modopts of the return type. This PR doesn't handle the modopts yet - Rewrite `mono_marshal_emit_native_wrapper` to take a new `MonoNativeWrapperFlags` argument instead of a collection of bools. Add a new `EMIT_NATIVE_WRAPPER_FUNC_PARAM_UNBOXED` value. Add support to emit a wrapper that uses an unboxed function pointer as the indirect arg. Related to dotnet/runtime#38480
…20713) - Add `mono_marshal_get_native_func_wrapper_indirect` This will be used to add a wrapper around `calli <sig>` indirect calls where `sig` has an unmanaged calling convention. We need to do a GC transition before calling an unmanaged function from managed. So this wrapper does it. This is reusing much of the code implemented for `mono_marshal_get_native_func_wrapper_aot` which is used for delegates. - Treat CallConv bit 0x09 as `MONO_CALL_UNMANAGED_MD` This is the C#9 function pointers "unmanaged"+ext calling convention. Additional calling convention details are encoded in the modopts of the return type. This PR doesn't handle the modopts yet - Rewrite `mono_marshal_emit_native_wrapper` to take a new `MonoNativeWrapperFlags` argument instead of a collection of bools. Add a new `EMIT_NATIVE_WRAPPER_FUNC_PARAM_UNBOXED` value. Add support to emit a wrapper that uses an unboxed function pointer as the indirect arg. Related to dotnet/runtime#38480 Co-authored-by: lambdageek <[email protected]>
@BrzVlad - is the last tracking item above " interp - ditto - emit GC transitions around calli instructions with the pinvoke bit set." necessary for 6.0 ? |
Assigning to @BrzVlad for the last item |
In #38357, a new calling convention value is added to function signatures. Mono should not crash when we see this value in assemblies.
The runtime should basically treat it the same as cdecl on non-Windows platforms (and on Windows for .net 5, too).
When the execution engine sees the
calli fsig
IL instruction, we will need to look forunmanaged
infsig
and do a GC transition around the call.Next, a
modopt
on the return type of the signature will encode details of the calling convention #34805Finally, if the unmanaged calling convention modopts have
CallConvSuppressGCTransition
as one of the options, we can drop the GC transition around the indirect call.Tasks:
ikdasm
andmonodis
work correctlypinvoke
bit on signatures that encodeunmanaged
calling convention (PR [Mono][jit] Emit GC transitions for "calli unmanaged" instructions #46491)calli
instruction that has pinvoke set. (PR [Mono][jit] Emit GC transitions for "calli unmanaged" instructions #46491)delegate* unmanaged[SuppressGCTransition]
- [Mono] Implement support for CallConvSuppressGCTransition #46451 (PR Mono: support CallConvSuppressGCTransition #47006)calli
instructions with the pinvoke bit set. (PR [interp] Add wrapper for calli to native pointer #57119)The text was updated successfully, but these errors were encountered: