< prev index next >

src/hotspot/share/gc/g1/g1FullGCCompactTask.cpp

Print this page

 42 size_t G1FullGCCompactTask::G1CompactRegionClosure::apply(oop obj) {
 43   size_t size = obj->size();
 44   if (FullGCForwarding::is_forwarded(obj)) {
 45     G1FullGCCompactTask::copy_object_to_new_location(obj);
 46   }
 47 
 48   // Clear the mark for the compacted object to allow reuse of the
 49   // bitmap without an additional clearing step.
 50   clear_in_bitmap(obj);
 51   return size;
 52 }
 53 
 54 void G1FullGCCompactTask::copy_object_to_new_location(oop obj) {
 55   assert(FullGCForwarding::is_forwarded(obj), "Sanity!");
 56   assert(FullGCForwarding::forwardee(obj) != obj, "Object must have a new location");
 57 
 58   size_t size = obj->size();
 59   // Copy object and reinit its mark.
 60   HeapWord* obj_addr = cast_from_oop<HeapWord*>(obj);
 61   HeapWord* destination = cast_from_oop<HeapWord*>(FullGCForwarding::forwardee(obj));

 62   Copy::aligned_conjoint_words(obj_addr, destination, size);
 63 
 64   // There is no need to transform stack chunks - marking already did that.
 65   cast_to_oop(destination)->init_mark();

 66   assert(cast_to_oop(destination)->klass() != nullptr, "should have a class");
 67 }
 68 
 69 void G1FullGCCompactTask::compact_region(G1HeapRegion* hr) {
 70   assert(!hr->has_pinned_objects(), "Should be no region with pinned objects in compaction queue");
 71   assert(!hr->is_humongous(), "Should be no humongous regions in compaction queue");
 72 
 73   if (!collector()->is_free(hr->hrm_index())) {
 74     // The compaction closure not only copies the object to the new
 75     // location, but also clears the bitmap for it. This is needed
 76     // for bitmap verification and to be able to use the bitmap
 77     // for evacuation failures in the next young collection. Testing
 78     // showed that it was better overall to clear bit by bit, compared
 79     // to clearing the whole region at the end. This difference was
 80     // clearly seen for regions with few marks.
 81     G1CompactRegionClosure compact(collector()->mark_bitmap());
 82     hr->apply_to_marked_objects(collector()->mark_bitmap(), &compact);
 83   }
 84 
 85   hr->reset_compacted_after_full_gc(_collector->compaction_top(hr));

 42 size_t G1FullGCCompactTask::G1CompactRegionClosure::apply(oop obj) {
 43   size_t size = obj->size();
 44   if (FullGCForwarding::is_forwarded(obj)) {
 45     G1FullGCCompactTask::copy_object_to_new_location(obj);
 46   }
 47 
 48   // Clear the mark for the compacted object to allow reuse of the
 49   // bitmap without an additional clearing step.
 50   clear_in_bitmap(obj);
 51   return size;
 52 }
 53 
 54 void G1FullGCCompactTask::copy_object_to_new_location(oop obj) {
 55   assert(FullGCForwarding::is_forwarded(obj), "Sanity!");
 56   assert(FullGCForwarding::forwardee(obj) != obj, "Object must have a new location");
 57 
 58   size_t size = obj->size();
 59   // Copy object and reinit its mark.
 60   HeapWord* obj_addr = cast_from_oop<HeapWord*>(obj);
 61   HeapWord* destination = cast_from_oop<HeapWord*>(FullGCForwarding::forwardee(obj));
 62   assert(obj_addr != destination, "only copy actually-moving objects");
 63   Copy::aligned_conjoint_words(obj_addr, destination, size);
 64 
 65   // There is no need to transform stack chunks - marking already did that.
 66   cast_to_oop(destination)->init_mark();
 67   cast_to_oop(destination)->initialize_hash_if_necessary(obj);
 68   assert(cast_to_oop(destination)->klass() != nullptr, "should have a class");
 69 }
 70 
 71 void G1FullGCCompactTask::compact_region(G1HeapRegion* hr) {
 72   assert(!hr->has_pinned_objects(), "Should be no region with pinned objects in compaction queue");
 73   assert(!hr->is_humongous(), "Should be no humongous regions in compaction queue");
 74 
 75   if (!collector()->is_free(hr->hrm_index())) {
 76     // The compaction closure not only copies the object to the new
 77     // location, but also clears the bitmap for it. This is needed
 78     // for bitmap verification and to be able to use the bitmap
 79     // for evacuation failures in the next young collection. Testing
 80     // showed that it was better overall to clear bit by bit, compared
 81     // to clearing the whole region at the end. This difference was
 82     // clearly seen for regions with few marks.
 83     G1CompactRegionClosure compact(collector()->mark_bitmap());
 84     hr->apply_to_marked_objects(collector()->mark_bitmap(), &compact);
 85   }
 86 
 87   hr->reset_compacted_after_full_gc(_collector->compaction_top(hr));
< prev index next >