diff options
author | Aditya Mandaleeka <adityam@microsoft.com> | 2017-04-11 19:11:32 -0700 |
---|---|---|
committer | Aditya Mandaleeka <adityam@microsoft.com> | 2017-04-17 14:32:05 -0700 |
commit | 80ca6807369ff9fa468099a936072a121215d3dc (patch) | |
tree | fa23eff8c4a85de6af8ce7a98c02defe487993db /src/gc | |
parent | a6c2f7834d338e08bf3dcf9dedb48b2a0c08fcfa (diff) | |
download | coreclr-80ca6807369ff9fa468099a936072a121215d3dc.tar.gz coreclr-80ca6807369ff9fa468099a936072a121215d3dc.tar.bz2 coreclr-80ca6807369ff9fa468099a936072a121215d3dc.zip |
Move handle manipulation functions to interface.
Diffstat (limited to 'src/gc')
-rw-r--r-- | src/gc/gc.cpp | 4 | ||||
-rw-r--r-- | src/gc/gchandletable.cpp | 15 | ||||
-rw-r--r-- | src/gc/gchandletableimpl.h | 6 | ||||
-rw-r--r-- | src/gc/gcinterface.h | 6 | ||||
-rw-r--r-- | src/gc/objecthandle.h | 12 |
5 files changed, 30 insertions, 13 deletions
diff --git a/src/gc/gc.cpp b/src/gc/gc.cpp index 6d53c897fb..7d4a8d6501 100644 --- a/src/gc/gc.cpp +++ b/src/gc/gc.cpp @@ -34222,7 +34222,7 @@ bool GCHeap::StressHeap(gc_alloc_context * context) if (g_pConfig->AppDomainLeaks() && str->SetAppDomainNoThrow()) { #endif - StoreObjectInHandle(m_StressObjs[i], ObjectToOBJECTREF(str)); + HndAssignHandle(m_StressObjs[i], ObjectToOBJECTREF(str)); #if CHECK_APP_DOMAIN_LEAKS } #endif @@ -34255,7 +34255,7 @@ bool GCHeap::StressHeap(gc_alloc_context * context) { // Let the string itself become garbage. // will be realloced next time around - StoreObjectInHandle(m_StressObjs[m_CurStressObj], 0); + HndAssignHandle(m_StressObjs[m_CurStressObj], 0); } } } diff --git a/src/gc/gchandletable.cpp b/src/gc/gchandletable.cpp index 68a1c976d9..3077133680 100644 --- a/src/gc/gchandletable.cpp +++ b/src/gc/gchandletable.cpp @@ -132,3 +132,18 @@ void* GCHandleManager::GetExtraInfoFromHandle(OBJECTHANDLE handle) { return (void*)::HndGetHandleExtraInfo(handle); } + +void GCHandleManager::StoreObjectInHandle(OBJECTHANDLE handle, Object* object) +{ + ::HndAssignHandle(handle, ObjectToOBJECTREF(object)); +} + +bool GCHandleManager::StoreObjectInHandleIfNull(OBJECTHANDLE handle, Object* object) +{ + return !!::HndFirstAssignHandle(handle, ObjectToOBJECTREF(object)); +} + +Object* GCHandleManager::CompareAndSwapObjectInHandle(OBJECTHANDLE handle, Object* object, Object* comparandObject) +{ + return (Object*)::HndInterlockedCompareExchangeHandle(handle, ObjectToOBJECTREF(object), ObjectToOBJECTREF(comparandObject)); +} diff --git a/src/gc/gchandletableimpl.h b/src/gc/gchandletableimpl.h index 9247615a84..2183b9b94b 100644 --- a/src/gc/gchandletableimpl.h +++ b/src/gc/gchandletableimpl.h @@ -54,6 +54,12 @@ public: virtual void DestroyHandleOfUnknownType(OBJECTHANDLE handle); virtual void* GetExtraInfoFromHandle(OBJECTHANDLE handle); + + virtual void StoreObjectInHandle(OBJECTHANDLE handle, Object* object); + + virtual bool StoreObjectInHandleIfNull(OBJECTHANDLE handle, Object* object); + + virtual Object* CompareAndSwapObjectInHandle(OBJECTHANDLE handle, Object* object, Object* comparandObject); }; #endif // GCHANDLETABLE_H_ diff --git a/src/gc/gcinterface.h b/src/gc/gcinterface.h index 85c331bd13..60dfd3f597 100644 --- a/src/gc/gcinterface.h +++ b/src/gc/gcinterface.h @@ -444,6 +444,12 @@ public: virtual void DestroyHandleOfUnknownType(OBJECTHANDLE handle) = 0; virtual void* GetExtraInfoFromHandle(OBJECTHANDLE handle) = 0; + + virtual void StoreObjectInHandle(OBJECTHANDLE handle, Object* object) = 0; + + virtual bool StoreObjectInHandleIfNull(OBJECTHANDLE handle, Object* object) = 0; + + virtual Object* CompareAndSwapObjectInHandle(OBJECTHANDLE handle, Object* object, Object* comparandObject) = 0; }; // IGCHeap is the interface that the VM will use when interacting with the GC. diff --git a/src/gc/objecthandle.h b/src/gc/objecthandle.h index 945e8d6a73..c320dcc3a9 100644 --- a/src/gc/objecthandle.h +++ b/src/gc/objecthandle.h @@ -21,16 +21,6 @@ #include <weakreference.h> #endif // FEATURE_COMINTEROP -/* - * Convenience macros for accessing handles. StoreFirstObjectInHandle is like - * StoreObjectInHandle, except it only succeeds if transitioning from NULL to - * non-NULL. In other words, if this handle is being initialized for the first - * time. - */ -#define StoreObjectInHandle(handle, object) HndAssignHandle(handle, object) -#define InterlockedCompareExchangeObjectInHandle(handle, object, oldObj) HndInterlockedCompareExchangeHandle(handle, object, oldObj) -#define StoreFirstObjectInHandle(handle, object) HndFirstAssignHandle(handle, object) - typedef DPTR(struct HandleTableMap) PTR_HandleTableMap; typedef DPTR(struct HandleTableBucket) PTR_HandleTableBucket; typedef DPTR(PTR_HandleTableBucket) PTR_PTR_HandleTableBucket; @@ -94,7 +84,7 @@ inline void ResetOBJECTHANDLE(OBJECTHANDLE handle) { WRAPPER_NO_CONTRACT; - StoreObjectInHandle(handle, NULL); + HndAssignHandle(handle, NULL); } #ifndef FEATURE_REDHAWK |