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

Handle blittable byref returns in built-in marshalling #72433

Merged
merged 1 commit into from
Jul 20, 2022

Conversation

jkotas
Copy link
Member

@jkotas jkotas commented Jul 19, 2022

Fixes #72316

{
var pointedAtType = type.GetParameterType();
if (!pointedAtType.IsPrimitive && !type.IsEnum && marshallerType != MarshallerType.Field
Copy link
Member Author

@jkotas jkotas Jul 19, 2022

Choose a reason for hiding this comment

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

type.IsEnum was always false here since type was a byref.

type = type.GetParameterType();

if (!type.IsPrimitive && type.IsValueType && marshallerType != MarshallerType.Field
if (type.IsValueType && !type.IsPrimitive && !type.IsEnum && !isField
Copy link
Member Author

@jkotas jkotas Jul 19, 2022

Choose a reason for hiding this comment

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

Trying to make these conditions consistent and more in sync with CoreCLR logic. This path should be only ever used by managed C++ so it does not matter a whole lot anyway.

{
ILEmitter emitter = _ilCodeStreams.Emitter;

_managedHome = new Home(emitter.NewLocal(ManagedParameterType), ManagedParameterType, isByRef: false);
Copy link
Member Author

Choose a reason for hiding this comment

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

We just need to create locals of the right type. The default implementation works fine otherwise.

Copy link
Member

@MichalStrehovsky MichalStrehovsky left a comment

Choose a reason for hiding this comment

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

Thank you!

@jkotas jkotas merged commit 2ccf0d5 into dotnet:main Jul 20, 2022
@jkotas jkotas deleted the byref-return branch July 20, 2022 01:22
@ghost ghost locked as resolved and limited conversation to collaborators Aug 19, 2022
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.

[NativeAOT] Can't call a function pointer with a ref return value
2 participants