Skip to content

Commit 9bef28b

Browse files
authored
Cleanup unused JIT stubs in vm (#111237)
* Undef JIT_TailCall on non-Windows x86 * JIT_TailCallReturnFromVSD * JIT_TailCallVSDLeave and JIT_TailCallLeave * Move JIT_ProfilerEnterLeaveTailcallStub to asm * GetCONTEXTFromRedirectedStubStackFrame * RedirectForThrowControl and empty unixstubs * Update comment mentioning RedirectForThrowControl * Link to issue for stack probing * Remove GetCONTEXTFromRedirectedStubStackFrame(T_DISPATCHER_CONTEXT) on all unix * Remove defines for other archs in Windows specific handler
1 parent 82ab892 commit 9bef28b

27 files changed

+41
-229
lines changed

src/coreclr/debug/ee/debugger.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3994,6 +3994,8 @@ HANDLE OpenWin32EventOrThrow(
39943994
// Returns true if the specified IL offset has a special meaning (eg. prolog, etc.)
39953995
bool DbgIsSpecialILOffset(DWORD offset);
39963996

3997+
#if defined(TARGET_WINDOWS)
39973998
void FixupDispatcherContext(T_DISPATCHER_CONTEXT* pDispatcherContext, T_CONTEXT* pContext, PEXCEPTION_ROUTINE pUnwindPersonalityRoutine = NULL);
3999+
#endif
39984000

39994001
#endif /* DEBUGGER_H_ */

src/coreclr/jit/lower.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3411,7 +3411,7 @@ void Lowering::RehomeArgForFastTailCall(unsigned int lclNum,
34113411
//------------------------------------------------------------------------
34123412
// LowerTailCallViaJitHelper: lower a call via the tailcall JIT helper. Morph
34133413
// has already inserted tailcall helper special arguments. This function inserts
3414-
// actual data for some placeholders. This function is only used on x86.
3414+
// actual data for some placeholders. This function is only used on Windows x86.
34153415
//
34163416
// Lower
34173417
// tail.call(<function args>, int numberOfOldStackArgs, int dummyNumberOfNewStackArgs, int flags, void* dummyArg)

src/coreclr/jit/morph.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6319,7 +6319,7 @@ void Compiler::fgMorphTailCallViaJitHelper(GenTreeCall* call)
63196319
// For the helper-assisted tail calls, we need to push all the arguments
63206320
// into a single list, and then add a few extra at the beginning or end.
63216321
//
6322-
// For x86, the tailcall helper is defined as:
6322+
// For Windows x86, the tailcall helper is defined as:
63236323
//
63246324
// JIT_TailCall(<function args>, int numberOfOldStackArgsWords, int numberOfNewStackArgsWords, int flags, void*
63256325
// callTarget)

src/coreclr/vm/CMakeLists.txt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -855,12 +855,6 @@ elseif(CLR_CMAKE_TARGET_ARCH_RISCV64)
855855
)
856856
endif()
857857

858-
if(CLR_CMAKE_HOST_UNIX)
859-
list(APPEND VM_SOURCES_WKS_ARCH
860-
${ARCH_SOURCES_DIR}/unixstubs.cpp
861-
)
862-
endif(CLR_CMAKE_HOST_UNIX)
863-
864858
set(VM_SOURCES_DAC_ARCH
865859
exceptionhandling.cpp
866860
)

src/coreclr/vm/amd64/asmhelpers.S

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@
4444
#
4545
# ***********************************************************
4646

47+
# EXTERN_C void JIT_ProfilerEnterLeaveTailcallStub(UINT_PTR ProfilerHandle);
48+
# <NOTE>
49+
#
50+
# </NOTE>
51+
LEAF_ENTRY JIT_ProfilerEnterLeaveTailcallStub, _TEXT
52+
ret
53+
LEAF_END JIT_ProfilerEnterLeaveTailcallStub, _TEXT
54+
4755
# EXTERN_C void ProfileEnterNaked(FunctionIDOrClientID functionIDOrClientID, size_t profiledRsp);
4856
# <NOTE>
4957
#

src/coreclr/vm/amd64/excepamd64.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,14 @@ inline PTR_CONTEXT GetCONTEXTFromRedirectedStubStackFrameWorker(UINT_PTR establi
4848
return *ppContext;
4949
}
5050

51+
#ifdef TARGET_WINDOWS
5152
PTR_CONTEXT GetCONTEXTFromRedirectedStubStackFrame(DISPATCHER_CONTEXT * pDispatcherContext)
5253
{
5354
LIMITED_METHOD_DAC_CONTRACT;
5455

5556
return GetCONTEXTFromRedirectedStubStackFrameWorker(pDispatcherContext->EstablisherFrame);
5657
}
58+
#endif // TARGET_WINDOWS
5759

5860
PTR_CONTEXT GetCONTEXTFromRedirectedStubStackFrame(CONTEXT * pContext)
5961
{
@@ -63,17 +65,14 @@ PTR_CONTEXT GetCONTEXTFromRedirectedStubStackFrame(CONTEXT * pContext)
6365
}
6466

6567
#if !defined(DACCESS_COMPILE)
66-
68+
#ifdef TARGET_WINDOWS
6769
FaultingExceptionFrame *GetFrameFromRedirectedStubStackFrame (DISPATCHER_CONTEXT *pDispatcherContext)
6870
{
6971
LIMITED_METHOD_CONTRACT;
7072

7173
return (FaultingExceptionFrame*)(pDispatcherContext->EstablisherFrame + THROWSTUB_ESTABLISHER_OFFSET_FaultingExceptionFrame);
7274
}
73-
74-
#endif // !DACCESS_COMPILE
75-
76-
#if !defined(DACCESS_COMPILE)
75+
#endif // TARGET_WINDOWS
7776

7877
#define AMD64_SIZE64_PREFIX 0x48
7978
#define AMD64_ADD_IMM8_OP 0x83

src/coreclr/vm/amd64/excepcpu.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,18 @@ EXTERN_C void RedirectForThrowControl();
4040
// Retrieves the redirected CONTEXT* from the stack frame of one of the
4141
// RedirectedHandledJITCaseForXXX_Stub's.
4242
//
43+
#ifdef TARGET_WINDOWS
4344
PTR_CONTEXT GetCONTEXTFromRedirectedStubStackFrame(DISPATCHER_CONTEXT * pDispatcherContext);
45+
#endif // TARGET_WINDOWS
4446
PTR_CONTEXT GetCONTEXTFromRedirectedStubStackFrame(CONTEXT * pContext);
4547

48+
#ifdef TARGET_WINDOWS
4649
//
4750
// Retrieves the FaultingExceptionFrame* from the stack frame of
4851
// RedirectForThrowControl.
4952
//
5053
FaultingExceptionFrame *GetFrameFromRedirectedStubStackFrame (DISPATCHER_CONTEXT *pDispatcherContext);
54+
#endif // TARGET_WINDOWS
5155

5256
//
5357
// Functions that wrap RtlVirtualUnwind to make sure that in the AMD64 case all the

src/coreclr/vm/amd64/unixstubs.cpp

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/coreclr/vm/arm/exceparm.cpp

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,6 @@
77
#include "asmconstants.h"
88
#include "virtualcallstub.h"
99

10-
PTR_CONTEXT GetCONTEXTFromRedirectedStubStackFrame(T_DISPATCHER_CONTEXT * pDispatcherContext)
11-
{
12-
LIMITED_METHOD_DAC_CONTRACT;
13-
14-
UINT_PTR stackSlot = pDispatcherContext->EstablisherFrame + REDIRECTSTUB_SP_OFFSET_CONTEXT;
15-
PTR_PTR_CONTEXT ppContext = dac_cast<PTR_PTR_CONTEXT>((TADDR)stackSlot);
16-
return *ppContext;
17-
}
18-
1910
PTR_CONTEXT GetCONTEXTFromRedirectedStubStackFrame(T_CONTEXT * pContext)
2011
{
2112
LIMITED_METHOD_DAC_CONTRACT;
@@ -27,32 +18,6 @@ PTR_CONTEXT GetCONTEXTFromRedirectedStubStackFrame(T_CONTEXT * pContext)
2718

2819
#if !defined(DACCESS_COMPILE)
2920

30-
// The next two functions help retrieve data kept relative to FaultingExceptionFrame that is setup
31-
// for handling async exceptions (e.g. AV, NullRef, ThreadAbort, etc).
32-
//
33-
// FEF (and related data) is available relative to R4 - the thing to be kept in mind is that the
34-
// DispatcherContext->ContextRecord:
35-
//
36-
// 1) represents the caller context in the first pass.
37-
// 2) represents the current context in the second pass.
38-
//
39-
// Since R4 is a non-volatile register, this works for us since we setup the value of R4
40-
// in the redirection helpers (e.g. RedirectForThreadAbort) but do not
41-
// change it in their respective callee functions (e.g. RedirectForThreadAbort2)
42-
// that have the personality routines associated with them (which perform the collided unwind and also
43-
// invoke the two functions below).
44-
//
45-
// Thus, when our personality routine gets called in either passes, DC->ContextRecord->R4 will
46-
// have the same value.
47-
48-
// Returns the pointer to the FEF
49-
FaultingExceptionFrame *GetFrameFromRedirectedStubStackFrame (T_DISPATCHER_CONTEXT *pDispatcherContext)
50-
{
51-
LIMITED_METHOD_CONTRACT;
52-
53-
return (FaultingExceptionFrame*)((TADDR)pDispatcherContext->ContextRecord->R4);
54-
}
55-
5621
// Returns TRUE if caller should resume execution.
5722
BOOL
5823
AdjustContextForVirtualStub(

src/coreclr/vm/arm/excepcpu.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,8 @@ class FaultingExceptionFrame;
2626
// Retrieves the redirected CONTEXT* from the stack frame of one of the
2727
// RedirectedHandledJITCaseForXXX_Stub's.
2828
//
29-
PTR_CONTEXT GetCONTEXTFromRedirectedStubStackFrame(T_DISPATCHER_CONTEXT * pDispatcherContext);
3029
PTR_CONTEXT GetCONTEXTFromRedirectedStubStackFrame(T_CONTEXT * pContext);
3130

32-
//
33-
// Retrieves the FaultingExceptionFrame* from the stack frame of
34-
// RedirectForThrowControl.
35-
//
36-
FaultingExceptionFrame *GetFrameFromRedirectedStubStackFrame (T_DISPATCHER_CONTEXT *pDispatcherContext);
37-
3831
inline
3932
PCODE GetAdjustedCallAddress(PCODE returnAddress)
4033
{

0 commit comments

Comments
 (0)