--- a/src/hotspot/share/gc/shenandoah/shenandoahMarkCompact.cpp Thu Oct 17 20:27:44 2019 +0100
+++ b/src/hotspot/share/gc/shenandoah/shenandoahMarkCompact.cpp Thu Oct 17 20:53:35 2019 +0100
@@ -175,8 +175,6 @@
_preserved_marks->restore(&exec);
BiasedLocking::restore_marks();
_preserved_marks->reclaim();
-
- JvmtiExport::gc_epilogue();
}
// Resize metaspace
@@ -329,14 +327,25 @@
ShenandoahHeapRegion* next_from_region(ShenandoahHeapRegionSet* slice) {
ShenandoahHeapRegion* from_region = _heap_regions.next();
- while (from_region != NULL && (!from_region->is_move_allowed() || from_region->is_humongous())) {
+ // Look for next candidate for this slice:
+ while (from_region != NULL) {
+ // Empty region: get it into the slice to defragment the slice itself.
+ // We could have skipped this without violating correctness, but we really
+ // want to compact all live regions to the start of the heap, which sometimes
+ // means moving them into the fully empty regions.
+ if (from_region->is_empty()) break;
+
+ // Can move the region, and this is not the humongous region. Humongous
+ // moves are special cased here, because their moves are handled separately.
+ if (from_region->is_stw_move_allowed() && !from_region->is_humongous()) break;
+
from_region = _heap_regions.next();
}
if (from_region != NULL) {
assert(slice != NULL, "sanity");
assert(!from_region->is_humongous(), "this path cannot handle humongous regions");
- assert(from_region->is_move_allowed(), "only regions that can be moved in mark-compact");
+ assert(from_region->is_empty() || from_region->is_stw_move_allowed(), "only regions that can be moved in mark-compact");
slice->add_region(from_region);
}
@@ -410,7 +419,7 @@
continue;
}
- if (r->is_humongous_start() && r->is_move_allowed()) {
+ if (r->is_humongous_start() && r->is_stw_move_allowed()) {
// From-region candidate: movable humongous region
oop old_obj = oop(r->bottom());
size_t words_size = old_obj->size();
@@ -752,7 +761,7 @@
size_t new_start = heap->heap_region_index_containing(old_obj->forwardee());
size_t new_end = new_start + num_regions - 1;
assert(old_start != new_start, "must be real move");
- assert (r->is_move_allowed(), "should be movable");
+ assert(r->is_stw_move_allowed(), "Region " SIZE_FORMAT " should be movable", r->region_number());
Copy::aligned_conjoint_words(heap->get_region(old_start)->bottom(),
heap->get_region(new_start)->bottom(),