Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NativeAOT] Move IsByRefLikeFlag from RareFlags to ExtendedFlags #106155

Closed
wants to merge 1 commit into from
Closed
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 @@ -618,7 +618,7 @@ internal bool IsByRefLike
{
get
{
return (RareFlags & EETypeRareFlags.IsByRefLikeFlag) != 0;
return IsValueType && (_uFlags & (uint)EETypeFlagsEx.IsByRefLikeFlag) != 0;
}
}

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 @@ -162,6 +162,9 @@ class MethodTable
HasCriticalFinalizerFlag = 0x0002,
IsTrackedReferenceWithFinalizerFlag = 0x0004,

// This MethodTable is for a Byref-like class (TypedReference, Span<T>, ...)
IsByRefLikeFlag = 0x0010,

// This type requires 8-byte alignment for its fields on certain platforms (ARM32, WASM)
RequiresAlign8Flag = 0x1000
};
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.IsByRefLike)
{
flagsEx |= (ushort)EETypeFlagsEx.IsByRefLikeFlag;
}

if (type.RequiresAlign8())
{
flagsEx |= (ushort)EETypeFlagsEx.RequiresAlign8Flag;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ internal enum EETypeFlagsEx : ushort
/// </summary>
IDynamicInterfaceCastableFlag = 0x0008,

/// <summary>
/// This MethodTable is for a Byref-like class (TypedReference, Span&lt;T&gt;,...)
/// </summary>
IsByRefLikeFlag = 0x0010,

/// <summary>
/// This type requires 8-byte alignment for its fields on certain platforms (ARM32, WASM)
/// </summary>
Expand Down Expand Up @@ -163,10 +168,7 @@ internal enum EETypeRareFlags : int

// UNUSED = 0x00004000,

/// <summary>
/// This MethodTable is for a Byref-like class (TypedReference, Span&lt;T&gt;,...)
/// </summary>
IsByRefLikeFlag = 0x00008000,
// UNUSED = 0x00008000,
}

internal enum EETypeField
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1343,26 +1343,10 @@ private void OutputDispatchMap(NodeFactory factory, ref ObjectDataBuilder objDat
/// </summary>
protected internal virtual void ComputeOptionalEETypeFields(NodeFactory factory, bool relocsOnly)
{
ComputeRareFlags();
ComputeNullableValueOffset();
ComputeValueTypeFieldPadding();
}

private void ComputeRareFlags()
{
uint flags = 0;

if (_type.IsByRefLike)
{
flags |= (uint)EETypeRareFlags.IsByRefLikeFlag;
}

if (flags != 0)
{
_optionalFieldsBuilder.SetFieldValue(EETypeOptionalFieldTag.RareFlags, flags);
}
}

/// <summary>
/// To support boxing / unboxing, the offset of the value field of a Nullable type is recorded on the MethodTable.
/// This is variable according to the alignment requirements of the Nullable&lt;T&gt; type parameter.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ protected override ObjectData GetDehydratableData(NodeFactory factory, bool relo

dataBuilder.RequireInitialPointerAlignment();
dataBuilder.AddSymbol(this);
EETypeRareFlags rareFlags = 0;

uint flags = EETypeBuilderHelpers.ComputeFlags(_type);

Expand All @@ -51,10 +50,7 @@ protected override ObjectData GetDehydratableData(NodeFactory factory, bool relo
flags |= (uint)EETypeFlags.GenericVarianceFlag;

if (_type.IsByRefLike)
rareFlags |= EETypeRareFlags.IsByRefLikeFlag;

if (rareFlags != 0)
_optionalFieldsBuilder.SetFieldValue(EETypeOptionalFieldTag.RareFlags, (uint)rareFlags);
flags |= (uint)EETypeFlagsEx.IsByRefLikeFlag;

if (HasOptionalFields)
flags |= (uint)EETypeFlags.OptionalFieldsFlag;
Expand Down
Loading