Mercurial > hg > truffle
annotate src/share/vm/memory/iterator.hpp @ 14702:d4dd5204c0aa
Merge
author | ehelin |
---|---|
date | Fri, 14 Mar 2014 13:27:18 +0100 |
parents | be0ac0e8f6e7 |
children | 4ca6dc0799b6 5255b195f828 |
rev | line source |
---|---|
0 | 1 /* |
14223
de6a9e811145
8029233: Update copyright year to match last edit in jdk8 hotspot repository for 2013
mikael
parents:
10327
diff
changeset
|
2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. |
0 | 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1190
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1190
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1190
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 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" | |
30 #include "runtime/prefetch.hpp" | |
31 #include "utilities/top.hpp" | |
32 | |
0 | 33 // The following classes are C++ `closures` for iterating over objects, roots and spaces |
34 | |
989
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
356
diff
changeset
|
35 class CodeBlob; |
994
753cf9794df9
6885169: merge of 4957990 and 6863023 causes conflict on do_nmethods
jrose
parents:
993
diff
changeset
|
36 class nmethod; |
0 | 37 class ReferenceProcessor; |
941 | 38 class DataLayout; |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
39 class KlassClosure; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
40 class ClassLoaderData; |
0 | 41 |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
42 // Closure provides abortability. |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
43 |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
44 class Closure : public StackObj { |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
45 protected: |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
46 bool _abort; |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
47 void set_abort() { _abort = true; } |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
48 public: |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
49 Closure() : _abort(false) {} |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
50 // A subtype can use this mechanism to indicate to some iterator mapping |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
51 // functions that the iteration should cease. |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
52 bool abort() { return _abort; } |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
53 void clear_abort() { _abort = false; } |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
54 }; |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
55 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
56 // OopClosure is used for iterating through references to Java objects. |
0 | 57 |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
58 class OopClosure : public Closure { |
0 | 59 public: |
60 virtual void do_oop(oop* o) = 0; | |
61 virtual void do_oop_v(oop* o) { do_oop(o); } | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
62 virtual void do_oop(narrowOop* o) = 0; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
63 virtual void do_oop_v(narrowOop* o) { do_oop(o); } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
64 }; |
935 | 65 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
66 // ExtendedOopClosure adds extra code to be run during oop iterations. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
67 // This is needed by the GC and is extracted to a separate type to not |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
68 // pollute the OopClosure interface. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
69 class ExtendedOopClosure : public OopClosure { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
70 public: |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
71 ReferenceProcessor* _ref_processor; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
72 ExtendedOopClosure(ReferenceProcessor* rp) : _ref_processor(rp) { } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
73 ExtendedOopClosure() : OopClosure(), _ref_processor(NULL) { } |
0 | 74 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
75 // If the do_metadata functions return "true", |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
76 // we invoke the following when running oop_iterate(): |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
77 // |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
78 // 1) do_klass on the header klass pointer. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
79 // 2) do_klass on the klass pointer in the mirrors. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
80 // 3) do_class_loader_data on the class loader data in class loaders. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
81 // |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
82 // The virtual (without suffix) and the non-virtual (with _nv suffix) need |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
83 // to be updated together, or else the devirtualization will break. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
84 // |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
85 // Providing default implementations of the _nv functions unfortunately |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
86 // removes the compile-time safeness, but reduces the clutter for the |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
87 // ExtendedOopClosures that don't need to walk the metadata. Currently, |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
88 // only CMS needs these. |
941 | 89 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
90 virtual bool do_metadata() { return do_metadata_nv(); } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
91 bool do_metadata_v() { return do_metadata(); } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
92 bool do_metadata_nv() { return false; } |
0 | 93 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
94 virtual void do_klass(Klass* k) { do_klass_nv(k); } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
95 void do_klass_v(Klass* k) { do_klass(k); } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
96 void do_klass_nv(Klass* k) { ShouldNotReachHere(); } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
97 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
98 virtual void do_class_loader_data(ClassLoaderData* cld) { ShouldNotReachHere(); } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
99 |
0 | 100 // Controls how prefetching is done for invocations of this closure. |
101 Prefetch::style prefetch_style() { // Note that this is non-virtual. | |
102 return Prefetch::do_none; | |
103 } | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
104 |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
105 // True iff this closure may be safely applied more than once to an oop |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
106 // location without an intervening "major reset" (like the end of a GC). |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
107 virtual bool idempotent() { return false; } |
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
108 virtual bool apply_to_weak_ref_discovered_field() { return false; } |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
109 }; |
935 | 110 |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
111 // Wrapper closure only used to implement oop_iterate_no_header(). |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
112 class NoHeaderExtendedOopClosure : public ExtendedOopClosure { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
113 OopClosure* _wrapped_closure; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
114 public: |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
115 NoHeaderExtendedOopClosure(OopClosure* cl) : _wrapped_closure(cl) {} |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
116 // Warning: this calls the virtual version do_oop in the the wrapped closure. |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
117 void do_oop_nv(oop* p) { _wrapped_closure->do_oop(p); } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
118 void do_oop_nv(narrowOop* p) { _wrapped_closure->do_oop(p); } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
119 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
120 void do_oop(oop* p) { assert(false, "Only the _nv versions should be used"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
121 _wrapped_closure->do_oop(p); } |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
122 void do_oop(narrowOop* p) { assert(false, "Only the _nv versions should be used"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
123 _wrapped_closure->do_oop(p);} |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
124 }; |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
125 |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
126 class KlassClosure : public Closure { |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
127 public: |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
128 virtual void do_klass(Klass* k) = 0; |
0 | 129 }; |
130 | |
14483
be0ac0e8f6e7
8035393: Use CLDClosure instead of CLDToOopClosure in frame::oops_interpreted_do
stefank
parents:
14223
diff
changeset
|
131 class CLDClosure : public Closure { |
be0ac0e8f6e7
8035393: Use CLDClosure instead of CLDToOopClosure in frame::oops_interpreted_do
stefank
parents:
14223
diff
changeset
|
132 public: |
be0ac0e8f6e7
8035393: Use CLDClosure instead of CLDToOopClosure in frame::oops_interpreted_do
stefank
parents:
14223
diff
changeset
|
133 virtual void do_cld(ClassLoaderData* cld) = 0; |
be0ac0e8f6e7
8035393: Use CLDClosure instead of CLDToOopClosure in frame::oops_interpreted_do
stefank
parents:
14223
diff
changeset
|
134 }; |
be0ac0e8f6e7
8035393: Use CLDClosure instead of CLDToOopClosure in frame::oops_interpreted_do
stefank
parents:
14223
diff
changeset
|
135 |
6738
ec98e58952b2
7197350: NPG: jvmtiHeapReferenceCallback receives incorrect reference_kind for system class roots
stefank
parents:
6725
diff
changeset
|
136 class KlassToOopClosure : public KlassClosure { |
ec98e58952b2
7197350: NPG: jvmtiHeapReferenceCallback receives incorrect reference_kind for system class roots
stefank
parents:
6725
diff
changeset
|
137 OopClosure* _oop_closure; |
ec98e58952b2
7197350: NPG: jvmtiHeapReferenceCallback receives incorrect reference_kind for system class roots
stefank
parents:
6725
diff
changeset
|
138 public: |
ec98e58952b2
7197350: NPG: jvmtiHeapReferenceCallback receives incorrect reference_kind for system class roots
stefank
parents:
6725
diff
changeset
|
139 KlassToOopClosure(OopClosure* oop_closure) : _oop_closure(oop_closure) {} |
ec98e58952b2
7197350: NPG: jvmtiHeapReferenceCallback receives incorrect reference_kind for system class roots
stefank
parents:
6725
diff
changeset
|
140 virtual void do_klass(Klass* k); |
ec98e58952b2
7197350: NPG: jvmtiHeapReferenceCallback receives incorrect reference_kind for system class roots
stefank
parents:
6725
diff
changeset
|
141 }; |
ec98e58952b2
7197350: NPG: jvmtiHeapReferenceCallback receives incorrect reference_kind for system class roots
stefank
parents:
6725
diff
changeset
|
142 |
14483
be0ac0e8f6e7
8035393: Use CLDClosure instead of CLDToOopClosure in frame::oops_interpreted_do
stefank
parents:
14223
diff
changeset
|
143 class CLDToOopClosure : public CLDClosure { |
7179
d0aa87f04bd5
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
6738
diff
changeset
|
144 OopClosure* _oop_closure; |
d0aa87f04bd5
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
6738
diff
changeset
|
145 KlassToOopClosure _klass_closure; |
d0aa87f04bd5
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
6738
diff
changeset
|
146 bool _must_claim_cld; |
d0aa87f04bd5
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
6738
diff
changeset
|
147 |
d0aa87f04bd5
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
6738
diff
changeset
|
148 public: |
d0aa87f04bd5
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
6738
diff
changeset
|
149 CLDToOopClosure(OopClosure* oop_closure, bool must_claim_cld = true) : |
d0aa87f04bd5
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
6738
diff
changeset
|
150 _oop_closure(oop_closure), |
d0aa87f04bd5
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
6738
diff
changeset
|
151 _klass_closure(oop_closure), |
d0aa87f04bd5
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
6738
diff
changeset
|
152 _must_claim_cld(must_claim_cld) {} |
d0aa87f04bd5
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
6738
diff
changeset
|
153 |
d0aa87f04bd5
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
6738
diff
changeset
|
154 void do_cld(ClassLoaderData* cld); |
d0aa87f04bd5
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
6738
diff
changeset
|
155 }; |
d0aa87f04bd5
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
6738
diff
changeset
|
156 |
0 | 157 // ObjectClosure is used for iterating through an object space |
158 | |
342
37f87013dfd8
6711316: Open source the Garbage-First garbage collector
ysr
parents:
113
diff
changeset
|
159 class ObjectClosure : public Closure { |
0 | 160 public: |
161 // Called for each object. | |
162 virtual void do_object(oop obj) = 0; | |
163 }; | |
164 | |
165 | |
10327
001ec9515f84
8014277: Remove ObjectClosure as base class for BoolObjectClosure
ehelin
parents:
7179
diff
changeset
|
166 class BoolObjectClosure : public Closure { |
0 | 167 public: |
168 virtual bool do_object_b(oop obj) = 0; | |
169 }; | |
170 | |
171 // Applies an oop closure to all ref fields in objects iterated over in an | |
172 // object iteration. | |
173 class ObjectToOopClosure: public ObjectClosure { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
174 ExtendedOopClosure* _cl; |
0 | 175 public: |
176 void do_object(oop obj); | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
177 ObjectToOopClosure(ExtendedOopClosure* cl) : _cl(cl) {} |
0 | 178 }; |
179 | |
180 // A version of ObjectClosure with "memory" (see _previous_address below) | |
181 class UpwardsObjectClosure: public BoolObjectClosure { | |
182 HeapWord* _previous_address; | |
183 public: | |
184 UpwardsObjectClosure() : _previous_address(NULL) { } | |
185 void set_previous(HeapWord* addr) { _previous_address = addr; } | |
186 HeapWord* previous() { return _previous_address; } | |
187 // A return value of "true" can be used by the caller to decide | |
188 // if this object's end should *NOT* be recorded in | |
189 // _previous_address above. | |
190 virtual bool do_object_bm(oop obj, MemRegion mr) = 0; | |
191 }; | |
192 | |
193 // A version of ObjectClosure that is expected to be robust | |
194 // in the face of possibly uninitialized objects. | |
195 class ObjectClosureCareful : public ObjectClosure { | |
196 public: | |
197 virtual size_t do_object_careful_m(oop p, MemRegion mr) = 0; | |
198 virtual size_t do_object_careful(oop p) = 0; | |
199 }; | |
200 | |
201 // The following are used in CompactibleFreeListSpace and | |
202 // ConcurrentMarkSweepGeneration. | |
203 | |
204 // Blk closure (abstract class) | |
205 class BlkClosure : public StackObj { | |
206 public: | |
207 virtual size_t do_blk(HeapWord* addr) = 0; | |
208 }; | |
209 | |
210 // A version of BlkClosure that is expected to be robust | |
211 // in the face of possibly uninitialized objects. | |
212 class BlkClosureCareful : public BlkClosure { | |
213 public: | |
214 size_t do_blk(HeapWord* addr) { | |
215 guarantee(false, "call do_blk_careful instead"); | |
216 return 0; | |
217 } | |
218 virtual size_t do_blk_careful(HeapWord* addr) = 0; | |
219 }; | |
220 | |
221 // SpaceClosure is used for iterating over spaces | |
222 | |
223 class Space; | |
224 class CompactibleSpace; | |
225 | |
226 class SpaceClosure : public StackObj { | |
227 public: | |
228 // Called for each space | |
229 virtual void do_space(Space* s) = 0; | |
230 }; | |
231 | |
232 class CompactibleSpaceClosure : public StackObj { | |
233 public: | |
234 // Called for each compactible space | |
235 virtual void do_space(CompactibleSpace* s) = 0; | |
236 }; | |
237 | |
238 | |
989
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
356
diff
changeset
|
239 // CodeBlobClosure is used for iterating through code blobs |
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
356
diff
changeset
|
240 // in the code cache or on thread stacks |
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
356
diff
changeset
|
241 |
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
356
diff
changeset
|
242 class CodeBlobClosure : public Closure { |
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
356
diff
changeset
|
243 public: |
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
356
diff
changeset
|
244 // Called for each code blob. |
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
356
diff
changeset
|
245 virtual void do_code_blob(CodeBlob* cb) = 0; |
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
356
diff
changeset
|
246 }; |
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
356
diff
changeset
|
247 |
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
356
diff
changeset
|
248 |
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
356
diff
changeset
|
249 class MarkingCodeBlobClosure : public CodeBlobClosure { |
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
356
diff
changeset
|
250 public: |
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
356
diff
changeset
|
251 // Called for each code blob, but at most once per unique blob. |
994
753cf9794df9
6885169: merge of 4957990 and 6863023 causes conflict on do_nmethods
jrose
parents:
993
diff
changeset
|
252 virtual void do_newly_marked_nmethod(nmethod* nm) = 0; |
989
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
356
diff
changeset
|
253 |
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
356
diff
changeset
|
254 virtual void do_code_blob(CodeBlob* cb); |
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
356
diff
changeset
|
255 // = { if (!nmethod(cb)->test_set_oops_do_mark()) do_newly_marked_nmethod(cb); } |
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
356
diff
changeset
|
256 |
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
356
diff
changeset
|
257 class MarkScope : public StackObj { |
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
356
diff
changeset
|
258 protected: |
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
356
diff
changeset
|
259 bool _active; |
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
356
diff
changeset
|
260 public: |
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
356
diff
changeset
|
261 MarkScope(bool activate = true); |
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
356
diff
changeset
|
262 // = { if (active) nmethod::oops_do_marking_prologue(); } |
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
356
diff
changeset
|
263 ~MarkScope(); |
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
356
diff
changeset
|
264 // = { if (active) nmethod::oops_do_marking_epilogue(); } |
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
356
diff
changeset
|
265 }; |
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
356
diff
changeset
|
266 }; |
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
356
diff
changeset
|
267 |
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
356
diff
changeset
|
268 |
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
356
diff
changeset
|
269 // Applies an oop closure to all ref fields in code blobs |
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
356
diff
changeset
|
270 // iterated over in an object iteration. |
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
356
diff
changeset
|
271 class CodeBlobToOopClosure: public MarkingCodeBlobClosure { |
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
356
diff
changeset
|
272 OopClosure* _cl; |
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
356
diff
changeset
|
273 bool _do_marking; |
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
356
diff
changeset
|
274 public: |
994
753cf9794df9
6885169: merge of 4957990 and 6863023 causes conflict on do_nmethods
jrose
parents:
993
diff
changeset
|
275 virtual void do_newly_marked_nmethod(nmethod* cb); |
989
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
356
diff
changeset
|
276 // = { cb->oops_do(_cl); } |
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
356
diff
changeset
|
277 virtual void do_code_blob(CodeBlob* cb); |
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
356
diff
changeset
|
278 // = { if (_do_marking) super::do_code_blob(cb); else cb->oops_do(_cl); } |
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
356
diff
changeset
|
279 CodeBlobToOopClosure(OopClosure* cl, bool do_marking) |
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
356
diff
changeset
|
280 : _cl(cl), _do_marking(do_marking) {} |
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
356
diff
changeset
|
281 }; |
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
356
diff
changeset
|
282 |
148e5441d916
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
356
diff
changeset
|
283 |
0 | 284 |
285 // MonitorClosure is used for iterating over monitors in the monitors cache | |
286 | |
287 class ObjectMonitor; | |
288 | |
289 class MonitorClosure : public StackObj { | |
290 public: | |
291 // called for each monitor in cache | |
292 virtual void do_monitor(ObjectMonitor* m) = 0; | |
293 }; | |
294 | |
295 // A closure that is applied without any arguments. | |
296 class VoidClosure : public StackObj { | |
297 public: | |
298 // I would have liked to declare this a pure virtual, but that breaks | |
299 // in mysterious ways, for unknown reasons. | |
300 virtual void do_void(); | |
301 }; | |
302 | |
303 | |
304 // YieldClosure is intended for use by iteration loops | |
305 // to incrementalize their work, allowing interleaving | |
306 // of an interruptable task so as to allow other | |
307 // threads to run (which may not otherwise be able to access | |
308 // exclusive resources, for instance). Additionally, the | |
309 // closure also allows for aborting an ongoing iteration | |
310 // by means of checking the return value from the polling | |
311 // call. | |
312 class YieldClosure : public StackObj { | |
313 public: | |
314 virtual bool should_return() = 0; | |
315 }; | |
316 | |
317 // Abstract closure for serializing data (read or write). | |
318 | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
2426
diff
changeset
|
319 class SerializeClosure : public Closure { |
0 | 320 public: |
321 // Return bool indicating whether closure implements read or write. | |
322 virtual bool reading() const = 0; | |
323 | |
324 // Read/write the void pointer pointed to by p. | |
325 virtual void do_ptr(void** p) = 0; | |
326 | |
327 // Read/write the region specified. | |
328 virtual void do_region(u_char* start, size_t size) = 0; | |
329 | |
330 // Check/write the tag. If reading, then compare the tag against | |
331 // the passed in value and fail is they don't match. This allows | |
332 // for verification that sections of the serialized data are of the | |
333 // correct length. | |
334 virtual void do_tag(int tag) = 0; | |
335 }; | |
935 | 336 |
2177
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
337 class SymbolClosure : public StackObj { |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
338 public: |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
339 virtual void do_symbol(Symbol**) = 0; |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
340 |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
341 // Clear LSB in symbol address; it can be set by CPSlot. |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
342 static Symbol* load_symbol(Symbol** p) { |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
343 return (Symbol*)(intptr_t(*p) & ~1); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
344 } |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
345 |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
346 // Store symbol, adjusting new pointer if the original pointer was adjusted |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
347 // (symbol references in constant pool slots have their LSB set to 1). |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
348 static void store_symbol(Symbol** p, Symbol* sym) { |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
349 *p = (Symbol*)(intptr_t(sym) | (intptr_t(*p) & 1)); |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
350 } |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
351 }; |
3582bf76420e
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
1972
diff
changeset
|
352 |
1972 | 353 #endif // SHARE_VM_MEMORY_ITERATOR_HPP |