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

Mono: support CallConvSuppressGCTransition #47006

Merged
merged 4 commits into from
Jan 15, 2021

Conversation

lambdageek
Copy link
Member

@lambdageek lambdageek commented Jan 14, 2021

  • Parse modopt encoded calling conventions
    Add suppress_gc_transition bit to MonoMethodSignature to add support for the SuppressGCTransition unmanaged calling convention modifier.

  • Don't emit a wrapper on calli if suppress_gc_transition is set

    This adds support for delegate* unmanaged[Cdecl, SuppressGCTransition] <TRet, TArgs...> function pointers. (And other base calling conventions other than Cdecl).

  • Allow blittable types in mono_marshal_get_native_func_wrapper_indirect

    This was already used by C++/CLI, so the C# function pointers spec allows blittable types in unmanaged function pointer types.

  • Remove SuppressGCTransitionTest from exclude list

Fixes #46451, Contributes to #38480

Add suppress_gc_transition bit to MonoMethodSignature to add support for
the SuppressGCTransition unmanaged calling convention modifier.
This adds support for `delegate* unmanaged[Cdecl, SuppressGCTransition] <TRet,
TArgs...>` function pointers.
(And other base calling conventions other than Cdecl).
…er_indirect

This was already used by C++/CLI, so the C# function pointers spec allows blittable types in
unmanaged function pointer types.
@jkoritzinsky
Copy link
Member

Don't forget to re-enable the SuppressGCTransition runtime test test. It's disabled in issues.targets.

@lambdageek
Copy link
Member Author

Don't forget to re-enable the SuppressGCTransition runtime test test. It's disabled in issues.targets.

Done. It's the last commit in the PR 😁

@@ -3688,13 +3688,19 @@ mono_marshal_get_native_func_wrapper_indirect (MonoClass *caller_class, MonoMeth
g_assert (!sig->hasthis && ! sig->explicit_this);
g_assert (!sig->is_inflated && !sig->has_type_parameters);

#if 0
/*
Copy link
Contributor

Choose a reason for hiding this comment

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

How can non-blittable types be passed to unmanaged code, how are they marshalled ?

Copy link
Member Author

Choose a reason for hiding this comment

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

(I'm going by what I see in #46402 (comment))

It works the same way as a normal pinvoke: the wrapper does marshalling based on the managed signature. we don't know the exact callee, but we know the types.

@lambdageek lambdageek merged commit a3b37a2 into dotnet:master Jan 15, 2021
@ghost ghost locked as resolved and limited conversation to collaborators Feb 14, 2021
@lambdageek lambdageek deleted the hack-suppress_gc_transition-bit branch March 7, 2021 21:55
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Mono] Implement support for CallConvSuppressGCTransition
3 participants