Skip to content

Commit 51152d5

Browse files
committed
Create the native-to-interpreter call stub in a better place so it's always present when we need it
Revert changes to the helper
1 parent 7aa94bc commit 51152d5

File tree

2 files changed

+8
-39
lines changed

2 files changed

+8
-39
lines changed

src/coreclr/vm/amd64/AsmHelpers.asm

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ include AsmMacros.inc
55
include asmconstants.inc
66

77
Thread_GetInterpThreadContext TEXTEQU <?GetInterpThreadContext@Thread@@QEAAPEAUInterpThreadContext@@XZ>
8-
CreateNativeToInterpreterCallStub TEXTEQU <?CreateNativeToInterpreterCallStub@@YAPEAUCallStubHeader@@PEAUInterpMethod@@@Z>
98

109
extern PInvokeImportWorker:proc
1110
extern ThePreStub:proc
@@ -17,7 +16,6 @@ extern JIT_RareDisableHelperWorker:proc
1716
ifdef FEATURE_INTERPRETER
1817
extern ExecuteInterpretedMethod:proc
1918
extern Thread_GetInterpThreadContext:proc
20-
extern CreateNativeToInterpreterCallStub:proc
2119
endif
2220

2321
extern g_pPollGC:QWORD
@@ -580,34 +578,8 @@ HaveInterpThreadContext:
580578
mov r10, qword ptr [rax + OFFSETOF__InterpThreadContext__pStackPointer]
581579
; Load the InterpMethod pointer from the IR bytecode
582580
mov rax, qword ptr [rbx]
583-
584-
; Do we have a call stub? If not, create it.
585-
mov r11, qword ptr [rax + OFFSETOF__InterpMethod__pCallStub]
586-
test r11, r11
587-
jnz HaveCallStub
588-
589-
; Pass the InterpMethod * to CreateNativeToInterpreterCallStub so it can populate the call stub
590-
mov rcx, rax
591-
; The x64 ABI considers the registers RAX, RCX, RDX, R8, R9, R10, R11, and XMM0-XMM5 volatile.
592-
push rax
593-
push rdx
594-
push r8
595-
push r9
596-
push r10
597-
; We're going to recreate r11 after this and we already trashed rcx so we don't need to save it.
598-
call CreateNativeToInterpreterCallStub
599-
; Restore the volatile registers
600-
pop r10
601-
pop r9
602-
pop r9
603-
pop rdx
604-
pop rax
605-
; CreateNativeToInterpreterCallStub populated pCallStub so now load it
606-
mov r11, qword ptr [rax + OFFSETOF__InterpMethod__pCallStub]
607-
608-
HaveCallStub:
609-
610-
lea r11, qword ptr [r11 + OFFSETOF__CallStubHeader__Routines]
581+
mov rax, qword ptr [rax + OFFSETOF__InterpMethod__pCallStub]
582+
lea r11, qword ptr [rax + OFFSETOF__CallStubHeader__Routines]
611583
lea rax, [rsp + __PWTB_TransitionBlock]
612584
; Copy the arguments to the interpreter stack, invoke the InterpExecMethod and load the return value
613585
call qword ptr [r11]

src/coreclr/vm/prestub.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,6 +1004,11 @@ PCODE MethodDesc::JitCompileCodeLocked(PrepareCodeConfig* pConfig, COR_ILMETHOD_
10041004
InterpreterPrecode* pPrecode = InterpreterPrecode::FromEntryPoint(pCode);
10051005
InterpByteCodeStart* interpreterCode = dac_cast<InterpByteCodeStart*>(pPrecode->GetData()->ByteCodeAddr);
10061006
pConfig->GetMethodDesc()->SetInterpreterCode(interpreterCode);
1007+
1008+
// Ensure the method has a call stub. We have to do this eagerly here.
1009+
#if defined(FEATURE_JIT)
1010+
CreateNativeToInterpreterCallStub(interpreterCode->Method);
1011+
#endif
10071012
}
10081013
#endif // FEATURE_INTERPRETER
10091014

@@ -2377,14 +2382,6 @@ PCODE MethodDesc::DoPrestub(MethodTable *pDispatchingMT, CallerGCMode callerGCMo
23772382
pCode = DoBackpatch(pMT, pDispatchingMT, FALSE);
23782383

23792384
Return:
2380-
#if defined(FEATURE_INTERPRETER) && defined(FEATURE_JIT)
2381-
InterpByteCodeStart *pInterpreterCode = GetInterpreterCode();
2382-
if (pInterpreterCode != NULL)
2383-
{
2384-
CreateNativeToInterpreterCallStub(pInterpreterCode->Method);
2385-
}
2386-
#endif // FEATURE_INTERPRETER && FEATURE_JIT
2387-
23882385
RETURN pCode;
23892386
}
23902387

@@ -2944,7 +2941,7 @@ static PCODE getHelperForSharedStatic(Module * pModule, ReadyToRunFixupKind kind
29442941
}
29452942
pArgs->offset = pFD->GetOffset();
29462943

2947-
BinderMethodID managedHelperId = fUnbox ?
2944+
BinderMethodID managedHelperId = fUnbox ?
29482945
METHOD__STATICSHELPERS__STATICFIELDADDRESSUNBOX_DYNAMIC :
29492946
METHOD__STATICSHELPERS__STATICFIELDADDRESS_DYNAMIC;
29502947

0 commit comments

Comments
 (0)