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_ShenandoahInitUpdateRefs: initiate update references
 40 //   - VM_ShenandoahFinalUpdateRefs: finish up update references
 41 //   - VM_ShenandoahReferenceOperation:
 42 //       - VM_ShenandoahFullGC: do full GC
 43 //       - VM_ShenandoahDegeneratedGC: do STW degenerated GC
 44 
 45 class VM_ShenandoahOperation : public VM_Operation {
 46 protected:
 47   uint         _gc_id;
 48 public:
 49   VM_ShenandoahOperation() : _gc_id(GCId::current()) {};
 50   bool skip_thread_oop_barriers() const override { return true; }
 51   bool doit_prologue() override;
 52   void doit_epilogue() override;
 53 };
 54 
 55 class VM_ShenandoahReferenceOperation : public VM_ShenandoahOperation {
 56 public:
 57   VM_ShenandoahReferenceOperation() : VM_ShenandoahOperation() {};
 58   bool doit_prologue() override;
 59   void doit_epilogue() override;
 60 };
 61 
 62 class VM_ShenandoahInitMark: public VM_ShenandoahOperation {
 63 private:
 64   ShenandoahConcurrentGC* const _gc;
 65 public:
 66   VM_ShenandoahInitMark(ShenandoahConcurrentGC* gc) :
 67     VM_ShenandoahOperation(),
 68     _gc(gc) {};
 69   VM_Operation::VMOp_Type type() const { return VMOp_ShenandoahInitMark; }
 70   const char* name()             const { return "Shenandoah Init Marking"; }
 71   virtual void doit();
 72 };
 73 
 74 class VM_ShenandoahFinalMarkStartEvac: public VM_ShenandoahOperation {
 75 private:
 76   ShenandoahConcurrentGC* const _gc;
 77 public:
 78   VM_ShenandoahFinalMarkStartEvac(ShenandoahConcurrentGC* gc) :
 79     VM_ShenandoahOperation(),
 80     _gc(gc) {};
 81   VM_Operation::VMOp_Type type() const { return VMOp_ShenandoahFinalMarkStartEvac; }
 82   const char* name()             const { return "Shenandoah Final Mark and Start Evacuation"; }
 83   virtual  void doit();
 84 };
 85 
 86 class VM_ShenandoahDegeneratedGC: public VM_ShenandoahReferenceOperation {
 87 private:
 88   ShenandoahDegenGC* const _gc;
 89 public:
 90   VM_ShenandoahDegeneratedGC(ShenandoahDegenGC* gc) :
 91     VM_ShenandoahReferenceOperation(),
 92     _gc(gc) {};
 93 
 94   VM_Operation::VMOp_Type type() const { return VMOp_ShenandoahDegeneratedGC; }
 95   const char* name()             const { return "Shenandoah Degenerated GC"; }
 96   virtual  void doit();
 97 };
 98 
 99 class VM_ShenandoahFullGC : public VM_ShenandoahReferenceOperation {
100 private:
101   GCCause::Cause           _gc_cause;
102   ShenandoahFullGC* const  _full_gc;
103 public:
104   VM_ShenandoahFullGC(GCCause::Cause gc_cause, ShenandoahFullGC* full_gc) :
105     VM_ShenandoahReferenceOperation(),
106     _gc_cause(gc_cause),
107     _full_gc(full_gc) {};
108   VM_Operation::VMOp_Type type() const { return VMOp_ShenandoahFullGC; }
109   const char* name()             const { return "Shenandoah Full GC"; }
110   virtual void doit();
111 };
112 
113 class VM_ShenandoahInitUpdateRefs: public VM_ShenandoahOperation {
114   ShenandoahConcurrentGC* const _gc;
115 public:
116   VM_ShenandoahInitUpdateRefs(ShenandoahConcurrentGC* gc) :
117     VM_ShenandoahOperation(),
118     _gc(gc) {};
119   VM_Operation::VMOp_Type type() const { return VMOp_ShenandoahInitUpdateRefs; }
120   const char* name()             const { return "Shenandoah Init Update References"; }
121   virtual void doit();
122 };
123 
124 class VM_ShenandoahFinalUpdateRefs: public VM_ShenandoahOperation {
125   ShenandoahConcurrentGC* const _gc;
126 public:
127   VM_ShenandoahFinalUpdateRefs(ShenandoahConcurrentGC* gc) :
128     VM_ShenandoahOperation(),
129     _gc(gc) {};
130   VM_Operation::VMOp_Type type() const { return VMOp_ShenandoahFinalUpdateRefs; }
131   const char* name()             const { return "Shenandoah Final Update References"; }
132   virtual void doit();
133 };
134 
135 class VM_ShenandoahFinalRoots: public VM_ShenandoahOperation {
136   ShenandoahConcurrentGC* const _gc;
137 public:
138   VM_ShenandoahFinalRoots(ShenandoahConcurrentGC* gc) :
139     VM_ShenandoahOperation(),
140     _gc(gc) {};
141   VM_Operation::VMOp_Type type() const { return VMOp_ShenandoahFinalRoots; }
142   const char* name()             const { return "Shenandoah Final Roots"; }
143   virtual void doit();
144 };
145 
146 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHVMOPERATIONS_HPP