author | trims |
Tue, 05 Apr 2011 14:12:31 -0700 | |
changeset 8921 | 14bfe81f2a9d |
parent 8076 | 96d498ec7ae1 |
child 13728 | 882756847a04 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
8921
14bfe81f2a9d
7010070: Update all 2010 Oracle-changed OpenJDK files to have the proper copyright dates - second pass
trims
parents:
8076
diff
changeset
|
2 |
* Copyright (c) 1997, 2011, 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" |
|
30 |
#include "runtime/prefetch.hpp" |
|
31 |
#include "utilities/top.hpp" |
|
32 |
||
1 | 33 |
// The following classes are C++ `closures` for iterating over objects, roots and spaces |
34 |
||
3908
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
35 |
class CodeBlob; |
3913
e049e6b81e11
6885169: merge of 4957990 and 6863023 causes conflict on do_nmethods
jrose
parents:
3912
diff
changeset
|
36 |
class nmethod; |
1 | 37 |
class ReferenceProcessor; |
3696 | 38 |
class DataLayout; |
1 | 39 |
|
1374
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
40 |
// Closure provides abortability. |
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
41 |
|
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
42 |
class Closure : public StackObj { |
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
43 |
protected: |
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
44 |
bool _abort; |
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
45 |
void set_abort() { _abort = true; } |
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
46 |
public: |
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
47 |
Closure() : _abort(false) {} |
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
48 |
// A subtype can use this mechanism to indicate to some iterator mapping |
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
49 |
// functions that the iteration should cease. |
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
50 |
bool abort() { return _abort; } |
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
51 |
void clear_abort() { _abort = false; } |
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
52 |
}; |
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
53 |
|
1 | 54 |
// OopClosure is used for iterating through roots (oop*) |
55 |
||
1374
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
56 |
class OopClosure : public Closure { |
1 | 57 |
public: |
58 |
ReferenceProcessor* _ref_processor; |
|
59 |
OopClosure(ReferenceProcessor* rp) : _ref_processor(rp) { } |
|
60 |
OopClosure() : _ref_processor(NULL) { } |
|
61 |
virtual void do_oop(oop* o) = 0; |
|
62 |
virtual void do_oop_v(oop* o) { do_oop(o); } |
|
360
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
63 |
virtual void do_oop(narrowOop* o) = 0; |
21d113ecbf6a
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
1
diff
changeset
|
64 |
virtual void do_oop_v(narrowOop* o) { do_oop(o); } |
1 | 65 |
|
66 |
// In support of post-processing of weak links of KlassKlass objects; |
|
67 |
// see KlassKlass::oop_oop_iterate(). |
|
3690 | 68 |
|
69 |
virtual const bool should_remember_klasses() const { |
|
70 |
assert(!must_remember_klasses(), "Should have overriden this method."); |
|
71 |
return false; |
|
72 |
} |
|
73 |
||
1 | 74 |
virtual void remember_klass(Klass* k) { /* do nothing */ } |
75 |
||
3696 | 76 |
// In support of post-processing of weak references in |
77 |
// ProfileData (MethodDataOop) objects; see, for example, |
|
78 |
// VirtualCallData::oop_iterate(). |
|
79 |
virtual const bool should_remember_mdo() const { return false; } |
|
80 |
virtual void remember_mdo(DataLayout* v) { /* do nothing */ } |
|
81 |
||
1 | 82 |
// The methods below control how object iterations invoking this closure |
83 |
// should be performed: |
|
84 |
||
85 |
// If "true", invoke on header klass field. |
|
86 |
bool do_header() { return true; } // Note that this is non-virtual. |
|
87 |
// Controls how prefetching is done for invocations of this closure. |
|
88 |
Prefetch::style prefetch_style() { // Note that this is non-virtual. |
|
89 |
return Prefetch::do_none; |
|
90 |
} |
|
1374
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
91 |
|
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
92 |
// 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
|
93 |
// 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
|
94 |
virtual bool idempotent() { return false; } |
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
95 |
virtual bool apply_to_weak_ref_discovered_field() { return false; } |
3690 | 96 |
|
97 |
#ifdef ASSERT |
|
98 |
static bool _must_remember_klasses; |
|
99 |
static bool must_remember_klasses(); |
|
100 |
static void set_must_remember_klasses(bool v); |
|
101 |
#endif |
|
1 | 102 |
}; |
103 |
||
104 |
// ObjectClosure is used for iterating through an object space |
|
105 |
||
1374
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
106 |
class ObjectClosure : public Closure { |
1 | 107 |
public: |
108 |
// Called for each object. |
|
109 |
virtual void do_object(oop obj) = 0; |
|
110 |
}; |
|
111 |
||
112 |
||
113 |
class BoolObjectClosure : public ObjectClosure { |
|
114 |
public: |
|
115 |
virtual bool do_object_b(oop obj) = 0; |
|
116 |
}; |
|
117 |
||
118 |
// Applies an oop closure to all ref fields in objects iterated over in an |
|
119 |
// object iteration. |
|
120 |
class ObjectToOopClosure: public ObjectClosure { |
|
121 |
OopClosure* _cl; |
|
122 |
public: |
|
123 |
void do_object(oop obj); |
|
124 |
ObjectToOopClosure(OopClosure* cl) : _cl(cl) {} |
|
125 |
}; |
|
126 |
||
127 |
// A version of ObjectClosure with "memory" (see _previous_address below) |
|
128 |
class UpwardsObjectClosure: public BoolObjectClosure { |
|
129 |
HeapWord* _previous_address; |
|
130 |
public: |
|
131 |
UpwardsObjectClosure() : _previous_address(NULL) { } |
|
132 |
void set_previous(HeapWord* addr) { _previous_address = addr; } |
|
133 |
HeapWord* previous() { return _previous_address; } |
|
134 |
// A return value of "true" can be used by the caller to decide |
|
135 |
// if this object's end should *NOT* be recorded in |
|
136 |
// _previous_address above. |
|
137 |
virtual bool do_object_bm(oop obj, MemRegion mr) = 0; |
|
138 |
}; |
|
139 |
||
140 |
// A version of ObjectClosure that is expected to be robust |
|
141 |
// in the face of possibly uninitialized objects. |
|
142 |
class ObjectClosureCareful : public ObjectClosure { |
|
143 |
public: |
|
144 |
virtual size_t do_object_careful_m(oop p, MemRegion mr) = 0; |
|
145 |
virtual size_t do_object_careful(oop p) = 0; |
|
146 |
}; |
|
147 |
||
148 |
// The following are used in CompactibleFreeListSpace and |
|
149 |
// ConcurrentMarkSweepGeneration. |
|
150 |
||
151 |
// Blk closure (abstract class) |
|
152 |
class BlkClosure : public StackObj { |
|
153 |
public: |
|
154 |
virtual size_t do_blk(HeapWord* addr) = 0; |
|
155 |
}; |
|
156 |
||
157 |
// A version of BlkClosure that is expected to be robust |
|
158 |
// in the face of possibly uninitialized objects. |
|
159 |
class BlkClosureCareful : public BlkClosure { |
|
160 |
public: |
|
161 |
size_t do_blk(HeapWord* addr) { |
|
162 |
guarantee(false, "call do_blk_careful instead"); |
|
163 |
return 0; |
|
164 |
} |
|
165 |
virtual size_t do_blk_careful(HeapWord* addr) = 0; |
|
166 |
}; |
|
167 |
||
168 |
// SpaceClosure is used for iterating over spaces |
|
169 |
||
170 |
class Space; |
|
171 |
class CompactibleSpace; |
|
172 |
||
173 |
class SpaceClosure : public StackObj { |
|
174 |
public: |
|
175 |
// Called for each space |
|
176 |
virtual void do_space(Space* s) = 0; |
|
177 |
}; |
|
178 |
||
179 |
class CompactibleSpaceClosure : public StackObj { |
|
180 |
public: |
|
181 |
// Called for each compactible space |
|
182 |
virtual void do_space(CompactibleSpace* s) = 0; |
|
183 |
}; |
|
184 |
||
185 |
||
3908
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
186 |
// 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
|
187 |
// 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
|
188 |
|
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
189 |
class CodeBlobClosure : public Closure { |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
190 |
public: |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
191 |
// Called for each code blob. |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
192 |
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
|
193 |
}; |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
194 |
|
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
195 |
|
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
196 |
class MarkingCodeBlobClosure : public CodeBlobClosure { |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
197 |
public: |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
198 |
// Called for each code blob, but at most once per unique blob. |
3913
e049e6b81e11
6885169: merge of 4957990 and 6863023 causes conflict on do_nmethods
jrose
parents:
3912
diff
changeset
|
199 |
virtual void do_newly_marked_nmethod(nmethod* nm) = 0; |
3908
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
200 |
|
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
201 |
virtual void do_code_blob(CodeBlob* cb); |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
202 |
// = { if (!nmethod(cb)->test_set_oops_do_mark()) do_newly_marked_nmethod(cb); } |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
203 |
|
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
204 |
class MarkScope : public StackObj { |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
205 |
protected: |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
206 |
bool _active; |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
207 |
public: |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
208 |
MarkScope(bool activate = true); |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
209 |
// = { if (active) nmethod::oops_do_marking_prologue(); } |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
210 |
~MarkScope(); |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
211 |
// = { if (active) nmethod::oops_do_marking_epilogue(); } |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
212 |
}; |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
213 |
}; |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
214 |
|
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
215 |
|
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
216 |
// Applies an oop closure to all ref fields in code blobs |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
217 |
// iterated over in an object iteration. |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
218 |
class CodeBlobToOopClosure: public MarkingCodeBlobClosure { |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
219 |
OopClosure* _cl; |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
220 |
bool _do_marking; |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
221 |
public: |
3913
e049e6b81e11
6885169: merge of 4957990 and 6863023 causes conflict on do_nmethods
jrose
parents:
3912
diff
changeset
|
222 |
virtual void do_newly_marked_nmethod(nmethod* cb); |
3908
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
223 |
// = { cb->oops_do(_cl); } |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
224 |
virtual void do_code_blob(CodeBlob* cb); |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
225 |
// = { if (_do_marking) super::do_code_blob(cb); else cb->oops_do(_cl); } |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
226 |
CodeBlobToOopClosure(OopClosure* cl, bool do_marking) |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
227 |
: _cl(cl), _do_marking(do_marking) {} |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
228 |
}; |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
229 |
|
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
230 |
|
1 | 231 |
|
232 |
// MonitorClosure is used for iterating over monitors in the monitors cache |
|
233 |
||
234 |
class ObjectMonitor; |
|
235 |
||
236 |
class MonitorClosure : public StackObj { |
|
237 |
public: |
|
238 |
// called for each monitor in cache |
|
239 |
virtual void do_monitor(ObjectMonitor* m) = 0; |
|
240 |
}; |
|
241 |
||
242 |
// A closure that is applied without any arguments. |
|
243 |
class VoidClosure : public StackObj { |
|
244 |
public: |
|
245 |
// I would have liked to declare this a pure virtual, but that breaks |
|
246 |
// in mysterious ways, for unknown reasons. |
|
247 |
virtual void do_void(); |
|
248 |
}; |
|
249 |
||
250 |
||
251 |
// YieldClosure is intended for use by iteration loops |
|
252 |
// to incrementalize their work, allowing interleaving |
|
253 |
// of an interruptable task so as to allow other |
|
254 |
// threads to run (which may not otherwise be able to access |
|
255 |
// exclusive resources, for instance). Additionally, the |
|
256 |
// closure also allows for aborting an ongoing iteration |
|
257 |
// by means of checking the return value from the polling |
|
258 |
// call. |
|
259 |
class YieldClosure : public StackObj { |
|
260 |
public: |
|
261 |
virtual bool should_return() = 0; |
|
262 |
}; |
|
263 |
||
264 |
// Abstract closure for serializing data (read or write). |
|
265 |
||
266 |
class SerializeOopClosure : public OopClosure { |
|
267 |
public: |
|
268 |
// Return bool indicating whether closure implements read or write. |
|
269 |
virtual bool reading() const = 0; |
|
270 |
||
271 |
// Read/write the int pointed to by i. |
|
272 |
virtual void do_int(int* i) = 0; |
|
273 |
||
274 |
// Read/write the size_t pointed to by i. |
|
275 |
virtual void do_size_t(size_t* i) = 0; |
|
276 |
||
277 |
// Read/write the void pointer pointed to by p. |
|
278 |
virtual void do_ptr(void** p) = 0; |
|
279 |
||
280 |
// Read/write the HeapWord pointer pointed to be p. |
|
281 |
virtual void do_ptr(HeapWord** p) = 0; |
|
282 |
||
283 |
// Read/write the region specified. |
|
284 |
virtual void do_region(u_char* start, size_t size) = 0; |
|
285 |
||
286 |
// Check/write the tag. If reading, then compare the tag against |
|
287 |
// the passed in value and fail is they don't match. This allows |
|
288 |
// for verification that sections of the serialized data are of the |
|
289 |
// correct length. |
|
290 |
virtual void do_tag(int tag) = 0; |
|
291 |
}; |
|
3690 | 292 |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
293 |
class SymbolClosure : public StackObj { |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
294 |
public: |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
295 |
virtual void do_symbol(Symbol**) = 0; |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
296 |
|
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
297 |
// 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
|
298 |
static Symbol* load_symbol(Symbol** p) { |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
299 |
return (Symbol*)(intptr_t(*p) & ~1); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
300 |
} |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
301 |
|
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
302 |
// 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
|
303 |
// (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
|
304 |
static void store_symbol(Symbol** p, Symbol* sym) { |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
305 |
*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
|
306 |
} |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
307 |
}; |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
308 |
|
3690 | 309 |
#ifdef ASSERT |
310 |
// This class is used to flag phases of a collection that |
|
311 |
// can unload classes and which should override the |
|
312 |
// should_remember_klasses() and remember_klass() of OopClosure. |
|
313 |
// The _must_remember_klasses is set in the contructor and restored |
|
314 |
// in the destructor. _must_remember_klasses is checked in assertions |
|
315 |
// in the OopClosure implementations of should_remember_klasses() and |
|
316 |
// remember_klass() and the expectation is that the OopClosure |
|
317 |
// implementation should not be in use if _must_remember_klasses is set. |
|
318 |
// Instances of RememberKlassesChecker can be place in |
|
319 |
// marking phases of collections which can do class unloading. |
|
320 |
// RememberKlassesChecker can be passed "false" to turn off checking. |
|
321 |
// It is used by CMS when CMS yields to a different collector. |
|
322 |
class RememberKlassesChecker: StackObj { |
|
4738
25586a89c1c3
6895236: CMS: cmsOopClosures.inline.hpp:43 assert(..., "Should remember klasses in this context")
jmasa
parents:
3919
diff
changeset
|
323 |
bool _saved_state; |
25586a89c1c3
6895236: CMS: cmsOopClosures.inline.hpp:43 assert(..., "Should remember klasses in this context")
jmasa
parents:
3919
diff
changeset
|
324 |
bool _do_check; |
3690 | 325 |
public: |
4738
25586a89c1c3
6895236: CMS: cmsOopClosures.inline.hpp:43 assert(..., "Should remember klasses in this context")
jmasa
parents:
3919
diff
changeset
|
326 |
RememberKlassesChecker(bool checking_on) : _saved_state(false), |
25586a89c1c3
6895236: CMS: cmsOopClosures.inline.hpp:43 assert(..., "Should remember klasses in this context")
jmasa
parents:
3919
diff
changeset
|
327 |
_do_check(true) { |
25586a89c1c3
6895236: CMS: cmsOopClosures.inline.hpp:43 assert(..., "Should remember klasses in this context")
jmasa
parents:
3919
diff
changeset
|
328 |
// The ClassUnloading unloading flag affects the collectors except |
25586a89c1c3
6895236: CMS: cmsOopClosures.inline.hpp:43 assert(..., "Should remember klasses in this context")
jmasa
parents:
3919
diff
changeset
|
329 |
// for CMS. |
25586a89c1c3
6895236: CMS: cmsOopClosures.inline.hpp:43 assert(..., "Should remember klasses in this context")
jmasa
parents:
3919
diff
changeset
|
330 |
// CMS unloads classes if CMSClassUnloadingEnabled is true or |
25586a89c1c3
6895236: CMS: cmsOopClosures.inline.hpp:43 assert(..., "Should remember klasses in this context")
jmasa
parents:
3919
diff
changeset
|
331 |
// if ExplicitGCInvokesConcurrentAndUnloadsClasses is true and |
25586a89c1c3
6895236: CMS: cmsOopClosures.inline.hpp:43 assert(..., "Should remember klasses in this context")
jmasa
parents:
3919
diff
changeset
|
332 |
// the current collection is an explicit collection. Turning |
25586a89c1c3
6895236: CMS: cmsOopClosures.inline.hpp:43 assert(..., "Should remember klasses in this context")
jmasa
parents:
3919
diff
changeset
|
333 |
// on the checking in general for |
25586a89c1c3
6895236: CMS: cmsOopClosures.inline.hpp:43 assert(..., "Should remember klasses in this context")
jmasa
parents:
3919
diff
changeset
|
334 |
// ExplicitGCInvokesConcurrentAndUnloadsClasses and |
25586a89c1c3
6895236: CMS: cmsOopClosures.inline.hpp:43 assert(..., "Should remember klasses in this context")
jmasa
parents:
3919
diff
changeset
|
335 |
// UseConcMarkSweepGC should not lead to false positives. |
25586a89c1c3
6895236: CMS: cmsOopClosures.inline.hpp:43 assert(..., "Should remember klasses in this context")
jmasa
parents:
3919
diff
changeset
|
336 |
_do_check = |
25586a89c1c3
6895236: CMS: cmsOopClosures.inline.hpp:43 assert(..., "Should remember klasses in this context")
jmasa
parents:
3919
diff
changeset
|
337 |
ClassUnloading && !UseConcMarkSweepGC || |
25586a89c1c3
6895236: CMS: cmsOopClosures.inline.hpp:43 assert(..., "Should remember klasses in this context")
jmasa
parents:
3919
diff
changeset
|
338 |
CMSClassUnloadingEnabled && UseConcMarkSweepGC || |
25586a89c1c3
6895236: CMS: cmsOopClosures.inline.hpp:43 assert(..., "Should remember klasses in this context")
jmasa
parents:
3919
diff
changeset
|
339 |
ExplicitGCInvokesConcurrentAndUnloadsClasses && UseConcMarkSweepGC; |
25586a89c1c3
6895236: CMS: cmsOopClosures.inline.hpp:43 assert(..., "Should remember klasses in this context")
jmasa
parents:
3919
diff
changeset
|
340 |
if (_do_check) { |
25586a89c1c3
6895236: CMS: cmsOopClosures.inline.hpp:43 assert(..., "Should remember klasses in this context")
jmasa
parents:
3919
diff
changeset
|
341 |
_saved_state = OopClosure::must_remember_klasses(); |
25586a89c1c3
6895236: CMS: cmsOopClosures.inline.hpp:43 assert(..., "Should remember klasses in this context")
jmasa
parents:
3919
diff
changeset
|
342 |
OopClosure::set_must_remember_klasses(checking_on); |
3690 | 343 |
} |
344 |
} |
|
345 |
~RememberKlassesChecker() { |
|
4738
25586a89c1c3
6895236: CMS: cmsOopClosures.inline.hpp:43 assert(..., "Should remember klasses in this context")
jmasa
parents:
3919
diff
changeset
|
346 |
if (_do_check) { |
25586a89c1c3
6895236: CMS: cmsOopClosures.inline.hpp:43 assert(..., "Should remember klasses in this context")
jmasa
parents:
3919
diff
changeset
|
347 |
OopClosure::set_must_remember_klasses(_saved_state); |
3690 | 348 |
} |
349 |
} |
|
350 |
}; |
|
351 |
#endif // ASSERT |
|
7397 | 352 |
|
353 |
#endif // SHARE_VM_MEMORY_ITERATOR_HPP |