@@ -24092,12 +24092,17 @@ BOOL ref_p (uint8_t* r)
2409224092 return (straight_ref_p (r) || partial_object_p (r));
2409324093}
2409424094
24095- mark_queue_t::mark_queue_t() : curr_slot_index(0)
24095+ mark_queue_t::mark_queue_t()
24096+ #ifdef MARK_PHASE_PREFETCH
24097+ : curr_slot_index(0)
24098+ #endif //MARK_PHASE_PREFETCH
2409624099{
24100+ #ifdef MARK_PHASE_PREFETCH
2409724101 for (size_t i = 0; i < slot_count; i++)
2409824102 {
2409924103 slot_table[i] = nullptr;
2410024104 }
24105+ #endif //MARK_PHASE_PREFETCH
2410124106}
2410224107
2410324108// place an object in the mark queue
@@ -24107,6 +24112,7 @@ mark_queue_t::mark_queue_t() : curr_slot_index(0)
2410724112FORCEINLINE
2410824113uint8_t *mark_queue_t::queue_mark(uint8_t *o)
2410924114{
24115+ #ifdef MARK_PHASE_PREFETCH
2411024116 Prefetch (o);
2411124117
2411224118 // while the prefetch is taking effect, park our object in the queue
@@ -24119,6 +24125,9 @@ uint8_t *mark_queue_t::queue_mark(uint8_t *o)
2411924125 curr_slot_index = (slot_index + 1) % slot_count;
2412024126 if (old_o == nullptr)
2412124127 return nullptr;
24128+ #else //MARK_PHASE_PREFETCH
24129+ uint8_t* old_o = o;
24130+ #endif //MARK_PHASE_PREFETCH
2412224131
2412324132 // this causes us to access the method table pointer of the old object
2412424133 BOOL already_marked = marked (old_o);
@@ -24170,6 +24179,7 @@ uint8_t *mark_queue_t::queue_mark(uint8_t *o, int condemned_gen)
2417024179// returns nullptr if there is no such object
2417124180uint8_t* mark_queue_t::get_next_marked()
2417224181{
24182+ #ifdef MARK_PHASE_PREFETCH
2417324183 size_t slot_index = curr_slot_index;
2417424184 size_t empty_slot_count = 0;
2417524185 while (empty_slot_count < slot_count)
@@ -24189,15 +24199,18 @@ uint8_t* mark_queue_t::get_next_marked()
2418924199 }
2419024200 empty_slot_count++;
2419124201 }
24202+ #endif //MARK_PHASE_PREFETCH
2419224203 return nullptr;
2419324204}
2419424205
2419524206void mark_queue_t::verify_empty()
2419624207{
24208+ #ifdef MARK_PHASE_PREFETCH
2419724209 for (size_t slot_index = 0; slot_index < slot_count; slot_index++)
2419824210 {
2419924211 assert(slot_table[slot_index] == nullptr);
2420024212 }
24213+ #endif //MARK_PHASE_PREFETCH
2420124214}
2420224215
2420324216void gc_heap::mark_object_simple1 (uint8_t* oo, uint8_t* start THREAD_NUMBER_DCL)
@@ -25892,6 +25905,7 @@ BOOL gc_heap::process_mark_overflow(int condemned_gen_number)
2589225905
2589325906 BOOL overflow_p = FALSE;
2589425907recheck:
25908+ drain_mark_queue();
2589525909 if ((! (max_overflow_address == 0) ||
2589625910 ! (min_overflow_address == MAX_PTR)))
2589725911 {
@@ -26156,7 +26170,8 @@ void gc_heap::scan_dependent_handles (int condemned_gen_number, ScanContext *sc,
2615626170 if (process_mark_overflow(condemned_gen_number))
2615726171 fUnscannedPromotions = true;
2615826172
26159- drain_mark_queue();
26173+ // mark queue must be empty after process_mark_overflow
26174+ mark_queue.verify_empty();
2616026175
2616126176 // Perform the scan and set the flag if any promotions resulted.
2616226177 if (GCScan::GcDhReScan(sc))
@@ -26774,7 +26789,9 @@ void gc_heap::mark_phase (int condemned_gen_number, BOOL mark_only_p)
2677426789 // handle table has been fully promoted.
2677526790 GCScan::GcDhInitialScan(GCHeap::Promote, condemned_gen_number, max_generation, &sc);
2677626791 scan_dependent_handles(condemned_gen_number, &sc, true);
26777- drain_mark_queue();
26792+
26793+ // mark queue must be empty after scan_dependent_handles
26794+ mark_queue.verify_empty();
2677826795 fire_mark_event (ETW::GC_ROOT_DH_HANDLES, current_promoted_bytes, last_promoted_bytes);
2677926796
2678026797#ifdef MULTIPLE_HEAPS
@@ -26864,7 +26881,9 @@ void gc_heap::mark_phase (int condemned_gen_number, BOOL mark_only_p)
2686426881 // Scan dependent handles again to promote any secondaries associated with primaries that were promoted
2686526882 // for finalization. As before scan_dependent_handles will also process any mark stack overflow.
2686626883 scan_dependent_handles(condemned_gen_number, &sc, false);
26867- drain_mark_queue();
26884+
26885+ // mark queue must be empty after scan_dependent_handles
26886+ mark_queue.verify_empty();
2686826887 fire_mark_event (ETW::GC_ROOT_DH_HANDLES, current_promoted_bytes, last_promoted_bytes);
2686926888#endif //FEATURE_PREMORTEM_FINALIZATION
2687026889
0 commit comments