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/gchandletable.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/gc/gchandletable.cpp')
-rw-r--r-- | src/gc/gchandletable.cpp | 24 |
1 files changed, 19 insertions, 5 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); +} + |