annotate src/share/vm/memory/iterator.hpp @ 989:148e5441d916

6863023: need non-perm oops in code cache for JSR 292 Summary: Make a special root-list for those few nmethods which might contain non-perm oops. Reviewed-by: twisti, kvn, never, jmasa, ysr
author jrose
date Tue, 15 Sep 2009 21:53:47 -0700
parents 1ee8caae33af
children 54b3b351d6f9
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
196
d1605aabd0a1 6719955: Update copyright year
xdono
parents: 113
diff changeset
2 * Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
a61af66fc99e Initial load
duke
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a61af66fc99e Initial load
duke
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
a61af66fc99e Initial load
duke
parents:
diff changeset
21 * have any questions.
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 // The following classes are C++ `closures` for iterating over objects, roots and spaces
a61af66fc99e Initial load
duke
parents:
diff changeset
26
989
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 356
diff changeset
27 class CodeBlob;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
28 class ReferenceProcessor;
a61af66fc99e Initial load
duke
parents:
diff changeset
29
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 113
diff changeset
30 // Closure provides abortability.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 113
diff changeset
31
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 113
diff changeset
32 class Closure : public StackObj {
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 113
diff changeset
33 protected:
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 113
diff changeset
34 bool _abort;
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 113
diff changeset
35 void set_abort() { _abort = true; }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 113
diff changeset
36 public:
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 113
diff changeset
37 Closure() : _abort(false) {}
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 113
diff changeset
38 // 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
39 // functions that the iteration should cease.
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 113
diff changeset
40 bool abort() { return _abort; }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 113
diff changeset
41 void clear_abort() { _abort = false; }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 113
diff changeset
42 };
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 113
diff changeset
43
0
a61af66fc99e Initial load
duke
parents:
diff changeset
44 // OopClosure is used for iterating through roots (oop*)
a61af66fc99e Initial load
duke
parents:
diff changeset
45
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 113
diff changeset
46 class OopClosure : public Closure {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
47 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
48 ReferenceProcessor* _ref_processor;
a61af66fc99e Initial load
duke
parents:
diff changeset
49 OopClosure(ReferenceProcessor* rp) : _ref_processor(rp) { }
a61af66fc99e Initial load
duke
parents:
diff changeset
50 OopClosure() : _ref_processor(NULL) { }
a61af66fc99e Initial load
duke
parents:
diff changeset
51 virtual void do_oop(oop* o) = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
52 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
53 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
54 virtual void do_oop_v(narrowOop* o) { do_oop(o); }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
55
a61af66fc99e Initial load
duke
parents:
diff changeset
56 // In support of post-processing of weak links of KlassKlass objects;
a61af66fc99e Initial load
duke
parents:
diff changeset
57 // see KlassKlass::oop_oop_iterate().
a61af66fc99e Initial load
duke
parents:
diff changeset
58 virtual const bool should_remember_klasses() const { return false; }
a61af66fc99e Initial load
duke
parents:
diff changeset
59 virtual void remember_klass(Klass* k) { /* do nothing */ }
a61af66fc99e Initial load
duke
parents:
diff changeset
60
a61af66fc99e Initial load
duke
parents:
diff changeset
61 // The methods below control how object iterations invoking this closure
a61af66fc99e Initial load
duke
parents:
diff changeset
62 // should be performed:
a61af66fc99e Initial load
duke
parents:
diff changeset
63
a61af66fc99e Initial load
duke
parents:
diff changeset
64 // If "true", invoke on header klass field.
a61af66fc99e Initial load
duke
parents:
diff changeset
65 bool do_header() { return true; } // Note that this is non-virtual.
a61af66fc99e Initial load
duke
parents:
diff changeset
66 // Controls how prefetching is done for invocations of this closure.
a61af66fc99e Initial load
duke
parents:
diff changeset
67 Prefetch::style prefetch_style() { // Note that this is non-virtual.
a61af66fc99e Initial load
duke
parents:
diff changeset
68 return Prefetch::do_none;
a61af66fc99e Initial load
duke
parents:
diff changeset
69 }
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 113
diff changeset
70
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 113
diff changeset
71 // 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
72 // 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
73 virtual bool idempotent() { return false; }
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 113
diff changeset
74 virtual bool apply_to_weak_ref_discovered_field() { return false; }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
75 };
a61af66fc99e Initial load
duke
parents:
diff changeset
76
a61af66fc99e Initial load
duke
parents:
diff changeset
77 // ObjectClosure is used for iterating through an object space
a61af66fc99e Initial load
duke
parents:
diff changeset
78
342
37f87013dfd8 6711316: Open source the Garbage-First garbage collector
ysr
parents: 113
diff changeset
79 class ObjectClosure : public Closure {
0
a61af66fc99e Initial load
duke
parents:
diff changeset
80 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
81 // Called for each object.
a61af66fc99e Initial load
duke
parents:
diff changeset
82 virtual void do_object(oop obj) = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
83 };
a61af66fc99e Initial load
duke
parents:
diff changeset
84
a61af66fc99e Initial load
duke
parents:
diff changeset
85
a61af66fc99e Initial load
duke
parents:
diff changeset
86 class BoolObjectClosure : public ObjectClosure {
a61af66fc99e Initial load
duke
parents:
diff changeset
87 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
88 virtual bool do_object_b(oop obj) = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
89 };
a61af66fc99e Initial load
duke
parents:
diff changeset
90
a61af66fc99e Initial load
duke
parents:
diff changeset
91 // Applies an oop closure to all ref fields in objects iterated over in an
a61af66fc99e Initial load
duke
parents:
diff changeset
92 // object iteration.
a61af66fc99e Initial load
duke
parents:
diff changeset
93 class ObjectToOopClosure: public ObjectClosure {
a61af66fc99e Initial load
duke
parents:
diff changeset
94 OopClosure* _cl;
a61af66fc99e Initial load
duke
parents:
diff changeset
95 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
96 void do_object(oop obj);
a61af66fc99e Initial load
duke
parents:
diff changeset
97 ObjectToOopClosure(OopClosure* cl) : _cl(cl) {}
a61af66fc99e Initial load
duke
parents:
diff changeset
98 };
a61af66fc99e Initial load
duke
parents:
diff changeset
99
a61af66fc99e Initial load
duke
parents:
diff changeset
100 // A version of ObjectClosure with "memory" (see _previous_address below)
a61af66fc99e Initial load
duke
parents:
diff changeset
101 class UpwardsObjectClosure: public BoolObjectClosure {
a61af66fc99e Initial load
duke
parents:
diff changeset
102 HeapWord* _previous_address;
a61af66fc99e Initial load
duke
parents:
diff changeset
103 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
104 UpwardsObjectClosure() : _previous_address(NULL) { }
a61af66fc99e Initial load
duke
parents:
diff changeset
105 void set_previous(HeapWord* addr) { _previous_address = addr; }
a61af66fc99e Initial load
duke
parents:
diff changeset
106 HeapWord* previous() { return _previous_address; }
a61af66fc99e Initial load
duke
parents:
diff changeset
107 // A return value of "true" can be used by the caller to decide
a61af66fc99e Initial load
duke
parents:
diff changeset
108 // if this object's end should *NOT* be recorded in
a61af66fc99e Initial load
duke
parents:
diff changeset
109 // _previous_address above.
a61af66fc99e Initial load
duke
parents:
diff changeset
110 virtual bool do_object_bm(oop obj, MemRegion mr) = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
111 };
a61af66fc99e Initial load
duke
parents:
diff changeset
112
a61af66fc99e Initial load
duke
parents:
diff changeset
113 // A version of ObjectClosure that is expected to be robust
a61af66fc99e Initial load
duke
parents:
diff changeset
114 // in the face of possibly uninitialized objects.
a61af66fc99e Initial load
duke
parents:
diff changeset
115 class ObjectClosureCareful : public ObjectClosure {
a61af66fc99e Initial load
duke
parents:
diff changeset
116 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
117 virtual size_t do_object_careful_m(oop p, MemRegion mr) = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
118 virtual size_t do_object_careful(oop p) = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
119 };
a61af66fc99e Initial load
duke
parents:
diff changeset
120
a61af66fc99e Initial load
duke
parents:
diff changeset
121 // The following are used in CompactibleFreeListSpace and
a61af66fc99e Initial load
duke
parents:
diff changeset
122 // ConcurrentMarkSweepGeneration.
a61af66fc99e Initial load
duke
parents:
diff changeset
123
a61af66fc99e Initial load
duke
parents:
diff changeset
124 // Blk closure (abstract class)
a61af66fc99e Initial load
duke
parents:
diff changeset
125 class BlkClosure : public StackObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
126 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
127 virtual size_t do_blk(HeapWord* addr) = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
128 };
a61af66fc99e Initial load
duke
parents:
diff changeset
129
a61af66fc99e Initial load
duke
parents:
diff changeset
130 // A version of BlkClosure that is expected to be robust
a61af66fc99e Initial load
duke
parents:
diff changeset
131 // in the face of possibly uninitialized objects.
a61af66fc99e Initial load
duke
parents:
diff changeset
132 class BlkClosureCareful : public BlkClosure {
a61af66fc99e Initial load
duke
parents:
diff changeset
133 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
134 size_t do_blk(HeapWord* addr) {
a61af66fc99e Initial load
duke
parents:
diff changeset
135 guarantee(false, "call do_blk_careful instead");
a61af66fc99e Initial load
duke
parents:
diff changeset
136 return 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
137 }
a61af66fc99e Initial load
duke
parents:
diff changeset
138 virtual size_t do_blk_careful(HeapWord* addr) = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
139 };
a61af66fc99e Initial load
duke
parents:
diff changeset
140
a61af66fc99e Initial load
duke
parents:
diff changeset
141 // SpaceClosure is used for iterating over spaces
a61af66fc99e Initial load
duke
parents:
diff changeset
142
a61af66fc99e Initial load
duke
parents:
diff changeset
143 class Space;
a61af66fc99e Initial load
duke
parents:
diff changeset
144 class CompactibleSpace;
a61af66fc99e Initial load
duke
parents:
diff changeset
145
a61af66fc99e Initial load
duke
parents:
diff changeset
146 class SpaceClosure : public StackObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
147 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
148 // Called for each space
a61af66fc99e Initial load
duke
parents:
diff changeset
149 virtual void do_space(Space* s) = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
150 };
a61af66fc99e Initial load
duke
parents:
diff changeset
151
a61af66fc99e Initial load
duke
parents:
diff changeset
152 class CompactibleSpaceClosure : public StackObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
153 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
154 // Called for each compactible space
a61af66fc99e Initial load
duke
parents:
diff changeset
155 virtual void do_space(CompactibleSpace* s) = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
156 };
a61af66fc99e Initial load
duke
parents:
diff changeset
157
a61af66fc99e Initial load
duke
parents:
diff changeset
158
989
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 356
diff changeset
159 // 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
160 // 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
161
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 356
diff changeset
162 class CodeBlobClosure : public Closure {
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 356
diff changeset
163 public:
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 356
diff changeset
164 // Called for each code blob.
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 356
diff changeset
165 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
166 };
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 356
diff changeset
167
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 356
diff changeset
168
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 356
diff changeset
169 class MarkingCodeBlobClosure : public CodeBlobClosure {
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 356
diff changeset
170 public:
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 356
diff changeset
171 // Called for each code blob, but at most once per unique blob.
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 356
diff changeset
172 virtual void do_newly_marked_nmethod(CodeBlob* cb) = 0;
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 356
diff changeset
173
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 356
diff changeset
174 virtual void do_code_blob(CodeBlob* cb);
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 356
diff changeset
175 // = { 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
176
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 356
diff changeset
177 class MarkScope : public StackObj {
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 356
diff changeset
178 protected:
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 356
diff changeset
179 bool _active;
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 356
diff changeset
180 public:
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 356
diff changeset
181 MarkScope(bool activate = true);
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 356
diff changeset
182 // = { if (active) nmethod::oops_do_marking_prologue(); }
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 356
diff changeset
183 ~MarkScope();
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 356
diff changeset
184 // = { if (active) nmethod::oops_do_marking_epilogue(); }
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 356
diff changeset
185 };
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 356
diff changeset
186 };
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 356
diff changeset
187
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 356
diff changeset
188
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 356
diff changeset
189 // 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
190 // iterated over in an object iteration.
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 356
diff changeset
191 class CodeBlobToOopClosure: public MarkingCodeBlobClosure {
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 356
diff changeset
192 OopClosure* _cl;
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 356
diff changeset
193 bool _do_marking;
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 356
diff changeset
194 public:
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 356
diff changeset
195 virtual void do_newly_marked_nmethod(CodeBlob* cb);
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 356
diff changeset
196 // = { cb->oops_do(_cl); }
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 356
diff changeset
197 virtual void do_code_blob(CodeBlob* cb);
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 356
diff changeset
198 // = { 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
199 CodeBlobToOopClosure(OopClosure* cl, bool do_marking)
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 356
diff changeset
200 : _cl(cl), _do_marking(do_marking) {}
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 356
diff changeset
201 };
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 356
diff changeset
202
148e5441d916 6863023: need non-perm oops in code cache for JSR 292
jrose
parents: 356
diff changeset
203
0
a61af66fc99e Initial load
duke
parents:
diff changeset
204
a61af66fc99e Initial load
duke
parents:
diff changeset
205 // MonitorClosure is used for iterating over monitors in the monitors cache
a61af66fc99e Initial load
duke
parents:
diff changeset
206
a61af66fc99e Initial load
duke
parents:
diff changeset
207 class ObjectMonitor;
a61af66fc99e Initial load
duke
parents:
diff changeset
208
a61af66fc99e Initial load
duke
parents:
diff changeset
209 class MonitorClosure : public StackObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
210 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
211 // called for each monitor in cache
a61af66fc99e Initial load
duke
parents:
diff changeset
212 virtual void do_monitor(ObjectMonitor* m) = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
213 };
a61af66fc99e Initial load
duke
parents:
diff changeset
214
a61af66fc99e Initial load
duke
parents:
diff changeset
215 // A closure that is applied without any arguments.
a61af66fc99e Initial load
duke
parents:
diff changeset
216 class VoidClosure : public StackObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
217 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
218 // I would have liked to declare this a pure virtual, but that breaks
a61af66fc99e Initial load
duke
parents:
diff changeset
219 // in mysterious ways, for unknown reasons.
a61af66fc99e Initial load
duke
parents:
diff changeset
220 virtual void do_void();
a61af66fc99e Initial load
duke
parents:
diff changeset
221 };
a61af66fc99e Initial load
duke
parents:
diff changeset
222
a61af66fc99e Initial load
duke
parents:
diff changeset
223
a61af66fc99e Initial load
duke
parents:
diff changeset
224 // YieldClosure is intended for use by iteration loops
a61af66fc99e Initial load
duke
parents:
diff changeset
225 // to incrementalize their work, allowing interleaving
a61af66fc99e Initial load
duke
parents:
diff changeset
226 // of an interruptable task so as to allow other
a61af66fc99e Initial load
duke
parents:
diff changeset
227 // threads to run (which may not otherwise be able to access
a61af66fc99e Initial load
duke
parents:
diff changeset
228 // exclusive resources, for instance). Additionally, the
a61af66fc99e Initial load
duke
parents:
diff changeset
229 // closure also allows for aborting an ongoing iteration
a61af66fc99e Initial load
duke
parents:
diff changeset
230 // by means of checking the return value from the polling
a61af66fc99e Initial load
duke
parents:
diff changeset
231 // call.
a61af66fc99e Initial load
duke
parents:
diff changeset
232 class YieldClosure : public StackObj {
a61af66fc99e Initial load
duke
parents:
diff changeset
233 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
234 virtual bool should_return() = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
235 };
a61af66fc99e Initial load
duke
parents:
diff changeset
236
a61af66fc99e Initial load
duke
parents:
diff changeset
237 // Abstract closure for serializing data (read or write).
a61af66fc99e Initial load
duke
parents:
diff changeset
238
a61af66fc99e Initial load
duke
parents:
diff changeset
239 class SerializeOopClosure : public OopClosure {
a61af66fc99e Initial load
duke
parents:
diff changeset
240 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
241 // Return bool indicating whether closure implements read or write.
a61af66fc99e Initial load
duke
parents:
diff changeset
242 virtual bool reading() const = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
243
a61af66fc99e Initial load
duke
parents:
diff changeset
244 // Read/write the int pointed to by i.
a61af66fc99e Initial load
duke
parents:
diff changeset
245 virtual void do_int(int* i) = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
246
a61af66fc99e Initial load
duke
parents:
diff changeset
247 // Read/write the size_t pointed to by i.
a61af66fc99e Initial load
duke
parents:
diff changeset
248 virtual void do_size_t(size_t* i) = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
249
a61af66fc99e Initial load
duke
parents:
diff changeset
250 // Read/write the void pointer pointed to by p.
a61af66fc99e Initial load
duke
parents:
diff changeset
251 virtual void do_ptr(void** p) = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
252
a61af66fc99e Initial load
duke
parents:
diff changeset
253 // Read/write the HeapWord pointer pointed to be p.
a61af66fc99e Initial load
duke
parents:
diff changeset
254 virtual void do_ptr(HeapWord** p) = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
255
a61af66fc99e Initial load
duke
parents:
diff changeset
256 // Read/write the region specified.
a61af66fc99e Initial load
duke
parents:
diff changeset
257 virtual void do_region(u_char* start, size_t size) = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
258
a61af66fc99e Initial load
duke
parents:
diff changeset
259 // Check/write the tag. If reading, then compare the tag against
a61af66fc99e Initial load
duke
parents:
diff changeset
260 // the passed in value and fail is they don't match. This allows
a61af66fc99e Initial load
duke
parents:
diff changeset
261 // for verification that sections of the serialized data are of the
a61af66fc99e Initial load
duke
parents:
diff changeset
262 // correct length.
a61af66fc99e Initial load
duke
parents:
diff changeset
263 virtual void do_tag(int tag) = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
264 };