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
7 changes: 5 additions & 2 deletions src/coreclr/vm/datadescriptor/datadescriptor.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1160,8 +1160,6 @@ CDAC_TYPE_BEGIN(TransitionBlock)
CDAC_TYPE_SIZE(sizeof(TransitionBlock))
CDAC_TYPE_FIELD(TransitionBlock, TYPE(CodePointer), ReturnAddress, offsetof(TransitionBlock, m_ReturnAddress))
CDAC_TYPE_FIELD(TransitionBlock, TYPE(CalleeSavedRegisters), CalleeSavedRegisters, offsetof(TransitionBlock, m_calleeSavedRegisters))
// Offset to where stack arguments begin (just past the end of the TransitionBlock)
CDAC_TYPE_FIELD(TransitionBlock, T_UINT32, OffsetOfArgs, sizeof(TransitionBlock))
// Offset to argument registers and first GCRefMap slot (platform-specific)
#if (defined(TARGET_AMD64) && !defined(UNIX_AMD64_ABI)) || defined(TARGET_WASM)
CDAC_TYPE_FIELD(TransitionBlock, T_UINT32, ArgumentRegisters, sizeof(TransitionBlock))
Expand Down Expand Up @@ -1204,6 +1202,11 @@ CDAC_TYPE_SIZE(sizeof(ExternalMethodFrame))
CDAC_TYPE_FIELD(ExternalMethodFrame, T_POINTER, Indirection, cdac_data<ExternalMethodFrame>::Indirection)
CDAC_TYPE_END(ExternalMethodFrame)

CDAC_TYPE_BEGIN(PInvokeCalliFrame)
CDAC_TYPE_SIZE(sizeof(PInvokeCalliFrame))
CDAC_TYPE_FIELD(PInvokeCalliFrame, T_POINTER, VASigCookiePtr, cdac_data<PInvokeCalliFrame>::VASigCookiePtr)
CDAC_TYPE_END(PInvokeCalliFrame)

CDAC_TYPE_BEGIN(DynamicHelperFrame)
CDAC_TYPE_SIZE(sizeof(DynamicHelperFrame))
CDAC_TYPE_FIELD(DynamicHelperFrame, T_INT32, DynamicHelperFrameFlags, cdac_data<DynamicHelperFrame>::DynamicHelperFrameFlags)
Expand Down
8 changes: 8 additions & 0 deletions src/coreclr/vm/frames.h
Original file line number Diff line number Diff line change
Expand Up @@ -1359,6 +1359,14 @@ class PInvokeCalliFrame : public FramedMethodFrame
trace->InitForUnmanaged(GetPInvokeCalliTarget());
return TRUE;
}

friend struct ::cdac_data<PInvokeCalliFrame>;
};

template <>
struct cdac_data<PInvokeCalliFrame>
{
static constexpr size_t VASigCookiePtr = offsetof(PInvokeCalliFrame, m_pVASigCookie);
};

