< prev index next >

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

Print this page
rev 55208 : imported patch 8220089.webrev.0
rev 55210 : imported patch 8220089.webrev.2
rev 55211 : imported patch 8220089.webrev.3
rev 55212 : imported patch 8220089.webrev.4


  24 
  25 #include "precompiled.hpp"
  26 #include "gc/g1/g1Allocator.inline.hpp"
  27 #include "gc/g1/g1AllocRegion.inline.hpp"
  28 #include "gc/g1/g1EvacStats.inline.hpp"
  29 #include "gc/g1/g1EvacuationInfo.hpp"
  30 #include "gc/g1/g1CollectedHeap.inline.hpp"
  31 #include "gc/g1/g1Policy.hpp"
  32 #include "gc/g1/heapRegion.inline.hpp"
  33 #include "gc/g1/heapRegionSet.inline.hpp"
  34 #include "gc/g1/heapRegionType.hpp"
  35 #include "utilities/align.hpp"
  36 
  37 G1Allocator::G1Allocator(G1CollectedHeap* heap) :
  38   _g1h(heap),
  39   _survivor_is_full(false),
  40   _old_is_full(false),
  41   _mutator_alloc_region(),
  42   _survivor_gc_alloc_region(heap->alloc_buffer_stats(G1HeapRegionAttr::Young)),
  43   _old_gc_alloc_region(heap->alloc_buffer_stats(G1HeapRegionAttr::Old)),
  44   _retained_old_gc_alloc_region(NULL) {

  45 }
  46 
  47 void G1Allocator::init_mutator_alloc_region() {
  48   assert(_mutator_alloc_region.get() == NULL, "pre-condition");
  49   _mutator_alloc_region.init();












  50 }
  51 
  52 void G1Allocator::release_mutator_alloc_region() {
  53   _mutator_alloc_region.release();
  54   assert(_mutator_alloc_region.get() == NULL, "post-condition");
  55 }
  56 
  57 bool G1Allocator::is_retained_old_region(HeapRegion* hr) {
  58   return _retained_old_gc_alloc_region == hr;
  59 }
  60 
  61 void G1Allocator::reuse_retained_old_region(G1EvacuationInfo& evacuation_info,
  62                                             OldGCAllocRegion* old,
  63                                             HeapRegion** retained_old) {
  64   HeapRegion* retained_region = *retained_old;
  65   *retained_old = NULL;
  66   assert(retained_region == NULL || !retained_region->is_archive(),
  67          "Archive region should not be alloc region (index %u)", retained_region->hrm_index());
  68 
  69   // We will discard the current GC alloc region if:


  90     evacuation_info.set_alloc_regions_used_before(retained_region->used());
  91   }
  92 }
  93 
  94 void G1Allocator::init_gc_alloc_regions(G1EvacuationInfo& evacuation_info) {
  95   assert_at_safepoint_on_vm_thread();
  96 
  97   _survivor_is_full = false;
  98   _old_is_full = false;
  99 
 100   _survivor_gc_alloc_region.init();
 101   _old_gc_alloc_region.init();
 102   reuse_retained_old_region(evacuation_info,
 103                             &_old_gc_alloc_region,
 104                             &_retained_old_gc_alloc_region);
 105 }
 106 
 107 void G1Allocator::release_gc_alloc_regions(G1EvacuationInfo& evacuation_info) {
 108   evacuation_info.set_allocation_regions(survivor_gc_alloc_region()->count() +
 109                                          old_gc_alloc_region()->count());
 110   survivor_gc_alloc_region()->release();





 111   // If we have an old GC alloc region to release, we'll save it in
 112   // _retained_old_gc_alloc_region. If we don't
 113   // _retained_old_gc_alloc_region will become NULL. This is what we
 114   // want either way so no reason to check explicitly for either
 115   // condition.
 116   _retained_old_gc_alloc_region = old_gc_alloc_region()->release();
 117 }
 118 
 119 void G1Allocator::abandon_gc_alloc_regions() {
 120   assert(survivor_gc_alloc_region()->get() == NULL, "pre-condition");
 121   assert(old_gc_alloc_region()->get() == NULL, "pre-condition");
 122   _retained_old_gc_alloc_region = NULL;
 123 }
 124 
 125 bool G1Allocator::survivor_is_full() const {
 126   return _survivor_is_full;
 127 }
 128 
 129 bool G1Allocator::old_is_full() const {
 130   return _old_is_full;




  24 
  25 #include "precompiled.hpp"
  26 #include "gc/g1/g1Allocator.inline.hpp"
  27 #include "gc/g1/g1AllocRegion.inline.hpp"
  28 #include "gc/g1/g1EvacStats.inline.hpp"
  29 #include "gc/g1/g1EvacuationInfo.hpp"
  30 #include "gc/g1/g1CollectedHeap.inline.hpp"
  31 #include "gc/g1/g1Policy.hpp"
  32 #include "gc/g1/heapRegion.inline.hpp"
  33 #include "gc/g1/heapRegionSet.inline.hpp"
  34 #include "gc/g1/heapRegionType.hpp"
  35 #include "utilities/align.hpp"
  36 
  37 G1Allocator::G1Allocator(G1CollectedHeap* heap) :
  38   _g1h(heap),
  39   _survivor_is_full(false),
  40   _old_is_full(false),
  41   _mutator_alloc_region(),
  42   _survivor_gc_alloc_region(heap->alloc_buffer_stats(G1HeapRegionAttr::Young)),
  43   _old_gc_alloc_region(heap->alloc_buffer_stats(G1HeapRegionAttr::Old)),
  44   _retained_old_gc_alloc_region(NULL),
  45   _retained_survivor_gc_alloc_region(NULL) {
  46 }
  47 
  48 void G1Allocator::init_mutator_alloc_region() {
  49   assert(_mutator_alloc_region.get() == NULL, "pre-condition");
  50   _mutator_alloc_region.init();
  51 
  52   reuse_retained_survivor_region(&_retained_survivor_gc_alloc_region);
  53 }
  54 
  55 void G1Allocator::reuse_retained_survivor_region(HeapRegion** retained_survivor) {
  56   HeapRegion* retained_region = *retained_survivor;
  57   *retained_survivor = NULL;
  58 
  59   if (retained_region != NULL) {
  60     mutator_alloc_region()->set(retained_region);
  61     _g1h->reuse_retained_survivor_region(retained_region);
  62   }
  63 }
  64 
  65 void G1Allocator::release_mutator_alloc_region() {
  66   _mutator_alloc_region.release();
  67   assert(_mutator_alloc_region.get() == NULL, "post-condition");
  68 }
  69 
  70 bool G1Allocator::is_retained_old_region(HeapRegion* hr) {
  71   return _retained_old_gc_alloc_region == hr;
  72 }
  73 
  74 void G1Allocator::reuse_retained_old_region(G1EvacuationInfo& evacuation_info,
  75                                             OldGCAllocRegion* old,
  76                                             HeapRegion** retained_old) {
  77   HeapRegion* retained_region = *retained_old;
  78   *retained_old = NULL;
  79   assert(retained_region == NULL || !retained_region->is_archive(),
  80          "Archive region should not be alloc region (index %u)", retained_region->hrm_index());
  81 
  82   // We will discard the current GC alloc region if:


 103     evacuation_info.set_alloc_regions_used_before(retained_region->used());
 104   }
 105 }
 106 
 107 void G1Allocator::init_gc_alloc_regions(G1EvacuationInfo& evacuation_info) {
 108   assert_at_safepoint_on_vm_thread();
 109 
 110   _survivor_is_full = false;
 111   _old_is_full = false;
 112 
 113   _survivor_gc_alloc_region.init();
 114   _old_gc_alloc_region.init();
 115   reuse_retained_old_region(evacuation_info,
 116                             &_old_gc_alloc_region,
 117                             &_retained_old_gc_alloc_region);
 118 }
 119 
 120 void G1Allocator::release_gc_alloc_regions(G1EvacuationInfo& evacuation_info) {
 121   evacuation_info.set_allocation_regions(survivor_gc_alloc_region()->count() +
 122                                          old_gc_alloc_region()->count());
 123   HeapRegion* reuse_candidate = survivor_gc_alloc_region()->release();
 124   if (reuse_candidate != NULL && SurvivorGCAllocRegion::should_retain(reuse_candidate)) {
 125     _g1h->update_retained_survivor_gc_alloc_region(reuse_candidate);
 126     _retained_survivor_gc_alloc_region = reuse_candidate;
 127   }
 128 
 129   // If we have an old GC alloc region to release, we'll save it in
 130   // _retained_old_gc_alloc_region. If we don't
 131   // _retained_old_gc_alloc_region will become NULL. This is what we
 132   // want either way so no reason to check explicitly for either
 133   // condition.
 134   _retained_old_gc_alloc_region = old_gc_alloc_region()->release();
 135 }
 136 
 137 void G1Allocator::abandon_gc_alloc_regions() {
 138   assert(survivor_gc_alloc_region()->get() == NULL, "pre-condition");
 139   assert(old_gc_alloc_region()->get() == NULL, "pre-condition");
 140   _retained_old_gc_alloc_region = NULL;
 141 }
 142 
 143 bool G1Allocator::survivor_is_full() const {
 144   return _survivor_is_full;
 145 }
 146 
 147 bool G1Allocator::old_is_full() const {
 148   return _old_is_full;


< prev index next >