forked from dotnet/runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add IL Emit support for MethodInfo.Invoke() and friends (dotnet#67917)
- Loading branch information
1 parent
1e41844
commit 5195418
Showing
45 changed files
with
1,196 additions
and
654 deletions.
There are no files selected for viewing
This file contains 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
18 changes: 18 additions & 0 deletions
18
src/coreclr/System.Private.CoreLib/src/System/Reflection/ConstructorInvoker.CoreCLR.cs
This file contains 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 |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System.Runtime.CompilerServices; | ||
|
||
namespace System.Reflection | ||
{ | ||
internal partial class ConstructorInvoker | ||
{ | ||
public InvocationFlags _invocationFlags; | ||
|
||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
private unsafe object? InterpretedInvoke(object? obj, IntPtr* arguments) | ||
{ | ||
return RuntimeMethodHandle.InvokeMethod(obj, (void**)arguments, _method.Signature, isConstructor: obj is null)!; | ||
} | ||
} | ||
} |
This file contains 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
24 changes: 0 additions & 24 deletions
24
src/coreclr/System.Private.CoreLib/src/System/Reflection/Emit/DynamicMethodInvoker.cs
This file was deleted.
Oops, something went wrong.
33 changes: 33 additions & 0 deletions
33
src/coreclr/System.Private.CoreLib/src/System/Reflection/MethodInvoker.CoreCLR.cs
This file contains 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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System.Runtime.CompilerServices; | ||
|
||
namespace System.Reflection | ||
{ | ||
internal partial class MethodInvoker | ||
{ | ||
private readonly Signature _signature; | ||
internal InvocationFlags _invocationFlags; | ||
|
||
public MethodInvoker(MethodBase method, Signature signature) | ||
{ | ||
_method = method; | ||
_signature = signature; | ||
|
||
#if USE_NATIVE_INVOKE | ||
// Always use the native invoke; useful for testing. | ||
_strategyDetermined = true; | ||
#elif USE_EMIT_INVOKE | ||
// Always use emit invoke (if IsDynamicCodeCompiled == true); useful for testing. | ||
_invoked = true; | ||
#endif | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
private unsafe object? InterpretedInvoke(object? obj, IntPtr* arguments) | ||
{ | ||
return RuntimeMethodHandle.InvokeMethod(obj, (void**)arguments, _signature, isConstructor: false); | ||
} | ||
} | ||
} |
This file contains 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 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 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 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
Oops, something went wrong.