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

Enable Mono for using faster invoke stubs #89108

Merged
merged 4 commits into from
Jul 25, 2023

Conversation

steveharter
Copy link
Member

@steveharter steveharter commented Jul 18, 2023

Add support for Mono to emit faster invoke stubs for both the new invoke APIs added in #88415 as well as standard invoke.

Replacement for closed issue #88952

@ghost
Copy link

ghost commented Jul 18, 2023

Tagging subscribers to this area: @dotnet/area-system-reflection
See info in area-owners.md if you want to be subscribed.

Issue Details

[Verifying Tests]

Author: steveharter
Assignees: steveharter
Labels:

area-System.Reflection

Milestone: -

@EgorBo
Copy link
Member

EgorBo commented Jul 18, 2023

just curious - is it possible to avoid boxed Nullable<> in the first place? I guess it's not possible to create ones with plain C# (where boxed nullables are boxed as just plain values)

@steveharter
Copy link
Member Author

just curious - is it possible to avoid boxed Nullable<> in the first place? I guess it's not possible to create ones with plain C# (where boxed nullables are boxed as just plain values)

It's done this way primarily for the interpreted path, which doesn't use emit and is located in the native runtime -- it either needs to be passed a pointer to a nullable or have special logic that creates a nullable from the null \ <T> input. The design we went with keeps the native code (and also emit) to be minimal, so we went with first approach where we pass in a pointer to a nullable which is triggered from the library reflection invoke code. The most straightforward way of doing that is to box a nullable.

Also, for both the interpreted path and the various emit paths we also wanted to normalize the object arg input and have the same validation\fix-up code so we can select the strategy without having to do special fix-ups and validation per strategy type.

return CheckValueStatus.Success;

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 needed ?

Copy link
Member Author

@steveharter steveharter Jul 25, 2023

Choose a reason for hiding this comment

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

Thanks for this. With the last commit, it is no longer necessary. Also removed from core CLR.

It was necessary previously since the Opcodes.UnboxAny would throw a InvalidCastException for UIntPtr arguments.

@steveharter steveharter changed the title Unbox a true nullable without Opcodes.Unbox Enable Mono for using faster invoke stubs Jul 25, 2023
@steveharter steveharter merged commit 2427b67 into dotnet:main Jul 25, 2023
@steveharter steveharter deleted the NullableEmit branch July 25, 2023 15:46
@ghost ghost locked as resolved and limited conversation to collaborators Aug 24, 2023
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.

4 participants