return NULL;
}
-EXTERN_C Thread* GetThread()
+Thread* GetThread()
{
// In dac mode it's unlikely that the thread calling dac
// is actually the same "current thread" that the runtime cares
return NULL;
}
+Thread* GetThreadNULLOk()
+{
+ return GetThread();
+}
+
BOOL
DacGetThreadContext(Thread* thread, T_CONTEXT* context)
{
//-----------------------------------------------------------------------------
void HelperCanary::TakeLocks()
{
- _ASSERTE(::GetThread() == NULL); // Canary Thread should always be outside the runtime.
+ _ASSERTE(::GetThreadNULLOk() == NULL); // Canary Thread should always be outside the runtime.
_ASSERTE(m_CanaryThreadId == GetCurrentThreadId());
// Call new, which will take whatever standard heap locks there are.
// Either this is the helper thread, or we're manipulating our own context.
_ASSERTE(
ThisIsHelperThreadWorker() ||
- (thread == ::GetThread())
+ (thread == ::GetThreadNULLOk())
);
CONTEXT *context = GetManagedStoppedCtx(thread);
MODE_ANY;
// Filter context not set yet b/c we can only set it in COOP, and this may be in preemptive.
- PRECONDITION(thread == ::GetThread());
+ PRECONDITION(thread == ::GetThreadNULLOk());
PRECONDITION((g_pEEInterface->GetThreadFilterContext(thread) == NULL));
PRECONDITION(CheckPointer(pException));
}
// 2. Create a "stack walking" implementation for native code and use it to get the current IP and
// set the IP to the right place.
- Thread *thread = GetThread();
+ Thread *thread = GetThreadNULLOk();
if (thread != NULL)
{
BYTE *patchBypass = m_pSharedPatchBypassBuffer->PatchBypass;
// toggled the GC mode underneath us.
MODE_ANY;
- PRECONDITION(GetThread() == thread);
+ PRECONDITION(GetThreadNULLOk() == thread);
PRECONDITION(thread != NULL);
PRECONDITION(CheckPointer(context));
}
"\n", fp.GetSPValue(), this ));
Thread *thread = GetThread();
-
-
CONTEXT *context = g_pEEInterface->GetThreadFilterContext(thread);
ControllerStackInfo info;
LOG((LF_CORDB, LL_INFO10000, "DS::SE m_fpStepInto:0x%x\n", m_fpStepInto.GetSPValue()));
_ASSERTE(m_fReadyToSend);
- _ASSERTE(GetThread() == thread);
+ _ASSERTE(GetThreadNULLOk() == thread);
CONTEXT *context = g_pEEInterface->GetThreadFilterContext(thread);
_ASSERTE(!ISREDIRECTEDTHREAD(thread));
//
Thread * pThread;
bool fIsCooperative;
- BEGIN_GETTHREAD_ALLOWED;
+
pThread = g_pEEInterface->GetThread();
fIsCooperative = (pThread != NULL) && (pThread->PreemptiveGCDisabled());
- END_GETTHREAD_ALLOWED;
+
if (m_fShutdownMode && !fIsCooperative)
{
// The big fear is that some other random thread will take the debugger-lock and then block on something else,
// We're in some Controller's Filter after hitting an exception.
// We're not stopped.
//_ASSERTE(!g_pDebugger->IsStopped()); <-- @todo - this fires, need to find out why.
- _ASSERTE(GetThread() == pThread);
+ _ASSERTE(GetThreadNULLOk() == pThread);
CONTEXT *pCtx = g_pEEInterface->GetThreadFilterContext(pThread);
#endif // _DEBUG
}
-
-// This is a notification from the EE it's about to go to fiber mode.
-// This is given *before* it actually goes to fiber mode.
-HRESULT Debugger::SetFiberMode(bool isFiberMode)
-{
- CONTRACTL
- {
- NOTHROW;
- GC_NOTRIGGER;
-
- // Notifications from EE never come on helper worker.
- PRECONDITION(!ThisIsHelperThreadWorker());
- }
- CONTRACTL_END;
-
-
- Thread * pThread = ::GetThread();
-
- m_pRCThread->m_pDCB->m_bHostingInFiber = isFiberMode;
-
- // If there is a debugger already attached, then we have a big problem. As of V2.0, the debugger
- // does not support debugging processes with fibers in them. We set the unrecoverable state to
- // indicate that we're in a bad state now. The debugger will notice this, and take appropiate action.
- if (isFiberMode && CORDebuggerAttached())
- {
- LOG((LF_CORDB, LL_INFO10, "Thread has entered fiber mode while debugger attached.\n"));
-
- EX_TRY
- {
- // We send up a MDA for two reasons: 1) we want to give the user some chance to see what went wrong,
- // and 2) we want to get the Right Side to notice that we're in an unrecoverable error state now.
-
- SString szName(W("DebuggerFiberModeNotSupported"));
- SString szDescription;
- szDescription.LoadResource(CCompRC::Debugging, MDARC_DEBUGGER_FIBER_MODE_NOT_SUPPORTED);
- SString szXML(W(""));
-
- // Sending any debug event will be a GC violation.
- // However, if we're enabling fiber-mode while a debugger is attached, we're already doomed.
- // Deadlocks and AVs are just around the corner. A Gc-violation is the least of our worries.
- // We want to at least notify the debugger at all costs.
- CONTRACT_VIOLATION(GCViolation);
-
- // As soon as we set unrecoverable error in the LS, the RS will pick it up and basically shut down.
- // It won't dispatch any events. So we fire the MDA first, and then set unrecoverable error.
- SendMDANotification(pThread, &szName, &szDescription, &szXML, (CorDebugMDAFlags) 0, FALSE);
-
- CORDBDebuggerSetUnrecoverableError(this, CORDBG_E_CANNOT_DEBUG_FIBER_PROCESS, false);
-
- // Fire the MDA again just to force the RS to sniff the LS and pick up that we're in an unrecoverable error.
- // No harm done from dispatching an MDA twice. And
- SendMDANotification(pThread, &szName, &szDescription, &szXML, (CorDebugMDAFlags) 0, FALSE);
-
- }
- EX_CATCH
- {
- LOG((LF_CORDB, LL_INFO10, "Error sending MDA regarding fiber mode.\n"));
- }
- EX_END_CATCH(SwallowAllExceptions);
- }
-
- return S_OK;
-}
-
// Checks if the MethodInfos table has been allocated, and if not does so.
// Throw on failure, so we always return
HRESULT Debugger::CheckInitMethodInfoTable()
// This ensures the debuggee is actually stopped at startup, and
// this gives the debugger a chance to call SetDesiredNGENFlags before we
// set s_fCanChangeNgenFlags to FALSE.
- _ASSERTE(GetThread() != NULL);
+ _ASSERTE(GetThreadNULLOk() != NULL);
SENDIPCEVENT_RAW_END;
pDbgLockHolder->Acquire();
GC_NOTRIGGER;
MODE_PREEMPTIVE;
- PRECONDITION(pThread == GetThread());
+ PRECONDITION(pThread == GetThreadNULLOk());
PRECONDITION(ThreadHoldsLock());
DebuggerEval *pDE = pfe->pDE;
_ASSERTE(pDE->m_evalDuringException);
- _ASSERTE(pDE->m_thread == GetThread());
+ _ASSERTE(pDE->m_thread == GetThreadNULLOk());
// Remove the pending eval from the hash. This ensures that if we take a first chance exception during the eval
// that we can do another nested eval properly.
LOG((LF_CORDB, LL_INFO10000, "D::FCE: First chance exception, TID:0x%x, \n", GetThreadIdHelper(pThread)));
- _ASSERTE(GetThread() != NULL);
+ _ASSERTE(GetThreadNULLOk() != NULL);
#ifdef _DEBUG
static ConfigDWORD d_fce;
// @@@
// Implements DebugInterface
// Call by EE/exception. Must be on managed thread
- _ASSERTE(GetThread() != NULL);
+ _ASSERTE(GetThreadNULLOk() != NULL);
// Quick check.
if (!CORDebuggerAttached())
{
CONTRACTL
{
- if ((GetThread() == NULL) || g_pEEInterface->IsThreadExceptionNull(GetThread()))
+ if ((GetThreadNULLOk() == NULL) || g_pEEInterface->IsThreadExceptionNull(GetThread()))
{
NOTHROW;
GC_NOTRIGGER;
// useful information for the debugger and, in fact, it may be a completely
// internally handled runtime exception, so we should do nothing.
//
- if ((GetThread() == NULL) || g_pEEInterface->IsThreadExceptionNull(GetThread()))
+ if ((GetThreadNULLOk() == NULL) || g_pEEInterface->IsThreadExceptionNull(GetThread()))
{
return EXCEPTION_CONTINUE_SEARCH;
}
MODE_ANY;
PRECONDITION(thread != NULL);
- PRECONDITION(thread == ::GetThread());
+ PRECONDITION(thread == ::GetThreadNULLOk());
}
CONTRACTL_END;
CONTRACTL
{
NOTHROW;
- if (GetThread()) { GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
+ if (GetThreadNULLOk()) { GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
}
CONTRACTL_END;
if (g_fProcessDetach)
return true;
- BEGIN_GETTHREAD_ALLOWED;
if (g_pEEInterface->GetThread())
{
return (GetThreadIdHelper(g_pEEInterface->GetThread()) == m_mutexOwner);
{
return (GetCurrentThreadId() == m_mutexOwner);
}
- END_GETTHREAD_ALLOWED;
}
#endif // _DEBUG_IMPL
BOOL ShouldAutoAttach();
BOOL FallbackJITAttachPrompt();
- HRESULT SetFiberMode(bool isFiberMode);
HRESULT AddAppDomainToIPC (AppDomain *pAppDomain);
HRESULT RemoveAppDomainFromIPC (AppDomain *pAppDomain);
if ((m_pRCThread == NULL) || !m_pRCThread->IsRCThreadReady()) { THROWS; } else { NOTHROW; }
#define MAY_DO_HELPER_THREAD_DUTY_GC_TRIGGERS_CONTRACT \
- if ((m_pRCThread == NULL) || !m_pRCThread->IsRCThreadReady() || (GetThread() != NULL)) { GC_TRIGGERS; } else { GC_NOTRIGGER; }
+ if ((m_pRCThread == NULL) || !m_pRCThread->IsRCThreadReady() || (GetThreadNULLOk() != NULL)) { GC_TRIGGERS; } else { GC_NOTRIGGER; }
#define GC_TRIGGERS_FROM_GETJITINFO if (GetThreadNULLOk() != NULL) { GC_TRIGGERS; } else { GC_NOTRIGGER; }
// If we're tracing ourselves, we must be in managed code.
// Native user code can't initiate a managed stackwalk.
- if (pThread == GetThread())
+ if (pThread == GetThreadNULLOk())
{
return false;
}
// We need to get thread's context (InitRegDisplay will do that under the covers).
// If this is our thread, we're in bad shape. Fortunately that should never happen.
- _ASSERTE(thread != GetThread());
+ _ASSERTE(thread != GetThreadNULLOk());
Thread::SuspendThreadResult str = thread->SuspendThread();
if (str != Thread::STR_Success)
// then it's ok for this function to as well. If LIMITED_METHOD_CONTRACT is specified,
// however, then CANNOT_TAKE_LOCK is assumed.
//
-// EE_THREAD_NOT_REQUIRED the function does not assume an EE Thread object is available in TLS.
-// Either GetThread() is never called, or any code path that requires a Thread
-// has another code path that deals with the absence of a Thread. Any call to
-// to GetThread() must be bracketed with BEGIN_GETTHREAD_ALLOWED /
-// END_GETTHREAD_ALLOWED to avoid bogus asserts (the short-form
-// GetThreadNULLOk() may be used as well). However, this is only allowed if visual
-// inspection of the call site makes it patently obvious that the function deals
-// appropriately with the GetThread() == NULL case.
-// -or- EE_THREAD_REQUIRED the function requires an EE Thread object in TLS (i.e., GetThread() != NULL)
-// If this contract is used, we will ASSERT on entry to the function that
-// GetThread() != NULL.
-// -or- the default is DISABLED(EE_THREAD_REQUIRED). i.e., we do not assert
-// GetThread() != NULL on entry to the function and do not assert on any
-// unprotected uses of GetThread().
-// See code:GetThreadGenericFullCheck for info on how these
-// contracts are enforced.
//
// SUPPORTS_DAC The function has been written to be callable from out-of-process using DAC.
// In builds where DACCESS_COMPILE is defined, such functions can only call
#define CONTRACT_BITMASK_SOTOLERANT 0x1 << 3
#define CONTRACT_BITMASK_DEBUGONLY 0x1 << 4
#define CONTRACT_BITMASK_SONOTMAINLINE 0x1 << 5
-#define CONTRACT_BITMASK_ALLOWGETTHREAD 0x1 << 6
-#define CONTRACT_BITMASK_OK_TO_LOCK 0x1 << 7
-#define CONTRACT_BITMASK_OK_TO_RETAKE_LOCK 0x1 << 8
+#define CONTRACT_BITMASK_OK_TO_LOCK 0x1 << 6
+#define CONTRACT_BITMASK_OK_TO_RETAKE_LOCK 0x1 << 7
#define CONTRACT_BITMASK_IS_SET(whichbit) ((m_flags & (whichbit)) != 0)
m_flags = CONTRACT_BITMASK_OK_TO_THROW|
CONTRACT_BITMASK_HOSTCALLS|
CONTRACT_BITMASK_SOTOLERANT|
- CONTRACT_BITMASK_ALLOWGETTHREAD|
CONTRACT_BITMASK_OK_TO_LOCK|
CONTRACT_BITMASK_OK_TO_RETAKE_LOCK;
}
//--//
- BOOL IsGetThreadAllowed()
- {
- return CONTRACT_BITMASK_IS_SET(CONTRACT_BITMASK_ALLOWGETTHREAD);
-
- }
- void SetGetThreadAllowed()
- {
- CONTRACT_BITMASK_SET(CONTRACT_BITMASK_ALLOWGETTHREAD);
- }
-
-
- BOOL SetGetThreadAllowed(BOOL value)
- {
- BOOL prevState = CONTRACT_BITMASK_IS_SET(CONTRACT_BITMASK_ALLOWGETTHREAD);
- CONTRACT_BITMASK_UPDATE(CONTRACT_BITMASK_ALLOWGETTHREAD,value);
- return prevState;
- }
-
- void ResetGetThreadAllowed()
- {
- CONTRACT_BITMASK_RESET(CONTRACT_BITMASK_ALLOWGETTHREAD);
- }
-
- //--//
BOOL IsOkToLock()
{
return CONTRACT_BITMASK_IS_SET(CONTRACT_BITMASK_OK_TO_LOCK);
HOST_NoCalls = 0x00001000,
HOST_Disabled = 0x00000000, // the default
- // This enforces the EE_THREAD_NOT_REQUIRED contract by clearing
- // ClrDebugState::m_allowGetThread in its scope. That causes raw calls
- // to GetThread() to assert, unless inside a temporary "don't worry it's ok" scope
- // via BEGIN/END_GETTHREAD_ALLOWED. Useful for enforcing our docs that
- // state certain unmanaged API entrypoints (e.g., some from profiling API)
- // are callable without an EE Thread in TLS.
- EE_THREAD_Mask = 0x0000C000,
- EE_THREAD_Disabled = 0x00000000, // the default
- EE_THREAD_Required = 0x00004000,
- EE_THREAD_Not_Required = 0x00008000,
-
// These enforce the CAN_TAKE_LOCK / CANNOT_TAKE_LOCK contracts
CAN_TAKE_LOCK_Mask = 0x00060000,
CAN_TAKE_LOCK_Yes = 0x00020000,
LOADS_TYPE_Disabled = 0x00000000, // the default
ALL_Disabled = THROWS_Disabled|GC_Disabled|FAULT_Disabled|MODE_Disabled|LOADS_TYPE_Disabled|
- HOST_Disabled|EE_THREAD_Disabled|CAN_TAKE_LOCK_Disabled|CAN_RETAKE_LOCK_No_Disabled
+ HOST_Disabled|CAN_TAKE_LOCK_Disabled|CAN_RETAKE_LOCK_No_Disabled
};
LoadsTypeViolation = 0x00000040, // suppress LOADS_TYPE tags in this scope
TakesLockViolation = 0x00000080, // suppress CAN_TAKE_LOCK tags in this scope
HostViolation = 0x00000100, // suppress HOST_CALLS tags in this scope
- EEThreadViolation = 0x00000200, // suppress EE_THREAD_REQUIRED tags in this scope
//These are not violation bits. We steal some bits out of the violation mask to serve as
// general flag bits.
}
#endif
-#ifdef ENABLE_CONTRACTS_IMPL
-
-class GetThreadAllowedHolder
-{
- public:
- GetThreadAllowedHolder(BOOL newState)
- {
- m_clrDebugState = ::GetClrDebugState();
- m_previousState = m_clrDebugState->SetGetThreadAllowed(newState);
- }
-
- ~GetThreadAllowedHolder()
- {
- m_clrDebugState->SetGetThreadAllowed(m_previousState);
- }
-
-private:
- BOOL m_previousState;
- ClrDebugState* m_clrDebugState;
-};
-
-// When in an EE_THREAD_NOT_REQUIRED contracted scope, it's expected that the
-// function does not assume an EE Thread object is available in TLS. Either
-// GetThread() is never called, or any code path that requires a Thread
-// has another code path that deals with the absence of a Thread. Any call to
-// to GetThread() must be bracketed with BEGIN_GETTHREAD_ALLOWED /
-// END_GETTHREAD_ALLOWED to avoid bogus asserts (the short-form
-// GetThreadNULLOk() may be used as well). However, this is only allowed if visual
-// inspection of the call site makes it patently obvious that the function deals
-// appropriately with the GetThread() == NULL case (or that case has already been
-// dealt with and control has exited before the BEGIN_GETTHREAD_ALLOWED /
-// END_GETTHREAD_ALLOWED block.
-//
-// These use holder objects, which causes the compiler to generate EH code and prevent
-// inlining. So try to avoid these in small, downstream functions (like inline
-// EE Thread member functions). Use the _IN_NO_THROW_REGION variants below instead.
-
-#define BEGIN_GETTHREAD_ALLOWED \
- { \
- GetThreadAllowedHolder __getThreadAllowedHolder(TRUE); \
-
-#define END_GETTHREAD_ALLOWED \
- }
-
-// These are lighter-weight versions of BEGIN_GETTHREAD_ALLOWED /
-// END_GETTHREAD_ALLOWED. These don't use holders, so be sure only to
-// use these to bracket code that won't throw exceptions
-#define BEGIN_GETTHREAD_ALLOWED_IN_NO_THROW_REGION \
- { \
- ClrDebugState * __clrDebugState = ::GetClrDebugState(); \
- BOOL __previousState = __clrDebugState->SetGetThreadAllowed(TRUE); \
-
-#define END_GETTHREAD_ALLOWED_IN_NO_THROW_REGION \
- __clrDebugState->SetGetThreadAllowed(__previousState); \
- }
-
-#else // ENABLE_CONTRACTS_IMPL
-#define BEGIN_GETTHREAD_ALLOWED
-#define END_GETTHREAD_ALLOWED
-#define BEGIN_GETTHREAD_ALLOWED_IN_NO_THROW_REGION
-#define END_GETTHREAD_ALLOWED_IN_NO_THROW_REGION
-#endif
#if defined(ENABLE_CONTRACTS_IMPL)
// Special define to be used in EEStartup that will also check for VM initialization before
// commencing on a path that may use the managed thread object.
#define RethrowTerminalExceptionsWithInitCheck \
- if ((g_fEEStarted == TRUE) && (GetThread() != NULL)) \
+ if ((g_fEEStarted == TRUE) && (GetThreadNULLOk() != NULL)) \
{ \
RethrowTerminalExceptions \
}
{
LIMITED_METHOD_CONTRACT;
- Thread * pThread = GetThread();
+ Thread * pThread = GetThreadNULLOk();
// We may not have a managed thread object. Example is an AV on the helper thread.
// (perhaps during StubManager::IsStub)
int WriteBarrierManager::ChangeWriteBarrierTo(WriteBarrierType newWriteBarrier, bool isRuntimeSuspended)
{
- GCX_MAYBE_COOP_NO_THREAD_BROKEN((!isRuntimeSuspended && GetThread() != NULL));
+ GCX_MAYBE_COOP_NO_THREAD_BROKEN((!isRuntimeSuspended && GetThreadNULLOk() != NULL));
int stompWBCompleteActions = SWB_PASS;
if (!isRuntimeSuspended && m_currentWriteBarrier != WRITE_BARRIER_UNINITIALIZED)
{
mov r14, rdi
// Get current thread and cache it in current frame
- call C_FUNC(GetThread)
+ call C_FUNC(GetThreadHelper)
mov qword ptr [r14 + OFFSETOF__InlinedCallFrame__m_pThread], rax
// pFrame->m_Next = pThread->m_pFrame;
// yet).
// TODO: we should really not running managed DLLMain during process detach.
- if (GetThread() == NULL)
+ if (GetThreadNULLOk() == NULL)
{
return;
}
STANDARD_VM_CONTRACT;
Thread* pThread = GetThread();
- _ASSERTE(pThread);
-
if(state == Thread::AS_InSTA)
{
Thread::ApartmentState pState = pThread->SetApartment(Thread::AS_InSTA);
CONTRACTL
{
THROWS;
- if (GetThread()) {GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
+ if (GetThreadNULLOk()) {GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
MODE_ANY;
INJECT_FAULT(COMPlusThrowOM(););
}
CONTRACT (LPCWSTR)
{
THROWS;
- if (GetThread()) {GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
+ if (GetThreadNULLOk()) {GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
MODE_ANY;
POSTCONDITION(CheckPointer(RETVAL, NULL_OK));
INJECT_FAULT(COMPlusThrowOM(););
CONTRACT (LPCWSTR)
{
NOTHROW;
- if (GetThread()) {GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
+ if (GetThreadNULLOk()) {GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
MODE_ANY;
POSTCONDITION(CheckPointer(RETVAL));
}
LOG((LF_APPDOMAIN, LL_INFO10, "AppDomain::ExceptionUnwind for %8.8x\n", pFrame));
Thread *pThread = GetThread();
- _ASSERTE(pThread);
LOG((LF_APPDOMAIN, LL_INFO10, "AppDomain::ExceptionUnwind: not first transition or abort\n"));
}
void Activate()
{
WRAPPER_NO_CONTRACT;
- m_previousLimit=GetThread()->GetLoadLevelLimiter();
+ m_previousLimit= GetThread()->GetLoadLevelLimiter();
if(m_previousLimit)
m_currentLevel=m_previousLimit->GetLoadLevel();
GetThread()->SetLoadLevelLimiter(this);
{
LIMITED_METHOD_CONTRACT;
- Thread * pThread = GetThread();
+ Thread * pThread = GetThreadNULLOk();
// We may not have a managed thread object. Example is an AV on the helper thread.
// (perhaps during StubManager::IsStub)
str r9, [r4, #InlinedCallFrame__m_pSPAfterProlog]
// r0 = GetThread()
- bl C_FUNC(GetThread)
+ bl C_FUNC(GetThreadHelper)
str r0, [r4, #InlinedCallFrame__m_pThread]
// pFrame->m_Next = pThread->m_pFrame;
{
#ifdef TARGET_UNIX
- ThumbEmitMovConstant(ThumbReg(0), (TADDR)GetThread);
+ ThumbEmitMovConstant(ThumbReg(0), (TADDR)GetThreadHelper);
ThumbEmitCallRegister(ThumbReg(0));
str x9, [x19, #InlinedCallFrame__m_pCalleeSavedFP]
// x0 = GetThread()
- bl C_FUNC(GetThread)
+ bl C_FUNC(GetThreadHelper)
str x0, [x19, #InlinedCallFrame__m_pThread]
// pFrame->m_Next = pThread->m_pFrame;
{
LIMITED_METHOD_CONTRACT;
- Thread * pThread = GetThread();
+ Thread * pThread = GetThreadNULLOk();
// We may not have a managed thread object. Example is an AV on the helper thread.
// (perhaps during StubManager::IsStub)
{
LIMITED_METHOD_CONTRACT;
- _ASSERTE(GetThread() != 0);
+ _ASSERTE(GetThreadNULLOk() != 0);
g_fWeControlLifetime = TRUE;
}
GC_TRIGGERS;
MODE_ANY;
INJECT_FAULT(COMPlusThrowOM(););
- PRECONDITION(CheckPointer(GetThread()));
+ PRECONDITION(CheckPointer(GetThreadNULLOk()));
}
CONTRACTL_END
CONTRACTL_END;
#ifndef DACCESS_COMPILE
- _ASSERTE (GetThread ());
+ _ASSERTE (GetThreadNULLOk());
TRIGGERSGC ();
// Force a GC here because GetClass could trigger GC nondeterminsticly
if (g_pConfig->GetGCStressLevel() != 0)
{
DEBUG_ONLY_REGION();
- Thread * pThread = GetThread ();
+ Thread * pThread = GetThread();
BOOL bInCoopMode = pThread->PreemptiveGCDisabled ();
GCX_COOP ();
if (bInCoopMode)
}
CONTRACTL_END;
- _ASSERTE(GetThread() == TieredCompilationManager::GetBackgroundWorkerThread());
+ _ASSERTE(GetThreadNULLOk() == TieredCompilationManager::GetBackgroundWorkerThread());
AppDomain *appDomain = GetAppDomain();
TieredCompilationManager *tieredCompilationManager = appDomain->GetTieredCompilationManager();
}
CONTRACTL_END;
- _ASSERTE(GetThread() == TieredCompilationManager::GetBackgroundWorkerThread());
+ _ASSERTE(GetThreadNULLOk() == TieredCompilationManager::GetBackgroundWorkerThread());
// If a number of call counting stubs have completed, we can try to delete them to reclaim some memory. Deleting
// involves suspending the runtime and will delete all call counting stubs, and after that some call counting stubs may
}
CONTRACTL_END;
- _ASSERTE(GetThread() == TieredCompilationManager::GetBackgroundWorkerThread());
+ _ASSERTE(GetThreadNULLOk() == TieredCompilationManager::GetBackgroundWorkerThread());
_ASSERTE(MethodDescBackpatchInfoTracker::IsLockOwnedByCurrentThread());
_ASSERTE(CodeVersionManager::IsLockOwnedByCurrentThread());
_ASSERTE(tieredCompilationManager != nullptr);
DWORD_PTR ObjRefTable[OBJREF_TABSIZE];
curThread = GetThread();
- _ASSERTE(curThread != NULL);
static_assert_no_msg(sizeof(curThread->dangerousObjRefs) == sizeof(ObjRefTable));
memcpy(ObjRefTable, curThread->dangerousObjRefs, sizeof(ObjRefTable));
// We are shutting down. GC triggers does not have any effect now.
CONTRACT_VIOLATION(GCViolation);
- Thread *pThread = GetThread();
+ Thread *pThread = GetThreadNULLOk();
// After a thread is blocked in WaitForEndOfShutdown, the thread should not enter runtime again,
// and block at WaitForEndOfShutdown again.
if (pThread)
#if defined(FEATURE_COMINTEROP)
// Get the current thread.
- Thread * pThisThread = GetThread();
+ Thread * pThisThread = GetThreadNULLOk();
#endif
// If the process is detaching then set the global state.
#endif
}
- if (GetThread())
+ if (GetThreadNULLOk())
{
GCX_COOP();
EEShutDownHelper(fIsDllUnloading);
// Don't destroy threads here if we're in shutdown (shutdown will
// clean up for us instead).
- Thread* thread = GetThread();
+ Thread* thread = GetThreadNULLOk();
if (thread)
{
#ifdef FEATURE_COMINTEROP
InlineSString<LOCALE_NAME_MAX_LENGTH> sParentCulture;
#if 0 // Enable and test if/once the unmanaged runtime is localized
- Thread * pThread = GetThread();
+ Thread * pThread = GetThreadNULLOk();
// When fatal errors have occured our invariants around GC modes may be broken and attempting to transition to co-op may hang
// indefinately. We want to ensure a clean exit so rather than take the risk of hang we take a risk of the error resource not
int Result = 0;
- Thread * pThread = GetThread();
+ Thread * pThread = GetThreadNULLOk();
#if 0 // Enable and test if/once the unmanaged runtime is localized
// When fatal errors have occured our invariants around GC modes may be broken and attempting to transition to co-op may hang
*pcBuildingInterfaceList = 0;
*ppBuildingInterfaceList = NULL;
- // Get the thread for stacking allocator
- Thread *pThread = GetThread();
-
// Get the metadata for enumerating the interfaces of the class
IMDInternalImport *pMDImport = GetModule()->GetMDImport();
HRESULT hr = S_OK;
DWORD i;
- Thread *pThread = GetThread();
// resolve unresolved interfaces, determine an upper bound on the size of the interface map,
// and determine the size of the largest interface (in # slots)
// laying out the method table.
if(bmtInterface->pdwOriginalStart == NULL)
{
- Thread *pThread = GetThread();
bmtInterface->pdwOriginalStart = new (GetStackingAllocator()) DWORD[bmtInterface->dwMaxExpandedInterfaces];
memset(bmtInterface->pdwOriginalStart, 0, sizeof(DWORD)*bmtInterface->dwMaxExpandedInterfaces);
}
}
CONTRACTL_END;
- Thread* pThread = GetThread();
-
// Can't have a throwable without a Thread.
- _ASSERTE(pThread != NULL);
+ Thread* pThread = GetThread();
if (NULL == pException)
{
if (m_pThread != NULL)
{
- BEGIN_GETTHREAD_ALLOWED;
+
// If there is no frame to unwind, UnwindFrameChain call is just an expensive NOP
// due to setting up and tear down of EH records. So we avoid it if we can.
if (m_pThread->GetFrame() < m_pFrame)
else
m_pThread->EnablePreemptiveGC();
}
- END_GETTHREAD_ALLOWED;
+
}
// Make sure to call the base class's CleanupTry so it can do whatever it wants to do.
if (g_fEEStarted)
{
- pThread = GetThread();
+ pThread = GetThreadNULLOk();
exceptionCode = GetCurrentExceptionCode();
}
}
CONTRACTL_END;
- _ASSERTE(GetThread() != NULL);
+ _ASSERTE(GetThreadNULLOk() != NULL);
ProtectArgsStruct prot;
memset(&prot, 0, sizeof(ProtectArgsStruct));
CONTRACTL_END;
// If the Thread has been set up, then the LastThrownObject may make sense...
- if (GetThread())
+ if (GetThreadNULLOk())
{
// give back an object that knows about Threads and their exceptions.
*ppException = new CLRLastThrownObjectException();
#define PAL_SEH_RESTORE_GUARD_PAGE \
if (__exCode == STATUS_STACK_OVERFLOW) \
{ \
- Thread *__pThread = GetThread(); \
+ Thread *__pThread = GetThreadNULLOk(); \
if (__pThread != NULL) \
{ \
__pThread->RestoreGuardPage(); \
STRESS_LOG1(LF_EH, LL_INFO100, \
"EX_RETHROW " INDEBUG(__FILE__) " line %d\n", __LINE__); \
__pException.SuppressRelease(); \
- if ((!__state.DidCatchCxx()) && (GetThread() != NULL)) \
+ if ((!__state.DidCatchCxx()) && (GetThreadNULLOk() != NULL)) \
{ \
if (GetThread()->PreemptiveGCDisabled()) \
{ \
{ \
HRESULT *__phr = (phresult); \
*__phr = S_OK; \
- _ASSERTE(GetThread() == NULL || \
+ _ASSERTE(GetThreadNULLOk() == NULL || \
!GetThread()->PreemptiveGCDisabled()); \
MAKE_CURRENT_THREAD_AVAILABLE_EX(GetThreadNULLOk()); \
if (CURRENT_THREAD == NULL) \
#ifndef DACCESS_COMPILE
- Thread* thread = GetThread();
+ Thread* thread = GetThreadNULLOk();
if (thread == NULL)
{
//
// If this instantiation doesn't have a unique home then use the ngen module
// OK, we're certainly NGEN'ing. And if we're NGEN'ing then we're not on the debugger thread.
- CONSISTENCY_CHECK(((GetThread() && GetAppDomain()) || IsGCThread()) &&
+ CONSISTENCY_CHECK(((GetThreadNULLOk() && GetAppDomain()) || IsGCThread()) &&
"unexpected: running a load on debug thread but IsCompilationProcess() returned TRUE");
// Save it into its PreferredZapModule if it's always going to be saved there.
} CONTRACTL_END;
#if !defined(DACCESS_COMPILE) && !defined(CROSSGEN_COMPILE)
- BEGIN_GETTHREAD_ALLOWED;
+
- Thread *pThread = GetThread();
+ Thread *pThread = GetThreadNULLOk();
if (!pThread)
return ScanNoReaderLock;
if (pThread->PreemptiveGCDisabled() || (pThread == ThreadSuspend::GetSuspensionThread()))
return ScanNoReaderLock;
- END_GETTHREAD_ALLOWED;
+
return ScanReaderLock;
#else
CONTRACTL_END;
CtxEntry * pCtxEntry = NULL;
- Thread * pThread = GetThread();
// If we don't already have a context entry for the context cookie,
// we need to create one.
pSTAThread = pThread;
}
- ASSERT (GetThread ());
+ ASSERT (GetThreadNULLOk ());
BOOL bFound = FALSE;
ACQUIRE_SPINLOCK_NO_HOLDER(&m_Lock);
CONTRACTL_END;
// Log the de-allocation of the IUnknown entry.
- LOG((LF_INTEROP, LL_INFO10000, "IUnkEntry::Free called for context 0x%08X, to release entry with m_pUnknown %p, on thread %p\n", m_pCtxCookie, m_pUnknown, GetThread()));
+ LOG((LF_INTEROP, LL_INFO10000, "IUnkEntry::Free called for context 0x%08X, to release entry with m_pUnknown %p, on thread %p\n", m_pCtxCookie, m_pUnknown, GetThreadNULLOk()));
if (g_fProcessDetach)
{
CtxEntryEnterContextCallbackData *pData = (CtxEntryEnterContextCallbackData*)pComCallData->pUserDefined;
- Thread *pThread = GetThread();
+ Thread *pThread = GetThreadNULLOk();
// Make sure the thread has been set before we call the user callback function.
if (!pThread)
PRECONDITION(IsProtectedByGCFrame(pComObj));
PRECONDITION(!m_typeHandle.IsNull());
PRECONDITION(m_typeHandle.IsComObjectType());
- PRECONDITION(m_pThread == GetThread());
+ PRECONDITION(m_pThread == GetThreadNULLOk());
PRECONDITION(pIncomingItfMT == NULL || pIncomingItfMT->IsInterface());
}
CONTRACTL_END;
THROWS;
GC_TRIGGERS;
MODE_COOPERATIVE;
- PRECONDITION(m_pThread == GetThread());
+ PRECONDITION(m_pThread == GetThreadNULLOk());
PRECONDITION(pIncomingItfMT == NULL || pIncomingItfMT->IsInterface());
}
CONTRACTL_END;
typedef DPTR(OBJECTREF) PTR_OBJECTREF;
typedef DPTR(PTR_OBJECTREF) PTR_PTR_OBJECTREF;
-EXTERN_C Thread* STDCALL GetThread();
+Thread* GetThread();
+Thread* GetThreadNULLOk();
+
+EXTERN_C Thread* STDCALL GetThreadHelper();
+
void SetThread(Thread*);
// This is a mechanism by which macros can make the Thread pointer available to inner scopes
//
if (SUCCEEDED(hr)) {
#ifdef _DEBUG
- Thread *pThread = GetThread();
+ Thread *pThread = GetThreadNULLOk();
_ASSERTE(pThread);
#endif
// we need a thread adjustment, before setting up the frame.
//
Thread *pThread = GetThread();
- _ASSERTE (pThread);
INT32 priority = pThread->ResetManagedThreadObjectInCoopMode(ThreadNative::PRIORITY_NORMAL);
VOID NTAPI RegisterWaitForSingleObjectCallback(PVOID delegateInfo, BOOLEAN TimerOrWaitFired)
{
- Thread* pThread = GetThread();
+ Thread* pThread = GetThreadNULLOk();
if (pThread == NULL)
{
ClrFlsSetThreadType(ThreadType_Threadpool_Worker);
_ASSERTE(hWaitHandle);
Thread* pCurThread = GetThread();
- _ASSERTE( pCurThread);
DelegateInfoHolder delegateInfo = DelegateInfo::MakeDelegateInfo(
&gc.state,
LPOVERLAPPED lpOverlapped,
BOOL setStack)
{
- Thread* pThread = GetThread();
+ Thread* pThread = GetThreadNULLOk();
if (pThread == NULL)
{
// TODO: how do we notify user of OOM here?
VOID WINAPI AppDomainTimerCallback(PVOID callbackState, BOOLEAN timerOrWaitFired)
{
- Thread* pThread = GetThread();
+ Thread* pThread = GetThreadNULLOk();
if (pThread == NULL)
{
// TODO: how do we notify user of OOM here?
//
HRESULT hr = S_OK;
- pThread = GetThread();
+ pThread = GetThreadNULLOk();
if (pThread == NULL)
{
pThread = SetupThreadNoThrow();
EXCEPTION_POINTERS* retVal = NULL;
Thread *pThread = GetThread();
- _ASSERTE(pThread);
-
if (pThread->IsExceptionInProgress())
{
retVal = pThread->GetExceptionState()->GetExceptionPointers();
INT32 retVal = 0;
Thread *pThread = GetThread();
- _ASSERTE(pThread);
-
if (pThread->IsExceptionInProgress())
{
retVal = pThread->GetExceptionState()->GetExceptionCode();
{
CONTRACTL {
NOTHROW;
- PRECONDITION(CheckPointer(GetThread()));
if (GetThread()->PreemptiveGCDisabled()) { GC_NOTRIGGER; } else { GC_TRIGGERS; }
} CONTRACTL_END;
{
CONTRACTL {
NOTHROW;
- PRECONDITION(CheckPointer(GetThread()));
if (GetThread()->PreemptiveGCDisabled()) { GC_NOTRIGGER; } else { GC_TRIGGERS; }
PRECONDITION(id <= TypeIDProvider::MAX_TYPE_ID);
} CONTRACTL_END;
{
NOTHROW;
ENTRY_POINT; // We're bringing the EE down, so no point in probing
- if (GetThread()) {GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
+ if (GetThreadNULLOk()) {GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
}
CONTRACTL_END;
if (!g_fEEStarted)
}
else
{
- Thread *pThread = GetThread();
+ Thread *pThread = GetThreadNULLOk();
if (!pThread)
{
hr = E_UNEXPECTED;
AppDomain *pCurDomain = SystemDomain::GetCurrentDomain();
- Thread *pThread = GetThread();
+ Thread *pThread = GetThreadNULLOk();
if (pThread == NULL)
{
pThread = SetupThreadNoThrow(&hr);
BEGIN_ENTRYPOINT_NOTHROW;
- Thread *pThread = GetThread();
+ Thread *pThread = GetThreadNULLOk();
if (pThread == NULL)
{
pThread = SetupThreadNoThrow(&hr);
CONTRACTL
{
NOTHROW;
- if (GetThread()) {GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
+ if (GetThreadNULLOk()) {GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
ENTRY_POINT; // This is called by a host.
}
CONTRACTL_END;
CONTRACTL
{
NOTHROW;
- if (GetThread()) {GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
+ if (GetThreadNULLOk()) {GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
ENTRY_POINT; // This is called by a host.
}
CONTRACTL_END;
CONTRACTL
{
NOTHROW;
- if (GetThread()) {GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
+ if (GetThreadNULLOk()) {GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
ENTRY_POINT; // This is called by a host.
}
CONTRACTL_END;
CONTRACTL
{
NOTHROW;
- if (GetThread()) {GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
+ if (GetThreadNULLOk()) {GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
ENTRY_POINT; // This is called by a host.
}
CONTRACTL_END;
CONTRACTL
{
NOTHROW;
- if (GetThread()) {GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
+ if (GetThreadNULLOk()) {GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
ENTRY_POINT; // This is called by a host.
}
CONTRACTL_END;
CONTRACTL
{
NOTHROW;
- if (GetThread()) {GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
+ if (GetThreadNULLOk()) {GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
ENTRY_POINT; // This is called by a host.
}
CONTRACTL_END;
// Note: Sampling profilers also use this function to initialize TLS for a unmanaged
// sampling thread so that initialization can be done in advance to avoid deadlocks.
// See ProfToEEInterfaceImpl::InitializeCurrentThread for more details.
-void SetupTLSForThread(Thread* pThread)
+void SetupTLSForThread()
{
STATIC_CONTRACT_THROWS;
STATIC_CONTRACT_GC_NOTRIGGER;
Thread * pThread;
BOOL fToggle;
- BEGIN_GETTHREAD_ALLOWED;
- pThread = GetThread();
+ pThread = GetThreadNULLOk();
fToggle = ((m_dwFlags & (CRST_UNSAFE_ANYMODE | CRST_UNSAFE_COOPGC | CRST_GC_NOTRIGGER_WHEN_TAKEN)) == 0) // condition normally false
&& pThread && pThread->PreemptiveGCDisabled();
if (fToggle) {
pThread->EnablePreemptiveGC();
}
- END_GETTHREAD_ALLOWED;
#ifdef _DEBUG
PreEnter ();
if (fToggle)
{
- BEGIN_GETTHREAD_ALLOWED;
+
pThread->DisablePreemptiveGC();
- END_GETTHREAD_ALLOWED;
+
}
}
#endif //_DEBUG
#if defined(_DEBUG)
- Thread * pThread = GetThread();
+ Thread * pThread = GetThreadNULLOk();
#endif
LeaveCriticalSection(&m_criticalsection);
// If there is no thread object, we ignore the check since this thread isn't
// coordinated with the GC.
Thread * pThread;
- BEGIN_GETTHREAD_ALLOWED;
- pThread = GetThread();
+
+ pThread = GetThreadNULLOk();
_ASSERTE(pThread == NULL ||
(pThread->PreemptiveGCDisabled() == ((m_dwFlags & CRST_UNSAFE_COOPGC) != 0)) ||
((m_dwFlags & (CRST_UNSAFE_ANYMODE | CRST_GC_NOTRIGGER_WHEN_TAKEN)) != 0) ||
(GCHeapUtilities::IsGCInProgress() && pThread == ThreadSuspend::GetSuspensionThread()));
- END_GETTHREAD_ALLOWED;
+
if (m_holderthreadid.IsCurrentThread())
{
_ASSERTE((pCrst->m_dwFlags & CRST_REENTRANCY) == 0);
Thread *pThread = GetThread();
- _ASSERTE(pThread != nullptr);
if (pThread->IsInForbidSuspendForDebuggerRegion())
{
AcquireLock(pCrst);
virtual BOOL ShouldAutoAttach() = 0;
virtual BOOL FallbackJITAttachPrompt() = 0;
- virtual HRESULT SetFiberMode(bool isFiberMode) = 0;
#ifdef FEATURE_INTEROP_DEBUGGING
virtual LONG FirstChanceSuspendHijackWorker(PCONTEXT pContext, PEXCEPTION_RECORD pExceptionRecord) = 0;
CONTRACTL_END;
Thread * pThread = GetThread();
- _ASSERTE(pThread != NULL);
-
UINT_PTR address = NULL;
CONTEXT ctx;
return(pMD->GetSig());
}
-Thread * CurrentThreadInfo ()
-{
- CONTRACTL
- {
- NOTHROW;
- GC_NOTRIGGER;
- }
- CONTRACTL_END;
-
- return GetThread ();
-}
-
SyncBlock *GetSyncBlockForObject(UINT_PTR obj)
{
CONTRACTL
DEBUG_ONLY;
GC_NOTRIGGER;
ENTRY_POINT;
- if (GetThread()) MODE_PREEMPTIVE; else MODE_ANY;
+ if (GetThreadNULLOk()) MODE_PREEMPTIVE; else MODE_ANY;
DEBUG_ONLY;
PRECONDITION(CheckPointer(thunk));
- PRECONDITION((GetThread() != NULL) ? (!GetThread()->PreemptiveGCDisabled()) : TRUE);
+ PRECONDITION((GetThreadNULLOk() != NULL) ? (!GetThread()->PreemptiveGCDisabled()) : TRUE);
}
CONTRACTL_END;
if (IsError())
return FALSE;
- Thread *pThread;
- pThread = GetThread();
- _ASSERTE(pThread);
-
+ Thread *pThread = GetThread();
switch (level)
{
case FILE_LOAD_BEGIN:
GenericModeBlock gmb;
// Make sure this is (or at least has been) a managed thread.
- Thread *pThread = GetThread();
+ Thread *pThread = GetThreadNULLOk();
if (pThread == NULL)
{ // Not the greatest error, but we don't expect to be called on a unmanaged thread.
return E_UNEXPECTED;
// Many of the checks below result in calls to GetThread()
// that work just fine if GetThread() returns NULL, so temporarily
// allow such calls.
- BEGIN_GETTHREAD_ALLOWED_IN_NO_THROW_REGION;
- m_pThread = GetThread();
+ m_pThread = GetThreadNULLOk();
m_pClrDebugState = GetClrDebugState();
// Call our base DoChecks.
default:
UNREACHABLE();
}
- END_GETTHREAD_ALLOWED_IN_NO_THROW_REGION;
-
- // EE Thread-required check
- // NOTE: The following must NOT be inside BEGIN/END_GETTHREAD_ALLOWED,
- // as the change to m_pClrDebugState->m_allowGetThread below would be
- // overwritten by END_GETTHREAD_ALLOWED.
- switch (testmask & EE_THREAD_Mask)
- {
- case EE_THREAD_Required:
- if (!((EEThreadViolation|BadDebugState) & m_pClrDebugState->ViolationMask()))
- {
- if (m_pThread == NULL)
- {
- CONTRACT_ASSERT("EE_THREAD_REQUIRED encountered with no current EE Thread object in TLS.",
- Contract::EE_THREAD_Required,
- Contract::EE_THREAD_Mask,
- m_contractStackRecord.m_szFunction,
- m_contractStackRecord.m_szFile,
- m_contractStackRecord.m_lineNum
- );
- }
- else if (!m_pClrDebugState->IsGetThreadAllowed())
- {
- // In general, it's unsafe for an EE_THREAD_NOT_REQUIRED function to
- // call an EE_THREAD_REQUIRED function. In cases where it is safe,
- // you may wrap the call to the EE_THREAD_REQUIRED function inside a
- // BEGIN/END_GETTHREAD_ALLOWED block, but you may only do so if the
- // case where GetThread() == NULL is clearly handled in a way that
- // prevents entry into the BEGIN/END_GETTHREAD_ALLOWED block.
- CONTRACT_ASSERT("EE_THREAD_REQUIRED encountered in an EE_THREAD_NOT_REQUIRED scope, without an intervening BEGIN/END_GETTHREAD_ALLOWED block.",
- Contract::EE_THREAD_Required,
- Contract::EE_THREAD_Mask,
- m_contractStackRecord.m_szFunction,
- m_contractStackRecord.m_szFile,
- m_contractStackRecord.m_lineNum
- );
- }
- }
- m_pClrDebugState->SetGetThreadAllowed();
- break;
-
- case EE_THREAD_Not_Required:
- m_pClrDebugState->ResetGetThreadAllowed();
- break;
-
- case EE_THREAD_Disabled:
- break;
-
- default:
- UNREACHABLE();
- }
}
#endif // ENABLE_CONTRACTS
#define GC_TRIGGERS do { STATIC_CONTRACT_GC_TRIGGERS; REQUEST_TEST(Contract::GC_Triggers, Contract::GC_Disabled); } while(0)
#define GC_NOTRIGGER do { STATIC_CONTRACT_GC_NOTRIGGER; REQUEST_TEST(Contract::GC_NoTrigger, Contract::GC_Disabled); } while(0)
-// Notice there's no static contract component to this. It's
-// perfectly reasonable to find EE_THREAD_REQUIRED inside the scope of
-// EE_THREAD_NOT_REQUIRED (e.g., an EE_THREAD_NOT_REQUIRED scope can have two
-// possible code paths--one with an EE Thread and one without). So we can't do
-// any meaningful testing statically. It's all gotta be done at runtime.
-#define EE_THREAD_NOT_REQUIRED \
- do { REQUEST_TEST(Contract::EE_THREAD_Not_Required, Contract::EE_THREAD_Disabled); } while(0)
-
-#define EE_THREAD_REQUIRED do { REQUEST_TEST(Contract::EE_THREAD_Required, Contract::EE_THREAD_Disabled); } while(0)
-
#define HOST_NOCALLS do { STATIC_CONTRACT_HOST_NOCALLS; REQUEST_TEST(Contract::HOST_NoCalls, Contract::HOST_Disabled); } while(0)
#define HOST_CALLS do { STATIC_CONTRACT_HOST_CALLS; REQUEST_TEST(Contract::HOST_Calls, Contract::HOST_Disabled); } while(0)
#define GC_NOTRIGGER
#define HOST_NOCALLS
#define HOST_CALLS
-#define EE_THREAD_NOT_REQUIRED
-#define EE_THREAD_REQUIRED
-
#endif // ENABLE_CONTRACTS_IMPL
+#define EE_THREAD_NOT_REQUIRED
+
// Replace the CONTRACT macro with the EE version
#undef CONTRACT
#define CONTRACT(_returntype) CUSTOM_CONTRACT(EEContract, _returntype)
CONTRACT_END;
#endif
- return ::GetThread();
+ return ::GetThreadNULLOk();
}
#ifndef DACCESS_COMPILE
CONTRACTL_END
#if defined(_DEBUG) && !defined(CROSSGEN_COMPILE)
- BEGIN_GETTHREAD_ALLOWED;
- Thread * pThread = GetThread();
+ Thread * pThread = GetThreadNULLOk();
_ASSERTE(!g_fEEStarted || (pThread == NULL) || (pThread->PreemptiveGCDisabled()));
- END_GETTHREAD_ALLOWED;
#endif
// Make the new bucket table 4 times bigger
STRESS_LOG0(LF_EH, LL_INFO100, "In EEPolicy::HandleStackOverflow\n");
- Thread *pThread = GetThread();
-
+ Thread *pThread = GetThreadNULLOk();
if (pThread == NULL)
{
// For security reason, it is not safe to continue execution if stack overflow happens
static Thread *volatile s_pCrashingThread = FatalErrorNotSeenYet;
- Thread *pThread = GetThread();
+ Thread *pThread = GetThreadNULLOk();
Thread *pPreviousThread = InterlockedCompareExchangeT<Thread *>(&s_pCrashingThread, pThread, FatalErrorNotSeenYet);
if (pPreviousThread == pThread)
{
#ifdef DEBUGGING_SUPPORTED
//Give a managed debugger a chance if this fatal error is on a managed thread.
- Thread *pThread = GetThread();
+ Thread *pThread = GetThreadNULLOk();
if (pThread && !g_fFatalErrorOccuredOnGCThread)
{
{
DisplayStackOverflowException();
- HandleHolder stackDumpThreadHandle = Thread::CreateUtilityThread(Thread::StackSize_Small, LogStackOverflowStackTraceThread, GetThread(), W(".NET Stack overflow trace logger"));
+ HandleHolder stackDumpThreadHandle = Thread::CreateUtilityThread(Thread::StackSize_Small, LogStackOverflowStackTraceThread, GetThreadNULLOk(), W(".NET Stack overflow trace logger"));
if (stackDumpThreadHandle != INVALID_HANDLE_VALUE)
{
// Wait for the stack trace logging completion
if (!fSkipDebugger)
{
- Thread *pThread = GetThread();
+ Thread *pThread = GetThreadNULLOk();
BOOL fTreatAsNativeUnhandledException = FALSE;
if (pThread)
{
// because debugger is going to take CrstDebuggerMutex, whose lock level is higher than that of
// CrstThreadStore. It should be safe to release the lock since execution will not be resumed
// after fatal errors.
- if (ThreadStore::HoldingThreadStore(GetThread()))
+ if (ThreadStore::HoldingThreadStore(GetThreadNULLOk()))
{
ThreadSuspend::UnlockThreadStore();
}
// CLR_TO_PROFILER_ENTRYPOINT (typical choice)
// This is used for calling ICorProfilerCallback* methods that either have no
// ThreadID parameters, or if they do have a ThreadID parameter, the parameter's
-// value is always the *current* ThreadID (i.e., param == GetThread()). This will
+// value is always the *current* ThreadID (i.e., param == GetThreadNULLOk()). This will
// also force a mode switch to preemptive before calling the profiler.
// CLR_TO_PROFILER_ENTRYPOINT_FOR_THREAD
// Similar to above, except these are used for ICorProfilerCallback* methods that
// specify a ThreadID parameter whose value may not always be the *current*
// ThreadID. You must specify the ThreadID as the first parameter to these
// macros. The macro will then use your ThreadID rather than that of the current
-// GetThread(), to assert that the callback is currently allowed for that
+// GetThreadNULLOk(), to assert that the callback is currently allowed for that
// ThreadID (i.e., that we have not yet issued a ThreadDestroyed() for that
// ThreadID).
//
LL_INFO1000,
"**PROF: ExceptionThrown. ObjectID: 0x%p. ThreadID: 0x%p\n",
thrownObjectId,
- GetThread()));
+ GetThreadNULLOk()));
{
// All callbacks are really NOTHROW, but that's enforced partially by the profiler,
CLR_TO_PROFILER_ENTRYPOINT((LF_CORPROF,
LL_INFO1000,
"**PROF: ExceptionSearchFunctionEnter. ThreadID: 0x%p, functionId: 0x%p\n",
- GetThread(),
+ GetThreadNULLOk(),
functionId));
{
CLR_TO_PROFILER_ENTRYPOINT((LF_CORPROF,
LL_INFO1000,
"**PROF: ExceptionSearchFunctionLeave. ThreadID: 0x%p\n",
- GetThread()));
+ GetThreadNULLOk()));
{
// All callbacks are really NOTHROW, but that's enforced partially by the profiler,
CLR_TO_PROFILER_ENTRYPOINT((LF_CORPROF,
LL_INFO1000,
"**PROF: ExceptionSearchFilterEnter. ThreadID: 0x%p, functionId: 0x%p\n",
- GetThread(),
+ GetThreadNULLOk(),
functionId));
{
CLR_TO_PROFILER_ENTRYPOINT((LF_CORPROF,
LL_INFO1000,
"**PROF: ExceptionFilterLeave. ThreadID: 0x%p\n",
- GetThread()));
+ GetThreadNULLOk()));
{
// All callbacks are really NOTHROW, but that's enforced partially by the profiler,
CLR_TO_PROFILER_ENTRYPOINT((LF_CORPROF,
LL_INFO1000,
"**PROF: ExceptionSearchCatcherFound. ThreadID: 0x%p\n",
- GetThread()));
+ GetThreadNULLOk()));
{
// All callbacks are really NOTHROW, but that's enforced partially by the profiler,
(LF_CORPROF,
LL_INFO1000,
"**PROF: ExceptionUnwindFunctionEnter. ThreadID: 0x%p, functionId: 0x%p\n",
- GetThread(),
+ GetThreadNULLOk(),
functionId));
{
(LF_CORPROF,
LL_INFO1000,
"**PROF: ExceptionUnwindFunctionLeave. ThreadID: 0x%p\n",
- GetThread()));
+ GetThreadNULLOk()));
{
// All callbacks are really NOTHROW, but that's enforced partially by the profiler,
(LF_CORPROF,
LL_INFO1000,
"**PROF: ExceptionUnwindFinallyEnter. ThreadID: 0x%p, functionId: 0x%p\n",
- GetThread(),
+ GetThreadNULLOk(),
functionId));
{
(LF_CORPROF,
LL_INFO1000,
"**PROF: ExceptionUnwindFinallyLeave. ThreadID: 0x%p\n",
- GetThread()));
+ GetThreadNULLOk()));
{
// All callbacks are really NOTHROW, but that's enforced partially by the profiler,
kEE2PNoTrigger,
(LF_CORPROF,
LL_INFO1000, "**PROF: ExceptionCatcherEnter. ThreadID: 0x%p, functionId: 0x%p\n",
- GetThread(),
+ GetThreadNULLOk(),
functionId));
{
CLR_TO_PROFILER_ENTRYPOINT((LF_CORPROF,
LL_INFO1000,
"**PROF: ExceptionCatcherLeave. ThreadID: 0x%p\n",
- GetThread()));
+ GetThreadNULLOk()));
{
(LF_CORPROF,
LL_INFO100,
"**PROF: RuntimeSuspendStarted. ThreadID 0x%p.\n",
- GetThread()));
+ GetThreadNULLOk()));
{
// All callbacks are really NOTHROW, but that's enforced partially by the profiler,
(LF_CORPROF,
LL_INFO100,
"**PROF: RuntimeSuspendFinished. ThreadID 0x%p.\n",
- GetThread()));
+ GetThreadNULLOk()));
{
(LF_CORPROF,
LL_INFO100,
"**PROF: RuntimeSuspendAborted. ThreadID 0x%p.\n",
- GetThread()));
+ GetThreadNULLOk()));
{
// All callbacks are really NOTHROW, but that's enforced partially by the profiler,
CLR_TO_PROFILER_ENTRYPOINT((LF_CORPROF,
LL_INFO100,
"**PROF: RuntimeResumeStarted. ThreadID 0x%p.\n",
- GetThread()));
+ GetThreadNULLOk()));
{
// All callbacks are really NOTHROW, but that's enforced partially by the profiler,
CLR_TO_PROFILER_ENTRYPOINT((LF_CORPROF,
LL_INFO100,
"**PROF: RuntimeResumeFinished. ThreadID 0x%p.\n",
- GetThread()));
+ GetThreadNULLOk()));
{
// All callbacks are really NOTHROW, but that's enforced partially by the profiler,
// (4) from occurring until 3) is completely done. It's sufficient to determine we're in 3) by noting
// whether the callback is reporting that a thread is "suspending itself" (i.e., suspendedThreadId == threadId)
- ForbidSuspendThreadHolder forbidSuspendThread((Thread *) suspendedThreadId == GetThread());
+ ForbidSuspendThreadHolder forbidSuspendThread((Thread *) suspendedThreadId == GetThreadNULLOk());
{
// All callbacks are really NOTHROW, but that's enforced partially by the profiler,
CLR_TO_PROFILER_ENTRYPOINT((LF_CORPROF,
LL_INFO1000,
"**PROF: RemotingClientInvocationStarted. ThreadID: 0x%p\n",
- GetThread()));
+ GetThreadNULLOk()));
{
// All callbacks are really NOTHROW, but that's enforced partially by the profiler,
CLR_TO_PROFILER_ENTRYPOINT((LF_CORPROF,
LL_INFO1000,
"**PROF: RemotingClientSendingMessage. ThreadID: 0x%p\n",
- GetThread()));
+ GetThreadNULLOk()));
{
// All callbacks are really NOTHROW, but that's enforced partially by the profiler,
CLR_TO_PROFILER_ENTRYPOINT((LF_CORPROF,
LL_INFO1000,
"**PROF: RemotingClientReceivingReply. ThreadID: 0x%p\n",
- GetThread()));
+ GetThreadNULLOk()));
{
// All callbacks are really NOTHROW, but that's enforced partially by the profiler,
CLR_TO_PROFILER_ENTRYPOINT((LF_CORPROF,
LL_INFO1000,
"**PROF: RemotingClientInvocationFinished. ThreadID: 0x%p\n",
- GetThread()));
+ GetThreadNULLOk()));
{
// All callbacks are really NOTHROW, but that's enforced partially by the profiler,
CLR_TO_PROFILER_ENTRYPOINT((LF_CORPROF,
LL_INFO1000,
"**PROF: RemotingServerReceivingMessage. ThreadID: 0x%p\n",
- GetThread()));
+ GetThreadNULLOk()));
{
// All callbacks are really NOTHROW, but that's enforced partially by the profiler,
CLR_TO_PROFILER_ENTRYPOINT((LF_CORPROF,
LL_INFO1000,
"**PROF: RemotingServerInvocationStarted. ThreadID: 0x%p\n",
- GetThread()));
+ GetThreadNULLOk()));
{
// All callbacks are really NOTHROW, but that's enforced partially by the profiler,
CLR_TO_PROFILER_ENTRYPOINT((LF_CORPROF,
LL_INFO1000,
"**PROF: RemotingServerInvocationReturned. ThreadID: 0x%p\n",
- GetThread()));
+ GetThreadNULLOk()));
{
// All callbacks are really NOTHROW, but that's enforced partially by the profiler,
CLR_TO_PROFILER_ENTRYPOINT((LF_CORPROF,
LL_INFO1000,
"**PROF: RemotingServerSendingReply. ThreadID: 0x%p\n",
- GetThread()));
+ GetThreadNULLOk()));
{
// All callbacks are really NOTHROW, but that's enforced partially by the profiler,
// so that gc can crawl the stack and do the right thing.
_ASSERTE(pOrigContext);
Thread *pCurThread = GetThread();
- _ASSERTE(pCurThread);
FrameWithCookie<ResumableFrame> resFrame(pOrigContext);
resFrame.Push(pCurThread);
LOG((LF_ENC, LL_INFO100, "EnCModule::ResumeInUpdatedFunction: Resume at EIP=0x%x\n", pNewCodeInfo->GetCodeAddress()));
Thread *pCurThread = GetThread();
- _ASSERTE(pCurThread);
-
pCurThread->SetFilterContext(pContext);
SetIP(pContext, pNewCodeInfo->GetCodeAddress());
ep_rt_thread_get_handle (void)
{
STATIC_CONTRACT_NOTHROW;
- return GetThread ();
+ return GetThreadNULLOk ();
}
static
BEGIN_QCALL;
- Thread *pThread = GetThread();
+ Thread *pThread = GetThreadNULLOk();
if (pThread == NULL || pActivityId == NULL)
{
retVal = 1;
void LogCallstackForEventReporterWorker(EventReporter& reporter)
{
Thread* pThread = GetThread();
- _ASSERTE (pThread);
-
SmallStackSString WordAt;
if (!WordAt.LoadResource(CCompRC::Optional, IDS_ER_WORDAT))
if (ShouldLogInEventLog())
{
- Thread *pThread = GetThread();
+ Thread *pThread = GetThreadNULLOk();
EventReporter reporter(EventReporter::ERT_UnhandledException);
EX_TRY
{
return ETW::SamplingLog::UnInitialized;
}
#endif // TARGET_AMD64
- Thread *pThread = GetThread();
+ Thread *pThread = GetThreadNULLOk();
if (pThread == NULL)
{
return ETW::SamplingLog::UnInitialized;
// When we have a thread context, default to calling the API that requires one which
// reduces the cost of locking.
- if (GetThread() != NULL)
+ if (GetThreadNULLOk() != NULL)
{
LookupOrCreateTypeLoggingInfo(th, &fCreatedNew);
}
CONTRACTL {
NOTHROW;
GC_TRIGGERS;
- PRECONDITION(GetThread() != NULL);
+ PRECONDITION(GetThreadNULLOk() != NULL);
PRECONDITION(GetThread()->GetThrowable() != NULL);
} CONTRACTL_END;
PRECONDITION(IsProtectedByGCFrame(pInnerException));
PRECONDITION(IsProtectedByGCFrame(pInitException));
PRECONDITION(IsProtectedByGCFrame(pThrowable));
- PRECONDITION(CheckPointer(GetThread()));
+ PRECONDITION(CheckPointer(GetThreadNULLOk()));
} CONTRACTL_END;
- Thread *pThread = GetThread();
+ Thread *pThread = GetThreadNULLOk();
*pThrowable = NULL;
// This will make sure to put the thread back to its original state if something
// <TODO>@NICE: At one point, we had the comment:
// (DM) Remove this when shutdown works better.</TODO>
// This test may no longer be necessary. Remove at own peril.
- Thread *pThread = GetThread();
+ Thread *pThread = GetThreadNULLOk();
if (!pThread)
return;
#ifndef TARGET_UNIX // Watson is supported on Windows only
Thread *pThread = GetThread();
- _ASSERTE(pThread);
if (pThread && (currentIP != 0))
{
STATIC_CONTRACT_MODE_COOPERATIVE;
STATIC_CONTRACT_FORBID_FAULT;
- if ( (GetThread() && GetThread()->IsRudeAbort() && GetThread()->IsRudeAbortInitiated())
+ if ( (GetThreadNULLOk() && GetThread()->IsRudeAbort() && GetThread()->IsRudeAbortInitiated())
||IsExceptionOfType(kThreadAbortException, pThrowable)
||IsExceptionOfType(kThreadInterruptedException, pThrowable)) {
return TRUE;
_ASSERTE(pThrowable != NULL);
- Thread *pThread = GetThread();
+ Thread *pThread = GetThreadNULLOk();
if (pThread)
{
}
else
{
- g_pDebugInterface->LaunchDebuggerForUser(GetThread(), pExceptionInfo, FALSE, FALSE);
+ g_pDebugInterface->LaunchDebuggerForUser(GetThreadNULLOk(), pExceptionInfo, FALSE, FALSE);
}
return EXCEPTION_CONTINUE_SEARCH;
{
LIMITED_METHOD_CONTRACT;
- Thread* pThread = GetThread();
-
+ Thread* pThread = GetThreadNULLOk();
if (pThread == NULL)
{
return false;
if (IsComPlusException(pExceptionInfo->ExceptionRecord))
{
// Our exception code. Get the current exception from the thread.
- Thread *pThread = GetThread();
+ Thread *pThread = GetThreadNULLOk();
if (pThread)
{
OBJECTREF throwable;
}
// We don't do anything when this is called from an unmanaged thread.
- Thread *pThread = GetThread();
+ Thread *pThread = GetThreadNULLOk();
#ifdef _DEBUG
static bool bBreakOnUncaught = false;
#ifdef _DEBUG
char buffer[200];
sprintf_s(buffer, 200, "\nInternal error: Uncaught exception was thrown from IP = %p in UnhandledExceptionFilter_Worker on thread 0x%08x\n",
- param.ExceptionEIP, ((GetThread() == NULL) ? NULL : GetThread()->GetThreadId()));
+ param.ExceptionEIP, ((GetThreadNULLOk() == NULL) ? NULL : GetThread()->GetThreadId()));
PrintToStdErrA(buffer);
_ASSERTE(!"Unexpected exception in UnhandledExceptionFilter_Worker");
#endif
return EXCEPTION_CONTINUE_SEARCH;
}
- Thread* pThread = GetThread();
- if (pThread && !GetThread()->HasThreadStateNC(Thread::TSNC_ProcessedUnhandledException))
+ Thread* pThread = GetThreadNULLOk();
+ if (pThread && !pThread->HasThreadStateNC(Thread::TSNC_ProcessedUnhandledException))
{
// Invoke the UEF worker to perform unhandled exception processing
ret = InternalUnhandledExceptionFilter_Worker (pExceptionInfo);
// various runtimes again.
//
// Thus, check if this UEF has already been invoked in context of this thread and runtime and if so, dont invoke it again.
- if (GetThread() && (GetThread()->HasThreadStateNC(Thread::TSNC_ProcessedUnhandledException)))
+ if (GetThreadNULLOk() && (GetThread()->HasThreadStateNC(Thread::TSNC_ProcessedUnhandledException)))
{
LOG((LF_EH, LL_INFO10, "Exiting COMUnhandledExceptionFilter since we have already done UE processing for this thread!\n"));
return retVal;
retVal = InternalUnhandledExceptionFilter(pExceptionInfo);
// If thread object exists, mark that this thread has done unhandled exception processing
- if (GetThread())
+ if (GetThreadNULLOk())
{
LOG((LF_EH, LL_INFO100, "COMUnhandledExceptionFilter: setting TSNC_ProcessedUnhandledException\n"));
GetThread()->SetThreadStateNC(Thread::TSNC_ProcessedUnhandledException);
int suppressSelectiveBreak = false; // to filter for the case where breakOnUncaught == "2"
#endif
- Thread *pThread = GetThread();
+ Thread *pThread = GetThreadNULLOk();
// The following reduces a window for a race during shutdown.
if (!pThread)
LOG((LF_EH, LL_INFO10, "In NotifyAppDomainsOfUnhandledException\n"));
- Thread *pThread = GetThread();
+ Thread *pThread = GetThreadNULLOk();
// The following reduces a window for a race during shutdown.
if (!pThread)
_ASSERTE(!g_fNoExceptions);
Thread* pThread = GetThread();
- _ASSERTE(pThread);
#ifdef _DEBUG
if (CLRConfig::GetConfigValue(CLRConfig::INTERNAL_BreakOnUncaughtException) &&
}
CONTRACTL_END;
- _ASSERTE(GetThread() == pThread);
+ _ASSERTE(GetThreadNULLOk() == pThread);
DWORD exceptionCode = pExceptionRecord->ExceptionCode;
//
// Note these "fake" AVs will be reported by the kernel as reads from
// address 0xF...F so we also use that as a screen.
- Thread* pThread = GetThread();
+ Thread* pThread = GetThreadNULLOk();
if (exceptionCode == STATUS_ACCESS_VIOLATION &&
GCStress<cfg_instr>::IsEnabled() &&
pExceptionRecord->ExceptionInformation[0] == 0 &&
// Even if a debugger is not attached, we must let the debugger handle the exception in case it's coming from a
// patch-skipper.
if ((!IsComPlusException(pExceptionRecord)) &&
- (GetThread() != NULL) &&
+ (GetThreadNULLOk() != NULL) &&
(g_pDebugInterface != NULL) &&
g_pDebugInterface->FirstChanceNativeException(pExceptionRecord,
pContext,
{
LIMITED_METHOD_CONTRACT;
- Thread * pThread = GetThread();
+ Thread * pThread = GetThreadNULLOk();
// We may not have a managed thread object. Example is an AV on the helper thread.
// (perhaps during StubManager::IsStub)
{
MAYBE_FAULT_FORBID_NO_ALLOC((pExceptionInfo->ExceptionRecord->ExceptionCode == STATUS_NO_MEMORY));
- pThread = GetThread();
+ pThread = GetThreadNULLOk();
//
// Since we are in an OOM situation, we test the thread object before logging since if the
//
// @TODO: I'd love a way to call into the debugger with GCX_NOTRIGGER still in scope, and force them to make
// the choice to break the no-trigger region after taking all necessary precautions.
- if (IsDebuggerFault(pExceptionRecord, pExceptionInfo->ContextRecord, pExceptionRecord->ExceptionCode, GetThread()))
+ if (IsDebuggerFault(pExceptionRecord, pExceptionInfo->ContextRecord, pExceptionRecord->ExceptionCode, GetThreadNULLOk()))
{
return EXCEPTION_CONTINUE_EXECUTION;
}
// time, then skip the check for whether or not the AV is in our impl.
// AVs are ok on the Helper thread (for which there is no pThread object,
// and so the AVInRuntime holder doesn't work.
- Thread *pThread = GetThread();
+ Thread *pThread = GetThreadNULLOk();
bool fAVisOk =
(IsDbgHelperSpecialThread() || IsETWRundownSpecialThread() ||
// exceptions on this thread. Indeed, even checking to see if the faulting
// address is in JITted code is problematic if we have no Thread object, since
// this thread will bypass all our locks.
- Thread *pThread = GetThread();
+ Thread *pThread = GetThreadNULLOk();
if (pThread)
{
// 1) The thread object has been set up.
// 2) The thread has an exception on it.
// 3) The exception is the same as the one this filter is called on.
- Thread *pThread = GetThread();
+ Thread *pThread = GetThreadNULLOk();
if ( (pThread == NULL) ||
(pThread->GetExceptionState()->GetContextRecord() == NULL) ||
(GetSP(pThread->GetExceptionState()->GetContextRecord()) != GetSP(pExceptionInfo->ContextRecord) ) )
LIMITED_METHOD_CONTRACT;
Thread *pCurThread = GetThread();
- _ASSERTE(pCurThread);
-
if (pCurThread->GetExceptionState()->IsExceptionInProgress())
{
if (!fIsUnwinding)
GC_TRIGGERS;
MODE_COOPERATIVE;
NOTHROW;
- PRECONDITION(GetThread() != NULL);
+ PRECONDITION(GetThreadNULLOk() != NULL);
}
CONTRACTL_END;
GC_TRIGGERS;
MODE_ANY;
NOTHROW;
- PRECONDITION(GetThread() != NULL);
+ PRECONDITION(GetThreadNULLOk() != NULL);
}
CONTRACTL_END;
GC_TRIGGERS;
MODE_ANY;
NOTHROW;
- PRECONDITION(GetThread() != NULL);
+ PRECONDITION(GetThreadNULLOk() != NULL);
}
CONTRACTL_END;
GC_NOTRIGGER;
MODE_COOPERATIVE;
NOTHROW;
- PRECONDITION(GetThread() != NULL);
+ PRECONDITION(GetThreadNULLOk() != NULL);
PRECONDITION(oThrowable != NULL);
}
CONTRACTL_END;
GC_NOTRIGGER;
MODE_COOPERATIVE;
NOTHROW;
- PRECONDITION(GetThread() != NULL);
+ PRECONDITION(GetThreadNULLOk() != NULL);
PRECONDITION(oPreAllocThrowable != NULL);
PRECONDITION(CLRException::IsPreallocatedExceptionObject(oPreAllocThrowable));
PRECONDITION(IsWatsonEnabled());
GC_TRIGGERS;
MODE_COOPERATIVE;
NOTHROW;
- PRECONDITION(GetThread() != NULL);
+ PRECONDITION(GetThreadNULLOk() != NULL);
PRECONDITION(oPreAllocThrowable != NULL);
PRECONDITION(CLRException::IsPreallocatedExceptionObject(oPreAllocThrowable));
PRECONDITION(IsWatsonEnabled());
{
if (fCaptureBucketsIfNotPresent)
{
- pWBTracker->CaptureUnhandledInfoForWatson(TypeOfReportedError::UnhandledException, GetThread(), &gc.oPreAllocThrowable);
+ pWBTracker->CaptureUnhandledInfoForWatson(TypeOfReportedError::UnhandledException, GetThreadNULLOk(), &gc.oPreAllocThrowable);
// Check if we have the buckets now
if (pWBTracker->RetrieveWatsonBuckets() != NULL)
GC_TRIGGERS;
MODE_ANY;
NOTHROW;
- PRECONDITION(GetThread() != NULL);
+ PRECONDITION(GetThreadNULLOk() != NULL);
PRECONDITION(refException != NULL);
PRECONDITION(IsWatsonEnabled());
}
GC_TRIGGERS;
MODE_ANY;
NOTHROW;
- PRECONDITION(GetThread() != NULL);
+ PRECONDITION(GetThreadNULLOk() != NULL);
PRECONDITION(!(GetThread()->GetExceptionState()->GetFlags()->GotWatsonBucketDetails()));
PRECONDITION(adjustedIp != NULL);
PRECONDITION(IsWatsonEnabled());
GC_TRIGGERS;
MODE_COOPERATIVE;
THROWS;
- PRECONDITION(GetThread() != NULL);
+ PRECONDITION(GetThreadNULLOk() != NULL);
PRECONDITION(pUnmanagedBuckets != NULL);
PRECONDITION(!CLRException::IsPreallocatedExceptionObject((oTargetThrowable == NULL)?GetThread()->GetThrowable():oTargetThrowable));
PRECONDITION(IsWatsonEnabled());
GC_TRIGGERS;
MODE_ANY;
NOTHROW;
- PRECONDITION(GetThread() != NULL);
+ PRECONDITION(GetThreadNULLOk() != NULL);
PRECONDITION(IsWatsonEnabled());
}
CONTRACTL_END;
GC_NOTRIGGER;
MODE_COOPERATIVE;
NOTHROW;
- PRECONDITION(GetThread() != NULL);
+ PRECONDITION(GetThreadNULLOk() != NULL);
PRECONDITION(oThrowable != NULL);
}
CONTRACTL_END;
THROWS;
GC_TRIGGERS;
MODE_COOPERATIVE;
- PRECONDITION(GetThread() != NULL);
+ PRECONDITION(GetThreadNULLOk() != NULL);
PRECONDITION(notificationType != UnhandledExceptionHandler);
}
CONTRACTL_END;
}
CONTRACTL_END;
- Thread *pCurThread = GetThread();
+ Thread *pCurThread = GetThreadNULLOk();
_ASSERTE(pCurThread != NULL);
// Get the current AppDomain
}
CONTRACTL_END;
- Thread* pThread = GetThread();
+ Thread* pThread = GetThreadNULLOk();
ExceptionTracker* pTracker = pThread ? pThread->GetExceptionState()->m_pCurrentTracker : NULL;
int i = 0;
pMD->m_pszDebugMethodName, pMD->m_pszDebugClassName));
Thread *pThread = GetThread();
- _ASSERTE (pThread);
-
INDEBUG( DumpClauses(pcfThisFrame->GetJitManager(), pcfThisFrame->GetMethodToken(), uMethodStartPC, uControlPC) );
bool fIsILStub = pMD->IsILStub();
// Only call into PopTrackers if we have a managed thread and we have an exception progress.
// Otherwise, the call below (to PopTrackers) is a noop. If this ever changes, then this short-circuit needs to be fixed.
- Thread *pCurThread = GetThread();
+ Thread *pCurThread = GetThreadNULLOk();
if ((pCurThread != NULL) && (pCurThread->GetExceptionState()->IsExceptionInProgress()))
{
// Refer to the comment around ExceptionTracker::HasFrameBeenUnwoundByAnyActiveException
}
CONTRACTL_END;
- Thread* pThread = GetThread();
+ Thread* pThread = GetThreadNULLOk();
ExceptionTracker* pTracker = (pThread ? pThread->GetExceptionState()->m_pCurrentTracker : NULL);
// NOTE:
if (g_EnableSIS)
{
- _ASSERTE(GetThread() == pThread);
+ _ASSERTE(GetThreadNULLOk() == pThread);
GCX_COOP();
EX_TRY
{
- Thread* pThisThread = GetThread();
+ Thread* pThisThread = GetThreadNULLOk();
if (m_pThread == pThisThread)
{
fRetVal = true;
UINT_PTR ExceptionTracker::DebugComputeNestingLevel()
{
UINT_PTR uNestingLevel = 0;
- Thread* pThread = GetThread();
+ Thread* pThread = GetThreadNULLOk();
if (pThread)
{
{
// Get the thread and the thread exception state - they must exist at this point
Thread *pCurThread = GetThread();
- _ASSERTE(pCurThread != NULL);
-
ThreadExceptionState * pCurTES = pCurThread->GetExceptionState();
_ASSERTE(pCurTES != NULL);
}
BOOL IsSafeToCallExecutionManager()
{
- Thread *pThread = GetThread();
+ Thread *pThread = GetThreadNULLOk();
// It is safe to call the ExecutionManager::IsManagedCode only if the current thread is in
// the cooperative mode. Otherwise ExecutionManager::IsManagedCode could deadlock if
else
{
// This is a breakpoint or single step stop, we report it to the debugger.
- Thread *pThread = GetThread();
+ Thread *pThread = GetThreadNULLOk();
if (pThread != NULL && g_pDebugInterface != NULL)
{
#if (defined(TARGET_ARM) || defined(TARGET_ARM64))
IN OUT PDISPATCHER_CONTEXT pDispatcherContext
)
{
- Thread* pThread = GetThread();
+ Thread* pThread = GetThreadNULLOk();
if (pThread == NULL) {
return ExceptionContinueSearch;
}
//
// We check for thread object since this function is the personality routine of the UMThunk
// and we can landup here even when thread creation (within the thunk) fails.
- if (GetThread() != NULL)
+ if (GetThreadNULLOk() != NULL)
{
SetReversePInvokeEscapingUnhandledExceptionStatus(IS_UNWINDING(pExceptionRecord->ExceptionFlags),
MemoryStackFp
{
Thread* pThread = GetThread();
- _ASSERTE(pThread);
-
if (pExceptionRecord->ExceptionCode == STATUS_STACK_OVERFLOW)
{
if (IS_UNWINDING(pExceptionRecord->ExceptionFlags))
{
NOTHROW;
GC_NOTRIGGER;
- if (GetThread() != NULL) MODE_COOPERATIVE; else MODE_ANY;
+ if (GetThreadNULLOk() != NULL) MODE_COOPERATIVE; else MODE_ANY;
FORBID_FAULT;
}
CONTRACTL_END;
{
NOTHROW; // This function does not throw.
GC_NOTRIGGER;
- if (GetThread() != NULL) MODE_COOPERATIVE; else MODE_ANY;
+ if (GetThreadNULLOk() != NULL) MODE_COOPERATIVE; else MODE_ANY;
}
CONTRACTL_END;
#ifdef DEBUGGING_SUPPORTED
// The debugger thread will be using this, even though it has no
// Thread object associated with it.
- _ASSERTE((GetThread() != NULL && GetThread()->PreemptiveGCDisabled()) ||
+ _ASSERTE((GetThreadNULLOk() != NULL && GetThread()->PreemptiveGCDisabled()) ||
((g_pDebugInterface != NULL) && (g_pDebugInterface->GetRCThreadId() == GetCurrentThreadId())));
#endif // DEBUGGING_SUPPORTED
WRAPPER_NO_CONTRACT;
Thread* pThread = GetThread();
- _ASSERTE(pThread);
-
m_pExState = pThread->GetExceptionState();
m_flag = flag;
WRAPPER_NO_CONTRACT;
m_pThread = GetThread();
- _ASSERTE(m_pThread);
-
m_pPreviousHelperMethodFrameCallerList = m_pThread->m_pHelperMethodFrameCallerList;
-
m_pThread->m_pHelperMethodFrameCallerList = NULL;
}
WRAPPER_NO_CONTRACT;
m_pThread = GetThread();
- _ASSERTE(m_pThread);
-
CONSISTENCY_CHECK_MSG((HelperMethodFrameCallerList*)-1 != m_pThread->m_pHelperMethodFrameCallerList,
"fcall entry point is missing a FCALL_TRANSITION_BEGIN or a FCIMPL\n");
//
Thread *pThread = GetThread();
- _ASSERTE(pThread);
-
HelperMethodFrameCallerList *pList = pThread->m_pHelperMethodFrameCallerList;
PCODE CurrentIP;
TADDR CurrentSP;
WRAPPER_NO_CONTRACT;
Thread *pThread = GetThread();
- _ASSERTE(pThread);
-
m_pLastHelperMethodFrameCallerList = pThread->m_pHelperMethodFrameCallerList;
-
pThread->m_pHelperMethodFrameCallerList = (HelperMethodFrameCallerList*)-1;
}
WRAPPER_NO_CONTRACT;
Thread *pThread = GetThread();
- _ASSERTE(pThread);
-
pThread->m_pHelperMethodFrameCallerList = m_pLastHelperMethodFrameCallerList;
}
{
LIMITED_METHOD_CONTRACT;
- return GetThread() == g_pFinalizerThread;
+ return GetThreadNULLOk() == g_pFinalizerThread;
}
void FinalizerThread::EnableFinalization()
GCX_PREEMP();
- Thread *pThread = GetThread();
-
ULONGLONG startTime = CLRGetTickCount64();
ULONGLONG endTime;
if (timeout == INFINITE)
EnableFinalization();
// Do not wait for FinalizerThread if the current one is FinalizerThread.
- if (GetThread() != GetFinalizerThread())
+ if (GetThreadNULLOk() != GetFinalizerThread())
{
// This wait must be alertable to handle cases where the current
// thread's context is needed (i.e. RCW cleanup)
BOOL oref_protected;
IsObjRefProtectedScanContext (OBJECTREF * oref)
{
- thread_under_crawl = GetThread ();
+ thread_under_crawl = GetThread();
promotion = TRUE;
oref_to_check = oref;
oref_protected = FALSE;
BYTE * savedInstrPtr = &gcCover->savedCode[offset];
- Thread* pThread = GetThread();
+ Thread* pThread = GetThreadNULLOk();
if (!pThread)
{
// No thread at the moment so we aren't doing coverage for this function.
DWORD offset = codeInfo.GetRelOffset();
Thread *pThread = GetThread();
- _ASSERTE(pThread);
// There is a race condition with the computation of `atCall`. Multiple threads could enter
// this function (DoGcStress) at the same time. If one reads `*instrPtr` and sets `atCall`
}
#endif // HAVE_GCCOVER
-
// the threadstore lock.
_ASSERTE(dbgOnly_IsSpecialEEThread() ||
- GetThread() == NULL ||
+ GetThreadNULLOk() == NULL ||
// this is for background GC threads which always call this when EE is suspended.
IsGCSpecialThread() ||
(GetThread() == ThreadSuspend::GetSuspensionThread() && ThreadStore::HoldingThreadStore()));
{
WRAPPER_NO_CONTRACT;
- Thread* pThread = ::GetThread();
+ Thread* pThread = ::GetThreadNULLOk();
if (!pThread)
{
return nullptr;
{
WRAPPER_NO_CONTRACT;
- Thread* pThread = ::GetThread();
+ Thread* pThread = ::GetThreadNULLOk();
return (pThread && pThread->PreemptiveGCDisabled());
}
{
WRAPPER_NO_CONTRACT;
- Thread* pThread = ::GetThread();
+ Thread* pThread = ::GetThreadNULLOk();
if (pThread && pThread->PreemptiveGCDisabled())
{
{
WRAPPER_NO_CONTRACT;
- Thread* pThread = ::GetThread();
+ Thread* pThread = ::GetThreadNULLOk();
if (pThread)
{
pThread->DisablePreemptiveGC();
{
WRAPPER_NO_CONTRACT;
- return ::GetThread();
+ return ::GetThreadNULLOk();
}
//
{
StressLog::LogMsg(level, facility, msg);
}
-
GcStressBase::MaybeTrigger(acontext);
#ifdef _DEBUG
- Thread *pThread = GetThread();
+ Thread *pThread = GetThreadNULLOk();
if (pThread)
{
pThread->EnableStressHeap();
LIMITED_METHOD_DAC_CONTRACT;
#if !defined(DACCESS_COMPILE) && !defined(CROSSGEN_COMPILE)
- _ASSERTE (!g_fEEStarted || !m_fAsyncMode || GetThread() == NULL || GetThread()->PreemptiveGCDisabled() || IsGCThread());
+ _ASSERTE (!g_fEEStarted || !m_fAsyncMode || GetThreadNULLOk() == NULL || GetThread()->PreemptiveGCDisabled() || IsGCThread());
#endif
return m_rgBuckets + 1;
}
GCX_MAYBE_COOP_NO_THREAD_BROKEN(m_fAsyncMode);
#ifndef CROSSGEN_COMPILE
- _ASSERTE (!g_fEEStarted || !m_fAsyncMode || GetThread() == NULL || GetThread()->PreemptiveGCDisabled());
+ _ASSERTE (!g_fEEStarted || !m_fAsyncMode || GetThreadNULLOk() == NULL || GetThread()->PreemptiveGCDisabled());
_ASSERTE (OwnLock());
#endif
NOTHROW;
GC_NOTRIGGER;
MODE_ANY;
- PRECONDITION(dwSleepMSec < 10000 || GetThread() == NULL || !GetThread()->PreemptiveGCDisabled());
+ PRECONDITION(dwSleepMSec < 10000 || GetThreadNULLOk() == NULL || !GetThread()->PreemptiveGCDisabled());
}
CONTRACTL_END;
pFrame = ((FrameHandlerExRecord *)pEstablisherFrame)->GetCurrFrame();
// Assert that the exception frame is on the thread or that the exception frame is the top frame.
- _ASSERTE(GetThread() == NULL || GetThread()->GetFrame() == (Frame*)-1 || GetThread()->GetFrame() <= pFrame);
+ _ASSERTE(GetThreadNULLOk() == NULL || GetThread()->GetFrame() == (Frame*)-1 || GetThread()->GetFrame() <= pFrame);
return pFrame;
}
_ASSERTE(ExecutionManager::IsManagedCode(GetControlPC(pCF->GetRegisterSet())));
// Cannot get to the TEB of other threads. So ignore them.
- if (pThread != GetThread())
+ if (pThread != GetThreadNULLOk())
{
return;
}
// Set up m_OSContext for the call to COMPlusCheckForAbort
//
Thread* pThread = GetThread();
- _ASSERTE(pThread != NULL);
SetIP(pThread->m_OSContext, (PCODE)*pRetAddress);
SetSP(pThread->m_OSContext, (TADDR)esp);
// the unwind.
Thread* pThread = GetThread();
- _ASSERTE(pThread);
ExInfo* pExInfo = &(pThread->GetExceptionState()->m_currentExInfo);
ExInfo* pPrevNestedInfo = pExInfo->m_pPrevNestedInfo;
GCX_COOP(); // Must be cooperative to modify frame chain.
Thread *pThread = GetThread();
- _ASSERTE(pThread);
Frame *pFrame = pThread->GetFrame();
pFrame->ExceptionUnwind();
pFrame->Pop(pThread);
{
LIMITED_METHOD_CONTRACT;
- Thread * pThread = GetThread();
+ Thread * pThread = GetThreadNULLOk();
// We may not have a managed thread object. Example is an AV on the helper thread.
// (perhaps during StubManager::IsStub)
{
CONTRACTL {
NOTHROW;
- if (GetThread()) {GC_TRIGGERS;} else {GC_NOTRIGGER;}
+ if (GetThreadNULLOk()) {GC_TRIGGERS;} else {GC_NOTRIGGER;}
} CONTRACTL_END;
int stompWBCompleteActions = SWB_PASS;
// Check if we need to use the upper bounds checking barrier stub.
if (bReqUpperBoundsCheck)
{
- GCX_MAYBE_COOP_NO_THREAD_BROKEN((GetThread()!=NULL));
+ GCX_MAYBE_COOP_NO_THREAD_BROKEN((GetThreadNULLOk()!=NULL));
if( !isRuntimeSuspended && !(stompWBCompleteActions & SWB_EE_RESTART) ) {
ThreadSuspend::SuspendEE(ThreadSuspend::SUSPEND_FOR_GC_PREP);
stompWBCompleteActions |= SWB_EE_RESTART;
X86EmitPushRegs(preservedRegSet & ((1 << kEAX) | (1 << kEDX) | (1 << kECX)));
// call GetThread
- X86EmitCall(NewExternalCodeLabel((LPVOID)GetThread), sizeof(void*));
+ X86EmitCall(NewExternalCodeLabel((LPVOID)GetThreadHelper), sizeof(void*));
// mov dstreg, eax
X86EmitMovRegReg(dstreg, kEAX);
if (p == NULL)
return;
- Thread * pThread = GetThread();
+ Thread * pThread = GetThreadNULLOk();
/* This could be called by the concurrent GC thread*/
/* where GetThread() returns NULL. In such cases,*/
if (pErrInfo != NULL)
{
- Thread* pThread = GetThread();
+ Thread* pThread = GetThreadNULLOk();
if (pThread != NULL)
{
GCX_PREEMP();
THROWS;
GC_TRIGGERS;
MODE_ANY;
- PRECONDITION(GetThread() || !fCoInitCurrentThread);
+ PRECONDITION(GetThreadNULLOk() || !fCoInitCurrentThread);
PRECONDITION(g_fEEStarted);
}
CONTRACTL_END;
GC_TRIGGERS;
MODE_ANY;
PRECONDITION(g_fEEStarted);
- PRECONDITION(GetThread() != NULL); // Should always be inside BEGIN_EXTERNAL_ENTRYPOINT
+ PRECONDITION(GetThreadNULLOk() != NULL); // Should always be inside BEGIN_EXTERNAL_ENTRYPOINT
}
CONTRACTL_END;
if (orThrowable != NULL)
{
- PTR_Thread pCurThread = GetThread();
-
// Don't catch ThreadAbort and other uncatchable exceptions
if (!IsUncatchable(&orThrowable))
{
MONHELPER_STATE(_ASSERTE(pbLockTaken != NULL && *pbLockTaken == 0));
Thread *pCurThread = GetThread();
-
if (pCurThread->CatchAtSafePointOpportunistic())
{
goto FramedLockHelper;
{
size = max(size, sizeof(Slab));
- Thread* pCurrentThread = GetThread();
+ Thread* pCurrentThread = GetThreadNULLOk();
if (m_pCurrentCachedList != NULL || m_pPreviousCachedList != NULL)
{
CrstHolder lock(&m_jitSlabAllocatorCrst);
Slab* pSlab = (Slab*)slab;
pSlab->size = actualSize;
- pSlab->affinity = GetThread();
+ pSlab->affinity = GetThreadNULLOk();
pSlab->pNext = m_pCurrentCachedList;
m_pCurrentCachedList = pSlab;
return;
//
#define JIT_TO_EE_TRANSITION() MAKE_CURRENT_THREAD_AVAILABLE_EX(m_pThread); \
- _ASSERTE(CURRENT_THREAD == GetThread()); \
INSTALL_UNWIND_AND_CONTINUE_HANDLER_NO_PROBE; \
COOPERATIVE_TRANSITION_BEGIN(); \
m_pOverride(NULL),
m_pMethodBeingCompiled(fd),
m_fVerifyOnly(fVerifyOnly),
- m_pThread(GetThread()),
+ m_pThread(GetThreadNULLOk()),
m_hMethodForSecurity_Key(NULL),
m_pMethodForSecurity_Value(NULL),
#if defined(FEATURE_GDBJIT)
// policy, keep this unless it proves intractable to remove all premature classinits in the system.
EnsureActive();
- Thread *pThread;
- pThread = GetThread();
- _ASSERTE(pThread);
+ Thread* pThread = GetThread();
AppDomain *pDomain = GetAppDomain();
// finalization.
if ((g_fEEShutDown & ShutDown_Finalize2) == 0)
{
- if (GetThread() != thread)
+ if (GetThreadNULLOk() != thread)
{
refThis->ClearInternal();
}
CONTRACTL
{
STANDARD_VM_CHECK;
- PRECONDITION(GetThread() != NULL);
+ PRECONDITION(GetThreadNULLOk() != NULL);
PRECONDITION(CheckPointer(pModule));
PRECONDITION(CheckPointer(bmtGenericsInfo));
}
CONTRACT(TypeHandle)
{
STANDARD_VM_CHECK;
- PRECONDITION(GetThread() != NULL);
+ PRECONDITION(GetThreadNULLOk() != NULL);
PRECONDITION(CheckPointer(pModule));
POSTCONDITION(!RETVAL.IsNull());
POSTCONDITION(CheckPointer(RETVAL.GetMethodTable()));
Thread *pThread = GetThread();
size_t key=0;
- _ASSERTE(pThread);
-
//Poll and wait if GC is in progress, to avoid blocking GC for too long.
FC_GC_POLL();
#ifdef _DEBUG
{
- BEGIN_GETTHREAD_ALLOWED_IN_NO_THROW_REGION;
- Thread *pThread = GetThread();
+ Thread *pThread = GetThreadNULLOk();
if (pThread != NULL && !(pThread->PreemptiveGCDisabled()))
{
if (!dbgOnly_IsSpecialEEThread() && !IsGCSpecialThread())
_ASSERTE(!"OBJECTREF being accessed while thread is in preemptive GC mode.");
}
- END_GETTHREAD_ALLOWED_IN_NO_THROW_REGION;
}
#endif
if (!(((*(BYTE**)&dest) < g_lowest_address ) ||
((*(BYTE**)&dest) >= g_highest_address)))
{
- Thread* pThread = GetThread();
+ Thread* pThread = GetThreadNULLOk();
// GCHeapUtilities::IsHeapPointer has race when called in preemptive mode. It walks the list of segments
// that can be modified by GC. Do the check below only if it is safe to do so.
if (!m_array)
return;
- assert(GetObjectThread() == GetThread());
+ assert(GetObjectThread() == GetThreadNULLOk());
size_t size = Size();
StackTraceElement const * p;
if (!m_array)
return;
- if (GetObjectThread() != GetThread())
+ if (GetObjectThread() != GetThreadNULLOk())
{
// object is being changed by a thread different from the one which created it
// make a copy of the array to prevent a race condition when two different threads try to change it
ETWOnStartup(PrestubWorker_V1, PrestubWorkerEnd_V1);
- MAKE_CURRENT_THREAD_AVAILABLE();
+ MAKE_CURRENT_THREAD_AVAILABLE_EX(GetThreadNULLOk());
// Attempt to check what GC mode we are running under.
if (CURRENT_THREAD == NULL
{
// This is called before entering a profiler. We set the specified dwFlags on
// the Thread object, and remember the previous flags for later.
- BEGIN_GETTHREAD_ALLOWED_IN_NO_THROW_REGION;
- m_pThread = GetThread();
+ m_pThread = GetThreadNULLOk();
if (m_pThread != NULL)
{
m_dwOriginalFullState = m_pThread->SetProfilerCallbackStateFlags(dwFlags);
{
m_dwOriginalFullState = 0;
}
- END_GETTHREAD_ALLOWED_IN_NO_THROW_REGION;
}
FORCEINLINE SetCallbackStateFlagsHolder::~SetCallbackStateFlagsHolder()
// original flag set here.
if (m_pThread != NULL)
{
- BEGIN_GETTHREAD_ALLOWED_IN_NO_THROW_REGION;
m_pThread->SetProfilerCallbackFullState(m_dwOriginalFullState);
- END_GETTHREAD_ALLOWED_IN_NO_THROW_REGION;
}
}
return E_INVALIDARG;
}
- if (GetThread() == NULL)
+ if (GetThreadNULLOk() == NULL)
{
return CORPROF_E_NOT_MANAGED_THREAD;
}
//
// Verify the value of threadId, which must be the current thread ID or NULL, which means using curernt thread ID.
//
- if ((threadId != NULL) && (threadId != ((ThreadID)GetThread())))
+ if ((threadId != NULL) && (threadId != ((ThreadID)GetThreadNULLOk())))
{
return E_INVALIDARG;
}
- threadId = reinterpret_cast<ThreadID>(GetThread());
+ threadId = reinterpret_cast<ThreadID>(GetThreadNULLOk());
AppDomainID appDomainId = reinterpret_cast<AppDomainID>(GetAppDomain());
//
if (threadId == NULL)
{
- if (GetThread() == NULL)
+ if (GetThreadNULLOk() == NULL)
{
return CORPROF_E_NOT_MANAGED_THREAD;
}
- threadId = reinterpret_cast<ThreadID>(GetThread());
+ threadId = reinterpret_cast<ThreadID>(GetThreadNULLOk());
}
//
EHClauseInfo* pCurrentEHClauseInfo = NULL;
// notification requires that we are on a managed thread with an exception in flight
- Thread *pThread = GetThread();
+ Thread *pThread = GetThreadNULLOk();
// If pThread is null, then the thread has never run managed code
if (pThread == NULL)
"**PROF: GetObjectGeneration 0x%p.\n",
objectId));
- BEGIN_GETTHREAD_ALLOWED;
- _ASSERTE((GetThread() == NULL) || (GetThread()->PreemptiveGCDisabled()));
- END_GETTHREAD_ALLOWED;
+
+ _ASSERTE((GetThreadNULLOk() == NULL) || (GetThreadNULLOk()->PreemptiveGCDisabled()));
+
// Announce we are using the generation table now
CounterHolder genTableLock(&s_generationTableLock);
HRESULT hr = S_OK;
EX_TRY
{
- if (GetThread() == NULL)
+ if (GetThreadNULLOk() == NULL)
{
SetupThread();
}
- Thread *pThread = GetThread();
+ Thread *pThread = GetThreadNULLOk();
pThread->SetProfilerCallbackStateFlags(COR_PRF_CALLBACKSTATE_REJIT_WAS_CALLED);
}
EX_CATCH_HRESULT(hr);
LL_INFO10,
"**PROF: InitializeCurrentThread.\n"));
- SetupTLSForThread(GetThread());
+ SetupTLSForThread();
return S_OK;
}
}
BOOL fRet;
- BEGIN_GETTHREAD_ALLOWED_IN_NO_THROW_REGION;
DWORD dwProfilerCallbackFullStateFlags = pThread->GetProfilerCallbackFullState();
if (((dwProfilerCallbackFullStateFlags & COR_PRF_CALLBACKSTATE_FORCEGC_WAS_CALLED) != 0)
|| ((dwProfilerCallbackFullStateFlags & COR_PRF_CALLBACKSTATE_REJIT_WAS_CALLED) != 0))
}
fRet = ((dwProfilerCallbackFullStateFlags & dwFlags) == dwFlags);
- END_GETTHREAD_ALLOWED_IN_NO_THROW_REGION;
return fRet;
}
// into cooperative GC mode. This "fix" will prevent us from doing so.
if (g_fEEShutDown & ShutDown_Finalize2)
{
- Thread *pThread = GetThread();
+ Thread *pThread = GetThreadNULLOk();
if (pThread && !FinalizerThread::IsCurrentThreadFinalizer())
pThread->SetThreadStateNC(Thread::TSNC_UnsafeSkipEnterCooperative);
}
// the MTA context), we will infinitely loop. So, we short circuit this with ctxTried.
Thread *pHeadThread = pHead->GetSTAThread();
- BOOL fCorrectThread = (pHeadThread == NULL) ? TRUE : (pHeadThread == GetThread());
+ BOOL fCorrectThread = (pHeadThread == NULL) ? TRUE : (pHeadThread == GetThreadNULLOk());
BOOL fCorrectCookie = (pCurrCtxCookie == NULL) ? TRUE : (pHead->GetWrapperCtxCookie() == pCurrCtxCookie);
if ( pHead->IsFreeThreaded() || // Avoid context transition if the list is for free threaded RCW
// Reset the bit indicating we cannot transition into cooperative GC mode.
if (g_fEEShutDown & ShutDown_Finalize2)
{
- Thread *pThread = GetThread();
+ Thread *pThread = GetThreadNULLOk();
if (pThread && !FinalizerThread::IsCurrentThreadFinalizer())
pThread->ResetThreadStateNC(Thread::TSNC_UnsafeSkipEnterCooperative);
}
// if this thread is an STA thread, then when the STA dies
// we need to cleanup this wrapper
m_pCreatorThread = GetThread();
- _ASSERTE(m_pCreatorThread != NULL);
m_pRCWCache = RCWCache::GetRCWCache();
CONTRACTL_END;
if (m_gcMode == PREEMPTIVE)
- _ASSERTE(!GetThread() || !GetThread()->PreemptiveGCDisabled());
+ _ASSERTE(!GetThreadNULLOk() || !GetThread()->PreemptiveGCDisabled());
else if (m_gcMode == COOPERATIVE)
- _ASSERTE(!GetThread() || GetThread()->PreemptiveGCDisabled());
+ _ASSERTE(!GetThreadNULLOk() || GetThread()->PreemptiveGCDisabled());
}
//=====================================================================
}
CONTRACTL_END;
- Thread* pThread = GetThread();
+ Thread* pThread = GetThreadNULLOk();
if (pThread)
{
// SpinLock can not be nested.
}
CONTRACTL_END;
- Thread* pThread = GetThread();
+ Thread* pThread = GetThreadNULLOk();
if (pThread)
{
INCONTRACT(pThread->BeginNoTriggerGC(__FILE__, __LINE__));
}
CONTRACTL_END;
- Thread* pThread = GetThread();
+ Thread* pThread = GetThreadNULLOk();
if (pThread)
{
_ASSERTE ((pThread->m_StateNC & Thread::TSNC_OwnsSpinLock) != 0);
bool fUseInitRegDisplay;
#ifndef DACCESS_COMPILE
- _ASSERTE(GetThread() == this || (flags & ALLOW_ASYNC_STACK_WALK));
+ _ASSERTE(GetThreadNULLOk() == this || (flags & ALLOW_ASYNC_STACK_WALK));
BOOL fDebuggerHasInitialContext = (GetFilterContext() != NULL);
BOOL fProfilerHasInitialContext = (GetProfilerFilterContext() != NULL);
CONTRACTL
{
NOTHROW;
- if(GetThread()){GC_NOTRIGGER;}else{DISABLED(GC_TRIGGERS);};
+ if(GetThreadNULLOk()){GC_NOTRIGGER;}else{DISABLED(GC_TRIGGERS);};
PRECONDITION(CheckPointer(this));
}
CONTRACTL_END;
CONTRACTL
{
NOTHROW;
- if(GetThread()){GC_NOTRIGGER;}else{DISABLED(GC_TRIGGERS);};
+ if(GetThreadNULLOk()){GC_NOTRIGGER;}else{DISABLED(GC_TRIGGERS);};
PRECONDITION(CheckPointer(this));
}
CONTRACTL_END;
CONTRACTL
{
NOTHROW;
- if(GetThread()){GC_NOTRIGGER;}else{DISABLED(GC_TRIGGERS);};
+ if(GetThreadNULLOk()){GC_NOTRIGGER;}else{DISABLED(GC_TRIGGERS);};
MODE_COOPERATIVE;
PRECONDITION(CheckPointer(this));
PRECONDITION(CheckPointer(pStringData));
for (;;)
{
- AwareLock::LeaveHelperAction action = thisObj->GetHeader ()->LeaveObjMonitorHelper(GetThread());
+ AwareLock::LeaveHelperAction action = thisObj->GetHeader()->LeaveObjMonitorHelper(GetThread());
switch(action)
{
__SwitchToThread(0, ++dwSwitchCount);
}
- INCONTRACT(Thread* pThread = GetThread());
+ INCONTRACT(Thread* pThread = GetThreadNULLOk());
INCONTRACT(if (pThread != NULL) pThread->BeginNoTriggerGC(__FILE__, __LINE__));
}
#else
__SwitchToThread(0, ++dwSwitchCount);
}
- INCONTRACT(Thread* pThread = GetThread());
+ INCONTRACT(Thread* pThread = GetThreadNULLOk());
INCONTRACT(if (pThread != NULL) pThread->BeginNoTriggerGC(__FILE__, __LINE__));
}
#endif //MP_LOCKS
SCAN_SCOPE_END;
LIMITED_METHOD_CONTRACT;
- INCONTRACT(Thread* pThread = GetThread());
+ INCONTRACT(Thread* pThread = GetThreadNULLOk());
INCONTRACT(if (pThread != NULL) pThread->EndNoTriggerGC());
FastInterlockAnd(&m_SyncBlockValue, ~BIT_SBLK_SPIN_LOCK);
}
#endif // HOST_64BIT && _DEBUG
-
return;
}
- BEGIN_GETTHREAD_ALLOWED
- _ASSERTE (GetThread() == NULL || GetThread()->PreemptiveGCDisabled());
- END_GETTHREAD_ALLOWED
+ _ASSERTE (GetThreadNULLOk() == NULL || GetThread()->PreemptiveGCDisabled());
Bucket * pTempBucket = NULL;
do
return;
}
- BEGIN_GETTHREAD_ALLOWED
- _ASSERTE (GetThread() == NULL || GetThread()->PreemptiveGCDisabled());
- END_GETTHREAD_ALLOWED
+ _ASSERTE (GetThreadNULLOk() == NULL || GetThread()->PreemptiveGCDisabled());
EEHashEntry ** pTempHashEntry = NULL;
do
// Only GC thread can call this.
_ASSERTE (g_fProcessDetach ||
IsGCSpecialThread() ||
- (GCHeapUtilities::IsGCInProgress() && GetThread() == ThreadSuspend::GetSuspensionThread()));
+ (GCHeapUtilities::IsGCInProgress() && GetThreadNULLOk() == ThreadSuspend::GetSuspensionThread()));
if (m_HashMap)
{
Bucket * pTempBucket = FastInterlockExchangePointer(m_HashMap.GetPointer(), NULL);
GC_NOTRIGGER;
// disallow creation of Crst before EE starts
PRECONDITION((g_fEEStarted));
- PRECONDITION((GetThread() != NULL));
+ PRECONDITION((GetThreadNULLOk() != NULL));
PRECONDITION((!IsOSEvent()));
}
CONTRACTL_END;
{
NOTHROW;
}
- if (GetThread())
+ if (GetThreadNULLOk())
{
if (alertable)
GC_TRIGGERS;
_ASSERTE(Thread::Debug_AllowCallout());
- Thread * pThread = GetThread();
+ Thread * pThread = GetThreadNULLOk();
#ifdef _DEBUG
// If a CLREvent is OS event only, we can not wait for the event on a managed thread
{
CONTRACTL
{
- if (GetThread() && alertable)
+ if (GetThreadNULLOk() && alertable)
{
THROWS; // Thread::DoAppropriateWait can throw
}
{
NOTHROW;
}
- if (GetThread())
+
+ if (GetThreadNULLOk())
{
if (alertable)
GC_TRIGGERS;
{
DISABLED(GC_TRIGGERS);
}
+
PRECONDITION(m_handle != INVALID_HANDLE_VALUE); // Invalid to have invalid handle
}
CONTRACTL_END;
- Thread *pThread = GetThread();
+ Thread *pThread = GetThreadNULLOk();
_ASSERTE (pThread || !g_fEEStarted || dbgOnly_IsSpecialEEThread());
{
}
*wasNotRecalled = ThreadpoolMgr::ShouldWorkerKeepRunning();
- Thread *pThread = GetThread();
+ Thread *pThread = GetThreadNULLOk();
if (pThread)
{
_ASSERTE(!pThread->IsAbortRequested());
*wasNotRecalled = true;
HRESULT hr;
- Thread * pThread = GetThread();
+ Thread * pThread = GetThreadNULLOk();
if (pThread == NULL)
{
ClrFlsSetThreadType(ThreadType_Threadpool_Worker);
{
}
+Thread* STDCALL GetThreadHelper()
+{
+ return GetThreadNULLOk();
+}
+
TailCallArgBuffer* TailCallTls::AllocArgBuffer(int size, void* gcDesc)
{
CONTRACTL
{
CONTRACTL {
THROWS;
- if (GetThread()) {GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
+ if (GetThreadNULLOk()) {GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
}
CONTRACTL_END;
BOOL alertable = (mode & WaitMode_Alertable)?TRUE:FALSE;
- Thread *pCurThread = GetThread();
+ Thread *pCurThread = GetThreadNULLOk();
_ASSERTE(pCurThread || dbgOnly_IsSpecialEEThread());
{
{
CONTRACTL {
NOTHROW;
- if (GetThread()) {GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
+ if (GetThreadNULLOk()) {GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
}
CONTRACTL_END;
HRESULT hr = S_OK;
- Thread *pThread = GetThread();
+ Thread *pThread = GetThreadNULLOk();
if (pThread != NULL)
{
return pThread;
{
CONTRACTL {
NOTHROW;
- if (GetThread()) {GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
+ if (GetThreadNULLOk()) {GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
}
CONTRACTL_END;
void EnsurePreemptive()
{
WRAPPER_NO_CONTRACT;
- Thread *pThread = GetThread();
+ Thread *pThread = GetThreadNULLOk();
if (pThread && pThread->PreemptiveGCDisabled())
{
pThread->EnablePreemptiveGC();
{
CONTRACTL {
THROWS;
- if (GetThread()) {GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
+ if (GetThreadNULLOk()) {GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
}
CONTRACTL_END;
Thread* pThread;
- if ((pThread = GetThread()) != NULL)
+ if ((pThread = GetThreadNULLOk()) != NULL)
return pThread;
// For interop debugging, we must mark that we're in a can't-stop region
Holder<Thread*,DoNothing<Thread*>,DeleteThread> threadHolder(pThread);
- SetupTLSForThread(pThread);
+ SetupTLSForThread();
if (!pThread->InitThread() ||
!pThread->PrepareApartmentAndContext())
{
CONTRACTL {
THROWS;
- if (GetThread()) {GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
+ if (GetThreadNULLOk()) {GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
}
CONTRACTL_END;
#endif // FEATURE_WRITEBARRIER_COPY
#ifndef TARGET_UNIX
- _ASSERTE(GetThread() == NULL);
+ _ASSERTE(GetThreadNULLOk() == NULL);
size_t offsetOfCurrentThreadInfo = Thread::GetOffsetOfThreadStatic(&gCurrentThreadInfo);
{
CONTRACTL {
THROWS;
- if (GetThread()) {GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
+ if (GetThreadNULLOk()) {GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
}
CONTRACTL_END;
m_ioThreadPoolCompletionCount = 0;
m_monitorLockContentionCount = 0;
- Thread *pThread = GetThread();
InitContext();
// Do not expose thread until it is fully constructed
{
CONTRACTL {
THROWS;
- if (GetThread()) {GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
+ if (GetThreadNULLOk()) {GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
}
CONTRACTL_END;
// the runtime. But sometimes that thread is used for DLL_THREAD_ATTACH notifications
// that call into managed code. In that case, the second HasStarted call is
// redundant and should be ignored.
- if (GetThread() == this)
+ if (GetThreadNULLOk() == this)
return TRUE;
- _ASSERTE(GetThread() == 0);
+ _ASSERTE(GetThreadNULLOk() == 0);
_ASSERTE(HasValidThreadHandle());
BOOL fKeepTLS = FALSE;
// Initialization must happen in the following order - hosts like SQL Server depend on this.
//
- SetupTLSForThread(this);
+ SetupTLSForThread();
fCanCleanupCOMState = TRUE;
res = PrepareApartmentAndContext();
SetThreadState(TS_FailStarted);
- if (GetThread() != NULL && IsAbortRequested())
+ if (GetThreadNULLOk() != NULL && IsAbortRequested())
UnmarkThreadForAbort();
if (!fKeepTLS)
}
CONTRACTL_END;
- _ASSERTE(GetThread() != NULL);
+ _ASSERTE(GetThreadNULLOk() != NULL);
struct ProtectArgs
{
{
CONTRACTL {
NOTHROW;
- if (GetThread()) {GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
+ if (GetThreadNULLOk()) {GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
}
CONTRACTL_END;
- Thread *pCurThread = GetThread();
+ Thread *pCurThread = GetThreadNULLOk();
_ASSERTE(m_ExternalRefCount > 0);
int retVal = FastInterlockIncrement((LONG*)&m_ExternalRefCount);
{
CONTRACTL {
NOTHROW;
- if (GetThread()) {GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
+ if (GetThreadNULLOk()) {GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
}
CONTRACTL_END;
// Note that it's possible to get here with a NULL current thread (during
// shutdown of the thread manager).
- Thread *pCurThread = GetThread();
+ Thread *pCurThread = GetThreadNULLOk();
_ASSERTE (pCurThread == NULL || IsAtProcessExit()
|| (!holdingLock && !ThreadStore::HoldingThreadStore(pCurThread))
|| (holdingLock && ThreadStore::HoldingThreadStore(pCurThread)));
{
CONTRACTL {
NOTHROW;
- if (GetThread()) {GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
+ if (GetThreadNULLOk()) {GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
}
CONTRACTL_END;
{
CONTRACTL {
NOTHROW;
- if (GetThread()) {GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
+ if (GetThreadNULLOk()) {GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
}
CONTRACTL_END;
{
CONTRACTL {
NOTHROW;
- if (GetThread()) {GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
+ if (GetThreadNULLOk()) {GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
}
CONTRACTL_END;
// Should not use OSThreadId:
// OSThreadId may change for the current thread is the thread is blocked and rescheduled
// by host.
- Thread *pCurrentThread = GetThread();
+ Thread *pCurrentThread = GetThreadNULLOk();
DWORD CurrentThreadID = pCurrentThread?pCurrentThread->GetThreadId():0;
DWORD ThisThreadID = GetThreadId();
// If the currently running thread is the thread that died and it is an STA thread, then we
// need to release all the RCW's in the current context. However, we cannot do this if we
// are in the middle of process detach.
- if (!IsAtProcessExit() && this == GetThread())
+ if (!IsAtProcessExit() && this == GetThreadNULLOk())
{
CleanupCOMState();
}
_ASSERTE(data == APC_Code);
- Thread *pCurThread = GetThread();
+ Thread *pCurThread = GetThreadNULLOk();
if (pCurThread)
{
// We should only take action if an interrupt is currently being
TRIGGERSGC();
- Thread *pCurThread = GetThread();
+ Thread *pCurThread = GetThreadNULLOk();
_ASSERTE (!(pCurThread == NULL || IsAtProcessExit()));
_ASSERTE(pCurThread->PreemptiveGCDisabled());
{
CONTRACTL {
NOTHROW;
- if (GetThread()) {GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
+ if (GetThreadNULLOk()) {GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
}
CONTRACTL_END;
if (exposed != NULL)
{
- _ASSERTE (GetThread() != this);
+ _ASSERTE (GetThreadNULLOk() != this);
_ASSERTE(IsUnstarted());
_ASSERTE(ObjectFromHandle(m_ExposedObject) == NULL);
// The exposed object keeps us alive until it is GC'ed. This doesn't mean the
}
CONTRACTL_END;
- if (this == GetThread())
+ if (this == GetThreadNULLOk())
{
THDTYPE type;
HRESULT hr = S_OK;
{
CONTRACTL {
NOTHROW;
- if (GetThread()) {GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
+ if (GetThreadNULLOk()) {GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
}
CONTRACTL_END;
}
CONTRACTL_END;
- _ASSERTE(GetThread() == thread);
+ _ASSERTE(GetThreadNULLOk() == thread);
LOG((LF_SYNC, INFO3, "TransferUnstartedThread obtain lock\n"));
ThreadStoreLockHolder TSLockHolder(FALSE);
// Cache the current change stamp for g_TrapReturningThreads
LONG chgStamp = g_trtChgStamp;
- STRESS_LOG3(LF_STORE, LL_INFO100, "ThreadStore::DbgFindThread - [thread=%p]. trt=%d. chgStamp=%d\n", GetThread(), g_TrapReturningThreads.Load(), chgStamp);
+ STRESS_LOG3(LF_STORE, LL_INFO100, "ThreadStore::DbgFindThread - [thread=%p]. trt=%d. chgStamp=%d\n", GetThreadNULLOk(), g_TrapReturningThreads.Load(), chgStamp);
#if 0 // g_TrapReturningThreads debug code.
int iRetry = 0;
}
#endif // g_TrapReturningThreads debug code.
- STRESS_LOG4(LF_STORE, LL_INFO100, "ThreadStore::DbgFindThread - [thread=%p]. trt=%d. chg=%d. cnt=%d\n", GetThread(), g_TrapReturningThreads.Load(), g_trtChgStamp.Load(), cntReturn);
+ STRESS_LOG4(LF_STORE, LL_INFO100, "ThreadStore::DbgFindThread - [thread=%p]. trt=%d. chg=%d. cnt=%d\n", GetThreadNULLOk(), g_TrapReturningThreads.Load(), g_trtChgStamp.Load(), cntReturn);
// Because of race conditions and the fact that the GC places its
// own count, I can't assert this precisely. But I do want to be
{
CrstHolder ch(g_pUniqueStackCrst);
#ifdef _DEBUG
- if (GetThread ())
- GetThread ()->m_bUniqueStacking = TRUE;
+ if (GetThreadNULLOk())
+ GetThread()->m_bUniqueStacking = TRUE;
#endif
if (g_pUniqueStackMap->LookupValue (stackTraceHash, stackTrace) != (LPVOID)INVALIDENTRY)
{
UniqueStackHelper(stackTraceHash, stackTrace);
}
#ifdef _DEBUG
- if (GetThread ())
- GetThread ()->m_bUniqueStacking = FALSE;
+ if (GetThreadNULLOk())
+ GetThread()->m_bUniqueStacking = FALSE;
#endif
}
}
CONTRACTL_END;
- Thread* pThread = GetThread(); // N.B. this can be NULL!
+ Thread* pThread = GetThreadNULLOk(); // N.B. this can be NULL!
UINT_PTR uStackLimit = (UINT_PTR)GetStackLowerBound();
UINT_PTR uStackBase = (UINT_PTR)GetStackUpperBound();
#else
pctx->ContextFlags = CONTEXT_FULL;
- _ASSERTE(this != GetThread()); // do not call GetThreadContext on the active thread
+ _ASSERTE(this != GetThreadNULLOk()); // do not call GetThreadContext on the active thread
BOOL ret = EEGetThreadContext(this, pctx);
if (!ret)
CONTRACTL_END;
Thread *thread = GetThread();
-
thread->HandleThreadAbort ();
if (thread->CatchAtSafePoint())
{
CONTRACTL {
THROWS;
- if (GetThread()) {GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
+ if (GetThreadNULLOk()) {GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
}
CONTRACTL_END;
{
CONTRACTL {
NOTHROW;
- if (GetThread()) {GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
+ if (GetThreadNULLOk()) {GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
}
CONTRACTL_END;
// Get the reference to the current thread..
Thread *pCurThread = GetThread();
- _ASSERTE(pCurThread);
//
// In the default domain, when an exception goes unhandled on a managed thread whose threadbase is in the VM (e.g. explicitly spawned threads,
STATIC_CONTRACT_MODE_COOPERATIVE;
// HasStarted() must have already been performed by our caller
- _ASSERTE(GetThread() != NULL);
+ _ASSERTE(GetThreadNULLOk() != NULL);
Thread *pThread = GetThread();
#ifdef FEATURE_EH_FUNCLETS
BOOL DeadlockAwareLock::CanEnterLock()
{
Thread * pThread = GetThread();
-
- CONSISTENCY_CHECK_MSG(pThread != NULL,
- "Cannot do deadlock detection on non-EE thread");
CONSISTENCY_CHECK_MSG(pThread->m_pBlockingLock.Load() == NULL,
"Cannot block on two locks at once");
CONTRACTL_END;
Thread * pThread = GetThread();
-
- CONSISTENCY_CHECK_MSG(pThread != NULL,
- "Cannot do deadlock detection on non-EE thread");
CONSISTENCY_CHECK_MSG(pThread->m_pBlockingLock.Load() == NULL,
"Cannot block on two locks at once");
CONTRACTL_END;
Thread * pThread = GetThread();
-
- CONSISTENCY_CHECK_MSG(pThread != NULL,
- "Cannot do deadlock detection on non-EE thread");
CONSISTENCY_CHECK_MSG(pThread->m_pBlockingLock.Load() == NULL,
"Cannot block on two locks at once");
#endif
//<TODO>Clean this up</TODO>
- if (GetThread() == NULL)
+ if (GetThreadNULLOk() == NULL)
return TRUE;
#endif // FEATURE_HIJACK
-//***************************************************************************
-#ifdef ENABLE_CONTRACTS_IMPL
-inline Thread* GetThreadNULLOk()
-{
- LIMITED_METHOD_CONTRACT;
- Thread * pThread;
- BEGIN_GETTHREAD_ALLOWED_IN_NO_THROW_REGION;
- pThread = GetThread();
- END_GETTHREAD_ALLOWED_IN_NO_THROW_REGION;
- return pThread;
-}
-#else
-#define GetThreadNULLOk() GetThread()
-#endif
-
// manifest constant for waiting in the exposed classlibs
const INT32 INFINITE_TIMEOUT = -1;
void CommonTripThread();
+void SetupTLSForThread();
+
// When we resume a thread at a new location, to get an exception thrown, we have to
// pretend the exception originated elsewhere.
EXTERN_C void ThrowControlForThread(
#endif // DACCESS_COMPILE
friend class ProfToEEInterfaceImpl; // HRESULT ProfToEEInterfaceImpl::GetHandleFromThread(ThreadID threadId, HANDLE *phThread);
- friend void SetupTLSForThread(Thread* pThread);
-
friend class CheckAsmOffsets;
friend class ExceptionTracker;
static BOOL IsAddressInCurrentStack (PTR_VOID addr)
{
LIMITED_METHOD_DAC_CONTRACT;
- Thread* currentThread = GetThread();
+ Thread* currentThread = GetThreadNULLOk();
if (currentThread == NULL)
{
return FALSE;
WRAPPER_NO_CONTRACT;
// Note that GetThread() may be 0 if it is the debugger thread
// or perhaps a concurrent GC thread.
- return HoldingThreadStore(GetThread());
+ return HoldingThreadStore(GetThreadNULLOk());
}
static BOOL HoldingThreadStore(Thread *pThread);
if (m_WasCoop)
{
// m_WasCoop is only TRUE if we've already verified there's an EE thread.
- BEGIN_GETTHREAD_ALLOWED;
-
_ASSERTE(m_Thread != NULL); // Cannot switch to cooperative with no thread
if (!m_Thread->PreemptiveGCDisabled())
m_Thread->DisablePreemptiveGC();
-
- END_GETTHREAD_ALLOWED;
}
else
{
// when it's TRUE, so we check it for perf.
if (THREAD_EXISTS || m_Thread != NULL)
{
- BEGIN_GETTHREAD_ALLOWED;
if (m_Thread->PreemptiveGCDisabled())
m_Thread->EnablePreemptiveGC();
- END_GETTHREAD_ALLOWED;
}
}
if (m_Thread != NULL)
{
- BEGIN_GETTHREAD_ALLOWED;
m_WasCoop = m_Thread->PreemptiveGCDisabled();
if (conditional && !m_WasCoop)
m_Thread->DisablePreemptiveGC();
_ASSERTE(m_Thread->PreemptiveGCDisabled());
}
- END_GETTHREAD_ALLOWED;
}
else
{
m_fThreadMustExist = false;
if (m_Thread != NULL && conditional)
{
- BEGIN_GETTHREAD_ALLOWED;
GCHOLDER_CHECK_FOR_PREEMP_IN_NOTRIGGER(m_Thread);
- END_GETTHREAD_ALLOWED;
}
#endif // ENABLE_CONTRACTS_IMPL
if (m_Thread != NULL)
{
- BEGIN_GETTHREAD_ALLOWED;
m_WasCoop = m_Thread->PreemptiveGCDisabled();
if (conditional && m_WasCoop)
m_Thread->EnablePreemptiveGC();
_ASSERTE(!m_Thread->PreemptiveGCDisabled());
}
- END_GETTHREAD_ALLOWED;
}
else
{
{
// This is the perf version. So we deliberately restrict the calls
// to already setup threads to avoid the null checks and GetThread call
- _ASSERTE(pThread && (pThread == GetThread()));
+ _ASSERTE(pThread == GetThread());
#ifdef ENABLE_CONTRACTS_IMPL
m_fThreadMustExist = true;
#endif // ENABLE_CONTRACTS_IMPL
{
// This is the perf version. So we deliberately restrict the calls
// to already setup threads to avoid the null checks and GetThread call
- _ASSERTE(!THREAD_EXISTS || (pThread && (pThread == GetThread())));
+ _ASSERTE(!THREAD_EXISTS || (pThread == GetThread()));
#ifdef ENABLE_CONTRACTS_IMPL
m_fThreadMustExist = !!THREAD_EXISTS;
#endif // ENABLE_CONTRACTS_IMPL
FORCEINLINE void DoCheck()
{
WRAPPER_NO_CONTRACT;
- Thread *pThread = GetThread();
+ Thread *pThread = GetThreadNULLOk();
if (COOPERATIVE)
{
_ASSERTE(pThread != NULL);
inline BOOL GC_ON_TRANSITIONS(BOOL val) {
WRAPPER_NO_CONTRACT;
#ifdef _DEBUG
- Thread* thread = GetThread();
+ Thread* thread = GetThreadNULLOk();
if (thread == 0)
return(FALSE);
BOOL ret = thread->m_GCOnTransitionsOK;
static void ReleaseBlockingLock()
{
Thread *pThread = GetThread();
- _ASSERTE (pThread);
pThread->m_pBlockingLock = NULL;
}
public:
ThreadStateHolder (BOOL fNeed, DWORD state)
{
LIMITED_METHOD_CONTRACT;
- _ASSERTE (GetThread());
+ _ASSERTE (GetThreadNULLOk());
m_fNeed = fNeed;
m_state = state;
}
if (m_fNeed)
{
Thread *pThread = GetThread();
- _ASSERTE (pThread);
FastInterlockAnd((ULONG *) &pThread->m_State, ~m_state);
}
}
{
LIMITED_METHOD_CONTRACT;
- _ASSERTE (GetThread());
+ _ASSERTE (GetThreadNULLOk());
m_fNeed = fNeed;
m_state = state;
if (fNeed)
{
Thread *pThread = GetThread();
- _ASSERTE (pThread);
-
if (fNeed < 0)
{
// if the state is set, reset it
if (m_fNeed)
{
Thread *pThread = GetThread();
- _ASSERTE (pThread);
-
if (m_fNeed < 0)
{
pThread->SetThreadStateNC(m_state); // set it
EXTERN_C __thread ThreadLocalInfo gCurrentThreadInfo;
#endif
-EXTERN_C inline Thread* STDCALL GetThread()
+inline Thread* GetThreadNULLOk()
{
return gCurrentThreadInfo.m_pThread;
}
+inline Thread* GetThread()
+{
+ Thread* pThread = gCurrentThreadInfo.m_pThread;
+ _ASSERTE(pThread);
+ return pThread;
+}
+
EXTERN_C inline AppDomain* STDCALL GetAppDomain()
{
return AppDomain::GetCurrentDomain();
#endif
{
LIMITED_METHOD_CONTRACT;
- _ASSERTE(thread != nullptr);
_ASSERTE(thread == GetThread());
_ASSERTE(config != nullptr);
{
// Get the current thread
Thread * pThread = GetThread();
-
return &pThread->m_ThreadLocalBlock;
}
}
// We suspend the right thread
#ifdef _DEBUG
- Thread * pCurThread = GetThread();
+ Thread * pCurThread = GetThreadNULLOk();
if (pCurThread != NULL)
{
pCurThread->dbg_m_cSuspendedThreads ++;
_ASSERTE (!m_Creater.IsCurrentThread());
if ((res != (DWORD)-1) && (res != 0))
{
- Thread * pCurThread = GetThread();
+ Thread * pCurThread = GetThreadNULLOk();
if (pCurThread != NULL)
{
_ASSERTE(pCurThread->dbg_m_cSuspendedThreads > 0);
}
CONTRACTL_END;
- _ASSERTE(GetThread() != pThread);
+ _ASSERTE(GetThreadNULLOk() != pThread);
_ASSERTE(CheckPointer(pThread));
#ifndef DISABLE_THREADSUSPEND
// !!! is to check if the target thread is processing exception.
// !!! If exception is in flight, we don't induce ThreadAbort. Instead at the end of Jit_EndCatch
// !!! we will handle abort.
- if (pData->pAbortee != GetThread() && !IsFaultOrFinally(&EHClause))
+ if (pData->pAbortee != GetThreadNULLOk() && !IsFaultOrFinally(&EHClause))
{
continue;
}
return FALSE;
Thread *pThread = GetThread();
- _ASSERTE (pThread);
StackCrawlContext sContext = { pThread,
StackCrawlContext::SCC_CheckWithinCer,
FALSE,
return FALSE;
}
- if (GetThread() == this && HasThreadStateNC (TSNC_PreparingAbort) && !IsRudeAbort() )
+ if (GetThreadNULLOk() == this && HasThreadStateNC (TSNC_PreparingAbort) && !IsRudeAbort() )
{
STRESS_LOG0(LF_APPDOMAIN, LL_INFO10, "in Thread::ReadyForAbort PreparingAbort\n");
// Avoid recursive call
StackWalkFramesEx(&rd, TAStackCrawlCallBack, &TAContext, QUICKUNWIND, pStartFrame);
- _ASSERTE(TAContext.fHasManagedCodeOnStack || !IsAbortInitiated() || (GetThread() != this));
+ _ASSERTE(TAContext.fHasManagedCodeOnStack || !IsAbortInitiated() || (GetThreadNULLOk() != this));
if (TAContext.fWithinCer)
{
CONTRACTL
{
THROWS;
- if (GetThread()) {GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
+ if (GetThreadNULLOk()) {GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
}
CONTRACTL_END;
MarkThreadForAbort(abortType);
- Thread *pCurThread = GetThread();
+ Thread *pCurThread = GetThreadNULLOk();
// If aborting self
if (this == pCurThread)
CONTRACTL {
NOTHROW;
// any thread entering with `PreemptiveGCDisabled` should be prepared to switch mode, thus GC_TRIGGERS
- if ((GetThread() != NULL) && GetThread()->PreemptiveGCDisabled()) {GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
+ if ((GetThreadNULLOk() != NULL) && GetThread()->PreemptiveGCDisabled()) {GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
}
CONTRACTL_END;
{
BOOL gcOnTransitions;
- Thread *pCurThread = GetThread();
+ Thread *pCurThread = GetThreadNULLOk();
gcOnTransitions = GC_ON_TRANSITIONS(FALSE); // dont do GC for GCStress 3
// 10 of our COM BVTs.
if (!IsAtProcessExit())
{
- Thread *pCurThread = GetThread();
+ Thread *pCurThread = GetThreadNULLOk();
LOG((LF_SYNC, INFO3, "Unlocking thread store\n"));
- _ASSERTE(GetThread() == NULL || ThreadStore::s_pThreadStore->m_HoldingThread == GetThread());
+ _ASSERTE(pCurThread == NULL || ThreadStore::s_pThreadStore->m_HoldingThread == pCurThread);
#ifdef _DEBUG
// If Thread object has been destroyed, we need to reset the ownership info in Crst.
- _ASSERTE(!bThreadDestroyed || GetThread() == NULL);
+ _ASSERTE(!bThreadDestroyed || pCurThread == NULL);
if (bThreadDestroyed) {
ThreadStore::s_pThreadStore->m_Crst.m_holderthreadid.SetToCurrentThread();
}
// Get the thread handle
Thread *pThread = GetThread();
- _ASSERTE(pThread);
-
STRESS_LOG2(LF_SYNC, LL_INFO100, "In RedirectedHandledJITCaseExceptionFilter fDone = %d pFrame = %p\n", fDone, pFrame);
DWORD dwLastError = GetLastError(); // BEGIN_PRESERVE_LAST_ERROR
Thread *pThread = GetThread();
- _ASSERTE(pThread);
// Get the saved context
CONTEXT *pCtx = pThread->GetSavedRedirectContext();
CONTRACTL_END;
_ASSERTE(HandledJITCase());
- _ASSERTE(GetThread() != this);
+ _ASSERTE(GetThreadNULLOk() != this);
_ASSERTE(ThreadStore::HoldingThreadStore());
////////////////////////////////////////////////////////////////
}
CONTRACTL_END;
- _ASSERTE(this != GetThread());
+ _ASSERTE(this != GetThreadNULLOk());
_ASSERTE(PreemptiveGCDisabledOther());
_ASSERTE(IsAddrOfRedirectFunc(pRedirectTarget));
{
CONTRACTL {
NOTHROW;
- if (GetThread())
+ if (GetThreadNULLOk())
{
GC_TRIGGERS; // CLREvent::Wait is GC_TRIGGERS
}
CONTRACTL_END;
// This thread
- Thread *pCurThread = GetThread();
+ Thread *pCurThread = GetThreadNULLOk();
// Caller is expected to be holding the ThreadStore lock. Also, caller must
// have set GcInProgress before coming here, or things will break;
{
CONTRACTL {
NOTHROW;
- if (GetThread()) {GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
+ if (GetThreadNULLOk()) {GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
}
CONTRACTL_END;
- Thread *pCurThread = GetThread();
+ Thread *pCurThread = GetThreadNULLOk();
// Caller is expected to be holding the ThreadStore lock. But they must have
// reset GcInProgress, or threads will continue to suspend themselves and won't
// Get the thread handle
Thread *pThread = GetThread();
- _ASSERTE(pThread);
-
STRESS_LOG0(LF_SYNC, LL_INFO100, "In RedirectedThrowControlExceptionFilter\n");
STATIC_CONTRACT_GC_NOTRIGGER;
Thread *pThread = GetThread();
- _ASSERTE(pThread);
_ASSERTE(pThread->m_OSContext);
_ASSERTE(pThread->PreemptiveGCDisabled());
}
CONTRACTL_END;
- Thread *pCurThread = GetThread();
+ Thread *pCurThread = GetThreadNULLOk();
Thread *thread = NULL;
if (IsAtProcessExit())
// We assume that only the "real" helper thread ever calls this (not somebody doing helper thread duty).
PRECONDITION(ThreadStore::HoldingThreadStore());
PRECONDITION(IsDbgHelperSpecialThread());
- PRECONDITION(GetThread() == NULL);
+ PRECONDITION(GetThreadNULLOk() == NULL);
// Iff we return true, then we have the TSL (or the aux lock used in workarounds).
POSTCONDITION(ThreadStore::HoldingThreadStore());
#ifdef _DEBUG
// We know IP is in managed code, mark current thread as safe for calls into host
- Thread * pCurThread = GetThread();
+ Thread * pCurThread = GetThreadNULLOk();
if (pCurThread != NULL)
{
pCurThread->dbg_m_cSuspendedThreadsWithoutOSLock ++;
gcOnTransitions = GC_ON_TRANSITIONS(FALSE); // dont do GC for GCStress 3
- Thread* pCurThread = GetThread();
+ Thread* pCurThread = GetThreadNULLOk();
DWORD dwSwitchCount = 0;
// is in a function where we can safely inject activation.
BOOL CheckActivationSafePoint(SIZE_T ip, BOOL checkingCurrentThread)
{
- Thread *pThread = GetThread();
+ Thread *pThread = GetThreadNULLOk();
// It is safe to call the ExecutionManager::IsManagedCode only if we are making the check for
// a thread different from the current one or if the current thread is in the cooperative mode.
// Otherwise ExecutionManager::IsManagedCode could deadlock if the activation happened when the
return GCHeapUtilities::IsGCInProgress() &&
(dbgOnly_IsSpecialEEThread() ||
IsGCSpecialThread() ||
- GetThread() == ThreadSuspend::GetSuspensionThread());
+ GetThreadNULLOk() == ThreadSuspend::GetSuspensionThread());
}
#endif
{
#ifndef CROSSGEN_COMPILE
// Use the thread-local Random instance if possible
- Thread* pThread = GetThread();
+ Thread* pThread = GetThreadNULLOk();
if (pThread)
return pThread->GetRandom()->Next(maxVal);
#endif
// Check the current and shared domains.
{
- Thread *pThread = GetThread();
-
+ Thread *pThread = GetThreadNULLOk();
if (pThread != NULL)
{
// Check the current domain
Function(Context);
- Thread *pThread = GetThread();
+ Thread *pThread = GetThreadNULLOk();
if (pThread)
{
_ASSERTE(!pThread->IsAbortRequested());
CONTRACTL
{
NOTHROW;
- if (GetThread()) { GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
+ if (GetThreadNULLOk()) { GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
MODE_ANY;
}
CONTRACTL_END;
CONTRACTL
{
NOTHROW;
- if (GetThread()) { GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
+ if (GetThreadNULLOk()) { GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
MODE_ANY;
}
CONTRACTL_END;
DWORD dwNumberOfBytesTransfered,
LPOVERLAPPED lpOverlapped)
{
- Thread *pThread = GetThread();
+ Thread *pThread = GetThreadNULLOk();
if (pThread == NULL)
{
ClrFlsSetThreadType(ThreadType_Threadpool_Worker);
else
{
Thread* pCurThread = GetThread();
- _ASSERTE( pCurThread);
-
AppDomain* pAppDomain = pCurThread->GetDomain();
_ASSERTE(pAppDomain);
else
{
Thread* pCurThread = GetThread();
- _ASSERTE( pCurThread);
-
AppDomain* pAppDomain = pCurThread->GetDomain();
_ASSERTE(pAppDomain);
Thread* ThreadpoolMgr::CreateUnimpersonatedThread(LPTHREAD_START_ROUTINE lpStartAddress, LPVOID lpArgs, BOOL *pIsCLRThread)
{
STATIC_CONTRACT_NOTHROW;
- if (GetThread()) { STATIC_CONTRACT_GC_TRIGGERS;} else {DISABLED(STATIC_CONTRACT_GC_NOTRIGGER);}
+ if (GetThreadNULLOk()) { STATIC_CONTRACT_GC_TRIGGERS;} else {DISABLED(STATIC_CONTRACT_GC_NOTRIGGER);}
STATIC_CONTRACT_MODE_ANY;
/* cannot use contract because of SEH
CONTRACTL
{
CONTRACTL
{
- if (GetThread()) { GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
+ if (GetThreadNULLOk()) { GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
NOTHROW;
MODE_ANY; // We may try to add a worker thread while queuing a work item thru an fcall
}
{
// Reset TLS etc. for next WorkRequest.
if (pThread == NULL)
- pThread = GetThread();
+ pThread = GetThreadNULLOk();
if (pThread)
{
{
THROWS;
MODE_ANY;
- if (GetThread()) { GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
+ if (GetThreadNULLOk()) { GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
}
CONTRACTL_END;
}
CONTRACTL_END;
- Thread * pThread = GetThread();
-
+ Thread * pThread = GetThreadNULLOk();
if (pThread == NULL)
{
HRESULT hr = ERROR_SUCCESS;
{
if (waitInfo->ExternalEventSafeHandle != NULL) { THROWS;} else { NOTHROW; }
MODE_ANY;
- if (GetThread()) {GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
+ if (GetThreadNULLOk()) {GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
}
CONTRACTL_END;
CONTRACTL
{
THROWS; //NOTHROW;
- if (GetThread()) {GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
+ if (GetThreadNULLOk()) {GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
MODE_ANY;
}
CONTRACTL_END;
CONTRACTL
{
THROWS; // EnsureInitialized can throw
- if (GetThread()) { GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
+ if (GetThreadNULLOk()) { GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
MODE_ANY;
}
CONTRACTL_END;
CONTRACTL
{
NOTHROW;
- if (GetThread()) { GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
+ if (GetThreadNULLOk()) { GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
MODE_ANY;
}
CONTRACTL_END;
CONTRACTL
{
THROWS;
- if (GetThread()) { MODE_PREEMPTIVE;} else { DISABLED(MODE_ANY);}
- if (GetThread()) { GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
+ if (GetThreadNULLOk()) { MODE_PREEMPTIVE;} else { DISABLED(MODE_ANY);}
+ if (GetThreadNULLOk()) { GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
}
CONTRACTL_END;
if (pThread == NULL)
{
- pThread = GetThread();
+ pThread = GetThreadNULLOk();
}
if (pThread)
{
-
context = (PIOCompletionContext) pThread->GetIOCompletionContext();
if (context->lpOverlapped != NULL)
if (pThread == NULL)
{
- pThread = GetThread();
+ pThread = GetThreadNULLOk();
}
if (pThread)
{
CONTRACTL
{
- if (GetThread()) { GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
+ if (GetThreadNULLOk()) { GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
NOTHROW;
MODE_ANY;
}
CONTRACTL
{
THROWS; // EnsureInitialized, CreateAutoEvent can throw
- if (GetThread()) {GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);} // There can be calls thru ICorThreadpool
+ if (GetThreadNULLOk()) {GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);} // There can be calls thru ICorThreadpool
MODE_ANY;
INJECT_FAULT(COMPlusThrowOM());
}
CONTRACTL
{
THROWS; // QueueUserWorkItem can throw
- if (GetThread()) { GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
- if (GetThread()) { MODE_PREEMPTIVE;} else { DISABLED(MODE_ANY);}
+ if (GetThreadNULLOk()) { GC_TRIGGERS;} else {DISABLED(GC_NOTRIGGER);}
+ if (GetThreadNULLOk()) { MODE_PREEMPTIVE;} else { DISABLED(MODE_ANY);}
}
CONTRACTL_END;
}
CONTRACTL_END;
- Thread* pThread = GetThread();
-
+ Thread* pThread = GetThreadNULLOk();
if (pThread == NULL)
{
HRESULT hr = ERROR_SUCCESS;
}
CONTRACTL_END;
- Thread * pThread = GetThread();
-
+ Thread * pThread = GetThreadNULLOk();
if (pThread == NULL)
{
HRESULT hr = ERROR_SUCCESS;
{
CONTRACTL
{
- if (GetThread() == pTimerThread) { NOTHROW; } else { THROWS; }
+ if (GetThreadNULLOk() == pTimerThread) { NOTHROW; } else { THROWS; }
GC_TRIGGERS;
MODE_ANY;
}
}
// We cannot block the timer thread, so some cleanup is deferred to other threads.
- if (GetThread() == pTimerThread)
+ if (GetThreadNULLOk() == pTimerThread)
{
// Notify the ExternalEventSafeHandle with an user work item
if (timerInfo->ExternalEventSafeHandle != NULL)
// - This function wont go into an alertable state. That could trigger another APC.
// Else two threads can be queueing timerinfos and a race could
// lead to leaked memory and handles
- _ASSERTE(GetThread());
_ASSERTE(pTimerThread == GetThread());
TimerInfo *pHead = NULL;
{
_ASSERTE(timerInfo->ExternalEventSafeHandle == NULL);
_ASSERTE(timerInfo->ExternalCompletionEvent == INVALID_HANDLE);
- _ASSERTE(GetThread() != pTimerThread);
+ _ASSERTE(GetThreadNULLOk() != pTimerThread);
timerInfo->InternalCompletionEvent.Wait(INFINITE,TRUE /*alertable*/);
timerInfo->InternalCompletionEvent.CloseEvent();
WRAPPER_NO_CONTRACT;
_ASSERTE(!UsePortableThreadPool());
- Thread::IncrementWorkerThreadPoolCompletionCount(GetThread());
+ Thread::IncrementWorkerThreadPoolCompletionCount(GetThreadNULLOk());
UpdateLastDequeueTime();
}