author | vlivanov |
Tue, 26 Nov 2019 16:09:21 +0300 | |
changeset 59276 | 94a84abb873b |
parent 59154 | 0c2e1808f800 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
52141
diff
changeset
|
2 |
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. |
1 | 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 |
* |
|
5547
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4738
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4738
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
4738
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
52141
diff
changeset
|
25 |
#ifndef SHARE_MEMORY_ITERATOR_HPP |
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
52141
diff
changeset
|
26 |
#define SHARE_MEMORY_ITERATOR_HPP |
7397 | 27 |
|
28 |
#include "memory/allocation.hpp" |
|
29 |
#include "memory/memRegion.hpp" |
|
37466 | 30 |
#include "oops/oopsHierarchy.hpp" |
7397 | 31 |
|
3908
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
32 |
class CodeBlob; |
3913
e049e6b81e11
6885169: merge of 4957990 and 6863023 causes conflict on do_nmethods
jrose
parents:
3912
diff
changeset
|
33 |
class nmethod; |
49827 | 34 |
class ReferenceDiscoverer; |
3696 | 35 |
class DataLayout; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
36 |
class KlassClosure; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
37 |
class ClassLoaderData; |
37466 | 38 |
class Symbol; |
54150
5529640c5f67
8220512: Deoptimize redefinition functions that have dirty ICs
coleenp
parents:
53889
diff
changeset
|
39 |
class Metadata; |
1 | 40 |
|
23538 | 41 |
// The following classes are C++ `closures` for iterating over objects, roots and spaces |
1374
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
42 |
|
23538 | 43 |
class Closure : public StackObj { }; |
1374
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
44 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
45 |
// OopClosure is used for iterating through references to Java objects. |
1374
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
46 |
class OopClosure : public Closure { |
1 | 47 |
public: |
48 |
virtual void do_oop(oop* o) = 0; |
|
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
49 |
virtual void do_oop(narrowOop* o) = 0; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
50 |
}; |
3690 | 51 |
|
47676
b1c020fc35a3
8189748: More precise closures for WeakProcessor::weak_oops_do calls
stefank
parents:
47580
diff
changeset
|
52 |
class DoNothingClosure : public OopClosure { |
b1c020fc35a3
8189748: More precise closures for WeakProcessor::weak_oops_do calls
stefank
parents:
47580
diff
changeset
|
53 |
public: |
b1c020fc35a3
8189748: More precise closures for WeakProcessor::weak_oops_do calls
stefank
parents:
47580
diff
changeset
|
54 |
virtual void do_oop(oop* p) {} |
b1c020fc35a3
8189748: More precise closures for WeakProcessor::weak_oops_do calls
stefank
parents:
47580
diff
changeset
|
55 |
virtual void do_oop(narrowOop* p) {} |
b1c020fc35a3
8189748: More precise closures for WeakProcessor::weak_oops_do calls
stefank
parents:
47580
diff
changeset
|
56 |
}; |
b1c020fc35a3
8189748: More precise closures for WeakProcessor::weak_oops_do calls
stefank
parents:
47580
diff
changeset
|
57 |
extern DoNothingClosure do_nothing_cl; |
b1c020fc35a3
8189748: More precise closures for WeakProcessor::weak_oops_do calls
stefank
parents:
47580
diff
changeset
|
58 |
|
50752 | 59 |
// OopIterateClosure adds extra code to be run during oop iterations. |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
60 |
// This is needed by the GC and is extracted to a separate type to not |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
61 |
// pollute the OopClosure interface. |
50752 | 62 |
class OopIterateClosure : public OopClosure { |
33226
19cb9b844190
8139341: Hide ExtendedOopClosure::_ref_processor
kbarrett
parents:
32606
diff
changeset
|
63 |
private: |
49827 | 64 |
ReferenceDiscoverer* _ref_discoverer; |
33226
19cb9b844190
8139341: Hide ExtendedOopClosure::_ref_processor
kbarrett
parents:
32606
diff
changeset
|
65 |
|
19cb9b844190
8139341: Hide ExtendedOopClosure::_ref_processor
kbarrett
parents:
32606
diff
changeset
|
66 |
protected: |
50752 | 67 |
OopIterateClosure(ReferenceDiscoverer* rd) : _ref_discoverer(rd) { } |
68 |
OopIterateClosure() : _ref_discoverer(NULL) { } |
|
69 |
~OopIterateClosure() { } |
|
33226
19cb9b844190
8139341: Hide ExtendedOopClosure::_ref_processor
kbarrett
parents:
32606
diff
changeset
|
70 |
|
49827 | 71 |
void set_ref_discoverer_internal(ReferenceDiscoverer* rd) { _ref_discoverer = rd; } |
33226
19cb9b844190
8139341: Hide ExtendedOopClosure::_ref_processor
kbarrett
parents:
32606
diff
changeset
|
72 |
|
19cb9b844190
8139341: Hide ExtendedOopClosure::_ref_processor
kbarrett
parents:
32606
diff
changeset
|
73 |
public: |
49827 | 74 |
ReferenceDiscoverer* ref_discoverer() const { return _ref_discoverer; } |
1 | 75 |
|
46415
7d5a286cdf89
8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents:
37995
diff
changeset
|
76 |
// Iteration of InstanceRefKlasses differ depending on the closure, |
7d5a286cdf89
8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents:
37995
diff
changeset
|
77 |
// the below enum describes the different alternatives. |
7d5a286cdf89
8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents:
37995
diff
changeset
|
78 |
enum ReferenceIterationMode { |
46445
825b002e05ae
8138888: Remove ExtendedOopClosure::apply_to_weak_ref_discovered_field
sjohanss
parents:
46415
diff
changeset
|
79 |
DO_DISCOVERY, // Apply closure and discover references |
825b002e05ae
8138888: Remove ExtendedOopClosure::apply_to_weak_ref_discovered_field
sjohanss
parents:
46415
diff
changeset
|
80 |
DO_DISCOVERED_AND_DISCOVERY, // Apply closure to discovered field and do discovery |
50870
830b05ca7f58
8205923: ZGC: Verification applies load barrier before verification
stefank
parents:
50801
diff
changeset
|
81 |
DO_FIELDS, // Apply closure to all fields |
830b05ca7f58
8205923: ZGC: Verification applies load barrier before verification
stefank
parents:
50801
diff
changeset
|
82 |
DO_FIELDS_EXCEPT_REFERENT // Apply closure to all fields except the referent field |
46415
7d5a286cdf89
8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents:
37995
diff
changeset
|
83 |
}; |
7d5a286cdf89
8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents:
37995
diff
changeset
|
84 |
|
7d5a286cdf89
8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents:
37995
diff
changeset
|
85 |
// The default iteration mode is to do discovery. |
7d5a286cdf89
8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents:
37995
diff
changeset
|
86 |
virtual ReferenceIterationMode reference_iteration_mode() { return DO_DISCOVERY; } |
7d5a286cdf89
8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents:
37995
diff
changeset
|
87 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
88 |
// If the do_metadata functions return "true", |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
89 |
// we invoke the following when running oop_iterate(): |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
90 |
// |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
91 |
// 1) do_klass on the header klass pointer. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
92 |
// 2) do_klass on the klass pointer in the mirrors. |
32606
fdaa30d06ada
8129417: Oop iteration clean-up to remove oop_ms_follow_contents
sjohanss
parents:
30880
diff
changeset
|
93 |
// 3) do_cld on the class loader data in class loaders. |
3696 | 94 |
|
50752 | 95 |
virtual bool do_metadata() = 0; |
96 |
virtual void do_klass(Klass* k) = 0; |
|
97 |
virtual void do_cld(ClassLoaderData* cld) = 0; |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
98 |
|
30150
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
25492
diff
changeset
|
99 |
#ifdef ASSERT |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
25492
diff
changeset
|
100 |
// Default verification of each visited oop field. |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
25492
diff
changeset
|
101 |
template <typename T> void verify(T* p); |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
25492
diff
changeset
|
102 |
|
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
25492
diff
changeset
|
103 |
// Can be used by subclasses to turn off the default verification of oop fields. |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
25492
diff
changeset
|
104 |
virtual bool should_verify_oops() { return true; } |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
25492
diff
changeset
|
105 |
#endif |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
106 |
}; |
3690 | 107 |
|
50752 | 108 |
// An OopIterateClosure that can be used when there's no need to visit the Metadata. |
109 |
class BasicOopIterateClosure : public OopIterateClosure { |
|
110 |
public: |
|
111 |
BasicOopIterateClosure(ReferenceDiscoverer* rd = NULL) : OopIterateClosure(rd) {} |
|
112 |
||
113 |
virtual bool do_metadata() { return false; } |
|
114 |
virtual void do_klass(Klass* k) { ShouldNotReachHere(); } |
|
115 |
virtual void do_cld(ClassLoaderData* cld) { ShouldNotReachHere(); } |
|
116 |
}; |
|
117 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
118 |
class KlassClosure : public Closure { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
119 |
public: |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
120 |
virtual void do_klass(Klass* k) = 0; |
1 | 121 |
}; |
122 |
||
22899
e2a6bf7f343a
8035393: Use CLDClosure instead of CLDToOopClosure in frame::oops_interpreted_do
stefank
parents:
22234
diff
changeset
|
123 |
class CLDClosure : public Closure { |
e2a6bf7f343a
8035393: Use CLDClosure instead of CLDToOopClosure in frame::oops_interpreted_do
stefank
parents:
22234
diff
changeset
|
124 |
public: |
e2a6bf7f343a
8035393: Use CLDClosure instead of CLDToOopClosure in frame::oops_interpreted_do
stefank
parents:
22234
diff
changeset
|
125 |
virtual void do_cld(ClassLoaderData* cld) = 0; |
e2a6bf7f343a
8035393: Use CLDClosure instead of CLDToOopClosure in frame::oops_interpreted_do
stefank
parents:
22234
diff
changeset
|
126 |
}; |
e2a6bf7f343a
8035393: Use CLDClosure instead of CLDToOopClosure in frame::oops_interpreted_do
stefank
parents:
22234
diff
changeset
|
127 |
|
54150
5529640c5f67
8220512: Deoptimize redefinition functions that have dirty ICs
coleenp
parents:
53889
diff
changeset
|
128 |
class MetadataClosure : public Closure { |
5529640c5f67
8220512: Deoptimize redefinition functions that have dirty ICs
coleenp
parents:
53889
diff
changeset
|
129 |
public: |
5529640c5f67
8220512: Deoptimize redefinition functions that have dirty ICs
coleenp
parents:
53889
diff
changeset
|
130 |
virtual void do_metadata(Metadata* md) = 0; |
5529640c5f67
8220512: Deoptimize redefinition functions that have dirty ICs
coleenp
parents:
53889
diff
changeset
|
131 |
}; |
5529640c5f67
8220512: Deoptimize redefinition functions that have dirty ICs
coleenp
parents:
53889
diff
changeset
|
132 |
|
13741
e4395deb8597
7197350: NPG: jvmtiHeapReferenceCallback receives incorrect reference_kind for system class roots
stefank
parents:
13728
diff
changeset
|
133 |
|
22899
e2a6bf7f343a
8035393: Use CLDClosure instead of CLDToOopClosure in frame::oops_interpreted_do
stefank
parents:
22234
diff
changeset
|
134 |
class CLDToOopClosure : public CLDClosure { |
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
135 |
OopClosure* _oop_closure; |
52141
de6dc206a92b
8210330: Make CLD claiming allow multiple claim bits
eosterlund
parents:
50870
diff
changeset
|
136 |
int _cld_claim; |
14582
490bb6c0df7c
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
13741
diff
changeset
|
137 |
|
490bb6c0df7c
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
13741
diff
changeset
|
138 |
public: |
52141
de6dc206a92b
8210330: Make CLD claiming allow multiple claim bits
eosterlund
parents:
50870
diff
changeset
|
139 |
CLDToOopClosure(OopClosure* oop_closure, |
de6dc206a92b
8210330: Make CLD claiming allow multiple claim bits
eosterlund
parents:
50870
diff
changeset
|
140 |
int cld_claim) : |
14582
490bb6c0df7c
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
13741
diff
changeset
|
141 |
_oop_closure(oop_closure), |
52141
de6dc206a92b
8210330: Make CLD claiming allow multiple claim bits
eosterlund
parents:
50870
diff
changeset
|
142 |
_cld_claim(cld_claim) {} |
14582
490bb6c0df7c
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
13741
diff
changeset
|
143 |
|
490bb6c0df7c
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
13741
diff
changeset
|
144 |
void do_cld(ClassLoaderData* cld); |
490bb6c0df7c
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
13741
diff
changeset
|
145 |
}; |
490bb6c0df7c
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
13741
diff
changeset
|
146 |
|
55603
3868dde58ebb
8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents:
55251
diff
changeset
|
147 |
class ClaimMetadataVisitingOopIterateClosure : public OopIterateClosure { |
3868dde58ebb
8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents:
55251
diff
changeset
|
148 |
protected: |
3868dde58ebb
8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents:
55251
diff
changeset
|
149 |
const int _claim; |
3868dde58ebb
8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents:
55251
diff
changeset
|
150 |
|
25356
4a4a482298a6
8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents:
23539
diff
changeset
|
151 |
public: |
55603
3868dde58ebb
8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents:
55251
diff
changeset
|
152 |
ClaimMetadataVisitingOopIterateClosure(int claim, ReferenceDiscoverer* rd = NULL) : |
3868dde58ebb
8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents:
55251
diff
changeset
|
153 |
OopIterateClosure(rd), |
3868dde58ebb
8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents:
55251
diff
changeset
|
154 |
_claim(claim) { } |
25356
4a4a482298a6
8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents:
23539
diff
changeset
|
155 |
|
50752 | 156 |
virtual bool do_metadata() { return true; } |
157 |
virtual void do_klass(Klass* k); |
|
158 |
virtual void do_cld(ClassLoaderData* cld); |
|
25356
4a4a482298a6
8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents:
23539
diff
changeset
|
159 |
}; |
4a4a482298a6
8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents:
23539
diff
changeset
|
160 |
|
55603
3868dde58ebb
8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents:
55251
diff
changeset
|
161 |
// The base class for all concurrent marking closures, |
3868dde58ebb
8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents:
55251
diff
changeset
|
162 |
// that participates in class unloading. |
3868dde58ebb
8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents:
55251
diff
changeset
|
163 |
// It's used to proxy through the metadata to the oops defined in them. |
3868dde58ebb
8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents:
55251
diff
changeset
|
164 |
class MetadataVisitingOopIterateClosure: public ClaimMetadataVisitingOopIterateClosure { |
3868dde58ebb
8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents:
55251
diff
changeset
|
165 |
public: |
3868dde58ebb
8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents:
55251
diff
changeset
|
166 |
MetadataVisitingOopIterateClosure(ReferenceDiscoverer* rd = NULL); |
3868dde58ebb
8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents:
55251
diff
changeset
|
167 |
}; |
3868dde58ebb
8227175: ZGC: ZHeapIterator visits potentially dead objects
stefank
parents:
55251
diff
changeset
|
168 |
|
1 | 169 |
// ObjectClosure is used for iterating through an object space |
170 |
||
1374
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
171 |
class ObjectClosure : public Closure { |
1 | 172 |
public: |
173 |
// Called for each object. |
|
174 |
virtual void do_object(oop obj) = 0; |
|
175 |
}; |
|
176 |
||
177 |
||
17625
3e91c67ddece
8014277: Remove ObjectClosure as base class for BoolObjectClosure
ehelin
parents:
14582
diff
changeset
|
178 |
class BoolObjectClosure : public Closure { |
1 | 179 |
public: |
180 |
virtual bool do_object_b(oop obj) = 0; |
|
181 |
}; |
|
182 |
||
37106 | 183 |
class AlwaysTrueClosure: public BoolObjectClosure { |
184 |
public: |
|
185 |
bool do_object_b(oop p) { return true; } |
|
186 |
}; |
|
187 |
||
188 |
class AlwaysFalseClosure : public BoolObjectClosure { |
|
189 |
public: |
|
190 |
bool do_object_b(oop p) { return false; } |
|
191 |
}; |
|
192 |
||
1 | 193 |
// Applies an oop closure to all ref fields in objects iterated over in an |
194 |
// object iteration. |
|
195 |
class ObjectToOopClosure: public ObjectClosure { |
|
50752 | 196 |
OopIterateClosure* _cl; |
1 | 197 |
public: |
198 |
void do_object(oop obj); |
|
50752 | 199 |
ObjectToOopClosure(OopIterateClosure* cl) : _cl(cl) {} |
1 | 200 |
}; |
201 |
||
202 |
// SpaceClosure is used for iterating over spaces |
|
203 |
||
204 |
class Space; |
|
205 |
class CompactibleSpace; |
|
206 |
||
207 |
class SpaceClosure : public StackObj { |
|
208 |
public: |
|
209 |
// Called for each space |
|
210 |
virtual void do_space(Space* s) = 0; |
|
211 |
}; |
|
212 |
||
213 |
class CompactibleSpaceClosure : public StackObj { |
|
214 |
public: |
|
215 |
// Called for each compactible space |
|
216 |
virtual void do_space(CompactibleSpace* s) = 0; |
|
217 |
}; |
|
218 |
||
219 |
||
3908
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
220 |
// CodeBlobClosure is used for iterating through code blobs |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
221 |
// in the code cache or on thread stacks |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
222 |
|
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
223 |
class CodeBlobClosure : public Closure { |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
224 |
public: |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
225 |
// Called for each code blob. |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
226 |
virtual void do_code_blob(CodeBlob* cb) = 0; |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
227 |
}; |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
228 |
|
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
229 |
// Applies an oop closure to all ref fields in code blobs |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
230 |
// iterated over in an object iteration. |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
231 |
class CodeBlobToOopClosure : public CodeBlobClosure { |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
232 |
OopClosure* _cl; |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
233 |
bool _fix_relocations; |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
234 |
protected: |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
235 |
void do_nmethod(nmethod* nm); |
3908
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
236 |
public: |
36591
d0622cab5983
8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents:
33226
diff
changeset
|
237 |
// If fix_relocations(), then cl must copy objects to their new location immediately to avoid |
d0622cab5983
8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents:
33226
diff
changeset
|
238 |
// patching nmethods with the old locations. |
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
239 |
CodeBlobToOopClosure(OopClosure* cl, bool fix_relocations) : _cl(cl), _fix_relocations(fix_relocations) {} |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
240 |
virtual void do_code_blob(CodeBlob* cb); |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
241 |
|
36591
d0622cab5983
8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents:
33226
diff
changeset
|
242 |
bool fix_relocations() const { return _fix_relocations; } |
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
243 |
const static bool FixRelocations = true; |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
244 |
}; |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
245 |
|
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
246 |
class MarkingCodeBlobClosure : public CodeBlobToOopClosure { |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
247 |
public: |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
248 |
MarkingCodeBlobClosure(OopClosure* cl, bool fix_relocations) : CodeBlobToOopClosure(cl, fix_relocations) {} |
3908
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
249 |
// Called for each code blob, but at most once per unique blob. |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
250 |
|
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
251 |
virtual void do_code_blob(CodeBlob* cb); |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
252 |
}; |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
253 |
|
53889 | 254 |
class NMethodClosure : public Closure { |
255 |
public: |
|
256 |
virtual void do_nmethod(nmethod* n) = 0; |
|
257 |
}; |
|
258 |
||
1 | 259 |
// MonitorClosure is used for iterating over monitors in the monitors cache |
260 |
||
261 |
class ObjectMonitor; |
|
262 |
||
263 |
class MonitorClosure : public StackObj { |
|
264 |
public: |
|
265 |
// called for each monitor in cache |
|
266 |
virtual void do_monitor(ObjectMonitor* m) = 0; |
|
267 |
}; |
|
268 |
||
269 |
// A closure that is applied without any arguments. |
|
270 |
class VoidClosure : public StackObj { |
|
271 |
public: |
|
272 |
// I would have liked to declare this a pure virtual, but that breaks |
|
273 |
// in mysterious ways, for unknown reasons. |
|
274 |
virtual void do_void(); |
|
275 |
}; |
|
276 |
||
277 |
||
278 |
// YieldClosure is intended for use by iteration loops |
|
279 |
// to incrementalize their work, allowing interleaving |
|
280 |
// of an interruptable task so as to allow other |
|
281 |
// threads to run (which may not otherwise be able to access |
|
282 |
// exclusive resources, for instance). Additionally, the |
|
283 |
// closure also allows for aborting an ongoing iteration |
|
284 |
// by means of checking the return value from the polling |
|
285 |
// call. |
|
286 |
class YieldClosure : public StackObj { |
|
50097
ed8a43d83fcc
8201491: G1 support for java.lang.ref.Reference precleaning
tschatzl
parents:
49827
diff
changeset
|
287 |
public: |
ed8a43d83fcc
8201491: G1 support for java.lang.ref.Reference precleaning
tschatzl
parents:
49827
diff
changeset
|
288 |
virtual bool should_return() = 0; |
ed8a43d83fcc
8201491: G1 support for java.lang.ref.Reference precleaning
tschatzl
parents:
49827
diff
changeset
|
289 |
|
ed8a43d83fcc
8201491: G1 support for java.lang.ref.Reference precleaning
tschatzl
parents:
49827
diff
changeset
|
290 |
// Yield on a fine-grain level. The check in case of not yielding should be very fast. |
ed8a43d83fcc
8201491: G1 support for java.lang.ref.Reference precleaning
tschatzl
parents:
49827
diff
changeset
|
291 |
virtual bool should_return_fine_grain() { return false; } |
1 | 292 |
}; |
293 |
||
294 |
// Abstract closure for serializing data (read or write). |
|
295 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
296 |
class SerializeClosure : public Closure { |
1 | 297 |
public: |
298 |
// Return bool indicating whether closure implements read or write. |
|
299 |
virtual bool reading() const = 0; |
|
300 |
||
301 |
// Read/write the void pointer pointed to by p. |
|
302 |
virtual void do_ptr(void** p) = 0; |
|
303 |
||
37995 | 304 |
// Read/write the 32-bit unsigned integer pointed to by p. |
305 |
virtual void do_u4(u4* p) = 0; |
|
306 |
||
55251 | 307 |
// Read/write the bool pointed to by p. |
308 |
virtual void do_bool(bool* p) = 0; |
|
309 |
||
1 | 310 |
// Read/write the region specified. |
311 |
virtual void do_region(u_char* start, size_t size) = 0; |
|
312 |
||
313 |
// Check/write the tag. If reading, then compare the tag against |
|
314 |
// the passed in value and fail is they don't match. This allows |
|
315 |
// for verification that sections of the serialized data are of the |
|
316 |
// correct length. |
|
317 |
virtual void do_tag(int tag) = 0; |
|
37995 | 318 |
|
49329 | 319 |
// Read/write the oop |
320 |
virtual void do_oop(oop* o) = 0; |
|
321 |
||
37995 | 322 |
bool writing() { |
323 |
return !reading(); |
|
324 |
} |
|
1 | 325 |
}; |
3690 | 326 |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
327 |
class SymbolClosure : public StackObj { |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
328 |
public: |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
329 |
virtual void do_symbol(Symbol**) = 0; |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
330 |
|
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
331 |
// Clear LSB in symbol address; it can be set by CPSlot. |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
332 |
static Symbol* load_symbol(Symbol** p) { |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
333 |
return (Symbol*)(intptr_t(*p) & ~1); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
334 |
} |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
335 |
|
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
336 |
// Store symbol, adjusting new pointer if the original pointer was adjusted |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
337 |
// (symbol references in constant pool slots have their LSB set to 1). |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
338 |
static void store_symbol(Symbol** p, Symbol* sym) { |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
339 |
*p = (Symbol*)(intptr_t(sym) | (intptr_t(*p) & 1)); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
340 |
} |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
341 |
}; |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
342 |
|
50752 | 343 |
// Dispatches to the non-virtual functions if OopClosureType has |
344 |
// a concrete implementation, otherwise a virtual call is taken. |
|
345 |
class Devirtualizer { |
|
30150
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
25492
diff
changeset
|
346 |
public: |
50752 | 347 |
template <typename OopClosureType, typename T> static void do_oop_no_verify(OopClosureType* closure, T* p); |
348 |
template <typename OopClosureType, typename T> static void do_oop(OopClosureType* closure, T* p); |
|
349 |
template <typename OopClosureType> static void do_klass(OopClosureType* closure, Klass* k); |
|
350 |
template <typename OopClosureType> static void do_cld(OopClosureType* closure, ClassLoaderData* cld); |
|
351 |
template <typename OopClosureType> static bool do_metadata(OopClosureType* closure); |
|
30150
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
25492
diff
changeset
|
352 |
}; |
25356
4a4a482298a6
8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents:
23539
diff
changeset
|
353 |
|
50752 | 354 |
class OopIteratorClosureDispatch { |
30150
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
25492
diff
changeset
|
355 |
public: |
50752 | 356 |
template <typename OopClosureType> static void oop_oop_iterate(OopClosureType* cl, oop obj, Klass* klass); |
357 |
template <typename OopClosureType> static void oop_oop_iterate(OopClosureType* cl, oop obj, Klass* klass, MemRegion mr); |
|
358 |
template <typename OopClosureType> static void oop_oop_iterate_backwards(OopClosureType* cl, oop obj, Klass* klass); |
|
30150
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
25492
diff
changeset
|
359 |
}; |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
25492
diff
changeset
|
360 |
|
53244
9807daeb47c4
8216167: Update include guards to reflect correct directories
coleenp
parents:
52141
diff
changeset
|
361 |
#endif // SHARE_MEMORY_ITERATOR_HPP |