Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,10 @@ protected Delegate([DynamicallyAccessedMembers(DynamicallyAccessedMemberTypes.Al
throw new PlatformNotSupportedException();
}

// New Delegate Implementation

private object _firstParameter;
private object _helperObject;
private nint _extraFunctionPointerOrData;
private object _firstParameter; // Keep _firstParameter and _functionPointer next to each other for optimal delegate invoke performance
private IntPtr _functionPointer;
private nint _extraFunctionPointerOrData;

// _helperObject may point to an array of delegates if this is a multicast delegate. We use this wrapper to distinguish between
// our own array of delegates and user provided Wrapper[]. As a added benefit, this wrapper also eliminates array co-variance
Expand Down
9 changes: 7 additions & 2 deletions src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3451,8 +3451,13 @@ private void getEEInfo(ref CORINFO_EE_INFO pEEInfoOut)

pEEInfoOut.inlinedCallFrameInfo.size = (uint)SizeOfPInvokeTransitionFrame;

pEEInfoOut.offsetOfDelegateInstance = (uint)pointerSize; // Delegate::_firstParameter
pEEInfoOut.offsetOfDelegateFirstTarget = OffsetOfDelegateFirstTarget;
#if READYTORUN
pEEInfoOut.offsetOfDelegateInstance = (uint)pointerSize; // Delegate._target
pEEInfoOut.offsetOfDelegateFirstTarget = 3 * (uint)pointerSize; // Delegate._methodPtr
#else
pEEInfoOut.offsetOfDelegateInstance = 2 * (uint)pointerSize; // Delegate._firstParameter
pEEInfoOut.offsetOfDelegateFirstTarget = 3 * (uint)pointerSize; // Delegate._functionPointer
#endif

pEEInfoOut.sizeOfReversePInvokeFrame = (uint)SizeOfReversePInvokeTransitionFrame;

Expand Down
20 changes: 10 additions & 10 deletions src/coreclr/tools/aot/ILCompiler.Compiler/Compiler/TypePreinit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3295,34 +3295,34 @@ public void WriteContent(ref ObjectDataBuilder builder, ISymbolNode thisNode, No
{
Debug.Assert(creationInfo.Constructor.Method.Name == "InitializeOpenStaticThunk"u8);

// _firstParameter
builder.EmitPointerReloc(thisNode);

// _helperObject
builder.EmitZeroPointer();

// _extraFunctionPointerOrData
builder.EmitPointerReloc(creationInfo.GetTargetNode(factory));
// _firstParameter
builder.EmitPointerReloc(thisNode);

// _functionPointer
Debug.Assert(creationInfo.Thunk != null);
builder.EmitPointerReloc(creationInfo.Thunk);

// _extraFunctionPointerOrData
builder.EmitPointerReloc(creationInfo.GetTargetNode(factory));
}
else
{
Debug.Assert(creationInfo.Constructor.Method.Name == "InitializeClosedInstance"u8);

// _firstParameter
_firstParameter.WriteFieldData(ref builder, factory);

// _helperObject
builder.EmitZeroPointer();

// _extraFunctionPointerOrData
builder.EmitZeroPointer();
// _firstParameter
_firstParameter.WriteFieldData(ref builder, factory);

// _functionPointer
builder.EmitPointerReloc(creationInfo.GetTargetNode(factory));

// _extraFunctionPointerOrData
builder.EmitZeroPointer();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -477,8 +477,6 @@ unsafe partial class CorInfoImpl
{
private const CORINFO_RUNTIME_ABI TargetABI = CORINFO_RUNTIME_ABI.CORINFO_CORECLR_ABI;

private uint OffsetOfDelegateFirstTarget => (uint)(3 * PointerSize); // Delegate._methodPtr

private readonly ReadyToRunCodegenCompilation _compilation;
private MethodWithGCInfo _methodCodeNode;
private MethodColdCodeNode _methodColdCodeNode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ internal unsafe partial class CorInfoImpl
{
private const CORINFO_RUNTIME_ABI TargetABI = CORINFO_RUNTIME_ABI.CORINFO_NATIVEAOT_ABI;

private uint OffsetOfDelegateFirstTarget => (uint)(4 * PointerSize); // Delegate._functionPointer
private int SizeOfReversePInvokeTransitionFrame => 2 * PointerSize;

private RyuJitCompilation _compilation;
Expand Down
Loading