< prev index next >

src/share/vm/gc/g1/concurrentMark.cpp

Print this page

        

@@ -1935,22 +1935,14 @@
 
   double start = os::elapsedTime();
 
   HeapRegionRemSet::reset_for_cleanup_tasks();
 
-  uint n_workers;
-
   // Do counting once more with the world stopped for good measure.
   G1ParFinalCountTask g1_par_count_task(g1h, &_region_bm, &_card_bm);
 
-  g1h->set_par_threads();
-  n_workers = g1h->n_par_threads();
-  assert(g1h->n_par_threads() == n_workers,
-         "Should not have been reset");
   g1h->workers()->run_task(&g1_par_count_task);
-  // Done with the parallel phase so reset to 0.
-  g1h->set_par_threads(0);
 
   if (VerifyDuringGC) {
     // Verify that the counting data accumulated during marking matches
     // that calculated by walking the marking bitmap.
 

@@ -1962,14 +1954,11 @@
                                                  &_region_bm,
                                                  &_card_bm,
                                                  &expected_region_bm,
                                                  &expected_card_bm);
 
-    g1h->set_par_threads((int)n_workers);
     g1h->workers()->run_task(&g1_par_verify_task);
-    // Done with the parallel phase so reset to 0.
-    g1h->set_par_threads(0);
 
     guarantee(g1_par_verify_task.failures() == 0, "Unexpected accounting failures");
   }
 
   size_t start_used_bytes = g1h->used();

@@ -1987,15 +1976,15 @@
   // Install newly created mark bitMap as "prev".
   swapMarkBitMaps();
 
   g1h->reset_gc_time_stamp();
 
+  uint n_workers = _g1h->workers()->active_workers();
+
   // Note end of marking in all heap regions.
   G1ParNoteEndTask g1_par_note_end_task(g1h, &_cleanup_list, n_workers);
-  g1h->set_par_threads((int)n_workers);
   g1h->workers()->run_task(&g1_par_note_end_task);
-  g1h->set_par_threads(0);
   g1h->check_gc_time_stamps();
 
   if (!cleanup_list_is_empty()) {
     // The cleanup list is not empty, so we'll have to process it
     // concurrently. Notify anyone else that might be wanting free

@@ -2006,13 +1995,11 @@
   // call below, since it affects the metric by which we sort the heap
   // regions.
   if (G1ScrubRemSets) {
     double rs_scrub_start = os::elapsedTime();
     G1ParScrubRemSetTask g1_par_scrub_rs_task(g1h, &_region_bm, &_card_bm, n_workers);
-    g1h->set_par_threads((int)n_workers);
     g1h->workers()->run_task(&g1_par_scrub_rs_task);
-    g1h->set_par_threads(0);
 
     double rs_scrub_end = os::elapsedTime();
     double this_rs_scrub_time = (rs_scrub_end - rs_scrub_start);
     _total_rs_scrub_time += this_rs_scrub_time;
   }

@@ -2309,13 +2296,11 @@
   // We need to reset the concurrency level before each
   // proxy task execution, so that the termination protocol
   // and overflow handling in CMTask::do_marking_step() knows
   // how many workers to wait for.
   _cm->set_concurrency(_active_workers);
-  _g1h->set_par_threads(_active_workers);
   _workers->run_task(&proc_task_proxy);
-  _g1h->set_par_threads(0);
 }
 
 class G1CMRefEnqueueTaskProxy: public AbstractGangTask {
   typedef AbstractRefProcTaskExecutor::EnqueueTask EnqueueTask;
   EnqueueTask& _enq_task;

@@ -2341,13 +2326,11 @@
   // We need to reset the concurrency level before each
   // proxy task execution, so that the termination protocol
   // and overflow handling in CMTask::do_marking_step() knows
   // how many workers to wait for.
   _cm->set_concurrency(_active_workers);
-  _g1h->set_par_threads(_active_workers);
   _workers->run_task(&enq_task_proxy);
-  _g1h->set_par_threads(0);
 }
 
 void ConcurrentMark::weakRefsWorkParallelPart(BoolObjectClosure* is_alive, bool purged_classes) {
   G1CollectedHeap::heap()->parallel_cleaning(is_alive, true, true, purged_classes);
 }

@@ -2605,11 +2588,10 @@
 
   G1CMTraceTime trace("Finalize Marking", G1Log::finer());
 
   g1h->ensure_parsability(false);
 
-  StrongRootsScope srs;
   // this is remark, so we'll use up all active threads
   uint active_workers = g1h->workers()->active_workers();
   if (active_workers == 0) {
     assert(active_workers > 0, "Should have been set earlier");
     active_workers = (uint) ParallelGCThreads;

@@ -2619,17 +2601,19 @@
   // Leave _parallel_marking_threads at it's
   // value originally calculated in the ConcurrentMark
   // constructor and pass values of the active workers
   // through the gang in the task.
 
+  {
+    StrongRootsScope srs(active_workers);
+
   CMRemarkTask remarkTask(this, active_workers);
   // We will start all available threads, even if we decide that the
   // active_workers will be fewer. The extra ones will just bail out
   // immediately.
-  g1h->set_par_threads(active_workers);
   g1h->workers()->run_task(&remarkTask);
-  g1h->set_par_threads(0);
+  }
 
   SATBMarkQueueSet& satb_mq_set = JavaThread::satb_mark_queue_set();
   guarantee(has_overflown() ||
             satb_mq_set.completed_buffers_num() == 0,
             err_msg("Invariant: has_overflown = %s, num buffers = %d",

@@ -2998,13 +2982,11 @@
   uint n_workers = _g1h->workers()->active_workers();
 
   G1AggregateCountDataTask g1_par_agg_task(_g1h, this, &_card_bm,
                                            _max_worker_id, n_workers);
 
-  _g1h->set_par_threads(n_workers);
   _g1h->workers()->run_task(&g1_par_agg_task);
-  _g1h->set_par_threads(0);
 }
 
 // Clear the per-worker arrays used to store the per-region counting data
 void ConcurrentMark::clear_all_count_data() {
   // Clear the global card bitmap - it will be filled during
< prev index next >