From: Aditya Mandaleeka Date: Wed, 12 Apr 2017 02:34:15 +0000 (-0700) Subject: Make a GCHandleStore class and interface for use by the VM. X-Git-Tag: submit/tizen/20210909.063632~11030^2~7258^2~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c924a42b986ff014af4750e7ab42cf24f2a3cd1e;p=platform%2Fupstream%2Fdotnet%2Fruntime.git Make a GCHandleStore class and interface for use by the VM. Commit migrated from https://github.com/dotnet/coreclr/commit/da00894a5d657b3ba06ebf6e004e5a5a0976434b --- diff --git a/src/coreclr/src/gc/gchandletable.cpp b/src/coreclr/src/gc/gchandletable.cpp index 82ab269..5a637d4 100644 --- a/src/coreclr/src/gc/gchandletable.cpp +++ b/src/coreclr/src/gc/gchandletable.cpp @@ -8,86 +8,94 @@ #include "gchandletableimpl.h" #include "objecthandle.h" +GCHandleStore* g_gcGlobalHandleStore; + IGCHandleTable* CreateGCHandleTable() { - return new(nothrow) GCHandleTable(); + return new (nothrow) GCHandleTable(); } -bool GCHandleTable::Initialize() +void GCHandleStore::Uproot() { - return Ref_Initialize(); + Ref_RemoveHandleTableBucket(_underlyingBucket); } -void GCHandleTable::Shutdown() +bool GCHandleStore::ContainsHandle(OBJECTHANDLE handle) { - Ref_Shutdown(); + return _underlyingBucket->Contains(handle); } -void* GCHandleTable::GetGlobalHandleStore() +OBJECTHANDLE GCHandleStore::CreateHandleOfType(Object* object, int type) { - return (void*)g_HandleTableMap.pBuckets[0]; + HHANDLETABLE handletable = _underlyingBucket->pTable[GetCurrentThreadHomeHeapNumber()]; + return ::HndCreateHandle(handletable, type, ObjectToOBJECTREF(object)); } -void* GCHandleTable::CreateHandleStore(void* context) +OBJECTHANDLE GCHandleStore::CreateHandleOfType(Object* object, int type, int heapToAffinitizeTo) { -#ifndef FEATURE_REDHAWK - return (void*)::Ref_CreateHandleTableBucket(ADIndex((DWORD)(uintptr_t)context)); -#else - assert("CreateHandleStore is not implemented when FEATURE_REDHAWK is defined!"); - return nullptr; -#endif + HHANDLETABLE handletable = _underlyingBucket->pTable[heapToAffinitizeTo]; + return ::HndCreateHandle(handletable, type, ObjectToOBJECTREF(object)); } -void* GCHandleTable::GetHandleContext(OBJECTHANDLE handle) +OBJECTHANDLE GCHandleStore::CreateHandleWithExtraInfo(Object* object, int type, void* pExtraInfo) { - return (void*)((uintptr_t)::HndGetHandleTableADIndex(::HndGetHandleTable(handle)).m_dwIndex); + HHANDLETABLE handletable = _underlyingBucket->pTable[GetCurrentThreadHomeHeapNumber()]; + return ::HndCreateHandle(handletable, type, ObjectToOBJECTREF(object), reinterpret_cast(pExtraInfo)); } -void GCHandleTable::DestroyHandleStore(void* store) +OBJECTHANDLE GCHandleStore::CreateDependentHandle(Object* primary, Object* secondary) { - Ref_DestroyHandleTableBucket((HandleTableBucket*) store); + HHANDLETABLE handletable = _underlyingBucket->pTable[GetCurrentThreadHomeHeapNumber()]; + OBJECTHANDLE handle = ::HndCreateHandle(handletable, HNDTYPE_DEPENDENT, ObjectToOBJECTREF(primary)); + ::SetDependentHandleSecondary(handle, ObjectToOBJECTREF(secondary)); + + return handle; } -void GCHandleTable::UprootHandleStore(void* store) +GCHandleStore::~GCHandleStore() { - Ref_RemoveHandleTableBucket((HandleTableBucket*) store); + Ref_DestroyHandleTableBucket(_underlyingBucket); } -bool GCHandleTable::ContainsHandle(void* store, OBJECTHANDLE handle) +bool GCHandleTable::Initialize() { - return ((HandleTableBucket*)store)->Contains(handle); + return Ref_Initialize(); } -OBJECTHANDLE GCHandleTable::CreateHandleOfType(void* store, Object* object, int type) +void GCHandleTable::Shutdown() { - HHANDLETABLE handletable = ((HandleTableBucket*)store)->pTable[GetCurrentThreadHomeHeapNumber()]; - return ::HndCreateHandle(handletable, type, ObjectToOBJECTREF(object)); + Ref_Shutdown(); } -OBJECTHANDLE GCHandleTable::CreateHandleOfType(void* store, Object* object, int type, int heapToAffinitizeTo) +IGCHandleStore* GCHandleTable::GetGlobalHandleStore() { - HHANDLETABLE handletable = ((HandleTableBucket*)store)->pTable[heapToAffinitizeTo]; - return ::HndCreateHandle(handletable, type, ObjectToOBJECTREF(object)); + return g_gcGlobalHandleStore; } -OBJECTHANDLE GCHandleTable::CreateGlobalHandleOfType(Object* object, int type) +IGCHandleStore* GCHandleTable::CreateHandleStore(void* context) { - return ::HndCreateHandle(g_HandleTableMap.pBuckets[0]->pTable[GetCurrentThreadHomeHeapNumber()], type, ObjectToOBJECTREF(object)); +#ifndef FEATURE_REDHAWK + HandleTableBucket* newBucket = ::Ref_CreateHandleTableBucket(ADIndex((DWORD)(uintptr_t)context)); + return new (nothrow) GCHandleStore(newBucket); +#else + assert("CreateHandleStore is not implemented when FEATURE_REDHAWK is defined!"); + return nullptr; +#endif } -OBJECTHANDLE GCHandleTable::CreateHandleWithExtraInfo(void* store, Object* object, int type, void* pExtraInfo) +void GCHandleTable::DestroyHandleStore(IGCHandleStore* store) { - HHANDLETABLE handletable = ((HandleTableBucket*)store)->pTable[GetCurrentThreadHomeHeapNumber()]; - return ::HndCreateHandle(handletable, type, ObjectToOBJECTREF(object), reinterpret_cast(pExtraInfo)); + delete store; } -OBJECTHANDLE GCHandleTable::CreateDependentHandle(void* store, Object* primary, Object* secondary) +void* GCHandleTable::GetHandleContext(OBJECTHANDLE handle) { - HHANDLETABLE handletable = ((HandleTableBucket*)store)->pTable[GetCurrentThreadHomeHeapNumber()]; - OBJECTHANDLE handle = ::HndCreateHandle(handletable, HNDTYPE_DEPENDENT, ObjectToOBJECTREF(primary)); - ::SetDependentHandleSecondary(handle, ObjectToOBJECTREF(secondary)); + return (void*)((uintptr_t)::HndGetHandleTableADIndex(::HndGetHandleTable(handle)).m_dwIndex); +} - return handle; +OBJECTHANDLE GCHandleTable::CreateGlobalHandleOfType(Object* object, int type) +{ + return ::HndCreateHandle(g_HandleTableMap.pBuckets[0]->pTable[GetCurrentThreadHomeHeapNumber()], type, ObjectToOBJECTREF(object)); } OBJECTHANDLE GCHandleTable::CreateDuplicateHandle(OBJECTHANDLE handle) diff --git a/src/coreclr/src/gc/gchandletableimpl.h b/src/coreclr/src/gc/gchandletableimpl.h index af20f52..1635c6e 100644 --- a/src/coreclr/src/gc/gchandletableimpl.h +++ b/src/coreclr/src/gc/gchandletableimpl.h @@ -6,33 +6,49 @@ #define GCHANDLETABLE_H_ #include "gcinterface.h" +#include "objecthandle.h" -class GCHandleTable : public IGCHandleTable +class GCHandleStore : public IGCHandleStore { public: - virtual bool Initialize(); + GCHandleStore(HandleTableBucket *bucket) + : _underlyingBucket(bucket) + { } - virtual void Shutdown(); + virtual void Uproot(); - virtual void* GetGlobalHandleStore(); + virtual bool ContainsHandle(OBJECTHANDLE handle); - virtual void* CreateHandleStore(void* context); + virtual OBJECTHANDLE CreateHandleOfType(Object* object, int type); - virtual void* GetHandleContext(OBJECTHANDLE handle); + virtual OBJECTHANDLE CreateHandleOfType(Object* object, int type, int heapToAffinitizeTo); - virtual void DestroyHandleStore(void* store); + virtual OBJECTHANDLE CreateHandleWithExtraInfo(Object* object, int type, void* pExtraInfo); - virtual void UprootHandleStore(void* store); + virtual OBJECTHANDLE CreateDependentHandle(Object* primary, Object* secondary); - virtual bool ContainsHandle(void* store, OBJECTHANDLE handle); + virtual ~GCHandleStore(); - virtual OBJECTHANDLE CreateHandleOfType(void* store, Object* object, int type); +private: + HandleTableBucket* _underlyingBucket; +}; + +extern GCHandleStore* g_gcGlobalHandleStore; + +class GCHandleTable : public IGCHandleTable +{ +public: + virtual bool Initialize(); + + virtual void Shutdown(); + + virtual void* GetHandleContext(OBJECTHANDLE handle); - virtual OBJECTHANDLE CreateHandleOfType(void* store, Object* object, int type, int heapToAffinitizeTo); + virtual IGCHandleStore* GetGlobalHandleStore(); - virtual OBJECTHANDLE CreateHandleWithExtraInfo(void* store, Object* object, int type, void* pExtraInfo); + virtual IGCHandleStore* CreateHandleStore(void* context); - virtual OBJECTHANDLE CreateDependentHandle(void* store, Object* primary, Object* secondary); + virtual void DestroyHandleStore(IGCHandleStore* store); virtual OBJECTHANDLE CreateGlobalHandleOfType(Object* object, int type); diff --git a/src/coreclr/src/gc/gcinterface.h b/src/coreclr/src/gc/gcinterface.h index cac2ba7..e4311fa 100644 --- a/src/coreclr/src/gc/gcinterface.h +++ b/src/coreclr/src/gc/gcinterface.h @@ -402,32 +402,38 @@ typedef struct OBJECTHANDLE__* OBJECTHANDLE; typedef uintptr_t OBJECTHANDLE; #endif -class IGCHandleTable { +class IGCHandleStore { public: - virtual bool Initialize() = 0; + virtual void Uproot() = 0; - virtual void Shutdown() = 0; + virtual bool ContainsHandle(OBJECTHANDLE handle) = 0; - virtual void* GetHandleContext(OBJECTHANDLE handle) = 0; + virtual OBJECTHANDLE CreateHandleOfType(Object* object, int type) = 0; + + virtual OBJECTHANDLE CreateHandleOfType(Object* object, int type, int heapToAffinitizeTo) = 0; + + virtual OBJECTHANDLE CreateHandleWithExtraInfo(Object* object, int type, void* pExtraInfo) = 0; - virtual void* GetGlobalHandleStore() = 0; + virtual OBJECTHANDLE CreateDependentHandle(Object* primary, Object* secondary) = 0; - virtual void* CreateHandleStore(void* context) = 0; + virtual ~IGCHandleStore() {}; +}; - virtual void DestroyHandleStore(void* store) = 0; +class IGCHandleTable { +public: - virtual void UprootHandleStore(void* store) = 0; + virtual bool Initialize() = 0; - virtual bool ContainsHandle(void* store, OBJECTHANDLE handle) = 0; + virtual void Shutdown() = 0; - virtual OBJECTHANDLE CreateHandleOfType(void* store, Object* object, int type) = 0; + virtual void* GetHandleContext(OBJECTHANDLE handle) = 0; - virtual OBJECTHANDLE CreateHandleOfType(void* store, Object* object, int type, int heapToAffinitizeTo) = 0; + virtual IGCHandleStore* GetGlobalHandleStore() = 0; - virtual OBJECTHANDLE CreateHandleWithExtraInfo(void* store, Object* object, int type, void* pExtraInfo) = 0; + virtual IGCHandleStore* CreateHandleStore(void* context) = 0; - virtual OBJECTHANDLE CreateDependentHandle(void* store, Object* primary, Object* secondary) = 0; + virtual void DestroyHandleStore(IGCHandleStore* store) = 0; virtual OBJECTHANDLE CreateGlobalHandleOfType(Object* object, int type) = 0; diff --git a/src/coreclr/src/gc/handletablecore.cpp b/src/coreclr/src/gc/handletablecore.cpp index 5776c26..edd0d94 100644 --- a/src/coreclr/src/gc/handletablecore.cpp +++ b/src/coreclr/src/gc/handletablecore.cpp @@ -1003,7 +1003,8 @@ void SegmentRelocateAsyncPinHandles (TableSegment *pSegment, HandleTable *pTarge overlapped->m_userObject = NULL; } BashMTForPinnedObject(ObjectToOBJECTREF(value)); - overlapped->m_pinSelf = CreateAsyncPinningHandle((HHANDLETABLE)pTargetTable,ObjectToOBJECTREF(value)); + + overlapped->m_pinSelf = HndCreateHandle((HHANDLETABLE)pTargetTable, HNDTYPE_ASYNCPINNED, ObjectToOBJECTREF(value)); *pValue = NULL; } pValue ++; diff --git a/src/coreclr/src/gc/objecthandle.cpp b/src/coreclr/src/gc/objecthandle.cpp index 5df53ba..f0a4fff 100644 --- a/src/coreclr/src/gc/objecthandle.cpp +++ b/src/coreclr/src/gc/objecthandle.cpp @@ -19,6 +19,8 @@ #include "objecthandle.h" #include "handletablepriv.h" +#include "gchandletableimpl.h" + #ifdef FEATURE_COMINTEROP #include "comcallablewrapper.h" #endif // FEATURE_COMINTEROP @@ -663,6 +665,10 @@ bool Ref_Initialize() g_HandleTableMap.dwMaxIndex = INITIAL_HANDLE_TABLE_ARRAY_SIZE; g_HandleTableMap.pNext = NULL; + g_gcGlobalHandleStore = new (nothrow) GCHandleStore(g_HandleTableMap.pBuckets[0]); + if (g_gcGlobalHandleStore == NULL) + goto CleanupAndFail; + // Allocate contexts used during dependent handle promotion scanning. There's one of these for every GC // heap since they're scanned in parallel. g_pDependentHandleContexts = new (nothrow) DhContext[n_slots]; @@ -672,6 +678,7 @@ bool Ref_Initialize() return true; } + CleanupAndFail: if (pBuckets != NULL) delete[] pBuckets; diff --git a/src/coreclr/src/vm/appdomain.cpp b/src/coreclr/src/vm/appdomain.cpp index 5bfb12f..3f7fd90 100644 --- a/src/coreclr/src/vm/appdomain.cpp +++ b/src/coreclr/src/vm/appdomain.cpp @@ -4578,7 +4578,7 @@ void AppDomain::Terminate() BaseDomain::Terminate(); - if (m_handleStore) + if (m_handleStore) { GCHandleTableUtilities::GetGCHandleTable()->DestroyHandleStore(m_handleStore); m_handleStore = NULL; @@ -9197,8 +9197,8 @@ void AppDomain::ClearGCHandles() // Keep async pin handles alive by moving them to default domain HandleAsyncPinHandles(); - // Remove our handle table as a source of GC roots - GCHandleTableUtilities::GetGCHandleTable()->UprootHandleStore(m_handleStore); + // 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. @@ -9247,15 +9247,13 @@ void AppDomain::ClearGCRoots() // this point, so only need to synchronize the preemptive mode threads. ExecutionManager::Unload(GetLoaderAllocator()); - IGCHandleTable* pHandleTable = GCHandleTableUtilities::GetGCHandleTable(); - while ((pThread = ThreadStore::GetAllThreadList(pThread, 0, 0)) != NULL) { // Delete the thread local static store pThread->DeleteThreadStaticData(this); // @TODO: A pre-allocated AppDomainUnloaded exception might be better. - if (pHandleTable->ContainsHandle(m_handleStore, pThread->m_LastThrownObjectHandle)) + if (m_handleStore->ContainsHandle(pThread->m_LastThrownObjectHandle)) { // Never delete a handle to a preallocated exception object. if (!CLRException::IsPreallocatedExceptionHandle(pThread->m_LastThrownObjectHandle)) diff --git a/src/coreclr/src/vm/appdomain.hpp b/src/coreclr/src/vm/appdomain.hpp index 898e50f..3b66435 100644 --- a/src/coreclr/src/vm/appdomain.hpp +++ b/src/coreclr/src/vm/appdomain.hpp @@ -1244,9 +1244,7 @@ public: OBJECTHANDLE CreateTypedHandle(OBJECTREF object, int type) { WRAPPER_NO_CONTRACT; - - IGCHandleTable *pHandleTable = GCHandleTableUtilities::GetGCHandleTable(); - return pHandleTable->CreateHandleOfType(m_handleStore, OBJECTREFToObject(object), type); + return m_handleStore->CreateHandleOfType(OBJECTREFToObject(object), type); } OBJECTHANDLE CreateHandle(OBJECTREF object) @@ -1345,8 +1343,7 @@ public: } CONTRACTL_END; - IGCHandleTable *pHandleTable = GCHandleTableUtilities::GetGCHandleTable(); - return pHandleTable->CreateDependentHandle(m_handleStore, OBJECTREFToObject(primary), OBJECTREFToObject(secondary)); + return m_handleStore->CreateDependentHandle(OBJECTREFToObject(primary), OBJECTREFToObject(secondary)); } #endif // DACCESS_COMPILE && !CROSSGEN_COMPILE @@ -1402,7 +1399,7 @@ protected: CLRPrivBinderCoreCLR *m_pTPABinderContext; // Reference to the binding context that holds TPA list details - void* m_handleStore; + IGCHandleStore* m_handleStore; // The large heap handle table. LargeHeapHandleTable *m_pLargeHeapHandleTable; diff --git a/src/coreclr/src/vm/exstate.cpp b/src/coreclr/src/vm/exstate.cpp index c598412..0dc902a 100644 --- a/src/coreclr/src/vm/exstate.cpp +++ b/src/coreclr/src/vm/exstate.cpp @@ -102,7 +102,7 @@ void ThreadExceptionState::FreeAllStackTraces() } } -void ThreadExceptionState::ClearThrowablesForUnload(void* handleStore) +void ThreadExceptionState::ClearThrowablesForUnload(IGCHandleStore* handleStore) { WRAPPER_NO_CONTRACT; @@ -112,13 +112,11 @@ void ThreadExceptionState::ClearThrowablesForUnload(void* handleStore) ExInfo* pNode = &m_currentExInfo; #endif // WIN64EXCEPTIONS - IGCHandleTable *pHandleTable = GCHandleTableUtilities::GetGCHandleTable(); - for ( ; pNode != NULL; pNode = pNode->m_pPrevNestedInfo) { - if (pHandleTable->ContainsHandle(handleStore, pNode->m_hThrowable)) + if (handleStore->ContainsHandle(pNode->m_hThrowable)) { pNode->DestroyExceptionHandle(); } diff --git a/src/coreclr/src/vm/exstate.h b/src/coreclr/src/vm/exstate.h index 104c76c..ba2ce2d 100644 --- a/src/coreclr/src/vm/exstate.h +++ b/src/coreclr/src/vm/exstate.h @@ -56,7 +56,7 @@ class ThreadExceptionState public: void FreeAllStackTraces(); - void ClearThrowablesForUnload(void* handleStore); + void ClearThrowablesForUnload(IGCHandleStore* handleStore); #ifdef _DEBUG typedef enum diff --git a/src/coreclr/src/vm/gchandletableutilities.h b/src/coreclr/src/vm/gchandletableutilities.h index 6e32add..fb1a680 100644 --- a/src/coreclr/src/vm/gchandletableutilities.h +++ b/src/coreclr/src/vm/gchandletableutilities.h @@ -64,54 +64,54 @@ inline BOOL ObjectHandleIsNull(OBJECTHANDLE handle) // Handle creation convenience functions -inline OBJECTHANDLE CreateHandle(void* table, OBJECTREF object) +inline OBJECTHANDLE CreateHandle(IGCHandleStore* store, OBJECTREF object) { - return GCHandleTableUtilities::GetGCHandleTable()->CreateHandleOfType(table, OBJECTREFToObject(object), HNDTYPE_DEFAULT); + return store->CreateHandleOfType(OBJECTREFToObject(object), HNDTYPE_DEFAULT); } -inline OBJECTHANDLE CreateWeakHandle(void* table, OBJECTREF object) +inline OBJECTHANDLE CreateWeakHandle(IGCHandleStore* store, OBJECTREF object) { - return GCHandleTableUtilities::GetGCHandleTable()->CreateHandleOfType(table, OBJECTREFToObject(object), HNDTYPE_WEAK_DEFAULT); + return store->CreateHandleOfType(OBJECTREFToObject(object), HNDTYPE_WEAK_DEFAULT); } -inline OBJECTHANDLE CreateShortWeakHandle(void* table, OBJECTREF object) +inline OBJECTHANDLE CreateShortWeakHandle(IGCHandleStore* store, OBJECTREF object) { - return GCHandleTableUtilities::GetGCHandleTable()->CreateHandleOfType(table, OBJECTREFToObject(object), HNDTYPE_WEAK_SHORT); + return store->CreateHandleOfType(OBJECTREFToObject(object), HNDTYPE_WEAK_SHORT); } -inline OBJECTHANDLE CreateLongWeakHandle(void* table, OBJECTREF object) +inline OBJECTHANDLE CreateLongWeakHandle(IGCHandleStore* store, OBJECTREF object) { - return GCHandleTableUtilities::GetGCHandleTable()->CreateHandleOfType(table, OBJECTREFToObject(object), HNDTYPE_WEAK_LONG); + return store->CreateHandleOfType(OBJECTREFToObject(object), HNDTYPE_WEAK_LONG); } -inline OBJECTHANDLE CreateStrongHandle(void* table, OBJECTREF object) +inline OBJECTHANDLE CreateStrongHandle(IGCHandleStore* store, OBJECTREF object) { - return GCHandleTableUtilities::GetGCHandleTable()->CreateHandleOfType(table, OBJECTREFToObject(object), HNDTYPE_STRONG); + return store->CreateHandleOfType(OBJECTREFToObject(object), HNDTYPE_STRONG); } -inline OBJECTHANDLE CreatePinningHandle(void* table, OBJECTREF object) +inline OBJECTHANDLE CreatePinningHandle(IGCHandleStore* store, OBJECTREF object) { - return GCHandleTableUtilities::GetGCHandleTable()->CreateHandleOfType(table, OBJECTREFToObject(object), HNDTYPE_PINNED); + return store->CreateHandleOfType(OBJECTREFToObject(object), HNDTYPE_PINNED); } -inline OBJECTHANDLE CreateAsyncPinningHandle(void* table, OBJECTREF object) +inline OBJECTHANDLE CreateAsyncPinningHandle(IGCHandleStore* store, OBJECTREF object) { - return GCHandleTableUtilities::GetGCHandleTable()->CreateHandleOfType(table, OBJECTREFToObject(object), HNDTYPE_ASYNCPINNED); + return store->CreateHandleOfType(OBJECTREFToObject(object), HNDTYPE_ASYNCPINNED); } -inline OBJECTHANDLE CreateRefcountedHandle(void* table, OBJECTREF object) +inline OBJECTHANDLE CreateRefcountedHandle(IGCHandleStore* store, OBJECTREF object) { - return GCHandleTableUtilities::GetGCHandleTable()->CreateHandleOfType(table, OBJECTREFToObject(object), HNDTYPE_REFCOUNTED); + return store->CreateHandleOfType(OBJECTREFToObject(object), HNDTYPE_REFCOUNTED); } -inline OBJECTHANDLE CreateSizedRefHandle(void* table, OBJECTREF object) +inline OBJECTHANDLE CreateSizedRefHandle(IGCHandleStore* store, OBJECTREF object) { - return GCHandleTableUtilities::GetGCHandleTable()->CreateHandleOfType(table, OBJECTREFToObject(object), HNDTYPE_SIZEDREF); + return store->CreateHandleOfType(OBJECTREFToObject(object), HNDTYPE_SIZEDREF); } -inline OBJECTHANDLE CreateSizedRefHandle(void* table, OBJECTREF object, int heapToAffinitizeTo) +inline OBJECTHANDLE CreateSizedRefHandle(IGCHandleStore* store, OBJECTREF object, int heapToAffinitizeTo) { - return GCHandleTableUtilities::GetGCHandleTable()->CreateHandleOfType(table, OBJECTREFToObject(object), HNDTYPE_SIZEDREF, heapToAffinitizeTo); + return store->CreateHandleOfType(OBJECTREFToObject(object), HNDTYPE_SIZEDREF, heapToAffinitizeTo); } // Global handle creation convenience functions @@ -157,22 +157,16 @@ inline OBJECTHANDLE CreateGlobalRefcountedHandle(OBJECTREF object) // Special handle creation convenience functions #ifdef FEATURE_COMINTEROP -inline OBJECTHANDLE CreateWinRTWeakHandle(void* table, OBJECTREF object, IWeakReference* pWinRTWeakReference) +inline OBJECTHANDLE CreateWinRTWeakHandle(IGCHandleStore* store, OBJECTREF object, IWeakReference* pWinRTWeakReference) { - return GCHandleTableUtilities::GetGCHandleTable()->CreateHandleWithExtraInfo(table, - OBJECTREFToObject(object), - HNDTYPE_WEAK_WINRT, - (void*)pWinRTWeakReference); + return store->CreateHandleWithExtraInfo(OBJECTREFToObject(object), HNDTYPE_WEAK_WINRT, (void*)pWinRTWeakReference); } #endif // FEATURE_COMINTEROP // Creates a variable-strength handle -inline OBJECTHANDLE CreateVariableHandle(void* table, OBJECTREF object, uint32_t type) +inline OBJECTHANDLE CreateVariableHandle(IGCHandleStore* store, OBJECTREF object, uint32_t type) { - return GCHandleTableUtilities::GetGCHandleTable()->CreateHandleWithExtraInfo(table, - OBJECTREFToObject(object), - HNDTYPE_VARIABLE, - (void*)((uintptr_t)type)); + return store->CreateHandleWithExtraInfo(OBJECTREFToObject(object), HNDTYPE_VARIABLE, (void*)((uintptr_t)type)); } // Handle destruction convenience functions