--- old/src/share/vm/gc/g1/concurrentMark.cpp 2015-05-20 11:05:15.925869637 +0200 +++ new/src/share/vm/gc/g1/concurrentMark.cpp 2015-05-20 11:05:15.765864232 +0200 @@ -1937,18 +1937,10 @@ 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 @@ -1964,10 +1956,7 @@ &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"); } @@ -1989,11 +1978,11 @@ 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()) { @@ -2008,9 +1997,7 @@ 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); @@ -2311,9 +2298,7 @@ // 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 { @@ -2343,9 +2328,7 @@ // 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) { @@ -2607,7 +2590,6 @@ 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) { @@ -2621,13 +2603,15 @@ // constructor and pass values of the active workers // through the gang in the task. - 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); + { + 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->workers()->run_task(&remarkTask); + } SATBMarkQueueSet& satb_mq_set = JavaThread::satb_mark_queue_set(); guarantee(has_overflown() || @@ -3000,9 +2984,7 @@ 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