diff --git a/src/coreclr/gc/gc.cpp b/src/coreclr/gc/gc.cpp index 4cc0ff0fc19473..6aee205096ba7e 100644 --- a/src/coreclr/gc/gc.cpp +++ b/src/coreclr/gc/gc.cpp @@ -24170,12 +24170,17 @@ BOOL ref_p (uint8_t* r) return (straight_ref_p (r) || partial_object_p (r)); } -mark_queue_t::mark_queue_t() : curr_slot_index(0) +mark_queue_t::mark_queue_t() +#ifdef MARK_PHASE_PREFETCH + : curr_slot_index(0) +#endif //MARK_PHASE_PREFETCH { +#ifdef MARK_PHASE_PREFETCH for (size_t i = 0; i < slot_count; i++) { slot_table[i] = nullptr; } +#endif //MARK_PHASE_PREFETCH } // place an object in the mark queue @@ -24185,6 +24190,7 @@ mark_queue_t::mark_queue_t() : curr_slot_index(0) FORCEINLINE uint8_t *mark_queue_t::queue_mark(uint8_t *o) { +#ifdef MARK_PHASE_PREFETCH Prefetch (o); // while the prefetch is taking effect, park our object in the queue @@ -24197,6 +24203,9 @@ uint8_t *mark_queue_t::queue_mark(uint8_t *o) curr_slot_index = (slot_index + 1) % slot_count; if (old_o == nullptr) return nullptr; +#else //MARK_PHASE_PREFETCH + uint8_t* old_o = o; +#endif //MARK_PHASE_PREFETCH // this causes us to access the method table pointer of the old object BOOL already_marked = marked (old_o); @@ -24248,6 +24257,7 @@ uint8_t *mark_queue_t::queue_mark(uint8_t *o, int condemned_gen) // returns nullptr if there is no such object uint8_t* mark_queue_t::get_next_marked() { +#ifdef MARK_PHASE_PREFETCH size_t slot_index = curr_slot_index; size_t empty_slot_count = 0; while (empty_slot_count < slot_count) @@ -24267,15 +24277,18 @@ uint8_t* mark_queue_t::get_next_marked() } empty_slot_count++; } +#endif //MARK_PHASE_PREFETCH return nullptr; } void mark_queue_t::verify_empty() { +#ifdef MARK_PHASE_PREFETCH for (size_t slot_index = 0; slot_index < slot_count; slot_index++) { assert(slot_table[slot_index] == nullptr); } +#endif //MARK_PHASE_PREFETCH } void gc_heap::mark_object_simple1 (uint8_t* oo, uint8_t* start THREAD_NUMBER_DCL) diff --git a/src/coreclr/gc/gcpriv.h b/src/coreclr/gc/gcpriv.h index 54f4664660e027..599a5b86908492 100644 --- a/src/coreclr/gc/gcpriv.h +++ b/src/coreclr/gc/gcpriv.h @@ -62,6 +62,7 @@ inline void FATAL_GC_ERROR() // + creates some ro segs // We can add more mechanisms here. //#define STRESS_REGIONS +#define MARK_PHASE_PREFETCH #endif //USE_REGIONS // FEATURE_STRUCTALIGN was added by Midori. In CLR we are not interested @@ -1222,9 +1223,11 @@ enum bookkeeping_element class mark_queue_t { +#ifdef MARK_PHASE_PREFETCH static const size_t slot_count = 16; uint8_t* slot_table[slot_count]; size_t curr_slot_index; +#endif //MARK_PHASE_PREFETCH public: mark_queue_t();