-
Couldn't load subscription status.
- Fork 5.2k
Improve startup perf by avoiding JIT when invoking well-known signatures #115345
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
Closed
Closed
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
d9b1877
Improve startup perf by avoiding JIT when invoking well-known signatures
steveharter 152f1c9
Fix issue with byref return; support rare enums
steveharter ca22090
Update unloadable assembly test that was flawed since reflection used…
steveharter db1b503
Add Mono intepreter to ActiveIssue for calling assembly test
steveharter d15dd74
Add Mono intepreter to ActiveIssue for calling assembly test 2
steveharter 6f28121
Add Mono intepreter to ActiveIssue for calling assembly test 3
steveharter File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 22 additions & 6 deletions
28
src/coreclr/System.Private.CoreLib/src/System/Reflection/ConstructorInvoker.CoreCLR.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,21 +1,37 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System.Diagnostics; | ||
| using System.Runtime.CompilerServices; | ||
| using static System.Reflection.InvokerEmitUtil; | ||
| using static System.Reflection.MethodBase; | ||
| using static System.RuntimeType; | ||
|
|
||
| namespace System.Reflection | ||
| { | ||
| public partial class ConstructorInvoker | ||
| { | ||
| private readonly Signature? _signature; | ||
| private readonly CreateUninitializedCache? _allocator; | ||
|
|
||
| [MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
| private object CreateUninitializedObject() => _allocator!.CreateUninitializedObject(_declaringType); | ||
|
|
||
| internal unsafe ConstructorInvoker(RuntimeConstructorInfo constructor) : this(constructor, constructor.Signature.Arguments) | ||
| private bool ShouldAllocate | ||
| { | ||
| _signature = constructor.Signature; | ||
| _invokeFunc_RefArgs = InterpretedInvoke; | ||
| [MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
| get => _allocator is not null; | ||
| } | ||
| private unsafe Delegate CreateInvokeDelegateForInterpreted() | ||
| { | ||
| Debug.Assert(MethodInvokerCommon.UseInterpretedPath); | ||
| Debug.Assert(_strategy == InvokerStrategy.Ref4 || _strategy == InvokerStrategy.RefMany); | ||
|
|
||
| return (InvokeFunc_RefArgs)InterpretedInvoke; | ||
| } | ||
|
|
||
| private unsafe object? InterpretedInvoke(object? obj, IntPtr* args) | ||
| private unsafe object? InterpretedInvoke(IntPtr _, object? obj, IntPtr* args) | ||
| { | ||
| return RuntimeMethodHandle.InvokeMethod(obj, (void**)args, _signature!, isConstructor: obj is null); | ||
| return RuntimeMethodHandle.InvokeMethod(obj, (void**)args, _method.Signature, isConstructor: obj is null); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 34 additions & 18 deletions
52
src/coreclr/System.Private.CoreLib/src/System/Reflection/MethodBaseInvoker.CoreCLR.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,38 +1,54 @@ | ||
| // Licensed to the .NET Foundation under one or more agreements. | ||
| // The .NET Foundation licenses this file to you under the MIT license. | ||
|
|
||
| using System.Diagnostics; | ||
| using System.Reflection.Emit; | ||
| using System.Runtime.CompilerServices; | ||
| using static System.Reflection.InvokerEmitUtil; | ||
| using static System.Reflection.MethodBase; | ||
| using static System.RuntimeType; | ||
|
|
||
| namespace System.Reflection | ||
| { | ||
| internal partial class MethodBaseInvoker | ||
| { | ||
| private readonly Signature? _signature; | ||
| private readonly CreateUninitializedCache? _allocator; | ||
|
|
||
| internal unsafe MethodBaseInvoker(RuntimeMethodInfo method) : this(method, method.Signature.Arguments) | ||
| { | ||
| _signature = method.Signature; | ||
| _invocationFlags = method.ComputeAndUpdateInvocationFlags(); | ||
| _invokeFunc_RefArgs = InterpretedInvoke_Method; | ||
| } | ||
| [MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
| private object CreateUninitializedObject() => _allocator!.CreateUninitializedObject(_declaringType!); | ||
|
|
||
| internal unsafe MethodBaseInvoker(RuntimeConstructorInfo constructor) : this(constructor, constructor.Signature.Arguments) | ||
| private bool ShouldAllocate | ||
| { | ||
| _signature = constructor.Signature; | ||
| _invocationFlags = constructor.ComputeAndUpdateInvocationFlags(); | ||
| _invokeFunc_RefArgs = InterpretedInvoke_Constructor; | ||
| [MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
| get => _allocator is not null; | ||
| } | ||
|
|
||
| internal unsafe MethodBaseInvoker(DynamicMethod method, Signature signature) : this(method, signature.Arguments) | ||
| private unsafe Delegate CreateInvokeDelegateForInterpreted() | ||
| { | ||
| _signature = signature; | ||
| _invokeFunc_RefArgs = InterpretedInvoke_Method; | ||
| Debug.Assert(MethodInvokerCommon.UseInterpretedPath); | ||
| Debug.Assert(_strategy == InvokerStrategy.Ref4 || _strategy == InvokerStrategy.RefMany); | ||
|
|
||
| if (_method is RuntimeMethodInfo) | ||
| { | ||
| return (InvokeFunc_RefArgs)InterpretedInvoke_Method; | ||
| } | ||
|
|
||
| if (_method is RuntimeConstructorInfo) | ||
| { | ||
| return (InvokeFunc_RefArgs)InterpretedInvoke_Constructor; | ||
| } | ||
|
|
||
| Debug.Assert(_method is DynamicMethod); | ||
| return (InvokeFunc_RefArgs)InterpretedInvoke_DynamicMethod; | ||
| } | ||
|
|
||
| private unsafe object? InterpretedInvoke_Constructor(object? obj, IntPtr* args) => | ||
| RuntimeMethodHandle.InvokeMethod(obj, (void**)args, _signature!, isConstructor: obj is null); | ||
| private unsafe object? InterpretedInvoke_Method(IntPtr _, object? obj, IntPtr* args) => | ||
| RuntimeMethodHandle.InvokeMethod(obj, (void**)args, ((RuntimeMethodInfo)_method).Signature, isConstructor: false); | ||
|
|
||
| private unsafe object? InterpretedInvoke_Constructor(IntPtr _, object? obj, IntPtr* args) => | ||
| RuntimeMethodHandle.InvokeMethod(obj, (void**)args, ((RuntimeConstructorInfo)_method).Signature, isConstructor: obj is null); | ||
|
|
||
| private unsafe object? InterpretedInvoke_Method(object? obj, IntPtr* args) => | ||
| RuntimeMethodHandle.InvokeMethod(obj, (void**)args, _signature!, isConstructor: false); | ||
| private unsafe object? InterpretedInvoke_DynamicMethod(IntPtr _, object? obj, IntPtr* args) => | ||
| RuntimeMethodHandle.InvokeMethod(obj, (void**)args, ((DynamicMethod)_method).Signature, isConstructor: false); | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.