Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Prev Previous commit
Next Next commit
Revert implementation
  • Loading branch information
huoyaoyuan committed Jun 16, 2023
commit 85ba6f203aa01beedc3a61f8f3b85b4231042dd7
8 changes: 0 additions & 8 deletions src/coreclr/tools/Common/JitInterface/CorInfoImpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1789,14 +1789,6 @@ private void resolveToken(ref CORINFO_RESOLVED_TOKEN pResolvedToken)

type = type.MakeArrayType();
}
else if (pResolvedToken.tokenType == CorInfoTokenKind.CORINFO_TOKENKIND_Casting)
{
if (type.IsVoid)
ThrowHelper.ThrowInvalidProgramException(ExceptionStringID.InvalidProgramSpecific, methodIL.OwningMethod);

if (type.IsNullable)
type = type.Instantiation[0];
}
pResolvedToken.hClass = ObjectToHandle(type);

#if !SUPPORT_JIT
Expand Down
33 changes: 15 additions & 18 deletions src/coreclr/vm/jitinterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1156,28 +1156,25 @@ void CEEInfo::resolveToken(/* IN, OUT */ CORINFO_RESOLVED_TOKEN * pResolvedToken
// tokenType specific verification and transformations
//
CorElementType et = th.GetInternalCorElementType();

if (tokenType != CORINFO_TOKENKIND_Ldtoken)
switch (tokenType)
{
// Disallow ELEMENT_TYPE_BYREF and ELEMENT_TYPE_VOID
if (et == ELEMENT_TYPE_BYREF || et == ELEMENT_TYPE_VOID)
COMPlusThrow(kInvalidProgramException);
case CORINFO_TOKENKIND_Ldtoken:
// Allow everything.
break;

switch (tokenType)
{
case CORINFO_TOKENKIND_Newarr:
th = ClassLoader::LoadArrayTypeThrowing(th);
break;
case CORINFO_TOKENKIND_Newarr:
// Disallow ELEMENT_TYPE_BYREF and ELEMENT_TYPE_VOID
if (et == ELEMENT_TYPE_BYREF || et == ELEMENT_TYPE_VOID)
COMPlusThrow(kInvalidProgramException);

case CORINFO_TOKENKIND_Casting:
// isinst and castclass to Nullable<T> is same as underlying type
if (Nullable::IsNullableType(th))
th = th.AsMethodTable()->GetInstantiation()[0];
break;
th = ClassLoader::LoadArrayTypeThrowing(th);
break;

default:
break;
}
default:
// Disallow ELEMENT_TYPE_BYREF and ELEMENT_TYPE_VOID
if (et == ELEMENT_TYPE_BYREF || et == ELEMENT_TYPE_VOID)
COMPlusThrow(kInvalidProgramException);
break;
}

// The JIT interface should always return fully loaded types
Expand Down