From 468ccf53dbe6b04c50fe7da2c31df57799f74ec3 Mon Sep 17 00:00:00 2001 From: Aditya Mandaleeka Date: Fri, 31 Mar 2017 17:09:46 -0700 Subject: [PATCH] Add way to get table for handle and ADIndex for handletable. Commit migrated from https://github.com/dotnet/coreclr/commit/dab2f6b76a1ed088a871374189e2133db9c9accb --- src/coreclr/src/gc/gchandletable.cpp | 10 ++++++++++ src/coreclr/src/gc/gchandletableimpl.h | 4 ++++ src/coreclr/src/gc/gcinterface.h | 14 +++++++++++++- src/coreclr/src/vm/gcheaputilities.cpp | 1 - 4 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/coreclr/src/gc/gchandletable.cpp b/src/coreclr/src/gc/gchandletable.cpp index a4c3352..c096d9f 100644 --- a/src/coreclr/src/gc/gchandletable.cpp +++ b/src/coreclr/src/gc/gchandletable.cpp @@ -22,3 +22,13 @@ void GCHandleTable::Shutdown() { Ref_Shutdown(); } + +void* GCHandleTable::GetHandleTableContext(HHANDLETABLE hTable) +{ + return (void*)((uintptr_t)::HndGetHandleTableADIndex(hTable).m_dwIndex); +} + +HHANDLETABLE GCHandleTable::GetHandleTableForHandle(OBJECTHANDLE handle) +{ + return ::HndGetHandleTable(handle); +} diff --git a/src/coreclr/src/gc/gchandletableimpl.h b/src/coreclr/src/gc/gchandletableimpl.h index 233e326..eafb0a0 100644 --- a/src/coreclr/src/gc/gchandletableimpl.h +++ b/src/coreclr/src/gc/gchandletableimpl.h @@ -13,6 +13,10 @@ public: virtual bool Initialize(); virtual void Shutdown(); + + virtual void* GetHandleTableContext(HHANDLETABLE hTable); + + virtual HHANDLETABLE GetHandleTableForHandle(OBJECTHANDLE handle); }; #endif // GCHANDLETABLE_H_ diff --git a/src/coreclr/src/gc/gcinterface.h b/src/coreclr/src/gc/gcinterface.h index 77425b1..e1e7301 100644 --- a/src/coreclr/src/gc/gcinterface.h +++ b/src/coreclr/src/gc/gcinterface.h @@ -149,10 +149,18 @@ struct segment_info void * pvMem; // base of the allocation, not the first object (must add ibFirstObject) size_t ibFirstObject; // offset to the base of the first object in the segment size_t ibAllocated; // limit of allocated memory in the segment (>= firstobject) - size_t ibCommit; // limit of committed memory in the segment (>= alllocated) + size_t ibCommit; // limit of committed memory in the segment (>= allocated) size_t ibReserved; // limit of reserved memory in the segment (>= commit) }; + +/* + * handle to handle table + */ +typedef DPTR(struct HandleTable) PTR_HandleTable; +typedef DPTR(PTR_HandleTable) PTR_PTR_HandleTable; +typedef PTR_HandleTable HHANDLETABLE; +typedef PTR_PTR_HandleTable PTR_HHANDLETABLE; #ifdef PROFILING_SUPPORTED #define GC_PROFILING //Turn on profiling #endif // PROFILING_SUPPORTED @@ -391,6 +399,10 @@ public: virtual bool Initialize() = 0; virtual void Shutdown() = 0; + + virtual void* GetHandleTableContext(HHANDLETABLE hTable) = 0; + + virtual HHANDLETABLE GetHandleTableForHandle(OBJECTHANDLE handle) = 0; }; // IGCHeap is the interface that the VM will use when interacting with the GC. diff --git a/src/coreclr/src/vm/gcheaputilities.cpp b/src/coreclr/src/vm/gcheaputilities.cpp index aa90341..e24f1ad 100644 --- a/src/coreclr/src/vm/gcheaputilities.cpp +++ b/src/coreclr/src/vm/gcheaputilities.cpp @@ -35,4 +35,3 @@ bool g_sw_ww_enabled_for_gc_heap = false; #endif // FEATURE_USE_SOFTWARE_WRITE_WATCH_FOR_GC_HEAP gc_alloc_context g_global_alloc_context = {}; - -- 2.7.4