From db55a1decc1d02538e61eac7db80b7daa351d5b6 Mon Sep 17 00:00:00 2001 From: David Mason Date: Fri, 6 Apr 2018 13:19:21 -0700 Subject: [PATCH] Add GetLoaderAllocatorObjectForGC to IGCToCLR (#17443) --- src/gc/env/gcenv.ee.h | 3 +++ src/gc/env/gcenv.object.h | 6 ------ src/gc/gcenv.ee.standalone.inl | 6 ++++++ src/gc/gcinterface.ee.h | 4 ++++ src/gc/sample/gcenv.ee.cpp | 5 +++++ src/vm/gcenv.ee.cpp | 13 +++++++++++++ src/vm/gcenv.ee.h | 1 + 7 files changed, 32 insertions(+), 6 deletions(-) diff --git a/src/gc/env/gcenv.ee.h b/src/gc/env/gcenv.ee.h index db96631..ec79877 100644 --- a/src/gc/env/gcenv.ee.h +++ b/src/gc/env/gcenv.ee.h @@ -55,6 +55,9 @@ public: static gc_alloc_context * GetAllocContext(); static void GcEnumAllocContexts(enum_alloc_context_func* fn, void* param); + + static uint8_t* GetLoaderAllocatorObjectForGC(Object* pObject); + // Diagnostics methods. static void DiagGCStart(int gen, bool isInduced); static void DiagUpdateGenerationBounds(); diff --git a/src/gc/env/gcenv.object.h b/src/gc/env/gcenv.object.h index 191c7a1..930e0bc 100644 --- a/src/gc/env/gcenv.object.h +++ b/src/gc/env/gcenv.object.h @@ -122,12 +122,6 @@ public: { return true; } - - uint8_t* GetLoaderAllocatorObjectForGC() - { - // [LOCALGC TODO] this is not correct - return nullptr; - } }; class Object diff --git a/src/gc/gcenv.ee.standalone.inl b/src/gc/gcenv.ee.standalone.inl index c4ec29d..4fc8ca6 100644 --- a/src/gc/gcenv.ee.standalone.inl +++ b/src/gc/gcenv.ee.standalone.inl @@ -125,6 +125,12 @@ inline void GCToEEInterface::GcEnumAllocContexts(enum_alloc_context_func* fn, vo g_theGCToCLR->GcEnumAllocContexts(fn, param); } +inline uint8_t *GCToEEInterface::GetLoaderAllocatorObjectForGC(Object* pObject) +{ + assert(g_theGCToCLR != nullptr); + return g_theGCToCLR->GetLoaderAllocatorObjectForGC(pObject); +} + inline void GCToEEInterface::DiagGCStart(int gen, bool isInduced) { assert(g_theGCToCLR != nullptr); diff --git a/src/gc/gcinterface.ee.h b/src/gc/gcinterface.ee.h index 2d811e4..82d8934 100644 --- a/src/gc/gcinterface.ee.h +++ b/src/gc/gcinterface.ee.h @@ -251,6 +251,10 @@ public: virtual void GcEnumAllocContexts(enum_alloc_context_func* fn, void* param) = 0; + // Get the Allocator for objects from collectible assemblies + virtual + uint8_t* GetLoaderAllocatorObjectForGC(Object* pObject) = 0; + // Creates and returns a new thread. // Parameters: // threadStart - The function that will serve as the thread stub for the diff --git a/src/gc/sample/gcenv.ee.cpp b/src/gc/sample/gcenv.ee.cpp index 996701e..0311c0e 100644 --- a/src/gc/sample/gcenv.ee.cpp +++ b/src/gc/sample/gcenv.ee.cpp @@ -218,6 +218,11 @@ void GCToEEInterface::GcEnumAllocContexts (enum_alloc_context_func* fn, void* pa } } +uint8_t* GCToEEInterface::GetLoaderAllocatorObjectForGC(Object* pObject) +{ + return NULL; +} + void GCToEEInterface::SyncBlockCacheWeakPtrScan(HANDLESCANPROC /*scanProc*/, uintptr_t /*lp1*/, uintptr_t /*lp2*/) { } diff --git a/src/vm/gcenv.ee.cpp b/src/vm/gcenv.ee.cpp index 590cc10..5954b7b 100644 --- a/src/vm/gcenv.ee.cpp +++ b/src/vm/gcenv.ee.cpp @@ -347,6 +347,19 @@ void GCToEEInterface::GcEnumAllocContexts(enum_alloc_context_func* fn, void* par } } + +uint8_t* GCToEEInterface::GetLoaderAllocatorObjectForGC(Object* pObject) +{ + CONTRACTL + { + NOTHROW; + GC_NOTRIGGER; + } + CONTRACTL_END; + + return pObject->GetMethodTable()->GetLoaderAllocatorObjectForGC(); +} + bool GCToEEInterface::IsPreemptiveGCDisabled() { WRAPPER_NO_CONTRACT; diff --git a/src/vm/gcenv.ee.h b/src/vm/gcenv.ee.h index 97413e3..0dbf70d 100644 --- a/src/vm/gcenv.ee.h +++ b/src/vm/gcenv.ee.h @@ -35,6 +35,7 @@ public: Thread* GetThread(); gc_alloc_context * GetAllocContext(); void GcEnumAllocContexts(enum_alloc_context_func* fn, void* param); + uint8_t* GetLoaderAllocatorObjectForGC(Object* pObject); // Diagnostics methods. void DiagGCStart(int gen, bool isInduced); -- 2.7.4