CORINFO_CLASS_HANDLE impGetStringClass();
CORINFO_CLASS_HANDLE impGetObjectClass();
+ // Returns underlying type of handles returned by ldtoken instruction
+ inline var_types GetRuntimeHandleUnderlyingType()
+ {
+ // RuntimeTypeHandle is backed by raw pointer on CoreRT and by object reference on other runtimes
+ return IsTargetAbi(CORINFO_CORERT_ABI) ? TYP_I_IMPL : TYP_REF;
+ }
+
//=========================================================================
// PROTECTED
//=========================================================================
op1 = gtNewHelperCallNode(CORINFO_HELP_TYPEHANDLE_TO_RUNTIMETYPE_MAYBENULL, TYP_STRUCT, helperArgs);
// The handle struct is returned in register
- op1->gtCall.gtReturnType = TYP_REF;
+ op1->gtCall.gtReturnType = GetRuntimeHandleUnderlyingType();
tiRetVal = typeInfo(TI_STRUCT, impGetTypeHandleClass());
}
op1 = gtNewHelperCallNode(helper, TYP_STRUCT, helperArgs);
// The handle struct is returned in register
- op1->gtCall.gtReturnType = TYP_REF;
+ op1->gtCall.gtReturnType = GetRuntimeHandleUnderlyingType();
tiRetVal = verMakeTypeInfo(tokenType);
impPushOnStack(op1, tiRetVal);