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 // We need to do the finish mark here, so that a JNI critical region 94 // can't divide it from evacuation start. 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 if (ShenandoahGCVerbose) 100 tty->print("vm_ShenandoahFinalMark\n"); 101 102 GCTraceTime(Info, gc, phases) time("Pause Init-Evacuation", sh->gc_timer()); 103 sh->shenandoahPolicy()->record_phase_start(ShenandoahCollectorPolicy::final_mark); 104 sh->concurrentMark()->finish_mark_from_roots(); 105 sh->stop_concurrent_marking(); 106 sh->shenandoahPolicy()->record_phase_end(ShenandoahCollectorPolicy::final_mark); 107 108 sh->shenandoahPolicy()->record_phase_start(ShenandoahCollectorPolicy::prepare_evac); 109 sh->prepare_for_concurrent_evacuation(); 110 sh->shenandoahPolicy()->record_phase_end(ShenandoahCollectorPolicy::prepare_evac); 111 112 sh->set_evacuation_in_progress(true); 113 114 // From here on, we need to update references. 115 sh->set_need_update_refs(true); 116 117 sh->shenandoahPolicy()->record_phase_start(ShenandoahCollectorPolicy::init_evac); 118 sh->evacuate_and_update_roots(); 119 sh->shenandoahPolicy()->record_phase_end(ShenandoahCollectorPolicy::init_evac); 120 121 } else { 122 sh->concurrentMark()->cancel(); 123 sh->stop_concurrent_marking(); 124 sh->recycle_dirty_regions(); 125 } 126 } 127 128 VM_Operation::VMOp_Type VM_ShenandoahStartEvacuation::type() const { 129 return VMOp_ShenandoahStartEvacuation; 130 } 131 132 const char* VM_ShenandoahStartEvacuation::name() const { 133 return "Start shenandoah evacuation"; 134 } 135 136 VM_Operation::VMOp_Type VM_ShenandoahVerifyHeapAfterEvacuation::type() const { 137 return VMOp_ShenandoahVerifyHeapAfterEvacuation; 138 } 139 140 const char* VM_ShenandoahVerifyHeapAfterEvacuation::name() const { 141 return "Shenandoah verify heap after evacuation"; 142 } 143 144 void VM_ShenandoahVerifyHeapAfterEvacuation::doit() { 145 146 ShenandoahHeap *sh = ShenandoahHeap::heap(); 147 sh->verify_heap_after_evacuation(); 148 149 }