diff options
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 |