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