-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
087651e
commit a3428ed
Showing
81 changed files
with
3,504 additions
and
1,329 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
17 changes: 10 additions & 7 deletions
17
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 |
---|---|---|
@@ -1,18 +1,21 @@ | ||
// 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 partial class ConstructorInvoker | ||
{ | ||
public InvocationFlags _invocationFlags; | ||
private readonly Signature? _signature; | ||
|
||
internal unsafe ConstructorInvoker(RuntimeConstructorInfo constructor) : this(constructor, constructor.Signature.Arguments) | ||
{ | ||
_signature = constructor.Signature; | ||
_invokeFunc_RefArgs = InterpretedInvoke; | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
private unsafe object? InterpretedInvoke(object? obj, IntPtr* arguments) | ||
private unsafe object? InterpretedInvoke(object? obj, IntPtr* args) | ||
{ | ||
return RuntimeMethodHandle.InvokeMethod(obj, (void**)arguments, _method.Signature, isConstructor: obj is null)!; | ||
return RuntimeMethodHandle.InvokeMethod(obj, (void**)args, _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
38 changes: 38 additions & 0 deletions
38
src/coreclr/System.Private.CoreLib/src/System/Reflection/MethodBaseInvoker.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,38 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System.Reflection.Emit; | ||
|
||
namespace System.Reflection | ||
{ | ||
internal partial class MethodBaseInvoker | ||
{ | ||
private readonly Signature? _signature; | ||
|
||
internal unsafe MethodBaseInvoker(RuntimeMethodInfo method) : this(method, method.Signature.Arguments) | ||
{ | ||
_signature = method.Signature; | ||
_invocationFlags = method.ComputeAndUpdateInvocationFlags(); | ||
_invokeFunc_RefArgs = InterpretedInvoke_Method; | ||
} | ||
|
||
internal unsafe MethodBaseInvoker(RuntimeConstructorInfo constructor) : this(constructor, constructor.Signature.Arguments) | ||
{ | ||
_signature = constructor.Signature; | ||
_invocationFlags = constructor.ComputeAndUpdateInvocationFlags(); | ||
_invokeFunc_RefArgs = InterpretedInvoke_Constructor; | ||
} | ||
|
||
internal unsafe MethodBaseInvoker(DynamicMethod method, Signature signature) : this(method, signature.Arguments) | ||
{ | ||
_signature = signature; | ||
_invokeFunc_RefArgs = InterpretedInvoke_Method; | ||
} | ||
|
||
private unsafe object? InterpretedInvoke_Constructor(object? obj, IntPtr* args) => | ||
RuntimeMethodHandle.InvokeMethod(obj, (void**)args, _signature!, isConstructor: obj is null); | ||
|
||
private unsafe object? InterpretedInvoke_Method(object? obj, IntPtr* args) => | ||
RuntimeMethodHandle.InvokeMethod(obj, (void**)args, _signature!, isConstructor : false); | ||
} | ||
} |
43 changes: 23 additions & 20 deletions
43
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 |
---|---|---|
@@ -1,36 +1,39 @@ | ||
// 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; | ||
using System.Diagnostics; | ||
using System.Reflection.Emit; | ||
|
||
namespace System.Reflection | ||
{ | ||
internal partial class MethodInvoker | ||
public partial class MethodInvoker | ||
{ | ||
private readonly Signature _signature; | ||
internal InvocationFlags _invocationFlags; | ||
private readonly Signature? _signature; | ||
|
||
public MethodInvoker(MethodBase method, Signature signature) | ||
internal unsafe MethodInvoker(RuntimeMethodInfo method) : this(method, method.Signature.Arguments) | ||
{ | ||
_method = method; | ||
_signature = signature; | ||
_signature = method.Signature; | ||
_invokeFunc_RefArgs = InterpretedInvoke_Method; | ||
_invocationFlags = method.ComputeAndUpdateInvocationFlags(); | ||
} | ||
|
||
if (LocalAppContextSwitches.ForceInterpretedInvoke && !LocalAppContextSwitches.ForceEmitInvoke) | ||
{ | ||
// Always use the native invoke; useful for testing. | ||
_strategyDetermined = true; | ||
} | ||
else if (LocalAppContextSwitches.ForceEmitInvoke && !LocalAppContextSwitches.ForceInterpretedInvoke) | ||
{ | ||
// Always use emit invoke (if IsDynamicCodeSupported == true); useful for testing. | ||
_invoked = true; | ||
} | ||
internal unsafe MethodInvoker(DynamicMethod method) : this(method, method.Signature.Arguments) | ||
{ | ||
_signature = method.Signature; | ||
_invokeFunc_RefArgs = InterpretedInvoke_Method; | ||
} | ||
|
||
[MethodImpl(MethodImplOptions.AggressiveInlining)] | ||
private unsafe object? InterpretedInvoke(object? obj, IntPtr* arguments) | ||
internal unsafe MethodInvoker(RuntimeConstructorInfo constructor) : this(constructor, constructor.Signature.Arguments) | ||
{ | ||
return RuntimeMethodHandle.InvokeMethod(obj, (void**)arguments, _signature, isConstructor: false); | ||
_signature = constructor.Signature; | ||
_invokeFunc_RefArgs = InterpretedInvoke_Constructor; | ||
_invocationFlags = constructor.ComputeAndUpdateInvocationFlags(); | ||
} | ||
|
||
private unsafe object? InterpretedInvoke_Method(object? obj, IntPtr* args) => | ||
RuntimeMethodHandle.InvokeMethod(obj, (void**)args, _signature!, isConstructor: false); | ||
|
||
private unsafe object? InterpretedInvoke_Constructor(object? obj, IntPtr* args) => | ||
RuntimeMethodHandle.InvokeMethod(obj, (void**)args, _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
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.