@@ -158,6 +158,25 @@ CallStubHeader *CreateNativeToInterpreterCallStub(InterpMethod* pInterpMethod)
158158
159159#endif // !TARGET_WASM
160160
161+ // Use the NOINLINE to ensure that the InlinedCallFrame in this method is a lower stack address than any InterpMethodContextFrame values.
162+ NOINLINE void InvokePInvokeMethod (MethodDesc *targetMethod, int8_t *stack, InterpMethodContextFrame *pFrame, int32_t callArgsOffset, int32_t returnOffset, PCODE callTarget)
163+ {
164+ InlinedCallFrame inlinedCallFrame;
165+ inlinedCallFrame.m_pCallerReturnAddress = (TADDR)pFrame->ip ;
166+ inlinedCallFrame.m_pCallSiteSP = pFrame;
167+ inlinedCallFrame.m_pCalleeSavedFP = (TADDR)stack;
168+ inlinedCallFrame.m_pThread = GetThread ();
169+ inlinedCallFrame.m_Datum = NULL ;
170+ inlinedCallFrame.Push ();
171+
172+ {
173+ GCX_PREEMP ();
174+ InvokeCompiledMethod (targetMethod, stack + callArgsOffset, stack + returnOffset, callTarget);
175+ }
176+
177+ inlinedCallFrame.Pop ();
178+ }
179+
161180typedef void * (*HELPER_FTN_P_P)(void *);
162181typedef void * (*HELPER_FTN_BOX_UNBOX)(MethodTable*, void *);
163182typedef Object* (*HELPER_FTN_NEWARR)(MethodTable*, intptr_t );
@@ -1965,20 +1984,14 @@ void InterpExecMethod(InterpreterFrame *pInterpreterFrame, InterpMethodContextFr
19651984 // Save current execution state for when we return from called method
19661985 pFrame->ip = ip;
19671986
1968- InlinedCallFrame inlinedCallFrame;
1969- inlinedCallFrame.m_pCallerReturnAddress = (TADDR)ip;
1970- inlinedCallFrame.m_pCallSiteSP = pFrame;
1971- inlinedCallFrame.m_pCalleeSavedFP = (TADDR)stack;
1972- inlinedCallFrame.m_pThread = GetThread ();
1973- inlinedCallFrame.m_Datum = NULL ;
1974- inlinedCallFrame.Push ();
1975-
1987+ if (flags & (int32_t )PInvokeCallFlags::SuppressGCTransition)
19761988 {
1977- GCX_MAYBE_PREEMP (!(flags & (int32_t )PInvokeCallFlags::SuppressGCTransition));
19781989 InvokeCompiledMethod (targetMethod, stack + callArgsOffset, stack + returnOffset, callTarget);
19791990 }
1980-
1981- inlinedCallFrame.Pop ();
1991+ else
1992+ {
1993+ InvokePInvokeMethod (targetMethod, stack, pFrame, callArgsOffset, returnOffset, callTarget);
1994+ }
19821995
19831996 break ;
19841997 }
0 commit comments