1 /* 2 * Copyright (c) 2013, 2015, Red Hat, Inc. and/or its affiliates. 3 * 4 * This code is free software; you can redistribute it and/or modify it 5 * under the terms of the GNU General Public License version 2 only, as 6 * published by the Free Software Foundation. 7 * 8 * This code is distributed in the hope that it will be useful, but WITHOUT 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/vm_operations_shenandoah.hpp" 28 #include "gc/shenandoah/shenandoahHeap.inline.hpp" 29 30 VM_Operation::VMOp_Type VM_ShenandoahInitMark::type() const { 31 return VMOp_ShenandoahInitMark; 32 } 33 34 const char* VM_ShenandoahInitMark::name() const { 35 return "Shenandoah Initial Marking"; 36 } 37 38 void VM_ShenandoahInitMark::doit() { 39 ShenandoahHeap *sh = (ShenandoahHeap*) Universe::heap(); 40 GCTraceTime(Info, gc) time("Pause Init-Mark", sh->gc_timer()); 41 sh->shenandoahPolicy()->record_phase_start(ShenandoahCollectorPolicy::init_mark); 42 43 assert(sh->is_next_bitmap_clear(), "need clear marking bitmap"); 44 45 sh->start_concurrent_marking(); 46 if (UseTLAB) { 47 sh->shenandoahPolicy()->record_phase_start(ShenandoahCollectorPolicy::resize_tlabs); 48 sh->resize_all_tlabs(); 49 sh->shenandoahPolicy()->record_phase_end(ShenandoahCollectorPolicy::resize_tlabs); 50 } 51 52 sh->shenandoahPolicy()->record_phase_end(ShenandoahCollectorPolicy::init_mark); 53 54 } 55 56 VM_Operation::VMOp_Type VM_ShenandoahFullGC::type() const { 57 return VMOp_ShenandoahFullGC; 58 } 59 60 VM_ShenandoahFullGC::VM_ShenandoahFullGC(GCCause::Cause gc_cause) : 61 _gc_cause(gc_cause) { 62 } 63 64 void VM_ShenandoahFullGC::doit() { 65 66 ShenandoahMarkCompact::do_mark_compact(_gc_cause); 67 ShenandoahHeap *sh = ShenandoahHeap::heap(); 68 if (UseTLAB) { 69 sh->shenandoahPolicy()->record_phase_start(ShenandoahCollectorPolicy::resize_tlabs); 70 sh->resize_all_tlabs(); 71 sh->shenandoahPolicy()->record_phase_end(ShenandoahCollectorPolicy::resize_tlabs); 72 } 73 } 74 75 const char* VM_ShenandoahFullGC::name() const { 76 return "Shenandoah Full GC"; 77 } 78 79 80 bool VM_ShenandoahReferenceOperation::doit_prologue() { 81 Heap_lock->lock(); 82 return true; 83 } 84 85 void VM_ShenandoahReferenceOperation::doit_epilogue() { 86 if (Universe::has_reference_pending_list()) { 87 Heap_lock->notify_all(); 88 } 89 Heap_lock->unlock(); 90 } 91 92 void VM_ShenandoahStartEvacuation::doit() { 93 94 // It is critical that we 95 // evacuate roots right after finishing marking, so that we don't 96 // get unmarked objects in the roots. 97 ShenandoahHeap *sh = ShenandoahHeap::heap(); 98 if (! sh->cancelled_concgc()) { 99 GCTraceTime(Info, gc) time("Pause Final Mark", sh->gc_timer(), GCCause::_no_gc, true); 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 105 sh->shenandoahPolicy()->record_phase_start(ShenandoahCollectorPolicy::prepare_evac); 106 sh->prepare_for_concurrent_evacuation(); 107 sh->shenandoahPolicy()->record_phase_end(ShenandoahCollectorPolicy::prepare_evac); 108 109 sh->set_evacuation_in_progress(true); 110 111 // From here on, we need to update references. 112 sh->set_need_update_refs(true); 113 114 sh->shenandoahPolicy()->record_phase_start(ShenandoahCollectorPolicy::init_evac); 115 sh->evacuate_and_update_roots(); 116 sh->shenandoahPolicy()->record_phase_end(ShenandoahCollectorPolicy::init_evac); 117 118 } else { 119 GCTraceTime(Info, gc) time("Cancel concurrent Mark", sh->gc_timer(), GCCause::_no_gc, true); 120 sh->concurrentMark()->cancel(); 121 sh->stop_concurrent_marking(); 122 } 123 } 124 125 VM_Operation::VMOp_Type VM_ShenandoahStartEvacuation::type() const { 126 return VMOp_ShenandoahStartEvacuation; 127 } 128 129 const char* VM_ShenandoahStartEvacuation::name() const { 130 return "Start shenandoah evacuation"; 131 } 132 133 VM_Operation::VMOp_Type VM_ShenandoahVerifyHeapAfterEvacuation::type() const { 134 return VMOp_ShenandoahVerifyHeapAfterEvacuation; 135 } 136 137 const char* VM_ShenandoahVerifyHeapAfterEvacuation::name() const { 138 return "Shenandoah verify heap after evacuation"; 139 } 140 141 void VM_ShenandoahVerifyHeapAfterEvacuation::doit() { 142 143 ShenandoahHeap *sh = ShenandoahHeap::heap(); 144 sh->verify_heap_after_evacuation(); 145 146 }