hotspot/src/share/vm/gc/g1/g1ConcurrentMark.cpp
changeset 46447 dbb55d89699c
parent 46423 62fac1c2c841
child 46505 fd4bc78630b1
equal deleted inserted replaced
46446:ababb65abf24 46447:dbb55d89699c
   133 }
   133 }
   134 
   134 
   135 G1CMMarkStack::G1CMMarkStack() :
   135 G1CMMarkStack::G1CMMarkStack() :
   136   _max_chunk_capacity(0),
   136   _max_chunk_capacity(0),
   137   _base(NULL),
   137   _base(NULL),
   138   _chunk_capacity(0),
   138   _chunk_capacity(0) {
   139   _should_expand(false) {
       
   140   set_empty();
   139   set_empty();
   141 }
   140 }
   142 
   141 
   143 bool G1CMMarkStack::resize(size_t new_capacity) {
   142 bool G1CMMarkStack::resize(size_t new_capacity) {
   144   assert(is_empty(), "Only resize when stack is empty.");
   143   assert(is_empty(), "Only resize when stack is empty.");
   157   }
   156   }
   158 
   157 
   159   _base = new_base;
   158   _base = new_base;
   160   _chunk_capacity = new_capacity;
   159   _chunk_capacity = new_capacity;
   161   set_empty();
   160   set_empty();
   162   _should_expand = false;
       
   163 
   161 
   164   return true;
   162   return true;
   165 }
   163 }
   166 
   164 
   167 size_t G1CMMarkStack::capacity_alignment() {
   165 size_t G1CMMarkStack::capacity_alignment() {
   186 
   184 
   187   return resize(initial_chunk_capacity);
   185   return resize(initial_chunk_capacity);
   188 }
   186 }
   189 
   187 
   190 void G1CMMarkStack::expand() {
   188 void G1CMMarkStack::expand() {
   191   // Clear expansion flag
       
   192   _should_expand = false;
       
   193 
       
   194   if (_chunk_capacity == _max_chunk_capacity) {
   189   if (_chunk_capacity == _max_chunk_capacity) {
   195     log_debug(gc)("Can not expand overflow mark stack further, already at maximum capacity of " SIZE_FORMAT " chunks.", _chunk_capacity);
   190     log_debug(gc)("Can not expand overflow mark stack further, already at maximum capacity of " SIZE_FORMAT " chunks.", _chunk_capacity);
   196     return;
   191     return;
   197   }
   192   }
   198   size_t old_capacity = _chunk_capacity;
   193   size_t old_capacity = _chunk_capacity;
   588   set_concurrent_marking_in_progress();
   583   set_concurrent_marking_in_progress();
   589 }
   584 }
   590 
   585 
   591 
   586 
   592 void G1ConcurrentMark::reset_marking_state() {
   587 void G1ConcurrentMark::reset_marking_state() {
   593   _global_mark_stack.set_should_expand(has_overflown());
       
   594   _global_mark_stack.set_empty();
   588   _global_mark_stack.set_empty();
       
   589 
       
   590   // Expand the marking stack, if we have to and if we can.
       
   591   if (has_overflown()) {
       
   592     _global_mark_stack.expand();
       
   593   }
       
   594 
   595   clear_has_overflown();
   595   clear_has_overflown();
   596   _finger = _heap_start;
   596   _finger = _heap_start;
   597 
   597 
   598   for (uint i = 0; i < _max_worker_id; ++i) {
   598   for (uint i = 0; i < _max_worker_id; ++i) {
   599     G1CMTaskQueue* queue = _task_queues->queue(i);
   599     G1CMTaskQueue* queue = _task_queues->queue(i);
  1152     }
  1152     }
  1153     g1h->verifier()->check_bitmaps("Remark End");
  1153     g1h->verifier()->check_bitmaps("Remark End");
  1154     assert(!restart_for_overflow(), "sanity");
  1154     assert(!restart_for_overflow(), "sanity");
  1155     // Completely reset the marking state since marking completed
  1155     // Completely reset the marking state since marking completed
  1156     set_non_marking_state();
  1156     set_non_marking_state();
  1157   }
       
  1158 
       
  1159   // Expand the marking stack, if we have to and if we can.
       
  1160   if (_global_mark_stack.should_expand()) {
       
  1161     _global_mark_stack.expand();
       
  1162   }
  1157   }
  1163 
  1158 
  1164   // Statistics
  1159   // Statistics
  1165   double now = os::elapsedTime();
  1160   double now = os::elapsedTime();
  1166   _remark_mark_times.add((mark_work_end - start) * 1000.0);
  1161   _remark_mark_times.add((mark_work_end - start) * 1000.0);