< prev index next >

src/hotspot/share/gc/g1/g1CollectedHeap.cpp

Print this page




3110       _pss(per_thread_states),
3111       _queues(task_queues),
3112       _root_processor(root_processor),
3113       _terminator(n_workers, _queues),
3114       _n_workers(n_workers)
3115   {}
3116 
3117   void work(uint worker_id) {
3118     if (worker_id >= _n_workers) return;  // no work needed this round
3119 
3120     double start_sec = os::elapsedTime();
3121     _g1h->g1_policy()->phase_times()->record_time_secs(G1GCPhaseTimes::GCWorkerStart, worker_id, start_sec);
3122 
3123     {
3124       ResourceMark rm;
3125       HandleMark   hm;
3126 
3127       ReferenceProcessor*             rp = _g1h->ref_processor_stw();
3128 
3129       G1ParScanThreadState*           pss = _pss->state_for_worker(worker_id);
3130       pss->set_ref_processor(rp);
3131 
3132       double start_strong_roots_sec = os::elapsedTime();
3133 
3134       _root_processor->evacuate_roots(pss->closures(), worker_id);
3135 
3136       // We pass a weak code blobs closure to the remembered set scanning because we want to avoid
3137       // treating the nmethods visited to act as roots for concurrent marking.
3138       // We only want to make sure that the oops in the nmethods are adjusted with regard to the
3139       // objects copied by the current evacuation.
3140       _g1h->g1_rem_set()->oops_into_collection_set_do(pss,
3141                                                       pss->closures()->weak_codeblobs(),
3142                                                       worker_id);
3143 
3144       double strong_roots_sec = os::elapsedTime() - start_strong_roots_sec;
3145 
3146       double term_sec = 0.0;
3147       size_t evac_term_attempts = 0;
3148       {
3149         double start = os::elapsedTime();
3150         G1ParEvacuateFollowersClosure evac(_g1h, pss, _queues, &_terminator);


3810                         G1CollectedHeap* g1h,
3811                         G1ParScanThreadStateSet* per_thread_states,
3812                         RefToScanQueueSet *task_queues,
3813                         ParallelTaskTerminator* terminator) :
3814     AbstractGangTask("Process reference objects in parallel"),
3815     _proc_task(proc_task),
3816     _g1h(g1h),
3817     _pss(per_thread_states),
3818     _task_queues(task_queues),
3819     _terminator(terminator)
3820   {}
3821 
3822   virtual void work(uint worker_id) {
3823     // The reference processing task executed by a single worker.
3824     ResourceMark rm;
3825     HandleMark   hm;
3826 
3827     G1STWIsAliveClosure is_alive(_g1h);
3828 
3829     G1ParScanThreadState*          pss = _pss->state_for_worker(worker_id);
3830     pss->set_ref_processor(NULL);
3831 
3832     // Keep alive closure.
3833     G1CopyingKeepAliveClosure keep_alive(_g1h, pss->closures()->raw_strong_oops(), pss);
3834 
3835     // Complete GC closure
3836     G1ParEvacuateFollowersClosure drain_queue(_g1h, pss, _task_queues, _terminator);
3837 
3838     // Call the reference processing task's work routine.
3839     _proc_task.work(worker_id, is_alive, keep_alive, drain_queue);
3840 
3841     // Note we cannot assert that the refs array is empty here as not all
3842     // of the processing tasks (specifically phase2 - pp2_work) execute
3843     // the complete_gc closure (which ordinarily would drain the queue) so
3844     // the queue may not be empty.
3845   }
3846 };
3847 
3848 // Driver routine for parallel reference processing.
3849 // Creates an instance of the ref processing gang
3850 // task and has the worker threads execute it.


3902 
3903 public:
3904   G1ParPreserveCMReferentsTask(G1CollectedHeap* g1h, G1ParScanThreadStateSet* per_thread_states, int workers, RefToScanQueueSet *task_queues) :
3905     AbstractGangTask("ParPreserveCMReferents"),
3906     _g1h(g1h),
3907     _pss(per_thread_states),
3908     _queues(task_queues),
3909     _terminator(workers, _queues),
3910     _n_workers(workers)
3911   {
3912     g1h->ref_processor_cm()->set_active_mt_degree(workers);
3913   }
3914 
3915   void work(uint worker_id) {
3916     G1GCParPhaseTimesTracker x(_g1h->g1_policy()->phase_times(), G1GCPhaseTimes::PreserveCMReferents, worker_id);
3917 
3918     ResourceMark rm;
3919     HandleMark   hm;
3920 
3921     G1ParScanThreadState*          pss = _pss->state_for_worker(worker_id);
3922     pss->set_ref_processor(NULL);
3923     assert(pss->queue_is_empty(), "both queue and overflow should be empty");
3924 
3925     // Is alive closure
3926     G1AlwaysAliveClosure always_alive(_g1h);
3927 
3928     // Copying keep alive closure. Applied to referent objects that need
3929     // to be copied.
3930     G1CopyingKeepAliveClosure keep_alive(_g1h, pss->closures()->raw_strong_oops(), pss);
3931 
3932     ReferenceProcessor* rp = _g1h->ref_processor_cm();
3933 
3934     uint limit = ReferenceProcessor::number_of_subclasses_of_ref() * rp->max_num_q();
3935     uint stride = MIN2(MAX2(_n_workers, 1U), limit);
3936 
3937     // limit is set using max_num_q() - which was set using ParallelGCThreads.
3938     // So this must be true - but assert just in case someone decides to
3939     // change the worker ids.
3940     assert(worker_id < limit, "sanity");
3941     assert(!rp->discovery_is_atomic(), "check this code");
3942 


4008   g1_policy()->phase_times()->record_preserve_cm_referents_time_ms(preserve_cm_referents_time * 1000.0);
4009 }
4010 
4011 // Weak Reference processing during an evacuation pause (part 1).
4012 void G1CollectedHeap::process_discovered_references(G1ParScanThreadStateSet* per_thread_states) {
4013   double ref_proc_start = os::elapsedTime();
4014 
4015   ReferenceProcessor* rp = _ref_processor_stw;
4016   assert(rp->discovery_enabled(), "should have been enabled");
4017 
4018   // Closure to test whether a referent is alive.
4019   G1STWIsAliveClosure is_alive(this);
4020 
4021   // Even when parallel reference processing is enabled, the processing
4022   // of JNI refs is serial and performed serially by the current thread
4023   // rather than by a worker. The following PSS will be used for processing
4024   // JNI refs.
4025 
4026   // Use only a single queue for this PSS.
4027   G1ParScanThreadState*          pss = per_thread_states->state_for_worker(0);
4028   pss->set_ref_processor(NULL);
4029   assert(pss->queue_is_empty(), "pre-condition");
4030 
4031   // Keep alive closure.
4032   G1CopyingKeepAliveClosure keep_alive(this, pss->closures()->raw_strong_oops(), pss);
4033 
4034   // Serial Complete GC closure
4035   G1STWDrainQueueClosure drain_queue(this, pss);
4036 
4037   // Setup the soft refs policy...
4038   rp->setup_policy(false);
4039 
4040   ReferenceProcessorPhaseTimes* pt = g1_policy()->phase_times()->ref_phase_times();
4041 
4042   ReferenceProcessorStats stats;
4043   if (!rp->processing_is_mt()) {
4044     // Serial reference processing...
4045     stats = rp->process_discovered_references(&is_alive,
4046                                               &keep_alive,
4047                                               &drain_queue,
4048                                               NULL,




3110       _pss(per_thread_states),
3111       _queues(task_queues),
3112       _root_processor(root_processor),
3113       _terminator(n_workers, _queues),
3114       _n_workers(n_workers)
3115   {}
3116 
3117   void work(uint worker_id) {
3118     if (worker_id >= _n_workers) return;  // no work needed this round
3119 
3120     double start_sec = os::elapsedTime();
3121     _g1h->g1_policy()->phase_times()->record_time_secs(G1GCPhaseTimes::GCWorkerStart, worker_id, start_sec);
3122 
3123     {
3124       ResourceMark rm;
3125       HandleMark   hm;
3126 
3127       ReferenceProcessor*             rp = _g1h->ref_processor_stw();
3128 
3129       G1ParScanThreadState*           pss = _pss->state_for_worker(worker_id);
3130       pss->set_ref_discoverer(rp);
3131 
3132       double start_strong_roots_sec = os::elapsedTime();
3133 
3134       _root_processor->evacuate_roots(pss->closures(), worker_id);
3135 
3136       // We pass a weak code blobs closure to the remembered set scanning because we want to avoid
3137       // treating the nmethods visited to act as roots for concurrent marking.
3138       // We only want to make sure that the oops in the nmethods are adjusted with regard to the
3139       // objects copied by the current evacuation.
3140       _g1h->g1_rem_set()->oops_into_collection_set_do(pss,
3141                                                       pss->closures()->weak_codeblobs(),
3142                                                       worker_id);
3143 
3144       double strong_roots_sec = os::elapsedTime() - start_strong_roots_sec;
3145 
3146       double term_sec = 0.0;
3147       size_t evac_term_attempts = 0;
3148       {
3149         double start = os::elapsedTime();
3150         G1ParEvacuateFollowersClosure evac(_g1h, pss, _queues, &_terminator);


3810                         G1CollectedHeap* g1h,
3811                         G1ParScanThreadStateSet* per_thread_states,
3812                         RefToScanQueueSet *task_queues,
3813                         ParallelTaskTerminator* terminator) :
3814     AbstractGangTask("Process reference objects in parallel"),
3815     _proc_task(proc_task),
3816     _g1h(g1h),
3817     _pss(per_thread_states),
3818     _task_queues(task_queues),
3819     _terminator(terminator)
3820   {}
3821 
3822   virtual void work(uint worker_id) {
3823     // The reference processing task executed by a single worker.
3824     ResourceMark rm;
3825     HandleMark   hm;
3826 
3827     G1STWIsAliveClosure is_alive(_g1h);
3828 
3829     G1ParScanThreadState*          pss = _pss->state_for_worker(worker_id);
3830     pss->set_ref_discoverer(NULL);
3831 
3832     // Keep alive closure.
3833     G1CopyingKeepAliveClosure keep_alive(_g1h, pss->closures()->raw_strong_oops(), pss);
3834 
3835     // Complete GC closure
3836     G1ParEvacuateFollowersClosure drain_queue(_g1h, pss, _task_queues, _terminator);
3837 
3838     // Call the reference processing task's work routine.
3839     _proc_task.work(worker_id, is_alive, keep_alive, drain_queue);
3840 
3841     // Note we cannot assert that the refs array is empty here as not all
3842     // of the processing tasks (specifically phase2 - pp2_work) execute
3843     // the complete_gc closure (which ordinarily would drain the queue) so
3844     // the queue may not be empty.
3845   }
3846 };
3847 
3848 // Driver routine for parallel reference processing.
3849 // Creates an instance of the ref processing gang
3850 // task and has the worker threads execute it.


3902 
3903 public:
3904   G1ParPreserveCMReferentsTask(G1CollectedHeap* g1h, G1ParScanThreadStateSet* per_thread_states, int workers, RefToScanQueueSet *task_queues) :
3905     AbstractGangTask("ParPreserveCMReferents"),
3906     _g1h(g1h),
3907     _pss(per_thread_states),
3908     _queues(task_queues),
3909     _terminator(workers, _queues),
3910     _n_workers(workers)
3911   {
3912     g1h->ref_processor_cm()->set_active_mt_degree(workers);
3913   }
3914 
3915   void work(uint worker_id) {
3916     G1GCParPhaseTimesTracker x(_g1h->g1_policy()->phase_times(), G1GCPhaseTimes::PreserveCMReferents, worker_id);
3917 
3918     ResourceMark rm;
3919     HandleMark   hm;
3920 
3921     G1ParScanThreadState*          pss = _pss->state_for_worker(worker_id);
3922     pss->set_ref_discoverer(NULL);
3923     assert(pss->queue_is_empty(), "both queue and overflow should be empty");
3924 
3925     // Is alive closure
3926     G1AlwaysAliveClosure always_alive(_g1h);
3927 
3928     // Copying keep alive closure. Applied to referent objects that need
3929     // to be copied.
3930     G1CopyingKeepAliveClosure keep_alive(_g1h, pss->closures()->raw_strong_oops(), pss);
3931 
3932     ReferenceProcessor* rp = _g1h->ref_processor_cm();
3933 
3934     uint limit = ReferenceProcessor::number_of_subclasses_of_ref() * rp->max_num_q();
3935     uint stride = MIN2(MAX2(_n_workers, 1U), limit);
3936 
3937     // limit is set using max_num_q() - which was set using ParallelGCThreads.
3938     // So this must be true - but assert just in case someone decides to
3939     // change the worker ids.
3940     assert(worker_id < limit, "sanity");
3941     assert(!rp->discovery_is_atomic(), "check this code");
3942 


4008   g1_policy()->phase_times()->record_preserve_cm_referents_time_ms(preserve_cm_referents_time * 1000.0);
4009 }
4010 
4011 // Weak Reference processing during an evacuation pause (part 1).
4012 void G1CollectedHeap::process_discovered_references(G1ParScanThreadStateSet* per_thread_states) {
4013   double ref_proc_start = os::elapsedTime();
4014 
4015   ReferenceProcessor* rp = _ref_processor_stw;
4016   assert(rp->discovery_enabled(), "should have been enabled");
4017 
4018   // Closure to test whether a referent is alive.
4019   G1STWIsAliveClosure is_alive(this);
4020 
4021   // Even when parallel reference processing is enabled, the processing
4022   // of JNI refs is serial and performed serially by the current thread
4023   // rather than by a worker. The following PSS will be used for processing
4024   // JNI refs.
4025 
4026   // Use only a single queue for this PSS.
4027   G1ParScanThreadState*          pss = per_thread_states->state_for_worker(0);
4028   pss->set_ref_discoverer(NULL);
4029   assert(pss->queue_is_empty(), "pre-condition");
4030 
4031   // Keep alive closure.
4032   G1CopyingKeepAliveClosure keep_alive(this, pss->closures()->raw_strong_oops(), pss);
4033 
4034   // Serial Complete GC closure
4035   G1STWDrainQueueClosure drain_queue(this, pss);
4036 
4037   // Setup the soft refs policy...
4038   rp->setup_policy(false);
4039 
4040   ReferenceProcessorPhaseTimes* pt = g1_policy()->phase_times()->ref_phase_times();
4041 
4042   ReferenceProcessorStats stats;
4043   if (!rp->processing_is_mt()) {
4044     // Serial reference processing...
4045     stats = rp->process_discovered_references(&is_alive,
4046                                               &keep_alive,
4047                                               &drain_queue,
4048                                               NULL,


< prev index next >