author | stefank |
Sat, 26 May 2018 06:59:49 +0200 | |
changeset 50752 | 9d62da00bf15 |
parent 50097 | ed8a43d83fcc |
child 50800 | 6da12aa23b88 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
49329 | 2 |
* Copyright (c) 1997, 2018, 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 |
||
7397 | 25 |
#ifndef SHARE_VM_MEMORY_ITERATOR_HPP |
26 |
#define SHARE_VM_MEMORY_ITERATOR_HPP |
|
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; |
1 | 39 |
|
23538 | 40 |
// 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
|
41 |
|
23538 | 42 |
class Closure : public StackObj { }; |
1374
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
43 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
44 |
// 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
|
45 |
class OopClosure : public Closure { |
1 | 46 |
public: |
47 |
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
|
48 |
virtual void do_oop(narrowOop* o) = 0; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
49 |
}; |
3690 | 50 |
|
47676
b1c020fc35a3
8189748: More precise closures for WeakProcessor::weak_oops_do calls
stefank
parents:
47580
diff
changeset
|
51 |
class DoNothingClosure : public OopClosure { |
b1c020fc35a3
8189748: More precise closures for WeakProcessor::weak_oops_do calls
stefank
parents:
47580
diff
changeset
|
52 |
public: |
b1c020fc35a3
8189748: More precise closures for WeakProcessor::weak_oops_do calls
stefank
parents:
47580
diff
changeset
|
53 |
virtual void do_oop(oop* p) {} |
b1c020fc35a3
8189748: More precise closures for WeakProcessor::weak_oops_do calls
stefank
parents:
47580
diff
changeset
|
54 |
virtual void do_oop(narrowOop* p) {} |
b1c020fc35a3
8189748: More precise closures for WeakProcessor::weak_oops_do calls
stefank
parents:
47580
diff
changeset
|
55 |
}; |
b1c020fc35a3
8189748: More precise closures for WeakProcessor::weak_oops_do calls
stefank
parents:
47580
diff
changeset
|
56 |
extern DoNothingClosure do_nothing_cl; |
b1c020fc35a3
8189748: More precise closures for WeakProcessor::weak_oops_do calls
stefank
parents:
47580
diff
changeset
|
57 |
|
50752 | 58 |
// 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
|
59 |
// 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
|
60 |
// pollute the OopClosure interface. |
50752 | 61 |
class OopIterateClosure : public OopClosure { |
33226
19cb9b844190
8139341: Hide ExtendedOopClosure::_ref_processor
kbarrett
parents:
32606
diff
changeset
|
62 |
private: |
49827 | 63 |
ReferenceDiscoverer* _ref_discoverer; |
33226
19cb9b844190
8139341: Hide ExtendedOopClosure::_ref_processor
kbarrett
parents:
32606
diff
changeset
|
64 |
|
19cb9b844190
8139341: Hide ExtendedOopClosure::_ref_processor
kbarrett
parents:
32606
diff
changeset
|
65 |
protected: |
50752 | 66 |
OopIterateClosure(ReferenceDiscoverer* rd) : _ref_discoverer(rd) { } |
67 |
OopIterateClosure() : _ref_discoverer(NULL) { } |
|
68 |
~OopIterateClosure() { } |
|
33226
19cb9b844190
8139341: Hide ExtendedOopClosure::_ref_processor
kbarrett
parents:
32606
diff
changeset
|
69 |
|
49827 | 70 |
void set_ref_discoverer_internal(ReferenceDiscoverer* rd) { _ref_discoverer = rd; } |
33226
19cb9b844190
8139341: Hide ExtendedOopClosure::_ref_processor
kbarrett
parents:
32606
diff
changeset
|
71 |
|
19cb9b844190
8139341: Hide ExtendedOopClosure::_ref_processor
kbarrett
parents:
32606
diff
changeset
|
72 |
public: |
49827 | 73 |
ReferenceDiscoverer* ref_discoverer() const { return _ref_discoverer; } |
1 | 74 |
|
46415
7d5a286cdf89
8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents:
37995
diff
changeset
|
75 |
// 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
|
76 |
// the below enum describes the different alternatives. |
7d5a286cdf89
8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents:
37995
diff
changeset
|
77 |
enum ReferenceIterationMode { |
46445
825b002e05ae
8138888: Remove ExtendedOopClosure::apply_to_weak_ref_discovered_field
sjohanss
parents:
46415
diff
changeset
|
78 |
DO_DISCOVERY, // Apply closure and discover references |
825b002e05ae
8138888: Remove ExtendedOopClosure::apply_to_weak_ref_discovered_field
sjohanss
parents:
46415
diff
changeset
|
79 |
DO_DISCOVERED_AND_DISCOVERY, // Apply closure to discovered field and do discovery |
825b002e05ae
8138888: Remove ExtendedOopClosure::apply_to_weak_ref_discovered_field
sjohanss
parents:
46415
diff
changeset
|
80 |
DO_FIELDS // Apply closure to all fields |
46415
7d5a286cdf89
8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents:
37995
diff
changeset
|
81 |
}; |
7d5a286cdf89
8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents:
37995
diff
changeset
|
82 |
|
7d5a286cdf89
8138737: Remove oop_ms_adjust_pointers and use oop_iterate instead
sjohanss
parents:
37995
diff
changeset
|
83 |
// 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
|
84 |
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
|
85 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
86 |
// If the do_metadata functions return "true", |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
87 |
// we invoke the following when running oop_iterate(): |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
88 |
// |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
89 |
// 1) do_klass on the header klass pointer. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
90 |
// 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
|
91 |
// 3) do_cld on the class loader data in class loaders. |
3696 | 92 |
|
50752 | 93 |
virtual bool do_metadata() = 0; |
94 |
virtual void do_klass(Klass* k) = 0; |
|
95 |
virtual void do_cld(ClassLoaderData* cld) = 0; |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
96 |
|
1374
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
97 |
// True iff this closure may be safely applied more than once to an oop |
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
98 |
// location without an intervening "major reset" (like the end of a GC). |
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
99 |
virtual bool idempotent() { return false; } |
30150
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
25492
diff
changeset
|
100 |
|
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
25492
diff
changeset
|
101 |
#ifdef ASSERT |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
25492
diff
changeset
|
102 |
// 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
|
103 |
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
|
104 |
|
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
25492
diff
changeset
|
105 |
// 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
|
106 |
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
|
107 |
#endif |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
108 |
}; |
3690 | 109 |
|
50752 | 110 |
// An OopIterateClosure that can be used when there's no need to visit the Metadata. |
111 |
class BasicOopIterateClosure : public OopIterateClosure { |
|
112 |
public: |
|
113 |
BasicOopIterateClosure(ReferenceDiscoverer* rd = NULL) : OopIterateClosure(rd) {} |
|
114 |
||
115 |
virtual bool do_metadata() { return false; } |
|
116 |
virtual void do_klass(Klass* k) { ShouldNotReachHere(); } |
|
117 |
virtual void do_cld(ClassLoaderData* cld) { ShouldNotReachHere(); } |
|
118 |
}; |
|
119 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
120 |
// Wrapper closure only used to implement oop_iterate_no_header(). |
50752 | 121 |
class NoHeaderExtendedOopClosure : public BasicOopIterateClosure { |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
122 |
OopClosure* _wrapped_closure; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
123 |
public: |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
124 |
NoHeaderExtendedOopClosure(OopClosure* cl) : _wrapped_closure(cl) {} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
125 |
// Warning: this calls the virtual version do_oop in the the wrapped closure. |
50752 | 126 |
virtual void do_oop(oop* p) { _wrapped_closure->do_oop(p); } |
127 |
virtual void do_oop(narrowOop* p) { _wrapped_closure->do_oop(p); } |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
128 |
}; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
129 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
130 |
class KlassClosure : public Closure { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
131 |
public: |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
132 |
virtual void do_klass(Klass* k) = 0; |
1 | 133 |
}; |
134 |
||
22899
e2a6bf7f343a
8035393: Use CLDClosure instead of CLDToOopClosure in frame::oops_interpreted_do
stefank
parents:
22234
diff
changeset
|
135 |
class CLDClosure : public Closure { |
e2a6bf7f343a
8035393: Use CLDClosure instead of CLDToOopClosure in frame::oops_interpreted_do
stefank
parents:
22234
diff
changeset
|
136 |
public: |
e2a6bf7f343a
8035393: Use CLDClosure instead of CLDToOopClosure in frame::oops_interpreted_do
stefank
parents:
22234
diff
changeset
|
137 |
virtual void do_cld(ClassLoaderData* cld) = 0; |
e2a6bf7f343a
8035393: Use CLDClosure instead of CLDToOopClosure in frame::oops_interpreted_do
stefank
parents:
22234
diff
changeset
|
138 |
}; |
e2a6bf7f343a
8035393: Use CLDClosure instead of CLDToOopClosure in frame::oops_interpreted_do
stefank
parents:
22234
diff
changeset
|
139 |
|
13741
e4395deb8597
7197350: NPG: jvmtiHeapReferenceCallback receives incorrect reference_kind for system class roots
stefank
parents:
13728
diff
changeset
|
140 |
|
22899
e2a6bf7f343a
8035393: Use CLDClosure instead of CLDToOopClosure in frame::oops_interpreted_do
stefank
parents:
22234
diff
changeset
|
141 |
class CLDToOopClosure : public CLDClosure { |
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
142 |
OopClosure* _oop_closure; |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
143 |
bool _must_claim_cld; |
14582
490bb6c0df7c
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
13741
diff
changeset
|
144 |
|
490bb6c0df7c
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
13741
diff
changeset
|
145 |
public: |
490bb6c0df7c
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
13741
diff
changeset
|
146 |
CLDToOopClosure(OopClosure* oop_closure, bool must_claim_cld = true) : |
490bb6c0df7c
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
13741
diff
changeset
|
147 |
_oop_closure(oop_closure), |
490bb6c0df7c
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
13741
diff
changeset
|
148 |
_must_claim_cld(must_claim_cld) {} |
490bb6c0df7c
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
13741
diff
changeset
|
149 |
|
490bb6c0df7c
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
13741
diff
changeset
|
150 |
void do_cld(ClassLoaderData* cld); |
490bb6c0df7c
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
13741
diff
changeset
|
151 |
}; |
490bb6c0df7c
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
13741
diff
changeset
|
152 |
|
25356
4a4a482298a6
8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents:
23539
diff
changeset
|
153 |
// The base class for all concurrent marking closures, |
4a4a482298a6
8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents:
23539
diff
changeset
|
154 |
// that participates in class unloading. |
4a4a482298a6
8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents:
23539
diff
changeset
|
155 |
// It's used to proxy through the metadata to the oops defined in them. |
50752 | 156 |
class MetadataVisitingOopIterateClosure: public OopIterateClosure { |
25356
4a4a482298a6
8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents:
23539
diff
changeset
|
157 |
public: |
50752 | 158 |
MetadataVisitingOopIterateClosure(ReferenceDiscoverer* rd = NULL) : OopIterateClosure(rd) { } |
25356
4a4a482298a6
8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents:
23539
diff
changeset
|
159 |
|
50752 | 160 |
virtual bool do_metadata() { return true; } |
161 |
virtual void do_klass(Klass* k); |
|
162 |
virtual void do_cld(ClassLoaderData* cld); |
|
25356
4a4a482298a6
8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents:
23539
diff
changeset
|
163 |
}; |
4a4a482298a6
8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents:
23539
diff
changeset
|
164 |
|
1 | 165 |
// ObjectClosure is used for iterating through an object space |
166 |
||
1374
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
167 |
class ObjectClosure : public Closure { |
1 | 168 |
public: |
169 |
// Called for each object. |
|
170 |
virtual void do_object(oop obj) = 0; |
|
171 |
}; |
|
172 |
||
173 |
||
17625
3e91c67ddece
8014277: Remove ObjectClosure as base class for BoolObjectClosure
ehelin
parents:
14582
diff
changeset
|
174 |
class BoolObjectClosure : public Closure { |
1 | 175 |
public: |
176 |
virtual bool do_object_b(oop obj) = 0; |
|
177 |
}; |
|
178 |
||
37106 | 179 |
class AlwaysTrueClosure: public BoolObjectClosure { |
180 |
public: |
|
181 |
bool do_object_b(oop p) { return true; } |
|
182 |
}; |
|
183 |
||
184 |
class AlwaysFalseClosure : public BoolObjectClosure { |
|
185 |
public: |
|
186 |
bool do_object_b(oop p) { return false; } |
|
187 |
}; |
|
188 |
||
1 | 189 |
// Applies an oop closure to all ref fields in objects iterated over in an |
190 |
// object iteration. |
|
191 |
class ObjectToOopClosure: public ObjectClosure { |
|
50752 | 192 |
OopIterateClosure* _cl; |
1 | 193 |
public: |
194 |
void do_object(oop obj); |
|
50752 | 195 |
ObjectToOopClosure(OopIterateClosure* cl) : _cl(cl) {} |
1 | 196 |
}; |
197 |
||
198 |
// A version of ObjectClosure that is expected to be robust |
|
199 |
// in the face of possibly uninitialized objects. |
|
200 |
class ObjectClosureCareful : public ObjectClosure { |
|
201 |
public: |
|
202 |
virtual size_t do_object_careful_m(oop p, MemRegion mr) = 0; |
|
203 |
virtual size_t do_object_careful(oop p) = 0; |
|
204 |
}; |
|
205 |
||
206 |
// The following are used in CompactibleFreeListSpace and |
|
207 |
// ConcurrentMarkSweepGeneration. |
|
208 |
||
209 |
// Blk closure (abstract class) |
|
210 |
class BlkClosure : public StackObj { |
|
211 |
public: |
|
212 |
virtual size_t do_blk(HeapWord* addr) = 0; |
|
213 |
}; |
|
214 |
||
215 |
// A version of BlkClosure that is expected to be robust |
|
216 |
// in the face of possibly uninitialized objects. |
|
217 |
class BlkClosureCareful : public BlkClosure { |
|
218 |
public: |
|
219 |
size_t do_blk(HeapWord* addr) { |
|
220 |
guarantee(false, "call do_blk_careful instead"); |
|
221 |
return 0; |
|
222 |
} |
|
223 |
virtual size_t do_blk_careful(HeapWord* addr) = 0; |
|
224 |
}; |
|
225 |
||
226 |
// SpaceClosure is used for iterating over spaces |
|
227 |
||
228 |
class Space; |
|
229 |
class CompactibleSpace; |
|
230 |
||
231 |
class SpaceClosure : public StackObj { |
|
232 |
public: |
|
233 |
// Called for each space |
|
234 |
virtual void do_space(Space* s) = 0; |
|
235 |
}; |
|
236 |
||
237 |
class CompactibleSpaceClosure : public StackObj { |
|
238 |
public: |
|
239 |
// Called for each compactible space |
|
240 |
virtual void do_space(CompactibleSpace* s) = 0; |
|
241 |
}; |
|
242 |
||
243 |
||
3908
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
244 |
// 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
|
245 |
// 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
|
246 |
|
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
247 |
class CodeBlobClosure : public Closure { |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
248 |
public: |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
249 |
// Called for each code blob. |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
250 |
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
|
251 |
}; |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
252 |
|
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
253 |
// 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
|
254 |
// iterated over in an object iteration. |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
255 |
class CodeBlobToOopClosure : public CodeBlobClosure { |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
256 |
OopClosure* _cl; |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
257 |
bool _fix_relocations; |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
258 |
protected: |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
259 |
void do_nmethod(nmethod* nm); |
3908
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
260 |
public: |
36591
d0622cab5983
8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents:
33226
diff
changeset
|
261 |
// 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
|
262 |
// patching nmethods with the old locations. |
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
263 |
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
|
264 |
virtual void do_code_blob(CodeBlob* cb); |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
265 |
|
36591
d0622cab5983
8150013: ParNew: Prune nmethods scavengable list.
cvarming
parents:
33226
diff
changeset
|
266 |
bool fix_relocations() const { return _fix_relocations; } |
25492
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
267 |
const static bool FixRelocations = true; |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
268 |
}; |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
269 |
|
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
270 |
class MarkingCodeBlobClosure : public CodeBlobToOopClosure { |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
271 |
public: |
d27050bdfb04
8049421: G1 Class Unloading after completing a concurrent mark cycle
stefank
parents:
25491
diff
changeset
|
272 |
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
|
273 |
// 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
|
274 |
|
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
275 |
virtual void do_code_blob(CodeBlob* cb); |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
276 |
}; |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
277 |
|
1 | 278 |
// MonitorClosure is used for iterating over monitors in the monitors cache |
279 |
||
280 |
class ObjectMonitor; |
|
281 |
||
282 |
class MonitorClosure : public StackObj { |
|
283 |
public: |
|
284 |
// called for each monitor in cache |
|
285 |
virtual void do_monitor(ObjectMonitor* m) = 0; |
|
286 |
}; |
|
287 |
||
288 |
// A closure that is applied without any arguments. |
|
289 |
class VoidClosure : public StackObj { |
|
290 |
public: |
|
291 |
// I would have liked to declare this a pure virtual, but that breaks |
|
292 |
// in mysterious ways, for unknown reasons. |
|
293 |
virtual void do_void(); |
|
294 |
}; |
|
295 |
||
296 |
||
297 |
// YieldClosure is intended for use by iteration loops |
|
298 |
// to incrementalize their work, allowing interleaving |
|
299 |
// of an interruptable task so as to allow other |
|
300 |
// threads to run (which may not otherwise be able to access |
|
301 |
// exclusive resources, for instance). Additionally, the |
|
302 |
// closure also allows for aborting an ongoing iteration |
|
303 |
// by means of checking the return value from the polling |
|
304 |
// call. |
|
305 |
class YieldClosure : public StackObj { |
|
50097
ed8a43d83fcc
8201491: G1 support for java.lang.ref.Reference precleaning
tschatzl
parents:
49827
diff
changeset
|
306 |
public: |
ed8a43d83fcc
8201491: G1 support for java.lang.ref.Reference precleaning
tschatzl
parents:
49827
diff
changeset
|
307 |
virtual bool should_return() = 0; |
ed8a43d83fcc
8201491: G1 support for java.lang.ref.Reference precleaning
tschatzl
parents:
49827
diff
changeset
|
308 |
|
ed8a43d83fcc
8201491: G1 support for java.lang.ref.Reference precleaning
tschatzl
parents:
49827
diff
changeset
|
309 |
// 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
|
310 |
virtual bool should_return_fine_grain() { return false; } |
1 | 311 |
}; |
312 |
||
313 |
// Abstract closure for serializing data (read or write). |
|
314 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
315 |
class SerializeClosure : public Closure { |
1 | 316 |
public: |
317 |
// Return bool indicating whether closure implements read or write. |
|
318 |
virtual bool reading() const = 0; |
|
319 |
||
320 |
// Read/write the void pointer pointed to by p. |
|
321 |
virtual void do_ptr(void** p) = 0; |
|
322 |
||
37995 | 323 |
// Read/write the 32-bit unsigned integer pointed to by p. |
324 |
virtual void do_u4(u4* p) = 0; |
|
325 |
||
1 | 326 |
// Read/write the region specified. |
327 |
virtual void do_region(u_char* start, size_t size) = 0; |
|
328 |
||
329 |
// Check/write the tag. If reading, then compare the tag against |
|
330 |
// the passed in value and fail is they don't match. This allows |
|
331 |
// for verification that sections of the serialized data are of the |
|
332 |
// correct length. |
|
333 |
virtual void do_tag(int tag) = 0; |
|
37995 | 334 |
|
49329 | 335 |
// Read/write the oop |
336 |
virtual void do_oop(oop* o) = 0; |
|
337 |
||
37995 | 338 |
bool writing() { |
339 |
return !reading(); |
|
340 |
} |
|
1 | 341 |
}; |
3690 | 342 |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
343 |
class SymbolClosure : public StackObj { |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
344 |
public: |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
345 |
virtual void do_symbol(Symbol**) = 0; |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
346 |
|
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
347 |
// 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
|
348 |
static Symbol* load_symbol(Symbol** p) { |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
349 |
return (Symbol*)(intptr_t(*p) & ~1); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
350 |
} |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
351 |
|
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
352 |
// 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
|
353 |
// (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
|
354 |
static void store_symbol(Symbol** p, Symbol* sym) { |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
355 |
*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
|
356 |
} |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
357 |
}; |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
358 |
|
50752 | 359 |
// Dispatches to the non-virtual functions if OopClosureType has |
360 |
// a concrete implementation, otherwise a virtual call is taken. |
|
361 |
class Devirtualizer { |
|
30150
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
25492
diff
changeset
|
362 |
public: |
50752 | 363 |
template <typename OopClosureType, typename T> static void do_oop_no_verify(OopClosureType* closure, T* p); |
364 |
template <typename OopClosureType, typename T> static void do_oop(OopClosureType* closure, T* p); |
|
365 |
template <typename OopClosureType> static void do_klass(OopClosureType* closure, Klass* k); |
|
366 |
template <typename OopClosureType> static void do_cld(OopClosureType* closure, ClassLoaderData* cld); |
|
367 |
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
|
368 |
}; |
25356
4a4a482298a6
8046670: Make CMS metadata aware closures applicable for other collectors
stefank
parents:
23539
diff
changeset
|
369 |
|
50752 | 370 |
class OopIteratorClosureDispatch { |
30150
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
25492
diff
changeset
|
371 |
public: |
50752 | 372 |
template <typename OopClosureType> static void oop_oop_iterate(OopClosureType* cl, oop obj, Klass* klass); |
373 |
template <typename OopClosureType> static void oop_oop_iterate(OopClosureType* cl, oop obj, Klass* klass, MemRegion mr); |
|
374 |
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
|
375 |
}; |
d9c940aa42ef
8075955: Replace the macro based implementation of oop_oop_iterate with a template based solution
stefank
parents:
25492
diff
changeset
|
376 |
|
7397 | 377 |
#endif // SHARE_VM_MEMORY_ITERATOR_HPP |