Mercurial > hg > truffle
comparison src/share/vm/memory/referenceProcessor.cpp @ 20755:01dcaba9b3f3
8047125: (ref) More phantom object references
Reviewed-by: mchung, dfuchs, ahgross, jmasa, brutisso, mgerdin
Contributed-by: kim.barrett@oracle.com
author | jmasa |
---|---|
date | Fri, 26 Sep 2014 17:48:10 -0400 |
parents | 8e20ef014b08 |
children | c2844108a708 |
comparison
equal
deleted
inserted
replaced
20754:2c75e5ef41e9 | 20755:01dcaba9b3f3 |
---|---|
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); |
242 size_t phantom_count = 0; | 243 size_t phantom_count = 0; |
243 { | 244 { |
244 GCTraceTime tt("PhantomReference", trace_time, false, gc_timer); | 245 GCTraceTime tt("PhantomReference", trace_time, false, gc_timer); |
245 phantom_count = | 246 phantom_count = |
246 process_discovered_reflist(_discoveredPhantomRefs, NULL, false, | 247 process_discovered_reflist(_discoveredPhantomRefs, NULL, false, |
248 is_alive, keep_alive, complete_gc, task_executor); | |
249 | |
250 // Process cleaners, but include them in phantom statistics. We expect | |
251 // Cleaner references to be temporary, and don't want to deal with | |
252 // possible incompatibilities arising from making it more visible. | |
253 phantom_count += | |
254 process_discovered_reflist(_discoveredCleanerRefs, NULL, false, | |
247 is_alive, keep_alive, complete_gc, task_executor); | 255 is_alive, keep_alive, complete_gc, task_executor); |
248 } | 256 } |
249 | 257 |
250 // Weak global JNI references. It would make more sense (semantically) to | 258 // Weak global JNI references. It would make more sense (semantically) to |
251 // traverse these simultaneously with the regular weak references above, but | 259 // traverse these simultaneously with the regular weak references above, but |
880 void ReferenceProcessor::balance_all_queues() { | 888 void ReferenceProcessor::balance_all_queues() { |
881 balance_queues(_discoveredSoftRefs); | 889 balance_queues(_discoveredSoftRefs); |
882 balance_queues(_discoveredWeakRefs); | 890 balance_queues(_discoveredWeakRefs); |
883 balance_queues(_discoveredFinalRefs); | 891 balance_queues(_discoveredFinalRefs); |
884 balance_queues(_discoveredPhantomRefs); | 892 balance_queues(_discoveredPhantomRefs); |
893 balance_queues(_discoveredCleanerRefs); | |
885 } | 894 } |
886 | 895 |
887 size_t | 896 size_t |
888 ReferenceProcessor::process_discovered_reflist( | 897 ReferenceProcessor::process_discovered_reflist( |
889 DiscoveredList refs_lists[], | 898 DiscoveredList refs_lists[], |
1038 case REF_FINAL: | 1047 case REF_FINAL: |
1039 list = &_discoveredFinalRefs[id]; | 1048 list = &_discoveredFinalRefs[id]; |
1040 break; | 1049 break; |
1041 case REF_PHANTOM: | 1050 case REF_PHANTOM: |
1042 list = &_discoveredPhantomRefs[id]; | 1051 list = &_discoveredPhantomRefs[id]; |
1052 break; | |
1053 case REF_CLEANER: | |
1054 list = &_discoveredCleanerRefs[id]; | |
1043 break; | 1055 break; |
1044 case REF_NONE: | 1056 case REF_NONE: |
1045 // we should not reach here if we are an InstanceRefKlass | 1057 // we should not reach here if we are an InstanceRefKlass |
1046 default: | 1058 default: |
1047 ShouldNotReachHere(); | 1059 ShouldNotReachHere(); |
1303 return; | 1315 return; |
1304 } | 1316 } |
1305 preclean_discovered_reflist(_discoveredPhantomRefs[i], is_alive, | 1317 preclean_discovered_reflist(_discoveredPhantomRefs[i], is_alive, |
1306 keep_alive, complete_gc, yield); | 1318 keep_alive, complete_gc, yield); |
1307 } | 1319 } |
1320 | |
1321 // Cleaner references. Included in timing for phantom references. We | |
1322 // expect Cleaner references to be temporary, and don't want to deal with | |
1323 // possible incompatibilities arising from making it more visible. | |
1324 for (uint i = 0; i < _max_num_q; i++) { | |
1325 if (yield->should_return()) { | |
1326 return; | |
1327 } | |
1328 preclean_discovered_reflist(_discoveredCleanerRefs[i], is_alive, | |
1329 keep_alive, complete_gc, yield); | |
1330 } | |
1308 } | 1331 } |
1309 } | 1332 } |
1310 | 1333 |
1311 // Walk the given discovered ref list, and remove all reference objects | 1334 // Walk the given discovered ref list, and remove all reference objects |
1312 // whose referents are still alive, whose referents are NULL or which | 1335 // whose referents are still alive, whose referents are NULL or which |
1371 switch (j) { | 1394 switch (j) { |
1372 case 0: return "SoftRef"; | 1395 case 0: return "SoftRef"; |
1373 case 1: return "WeakRef"; | 1396 case 1: return "WeakRef"; |
1374 case 2: return "FinalRef"; | 1397 case 2: return "FinalRef"; |
1375 case 3: return "PhantomRef"; | 1398 case 3: return "PhantomRef"; |
1399 case 4: return "CleanerRef"; | |
1376 } | 1400 } |
1377 ShouldNotReachHere(); | 1401 ShouldNotReachHere(); |
1378 return NULL; | 1402 return NULL; |
1379 } | 1403 } |
1380 | 1404 |