@@ -64,8 +64,14 @@ public ReadyToRunCompilerContext(
6464 _r2rFieldLayoutAlgorithm = new ReadyToRunMetadataFieldLayoutAlgorithm ( ) ;
6565 _systemObjectFieldLayoutAlgorithm = new SystemObjectFieldLayoutAlgorithm ( _r2rFieldLayoutAlgorithm ) ;
6666
67- // Only the Arm64 JIT respects the OS rules for vector type abi currently
68- _vectorFieldLayoutAlgorithm = new VectorFieldLayoutAlgorithm ( _r2rFieldLayoutAlgorithm , ( details . Architecture == TargetArchitecture . ARM64 ) ? true : bubbleIncludesCorelib ) ;
67+ // There are a few types which require special layout algorithms and which could change based on hardware
68+ // or to better match the underlying native ABI in the future. However, these are also fairly core types
69+ // which are used in many perf critical functions that exist on startup and which are often tied to an ISA.
70+ //
71+ // Given that, we treat them as ABI stable today to ensure that R2R works well. If we end up modifying the
72+ // ABI handling in the future, we would need to take a major version bump to R2R, which is deemed worthwhile.
73+
74+ _vectorFieldLayoutAlgorithm = new VectorFieldLayoutAlgorithm ( _r2rFieldLayoutAlgorithm ) ;
6975
7076 ReadOnlySpan < byte > matchingVectorType = "Unknown"u8 ;
7177 if ( details . MaximumSimdVectorLength == SimdVectorLength . Vector128Bit )
@@ -75,10 +81,7 @@ public ReadyToRunCompilerContext(
7581 else if ( details . MaximumSimdVectorLength == SimdVectorLength . Vector512Bit )
7682 matchingVectorType = "Vector512`1"u8 ;
7783
78- // No architecture has completely stable handling of Vector<T> in the abi (Arm64 may change to SVE)
79- _vectorOfTFieldLayoutAlgorithm = new VectorOfTFieldLayoutAlgorithm ( _r2rFieldLayoutAlgorithm , _vectorFieldLayoutAlgorithm , matchingVectorType , bubbleIncludesCorelib ) ;
80-
81- // Int128 and UInt128 should be ABI stable on all currently supported platforms
84+ _vectorOfTFieldLayoutAlgorithm = new VectorOfTFieldLayoutAlgorithm ( _r2rFieldLayoutAlgorithm , _vectorFieldLayoutAlgorithm , matchingVectorType ) ;
8285 _int128FieldLayoutAlgorithm = new Int128FieldLayoutAlgorithm ( _r2rFieldLayoutAlgorithm ) ;
8386
8487 _typeWithRepeatedFieldsFieldLayoutAlgorithm = new TypeWithRepeatedFieldsFieldLayoutAlgorithm ( _r2rFieldLayoutAlgorithm ) ;
@@ -198,14 +201,12 @@ internal class VectorOfTFieldLayoutAlgorithm : FieldLayoutAlgorithm
198201 private FieldLayoutAlgorithm _vectorFallbackAlgorithm ;
199202 private byte [ ] _similarVectorName ;
200203 private DefType _similarVectorOpenType ;
201- private bool _vectorAbiIsStable ;
202204
203- public VectorOfTFieldLayoutAlgorithm ( FieldLayoutAlgorithm fallbackAlgorithm , FieldLayoutAlgorithm vectorFallbackAlgorithm , ReadOnlySpan < byte > similarVector , bool vectorAbiIsStable = true )
205+ public VectorOfTFieldLayoutAlgorithm ( FieldLayoutAlgorithm fallbackAlgorithm , FieldLayoutAlgorithm vectorFallbackAlgorithm , ReadOnlySpan < byte > similarVector )
204206 {
205207 _fallbackAlgorithm = fallbackAlgorithm ;
206208 _vectorFallbackAlgorithm = vectorFallbackAlgorithm ;
207209 _similarVectorName = similarVector . ToArray ( ) ;
208- _vectorAbiIsStable = vectorAbiIsStable ;
209210 }
210211
211212 private DefType GetSimilarVector ( DefType vectorOfTType )
@@ -256,7 +257,7 @@ public override ComputedInstanceFieldLayout ComputeInstanceLayout(DefType type,
256257 ByteCountUnaligned = LayoutInt . Indeterminate ,
257258 ByteCountAlignment = LayoutInt . Indeterminate ,
258259 Offsets = fieldsAndOffsets . ToArray ( ) ,
259- LayoutAbiStable = false ,
260+ LayoutAbiStable = true ,
260261 IsVectorTOrHasVectorTFields = true ,
261262 } ;
262263 return instanceLayout ;
@@ -275,7 +276,7 @@ public override ComputedInstanceFieldLayout ComputeInstanceLayout(DefType type,
275276 FieldAlignment = layoutFromSimilarIntrinsicVector . FieldAlignment ,
276277 FieldSize = layoutFromSimilarIntrinsicVector . FieldSize ,
277278 Offsets = layoutFromMetadata . Offsets ,
278- LayoutAbiStable = _vectorAbiIsStable ,
279+ LayoutAbiStable = true ,
279280 IsVectorTOrHasVectorTFields = true ,
280281 } ;
281282#else
@@ -286,7 +287,7 @@ public override ComputedInstanceFieldLayout ComputeInstanceLayout(DefType type,
286287 FieldAlignment = layoutFromMetadata . FieldAlignment ,
287288 FieldSize = layoutFromSimilarIntrinsicVector . FieldSize ,
288289 Offsets = layoutFromMetadata . Offsets ,
289- LayoutAbiStable = _vectorAbiIsStable ,
290+ LayoutAbiStable = true ,
290291 IsVectorTOrHasVectorTFields = true ,
291292 } ;
292293#endif
0 commit comments