1991
1992 G1Log::init();
1993
1994 // Necessary to satisfy locking discipline assertions.
1995
1996 MutexLocker x(Heap_lock);
1997
1998 // We have to initialize the printer before committing the heap, as
1999 // it will be used then.
2000 _hr_printer.set_active(G1PrintHeapRegions);
2001
2002 // While there are no constraints in the GC code that HeapWordSize
2003 // be any particular value, there are multiple other areas in the
2004 // system which believe this to be true (e.g. oop->object_size in some
2005 // cases incorrectly returns the size in wordSize units rather than
2006 // HeapWordSize).
2007 guarantee(HeapWordSize == wordSize, "HeapWordSize must equal wordSize");
2008
2009 size_t init_byte_size = collector_policy()->initial_heap_byte_size();
2010 size_t max_byte_size = collector_policy()->max_heap_byte_size();
2011 size_t heap_alignment = collector_policy()->max_alignment();
2012
2013 // Ensure that the sizes are properly aligned.
2014 Universe::check_alignment(init_byte_size, HeapRegion::GrainBytes, "g1 heap");
2015 Universe::check_alignment(max_byte_size, HeapRegion::GrainBytes, "g1 heap");
2016 Universe::check_alignment(max_byte_size, heap_alignment, "g1 heap");
2017
2018 _cg1r = new ConcurrentG1Refine(this);
2019
2020 // Reserve the maximum.
2021
2022 // When compressed oops are enabled, the preferred heap base
2023 // is calculated by subtracting the requested size from the
2024 // 32Gb boundary and using the result as the base address for
2025 // heap reservation. If the requested size is not aligned to
2026 // HeapRegion::GrainBytes (i.e. the alignment that is passed
2027 // into the ReservedHeapSpace constructor) then the actual
2028 // base of the reserved heap may end up differing from the
2029 // address that was requested (i.e. the preferred heap base).
2030 // If this happens then we could end up using a non-optimal
2031 // compressed oops mode.
2169 HeapRegion* dummy_region = new_heap_region(0 /* index of bottom region */,
2170 _g1_reserved.start());
2171 // We'll re-use the same region whether the alloc region will
2172 // require BOT updates or not and, if it doesn't, then a non-young
2173 // region will complain that it cannot support allocations without
2174 // BOT updates. So we'll tag the dummy region as young to avoid that.
2175 dummy_region->set_young();
2176 // Make sure it's full.
2177 dummy_region->set_top(dummy_region->end());
2178 G1AllocRegion::setup(this, dummy_region);
2179
2180 init_mutator_alloc_region();
2181
2182 // Do create of the monitoring and management support so that
2183 // values in the heap have been properly initialized.
2184 _g1mm = new G1MonitoringSupport(this);
2185
2186 return JNI_OK;
2187 }
2188
2189 void G1CollectedHeap::ref_processing_init() {
2190 // Reference processing in G1 currently works as follows:
2191 //
2192 // * There are two reference processor instances. One is
2193 // used to record and process discovered references
2194 // during concurrent marking; the other is used to
2195 // record and process references during STW pauses
2196 // (both full and incremental).
2197 // * Both ref processors need to 'span' the entire heap as
2198 // the regions in the collection set may be dotted around.
2199 //
2200 // * For the concurrent marking ref processor:
2201 // * Reference discovery is enabled at initial marking.
2202 // * Reference discovery is disabled and the discovered
2203 // references processed etc during remarking.
2204 // * Reference discovery is MT (see below).
2205 // * Reference discovery requires a barrier (see below).
2206 // * Reference processing may or may not be MT
2207 // (depending on the value of ParallelRefProcEnabled
2208 // and ParallelGCThreads).
|
1991
1992 G1Log::init();
1993
1994 // Necessary to satisfy locking discipline assertions.
1995
1996 MutexLocker x(Heap_lock);
1997
1998 // We have to initialize the printer before committing the heap, as
1999 // it will be used then.
2000 _hr_printer.set_active(G1PrintHeapRegions);
2001
2002 // While there are no constraints in the GC code that HeapWordSize
2003 // be any particular value, there are multiple other areas in the
2004 // system which believe this to be true (e.g. oop->object_size in some
2005 // cases incorrectly returns the size in wordSize units rather than
2006 // HeapWordSize).
2007 guarantee(HeapWordSize == wordSize, "HeapWordSize must equal wordSize");
2008
2009 size_t init_byte_size = collector_policy()->initial_heap_byte_size();
2010 size_t max_byte_size = collector_policy()->max_heap_byte_size();
2011 size_t heap_alignment = collector_policy()->heap_alignment();
2012
2013 // Ensure that the sizes are properly aligned.
2014 Universe::check_alignment(init_byte_size, HeapRegion::GrainBytes, "g1 heap");
2015 Universe::check_alignment(max_byte_size, HeapRegion::GrainBytes, "g1 heap");
2016 Universe::check_alignment(max_byte_size, heap_alignment, "g1 heap");
2017
2018 _cg1r = new ConcurrentG1Refine(this);
2019
2020 // Reserve the maximum.
2021
2022 // When compressed oops are enabled, the preferred heap base
2023 // is calculated by subtracting the requested size from the
2024 // 32Gb boundary and using the result as the base address for
2025 // heap reservation. If the requested size is not aligned to
2026 // HeapRegion::GrainBytes (i.e. the alignment that is passed
2027 // into the ReservedHeapSpace constructor) then the actual
2028 // base of the reserved heap may end up differing from the
2029 // address that was requested (i.e. the preferred heap base).
2030 // If this happens then we could end up using a non-optimal
2031 // compressed oops mode.
2169 HeapRegion* dummy_region = new_heap_region(0 /* index of bottom region */,
2170 _g1_reserved.start());
2171 // We'll re-use the same region whether the alloc region will
2172 // require BOT updates or not and, if it doesn't, then a non-young
2173 // region will complain that it cannot support allocations without
2174 // BOT updates. So we'll tag the dummy region as young to avoid that.
2175 dummy_region->set_young();
2176 // Make sure it's full.
2177 dummy_region->set_top(dummy_region->end());
2178 G1AllocRegion::setup(this, dummy_region);
2179
2180 init_mutator_alloc_region();
2181
2182 // Do create of the monitoring and management support so that
2183 // values in the heap have been properly initialized.
2184 _g1mm = new G1MonitoringSupport(this);
2185
2186 return JNI_OK;
2187 }
2188
2189 size_t G1CollectedHeap::conservative_max_heap_alignment() {
2190 return HeapRegion::max_region_size();
2191 }
2192
2193 void G1CollectedHeap::ref_processing_init() {
2194 // Reference processing in G1 currently works as follows:
2195 //
2196 // * There are two reference processor instances. One is
2197 // used to record and process discovered references
2198 // during concurrent marking; the other is used to
2199 // record and process references during STW pauses
2200 // (both full and incremental).
2201 // * Both ref processors need to 'span' the entire heap as
2202 // the regions in the collection set may be dotted around.
2203 //
2204 // * For the concurrent marking ref processor:
2205 // * Reference discovery is enabled at initial marking.
2206 // * Reference discovery is disabled and the discovered
2207 // references processed etc during remarking.
2208 // * Reference discovery is MT (see below).
2209 // * Reference discovery requires a barrier (see below).
2210 // * Reference processing may or may not be MT
2211 // (depending on the value of ParallelRefProcEnabled
2212 // and ParallelGCThreads).
|