diff options
author | Jan Kotas <jkotas@microsoft.com> | 2018-06-09 13:39:58 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-09 13:39:58 -0700 |
commit | 911d332c523848023e3c6564788b72b7f419fca1 (patch) | |
tree | ae979e6b048630ed0393983d14bde5d43942459f /src/vm/appdomain.cpp | |
parent | 618f9c2d18e88566ac61f93529bac58123c50cba (diff) | |
download | coreclr-911d332c523848023e3c6564788b72b7f419fca1.tar.gz coreclr-911d332c523848023e3c6564788b72b7f419fca1.tar.bz2 coreclr-911d332c523848023e3c6564788b72b7f419fca1.zip |
Avoid NativeOverlapped pinning by allocating unmanaged memory for it (#18360)
It makes PinnableBufferCache unnecessary
Diffstat (limited to 'src/vm/appdomain.cpp')
-rw-r--r-- | src/vm/appdomain.cpp | 66 |
1 files changed, 0 insertions, 66 deletions
diff --git a/src/vm/appdomain.cpp b/src/vm/appdomain.cpp index 8a69a997a7..3766ed528a 100644 --- a/src/vm/appdomain.cpp +++ b/src/vm/appdomain.cpp @@ -8966,76 +8966,10 @@ void AppDomain::ClearGCHandles() GCHeapUtilities::GetGCHeap()->WaitUntilConcurrentGCComplete(); - // Keep async pin handles alive by moving them to default domain - HandleAsyncPinHandles(); - // Remove our handle store as a source of GC roots m_handleStore->Uproot(); } -// When an AD is unloaded, we will release all objects in this AD. -// If a future asynchronous operation, like io completion port function, -// we need to keep the memory space fixed so that the gc heap is not corrupted. -void AppDomain::HandleAsyncPinHandles() -{ - CONTRACTL - { - GC_TRIGGERS; - MODE_COOPERATIVE; - NOTHROW; - } - CONTRACTL_END; - - IGCHandleStore *pBucket = m_handleStore; - - // IO completion port picks IO job using FIFO. Here is how we know which AsyncPinHandle can be freed. - // 1. We mark all non-pending AsyncPinHandle with READYTOCLEAN. - // 2. We queue a dump Overlapped to the IO completion as a marker. - // 3. When the Overlapped is picked up by completion port, we wait until all previous IO jobs are processed. - // 4. Then we can delete all AsyncPinHandle marked with READYTOCLEAN. - IGCHandleStore *pBucketInDefault = SystemDomain::System()->DefaultDomain()->m_handleStore; - - auto clearIfComplete = [](Object* object) - { - LIMITED_METHOD_CONTRACT; - - assert(object != nullptr); - if (object->GetGCSafeMethodTable() != g_pOverlappedDataClass) - { - return; - } - - OVERLAPPEDDATAREF overlapped = (OVERLAPPEDDATAREF)(ObjectToOBJECTREF((Object*)object)); - if (overlapped->HasCompleted()) - { - // IO has finished. We don't need to pin the user buffer any longer. - overlapped->m_userObject = NULL; - } - - BashMTForPinnedObject(ObjectToOBJECTREF(object)); - }; - - auto setHandle = [](Object* object, OBJECTHANDLE handle) - { - LIMITED_METHOD_CONTRACT; - - assert(object != nullptr); - assert(handle); - - if (object->GetGCSafeMethodTable() != g_pOverlappedDataClass) - { - return; - } - - OverlappedDataObject* overlapped = (OverlappedDataObject*)object; - overlapped->m_pinSelf = handle; - }; - - pBucket->RelocateAsyncPinnedHandles(pBucketInDefault, clearIfComplete, setHandle); - - OverlappedDataObject::RequestCleanup(); -} - void AppDomain::ClearGCRoots() { CONTRACTL |