< prev index next >

src/share/vm/gc/g1/g1ConcurrentMark.hpp

Print this page
rev 10384 : [mq]: step.00
rev 10385 : [mq]: step.01


  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_GC_G1_G1CONCURRENTMARK_HPP
  26 #define SHARE_VM_GC_G1_G1CONCURRENTMARK_HPP
  27 
  28 #include "classfile/javaClasses.hpp"
  29 #include "gc/g1/g1RegionToSpaceMapper.hpp"
  30 #include "gc/g1/heapRegionSet.hpp"
  31 #include "gc/shared/taskqueue.hpp"
  32 
  33 class G1CollectedHeap;
  34 class G1CMBitMap;
  35 class G1CMTask;
  36 class G1ConcurrentMark;


  37 typedef GenericTaskQueue<oop, mtGC>              G1CMTaskQueue;
  38 typedef GenericTaskQueueSet<G1CMTaskQueue, mtGC> G1CMTaskQueueSet;
  39 
  40 // Closure used by CM during concurrent reference discovery
  41 // and reference processing (during remarking) to determine
  42 // if a particular object is alive. It is primarily used
  43 // to determine if referents of discovered reference objects
  44 // are alive. An instance is also embedded into the
  45 // reference processor as the _is_alive_non_header field
  46 class G1CMIsAliveClosure: public BoolObjectClosure {
  47   G1CollectedHeap* _g1;
  48  public:
  49   G1CMIsAliveClosure(G1CollectedHeap* g1) : _g1(g1) { }
  50 
  51   bool do_object_b(oop obj);
  52 };
  53 
  54 // A generic CM bit map.  This is essentially a wrapper around the BitMap
  55 // class, with one bit per (1<<_shifter) HeapWords.
  56 


 335   WorkGangBarrierSync     _second_overflow_barrier_sync;
 336 
 337   // This is set by any task, when an overflow on the global data
 338   // structures is detected
 339   volatile bool           _has_overflown;
 340   // True: marking is concurrent, false: we're in remark
 341   volatile bool           _concurrent;
 342   // Set at the end of a Full GC so that marking aborts
 343   volatile bool           _has_aborted;
 344 
 345   // Used when remark aborts due to an overflow to indicate that
 346   // another concurrent marking phase should start
 347   volatile bool           _restart_for_overflow;
 348 
 349   // This is true from the very start of concurrent marking until the
 350   // point when all the tasks complete their work. It is really used
 351   // to determine the points between the end of concurrent marking and
 352   // time of remark.
 353   volatile bool           _concurrent_marking_in_progress;
 354 
 355   // There would be a race between ConcurrentMarkThread and VMThread(ConcurrentMark::abort())
 356   // to call ConcurrentGCTimer::register_gc_concurrent_end().
 357   // And this variable is used to keep track of concurrent phase.
 358   volatile uint           _concurrent_phase_status;
 359   // Concurrent phase is not yet started.
 360   static const uint       ConcPhaseNotStarted = 0;
 361   // Concurrent phase is started.
 362   static const uint       ConcPhaseStarted = 1;
 363   // Caller thread of ConcurrentGCTimer::register_gc_concurrent_end() is ending concurrent phase.
 364   // So other thread should wait until the status to be changed to ConcPhaseNotStarted.
 365   static const uint       ConcPhaseStopping = 2;
 366 
 367   // All of these times are in ms
 368   NumberSeq _init_times;
 369   NumberSeq _remark_times;
 370   NumberSeq _remark_mark_times;
 371   NumberSeq _remark_weak_ref_times;
 372   NumberSeq _cleanup_times;
 373   double    _total_counting_time;
 374   double    _total_rs_scrub_time;
 375 
 376   double*   _accum_task_vtime;   // Accumulated task vtime
 377 
 378   WorkGang* _parallel_workers;
 379 
 380   void weakRefsWorkParallelPart(BoolObjectClosure* is_alive, bool purged_classes);
 381   void weakRefsWork(bool clear_all_soft_refs);
 382 
 383   void swapMarkBitMaps();
 384 
 385   // It resets the global marking data structures, as well as the


 513   void mark_stack_pop(oop* arr, int max, int* n) {
 514     _markStack.par_pop_arr(arr, max, n);
 515   }
 516   size_t mark_stack_size()                { return _markStack.size(); }
 517   size_t partial_mark_stack_size_target() { return _markStack.maxElems()/3; }
 518   bool mark_stack_overflow()              { return _markStack.overflow(); }
 519   bool mark_stack_empty()                 { return _markStack.isEmpty(); }
 520 
 521   G1CMRootRegions* root_regions() { return &_root_regions; }
 522 
 523   bool concurrent_marking_in_progress() {
 524     return _concurrent_marking_in_progress;
 525   }
 526   void set_concurrent_marking_in_progress() {
 527     _concurrent_marking_in_progress = true;
 528   }
 529   void clear_concurrent_marking_in_progress() {
 530     _concurrent_marking_in_progress = false;
 531   }
 532 
 533   void register_concurrent_phase_start(const char* title);
 534   void register_concurrent_phase_end();
 535   // Ends both concurrent phase and timer.
 536   void register_concurrent_gc_end_and_stop_timer();
 537 
 538   void update_accum_task_vtime(int i, double vtime) {
 539     _accum_task_vtime[i] += vtime;
 540   }
 541 
 542   double all_task_accum_vtime() {
 543     double ret = 0.0;
 544     for (uint i = 0; i < _max_worker_id; ++i)
 545       ret += _accum_task_vtime[i];
 546     return ret;
 547   }
 548 
 549   // Attempts to steal an object from the task queues of other tasks
 550   bool try_stealing(uint worker_id, int* hash_seed, oop& obj);
 551 
 552   G1ConcurrentMark(G1CollectedHeap* g1h,
 553                    G1RegionToSpaceMapper* prev_bitmap_storage,
 554                    G1RegionToSpaceMapper* next_bitmap_storage);
 555   ~G1ConcurrentMark();
 556 


 712 
 713   // Attempts to mark the given object and, if successful, counts
 714   // the object in the given task/worker counting structures.
 715   inline bool par_mark_and_count(oop obj,
 716                                  HeapRegion* hr,
 717                                  size_t* marked_bytes_array,
 718                                  BitMap* task_card_bm);
 719 
 720   // Attempts to mark the given object and, if successful, counts
 721   // the object in the task/worker counting structures for the
 722   // given worker id.
 723   inline bool par_mark_and_count(oop obj,
 724                                  size_t word_size,
 725                                  HeapRegion* hr,
 726                                  uint worker_id);
 727 
 728   // Returns true if initialization was successfully completed.
 729   bool completed_initialization() const {
 730     return _completed_initialization;
 731   }



 732 
 733 protected:
 734   // Clear all the per-task bitmaps and arrays used to store the
 735   // counting data.
 736   void clear_all_count_data();
 737 
 738   // Aggregates the counting data for each worker/task
 739   // that was constructed while marking. Also sets
 740   // the amount of marked bytes for each region and
 741   // the top at concurrent mark count.
 742   void aggregate_count_data();
 743 
 744   // Verification routine
 745   void verify_count_data();
 746 };
 747 
 748 // A class representing a marking task.
 749 class G1CMTask : public TerminatorTerminator {
 750 private:
 751   enum PrivateConstants {




  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_VM_GC_G1_G1CONCURRENTMARK_HPP
  26 #define SHARE_VM_GC_G1_G1CONCURRENTMARK_HPP
  27 
  28 #include "classfile/javaClasses.hpp"
  29 #include "gc/g1/g1RegionToSpaceMapper.hpp"
  30 #include "gc/g1/heapRegionSet.hpp"
  31 #include "gc/shared/taskqueue.hpp"
  32 
  33 class G1CollectedHeap;
  34 class G1CMBitMap;
  35 class G1CMTask;
  36 class G1ConcurrentMark;
  37 class ConcurrentGCTimer;
  38 class G1OldTracer;
  39 typedef GenericTaskQueue<oop, mtGC>              G1CMTaskQueue;
  40 typedef GenericTaskQueueSet<G1CMTaskQueue, mtGC> G1CMTaskQueueSet;
  41 
  42 // Closure used by CM during concurrent reference discovery
  43 // and reference processing (during remarking) to determine
  44 // if a particular object is alive. It is primarily used
  45 // to determine if referents of discovered reference objects
  46 // are alive. An instance is also embedded into the
  47 // reference processor as the _is_alive_non_header field
  48 class G1CMIsAliveClosure: public BoolObjectClosure {
  49   G1CollectedHeap* _g1;
  50  public:
  51   G1CMIsAliveClosure(G1CollectedHeap* g1) : _g1(g1) { }
  52 
  53   bool do_object_b(oop obj);
  54 };
  55 
  56 // A generic CM bit map.  This is essentially a wrapper around the BitMap
  57 // class, with one bit per (1<<_shifter) HeapWords.
  58 


 337   WorkGangBarrierSync     _second_overflow_barrier_sync;
 338 
 339   // This is set by any task, when an overflow on the global data
 340   // structures is detected
 341   volatile bool           _has_overflown;
 342   // True: marking is concurrent, false: we're in remark
 343   volatile bool           _concurrent;
 344   // Set at the end of a Full GC so that marking aborts
 345   volatile bool           _has_aborted;
 346 
 347   // Used when remark aborts due to an overflow to indicate that
 348   // another concurrent marking phase should start
 349   volatile bool           _restart_for_overflow;
 350 
 351   // This is true from the very start of concurrent marking until the
 352   // point when all the tasks complete their work. It is really used
 353   // to determine the points between the end of concurrent marking and
 354   // time of remark.
 355   volatile bool           _concurrent_marking_in_progress;
 356 
 357   ConcurrentGCTimer*      _gc_timer_cm;
 358 
 359   G1OldTracer*            _gc_tracer_cm;








 360 
 361   // All of these times are in ms
 362   NumberSeq _init_times;
 363   NumberSeq _remark_times;
 364   NumberSeq _remark_mark_times;
 365   NumberSeq _remark_weak_ref_times;
 366   NumberSeq _cleanup_times;
 367   double    _total_counting_time;
 368   double    _total_rs_scrub_time;
 369 
 370   double*   _accum_task_vtime;   // Accumulated task vtime
 371 
 372   WorkGang* _parallel_workers;
 373 
 374   void weakRefsWorkParallelPart(BoolObjectClosure* is_alive, bool purged_classes);
 375   void weakRefsWork(bool clear_all_soft_refs);
 376 
 377   void swapMarkBitMaps();
 378 
 379   // It resets the global marking data structures, as well as the


 507   void mark_stack_pop(oop* arr, int max, int* n) {
 508     _markStack.par_pop_arr(arr, max, n);
 509   }
 510   size_t mark_stack_size()                { return _markStack.size(); }
 511   size_t partial_mark_stack_size_target() { return _markStack.maxElems()/3; }
 512   bool mark_stack_overflow()              { return _markStack.overflow(); }
 513   bool mark_stack_empty()                 { return _markStack.isEmpty(); }
 514 
 515   G1CMRootRegions* root_regions() { return &_root_regions; }
 516 
 517   bool concurrent_marking_in_progress() {
 518     return _concurrent_marking_in_progress;
 519   }
 520   void set_concurrent_marking_in_progress() {
 521     _concurrent_marking_in_progress = true;
 522   }
 523   void clear_concurrent_marking_in_progress() {
 524     _concurrent_marking_in_progress = false;
 525   }
 526 
 527   void concurrent_cycle_start();
 528   void concurrent_cycle_end();


 529 
 530   void update_accum_task_vtime(int i, double vtime) {
 531     _accum_task_vtime[i] += vtime;
 532   }
 533 
 534   double all_task_accum_vtime() {
 535     double ret = 0.0;
 536     for (uint i = 0; i < _max_worker_id; ++i)
 537       ret += _accum_task_vtime[i];
 538     return ret;
 539   }
 540 
 541   // Attempts to steal an object from the task queues of other tasks
 542   bool try_stealing(uint worker_id, int* hash_seed, oop& obj);
 543 
 544   G1ConcurrentMark(G1CollectedHeap* g1h,
 545                    G1RegionToSpaceMapper* prev_bitmap_storage,
 546                    G1RegionToSpaceMapper* next_bitmap_storage);
 547   ~G1ConcurrentMark();
 548 


 704 
 705   // Attempts to mark the given object and, if successful, counts
 706   // the object in the given task/worker counting structures.
 707   inline bool par_mark_and_count(oop obj,
 708                                  HeapRegion* hr,
 709                                  size_t* marked_bytes_array,
 710                                  BitMap* task_card_bm);
 711 
 712   // Attempts to mark the given object and, if successful, counts
 713   // the object in the task/worker counting structures for the
 714   // given worker id.
 715   inline bool par_mark_and_count(oop obj,
 716                                  size_t word_size,
 717                                  HeapRegion* hr,
 718                                  uint worker_id);
 719 
 720   // Returns true if initialization was successfully completed.
 721   bool completed_initialization() const {
 722     return _completed_initialization;
 723   }
 724 
 725   ConcurrentGCTimer* gc_timer_cm() const { return _gc_timer_cm; }
 726   G1OldTracer* gc_tracer_cm() const { return _gc_tracer_cm; }
 727 
 728 protected:
 729   // Clear all the per-task bitmaps and arrays used to store the
 730   // counting data.
 731   void clear_all_count_data();
 732 
 733   // Aggregates the counting data for each worker/task
 734   // that was constructed while marking. Also sets
 735   // the amount of marked bytes for each region and
 736   // the top at concurrent mark count.
 737   void aggregate_count_data();
 738 
 739   // Verification routine
 740   void verify_count_data();
 741 };
 742 
 743 // A class representing a marking task.
 744 class G1CMTask : public TerminatorTerminator {
 745 private:
 746   enum PrivateConstants {


< prev index next >