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 #ifndef SHARE_VM_GC_SHENANDOAH_VM_OPERATIONS_SHENANDOAH_HPP 25 #define SHARE_VM_GC_SHENANDOAH_VM_OPERATIONS_SHENANDOAH_HPP 26 27 #include "gc/shenandoah/shenandoahConcurrentMark.hpp" 28 #include "gc/shared/vmGCOperations.hpp" 29 30 // VM_operations for the Shenandoah Collector. 31 // 32 // VM_ShenandoahOperation 33 // - VM_ShenandoahInitMark: initiate concurrent marking 34 // - VM_ShenandoahReferenceOperation: 35 // - VM_ShenandoahFinalMarkStartEvac: finish up concurrent marking, and start evacuation 36 // - VM_ShenandoahFinalEvac: finish concurrent evacuation 37 // - VM_ShenandoahInitUpdateRefs: initiate update references 38 // - VM_ShenandoahFinalUpdateRefs: finish up update references 39 // - VM_ShenandoahFullGC: do full GC 40 // - VM_ShenandoahInitTraversalGC: init traversal GC 41 // - VM_ShenandoahFinalTraversalGC: finish traversal GC 42 43 class VM_ShenandoahOperation : public VM_Operation { 44 protected: 45 uint _gc_id; 46 public: 47 bool _safepoint_cleanup_done; 48 VM_ShenandoahOperation() : _gc_id(GCId::current()), _safepoint_cleanup_done(false) {}; 49 virtual bool deflates_idle_monitors() { return ShenandoahMergeSafepointCleanup && ! _safepoint_cleanup_done; } 50 virtual bool marks_nmethods() { return ShenandoahMergeSafepointCleanup && ! _safepoint_cleanup_done; } 51 }; 52 53 class VM_ShenandoahReferenceOperation : public VM_ShenandoahOperation { 54 public: 55 VM_ShenandoahReferenceOperation() : VM_ShenandoahOperation() {}; 56 bool doit_prologue(); 57 void doit_epilogue(); 58 }; 59 60 class VM_ShenandoahInitMark: public VM_ShenandoahOperation { 61 public: 62 VM_ShenandoahInitMark() : VM_ShenandoahOperation() {}; 63 VM_Operation::VMOp_Type type() const { return VMOp_ShenandoahInitMark; } 64 const char* name() const { return "Shenandoah Init Marking"; } 65 virtual void doit(); 66 }; 67 68 class VM_ShenandoahFinalMarkStartEvac: public VM_ShenandoahReferenceOperation { 69 public: 70 VM_ShenandoahFinalMarkStartEvac() : VM_ShenandoahReferenceOperation() {}; 71 VM_Operation::VMOp_Type type() const { return VMOp_ShenandoahFinalMarkStartEvac; } 72 const char* name() const { return "Shenandoah Final Mark and Start Evacuation"; } 73 virtual void doit(); 74 }; 75 76 class VM_ShenandoahFinalEvac: public VM_ShenandoahOperation { 77 public: 78 VM_ShenandoahFinalEvac() : VM_ShenandoahOperation() {}; 79 VM_Operation::VMOp_Type type() const { return VMOp_ShenandoahFinalEvac; } 80 const char* name() const { return "Shenandoah Final Evacuation"; } 81 virtual void doit(); 82 bool deflates_idle_monitors() { return false; } 83 bool marks_nmethods() { return false; } 84 }; 85 86 class VM_ShenandoahDegeneratedGC: public VM_ShenandoahReferenceOperation { 87 private: 88 // Really the ShenandoahHeap::ShenandoahDegenerationPoint, but casted to int here 89 // in order to avoid dependency on ShenandoahHeap 90 int _point; 91 public: 92 VM_ShenandoahDegeneratedGC(int point) : VM_ShenandoahReferenceOperation(), _point(point) {}; 93 VM_Operation::VMOp_Type type() const { return VMOp_ShenandoahDegeneratedGC; } 94 const char* name() const { return "Shenandoah Degenerated GC"; } 95 virtual void doit(); 96 97 // Degenerate GC may be upgraded to Full GC, and therefore we need to block deflation and 98 // marking, as VM_ShenandoahFullGC does. 99 bool deflates_idle_monitors() { return false; } 100 bool marks_nmethods() { return false; } 101 }; 102 103 class VM_ShenandoahFullGC : public VM_ShenandoahReferenceOperation { 104 private: 105 GCCause::Cause _gc_cause; 106 public: 107 VM_ShenandoahFullGC(GCCause::Cause gc_cause) : VM_ShenandoahReferenceOperation(), _gc_cause(gc_cause) {}; 108 VM_Operation::VMOp_Type type() const { return VMOp_ShenandoahFullGC; } 109 const char* name() const { return "Shenandoah Full GC"; } 110 virtual void doit(); 111 // Full-GC cannot deflate monitors and mark nmethods, because it installs a speciall BarrierSet 112 // that disables read-barriers. However, the monitor and nmethod code requires read-barriers 113 // to work correctly. 114 bool deflates_idle_monitors() { return false; } 115 bool marks_nmethods() { return false; } 116 }; 117 118 class VM_ShenandoahInitTraversalGC: public VM_ShenandoahOperation { 119 public: 120 VM_ShenandoahInitTraversalGC() : VM_ShenandoahOperation() {}; 121 VM_Operation::VMOp_Type type() const { return VMOp_ShenandoahInitTraversalGC; } 122 const char* name() const { return "Shenandoah Init Traversal Collection"; } 123 virtual void doit(); 124 }; 125 126 class VM_ShenandoahFinalTraversalGC: public VM_ShenandoahReferenceOperation { 127 public: 128 VM_ShenandoahFinalTraversalGC() : VM_ShenandoahReferenceOperation() {}; 129 VM_Operation::VMOp_Type type() const { return VMOp_ShenandoahFinalTraversalGC; } 130 const char* name() const { return "Shenandoah Final Traversal Collection"; } 131 virtual void doit(); 132 }; 133 134 class VM_ShenandoahInitUpdateRefs: public VM_ShenandoahOperation { 135 public: 136 VM_ShenandoahInitUpdateRefs() : VM_ShenandoahOperation() {}; 137 VM_Operation::VMOp_Type type() const { return VMOp_ShenandoahInitUpdateRefs; } 138 const char* name() const { return "Shenandoah Init Update References"; } 139 virtual void doit(); 140 // We cannot deflate monitors and mark nmethods here, because it doesn't scan roots. 141 bool deflates_idle_monitors() { return false; } 142 bool marks_nmethods() { return false; } 143 }; 144 145 class VM_ShenandoahFinalUpdateRefs: public VM_ShenandoahOperation { 146 public: 147 VM_ShenandoahFinalUpdateRefs() : VM_ShenandoahOperation() {}; 148 VM_Operation::VMOp_Type type() const { return VMOp_ShenandoahFinalUpdateRefs; } 149 const char* name() const { return "Shenandoah Final Update References"; } 150 virtual void doit(); 151 }; 152 153 #endif //SHARE_VM_GC_SHENANDOAH_VM_OPERATIONS_SHENANDOAH_HPP