|
1 /* |
|
2 * Copyright (c) 2017, Oracle and/or its affiliates. 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_G1_G1FULLGCOOPCLOSURES_HPP |
|
26 #define SHARE_GC_G1_G1FULLGCOOPCLOSURES_HPP |
|
27 |
|
28 #include "memory/iterator.hpp" |
|
29 #include "memory/universe.hpp" |
|
30 |
|
31 class G1CollectedHeap; |
|
32 class G1FullCollector; |
|
33 class G1CMBitMap; |
|
34 class G1FullGCMarker; |
|
35 |
|
36 // Below are closures used by the G1 Full GC. |
|
37 class G1IsAliveClosure : public BoolObjectClosure { |
|
38 G1CMBitMap* _bitmap; |
|
39 |
|
40 public: |
|
41 G1IsAliveClosure(G1CMBitMap* bitmap) : _bitmap(bitmap) { } |
|
42 |
|
43 virtual bool do_object_b(oop p); |
|
44 }; |
|
45 |
|
46 class G1FullKeepAliveClosure: public OopClosure { |
|
47 G1FullGCMarker* _marker; |
|
48 template <class T> |
|
49 inline void do_oop_work(T* p); |
|
50 |
|
51 public: |
|
52 G1FullKeepAliveClosure(G1FullGCMarker* pm) : _marker(pm) { } |
|
53 |
|
54 virtual void do_oop(oop* p); |
|
55 virtual void do_oop(narrowOop* p); |
|
56 }; |
|
57 |
|
58 class G1MarkAndPushClosure : public ExtendedOopClosure { |
|
59 G1FullGCMarker* _marker; |
|
60 uint _worker_id; |
|
61 |
|
62 public: |
|
63 G1MarkAndPushClosure(uint worker, G1FullGCMarker* marker, ReferenceProcessor* ref) : |
|
64 _marker(marker), |
|
65 _worker_id(worker), |
|
66 ExtendedOopClosure(ref) { } |
|
67 |
|
68 template <class T> inline void do_oop_nv(T* p); |
|
69 virtual void do_oop(oop* p); |
|
70 virtual void do_oop(narrowOop* p); |
|
71 |
|
72 virtual bool do_metadata(); |
|
73 bool do_metadata_nv(); |
|
74 |
|
75 virtual void do_klass(Klass* k); |
|
76 void do_klass_nv(Klass* k); |
|
77 |
|
78 virtual void do_cld(ClassLoaderData* cld); |
|
79 void do_cld_nv(ClassLoaderData* cld); |
|
80 }; |
|
81 |
|
82 class G1AdjustClosure : public OopClosure { |
|
83 public: |
|
84 template <class T> static inline oop adjust_pointer(T* p); |
|
85 virtual void do_oop(oop* p); |
|
86 virtual void do_oop(narrowOop* p); |
|
87 }; |
|
88 |
|
89 class G1AdjustAndRebuildClosure : public ExtendedOopClosure { |
|
90 uint _worker_id; |
|
91 size_t _compaction_delta; |
|
92 G1CollectedHeap* _g1h; |
|
93 |
|
94 inline size_t calculate_compaction_delta(oop current, oop forwardee); |
|
95 template <class T> inline T* add_compaction_delta(T* p); |
|
96 |
|
97 public: |
|
98 G1AdjustAndRebuildClosure(uint worker_id); |
|
99 |
|
100 void update_compaction_delta(oop obj); |
|
101 |
|
102 template <class T> inline void add_reference(T* from_field, oop reference, uint worker_id); |
|
103 template <class T> void do_oop_nv(T* p); |
|
104 virtual void do_oop(oop* p); |
|
105 virtual void do_oop(narrowOop* p); |
|
106 |
|
107 virtual ReferenceIterationMode reference_iteration_mode() { return DO_FIELDS; } |
|
108 }; |
|
109 |
|
110 class G1AdjustObjectClosure { |
|
111 G1AdjustAndRebuildClosure* _closure; |
|
112 |
|
113 public: |
|
114 G1AdjustObjectClosure(G1AdjustAndRebuildClosure* cl) : _closure(cl) { } |
|
115 |
|
116 inline int adjust_object(oop obj); |
|
117 }; |
|
118 |
|
119 class G1VerifyOopClosure: public OopClosure { |
|
120 private: |
|
121 G1CollectedHeap* _g1h; |
|
122 bool _failures; |
|
123 oop _containing_obj; |
|
124 VerifyOption _verify_option; |
|
125 |
|
126 public: |
|
127 int _cc; |
|
128 G1VerifyOopClosure(VerifyOption option); |
|
129 |
|
130 void set_containing_obj(oop obj) { |
|
131 _containing_obj = obj; |
|
132 } |
|
133 |
|
134 bool failures() { return _failures; } |
|
135 void print_object(outputStream* out, oop obj); |
|
136 |
|
137 template <class T> void do_oop_nv(T* p); |
|
138 |
|
139 void do_oop(oop* p) { do_oop_nv(p); } |
|
140 void do_oop(narrowOop* p) { do_oop_nv(p); } |
|
141 }; |
|
142 |
|
143 class G1FollowStackClosure: public VoidClosure { |
|
144 G1FullGCMarker* _marker; |
|
145 |
|
146 public: |
|
147 G1FollowStackClosure(G1FullGCMarker* marker) : _marker(marker) {} |
|
148 virtual void do_void(); |
|
149 }; |
|
150 |
|
151 #endif // SHARE_GC_G1_G1FULLGCOOPCLOSURES_HPP |