diff options
Diffstat (limited to 'src/jit/importer.cpp')
-rw-r--r-- | src/jit/importer.cpp | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/src/jit/importer.cpp b/src/jit/importer.cpp index 26aafb72b2..6aba97417c 100644 --- a/src/jit/importer.cpp +++ b/src/jit/importer.cpp @@ -3621,11 +3621,23 @@ GenTree* Compiler::impIntrinsic(GenTree* newobjThis, case CORINFO_INTRINSIC_GetTypeFromHandle: op1 = impStackTop(0).val; + CorInfoHelpFunc typeHandleHelper; if (op1->gtOper == GT_CALL && (op1->gtCall.gtCallType == CT_HELPER) && - gtIsTypeHandleToRuntimeTypeHelper(op1->AsCall())) + gtIsTypeHandleToRuntimeTypeHandleHelper(op1->AsCall(), &typeHandleHelper)) { op1 = impPopStack().val; - // Change call to return RuntimeType directly. + // Replace helper with a more specialized helper that returns RuntimeType + if (typeHandleHelper == CORINFO_HELP_TYPEHANDLE_TO_RUNTIMETYPEHANDLE) + { + typeHandleHelper = CORINFO_HELP_TYPEHANDLE_TO_RUNTIMETYPE; + } + else + { + assert(typeHandleHelper == CORINFO_HELP_TYPEHANDLE_TO_RUNTIMETYPEHANDLE_MAYBENULL); + typeHandleHelper = CORINFO_HELP_TYPEHANDLE_TO_RUNTIMETYPE_MAYBENULL; + } + assert(op1->gtCall.gtCallArgs->gtOp.gtOp2 == nullptr); + op1 = gtNewHelperCallNode(typeHandleHelper, TYP_REF, op1->gtCall.gtCallArgs); op1->gtType = TYP_REF; retNode = op1; } @@ -3635,7 +3647,7 @@ GenTree* Compiler::impIntrinsic(GenTree* newobjThis, case CORINFO_INTRINSIC_RTH_GetValueInternal: op1 = impStackTop(0).val; if (op1->gtOper == GT_CALL && (op1->gtCall.gtCallType == CT_HELPER) && - gtIsTypeHandleToRuntimeTypeHelper(op1->AsCall())) + gtIsTypeHandleToRuntimeTypeHandleHelper(op1->AsCall())) { // Old tree // Helper-RuntimeTypeHandle -> TreeToGetNativeTypeHandle @@ -8388,7 +8400,8 @@ DONE_CALL: if (call->IsCall()) { GenTreeCall* callNode = call->AsCall(); - if ((callNode->gtCallType == CT_HELPER) && gtIsTypeHandleToRuntimeTypeHelper(callNode)) + if ((callNode->gtCallType == CT_HELPER) && (gtIsTypeHandleToRuntimeTypeHelper(callNode) || + gtIsTypeHandleToRuntimeTypeHandleHelper(callNode))) { spillStack = false; } @@ -14707,7 +14720,8 @@ void Compiler::impImportBlockCode(BasicBlock* block) { GenTreeArgList* helperArgs = gtNewArgList(op1); - op1 = gtNewHelperCallNode(CORINFO_HELP_TYPEHANDLE_TO_RUNTIMETYPE_MAYBENULL, TYP_STRUCT, helperArgs); + op1 = gtNewHelperCallNode(CORINFO_HELP_TYPEHANDLE_TO_RUNTIMETYPEHANDLE_MAYBENULL, TYP_STRUCT, + helperArgs); // The handle struct is returned in register op1->gtCall.gtReturnType = GetRuntimeHandleUnderlyingType(); @@ -14733,7 +14747,7 @@ void Compiler::impImportBlockCode(BasicBlock* block) return; } - helper = CORINFO_HELP_TYPEHANDLE_TO_RUNTIMETYPE; + helper = CORINFO_HELP_TYPEHANDLE_TO_RUNTIMETYPEHANDLE; assert(resolvedToken.hClass != nullptr); if (resolvedToken.hMethod != nullptr) |