Skip to content
Merged
Changes from 1 commit
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
Next Next commit
Fix nested non-byref like VC with no pointer fields
  • Loading branch information
AaronRobinsonMSFT committed Jan 14, 2023
commit b69e03e592e913c65c3f7264a143c0bc85d68f1e
25 changes: 13 additions & 12 deletions src/coreclr/vm/methodtablebuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8732,29 +8732,30 @@ MethodTableBuilder::HandleExplicitLayout(
if (pMT->IsByRefLike())
return CheckByRefLikeValueClassLayout(pMT, pFieldLayout);

// This method assumes there is a GC desc associated with the MethodTable.
_ASSERTE(pMT->ContainsPointers());

// Build a layout of the value class (vc). Don't know the sizes of all the fields easily, but
// do know (a) vc is already consistent so don't need to check it's overlaps and
// (b) size and location of all objectrefs. So build it by setting all non-oref
// then fill in the orefs later
// then fill in the orefs later if present.
UINT fieldSize = pMT->GetNumInstanceFieldBytes();

CQuickBytes qb;
bmtFieldLayoutTag *vcLayout = (bmtFieldLayoutTag*) qb.AllocThrows(fieldSize * sizeof(bmtFieldLayoutTag));
memset((void*)vcLayout, nonoref, fieldSize);

// use pointer series to locate the orefs
CGCDesc* map = CGCDesc::GetCGCDescFromMT(pMT);
CGCDescSeries *pSeries = map->GetLowestSeries();

for (SIZE_T j = 0; j < map->GetNumSeries(); j++)
// If the type contains pointers fill it out from the GC data
if (pMT->ContainsPointers())
{
CONSISTENCY_CHECK(pSeries <= map->GetHighestSeries());
// use pointer series to locate the orefs
CGCDesc* map = CGCDesc::GetCGCDescFromMT(pMT);
CGCDescSeries *pSeries = map->GetLowestSeries();

memset((void*)&vcLayout[pSeries->GetSeriesOffset() - OBJECT_SIZE], oref, pSeries->GetSeriesSize() + pMT->GetBaseSize());
pSeries++;
for (SIZE_T j = 0; j < map->GetNumSeries(); j++)
{
CONSISTENCY_CHECK(pSeries <= map->GetHighestSeries());

memset((void*)&vcLayout[pSeries->GetSeriesOffset() - OBJECT_SIZE], oref, pSeries->GetSeriesSize() + pMT->GetBaseSize());
pSeries++;
}
}

ExplicitClassTrust explicitClassTrust;
Expand Down