Skip to content

Commit

Permalink
Sigh
Browse files Browse the repository at this point in the history
  • Loading branch information
MichalStrehovsky committed Nov 18, 2021
1 parent 24edc80 commit a706a05
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ protected internal virtual TypeDesc ConvertToCanon(TypeDesc typeToConvert, Canon
throw new NotSupportedException();
}

internal partial void InternalGetSupportsUniversalCanon(ref bool flag) => flag = SupportsUniversalCanon;
public abstract bool SupportsCanon { get; }
public abstract bool SupportsUniversalCanon { get; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,16 @@ out instanceByteSizeAndAlignment

protected virtual ComputedInstanceFieldLayout ComputeInstanceFieldLayout(MetadataType type, int numInstanceFields)
{
bool supportsUniversalCanon = false;
type.Context.InternalGetSupportsUniversalCanon(ref supportsUniversalCanon);

if (type.IsExplicitLayout)
{
return ComputeExplicitFieldLayout(type, numInstanceFields);
}
// Sequential layout has to be respected for blittable types only. We use approximation and respect it for
// all types without GC references (ie C# unmanaged types). Universal canonical instances might be blittable.
else if (type.IsSequentialLayout && (type.Context.SupportsUniversalCanon || !type.ContainsGCPointers))
else if (type.IsSequentialLayout && (supportsUniversalCanon || !type.ContainsGCPointers))
{
return ComputeSequentialFieldLayout(type, numInstanceFields);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -813,5 +813,7 @@ internal TypeFlags ComputeTypeFlags(TypeDesc type, TypeFlags flags, TypeFlags ma
/// Determine if the type implements <code>IDynamicInterfaceCastable</code>
/// </summary>
protected internal abstract bool IsIDynamicInterfaceCastableInterface(DefType type);

internal partial void InternalGetSupportsUniversalCanon(ref bool flag);
}
}

0 comments on commit a706a05

Please sign in to comment.