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