3714 // threads utilize different G1ParScanThreadState instances |
3714 // threads utilize different G1ParScanThreadState instances |
3715 // and different queues. |
3715 // and different queues. |
3716 |
3716 |
3717 class G1CopyingKeepAliveClosure: public OopClosure { |
3717 class G1CopyingKeepAliveClosure: public OopClosure { |
3718 G1CollectedHeap* _g1h; |
3718 G1CollectedHeap* _g1h; |
3719 OopClosure* _copy_non_heap_obj_cl; |
|
3720 G1ParScanThreadState* _par_scan_state; |
3719 G1ParScanThreadState* _par_scan_state; |
3721 |
3720 |
3722 public: |
3721 public: |
3723 G1CopyingKeepAliveClosure(G1CollectedHeap* g1h, |
3722 G1CopyingKeepAliveClosure(G1CollectedHeap* g1h, |
3724 OopClosure* non_heap_obj_cl, |
|
3725 G1ParScanThreadState* pss): |
3723 G1ParScanThreadState* pss): |
3726 _g1h(g1h), |
3724 _g1h(g1h), |
3727 _copy_non_heap_obj_cl(non_heap_obj_cl), |
|
3728 _par_scan_state(pss) |
3725 _par_scan_state(pss) |
3729 {} |
3726 {} |
3730 |
3727 |
3731 virtual void do_oop(narrowOop* p) { do_oop_work(p); } |
3728 virtual void do_oop(narrowOop* p) { do_oop_work(p); } |
3732 virtual void do_oop( oop* p) { do_oop_work(p); } |
3729 virtual void do_oop( oop* p) { do_oop_work(p); } |
3742 // heap, update the RSet for the referent. |
3739 // heap, update the RSet for the referent. |
3743 // |
3740 // |
3744 // If the referent has not been forwarded then we have to keep |
3741 // If the referent has not been forwarded then we have to keep |
3745 // it alive by policy. Therefore we have copy the referent. |
3742 // it alive by policy. Therefore we have copy the referent. |
3746 // |
3743 // |
3747 // If the reference field is in the G1 heap then we can push |
3744 // When the queue is drained (after each phase of reference processing) |
3748 // on the PSS queue. When the queue is drained (after each |
3745 // the object and it's followers will be copied, the reference field set |
3749 // phase of reference processing) the object and it's followers |
3746 // to point to the new location, and the RSet updated. |
3750 // will be copied, the reference field set to point to the |
3747 _par_scan_state->push_on_queue(p); |
3751 // new location, and the RSet updated. Otherwise we need to |
|
3752 // use the the non-heap or metadata closures directly to copy |
|
3753 // the referent object and update the pointer, while avoiding |
|
3754 // updating the RSet. |
|
3755 |
|
3756 if (_g1h->is_in_g1_reserved(p)) { |
|
3757 _par_scan_state->push_on_queue(p); |
|
3758 } else { |
|
3759 assert(!Metaspace::contains((const void*)p), |
|
3760 "Unexpectedly found a pointer from metadata: " PTR_FORMAT, p2i(p)); |
|
3761 _copy_non_heap_obj_cl->do_oop(p); |
|
3762 } |
|
3763 } |
3748 } |
3764 } |
3749 } |
3765 }; |
3750 }; |
3766 |
3751 |
3767 // Serial drain queue closure. Called as the 'complete_gc' |
3752 // Serial drain queue closure. Called as the 'complete_gc' |
3849 |
3834 |
3850 G1ParScanThreadState* pss = _pss->state_for_worker(worker_id); |
3835 G1ParScanThreadState* pss = _pss->state_for_worker(worker_id); |
3851 pss->set_ref_discoverer(NULL); |
3836 pss->set_ref_discoverer(NULL); |
3852 |
3837 |
3853 // Keep alive closure. |
3838 // Keep alive closure. |
3854 G1CopyingKeepAliveClosure keep_alive(_g1h, pss->closures()->raw_strong_oops(), pss); |
3839 G1CopyingKeepAliveClosure keep_alive(_g1h, pss); |
3855 |
3840 |
3856 // Complete GC closure |
3841 // Complete GC closure |
3857 G1ParEvacuateFollowersClosure drain_queue(_g1h, pss, _task_queues, _terminator); |
3842 G1ParEvacuateFollowersClosure drain_queue(_g1h, pss, _task_queues, _terminator); |
3858 |
3843 |
3859 // Call the reference processing task's work routine. |
3844 // Call the reference processing task's work routine. |
3901 G1ParScanThreadState* pss = per_thread_states->state_for_worker(0); |
3886 G1ParScanThreadState* pss = per_thread_states->state_for_worker(0); |
3902 pss->set_ref_discoverer(NULL); |
3887 pss->set_ref_discoverer(NULL); |
3903 assert(pss->queue_is_empty(), "pre-condition"); |
3888 assert(pss->queue_is_empty(), "pre-condition"); |
3904 |
3889 |
3905 // Keep alive closure. |
3890 // Keep alive closure. |
3906 G1CopyingKeepAliveClosure keep_alive(this, pss->closures()->raw_strong_oops(), pss); |
3891 G1CopyingKeepAliveClosure keep_alive(this, pss); |
3907 |
3892 |
3908 // Serial Complete GC closure |
3893 // Serial Complete GC closure |
3909 G1STWDrainQueueClosure drain_queue(this, pss); |
3894 G1STWDrainQueueClosure drain_queue(this, pss); |
3910 |
3895 |
3911 // Setup the soft refs policy... |
3896 // Setup the soft refs policy... |