diff options
author | Sean Gillespie <segilles@microsoft.com> | 2017-06-15 12:45:12 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-06-15 12:45:12 -0700 |
commit | dda6b6136e21901842758970d831f31687913a35 (patch) | |
tree | 07ea3363dc390bb6cda64975ba3e911711e115bf /src/vm/weakreferencenative.cpp | |
parent | d734877cd86016296fc6c6e884a2b119339545ec (diff) | |
download | coreclr-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
Diffstat (limited to 'src/vm/weakreferencenative.cpp')
-rw-r--r-- | src/vm/weakreferencenative.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
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); |