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   virtual bool skip_thread_oop_barriers() const { return true; }
 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 private:
 62   ShenandoahConcurrentGC* const _gc;
 63 public:
 64   explicit VM_ShenandoahInitMark(ShenandoahConcurrentGC* gc) :
 65     VM_ShenandoahOperation(),
 66     _gc(gc) {};
 67   VM_Operation::VMOp_Type type() const { return VMOp_ShenandoahInitMark; }
 68   const char* name()             const { return "Shenandoah Init Marking"; }
 69   virtual void doit();
 70 };
 71 
 72 class VM_ShenandoahFinalMarkStartEvac: public VM_ShenandoahOperation {
 73 private:
 74   ShenandoahConcurrentGC* const _gc;
 75 public:
 76   explicit VM_ShenandoahFinalMarkStartEvac(ShenandoahConcurrentGC* gc) :
 77     VM_ShenandoahOperation(),
 78     _gc(gc) {};
 79   VM_Operation::VMOp_Type type() const { return VMOp_ShenandoahFinalMarkStartEvac; }
 80   const char* name()             const { return "Shenandoah Final Mark and Start Evacuation"; }
 81   virtual  void doit();
 82 };
 83 
 84 class VM_ShenandoahDegeneratedGC: public VM_ShenandoahReferenceOperation {
 85 private:
 86   ShenandoahDegenGC* const _gc;
 87 public:
 88   VM_ShenandoahDegeneratedGC(ShenandoahDegenGC* gc) :
 89     VM_ShenandoahReferenceOperation(),
 90     _gc(gc) {};
 91 
 92   VM_Operation::VMOp_Type type() const { return VMOp_ShenandoahDegeneratedGC; }
 93   const char* name()             const { return "Shenandoah Degenerated GC"; }
 94   virtual  void doit();
 95 };
 96 
 97 class VM_ShenandoahFullGC : public VM_ShenandoahReferenceOperation {
 98 private:
 99   GCCause::Cause           _gc_cause;
100   ShenandoahFullGC* const  _full_gc;
101 public:
102   VM_ShenandoahFullGC(GCCause::Cause gc_cause, ShenandoahFullGC* full_gc) :
103     VM_ShenandoahReferenceOperation(),
104     _gc_cause(gc_cause),
105     _full_gc(full_gc) {};
106   VM_Operation::VMOp_Type type() const { return VMOp_ShenandoahFullGC; }
107   const char* name()             const { return "Shenandoah Full GC"; }
108   virtual void doit();
109 };
110 
111 class VM_ShenandoahInitUpdateRefs: public VM_ShenandoahOperation {
112   ShenandoahConcurrentGC* const _gc;
113 public:
114   VM_ShenandoahInitUpdateRefs(ShenandoahConcurrentGC* gc) :
115     VM_ShenandoahOperation(),
116     _gc(gc) {};
117   VM_Operation::VMOp_Type type() const { return VMOp_ShenandoahInitUpdateRefs; }
118   const char* name()             const { return "Shenandoah Init Update References"; }
119   virtual void doit();
120 };
121 
122 class VM_ShenandoahFinalUpdateRefs: public VM_ShenandoahOperation {
123   ShenandoahConcurrentGC* const _gc;
124 public:
125   VM_ShenandoahFinalUpdateRefs(ShenandoahConcurrentGC* gc) :
126     VM_ShenandoahOperation(),
127     _gc(gc) {};
128   VM_Operation::VMOp_Type type() const { return VMOp_ShenandoahFinalUpdateRefs; }
129   const char* name()             const { return "Shenandoah Final Update References"; }
130   virtual void doit();
131 };
132 
133 class VM_ShenandoahFinalRoots: public VM_ShenandoahOperation {
134   ShenandoahConcurrentGC* const _gc;
135   bool _incr_region_ages;
136 public:
137   VM_ShenandoahFinalRoots(ShenandoahConcurrentGC* gc, bool incr_region_ages) :
138     VM_ShenandoahOperation(),
139     _gc(gc), _incr_region_ages(incr_region_ages) {};
140   VM_Operation::VMOp_Type type() const { return VMOp_ShenandoahFinalRoots; }
141   const char* name()             const { return "Shenandoah Final Roots"; }
142   virtual void doit();
143 };
144 
145 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHVMOPERATIONS_HPP