< prev index next >

src/hotspot/share/gc/shared/genCollectedHeap.cpp

Print this page




  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 "aot/aotLoader.hpp"
  27 #include "classfile/symbolTable.hpp"
  28 #include "classfile/stringTable.hpp"
  29 #include "classfile/systemDictionary.hpp"
  30 #include "classfile/vmSymbols.hpp"
  31 #include "code/codeCache.hpp"
  32 #include "code/icBuffer.hpp"
  33 #include "gc/shared/adaptiveSizePolicy.hpp"
  34 #include "gc/shared/cardTableRS.hpp"
  35 #include "gc/shared/collectedHeap.inline.hpp"
  36 #include "gc/shared/collectorCounters.hpp"
  37 #include "gc/shared/gcId.hpp"
  38 #include "gc/shared/gcLocker.inline.hpp"

  39 #include "gc/shared/gcTrace.hpp"
  40 #include "gc/shared/gcTraceTime.inline.hpp"
  41 #include "gc/shared/genCollectedHeap.hpp"
  42 #include "gc/shared/genOopClosures.inline.hpp"
  43 #include "gc/shared/generationSpec.hpp"
  44 #include "gc/shared/space.hpp"
  45 #include "gc/shared/strongRootsScope.hpp"
  46 #include "gc/shared/vmGCOperations.hpp"
  47 #include "gc/shared/weakProcessor.hpp"
  48 #include "gc/shared/workgroup.hpp"
  49 #include "memory/filemap.hpp"
  50 #include "memory/resourceArea.hpp"
  51 #include "oops/oop.inline.hpp"
  52 #include "runtime/biasedLocking.hpp"
  53 #include "runtime/handles.hpp"
  54 #include "runtime/handles.inline.hpp"
  55 #include "runtime/java.hpp"
  56 #include "runtime/vmThread.hpp"
  57 #include "services/management.hpp"
  58 #include "services/memoryService.hpp"
  59 #include "utilities/debug.hpp"
  60 #include "utilities/formatBuffer.hpp"
  61 #include "utilities/macros.hpp"
  62 #include "utilities/stack.inline.hpp"
  63 #include "utilities/vmError.hpp"
  64 
  65 GenCollectedHeap::GenCollectedHeap(GenCollectorPolicy *policy,
  66                                    Generation::Name young,
  67                                    Generation::Name old) :

  68   CollectedHeap(),
  69   _rem_set(NULL),
  70   _young_gen_spec(new GenerationSpec(young,
  71                                      policy->initial_young_size(),
  72                                      policy->max_young_size(),
  73                                      policy->gen_alignment())),
  74   _old_gen_spec(new GenerationSpec(old,
  75                                    policy->initial_old_size(),
  76                                    policy->max_old_size(),
  77                                    policy->gen_alignment())),
  78   _gen_policy(policy),
  79   _soft_ref_gen_policy(),

  80   _process_strong_tasks(new SubTasksDone(GCH_PS_NumElements)),
  81   _full_collections_completed(0) {
  82 }
  83 
  84 jint GenCollectedHeap::initialize() {
  85   // While there are no constraints in the GC code that HeapWordSize
  86   // be any particular value, there are multiple other areas in the
  87   // system which believe this to be true (e.g. oop->object_size in some
  88   // cases incorrectly returns the size in wordSize units rather than
  89   // HeapWordSize).
  90   guarantee(HeapWordSize == wordSize, "HeapWordSize must equal wordSize");
  91 
  92   // Allocate space for the heap.
  93 
  94   char* heap_address;
  95   ReservedSpace heap_rs;
  96 
  97   size_t heap_alignment = collector_policy()->heap_alignment();
  98 
  99   heap_address = allocate(heap_alignment, &heap_rs);


 158 
 159   os::trace_page_sizes("Heap",
 160                        collector_policy()->min_heap_byte_size(),
 161                        total_reserved,
 162                        alignment,
 163                        heap_rs->base(),
 164                        heap_rs->size());
 165 
 166   return heap_rs->base();
 167 }
 168 
 169 void GenCollectedHeap::post_initialize() {
 170   CollectedHeap::post_initialize();
 171   ref_processing_init();
 172   check_gen_kinds();
 173   DefNewGeneration* def_new_gen = (DefNewGeneration*)_young_gen;
 174 
 175   initialize_size_policy(def_new_gen->eden()->capacity(),
 176                          _old_gen->capacity(),
 177                          def_new_gen->from()->capacity());
 178 
 179   _gen_policy->initialize_gc_policy_counters();
 180 }
 181 
 182 void GenCollectedHeap::ref_processing_init() {
 183   _young_gen->ref_processor_init();
 184   _old_gen->ref_processor_init();
 185 }
 186 
 187 GenerationSpec* GenCollectedHeap::young_gen_spec() const {
 188   assert(_young_gen_spec != NULL, "_young_gen_spec should have been initialized");
 189   return _young_gen_spec;
 190 }
 191 
 192 GenerationSpec* GenCollectedHeap::old_gen_spec() const {
 193   assert(_old_gen_spec != NULL, "_old_gen_spec should have been initialized");
 194   return _old_gen_spec;
 195 }
 196 
 197 size_t GenCollectedHeap::capacity() const {
 198   return _young_gen->capacity() + _old_gen->capacity();
 199 }




  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 "aot/aotLoader.hpp"
  27 #include "classfile/symbolTable.hpp"
  28 #include "classfile/stringTable.hpp"
  29 #include "classfile/systemDictionary.hpp"
  30 #include "classfile/vmSymbols.hpp"
  31 #include "code/codeCache.hpp"
  32 #include "code/icBuffer.hpp"
  33 #include "gc/shared/adaptiveSizePolicy.hpp"
  34 #include "gc/shared/cardTableRS.hpp"
  35 #include "gc/shared/collectedHeap.inline.hpp"
  36 #include "gc/shared/collectorCounters.hpp"
  37 #include "gc/shared/gcId.hpp"
  38 #include "gc/shared/gcLocker.inline.hpp"
  39 #include "gc/shared/gcPolicyCounters.hpp"
  40 #include "gc/shared/gcTrace.hpp"
  41 #include "gc/shared/gcTraceTime.inline.hpp"
  42 #include "gc/shared/genCollectedHeap.hpp"
  43 #include "gc/shared/genOopClosures.inline.hpp"
  44 #include "gc/shared/generationSpec.hpp"
  45 #include "gc/shared/space.hpp"
  46 #include "gc/shared/strongRootsScope.hpp"
  47 #include "gc/shared/vmGCOperations.hpp"
  48 #include "gc/shared/weakProcessor.hpp"
  49 #include "gc/shared/workgroup.hpp"
  50 #include "memory/filemap.hpp"
  51 #include "memory/resourceArea.hpp"
  52 #include "oops/oop.inline.hpp"
  53 #include "runtime/biasedLocking.hpp"
  54 #include "runtime/handles.hpp"
  55 #include "runtime/handles.inline.hpp"
  56 #include "runtime/java.hpp"
  57 #include "runtime/vmThread.hpp"
  58 #include "services/management.hpp"
  59 #include "services/memoryService.hpp"
  60 #include "utilities/debug.hpp"
  61 #include "utilities/formatBuffer.hpp"
  62 #include "utilities/macros.hpp"
  63 #include "utilities/stack.inline.hpp"
  64 #include "utilities/vmError.hpp"
  65 
  66 GenCollectedHeap::GenCollectedHeap(GenCollectorPolicy *policy,
  67                                    Generation::Name young,
  68                                    Generation::Name old,
  69                                    const char* policy_counters_name) :
  70   CollectedHeap(),
  71   _rem_set(NULL),
  72   _young_gen_spec(new GenerationSpec(young,
  73                                      policy->initial_young_size(),
  74                                      policy->max_young_size(),
  75                                      policy->gen_alignment())),
  76   _old_gen_spec(new GenerationSpec(old,
  77                                    policy->initial_old_size(),
  78                                    policy->max_old_size(),
  79                                    policy->gen_alignment())),
  80   _gen_policy(policy),
  81   _soft_ref_gen_policy(),
  82   _gc_policy_counters(new GCPolicyCounters(policy_counters_name, 2, 2)),
  83   _process_strong_tasks(new SubTasksDone(GCH_PS_NumElements)),
  84   _full_collections_completed(0) {
  85 }
  86 
  87 jint GenCollectedHeap::initialize() {
  88   // While there are no constraints in the GC code that HeapWordSize
  89   // be any particular value, there are multiple other areas in the
  90   // system which believe this to be true (e.g. oop->object_size in some
  91   // cases incorrectly returns the size in wordSize units rather than
  92   // HeapWordSize).
  93   guarantee(HeapWordSize == wordSize, "HeapWordSize must equal wordSize");
  94 
  95   // Allocate space for the heap.
  96 
  97   char* heap_address;
  98   ReservedSpace heap_rs;
  99 
 100   size_t heap_alignment = collector_policy()->heap_alignment();
 101 
 102   heap_address = allocate(heap_alignment, &heap_rs);


 161 
 162   os::trace_page_sizes("Heap",
 163                        collector_policy()->min_heap_byte_size(),
 164                        total_reserved,
 165                        alignment,
 166                        heap_rs->base(),
 167                        heap_rs->size());
 168 
 169   return heap_rs->base();
 170 }
 171 
 172 void GenCollectedHeap::post_initialize() {
 173   CollectedHeap::post_initialize();
 174   ref_processing_init();
 175   check_gen_kinds();
 176   DefNewGeneration* def_new_gen = (DefNewGeneration*)_young_gen;
 177 
 178   initialize_size_policy(def_new_gen->eden()->capacity(),
 179                          _old_gen->capacity(),
 180                          def_new_gen->from()->capacity());


 181 }
 182 
 183 void GenCollectedHeap::ref_processing_init() {
 184   _young_gen->ref_processor_init();
 185   _old_gen->ref_processor_init();
 186 }
 187 
 188 GenerationSpec* GenCollectedHeap::young_gen_spec() const {
 189   assert(_young_gen_spec != NULL, "_young_gen_spec should have been initialized");
 190   return _young_gen_spec;
 191 }
 192 
 193 GenerationSpec* GenCollectedHeap::old_gen_spec() const {
 194   assert(_old_gen_spec != NULL, "_old_gen_spec should have been initialized");
 195   return _old_gen_spec;
 196 }
 197 
 198 size_t GenCollectedHeap::capacity() const {
 199   return _young_gen->capacity() + _old_gen->capacity();
 200 }


< prev index next >