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_ShenandoahFinalVerify: final verification at the end of the 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 ShenandoahGeneration* _generation;
50
51 void set_active_generation();
52 public:
53 explicit VM_ShenandoahOperation(ShenandoahGeneration* generation)
54 : _gc_id(GCId::current())
55 , _generation(generation) {
56 }
57
58 bool skip_thread_oop_barriers() const override { return true; }
59
60 void log_active_generation(const char* prefix);
61 bool doit_prologue() override;
62 void doit_epilogue() override;
63
64 bool is_gc_operation() const override { return true; };
65 };
66
67 class VM_ShenandoahReferenceOperation : public VM_ShenandoahOperation {
68 public:
69 explicit VM_ShenandoahReferenceOperation(ShenandoahGeneration* generation)
70 : VM_ShenandoahOperation(generation) {};
71 bool doit_prologue() override;
72 void doit_epilogue() override;
73 };
74
75 class VM_ShenandoahInitMark: public VM_ShenandoahOperation {
76 ShenandoahConcurrentGC* const _gc;
77 public:
78 explicit VM_ShenandoahInitMark(ShenandoahConcurrentGC* gc);
79 VM_Operation::VMOp_Type type() const override { return VMOp_ShenandoahInitMark; }
80 const char* name() const override { return "Shenandoah Init Marking"; }
81 void doit() override;
82 };
83
84 class VM_ShenandoahFinalMarkStartEvac: public VM_ShenandoahOperation {
85 ShenandoahConcurrentGC* const _gc;
86 public:
87 explicit VM_ShenandoahFinalMarkStartEvac(ShenandoahConcurrentGC* gc);
88 VM_Operation::VMOp_Type type() const override { return VMOp_ShenandoahFinalMarkStartEvac; }
89 const char* name() const override { return "Shenandoah Final Mark and Start Evacuation"; }
90 void doit() override;
91 };
92
93 class VM_ShenandoahDegeneratedGC: public VM_ShenandoahReferenceOperation {
94 ShenandoahDegenGC* const _gc;
95 public:
96 explicit VM_ShenandoahDegeneratedGC(ShenandoahDegenGC* gc);
97 VM_Operation::VMOp_Type type() const override { return VMOp_ShenandoahDegeneratedGC; }
98 const char* name() const override { return "Shenandoah Degenerated GC"; }
99 void doit() override;
100 };
101
102 class VM_ShenandoahFullGC : public VM_ShenandoahReferenceOperation {
103 GCCause::Cause _gc_cause;
104 ShenandoahFullGC* const _full_gc;
105 public:
106 explicit VM_ShenandoahFullGC(GCCause::Cause gc_cause, ShenandoahFullGC* full_gc);
107 VM_Operation::VMOp_Type type() const override { return VMOp_ShenandoahFullGC; }
108 const char* name() const override { return "Shenandoah Full GC"; }
109 void doit() override;
110 };
111
112 class VM_ShenandoahInitUpdateRefs: public VM_ShenandoahOperation {
113 ShenandoahConcurrentGC* const _gc;
114 public:
115 explicit VM_ShenandoahInitUpdateRefs(ShenandoahConcurrentGC* gc);
116 VM_Operation::VMOp_Type type() const override { return VMOp_ShenandoahInitUpdateRefs; }
117 const char* name() const override { return "Shenandoah Init Update References"; }
118 void doit() override;
119 };
120
121 class VM_ShenandoahFinalUpdateRefs: public VM_ShenandoahOperation {
122 ShenandoahConcurrentGC* const _gc;
123 public:
124 explicit VM_ShenandoahFinalUpdateRefs(ShenandoahConcurrentGC* gc);
125 VM_Operation::VMOp_Type type() const override { return VMOp_ShenandoahFinalUpdateRefs; }
126 const char* name() const override { return "Shenandoah Final Update References"; }
127 void doit() override;
128 };
129
130 class VM_ShenandoahFinalVerify: public VM_ShenandoahOperation {
131 ShenandoahConcurrentGC* const _gc;
132 public:
133 explicit VM_ShenandoahFinalVerify(ShenandoahConcurrentGC* gc);
134 VM_Operation::VMOp_Type type() const override { return VMOp_ShenandoahFinalVerify; }
135 const char* name() const override { return "Shenandoah Final Verify"; }
136 void doit() override;
137 };
138
139 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHVMOPERATIONS_HPP