< prev index next >

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

Print this page

        

@@ -23,18 +23,46 @@
  */
 
 #include "precompiled.hpp"
 #include "gc/g1/g1Arguments.hpp"
 #include "gc/g1/g1CollectedHeap.inline.hpp"
-#include "gc/g1/g1CollectorPolicy.hpp"
 #include "gc/g1/g1HeapVerifier.hpp"
 #include "gc/g1/heapRegion.hpp"
+#include "gc/g1/heapRegionRemSet.hpp"
 #include "gc/shared/gcArguments.inline.hpp"
 #include "runtime/globals.hpp"
 #include "runtime/globals_extension.hpp"
 #include "runtime/vm_version.hpp"
 
+G1Settings G1Arguments::initialize_heap_flags() {
+  G1Settings s;
+
+  GCArguments::initialize_heap_flags(s);
+
+  // Set up the region size and associated fields. Given that the
+  // policy is created before the heap, we have to set this up here,
+  // so it's done as soon as possible.
+
+  // It would have been natural to pass initial_heap_byte_size() and
+  // max_heap_byte_size() to setup_heap_region_size() but those have
+  // not been set up at this point since they should be aligned with
+  // the region size. So, there is a circular dependency here. We base
+  // the region size on the heap size, but the heap size should be
+  // aligned with the region size. To get around this we use the
+  // unaligned values for the heap.
+
+  assert(InitialHeapSize == s._initial_heap_byte_size, "Sanity");
+  assert(MaxHeapSize == s._max_heap_byte_size, "Sanity");
+
+  HeapRegion::setup_heap_region_size(InitialHeapSize, MaxHeapSize);
+  HeapRegionRemSet::setup_remset_size();
+
+  GCArguments::initialize_size_info(s);
+
+  return s;
+}
+
 size_t G1Arguments::conservative_max_heap_alignment() {
   return HeapRegion::max_region_size();
 }
 
 void G1Arguments::initialize_flags() {

@@ -107,7 +135,7 @@
   // Always return true because we want to parse all values.
   return true;
 }
 
 CollectedHeap* G1Arguments::create_heap() {
-  return create_heap_with_policy<G1CollectedHeap, G1CollectorPolicy>();
+  return new G1CollectedHeap(initialize_heap_flags());
 }
< prev index next >