author | stefank |
Fri, 14 Feb 2014 09:29:56 +0100 | |
changeset 22883 | 5378704451dc |
parent 22234 | da823d78ad65 |
child 22899 | e2a6bf7f343a |
permissions | -rw-r--r-- |
1 | 1 |
/* |
22234
da823d78ad65
8029233: Update copyright year to match last edit in jdk8 hotspot repository for 2013
mikael
parents:
17625
diff
changeset
|
2 |
* Copyright (c) 1997, 2013, 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; |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
39 |
class KlassClosure; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
40 |
class ClassLoaderData; |
1 | 41 |
|
1374
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
42 |
// Closure provides abortability. |
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
43 |
|
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
44 |
class Closure : public StackObj { |
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
45 |
protected: |
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
46 |
bool _abort; |
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
47 |
void set_abort() { _abort = true; } |
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
48 |
public: |
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
49 |
Closure() : _abort(false) {} |
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
50 |
// 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
|
51 |
// functions that the iteration should cease. |
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
52 |
bool abort() { return _abort; } |
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
53 |
void clear_abort() { _abort = false; } |
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
54 |
}; |
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
55 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
56 |
// OopClosure is used for iterating through references to Java objects. |
1 | 57 |
|
1374
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
58 |
class OopClosure : public Closure { |
1 | 59 |
public: |
60 |
virtual void do_oop(oop* o) = 0; |
|
61 |
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
|
62 |
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
|
63 |
virtual void do_oop_v(narrowOop* o) { do_oop(o); } |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
64 |
}; |
3690 | 65 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
66 |
// ExtendedOopClosure adds extra code to be run during oop iterations. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
67 |
// This is needed by the GC and is extracted to a separate type to not |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
68 |
// pollute the OopClosure interface. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
69 |
class ExtendedOopClosure : public OopClosure { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
70 |
public: |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
71 |
ReferenceProcessor* _ref_processor; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
72 |
ExtendedOopClosure(ReferenceProcessor* rp) : _ref_processor(rp) { } |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
73 |
ExtendedOopClosure() : OopClosure(), _ref_processor(NULL) { } |
1 | 74 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
75 |
// If the do_metadata functions return "true", |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
76 |
// we invoke the following when running oop_iterate(): |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
77 |
// |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
78 |
// 1) do_klass on the header klass pointer. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
79 |
// 2) do_klass on the klass pointer in the mirrors. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
80 |
// 3) do_class_loader_data on the class loader data in class loaders. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
81 |
// |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
82 |
// The virtual (without suffix) and the non-virtual (with _nv suffix) need |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
83 |
// to be updated together, or else the devirtualization will break. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
84 |
// |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
85 |
// Providing default implementations of the _nv functions unfortunately |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
86 |
// removes the compile-time safeness, but reduces the clutter for the |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
87 |
// ExtendedOopClosures that don't need to walk the metadata. Currently, |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
88 |
// only CMS needs these. |
3696 | 89 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
90 |
virtual bool do_metadata() { return do_metadata_nv(); } |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
91 |
bool do_metadata_v() { return do_metadata(); } |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
92 |
bool do_metadata_nv() { return false; } |
1 | 93 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
94 |
virtual void do_klass(Klass* k) { do_klass_nv(k); } |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
95 |
void do_klass_v(Klass* k) { do_klass(k); } |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
96 |
void do_klass_nv(Klass* k) { ShouldNotReachHere(); } |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
97 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
98 |
virtual void do_class_loader_data(ClassLoaderData* cld) { ShouldNotReachHere(); } |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
99 |
|
1 | 100 |
// Controls how prefetching is done for invocations of this closure. |
101 |
Prefetch::style prefetch_style() { // Note that this is non-virtual. |
|
102 |
return Prefetch::do_none; |
|
103 |
} |
|
1374
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
104 |
|
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
105 |
// 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
|
106 |
// 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
|
107 |
virtual bool idempotent() { return false; } |
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
108 |
virtual bool apply_to_weak_ref_discovered_field() { return false; } |
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
109 |
}; |
3690 | 110 |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
111 |
// Wrapper closure only used to implement oop_iterate_no_header(). |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
112 |
class NoHeaderExtendedOopClosure : public ExtendedOopClosure { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
113 |
OopClosure* _wrapped_closure; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
114 |
public: |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
115 |
NoHeaderExtendedOopClosure(OopClosure* cl) : _wrapped_closure(cl) {} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
116 |
// Warning: this calls the virtual version do_oop in the the wrapped closure. |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
117 |
void do_oop_nv(oop* p) { _wrapped_closure->do_oop(p); } |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
118 |
void do_oop_nv(narrowOop* p) { _wrapped_closure->do_oop(p); } |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
119 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
120 |
void do_oop(oop* p) { assert(false, "Only the _nv versions should be used"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
121 |
_wrapped_closure->do_oop(p); } |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
122 |
void do_oop(narrowOop* p) { assert(false, "Only the _nv versions should be used"); |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
123 |
_wrapped_closure->do_oop(p);} |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
124 |
}; |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
125 |
|
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
126 |
class KlassClosure : public Closure { |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
127 |
public: |
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
128 |
virtual void do_klass(Klass* k) = 0; |
1 | 129 |
}; |
130 |
||
13741
e4395deb8597
7197350: NPG: jvmtiHeapReferenceCallback receives incorrect reference_kind for system class roots
stefank
parents:
13728
diff
changeset
|
131 |
class KlassToOopClosure : public KlassClosure { |
e4395deb8597
7197350: NPG: jvmtiHeapReferenceCallback receives incorrect reference_kind for system class roots
stefank
parents:
13728
diff
changeset
|
132 |
OopClosure* _oop_closure; |
e4395deb8597
7197350: NPG: jvmtiHeapReferenceCallback receives incorrect reference_kind for system class roots
stefank
parents:
13728
diff
changeset
|
133 |
public: |
e4395deb8597
7197350: NPG: jvmtiHeapReferenceCallback receives incorrect reference_kind for system class roots
stefank
parents:
13728
diff
changeset
|
134 |
KlassToOopClosure(OopClosure* oop_closure) : _oop_closure(oop_closure) {} |
e4395deb8597
7197350: NPG: jvmtiHeapReferenceCallback receives incorrect reference_kind for system class roots
stefank
parents:
13728
diff
changeset
|
135 |
virtual void do_klass(Klass* k); |
e4395deb8597
7197350: NPG: jvmtiHeapReferenceCallback receives incorrect reference_kind for system class roots
stefank
parents:
13728
diff
changeset
|
136 |
}; |
e4395deb8597
7197350: NPG: jvmtiHeapReferenceCallback receives incorrect reference_kind for system class roots
stefank
parents:
13728
diff
changeset
|
137 |
|
14582
490bb6c0df7c
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
13741
diff
changeset
|
138 |
class CLDToOopClosure { |
490bb6c0df7c
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
13741
diff
changeset
|
139 |
OopClosure* _oop_closure; |
490bb6c0df7c
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
13741
diff
changeset
|
140 |
KlassToOopClosure _klass_closure; |
490bb6c0df7c
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
13741
diff
changeset
|
141 |
bool _must_claim_cld; |
490bb6c0df7c
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
13741
diff
changeset
|
142 |
|
490bb6c0df7c
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
13741
diff
changeset
|
143 |
public: |
490bb6c0df7c
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
13741
diff
changeset
|
144 |
CLDToOopClosure(OopClosure* oop_closure, bool must_claim_cld = true) : |
490bb6c0df7c
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
13741
diff
changeset
|
145 |
_oop_closure(oop_closure), |
490bb6c0df7c
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
13741
diff
changeset
|
146 |
_klass_closure(oop_closure), |
490bb6c0df7c
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
13741
diff
changeset
|
147 |
_must_claim_cld(must_claim_cld) {} |
490bb6c0df7c
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
13741
diff
changeset
|
148 |
|
490bb6c0df7c
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
13741
diff
changeset
|
149 |
void do_cld(ClassLoaderData* cld); |
490bb6c0df7c
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
13741
diff
changeset
|
150 |
}; |
490bb6c0df7c
8003720: NPG: Method in interpreter stack frame can be deallocated
stefank
parents:
13741
diff
changeset
|
151 |
|
1 | 152 |
// ObjectClosure is used for iterating through an object space |
153 |
||
1374
4c24294029a9
6711316: Open source the Garbage-First garbage collector
ysr
parents:
360
diff
changeset
|
154 |
class ObjectClosure : public Closure { |
1 | 155 |
public: |
156 |
// Called for each object. |
|
157 |
virtual void do_object(oop obj) = 0; |
|
158 |
}; |
|
159 |
||
160 |
||
17625
3e91c67ddece
8014277: Remove ObjectClosure as base class for BoolObjectClosure
ehelin
parents:
14582
diff
changeset
|
161 |
class BoolObjectClosure : public Closure { |
1 | 162 |
public: |
163 |
virtual bool do_object_b(oop obj) = 0; |
|
164 |
}; |
|
165 |
||
166 |
// Applies an oop closure to all ref fields in objects iterated over in an |
|
167 |
// object iteration. |
|
168 |
class ObjectToOopClosure: public ObjectClosure { |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
169 |
ExtendedOopClosure* _cl; |
1 | 170 |
public: |
171 |
void do_object(oop obj); |
|
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
172 |
ObjectToOopClosure(ExtendedOopClosure* cl) : _cl(cl) {} |
1 | 173 |
}; |
174 |
||
175 |
// A version of ObjectClosure with "memory" (see _previous_address below) |
|
176 |
class UpwardsObjectClosure: public BoolObjectClosure { |
|
177 |
HeapWord* _previous_address; |
|
178 |
public: |
|
179 |
UpwardsObjectClosure() : _previous_address(NULL) { } |
|
180 |
void set_previous(HeapWord* addr) { _previous_address = addr; } |
|
181 |
HeapWord* previous() { return _previous_address; } |
|
182 |
// A return value of "true" can be used by the caller to decide |
|
183 |
// if this object's end should *NOT* be recorded in |
|
184 |
// _previous_address above. |
|
185 |
virtual bool do_object_bm(oop obj, MemRegion mr) = 0; |
|
186 |
}; |
|
187 |
||
188 |
// A version of ObjectClosure that is expected to be robust |
|
189 |
// in the face of possibly uninitialized objects. |
|
190 |
class ObjectClosureCareful : public ObjectClosure { |
|
191 |
public: |
|
192 |
virtual size_t do_object_careful_m(oop p, MemRegion mr) = 0; |
|
193 |
virtual size_t do_object_careful(oop p) = 0; |
|
194 |
}; |
|
195 |
||
196 |
// The following are used in CompactibleFreeListSpace and |
|
197 |
// ConcurrentMarkSweepGeneration. |
|
198 |
||
199 |
// Blk closure (abstract class) |
|
200 |
class BlkClosure : public StackObj { |
|
201 |
public: |
|
202 |
virtual size_t do_blk(HeapWord* addr) = 0; |
|
203 |
}; |
|
204 |
||
205 |
// A version of BlkClosure that is expected to be robust |
|
206 |
// in the face of possibly uninitialized objects. |
|
207 |
class BlkClosureCareful : public BlkClosure { |
|
208 |
public: |
|
209 |
size_t do_blk(HeapWord* addr) { |
|
210 |
guarantee(false, "call do_blk_careful instead"); |
|
211 |
return 0; |
|
212 |
} |
|
213 |
virtual size_t do_blk_careful(HeapWord* addr) = 0; |
|
214 |
}; |
|
215 |
||
216 |
// SpaceClosure is used for iterating over spaces |
|
217 |
||
218 |
class Space; |
|
219 |
class CompactibleSpace; |
|
220 |
||
221 |
class SpaceClosure : public StackObj { |
|
222 |
public: |
|
223 |
// Called for each space |
|
224 |
virtual void do_space(Space* s) = 0; |
|
225 |
}; |
|
226 |
||
227 |
class CompactibleSpaceClosure : public StackObj { |
|
228 |
public: |
|
229 |
// Called for each compactible space |
|
230 |
virtual void do_space(CompactibleSpace* s) = 0; |
|
231 |
}; |
|
232 |
||
233 |
||
3908
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
234 |
// 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
|
235 |
// 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
|
236 |
|
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
237 |
class CodeBlobClosure : public Closure { |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
238 |
public: |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
239 |
// Called for each code blob. |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
240 |
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
|
241 |
}; |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
242 |
|
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
243 |
|
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
244 |
class MarkingCodeBlobClosure : public CodeBlobClosure { |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
245 |
public: |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
246 |
// 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
|
247 |
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
|
248 |
|
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
249 |
virtual void do_code_blob(CodeBlob* cb); |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
250 |
// = { 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
|
251 |
|
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
252 |
class MarkScope : public StackObj { |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
253 |
protected: |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
254 |
bool _active; |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
255 |
public: |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
256 |
MarkScope(bool activate = true); |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
257 |
// = { if (active) nmethod::oops_do_marking_prologue(); } |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
258 |
~MarkScope(); |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
259 |
// = { if (active) nmethod::oops_do_marking_epilogue(); } |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
260 |
}; |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
261 |
}; |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
262 |
|
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
263 |
|
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
264 |
// 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
|
265 |
// iterated over in an object iteration. |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
266 |
class CodeBlobToOopClosure: public MarkingCodeBlobClosure { |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
267 |
OopClosure* _cl; |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
268 |
bool _do_marking; |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
269 |
public: |
3913
e049e6b81e11
6885169: merge of 4957990 and 6863023 causes conflict on do_nmethods
jrose
parents:
3912
diff
changeset
|
270 |
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
|
271 |
// = { cb->oops_do(_cl); } |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
272 |
virtual void do_code_blob(CodeBlob* cb); |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
273 |
// = { 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
|
274 |
CodeBlobToOopClosure(OopClosure* cl, bool do_marking) |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
275 |
: _cl(cl), _do_marking(do_marking) {} |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
276 |
}; |
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
277 |
|
24b55ad4c228
6863023: need non-perm oops in code cache for JSR 292
jrose
parents:
1388
diff
changeset
|
278 |
|
1 | 279 |
|
280 |
// MonitorClosure is used for iterating over monitors in the monitors cache |
|
281 |
||
282 |
class ObjectMonitor; |
|
283 |
||
284 |
class MonitorClosure : public StackObj { |
|
285 |
public: |
|
286 |
// called for each monitor in cache |
|
287 |
virtual void do_monitor(ObjectMonitor* m) = 0; |
|
288 |
}; |
|
289 |
||
290 |
// A closure that is applied without any arguments. |
|
291 |
class VoidClosure : public StackObj { |
|
292 |
public: |
|
293 |
// I would have liked to declare this a pure virtual, but that breaks |
|
294 |
// in mysterious ways, for unknown reasons. |
|
295 |
virtual void do_void(); |
|
296 |
}; |
|
297 |
||
298 |
||
299 |
// YieldClosure is intended for use by iteration loops |
|
300 |
// to incrementalize their work, allowing interleaving |
|
301 |
// of an interruptable task so as to allow other |
|
302 |
// threads to run (which may not otherwise be able to access |
|
303 |
// exclusive resources, for instance). Additionally, the |
|
304 |
// closure also allows for aborting an ongoing iteration |
|
305 |
// by means of checking the return value from the polling |
|
306 |
// call. |
|
307 |
class YieldClosure : public StackObj { |
|
308 |
public: |
|
309 |
virtual bool should_return() = 0; |
|
310 |
}; |
|
311 |
||
312 |
// Abstract closure for serializing data (read or write). |
|
313 |
||
13728
882756847a04
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
8921
diff
changeset
|
314 |
class SerializeClosure : public Closure { |
1 | 315 |
public: |
316 |
// Return bool indicating whether closure implements read or write. |
|
317 |
virtual bool reading() const = 0; |
|
318 |
||
319 |
// Read/write the void pointer pointed to by p. |
|
320 |
virtual void do_ptr(void** p) = 0; |
|
321 |
||
322 |
// Read/write the region specified. |
|
323 |
virtual void do_region(u_char* start, size_t size) = 0; |
|
324 |
||
325 |
// Check/write the tag. If reading, then compare the tag against |
|
326 |
// the passed in value and fail is they don't match. This allows |
|
327 |
// for verification that sections of the serialized data are of the |
|
328 |
// correct length. |
|
329 |
virtual void do_tag(int tag) = 0; |
|
330 |
}; |
|
3690 | 331 |
|
8076
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
332 |
class SymbolClosure : public StackObj { |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
333 |
public: |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
334 |
virtual void do_symbol(Symbol**) = 0; |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
335 |
|
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
336 |
// 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
|
337 |
static Symbol* load_symbol(Symbol** p) { |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
338 |
return (Symbol*)(intptr_t(*p) & ~1); |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
339 |
} |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
340 |
|
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
341 |
// 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
|
342 |
// (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
|
343 |
static void store_symbol(Symbol** p, Symbol* sym) { |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
344 |
*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
|
345 |
} |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
346 |
}; |
96d498ec7ae1
6990754: Use native memory and reference counting to implement SymbolTable
coleenp
parents:
7397
diff
changeset
|
347 |
|
7397 | 348 |
#endif // SHARE_VM_MEMORY_ITERATOR_HPP |