Skip to content

Commit 00d5d41

Browse files
authored
fix backcompat issue for standalone GC (#117793)
#116310 breaks the backward compatibility for the standalone GC - it can no longer work with previous versions of the runtime on both windows and linux. this is easily reproducible by just loading a standalone GC dll built from main with say 8.0 runtime because it will fail as soon as it hits FinalizeLoad when coreclr is trying to load the standalone dll. both msvc and clang put the 2 methods, both named IsPromoted next to each other instead of maintaining the order as declared. renaming the new one to IsPromoted2 worked. but I also just made IsPromoted2 on IGCHeapInternal instead since it's only used by the GC side.
1 parent 40e90f3 commit 00d5d41

File tree

5 files changed

+12
-7
lines changed

5 files changed

+12
-7
lines changed

src/coreclr/gc/gc.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49779,10 +49779,10 @@ HRESULT GCHeap::Initialize()
4977949779
// GC callback functions
4978049780
bool GCHeap::IsPromoted(Object* object)
4978149781
{
49782-
return IsPromoted(object, true);
49782+
return IsPromoted2(object, true);
4978349783
}
4978449784

49785-
bool GCHeap::IsPromoted(Object* object, bool bVerifyNextHeader)
49785+
bool GCHeap::IsPromoted2(Object* object, bool bVerifyNextHeader)
4978649786
{
4978749787
uint8_t* o = (uint8_t*)object;
4978849788

src/coreclr/gc/gc.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,11 +285,16 @@ struct alloc_context : gc_alloc_context
285285
#endif // FEATURE_SVR_GC
286286
};
287287

288+
// NOTE!
289+
// Do not add overloaded methods, always use a different name, different from any methods declared here or
290+
// on the IGCHeap interface.
288291
class IGCHeapInternal : public IGCHeap {
289292
public:
290293
virtual int GetNumberOfHeaps () PURE_VIRTUAL
291294
virtual int GetHomeHeapNumber () PURE_VIRTUAL
292295
virtual size_t GetPromotedBytes(int heap_index) PURE_VIRTUAL
296+
// Used by the bridge code.
297+
virtual bool IsPromoted2(Object* object, bool bVerifyNextHeader) PURE_VIRTUAL
293298

294299
unsigned GetMaxGeneration()
295300
{

src/coreclr/gc/gcbridge.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ static bool PushObject(Object* obj, void* unused)
666666
}
667667

668668
// We only care about dead objects
669-
if (!data && g_theGCHeap->IsPromoted(obj, false))
669+
if (!data && g_theGCHeap->IsPromoted2(obj, false))
670670
{
671671
#if DUMP_GRAPH
672672
printf ("alive\n");

src/coreclr/gc/gcimpl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ class GCHeap : public IGCHeapInternal
126126
// Check if an argument is promoted (ONLY CALL DURING
127127
// THE PROMOTIONSGRANTED CALLBACK.)
128128
bool IsPromoted (Object *object);
129-
bool IsPromoted (Object *object, bool bVerifyNextHeader);
129+
bool IsPromoted2 (Object *object, bool bVerifyNextHeader);
130130

131131
size_t GetPromotedBytes (int heap_index);
132132

src/coreclr/gc/gcinterface.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,9 @@ enum class GCConfigurationType
644644
using ConfigurationValueFunc = void (*)(void* context, void* name, void* publicKey, GCConfigurationType type, int64_t data);
645645

646646
// IGCHeap is the interface that the VM will use when interacting with the GC.
647+
// NOTE!
648+
// Only add methods to the end.
649+
// Do not add overloaded methods. Always use a different name.
647650
class IGCHeap {
648651
public:
649652
/*
@@ -1065,9 +1068,6 @@ class IGCHeap {
10651068
virtual void DiagWalkHeapWithACHandling(walk_fn fn, void* context, int gen_number, bool walk_large_object_heap_p) PURE_VIRTUAL
10661069

10671070
virtual void NullBridgeObjectsWeakRefs(size_t length, void* unreachableObjectHandles) PURE_VIRTUAL;
1068-
1069-
// Returns whether nor this GC was promoted by the last GC.
1070-
virtual bool IsPromoted(Object* object, bool bVerifyNextHeader) PURE_VIRTUAL
10711071
};
10721072

10731073
#ifdef WRITE_BARRIER_CHECK

0 commit comments

Comments
 (0)