Mercurial > hg > graal-compiler
comparison src/share/vm/memory/referenceProcessor.cpp @ 20804:7848fc12602b
Merge with jdk8u40-b25
author | Gilles Duboscq <gilles.m.duboscq@oracle.com> |
---|---|
date | Tue, 07 Apr 2015 14:58:49 +0200 |
parents | 52b4284cb496 c2844108a708 |
children | f01ebceea995 |
comparison
equal
deleted
inserted
replaced
20184:84105dcdb05b | 20804:7848fc12602b |
---|---|
116 } | 116 } |
117 _discoveredSoftRefs = &_discovered_refs[0]; | 117 _discoveredSoftRefs = &_discovered_refs[0]; |
118 _discoveredWeakRefs = &_discoveredSoftRefs[_max_num_q]; | 118 _discoveredWeakRefs = &_discoveredSoftRefs[_max_num_q]; |
119 _discoveredFinalRefs = &_discoveredWeakRefs[_max_num_q]; | 119 _discoveredFinalRefs = &_discoveredWeakRefs[_max_num_q]; |
120 _discoveredPhantomRefs = &_discoveredFinalRefs[_max_num_q]; | 120 _discoveredPhantomRefs = &_discoveredFinalRefs[_max_num_q]; |
121 _discoveredCleanerRefs = &_discoveredPhantomRefs[_max_num_q]; | |
121 | 122 |
122 // Initialize all entries to NULL | 123 // Initialize all entries to NULL |
123 for (uint i = 0; i < _max_num_q * number_of_subclasses_of_ref(); i++) { | 124 for (uint i = 0; i < _max_num_q * number_of_subclasses_of_ref(); i++) { |
124 _discovered_refs[i].set_head(NULL); | 125 _discovered_refs[i].set_head(NULL); |
125 _discovered_refs[i].set_length(0); | 126 _discovered_refs[i].set_length(0); |
188 ReferenceProcessorStats ReferenceProcessor::process_discovered_references( | 189 ReferenceProcessorStats ReferenceProcessor::process_discovered_references( |
189 BoolObjectClosure* is_alive, | 190 BoolObjectClosure* is_alive, |
190 OopClosure* keep_alive, | 191 OopClosure* keep_alive, |
191 VoidClosure* complete_gc, | 192 VoidClosure* complete_gc, |
192 AbstractRefProcTaskExecutor* task_executor, | 193 AbstractRefProcTaskExecutor* task_executor, |
193 GCTimer* gc_timer) { | 194 GCTimer* gc_timer, |
195 GCId gc_id) { | |
194 NOT_PRODUCT(verify_ok_to_handle_reflists()); | 196 NOT_PRODUCT(verify_ok_to_handle_reflists()); |
195 | 197 |
196 assert(!enqueuing_is_done(), "If here enqueuing should not be complete"); | 198 assert(!enqueuing_is_done(), "If here enqueuing should not be complete"); |
197 // Stop treating discovered references specially. | 199 // Stop treating discovered references specially. |
198 disable_discovery(); | 200 disable_discovery(); |
210 bool trace_time = PrintGCDetails && PrintReferenceGC; | 212 bool trace_time = PrintGCDetails && PrintReferenceGC; |
211 | 213 |
212 // Soft references | 214 // Soft references |
213 size_t soft_count = 0; | 215 size_t soft_count = 0; |
214 { | 216 { |
215 GCTraceTime tt("SoftReference", trace_time, false, gc_timer); | 217 GCTraceTime tt("SoftReference", trace_time, false, gc_timer, gc_id); |
216 soft_count = | 218 soft_count = |
217 process_discovered_reflist(_discoveredSoftRefs, _current_soft_ref_policy, true, | 219 process_discovered_reflist(_discoveredSoftRefs, _current_soft_ref_policy, true, |
218 is_alive, keep_alive, complete_gc, task_executor); | 220 is_alive, keep_alive, complete_gc, task_executor); |
219 } | 221 } |
220 | 222 |
221 update_soft_ref_master_clock(); | 223 update_soft_ref_master_clock(); |
222 | 224 |
223 // Weak references | 225 // Weak references |
224 size_t weak_count = 0; | 226 size_t weak_count = 0; |
225 { | 227 { |
226 GCTraceTime tt("WeakReference", trace_time, false, gc_timer); | 228 GCTraceTime tt("WeakReference", trace_time, false, gc_timer, gc_id); |
227 weak_count = | 229 weak_count = |
228 process_discovered_reflist(_discoveredWeakRefs, NULL, true, | 230 process_discovered_reflist(_discoveredWeakRefs, NULL, true, |
229 is_alive, keep_alive, complete_gc, task_executor); | 231 is_alive, keep_alive, complete_gc, task_executor); |
230 } | 232 } |
231 | 233 |
232 // Final references | 234 // Final references |
233 size_t final_count = 0; | 235 size_t final_count = 0; |
234 { | 236 { |
235 GCTraceTime tt("FinalReference", trace_time, false, gc_timer); | 237 GCTraceTime tt("FinalReference", trace_time, false, gc_timer, gc_id); |
236 final_count = | 238 final_count = |
237 process_discovered_reflist(_discoveredFinalRefs, NULL, false, | 239 process_discovered_reflist(_discoveredFinalRefs, NULL, false, |
238 is_alive, keep_alive, complete_gc, task_executor); | 240 is_alive, keep_alive, complete_gc, task_executor); |
239 } | 241 } |
240 | 242 |
241 // Phantom references | 243 // Phantom references |
242 size_t phantom_count = 0; | 244 size_t phantom_count = 0; |
243 { | 245 { |
244 GCTraceTime tt("PhantomReference", trace_time, false, gc_timer); | 246 GCTraceTime tt("PhantomReference", trace_time, false, gc_timer, gc_id); |
245 phantom_count = | 247 phantom_count = |
246 process_discovered_reflist(_discoveredPhantomRefs, NULL, false, | 248 process_discovered_reflist(_discoveredPhantomRefs, NULL, false, |
249 is_alive, keep_alive, complete_gc, task_executor); | |
250 | |
251 // Process cleaners, but include them in phantom statistics. We expect | |
252 // Cleaner references to be temporary, and don't want to deal with | |
253 // possible incompatibilities arising from making it more visible. | |
254 phantom_count += | |
255 process_discovered_reflist(_discoveredCleanerRefs, NULL, false, | |
247 is_alive, keep_alive, complete_gc, task_executor); | 256 is_alive, keep_alive, complete_gc, task_executor); |
248 } | 257 } |
249 | 258 |
250 // Weak global JNI references. It would make more sense (semantically) to | 259 // Weak global JNI references. It would make more sense (semantically) to |
251 // traverse these simultaneously with the regular weak references above, but | 260 // traverse these simultaneously with the regular weak references above, but |
252 // that is not how the JDK1.2 specification is. See #4126360. Native code can | 261 // that is not how the JDK1.2 specification is. See #4126360. Native code can |
253 // thus use JNI weak references to circumvent the phantom references and | 262 // thus use JNI weak references to circumvent the phantom references and |
254 // resurrect a "post-mortem" object. | 263 // resurrect a "post-mortem" object. |
255 { | 264 { |
256 GCTraceTime tt("JNI Weak Reference", trace_time, false, gc_timer); | 265 GCTraceTime tt("JNI Weak Reference", trace_time, false, gc_timer, gc_id); |
257 if (task_executor != NULL) { | 266 if (task_executor != NULL) { |
258 task_executor->set_single_threaded_mode(); | 267 task_executor->set_single_threaded_mode(); |
259 } | 268 } |
260 process_phaseJNI(is_alive, keep_alive, complete_gc); | 269 process_phaseJNI(is_alive, keep_alive, complete_gc); |
261 } | 270 } |
880 void ReferenceProcessor::balance_all_queues() { | 889 void ReferenceProcessor::balance_all_queues() { |
881 balance_queues(_discoveredSoftRefs); | 890 balance_queues(_discoveredSoftRefs); |
882 balance_queues(_discoveredWeakRefs); | 891 balance_queues(_discoveredWeakRefs); |
883 balance_queues(_discoveredFinalRefs); | 892 balance_queues(_discoveredFinalRefs); |
884 balance_queues(_discoveredPhantomRefs); | 893 balance_queues(_discoveredPhantomRefs); |
894 balance_queues(_discoveredCleanerRefs); | |
885 } | 895 } |
886 | 896 |
887 size_t | 897 size_t |
888 ReferenceProcessor::process_discovered_reflist( | 898 ReferenceProcessor::process_discovered_reflist( |
889 DiscoveredList refs_lists[], | 899 DiscoveredList refs_lists[], |
1038 case REF_FINAL: | 1048 case REF_FINAL: |
1039 list = &_discoveredFinalRefs[id]; | 1049 list = &_discoveredFinalRefs[id]; |
1040 break; | 1050 break; |
1041 case REF_PHANTOM: | 1051 case REF_PHANTOM: |
1042 list = &_discoveredPhantomRefs[id]; | 1052 list = &_discoveredPhantomRefs[id]; |
1053 break; | |
1054 case REF_CLEANER: | |
1055 list = &_discoveredCleanerRefs[id]; | |
1043 break; | 1056 break; |
1044 case REF_NONE: | 1057 case REF_NONE: |
1045 // we should not reach here if we are an InstanceRefKlass | 1058 // we should not reach here if we are an InstanceRefKlass |
1046 default: | 1059 default: |
1047 ShouldNotReachHere(); | 1060 ShouldNotReachHere(); |
1249 void ReferenceProcessor::preclean_discovered_references( | 1262 void ReferenceProcessor::preclean_discovered_references( |
1250 BoolObjectClosure* is_alive, | 1263 BoolObjectClosure* is_alive, |
1251 OopClosure* keep_alive, | 1264 OopClosure* keep_alive, |
1252 VoidClosure* complete_gc, | 1265 VoidClosure* complete_gc, |
1253 YieldClosure* yield, | 1266 YieldClosure* yield, |
1254 GCTimer* gc_timer) { | 1267 GCTimer* gc_timer, |
1268 GCId gc_id) { | |
1255 | 1269 |
1256 NOT_PRODUCT(verify_ok_to_handle_reflists()); | 1270 NOT_PRODUCT(verify_ok_to_handle_reflists()); |
1257 | 1271 |
1258 // Soft references | 1272 // Soft references |
1259 { | 1273 { |
1260 GCTraceTime tt("Preclean SoftReferences", PrintGCDetails && PrintReferenceGC, | 1274 GCTraceTime tt("Preclean SoftReferences", PrintGCDetails && PrintReferenceGC, |
1261 false, gc_timer); | 1275 false, gc_timer, gc_id); |
1262 for (uint i = 0; i < _max_num_q; i++) { | 1276 for (uint i = 0; i < _max_num_q; i++) { |
1263 if (yield->should_return()) { | 1277 if (yield->should_return()) { |
1264 return; | 1278 return; |
1265 } | 1279 } |
1266 preclean_discovered_reflist(_discoveredSoftRefs[i], is_alive, | 1280 preclean_discovered_reflist(_discoveredSoftRefs[i], is_alive, |
1269 } | 1283 } |
1270 | 1284 |
1271 // Weak references | 1285 // Weak references |
1272 { | 1286 { |
1273 GCTraceTime tt("Preclean WeakReferences", PrintGCDetails && PrintReferenceGC, | 1287 GCTraceTime tt("Preclean WeakReferences", PrintGCDetails && PrintReferenceGC, |
1274 false, gc_timer); | 1288 false, gc_timer, gc_id); |
1275 for (uint i = 0; i < _max_num_q; i++) { | 1289 for (uint i = 0; i < _max_num_q; i++) { |
1276 if (yield->should_return()) { | 1290 if (yield->should_return()) { |
1277 return; | 1291 return; |
1278 } | 1292 } |
1279 preclean_discovered_reflist(_discoveredWeakRefs[i], is_alive, | 1293 preclean_discovered_reflist(_discoveredWeakRefs[i], is_alive, |
1282 } | 1296 } |
1283 | 1297 |
1284 // Final references | 1298 // Final references |
1285 { | 1299 { |
1286 GCTraceTime tt("Preclean FinalReferences", PrintGCDetails && PrintReferenceGC, | 1300 GCTraceTime tt("Preclean FinalReferences", PrintGCDetails && PrintReferenceGC, |
1287 false, gc_timer); | 1301 false, gc_timer, gc_id); |
1288 for (uint i = 0; i < _max_num_q; i++) { | 1302 for (uint i = 0; i < _max_num_q; i++) { |
1289 if (yield->should_return()) { | 1303 if (yield->should_return()) { |
1290 return; | 1304 return; |
1291 } | 1305 } |
1292 preclean_discovered_reflist(_discoveredFinalRefs[i], is_alive, | 1306 preclean_discovered_reflist(_discoveredFinalRefs[i], is_alive, |
1295 } | 1309 } |
1296 | 1310 |
1297 // Phantom references | 1311 // Phantom references |
1298 { | 1312 { |
1299 GCTraceTime tt("Preclean PhantomReferences", PrintGCDetails && PrintReferenceGC, | 1313 GCTraceTime tt("Preclean PhantomReferences", PrintGCDetails && PrintReferenceGC, |
1300 false, gc_timer); | 1314 false, gc_timer, gc_id); |
1301 for (uint i = 0; i < _max_num_q; i++) { | 1315 for (uint i = 0; i < _max_num_q; i++) { |
1302 if (yield->should_return()) { | 1316 if (yield->should_return()) { |
1303 return; | 1317 return; |
1304 } | 1318 } |
1305 preclean_discovered_reflist(_discoveredPhantomRefs[i], is_alive, | 1319 preclean_discovered_reflist(_discoveredPhantomRefs[i], is_alive, |
1320 keep_alive, complete_gc, yield); | |
1321 } | |
1322 | |
1323 // Cleaner references. Included in timing for phantom references. We | |
1324 // expect Cleaner references to be temporary, and don't want to deal with | |
1325 // possible incompatibilities arising from making it more visible. | |
1326 for (uint i = 0; i < _max_num_q; i++) { | |
1327 if (yield->should_return()) { | |
1328 return; | |
1329 } | |
1330 preclean_discovered_reflist(_discoveredCleanerRefs[i], is_alive, | |
1306 keep_alive, complete_gc, yield); | 1331 keep_alive, complete_gc, yield); |
1307 } | 1332 } |
1308 } | 1333 } |
1309 } | 1334 } |
1310 | 1335 |
1371 switch (j) { | 1396 switch (j) { |
1372 case 0: return "SoftRef"; | 1397 case 0: return "SoftRef"; |
1373 case 1: return "WeakRef"; | 1398 case 1: return "WeakRef"; |
1374 case 2: return "FinalRef"; | 1399 case 2: return "FinalRef"; |
1375 case 3: return "PhantomRef"; | 1400 case 3: return "PhantomRef"; |
1401 case 4: return "CleanerRef"; | |
1376 } | 1402 } |
1377 ShouldNotReachHere(); | 1403 ShouldNotReachHere(); |
1378 return NULL; | 1404 return NULL; |
1379 } | 1405 } |
1380 | 1406 |