Skip to content

Commit 0fafa0a

Browse files
committed
Add RequiresAlign8 to MethodTable
1 parent abb2d5a commit 0fafa0a

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

src/coreclr/System.Private.CoreLib/src/System/Runtime/CompilerServices/CastHelpers.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -557,8 +557,13 @@ internal static object BoxImpl(MethodTable* typeMT, ref byte unboxedData)
557557
Debug.Assert(typeMT != null);
558558
Debug.Assert(typeMT->IsValueType);
559559

560+
#if FEATURE_64BIT_ALIGNMENT
561+
object boxed = typeMT->RequiresAlign8 ? (RuntimeTypeHandle.GetThreadLocalAllocInternal(typeMT) ??
562+
RuntimeTypeHandle.InternalAllocNoChecks(typeMT)) : RuntimeTypeHandle.InternalAllocNoChecks(typeMT);
563+
#else
560564
object boxed = RuntimeTypeHandle.GetThreadLocalAllocInternal(typeMT) ??
561565
RuntimeTypeHandle.InternalAllocNoChecks(typeMT);
566+
#endif
562567

563568
if (typeMT->ContainsGCPointers)
564569
{

src/coreclr/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeHelpers.CoreCLR.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,9 @@ internal unsafe struct MethodTable
755755
private const uint enum_flag_HasTypeEquivalence = 0x02000000;
756756
#endif // FEATURE_TYPEEQUIVALENCE
757757
private const uint enum_flag_HasFinalizer = 0x00100000;
758+
#if FEATURE_64BIT_ALIGNMENT
759+
private const uint enum_flag_RequiresAlign8 = 0x00800000; // Type requires 8-byte alignment (only set on platforms that require this and don't get it implicitly)
760+
#endif
758761
private const uint enum_flag_Category_Mask = 0x000F0000;
759762
private const uint enum_flag_Category_ValueType = 0x00040000;
760763
private const uint enum_flag_Category_Nullable = 0x00050000;
@@ -815,6 +818,10 @@ internal unsafe struct MethodTable
815818

816819
public bool HasFinalizer => (Flags & enum_flag_HasFinalizer) != 0;
817820

821+
#if FEATURE_64BIT_ALIGNMENT
822+
public bool RequiresAlign8 => (Flags & enum_flag_RequiresAlign8) != 0;
823+
#endif
824+
818825
internal static bool AreSameType(MethodTable* mt1, MethodTable* mt2) => mt1 == mt2;
819826

820827
public bool HasDefaultConstructor => (Flags & (enum_flag_HasComponentSize | enum_flag_HasDefaultCtor)) == enum_flag_HasDefaultCtor;

src/coreclr/clr.featuredefines.props

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
<FeatureEHFunclets>true</FeatureEHFunclets>
2727
</PropertyGroup>
2828

29+
<PropertyGroup Condition="'$(Platform)' == 'arm' OR '$(Platform)' == 'armel' OR '$(Platform)' == 'wasm'">
30+
<Feature64BitAlignmentRequired>true</Feature64BitAlignmentRequired>
31+
</PropertyGroup>
32+
2933
<PropertyGroup>
3034
<DefineConstants Condition="'$(FeatureComWrappers)' == 'true'">$(DefineConstants);FEATURE_COMWRAPPERS</DefineConstants>
3135
<DefineConstants Condition="'$(FeatureCominterop)' == 'true'">$(DefineConstants);FEATURE_COMINTEROP</DefineConstants>
@@ -36,6 +40,7 @@
3640
<DefineConstants Condition="'$(FeatureXplatEventSource)' == 'true'">$(DefineConstants);FEATURE_EVENTSOURCE_XPLAT</DefineConstants>
3741
<DefineConstants Condition="'$(FeatureTypeEquivalence)' == 'true'">$(DefineConstants);FEATURE_TYPEEQUIVALENCE</DefineConstants>
3842
<DefineConstants Condition="'$(FeatureEHFunclets)' == 'true'">$(DefineConstants);FEATURE_EH_FUNCLETS</DefineConstants>
43+
<DefineConstants Condition="'$(Feature64BitAlignmentRequired)' == 'true'">$(DefineConstants);FEATURE_64BIT_ALIGNMENT</DefineConstants>
3944

4045
<DefineConstants Condition="'$(ProfilingSupportedBuild)' == 'true'">$(DefineConstants);PROFILING_SUPPORTED</DefineConstants>
4146
</PropertyGroup>

0 commit comments

Comments
 (0)