diff --git a/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj b/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj
index 1dd3eb3291ca9a..f99a2842e7fcad 100644
--- a/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj
+++ b/src/coreclr/System.Private.CoreLib/System.Private.CoreLib.csproj
@@ -185,6 +185,7 @@
+
diff --git a/src/coreclr/System.Private.CoreLib/src/System/Reflection/ConstructorInvoker.CoreCLR.cs b/src/coreclr/System.Private.CoreLib/src/System/Reflection/ConstructorInvoker.CoreCLR.cs
index 05f69d2670e3ed..f58e24742dc500 100644
--- a/src/coreclr/System.Private.CoreLib/src/System/Reflection/ConstructorInvoker.CoreCLR.cs
+++ b/src/coreclr/System.Private.CoreLib/src/System/Reflection/ConstructorInvoker.CoreCLR.cs
@@ -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);
}
}
}
diff --git a/src/coreclr/System.Private.CoreLib/src/System/Reflection/Emit/DynamicMethod.CoreCLR.cs b/src/coreclr/System.Private.CoreLib/src/System/Reflection/Emit/DynamicMethod.CoreCLR.cs
index dc764971c2604d..0a4ebb1c5140c8 100644
--- a/src/coreclr/System.Private.CoreLib/src/System/Reflection/Emit/DynamicMethod.CoreCLR.cs
+++ b/src/coreclr/System.Private.CoreLib/src/System/Reflection/Emit/DynamicMethod.CoreCLR.cs
@@ -24,7 +24,7 @@ public sealed partial class DynamicMethod : MethodInfo
private Module _module;
internal bool _skipVisibility;
internal RuntimeType? _typeOwner;
- private MethodInvoker? _invoker;
+ private MethodBaseInvoker? _invoker;
private Signature? _signature;
private string _name;
private MethodAttributes _attributes;
@@ -85,12 +85,12 @@ internal RuntimeMethodHandle GetMethodDescriptor()
return new RuntimeMethodHandle(_methodHandle!);
}
- private MethodInvoker Invoker
+ private MethodBaseInvoker Invoker
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
get
{
- return _invoker ??= new MethodInvoker(this, Signature);
+ return _invoker ??= new MethodBaseInvoker(this, Signature);
}
}
@@ -134,136 +134,28 @@ Signature LazyCreateSignature()
throw new TargetParameterCountException(SR.Arg_ParmCnt);
object? retValue;
-
- unsafe
+ switch (argCount)
{
- if (argCount == 0)
- {
- retValue = Invoker.InlinedInvoke(obj, args: default, invokeAttr);
- }
- else if (argCount > MaxStackAllocArgCount)
- {
- Debug.Assert(parameters != null);
- retValue = InvokeWithManyArguments(this, argCount, obj, invokeAttr, binder, parameters, culture);
- }
- else
- {
- Debug.Assert(parameters != null);
- StackAllocedArguments argStorage = default;
- Span