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, phases) time("Pause Init-Mark", sh->gc_timer()); 41 sh->shenandoahPolicy()->record_phase_start(ShenandoahCollectorPolicy::init_mark); 42 43 assert(sh->is_bitmap_clear(), "need clear marking bitmap"); 44 45 if (ShenandoahGCVerbose) 46 tty->print("vm_ShenandoahInitMark\n"); 47 sh->start_concurrent_marking(); 48 if (UseTLAB) { 49 sh->shenandoahPolicy()->record_phase_start(ShenandoahCollectorPolicy::resize_tlabs); 50 sh->resize_all_tlabs(); 51 sh->shenandoahPolicy()->record_phase_end(ShenandoahCollectorPolicy::resize_tlabs); 52 } 53 54 sh->shenandoahPolicy()->record_phase_end(ShenandoahCollectorPolicy::init_mark); 55 56 } 57 58 VM_Operation::VMOp_Type VM_ShenandoahFullGC::type() const { 59 return VMOp_ShenandoahFullGC; 60 } 61 62 VM_ShenandoahFullGC::VM_ShenandoahFullGC(GCCause::Cause gc_cause) : 63 _gc_cause(gc_cause) { 64 } 65 66 void VM_ShenandoahFullGC::doit() { 67 68 ShenandoahMarkCompact::do_mark_compact(_gc_cause); 69 ShenandoahHeap *sh = ShenandoahHeap::heap(); 70 if (UseTLAB) { 71 sh->shenandoahPolicy()->record_phase_start(ShenandoahCollectorPolicy::resize_tlabs); 72 sh->resize_all_tlabs(); 73 sh->shenandoahPolicy()->record_phase_end(ShenandoahCollectorPolicy::resize_tlabs); 74 } 75 } 76 77 const char* VM_ShenandoahFullGC::name() const { 78 return "Shenandoah Full GC"; 79 } 80 81 82 bool VM_ShenandoahReferenceOperation::doit_prologue() { 83 _pending_list_locker.lock(); 84 return true; 85 } 86 87 void VM_ShenandoahReferenceOperation::doit_epilogue() { 88 _pending_list_locker.unlock(); 89 } 90 91 void VM_ShenandoahStartEvacuation::doit() { 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 ShenandoahHeap *sh = ShenandoahHeap::heap(); 97 if (! sh->cancelled_concgc()) { 98 if (ShenandoahGCVerbose) 99 tty->print("vm_ShenandoahFinalMark\n"); 100 101 GCTraceTime(Info, gc, phases) time("Pause Init-Evacuation", sh->gc_timer()); 102 sh->shenandoahPolicy()->record_phase_start(ShenandoahCollectorPolicy::final_mark); 103 sh->concurrentMark()->finish_mark_from_roots(); 104 sh->stop_concurrent_marking(); 105 sh->shenandoahPolicy()->record_phase_end(ShenandoahCollectorPolicy::final_mark); 106 107 sh->shenandoahPolicy()->record_phase_start(ShenandoahCollectorPolicy::prepare_evac); 108 sh->prepare_for_concurrent_evacuation(); 109 sh->shenandoahPolicy()->record_phase_end(ShenandoahCollectorPolicy::prepare_evac); 110 111 sh->set_evacuation_in_progress(true); 112 113 // From here on, we need to update references. 114 sh->set_need_update_refs(true); 115 116 sh->shenandoahPolicy()->record_phase_start(ShenandoahCollectorPolicy::init_evac); 117 sh->evacuate_and_update_roots(); 118 sh->shenandoahPolicy()->record_phase_end(ShenandoahCollectorPolicy::init_evac); 119 120 } else { 121 sh->concurrentMark()->cancel(); 122 sh->stop_concurrent_marking(); 123 sh->recycle_dirty_regions(); 124 } 125 } 126 127 VM_Operation::VMOp_Type VM_ShenandoahStartEvacuation::type() const { 128 return VMOp_ShenandoahStartEvacuation; 129 } 130 131 const char* VM_ShenandoahStartEvacuation::name() const { 132 return "Start shenandoah evacuation"; 133 } 134 135 VM_Operation::VMOp_Type VM_ShenandoahVerifyHeapAfterEvacuation::type() const { 136 return VMOp_ShenandoahVerifyHeapAfterEvacuation; 137 } 138 139 const char* VM_ShenandoahVerifyHeapAfterEvacuation::name() const { 140 return "Shenandoah verify heap after evacuation"; 141 } 142 143 void VM_ShenandoahVerifyHeapAfterEvacuation::doit() { 144 145 ShenandoahHeap *sh = ShenandoahHeap::heap(); 146 sh->verify_heap_after_evacuation(); 147 148 }