Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions src/coreclr/vm/appdomain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4122,15 +4122,6 @@ AppDomain::RaiseAssemblyResolveEvent(
RETURN pAssembly;
} // AppDomain::RaiseAssemblyResolveEvent

enum WorkType
{
WT_UnloadDomain = 0x1,
WT_ThreadAbort = 0x2,
WT_FinalizerThread = 0x4
};

static Volatile<DWORD> s_WorkType = 0;

void SystemDomain::ProcessDelayedUnloadLoaderAllocators()
{
CONTRACTL
Expand Down
52 changes: 7 additions & 45 deletions src/coreclr/vm/finalizerthread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ VOID FinalizerThread::FinalizerThreadWorker(void *args)
// Setting the event here, instead of at the bottom of the loop, could
// cause us to skip draining the Q, if the request is made as soon as
// the app starts running.
SignalFinalizationDone(TRUE);
SignalFinalizationDone();
#endif //0

WaitForFinalizerEvent (hEventFinalizer);
Expand Down Expand Up @@ -410,7 +410,7 @@ VOID FinalizerThread::FinalizerThreadWorker(void *args)
// race in that another thread starting a drain, as we leave a drain, may
// consider itself satisfied by the drain that just completed. This is
// acceptable.
SignalFinalizationDone(TRUE);
SignalFinalizationDone();
}

if (s_InitializedFinalizerThreadForPlatform)
Expand Down Expand Up @@ -538,19 +538,15 @@ void FinalizerThread::FinalizerThreadCreate()
}
}

void FinalizerThread::SignalFinalizationDone(BOOL fFinalizer)
void FinalizerThread::SignalFinalizationDone()
{
WRAPPER_NO_CONTRACT;

if (fFinalizer)
{
InterlockedAnd((LONG*)&g_FinalizerWaiterStatus, ~FWS_WaitInterrupt);
}
hEventFinalizerDone->Set();
}

// Wait for the finalizer thread to complete one pass.
void FinalizerThread::FinalizerThreadWait(DWORD timeout)
void FinalizerThread::FinalizerThreadWait()
{
ASSERT(hEventFinalizerDone->IsValid());
ASSERT(hEventFinalizer->IsValid());
Expand All @@ -569,44 +565,10 @@ void FinalizerThread::FinalizerThreadWait(DWORD timeout)
g_pRCWCleanupList->CleanupWrappersInCurrentCtxThread();
#endif // FEATURE_COMINTEROP

ULONGLONG startTime = CLRGetTickCount64();
ULONGLONG endTime;
if (timeout == INFINITE)
{
endTime = MAXULONGLONG;
}
else
{
endTime = timeout + startTime;
}

while (TRUE)
{
hEventFinalizerDone->Reset();
EnableFinalization();
hEventFinalizerDone->Reset();

//----------------------------------------------------
// Do appropriate wait and pump messages if necessary
//----------------------------------------------------
EnableFinalization();

DWORD status = hEventFinalizerDone->Wait(timeout,TRUE);
if (status != WAIT_TIMEOUT && !(g_FinalizerWaiterStatus & FWS_WaitInterrupt))
{
return;
}
// recalculate timeout
if (timeout != INFINITE)
{
ULONGLONG curTime = CLRGetTickCount64();
if (curTime >= endTime)
{
return;
}
else
{
timeout = (DWORD)(endTime - curTime);
}
}
}
hEventFinalizerDone->Wait(INFINITE,TRUE);
}
}
7 changes: 2 additions & 5 deletions src/coreclr/vm/finalizerthread.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,9 @@ class FinalizerThread
}
}

static void FinalizerThreadWait(DWORD timeout = INFINITE);
static void FinalizerThreadWait();

// We wake up a wait for finaliation for two reasons:
// if fFinalizer=TRUE, we have finished finalization.
// if fFinalizer=FALSE, the timeout for finalization is changed, and AD unload helper thread is notified.
static void SignalFinalizationDone(BOOL fFinalizer);
static void SignalFinalizationDone();

static VOID FinalizerThreadWorker(void *args);
static DWORD WINAPI FinalizerThreadStart(void *args);
Expand Down
2 changes: 0 additions & 2 deletions src/coreclr/vm/vars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,6 @@ GVAL_IMPL(SIZE_T, g_runtimeVirtualSize);

bool g_fManagedAttach = false;

DWORD g_FinalizerWaiterStatus = 0;

//
// Do we own the lifetime of the process, ie. is it an EXE?
//
Expand Down
7 changes: 0 additions & 7 deletions src/coreclr/vm/vars.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -467,13 +467,6 @@ inline BOOL IsAtProcessExit()
return g_fProcessDetach;
}

enum FWStatus
{
FWS_WaitInterrupt = 0x00000001,
};

EXTERN DWORD g_FinalizerWaiterStatus;

#if defined(TARGET_UNIX) && defined(FEATURE_EVENT_TRACE)
extern Volatile<BOOL> g_TriggerHeapDump;
#endif // TARGET_UNIX
Expand Down