1491 verifier()->verify_roots_no_forwarded(); |
1491 verifier()->verify_roots_no_forwarded(); |
1492 } |
1492 } |
1493 |
1493 |
1494 stop_concurrent_marking(); |
1494 stop_concurrent_marking(); |
1495 |
1495 |
|
1496 // All allocations past TAMS are implicitly live, adjust the region data. |
|
1497 // Bitmaps/TAMS are swapped at this point, so we need to poll complete bitmap. |
1496 { |
1498 { |
1497 ShenandoahGCPhase phase(ShenandoahPhaseTimings::complete_liveness); |
1499 ShenandoahGCPhase phase(ShenandoahPhaseTimings::complete_liveness); |
1498 |
|
1499 // All allocations past TAMS are implicitly live, adjust the region data. |
|
1500 // Bitmaps/TAMS are swapped at this point, so we need to poll complete bitmap. |
|
1501 ShenandoahCompleteLivenessClosure cl; |
1500 ShenandoahCompleteLivenessClosure cl; |
1502 parallel_heap_region_iterate(&cl); |
1501 parallel_heap_region_iterate(&cl); |
1503 } |
1502 } |
1504 |
1503 |
|
1504 // Force the threads to reacquire their TLABs outside the collection set. |
1505 { |
1505 { |
1506 ShenandoahGCPhase prepare_evac(ShenandoahPhaseTimings::prepare_evac); |
1506 ShenandoahGCPhase phase(ShenandoahPhaseTimings::retire_tlabs); |
1507 |
|
1508 make_parsable(true); |
1507 make_parsable(true); |
1509 |
1508 } |
|
1509 |
|
1510 // Trash the collection set left over from previous cycle, if any. |
|
1511 { |
|
1512 ShenandoahGCPhase phase(ShenandoahPhaseTimings::trash_cset); |
1510 trash_cset_regions(); |
1513 trash_cset_regions(); |
1511 |
1514 } |
1512 { |
1515 |
1513 ShenandoahHeapLocker locker(lock()); |
1516 { |
1514 _collection_set->clear(); |
1517 ShenandoahGCPhase phase(ShenandoahPhaseTimings::prepare_evac); |
1515 _free_set->clear(); |
1518 |
1516 |
1519 ShenandoahHeapLocker locker(lock()); |
1517 heuristics()->choose_collection_set(_collection_set); |
1520 _collection_set->clear(); |
1518 |
1521 _free_set->clear(); |
1519 _free_set->rebuild(); |
1522 |
1520 } |
1523 heuristics()->choose_collection_set(_collection_set); |
|
1524 |
|
1525 _free_set->rebuild(); |
1521 } |
1526 } |
1522 |
1527 |
1523 // If collection set has candidates, start evacuation. |
1528 // If collection set has candidates, start evacuation. |
1524 // Otherwise, bypass the rest of the cycle. |
1529 // Otherwise, bypass the rest of the cycle. |
1525 if (!collection_set()->is_empty()) { |
1530 if (!collection_set()->is_empty()) { |
1578 void ShenandoahHeap::op_final_evac() { |
1583 void ShenandoahHeap::op_final_evac() { |
1579 assert(ShenandoahSafepoint::is_at_shenandoah_safepoint(), "Should be at safepoint"); |
1584 assert(ShenandoahSafepoint::is_at_shenandoah_safepoint(), "Should be at safepoint"); |
1580 |
1585 |
1581 set_evacuation_in_progress(false); |
1586 set_evacuation_in_progress(false); |
1582 |
1587 |
1583 retire_and_reset_gclabs(); |
1588 { |
|
1589 ShenandoahGCPhase phase(ShenandoahPhaseTimings::final_evac_retire_gclabs); |
|
1590 retire_and_reset_gclabs(); |
|
1591 } |
1584 |
1592 |
1585 if (ShenandoahVerify) { |
1593 if (ShenandoahVerify) { |
1586 verifier()->verify_after_evacuation(); |
1594 verifier()->verify_after_evacuation(); |
1587 } |
1595 } |
1588 |
1596 |
2232 void ShenandoahHeap::op_init_updaterefs() { |
2240 void ShenandoahHeap::op_init_updaterefs() { |
2233 assert(ShenandoahSafepoint::is_at_shenandoah_safepoint(), "must be at safepoint"); |
2241 assert(ShenandoahSafepoint::is_at_shenandoah_safepoint(), "must be at safepoint"); |
2234 |
2242 |
2235 set_evacuation_in_progress(false); |
2243 set_evacuation_in_progress(false); |
2236 |
2244 |
2237 retire_and_reset_gclabs(); |
2245 { |
|
2246 ShenandoahGCPhase phase(ShenandoahPhaseTimings::init_update_refs_retire_gclabs); |
|
2247 retire_and_reset_gclabs(); |
|
2248 } |
2238 |
2249 |
2239 if (ShenandoahVerify) { |
2250 if (ShenandoahVerify) { |
2240 if (!is_degenerated_gc_in_progress()) { |
2251 if (!is_degenerated_gc_in_progress()) { |
2241 verifier()->verify_roots_no_forwarded_except(ShenandoahRootVerifier::ThreadRoots); |
2252 verifier()->verify_roots_no_forwarded_except(ShenandoahRootVerifier::ThreadRoots); |
2242 } |
2253 } |
2243 verifier()->verify_before_updaterefs(); |
2254 verifier()->verify_before_updaterefs(); |
2244 } |
2255 } |
2245 |
2256 |
2246 set_update_refs_in_progress(true); |
2257 set_update_refs_in_progress(true); |
2247 make_parsable(true); |
2258 |
2248 for (uint i = 0; i < num_regions(); i++) { |
2259 { |
2249 ShenandoahHeapRegion* r = get_region(i); |
2260 ShenandoahGCPhase phase(ShenandoahPhaseTimings::init_update_refs_prepare); |
2250 r->set_concurrent_iteration_safe_limit(r->top()); |
2261 |
2251 } |
2262 make_parsable(true); |
2252 |
2263 for (uint i = 0; i < num_regions(); i++) { |
2253 // Reset iterator. |
2264 ShenandoahHeapRegion* r = get_region(i); |
2254 _update_refs_iterator.reset(); |
2265 r->set_concurrent_iteration_safe_limit(r->top()); |
|
2266 } |
|
2267 |
|
2268 // Reset iterator. |
|
2269 _update_refs_iterator.reset(); |
|
2270 } |
2255 |
2271 |
2256 if (ShenandoahPacing) { |
2272 if (ShenandoahPacing) { |
2257 pacer()->setup_for_updaterefs(); |
2273 pacer()->setup_for_updaterefs(); |
2258 } |
2274 } |
2259 } |
2275 } |
2261 void ShenandoahHeap::op_final_updaterefs() { |
2277 void ShenandoahHeap::op_final_updaterefs() { |
2262 assert(ShenandoahSafepoint::is_at_shenandoah_safepoint(), "must be at safepoint"); |
2278 assert(ShenandoahSafepoint::is_at_shenandoah_safepoint(), "must be at safepoint"); |
2263 |
2279 |
2264 // Check if there is left-over work, and finish it |
2280 // Check if there is left-over work, and finish it |
2265 if (_update_refs_iterator.has_next()) { |
2281 if (_update_refs_iterator.has_next()) { |
2266 ShenandoahGCPhase final_work(ShenandoahPhaseTimings::final_update_refs_finish_work); |
2282 ShenandoahGCPhase phase(ShenandoahPhaseTimings::final_update_refs_finish_work); |
2267 |
2283 |
2268 // Finish updating references where we left off. |
2284 // Finish updating references where we left off. |
2269 clear_cancelled_gc(); |
2285 clear_cancelled_gc(); |
2270 update_heap_references(false); |
2286 update_heap_references(false); |
2271 } |
2287 } |
2290 // Has to be done before cset is clear |
2306 // Has to be done before cset is clear |
2291 if (ShenandoahVerify) { |
2307 if (ShenandoahVerify) { |
2292 verifier()->verify_roots_in_to_space(); |
2308 verifier()->verify_roots_in_to_space(); |
2293 } |
2309 } |
2294 |
2310 |
2295 ShenandoahGCPhase final_update_refs(ShenandoahPhaseTimings::final_update_refs_recycle); |
2311 { |
2296 |
2312 ShenandoahGCPhase phase(ShenandoahPhaseTimings::final_update_refs_trash_cset); |
2297 trash_cset_regions(); |
2313 trash_cset_regions(); |
|
2314 } |
|
2315 |
2298 set_has_forwarded_objects(false); |
2316 set_has_forwarded_objects(false); |
2299 set_update_refs_in_progress(false); |
2317 set_update_refs_in_progress(false); |
2300 |
2318 |
2301 if (ShenandoahVerify) { |
2319 if (ShenandoahVerify) { |
2302 verifier()->verify_after_updaterefs(); |
2320 verifier()->verify_after_updaterefs(); |