diff options
author | Scott Mosier <smosier@microsoft.com> | 2016-05-06 19:42:11 +0300 |
---|---|---|
committer | Scott Mosier <smosier@microsoft.com> | 2016-05-06 19:42:11 +0300 |
commit | b3c52f6e4bfd714ce947fda83d5bf0b1c0813dcd (patch) | |
tree | cbdef2a3c6682ef6177286053c393fb02147bd05 /src/Native/Runtime/threadstore.cpp | |
parent | d912adb01743ce16bfe195808b697206f713a75d (diff) |
Fix two small issues in the runtime
1) Perf fix for thread attach during GC. The runtime holds the ThreadStore's ReaderWriterLock for the entire duration of a suspend-for-GC. This causes new threads to spin in the RWL code waiting on the GC to finish. I have added a check that shortcuts to the proper wait-on-an-event in this case.
2) Fix RhpCheckCctor2__SlowPath to properly preserve stack alignment on AMD64. This was found while experimenting with a PGO instrumented build of the runtime.
[tfs-changeset: 1602614]
Diffstat (limited to 'src/Native/Runtime/threadstore.cpp')
-rw-r--r-- | src/Native/Runtime/threadstore.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/Native/Runtime/threadstore.cpp b/src/Native/Runtime/threadstore.cpp index 2094a0c72..26403e0f5 100644 --- a/src/Native/Runtime/threadstore.cpp +++ b/src/Native/Runtime/threadstore.cpp @@ -138,6 +138,13 @@ void ThreadStore::AttachCurrentThread(bool fAcquireThreadStoreLock) pAttachingThread->Construct(); ASSERT(pAttachingThread->m_ThreadStateFlags == Thread::TSF_Unknown); + // The runtime holds the thread store lock for the duration of thread suspension for GC, so let's check to + // see if that's going on and, if so, use a proper wait instead of the RWL's spinning. NOTE: when we are + // called with fAcquireThreadStoreLock==false, we are being called in a situation where the GC is trying to + // init a GC thread, so we must honor the flag to mean "do not block on GC" or else we will deadlock. + if (fAcquireThreadStoreLock && (RhpTrapThreads != 0)) + RedhawkGCInterface::WaitForGCCompletion(); + ThreadStore* pTS = GetThreadStore(); ReaderWriterLock::WriteHolder write(&pTS->m_Lock, fAcquireThreadStoreLock); |