< prev index next >

src/hotspot/share/gc/shenandoah/shenandoahHeuristics.cpp

Print this page
rev 55608 : Rename ShenandoahBrooksPointer to ShenandoahForwarding
rev 55609 : Eliminate extra forwarding pointer per object


   7  *
   8  * This code is distributed in the hope that it will be useful, but WITHOUT
   9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  11  * version 2 for more details (a copy is included in the LICENSE file that
  12  * accompanied this code).
  13  *
  14  * You should have received a copy of the GNU General Public License version
  15  * 2 along with this work; if not, write to the Free Software Foundation,
  16  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  17  *
  18  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  19  * or visit www.oracle.com if you need additional information or have any
  20  * questions.
  21  *
  22  */
  23 
  24 #include "precompiled.hpp"
  25 
  26 #include "gc/shared/gcCause.hpp"
  27 #include "gc/shenandoah/shenandoahForwarding.hpp"
  28 #include "gc/shenandoah/shenandoahCollectionSet.inline.hpp"
  29 #include "gc/shenandoah/shenandoahCollectorPolicy.hpp"
  30 #include "gc/shenandoah/shenandoahHeap.inline.hpp"
  31 #include "gc/shenandoah/shenandoahHeapRegion.hpp"
  32 #include "gc/shenandoah/shenandoahHeuristics.hpp"
  33 #include "gc/shenandoah/shenandoahMarkingContext.inline.hpp"
  34 #include "logging/log.hpp"
  35 #include "logging/logTag.hpp"
  36 
  37 int ShenandoahHeuristics::compare_by_garbage(RegionData a, RegionData b) {
  38   if (a._garbage > b._garbage)
  39     return -1;
  40   else if (a._garbage < b._garbage)
  41     return 1;
  42   else return 0;
  43 }
  44 
  45 int ShenandoahHeuristics::compare_by_garbage_then_alloc_seq_ascending(RegionData a, RegionData b) {
  46   int r = compare_by_garbage(a, b);
  47   if (r != 0) {


 147 
 148     if (region->is_empty()) {
 149       free_regions++;
 150       free += ShenandoahHeapRegion::region_size_bytes();
 151     } else if (region->is_regular()) {
 152       if (!region->has_live()) {
 153         // We can recycle it right away and put it in the free set.
 154         immediate_regions++;
 155         immediate_garbage += garbage;
 156         region->make_trash_immediate();
 157       } else {
 158         // This is our candidate for later consideration.
 159         candidates[cand_idx]._region = region;
 160         candidates[cand_idx]._garbage = garbage;
 161         cand_idx++;
 162       }
 163     } else if (region->is_humongous_start()) {
 164       // Reclaim humongous regions here, and count them as the immediate garbage
 165 #ifdef ASSERT
 166       bool reg_live = region->has_live();
 167       bool bm_live = ctx->is_marked(oop(region->bottom() + ShenandoahForwarding::word_size()));
 168       assert(reg_live == bm_live,
 169              "Humongous liveness and marks should agree. Region live: %s; Bitmap live: %s; Region Live Words: " SIZE_FORMAT,
 170              BOOL_TO_STR(reg_live), BOOL_TO_STR(bm_live), region->get_live_data_words());
 171 #endif
 172       if (!region->has_live()) {
 173         heap->trash_humongous_region_at(region);
 174 
 175         // Count only the start. Continuations would be counted on "trash" path
 176         immediate_regions++;
 177         immediate_garbage += garbage;
 178       }
 179     } else if (region->is_trash()) {
 180       // Count in just trashed collection set, during coalesced CM-with-UR
 181       immediate_regions++;
 182       immediate_garbage += garbage;
 183     }
 184   }
 185 
 186   // Step 2. Look back at garbage statistics, and decide if we want to collect anything,
 187   // given the amount of immediately reclaimable garbage. If we do, figure out the collection set.




   7  *
   8  * This code is distributed in the hope that it will be useful, but WITHOUT
   9  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  11  * version 2 for more details (a copy is included in the LICENSE file that
  12  * accompanied this code).
  13  *
  14  * You should have received a copy of the GNU General Public License version
  15  * 2 along with this work; if not, write to the Free Software Foundation,
  16  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  17  *
  18  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  19  * or visit www.oracle.com if you need additional information or have any
  20  * questions.
  21  *
  22  */
  23 
  24 #include "precompiled.hpp"
  25 
  26 #include "gc/shared/gcCause.hpp"

  27 #include "gc/shenandoah/shenandoahCollectionSet.inline.hpp"
  28 #include "gc/shenandoah/shenandoahCollectorPolicy.hpp"
  29 #include "gc/shenandoah/shenandoahHeap.inline.hpp"
  30 #include "gc/shenandoah/shenandoahHeapRegion.hpp"
  31 #include "gc/shenandoah/shenandoahHeuristics.hpp"
  32 #include "gc/shenandoah/shenandoahMarkingContext.inline.hpp"
  33 #include "logging/log.hpp"
  34 #include "logging/logTag.hpp"
  35 
  36 int ShenandoahHeuristics::compare_by_garbage(RegionData a, RegionData b) {
  37   if (a._garbage > b._garbage)
  38     return -1;
  39   else if (a._garbage < b._garbage)
  40     return 1;
  41   else return 0;
  42 }
  43 
  44 int ShenandoahHeuristics::compare_by_garbage_then_alloc_seq_ascending(RegionData a, RegionData b) {
  45   int r = compare_by_garbage(a, b);
  46   if (r != 0) {


 146 
 147     if (region->is_empty()) {
 148       free_regions++;
 149       free += ShenandoahHeapRegion::region_size_bytes();
 150     } else if (region->is_regular()) {
 151       if (!region->has_live()) {
 152         // We can recycle it right away and put it in the free set.
 153         immediate_regions++;
 154         immediate_garbage += garbage;
 155         region->make_trash_immediate();
 156       } else {
 157         // This is our candidate for later consideration.
 158         candidates[cand_idx]._region = region;
 159         candidates[cand_idx]._garbage = garbage;
 160         cand_idx++;
 161       }
 162     } else if (region->is_humongous_start()) {
 163       // Reclaim humongous regions here, and count them as the immediate garbage
 164 #ifdef ASSERT
 165       bool reg_live = region->has_live();
 166       bool bm_live = ctx->is_marked(oop(region->bottom()));
 167       assert(reg_live == bm_live,
 168              "Humongous liveness and marks should agree. Region live: %s; Bitmap live: %s; Region Live Words: " SIZE_FORMAT,
 169              BOOL_TO_STR(reg_live), BOOL_TO_STR(bm_live), region->get_live_data_words());
 170 #endif
 171       if (!region->has_live()) {
 172         heap->trash_humongous_region_at(region);
 173 
 174         // Count only the start. Continuations would be counted on "trash" path
 175         immediate_regions++;
 176         immediate_garbage += garbage;
 177       }
 178     } else if (region->is_trash()) {
 179       // Count in just trashed collection set, during coalesced CM-with-UR
 180       immediate_regions++;
 181       immediate_garbage += garbage;
 182     }
 183   }
 184 
 185   // Step 2. Look back at garbage statistics, and decide if we want to collect anything,
 186   // given the amount of immediately reclaimable garbage. If we do, figure out the collection set.


< prev index next >