1 /*
2 * Copyright (c) 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_SHENANDOAHCONCURRENTGC_HPP
26 #define SHARE_GC_SHENANDOAH_SHENANDOAHCONCURRENTGC_HPP
27
28 #include "gc/shared/gcCause.hpp"
29 #include "gc/shenandoah/shenandoahConcurrentMark.hpp"
30 #include "gc/shenandoah/shenandoahGC.hpp"
31 #include "gc/shenandoah/shenandoahHeap.hpp"
32
33 class VM_ShenandoahInitMark;
34 class VM_ShenandoahFinalMarkStartEvac;
35 class VM_ShenandoahInitUpdateRefs;
36 class VM_ShenandoahFinalUpdateRefs;
37
38 class ShenandoahConcurrentGC : public ShenandoahGC {
39 friend class VM_ShenandoahInitMark;
40 friend class VM_ShenandoahFinalMarkStartEvac;
41 friend class VM_ShenandoahInitUpdateRefs;
42 friend class VM_ShenandoahFinalUpdateRefs;
43 friend class VM_ShenandoahFinalRoots;
44
45 private:
46 ShenandoahConcurrentMark _mark;
47 ShenandoahDegenPoint _degen_point;
48
49 public:
50 ShenandoahConcurrentGC();
51 bool collect(GCCause::Cause cause);
52 ShenandoahDegenPoint degen_point() const;
53
54 // Cancel ongoing concurrent GC
55 static void cancel();
56 private:
57 // Entry points to STW GC operations, these cause a related safepoint, that then
58 // call the entry method below
59 void vmop_entry_init_mark();
60 void vmop_entry_final_mark();
61 void vmop_entry_init_updaterefs();
62 void vmop_entry_final_updaterefs();
63 void vmop_entry_final_roots();
64
65 // Entry methods to normally STW GC operations. These set up logging, monitoring
66 // and workers for net VM operation
67 void entry_init_mark();
68 void entry_final_mark();
69 void entry_init_updaterefs();
70 void entry_final_updaterefs();
71 void entry_final_roots();
72
73 // Entry methods to normally concurrent GC operations. These set up logging, monitoring
74 // for concurrent operation.
75 void entry_reset();
76 void entry_mark_roots();
77 void entry_mark();
78 void entry_thread_roots();
79 void entry_weak_refs();
80 void entry_weak_roots();
81 void entry_class_unloading();
82 void entry_strong_roots();
83 void entry_cleanup_early();
84 void entry_evacuate();
85 void entry_update_thread_roots();
86 void entry_updaterefs();
87 void entry_cleanup_complete();
88
89 // Actual work for the phases
90 void op_reset();
91 void op_init_mark();
92 void op_mark_roots();
93 void op_mark();
94 void op_final_mark();
95 void op_thread_roots();
96 void op_weak_refs();
97 void op_weak_roots();
98 void op_class_unloading();
99 void op_strong_roots();
100 void op_cleanup_early();
101 void op_evacuate();
102 void op_init_updaterefs();
103 void op_updaterefs();
104 void op_update_thread_roots();
105 void op_final_updaterefs();
106 void op_final_roots();
107 void op_cleanup_complete();
108
109 void start_mark();
110
111 // Messages for GC trace events, they have to be immortal for
112 // passing around the logging/tracing systems
113 const char* init_mark_event_message() const;
114 const char* final_mark_event_message() const;
115 const char* conc_mark_event_message() const;
116
117 // Check GC cancellation and abort concurrent GC
118 bool check_cancellation_and_abort(ShenandoahDegenPoint point);
119 };
120
121 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHCONCURRENTGC_HPP
|
1 /*
2 * Copyright (c) 2021, Red Hat, Inc. All rights reserved.
3 * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 *
24 */
25
26 #ifndef SHARE_GC_SHENANDOAH_SHENANDOAHCONCURRENTGC_HPP
27 #define SHARE_GC_SHENANDOAH_SHENANDOAHCONCURRENTGC_HPP
28
29 #include "gc/shared/gcCause.hpp"
30 #include "gc/shenandoah/shenandoahConcurrentMark.hpp"
31 #include "gc/shenandoah/shenandoahGC.hpp"
32 #include "gc/shenandoah/shenandoahHeap.hpp"
33
34 class ShenandoahGeneration;
35
36 class VM_ShenandoahInitMark;
37 class VM_ShenandoahFinalMarkStartEvac;
38 class VM_ShenandoahInitUpdateRefs;
39 class VM_ShenandoahFinalUpdateRefs;
40
41 class ShenandoahConcurrentGC : public ShenandoahGC {
42 friend class VM_ShenandoahInitMark;
43 friend class VM_ShenandoahFinalMarkStartEvac;
44 friend class VM_ShenandoahInitUpdateRefs;
45 friend class VM_ShenandoahFinalUpdateRefs;
46 friend class VM_ShenandoahFinalRoots;
47
48 protected:
49 ShenandoahConcurrentMark _mark;
50 ShenandoahGeneration* const _generation;
51
52 private:
53 ShenandoahDegenPoint _degen_point;
54 bool _abbreviated;
55 const bool _do_old_gc_bootstrap;
56
57 public:
58 ShenandoahConcurrentGC(ShenandoahGeneration* generation, bool do_old_gc_bootstrap);
59
60 bool collect(GCCause::Cause cause) override;
61 ShenandoahDegenPoint degen_point() const;
62
63 void entry_concurrent_update_refs_prepare(ShenandoahHeap* heap);
64
65 // Return true if this cycle found enough immediate garbage to skip evacuation
66 bool abbreviated() const { return _abbreviated; }
67
68 protected:
69 // Entry points to STW GC operations, these cause a related safepoint, that then
70 // call the entry method below
71 void vmop_entry_init_mark();
72 void vmop_entry_final_mark();
73 void vmop_entry_init_update_refs();
74 void vmop_entry_final_update_refs();
75 void vmop_entry_verify_final_roots();
76
77 // Entry methods to normally STW GC operations. These set up logging, monitoring
78 // and workers for net VM operation
79 void entry_init_mark();
80 void entry_final_mark();
81 void entry_init_update_refs();
82 void entry_final_update_refs();
83 void entry_verify_final_roots();
84
85 // Entry methods to normally concurrent GC operations. These set up logging, monitoring
86 // for concurrent operation.
87 void entry_reset();
88 void entry_mark_roots();
89 void entry_scan_remembered_set();
90 void entry_mark();
91 void entry_thread_roots();
92 void entry_weak_refs();
93 void entry_weak_roots();
94 void entry_class_unloading();
95 void entry_strong_roots();
96 void entry_cleanup_early();
97 void entry_evacuate();
98 void entry_update_thread_roots();
99 void entry_update_refs();
100 void entry_cleanup_complete();
101
102 // This is the last phase of a cycle which performs no evacuations
103 bool entry_final_roots();
104
105 // Called when the collection set is empty, but the generational mode has regions to promote in place
106 void entry_promote_in_place() const;
107
108 // Actual work for the phases
109 void op_reset();
110 void op_init_mark();
111 void op_mark_roots();
112 void op_mark();
113 virtual void op_final_mark();
114 void op_thread_roots();
115 void op_weak_refs();
116 void op_weak_roots();
117 void op_class_unloading();
118 void op_strong_roots();
119 void op_cleanup_early();
120 void op_evacuate();
121 void op_init_update_refs();
122 void op_update_refs();
123 void op_update_thread_roots();
124 void op_final_update_refs();
125
126 void op_verify_final_roots();
127 void op_cleanup_complete();
128 void op_reset_after_collect();
129
130 // Check GC cancellation and abort concurrent GC
131 bool check_cancellation_and_abort(ShenandoahDegenPoint point);
132
133 // Called when concurrent GC succeeds.
134 void entry_reset_after_collect();
135
136 private:
137 void start_mark();
138
139 bool complete_abbreviated_cycle();
140
141 static bool has_in_place_promotions(ShenandoahHeap* heap);
142
143 // Messages for GC trace events, they have to be immortal for
144 // passing around the logging/tracing systems
145 const char* init_mark_event_message() const;
146 const char* final_mark_event_message() const;
147 const char* verify_final_roots_event_message() const;
148 const char* conc_final_roots_event_message() const;
149 const char* conc_mark_event_message() const;
150 const char* conc_reset_event_message() const;
151 const char* conc_reset_after_collect_event_message() const;
152 const char* conc_weak_refs_event_message() const;
153 const char* conc_weak_roots_event_message() const;
154 const char* conc_cleanup_event_message() const;
155 const char* conc_init_update_refs_event_message() const;
156 };
157
158 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHCONCURRENTGC_HPP
|