Skip to content
Merged
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 @@ -333,6 +333,8 @@ internal static unsafe class CastHelpers
return ChkCastClassSpecial(toTypeHnd, obj);
}

// Optimized helper for classes. Assumes that the trivial cases
// has been taken care of by the inlined check
[DebuggerHidden]
[StackTraceHidden]
[DebuggerStepThrough]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ public static unsafe void RhUnboxAny(object? o, ref byte data, EETypePtr pUnboxT
}
else
{
if (o != null && (TypeCast.IsInstanceOf(ptrUnboxToEEType, o) == null))
if (o != null && (TypeCast.IsInstanceOfAny(ptrUnboxToEEType, o) == null))
{
throw ptrUnboxToEEType->GetClasslibException(ExceptionIDs.InvalidCast);
}
Expand Down Expand Up @@ -392,26 +392,18 @@ internal static unsafe IntPtr RhGetRuntimeHelperForType(MethodTable* pEEType, Ru
return (IntPtr)(delegate*<MethodTable*, object>)&InternalCalls.RhpNewFast;

case RuntimeHelperKind.IsInst:
if (pEEType->IsArray)
return (IntPtr)(delegate*<MethodTable*, object, object>)&TypeCast.IsInstanceOfArray;
else if (pEEType->HasGenericVariance)
return (IntPtr)(delegate*<MethodTable*, object, object>)&TypeCast.IsInstanceOf;
if (pEEType->HasGenericVariance || pEEType->IsParameterizedType || pEEType->IsFunctionPointerType)
return (IntPtr)(delegate*<MethodTable*, object, object?>)&TypeCast.IsInstanceOfAny;
else if (pEEType->IsInterface)
return (IntPtr)(delegate*<MethodTable*, object?, object?>)&TypeCast.IsInstanceOfInterface;
else if (pEEType->IsParameterizedType || pEEType->IsFunctionPointerType)
return (IntPtr)(delegate*<MethodTable*, object, object>)&TypeCast.IsInstanceOf; // Array handled above; pointers and byrefs handled here
else
return (IntPtr)(delegate*<MethodTable*, object?, object?>)&TypeCast.IsInstanceOfClass;

case RuntimeHelperKind.CastClass:
if (pEEType->IsArray)
return (IntPtr)(delegate*<MethodTable*, object, object>)&TypeCast.CheckCastArray;
else if (pEEType->HasGenericVariance)
return (IntPtr)(delegate*<MethodTable*, object, object>)&TypeCast.CheckCast;
if (pEEType->HasGenericVariance || pEEType->IsParameterizedType || pEEType->IsFunctionPointerType)
return (IntPtr)(delegate*<MethodTable*, object, object>)&TypeCast.CheckCastAny;
else if (pEEType->IsInterface)
return (IntPtr)(delegate*<MethodTable*, object, object>)&TypeCast.CheckCastInterface;
else if (pEEType->IsParameterizedType || pEEType->IsFunctionPointerType)
return (IntPtr)(delegate*<MethodTable*, object, object>)&TypeCast.CheckCast; // Array handled above; pointers and byrefs handled here
else
return (IntPtr)(delegate*<MethodTable*, object, object>)&TypeCast.CheckCastClass;

Expand Down
Loading