diff options
Diffstat (limited to 'src/vm/threadsuspend.cpp')
-rw-r--r-- | src/vm/threadsuspend.cpp | 70 |
1 files changed, 34 insertions, 36 deletions
diff --git a/src/vm/threadsuspend.cpp b/src/vm/threadsuspend.cpp index c71855f45f..2e6563da1e 100644 --- a/src/vm/threadsuspend.cpp +++ b/src/vm/threadsuspend.cpp @@ -754,6 +754,7 @@ static StackWalkAction TAStackCrawlCallBackWorker(CrawlFrame* pCf, StackCrawlCon } #undef METHODNAME +#ifdef FEATURE_CER // If we're asking about CERs and we don't yet have a definite answer either way then take a closer look at the current method. if (pData->eType & StackCrawlContext::SCC_CheckWithinCer && !pData->fUnprotectedCode && !pData->fWithinCer) { @@ -775,6 +776,7 @@ static StackWalkAction TAStackCrawlCallBackWorker(CrawlFrame* pCf, StackCrawlCon pData->fUnprotectedCode = true; } } +#endif // FEATURE_CER // If we weren't asked about EH clauses then we can return now (stop the stack trace if we have a definitive answer on the CER // question, move to the next frame otherwise). @@ -1122,6 +1124,7 @@ struct CerStackCrawlContext bool m_fWithinCer; // The result }; +#ifdef FEATURE_CER // Callback used on the stack crawl described above. StackWalkAction CerStackCrawlCallBack(CrawlFrame *pCf, void *pData) { @@ -1164,6 +1167,7 @@ StackWalkAction CerStackCrawlCallBack(CrawlFrame *pCf, void *pData) // Otherwise everything looks OK so far and we need to investigate the next frame. return SWA_CONTINUE; } +#endif // FEATURE_CER // Determine whether the method at the given depth in the thread's execution stack is executing within a CER. BOOL Thread::IsWithinCer(CrawlFrame *pCf) @@ -1175,6 +1179,9 @@ BOOL Thread::IsWithinCer(CrawlFrame *pCf) } CONTRACTL_END; +#ifndef FEATURE_CER + return FALSE; +#else // There had better be a method associated with this frame. MethodDesc *pMD = pCf->GetFunction(); _ASSERTE(pMD != NULL); @@ -1291,6 +1298,7 @@ BOOL Thread::IsWithinCer(CrawlFrame *pCf) _ASSERTE(!sContext.m_fFirstFrame); return sContext.m_fWithinCer; +#endif // FEATURE_CER } #if defined(_TARGET_AMD64_) && defined(FEATURE_HIJACK) @@ -3276,7 +3284,7 @@ void Thread::RareDisablePreemptiveGC() __SwitchToThread(0, CALLER_LIMITS_SPINNING); } - if (!GCHeap::IsGCHeapInitialized()) + if (!GCHeapUtilities::IsGCHeapInitialized()) { goto Exit; } @@ -3284,7 +3292,7 @@ void Thread::RareDisablePreemptiveGC() // Note IsGCInProgress is also true for say Pause (anywhere SuspendEE happens) and GCThread is the // thread that did the Pause. While in Pause if another thread attempts Rev/Pinvoke it should get inside the following and // block until resume - if (((GCHeap::IsGCInProgress() && (this != ThreadSuspend::GetSuspensionThread())) || + if (((GCHeapUtilities::IsGCInProgress() && (this != ThreadSuspend::GetSuspensionThread())) || (m_State & (TS_UserSuspendPending | TS_DebugSuspendPending | TS_StackCrawlNeeded))) && (!g_fSuspendOnShutdown || IsFinalizerThread() || IsShutdownSpecialThread())) { @@ -3350,7 +3358,7 @@ void Thread::RareDisablePreemptiveGC() DWORD status = S_OK; SetThreadStateNC(TSNC_WaitUntilGCFinished); - status = GCHeap::GetGCHeap()->WaitUntilGCComplete(); + status = GCHeapUtilities::GetGCHeap()->WaitUntilGCComplete(); ResetThreadStateNC(TSNC_WaitUntilGCFinished); if (status == (DWORD)COR_E_STACKOVERFLOW) @@ -3359,7 +3367,7 @@ void Thread::RareDisablePreemptiveGC() // 1. GC is suspending the process. GC needs to wait. // 2. GC is proceeding after suspension. The current thread needs to spin. SetThreadState(TS_BlockGCForSO); - while (GCHeap::IsGCInProgress() && m_fPreemptiveGCDisabled.Load() == 0) + while (GCHeapUtilities::IsGCInProgress() && m_fPreemptiveGCDisabled.Load() == 0) { #undef Sleep // We can not go to a host for blocking operation due ot lack of stack. @@ -3376,7 +3384,7 @@ void Thread::RareDisablePreemptiveGC() break; } } - if (!GCHeap::IsGCInProgress()) + if (!GCHeapUtilities::IsGCInProgress()) { if (HasThreadState(TS_StackCrawlNeeded)) { @@ -3411,7 +3419,7 @@ void Thread::RareDisablePreemptiveGC() // thread while in this loop. This happens if you use the COM+ // debugger to suspend this thread and then release it. - } while ((GCHeap::IsGCInProgress() && (this != ThreadSuspend::GetSuspensionThread())) || + } while ((GCHeapUtilities::IsGCInProgress() && (this != ThreadSuspend::GetSuspensionThread())) || (m_State & (TS_UserSuspendPending | TS_DebugSuspendPending | TS_StackCrawlNeeded))); } STRESS_LOG0(LF_SYNC, LL_INFO1000, "RareDisablePreemptiveGC: leaving\n"); @@ -3705,7 +3713,7 @@ void Thread::PerformPreemptiveGC() if (!GCStressPolicy::IsEnabled() || !GCStress<cfg_transition>::IsEnabled()) return; - if (!GCHeap::IsGCHeapInitialized()) + if (!GCHeapUtilities::IsGCHeapInitialized()) return; if (!m_GCOnTransitionsOK @@ -3713,8 +3721,8 @@ void Thread::PerformPreemptiveGC() || RawGCNoTrigger() #endif || g_fEEShutDown - || GCHeap::IsGCInProgress(TRUE) - || GCHeap::GetGCHeap()->GetGcCount() == 0 // Need something that works for isolated heap. + || GCHeapUtilities::IsGCInProgress(TRUE) + || GCHeapUtilities::GetGCHeap()->GetGcCount() == 0 // Need something that works for isolated heap. || ThreadStore::HoldingThreadStore()) return; @@ -3738,7 +3746,7 @@ void Thread::PerformPreemptiveGC() { GCX_COOP(); m_bGCStressing = TRUE; - GCHeap::GetGCHeap()->StressHeap(); + GCHeapUtilities::GetGCHeap()->StressHeap(); m_bGCStressing = FALSE; } m_GCOnTransitionsOK = TRUE; @@ -4846,7 +4854,7 @@ HRESULT ThreadSuspend::SuspendRuntime(ThreadSuspend::SUSPEND_REASON reason) // Caller is expected to be holding the ThreadStore lock. Also, caller must // have set GcInProgress before coming here, or things will break; _ASSERTE(ThreadStore::HoldingThreadStore() || IsAtProcessExit()); - _ASSERTE(GCHeap::IsGCInProgress() ); + _ASSERTE(GCHeapUtilities::IsGCInProgress() ); STRESS_LOG1(LF_SYNC, LL_INFO1000, "Thread::SuspendRuntime(reason=0x%x)\n", reason); @@ -5547,7 +5555,7 @@ void ThreadSuspend::ResumeRuntime(BOOL bFinishedGC, BOOL SuspendSucceded) // reset GcInProgress, or threads will continue to suspend themselves and won't // be resumed until the next GC. _ASSERTE(IsGCSpecialThread() || ThreadStore::HoldingThreadStore()); - _ASSERTE(!GCHeap::IsGCInProgress() ); + _ASSERTE(!GCHeapUtilities::IsGCInProgress() ); STRESS_LOG2(LF_SYNC, LL_INFO1000, "Thread::ResumeRuntime(finishedGC=%d, SuspendSucceeded=%d) - Start\n", bFinishedGC, SuspendSucceded); @@ -5564,7 +5572,7 @@ void ThreadSuspend::ResumeRuntime(BOOL bFinishedGC, BOOL SuspendSucceded) { // If we the suspension was for a GC, tell the host what generation GC. DWORD Generation = (bFinishedGC - ? GCHeap::GetGCHeap()->GetCondemnedGeneration() + ? GCHeapUtilities::GetGCHeap()->GetCondemnedGeneration() : ~0U); pGCThreadControl->SuspensionEnding(Generation); @@ -5574,7 +5582,7 @@ void ThreadSuspend::ResumeRuntime(BOOL bFinishedGC, BOOL SuspendSucceded) { // If we the suspension was for a GC, tell the host what generation GC. DWORD Generation = (bFinishedGC - ? GCHeap::GetGCHeap()->GetCondemnedGeneration() + ? GCHeapUtilities::GetGCHeap()->GetCondemnedGeneration() : ~0U); BEGIN_SO_TOLERANT_CODE_CALLING_HOST(GetThread()); @@ -7275,18 +7283,8 @@ ReturnKind GetReturnKindFromMethodTable(Thread *pThread, EECodeInfo *codeInfo) ReturnKind GetReturnKind(Thread *pThread, EECodeInfo *codeInfo) { - ReturnKind returnKind = RT_Illegal; - -#ifdef _TARGET_X86_ - // X86 GCInfo updates yet to be implemented. -#else GCInfoToken gcInfoToken = codeInfo->GetGCInfoToken(); - if (gcInfoToken.IsReturnKindAvailable()) - { - GcInfoDecoder gcInfoDecoder(gcInfoToken, DECODE_RETURN_KIND); - returnKind = gcInfoDecoder.GetReturnKind(); - } -#endif // _TARGET_X86_ + ReturnKind returnKind = codeInfo->GetCodeManager()->GetReturnKind(gcInfoToken); if (!IsValidReturnKind(returnKind)) { @@ -7312,7 +7310,7 @@ VOID * GetHijackAddr(Thread *pThread, EECodeInfo *codeInfo) #ifdef _TARGET_X86_ if (returnKind == RT_Float) { - return reinterpret_cast<VOID *>(OnHijackTripThread); + return reinterpret_cast<VOID *>(OnHijackFPTripThread); } #endif // _TARGET_X86_ @@ -7898,7 +7896,7 @@ void ThreadSuspend::RestartEE(BOOL bFinishedGC, BOOL SuspendSucceded) // Revert to being a normal thread // ClrFlsClearThreadType (ThreadType_DynamicSuspendEE); - GCHeap::GetGCHeap()->SetGCInProgress(FALSE); + GCHeapUtilities::GetGCHeap()->SetGCInProgress(FALSE); // // Allow threads to enter COOP mode (though we still need to wake the ones @@ -7906,7 +7904,7 @@ void ThreadSuspend::RestartEE(BOOL bFinishedGC, BOOL SuspendSucceded) // // Note: this is the last barrier that keeps managed threads // from entering cooperative mode. If the sequence changes, - // you may have to change routine GCHeap::SafeToRestartManagedThreads + // you may have to change routine GCHeapUtilities::SafeToRestartManagedThreads // as well. // ThreadStore::TrapReturningThreads(FALSE); @@ -7915,7 +7913,7 @@ void ThreadSuspend::RestartEE(BOOL bFinishedGC, BOOL SuspendSucceded) // // Any threads that are waiting in WaitUntilGCComplete will continue now. // - GCHeap::GetGCHeap()->GetWaitForGCEvent()->Set(); + GCHeapUtilities::GetGCHeap()->GetWaitForGCEvent()->Set(); _ASSERTE(IsGCSpecialThread() || ThreadStore::HoldingThreadStore()); ResumeRuntime(bFinishedGC, SuspendSucceded); @@ -7964,7 +7962,7 @@ void ThreadSuspend::SuspendEE(SUSPEND_REASON reason) ETW::GCLog::ETW_GC_INFO Info; Info.SuspendEE.Reason = reason; Info.SuspendEE.GcCount = (((reason == SUSPEND_FOR_GC) || (reason == SUSPEND_FOR_GC_PREP)) ? - (ULONG)GCHeap::GetGCHeap()->GetGcCount() : (ULONG)-1); + (ULONG)GCHeapUtilities::GetGCHeap()->GetGcCount() : (ULONG)-1); FireEtwGCSuspendEEBegin_V1(Info.SuspendEE.Reason, Info.SuspendEE.GcCount, GetClrInstanceId()); @@ -8041,7 +8039,7 @@ retry_for_debugger: // // First, we reset the event that we're about to tell other threads to wait for. // - GCHeap::GetGCHeap()->GetWaitForGCEvent()->Reset(); + GCHeapUtilities::GetGCHeap()->GetWaitForGCEvent()->Reset(); // // Remember that we're the one doing the GC. Actually, maybe we're not doing a GC - @@ -8066,7 +8064,7 @@ retry_for_debugger: // It seems like much of the above is redundant. We should investigate reducing the number // of mechanisms we use to indicate that a suspension is in progress. // - GCHeap::GetGCHeap()->SetGCInProgress(TRUE); + GCHeapUtilities::GetGCHeap()->SetGCInProgress(TRUE); // // Gratuitous memory barrier. (may be needed - but I'm not sure why.) @@ -8214,7 +8212,7 @@ retry_for_debugger: // This function is called by PAL to check if the specified instruction pointer // is in a function where we can safely inject activation. -BOOL PALAPI CheckActivationSafePoint(SIZE_T ip, BOOL checkingCurrentThread) +BOOL CheckActivationSafePoint(SIZE_T ip, BOOL checkingCurrentThread) { Thread *pThread = GetThread(); // It is safe to call the ExecutionManager::IsManagedCode only if we are making the check for @@ -8241,7 +8239,7 @@ BOOL PALAPI CheckActivationSafePoint(SIZE_T ip, BOOL checkingCurrentThread) // address to take the thread to the appropriate stub (based on the return // type of the method) which will then handle preparing the thread for GC. // -void PALAPI HandleGCSuspensionForInterruptedThread(CONTEXT *interruptedContext) +void HandleGCSuspensionForInterruptedThread(CONTEXT *interruptedContext) { Thread *pThread = GetThread(); @@ -8357,7 +8355,7 @@ void ThreadSuspend::Initialize() BOOL Debug_IsLockedViaThreadSuspension() { LIMITED_METHOD_CONTRACT; - return GCHeap::IsGCInProgress() && + return GCHeapUtilities::IsGCInProgress() && (dbgOnly_IsSpecialEEThread() || IsGCSpecialThread() || GetThread() == ThreadSuspend::GetSuspensionThread()); @@ -8485,7 +8483,7 @@ void SuspendStatistics::EndSuspend(BOOL bForGC) // details on suspends... if (!bForGC) cntNonGCSuspends++; - if (GCHeap::GetGCHeap()->IsConcurrentGCInProgress()) + if (GCHeapUtilities::GetGCHeap()->IsConcurrentGCInProgress()) { cntSuspendsInBGC++; if (!bForGC) |