Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Commit

Permalink
Make getClassGClayout work with with class types.
Browse files Browse the repository at this point in the history
Also add an assert to getHeapClassSize to ensure it's not
called in R2R cross-version-bubble.
  • Loading branch information
erozenfeld committed Nov 9, 2018
1 parent 26df4f3 commit e472fd4
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions src/vm/jitinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1961,6 +1961,10 @@ CEEInfo::getHeapClassSize(
MethodTable* pMT = VMClsHnd.GetMethodTable();
_ASSERTE(pMT);
_ASSERTE(!pMT->IsValueType());
_ASSERTE(!pMT->HasComponentSize());
#ifdef FEATURE_READYTORUN_COMPILER
_ASSERTE(!IsReadyToRunCompilation() || pMT->IsInheritanceChainLayoutFixedInCurrentVersionBubble());
#endif

// Add OBJECT_SIZE to account for method table pointer.
result = pMT->GetNumInstanceFieldBytes() + OBJECT_SIZE;
Expand Down Expand Up @@ -2280,13 +2284,20 @@ unsigned CEEInfo::getClassGClayout (CORINFO_CLASS_HANDLE clsHnd, BYTE* gcPtrs)
}
else
{
_ASSERTE(pMT->IsValueType());
_ASSERTE(sizeof(BYTE) == 1);

BOOL isValueClass = pMT->IsValueType();

#ifdef FEATURE_READYTORUN_COMPILER
_ASSERTE(isValueClass || !IsReadyToRunCompilation() || pMT->IsInheritanceChainLayoutFixedInCurrentVersionBubble());
#endif

unsigned int size = isValueClass ? VMClsHnd.GetSize() : pMT->GetNumInstanceFieldBytes() + OBJECT_SIZE;

// assume no GC pointers at first
result = 0;
memset(gcPtrs, TYPE_GC_NONE,
(VMClsHnd.GetSize() + TARGET_POINTER_SIZE - 1) / TARGET_POINTER_SIZE);
(size + TARGET_POINTER_SIZE - 1) / TARGET_POINTER_SIZE);

// walk the GC descriptors, turning on the correct bits
if (pMT->ContainsPointers())
Expand All @@ -2298,7 +2309,8 @@ unsigned CEEInfo::getClassGClayout (CORINFO_CLASS_HANDLE clsHnd, BYTE* gcPtrs)
{
// Get offset into the value class of the first pointer field (includes a +Object)
size_t cbSeriesSize = pByValueSeries->GetSeriesSize() + pMT->GetBaseSize();
size_t cbOffset = pByValueSeries->GetSeriesOffset() - OBJECT_SIZE;
size_t cbSeriesOffset = pByValueSeries->GetSeriesOffset();
size_t cbOffset = isValueClass ? cbSeriesOffset - OBJECT_SIZE : cbSeriesOffset;

_ASSERTE (cbOffset % TARGET_POINTER_SIZE == 0);
_ASSERTE (cbSeriesSize % TARGET_POINTER_SIZE == 0);
Expand Down

0 comments on commit e472fd4

Please sign in to comment.