Skip to content
Draft
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
24 changes: 19 additions & 5 deletions src/coreclr/jit/gcencode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2124,21 +2124,35 @@ unsigned PendingArgsStack::pasEnumGCoffs(unsigned iter, unsigned* offs)
// when reporting interruptible ranges.
class NoGCRegionEncoder
{
BYTE* dest;
BYTE* dest;
unsigned lastSize = 0;
unsigned lastEndOffs = -1;
public:
size_t totalSize;
size_t totalSize = 0;

NoGCRegionEncoder(BYTE* dest)
: dest(dest)
, totalSize(0)
{
}

// This callback is called for each insGroup marked with IGF_NOGCINTERRUPT.
bool operator()(unsigned igFuncIdx, unsigned igOffs, unsigned igSize, unsigned firstInstrSize, bool isInProlog)
{
totalSize += encodeUnsigned(dest == NULL ? NULL : dest + totalSize, igOffs);
totalSize += encodeUnsigned(dest == NULL ? NULL : dest + totalSize, igSize);
unsigned size;
if (igOffs == lastEndOffs) // Coalesce adjacent intervals by re-encoding the enlarged size.
{
totalSize -= encodeUnsigned(nullptr, lastSize);
size = lastSize + igSize;
}
else
{
totalSize += encodeUnsigned(dest == nullptr ? nullptr : dest + totalSize, igOffs);
size = igSize;
}
totalSize += encodeUnsigned(dest == nullptr ? nullptr : dest + totalSize, size);

lastSize = size;
lastEndOffs = igOffs + igSize;
return true;
}
};
Expand Down
Loading