summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJan Kotas <jkotas@microsoft.com>2017-09-18 11:01:41 -0700
committerGitHub <noreply@github.com>2017-09-18 11:01:41 -0700
commit4aca96e9f2572e66a687d1f4d418e9545c6cb4cb (patch)
tree65756fdf69488c8a651c5c0d2cbe8f7728291bf8 /src
parente1154bc588677f11f385bf60bd3aee38ba8115fb (diff)
downloadcoreclr-4aca96e9f2572e66a687d1f4d418e9545c6cb4cb.tar.gz
coreclr-4aca96e9f2572e66a687d1f4d418e9545c6cb4cb.tar.bz2
coreclr-4aca96e9f2572e66a687d1f4d418e9545c6cb4cb.zip
Fix RuntimeTypeHandle underlying type for CoreRT (#14026)
RuntimeTypeHandles on CoreRT are backed by IntPtr today. This fix is not complete. There are likely more places that make assumption about the underlying runtime handle types, but this is enough to fix the immediate problem hit by @sergign60.
Diffstat (limited to 'src')
-rw-r--r--src/jit/compiler.h7
-rw-r--r--src/jit/importer.cpp4
2 files changed, 9 insertions, 2 deletions
diff --git a/src/jit/compiler.h b/src/jit/compiler.h
index 7c99a6985a..0997154b65 100644
--- a/src/jit/compiler.h
+++ b/src/jit/compiler.h
@@ -2895,6 +2895,13 @@ public:
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
//=========================================================================
diff --git a/src/jit/importer.cpp b/src/jit/importer.cpp
index 90d1618f2e..ddee0aba5b 100644
--- a/src/jit/importer.cpp
+++ b/src/jit/importer.cpp
@@ -14236,7 +14236,7 @@ void Compiler::impImportBlockCode(BasicBlock* block)
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());
}
@@ -14276,7 +14276,7 @@ void Compiler::impImportBlockCode(BasicBlock* block)
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);