-
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
[NativeAOT] Reflection Invoke refactoring #73131
Conversation
- Refactored reflection Invoke in NativeAOT to be similar to how it is done in CoreCLR. - All argument validation and coercion is done via static code now. This makes the reflection invoke stubs much smaller and the AOT compiler side a lot simpler. - The invoke stub is minimal now and just takes the arguments for the methods to invoke as "Span of byrefs". The two notable differences with CoreCLR are: - The invoke stub takes the function pointer to call as an argument to allow sharing of the stubs between methods with the same signature. CoreCLR has the thunks non-sharable currently. We have discussed sharing them among methods with the same signature like it is done here. - The return value is returned as byref. CoreCLR thunk does boxing of the return value as part of the stub. Again, we have discussed to do it this way in CoreCLR too, we just did not have time to do it yet. Fixes dotnet#72548
0bef061
to
b08f4ee
Compare
Some perf numbers
The extra fixed overhead that is observable in invoke static method with no arguments is due extra "Invoker" layer in native AOT. I am going to delete that layer in subsequent PRs. |
cc @steveharter @dotnet/area-system-reflection |
/azp run runtime-extra-platforms |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run runtime-extra-platforms |
Azure Pipelines successfully started running 1 pipeline(s). |
@MichalStrehovsky @dotnet/ilc-contrib This is ready for review. |
/azp run runtime-extra-platforms |
Azure Pipelines successfully started running 1 pipeline(s). |
/azp run runtime-extra-platforms |
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice!
src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/DynamicInvokeInfo.cs
Outdated
Show resolved
Hide resolved
src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/DynamicInvokeInfo.cs
Outdated
Show resolved
Hide resolved
src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/DynamicInvokeInfo.cs
Outdated
Show resolved
Hide resolved
src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/DynamicInvokeInfo.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: Michal Strehovský <MichalStrehovsky@users.noreply.github.com>
@jkotas I think this broke the API compat for AOT.
|
@akoeplinger It looks like your #72143 was not updated to account for my changes. Could you please fix it up? |
Yep, I did merge main into my PR branch but looks like it was a few minutes before your PR went it. |
Fixed build break caused by merging dotnet#73131 and dotnet#73131 around the same time.
Opened a PR with the fix: #73248 |
Fixes #72548