@@ -2427,6 +2427,10 @@ class UpdateDensePrefixAndCompactionTask: public WorkerTask {
2427
2427
// Once a thread has drained it's stack, it should try to steal regions from
2428
2428
// other threads.
2429
2429
compaction_with_stealing_work (&_terminator, worker_id);
2430
+
2431
+ // At this point all regions have been compacted, so it's now safe
2432
+ // to update the deferred objects that cross region boundaries.
2433
+ cm->drain_deferred_objects ();
2430
2434
}
2431
2435
};
2432
2436
@@ -2456,22 +2460,13 @@ void PSParallelCompact::compact() {
2456
2460
ParallelScavengeHeap::heap ()->workers ().run_task (&task);
2457
2461
2458
2462
#ifdef ASSERT
2459
- // Verify that all regions have been processed before the deferred updates .
2463
+ // Verify that all regions have been processed.
2460
2464
for (unsigned int id = old_space_id; id < last_space_id; ++id) {
2461
2465
verify_complete (SpaceId (id));
2462
2466
}
2463
2467
#endif
2464
2468
}
2465
2469
2466
- {
2467
- GCTraceTime (Trace, gc, phases) tm (" Deferred Updates" , &_gc_timer);
2468
- // Update the deferred objects, if any.
2469
- ParCompactionManager* cm = ParCompactionManager::get_vmthread_cm ();
2470
- for (unsigned int id = old_space_id; id < last_space_id; ++id) {
2471
- update_deferred_objects (cm, SpaceId (id));
2472
- }
2473
- }
2474
-
2475
2470
DEBUG_ONLY (write_block_fill_histogram ());
2476
2471
}
2477
2472
@@ -2598,32 +2593,22 @@ PSParallelCompact::SpaceId PSParallelCompact::space_id(HeapWord* addr) {
2598
2593
return last_space_id;
2599
2594
}
2600
2595
2601
- void PSParallelCompact::update_deferred_objects (ParCompactionManager* cm,
2602
- SpaceId id) {
2603
- assert (id < last_space_id, " bad space id" );
2604
-
2596
+ void PSParallelCompact::update_deferred_object (ParCompactionManager* cm, HeapWord *addr) {
2597
+ #ifdef ASSERT
2605
2598
ParallelCompactData& sd = summary_data ();
2606
- const SpaceInfo* const space_info = _space_info + id;
2607
- ObjectStartArray* const start_array = space_info->start_array ();
2599
+ size_t region_idx = sd.addr_to_region_idx (addr);
2600
+ assert (sd.region (region_idx)->completed (), " first region must be completed before deferred updates" );
2601
+ assert (sd.region (region_idx + 1 )->completed (), " second region must be completed before deferred updates" );
2602
+ #endif
2608
2603
2609
- const MutableSpace* const space = space_info->space ();
2610
- assert (space_info->dense_prefix () >= space->bottom (), " dense_prefix not set" );
2611
- HeapWord* const beg_addr = space_info->dense_prefix ();
2612
- HeapWord* const end_addr = sd.region_align_up (space_info->new_top ());
2613
-
2614
- const RegionData* const beg_region = sd.addr_to_region_ptr (beg_addr);
2615
- const RegionData* const end_region = sd.addr_to_region_ptr (end_addr);
2616
- const RegionData* cur_region;
2617
- for (cur_region = beg_region; cur_region < end_region; ++cur_region) {
2618
- HeapWord* const addr = cur_region->deferred_obj_addr ();
2619
- if (addr != NULL ) {
2620
- if (start_array != NULL ) {
2621
- start_array->allocate_block (addr);
2622
- }
2623
- cm->update_contents (cast_to_oop (addr));
2624
- assert (oopDesc::is_oop_or_null (cast_to_oop (addr)), " Expected an oop or NULL at " PTR_FORMAT, p2i (cast_to_oop (addr)));
2625
- }
2604
+ const SpaceInfo* const space_info = _space_info + space_id (addr);
2605
+ ObjectStartArray* const start_array = space_info->start_array ();
2606
+ if (start_array != NULL ) {
2607
+ start_array->allocate_block (addr);
2626
2608
}
2609
+
2610
+ cm->update_contents (cast_to_oop (addr));
2611
+ assert (oopDesc::is_oop (cast_to_oop (addr)), " Expected an oop at " PTR_FORMAT, p2i (cast_to_oop (addr)));
2627
2612
}
2628
2613
2629
2614
// Skip over count live words starting from beg, and return the address of the
@@ -2870,7 +2855,6 @@ void PSParallelCompact::fill_region(ParCompactionManager* cm, MoveAndUpdateClosu
2870
2855
if (closure.is_full ()) {
2871
2856
decrement_destination_counts (cm, src_space_id, src_region_idx,
2872
2857
closure.source ());
2873
- region_ptr->set_deferred_obj_addr (NULL );
2874
2858
closure.complete_region (cm, dest_addr, region_ptr);
2875
2859
return ;
2876
2860
}
@@ -2915,7 +2899,7 @@ void PSParallelCompact::fill_region(ParCompactionManager* cm, MoveAndUpdateClosu
2915
2899
if (status == ParMarkBitMap::would_overflow) {
2916
2900
// The last object did not fit. Note that interior oop updates were
2917
2901
// deferred, then copy enough of the object to fill the region.
2918
- region_ptr-> set_deferred_obj_addr (closure.destination ());
2902
+ cm-> push_deferred_object (closure.destination ());
2919
2903
status = closure.copy_until_full (); // copies from closure.source()
2920
2904
2921
2905
decrement_destination_counts (cm, src_space_id, src_region_idx,
@@ -2927,7 +2911,6 @@ void PSParallelCompact::fill_region(ParCompactionManager* cm, MoveAndUpdateClosu
2927
2911
if (status == ParMarkBitMap::full) {
2928
2912
decrement_destination_counts (cm, src_space_id, src_region_idx,
2929
2913
closure.source ());
2930
- region_ptr->set_deferred_obj_addr (NULL );
2931
2914
closure.complete_region (cm, dest_addr, region_ptr);
2932
2915
return ;
2933
2916
}
0 commit comments