// Some context-related forwards.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ private void GetTransitionsFullyInterruptible(ref TargetPointer offset)
/// </summary>
private void GetTransitionsEbpFrame(ref TargetPointer offset)
{
uint curOffs = 0;
while (true)
{
uint argMask = 0, byrefArgMask = 0;
Expand All @@ -207,7 +208,6 @@ private void GetTransitionsEbpFrame(ref TargetPointer offset)
uint argTabSize;

uint val, nxt;
uint curOffs = 0;

// Get the next byte and check for a 'special' entry
uint encType = _target.Read<byte>(offset++);
Expand All @@ -231,19 +231,14 @@ private void GetTransitionsEbpFrame(ref TargetPointer offset)
}
else
{
RegMask reg;
if ((val & 0x10) != 0)
reg = RegMask.EDI;
else if ((val & 0x20) != 0)
reg = RegMask.ESI;
else if ((val & 0x40) != 0)
reg = RegMask.EBX;
else
throw new BadImageFormatException("Invalid register");
transition = new GcTransitionCall((int)curOffs);
transition.CallRegisters.Add(new GcTransitionCall.CallRegister(reg, false));
AddNewTransition(transition);

// "This pointer liveness encoding" (val & 0x80 == 0 && val & 0x0F == 0):
// metadata for which callee-saved register holds the 'this' pointer
// at the next call site. Native (gc_unwind_x86.inl ~line 970) does NOT
// record a call entry here -- it only sets thisPtrReg. Adding a spurious
// GcTransitionCall at the current curOffs would overwrite the real
// call site's CallRegisters during EnumerateLiveSlots (since the
// partial-EBP decoder may emit the this-ptr tag at the same curOffs
// as a real call site), so we just consume the byte and continue.
continue;
}
}
Expand Down Expand Up @@ -296,7 +291,9 @@ private void GetTransitionsEbpFrame(ref TargetPointer offset)
val = _target.Read<byte>(offset++);
regMask = val & 0x7;
byrefRegMask = val >> 4;
curOffs = _target.Read<uint>(offset);
// Code delta is 32-bit and is added to curOffs (mirrors `scanOffs +=` in
// native gc_unwind_x86.inl scanArgRegTable case 0xFB).
curOffs += _target.Read<uint>(offset);
offset += 4;
argCnt = _target.Read<uint>(offset);
offset += 4;
Expand Down Expand Up @@ -345,7 +342,7 @@ argMask ... bitmask of pushed pointer arguments
/// <summary>
/// based on <a href="https://github.com/dotnet/runtime/blob/main/src/coreclr/gcdump/i386/gcdumpx86.cpp">GCDump::DumpGCTable</a>
/// </summary>
private void SaveCallTransition(ref TargetPointer offset, uint val, uint curOffs, uint callRegMask, bool callPndTab, uint callPndTabCnt, uint callPndMask, uint lastSkip, ref uint imask)
private void SaveCallTransition(ref TargetPointer offset, uint curOffs, uint callRegMask, bool callPndTab, uint callPndTabCnt, uint callPndMask, ref uint imask)
{
uint iregMask, iargMask;
iregMask = imask & 0xF;
Expand All @@ -359,11 +356,6 @@ private void SaveCallTransition(ref TargetPointer offset, uint val, uint curOffs
for (int i = 0; i < callPndTabCnt; i++)
{
uint pndOffs = _target.GCDecodeUnsigned(ref offset);

uint stkOffs = val & ~byref_OFFSET_FLAG;
uint lowBit = val & byref_OFFSET_FLAG;
Console.WriteLine($"stkOffs: {stkOffs}, lowBit: {lowBit}");

transition.PtrArgs.Add(new GcTransitionCall.PtrArg(pndOffs, 0));
}
Comment thread
max-charlamb marked this conversation as resolved.
}
Expand All @@ -375,15 +367,14 @@ private void SaveCallTransition(ref TargetPointer offset, uint val, uint curOffs
transition.IArgs = iargMask;
}

Console.WriteLine($"lastSkip: {lastSkip}");
imask /* = lastSkip */ = 0;
}

