--- old/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp 2018-04-03 14:10:08.771032207 +0200 +++ new/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp 2018-04-03 14:10:08.515024408 +0200 @@ -1025,15 +1025,22 @@ void distribute_marked_bytes(HeapRegion* hr, size_t marked_words) { uint const region_idx = hr->hrm_index(); - assert(hr->is_starts_humongous(), "Should not have marked bytes " SIZE_FORMAT " in non-starts humongous region %u (%s)", marked_words, region_idx, hr->get_type_str()); + assert(hr->is_starts_humongous(), + "Should not have marked bytes " SIZE_FORMAT " in non-starts humongous region %u (%s)", + marked_words, region_idx, hr->get_type_str()); uint num_regions_in_humongous = (uint)G1CollectedHeap::humongous_obj_size_in_regions(marked_words); for (uint i = region_idx; i < (region_idx + num_regions_in_humongous); i++) { HeapRegion* const r = _g1h->region_at(i); size_t const words_to_add = MIN2(HeapRegion::GrainWords, marked_words); + assert(words_to_add > 0, "Out of space to distribute before end of humongous object in region %u (starts %u)", i, region_idx); + r->add_to_marked_bytes(words_to_add * HeapWordSize); marked_words -= words_to_add; } + assert(marked_words == 0, + SIZE_FORMAT " words left after distributing space across %u regions", + marked_words, num_regions_in_humongous); } void update_marked_bytes(HeapRegion* hr) { @@ -1042,20 +1049,23 @@ // The marking attributes the object's size completely to the humongous starts // region. We need to distribute this value across the entire set of regions a // humongous object spans. - if (!hr->is_humongous()) { - hr->add_to_marked_bytes(marked_words * HeapWordSize); - log_trace(gc)("Added " SIZE_FORMAT " words to region %u (%s)", marked_words, region_idx, hr->get_type_str()); - } else { + if (hr->is_humongous()) { if (marked_words > 0) { - log_trace(gc)("Distributing " SIZE_FORMAT " words to humongous start region %u (%s), word size %d (%f)", - marked_words, region_idx, hr->get_type_str(), - oop(hr->bottom())->size(), (double)oop(hr->bottom())->size() / HeapRegion::GrainWords); + log_trace(gc, marking)("Adding " SIZE_FORMAT " words to humongous start region %u (%s), word size %d (%f)", + marked_words, region_idx, hr->get_type_str(), + oop(hr->bottom())->size(), (double)oop(hr->bottom())->size() / HeapRegion::GrainWords); distribute_marked_bytes(hr, marked_words); } else { - log_trace(gc)("NOT Added " SIZE_FORMAT " words to region %u (%s)", marked_words, region_idx, hr->get_type_str()); + assert(marked_words == 0, + "Asked to add " SIZE_FORMAT " words to add to continues humongous region %u (%s)", + marked_words, region_idx, hr->get_type_str()); } + } else { + log_trace(gc, marking)("Adding " SIZE_FORMAT " words to region %u (%s)", marked_words, region_idx, hr->get_type_str()); + hr->add_to_marked_bytes(marked_words * HeapWordSize); } } + public: G1UpdateRemSetTrackingBeforeRebuild(G1CollectedHeap* g1h, G1ConcurrentMark* cm) : _g1h(g1h), _cm(cm), _cl("Post-Marking"), _num_regions_selected_for_rebuild(0) { } @@ -1680,15 +1690,13 @@ void G1ConcurrentMark::report_object_count(bool mark_completed) { // Depending on the completion of the marking liveness needs to be determined // using either the next or prev bitmap. - G1ObjectCountIsAliveClosure is_alive_prev(_g1h); - G1CMIsAliveClosure is_alive_next(_g1h); - BoolObjectClosure* is_alive; if (mark_completed) { - is_alive = &is_alive_prev; + G1ObjectCountIsAliveClosure is_alive(_g1h); + _gc_tracer_cm->report_object_count_after_gc(&is_alive); } else { - is_alive = &is_alive_next; + G1CMIsAliveClosure is_alive(_g1h); + _gc_tracer_cm->report_object_count_after_gc(&is_alive); } - _gc_tracer_cm->report_object_count_after_gc(is_alive); }