diff --git a/src/coreclr/gc/gc.cpp b/src/coreclr/gc/gc.cpp index bfba24d3fc4453..fa0835758fb0b9 100644 --- a/src/coreclr/gc/gc.cpp +++ b/src/coreclr/gc/gc.cpp @@ -4473,8 +4473,12 @@ class CObjectHeader : public Object return ((ArrayBase *)this)->GetNumComponents(); } - void Validate(BOOL bDeep=TRUE) + void Validate(BOOL bDeep=TRUE, BOOL bVerifyNextHeader = FALSE, BOOL bVerifySyncBlock = FALSE) { + // declaration of extra parameters just so the call site would need no #ifdefs + UNREFERENCED_PARAMETER(bVerifyNextHeader); + UNREFERENCED_PARAMETER(bVerifySyncBlock); + MethodTable * pMT = GetMethodTable(); _ASSERTE(pMT->SanityCheck()); @@ -45142,15 +45146,10 @@ HRESULT GCHeap::Initialize() // GC callback functions bool GCHeap::IsPromoted(Object* object) { -#ifdef _DEBUG - if (object) - { - ((CObjectHeader*)object)->Validate(); - } -#endif //_DEBUG - uint8_t* o = (uint8_t*)object; + bool is_marked; + if (gc_heap::settings.condemned_generation == max_generation) { #ifdef MULTIPLE_HEAPS @@ -45162,27 +45161,35 @@ bool GCHeap::IsPromoted(Object* object) #ifdef BACKGROUND_GC if (gc_heap::settings.concurrent) { - bool is_marked = (!((o < hp->background_saved_highest_address) && (o >= hp->background_saved_lowest_address))|| + is_marked = (!((o < hp->background_saved_highest_address) && (o >= hp->background_saved_lowest_address))|| hp->background_marked (o)); - return is_marked; } else #endif //BACKGROUND_GC { - return (!((o < hp->highest_address) && (o >= hp->lowest_address)) - || hp->is_mark_set (o)); + is_marked = (!((o < hp->highest_address) && (o >= hp->lowest_address)) + || hp->is_mark_set (o)); } } else { #ifdef USE_REGIONS - return (gc_heap::is_in_gc_range (o) ? (gc_heap::is_in_condemned_gc (o) ? gc_heap::is_mark_set (o) : true) : true); + is_marked = (gc_heap::is_in_gc_range (o) ? (gc_heap::is_in_condemned_gc (o) ? gc_heap::is_mark_set (o) : true) : true); #else gc_heap* hp = gc_heap::heap_of (o); - return (!((o < hp->gc_high) && (o >= hp->gc_low)) - || hp->is_mark_set (o)); + is_marked = (!((o < hp->gc_high) && (o >= hp->gc_low)) + || hp->is_mark_set (o)); #endif //USE_REGIONS } + +#ifdef _DEBUG + if (o) + { + ((CObjectHeader*)o)->Validate(TRUE, TRUE, is_marked); + } +#endif //_DEBUG + + return is_marked; } size_t GCHeap::GetPromotedBytes(int heap_index)