565 // Finish the last termination pause. |
565 // Finish the last termination pause. |
566 par_scan_state()->end_term_time(); |
566 par_scan_state()->end_term_time(); |
567 } |
567 } |
568 |
568 |
569 ParNewGenTask::ParNewGenTask(ParNewGeneration* gen, Generation* old_gen, |
569 ParNewGenTask::ParNewGenTask(ParNewGeneration* gen, Generation* old_gen, |
570 HeapWord* young_old_boundary, ParScanThreadStateSet* state_set) : |
570 HeapWord* young_old_boundary, ParScanThreadStateSet* state_set, |
|
571 StrongRootsScope* strong_roots_scope) : |
571 AbstractGangTask("ParNewGeneration collection"), |
572 AbstractGangTask("ParNewGeneration collection"), |
572 _gen(gen), _old_gen(old_gen), |
573 _gen(gen), _old_gen(old_gen), |
573 _young_old_boundary(young_old_boundary), |
574 _young_old_boundary(young_old_boundary), |
574 _state_set(state_set) |
575 _state_set(state_set), |
|
576 _strong_roots_scope(strong_roots_scope) |
575 {} |
577 {} |
576 |
578 |
577 // Reset the terminator for the given number of |
579 // Reset the terminator for the given number of |
578 // active threads. |
580 // active threads. |
579 void ParNewGenTask::set_for_termination(uint active_workers) { |
581 void ParNewGenTask::set_for_termination(uint active_workers) { |
601 CLDToKlassAndOopClosure cld_scan_closure(&klass_scan_closure, |
603 CLDToKlassAndOopClosure cld_scan_closure(&klass_scan_closure, |
602 &par_scan_state.to_space_root_closure(), |
604 &par_scan_state.to_space_root_closure(), |
603 false); |
605 false); |
604 |
606 |
605 par_scan_state.start_strong_roots(); |
607 par_scan_state.start_strong_roots(); |
606 gch->gen_process_roots(_gen->level(), |
608 gch->gen_process_roots(_strong_roots_scope, |
|
609 _gen->level(), |
607 true, // Process younger gens, if any, |
610 true, // Process younger gens, if any, |
608 // as strong roots. |
611 // as strong roots. |
609 false, // no scope; this is parallel code |
|
610 GenCollectedHeap::SO_ScavengeCodeCache, |
612 GenCollectedHeap::SO_ScavengeCodeCache, |
611 GenCollectedHeap::StrongAndWeakRoots, |
613 GenCollectedHeap::StrongAndWeakRoots, |
612 &par_scan_state.to_space_root_closure(), |
614 &par_scan_state.to_space_root_closure(), |
613 &par_scan_state.older_gen_closure(), |
615 &par_scan_state.older_gen_closure(), |
614 &cld_scan_closure); |
616 &cld_scan_closure); |
950 ParallelTaskTerminator _term(n_workers, task_queues()); |
952 ParallelTaskTerminator _term(n_workers, task_queues()); |
951 ParScanThreadStateSet thread_state_set(workers->active_workers(), |
953 ParScanThreadStateSet thread_state_set(workers->active_workers(), |
952 *to(), *this, *_old_gen, *task_queues(), |
954 *to(), *this, *_old_gen, *task_queues(), |
953 _overflow_stacks, desired_plab_sz(), _term); |
955 _overflow_stacks, desired_plab_sz(), _term); |
954 |
956 |
955 ParNewGenTask tsk(this, _old_gen, reserved().end(), &thread_state_set); |
957 { |
956 gch->set_par_threads(n_workers); |
958 StrongRootsScope srs(n_workers); |
957 gch->rem_set()->prepare_for_younger_refs_iterate(true); |
959 |
958 // It turns out that even when we're using 1 thread, doing the work in a |
960 ParNewGenTask tsk(this, _old_gen, reserved().end(), &thread_state_set, &srs); |
959 // separate thread causes wide variance in run times. We can't help this |
961 gch->set_par_threads(n_workers); |
960 // in the multi-threaded case, but we special-case n=1 here to get |
962 gch->rem_set()->prepare_for_younger_refs_iterate(true); |
961 // repeatable measurements of the 1-thread overhead of the parallel code. |
963 // It turns out that even when we're using 1 thread, doing the work in a |
962 if (n_workers > 1) { |
964 // separate thread causes wide variance in run times. We can't help this |
963 StrongRootsScope srs; |
965 // in the multi-threaded case, but we special-case n=1 here to get |
964 workers->run_task(&tsk); |
966 // repeatable measurements of the 1-thread overhead of the parallel code. |
965 } else { |
967 if (n_workers > 1) { |
966 StrongRootsScope srs; |
968 workers->run_task(&tsk); |
967 tsk.work(0); |
969 } else { |
968 } |
970 tsk.work(0); |
|
971 } |
|
972 } |
|
973 |
969 thread_state_set.reset(0 /* Bad value in debug if not reset */, |
974 thread_state_set.reset(0 /* Bad value in debug if not reset */, |
970 promotion_failed()); |
975 promotion_failed()); |
971 |
976 |
972 // Trace and reset failed promotion info. |
977 // Trace and reset failed promotion info. |
973 if (promotion_failed()) { |
978 if (promotion_failed()) { |