author | stefank |
Tue, 23 Nov 2010 13:22:55 -0800 | |
changeset 7397 | 5b173b4ca846 |
parent 5547 | f4b087cbb361 |
child 13728 | 882756847a04 |
permissions | -rw-r--r-- |
1 | 1 |
/* |
7397 | 2 |
* Copyright (c) 2001, 2010, 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:
1374
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
f4b087cbb361
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1374
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:
1374
diff
changeset
|
21 |
* questions. |
1 | 22 |
* |
23 |
*/ |
|
24 |
||
7397 | 25 |
#ifndef SHARE_VM_MEMORY_SPECIALIZED_OOP_CLOSURES_HPP |
26 |
#define SHARE_VM_MEMORY_SPECIALIZED_OOP_CLOSURES_HPP |
|
27 |
||
28 |
#include "runtime/atomic.hpp" |
|
29 |
#ifndef SERIALGC |
|
30 |
#include "gc_implementation/g1/g1_specialized_oop_closures.hpp" |
|
31 |
#endif |
|
32 |
||
1 | 33 |
// The following OopClosure types get specialized versions of |
34 |
// "oop_oop_iterate" that invoke the closures' do_oop methods |
|
35 |
// non-virtually, using a mechanism defined in this file. Extend these |
|
36 |
// macros in the obvious way to add specializations for new closures. |
|
37 |
||
38 |
// Forward declarations. |
|
39 |
class OopClosure; |
|
40 |
class OopsInGenClosure; |
|
41 |
// DefNew |
|
42 |
class ScanClosure; |
|
43 |
class FastScanClosure; |
|
44 |
class FilteringClosure; |
|
45 |
// ParNew |
|
46 |
class ParScanWithBarrierClosure; |
|
47 |
class ParScanWithoutBarrierClosure; |
|
48 |
// CMS |
|
49 |
class MarkRefsIntoAndScanClosure; |
|
50 |
class Par_MarkRefsIntoAndScanClosure; |
|
51 |
class PushAndMarkClosure; |
|
52 |
class Par_PushAndMarkClosure; |
|
53 |
class PushOrMarkClosure; |
|
54 |
class Par_PushOrMarkClosure; |
|
55 |
class CMSKeepAliveClosure; |
|
56 |
class CMSInnerParMarkAndPushClosure; |
|
57 |
||
58 |
// This macro applies an argument macro to all OopClosures for which we |
|
59 |
// want specialized bodies of "oop_oop_iterate". The arguments to "f" are: |
|
60 |
// "f(closureType, non_virtual)" |
|
61 |
// where "closureType" is the name of the particular subclass of OopClosure, |
|
62 |
// and "non_virtual" will be the string "_nv" if the closure type should |
|
63 |
// have its "do_oop" method invoked non-virtually, or else the |
|
64 |
// string "_v". ("OopClosure" itself will be the only class in the latter |
|
65 |
// category.) |
|
66 |
||
67 |
// This is split into several because of a Visual C++ 6.0 compiler bug |
|
68 |
// where very long macros cause the compiler to crash |
|
69 |
||
1374 | 70 |
// Some other heap might define further specialized closures. |
71 |
#ifndef FURTHER_SPECIALIZED_OOP_OOP_ITERATE_CLOSURES |
|
72 |
#define FURTHER_SPECIALIZED_OOP_OOP_ITERATE_CLOSURES(f) \ |
|
73 |
/* None */ |
|
74 |
#endif |
|
75 |
||
1 | 76 |
#define SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_S(f) \ |
77 |
f(ScanClosure,_nv) \ |
|
78 |
f(FastScanClosure,_nv) \ |
|
79 |
f(FilteringClosure,_nv) |
|
80 |
||
81 |
#ifndef SERIALGC |
|
82 |
#define SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_P(f) \ |
|
83 |
f(ParScanWithBarrierClosure,_nv) \ |
|
84 |
f(ParScanWithoutBarrierClosure,_nv) |
|
85 |
#else // SERIALGC |
|
86 |
#define SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_P(f) |
|
87 |
#endif // SERIALGC |
|
88 |
||
89 |
#define SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_1(f) \ |
|
90 |
SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_S(f) \ |
|
91 |
SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_P(f) |
|
92 |
||
93 |
#ifndef SERIALGC |
|
1374 | 94 |
#define SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_2(f) \ |
1 | 95 |
f(MarkRefsIntoAndScanClosure,_nv) \ |
96 |
f(Par_MarkRefsIntoAndScanClosure,_nv) \ |
|
97 |
f(PushAndMarkClosure,_nv) \ |
|
98 |
f(Par_PushAndMarkClosure,_nv) \ |
|
99 |
f(PushOrMarkClosure,_nv) \ |
|
100 |
f(Par_PushOrMarkClosure,_nv) \ |
|
101 |
f(CMSKeepAliveClosure,_nv) \ |
|
1374 | 102 |
f(CMSInnerParMarkAndPushClosure,_nv) \ |
103 |
FURTHER_SPECIALIZED_OOP_OOP_ITERATE_CLOSURES(f) |
|
1 | 104 |
#else // SERIALGC |
1374 | 105 |
#define SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_2(f) |
1 | 106 |
#endif // SERIALGC |
107 |
||
1374 | 108 |
|
1 | 109 |
// We separate these out, because sometime the general one has |
110 |
// a different definition from the specialized ones, and sometimes it |
|
111 |
// doesn't. |
|
112 |
||
113 |
#define ALL_OOP_OOP_ITERATE_CLOSURES_1(f) \ |
|
114 |
f(OopClosure,_v) \ |
|
115 |
SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_1(f) |
|
116 |
||
1374 | 117 |
#define ALL_OOP_OOP_ITERATE_CLOSURES_2(f) \ |
118 |
SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_2(f) |
|
1 | 119 |
|
120 |
#ifndef SERIALGC |
|
121 |
// This macro applies an argument macro to all OopClosures for which we |
|
122 |
// want specialized bodies of a family of methods related to |
|
123 |
// "par_oop_iterate". The arguments to f are the same as above. |
|
124 |
// The "root_class" is the most general class to define; this may be |
|
125 |
// "OopClosure" in some applications and "OopsInGenClosure" in others. |
|
126 |
||
127 |
#define SPECIALIZED_PAR_OOP_ITERATE_CLOSURES(f) \ |
|
128 |
f(MarkRefsIntoAndScanClosure,_nv) \ |
|
129 |
f(PushAndMarkClosure,_nv) \ |
|
130 |
f(Par_MarkRefsIntoAndScanClosure,_nv) \ |
|
131 |
f(Par_PushAndMarkClosure,_nv) |
|
132 |
||
133 |
#define ALL_PAR_OOP_ITERATE_CLOSURES(f) \ |
|
134 |
f(OopClosure,_v) \ |
|
135 |
SPECIALIZED_PAR_OOP_ITERATE_CLOSURES(f) |
|
136 |
#endif // SERIALGC |
|
137 |
||
138 |
// This macro applies an argument macro to all OopClosures for which we |
|
139 |
// want specialized bodies of a family of methods related to |
|
140 |
// "oops_since_save_marks_do". The arguments to f are the same as above. |
|
141 |
// The "root_class" is the most general class to define; this may be |
|
142 |
// "OopClosure" in some applications and "OopsInGenClosure" in others. |
|
143 |
||
1374 | 144 |
|
145 |
// Some other heap might define further specialized closures. |
|
146 |
#ifndef FURTHER_SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES |
|
147 |
#define FURTHER_SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES(f) \ |
|
148 |
/* None */ |
|
149 |
#endif |
|
150 |
||
1 | 151 |
#define SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES_YOUNG_S(f) \ |
152 |
f(ScanClosure,_nv) \ |
|
153 |
f(FastScanClosure,_nv) |
|
154 |
||
155 |
#ifndef SERIALGC |
|
156 |
#define SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES_YOUNG_P(f) \ |
|
157 |
f(ParScanWithBarrierClosure,_nv) \ |
|
1374 | 158 |
f(ParScanWithoutBarrierClosure,_nv) \ |
159 |
FURTHER_SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES(f) |
|
1 | 160 |
#else // SERIALGC |
161 |
#define SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES_YOUNG_P(f) |
|
162 |
#endif // SERIALGC |
|
163 |
||
164 |
#define SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES_YOUNG(f) \ |
|
165 |
SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES_YOUNG_S(f) \ |
|
166 |
SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES_YOUNG_P(f) |
|
167 |
||
168 |
#define SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES(f) \ |
|
169 |
SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES_YOUNG(f) |
|
170 |
||
171 |
// We separate these out, because sometime the general one has |
|
172 |
// a different definition from the specialized ones, and sometimes it |
|
173 |
// doesn't. |
|
174 |
// NOTE: One of the valid criticisms of this |
|
175 |
// specialize-oop_oop_iterate-for-specific-closures idiom is that it is |
|
176 |
// easy to have a silent performance bug: if you fail to de-virtualize, |
|
177 |
// things still work, just slower. The "SpecializationStats" mode is |
|
178 |
// intended to at least make such a failure easy to detect. |
|
179 |
// *Not* using the ALL_SINCE_SAVE_MARKS_CLOSURES(f) macro defined |
|
180 |
// below means that *only* closures for which oop_oop_iterate specializations |
|
181 |
// exist above may be applied to "oops_since_save_marks". That is, |
|
182 |
// this form of the performance bug is caught statically. When you add |
|
183 |
// a definition for the general type, this property goes away. |
|
184 |
// Make sure you test with SpecializationStats to find such bugs |
|
185 |
// when introducing a new closure where you don't want virtual dispatch. |
|
186 |
||
187 |
#define ALL_SINCE_SAVE_MARKS_CLOSURES(f) \ |
|
188 |
f(OopsInGenClosure,_v) \ |
|
189 |
SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES(f) |
|
190 |
||
191 |
// For keeping stats on effectiveness. |
|
192 |
#define ENABLE_SPECIALIZATION_STATS 0 |
|
193 |
||
194 |
||
195 |
class SpecializationStats { |
|
196 |
public: |
|
197 |
enum Kind { |
|
198 |
ik, // instanceKlass |
|
199 |
irk, // instanceRefKlass |
|
200 |
oa, // objArrayKlass |
|
201 |
NUM_Kinds |
|
202 |
}; |
|
203 |
||
204 |
#if ENABLE_SPECIALIZATION_STATS |
|
205 |
private: |
|
1374 | 206 |
static bool _init; |
207 |
static bool _wrapped; |
|
208 |
static jint _numCallsAll; |
|
1 | 209 |
|
1374 | 210 |
static jint _numCallsTotal[NUM_Kinds]; |
211 |
static jint _numCalls_nv[NUM_Kinds]; |
|
1 | 212 |
|
1374 | 213 |
static jint _numDoOopCallsTotal[NUM_Kinds]; |
214 |
static jint _numDoOopCalls_nv[NUM_Kinds]; |
|
1 | 215 |
public: |
216 |
#endif |
|
217 |
static void clear() PRODUCT_RETURN; |
|
218 |
||
219 |
static inline void record_call() PRODUCT_RETURN; |
|
220 |
static inline void record_iterate_call_v(Kind k) PRODUCT_RETURN; |
|
221 |
static inline void record_iterate_call_nv(Kind k) PRODUCT_RETURN; |
|
222 |
static inline void record_do_oop_call_v(Kind k) PRODUCT_RETURN; |
|
223 |
static inline void record_do_oop_call_nv(Kind k) PRODUCT_RETURN; |
|
224 |
||
225 |
static void print() PRODUCT_RETURN; |
|
226 |
}; |
|
227 |
||
228 |
#ifndef PRODUCT |
|
229 |
#if ENABLE_SPECIALIZATION_STATS |
|
230 |
||
231 |
inline void SpecializationStats::record_call() { |
|
1374 | 232 |
Atomic::inc(&_numCallsAll); |
1 | 233 |
} |
234 |
inline void SpecializationStats::record_iterate_call_v(Kind k) { |
|
1374 | 235 |
Atomic::inc(&_numCallsTotal[k]); |
1 | 236 |
} |
237 |
inline void SpecializationStats::record_iterate_call_nv(Kind k) { |
|
1374 | 238 |
Atomic::inc(&_numCallsTotal[k]); |
239 |
Atomic::inc(&_numCalls_nv[k]); |
|
1 | 240 |
} |
241 |
||
242 |
inline void SpecializationStats::record_do_oop_call_v(Kind k) { |
|
1374 | 243 |
Atomic::inc(&_numDoOopCallsTotal[k]); |
1 | 244 |
} |
245 |
inline void SpecializationStats::record_do_oop_call_nv(Kind k) { |
|
1374 | 246 |
Atomic::inc(&_numDoOopCallsTotal[k]); |
247 |
Atomic::inc(&_numDoOopCalls_nv[k]); |
|
1 | 248 |
} |
249 |
||
250 |
#else // !ENABLE_SPECIALIZATION_STATS |
|
251 |
||
252 |
inline void SpecializationStats::record_call() {} |
|
253 |
inline void SpecializationStats::record_iterate_call_v(Kind k) {} |
|
254 |
inline void SpecializationStats::record_iterate_call_nv(Kind k) {} |
|
255 |
inline void SpecializationStats::record_do_oop_call_v(Kind k) {} |
|
256 |
inline void SpecializationStats::record_do_oop_call_nv(Kind k) {} |
|
257 |
inline void SpecializationStats::clear() {} |
|
258 |
inline void SpecializationStats::print() {} |
|
259 |
||
260 |
#endif // ENABLE_SPECIALIZATION_STATS |
|
261 |
#endif // !PRODUCT |
|
7397 | 262 |
|
263 |
#endif // SHARE_VM_MEMORY_SPECIALIZED_OOP_CLOSURES_HPP |