Skip to content

Commit f92c36e

Browse files
committed
removed RareEnablePreemptiveGC
1 parent 44102d3 commit f92c36e

10 files changed

Lines changed: 57 additions & 256 deletions

File tree

src/coreclr/debug/ee/debugger.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3807,7 +3807,7 @@ HANDLE OpenWin32EventOrThrow(
38073807
// debugger may not be expecting it. Instead, just leave the lock and retry.
38083808
// When we leave, we'll enter coop mode first and get suspended if a suspension is in progress.
38093809
// Afterwards, we'll transition back into preemptive mode, and we'll block because this thread
3810-
// has been suspended by the debugger (see code:Thread::RareEnablePreemptiveGC).
3810+
// has been suspended by the debugger (see code:Thread::RareDisablePreemptiveGC).
38113811
#define SENDIPCEVENT_BEGIN_EX(pDebugger, thread, gcxStmt) \
38123812
{ \
38133813
FireEtwDebugIPCEventStart(); \

src/coreclr/vm/eedbginterfaceimpl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,7 @@ void EEDbgInterfaceImpl::EnablePreemptiveGC(void)
652652
CONTRACTL
653653
{
654654
NOTHROW;
655-
DISABLED(GC_TRIGGERS); // Disabled because disabled in RareEnablePreemptiveGC()
655+
GC_NOTRIGGER;
656656
}
657657
CONTRACTL_END;
658658

src/coreclr/vm/i386/asmhelpers.S

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -126,31 +126,6 @@ LEAF_ENTRY RestoreFPUContext, _TEXT
126126
ret 4
127127
LEAF_END RestoreFPUContext, _TEXT
128128

129-
// -----------------------------------------------------------------------
130-
// The out-of-line portion of the code to enable preemptive GC.
131-
// After the work is done, the code jumps back to the "pRejoinPoint"
132-
// which should be emitted right after the inline part is generated.
133-
//
134-
// Assumptions:
135-
// ebx = Thread
136-
// Preserves
137-
// all registers except ecx.
138-
//
139-
// -----------------------------------------------------------------------
140-
NESTED_ENTRY StubRareEnable, _TEXT, NoHandler
141-
push eax
142-
push edx
143-
144-
push ebx
145-
146-
CHECK_STACK_ALIGNMENT
147-
call C_FUNC(StubRareEnableWorker)
148-
149-
pop edx
150-
pop eax
151-
ret
152-
NESTED_END StubRareEnable, _TEXT
153-
154129
NESTED_ENTRY StubRareDisableTHROW, _TEXT, NoHandler
155130
push eax
156131
push edx

src/coreclr/vm/i386/asmhelpers.asm

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ EXTERN __imp__RtlUnwind@16:DWORD
2424
ifdef _DEBUG
2525
EXTERN _HelperMethodFrameConfirmState@20:PROC
2626
endif
27-
EXTERN _StubRareEnableWorker@4:PROC
2827
ifdef FEATURE_COMINTEROP
2928
EXTERN _StubRareDisableHRWorker@4:PROC
3029
endif ; FEATURE_COMINTEROP
@@ -394,29 +393,6 @@ endif
394393
retn 8
395394
_CallJitEHFinallyHelper@8 ENDP
396395

397-
;-----------------------------------------------------------------------
398-
; The out-of-line portion of the code to enable preemptive GC.
399-
; After the work is done, the code jumps back to the "pRejoinPoint"
400-
; which should be emitted right after the inline part is generated.
401-
;
402-
; Assumptions:
403-
; ebx = Thread
404-
; Preserves
405-
; all registers except ecx.
406-
;
407-
;-----------------------------------------------------------------------
408-
_StubRareEnable proc public
409-
push eax
410-
push edx
411-
412-
push ebx
413-
call _StubRareEnableWorker@4
414-
415-
pop edx
416-
pop eax
417-
retn
418-
_StubRareEnable ENDP
419-
420396
ifdef FEATURE_COMINTEROP
421397
_StubRareDisableHR proc public
422398
push edx

src/coreclr/vm/i386/cgenx86.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -911,18 +911,6 @@ Stub *GenerateInitPInvokeFrameHelper()
911911
RETURN psl->Link(SystemDomain::GetGlobalLoaderAllocator()->GetExecutableHeap());
912912
}
913913

914-
915-
extern "C" VOID STDCALL StubRareEnableWorker(Thread *pThread)
916-
{
917-
WRAPPER_NO_CONTRACT;
918-
919-
//printf("RareEnable\n");
920-
pThread->RareEnablePreemptiveGC();
921-
}
922-
923-
924-
925-
926914
// Disable when calling into managed code from a place that fails via Exceptions
927915
extern "C" VOID STDCALL StubRareDisableTHROWWorker(Thread *pThread)
928916
{

src/coreclr/vm/i386/stublinkerx86.cpp

Lines changed: 11 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@
4545

4646

4747
#ifndef DACCESS_COMPILE
48-
49-
extern "C" VOID __cdecl StubRareEnable(Thread *pThread);
5048
#ifdef FEATURE_COMINTEROP
5149
extern "C" HRESULT __cdecl StubRareDisableHR(Thread *pThread);
5250
#endif // FEATURE_COMINTEROP
@@ -2615,6 +2613,8 @@ void StubLinkerCPU::EmitComMethodStubEpilog(TADDR pFrameVptr,
26152613
PRECONDITION(rgRareLabels[0] != NULL && rgRareLabels[1] != NULL && rgRareLabels[2] != NULL);
26162614
PRECONDITION(rgRejoinLabels != NULL);
26172615
PRECONDITION(rgRejoinLabels[0] != NULL && rgRejoinLabels[1] != NULL && rgRejoinLabels[2] != NULL);
2616+
PRECONDITION(4 == sizeof( ((Thread*)0)->m_State ));
2617+
PRECONDITION(4 == sizeof( ((Thread*)0)->m_fPreemptiveGCDisabled ));
26182618
}
26192619
CONTRACTL_END;
26202620

@@ -2623,11 +2623,9 @@ void StubLinkerCPU::EmitComMethodStubEpilog(TADDR pFrameVptr,
26232623
// mov [ebx + Thread.GetFrame()], edi ;; restore previous frame
26242624
X86EmitIndexRegStore(kEBX, Thread::GetOffsetOfCurrentFrame(), kEDI);
26252625

2626-
//-----------------------------------------------------------------------
2627-
// Generate the inline part of disabling preemptive GC
2628-
//-----------------------------------------------------------------------
2629-
EmitEnable(rgRareLabels[2]); // rare gc
2630-
EmitLabel(rgRejoinLabels[2]); // rejoin for rare gc
2626+
// move byte ptr [ebx + Thread.m_fPreemptiveGCDisabled],0
2627+
X86EmitOffsetModRM(0xc6, (X86Reg)0, kEBX, Thread::GetOffsetOfGCFlag());
2628+
Emit8(0);
26312629

26322630
// add esp, popstack
26332631
X86EmitAddEsp(sizeof(GSCookie) + UnmanagedToManagedFrame::GetOffsetOfCalleeSavedRegisters());
@@ -2651,12 +2649,6 @@ void StubLinkerCPU::EmitComMethodStubEpilog(TADDR pFrameVptr,
26512649
// keeps on going past the previous "jmp eax".
26522650
X86EmitReturn(0);
26532651

2654-
//-----------------------------------------------------------------------
2655-
// The out-of-line portion of enabling preemptive GC - rarely executed
2656-
//-----------------------------------------------------------------------
2657-
EmitLabel(rgRareLabels[2]); // label for rare enable gc
2658-
EmitRareEnable(rgRejoinLabels[2]); // emit rare enable gc
2659-
26602652
//-----------------------------------------------------------------------
26612653
// The out-of-line portion of disabling preemptive GC - rarely executed
26622654
//-----------------------------------------------------------------------
@@ -2736,6 +2728,8 @@ void StubLinkerCPU::EmitSharedComMethodStubEpilog(TADDR pFrameVptr,
27362728
PRECONDITION(rgRareLabels[0] != NULL && rgRareLabels[1] != NULL && rgRareLabels[2] != NULL);
27372729
PRECONDITION(rgRejoinLabels != NULL);
27382730
PRECONDITION(rgRejoinLabels[0] != NULL && rgRejoinLabels[1] != NULL && rgRejoinLabels[2] != NULL);
2731+
PRECONDITION(4 == sizeof( ((Thread*)0)->m_State ));
2732+
PRECONDITION(4 == sizeof( ((Thread*)0)->m_fPreemptiveGCDisabled ));
27392733
}
27402734
CONTRACTL_END;
27412735

@@ -2748,12 +2742,13 @@ void StubLinkerCPU::EmitSharedComMethodStubEpilog(TADDR pFrameVptr,
27482742
X86EmitIndexRegStore(kEBX, Thread::GetOffsetOfCurrentFrame(), kEDI);
27492743

27502744
//-----------------------------------------------------------------------
2751-
// Generate the inline part of enabling preemptive GC
2745+
// Generate enabling preemptive GC
27522746
//-----------------------------------------------------------------------
27532747
EmitLabel(NoEntryLabel); // need to enable preemp mode even when we fail the disable as rare disable will return in coop mode
27542748

2755-
EmitEnable(rgRareLabels[2]); // rare enable gc
2756-
EmitLabel(rgRejoinLabels[2]); // rejoin for rare enable gc
2749+
// move byte ptr [ebx + Thread.m_fPreemptiveGCDisabled],0
2750+
X86EmitOffsetModRM(0xc6, (X86Reg)0, kEBX, Thread::GetOffsetOfGCFlag());
2751+
Emit8(0);
27572752

27582753
#ifdef PROFILING_SUPPORTED
27592754
// If profiling is active, emit code to notify profiler of transition
@@ -2800,12 +2795,6 @@ void StubLinkerCPU::EmitSharedComMethodStubEpilog(TADDR pFrameVptr,
28002795
// keeps on going past the previous "jmp ecx".
28012796
X86EmitReturn(0);
28022797

2803-
//-----------------------------------------------------------------------
2804-
// The out-of-line portion of enabling preemptive GC - rarely executed
2805-
//-----------------------------------------------------------------------
2806-
EmitLabel(rgRareLabels[2]); // label for rare enable gc
2807-
EmitRareEnable(rgRejoinLabels[2]); // emit rare enable gc
2808-
28092798
//-----------------------------------------------------------------------
28102799
// The out-of-line portion of disabling preemptive GC - rarely executed
28112800
//-----------------------------------------------------------------------
@@ -3335,77 +3324,6 @@ VOID StubLinkerCPU::EmitUnwindInfoCheckSubfunction()
33353324

33363325
#if defined(FEATURE_COMINTEROP) && defined(TARGET_X86)
33373326

3338-
//-----------------------------------------------------------------------
3339-
// Generates the inline portion of the code to enable preemptive GC. Hopefully,
3340-
// the inline code is all that will execute most of the time. If this code
3341-
// path is entered at certain times, however, it will need to jump out to
3342-
// a separate out-of-line path which is more expensive. The "pForwardRef"
3343-
// label indicates the start of the out-of-line path.
3344-
//
3345-
// Assumptions:
3346-
// ebx = Thread
3347-
// Preserves
3348-
// all registers except ecx.
3349-
//
3350-
//-----------------------------------------------------------------------
3351-
VOID StubLinkerCPU::EmitEnable(CodeLabel *pForwardRef)
3352-
{
3353-
CONTRACTL
3354-
{
3355-
STANDARD_VM_CHECK;
3356-
3357-
PRECONDITION(4 == sizeof( ((Thread*)0)->m_State ));
3358-
PRECONDITION(4 == sizeof( ((Thread*)0)->m_fPreemptiveGCDisabled ));
3359-
}
3360-
CONTRACTL_END;
3361-
3362-
// move byte ptr [ebx + Thread.m_fPreemptiveGCDisabled],0
3363-
X86EmitOffsetModRM(0xc6, (X86Reg)0, kEBX, Thread::GetOffsetOfGCFlag());
3364-
Emit8(0);
3365-
3366-
_ASSERTE(FitsInI1(Thread::TS_CatchAtSafePoint));
3367-
3368-
// test byte ptr [ebx + Thread.m_State], TS_CatchAtSafePoint
3369-
X86EmitOffsetModRM(0xf6, (X86Reg)0, kEBX, Thread::GetOffsetOfState());
3370-
Emit8(Thread::TS_CatchAtSafePoint);
3371-
3372-
// jnz RarePath
3373-
X86EmitCondJump(pForwardRef, X86CondCode::kJNZ);
3374-
3375-
#ifdef _DEBUG
3376-
X86EmitDebugTrashReg(kECX);
3377-
#endif
3378-
3379-
}
3380-
3381-
3382-
//-----------------------------------------------------------------------
3383-
// Generates the out-of-line portion of the code to enable preemptive GC.
3384-
// After the work is done, the code jumps back to the "pRejoinPoint"
3385-
// which should be emitted right after the inline part is generated.
3386-
//
3387-
// Assumptions:
3388-
// ebx = Thread
3389-
// Preserves
3390-
// all registers except ecx.
3391-
//
3392-
//-----------------------------------------------------------------------
3393-
VOID StubLinkerCPU::EmitRareEnable(CodeLabel *pRejoinPoint)
3394-
{
3395-
STANDARD_VM_CONTRACT;
3396-
3397-
X86EmitCall(NewExternalCodeLabel((LPVOID) StubRareEnable), 0);
3398-
#ifdef _DEBUG
3399-
X86EmitDebugTrashReg(kECX);
3400-
#endif
3401-
if (pRejoinPoint)
3402-
{
3403-
X86EmitNearJump(pRejoinPoint);
3404-
}
3405-
3406-
}
3407-
3408-
34093327
//-----------------------------------------------------------------------
34103328
// Generates the inline portion of the code to disable preemptive GC. Hopefully,
34113329
// the inline code is all that will execute most of the time. If this code

src/coreclr/vm/i386/stublinkerx86.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -323,9 +323,6 @@ class StubLinkerCPU : public StubLinker
323323
}
324324

325325
#if defined(FEATURE_COMINTEROP) && defined(TARGET_X86)
326-
VOID EmitEnable(CodeLabel *pForwardRef);
327-
VOID EmitRareEnable(CodeLabel *pRejoinPoint);
328-
329326
VOID EmitDisable(CodeLabel *pForwardRef, BOOL fCallIn, X86Reg ThreadReg);
330327
VOID EmitRareDisable(CodeLabel *pRejoinPoint);
331328
VOID EmitRareDisableHRESULT(CodeLabel *pRejoinPoint, CodeLabel *pExitPoint);

src/coreclr/vm/threads.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1399,13 +1399,6 @@ Thread::Thread()
13991399
#ifdef _DEBUG
14001400
m_ulForbidTypeLoad = 0;
14011401
m_GCOnTransitionsOK = TRUE;
1402-
#endif
1403-
1404-
#ifdef ENABLE_CONTRACTS
1405-
m_ulEnablePreemptiveGCCount = 0;
1406-
#endif
1407-
1408-
#ifdef _DEBUG
14091402
dbg_m_cSuspendedThreads = 0;
14101403
dbg_m_cSuspendedThreadsWithoutOSLock = 0;
14111404
m_Creator.Clear();

src/coreclr/vm/threads.h

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1397,11 +1397,6 @@ class Thread
13971397
// holding a spin lock in coop mode and transit to preemp mode will cause deadlock on GC
13981398
_ASSERTE ((m_StateNC & Thread::TSNC_OwnsSpinLock) == 0);
13991399

1400-
#ifdef ENABLE_CONTRACTS_IMPL
1401-
_ASSERTE(!GCForbidden());
1402-
TriggersGC(this);
1403-
#endif
1404-
14051400
// ------------------------------------------------------------------------
14061401
// ** WARNING ** WARNING ** WARNING ** WARNING ** WARNING ** WARNING ** |
14071402
// ------------------------------------------------------------------------
@@ -1414,21 +1409,12 @@ class Thread
14141409
// ------------------------------------------------------------------------
14151410

14161411
m_fPreemptiveGCDisabled.StoreWithoutBarrier(0);
1417-
#ifdef ENABLE_CONTRACTS
1418-
m_ulEnablePreemptiveGCCount ++;
1419-
#endif // _DEBUG
1420-
1421-
// TODO: VS remove this. no polling on going to preemptive
1422-
// Delete RareEnablePreemptiveGC as well.
1423-
if (CatchAtSafePointOpportunistic())
1424-
RareEnablePreemptiveGC();
14251412
#endif
14261413
}
14271414

14281415
#if defined(STRESS_HEAP) && defined(_DEBUG)
14291416
void PerformPreemptiveGC();
14301417
#endif
1431-
void RareEnablePreemptiveGC();
14321418
void PulseGCMode();
14331419

14341420
//--------------------------------------------------------------
@@ -2804,11 +2790,6 @@ class Thread
28042790

28052791
#endif // TRACK_SYNC
28062792

2807-
private:
2808-
#ifdef ENABLE_CONTRACTS_DATA
2809-
ULONG m_ulEnablePreemptiveGCCount;
2810-
#endif // _DEBUG
2811-
28122793
private:
28132794
// For suspends:
28142795
CLREvent m_DebugSuspendEvent;

0 commit comments

Comments
 (0)