summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJan Kotas <jkotas@microsoft.com>2018-11-15 19:35:35 -0800
committerGitHub <noreply@github.com>2018-11-15 19:35:35 -0800
commit31e8eec10cc014191ac327526221c2d30357d005 (patch)
treeb00ded0a513675d44012f0a213ecff93e71b1c0a /src
parentc21a3d6d137cc148d146d93306dab56085c6371f (diff)
downloadcoreclr-31e8eec10cc014191ac327526221c2d30357d005.tar.gz
coreclr-31e8eec10cc014191ac327526221c2d30357d005.tar.bz2
coreclr-31e8eec10cc014191ac327526221c2d30357d005.zip
Delete HAS_FLS_SUPPORT and related code (#21035)
Diffstat (limited to 'src')
-rw-r--r--src/debug/daccess/dacdbiimpl.cpp6
-rw-r--r--src/debug/daccess/request.cpp21
-rw-r--r--src/debug/ee/debugger.cpp12
-rw-r--r--src/vm/ceemain.h4
-rw-r--r--src/vm/codeman.cpp9
-rw-r--r--src/vm/corhost.cpp231
-rw-r--r--src/vm/stackprobe.cpp20
-rw-r--r--src/vm/threads.cpp557
-rw-r--r--src/vm/threads.h113
-rw-r--r--src/vm/threadsuspend.cpp26
10 files changed, 25 insertions, 974 deletions
diff --git a/src/debug/daccess/dacdbiimpl.cpp b/src/debug/daccess/dacdbiimpl.cpp
index 988f6734fa..cc68cdc930 100644
--- a/src/debug/daccess/dacdbiimpl.cpp
+++ b/src/debug/daccess/dacdbiimpl.cpp
@@ -4667,8 +4667,7 @@ CONNID DacDbiInterfaceImpl::GetConnectionID(VMPTR_Thread vmThread)
{
DD_ENTER_MAY_THROW;
- Thread * pThread = vmThread.GetDacPtr();
- return pThread->GetConnectionId();
+ return INVALID_CONNECTION_ID;
}
// Return the task ID of the specified thread.
@@ -4676,8 +4675,7 @@ TASKID DacDbiInterfaceImpl::GetTaskID(VMPTR_Thread vmThread)
{
DD_ENTER_MAY_THROW;
- Thread * pThread = vmThread.GetDacPtr();
- return pThread->GetTaskId();
+ return INVALID_TASK_ID;
}
// Return the OS thread ID of the specified thread
diff --git a/src/debug/daccess/request.cpp b/src/debug/daccess/request.cpp
index 3607916317..c196d7f2a4 100644
--- a/src/debug/daccess/request.cpp
+++ b/src/debug/daccess/request.cpp
@@ -765,26 +765,7 @@ ClrDataAccess::GetThreadData(CLRDATA_ADDRESS threadAddr, struct DacpThreadData *
threadData->allocContextPtr = TO_CDADDR(thread->m_alloc_context.alloc_ptr);
threadData->allocContextLimit = TO_CDADDR(thread->m_alloc_context.alloc_limit);
- // @todo Microsoft: the following assignment is pointless--we're just getting the
- // target address of the m_pFiberData field of the Thread instance. Then we're going to
- // compute it again as the argument to ReadVirtual. Ultimately, we want the value of
- // that field, not its address. We already have that value as part of thread (the
- // marshaled Thread instance).This should just go away and we should simply have:
- // threadData->fiberData = TO_CDADDR(thread->m_pFiberData );
- // instead of the next 11 lines.
- threadData->fiberData = (CLRDATA_ADDRESS)PTR_HOST_MEMBER_TADDR(Thread, thread, m_pFiberData);
-
- ULONG32 returned = 0;
- TADDR Value = NULL;
- HRESULT hr = m_pTarget->ReadVirtual(PTR_HOST_MEMBER_TADDR(Thread, thread, m_pFiberData),
- (PBYTE)&Value,
- sizeof(TADDR),
- &returned);
-
- if ((hr == S_OK) && (returned == sizeof(TADDR)))
- {
- threadData->fiberData = (CLRDATA_ADDRESS) Value;
- }
+ threadData->fiberData = NULL;
threadData->pFrame = PTR_CDADDR(thread->m_pFrame);
threadData->context = PTR_CDADDR(thread->m_Context);
diff --git a/src/debug/ee/debugger.cpp b/src/debug/ee/debugger.cpp
index c6fb4192e5..b23a1ca905 100644
--- a/src/debug/ee/debugger.cpp
+++ b/src/debug/ee/debugger.cpp
@@ -11429,20 +11429,8 @@ bool Debugger::HandleIPCEvent(DebuggerIPCEvent * pEvent)
case DB_IPCE_GET_THREAD_FOR_TASKID:
{
- TASKID taskid = pEvent->GetThreadForTaskId.taskid;
- Thread *pThread = ThreadStore::GetThreadList(NULL);
Thread *pThreadRet = NULL;
- while (pThread != NULL)
- {
- if (pThread->GetTaskId() == taskid)
- {
- pThreadRet = pThread;
- break;
- }
- pThread = ThreadStore::GetThreadList(pThread);
- }
-
// This is a synchronous event (reply required)
pEvent = m_pRCThread->GetIPCEventReceiveBuffer();
diff --git a/src/vm/ceemain.h b/src/vm/ceemain.h
index 9a14af54ca..451bbc58b1 100644
--- a/src/vm/ceemain.h
+++ b/src/vm/ceemain.h
@@ -69,10 +69,6 @@ public:
// Delete on TLS block
static void DeleteTLS(void **pTlsData);
- // Fiber switch notifications
- static void SwitchIn();
- static void SwitchOut();
-
static void **CheckThreadState(DWORD slot, BOOL force = TRUE);
static void **CheckThreadStateNoCreate(DWORD slot
#ifdef _DEBUG
diff --git a/src/vm/codeman.cpp b/src/vm/codeman.cpp
index 1ea4303e34..815507fa60 100644
--- a/src/vm/codeman.cpp
+++ b/src/vm/codeman.cpp
@@ -2311,11 +2311,6 @@ extern "C" PT_RUNTIME_FUNCTION GetRuntimeFunctionCallback(IN ULONG ControlPc
BEGIN_PRESERVE_LAST_ERROR;
#ifdef ENABLE_CONTRACTS
- // See comment in code:Thread::SwitchIn and SwitchOut.
- Thread *pThread = GetThread();
- if (!(pThread && pThread->HasThreadStateNC(Thread::TSNC_InTaskSwitch)))
- {
-
// Some 64-bit OOM tests use the hosting interface to re-enter the CLR via
// RtlVirtualUnwind to track unique stacks at each failure point. RtlVirtualUnwind can
// result in the EEJitManager taking a reader lock. This, in turn, results in a
@@ -2336,10 +2331,6 @@ extern "C" PT_RUNTIME_FUNCTION GetRuntimeFunctionCallback(IN ULONG ControlPc
LOG((LF_EH, LL_INFO1000000, "GetRuntimeFunctionCallback(%p) returned %p\n", ControlPc, prf));
-#ifdef ENABLE_CONTRACTS
- }
-#endif // ENABLE_CONTRACTS
-
END_PRESERVE_LAST_ERROR;
return prf;
diff --git a/src/vm/corhost.cpp b/src/vm/corhost.cpp
index b58d75d676..17079082b7 100644
--- a/src/vm/corhost.cpp
+++ b/src/vm/corhost.cpp
@@ -2719,64 +2719,9 @@ ULONG STDMETHODCALLTYPE CExecutionEngine::Release()
struct ClrTlsInfo
{
void* data[MAX_PREDEFINED_TLS_SLOT];
- // When hosted, we may not be able to delete memory in DLL_THREAD_DETACH.
- // We will chain this into a side list, and free these on Finalizer thread.
- ClrTlsInfo *next;
};
-#define DataToClrTlsInfo(a) (a)?(ClrTlsInfo*)((BYTE*)a - offsetof(ClrTlsInfo, data)):NULL
-
-
-#ifdef HAS_FLS_SUPPORT
-
-static BOOL fHasFlsSupport = FALSE;
-
-typedef DWORD (*Func_FlsAlloc)(PFLS_CALLBACK_FUNCTION lpCallback);
-typedef BOOL (*Func_FlsFree)(DWORD dwFlsIndex);
-typedef BOOL (*Func_FlsSetValue)(DWORD dwFlsIndex,PVOID lpFlsData);
-typedef PVOID (*Func_FlsGetValue)(DWORD dwFlsIndex);
-
-static DWORD FlsIndex = FLS_OUT_OF_INDEXES;
-static Func_FlsAlloc pFlsAlloc;
-static Func_FlsSetValue pFlsSetValue;
-static Func_FlsFree pFlsFree;
-static Func_FlsGetValue pFlsGetValue;
-static Volatile<BOOL> fFlsSetupDone = FALSE;
-
-VOID WINAPI FlsCallback(
- PVOID lpFlsData
-)
-{
- LIMITED_METHOD_CONTRACT;
-
- _ASSERTE (pFlsGetValue);
- if (pFlsGetValue(FlsIndex) != lpFlsData)
- {
- // The current running fiber is being destroyed. We can not destroy the memory yet,
- // because our DllMain function may still need the memory.
- CExecutionEngine::ThreadDetaching((void **)lpFlsData);
- }
- else
- {
- // The thread is being wound down.
- // In hosting scenarios the host will have already called ICLRTask::ExitTask, which
- // ends up calling CExecutionEngine::SwitchOut, which will have reset the TLS at TlsIndex.
- //
- // Unfortunately different OSes have different ordering of destroying FLS data and sending
- // the DLL_THREAD_DETACH notification (pre-Vista FlsCallback is called after DllMain, while
- // in Vista and up, FlsCallback is called before DllMain). Additionally, starting with
- // Vista SP1 and Win2k8, the OS will set the FLS slot to 0 after the call to FlsCallback,
- // effectively removing our last reference to this data. Since in EEDllMain we need to be
- // able to access the FLS data, we save lpFlsData in the TLS slot at TlsIndex, if needed.
- if (CExecutionEngine::GetTlsData() == NULL)
- {
- CExecutionEngine::SetTlsData((void **)lpFlsData);
- }
- }
-}
-
-#endif // HAS_FLS_SUPPORT
-
+#define DataToClrTlsInfo(a) ((ClrTlsInfo*)a)
void** CExecutionEngine::GetTlsData()
{
@@ -2821,10 +2766,6 @@ void **CExecutionEngine::CheckThreadState(DWORD slot, BOOL force)
STATIC_CONTRACT_CANNOT_TAKE_LOCK;
STATIC_CONTRACT_SO_TOLERANT;
- // !!! This function is called during Thread::SwitchIn and SwitchOut
- // !!! It is extremely important that while executing this function, we will not
- // !!! cause fiber switch. This means we can not allocate memory, lock, etc...
-
//<TODO> @TODO: Decide on an exception strategy for all the DLLs of the CLR, and then
// enable all the exceptions out of this method.</TODO>
@@ -2833,68 +2774,9 @@ void **CExecutionEngine::CheckThreadState(DWORD slot, BOOL force)
// if (slot >= MAX_PREDEFINED_TLS_SLOT)
// COMPlusThrow(kArgumentOutOfRangeException);
-#ifdef HAS_FLS_SUPPORT
- if (!fFlsSetupDone)
- {
- // Contract depends on Fls support. Don't use contract here.
- HMODULE hmod = GetModuleHandleA(WINDOWS_KERNEL32_DLLNAME_A);
- if (hmod)
- {
- pFlsSetValue = (Func_FlsSetValue) GetProcAddress(hmod, "FlsSetValue");
- pFlsGetValue = (Func_FlsGetValue) GetProcAddress(hmod, "FlsGetValue");
- pFlsAlloc = (Func_FlsAlloc) GetProcAddress(hmod, "FlsAlloc");
- pFlsFree = (Func_FlsFree) GetProcAddress(hmod, "FlsFree");
-
- if (pFlsSetValue && pFlsGetValue && pFlsAlloc && pFlsFree )
- {
- fHasFlsSupport = TRUE;
- }
- else
- {
- // Since we didn't find them all, we shouldn't have found any
- _ASSERTE( pFlsSetValue == NULL && pFlsGetValue == NULL && pFlsAlloc == NULL && pFlsFree == NULL);
- }
- fFlsSetupDone = TRUE;
- }
- }
-
- if (fHasFlsSupport && FlsIndex == FLS_OUT_OF_INDEXES)
- {
- // PREFIX_ASSUME needs TLS. If we use it here, we will loop forever
-#if defined(_PREFAST_) || defined(_PREFIX_)
- if (pFlsAlloc == NULL) __UNREACHABLE();
-#else
- _ASSERTE(pFlsAlloc != NULL);
-#endif // _PREFAST_ || _PREFIX_
-
- DWORD tryFlsIndex = pFlsAlloc(FlsCallback);
- if (tryFlsIndex != FLS_OUT_OF_INDEXES)
- {
- if (FastInterlockCompareExchange((LONG*)&FlsIndex, tryFlsIndex, FLS_OUT_OF_INDEXES) != FLS_OUT_OF_INDEXES)
- {
- pFlsFree(tryFlsIndex);
- }
- }
- if (FlsIndex == FLS_OUT_OF_INDEXES)
- {
- COMPlusThrowOM();
- }
- }
-#endif // HAS_FLS_SUPPORT
-
void** pTlsData = CExecutionEngine::GetTlsData();
BOOL fInTls = (pTlsData != NULL);
-#ifdef HAS_FLS_SUPPORT
- if (fHasFlsSupport)
- {
- if (pTlsData == NULL)
- {
- pTlsData = (void **)pFlsGetValue(FlsIndex);
- }
- }
-#endif
-
ClrTlsInfo *pTlsInfo = DataToClrTlsInfo(pTlsData);
if (pTlsInfo == 0 && force)
{
@@ -2910,12 +2792,6 @@ void **CExecutionEngine::CheckThreadState(DWORD slot, BOOL force)
goto LError;
}
memset (pTlsInfo, 0, sizeof(ClrTlsInfo));
-#ifdef HAS_FLS_SUPPORT
- if (fHasFlsSupport && !pFlsSetValue(FlsIndex, pTlsInfo))
- {
- goto LError;
- }
-#endif
// We save the last intolerant marker on stack in this slot.
// -1 is the larget unsigned number, and therefore our marker is always smaller than it.
pTlsInfo->data[TlsIdx_SOIntolerantTransitionHandler] = (void*)(-1);
@@ -2923,31 +2799,10 @@ void **CExecutionEngine::CheckThreadState(DWORD slot, BOOL force)
if (!fInTls && pTlsInfo)
{
-#ifdef HAS_FLS_SUPPORT
- // If we have a thread object or are on a non-fiber thread, we are safe for fiber switching.
- if (!fHasFlsSupport ||
- GetThread() ||
- (g_fEEStarted || g_fEEInit) ||
- (((size_t)pTlsInfo->data[TlsIdx_ThreadType]) & (ThreadType_GC | ThreadType_Gate | ThreadType_Timer | ThreadType_DbgHelper)))
- {
-#ifdef _DEBUG
- Thread *pThread = GetThread();
- if (pThread)
- {
- pThread->AddFiberInfo(Thread::ThreadTrackInfo_Lifetime);
- }
-#endif
- if (!CExecutionEngine::SetTlsData(pTlsInfo->data) && !fHasFlsSupport)
- {
- goto LError;
- }
- }
-#else
if (!CExecutionEngine::SetTlsData(pTlsInfo->data))
{
goto LError;
}
-#endif
}
return pTlsInfo?pTlsInfo->data:NULL;
@@ -2991,16 +2846,6 @@ void **CExecutionEngine::CheckThreadStateNoCreate(DWORD slot
void **pTlsData = CExecutionEngine::GetTlsData();
-#ifdef HAS_FLS_SUPPORT
- if (fHasFlsSupport)
- {
- if (pTlsData == NULL)
- {
- pTlsData = (void **)pFlsGetValue(FlsIndex);
- }
- }
-#endif
-
ClrTlsInfo *pTlsInfo = DataToClrTlsInfo(pTlsData);
return pTlsInfo?pTlsInfo->data:NULL;
@@ -3016,10 +2861,6 @@ void CExecutionEngine::SetupTLSForThread(Thread *pThread)
STATIC_CONTRACT_SO_TOLERANT;
STATIC_CONTRACT_MODE_ANY;
-#ifdef _DEBUG
- if (pThread)
- pThread->AddFiberInfo(Thread::ThreadTrackInfo_Lifetime);
-#endif
#ifdef STRESS_LOG
if (StressLog::StressLogOn(~0u, 0))
{
@@ -3041,57 +2882,6 @@ void CExecutionEngine::SetupTLSForThread(Thread *pThread)
#endif
}
-void CExecutionEngine::SwitchIn()
-{
- // No real contracts here. This function is called by Thread::SwitchIn.
- STATIC_CONTRACT_NOTHROW;
- STATIC_CONTRACT_GC_NOTRIGGER;
- STATIC_CONTRACT_MODE_ANY;
- STATIC_CONTRACT_ENTRY_POINT;
-
- // @TODO - doesn't look like we can probe here....
-
-#ifdef HAS_FLS_SUPPORT
- if (fHasFlsSupport)
- {
- void **pTlsData = (void **)pFlsGetValue(FlsIndex);
-
- BOOL fResult = CExecutionEngine::SetTlsData(pTlsData);
- if (fResult)
- {
-#ifdef STRESS_LOG
- // We are in task transition period. We can not call into host to create stress log.
- if (ClrTlsGetValue(TlsIdx_StressLog) != NULL)
- {
- STRESS_LOG1(LF_SYNC, LL_INFO100, ThreadStressLog::TaskSwitchMsg(), ::GetCurrentThreadId());
- }
-#endif
- }
- // It is OK for UnsafeTlsSetValue to fail here, since we can always go back to Fls to get value.
- }
-#endif
-}
-
-void CExecutionEngine::SwitchOut()
-{
- // No real contracts here. This function is called by Thread::SwitchOut
- STATIC_CONTRACT_NOTHROW;
- STATIC_CONTRACT_GC_NOTRIGGER;
- STATIC_CONTRACT_MODE_ANY;
- STATIC_CONTRACT_ENTRY_POINT;
-
-#ifdef HAS_FLS_SUPPORT
- // @TODO - doesn't look like we can probe here.
- if (fHasFlsSupport && pFlsGetValue != NULL && (void **)pFlsGetValue(FlsIndex) != NULL)
- {
- // Clear out TLS unless we're in the process of ThreadDetach
- // We establish that we're in ThreadDetach because fHasFlsSupport will
- // be TRUE, but the FLS will not exist.
- CExecutionEngine::SetTlsData(NULL);
- }
-#endif // HAS_FLS_SUPPORT
-}
-
static void ThreadDetachingHelper(PTLS_CALLBACK_FUNCTION callback, void* pData)
{
// Do not use contract. We are freeing TLS blocks.
@@ -3099,8 +2889,8 @@ static void ThreadDetachingHelper(PTLS_CALLBACK_FUNCTION callback, void* pData)
STATIC_CONTRACT_GC_NOTRIGGER;
STATIC_CONTRACT_MODE_ANY;
- callback(pData);
- }
+ callback(pData);
+}
// Called here from a thread detach or from destruction of a Thread object. In
// the detach case, we get our info from TLS. In the destruct case, it comes from
@@ -3178,14 +2968,6 @@ void CExecutionEngine::DeleteTLS(void ** pTlsData)
ThreadDetachingHelper(Callbacks[TlsIdx_ClrDebugState], pData);
}
-#ifdef _DEBUG
- Thread *pThread = GetThread();
- if (pThread)
- {
- pThread->AddFiberInfo(Thread::ThreadTrackInfo_Lifetime);
- }
-#endif
-
// NULL TLS and FLS entry so that we don't double free.
// We may get two callback here on thread death
// 1. From EEDllMain
@@ -3195,13 +2977,6 @@ void CExecutionEngine::DeleteTLS(void ** pTlsData)
CExecutionEngine::SetTlsData(0);
}
-#ifdef HAS_FLS_SUPPORT
- if (fHasFlsSupport && pFlsGetValue(FlsIndex) == pTlsData)
- {
- pFlsSetValue(FlsIndex, NULL);
- }
-#endif
-
#undef HeapFree
#undef GetProcessHeap
::HeapFree (GetProcessHeap(),0,pTlsInfo);
diff --git a/src/vm/stackprobe.cpp b/src/vm/stackprobe.cpp
index 6663300e90..7e40ca8738 100644
--- a/src/vm/stackprobe.cpp
+++ b/src/vm/stackprobe.cpp
@@ -1381,16 +1381,6 @@ void BaseStackGuard::ProtectMarkerPageInDebugger()
return;
}
-#ifdef _DEBUG
- BEGIN_GETTHREAD_ALLOWED;
- Thread* pThread = GetThread();
- if (pThread)
- {
- pThread->AddFiberInfo(Thread::ThreadTrackInfo_Escalation);
- }
- END_GETTHREAD_ALLOWED;
-#endif
-
DWORD flOldProtect;
LOG((LF_EH, LL_INFO100000, "BSG::PMP: m_pMarker 0x%p, value 0x%p\n", m_pMarker, *m_pMarker));
@@ -1436,16 +1426,6 @@ void BaseStackGuard::UndoPageProtectionInDebugger()
_ASSERTE(IsProbeGuard());
-#ifdef _DEBUG
- BEGIN_GETTHREAD_ALLOWED;
- Thread* pThread = GetThread();
- if (pThread)
- {
- pThread->AddFiberInfo(Thread::ThreadTrackInfo_Escalation);
- }
- END_GETTHREAD_ALLOWED;
-#endif
-
DWORD flOldProtect;
// EEVirtualProtect installs a BoundaryStackGuard. To avoid recursion, we call
// into OS for VirtualProtect instead.
diff --git a/src/vm/threads.cpp b/src/vm/threads.cpp
index 7a638a9c66..707330a30f 100644
--- a/src/vm/threads.cpp
+++ b/src/vm/threads.cpp
@@ -745,10 +745,6 @@ Thread* SetupThread(BOOL fInternal)
FastInterlockOr((ULONG *) &pThread->m_State, Thread::TS_FullyInitialized);
-#ifdef _DEBUG
- pThread->AddFiberInfo(Thread::ThreadTrackInfo_Lifetime);
-#endif
-
#ifdef DEBUGGING_SUPPORTED
//
// If we're debugging, let the debugger know that this
@@ -997,7 +993,24 @@ HRESULT Thread::DetachThread(BOOL fDLLThreadDetach)
END_CONTRACT_VIOLATION;
- InternalSwitchOut();
+ HANDLE hThread = GetThreadHandle();
+ SetThreadHandle (SWITCHOUT_HANDLE_VALUE);
+ while (m_dwThreadHandleBeingUsed > 0)
+ {
+ // Another thread is using the handle now.
+#undef Sleep
+ // We can not call __SwitchToThread since we can not go back to host.
+ ::Sleep(10);
+#define Sleep(a) Dont_Use_Sleep(a)
+ }
+ if (m_WeOwnThreadHandle && m_ThreadHandleForClose == INVALID_HANDLE_VALUE)
+ {
+ m_ThreadHandleForClose = hThread;
+ }
+
+ // We need to make sure that TLS are touched last here.
+ SetThread(NULL);
+ SetAppDomain(NULL);
#ifdef ENABLE_CONTRACTS_DATA
m_pClrDebugState = NULL;
@@ -1535,27 +1548,6 @@ Thread::Thread()
m_dwAbortPoint = 0;
#endif
- m_pFiberData = NULL;
-
- m_TaskId = INVALID_TASK_ID;
- m_dwConnectionId = INVALID_CONNECTION_ID;
-
-#ifdef _DEBUG
- DWORD_PTR *ttInfo = NULL;
- size_t nBytes = MaxThreadRecord *
- (sizeof(FiberSwitchInfo)-sizeof(size_t)+MaxStackDepth*sizeof(size_t));
- if (g_pConfig->SaveThreadInfo()) {
- ttInfo = new DWORD_PTR[(nBytes/sizeof(DWORD_PTR))*ThreadTrackInfo_Max];
- memset(ttInfo,0,nBytes*ThreadTrackInfo_Max);
- }
- for (DWORD i = 0; i < ThreadTrackInfo_Max; i ++)
- {
- m_FiberInfoIndex[i] = 0;
- m_pFiberInfo[i] = (FiberSwitchInfo*)((DWORD_PTR)ttInfo + i*nBytes);
- }
- NewArrayHolder<DWORD_PTR> fiberInfoHolder(ttInfo);
-#endif
-
m_OSContext = new CONTEXT();
NewHolder<CONTEXT> contextHolder(m_OSContext);
@@ -1566,7 +1558,6 @@ Thread::Thread()
m_pRCWStack = new RCWStackHeader();
#endif
- m_pCerPreparationState = NULL;
#ifdef _DEBUG
m_bGCStressing = FALSE;
m_bUniqueStacking = FALSE;
@@ -1646,9 +1637,6 @@ Thread::Thread()
#if defined(_DEBUG) && defined(TRACK_SYNC)
trackSyncHolder.SuppressRelease();
#endif
-#ifdef _DEBUG
- fiberInfoHolder.SuppressRelease();
-#endif
contextHolder.SuppressRelease();
savedRedirectContextHolder.SuppressRelease();
@@ -1932,10 +1920,6 @@ BOOL Thread::HasStarted(BOOL bRequiresTSL)
ThrowOutOfMemory();
}
-#ifdef _DEBUG
- AddFiberInfo(Thread::ThreadTrackInfo_Lifetime);
-#endif
-
SetupThreadForHost();
@@ -2531,9 +2515,6 @@ int Thread::DecExternalCount(BOOL holdingLock)
m_ExceptionState.FreeAllStackTraces();
if (SelfDelete) {
SetThread(NULL);
-#ifdef _DEBUG
- AddFiberInfo(ThreadTrackInfo_Lifetime);
-#endif
}
delete this;
}
@@ -2742,12 +2723,6 @@ Thread::~Thread()
}
#endif
-#ifdef _DEBUG
- if (m_pFiberInfo != NULL) {
- delete [] (DWORD_PTR*)m_pFiberInfo[0];
- }
-#endif
-
#ifdef FEATURE_EVENT_TRACE
// Destruct the thread local type cache for allocation sampling
if(m_pAllLoggedTypes) {
@@ -4287,9 +4262,6 @@ void Thread::UserInterrupt(ThreadInterruptMode mode)
if (HasValidThreadHandle() &&
HasThreadState (TS_Interruptible))
{
-#ifdef _DEBUG
- AddFiberInfo(ThreadTrackInfo_Abort);
-#endif
Alert();
}
}
@@ -4413,9 +4385,6 @@ OBJECTREF Thread::GetExposedObject()
// already hold the thread lock and IncExternalCount won't be able to take it.
ULONG retVal = FastInterlockIncrement ((LONG*)&m_ExternalRefCount);
-#ifdef _DEBUG
- AddFiberInfo(ThreadTrackInfo_Lifetime);
-#endif
// Check to see if we need to store a strong pointer to the object.
if (retVal > 1)
StoreObjectInHandle(m_StrongHndToExposedObject, (OBJECTREF) attempt);
@@ -5387,14 +5356,6 @@ void ThreadStore::InitThreadStore()
ThreadSuspend::g_pGCSuspendEvent = new CLREvent();
ThreadSuspend::g_pGCSuspendEvent->CreateManualEvent(FALSE);
-#ifdef _DEBUG
- Thread::MaxThreadRecord = EEConfig::GetConfigDWORD_DontUse_(CLRConfig::INTERNAL_MaxThreadRecord,Thread::MaxThreadRecord);
- Thread::MaxStackDepth = EEConfig::GetConfigDWORD_DontUse_(CLRConfig::INTERNAL_MaxStackDepth,Thread::MaxStackDepth);
- if (Thread::MaxStackDepth > 100) {
- Thread::MaxStackDepth = 100;
- }
-#endif
-
s_pWaitForStackCrawlEvent = new CLREvent();
s_pWaitForStackCrawlEvent->CreateManualEvent(FALSE);
@@ -6141,10 +6102,6 @@ void Thread::HandleThreadInterrupt (BOOL fWaitForADUnload)
ResetThreadState ((ThreadState)(TS_Interrupted | TS_Interruptible));
FastInterlockAnd ((DWORD*)&m_UserInterrupt, ~TI_Interrupt);
-#ifdef _DEBUG
- AddFiberInfo(ThreadTrackInfo_Abort);
-#endif
-
COMPlusThrow(kThreadInterruptedException);
}
END_SO_INTOLERANT_CODE;
@@ -9520,324 +9477,6 @@ BOOL ThreadStore::HoldingThreadStore(Thread *pThread)
}
}
-
-#ifdef _DEBUG
-
-int Thread::MaxThreadRecord = 20;
-int Thread::MaxStackDepth = 20;
-
-const int Thread::MaxThreadTrackInfo = Thread::ThreadTrackInfo_Max;
-
-void Thread::AddFiberInfo(DWORD type)
-{
- STATIC_CONTRACT_NOTHROW;
- STATIC_CONTRACT_GC_NOTRIGGER;
- STATIC_CONTRACT_MODE_ANY;
- STATIC_CONTRACT_SO_TOLERANT;
-
-#ifndef FEATURE_PAL
-
- if (m_pFiberInfo[0] == NULL) {
- return;
- }
-
- DWORD mask = g_pConfig->SaveThreadInfoMask();
- if ((mask & type) == 0)
- {
- return;
- }
-
- int slot = -1;
- while (type != 0)
- {
- type >>= 1;
- slot ++;
- }
-
- _ASSERTE (slot < ThreadTrackInfo_Max);
-
- // use try to force ebp frame.
- PAL_TRY_NAKED {
- ULONG index = FastInterlockIncrement((LONG*)&m_FiberInfoIndex[slot])-1;
- index %= MaxThreadRecord;
- size_t unitBytes = sizeof(FiberSwitchInfo)-sizeof(size_t)+MaxStackDepth*sizeof(size_t);
- FiberSwitchInfo *pInfo = (FiberSwitchInfo*)((char*)m_pFiberInfo[slot] + index*unitBytes);
- pInfo->timeStamp = getTimeStamp();
- pInfo->threadID = GetCurrentThreadId();
-
-#ifdef FEATURE_HIJACK
- // We can't crawl the stack of a thread that currently has a hijack pending
- // (since the hijack routine won't be recognized by any code manager). So we
- // undo any hijack, the EE will re-attempt it later.
- // Stack crawl happens on the current thread, which may not be 'this' thread.
- Thread* pCurrentThread = GetThread();
- if (pCurrentThread != NULL && (pCurrentThread->m_State & TS_Hijacked))
- {
- pCurrentThread->UnhijackThread();
- }
-#endif
-
- int count = UtilCaptureStackBackTrace (2,MaxStackDepth,(PVOID*)pInfo->callStack,NULL);
- while (count < MaxStackDepth) {
- pInfo->callStack[count++] = 0;
- }
- }
- PAL_EXCEPT_NAKED (EXCEPTION_EXECUTE_HANDLER)
- {
- }
- PAL_ENDTRY_NAKED;
-#endif // !FEATURE_PAL
-}
-
-#endif // _DEBUG
-
-HRESULT Thread::SwitchIn(HANDLE threadHandle)
-{
- // can't have dynamic contracts because this method is going to mess with TLS
- STATIC_CONTRACT_NOTHROW;
- STATIC_CONTRACT_GC_NOTRIGGER;
- STATIC_CONTRACT_MODE_ANY;
-
- //can't do heap allocation in this method
- CantAllocHolder caHolder;
-
- // !!! Can not use the following line, since it uses an object which .dctor calls
- // !!! FLS_SETVALUE, and a new FLS is created after SwitchOut.
- // CANNOTTHROWCOMPLUSEXCEPTION();
-
- // Case Cookie to thread object and add to tls
-#ifdef _DEBUG
- Thread *pThread = GetThread();
- // If this is hit, we need to understand.
- // Sometimes we see the assert but the memory does not match the assert.
- if (pThread) {
- DebugBreak();
- }
- //_ASSERT(GetThread() == NULL);
-#endif
-
- if (GetThread() != NULL) {
- return HOST_E_INVALIDOPERATION;
- }
-
- CExecutionEngine::SwitchIn();
-
- // !!! no contract for this class.
- // !!! We have not switched in tls block.
- class EnsureTlsData
- {
- private:
- Thread *m_pThread;
- BOOL m_fNeedReset;
- public:
- EnsureTlsData(Thread* pThread){m_pThread = pThread; m_fNeedReset = TRUE;}
- ~EnsureTlsData()
- {
- if (m_fNeedReset)
- {
- SetThread(NULL);
- SetAppDomain(NULL);
- CExecutionEngine::SwitchOut();
- }
- }
- void SuppressRelease()
- {
- m_fNeedReset = FALSE;
- }
- };
-
- EnsureTlsData ensure(this);
-
- if (SetThread(this))
- {
- Thread *pThread = GetThread();
- if (!pThread)
- return E_OUTOFMEMORY;
-
- // !!! make sure that we switchin TLS so that FLS is available for Contract etc.
-
- // We redundantly keep the domain in its own TLS slot, for faster access from
- // stubs
- if (!SetAppDomain(m_pDomainAtTaskSwitch))
- {
- return E_OUTOFMEMORY;
- }
-
- CANNOTTHROWCOMPLUSEXCEPTION();
-#if 0
- // We switch out a fiber only if the fiber is in preemptive gc mode.
- _ASSERTE (!PreemptiveGCDisabled());
-#endif
-
-
- // We have to be switched in on the same fiber
- _ASSERTE (GetCachedStackBase() == GetStackUpperBound());
-
- if (m_pFiberData)
- {
- // only set the m_OSThreadId to bad food in Fiber mode
- m_OSThreadId = ::GetCurrentThreadId();
-#ifdef PROFILING_SUPPORTED
- // If a profiler is present, then notify the profiler that a
- // thread has been created.
- {
- BEGIN_PIN_PROFILER(CORProfilerTrackThreads());
- g_profControlBlock.pProfInterface->ThreadAssignedToOSThread(
- (ThreadID)this, m_OSThreadId);
- END_PIN_PROFILER();
- }
-#endif // PROFILING_SUPPORTED
- }
- SetThreadHandle(threadHandle);
-
-#ifndef FEATURE_PAL
- m_pTEB = (struct _NT_TIB*)NtCurrentTeb();
-#endif // !FEATURE_PAL
-
-#if 0
- if (g_TrapReturningThreads && m_fPreemptiveGCDisabled && this != ThreadSuspend::GetSuspensionThread()) {
- WorkingOnThreadContextHolder workingOnThreadContext(this);
- if (workingOnThreadContext.Acquired())
- {
- HandledJITCase(TRUE);
- }
- }
-#endif
-
-#ifdef _DEBUG
- // For debugging purpose, we save callstack during task switch. On Win64, the callstack
- // is done within OS loader lock, and obtaining managed callstack may cause fiber switch.
- SetThreadStateNC(TSNC_InTaskSwitch);
- AddFiberInfo(ThreadTrackInfo_Schedule);
- ResetThreadStateNC(TSNC_InTaskSwitch);
-#endif
-
- ensure.SuppressRelease();
- return S_OK;
- }
- else
- {
- return E_FAIL;
- }
-}
-
-HRESULT Thread::SwitchOut()
-{
- LIMITED_METHOD_CONTRACT;
-
- return E_NOTIMPL;
-}
-
-void Thread::InternalSwitchOut()
-{
- INDEBUG( BOOL fNoTLS = (CExecutionEngine::CheckThreadStateNoCreate(0) == NULL));
-
- CONTRACTL
- {
- NOTHROW;
- GC_NOTRIGGER;
- SO_TOLERANT;
- MODE_ANY;
- }
- CONTRACTL_END;
-
- {
- // Can't do heap allocation in this method.
- // We need to scope this holder because its destructor accesses FLS.
- CantAllocHolder caHolder;
-
- // !!! Can not use the following line, since it uses an object which .dctor calls
- // !!! FLS_SETVALUE, and a new FLS is created after SwitchOut.
- // CANNOTTHROWCOMPLUSEXCEPTION();
-
- _ASSERTE(GetThread() == this);
-
- _ASSERTE (!fNoTLS ||
- (CExecutionEngine::CheckThreadStateNoCreate(0) == NULL));
-
-#if 0
- // workaround wwl: for SQL reschedule
-#ifndef _DEBUG
- if (PreemptiveGCDisabled)
- {
- DebugBreak();
- }
-#endif
- _ASSERTE(!PreemptiveGCDisabled());
-#endif
-
- // Can not assert here. If a mutex is orphaned, the thread will have ThreadAffinity.
- //_ASSERTE(!HasThreadAffinity());
-
- _ASSERTE (!fNoTLS ||
- (CExecutionEngine::CheckThreadStateNoCreate(0) == NULL));
-
-#ifdef _DEBUG
- // For debugging purpose, we save callstack during task switch. On Win64, the callstack
- // is done within OS loader lock, and obtaining managed callstack may cause fiber switch.
- SetThreadStateNC(TSNC_InTaskSwitch);
- AddFiberInfo(ThreadTrackInfo_Schedule);
- ResetThreadStateNC(TSNC_InTaskSwitch);
-#endif
-
- _ASSERTE (!fNoTLS ||
- (CExecutionEngine::CheckThreadStateNoCreate(0) == NULL));
-
- m_pDomainAtTaskSwitch = GetAppDomain();
-
- if (m_pFiberData)
- {
- // only set the m_OSThreadId to bad food in Fiber mode
- m_OSThreadId = SWITCHED_OUT_FIBER_OSID;
-#ifdef PROFILING_SUPPORTED
- // If a profiler is present, then notify the profiler that a
- // thread has been created.
- {
- BEGIN_PIN_PROFILER(CORProfilerTrackThreads());
- g_profControlBlock.pProfInterface->ThreadAssignedToOSThread(
- (ThreadID)this, m_OSThreadId);
- END_PIN_PROFILER();
- }
-#endif // PROFILING_SUPPORTED
- }
-
- _ASSERTE (!fNoTLS ||
- (CExecutionEngine::CheckThreadStateNoCreate(0) == NULL));
-
- HANDLE hThread = GetThreadHandle();
-
- SetThreadHandle (SWITCHOUT_HANDLE_VALUE);
- while (m_dwThreadHandleBeingUsed > 0)
- {
- // Another thread is using the handle now.
-#undef Sleep
- // We can not call __SwitchToThread since we can not go back to host.
- ::Sleep(10);
-#define Sleep(a) Dont_Use_Sleep(a)
- }
-
- if (m_WeOwnThreadHandle && m_ThreadHandleForClose == INVALID_HANDLE_VALUE)
- {
- m_ThreadHandleForClose = hThread;
- }
-
- _ASSERTE (!fNoTLS ||
- (CExecutionEngine::CheckThreadStateNoCreate(0) == NULL));
- }
-
- CExecutionEngine::SwitchOut();
-
- // We need to make sure that TLS are touched last here.
- // Contract uses TLS.
- SetThread(NULL);
- SetAppDomain(NULL);
-
- _ASSERTE (!fNoTLS ||
- (CExecutionEngine::CheckThreadStateNoCreate(0) == NULL));
-}
-
-
-
LONG Thread::GetTotalThreadPoolCompletionCount()
{
CONTRACTL
@@ -10014,149 +9653,6 @@ void Thread::InternalReset(BOOL fFull, BOOL fNotFinalizerThread, BOOL fThreadObj
}
}
-HRESULT Thread::Reset(BOOL fFull)
-{
- // !!! Can not use non-static contract here.
- // !!! Contract depends on Thread object for GC_TRIGGERS.
- // !!! At the end of this function, we call InternalSwitchOut,
- // !!! and then GetThread()=NULL, and dtor of contract does not work any more.
- STATIC_CONTRACT_NOTHROW;
- STATIC_CONTRACT_GC_TRIGGERS;
- STATIC_CONTRACT_ENTRY_POINT;
-
- if ( !g_fEEStarted)
- return(E_FAIL);
-
- HRESULT hr = S_OK;
-
- BEGIN_SO_INTOLERANT_CODE_NOPROBE;
-
-#ifdef _DEBUG
- _ASSERTE (GetThread() == this);
-#ifdef _TARGET_X86_
- _ASSERTE (GetExceptionState()->GetContextRecord() == NULL);
-#endif
-#endif
-
- if (GetThread() != this)
- {
- IfFailGo(E_UNEXPECTED);
- }
-
- _ASSERTE (!PreemptiveGCDisabled());
- _ASSERTE (m_pFrame == FRAME_TOP);
- // A host should not recycle a CLRTask if the task is created by us through CreateNewThread.
- // We need to make Thread.Join work for this case.
- if ((m_StateNC & (TSNC_CLRCreatedThread | TSNC_CannotRecycle)) != 0)
- {
- // Todo: wwl better returning code.
- IfFailGo(E_UNEXPECTED);
- }
-
-#ifdef FEATURE_COMINTEROP_APARTMENT_SUPPORT
- if (IsCoInitialized())
- {
- // The current thread has done CoInitialize
- IfFailGo(E_UNEXPECTED);
- }
-#endif
-
-#ifdef _DEBUG
- AddFiberInfo(ThreadTrackInfo_Lifetime);
-#endif
-
- SetThreadState(TS_TaskReset);
-
- if (IsAbortRequested())
- {
- EEResetAbort(Thread::TAR_ALL);
- }
-
- InternalReset(fFull);
-
- if (PreemptiveGCDisabled())
- {
- EnablePreemptiveGC();
- }
-
- {
-
-#ifdef WIN64EXCEPTIONS
- ExceptionTracker::PopTrackers((void*)-1);
-#endif // WIN64EXCEPTIONS
-
- ResetThreadStateNC(TSNC_UnbalancedLocks);
- m_dwLockCount = 0;
-
- InternalSwitchOut();
- m_OSThreadId = SWITCHED_OUT_FIBER_OSID;
- }
-
-ErrExit:
-
- END_SO_INTOLERANT_CODE_NOPROBE;
-
-#ifdef ENABLE_CONTRACTS_DATA
- // Decouple our cache from the Task.
- // Next time, the thread may be run on a different thread.
- if (SUCCEEDED(hr))
- {
- m_pClrDebugState = NULL;
- }
-#endif
-
- return hr;
-}
-
-HRESULT Thread::ExitTask ()
-{
- // !!! Can not use contract here.
- // !!! Contract depends on Thread object for GC_TRIGGERS.
- // !!! At the end of this function, we call InternalSwitchOut,
- // !!! and then GetThread()=NULL, and dtor of contract does not work any more.
- STATIC_CONTRACT_NOTHROW;
- STATIC_CONTRACT_GC_TRIGGERS;
- STATIC_CONTRACT_ENTRY_POINT;
-
- if ( !g_fEEStarted)
- return(E_FAIL);
-
- HRESULT hr = S_OK;
-
- // <TODO> We need to probe here, but can't introduce destructors etc.</TODO>
- BEGIN_CONTRACT_VIOLATION(SOToleranceViolation);
-
- //OnThreadTerminate(FALSE);
- _ASSERTE (this == GetThread());
- _ASSERTE (!PreemptiveGCDisabled());
-
- // Can not assert the following. SQL may call ExitTask after addref and abort a task.
- //_ASSERTE (m_UnmanagedRefCount == 0);
- if (this != GetThread())
- IfFailGo(HOST_E_INVALIDOPERATION);
-
-#ifdef FEATURE_COMINTEROP_APARTMENT_SUPPORT
- if (IsCoInitialized())
- {
- // This thread has used ole32. We need to balance CoInitialize call on this thread.
- // We also need to free any COM objects created on this thread.
-
- // If we don't do this work, ole32 is going to do the same during its DLL_THREAD_DETACH,
- // and may re-enter CLR.
- CleanupCOMState();
- }
-#endif
- m_OSThreadId = SWITCHED_OUT_FIBER_OSID;
- hr = DetachThread(FALSE);
- // !!! Do not touch any field of Thread object. The Thread object is subject to delete
- // !!! after DetachThread call.
-ErrExit:;
-
- END_CONTRACT_VIOLATION;
-
- return hr;
-}
-
HRESULT Thread::Abort ()
{
CONTRACTL
@@ -10230,15 +9726,6 @@ HRESULT Thread::LocksHeld(SIZE_T *pLockCount)
return S_OK;
}
-HRESULT Thread::SetTaskIdentifier(TASKID asked)
-{
- LIMITED_METHOD_CONTRACT;
-
- // @todo: Should be check for uniqueness?
- m_TaskId = asked;
- return S_OK;
-}
-
HRESULT Thread::BeginPreventAsyncAbort()
{
WRAPPER_NO_CONTRACT;
@@ -10250,7 +9737,6 @@ HRESULT Thread::BeginPreventAsyncAbort()
#ifdef _DEBUG
ASSERT(count > 0);
- AddFiberInfo(ThreadTrackInfo_Abort);
FastInterlockIncrement((LONG*)&m_dwDisableAbortCheckCount);
#endif
@@ -10269,7 +9755,6 @@ HRESULT Thread::EndPreventAsyncAbort()
#ifdef _DEBUG
ASSERT(count >= 0);
- AddFiberInfo(ThreadTrackInfo_Abort);
FastInterlockDecrement((LONG*)&m_dwDisableAbortCheckCount);
#endif
@@ -10287,9 +9772,6 @@ ULONG Thread::AddRef()
_ASSERTE (m_UnmanagedRefCount != (DWORD) -1);
ULONG ref = FastInterlockIncrement((LONG*)&m_UnmanagedRefCount);
-#ifdef _DEBUG
- AddFiberInfo(ThreadTrackInfo_Lifetime);
-#endif
return ref;
}
@@ -10301,9 +9783,6 @@ ULONG Thread::Release()
_ASSERTE (m_ExternalRefCount > 0);
_ASSERTE (m_UnmanagedRefCount > 0);
ULONG ref = FastInterlockDecrement((LONG*)&m_UnmanagedRefCount);
-#ifdef _DEBUG
- AddFiberInfo(ThreadTrackInfo_Lifetime);
-#endif
return ref;
}
diff --git a/src/vm/threads.h b/src/vm/threads.h
index 444d4d48d7..44a30b0b5b 100644
--- a/src/vm/threads.h
+++ b/src/vm/threads.h
@@ -162,7 +162,6 @@ struct HelperMethodFrameCallerList;
class ThreadLocalIBCInfo;
class EECodeInfo;
class DebuggerPatchSkip;
-class MethodCallGraphPreparer;
class FaultingExceptionFrame;
class ContextTransitionFrame;
enum BinderMethodID : int;
@@ -206,22 +205,6 @@ public:
StackingAllocator m_MarshalAlloc;
-private:
- MethodCallGraphPreparer * m_pCerPreparationState;
-
-public:
- MethodCallGraphPreparer * GetCerPreparationState()
- {
- LIMITED_METHOD_CONTRACT;
- return m_pCerPreparationState;
- }
-
- void SetCerPreparationState(MethodCallGraphPreparer * pCerPreparationState)
- {
- LIMITED_METHOD_CONTRACT;
- m_pCerPreparationState = pCerPreparationState;
- }
-
private:
LoadLevelLimiter *m_pLoadLimiter;
@@ -1189,7 +1172,7 @@ public:
TSNC_OSAlertableWait = 0x00001000, // Preparing abort. This avoids recursive HandleThreadAbort call.
TSNC_ADUnloadHelper = 0x00002000, // This thread is AD Unload helper.
TSNC_CreatingTypeInitException = 0x00004000, // Thread is trying to create a TypeInitException
- TSNC_InTaskSwitch = 0x00008000, // A task is switching
+ // unused = 0x00008000,
TSNC_AppDomainContainUnhandled = 0x00010000, // Used to control how unhandled exception reporting occurs.
// See detailed explanation for this bit in threads.cpp
TSNC_InRestoringSyncBlock = 0x00020000, // The thread is restoring its SyncBlock for Object.Wait.
@@ -1246,14 +1229,6 @@ public:
DAC_EMPTY_RET(0);
STDMETHODIMP_(ULONG) Release(void)
DAC_EMPTY_RET(0);
- STDMETHODIMP SwitchIn(HANDLE threadHandle)
- DAC_EMPTY_RET(E_FAIL);
- STDMETHODIMP SwitchOut()
- DAC_EMPTY_RET(E_FAIL);
- STDMETHODIMP Reset (BOOL fFull)
- DAC_EMPTY_RET(E_FAIL);
- STDMETHODIMP ExitTask()
- DAC_EMPTY_RET(E_FAIL);
STDMETHODIMP Abort()
DAC_EMPTY_RET(E_FAIL);
STDMETHODIMP RudeAbort()
@@ -1265,17 +1240,12 @@ public:
DAC_EMPTY_RET(E_FAIL);
STDMETHODIMP LocksHeld(SIZE_T *pLockCount)
DAC_EMPTY_RET(E_FAIL);
- STDMETHODIMP SetTaskIdentifier(TASKID asked)
- DAC_EMPTY_RET(E_FAIL);
STDMETHODIMP BeginPreventAsyncAbort()
DAC_EMPTY_RET(E_FAIL);
STDMETHODIMP EndPreventAsyncAbort()
DAC_EMPTY_RET(E_FAIL);
- STDMETHODIMP SetLocale(LCID lcid);
- STDMETHODIMP SetUILocale(LCID lcid);
-
void InternalReset (BOOL fFull, BOOL fNotFinalizerThread=FALSE, BOOL fThreadObjectResetNeeded=TRUE, BOOL fResetAbort=TRUE);
INT32 ResetManagedThreadObject(INT32 nPriority);
INT32 ResetManagedThreadObjectInCoopMode(INT32 nPriority);
@@ -1284,8 +1254,6 @@ private:
//Helpers for reset...
void FullResetThread();
public:
- void InternalSwitchOut();
-
HRESULT DetachThread(BOOL fDLLThreadDetach);
void SetThreadState(ThreadState ts)
@@ -2722,24 +2690,6 @@ public:
return m_OSThreadId;
}
- TASKID GetTaskId()
- {
- LIMITED_METHOD_CONTRACT;
- return m_TaskId;
- }
- CONNID GetConnectionId()
- {
- LIMITED_METHOD_CONTRACT;
- return m_dwConnectionId;
- }
-
-
- void SetConnectionId(CONNID dwConnectionId)
- {
- LIMITED_METHOD_CONTRACT;
- m_dwConnectionId = dwConnectionId;
- }
-
BOOL IsThreadPoolThread()
{
LIMITED_METHOD_CONTRACT;
@@ -4012,11 +3962,6 @@ private:
UINT_PTR m_LastAllowableStackAddress;
private:
-
- // Save the domain when a task is switched out, and restore it when
- // the task is switched in.
- PTR_AppDomain m_pDomainAtTaskSwitch;
-
//---------------------------------------------------------------
// m_debuggerFilterContext holds the thread's "filter context" for the
// debugger. This filter context is used by the debugger to seed
@@ -4508,69 +4453,13 @@ public:
size_t *m_pCleanedStackBase;
#endif
-private:
- PVOID m_pFiberData;
-
- TASKID m_TaskId;
- CONNID m_dwConnectionId;
-
-public:
- void SetupFiberData();
-
-#ifdef _DEBUG
-public:
- void AddFiberInfo(DWORD type);
- enum {
- ThreadTrackInfo_Lifetime=0x1, // creation, destruction, ref-count
- ThreadTrackInfo_Schedule=0x2, // switch in/out
- ThreadTrackInfo_UM_M=0x4, // Unmanaged <-> managed transtion
- ThreadTrackInfo_Abort=0x8, // Thread abort
- ThreadTrackInfo_Affinity=0x10, // Thread's affinity
- ThreadTrackInfo_GCMode=0x20,
- ThreadTrackInfo_Escalation=0x40,// escalation point
- ThreadTrackInfo_SO=0x80,
- ThreadTrackInfo_Max=8
- };
-private:
- static int MaxThreadRecord;
- static int MaxStackDepth;
- static const int MaxThreadTrackInfo;
- struct FiberSwitchInfo
- {
- unsigned __int64 timeStamp;
- DWORD threadID;
- size_t callStack[1];
- };
- FiberSwitchInfo *m_pFiberInfo[ThreadTrackInfo_Max];
- DWORD m_FiberInfoIndex[ThreadTrackInfo_Max];
-#endif
-
#ifdef DACCESS_COMPILE
public:
void EnumMemoryRegions(CLRDataEnumMemoryFlags flags);
void EnumMemoryRegionsWorker(CLRDataEnumMemoryFlags flags);
#endif
-private:
- // Head of a linked list of opaque records that record if and how the thread is currently preparing a
- // graph of methods for CER usage. This is used to determine if a re-entrant preparation request should
- // complete immediately as a no-op (because it would lead to an infinite recursion) or should proceed
- // recursively.
- MethodCallGraphPreparer * m_pCerPreparationState;
-
public:
- MethodCallGraphPreparer * GetCerPreparationState()
- {
- LIMITED_METHOD_CONTRACT;
- return m_pCerPreparationState;
- }
-
- void SetCerPreparationState(MethodCallGraphPreparer * pCerPreparationState)
- {
- LIMITED_METHOD_CONTRACT;
- m_pCerPreparationState = pCerPreparationState;
- }
-
// Is the current thread currently executing within a constrained execution region?
static BOOL IsExecutingWithinCer();
diff --git a/src/vm/threadsuspend.cpp b/src/vm/threadsuspend.cpp
index fd070a666d..67acec280a 100644
--- a/src/vm/threadsuspend.cpp
+++ b/src/vm/threadsuspend.cpp
@@ -1370,9 +1370,6 @@ Thread::UserAbort(ThreadAbortRequester requester,
CONTRACTL_END;
STRESS_LOG2(LF_SYNC | LF_APPDOMAIN, LL_INFO100, "UserAbort Thread %p Thread Id = %x\n", this, GetThreadId());
-#ifdef _DEBUG
- AddFiberInfo(ThreadTrackInfo_Abort);
-#endif
BOOL fHoldingThreadStoreLock = ThreadStore::HoldingThreadStore();
@@ -2441,10 +2438,6 @@ void Thread::MarkThreadForAbort(ThreadAbortRequester requester, EEPolicy::Thread
// The thread is asked for abort the first time
SetAbortRequestBit();
-
-#ifdef _DEBUG
- AddFiberInfo(ThreadTrackInfo_Abort);
-#endif
}
STRESS_LOG4(LF_APPDOMAIN, LL_ALWAYS, "Mark Thread %p Thread Id = %x for abort from requester %d (type %d)\n", this, GetThreadId(), requester, abortType);
}
@@ -2575,10 +2568,6 @@ void Thread::UnmarkThreadForAbort(ThreadAbortRequester requester, BOOL fForce)
FastInterlockAnd((DWORD*)&m_State,~(TS_AbortInitiated));
m_fRudeAbortInitiated = FALSE;
ResetUserInterrupted();
-
-#ifdef _DEBUG
- AddFiberInfo(ThreadTrackInfo_Abort);
-#endif
}
STRESS_LOG3(LF_APPDOMAIN, LL_ALWAYS, "Unmark Thread %p Thread Id = %x for abort from requester %d\n", this, GetThreadId(), requester);
@@ -2597,9 +2586,6 @@ void Thread::InternalResetAbort(ThreadAbortRequester requester, BOOL fResetRudeA
// managed code can not reset Rude thread abort
UnmarkThreadForAbort(requester, fResetRudeAbort);
-#ifdef _DEBUG
- AddFiberInfo(ThreadTrackInfo_Abort);
-#endif
}
@@ -2847,11 +2833,6 @@ void Thread::RareDisablePreemptiveGC()
goto Exit;
}
-
-#ifdef _DEBUG
- AddFiberInfo(ThreadTrackInfo_GCMode);
-#endif
-
// This should NEVER be called if the TSNC_UnsafeSkipEnterCooperative bit is set!
_ASSERTE(!(m_StateNC & TSNC_UnsafeSkipEnterCooperative) && "DisablePreemptiveGC called while the TSNC_UnsafeSkipEnterCooperative bit is set");
@@ -3145,9 +3126,6 @@ void Thread::HandleThreadAbort (BOOL fForce)
exceptObj = CLRException::GetThrowableFromException(&eeExcept);
}
-#ifdef _DEBUG
- AddFiberInfo(ThreadTrackInfo_Abort);
-#endif
RaiseTheExceptionInternalOnly(exceptObj, FALSE);
}
END_SO_INTOLERANT_CODE;
@@ -3282,10 +3260,6 @@ void Thread::RareEnablePreemptiveGC()
if (IsAtProcessExit())
return;
-#ifdef _DEBUG
- AddFiberInfo(ThreadTrackInfo_GCMode);
-#endif
-
// EnablePreemptiveGC already set us to preemptive mode before triggering the Rare path.
// Force other threads to see this update, since the Rare path implies that someone else
// is observing us (e.g. SuspendRuntime).