< prev index next >

src/hotspot/share/gc/parallel/psOldGen.cpp

Print this page
rev 59216 : [mq]: cleanup
rev 59217 : [mq]: remove_init_gen_size


  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "gc/parallel/objectStartArray.inline.hpp"
  27 #include "gc/parallel/parallelArguments.hpp"
  28 #include "gc/parallel/parallelScavengeHeap.hpp"
  29 #include "gc/parallel/psAdaptiveSizePolicy.hpp"
  30 #include "gc/parallel/psCardTable.hpp"
  31 #include "gc/parallel/psFileBackedVirtualspace.hpp"
  32 #include "gc/parallel/psOldGen.hpp"
  33 #include "gc/shared/cardTableBarrierSet.hpp"
  34 #include "gc/shared/gcLocker.hpp"
  35 #include "gc/shared/spaceDecorator.inline.hpp"
  36 #include "logging/log.hpp"
  37 #include "oops/oop.inline.hpp"
  38 #include "runtime/java.hpp"
  39 #include "utilities/align.hpp"
  40 
  41 PSOldGen::PSOldGen(ReservedSpace rs, size_t initial_size, size_t min_size,
  42                    size_t max_size, const char* perf_data_name, int level):
  43   _init_gen_size(initial_size), _min_gen_size(min_size),
  44   _max_gen_size(max_size)
  45 {
  46   initialize(rs, GenAlignment, perf_data_name, level);
  47 }
  48 
  49 void PSOldGen::initialize(ReservedSpace rs, size_t alignment,
  50                           const char* perf_data_name, int level) {
  51   initialize_virtual_space(rs, alignment);
  52   initialize_work(perf_data_name, level);
  53 
  54   // The old gen can grow to max_gen_size().  _reserve reflects only
  55   // the current maximum that can be committed.
  56   assert(_reserved.byte_size() <= max_gen_size(), "Consistency check");
  57 
  58   initialize_performance_counters(perf_data_name, level);
  59 }
  60 
  61 void PSOldGen::initialize_virtual_space(ReservedSpace rs, size_t alignment) {


  62 
  63   if(ParallelArguments::is_heterogeneous_heap()) {
  64     _virtual_space = new PSFileBackedVirtualSpace(rs, alignment, AllocateOldGenAt);
  65     if (!(static_cast <PSFileBackedVirtualSpace*>(_virtual_space))->initialize()) {
  66       vm_exit_during_initialization("Could not map space for PSOldGen at given AllocateOldGenAt path");
  67     }
  68   } else {
  69     _virtual_space = new PSVirtualSpace(rs, alignment);
  70   }
  71   if (!_virtual_space->expand_by(_init_gen_size)) {
  72     vm_exit_during_initialization("Could not reserve enough space for "
  73                                   "object heap");
  74   }
  75 }
  76 
  77 void PSOldGen::initialize_work(const char* perf_data_name, int level) {
  78   //
  79   // Basic memory initialization
  80   //
  81 
  82   MemRegion limit_reserved((HeapWord*)virtual_space()->low_boundary(),
  83     heap_word_size(_max_gen_size));
  84   assert(limit_reserved.byte_size() == _max_gen_size,
  85     "word vs bytes confusion");
  86   //
  87   // Object start stuff
  88   //
  89 
  90   start_array()->initialize(limit_reserved);
  91 
  92   _reserved = MemRegion((HeapWord*)virtual_space()->low_boundary(),
  93                         (HeapWord*)virtual_space()->high_boundary());
  94 
  95   //
  96   // Card table stuff
  97   //
  98 
  99   MemRegion cmr((HeapWord*)virtual_space()->low(),
 100                 (HeapWord*)virtual_space()->high());
 101   if (ZapUnusedHeapArea) {
 102     // Mangle newly committed space immediately rather than
 103     // waiting for the initialization of the space even though
 104     // mangling is related to spaces.  Doing it here eliminates


 120     // Don't check at the very end of the heap as we'll assert that we're probing off
 121     // the end if we try.
 122     guarantee(ct->is_card_aligned(_reserved.end()), "generation must be card aligned");
 123   }
 124 
 125   //
 126   // ObjectSpace stuff
 127   //
 128 
 129   _object_space = new MutableSpace(virtual_space()->alignment());
 130   object_space()->initialize(cmr,
 131                              SpaceDecorator::Clear,
 132                              SpaceDecorator::Mangle);
 133 
 134   // Update the start_array
 135   start_array()->set_covered_region(cmr);
 136 }
 137 
 138 void PSOldGen::initialize_performance_counters(const char* perf_data_name, int level) {
 139   // Generation Counters, generation 'level', 1 subspace
 140   _gen_counters = new PSGenerationCounters(perf_data_name, level, 1, _min_gen_size,
 141                                            _max_gen_size, virtual_space());
 142   _space_counters = new SpaceCounters(perf_data_name, 0,
 143                                       virtual_space()->reserved_size(),
 144                                       _object_space, _gen_counters);
 145 }
 146 
 147 // Assume that the generation has been allocated if its
 148 // reserved size is not 0.
 149 bool  PSOldGen::is_allocated() {
 150   return virtual_space()->reserved_size() != 0;
 151 }
 152 
 153 // Allocation. We report all successful allocations to the size policy
 154 // Note that the perm gen does not use this method, and should not!
 155 HeapWord* PSOldGen::allocate(size_t word_size) {
 156   assert_locked_or_safepoint(Heap_lock);
 157   HeapWord* res = allocate_noexpand(word_size);
 158 
 159   if (res == NULL) {
 160     res = expand_and_allocate(word_size);
 161   }




  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "gc/parallel/objectStartArray.inline.hpp"
  27 #include "gc/parallel/parallelArguments.hpp"
  28 #include "gc/parallel/parallelScavengeHeap.hpp"
  29 #include "gc/parallel/psAdaptiveSizePolicy.hpp"
  30 #include "gc/parallel/psCardTable.hpp"
  31 #include "gc/parallel/psFileBackedVirtualspace.hpp"
  32 #include "gc/parallel/psOldGen.hpp"
  33 #include "gc/shared/cardTableBarrierSet.hpp"
  34 #include "gc/shared/gcLocker.hpp"
  35 #include "gc/shared/spaceDecorator.inline.hpp"
  36 #include "logging/log.hpp"
  37 #include "oops/oop.inline.hpp"
  38 #include "runtime/java.hpp"
  39 #include "utilities/align.hpp"
  40 
  41 PSOldGen::PSOldGen(ReservedSpace rs, size_t initial_size, size_t min_size,
  42                    size_t max_size, const char* perf_data_name, int level):
  43   _min_gen_size(min_size),
  44   _max_gen_size(max_size)
  45 {
  46   initialize(rs, initial_size, GenAlignment, perf_data_name, level);
  47 }
  48 
  49 void PSOldGen::initialize(ReservedSpace rs, size_t initial_size, size_t alignment,
  50                           const char* perf_data_name, int level) {
  51   initialize_virtual_space(rs, initial_size, alignment);
  52   initialize_work(perf_data_name, level);
  53 
  54   // The old gen can grow to max_gen_size().  _reserve reflects only
  55   // the current maximum that can be committed.
  56   assert(_reserved.byte_size() <= max_gen_size(), "Consistency check");
  57 
  58   initialize_performance_counters(perf_data_name, level);
  59 }
  60 
  61 void PSOldGen::initialize_virtual_space(ReservedSpace rs,
  62                                         size_t initial_size,
  63                                         size_t alignment) {
  64 
  65   if(ParallelArguments::is_heterogeneous_heap()) {
  66     _virtual_space = new PSFileBackedVirtualSpace(rs, alignment, AllocateOldGenAt);
  67     if (!(static_cast <PSFileBackedVirtualSpace*>(_virtual_space))->initialize()) {
  68       vm_exit_during_initialization("Could not map space for PSOldGen at given AllocateOldGenAt path");
  69     }
  70   } else {
  71     _virtual_space = new PSVirtualSpace(rs, alignment);
  72   }
  73   if (!_virtual_space->expand_by(initial_size)) {
  74     vm_exit_during_initialization("Could not reserve enough space for "
  75                                   "object heap");
  76   }
  77 }
  78 
  79 void PSOldGen::initialize_work(const char* perf_data_name, int level) {
  80   //
  81   // Basic memory initialization
  82   //
  83 
  84   MemRegion limit_reserved((HeapWord*)virtual_space()->low_boundary(),
  85                            heap_word_size(max_gen_size()));
  86   assert(limit_reserved.byte_size() == max_gen_size(),
  87     "word vs bytes confusion");
  88   //
  89   // Object start stuff
  90   //
  91 
  92   start_array()->initialize(limit_reserved);
  93 
  94   _reserved = MemRegion((HeapWord*)virtual_space()->low_boundary(),
  95                         (HeapWord*)virtual_space()->high_boundary());
  96 
  97   //
  98   // Card table stuff
  99   //
 100 
 101   MemRegion cmr((HeapWord*)virtual_space()->low(),
 102                 (HeapWord*)virtual_space()->high());
 103   if (ZapUnusedHeapArea) {
 104     // Mangle newly committed space immediately rather than
 105     // waiting for the initialization of the space even though
 106     // mangling is related to spaces.  Doing it here eliminates


 122     // Don't check at the very end of the heap as we'll assert that we're probing off
 123     // the end if we try.
 124     guarantee(ct->is_card_aligned(_reserved.end()), "generation must be card aligned");
 125   }
 126 
 127   //
 128   // ObjectSpace stuff
 129   //
 130 
 131   _object_space = new MutableSpace(virtual_space()->alignment());
 132   object_space()->initialize(cmr,
 133                              SpaceDecorator::Clear,
 134                              SpaceDecorator::Mangle);
 135 
 136   // Update the start_array
 137   start_array()->set_covered_region(cmr);
 138 }
 139 
 140 void PSOldGen::initialize_performance_counters(const char* perf_data_name, int level) {
 141   // Generation Counters, generation 'level', 1 subspace
 142   _gen_counters = new PSGenerationCounters(perf_data_name, level, 1, min_gen_size(),
 143                                            max_gen_size(), virtual_space());
 144   _space_counters = new SpaceCounters(perf_data_name, 0,
 145                                       virtual_space()->reserved_size(),
 146                                       _object_space, _gen_counters);
 147 }
 148 
 149 // Assume that the generation has been allocated if its
 150 // reserved size is not 0.
 151 bool  PSOldGen::is_allocated() {
 152   return virtual_space()->reserved_size() != 0;
 153 }
 154 
 155 // Allocation. We report all successful allocations to the size policy
 156 // Note that the perm gen does not use this method, and should not!
 157 HeapWord* PSOldGen::allocate(size_t word_size) {
 158   assert_locked_or_safepoint(Heap_lock);
 159   HeapWord* res = allocate_noexpand(word_size);
 160 
 161   if (res == NULL) {
 162     res = expand_and_allocate(word_size);
 163   }


< prev index next >