9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11 * version 2 for more details (a copy is included in the LICENSE file that
12 * accompanied this code).
13 *
14 * You should have received a copy of the GNU General Public License version
15 * 2 along with this work; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17 *
18 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
19 * or visit www.oracle.com if you need additional information or have any
20 * questions.
21 *
22 */
23
24 #include "gc/shared/gcTraceTime.inline.hpp"
25 #include "gc/shenandoah/shenandoahCollectorPolicy.hpp"
26 #include "gc/shenandoah/shenandoahMarkCompact.hpp"
27 #include "gc/shenandoah/shenandoahConcurrentMark.inline.hpp"
28 #include "gc/shenandoah/shenandoahHeap.inline.hpp"
29 #include "gc/shenandoah/shenandoahWorkGroup.hpp"
30 #include "gc/shenandoah/vm_operations_shenandoah.hpp"
31
32 void VM_ShenandoahInitMark::doit() {
33 GCIdMark gc_id_mark(_gc_id);
34 ShenandoahHeap *sh = (ShenandoahHeap*) Universe::heap();
35 WorkGang* workers = sh->workers();
36
37 // Calculate workers for initial marking
38 uint nworkers = ShenandoahCollectorPolicy::calc_workers_for_init_marking(
39 workers->active_workers(), Threads::number_of_non_daemon_threads());
40
41 ShenandoahWorkerScope scope(workers, nworkers);
42
43 GCTraceTime(Info, gc) time("Pause Init Mark", sh->gc_timer());
44 sh->shenandoahPolicy()->record_phase_start(ShenandoahCollectorPolicy::total_pause);
45 sh->shenandoahPolicy()->record_phase_start(ShenandoahCollectorPolicy::init_mark);
46
47 assert(sh->is_next_bitmap_clear(), "need clear marking bitmap");
48
49 sh->start_concurrent_marking();
50 if (UseTLAB) {
51 sh->shenandoahPolicy()->record_phase_start(ShenandoahCollectorPolicy::resize_tlabs);
52 sh->resize_all_tlabs();
53 sh->shenandoahPolicy()->record_phase_end(ShenandoahCollectorPolicy::resize_tlabs);
54 }
55
56 sh->shenandoahPolicy()->record_phase_end(ShenandoahCollectorPolicy::init_mark);
57 sh->shenandoahPolicy()->record_phase_end(ShenandoahCollectorPolicy::total_pause);
58
59 }
60
61 void VM_ShenandoahFullGC::doit() {
62 GCIdMark gc_id_mark(_gc_id);
63 ShenandoahMarkCompact::do_mark_compact(_gc_cause);
64 ShenandoahHeap *sh = ShenandoahHeap::heap();
65 if (UseTLAB) {
66 sh->shenandoahPolicy()->record_phase_start(ShenandoahCollectorPolicy::resize_tlabs);
67 sh->resize_all_tlabs();
68 sh->shenandoahPolicy()->record_phase_end(ShenandoahCollectorPolicy::resize_tlabs);
69 }
70 }
71
72 bool VM_ShenandoahReferenceOperation::doit_prologue() {
73 Heap_lock->lock();
74 return true;
75 }
76
77 void VM_ShenandoahReferenceOperation::doit_epilogue() {
78 if (Universe::has_reference_pending_list()) {
79 Heap_lock->notify_all();
80 }
81 Heap_lock->unlock();
82 }
83
84 void VM_ShenandoahStartEvacuation::doit() {
85 GCIdMark gc_id_mark(_gc_id);
86
87 // It is critical that we
88 // evacuate roots right after finishing marking, so that we don't
89 // get unmarked objects in the roots.
90 ShenandoahHeap *sh = ShenandoahHeap::heap();
91 // Setup workers for final marking
92 WorkGang* workers = sh->workers();
93 uint n_workers = ShenandoahCollectorPolicy::calc_workers_for_final_marking(workers->active_workers(),
94 Threads::number_of_non_daemon_threads());
95 ShenandoahWorkerScope scope(workers, n_workers);
96
97 if (! sh->cancelled_concgc()) {
98 GCTraceTime(Info, gc) time("Pause Final Mark", sh->gc_timer(), GCCause::_no_gc, true);
99 sh->shenandoahPolicy()->record_phase_start(ShenandoahCollectorPolicy::total_pause);
100 sh->shenandoahPolicy()->record_phase_start(ShenandoahCollectorPolicy::final_mark);
101 sh->concurrentMark()->finish_mark_from_roots();
102 sh->stop_concurrent_marking();
103 sh->shenandoahPolicy()->record_phase_end(ShenandoahCollectorPolicy::final_mark);
104 sh->shenandoahPolicy()->record_phase_end(ShenandoahCollectorPolicy::total_pause);
105
106 sh->shenandoahPolicy()->record_phase_start(ShenandoahCollectorPolicy::prepare_evac);
107 sh->prepare_for_concurrent_evacuation();
108 sh->shenandoahPolicy()->record_phase_end(ShenandoahCollectorPolicy::prepare_evac);
109
110 sh->set_evacuation_in_progress_at_safepoint(true);
111
112 // From here on, we need to update references.
113 sh->set_need_update_refs(true);
114
115 sh->shenandoahPolicy()->record_phase_start(ShenandoahCollectorPolicy::init_evac);
116 sh->evacuate_and_update_roots();
117 sh->shenandoahPolicy()->record_phase_end(ShenandoahCollectorPolicy::init_evac);
118
119 } else {
120 GCTraceTime(Info, gc) time("Cancel Concurrent Mark", sh->gc_timer(), GCCause::_no_gc, true);
121 sh->concurrentMark()->cancel();
122 sh->stop_concurrent_marking();
123 }
124 }
125
126 void VM_ShenandoahVerifyHeapAfterEvacuation::doit() {
127 GCIdMark gc_id_mark(_gc_id);
128 ShenandoahHeap *sh = ShenandoahHeap::heap();
129 sh->verify_heap_after_evacuation();
130 }
|
9 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
10 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
11 * version 2 for more details (a copy is included in the LICENSE file that
12 * accompanied this code).
13 *
14 * You should have received a copy of the GNU General Public License version
15 * 2 along with this work; if not, write to the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
17 *
18 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
19 * or visit www.oracle.com if you need additional information or have any
20 * questions.
21 *
22 */
23
24 #include "gc/shared/gcTraceTime.inline.hpp"
25 #include "gc/shenandoah/shenandoahCollectorPolicy.hpp"
26 #include "gc/shenandoah/shenandoahMarkCompact.hpp"
27 #include "gc/shenandoah/shenandoahConcurrentMark.inline.hpp"
28 #include "gc/shenandoah/shenandoahHeap.inline.hpp"
29 #include "gc/shenandoah/shenandoahPartialGC.hpp"
30 #include "gc/shenandoah/shenandoahWorkGroup.hpp"
31 #include "gc/shenandoah/vm_operations_shenandoah.hpp"
32
33 void VM_ShenandoahInitMark::doit() {
34 GCIdMark gc_id_mark(_gc_id);
35 ShenandoahHeap *sh = (ShenandoahHeap*) Universe::heap();
36 WorkGang* workers = sh->workers();
37
38 // Calculate workers for initial marking
39 uint nworkers = ShenandoahCollectorPolicy::calc_workers_for_init_marking(
40 workers->active_workers(), Threads::number_of_non_daemon_threads());
41
42 ShenandoahWorkerScope scope(workers, nworkers);
43
44 GCTraceTime(Info, gc) time("Pause Init Mark", sh->gc_timer());
45 sh->shenandoahPolicy()->record_phase_start(ShenandoahCollectorPolicy::total_pause);
46 sh->shenandoahPolicy()->record_phase_start(ShenandoahCollectorPolicy::init_mark);
47
48 assert(sh->is_next_bitmap_clear(), "need clear marking bitmap");
49
50 sh->start_concurrent_marking();
51 if (UseTLAB) {
52 sh->shenandoahPolicy()->record_phase_start(ShenandoahCollectorPolicy::resize_tlabs);
53 sh->resize_all_tlabs();
54 sh->shenandoahPolicy()->record_phase_end(ShenandoahCollectorPolicy::resize_tlabs);
55 }
56
57 sh->shenandoahPolicy()->record_phase_end(ShenandoahCollectorPolicy::init_mark);
58 sh->shenandoahPolicy()->record_phase_end(ShenandoahCollectorPolicy::total_pause);
59
60 }
61
62 void VM_ShenandoahFullGC::doit() {
63 GCIdMark gc_id_mark(_gc_id);
64 ShenandoahHeap *sh = ShenandoahHeap::heap();
65 sh->shenandoahPolicy()->record_gc_start();
66 ShenandoahMarkCompact::do_mark_compact(_gc_cause);
67 if (UseTLAB) {
68 sh->shenandoahPolicy()->record_phase_start(ShenandoahCollectorPolicy::resize_tlabs);
69 sh->resize_all_tlabs();
70 sh->shenandoahPolicy()->record_phase_end(ShenandoahCollectorPolicy::resize_tlabs);
71 }
72 sh->shenandoahPolicy()->record_gc_end();
73 }
74
75 bool VM_ShenandoahReferenceOperation::doit_prologue() {
76 Heap_lock->lock();
77 return true;
78 }
79
80 void VM_ShenandoahReferenceOperation::doit_epilogue() {
81 if (Universe::has_reference_pending_list()) {
82 Heap_lock->notify_all();
83 }
84 Heap_lock->unlock();
85 }
86
87 void VM_ShenandoahStartEvacuation::doit() {
88 GCIdMark gc_id_mark(_gc_id);
89
90 ShenandoahHeap *sh = ShenandoahHeap::heap();
91 sh->shenandoahPolicy()->record_gc_start();
92
93 // It is critical that we
94 // evacuate roots right after finishing marking, so that we don't
95 // get unmarked objects in the roots.
96 // Setup workers for final marking
97 WorkGang* workers = sh->workers();
98 uint n_workers = ShenandoahCollectorPolicy::calc_workers_for_final_marking(workers->active_workers(),
99 Threads::number_of_non_daemon_threads());
100 ShenandoahWorkerScope scope(workers, n_workers);
101
102 if (! sh->cancelled_concgc()) {
103 GCTraceTime(Info, gc) time("Pause Final Mark", sh->gc_timer(), GCCause::_no_gc, true);
104 sh->shenandoahPolicy()->record_phase_start(ShenandoahCollectorPolicy::total_pause);
105 sh->shenandoahPolicy()->record_phase_start(ShenandoahCollectorPolicy::final_mark);
106 sh->concurrentMark()->finish_mark_from_roots();
107 sh->stop_concurrent_marking();
108 sh->shenandoahPolicy()->record_phase_end(ShenandoahCollectorPolicy::final_mark);
109 sh->shenandoahPolicy()->record_phase_end(ShenandoahCollectorPolicy::total_pause);
110
111 sh->shenandoahPolicy()->record_phase_start(ShenandoahCollectorPolicy::prepare_evac);
112 sh->prepare_for_concurrent_evacuation();
113 sh->shenandoahPolicy()->record_phase_end(ShenandoahCollectorPolicy::prepare_evac);
114
115 sh->set_evacuation_in_progress_at_safepoint(true);
116
117 // From here on, we need to update references.
118 sh->set_need_update_refs(true);
119
120 sh->shenandoahPolicy()->record_phase_start(ShenandoahCollectorPolicy::init_evac);
121 sh->evacuate_and_update_roots();
122 sh->shenandoahPolicy()->record_phase_end(ShenandoahCollectorPolicy::init_evac);
123
124 } else {
125 GCTraceTime(Info, gc) time("Cancel Concurrent Mark", sh->gc_timer(), GCCause::_no_gc, true);
126 sh->concurrentMark()->cancel();
127 sh->stop_concurrent_marking();
128 }
129
130 sh->shenandoahPolicy()->record_gc_end();
131 }
132
133 void VM_ShenandoahPartialGC::doit() {
134 GCIdMark gc_id_mark(_gc_id);
135 ShenandoahHeap *sh = ShenandoahHeap::heap();
136 sh->shenandoahPolicy()->record_gc_start();
137 ShenandoahHeap::heap()->do_partial_collection();
138 sh->shenandoahPolicy()->record_gc_end();
139 }
140
141 void VM_ShenandoahVerifyHeapAfterEvacuation::doit() {
142 GCIdMark gc_id_mark(_gc_id);
143 ShenandoahHeap *sh = ShenandoahHeap::heap();
144 sh->verify_heap_after_evacuation();
145 }
|