diff --git a/src/share/vm/gc_implementation/g1/concurrentMark.cpp b/src/share/vm/gc_implementation/g1/concurrentMark.cpp index 3ec008e7e59d2c46709be7d13dcb059967c1d87c..c66b309e4a3a8996175799063fa788a146444ea1 100644 --- a/src/share/vm/gc_implementation/g1/concurrentMark.cpp +++ b/src/share/vm/gc_implementation/g1/concurrentMark.cpp @@ -890,6 +890,10 @@ void ConcurrentMark::clearNextBitmap() { guarantee(!g1h->mark_in_progress(), "invariant"); } +bool ConcurrentMark::nextMarkBitmapIsClear() { + return _nextMarkBitMap->getNextMarkedWordAddress(_heap_start, _heap_end) == _heap_end; +} + class NoteStartOfMarkHRClosure: public HeapRegionClosure { public: bool doHeapRegion(HeapRegion* r) { @@ -3358,7 +3362,8 @@ void ConcurrentMark::print_stats() { // abandon current marking iteration due to a Full GC void ConcurrentMark::abort() { - // Clear all marks to force marking thread to do nothing + // Clear all marks in the next bitmap for the next marking cycle. This will allow us to skip the next + // concurrent bitmap clearing. _nextMarkBitMap->clearAll(); // Clear the liveness counting data clear_all_count_data(); diff --git a/src/share/vm/gc_implementation/g1/concurrentMark.hpp b/src/share/vm/gc_implementation/g1/concurrentMark.hpp index b32e4f35aa70db888be336e2ff449196caa6ace2..b630b42de6eda64bfd5076e0d3f0c60075206d46 100644 --- a/src/share/vm/gc_implementation/g1/concurrentMark.hpp +++ b/src/share/vm/gc_implementation/g1/concurrentMark.hpp @@ -736,6 +736,9 @@ public: // Clear the next marking bitmap (will be called concurrently). void clearNextBitmap(); + // Return whether the next mark bitmap has no marks set. + bool nextMarkBitmapIsClear(); + // These two do the work that needs to be done before and after the // initial root checkpoint. Since this checkpoint can be done at two // different points (i.e. an explicit pause or piggy-backed on a diff --git a/src/share/vm/gc_implementation/g1/concurrentMarkThread.cpp b/src/share/vm/gc_implementation/g1/concurrentMarkThread.cpp index b3f950b4c93135b9f8042e10189928da3fef88f1..b56e3092349347b25b8ed6c54cd6eea86107261a 100644 --- a/src/share/vm/gc_implementation/g1/concurrentMarkThread.cpp +++ b/src/share/vm/gc_implementation/g1/concurrentMarkThread.cpp @@ -275,9 +275,13 @@ void ConcurrentMarkThread::run() { // We now want to allow clearing of the marking bitmap to be // suspended by a collection pause. - { + // We may have aborted just before the remark. Do not bother clearing the + // bitmap then, as it has been done during mark abort. + if (!cm()->has_aborted()) { SuspendibleThreadSetJoiner sts; _cm->clearNextBitmap(); + } else { + assert(!G1VerifyBitmaps || _cm->nextMarkBitmapIsClear(), "Next mark bitmap must be clear"); } }