From 5a1368a64fa3628523cab439f6fb80880a500310 Mon Sep 17 00:00:00 2001 From: Pat Gavlin Date: Wed, 26 Oct 2016 14:40:59 -0700 Subject: [PATCH] Correct indirect P/Invoke call prlogs on x86. 32-bit targets require the size of the stack argument area in InlinedCallFrame.m_Datum rather than the stub argument (as on 64-bit targets). --- src/jit/lower.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/jit/lower.cpp b/src/jit/lower.cpp index dbe4b5d..743e359 100644 --- a/src/jit/lower.cpp +++ b/src/jit/lower.cpp @@ -2784,11 +2784,18 @@ void Lowering::InsertPInvokeCallProlog(GenTreeCall* call) if (callType == CT_INDIRECT) { +#if !defined(_TARGET_64BIT_) + // On 32-bit targets, indirect calls need the size of the stack args in InlinedCallFrame.m_Datum. + const unsigned numStkArgBytes = call->fgArgInfo->GetNextSlotNum() * TARGET_POINTER_SIZE; + src = comp->gtNewIconNode(numStkArgBytes, TYP_INT); +#else + // On 64-bit targets, indirect calls may need the stub parameter value in InlinedCallFrame.m_Datum. if (comp->info.compPublishStubParam) { - src = new (comp, GT_LCL_VAR) GenTreeLclVar(TYP_I_IMPL, comp->lvaStubArgumentVar, BAD_IL_OFFSET); + src = comp->gtNewLclvNode(comp->lvaStubArgumentVar, TYP_I_IMPL); } // else { If we don't have secret parameter, m_Datum will be initialized by VM code } +#endif // !defined(_TARGET_64BIT_) } else { -- 2.7.4