-
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
Add public MethodInvoker and ConstructorInvoker classes #88415
Conversation
Note regarding the This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change. |
Tagging subscribers to this area: @dotnet/area-system-reflection Issue Details[wip]
|
a7581d0
to
3a7296e
Compare
src/libraries/System.Private.CoreLib/src/System/Reflection/MethodInvoker.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Reflection/MethodInvoker.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Reflection/ConstructorInvoker.cs
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Reflection/MethodInvoker.cs
Outdated
Show resolved
Hide resolved
f72e73b
to
a3428ed
Compare
src/coreclr/System.Private.CoreLib/src/System/Reflection/MethodBaseInvoker.CoreCLR.cs
Show resolved
Hide resolved
src/coreclr/System.Private.CoreLib/src/System/Runtime/RuntimeImports.CoreCLR.cs
Outdated
Show resolved
Hide resolved
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.
Left a few NITs, overall looks good to me.
src/coreclr/nativeaot/System.Private.CoreLib/src/System/Reflection/DynamicInvokeInfo.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Reflection/MethodInvoker.cs
Show resolved
Hide resolved
src/coreclr/System.Private.CoreLib/src/System/Runtime/RuntimeImports.CoreCLR.cs
Outdated
Show resolved
Hide resolved
RuntimeType sigType = _argTypes[i]; | ||
|
||
// Convert the type if necessary. | ||
// Note that Type.Missing is not supported. |
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.
NIT: By assuming this applyes to all new Invoke methods, this might be good to be added to the public doc
src/libraries/System.Private.CoreLib/src/System/Runtime/GCFrameRegistration.cs
Outdated
Show resolved
Hide resolved
src/coreclr/System.Private.CoreLib/src/System/Runtime/RuntimeImports.CoreCLR.cs
Outdated
Show resolved
Hide resolved
src/coreclr/nativeaot/System.Private.CoreLib/src/System/RuntimeType.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Runtime/GCFrameRegistration.cs
Outdated
Show resolved
Hide resolved
Improvement in dotnet/perf-autofiling-issues#19968. |
Fixes #85539
Adds fixed-parameter-count and Span-based Invoke APIs for performance, primarily achieved by preventing the
object[]
allocation for when there are <= 4 parameters. Also, additional, faster, emit-based functions are generated for methods that don't haveref\out
parameters and meet other constraints. These are also used by the existing Invoke methods so performance there has increased as well.Todo
Benchmarks
Benchmarks for the new APIs. ~2.4- 3.3x faster for the 4 parameter case with no allocs. Also, these improvements would be greater but they are compared to the existing Invoke API which was also made faster here.
Benchmarks for existing Invoke APIs. Up to 1.4x faster for a property setter. Fewer allocs when >=5 parameters.
Benchmarks for NativeAot. ~1.3-1.7x faster when using the new APIs