282 ConcurrentMarkThread* _cmThread; // The thread doing the work
283 G1CollectedHeap* _g1h; // The heap
284 uint _parallel_marking_threads; // The number of marking
285 // threads we're using
286 uint _max_parallel_marking_threads; // Max number of marking
287 // threads we'll ever use
288 double _sleep_factor; // How much we have to sleep, with
289 // respect to the work we just did, to
290 // meet the marking overhead goal
291 double _marking_task_overhead; // Marking target overhead for
292 // a single task
293
294 FreeRegionList _cleanup_list;
295
296 // Concurrent marking support structures
297 G1CMBitMap _markBitMap1;
298 G1CMBitMap _markBitMap2;
299 G1CMBitMapRO* _prevMarkBitMap; // Completed mark bitmap
300 G1CMBitMap* _nextMarkBitMap; // Under-construction mark bitmap
301
302 BitMap _region_bm;
303 BitMap _card_bm;
304
305 // Heap bounds
306 HeapWord* _heap_start;
307 HeapWord* _heap_end;
308
309 // Root region tracking and claiming
310 G1CMRootRegions _root_regions;
311
312 // For gray objects
313 G1CMMarkStack _markStack; // Grey objects behind global finger
314 HeapWord* volatile _finger; // The global finger, region aligned,
315 // always points to the end of the
316 // last claimed region
317
318 // Marking tasks
319 uint _max_worker_id;// Maximum worker id
320 uint _active_tasks; // Task num currently active
321 G1CMTask** _tasks; // Task queue array (max_worker_id len)
322 G1CMTaskQueueSet* _task_queues; // Task queue set
356 bool _concurrent_phase_started;
357
358 // All of these times are in ms
359 NumberSeq _init_times;
360 NumberSeq _remark_times;
361 NumberSeq _remark_mark_times;
362 NumberSeq _remark_weak_ref_times;
363 NumberSeq _cleanup_times;
364 double _total_counting_time;
365 double _total_rs_scrub_time;
366
367 double* _accum_task_vtime; // Accumulated task vtime
368
369 WorkGang* _parallel_workers;
370
371 void weakRefsWorkParallelPart(BoolObjectClosure* is_alive, bool purged_classes);
372 void weakRefsWork(bool clear_all_soft_refs);
373
374 void swapMarkBitMaps();
375
376 // It resets the global marking data structures, as well as the
377 // task local ones; should be called during initial mark.
378 void reset();
379
380 // Resets all the marking data structures. Called when we have to restart
381 // marking or when marking completes (via set_non_marking_state below).
382 void reset_marking_state(bool clear_overflow = true);
383
384 // We do this after we're done with marking so that the marking data
385 // structures are initialized to a sensible and predictable state.
386 void set_non_marking_state();
387
388 // Called to indicate how many threads are currently active.
389 void set_concurrency(uint active_tasks);
390
391 // It should be called to indicate which phase we're in (concurrent
392 // mark or remark) and how many threads are currently active.
393 void set_concurrency_and_phase(uint active_tasks, bool concurrent);
394
395 // Prints all gathered CM-related statistics
613
614 // Notify data structures that a GC has started.
615 void note_start_of_gc() {
616 _markStack.note_start_of_gc();
617 }
618
619 // Notify data structures that a GC is finished.
620 void note_end_of_gc() {
621 _markStack.note_end_of_gc();
622 }
623
624 // Verify that there are no CSet oops on the stacks (taskqueues /
625 // global mark stack) and fingers (global / per-task).
626 // If marking is not in progress, it's a no-op.
627 void verify_no_cset_oops() PRODUCT_RETURN;
628
629 inline bool isPrevMarked(oop p) const;
630
631 inline bool do_yield_check(uint worker_i = 0);
632
633 // Called to abort the marking cycle after a Full GC takes place.
634 void abort();
635
636 bool has_aborted() { return _has_aborted; }
637
638 void print_summary_info();
639
640 void print_worker_threads_on(outputStream* st) const;
641
642 void print_on_error(outputStream* st) const;
643
644 // Liveness counting
645
646 // Utility routine to set an exclusive range of cards on the given
647 // card liveness bitmap
648 inline void set_card_bitmap_range(BitMap* card_bm,
649 BitMap::idx_t start_idx,
650 BitMap::idx_t end_idx,
651 bool is_par);
652
653 // Returns the card number of the bottom of the G1 heap.
703 size_t* marked_bytes_array,
704 BitMap* task_card_bm);
705
706 // Attempts to mark the given object and, if successful, counts
707 // the object in the task/worker counting structures for the
708 // given worker id.
709 inline bool par_mark_and_count(oop obj,
710 size_t word_size,
711 HeapRegion* hr,
712 uint worker_id);
713
714 // Returns true if initialization was successfully completed.
715 bool completed_initialization() const {
716 return _completed_initialization;
717 }
718
719 protected:
720 // Clear all the per-task bitmaps and arrays used to store the
721 // counting data.
722 void clear_all_count_data();
723
724 // Aggregates the counting data for each worker/task
725 // that was constructed while marking. Also sets
726 // the amount of marked bytes for each region and
727 // the top at concurrent mark count.
728 void aggregate_count_data();
729
730 // Verification routine
731 void verify_count_data();
732 };
733
734 // A class representing a marking task.
735 class G1CMTask : public TerminatorTerminator {
736 private:
737 enum PrivateConstants {
738 // the regular clock call is called once the scanned words reaches
739 // this limit
740 words_scanned_period = 12*1024,
741 // the regular clock call is called once the number of visited
742 // references reaches this limit
|
282 ConcurrentMarkThread* _cmThread; // The thread doing the work
283 G1CollectedHeap* _g1h; // The heap
284 uint _parallel_marking_threads; // The number of marking
285 // threads we're using
286 uint _max_parallel_marking_threads; // Max number of marking
287 // threads we'll ever use
288 double _sleep_factor; // How much we have to sleep, with
289 // respect to the work we just did, to
290 // meet the marking overhead goal
291 double _marking_task_overhead; // Marking target overhead for
292 // a single task
293
294 FreeRegionList _cleanup_list;
295
296 // Concurrent marking support structures
297 G1CMBitMap _markBitMap1;
298 G1CMBitMap _markBitMap2;
299 G1CMBitMapRO* _prevMarkBitMap; // Completed mark bitmap
300 G1CMBitMap* _nextMarkBitMap; // Under-construction mark bitmap
301
302 // A set bit indicates whether the given region contains any live object. This
303 // is the "master" bitmap used for remembered set scrubbing.
304 BitMap _region_bm;
305 // A set bit indicates that the given card contains a live object. This is the
306 // "master" bitmap used for remembered set scrubbing.
307 BitMap _card_bm;
308
309 // Heap bounds
310 HeapWord* _heap_start;
311 HeapWord* _heap_end;
312
313 // Root region tracking and claiming
314 G1CMRootRegions _root_regions;
315
316 // For gray objects
317 G1CMMarkStack _markStack; // Grey objects behind global finger
318 HeapWord* volatile _finger; // The global finger, region aligned,
319 // always points to the end of the
320 // last claimed region
321
322 // Marking tasks
323 uint _max_worker_id;// Maximum worker id
324 uint _active_tasks; // Task num currently active
325 G1CMTask** _tasks; // Task queue array (max_worker_id len)
326 G1CMTaskQueueSet* _task_queues; // Task queue set
360 bool _concurrent_phase_started;
361
362 // All of these times are in ms
363 NumberSeq _init_times;
364 NumberSeq _remark_times;
365 NumberSeq _remark_mark_times;
366 NumberSeq _remark_weak_ref_times;
367 NumberSeq _cleanup_times;
368 double _total_counting_time;
369 double _total_rs_scrub_time;
370
371 double* _accum_task_vtime; // Accumulated task vtime
372
373 WorkGang* _parallel_workers;
374
375 void weakRefsWorkParallelPart(BoolObjectClosure* is_alive, bool purged_classes);
376 void weakRefsWork(bool clear_all_soft_refs);
377
378 void swapMarkBitMaps();
379
380 // Allocates and returns a zero-ed out "large" bitmap of the given size in bits.
381 // It is always allocated using virtual memory.
382 BitMap allocate_large_bitmap(BitMap::idx_t size_in_bits);
383 // Allocates the memory for all bitmaps used by the concurrent marking.
384 void allocate_internal_bitmaps();
385 // Pre-touches the internal bitmaps.
386 void pretouch_internal_bitmaps();
387
388 // It resets the global marking data structures, as well as the
389 // task local ones; should be called during initial mark.
390 void reset();
391
392 // Resets all the marking data structures. Called when we have to restart
393 // marking or when marking completes (via set_non_marking_state below).
394 void reset_marking_state(bool clear_overflow = true);
395
396 // We do this after we're done with marking so that the marking data
397 // structures are initialized to a sensible and predictable state.
398 void set_non_marking_state();
399
400 // Called to indicate how many threads are currently active.
401 void set_concurrency(uint active_tasks);
402
403 // It should be called to indicate which phase we're in (concurrent
404 // mark or remark) and how many threads are currently active.
405 void set_concurrency_and_phase(uint active_tasks, bool concurrent);
406
407 // Prints all gathered CM-related statistics
625
626 // Notify data structures that a GC has started.
627 void note_start_of_gc() {
628 _markStack.note_start_of_gc();
629 }
630
631 // Notify data structures that a GC is finished.
632 void note_end_of_gc() {
633 _markStack.note_end_of_gc();
634 }
635
636 // Verify that there are no CSet oops on the stacks (taskqueues /
637 // global mark stack) and fingers (global / per-task).
638 // If marking is not in progress, it's a no-op.
639 void verify_no_cset_oops() PRODUCT_RETURN;
640
641 inline bool isPrevMarked(oop p) const;
642
643 inline bool do_yield_check(uint worker_i = 0);
644
645 // Abandon current marking iteration due to a Full GC.
646 void abort();
647
648 bool has_aborted() { return _has_aborted; }
649
650 void print_summary_info();
651
652 void print_worker_threads_on(outputStream* st) const;
653
654 void print_on_error(outputStream* st) const;
655
656 // Liveness counting
657
658 // Utility routine to set an exclusive range of cards on the given
659 // card liveness bitmap
660 inline void set_card_bitmap_range(BitMap* card_bm,
661 BitMap::idx_t start_idx,
662 BitMap::idx_t end_idx,
663 bool is_par);
664
665 // Returns the card number of the bottom of the G1 heap.
715 size_t* marked_bytes_array,
716 BitMap* task_card_bm);
717
718 // Attempts to mark the given object and, if successful, counts
719 // the object in the task/worker counting structures for the
720 // given worker id.
721 inline bool par_mark_and_count(oop obj,
722 size_t word_size,
723 HeapRegion* hr,
724 uint worker_id);
725
726 // Returns true if initialization was successfully completed.
727 bool completed_initialization() const {
728 return _completed_initialization;
729 }
730
731 protected:
732 // Clear all the per-task bitmaps and arrays used to store the
733 // counting data.
734 void clear_all_count_data();
735
736 // Verify all of the above data structures that they are in initial state.
737 void verify_all_count_data();
738
739 // Aggregates the counting data for each worker/task
740 // that was constructed while marking. Also sets
741 // the amount of marked bytes for each region and
742 // the top at concurrent mark count.
743 void aggregate_count_data();
744
745 // Verification routine
746 void verify_count_data();
747 };
748
749 // A class representing a marking task.
750 class G1CMTask : public TerminatorTerminator {
751 private:
752 enum PrivateConstants {
753 // the regular clock call is called once the scanned words reaches
754 // this limit
755 words_scanned_period = 12*1024,
756 // the regular clock call is called once the number of visited
757 // references reaches this limit
|