Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public override ComputedInstanceFieldLayout ComputeInstanceLayout(DefType defTyp
// 32bit platforms use standard metadata layout engine
if (defType.Context.Target.Architecture == TargetArchitecture.ARM)
{
layoutFromMetadata.LayoutAbiStable = false; // Int128 parameter passing ABI is unstable at this time
layoutFromMetadata.LayoutAbiStable = true;
layoutFromMetadata.IsInt128OrHasInt128Fields = true;
return layoutFromMetadata;
}
Expand All @@ -47,7 +47,7 @@ public override ComputedInstanceFieldLayout ComputeInstanceLayout(DefType defTyp
FieldAlignment = new LayoutInt(16),
FieldSize = layoutFromMetadata.FieldSize,
Offsets = layoutFromMetadata.Offsets,
LayoutAbiStable = false, // Int128 parameter passing ABI is unstable at this time
LayoutAbiStable = true,
IsInt128OrHasInt128Fields = true
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@ namespace ILCompiler
public class VectorFieldLayoutAlgorithm : FieldLayoutAlgorithm
{
private readonly FieldLayoutAlgorithm _fallbackAlgorithm;
private readonly bool _vectorAbiIsStable;

public VectorFieldLayoutAlgorithm(FieldLayoutAlgorithm fallbackAlgorithm, bool vectorAbiIsStable = true)
public VectorFieldLayoutAlgorithm(FieldLayoutAlgorithm fallbackAlgorithm)
{
_vectorAbiIsStable = vectorAbiIsStable;
_fallbackAlgorithm = fallbackAlgorithm;
}

Expand Down Expand Up @@ -119,7 +117,7 @@ public override ComputedInstanceFieldLayout ComputeInstanceLayout(DefType defTyp
FieldAlignment = alignment,
FieldSize = layoutFromMetadata.FieldSize,
Offsets = layoutFromMetadata.Offsets,
LayoutAbiStable = _vectorAbiIsStable
LayoutAbiStable = true
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,14 @@ public ReadyToRunCompilerContext(
_r2rFieldLayoutAlgorithm = new ReadyToRunMetadataFieldLayoutAlgorithm();
_systemObjectFieldLayoutAlgorithm = new SystemObjectFieldLayoutAlgorithm(_r2rFieldLayoutAlgorithm);

// Only the Arm64 JIT respects the OS rules for vector type abi currently
_vectorFieldLayoutAlgorithm = new VectorFieldLayoutAlgorithm(_r2rFieldLayoutAlgorithm, (details.Architecture == TargetArchitecture.ARM64) ? true : bubbleIncludesCorelib);
// There are a few types which require special layout algorithms and which could change based on hardware
// or to better match the underlying native ABI in the future. However, these are also fairly core types
// which are used in many perf critical functions that exist on startup and which are often tied to an ISA.
//
// Given that, we treat them as ABI stable today to ensure that R2R works well. If we end up modifying the
// ABI handling in the future, we would need to take a major version bump to R2R, which is deemed worthwhile.

_vectorFieldLayoutAlgorithm = new VectorFieldLayoutAlgorithm(_r2rFieldLayoutAlgorithm);

ReadOnlySpan<byte> matchingVectorType = "Unknown"u8;
if (details.MaximumSimdVectorLength == SimdVectorLength.Vector128Bit)
Expand All @@ -75,10 +81,7 @@ public ReadyToRunCompilerContext(
else if (details.MaximumSimdVectorLength == SimdVectorLength.Vector512Bit)
matchingVectorType = "Vector512`1"u8;

// No architecture has completely stable handling of Vector<T> in the abi (Arm64 may change to SVE)
_vectorOfTFieldLayoutAlgorithm = new VectorOfTFieldLayoutAlgorithm(_r2rFieldLayoutAlgorithm, _vectorFieldLayoutAlgorithm, matchingVectorType, bubbleIncludesCorelib);

// Int128 and UInt128 should be ABI stable on all currently supported platforms
_vectorOfTFieldLayoutAlgorithm = new VectorOfTFieldLayoutAlgorithm(_r2rFieldLayoutAlgorithm, _vectorFieldLayoutAlgorithm, matchingVectorType);
_int128FieldLayoutAlgorithm = new Int128FieldLayoutAlgorithm(_r2rFieldLayoutAlgorithm);

_typeWithRepeatedFieldsFieldLayoutAlgorithm = new TypeWithRepeatedFieldsFieldLayoutAlgorithm(_r2rFieldLayoutAlgorithm);
Expand Down Expand Up @@ -198,14 +201,12 @@ internal class VectorOfTFieldLayoutAlgorithm : FieldLayoutAlgorithm
private FieldLayoutAlgorithm _vectorFallbackAlgorithm;
private byte[] _similarVectorName;
private DefType _similarVectorOpenType;
private bool _vectorAbiIsStable;

public VectorOfTFieldLayoutAlgorithm(FieldLayoutAlgorithm fallbackAlgorithm, FieldLayoutAlgorithm vectorFallbackAlgorithm, ReadOnlySpan<byte> similarVector, bool vectorAbiIsStable = true)
public VectorOfTFieldLayoutAlgorithm(FieldLayoutAlgorithm fallbackAlgorithm, FieldLayoutAlgorithm vectorFallbackAlgorithm, ReadOnlySpan<byte> similarVector)
{
_fallbackAlgorithm = fallbackAlgorithm;
_vectorFallbackAlgorithm = vectorFallbackAlgorithm;
_similarVectorName = similarVector.ToArray();
_vectorAbiIsStable = vectorAbiIsStable;
}

private DefType GetSimilarVector(DefType vectorOfTType)
Expand Down Expand Up @@ -256,7 +257,7 @@ public override ComputedInstanceFieldLayout ComputeInstanceLayout(DefType type,
ByteCountUnaligned = LayoutInt.Indeterminate,
ByteCountAlignment = LayoutInt.Indeterminate,
Offsets = fieldsAndOffsets.ToArray(),
LayoutAbiStable = false,
LayoutAbiStable = true,
IsVectorTOrHasVectorTFields = true,
};
return instanceLayout;
Expand All @@ -275,7 +276,7 @@ public override ComputedInstanceFieldLayout ComputeInstanceLayout(DefType type,
FieldAlignment = layoutFromSimilarIntrinsicVector.FieldAlignment,
FieldSize = layoutFromSimilarIntrinsicVector.FieldSize,
Offsets = layoutFromMetadata.Offsets,
LayoutAbiStable = _vectorAbiIsStable,
LayoutAbiStable = true,
IsVectorTOrHasVectorTFields = true,
};
#else
Expand All @@ -286,7 +287,7 @@ public override ComputedInstanceFieldLayout ComputeInstanceLayout(DefType type,
FieldAlignment = layoutFromMetadata.FieldAlignment,
FieldSize = layoutFromSimilarIntrinsicVector.FieldSize,
Offsets = layoutFromMetadata.Offsets,
LayoutAbiStable = _vectorAbiIsStable,
LayoutAbiStable = true,
IsVectorTOrHasVectorTFields = true,
};
#endif
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ internal class TestTypeSystemContext : MetadataTypeSystemContext
public TestTypeSystemContext(TargetArchitecture arch, TargetOS targetOS = TargetOS.Unknown)
: base(new TargetDetails(arch, targetOS, TargetAbi.Unknown))
{
_vectorFieldLayoutAlgorithm = new VectorFieldLayoutAlgorithm(_metadataFieldLayout, true);
_vectorFieldLayoutAlgorithm = new VectorFieldLayoutAlgorithm(_metadataFieldLayout);
_int128FieldLayoutAlgorithm = new Int128FieldLayoutAlgorithm(_metadataFieldLayout);
}

Expand Down