From deb75b4f815fd4d86ad444d19eec50f0f869f994 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Strehovsk=C3=BD?= Date: Wed, 14 Dec 2016 10:03:53 -0800 Subject: Add support for R2R ldvirtftn helpers (#8608) The codegen for the non-readytorun path (used on CoreCLR) requires the runtime to support general purpose virtual method resolution based on a method handle. CoreRT doesn't have such helpers. --- src/jit/importer.cpp | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'src/jit') diff --git a/src/jit/importer.cpp b/src/jit/importer.cpp index 620ba14ebb..cb09ff8b8c 100644 --- a/src/jit/importer.cpp +++ b/src/jit/importer.cpp @@ -4934,14 +4934,26 @@ GenTreePtr Compiler::impImportLdvirtftn(GenTreePtr thisPtr, } #ifdef FEATURE_READYTORUN_COMPILER - if (opts.IsReadyToRun() && !pCallInfo->exactContextNeedsRuntimeLookup) + if (opts.IsReadyToRun()) { - GenTreeCall* call = gtNewHelperCallNode(CORINFO_HELP_READYTORUN_VIRTUAL_FUNC_PTR, TYP_I_IMPL, GTF_EXCEPT, - gtNewArgList(thisPtr)); + if (!pCallInfo->exactContextNeedsRuntimeLookup) + { + GenTreeCall* call = gtNewHelperCallNode(CORINFO_HELP_READYTORUN_VIRTUAL_FUNC_PTR, TYP_I_IMPL, GTF_EXCEPT, + gtNewArgList(thisPtr)); - call->setEntryPoint(pCallInfo->codePointerLookup.constLookup); + call->setEntryPoint(pCallInfo->codePointerLookup.constLookup); - return call; + return call; + } + + // We need a runtime lookup. CoreRT has a ReadyToRun helper for that too. + if (IsTargetAbi(CORINFO_CORERT_ABI)) + { + GenTreePtr ctxTree = getRuntimeContextTree(pCallInfo->codePointerLookup.lookupKind.runtimeLookupKind); + + return impReadyToRunHelperToTree(pResolvedToken, CORINFO_HELP_READYTORUN_GENERIC_HANDLE, TYP_I_IMPL, + gtNewArgList(ctxTree), &pCallInfo->codePointerLookup.lookupKind); + } } #endif -- cgit v1.2.3