Skip to content

Commit db55a1d

Browse files
authored
Add GetLoaderAllocatorObjectForGC to IGCToCLR (dotnet#17443)
1 parent e7c7551 commit db55a1d

File tree

7 files changed

+32
-6
lines changed

7 files changed

+32
-6
lines changed

src/gc/env/gcenv.ee.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ class GCToEEInterface
5555
static gc_alloc_context * GetAllocContext();
5656

5757
static void GcEnumAllocContexts(enum_alloc_context_func* fn, void* param);
58+
59+
static uint8_t* GetLoaderAllocatorObjectForGC(Object* pObject);
60+
5861
// Diagnostics methods.
5962
static void DiagGCStart(int gen, bool isInduced);
6063
static void DiagUpdateGenerationBounds();

src/gc/env/gcenv.object.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,12 +122,6 @@ class MethodTable
122122
{
123123
return true;
124124
}
125-
126-
uint8_t* GetLoaderAllocatorObjectForGC()
127-
{
128-
// [LOCALGC TODO] this is not correct
129-
return nullptr;
130-
}
131125
};
132126

133127
class Object

src/gc/gcenv.ee.standalone.inl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,12 @@ inline void GCToEEInterface::GcEnumAllocContexts(enum_alloc_context_func* fn, vo
125125
g_theGCToCLR->GcEnumAllocContexts(fn, param);
126126
}
127127

128+
inline uint8_t *GCToEEInterface::GetLoaderAllocatorObjectForGC(Object* pObject)
129+
{
130+
assert(g_theGCToCLR != nullptr);
131+
return g_theGCToCLR->GetLoaderAllocatorObjectForGC(pObject);
132+
}
133+
128134
inline void GCToEEInterface::DiagGCStart(int gen, bool isInduced)
129135
{
130136
assert(g_theGCToCLR != nullptr);

src/gc/gcinterface.ee.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,10 @@ class IGCToCLR {
251251
virtual
252252
void GcEnumAllocContexts(enum_alloc_context_func* fn, void* param) = 0;
253253

254+
// Get the Allocator for objects from collectible assemblies
255+
virtual
256+
uint8_t* GetLoaderAllocatorObjectForGC(Object* pObject) = 0;
257+
254258
// Creates and returns a new thread.
255259
// Parameters:
256260
// threadStart - The function that will serve as the thread stub for the

src/gc/sample/gcenv.ee.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,11 @@ void GCToEEInterface::GcEnumAllocContexts (enum_alloc_context_func* fn, void* pa
218218
}
219219
}
220220

221+
uint8_t* GCToEEInterface::GetLoaderAllocatorObjectForGC(Object* pObject)
222+
{
223+
return NULL;
224+
}
225+
221226
void GCToEEInterface::SyncBlockCacheWeakPtrScan(HANDLESCANPROC /*scanProc*/, uintptr_t /*lp1*/, uintptr_t /*lp2*/)
222227
{
223228
}

src/vm/gcenv.ee.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,19 @@ void GCToEEInterface::GcEnumAllocContexts(enum_alloc_context_func* fn, void* par
347347
}
348348
}
349349

350+
351+
uint8_t* GCToEEInterface::GetLoaderAllocatorObjectForGC(Object* pObject)
352+
{
353+
CONTRACTL
354+
{
355+
NOTHROW;
356+
GC_NOTRIGGER;
357+
}
358+
CONTRACTL_END;
359+
360+
return pObject->GetMethodTable()->GetLoaderAllocatorObjectForGC();
361+
}
362+
350363
bool GCToEEInterface::IsPreemptiveGCDisabled()
351364
{
352365
WRAPPER_NO_CONTRACT;

src/vm/gcenv.ee.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ class GCToEEInterface : public IGCToCLR {
3535
Thread* GetThread();
3636
gc_alloc_context * GetAllocContext();
3737
void GcEnumAllocContexts(enum_alloc_context_func* fn, void* param);
38+
uint8_t* GetLoaderAllocatorObjectForGC(Object* pObject);
3839

3940
// Diagnostics methods.
4041
void DiagGCStart(int gen, bool isInduced);

0 commit comments

Comments
 (0)