if (pinned)
flags |= GC_ALLOC_FLAGS.GC_ALLOC_PINNED_OBJECT_HEAP;
- return Unsafe.As<T[]>(AllocateNewArray(typeof(T[]).TypeHandle.Value, length, flags));
+ return Unsafe.As<T[]>(AllocateNewArray(RuntimeTypeHandle.ToIntPtr(typeof(T[]).TypeHandle), length, flags));
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static TypeHandle TypeHandleOf<T>()
{
- return new TypeHandle((void*)RuntimeTypeHandle.GetValueInternal(typeof(T).TypeHandle));
+ return new TypeHandle((void*)RuntimeTypeHandle.ToIntPtr(typeof(T).TypeHandle));
}
}
/// </summary>
/// <param name="value">A <see cref="RuntimeTypeHandle"/> object to retrieve an internal pointer representation from.</param>
/// <returns>An <see cref="IntPtr"/> object that represents a <see cref="RuntimeTypeHandle"/> object.</returns>
+ [Intrinsic]
public static IntPtr ToIntPtr(RuntimeTypeHandle value) => value.Value;
public static bool operator ==(RuntimeTypeHandle left, object? right) => left.Equals(right);
public IntPtr Value => m_type?.m_handle ?? 0;
- [Intrinsic]
- internal static IntPtr GetValueInternal(RuntimeTypeHandle handle)
- => handle.m_type?.GetUnderlyingNativeHandle() ?? 0;
-
internal RuntimeTypeHandle(RuntimeType type)
{
m_type = type;
return m_value;
}
- // Used by EE
- private static IntPtr GetValueInternal(RuntimeMethodHandle rmh)
- {
- return rmh.Value;
- }
-
// ISerializable interface
[Obsolete(Obsoletions.LegacyFormatterImplMessage, DiagnosticId = Obsoletions.LegacyFormatterImplDiagId, UrlFormat = Obsoletions.SharedUrlFormat)]
[EditorBrowsable(EditorBrowsableState.Never)]
case NI_System_Runtime_CompilerServices_RuntimeHelpers_IsKnownConstant:
// We need these to be able to fold "typeof(...) == typeof(...)"
- case NI_System_RuntimeTypeHandle_GetValueInternal:
+ case NI_System_RuntimeTypeHandle_ToIntPtr:
case NI_System_Type_GetTypeFromHandle:
case NI_System_Type_op_Equality:
case NI_System_Type_op_Inequality:
return lengthField;
}
- case NI_System_RuntimeTypeHandle_GetValueInternal:
+ case NI_System_RuntimeTypeHandle_ToIntPtr:
{
GenTree* op1 = impStackTop(0).val;
if (op1->gtOper == GT_CALL && (op1->AsCall()->gtCallType == CT_HELPER) &&
}
else if (strcmp(className, "RuntimeTypeHandle") == 0)
{
- if (strcmp(methodName, "GetValueInternal") == 0)
+ if (strcmp(methodName, "ToIntPtr") == 0)
{
- result = NI_System_RuntimeTypeHandle_GetValueInternal;
+ result = NI_System_RuntimeTypeHandle_ToIntPtr;
}
}
break;
NI_System_Array_GetUpperBound,
NI_System_Object_MemberwiseClone,
NI_System_Object_GetType,
- NI_System_RuntimeTypeHandle_GetValueInternal,
+ NI_System_RuntimeTypeHandle_ToIntPtr,
NI_System_StubHelpers_GetStubContext,
NI_System_StubHelpers_NextCallReturnAddress,
return modulePath;
}
- public static IntPtr GetRuntimeTypeHandleRawValue(RuntimeTypeHandle runtimeTypeHandle)
- {
- return runtimeTypeHandle.RawValue;
- }
-
// if functionPointer points at an import or unboxing stub, find the target of the stub
public static IntPtr GetCodeTarget(IntPtr functionPointer)
{
}
}
- internal IntPtr RawValue
- {
- get
- {
- return _value;
- }
- }
-
private IntPtr _value;
}
}
internal static class RuntimeHandlesExtensions
{
public static bool IsNull(this RuntimeTypeHandle rtth)
- {
- return RuntimeAugments.GetRuntimeTypeHandleRawValue(rtth) == IntPtr.Zero;
- }
+ => RuntimeTypeHandle.ToIntPtr(rtth) == 0;
}
}
internal static class RuntimeHandleExtensions
{
public static bool IsNull(this RuntimeTypeHandle rtth)
- {
- return RuntimeAugments.GetRuntimeTypeHandleRawValue(rtth) == IntPtr.Zero;
- }
+ => RuntimeTypeHandle.ToIntPtr(rtth) == 0;
public static unsafe bool IsDynamic(this RuntimeFieldHandle rtfh)
- {
- IntPtr rtfhValue = *(IntPtr*)&rtfh;
- return (rtfhValue.ToInt64() & 0x1) == 0x1;
- }
+ => (RuntimeFieldHandle.ToIntPtr(rtfh) & 1) != 0;
- public static unsafe bool IsDynamic(this RuntimeMethodHandle rtfh)
- {
- IntPtr rtfhValue = *(IntPtr*)&rtfh;
- return (rtfhValue.ToInt64() & 0x1) == 0x1;
- }
+ public static unsafe bool IsDynamic(this RuntimeMethodHandle rtmh)
+ => (RuntimeMethodHandle.ToIntPtr(rtmh) & 1) != 0;
}
}
}
[Intrinsic]
- internal static unsafe IntPtr GetValueInternal(RuntimeTypeHandle handle)
+ internal static unsafe IntPtr ToIntPtr(RuntimeTypeHandle handle)
{
return (IntPtr)handle._pEEType.ToPointer();
}
[Intrinsic]
public static bool operator ==(Type left, Type right)
{
- return RuntimeTypeHandle.GetValueInternal(left._typeHandle) == RuntimeTypeHandle.GetValueInternal(right._typeHandle);
+ return RuntimeTypeHandle.ToIntPtr(left._typeHandle) == RuntimeTypeHandle.ToIntPtr(right._typeHandle);
}
[Intrinsic]
DEFINE_CLASS(TYPE_HANDLE, System, RuntimeTypeHandle)
DEFINE_CLASS(RT_TYPE_HANDLE, System, RuntimeTypeHandle)
DEFINE_METHOD(RT_TYPE_HANDLE, PVOID_CTOR, .ctor, IM_RuntimeType_RetVoid)
-DEFINE_METHOD(RT_TYPE_HANDLE, GETVALUEINTERNAL, GetValueInternal, SM_RuntimeTypeHandle_RetIntPtr)
+DEFINE_METHOD(RT_TYPE_HANDLE, TO_INTPTR, ToIntPtr, SM_RuntimeTypeHandle_RetIntPtr)
#ifdef FEATURE_COMINTEROP
DEFINE_METHOD(RT_TYPE_HANDLE, ALLOCATECOMOBJECT, AllocateComObject, SM_VoidPtr_RetObj)
#endif
DEFINE_CLASS(METHOD_HANDLE, System, RuntimeMethodHandle)
DEFINE_FIELD(METHOD_HANDLE, METHOD, m_value)
-DEFINE_METHOD(METHOD_HANDLE, GETVALUEINTERNAL, GetValueInternal, SM_RuntimeMethodHandle_RetIntPtr)
+DEFINE_METHOD(METHOD_HANDLE, TO_INTPTR, ToIntPtr, SM_RuntimeMethodHandle_RetIntPtr)
DEFINE_CLASS(MISSING, Reflection, Missing)
DEFINE_FIELD(MISSING, VALUE, Value)
if (itfInfo.thNativeItf.GetMethodTable())
{
pslILEmit->EmitLDTOKEN(pslILEmit->GetToken(itfInfo.thNativeItf.GetMethodTable()));
- pslILEmit->EmitCALL(METHOD__RT_TYPE_HANDLE__GETVALUEINTERNAL, 1, 1);
+ pslILEmit->EmitCALL(METHOD__RT_TYPE_HANDLE__TO_INTPTR, 1, 1);
}
else
{
if (itfInfo.thClass.GetMethodTable())
{
pslILEmit->EmitLDTOKEN(pslILEmit->GetToken(itfInfo.thClass.GetMethodTable()));
- pslILEmit->EmitCALL(METHOD__RT_TYPE_HANDLE__GETVALUEINTERNAL, 1, 1);
+ pslILEmit->EmitCALL(METHOD__RT_TYPE_HANDLE__TO_INTPTR, 1, 1);
}
else
{
if (itfInfo.thItf.GetMethodTable())
{
pslILEmit->EmitLDTOKEN(pslILEmit->GetToken(itfInfo.thItf.GetMethodTable()));
- pslILEmit->EmitCALL(METHOD__RT_TYPE_HANDLE__GETVALUEINTERNAL, 1, 1);
+ pslILEmit->EmitCALL(METHOD__RT_TYPE_HANDLE__TO_INTPTR, 1, 1);
}
else
{
if (itfInfo.thClass.GetMethodTable())
{
pslILEmit->EmitLDTOKEN(pslILEmit->GetToken(itfInfo.thClass.GetMethodTable()));
- pslILEmit->EmitCALL(METHOD__RT_TYPE_HANDLE__GETVALUEINTERNAL, 1, 1);
+ pslILEmit->EmitCALL(METHOD__RT_TYPE_HANDLE__TO_INTPTR, 1, 1);
}
else
{
pslILEmit->EmitBRFALSE(pNullRefLabel);
pslILEmit->EmitLDTOKEN(pslILEmit->GetToken(m_pargs->m_pMT));
- pslILEmit->EmitCALL(METHOD__RT_TYPE_HANDLE__GETVALUEINTERNAL, 1, 1);
+ pslILEmit->EmitCALL(METHOD__RT_TYPE_HANDLE__TO_INTPTR, 1, 1);
// static object AllocateInternal(IntPtr typeHandle);
pslILEmit->EmitCALL(METHOD__STUBHELPERS__ALLOCATE_INTERNAL, 1, 1);
EmitStoreManagedValue(pslILEmit);
pslILEmit->EmitLDLOC(m_dwMngdMarshalerLocalNum);
pslILEmit->EmitLDTOKEN(pslILEmit->GetToken(mops.methodTable));
- pslILEmit->EmitCALL(METHOD__RT_TYPE_HANDLE__GETVALUEINTERNAL, 1, 1);
+ pslILEmit->EmitCALL(METHOD__RT_TYPE_HANDLE__TO_INTPTR, 1, 1);
DWORD dwFlags = mops.elementType;
dwFlags |= (((DWORD)mops.bestfitmapping) << 16);
pslILEmit->EmitLDLOC(m_dwMngdMarshalerLocalNum);
pslILEmit->EmitLDTOKEN(pslILEmit->GetToken(mops.methodTable));
- pslILEmit->EmitCALL(METHOD__RT_TYPE_HANDLE__GETVALUEINTERNAL, 1, 1);
+ pslILEmit->EmitCALL(METHOD__RT_TYPE_HANDLE__TO_INTPTR, 1, 1);
DWORD dwFlags = mops.elementType;
dwFlags |= (((DWORD)mops.bestfitmapping) << 16);
pslILEmit->EmitLDLOC(m_dwMngdMarshalerLocalNum);
pslILEmit->EmitLDTOKEN(pslILEmit->GetToken(mops.methodTable));
- pslILEmit->EmitCALL(METHOD__RT_TYPE_HANDLE__GETVALUEINTERNAL, 1, 1);
+ pslILEmit->EmitCALL(METHOD__RT_TYPE_HANDLE__TO_INTPTR, 1, 1);
pslILEmit->EmitLDC(m_pargs->m_pMarshalInfo->GetArrayRank());
pslILEmit->EmitLDC(dwFlags);
//
pslILEmit->EmitLDTOKEN(pslILEmit->GetToken(m_pargs->rcm.m_pMD));
- pslILEmit->EmitCALL(METHOD__METHOD_HANDLE__GETVALUEINTERNAL, 1, 1);
+ pslILEmit->EmitCALL(METHOD__METHOD_HANDLE__TO_INTPTR, 1, 1);
pslILEmit->EmitLDC(m_pargs->rcm.m_paramToken);
pslILEmit->EmitLDTOKEN(pslILEmit->GetToken(TypeHandle::FromPtr(m_pargs->rcm.m_hndManagedType)));
- pslILEmit->EmitCALL(METHOD__RT_TYPE_HANDLE__GETVALUEINTERNAL, 1, 1);
+ pslILEmit->EmitCALL(METHOD__RT_TYPE_HANDLE__TO_INTPTR, 1, 1);
pslILEmit->EmitCALL(METHOD__STUBHELPERS__CREATE_CUSTOM_MARSHALER_HELPER, 3, 1); // arg to CreateMarshaler
#ifdef FEATURE_ICASTABLE
// In case of ICastable, instead of trying to find method implementation in the real object type
- // we call pObj.GetValueInternal() and call GetMethodDescForInterfaceMethod() again with whatever type it returns.
+ // we call GetMethodDescForInterfaceMethod() again with whatever type it returns.
// It allows objects that implement ICastable to mimic behavior of other types.
if (pServerMT->IsICastable() &&
!pItfMD->HasMethodInstantiation() &&
GCStress<cfg_any>::MaybeTrigger();
// In case of ICastable, instead of trying to find method implementation in the real object type
- // we call pObj.GetValueInternal() and call Resolver() again with whatever type it returns.
+ // we call Resolver() again with whatever type it returns.
// It allows objects that implement ICastable to mimic behavior of other types.
MethodTable * pTokenMT = GetTypeFromToken(token);