--- a/src/hotspot/share/gc/g1/g1RemSetTrackingPolicy.cpp Mon Jul 09 12:20:56 2018 +0800
+++ b/src/hotspot/share/gc/g1/g1RemSetTrackingPolicy.cpp Mon Jul 09 10:19:51 2018 +0200
@@ -29,10 +29,6 @@
#include "gc/g1/heapRegionRemSet.hpp"
#include "runtime/safepoint.hpp"
-bool G1RemSetTrackingPolicy::is_interesting_humongous_region(HeapRegion* r) const {
- return r->is_humongous() && oop(r->humongous_start_region()->bottom())->is_typeArray();
-}
-
bool G1RemSetTrackingPolicy::needs_scan_for_rebuild(HeapRegion* r) const {
// All non-free, non-young, non-closed archive regions need to be scanned for references;
// At every gc we gather references to other regions in young, and closed archive
@@ -64,51 +60,81 @@
/* nothing to do */
}
+static void print_before_rebuild(HeapRegion* r, bool selected_for_rebuild, size_t total_live_bytes, size_t live_bytes) {
+ log_trace(gc, remset, tracking)("Before rebuild region %u "
+ "(ntams: " PTR_FORMAT ") "
+ "total_live_bytes " SIZE_FORMAT " "
+ "selected %s "
+ "(live_bytes " SIZE_FORMAT " "
+ "next_marked " SIZE_FORMAT " "
+ "marked " SIZE_FORMAT " "
+ "type %s)",
+ r->hrm_index(),
+ p2i(r->next_top_at_mark_start()),
+ total_live_bytes,
+ BOOL_TO_STR(selected_for_rebuild),
+ live_bytes,
+ r->next_marked_bytes(),
+ r->marked_bytes(),
+ r->get_type_str());
+}
+
+bool G1RemSetTrackingPolicy::update_humongous_before_rebuild(HeapRegion* r, bool is_live) {
+ assert(SafepointSynchronize::is_at_safepoint(), "should be at safepoint");
+ assert(r->is_humongous(), "Region %u should be humongous", r->hrm_index());
+
+ if (r->is_archive()) {
+ return false;
+ }
+
+ assert(!r->rem_set()->is_updating(), "Remembered set of region %u is updating before rebuild", r->hrm_index());
+
+ bool selected_for_rebuild = false;
+ // For humongous regions, to be of interest for rebuilding the remembered set the following must apply:
+ // - We always try to update the remembered sets of humongous regions containing
+ // type arrays as they might have been reset after full gc.
+ if (is_live && oop(r->humongous_start_region()->bottom())->is_typeArray() && !r->rem_set()->is_tracked()) {
+ r->rem_set()->set_state_updating();
+ selected_for_rebuild = true;
+ }
+
+ size_t const live_bytes = is_live ? HeapRegion::GrainBytes : 0;
+ print_before_rebuild(r, selected_for_rebuild, live_bytes, live_bytes);
+
+ return selected_for_rebuild;
+}
+
bool G1RemSetTrackingPolicy::update_before_rebuild(HeapRegion* r, size_t live_bytes) {
assert(SafepointSynchronize::is_at_safepoint(), "should be at safepoint");
-
- bool selected_for_rebuild = false;
+ assert(!r->is_humongous(), "Region %u is humongous", r->hrm_index());
// Only consider updating the remembered set for old gen regions - excluding archive regions
// which never move (but are "Old" regions).
- if (r->is_old_or_humongous() && !r->is_archive()) {
- size_t between_ntams_and_top = (r->top() - r->next_top_at_mark_start()) * HeapWordSize;
- size_t total_live_bytes = live_bytes + between_ntams_and_top;
- // Completely free regions after rebuild are of no interest wrt rebuilding the
- // remembered set.
- assert(!r->rem_set()->is_updating(), "Remembered set of region %u is updating before rebuild", r->hrm_index());
- // To be of interest for rebuilding the remembered set the following must apply:
- // - They must contain some live data in them.
- // - We always try to update the remembered sets of humongous regions containing
- // type arrays if they are empty as they might have been reset after full gc.
- // - Only need to rebuild non-complete remembered sets.
- // - Otherwise only add those old gen regions which occupancy is low enough that there
- // is a chance that we will ever evacuate them in the mixed gcs.
- if ((total_live_bytes > 0) &&
- (is_interesting_humongous_region(r) || CollectionSetChooser::region_occupancy_low_enough_for_evac(total_live_bytes)) &&
- !r->rem_set()->is_tracked()) {
+ if (!r->is_old() || r->is_archive()) {
+ return false;
+ }
+
+ assert(!r->rem_set()->is_updating(), "Remembered set of region %u is updating before rebuild", r->hrm_index());
+
+ size_t between_ntams_and_top = (r->top() - r->next_top_at_mark_start()) * HeapWordSize;
+ size_t total_live_bytes = live_bytes + between_ntams_and_top;
- r->rem_set()->set_state_updating();
- selected_for_rebuild = true;
- }
- log_trace(gc, remset, tracking)("Before rebuild region %u "
- "(ntams: " PTR_FORMAT ") "
- "total_live_bytes " SIZE_FORMAT " "
- "selected %s "
- "(live_bytes " SIZE_FORMAT " "
- "next_marked " SIZE_FORMAT " "
- "marked " SIZE_FORMAT " "
- "type %s)",
- r->hrm_index(),
- p2i(r->next_top_at_mark_start()),
- total_live_bytes,
- BOOL_TO_STR(selected_for_rebuild),
- live_bytes,
- r->next_marked_bytes(),
- r->marked_bytes(),
- r->get_type_str());
+ bool selected_for_rebuild = false;
+ // For old regions, to be of interest for rebuilding the remembered set the following must apply:
+ // - They must contain some live data in them.
+ // - Only need to rebuild non-complete remembered sets.
+ // - Otherwise only add those old gen regions which occupancy is low enough that there
+ // is a chance that we will ever evacuate them in the mixed gcs.
+ if ((total_live_bytes > 0) &&
+ CollectionSetChooser::region_occupancy_low_enough_for_evac(total_live_bytes) &&
+ !r->rem_set()->is_tracked()) {
+
+ r->rem_set()->set_state_updating();
+ selected_for_rebuild = true;
}
+ print_before_rebuild(r, selected_for_rebuild, total_live_bytes, live_bytes);
+
return selected_for_rebuild;
}
@@ -149,4 +175,3 @@
r->rem_set()->mem_size());
}
}
-