@@ -196,9 +196,9 @@ protected override ModuleFieldLayout CreateValueFromKey(EcmaModule module)
196196 }
197197 }
198198
199- if ( nonGcBytes [ StaticIndex . Regular ] != 0 ||
199+ if ( nonGcBytes [ StaticIndex . Regular ] != 0 ||
200200 nonGcBytes [ StaticIndex . ThreadLocal ] != 0 ||
201- gcBytes [ StaticIndex . Regular ] != 0 ||
201+ gcBytes [ StaticIndex . Regular ] != 0 ||
202202 gcBytes [ StaticIndex . ThreadLocal ] != 0 )
203203 {
204204 OffsetsForType offsetsForType = new OffsetsForType ( LayoutInt . Indeterminate , LayoutInt . Indeterminate , LayoutInt . Indeterminate , LayoutInt . Indeterminate ) ;
@@ -290,14 +290,14 @@ private void GetElementTypeInfoGeneric(
290290 }
291291
292292 private void GetElementTypeInfo (
293- EcmaModule module ,
293+ EcmaModule module ,
294294 FieldDesc fieldDesc ,
295- EntityHandle valueTypeHandle ,
295+ EntityHandle valueTypeHandle ,
296296 CorElementType elementType ,
297297 int pointerSize ,
298298 bool moduleLayout ,
299- out int alignment ,
300- out int size ,
299+ out int alignment ,
300+ out int size ,
301301 out bool isGcPointerField ,
302302 out bool isGcBoxedField )
303303 {
@@ -357,7 +357,7 @@ private void GetElementTypeInfo(
357357 ThrowHelper . ThrowTypeLoadException ( ExceptionStringID . ClassLoadGeneral , fieldDesc . OwningType ) ;
358358 break ;
359359
360- // Statics for valuetypes where the valuetype is defined in this module are handled here.
360+ // Statics for valuetypes where the valuetype is defined in this module are handled here.
361361 // Other valuetype statics utilize the pessimistic model below.
362362 case CorElementType . ELEMENT_TYPE_VALUETYPE :
363363 if ( IsTypeByRefLike ( valueTypeHandle , module . MetadataReader ) )
@@ -522,7 +522,7 @@ public FieldAndOffset[] CalculateTypeLayout(DefType defType, EcmaModule module,
522522 offsetsForType . GcOffsets [ StaticIndex . ThreadLocal ] ,
523523 } ;
524524
525- LayoutInt [ ] gcPointerFieldOffsets = new LayoutInt [ StaticIndex . Count ]
525+ LayoutInt [ ] gcPointerFieldOffsets = new LayoutInt [ StaticIndex . Count ]
526526 {
527527 offsetsForType . GcOffsets [ StaticIndex . Regular ] + new LayoutInt ( gcBoxedCount [ StaticIndex . Regular ] * pointerSize ) ,
528528 offsetsForType . GcOffsets [ StaticIndex . ThreadLocal ] + new LayoutInt ( gcBoxedCount [ StaticIndex . ThreadLocal ] * pointerSize )
@@ -768,10 +768,10 @@ private class ModuleFieldLayout
768768 private ConcurrentDictionary < DefType , FieldAndOffset [ ] > _genericTypeToFieldMap ;
769769
770770 public ModuleFieldLayout (
771- EcmaModule module ,
772- StaticsBlock gcStatics ,
773- StaticsBlock nonGcStatics ,
774- StaticsBlock threadGcStatics ,
771+ EcmaModule module ,
772+ StaticsBlock gcStatics ,
773+ StaticsBlock nonGcStatics ,
774+ StaticsBlock threadGcStatics ,
775775 StaticsBlock threadNonGcStatics ,
776776 IReadOnlyDictionary < TypeDefinitionHandle , OffsetsForType > typeOffsets )
777777 {
@@ -814,7 +814,7 @@ protected override ComputedInstanceFieldLayout ComputeInstanceFieldLayout(Metada
814814 }
815815
816816 /// <summary>
817- /// This method decides whether the type needs aligned base offset in order to have layout resilient to
817+ /// This method decides whether the type needs aligned base offset in order to have layout resilient to
818818 /// base class layout changes.
819819 /// </summary>
820820 protected override void AlignBaseOffsetIfNecessary ( MetadataType type , ref LayoutInt baseOffset , bool requiresAlign8 , bool requiresAlignedBase )
@@ -834,7 +834,7 @@ protected override bool AlignUpInstanceByteSizeForExplicitFieldLayoutCompatQuirk
834834
835835 public static bool IsManagedSequentialType ( TypeDesc type )
836836 {
837- if ( type . IsPointer )
837+ if ( type . IsPointer || type . IsFunctionPointer )
838838 {
839839 return true ;
840840 }
@@ -857,9 +857,20 @@ public static bool IsManagedSequentialType(TypeDesc type)
857857
858858 foreach ( FieldDesc field in type . GetFields ( ) )
859859 {
860- if ( ! field . IsStatic && ! IsManagedSequentialType ( field . FieldType . UnderlyingType ) )
860+ if ( ! field . IsStatic )
861861 {
862- return false ;
862+ if ( type . IsPointer )
863+ {
864+ continue ;
865+ }
866+ if ( ! type . IsValueType )
867+ {
868+ return false ;
869+ }
870+ if ( ( ( DefType ) type ) . ContainsGCPointers )
871+ {
872+ return false ;
873+ }
863874 }
864875 }
865876
0 commit comments