< prev index next >

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

Print this page
rev 53418 : imported patch 8217328-rename-collectionsetchooser
   1 /*
   2  * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  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/collectionSetChooser.hpp"
  27 #include "gc/g1/g1RemSetTrackingPolicy.hpp"
  28 #include "gc/g1/heapRegion.inline.hpp"
  29 #include "gc/g1/heapRegionRemSet.hpp"
  30 #include "runtime/safepoint.hpp"
  31 
  32 bool G1RemSetTrackingPolicy::needs_scan_for_rebuild(HeapRegion* r) const {
  33   // All non-free, non-young, non-closed archive regions need to be scanned for references;
  34   // At every gc we gather references to other regions in young, and closed archive
  35   // regions by definition do not have references going outside the closed archive.
  36   // Free regions trivially do not need scanning because they do not contain live
  37   // objects.
  38   return !(r->is_young() || r->is_closed_archive() || r->is_free());
  39 }
  40 
  41 void G1RemSetTrackingPolicy::update_at_allocate(HeapRegion* r) {
  42   if (r->is_young()) {
  43     // Always collect remembered set for young regions.
  44     r->rem_set()->set_state_complete();
  45   } else if (r->is_humongous()) {
  46     // Collect remembered sets for humongous regions by default to allow eager reclaim.


 109   assert(!r->is_humongous(), "Region %u is humongous", r->hrm_index());
 110 
 111   // Only consider updating the remembered set for old gen regions - excluding archive regions
 112   // which never move (but are "Old" regions).
 113   if (!r->is_old() || r->is_archive()) {
 114     return false;
 115   }
 116 
 117   assert(!r->rem_set()->is_updating(), "Remembered set of region %u is updating before rebuild", r->hrm_index());
 118 
 119   size_t between_ntams_and_top = (r->top() - r->next_top_at_mark_start()) * HeapWordSize;
 120   size_t total_live_bytes = live_bytes + between_ntams_and_top;
 121 
 122   bool selected_for_rebuild = false;
 123   // For old regions, to be of interest for rebuilding the remembered set the following must apply:
 124   // - They must contain some live data in them.
 125   // - Only need to rebuild non-complete remembered sets.
 126   // - Otherwise only add those old gen regions which occupancy is low enough that there
 127   // is a chance that we will ever evacuate them in the mixed gcs.
 128   if ((total_live_bytes > 0) &&
 129       CollectionSetChooser::region_occupancy_low_enough_for_evac(total_live_bytes) &&
 130       !r->rem_set()->is_tracked()) {
 131 
 132     r->rem_set()->set_state_updating();
 133     selected_for_rebuild = true;
 134   }
 135 
 136   print_before_rebuild(r, selected_for_rebuild, total_live_bytes, live_bytes);
 137 
 138   return selected_for_rebuild;
 139 }
 140 
 141 void G1RemSetTrackingPolicy::update_after_rebuild(HeapRegion* r) {
 142   assert(SafepointSynchronize::is_at_safepoint(), "should be at safepoint");
 143 
 144   if (r->is_old_or_humongous_or_archive()) {
 145     if (r->rem_set()->is_updating()) {
 146       assert(!r->is_archive(), "Archive region %u with remembered set", r->hrm_index());
 147       r->rem_set()->set_state_complete();
 148     }
 149     G1CollectedHeap* g1h = G1CollectedHeap::heap();


   1 /*
   2  * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  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/g1CollectionSetChooser.hpp"
  27 #include "gc/g1/g1RemSetTrackingPolicy.hpp"
  28 #include "gc/g1/heapRegion.inline.hpp"
  29 #include "gc/g1/heapRegionRemSet.hpp"
  30 #include "runtime/safepoint.hpp"
  31 
  32 bool G1RemSetTrackingPolicy::needs_scan_for_rebuild(HeapRegion* r) const {
  33   // All non-free, non-young, non-closed archive regions need to be scanned for references;
  34   // At every gc we gather references to other regions in young, and closed archive
  35   // regions by definition do not have references going outside the closed archive.
  36   // Free regions trivially do not need scanning because they do not contain live
  37   // objects.
  38   return !(r->is_young() || r->is_closed_archive() || r->is_free());
  39 }
  40 
  41 void G1RemSetTrackingPolicy::update_at_allocate(HeapRegion* r) {
  42   if (r->is_young()) {
  43     // Always collect remembered set for young regions.
  44     r->rem_set()->set_state_complete();
  45   } else if (r->is_humongous()) {
  46     // Collect remembered sets for humongous regions by default to allow eager reclaim.


 109   assert(!r->is_humongous(), "Region %u is humongous", r->hrm_index());
 110 
 111   // Only consider updating the remembered set for old gen regions - excluding archive regions
 112   // which never move (but are "Old" regions).
 113   if (!r->is_old() || r->is_archive()) {
 114     return false;
 115   }
 116 
 117   assert(!r->rem_set()->is_updating(), "Remembered set of region %u is updating before rebuild", r->hrm_index());
 118 
 119   size_t between_ntams_and_top = (r->top() - r->next_top_at_mark_start()) * HeapWordSize;
 120   size_t total_live_bytes = live_bytes + between_ntams_and_top;
 121 
 122   bool selected_for_rebuild = false;
 123   // For old regions, to be of interest for rebuilding the remembered set the following must apply:
 124   // - They must contain some live data in them.
 125   // - Only need to rebuild non-complete remembered sets.
 126   // - Otherwise only add those old gen regions which occupancy is low enough that there
 127   // is a chance that we will ever evacuate them in the mixed gcs.
 128   if ((total_live_bytes > 0) &&
 129       G1CollectionSetChooser::region_occupancy_low_enough_for_evac(total_live_bytes) &&
 130       !r->rem_set()->is_tracked()) {
 131 
 132     r->rem_set()->set_state_updating();
 133     selected_for_rebuild = true;
 134   }
 135 
 136   print_before_rebuild(r, selected_for_rebuild, total_live_bytes, live_bytes);
 137 
 138   return selected_for_rebuild;
 139 }
 140 
 141 void G1RemSetTrackingPolicy::update_after_rebuild(HeapRegion* r) {
 142   assert(SafepointSynchronize::is_at_safepoint(), "should be at safepoint");
 143 
 144   if (r->is_old_or_humongous_or_archive()) {
 145     if (r->rem_set()->is_updating()) {
 146       assert(!r->is_archive(), "Archive region %u with remembered set", r->hrm_index());
 147       r->rem_set()->set_state_complete();
 148     }
 149     G1CollectedHeap* g1h = G1CollectedHeap::heap();


< prev index next >