1 /*
  2  * Copyright (c) 2013, 2021, Red Hat, Inc. All rights reserved.
  3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  4  *
  5  * This code is free software; you can redistribute it and/or modify it
  6  * under the terms of the GNU General Public License version 2 only, as
  7  * published by the Free Software Foundation.
  8  *
  9  * This code is distributed in the hope that it will be useful, but WITHOUT
 10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 12  * version 2 for more details (a copy is included in the LICENSE file that
 13  * accompanied this code).
 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *
 23  */
 24 
 25 #ifndef SHARE_GC_SHENANDOAH_SHENANDOAHVMOPERATIONS_HPP
 26 #define SHARE_GC_SHENANDOAH_SHENANDOAHVMOPERATIONS_HPP
 27 
 28 #include "gc/shared/gcVMOperations.hpp"
 29 
 30 class ShenandoahConcurrentGC;
 31 class ShenandoahDegenGC;
 32 class ShenandoahFullGC;
 33 
 34 // VM_operations for the Shenandoah Collector.
 35 //
 36 // VM_ShenandoahOperation
 37 //   - VM_ShenandoahInitMark: initiate concurrent marking
 38 //   - VM_ShenandoahFinalMarkStartEvac: finish up concurrent marking, and start evacuation
 39 //   - VM_ShenandoahFinalRoots: finish up roots processing
 40 //   - VM_ShenandoahInitUpdateRefs: initiate update references
 41 //   - VM_ShenandoahFinalUpdateRefs: finish up update references
 42 //   - VM_ShenandoahFinalVerify: final verification at the end of the cycle
 43 //   - VM_ShenandoahReferenceOperation:
 44 //       - VM_ShenandoahFullGC: do full GC
 45 //       - VM_ShenandoahDegeneratedGC: do STW degenerated GC
 46 
 47 class VM_ShenandoahOperation : public VM_Operation {
 48 protected:
 49   uint _gc_id;
 50   ShenandoahGeneration* _generation;
 51 
 52   void set_active_generation();
 53 public:
 54   explicit VM_ShenandoahOperation(ShenandoahGeneration* generation)
 55   : _gc_id(GCId::current())
 56   , _generation(generation) {
 57   }
 58 
 59   bool skip_thread_oop_barriers() const override { return true; }
 60 
 61   void log_active_generation(const char* prefix);
 62   bool doit_prologue() override;
 63   void doit_epilogue() override;
 64 
 65   bool is_gc_operation() const override { return true; };
 66 };
 67 
 68 class VM_ShenandoahReferenceOperation : public VM_ShenandoahOperation {
 69 public:
 70   explicit VM_ShenandoahReferenceOperation(ShenandoahGeneration* generation)
 71     : VM_ShenandoahOperation(generation) {};
 72   bool doit_prologue() override;
 73   void doit_epilogue() override;
 74 };
 75 
 76 class VM_ShenandoahInitMark: public VM_ShenandoahOperation {
 77   ShenandoahConcurrentGC* const _gc;
 78 public:
 79   explicit VM_ShenandoahInitMark(ShenandoahConcurrentGC* gc);
 80   VM_Operation::VMOp_Type type() const override { return VMOp_ShenandoahInitMark; }
 81   const char* name()             const override { return "Shenandoah Init Marking"; }
 82   void doit() override;
 83 };
 84 
 85 class VM_ShenandoahFinalMarkStartEvac: public VM_ShenandoahOperation {
 86   ShenandoahConcurrentGC* const _gc;
 87 public:
 88   explicit VM_ShenandoahFinalMarkStartEvac(ShenandoahConcurrentGC* gc);
 89   VM_Operation::VMOp_Type type() const override { return VMOp_ShenandoahFinalMarkStartEvac; }
 90   const char* name()             const override { return "Shenandoah Final Mark and Start Evacuation"; }
 91   void doit() override;
 92 };
 93 
 94 class VM_ShenandoahDegeneratedGC: public VM_ShenandoahReferenceOperation {
 95   ShenandoahDegenGC* const _gc;
 96 public:
 97   explicit VM_ShenandoahDegeneratedGC(ShenandoahDegenGC* gc);
 98   VM_Operation::VMOp_Type type() const override { return VMOp_ShenandoahDegeneratedGC; }
 99   const char* name()             const override { return "Shenandoah Degenerated GC"; }
100   void doit() override;
101 };
102 
103 class VM_ShenandoahFullGC : public VM_ShenandoahReferenceOperation {
104   GCCause::Cause           _gc_cause;
105   ShenandoahFullGC* const  _full_gc;
106 public:
107   explicit VM_ShenandoahFullGC(GCCause::Cause gc_cause, ShenandoahFullGC* full_gc);
108   VM_Operation::VMOp_Type type() const override { return VMOp_ShenandoahFullGC; }
109   const char* name()             const override { return "Shenandoah Full GC"; }
110   void doit() override;
111 };
112 
113 class VM_ShenandoahInitUpdateRefs: public VM_ShenandoahOperation {
114   ShenandoahConcurrentGC* const _gc;
115 public:
116   explicit VM_ShenandoahInitUpdateRefs(ShenandoahConcurrentGC* gc);
117   VM_Operation::VMOp_Type type() const override { return VMOp_ShenandoahInitUpdateRefs; }
118   const char* name()             const override { return "Shenandoah Init Update References"; }
119   void doit() override;
120 };
121 
122 class VM_ShenandoahFinalUpdateRefs: public VM_ShenandoahOperation {
123   ShenandoahConcurrentGC* const _gc;
124 public:
125   explicit VM_ShenandoahFinalUpdateRefs(ShenandoahConcurrentGC* gc);
126   VM_Operation::VMOp_Type type() const override { return VMOp_ShenandoahFinalUpdateRefs; }
127   const char* name()             const override { return "Shenandoah Final Update References"; }
128   void doit() override;
129 };
130 
131 class VM_ShenandoahFinalRoots: public VM_ShenandoahOperation {
132   ShenandoahConcurrentGC* const _gc;
133 public:
134   explicit VM_ShenandoahFinalRoots(ShenandoahConcurrentGC* gc);
135   VM_Operation::VMOp_Type type() const override { return VMOp_ShenandoahFinalRoots; }
136   const char* name()             const override { return "Shenandoah Final Roots"; }
137   void doit() override;
138 };
139 
140 class VM_ShenandoahFinalVerify: public VM_ShenandoahOperation {
141   ShenandoahConcurrentGC* const _gc;
142 public:
143   explicit VM_ShenandoahFinalVerify(ShenandoahConcurrentGC* gc);
144   VM_Operation::VMOp_Type type() const override { return VMOp_ShenandoahFinalVerify; }
145   const char* name()             const override { return "Shenandoah Final Verify"; }
146   void doit() override;
147 };
148 
149 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHVMOPERATIONS_HPP