@@ -110,6 +110,7 @@ out instanceByteSizeAndAlignment
110110 FieldSize = sizeAndAlignment . Size ,
111111 LayoutAbiStable = true ,
112112 IsAutoLayoutOrHasAutoLayoutFields = false ,
113+ IsInt128OrHasInt128Fields = false ,
113114 } ;
114115
115116 if ( numInstanceFields > 0 )
@@ -211,7 +212,7 @@ public override ComputedStaticFieldLayout ComputeStaticFieldLayout(DefType defTy
211212 }
212213
213214 ref StaticsBlock block = ref GetStaticsBlockForField ( ref result , field ) ;
214- SizeAndAlignment sizeAndAlignment = ComputeFieldSizeAndAlignment ( fieldType , hasLayout : false , context . Target . DefaultPackingSize , out bool _ , out bool _ ) ;
215+ SizeAndAlignment sizeAndAlignment = ComputeFieldSizeAndAlignment ( fieldType , hasLayout : false , context . Target . DefaultPackingSize , out bool _ , out bool _ , out bool _ ) ;
215216
216217 block . Size = LayoutInt . AlignUp ( block . Size , sizeAndAlignment . Alignment , context . Target ) ;
217218 result . Offsets [ index ] = new FieldAndOffset ( field , block . Size ) ;
@@ -303,15 +304,18 @@ protected ComputedInstanceFieldLayout ComputeExplicitFieldLayout(MetadataType ty
303304 int fieldOrdinal = 0 ;
304305 bool layoutAbiStable = true ;
305306 bool hasAutoLayoutField = false ;
307+ bool hasInt128Field = type . BaseType == null ? false : type . BaseType . IsInt128OrHasInt128Fields ;
306308
307309 foreach ( var fieldAndOffset in layoutMetadata . Offsets )
308310 {
309311 TypeDesc fieldType = fieldAndOffset . Field . FieldType ;
310- var fieldSizeAndAlignment = ComputeFieldSizeAndAlignment ( fieldType . UnderlyingType , hasLayout : true , packingSize , out bool fieldLayoutAbiStable , out bool fieldHasAutoLayout ) ;
312+ var fieldSizeAndAlignment = ComputeFieldSizeAndAlignment ( fieldType . UnderlyingType , hasLayout : true , packingSize , out bool fieldLayoutAbiStable , out bool fieldHasAutoLayout , out bool fieldHasInt128Field ) ;
311313 if ( ! fieldLayoutAbiStable )
312314 layoutAbiStable = false ;
313315 if ( fieldHasAutoLayout )
314316 hasAutoLayoutField = true ;
317+ if ( fieldHasInt128Field )
318+ hasInt128Field = true ;
315319
316320 largestAlignmentRequired = LayoutInt . Max ( fieldSizeAndAlignment . Alignment , largestAlignmentRequired ) ;
317321
@@ -357,6 +361,7 @@ protected ComputedInstanceFieldLayout ComputeExplicitFieldLayout(MetadataType ty
357361 ComputedInstanceFieldLayout computedLayout = new ComputedInstanceFieldLayout
358362 {
359363 IsAutoLayoutOrHasAutoLayoutFields = hasAutoLayoutField ,
364+ IsInt128OrHasInt128Fields = hasInt128Field ,
360365 } ;
361366 computedLayout . FieldAlignment = instanceSizeAndAlignment . Alignment ;
362367 computedLayout . FieldSize = instanceSizeAndAlignment . Size ;
@@ -392,17 +397,20 @@ protected ComputedInstanceFieldLayout ComputeSequentialFieldLayout(MetadataType
392397 int packingSize = ComputePackingSize ( type , layoutMetadata ) ;
393398 bool layoutAbiStable = true ;
394399 bool hasAutoLayoutField = false ;
400+ bool hasInt128Field = type . BaseType == null ? false : type . BaseType . IsInt128OrHasInt128Fields ;
395401
396402 foreach ( var field in type . GetFields ( ) )
397403 {
398404 if ( field . IsStatic )
399405 continue ;
400406
401- var fieldSizeAndAlignment = ComputeFieldSizeAndAlignment ( field . FieldType . UnderlyingType , hasLayout : true , packingSize , out bool fieldLayoutAbiStable , out bool fieldHasAutoLayout ) ;
407+ var fieldSizeAndAlignment = ComputeFieldSizeAndAlignment ( field . FieldType . UnderlyingType , hasLayout : true , packingSize , out bool fieldLayoutAbiStable , out bool fieldHasAutoLayout , out bool fieldHasInt128Field ) ;
402408 if ( ! fieldLayoutAbiStable )
403409 layoutAbiStable = false ;
404410 if ( fieldHasAutoLayout )
405411 hasAutoLayoutField = true ;
412+ if ( fieldHasInt128Field )
413+ hasInt128Field = true ;
406414
407415 largestAlignmentRequirement = LayoutInt . Max ( fieldSizeAndAlignment . Alignment , largestAlignmentRequirement ) ;
408416
@@ -424,6 +432,7 @@ protected ComputedInstanceFieldLayout ComputeSequentialFieldLayout(MetadataType
424432 ComputedInstanceFieldLayout computedLayout = new ComputedInstanceFieldLayout
425433 {
426434 IsAutoLayoutOrHasAutoLayoutFields = hasAutoLayoutField ,
435+ IsInt128OrHasInt128Fields = hasInt128Field ,
427436 } ;
428437 computedLayout . FieldAlignment = instanceSizeAndAlignment . Alignment ;
429438 computedLayout . FieldSize = instanceSizeAndAlignment . Size ;
@@ -459,6 +468,7 @@ protected ComputedInstanceFieldLayout ComputeAutoFieldLayout(MetadataType type,
459468 int instanceValueClassFieldCount = 0 ;
460469 int instanceGCPointerFieldsCount = 0 ;
461470 int [ ] instanceNonGCPointerFieldsCount = new int [ maxLog2Size + 1 ] ;
471+ bool hasInt128Field = false ;
462472
463473 foreach ( var field in type . GetFields ( ) )
464474 {
@@ -471,6 +481,8 @@ protected ComputedInstanceFieldLayout ComputeAutoFieldLayout(MetadataType type,
471481 {
472482 // Valuetypes which are not primitives or enums
473483 instanceValueClassFieldCount ++ ;
484+ if ( ( ( DefType ) fieldType ) . IsInt128OrHasInt128Fields )
485+ hasInt128Field = true ;
474486 }
475487 else if ( fieldType . IsGCPointer )
476488 {
@@ -480,7 +492,7 @@ protected ComputedInstanceFieldLayout ComputeAutoFieldLayout(MetadataType type,
480492 {
481493 Debug . Assert ( fieldType . IsPrimitive || fieldType . IsPointer || fieldType . IsFunctionPointer || fieldType . IsEnum || fieldType . IsByRef ) ;
482494
483- var fieldSizeAndAlignment = ComputeFieldSizeAndAlignment ( fieldType , hasLayout , packingSize , out bool _ , out bool _ ) ;
495+ var fieldSizeAndAlignment = ComputeFieldSizeAndAlignment ( fieldType , hasLayout , packingSize , out bool _ , out bool _ , out bool _ ) ;
484496 instanceNonGCPointerFieldsCount [ CalculateLog2 ( fieldSizeAndAlignment . Size . AsInt ) ] ++ ;
485497 }
486498 }
@@ -517,7 +529,7 @@ protected ComputedInstanceFieldLayout ComputeAutoFieldLayout(MetadataType type,
517529
518530 TypeDesc fieldType = field . FieldType ;
519531
520- var fieldSizeAndAlignment = ComputeFieldSizeAndAlignment ( fieldType , hasLayout , packingSize , out bool fieldLayoutAbiStable , out bool _ ) ;
532+ var fieldSizeAndAlignment = ComputeFieldSizeAndAlignment ( fieldType , hasLayout , packingSize , out bool fieldLayoutAbiStable , out bool _ , out bool _ ) ;
521533 if ( ! fieldLayoutAbiStable )
522534 layoutAbiStable = false ;
523535
@@ -678,7 +690,7 @@ protected ComputedInstanceFieldLayout ComputeAutoFieldLayout(MetadataType type,
678690 for ( int i = 0 ; i < instanceValueClassFieldsArr . Length ; i ++ )
679691 {
680692 // Align the cumulative field offset to the indeterminate value
681- var fieldSizeAndAlignment = ComputeFieldSizeAndAlignment ( instanceValueClassFieldsArr [ i ] . FieldType , hasLayout , packingSize , out bool fieldLayoutAbiStable , out bool _ ) ;
693+ var fieldSizeAndAlignment = ComputeFieldSizeAndAlignment ( instanceValueClassFieldsArr [ i ] . FieldType , hasLayout , packingSize , out bool fieldLayoutAbiStable , out bool _ , out bool _ ) ;
682694 if ( ! fieldLayoutAbiStable )
683695 layoutAbiStable = false ;
684696
@@ -729,6 +741,7 @@ protected ComputedInstanceFieldLayout ComputeAutoFieldLayout(MetadataType type,
729741 ComputedInstanceFieldLayout computedLayout = new ComputedInstanceFieldLayout
730742 {
731743 IsAutoLayoutOrHasAutoLayoutFields = true ,
744+ IsInt128OrHasInt128Fields = hasInt128Field ,
732745 } ;
733746 computedLayout . FieldAlignment = instanceSizeAndAlignment . Alignment ;
734747 computedLayout . FieldSize = instanceSizeAndAlignment . Size ;
@@ -742,7 +755,7 @@ protected ComputedInstanceFieldLayout ComputeAutoFieldLayout(MetadataType type,
742755
743756 private static void PlaceInstanceField ( FieldDesc field , bool hasLayout , int packingSize , FieldAndOffset [ ] offsets , ref LayoutInt instanceFieldPos , ref int fieldOrdinal , LayoutInt offsetBias )
744757 {
745- var fieldSizeAndAlignment = ComputeFieldSizeAndAlignment ( field . FieldType , hasLayout , packingSize , out bool _ , out bool _ ) ;
758+ var fieldSizeAndAlignment = ComputeFieldSizeAndAlignment ( field . FieldType , hasLayout , packingSize , out bool _ , out bool _ , out bool _ ) ;
746759
747760 instanceFieldPos = AlignUpInstanceFieldOffset ( field . OwningType , instanceFieldPos , fieldSizeAndAlignment . Alignment , field . Context . Target ) ;
748761 offsets [ fieldOrdinal ] = new FieldAndOffset ( field , instanceFieldPos + offsetBias ) ;
@@ -802,11 +815,12 @@ public LayoutInt CalculateFieldBaseOffset(MetadataType type, bool requiresAlign8
802815 return cumulativeInstanceFieldPos ;
803816 }
804817
805- private static SizeAndAlignment ComputeFieldSizeAndAlignment ( TypeDesc fieldType , bool hasLayout , int packingSize , out bool layoutAbiStable , out bool fieldTypeHasAutoLayout )
818+ private static SizeAndAlignment ComputeFieldSizeAndAlignment ( TypeDesc fieldType , bool hasLayout , int packingSize , out bool layoutAbiStable , out bool fieldTypeHasAutoLayout , out bool fieldTypeHasInt128Field )
806819 {
807820 SizeAndAlignment result ;
808821 layoutAbiStable = true ;
809822 fieldTypeHasAutoLayout = true ;
823+ fieldTypeHasInt128Field = false ;
810824
811825 if ( fieldType . IsDefType )
812826 {
@@ -817,6 +831,7 @@ private static SizeAndAlignment ComputeFieldSizeAndAlignment(TypeDesc fieldType,
817831 result . Alignment = defType . InstanceFieldAlignment ;
818832 layoutAbiStable = defType . LayoutAbiStable ;
819833 fieldTypeHasAutoLayout = defType . IsAutoLayoutOrHasAutoLayoutFields ;
834+ fieldTypeHasInt128Field = defType . IsInt128OrHasInt128Fields ;
820835 }
821836 else
822837 {
0 commit comments