From e3a44616f941d1dd01fa3c3edc94204da4fa0b78 Mon Sep 17 00:00:00 2001 From: Juan Sebastian Hoyos Ayala Date: Sat, 14 Mar 2026 17:25:42 -0700 Subject: [PATCH 1/3] Remove dead function --- src/coreclr/gc/gchandletable.cpp | 5 ----- src/coreclr/gc/gchandletableimpl.h | 2 -- src/coreclr/gc/gcinterface.h | 6 ++---- src/coreclr/gc/objecthandle.cpp | 20 -------------------- src/coreclr/gc/objecthandle.h | 2 -- 5 files changed, 2 insertions(+), 33 deletions(-) diff --git a/src/coreclr/gc/gchandletable.cpp b/src/coreclr/gc/gchandletable.cpp index d503aca269b6cd..5c3acc452d297e 100644 --- a/src/coreclr/gc/gchandletable.cpp +++ b/src/coreclr/gc/gchandletable.cpp @@ -20,11 +20,6 @@ void GCHandleStore::Uproot() Ref_RemoveHandleTableBucket(&_underlyingBucket); } -bool GCHandleStore::ContainsHandle(OBJECTHANDLE handle) -{ - return _underlyingBucket.Contains(handle); -} - // this is the number of handles we allocate in a handle table before we switch to the next table. #define HANDLE_THRESHOLD (15) static int s_numTableSlots = 0; diff --git a/src/coreclr/gc/gchandletableimpl.h b/src/coreclr/gc/gchandletableimpl.h index 83bcab2b8fd8dd..b25198f13d497a 100644 --- a/src/coreclr/gc/gchandletableimpl.h +++ b/src/coreclr/gc/gchandletableimpl.h @@ -12,8 +12,6 @@ class GCHandleStore : public IGCHandleStore public: virtual void Uproot(); - virtual bool ContainsHandle(OBJECTHANDLE handle); - virtual OBJECTHANDLE CreateHandleOfType(Object* object, HandleType type); virtual OBJECTHANDLE CreateHandleOfType(Object* object, HandleType type, int heapToAffinitizeTo); diff --git a/src/coreclr/gc/gcinterface.h b/src/coreclr/gc/gcinterface.h index dc319277c413f8..1a91a0bc0ddf1e 100644 --- a/src/coreclr/gc/gcinterface.h +++ b/src/coreclr/gc/gcinterface.h @@ -6,12 +6,12 @@ // The major version of the IGCHeap interface. Breaking changes to this interface // require bumps in the major version number. -#define GC_INTERFACE_MAJOR_VERSION 5 +#define GC_INTERFACE_MAJOR_VERSION 6 // The minor version of the IGCHeap interface. Non-breaking changes are required // to bump the minor version number. GCs and EEs with minor version number // mismatches can still interoperate correctly, with some care. -#define GC_INTERFACE_MINOR_VERSION 6 +#define GC_INTERFACE_MINOR_VERSION 0 // The major version of the IGCToCLR interface. Breaking changes to this interface // require bumps in the major version number. @@ -580,8 +580,6 @@ class IGCHandleStore { virtual void Uproot() PURE_VIRTUAL - virtual bool ContainsHandle(OBJECTHANDLE handle) PURE_VIRTUAL - virtual OBJECTHANDLE CreateHandleOfType(Object* object, HandleType type) PURE_VIRTUAL virtual OBJECTHANDLE CreateHandleOfType(Object* object, HandleType type, int heapToAffinitizeTo) PURE_VIRTUAL diff --git a/src/coreclr/gc/objecthandle.cpp b/src/coreclr/gc/objecthandle.cpp index af7805107e5909..d30f08be4b6eda 100644 --- a/src/coreclr/gc/objecthandle.cpp +++ b/src/coreclr/gc/objecthandle.cpp @@ -2079,26 +2079,6 @@ gc_alloc_context* GetCurrentThreadAllocContext() return GCToEEInterface::GetAllocContext(); } -bool HandleTableBucket::Contains(OBJECTHANDLE handle) -{ - LIMITED_METHOD_CONTRACT; - - if (NULL == handle) - { - return FALSE; - } - - HHANDLETABLE hTable = HndGetHandleTable(handle); - for (int uCPUindex=0; uCPUindex < g_theGCHeap->GetNumberOfHeaps(); uCPUindex++) - { - if (hTable == this->pTable[uCPUindex]) - { - return TRUE; - } - } - return FALSE; -} - #endif // !DACCESS_COMPILE GC_DAC_VISIBLE diff --git a/src/coreclr/gc/objecthandle.h b/src/coreclr/gc/objecthandle.h index 27875c4cf5720b..4ba778db7acd27 100644 --- a/src/coreclr/gc/objecthandle.h +++ b/src/coreclr/gc/objecthandle.h @@ -36,8 +36,6 @@ struct HandleTableBucket { PTR_HHANDLETABLE pTable; uint32_t HandleTableIndex; - - bool Contains(OBJECTHANDLE handle); }; From 69fd78ce7645dbbe5ebd582aab67810dc4a39edf Mon Sep 17 00:00:00 2001 From: Juan Sebastian Hoyos Ayala Date: Sat, 14 Mar 2026 17:25:58 -0700 Subject: [PATCH 2/3] Revert "Remove dead function" This reverts commit e3a44616f941d1dd01fa3c3edc94204da4fa0b78. --- src/coreclr/gc/gchandletable.cpp | 5 +++++ src/coreclr/gc/gchandletableimpl.h | 2 ++ src/coreclr/gc/gcinterface.h | 6 ++++-- src/coreclr/gc/objecthandle.cpp | 20 ++++++++++++++++++++ src/coreclr/gc/objecthandle.h | 2 ++ 5 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/coreclr/gc/gchandletable.cpp b/src/coreclr/gc/gchandletable.cpp index 5c3acc452d297e..d503aca269b6cd 100644 --- a/src/coreclr/gc/gchandletable.cpp +++ b/src/coreclr/gc/gchandletable.cpp @@ -20,6 +20,11 @@ void GCHandleStore::Uproot() Ref_RemoveHandleTableBucket(&_underlyingBucket); } +bool GCHandleStore::ContainsHandle(OBJECTHANDLE handle) +{ + return _underlyingBucket.Contains(handle); +} + // this is the number of handles we allocate in a handle table before we switch to the next table. #define HANDLE_THRESHOLD (15) static int s_numTableSlots = 0; diff --git a/src/coreclr/gc/gchandletableimpl.h b/src/coreclr/gc/gchandletableimpl.h index b25198f13d497a..83bcab2b8fd8dd 100644 --- a/src/coreclr/gc/gchandletableimpl.h +++ b/src/coreclr/gc/gchandletableimpl.h @@ -12,6 +12,8 @@ class GCHandleStore : public IGCHandleStore public: virtual void Uproot(); + virtual bool ContainsHandle(OBJECTHANDLE handle); + virtual OBJECTHANDLE CreateHandleOfType(Object* object, HandleType type); virtual OBJECTHANDLE CreateHandleOfType(Object* object, HandleType type, int heapToAffinitizeTo); diff --git a/src/coreclr/gc/gcinterface.h b/src/coreclr/gc/gcinterface.h index 1a91a0bc0ddf1e..dc319277c413f8 100644 --- a/src/coreclr/gc/gcinterface.h +++ b/src/coreclr/gc/gcinterface.h @@ -6,12 +6,12 @@ // The major version of the IGCHeap interface. Breaking changes to this interface // require bumps in the major version number. -#define GC_INTERFACE_MAJOR_VERSION 6 +#define GC_INTERFACE_MAJOR_VERSION 5 // The minor version of the IGCHeap interface. Non-breaking changes are required // to bump the minor version number. GCs and EEs with minor version number // mismatches can still interoperate correctly, with some care. -#define GC_INTERFACE_MINOR_VERSION 0 +#define GC_INTERFACE_MINOR_VERSION 6 // The major version of the IGCToCLR interface. Breaking changes to this interface // require bumps in the major version number. @@ -580,6 +580,8 @@ class IGCHandleStore { virtual void Uproot() PURE_VIRTUAL + virtual bool ContainsHandle(OBJECTHANDLE handle) PURE_VIRTUAL + virtual OBJECTHANDLE CreateHandleOfType(Object* object, HandleType type) PURE_VIRTUAL virtual OBJECTHANDLE CreateHandleOfType(Object* object, HandleType type, int heapToAffinitizeTo) PURE_VIRTUAL diff --git a/src/coreclr/gc/objecthandle.cpp b/src/coreclr/gc/objecthandle.cpp index d30f08be4b6eda..af7805107e5909 100644 --- a/src/coreclr/gc/objecthandle.cpp +++ b/src/coreclr/gc/objecthandle.cpp @@ -2079,6 +2079,26 @@ gc_alloc_context* GetCurrentThreadAllocContext() return GCToEEInterface::GetAllocContext(); } +bool HandleTableBucket::Contains(OBJECTHANDLE handle) +{ + LIMITED_METHOD_CONTRACT; + + if (NULL == handle) + { + return FALSE; + } + + HHANDLETABLE hTable = HndGetHandleTable(handle); + for (int uCPUindex=0; uCPUindex < g_theGCHeap->GetNumberOfHeaps(); uCPUindex++) + { + if (hTable == this->pTable[uCPUindex]) + { + return TRUE; + } + } + return FALSE; +} + #endif // !DACCESS_COMPILE GC_DAC_VISIBLE diff --git a/src/coreclr/gc/objecthandle.h b/src/coreclr/gc/objecthandle.h index 4ba778db7acd27..27875c4cf5720b 100644 --- a/src/coreclr/gc/objecthandle.h +++ b/src/coreclr/gc/objecthandle.h @@ -36,6 +36,8 @@ struct HandleTableBucket { PTR_HHANDLETABLE pTable; uint32_t HandleTableIndex; + + bool Contains(OBJECTHANDLE handle); }; From c4afedb8bc7057f902bbb65f0b0df52844d62812 Mon Sep 17 00:00:00 2001 From: Juan Sebastian Hoyos Ayala Date: Sat, 14 Mar 2026 17:51:58 -0700 Subject: [PATCH 3/3] Fix HandleTableBucket::Contains to account for slots in DATAS --- src/coreclr/gc/objecthandle.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/coreclr/gc/objecthandle.cpp b/src/coreclr/gc/objecthandle.cpp index af7805107e5909..41bdea86374d96 100644 --- a/src/coreclr/gc/objecthandle.cpp +++ b/src/coreclr/gc/objecthandle.cpp @@ -2089,7 +2089,8 @@ bool HandleTableBucket::Contains(OBJECTHANDLE handle) } HHANDLETABLE hTable = HndGetHandleTable(handle); - for (int uCPUindex=0; uCPUindex < g_theGCHeap->GetNumberOfHeaps(); uCPUindex++) + int n_slots = getNumberOfSlots(); + for (int uCPUindex=0; uCPUindex < n_slots; uCPUindex++) { if (hTable == this->pTable[uCPUindex]) {