Skip to content

Commit 5b105c8

Browse files
committed
Address PR feedback
Encapsulate inlined callframe creation
1 parent ac5bd71 commit 5b105c8

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

src/coreclr/vm/interpexec.cpp

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// for numeric_limits
1313
#include <limits>
1414

15-
void InvokeCompiledMethod(MethodDesc *pMD, int8_t *pArgs, int8_t *pRet, PCODE overrideTarget = (PCODE)0)
15+
void InvokeCompiledMethod(MethodDesc *pMD, int8_t *pArgs, int8_t *pRet, PCODE target)
1616
{
1717
CONTRACTL
1818
{
@@ -45,11 +45,8 @@ void InvokeCompiledMethod(MethodDesc *pMD, int8_t *pArgs, int8_t *pRet, PCODE ov
4545
}
4646
}
4747

48-
if (overrideTarget)
49-
// Interpreter-FIXME: Is this a race condition?
50-
pHeader->SetTarget(overrideTarget);
51-
else
52-
pHeader->SetTarget(pMD->GetMultiCallableAddrOfCode(CORINFO_ACCESS_ANY)); // The method to call
48+
// Interpreter-FIXME: Potential race condition if a single CallStubHeader is reused for multiple targets.
49+
pHeader->SetTarget(target); // The method to call
5350

5451
pHeader->Invoke(pHeader->Routines, pArgs, pRet, pHeader->TotalStackSize);
5552
}
@@ -164,6 +161,20 @@ static OBJECTREF CreateMultiDimArray(MethodTable* arrayClass, int8_t* stack, int
164161
#define LOCAL_VAR_ADDR(offset,type) ((type*)(stack + (offset)))
165162
#define LOCAL_VAR(offset,type) (*LOCAL_VAR_ADDR(offset, type))
166163
#define NULL_CHECK(o) do { if ((o) == NULL) { COMPlusThrow(kNullReferenceException); } } while (0)
164+
#define WITH_INLINED_CALL_FRAME(block) \
165+
do { \
166+
InlinedCallFrame inlinedCallFrame; \
167+
inlinedCallFrame.m_pCallerReturnAddress = (TADDR)ip; \
168+
inlinedCallFrame.m_pCallSiteSP = pFrame; \
169+
inlinedCallFrame.m_pCalleeSavedFP = (TADDR)stack; \
170+
inlinedCallFrame.m_pThread = GetThread(); \
171+
inlinedCallFrame.m_Datum = NULL; \
172+
inlinedCallFrame.Push(); \
173+
\
174+
block\
175+
\
176+
inlinedCallFrame.Pop(); \
177+
} while (0)
167178

168179
template <typename THelper> static THelper GetPossiblyIndirectHelper(void* dataItem)
169180
{
@@ -1846,21 +1857,10 @@ void InterpExecMethod(InterpreterFrame *pInterpreterFrame, InterpMethodContextFr
18461857
? *(PCODE *)pMethod->pDataItems[targetAddrSlot]
18471858
: (PCODE)pMethod->pDataItems[targetAddrSlot];
18481859

1849-
InlinedCallFrame inlinedCallFrame;
1850-
inlinedCallFrame.m_pCallerReturnAddress = (TADDR)ip;
1851-
inlinedCallFrame.m_pCallSiteSP = pFrame;
1852-
inlinedCallFrame.m_pCalleeSavedFP = (TADDR)stack;
1853-
inlinedCallFrame.m_pThread = GetThread();
1854-
inlinedCallFrame.m_Datum = NULL;
1855-
inlinedCallFrame.Push();
1856-
1857-
{
1858-
// Interpreter-FIXME: Create InlinedCallFrame.
1860+
WITH_INLINED_CALL_FRAME({
18591861
GCX_PREEMP();
18601862
InvokeCompiledMethod(targetMethod, stack + callArgsOffset, stack + returnOffset, callTarget);
1861-
}
1862-
1863-
inlinedCallFrame.Pop();
1863+
});
18641864

18651865
break;
18661866
}
@@ -1898,7 +1898,7 @@ void InterpExecMethod(InterpreterFrame *pInterpreterFrame, InterpMethodContextFr
18981898
if (targetIp == NULL)
18991899
{
19001900
// If we didn't get the interpreter code pointer setup, then this is a method we need to invoke as a compiled method.
1901-
InvokeCompiledMethod(targetMethod, stack + callArgsOffset, stack + returnOffset);
1901+
InvokeCompiledMethod(targetMethod, stack + callArgsOffset, stack + returnOffset, targetMethod->GetMultiCallableAddrOfCode(CORINFO_ACCESS_ANY));
19021902
break;
19031903
}
19041904
}

0 commit comments

Comments
 (0)