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 db966310c039..ec79877867ac 100644 --- a/src/gc/env/gcenv.ee.h +++ b/src/gc/env/gcenv.ee.h @@ -55,6 +55,9 @@ class GCToEEInterface 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 191c7a158356..930e0bc9c837 100644 --- a/src/gc/env/gcenv.object.h +++ b/src/gc/env/gcenv.object.h @@ -122,12 +122,6 @@ class MethodTable { 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 c4ec29d2d61d..4fc8ca6a02b1 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 2d811e49f2a6..82d89345f59c 100644 --- a/src/gc/gcinterface.ee.h +++ b/src/gc/gcinterface.ee.h @@ -251,6 +251,10 @@ class IGCToCLR { 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 996701e74adf..0311c0e31bd9 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 590cc1022e43..5954b7b00cd4 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 97413e3d53db..0dbf70d8758c 100644 --- a/src/vm/gcenv.ee.h +++ b/src/vm/gcenv.ee.h @@ -35,6 +35,7 @@ class GCToEEInterface : public IGCToCLR { 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);