private void GetTransitionsNoEbp(ref TargetPointer offset)
{
uint curOffs = 0;
uint lastSkip = 0;
uint imask = 0;
uint lastSkip;

for (; ; )
{
Expand Down Expand Up @@ -418,7 +409,6 @@ private void GetTransitionsNoEbp(ref TargetPointer offset)
//
skip = _target.GCDecodeUnsigned(ref offset);
curOffs += skip;
lastSkip = skip;
}
else
{
Expand All @@ -431,18 +421,16 @@ private void GetTransitionsNoEbp(ref TargetPointer offset)
{
AddNewTransition(new GcTransitionRegister((int)curOffs, RegMask.ESP, Action.POP, false, false, (int)popSize));
}
else
lastSkip = skip;
}
}
}
else
{
uint callArgCnt = 0;
uint callArgCnt;
uint callRegMask;
bool callPndTab = false;
uint callPndMask = 0;
uint callPndTabCnt = 0, callPndTabSize = 0;
uint callPndTabCnt = 0;

switch ((val & 0x70) >> 4)
{
Expand All @@ -452,8 +440,8 @@ private void GetTransitionsNoEbp(ref TargetPointer offset)
//
CallPattern.DecodeCallPattern((val & 0x7f), out callArgCnt, out callRegMask, out callPndMask, out lastSkip);
curOffs += lastSkip;
SaveCallTransition(ref offset, val, curOffs, callRegMask, callPndTab, callPndTabCnt, callPndMask, lastSkip, ref imask);
AddNewTransition(new StackDepthTransition((int)curOffs, (int)callArgCnt));
SaveCallTransition(ref offset, curOffs, callRegMask, callPndTab, callPndTabCnt, callPndMask, ref imask);
AddNewTransition(new StackDepthTransition((int)curOffs, -(int)callArgCnt));
break;

case 5:
Expand All @@ -467,8 +455,8 @@ private void GetTransitionsNoEbp(ref TargetPointer offset)
callArgCnt = (val >> 3) & 0x7;
lastSkip = CallPattern.CallCommonDelta[(int)(val >> 6)];
curOffs += lastSkip;
SaveCallTransition(ref offset, val, curOffs, callRegMask, callPndTab, callPndTabCnt, callPndMask, lastSkip, ref imask);
AddNewTransition(new StackDepthTransition((int)curOffs, (int)callArgCnt));
SaveCallTransition(ref offset, curOffs, callRegMask, callPndTab, callPndTabCnt, callPndMask, ref imask);
AddNewTransition(new StackDepthTransition((int)curOffs, -(int)callArgCnt));
break;
case 6:
//
Expand All @@ -478,8 +466,8 @@ private void GetTransitionsNoEbp(ref TargetPointer offset)
callRegMask = val & 0xf; // EBP,EBX,ESI,EDI
callArgCnt = _target.GCDecodeUnsigned(ref offset);
callPndMask = _target.GCDecodeUnsigned(ref offset);
SaveCallTransition(ref offset, val, curOffs, callRegMask, callPndTab, callPndTabCnt, callPndMask, lastSkip, ref imask);
AddNewTransition(new StackDepthTransition((int)curOffs, (int)callArgCnt));
SaveCallTransition(ref offset, curOffs, callRegMask, callPndTab, callPndTabCnt, callPndMask, ref imask);
AddNewTransition(new StackDepthTransition((int)curOffs, -(int)callArgCnt));
break;
case 7:
switch (val & 0x0C)
Expand All @@ -505,11 +493,11 @@ private void GetTransitionsNoEbp(ref TargetPointer offset)
offset += 4;
callPndTabCnt = _target.Read<uint>(offset);
offset += 4;
callPndTabSize = _target.Read<uint>(offset);
// Skip callPndTabSize - present in encoding but unused by the decoder.
offset += 4;
callPndTab = true;
SaveCallTransition(ref offset, val, curOffs, callRegMask, callPndTab, callPndTabCnt, callPndMask, lastSkip, ref imask);
AddNewTransition(new StackDepthTransition((int)curOffs, (int)callArgCnt));
SaveCallTransition(ref offset, curOffs, callRegMask, callPndTab, callPndTabCnt, callPndMask, ref imask);
AddNewTransition(new StackDepthTransition((int)curOffs, -(int)callArgCnt));
break;
case 0x0C:
return;
Expand All @@ -518,8 +506,6 @@ private void GetTransitionsNoEbp(ref TargetPointer offset)
}
break;
}
Console.WriteLine($"CallArgCount: {callArgCnt}");
Console.WriteLine($"CallPndTabCnt: {callPndTabSize}");
}
}
}
Expand Down
Loading