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