diff --git a/src/coreclr/inc/corinfo.h b/src/coreclr/inc/corinfo.h index aabc86d3cd65a4..2ede16b9b15070 100644 --- a/src/coreclr/inc/corinfo.h +++ b/src/coreclr/inc/corinfo.h @@ -2377,10 +2377,10 @@ class ICorStaticInfo bool fDoubleAlignHint = false ) = 0; - // This is only called for Value classes. It returns a boolean array - // in representing of 'cls' from a GC perspective. The class is - // assumed to be an array of machine words - // (of length // getClassSize(cls) / TARGET_POINTER_SIZE), + // Returns a boolean array representing 'cls' from a GC perspective. + // The class is assumed to be an array of machine words + // (of length getClassSize(cls) / TARGET_POINTER_SIZE for value classes + // and getHeapClassSize(cls) / TARGET_POINTER_SIZE for reference types), // 'gcPtrs' is a pointer to an array of uint8_ts of this length. // getClassGClayout fills in this array so that gcPtrs[i] is set // to one of the CorInfoGCType values which is the GC type of diff --git a/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs b/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs index 865cda25ffab17..5ac150b37ec474 100644 --- a/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs +++ b/src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs @@ -2312,6 +2312,10 @@ private int MarkGcField(byte* gcPtrs, CorInfoGCType gcType) private int GatherClassGCLayout(MetadataType type, byte* gcPtrs) { int result = 0; + + if (type.MetadataBaseType is { ContainsGCPointers: true } baseType) + result += GatherClassGCLayout(baseType, gcPtrs); + bool isInlineArray = type.IsInlineArray; foreach (var field in type.GetFields())