Skip to content

Commit dfadb1f

Browse files
committed
Create stub only when interp. method called from JIT/AOT code
1 parent 99b9764 commit dfadb1f

File tree

3 files changed

+24
-12
lines changed

3 files changed

+24
-12
lines changed

src/coreclr/vm/interpexec.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,9 @@ void InvokeCompiledMethod(MethodDesc *pMD, int8_t *pArgs, int8_t *pRet)
5555
pHeader->Invoke(pHeader->Routines, pArgs, pRet, pHeader->TotalStackSize);
5656
}
5757

58-
59-
CallStubHeader *CreateNativeToInterpreterCallStub(PCODE pCode)
58+
// Create call stub for calling interpreted methods from JITted/AOTed code.
59+
CallStubHeader *CreateNativeToInterpreterCallStub(InterpMethod* pInterpMethod)
6060
{
61-
InterpMethod* pInterpMethod = *(InterpMethod**)pCode;
62-
6361
CallStubGenerator callStubGenerator;
6462
CallStubHeader *pHeader = VolatileLoadWithoutBarrier(&pInterpMethod->pCallStub);
6563
GCX_PREEMP();

src/coreclr/vm/interpexec.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,6 @@ struct ExceptionClauseArgs
7979

8080
void InterpExecMethod(InterpreterFrame *pInterpreterFrame, InterpMethodContextFrame *pFrame, InterpThreadContext *pThreadContext, ExceptionClauseArgs *pExceptionClauseArgs = NULL);
8181

82-
CallStubHeader *CreateNativeToInterpreterCallStub(PCODE pCode);
82+
CallStubHeader *CreateNativeToInterpreterCallStub(InterpMethod* pInterpMethod);
8383

8484
#endif

src/coreclr/vm/prestub.cpp

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -432,8 +432,6 @@ PCODE MethodDesc::PrepareILBasedCode(PrepareCodeConfig* pConfig)
432432
#ifdef FEATURE_INTERPRETER
433433
if (pConfig->IsInterpreterCode())
434434
{
435-
CreateNativeToInterpreterCallStub(pCode);
436-
437435
AllocMemTracker amt;
438436
InterpreterPrecode* pPrecode = Precode::AllocateInterpreterPrecode(pCode, GetLoaderAllocator(), &amt);
439437
amt.SuppressRelease();
@@ -2183,12 +2181,15 @@ PCODE MethodDesc::DoPrestub(MethodTable *pDispatchingMT, CallerGCMode callerGCMo
21832181

21842182
if (doBackpatch)
21852183
{
2186-
RETURN DoBackpatch(pMT, pDispatchingMT, doFullBackpatch);
2184+
pCode = DoBackpatch(pMT, pDispatchingMT, doFullBackpatch);
2185+
}
2186+
else
2187+
{
2188+
_ASSERTE(!doFullBackpatch);
21872189
}
21882190

21892191
_ASSERTE(pCode != (PCODE)NULL);
2190-
_ASSERTE(!doFullBackpatch);
2191-
RETURN pCode;
2192+
goto Return;
21922193
}
21932194
#endif
21942195

@@ -2200,7 +2201,8 @@ PCODE MethodDesc::DoPrestub(MethodTable *pDispatchingMT, CallerGCMode callerGCMo
22002201
MarkMethodNotPitchingCandidate(this);
22012202
#endif
22022203

2203-
RETURN DoBackpatch(pMT, pDispatchingMT, TRUE);
2204+
pCode = DoBackpatch(pMT, pDispatchingMT, TRUE);
2205+
goto Return;
22042206
}
22052207

22062208
/************************** CODE CREATION *************************/
@@ -2322,7 +2324,19 @@ PCODE MethodDesc::DoPrestub(MethodTable *pDispatchingMT, CallerGCMode callerGCMo
23222324
_ASSERTE(!IsPointingToPrestub());
23232325
_ASSERTE(HasStableEntryPoint());
23242326

2325-
RETURN DoBackpatch(pMT, pDispatchingMT, FALSE);
2327+
2328+
pCode = DoBackpatch(pMT, pDispatchingMT, FALSE);
2329+
2330+
Return:
2331+
#ifdef FEATURE_INTERPRETER
2332+
InterpByteCodeStart *pInterpreterCode = GetInterpreterCode();
2333+
if (pInterpreterCode != NULL)
2334+
{
2335+
CreateNativeToInterpreterCallStub(pInterpreterCode->Method);
2336+
}
2337+
#endif // FEATURE_INTERPRETER
2338+
2339+
RETURN pCode;
23262340
}
23272341

23282342
#endif // !DACCESS_COMPILE

0 commit comments

Comments
 (0)