comparison src/share/vm/memory/specialized_oop_closures.hpp @ 342:37f87013dfd8

6711316: Open source the Garbage-First garbage collector Summary: First mercurial integration of the code for the Garbage-First garbage collector. Reviewed-by: apetrusenko, iveresov, jmasa, sgoldman, tonyp, ysr
author ysr
date Thu, 05 Jun 2008 15:57:56 -0700
parents a61af66fc99e
children c18cbe5936b8
comparison
equal deleted inserted replaced
189:0b27f3512f9e 342:37f87013dfd8
57 // category.) 57 // category.)
58 58
59 // This is split into several because of a Visual C++ 6.0 compiler bug 59 // This is split into several because of a Visual C++ 6.0 compiler bug
60 // where very long macros cause the compiler to crash 60 // where very long macros cause the compiler to crash
61 61
62 // Some other heap might define further specialized closures.
63 #ifndef FURTHER_SPECIALIZED_OOP_OOP_ITERATE_CLOSURES
64 #define FURTHER_SPECIALIZED_OOP_OOP_ITERATE_CLOSURES(f) \
65 /* None */
66 #endif
67
62 #define SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_S(f) \ 68 #define SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_S(f) \
63 f(ScanClosure,_nv) \ 69 f(ScanClosure,_nv) \
64 f(FastScanClosure,_nv) \ 70 f(FastScanClosure,_nv) \
65 f(FilteringClosure,_nv) 71 f(FilteringClosure,_nv)
66 72
75 #define SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_1(f) \ 81 #define SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_1(f) \
76 SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_S(f) \ 82 SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_S(f) \
77 SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_P(f) 83 SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_P(f)
78 84
79 #ifndef SERIALGC 85 #ifndef SERIALGC
80 #define SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_3(f) \ 86 #define SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_2(f) \
81 f(MarkRefsIntoAndScanClosure,_nv) \ 87 f(MarkRefsIntoAndScanClosure,_nv) \
82 f(Par_MarkRefsIntoAndScanClosure,_nv) \ 88 f(Par_MarkRefsIntoAndScanClosure,_nv) \
83 f(PushAndMarkClosure,_nv) \ 89 f(PushAndMarkClosure,_nv) \
84 f(Par_PushAndMarkClosure,_nv) \ 90 f(Par_PushAndMarkClosure,_nv) \
85 f(PushOrMarkClosure,_nv) \ 91 f(PushOrMarkClosure,_nv) \
86 f(Par_PushOrMarkClosure,_nv) \ 92 f(Par_PushOrMarkClosure,_nv) \
87 f(CMSKeepAliveClosure,_nv) \ 93 f(CMSKeepAliveClosure,_nv) \
88 f(CMSInnerParMarkAndPushClosure,_nv) 94 f(CMSInnerParMarkAndPushClosure,_nv) \
95 FURTHER_SPECIALIZED_OOP_OOP_ITERATE_CLOSURES(f)
89 #else // SERIALGC 96 #else // SERIALGC
90 #define SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_3(f) 97 #define SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_2(f)
91 #endif // SERIALGC 98 #endif // SERIALGC
99
92 100
93 // We separate these out, because sometime the general one has 101 // We separate these out, because sometime the general one has
94 // a different definition from the specialized ones, and sometimes it 102 // a different definition from the specialized ones, and sometimes it
95 // doesn't. 103 // doesn't.
96 104
97 #define ALL_OOP_OOP_ITERATE_CLOSURES_1(f) \ 105 #define ALL_OOP_OOP_ITERATE_CLOSURES_1(f) \
98 f(OopClosure,_v) \ 106 f(OopClosure,_v) \
99 SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_1(f) 107 SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_1(f)
100 108
101 #define ALL_OOP_OOP_ITERATE_CLOSURES_3(f) \ 109 #define ALL_OOP_OOP_ITERATE_CLOSURES_2(f) \
102 SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_3(f) 110 SPECIALIZED_OOP_OOP_ITERATE_CLOSURES_2(f)
103 111
104 #ifndef SERIALGC 112 #ifndef SERIALGC
105 // This macro applies an argument macro to all OopClosures for which we 113 // This macro applies an argument macro to all OopClosures for which we
106 // want specialized bodies of a family of methods related to 114 // want specialized bodies of a family of methods related to
107 // "par_oop_iterate". The arguments to f are the same as above. 115 // "par_oop_iterate". The arguments to f are the same as above.
123 // want specialized bodies of a family of methods related to 131 // want specialized bodies of a family of methods related to
124 // "oops_since_save_marks_do". The arguments to f are the same as above. 132 // "oops_since_save_marks_do". The arguments to f are the same as above.
125 // The "root_class" is the most general class to define; this may be 133 // The "root_class" is the most general class to define; this may be
126 // "OopClosure" in some applications and "OopsInGenClosure" in others. 134 // "OopClosure" in some applications and "OopsInGenClosure" in others.
127 135
136
137 // Some other heap might define further specialized closures.
138 #ifndef FURTHER_SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES
139 #define FURTHER_SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES(f) \
140 /* None */
141 #endif
142
128 #define SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES_YOUNG_S(f) \ 143 #define SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES_YOUNG_S(f) \
129 f(ScanClosure,_nv) \ 144 f(ScanClosure,_nv) \
130 f(FastScanClosure,_nv) 145 f(FastScanClosure,_nv)
131 146
132 #ifndef SERIALGC 147 #ifndef SERIALGC
133 #define SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES_YOUNG_P(f) \ 148 #define SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES_YOUNG_P(f) \
134 f(ParScanWithBarrierClosure,_nv) \ 149 f(ParScanWithBarrierClosure,_nv) \
135 f(ParScanWithoutBarrierClosure,_nv) 150 f(ParScanWithoutBarrierClosure,_nv) \
151 FURTHER_SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES(f)
136 #else // SERIALGC 152 #else // SERIALGC
137 #define SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES_YOUNG_P(f) 153 #define SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES_YOUNG_P(f)
138 #endif // SERIALGC 154 #endif // SERIALGC
139 155
140 #define SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES_YOUNG(f) \ 156 #define SPECIALIZED_SINCE_SAVE_MARKS_CLOSURES_YOUNG(f) \
177 NUM_Kinds 193 NUM_Kinds
178 }; 194 };
179 195
180 #if ENABLE_SPECIALIZATION_STATS 196 #if ENABLE_SPECIALIZATION_STATS
181 private: 197 private:
182 static int _numCallsAll; 198 static bool _init;
183 199 static bool _wrapped;
184 static int _numCallsTotal[NUM_Kinds]; 200 static jint _numCallsAll;
185 static int _numCalls_nv[NUM_Kinds]; 201
186 202 static jint _numCallsTotal[NUM_Kinds];
187 static int _numDoOopCallsTotal[NUM_Kinds]; 203 static jint _numCalls_nv[NUM_Kinds];
188 static int _numDoOopCalls_nv[NUM_Kinds]; 204
205 static jint _numDoOopCallsTotal[NUM_Kinds];
206 static jint _numDoOopCalls_nv[NUM_Kinds];
189 public: 207 public:
190 #endif 208 #endif
191 static void clear() PRODUCT_RETURN; 209 static void clear() PRODUCT_RETURN;
192 210
193 static inline void record_call() PRODUCT_RETURN; 211 static inline void record_call() PRODUCT_RETURN;
201 219
202 #ifndef PRODUCT 220 #ifndef PRODUCT
203 #if ENABLE_SPECIALIZATION_STATS 221 #if ENABLE_SPECIALIZATION_STATS
204 222
205 inline void SpecializationStats::record_call() { 223 inline void SpecializationStats::record_call() {
206 _numCallsAll++;; 224 Atomic::inc(&_numCallsAll);
207 } 225 }
208 inline void SpecializationStats::record_iterate_call_v(Kind k) { 226 inline void SpecializationStats::record_iterate_call_v(Kind k) {
209 _numCallsTotal[k]++; 227 Atomic::inc(&_numCallsTotal[k]);
210 } 228 }
211 inline void SpecializationStats::record_iterate_call_nv(Kind k) { 229 inline void SpecializationStats::record_iterate_call_nv(Kind k) {
212 _numCallsTotal[k]++; 230 Atomic::inc(&_numCallsTotal[k]);
213 _numCalls_nv[k]++; 231 Atomic::inc(&_numCalls_nv[k]);
214 } 232 }
215 233
216 inline void SpecializationStats::record_do_oop_call_v(Kind k) { 234 inline void SpecializationStats::record_do_oop_call_v(Kind k) {
217 _numDoOopCallsTotal[k]++; 235 Atomic::inc(&_numDoOopCallsTotal[k]);
218 } 236 }
219 inline void SpecializationStats::record_do_oop_call_nv(Kind k) { 237 inline void SpecializationStats::record_do_oop_call_nv(Kind k) {
220 _numDoOopCallsTotal[k]++; 238 Atomic::inc(&_numDoOopCallsTotal[k]);
221 _numDoOopCalls_nv[k]++; 239 Atomic::inc(&_numDoOopCalls_nv[k]);
222 } 240 }
223 241
224 #else // !ENABLE_SPECIALIZATION_STATS 242 #else // !ENABLE_SPECIALIZATION_STATS
225 243
226 inline void SpecializationStats::record_call() {} 244 inline void SpecializationStats::record_call() {}