summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean Gillespie <segilles@microsoft.com>2017-06-15 12:45:12 -0700
committerGitHub <noreply@github.com>2017-06-15 12:45:12 -0700
commitdda6b6136e21901842758970d831f31687913a35 (patch)
tree07ea3363dc390bb6cda64975ba3e911711e115bf
parentd734877cd86016296fc6c6e884a2b119339545ec (diff)
downloadcoreclr-dda6b6136e21901842758970d831f31687913a35.tar.gz
coreclr-dda6b6136e21901842758970d831f31687913a35.tar.bz2
coreclr-dda6b6136e21901842758970d831f31687913a35.zip
[Local GC] Fix a number of handle table interface violations (#12277)
* Fix a smattering of GC handle table interface violations Stub out a few other handle violations * [Local GC] Add SetExtraInfoForHandle onto GC handle manager interface * [Local GC] Changes uses of HndGetHandleADIndex to GetHandleContext * Add HandleGetType to GC handle table interface 1) Change IGCHandleManager methods that take "int" to represent the type of a handle to HandleType, and fix callers to cast to HandleType 2) Add HandleFetchType to IGCHandleManager, returning a HandleType 3) Fix uses of handtablepriv's HandleFetchType and remove the GC directory from the include path * 9 -> HNDTYPE_WEAK_WINRT, 0 -> HNDTYPE_WEAK_SHORT in assert
-rw-r--r--src/debug/ee/debugger.cpp3
-rw-r--r--src/gc/gchandletable.cpp24
-rw-r--r--src/gc/gchandletableimpl.h14
-rw-r--r--src/gc/gcinterface.h14
-rw-r--r--src/vm/CMakeLists.txt3
-rw-r--r--src/vm/appdomain.cpp9
-rw-r--r--src/vm/appdomain.hpp2
-rw-r--r--src/vm/encee.cpp9
-rw-r--r--src/vm/gcenv.os.cpp2
-rw-r--r--src/vm/gcheaputilities.cpp5
-rw-r--r--src/vm/marshalnative.cpp8
-rw-r--r--src/vm/rcwrefcache.cpp10
-rw-r--r--src/vm/runtimehandles.cpp3
-rw-r--r--src/vm/weakreferencenative.cpp18
14 files changed, 74 insertions, 50 deletions
diff --git a/src/debug/ee/debugger.cpp b/src/debug/ee/debugger.cpp
index f8ebfc56fe..fdbbe69ec1 100644
--- a/src/debug/ee/debugger.cpp
+++ b/src/debug/ee/debugger.cpp
@@ -10999,7 +10999,8 @@ bool Debugger::HandleIPCEvent(DebuggerIPCEvent * pEvent)
if(fValid)
{
// Get the appdomain
- ADIndex appDomainIndex = HndGetHandleADIndex(objectHandle);
+ IGCHandleManager *mgr = GCHandleUtilities::GetGCHandleManager();
+ ADIndex appDomainIndex = ADIndex(reinterpret_cast<DWORD>(mgr->GetHandleContext(objectHandle)));
pAppDomain = SystemDomain::GetAppDomainAtIndex(appDomainIndex);
_ASSERTE(pAppDomain != NULL);
diff --git a/src/gc/gchandletable.cpp b/src/gc/gchandletable.cpp
index 63f2f79711..38ca0cdd6d 100644
--- a/src/gc/gchandletable.cpp
+++ b/src/gc/gchandletable.cpp
@@ -7,6 +7,7 @@
#include "gcenv.h"
#include "gchandletableimpl.h"
#include "objecthandle.h"
+#include "handletablepriv.h"
GCHandleStore* g_gcGlobalHandleStore;
@@ -25,19 +26,19 @@ bool GCHandleStore::ContainsHandle(OBJECTHANDLE handle)
return _underlyingBucket.Contains(handle);
}
-OBJECTHANDLE GCHandleStore::CreateHandleOfType(Object* object, int type)
+OBJECTHANDLE GCHandleStore::CreateHandleOfType(Object* object, HandleType type)
{
HHANDLETABLE handletable = _underlyingBucket.pTable[GetCurrentThreadHomeHeapNumber()];
return ::HndCreateHandle(handletable, type, ObjectToOBJECTREF(object));
}
-OBJECTHANDLE GCHandleStore::CreateHandleOfType(Object* object, int type, int heapToAffinitizeTo)
+OBJECTHANDLE GCHandleStore::CreateHandleOfType(Object* object, HandleType type, int heapToAffinitizeTo)
{
HHANDLETABLE handletable = _underlyingBucket.pTable[heapToAffinitizeTo];
return ::HndCreateHandle(handletable, type, ObjectToOBJECTREF(object));
}
-OBJECTHANDLE GCHandleStore::CreateHandleWithExtraInfo(Object* object, int type, void* pExtraInfo)
+OBJECTHANDLE GCHandleStore::CreateHandleWithExtraInfo(Object* object, HandleType type, void* pExtraInfo)
{
HHANDLETABLE handletable = _underlyingBucket.pTable[GetCurrentThreadHomeHeapNumber()];
return ::HndCreateHandle(handletable, type, ObjectToOBJECTREF(object), reinterpret_cast<uintptr_t>(pExtraInfo));
@@ -124,7 +125,7 @@ void* GCHandleManager::GetHandleContext(OBJECTHANDLE handle)
return (void*)((uintptr_t)::HndGetHandleTableADIndex(::HndGetHandleTable(handle)).m_dwIndex);
}
-OBJECTHANDLE GCHandleManager::CreateGlobalHandleOfType(Object* object, int type)
+OBJECTHANDLE GCHandleManager::CreateGlobalHandleOfType(Object* object, HandleType type)
{
return ::HndCreateHandle(g_HandleTableMap.pBuckets[0]->pTable[GetCurrentThreadHomeHeapNumber()], type, ObjectToOBJECTREF(object));
}
@@ -134,7 +135,7 @@ OBJECTHANDLE GCHandleManager::CreateDuplicateHandle(OBJECTHANDLE handle)
return ::HndCreateHandle(HndGetHandleTable(handle), HNDTYPE_DEFAULT, ::HndFetchHandle(handle));
}
-void GCHandleManager::DestroyHandleOfType(OBJECTHANDLE handle, int type)
+void GCHandleManager::DestroyHandleOfType(OBJECTHANDLE handle, HandleType type)
{
::HndDestroyHandle(::HndGetHandleTable(handle), type, handle);
}
@@ -144,6 +145,11 @@ void GCHandleManager::DestroyHandleOfUnknownType(OBJECTHANDLE handle)
::HndDestroyHandleOfUnknownType(::HndGetHandleTable(handle), handle);
}
+void GCHandleManager::SetExtraInfoForHandle(OBJECTHANDLE handle, HandleType type, void* pExtraInfo)
+{
+ ::HndSetHandleExtraInfo(handle, type, (uintptr_t)pExtraInfo);
+}
+
void* GCHandleManager::GetExtraInfoFromHandle(OBJECTHANDLE handle)
{
return (void*)::HndGetHandleExtraInfo(handle);
@@ -173,3 +179,11 @@ Object* GCHandleManager::InterlockedCompareExchangeObjectInHandle(OBJECTHANDLE h
{
return (Object*)::HndInterlockedCompareExchangeHandle(handle, ObjectToOBJECTREF(object), ObjectToOBJECTREF(comparandObject));
}
+
+HandleType GCHandleManager::HandleFetchType(OBJECTHANDLE handle)
+{
+ uint32_t type = ::HandleFetchType(handle);
+ assert(type >= HNDTYPE_WEAK_SHORT && type <= HNDTYPE_WEAK_WINRT);
+ return static_cast<HandleType>(type);
+}
+
diff --git a/src/gc/gchandletableimpl.h b/src/gc/gchandletableimpl.h
index 4be346fb28..288927c859 100644
--- a/src/gc/gchandletableimpl.h
+++ b/src/gc/gchandletableimpl.h
@@ -15,11 +15,11 @@ public:
virtual bool ContainsHandle(OBJECTHANDLE handle);
- virtual OBJECTHANDLE CreateHandleOfType(Object* object, int type);
+ virtual OBJECTHANDLE CreateHandleOfType(Object* object, HandleType type);
- virtual OBJECTHANDLE CreateHandleOfType(Object* object, int type, int heapToAffinitizeTo);
+ virtual OBJECTHANDLE CreateHandleOfType(Object* object, HandleType type, int heapToAffinitizeTo);
- virtual OBJECTHANDLE CreateHandleWithExtraInfo(Object* object, int type, void* pExtraInfo);
+ virtual OBJECTHANDLE CreateHandleWithExtraInfo(Object* object, HandleType type, void* pExtraInfo);
virtual OBJECTHANDLE CreateDependentHandle(Object* primary, Object* secondary);
@@ -49,14 +49,16 @@ public:
virtual void DestroyHandleStore(IGCHandleStore* store);
- virtual OBJECTHANDLE CreateGlobalHandleOfType(Object* object, int type);
+ virtual OBJECTHANDLE CreateGlobalHandleOfType(Object* object, HandleType type);
virtual OBJECTHANDLE CreateDuplicateHandle(OBJECTHANDLE handle);
- virtual void DestroyHandleOfType(OBJECTHANDLE handle, int type);
+ virtual void DestroyHandleOfType(OBJECTHANDLE handle, HandleType type);
virtual void DestroyHandleOfUnknownType(OBJECTHANDLE handle);
+ virtual void SetExtraInfoForHandle(OBJECTHANDLE handle, HandleType type, void* pExtraInfo);
+
virtual void* GetExtraInfoFromHandle(OBJECTHANDLE handle);
virtual void StoreObjectInHandle(OBJECTHANDLE handle, Object* object);
@@ -68,6 +70,8 @@ public:
virtual Object* GetDependentHandleSecondary(OBJECTHANDLE handle);
virtual Object* InterlockedCompareExchangeObjectInHandle(OBJECTHANDLE handle, Object* object, Object* comparandObject);
+
+ virtual HandleType HandleFetchType(OBJECTHANDLE handle);
};
#endif // GCHANDLETABLE_H_
diff --git a/src/gc/gcinterface.h b/src/gc/gcinterface.h
index aefa84b99b..e474ee24b2 100644
--- a/src/gc/gcinterface.h
+++ b/src/gc/gcinterface.h
@@ -413,11 +413,11 @@ public:
virtual bool ContainsHandle(OBJECTHANDLE handle) = 0;
- virtual OBJECTHANDLE CreateHandleOfType(Object* object, int type) = 0;
+ virtual OBJECTHANDLE CreateHandleOfType(Object* object, HandleType type) = 0;
- virtual OBJECTHANDLE CreateHandleOfType(Object* object, int type, int heapToAffinitizeTo) = 0;
+ virtual OBJECTHANDLE CreateHandleOfType(Object* object, HandleType type, int heapToAffinitizeTo) = 0;
- virtual OBJECTHANDLE CreateHandleWithExtraInfo(Object* object, int type, void* pExtraInfo) = 0;
+ virtual OBJECTHANDLE CreateHandleWithExtraInfo(Object* object, HandleType type, void* pExtraInfo) = 0;
virtual OBJECTHANDLE CreateDependentHandle(Object* primary, Object* secondary) = 0;
@@ -443,14 +443,16 @@ public:
virtual void DestroyHandleStore(IGCHandleStore* store) = 0;
- virtual OBJECTHANDLE CreateGlobalHandleOfType(Object* object, int type) = 0;
+ virtual OBJECTHANDLE CreateGlobalHandleOfType(Object* object, HandleType type) = 0;
virtual OBJECTHANDLE CreateDuplicateHandle(OBJECTHANDLE handle) = 0;
- virtual void DestroyHandleOfType(OBJECTHANDLE handle, int type) = 0;
+ virtual void DestroyHandleOfType(OBJECTHANDLE handle, HandleType type) = 0;
virtual void DestroyHandleOfUnknownType(OBJECTHANDLE handle) = 0;
+ virtual void SetExtraInfoForHandle(OBJECTHANDLE handle, HandleType type, void* pExtraInfo) = 0;
+
virtual void* GetExtraInfoFromHandle(OBJECTHANDLE handle) = 0;
virtual void StoreObjectInHandle(OBJECTHANDLE handle, Object* object) = 0;
@@ -462,6 +464,8 @@ public:
virtual Object* GetDependentHandleSecondary(OBJECTHANDLE handle) = 0;
virtual Object* InterlockedCompareExchangeObjectInHandle(OBJECTHANDLE handle, Object* object, Object* comparandObject) = 0;
+
+ virtual HandleType HandleFetchType(OBJECTHANDLE handle) = 0;
};
// IGCHeap is the interface that the VM will use when interacting with the GC.
diff --git a/src/vm/CMakeLists.txt b/src/vm/CMakeLists.txt
index 4e6a523ba2..7d5ea89793 100644
--- a/src/vm/CMakeLists.txt
+++ b/src/vm/CMakeLists.txt
@@ -2,9 +2,6 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
# Needed due to the cmunged files being in the binary folders, the set(CMAKE_INCLUDE_CURRENT_DIR ON) is not enough
include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR})
-
-include_directories(${CLR_DIR}/src/gc)
-
include_directories(${ARCH_SOURCES_DIR})
add_definitions(-DUNICODE)
diff --git a/src/vm/appdomain.cpp b/src/vm/appdomain.cpp
index 56b5aa1256..ee495f1c74 100644
--- a/src/vm/appdomain.cpp
+++ b/src/vm/appdomain.cpp
@@ -1749,7 +1749,8 @@ void AppDomain::CacheWinRTFactoryObject(MethodTable *pClassMT, OBJECTREF *refFac
pNewCtxEntry = pEntry->m_pCtxEntry;
pEntry->m_pCtxEntry = pTemp;
- HndAssignHandle(pEntry->m_ohFactoryObject, *refFactory);
+ IGCHandleManager *mgr = GCHandleUtilities::GetGCHandleManager();
+ mgr->StoreObjectInHandle(pEntry->m_ohFactoryObject, OBJECTREFToObject(*refFactory));
}
}
@@ -4153,12 +4154,6 @@ AppDomain::~AppDomain()
//*****************************************************************************
//*****************************************************************************
//*****************************************************************************
-#ifdef _DEBUG
-#include "handletablepriv.h"
-#endif
-
-
-
void AppDomain::Init()
{
CONTRACTL
diff --git a/src/vm/appdomain.hpp b/src/vm/appdomain.hpp
index edd638ed31..18bc73e5a5 100644
--- a/src/vm/appdomain.hpp
+++ b/src/vm/appdomain.hpp
@@ -1237,7 +1237,7 @@ public:
// Handles
#if !defined(DACCESS_COMPILE) && !defined(CROSSGEN_COMPILE)
- OBJECTHANDLE CreateTypedHandle(OBJECTREF object, int type)
+ OBJECTHANDLE CreateTypedHandle(OBJECTREF object, HandleType type)
{
WRAPPER_NO_CONTRACT;
diff --git a/src/vm/encee.cpp b/src/vm/encee.cpp
index 7f12643340..b1315ddefa 100644
--- a/src/vm/encee.cpp
+++ b/src/vm/encee.cpp
@@ -1139,7 +1139,8 @@ EnCAddedField *EnCAddedField::Allocate(OBJECTREF thisPointer, EnCFieldDesc *pFD)
FieldDesc *pHelperField = MscorlibBinder::GetField(FIELD__ENC_HELPER__OBJECT_REFERENCE);
// store the empty boxed object into the helper object
- OBJECTREF pHelperObj = GetDependentHandleSecondary(pEntry->m_FieldData);
+ IGCHandleManager *mgr = GCHandleUtilities::GetGCHandleManager();
+ OBJECTREF pHelperObj = ObjectToOBJECTREF(mgr->GetDependentHandleSecondary(pEntry->m_FieldData));
OBJECTREF *pHelperRef = (OBJECTREF *)pHelperField->GetAddress( pHelperObj->GetAddress() );
SetObjectReference( pHelperRef, obj, pDomain );
@@ -1244,7 +1245,8 @@ PTR_CBYTE EnCSyncBlockInfo::ResolveField(OBJECTREF thisPointer, EnCFieldDesc *pF
// we found a matching entry in the list of EnCAddedFields
// Get the EnC helper object (see the detailed description in Allocate above)
- OBJECTREF pHelper = GetDependentHandleSecondary(pEntry->m_FieldData);
+ IGCHandleManager *mgr = GCHandleUtilities::GetGCHandleManager();
+ OBJECTREF pHelper = ObjectToOBJECTREF(mgr->GetDependentHandleSecondary(pEntry->m_FieldData));
_ASSERTE(pHelper != NULL);
FieldDesc *pHelperFieldDesc = NULL;
@@ -1333,7 +1335,8 @@ PTR_CBYTE EnCSyncBlockInfo::ResolveOrAllocateField(OBJECTREF thisPointer, EnCFie
// we found a matching entry in the list of EnCAddedFields
// Get the EnC helper object (see the detailed description in Allocate above)
- OBJECTREF pHelper = GetDependentHandleSecondary(pEntry->m_FieldData);
+ IGCHandleManager *mgr = GCHandleUtilities::GetGCHandleManager();
+ OBJECTREF pHelper = ObjectToOBJECTREF(mgr->GetDependentHandleSecondary(pEntry->m_FieldData));
_ASSERTE(pHelper != NULL);
FieldDesc * pHelperField = NULL;
diff --git a/src/vm/gcenv.os.cpp b/src/vm/gcenv.os.cpp
index 8572551a06..bb75f01ee6 100644
--- a/src/vm/gcenv.os.cpp
+++ b/src/vm/gcenv.os.cpp
@@ -22,7 +22,7 @@
#undef Sleep
#endif // Sleep
-#include "env/gcenv.os.h"
+#include "../gc/env/gcenv.os.h"
#define MAX_PTR ((uint8_t*)(~(ptrdiff_t)0))
diff --git a/src/vm/gcheaputilities.cpp b/src/vm/gcheaputilities.cpp
index cd7afede70..d0bfda6c2d 100644
--- a/src/vm/gcheaputilities.cpp
+++ b/src/vm/gcheaputilities.cpp
@@ -78,7 +78,8 @@ void ValidateHandleAssignment(OBJECTHANDLE handle, OBJECTREF objRef)
_ASSERTE("Attempt to access destroyed handle." && *(_UNCHECKED_OBJECTREF*)handle != DEBUG_DestroyedHandleValue);
#endif
- ADIndex appDomainIndex = HndGetHandleADIndex(handle);
+ IGCHandleManager *mgr = GCHandleUtilities::GetGCHandleManager();
+ ADIndex appDomainIndex = ADIndex(reinterpret_cast<DWORD>(mgr->GetHandleContext(handle)));
AppDomain *unloadingDomain = SystemDomain::AppDomainBeingUnloaded();
if (unloadingDomain && unloadingDomain->GetIndex() == appDomainIndex && unloadingDomain->NoAccessToHandleTable())
@@ -88,4 +89,4 @@ void ValidateHandleAssignment(OBJECTHANDLE handle, OBJECTREF objRef)
ValidateObjectAndAppDomain(objRef, appDomainIndex);
#endif // _DEBUG_IMPL
-} \ No newline at end of file
+}
diff --git a/src/vm/marshalnative.cpp b/src/vm/marshalnative.cpp
index 17f39457b7..8aebd9ab8e 100644
--- a/src/vm/marshalnative.cpp
+++ b/src/vm/marshalnative.cpp
@@ -35,7 +35,6 @@
#include "fcall.h"
#include "dllimportcallback.h"
#include "comdelegate.h"
-#include "handletablepriv.h"
#include "mdaassistants.h"
#include "typestring.h"
#include "appdomain.inl"
@@ -640,13 +639,14 @@ FCIMPL2(LPVOID, MarshalNative::GCHandleInternalAlloc, Object *obj, int type)
OBJECTHANDLE hnd = 0;
HELPER_METHOD_FRAME_BEGIN_RET_NOPOLL();
-
+
// If it is a pinned handle, check the object type.
if (type == HNDTYPE_PINNED)
GCHandleValidatePinnedObject(objRef);
+ assert(type >= HNDTYPE_WEAK_SHORT && type <= HNDTYPE_WEAK_WINRT);
// Create the handle.
- hnd = GetAppDomain()->CreateTypedHandle(objRef, type);
+ hnd = GetAppDomain()->CreateTypedHandle(objRef, static_cast<HandleType>(type));
HELPER_METHOD_FRAME_END_POLL();
return (LPVOID) hnd;
@@ -764,7 +764,7 @@ FCIMPL1(INT32, MarshalNative::GCHandleInternalGetHandleType, OBJECTHANDLE handle
{
FCALL_CONTRACT;
- return HandleFetchType(handle);
+ return GCHandleUtilities::GetGCHandleManager()->HandleFetchType(handle);
}
FCIMPLEND
diff --git a/src/vm/rcwrefcache.cpp b/src/vm/rcwrefcache.cpp
index 328dc4ace7..acb174d42b 100644
--- a/src/vm/rcwrefcache.cpp
+++ b/src/vm/rcwrefcache.cpp
@@ -176,8 +176,9 @@ void RCWRefCache::ShrinkDependentHandles()
{
OBJECTHANDLE depHnd = m_depHndList[i];
- HndAssignHandle(depHnd, NULL);
- SetDependentHandleSecondary(depHnd, NULL);
+ IGCHandleManager *mgr = GCHandleUtilities::GetGCHandleManager();
+ mgr->StoreObjectInHandle(depHnd, NULL);
+ mgr->SetDependentHandleSecondary(depHnd, NULL);
LOG((LF_INTEROP, LL_INFO1000, "\t[RCWRefCache 0x%p] DependentHandle 0x%p cleared @ index %d\n", this, depHnd, (ULONG) i));
}
@@ -266,8 +267,9 @@ HRESULT RCWRefCache::AddReferenceUsingDependentHandle(RCW *pRCW, ComCallWrapper
// Yes, there is a valid DependentHandle entry on the list, use that
OBJECTHANDLE depHnd = (OBJECTHANDLE) m_depHndList[m_dwDepHndListFreeIndex];
- HndAssignHandle(depHnd, pRCW->GetExposedObject());
- SetDependentHandleSecondary(depHnd, pCCW->GetObjectRef());
+ IGCHandleManager *mgr = GCHandleUtilities::GetGCHandleManager();
+ mgr->StoreObjectInHandle(depHnd, OBJECTREFToObject(pRCW->GetExposedObject()));
+ mgr->SetDependentHandleSecondary(depHnd, OBJECTREFToObject(pCCW->GetObjectRef()));
STRESS_LOG3(
LF_INTEROP, LL_INFO1000,
diff --git a/src/vm/runtimehandles.cpp b/src/vm/runtimehandles.cpp
index fa0feb8bc4..da47cc9e70 100644
--- a/src/vm/runtimehandles.cpp
+++ b/src/vm/runtimehandles.cpp
@@ -1152,7 +1152,8 @@ PVOID QCALLTYPE RuntimeTypeHandle::GetGCHandle(EnregisteredTypeHandle pTypeHandl
GCX_COOP();
TypeHandle th = TypeHandle::FromPtr(pTypeHandle);
- objHandle = th.GetDomain()->CreateTypedHandle(NULL, handleType);
+ assert(handleType >= HNDTYPE_WEAK_SHORT && handleType <= HNDTYPE_WEAK_WINRT);
+ objHandle = th.GetDomain()->CreateTypedHandle(NULL, static_cast<HandleType>(handleType));
th.GetLoaderAllocator()->RegisterHandleForCleanup(objHandle);
END_QCALL;
diff --git a/src/vm/weakreferencenative.cpp b/src/vm/weakreferencenative.cpp
index b7052b82b1..05640be715 100644
--- a/src/vm/weakreferencenative.cpp
+++ b/src/vm/weakreferencenative.cpp
@@ -11,8 +11,8 @@
#include "common.h"
+#include "gchandleutilities.h"
#include "weakreferencenative.h"
-#include "handletablepriv.h"
#include "typestring.h"
#include "typeparse.h"
@@ -218,7 +218,7 @@ NOINLINE Object* LoadWinRTWeakReferenceTarget(WEAKREFERENCEREF weakReference, Ty
}
else if(IsWinRTWeakReferenceHandle(handle.RawHandle))
{
- _ASSERTE(HandleFetchType(handle.Handle) == HNDTYPE_WEAK_WINRT);
+ _ASSERTE(GCHandleUtilities::GetGCHandleManager()->HandleFetchType(handle.Handle) == HNDTYPE_WEAK_WINRT);
// Retrieve the associated IWeakReference* for this weak reference. Add a reference to it while we release
// the spin lock so that another thread doesn't release it out from underneath us.
@@ -227,7 +227,8 @@ NOINLINE Object* LoadWinRTWeakReferenceTarget(WEAKREFERENCEREF weakReference, Ty
// it's always set to NULL here and there's nothing for it to release.
_ASSERTE(pWinRTWeakReference.IsNull());
CONTRACT_VIOLATION(GCViolation);
- pWinRTWeakReference = reinterpret_cast<IWeakReference*>(HndGetHandleExtraInfo(handle.Handle));
+ IGCHandleManager *mgr = GCHandleUtilities::GetGCHandleManager();
+ pWinRTWeakReference = reinterpret_cast<IWeakReference*>(mgr->GetExtraInfoFromHandle(handle.Handle));
if (!pWinRTWeakReference.IsNull())
{
pWinRTWeakReference->AddRef();
@@ -508,7 +509,7 @@ void FinalizeWeakReference(Object * obj)
handleToDestroy = GetHandleValue(handle);
// Cache the old handle value
- UINT handleType = HandleFetchType(handleToDestroy);
+ HandleType handleType = GCHandleUtilities::GetGCHandleManager()->HandleFetchType(handleToDestroy);
#ifdef FEATURE_COMINTEROP
_ASSERTE(handleType == HNDTYPE_WEAK_LONG || handleType == HNDTYPE_WEAK_SHORT || handleType == HNDTYPE_WEAK_WINRT);
isWeakWinRTHandle = handleType == HNDTYPE_WEAK_WINRT;
@@ -755,8 +756,9 @@ NOINLINE void SetWeakReferenceTarget(WEAKREFERENCEREF weakReference, OBJECTREF t
// and update it with the new weak reference pointer. If the incoming object is not an RCW that can
// use IWeakReference, then pTargetWeakReference will be null. Therefore, no matter what the incoming
// object type is, we can unconditionally store pTargetWeakReference to the object handle's extra data.
- IWeakReference* pExistingWeakReference = reinterpret_cast<IWeakReference*>(HndGetHandleExtraInfo(handle.Handle));
- HndSetHandleExtraInfo(handle.Handle, HNDTYPE_WEAK_WINRT, reinterpret_cast<LPARAM>(pTargetWeakReference.GetValue()));
+ IGCHandleManager *mgr = GCHandleUtilities::GetGCHandleManager();
+ IWeakReference* pExistingWeakReference = reinterpret_cast<IWeakReference*>(mgr->GetExtraInfoFromHandle(handle.Handle));
+ mgr->SetExtraInfoForHandle(handle.Handle, HNDTYPE_WEAK_WINRT, reinterpret_cast<void*>(pTargetWeakReference.GetValue()));
StoreObjectInHandle(handle.Handle, target);
if (pExistingWeakReference != nullptr)
@@ -931,7 +933,7 @@ FCIMPL1(FC_BOOL_RET, WeakReferenceNative::IsTrackResurrection, WeakReferenceObje
}
else
{
- trackResurrection = HandleFetchType(GetHandleValue(handle)) == HNDTYPE_WEAK_LONG;
+ trackResurrection = GCHandleUtilities::GetGCHandleManager()->HandleFetchType(GetHandleValue(handle)) == HNDTYPE_WEAK_LONG;
}
ReleaseWeakHandleSpinLock(pThis, handle);
@@ -969,7 +971,7 @@ FCIMPL1(FC_BOOL_RET, WeakReferenceOfTNative::IsTrackResurrection, WeakReferenceO
}
else
{
- trackResurrection = HandleFetchType(GetHandleValue(handle)) == HNDTYPE_WEAK_LONG;
+ trackResurrection = GCHandleUtilities::GetGCHandleManager()->HandleFetchType(GetHandleValue(handle)) == HNDTYPE_WEAK_LONG;
}
ReleaseWeakHandleSpinLock(pThis, handle);