src/hotspot/share/gc/g1/g1ConcurrentMark.cpp
changeset 49643 a3453bbd5418
parent 49635 e79bbf1635da
child 49644 50a01910e00a
equal deleted inserted replaced
49642:7bad9c9efdf3 49643:a3453bbd5418
   654         // Repeat the asserts from before the start of the closure. We will do them
   654         // Repeat the asserts from before the start of the closure. We will do them
   655         // as asserts here to minimize their overhead on the product. However, we
   655         // as asserts here to minimize their overhead on the product. However, we
   656         // will have them as guarantees at the beginning / end of the bitmap
   656         // will have them as guarantees at the beginning / end of the bitmap
   657         // clearing to get some checking in the product.
   657         // clearing to get some checking in the product.
   658         assert(_cm == NULL || _cm->cm_thread()->during_cycle(), "invariant");
   658         assert(_cm == NULL || _cm->cm_thread()->during_cycle(), "invariant");
   659         assert(_cm == NULL || !G1CollectedHeap::heap()->collector_state()->mark_in_progress(), "invariant");
   659         assert(_cm == NULL || !G1CollectedHeap::heap()->collector_state()->mark_or_rebuild_in_progress(), "invariant");
   660       }
   660       }
   661       assert(cur == end, "Must have completed iteration over the bitmap for region %u.", r->hrm_index());
   661       assert(cur == end, "Must have completed iteration over the bitmap for region %u.", r->hrm_index());
   662 
   662 
   663       return false;
   663       return false;
   664     }
   664     }
   708 
   708 
   709   // We are finishing up the current cycle by clearing the next
   709   // We are finishing up the current cycle by clearing the next
   710   // marking bitmap and getting it ready for the next cycle. During
   710   // marking bitmap and getting it ready for the next cycle. During
   711   // this time no other cycle can start. So, let's make sure that this
   711   // this time no other cycle can start. So, let's make sure that this
   712   // is the case.
   712   // is the case.
   713   guarantee(!_g1h->collector_state()->mark_in_progress(), "invariant");
   713   guarantee(!_g1h->collector_state()->mark_or_rebuild_in_progress(), "invariant");
   714 
   714 
   715   clear_bitmap(_next_mark_bitmap, _concurrent_workers, true);
   715   clear_bitmap(_next_mark_bitmap, _concurrent_workers, true);
   716 
   716 
   717   // Repeat the asserts from above.
   717   // Repeat the asserts from above.
   718   guarantee(cm_thread()->during_cycle(), "invariant");
   718   guarantee(cm_thread()->during_cycle(), "invariant");
   719   guarantee(!_g1h->collector_state()->mark_in_progress(), "invariant");
   719   guarantee(!_g1h->collector_state()->mark_or_rebuild_in_progress(), "invariant");
   720 }
   720 }
   721 
   721 
   722 void G1ConcurrentMark::clear_prev_bitmap(WorkGang* workers) {
   722 void G1ConcurrentMark::clear_prev_bitmap(WorkGang* workers) {
   723   assert(SafepointSynchronize::is_at_safepoint(), "Should only clear the entire prev bitmap at a safepoint.");
   723   assert(SafepointSynchronize::is_at_safepoint(), "Should only clear the entire prev bitmap at a safepoint.");
   724   clear_bitmap(_prev_mark_bitmap, workers, false);
   724   clear_bitmap(_prev_mark_bitmap, workers, false);
  1061 
  1061 
  1062   G1CollectedHeap* g1h = G1CollectedHeap::heap();
  1062   G1CollectedHeap* g1h = G1CollectedHeap::heap();
  1063 
  1063 
  1064   // If a full collection has happened, we shouldn't do this.
  1064   // If a full collection has happened, we shouldn't do this.
  1065   if (has_aborted()) {
  1065   if (has_aborted()) {
  1066     g1h->collector_state()->set_mark_in_progress(false); // So bitmap clearing isn't confused
       
  1067     return;
  1066     return;
  1068   }
  1067   }
  1069 
  1068 
  1070   if (VerifyDuringGC) {
  1069   if (VerifyDuringGC) {
  1071     g1h->verifier()->verify(G1HeapVerifier::G1VerifyRemark, VerifyOption_G1UsePrevMarking, "During GC (Remark before)");
  1070     g1h->verifier()->verify(G1HeapVerifier::G1VerifyRemark, VerifyOption_G1UsePrevMarking, "During GC (Remark before)");
  1249          "world should be stopped");
  1248          "world should be stopped");
  1250   G1CollectedHeap* g1h = G1CollectedHeap::heap();
  1249   G1CollectedHeap* g1h = G1CollectedHeap::heap();
  1251 
  1250 
  1252   // If a full collection has happened, we shouldn't do this.
  1251   // If a full collection has happened, we shouldn't do this.
  1253   if (has_aborted()) {
  1252   if (has_aborted()) {
  1254     g1h->collector_state()->set_mark_in_progress(false); // So bitmap clearing isn't confused
       
  1255     return;
  1253     return;
  1256   }
  1254   }
  1257 
  1255 
  1258   g1h->verifier()->verify_region_sets_optional();
  1256   g1h->verifier()->verify_region_sets_optional();
  1259 
  1257 
  1270   {
  1268   {
  1271     GCTraceTime(Debug, gc, phases)("Update Remembered Set Tracking After Rebuild");
  1269     GCTraceTime(Debug, gc, phases)("Update Remembered Set Tracking After Rebuild");
  1272     G1UpdateRemSetTrackingAfterRebuild cl(_g1h);
  1270     G1UpdateRemSetTrackingAfterRebuild cl(_g1h);
  1273     g1h->heap_region_iterate(&cl);
  1271     g1h->heap_region_iterate(&cl);
  1274   }
  1272   }
  1275 
       
  1276   g1h->collector_state()->set_mark_in_progress(false);
       
  1277 
  1273 
  1278   double count_end = os::elapsedTime();
  1274   double count_end = os::elapsedTime();
  1279   double this_final_counting_time = (count_end - start);
  1275   double this_final_counting_time = (count_end - start);
  1280   _total_counting_time += this_final_counting_time;
  1276   _total_counting_time += this_final_counting_time;
  1281 
  1277 
  1898   }
  1894   }
  1899 };
  1895 };
  1900 
  1896 
  1901 void G1ConcurrentMark::verify_no_cset_oops() {
  1897 void G1ConcurrentMark::verify_no_cset_oops() {
  1902   assert(SafepointSynchronize::is_at_safepoint(), "should be at a safepoint");
  1898   assert(SafepointSynchronize::is_at_safepoint(), "should be at a safepoint");
  1903   if (!G1CollectedHeap::heap()->collector_state()->mark_in_progress()) {
  1899   if (!G1CollectedHeap::heap()->collector_state()->mark_or_rebuild_in_progress()) {
  1904     return;
  1900     return;
  1905   }
  1901   }
  1906 
  1902 
  1907   // Verify entries on the global mark stack
  1903   // Verify entries on the global mark stack
  1908   _global_mark_stack.iterate(VerifyNoCSetOops("Stack"));
  1904   _global_mark_stack.iterate(VerifyNoCSetOops("Stack"));