annotate src/share/vm/memory/iterator.hpp @ 1972:f95d63e2154a

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