< prev index next >

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

Print this page




  32 #include "gc/g1/heapRegion.inline.hpp"
  33 #include "gc/g1/heapRegionBounds.inline.hpp"
  34 #include "gc/g1/heapRegionManager.inline.hpp"
  35 #include "gc/g1/heapRegionRemSet.hpp"
  36 #include "gc/g1/heapRegionTracer.hpp"
  37 #include "gc/shared/genOopClosures.inline.hpp"
  38 #include "gc/shared/space.inline.hpp"
  39 #include "logging/log.hpp"
  40 #include "logging/logStream.hpp"
  41 #include "memory/iterator.inline.hpp"
  42 #include "memory/resourceArea.hpp"
  43 #include "oops/access.inline.hpp"
  44 #include "oops/compressedOops.inline.hpp"
  45 #include "oops/oop.inline.hpp"
  46 #include "runtime/atomic.hpp"
  47 #include "runtime/orderAccess.hpp"
  48 #include "utilities/growableArray.hpp"
  49 
  50 int    HeapRegion::LogOfHRGrainBytes = 0;
  51 int    HeapRegion::LogOfHRGrainWords = 0;
  52 int    HeapRegion::LogCardsPerRegion = 0;
  53 size_t HeapRegion::GrainBytes        = 0;
  54 size_t HeapRegion::GrainWords        = 0;
  55 size_t HeapRegion::CardsPerRegion    = 0;
  56 
  57 size_t HeapRegion::max_region_size() {
  58   return HeapRegionBounds::max_size();
  59 }
  60 
  61 size_t HeapRegion::min_region_size_in_words() {
  62   return HeapRegionBounds::min_size() >> LogHeapWordSize;
  63 }
  64 
  65 void HeapRegion::setup_heap_region_size(size_t initial_heap_size, size_t max_heap_size) {
  66   size_t region_size = G1HeapRegionSize;
  67   if (FLAG_IS_DEFAULT(G1HeapRegionSize)) {
  68     size_t average_heap_size = (initial_heap_size + max_heap_size) / 2;
  69     region_size = MAX2(average_heap_size / HeapRegionBounds::target_number(),
  70                        HeapRegionBounds::min_size());
  71   }
  72 


  89   // Now, set up the globals.
  90   guarantee(LogOfHRGrainBytes == 0, "we should only set it once");
  91   LogOfHRGrainBytes = region_size_log;
  92 
  93   guarantee(LogOfHRGrainWords == 0, "we should only set it once");
  94   LogOfHRGrainWords = LogOfHRGrainBytes - LogHeapWordSize;
  95 
  96   guarantee(GrainBytes == 0, "we should only set it once");
  97   // The cast to int is safe, given that we've bounded region_size by
  98   // MIN_REGION_SIZE and MAX_REGION_SIZE.
  99   GrainBytes = region_size;
 100   log_info(gc, heap)("Heap region size: " SIZE_FORMAT "M", GrainBytes / M);
 101 
 102   guarantee(GrainWords == 0, "we should only set it once");
 103   GrainWords = GrainBytes >> LogHeapWordSize;
 104   guarantee((size_t) 1 << LogOfHRGrainWords == GrainWords, "sanity");
 105 
 106   guarantee(CardsPerRegion == 0, "we should only set it once");
 107   CardsPerRegion = GrainBytes >> G1CardTable::card_shift;
 108 
 109   LogCardsPerRegion = log2_long((jlong) CardsPerRegion);
 110 
 111   if (G1HeapRegionSize != GrainBytes) {
 112     FLAG_SET_ERGO(G1HeapRegionSize, GrainBytes);
 113   }
 114 }
 115 
 116 void HeapRegion::hr_clear(bool keep_remset, bool clear_space, bool locked) {
 117   assert(_humongous_start_region == NULL,
 118          "we should have already filtered out humongous regions");
 119   assert(!in_collection_set(),
 120          "Should not clear heap region %u in the collection set", hrm_index());
 121 
 122   clear_young_index_in_cset();
 123   clear_index_in_opt_cset();
 124   uninstall_surv_rate_group();
 125   set_free();
 126   reset_pre_dummy_top();
 127 
 128   if (!keep_remset) {
 129     if (locked) {
 130       rem_set()->clear_locked();
 131     } else {
 132       rem_set()->clear();
 133     }
 134   }
 135 
 136   zero_marked_bytes();
 137 
 138   init_top_at_mark_start();
 139   if (clear_space) clear(SpaceDecorator::Mangle);
 140 }
 141 
 142 void HeapRegion::clear_cardtable() {




  32 #include "gc/g1/heapRegion.inline.hpp"
  33 #include "gc/g1/heapRegionBounds.inline.hpp"
  34 #include "gc/g1/heapRegionManager.inline.hpp"
  35 #include "gc/g1/heapRegionRemSet.hpp"
  36 #include "gc/g1/heapRegionTracer.hpp"
  37 #include "gc/shared/genOopClosures.inline.hpp"
  38 #include "gc/shared/space.inline.hpp"
  39 #include "logging/log.hpp"
  40 #include "logging/logStream.hpp"
  41 #include "memory/iterator.inline.hpp"
  42 #include "memory/resourceArea.hpp"
  43 #include "oops/access.inline.hpp"
  44 #include "oops/compressedOops.inline.hpp"
  45 #include "oops/oop.inline.hpp"
  46 #include "runtime/atomic.hpp"
  47 #include "runtime/orderAccess.hpp"
  48 #include "utilities/growableArray.hpp"
  49 
  50 int    HeapRegion::LogOfHRGrainBytes = 0;
  51 int    HeapRegion::LogOfHRGrainWords = 0;

  52 size_t HeapRegion::GrainBytes        = 0;
  53 size_t HeapRegion::GrainWords        = 0;
  54 size_t HeapRegion::CardsPerRegion    = 0;
  55 
  56 size_t HeapRegion::max_region_size() {
  57   return HeapRegionBounds::max_size();
  58 }
  59 
  60 size_t HeapRegion::min_region_size_in_words() {
  61   return HeapRegionBounds::min_size() >> LogHeapWordSize;
  62 }
  63 
  64 void HeapRegion::setup_heap_region_size(size_t initial_heap_size, size_t max_heap_size) {
  65   size_t region_size = G1HeapRegionSize;
  66   if (FLAG_IS_DEFAULT(G1HeapRegionSize)) {
  67     size_t average_heap_size = (initial_heap_size + max_heap_size) / 2;
  68     region_size = MAX2(average_heap_size / HeapRegionBounds::target_number(),
  69                        HeapRegionBounds::min_size());
  70   }
  71 


  88   // Now, set up the globals.
  89   guarantee(LogOfHRGrainBytes == 0, "we should only set it once");
  90   LogOfHRGrainBytes = region_size_log;
  91 
  92   guarantee(LogOfHRGrainWords == 0, "we should only set it once");
  93   LogOfHRGrainWords = LogOfHRGrainBytes - LogHeapWordSize;
  94 
  95   guarantee(GrainBytes == 0, "we should only set it once");
  96   // The cast to int is safe, given that we've bounded region_size by
  97   // MIN_REGION_SIZE and MAX_REGION_SIZE.
  98   GrainBytes = region_size;
  99   log_info(gc, heap)("Heap region size: " SIZE_FORMAT "M", GrainBytes / M);
 100 
 101   guarantee(GrainWords == 0, "we should only set it once");
 102   GrainWords = GrainBytes >> LogHeapWordSize;
 103   guarantee((size_t) 1 << LogOfHRGrainWords == GrainWords, "sanity");
 104 
 105   guarantee(CardsPerRegion == 0, "we should only set it once");
 106   CardsPerRegion = GrainBytes >> G1CardTable::card_shift;
 107 


 108   if (G1HeapRegionSize != GrainBytes) {
 109     FLAG_SET_ERGO(G1HeapRegionSize, GrainBytes);
 110   }
 111 }
 112 
 113 void HeapRegion::hr_clear(bool keep_remset, bool clear_space, bool locked) {
 114   assert(_humongous_start_region == NULL,
 115          "we should have already filtered out humongous regions");
 116   assert(!in_collection_set(),
 117          "Should not clear heap region %u in the collection set", hrm_index());
 118 
 119   set_young_index_in_cset(-1);
 120   clear_index_in_opt_cset();
 121   uninstall_surv_rate_group();
 122   set_free();
 123   reset_pre_dummy_top();
 124 
 125   if (!keep_remset) {
 126     if (locked) {
 127       rem_set()->clear_locked();
 128     } else {
 129       rem_set()->clear();
 130     }
 131   }
 132 
 133   zero_marked_bytes();
 134 
 135   init_top_at_mark_start();
 136   if (clear_space) clear(SpaceDecorator::Mangle);
 137 }
 138 
 139 void HeapRegion::clear_cardtable() {


< prev index next >