< prev index next >

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

Print this page

 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *
 23  */
 24 
 25 #include "precompiled.hpp"
 26 #include "gc/g1/g1CollectedHeap.hpp"
 27 #include "gc/g1/g1ConcurrentMarkBitMap.inline.hpp"
 28 #include "gc/g1/g1FullCollector.hpp"
 29 #include "gc/g1/g1FullCollector.inline.hpp"
 30 #include "gc/g1/g1FullGCCompactionPoint.hpp"
 31 #include "gc/g1/g1FullGCCompactTask.hpp"
 32 #include "gc/g1/heapRegion.inline.hpp"
 33 #include "gc/shared/gcTraceTime.inline.hpp"

 34 #include "logging/log.hpp"
 35 #include "oops/oop.inline.hpp"
 36 #include "utilities/ticks.hpp"
 37 
 38 // Do work for all skip-compacting regions.
 39 class G1ResetSkipCompactingClosure : public HeapRegionClosure {
 40   G1FullCollector* _collector;
 41 
 42 public:
 43   G1ResetSkipCompactingClosure(G1FullCollector* collector) : _collector(collector) { }
 44 
 45   bool do_heap_region(HeapRegion* r) {
 46     uint region_index = r->hrm_index();
 47     // Only for skip-compaction regions; early return otherwise.
 48     if (!_collector->is_skip_compacting(region_index)) {
 49       return false;
 50     }
 51 #ifdef ASSERT
 52     if (r->is_humongous()) {
 53       oop obj = cast_to_oop(r->humongous_start_region()->bottom());

 63              "should be quite full");
 64     }
 65 #endif
 66     r->reset_skip_compacting_after_full_gc();
 67     return false;
 68   }
 69 };
 70 
 71 void G1FullGCCompactTask::G1CompactRegionClosure::clear_in_prev_bitmap(oop obj) {
 72   assert(_bitmap->is_marked(obj), "Should only compact marked objects");
 73   _bitmap->clear(obj);
 74 }
 75 
 76 size_t G1FullGCCompactTask::G1CompactRegionClosure::apply(oop obj) {
 77   size_t size = obj->size();
 78   if (!obj->is_forwarded()) {
 79     // Object not moving, but clear the mark to allow reuse of the bitmap.
 80     clear_in_prev_bitmap(obj);
 81     return size;
 82   }
 83 
 84   HeapWord* destination = cast_from_oop<HeapWord*>(obj->forwardee());
 85 
 86   // copy object and reinit its mark
 87   HeapWord* obj_addr = cast_from_oop<HeapWord*>(obj);
 88   assert(obj_addr != destination, "everything in this pass should be moving");
 89   Copy::aligned_conjoint_words(obj_addr, destination, size);
 90   cast_to_oop(destination)->init_mark();
 91   assert(cast_to_oop(destination)->klass() != NULL, "should have a class");
 92 
 93   // Clear the mark for the compacted object to allow reuse of the
 94   // bitmap without an additional clearing step.
 95   clear_in_prev_bitmap(obj);
 96   return size;
 97 }
 98 
 99 void G1FullGCCompactTask::compact_region(HeapRegion* hr) {
100   assert(!hr->is_pinned(), "Should be no pinned region in compaction queue");
101   assert(!hr->is_humongous(), "Should be no humongous regions in compaction queue");
102 
103   if (!collector()->is_free(hr->hrm_index())) {
104     // The compaction closure not only copies the object to the new

 14  *
 15  * You should have received a copy of the GNU General Public License version
 16  * 2 along with this work; if not, write to the Free Software Foundation,
 17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 18  *
 19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 20  * or visit www.oracle.com if you need additional information or have any
 21  * questions.
 22  *
 23  */
 24 
 25 #include "precompiled.hpp"
 26 #include "gc/g1/g1CollectedHeap.hpp"
 27 #include "gc/g1/g1ConcurrentMarkBitMap.inline.hpp"
 28 #include "gc/g1/g1FullCollector.hpp"
 29 #include "gc/g1/g1FullCollector.inline.hpp"
 30 #include "gc/g1/g1FullGCCompactionPoint.hpp"
 31 #include "gc/g1/g1FullGCCompactTask.hpp"
 32 #include "gc/g1/heapRegion.inline.hpp"
 33 #include "gc/shared/gcTraceTime.inline.hpp"
 34 #include "gc/shared/slidingForwarding.inline.hpp"
 35 #include "logging/log.hpp"
 36 #include "oops/oop.inline.hpp"
 37 #include "utilities/ticks.hpp"
 38 
 39 // Do work for all skip-compacting regions.
 40 class G1ResetSkipCompactingClosure : public HeapRegionClosure {
 41   G1FullCollector* _collector;
 42 
 43 public:
 44   G1ResetSkipCompactingClosure(G1FullCollector* collector) : _collector(collector) { }
 45 
 46   bool do_heap_region(HeapRegion* r) {
 47     uint region_index = r->hrm_index();
 48     // Only for skip-compaction regions; early return otherwise.
 49     if (!_collector->is_skip_compacting(region_index)) {
 50       return false;
 51     }
 52 #ifdef ASSERT
 53     if (r->is_humongous()) {
 54       oop obj = cast_to_oop(r->humongous_start_region()->bottom());

 64              "should be quite full");
 65     }
 66 #endif
 67     r->reset_skip_compacting_after_full_gc();
 68     return false;
 69   }
 70 };
 71 
 72 void G1FullGCCompactTask::G1CompactRegionClosure::clear_in_prev_bitmap(oop obj) {
 73   assert(_bitmap->is_marked(obj), "Should only compact marked objects");
 74   _bitmap->clear(obj);
 75 }
 76 
 77 size_t G1FullGCCompactTask::G1CompactRegionClosure::apply(oop obj) {
 78   size_t size = obj->size();
 79   if (!obj->is_forwarded()) {
 80     // Object not moving, but clear the mark to allow reuse of the bitmap.
 81     clear_in_prev_bitmap(obj);
 82     return size;
 83   }
 84   HeapWord* destination = cast_from_oop<HeapWord*>(_forwarding->forwardee(obj));

 85 
 86   // copy object and reinit its mark
 87   HeapWord* obj_addr = cast_from_oop<HeapWord*>(obj);
 88   assert(obj_addr != destination, "everything in this pass should be moving");
 89   Copy::aligned_conjoint_words(obj_addr, destination, size);
 90   cast_to_oop(destination)->init_mark();
 91   assert(cast_to_oop(destination)->klass() != NULL, "should have a class");
 92 
 93   // Clear the mark for the compacted object to allow reuse of the
 94   // bitmap without an additional clearing step.
 95   clear_in_prev_bitmap(obj);
 96   return size;
 97 }
 98 
 99 void G1FullGCCompactTask::compact_region(HeapRegion* hr) {
100   assert(!hr->is_pinned(), "Should be no pinned region in compaction queue");
101   assert(!hr->is_humongous(), "Should be no humongous regions in compaction queue");
102 
103   if (!collector()->is_free(hr->hrm_index())) {
104     // The compaction closure not only copies the object to the new
< prev index next >