@@ -740,10 +740,10 @@ BaseDomain::BaseDomain()
740
740
m_pLargeHeapHandleTable = NULL ;
741
741
742
742
#ifndef CROSSGEN_COMPILE
743
- // Note that m_hHandleTableBucket is overridden by app domains
744
- m_hHandleTableBucket = g_HandleTableMap. pBuckets [ 0 ] ;
743
+ // Note that m_handleStore is overridden by app domains
744
+ m_handleStore = GCHandleTableUtilities::GetGCHandleTable ()-> GetGlobalHandleStore () ;
745
745
#else
746
- m_hHandleTableBucket = NULL ;
746
+ m_handleStore = NULL ;
747
747
#endif
748
748
749
749
m_pMarshalingData = NULL ;
@@ -993,17 +993,6 @@ void BaseDomain::InitVSD()
993
993
}
994
994
995
995
#ifndef CROSSGEN_COMPILE
996
- BOOL BaseDomain::ContainsOBJECTHANDLE (OBJECTHANDLE handle)
997
- {
998
- CONTRACTL
999
- {
1000
- NOTHROW;
1001
- GC_NOTRIGGER;
1002
- }
1003
- CONTRACTL_END;
1004
-
1005
- return Ref_ContainHandle (m_hHandleTableBucket,handle);
1006
- }
1007
996
1008
997
DWORD BaseDomain::AllocateContextStaticsOffset (DWORD* pOffsetSlot)
1009
998
{
@@ -4053,7 +4042,7 @@ AppDomain::AppDomain()
4053
4042
m_pUMEntryThunkCache = NULL ;
4054
4043
4055
4044
m_pAsyncPool = NULL ;
4056
- m_hHandleTableBucket = NULL ;
4045
+ m_handleStore = NULL ;
4057
4046
4058
4047
m_ExposedObject = NULL ;
4059
4048
m_pComIPForExposedObject = NULL ;
@@ -4284,18 +4273,13 @@ void AppDomain::Init()
4284
4273
// default domain cannot be unloaded.
4285
4274
if (GetId ().m_dwId == DefaultADID)
4286
4275
{
4287
- m_hHandleTableBucket = g_HandleTableMap. pBuckets [ 0 ] ;
4276
+ m_handleStore = GCHandleTableUtilities::GetGCHandleTable ()-> GetGlobalHandleStore () ;
4288
4277
}
4289
4278
else
4290
4279
{
4291
- m_hHandleTableBucket = Ref_CreateHandleTableBucket ( m_dwIndex);
4280
+ m_handleStore = GCHandleTableUtilities::GetGCHandleTable ()-> CreateHandleStore (( void *)( uintptr_t )m_dwIndex. m_dwIndex );
4292
4281
}
4293
4282
4294
- #ifdef _DEBUG
4295
- if (((HandleTable *)(m_hHandleTableBucket->pTable [0 ]))->uADIndex != m_dwIndex)
4296
- _ASSERTE (!" AD index mismatch" );
4297
- #endif // _DEBUG
4298
-
4299
4283
#endif // CROSSGEN_COMPILE
4300
4284
4301
4285
#ifdef FEATURE_TYPEEQUIVALENCE
@@ -4594,16 +4578,10 @@ void AppDomain::Terminate()
4594
4578
4595
4579
BaseDomain::Terminate ();
4596
4580
4597
- #ifdef _DEBUG
4598
- if (m_hHandleTableBucket &&
4599
- m_hHandleTableBucket->pTable &&
4600
- ((HandleTable *)(m_hHandleTableBucket->pTable [0 ]))->uADIndex != m_dwIndex)
4601
- _ASSERTE (!" AD index mismatch" );
4602
- #endif // _DEBUG
4603
-
4604
- if (m_hHandleTableBucket) {
4605
- Ref_DestroyHandleTableBucket (m_hHandleTableBucket);
4606
- m_hHandleTableBucket = NULL ;
4581
+ if (m_handleStore)
4582
+ {
4583
+ GCHandleTableUtilities::GetGCHandleTable ()->DestroyHandleStore (m_handleStore);
4584
+ m_handleStore = NULL ;
4607
4585
}
4608
4586
4609
4587
#ifdef FEATURE_APPDOMAIN_RESOURCE_MONITORING
@@ -9220,14 +9198,7 @@ void AppDomain::ClearGCHandles()
9220
9198
HandleAsyncPinHandles ();
9221
9199
9222
9200
// Remove our handle table as a source of GC roots
9223
- HandleTableBucket *pBucket = m_hHandleTableBucket;
9224
-
9225
- #ifdef _DEBUG
9226
- if (((HandleTable *)(pBucket->pTable [0 ]))->uADIndex != m_dwIndex)
9227
- _ASSERTE (!" AD index mismatch" );
9228
- #endif // _DEBUG
9229
-
9230
- Ref_RemoveHandleTableBucket (pBucket);
9201
+ GCHandleTableUtilities::GetGCHandleTable ()->UprootHandleStore (m_handleStore);
9231
9202
}
9232
9203
9233
9204
// When an AD is unloaded, we will release all objects in this AD.
@@ -9243,13 +9214,17 @@ void AppDomain::HandleAsyncPinHandles()
9243
9214
}
9244
9215
CONTRACTL_END;
9245
9216
9246
- HandleTableBucket *pBucket = m_hHandleTableBucket;
9217
+ // TODO: Temporarily casting stuff here until Ref_RelocateAsyncPinHandles is moved to the interface.
9218
+ HandleTableBucket *pBucket = (HandleTableBucket*)m_handleStore;
9219
+
9247
9220
// IO completion port picks IO job using FIFO. Here is how we know which AsyncPinHandle can be freed.
9248
9221
// 1. We mark all non-pending AsyncPinHandle with READYTOCLEAN.
9249
9222
// 2. We queue a dump Overlapped to the IO completion as a marker.
9250
9223
// 3. When the Overlapped is picked up by completion port, we wait until all previous IO jobs are processed.
9251
9224
// 4. Then we can delete all AsyncPinHandle marked with READYTOCLEAN.
9252
- HandleTableBucket *pBucketInDefault = SystemDomain::System ()->DefaultDomain ()->m_hHandleTableBucket ;
9225
+ HandleTableBucket *pBucketInDefault = (HandleTableBucket*)SystemDomain::System ()->DefaultDomain ()->m_handleStore ;
9226
+
9227
+ // TODO: When this function is moved to the interface it will take void*s
9253
9228
Ref_RelocateAsyncPinHandles (pBucket, pBucketInDefault);
9254
9229
9255
9230
OverlappedDataObject::RequestCleanup ();
@@ -9272,14 +9247,15 @@ void AppDomain::ClearGCRoots()
9272
9247
// this point, so only need to synchronize the preemptive mode threads.
9273
9248
ExecutionManager::Unload (GetLoaderAllocator ());
9274
9249
9250
+ IGCHandleTable* pHandleTable = GCHandleTableUtilities::GetGCHandleTable ();
9251
+
9275
9252
while ((pThread = ThreadStore::GetAllThreadList (pThread, 0 , 0 )) != NULL )
9276
9253
{
9277
9254
// Delete the thread local static store
9278
9255
pThread->DeleteThreadStaticData (this );
9279
9256
9280
-
9281
9257
// <TODO>@TODO: A pre-allocated AppDomainUnloaded exception might be better.</TODO>
9282
- if (m_hHandleTableBucket-> Contains ( pThread->m_LastThrownObjectHandle ))
9258
+ if (pHandleTable-> ContainsHandle (m_handleStore, pThread->m_LastThrownObjectHandle ))
9283
9259
{
9284
9260
// Never delete a handle to a preallocated exception object.
9285
9261
if (!CLRException::IsPreallocatedExceptionHandle (pThread->m_LastThrownObjectHandle ))
@@ -9291,7 +9267,7 @@ void AppDomain::ClearGCRoots()
9291
9267
}
9292
9268
9293
9269
// Clear out the exceptions objects held by a thread.
9294
- pThread->GetExceptionState ()->ClearThrowablesForUnload (m_hHandleTableBucket );
9270
+ pThread->GetExceptionState ()->ClearThrowablesForUnload (m_handleStore );
9295
9271
}
9296
9272
9297
9273
// delete them while we still have the runtime suspended
0 commit comments