Skip to content

Commit

Permalink
Move RequiresAlign8 flag from RareFlags into ExtendedFlags
Browse files Browse the repository at this point in the history
  • Loading branch information
filipnavara committed Aug 6, 2024
1 parent 483db3e commit 9c54401
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ internal bool RequiresAlign8
{
get
{
return (RareFlags & EETypeRareFlags.RequiresAlign8Flag) != 0;
return (Flags & ((uint)EETypeFlags.HasComponentSizeFlag | (uint)EETypeFlagsEx.RequiresAlign8Flag)) == (uint)EETypeFlagsEx.RequiresAlign8Flag;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ public static unsafe object RhNewArray(MethodTable* pEEType, int length)
Debug.Assert(pEEType->IsArray || pEEType->IsString);

#if FEATURE_64BIT_ALIGNMENT
if (pEEType->RequiresAlign8)
MethodTable* pEEElementType = pEEType->RelatedParameterType;
if (pEEElementType->IsValueType && pEEElementType->RequiresAlign8)
{
return InternalCalls.RhpNewArrayAlign8(pEEType, length);
}
Expand Down Expand Up @@ -381,7 +382,8 @@ internal static unsafe IntPtr RhGetRuntimeHelperForType(MethodTable* pEEType, Ru

case RuntimeHelperKind.AllocateArray:
#if FEATURE_64BIT_ALIGNMENT
if (pEEType->RequiresAlign8)
MethodTable* pEEElementType = pEEType->RelatedParameterType;
if (pEEElementType->IsValueType && pEEElementType->RequiresAlign8)
return (IntPtr)(delegate*<MethodTable*, int, object>)&InternalCalls.RhpNewArrayAlign8;
#endif // FEATURE_64BIT_ALIGNMENT

Expand Down
3 changes: 3 additions & 0 deletions src/coreclr/nativeaot/Runtime/inc/MethodTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ class MethodTable
// GC depends on this bit, this type has a critical finalizer
HasCriticalFinalizerFlag = 0x0002,
IsTrackedReferenceWithFinalizerFlag = 0x0004,

// This type requires 8-byte alignment for its fields on certain platforms (ARM32, WASM)
RequiresAlign8 = 0x1000
};

public:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@ mdType.Name is "WeakReference" or "WeakReference`1" &&
flagsEx |= (ushort)EETypeFlagsEx.IDynamicInterfaceCastableFlag;
}

if (type.RequiresAlign8())
{
flagsEx |= (ushort)EETypeFlagsEx.RequiresAlign8Flag;
}

return flagsEx;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ internal enum EETypeFlagsEx : ushort
/// This type implements IDynamicInterfaceCastable to allow dynamic resolution of interface casts.
/// </summary>
IDynamicInterfaceCastableFlag = 0x0008,

/// <summary>
/// This type requires 8-byte alignment for its fields on certain platforms (ARM32, WASM)
/// </summary>
RequiresAlign8 = 0x1000
}

internal enum EETypeKind : uint
Expand Down Expand Up @@ -116,10 +121,7 @@ internal enum EETypeKind : uint
[Flags]
internal enum EETypeRareFlags : int
{
/// <summary>
/// This type requires 8-byte alignment for its fields on certain platforms (only ARM currently).
/// </summary>
RequiresAlign8Flag = 0x00000001,
// UNUSED = 0x00000001,

// UNUSED1 = 0x00000002,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1359,11 +1359,6 @@ private void ComputeRareFlags(NodeFactory factory)
flags |= (uint)EETypeRareFlags.HasCctorFlag;
}

if (_type.RequiresAlign8())
{
flags |= (uint)EETypeRareFlags.RequiresAlign8Flag;
}

TargetArchitecture targetArch = _type.Context.Target.Architecture;
if (metadataType != null &&
(targetArch == TargetArchitecture.ARM ||
Expand Down

0 comments on commit 9c54401

Please sign in to comment.