Mercurial > hg > graal-compiler
annotate src/share/vm/memory/specialized_oop_closures.hpp @ 7462:ade95d680b42
8004728: Add hotspot support for parameter reflection
Summary: Add hotspot support for parameter reflection
Reviewed-by: acorn, jrose, coleenp
Contributed-by: eric.mccorkle@oracle.com
author | coleenp |
---|---|
date | Tue, 08 Jan 2013 14:01:36 -0500 |
parents | d8ce2825b193 |
children | db9981fd3124 |
rev | line source |
---|---|
0 | 1 /* |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1972
diff
changeset
|
2 * Copyright (c) 2001, 2012, Oracle and/or its affiliates. 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
342
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
342
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:
342
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 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 | |
0 | 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; | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1972
diff
changeset
|
57 // Misc |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1972
diff
changeset
|
58 class NoHeaderExtendedOopClosure; |
0 | 59 |
60 // This macro applies an argument macro to all OopClosures for which we | |
61 // want specialized bodies of "oop_oop_iterate". The arguments to "f" are: | |
62 // "f(closureType, non_virtual)" | |
63 // where "closureType" is the name of the particular subclass of OopClosure, | |
64 // and "non_virtual" will be the string "_nv" if the closure type should | |
65 // have its "do_oop" method invoked non-virtually, or else the | |
66 // string "_v". ("OopClosure" itself will be the only class in the latter | |
67 // category.) | |
68 | |
69 // This is split into several because of a Visual C++ 6.0 compiler bug | |
70 // where very long macros cause the compiler to crash | |
71 | |
342 | 72 // Some other heap might define further specialized closures. |
73 #ifndef FURTHER_SPECIALIZED_OOP_OOP_ITERATE_CLOSURES | |
74 #define FURTHER_SPECIALIZED_OOP_OOP_ITERATE_CLOSURES(f) \ | |
75 /* None */ | |
76 #endif | |
77 | |
0 | 78 #define SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_S(f) \ |
79 f(ScanClosure,_nv) \ | |
80 f(FastScanClosure,_nv) \ | |
81 f(FilteringClosure,_nv) | |
82 | |
83 #ifndef SERIALGC | |
84 #define SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_P(f) \ | |
85 f(ParScanWithBarrierClosure,_nv) \ | |
86 f(ParScanWithoutBarrierClosure,_nv) | |
87 #else // SERIALGC | |
88 #define SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_P(f) | |
89 #endif // SERIALGC | |
90 | |
91 #define SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_1(f) \ | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1972
diff
changeset
|
92 f(NoHeaderExtendedOopClosure,_nv) \ |
0 | 93 SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_S(f) \ |
94 SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_P(f) | |
95 | |
96 #ifndef SERIALGC | |
342 | 97 #define SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_2(f) \ |
0 | 98 f(MarkRefsIntoAndScanClosure,_nv) \ |
99 f(Par_MarkRefsIntoAndScanClosure,_nv) \ | |
100 f(PushAndMarkClosure,_nv) \ | |
101 f(Par_PushAndMarkClosure,_nv) \ | |
102 f(PushOrMarkClosure,_nv) \ | |
103 f(Par_PushOrMarkClosure,_nv) \ | |
104 f(CMSKeepAliveClosure,_nv) \ | |
342 | 105 f(CMSInnerParMarkAndPushClosure,_nv) \ |
106 FURTHER_SPECIALIZED_OOP_OOP_ITERATE_CLOSURES(f) | |
0 | 107 #else // SERIALGC |
342 | 108 #define SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_2(f) |
0 | 109 #endif // SERIALGC |
110 | |
342 | 111 |
0 | 112 // We separate these out, because sometime the general one has |
113 // a different definition from the specialized ones, and sometimes it | |
114 // doesn't. | |
115 | |
116 #define ALL_OOP_OOP_ITERATE_CLOSURES_1(f) \ | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1972
diff
changeset
|
117 f(ExtendedOopClosure,_v) \ |
0 | 118 SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_1(f) |
119 | |
342 | 120 #define ALL_OOP_OOP_ITERATE_CLOSURES_2(f) \ |
121 SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_2(f) | |
0 | 122 |
123 #ifndef SERIALGC | |
124 // This macro applies an argument macro to all OopClosures for which we | |
125 // want specialized bodies of a family of methods related to | |
126 // "par_oop_iterate". The arguments to f are the same as above. | |
127 // The "root_class" is the most general class to define; this may be | |
128 // "OopClosure" in some applications and "OopsInGenClosure" in others. | |
129 | |
130 #define SPECIALIZED_PAR_OOP_ITERATE_CLOSURES(f) \ | |
131 f(MarkRefsIntoAndScanClosure,_nv) \ | |
132 f(PushAndMarkClosure,_nv) \ | |
133 f(Par_MarkRefsIntoAndScanClosure,_nv) \ | |
134 f(Par_PushAndMarkClosure,_nv) | |
135 | |
136 #define ALL_PAR_OOP_ITERATE_CLOSURES(f) \ | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1972
diff
changeset
|
137 f(ExtendedOopClosure,_v) \ |
0 | 138 SPECIALIZED_PAR_OOP_ITERATE_CLOSURES(f) |
139 #endif // SERIALGC | |
140 | |
141 // This macro applies an argument macro to all OopClosures for which we | |
142 // want specialized bodies of a family of methods related to | |
143 // "oops_since_save_marks_do". The arguments to f are the same as above. | |
144 // The "root_class" is the most general class to define; this may be | |
145 // "OopClosure" in some applications and "OopsInGenClosure" in others. | |
146 | |
342 | 147 |
148 // Some other heap might define further specialized closures. | |
149 #ifndef FURTHER_SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES | |
150 #define FURTHER_SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES(f) \ | |
151 /* None */ | |
152 #endif | |
153 | |
0 | 154 #define SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES_YOUNG_S(f) \ |
155 f(ScanClosure,_nv) \ | |
156 f(FastScanClosure,_nv) | |
157 | |
158 #ifndef SERIALGC | |
159 #define SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES_YOUNG_P(f) \ | |
160 f(ParScanWithBarrierClosure,_nv) \ | |
342 | 161 f(ParScanWithoutBarrierClosure,_nv) \ |
162 FURTHER_SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES(f) | |
0 | 163 #else // SERIALGC |
164 #define SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES_YOUNG_P(f) | |
165 #endif // SERIALGC | |
166 | |
167 #define SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES_YOUNG(f) \ | |
168 SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES_YOUNG_S(f) \ | |
169 SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES_YOUNG_P(f) | |
170 | |
171 #define SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES(f) \ | |
172 SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES_YOUNG(f) | |
173 | |
174 // We separate these out, because sometime the general one has | |
175 // a different definition from the specialized ones, and sometimes it | |
176 // doesn't. | |
177 // NOTE: One of the valid criticisms of this | |
178 // specialize-oop_oop_iterate-for-specific-closures idiom is that it is | |
179 // easy to have a silent performance bug: if you fail to de-virtualize, | |
180 // things still work, just slower. The "SpecializationStats" mode is | |
181 // intended to at least make such a failure easy to detect. | |
182 // *Not* using the ALL_SINCE_SAVE_MARKS_CLOSURES(f) macro defined | |
183 // below means that *only* closures for which oop_oop_iterate specializations | |
184 // exist above may be applied to "oops_since_save_marks". That is, | |
185 // this form of the performance bug is caught statically. When you add | |
186 // a definition for the general type, this property goes away. | |
187 // Make sure you test with SpecializationStats to find such bugs | |
188 // when introducing a new closure where you don't want virtual dispatch. | |
189 | |
190 #define ALL_SINCE_SAVE_MARKS_CLOSURES(f) \ | |
191 f(OopsInGenClosure,_v) \ | |
192 SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES(f) | |
193 | |
194 // For keeping stats on effectiveness. | |
195 #define ENABLE_SPECIALIZATION_STATS 0 | |
196 | |
197 | |
198 class SpecializationStats { | |
199 public: | |
200 enum Kind { | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
1972
diff
changeset
|
201 ik, // InstanceKlass |
6735
aed758eda82a
7195833: NPG: Rename instanceClassLoaderKlass, instanceRefKlass and instanceMirrorKlass
coleenp
parents:
6725
diff
changeset
|
202 irk, // InstanceRefKlass |
6831
d8ce2825b193
8000213: NPG: Should have renamed arrayKlass and typeArrayKlass
coleenp
parents:
6735
diff
changeset
|
203 oa, // ObjArrayKlass |
0 | 204 NUM_Kinds |
205 }; | |
206 | |
207 #if ENABLE_SPECIALIZATION_STATS | |
208 private: | |
342 | 209 static bool _init; |
210 static bool _wrapped; | |
211 static jint _numCallsAll; | |
0 | 212 |
342 | 213 static jint _numCallsTotal[NUM_Kinds]; |
214 static jint _numCalls_nv[NUM_Kinds]; | |
0 | 215 |
342 | 216 static jint _numDoOopCallsTotal[NUM_Kinds]; |
217 static jint _numDoOopCalls_nv[NUM_Kinds]; | |
0 | 218 public: |
219 #endif | |
220 static void clear() PRODUCT_RETURN; | |
221 | |
222 static inline void record_call() PRODUCT_RETURN; | |
223 static inline void record_iterate_call_v(Kind k) PRODUCT_RETURN; | |
224 static inline void record_iterate_call_nv(Kind k) PRODUCT_RETURN; | |
225 static inline void record_do_oop_call_v(Kind k) PRODUCT_RETURN; | |
226 static inline void record_do_oop_call_nv(Kind k) PRODUCT_RETURN; | |
227 | |
228 static void print() PRODUCT_RETURN; | |
229 }; | |
230 | |
231 #ifndef PRODUCT | |
232 #if ENABLE_SPECIALIZATION_STATS | |
233 | |
234 inline void SpecializationStats::record_call() { | |
342 | 235 Atomic::inc(&_numCallsAll); |
0 | 236 } |
237 inline void SpecializationStats::record_iterate_call_v(Kind k) { | |
342 | 238 Atomic::inc(&_numCallsTotal[k]); |
0 | 239 } |
240 inline void SpecializationStats::record_iterate_call_nv(Kind k) { | |
342 | 241 Atomic::inc(&_numCallsTotal[k]); |
242 Atomic::inc(&_numCalls_nv[k]); | |
0 | 243 } |
244 | |
245 inline void SpecializationStats::record_do_oop_call_v(Kind k) { | |
342 | 246 Atomic::inc(&_numDoOopCallsTotal[k]); |
0 | 247 } |
248 inline void SpecializationStats::record_do_oop_call_nv(Kind k) { | |
342 | 249 Atomic::inc(&_numDoOopCallsTotal[k]); |
250 Atomic::inc(&_numDoOopCalls_nv[k]); | |
0 | 251 } |
252 | |
253 #else // !ENABLE_SPECIALIZATION_STATS | |
254 | |
255 inline void SpecializationStats::record_call() {} | |
256 inline void SpecializationStats::record_iterate_call_v(Kind k) {} | |
257 inline void SpecializationStats::record_iterate_call_nv(Kind k) {} | |
258 inline void SpecializationStats::record_do_oop_call_v(Kind k) {} | |
259 inline void SpecializationStats::record_do_oop_call_nv(Kind k) {} | |
260 inline void SpecializationStats::clear() {} | |
261 inline void SpecializationStats::print() {} | |
262 | |
263 #endif // ENABLE_SPECIALIZATION_STATS | |
264 #endif // !PRODUCT | |
1972 | 265 |
266 #endif // SHARE_VM_MEMORY_SPECIALIZED_OOP_CLOSURES_HPP |