Skip to content

Commit

Permalink
Rename get_* to Get* in NativeAOT runtime (dotnet#92498)
Browse files Browse the repository at this point in the history
* Rename get_* to Get* in NativeAOT runtime

A few methods in native AOT runtime data structures used get_ prefix for
historic reasons.

* Rename MethodTable.Is*Type to MethodTable.Is* for several properties to make them match names used by the managed type system
  • Loading branch information
jkotas authored Sep 23, 2023
1 parent 0976df5 commit c7ca1f3
Show file tree
Hide file tree
Showing 20 changed files with 84 additions and 108 deletions.
26 changes: 13 additions & 13 deletions src/coreclr/nativeaot/Common/src/Internal/Runtime/MethodTable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -593,15 +593,15 @@ internal GenericVariance* GenericVariance
}
}

internal bool IsPointerType
internal bool IsPointer
{
get
{
return ElementType == EETypeElementType.Pointer;
}
}

internal bool IsByRefType
internal bool IsByRef
{
get
{
Expand Down Expand Up @@ -641,7 +641,7 @@ internal bool IsParameterizedType
}
}

internal bool IsFunctionPointerType
internal bool IsFunctionPointer
{
get
{
Expand Down Expand Up @@ -673,13 +673,13 @@ internal uint NumFunctionPointerParameters
{
get
{
Debug.Assert(IsFunctionPointerType);
Debug.Assert(IsFunctionPointer);
return _uBaseSize & ~FunctionPointerFlags.FlagsMask;
}
#if TYPE_LOADER_IMPLEMENTATION
set
{
Debug.Assert(IsFunctionPointerType);
Debug.Assert(IsFunctionPointer);
_uBaseSize = value | (_uBaseSize & FunctionPointerFlags.FlagsMask);
}
#endif
Expand All @@ -689,13 +689,13 @@ internal bool IsUnmanagedFunctionPointer
{
get
{
Debug.Assert(IsFunctionPointerType);
Debug.Assert(IsFunctionPointer);
return (_uBaseSize & FunctionPointerFlags.IsUnmanaged) != 0;
}
#if TYPE_LOADER_IMPLEMENTATION
set
{
Debug.Assert(IsFunctionPointerType);
Debug.Assert(IsFunctionPointer);
if (value)
_uBaseSize |= FunctionPointerFlags.IsUnmanaged;
else
Expand All @@ -719,13 +719,13 @@ internal MethodTable* FunctionPointerReturnType
{
get
{
Debug.Assert(IsFunctionPointerType);
Debug.Assert(IsFunctionPointer);
return _relatedType._pRelatedParameterType;
}
#if TYPE_LOADER_IMPLEMENTATION
set
{
Debug.Assert(IsDynamicType && IsFunctionPointerType);
Debug.Assert(IsDynamicType && IsFunctionPointer);
_relatedType._pRelatedParameterType = value;
}
#endif
Expand Down Expand Up @@ -834,7 +834,7 @@ internal uint ValueTypeSize
get
{
Debug.Assert(IsValueType);
// get_BaseSize returns the GC size including space for the sync block index field, the MethodTable* and
// BaseSize returns the GC size including space for the sync block index field, the MethodTable* and
// padding for GC heap alignment. Must subtract all of these to get the size used for locals, array
// elements or fields of another type.
return BaseSize - ((uint)sizeof(ObjHeader) + (uint)sizeof(MethodTable*) + ValueTypeFieldPadding);
Expand Down Expand Up @@ -924,7 +924,7 @@ internal MethodTable* BaseType
{
Debug.Assert(IsDynamicType);
Debug.Assert(!IsParameterizedType);
Debug.Assert(!IsFunctionPointerType);
Debug.Assert(!IsFunctionPointer);
Debug.Assert(IsCanonical);
_relatedType._pBaseType = value;
}
Expand Down Expand Up @@ -1332,10 +1332,10 @@ public uint GetFieldOffset(EETypeField eField)

if (eField == EETypeField.ETF_FunctionPointerParameters)
{
Debug.Assert(IsFunctionPointerType);
Debug.Assert(IsFunctionPointer);
return cbOffset;
}
if (IsFunctionPointerType)
if (IsFunctionPointer)
{
cbOffset += NumFunctionPointerParameters * relativeOrFullPointerOffset;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public static unsafe object RhNewObject(MethodTable* pEEType)
!pEEType->IsInterface &&
!pEEType->IsArray &&
!pEEType->IsString &&
!pEEType->IsPointerType &&
!pEEType->IsFunctionPointerType &&
!pEEType->IsPointer &&
!pEEType->IsFunctionPointer &&
!pEEType->IsByRefLike;
if (!isValid)
Debug.Assert(false);
Expand Down Expand Up @@ -356,15 +356,15 @@ internal static unsafe IntPtr RhGetRuntimeHelperForType(MethodTable* pEEType, Ru
return (IntPtr)(delegate*<MethodTable*, object>)&InternalCalls.RhpNewFast;

case RuntimeHelperKind.IsInst:
if (pEEType->HasGenericVariance || pEEType->IsParameterizedType || pEEType->IsFunctionPointerType)
if (pEEType->HasGenericVariance || pEEType->IsParameterizedType || pEEType->IsFunctionPointer)
return (IntPtr)(delegate*<MethodTable*, object, object?>)&TypeCast.IsInstanceOfAny;
else if (pEEType->IsInterface)
return (IntPtr)(delegate*<MethodTable*, object?, object?>)&TypeCast.IsInstanceOfInterface;
else
return (IntPtr)(delegate*<MethodTable*, object?, object?>)&TypeCast.IsInstanceOfClass;

case RuntimeHelperKind.CastClass:
if (pEEType->HasGenericVariance || pEEType->IsParameterizedType || pEEType->IsFunctionPointerType)
if (pEEType->HasGenericVariance || pEEType->IsParameterizedType || pEEType->IsFunctionPointer)
return (IntPtr)(delegate*<MethodTable*, object, object>)&TypeCast.CheckCastAny;
else if (pEEType->IsInterface)
return (IntPtr)(delegate*<MethodTable*, object, object>)&TypeCast.CheckCastInterface;
Expand Down
26 changes: 13 additions & 13 deletions src/coreclr/nativeaot/Runtime.Base/src/System/Runtime/TypeCast.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ internal enum AssignmentVariation
public static unsafe object? IsInstanceOfClass(MethodTable* pTargetType, object? obj)
{
Debug.Assert(!pTargetType->IsParameterizedType, "IsInstanceOfClass called with parameterized MethodTable");
Debug.Assert(!pTargetType->IsFunctionPointerType, "IsInstanceOfClass called with function pointer MethodTable");
Debug.Assert(!pTargetType->IsFunctionPointer, "IsInstanceOfClass called with function pointer MethodTable");
Debug.Assert(!pTargetType->IsInterface, "IsInstanceOfClass called with interface MethodTable");
Debug.Assert(!pTargetType->HasGenericVariance, "IsInstanceOfClass with variant MethodTable");

Expand Down Expand Up @@ -389,7 +389,7 @@ private static unsafe object CheckCastInterface_Helper(MethodTable* pTargetType,
public static unsafe object CheckCastClass(MethodTable* pTargetType, object obj)
{
Debug.Assert(!pTargetType->IsParameterizedType, "CheckCastClass called with parameterized MethodTable");
Debug.Assert(!pTargetType->IsFunctionPointerType, "CheckCastClass called with function pointer MethodTable");
Debug.Assert(!pTargetType->IsFunctionPointer, "CheckCastClass called with function pointer MethodTable");
Debug.Assert(!pTargetType->IsInterface, "CheckCastClass called with interface MethodTable");
Debug.Assert(!pTargetType->HasGenericVariance, "CheckCastClass with variant MethodTable");

Expand All @@ -407,7 +407,7 @@ public static unsafe object CheckCastClass(MethodTable* pTargetType, object obj)
private static unsafe object CheckCastClassSpecial(MethodTable* pTargetType, object obj)
{
Debug.Assert(!pTargetType->IsParameterizedType, "CheckCastClass called with parameterized MethodTable");
Debug.Assert(!pTargetType->IsFunctionPointerType, "CheckCastClass called with function pointer MethodTable");
Debug.Assert(!pTargetType->IsFunctionPointer, "CheckCastClass called with function pointer MethodTable");
Debug.Assert(!pTargetType->IsInterface, "CheckCastClass called with interface MethodTable");
Debug.Assert(!pTargetType->HasGenericVariance, "CheckCastClass with variant MethodTable");

Expand Down Expand Up @@ -478,11 +478,11 @@ internal static unsafe bool IsDerived(MethodTable* pDerivedType, MethodTable* pB
{
Debug.Assert(!pDerivedType->IsArray, "did not expect array type");
Debug.Assert(!pDerivedType->IsParameterizedType, "did not expect parameterType");
Debug.Assert(!pDerivedType->IsFunctionPointerType, "did not expect function pointer");
Debug.Assert(!pDerivedType->IsFunctionPointer, "did not expect function pointer");
Debug.Assert(!pBaseType->IsArray, "did not expect array type");
Debug.Assert(!pBaseType->IsInterface, "did not expect interface type");
Debug.Assert(!pBaseType->IsParameterizedType, "did not expect parameterType");
Debug.Assert(!pBaseType->IsFunctionPointerType, "did not expect function pointer");
Debug.Assert(!pBaseType->IsFunctionPointer, "did not expect function pointer");
Debug.Assert(pBaseType->IsCanonical || pBaseType->IsGenericTypeDefinition, "unexpected MethodTable");
Debug.Assert(pDerivedType->IsCanonical || pDerivedType->IsGenericTypeDefinition, "unexpected MethodTable");

Expand All @@ -504,7 +504,7 @@ internal static unsafe bool IsDerived(MethodTable* pDerivedType, MethodTable* pB
private static unsafe bool ImplementsInterface(MethodTable* pObjType, MethodTable* pTargetType, EETypePairList* pVisited)
{
Debug.Assert(!pTargetType->IsParameterizedType, "did not expect parameterized type");
Debug.Assert(!pTargetType->IsFunctionPointerType, "did not expect function pointer type");
Debug.Assert(!pTargetType->IsFunctionPointer, "did not expect function pointer type");
Debug.Assert(pTargetType->IsInterface, "IsInstanceOfInterface called with non-interface MethodTable");

int numInterfaces = pObjType->NumInterfaces;
Expand Down Expand Up @@ -1106,22 +1106,22 @@ internal static unsafe bool AreTypesAssignableInternalUncached(MethodTable* pSou
{
MethodTable* pSourceRelatedParameterType = pSourceType->RelatedParameterType;
// Source type is also a parameterized type. Are the parameter types compatible?
if (pSourceRelatedParameterType->IsPointerType)
if (pSourceRelatedParameterType->IsPointer)
{
// If the parameter types are pointers, then only exact matches are correct.
// As we've already compared equality at the start of this function,
// return false as the exact match case has already been handled.
// int** is not compatible with uint**, nor is int*[] oompatible with uint*[].
return false;
}
else if (pSourceRelatedParameterType->IsByRefType)
else if (pSourceRelatedParameterType->IsByRef)
{
// Only allow exact matches for ByRef types - same as pointers above. This should
// be unreachable and it's only a defense in depth. ByRefs can't be parameters
// of any parameterized type.
return false;
}
else if (pSourceRelatedParameterType->IsFunctionPointerType)
else if (pSourceRelatedParameterType->IsFunctionPointer)
{
// If the parameter types are function pointers, then only exact matches are correct.
// As we've already compared equality at the start of this function,
Expand All @@ -1142,7 +1142,7 @@ internal static unsafe bool AreTypesAssignableInternalUncached(MethodTable* pSou
return false;
}

if (pTargetType->IsFunctionPointerType)
if (pTargetType->IsFunctionPointer)
{
// Function pointers only cast if source and target are equivalent types.
return false;
Expand All @@ -1157,7 +1157,7 @@ internal static unsafe bool AreTypesAssignableInternalUncached(MethodTable* pSou
{
return false;
}
else if (pSourceType->IsFunctionPointerType)
else if (pSourceType->IsFunctionPointer)
{
return false;
}
Expand Down Expand Up @@ -1228,7 +1228,7 @@ internal static unsafe bool AreTypesAssignableInternalUncached(MethodTable* pSou
{
retObj = IsInstanceOfInterface(pTargetType, obj);
}
else if (pTargetType->IsParameterizedType || pTargetType->IsFunctionPointerType)
else if (pTargetType->IsParameterizedType || pTargetType->IsFunctionPointer)
{
// We handled arrays above so this is for pointers and byrefs only.
retObj = null;
Expand Down Expand Up @@ -1269,7 +1269,7 @@ private static unsafe object CheckCastAny_NoCacheLookup(MethodTable* pTargetType
{
obj = CheckCastInterface(pTargetType, obj);
}
else if (pTargetType->IsParameterizedType || pTargetType->IsFunctionPointerType)
else if (pTargetType->IsParameterizedType || pTargetType->IsFunctionPointer)
{
// We handled arrays above so this is for pointers and byrefs only.
// Nothing can be a boxed instance of these.
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/nativeaot/Runtime/GCHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,14 @@ EXTERN_C NATIVEAOT_API int32_t __cdecl RhpEndNoGCRegion()

COOP_PINVOKE_HELPER(void, RhSuppressFinalize, (OBJECTREF refObj))
{
if (!refObj->get_EEType()->HasFinalizer())
if (!refObj->GetMethodTable()->HasFinalizer())
return;
GCHeapUtilities::GetGCHeap()->SetFinalizationRun(refObj);
}

COOP_PINVOKE_HELPER(FC_BOOL_RET, RhReRegisterForFinalize, (OBJECTREF refObj))
{
if (!refObj->get_EEType()->HasFinalizer())
if (!refObj->GetMethodTable()->HasFinalizer())
FC_RETURN_BOOL(true);
FC_RETURN_BOOL(GCHeapUtilities::GetGCHeap()->RegisterForFinalization(-1, refObj));
}
Expand Down
12 changes: 6 additions & 6 deletions src/coreclr/nativeaot/Runtime/MethodTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ bool MethodTable::Validate(bool assertOnFail /* default: true */)
REPORT_FAILURE();

// Verify object size is bigger than min_obj_size
size_t minObjSize = get_BaseSize();
size_t minObjSize = GetBaseSize();
if (HasComponentSize())
{
// If it is an array, we will align the size to the nearest pointer alignment, even if there are
Expand All @@ -35,14 +35,14 @@ bool MethodTable::Validate(bool assertOnFail /* default: true */)
if (minObjSize < (3 * sizeof(TADDR)))
REPORT_FAILURE();

switch (get_Kind())
switch (GetKind())
{
case CanonicalEEType:
{
// If the parent type is NULL this had better look like Object.
if (!IsInterface() && (m_RelatedType.m_pBaseType == NULL))
{
if (get_IsValueType() ||
if (IsValueType() ||
HasFinalizer() ||
HasReferenceFields() ||
HasGenericVariance())
Expand All @@ -65,7 +65,7 @@ bool MethodTable::Validate(bool assertOnFail /* default: true */)
if (GetComponentSize() == 0)
REPORT_FAILURE();

if (get_IsValueType() ||
if (IsValueType() ||
HasFinalizer() ||
HasGenericVariance())
{
Expand Down Expand Up @@ -93,13 +93,13 @@ bool MethodTable::Validate(bool assertOnFail /* default: true */)
}

//-----------------------------------------------------------------------------------------------------------
MethodTable::Kinds MethodTable::get_Kind()
MethodTable::Kinds MethodTable::GetKind()
{
return (Kinds)(m_uFlags & (uint16_t)EETypeKindMask);
}

//-----------------------------------------------------------------------------------------------------------
MethodTable * MethodTable::get_RelatedParameterType()
MethodTable * MethodTable::GetRelatedParameterType()
{
ASSERT(IsParameterizedType());

Expand Down
6 changes: 3 additions & 3 deletions src/coreclr/nativeaot/Runtime/MiscHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ COOP_PINVOKE_HELPER(uint32_t, RhGetLoadedOSModules, (Array * pResultArray))

// If a result array is passed then it should be an array type with pointer-sized components that are not
// GC-references.
ASSERT(!pResultArray || pResultArray->get_EEType()->IsArray());
ASSERT(!pResultArray || !pResultArray->get_EEType()->HasReferenceFields());
ASSERT(!pResultArray || pResultArray->get_EEType()->RawGetComponentSize() == sizeof(void*));
ASSERT(!pResultArray || pResultArray->GetMethodTable()->IsArray());
ASSERT(!pResultArray || !pResultArray->GetMethodTable()->HasReferenceFields());
ASSERT(!pResultArray || pResultArray->GetMethodTable()->RawGetComponentSize() == sizeof(void*));

uint32_t cResultArrayElements = pResultArray ? pResultArray->GetArrayLength() : 0;
HANDLE * pResultElements = pResultArray ? (HANDLE*)(pResultArray + 1) : NULL;
Expand Down
6 changes: 3 additions & 3 deletions src/coreclr/nativeaot/Runtime/ObjectLayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ uint32_t Array::GetArrayLength()
void* Array::GetArrayData()
{
uint8_t* pData = (uint8_t*)this;
pData += (get_EEType()->get_BaseSize() - sizeof(ObjHeader));
pData += (GetMethodTable()->GetBaseSize() - sizeof(ObjHeader));
return pData;
}

Expand All @@ -55,12 +55,12 @@ void ObjHeader::ClrBit(uint32_t uBit)

size_t Object::GetSize()
{
MethodTable * pEEType = get_EEType();
MethodTable * pEEType = GetMethodTable();

// strings have component size2, all other non-arrays should have 0
ASSERT(( pEEType->GetComponentSize() <= 2) || pEEType->IsArray());

size_t s = pEEType->get_BaseSize();
size_t s = pEEType->GetBaseSize();
if (pEEType->HasComponentSize())
s += (size_t)((Array*)this)->GetArrayLength() * pEEType->RawGetComponentSize();

Expand Down
10 changes: 3 additions & 7 deletions src/coreclr/nativeaot/Runtime/ObjectLayout.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ class Object

PTR_EEType m_pEEType;
public:
MethodTable * get_EEType() const
MethodTable * GetMethodTable() const
{ return m_pEEType; }
MethodTable * get_SafeEEType() const
MethodTable * GetGCSafeMethodTable() const
#ifdef TARGET_64BIT
{ return dac_cast<PTR_EEType>((dac_cast<TADDR>(m_pEEType)) & ~((uintptr_t)7)); }
#else
Expand All @@ -66,11 +66,7 @@ class Object
//
MethodTable * RawGetMethodTable() const
{
return (MethodTable*)get_EEType();
}
MethodTable * GetGCSafeMethodTable() const
{
return (MethodTable *)get_SafeEEType();
return (MethodTable*)GetMethodTable();
}
void RawSetMethodTable(MethodTable * pMT)
{
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/nativeaot/Runtime/RestrictedCallouts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ bool RestrictedCallouts::InvokeRefCountedHandleCallbacks(Object * pObject)
HandleTableRestrictedCallout * pCurrCallout = s_pHandleTableRestrictedCallouts;
while (pCurrCallout)
{
if (pObject->get_SafeEEType() == pCurrCallout->m_pTypeFilter)
if (pObject->GetGCSafeMethodTable() == pCurrCallout->m_pTypeFilter)
{
// Make the callout. Return true to our caller as soon as we see a true result here.
if (((HandleTableRestrictedCallbackFunction)pCurrCallout->m_pCalloutMethod)(pObject))
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/nativeaot/Runtime/eventtrace_bulktype.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ int BulkTypeEventLogger::LogSingleType(MethodTable * pEEType)
// Array
pVal->fixedSizedData.Flags |= kEtwTypeFlagsArray;
pVal->cTypeParameters = 1;
pVal->ullSingleTypeParameter = (ULONGLONG) pEEType->get_RelatedParameterType();
pVal->ullSingleTypeParameter = (ULONGLONG) pEEType->GetRelatedParameterType();
}
else
{
Expand Down
Loading

0 comments on commit c7ca1f3

Please sign in to comment.