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/gc | |
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/gc')
-rw-r--r-- | src/gc/gchandletable.cpp | 24 | ||||
-rw-r--r-- | src/gc/gchandletableimpl.h | 14 | ||||
-rw-r--r-- | src/gc/gcinterface.h | 14 |
3 files changed, 37 insertions, 15 deletions
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. |