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