src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File hsx-rt.8007074 Sdiff src/share/vm/gc_implementation/g1

src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp

Print this page




2002 
2003   G1Log::init();
2004 
2005   // Necessary to satisfy locking discipline assertions.
2006 
2007   MutexLocker x(Heap_lock);
2008 
2009   // We have to initialize the printer before committing the heap, as
2010   // it will be used then.
2011   _hr_printer.set_active(G1PrintHeapRegions);
2012 
2013   // While there are no constraints in the GC code that HeapWordSize
2014   // be any particular value, there are multiple other areas in the
2015   // system which believe this to be true (e.g. oop->object_size in some
2016   // cases incorrectly returns the size in wordSize units rather than
2017   // HeapWordSize).
2018   guarantee(HeapWordSize == wordSize, "HeapWordSize must equal wordSize");
2019 
2020   size_t init_byte_size = collector_policy()->initial_heap_byte_size();
2021   size_t max_byte_size = collector_policy()->max_heap_byte_size();

2022 
2023   // Ensure that the sizes are properly aligned.
2024   Universe::check_alignment(init_byte_size, HeapRegion::GrainBytes, "g1 heap");
2025   Universe::check_alignment(max_byte_size, HeapRegion::GrainBytes, "g1 heap");

2026 
2027   _cg1r = new ConcurrentG1Refine(this);
2028 
2029   // Reserve the maximum.
2030 
2031   // When compressed oops are enabled, the preferred heap base
2032   // is calculated by subtracting the requested size from the
2033   // 32Gb boundary and using the result as the base address for
2034   // heap reservation. If the requested size is not aligned to
2035   // HeapRegion::GrainBytes (i.e. the alignment that is passed
2036   // into the ReservedHeapSpace constructor) then the actual
2037   // base of the reserved heap may end up differing from the
2038   // address that was requested (i.e. the preferred heap base).
2039   // If this happens then we could end up using a non-optimal
2040   // compressed oops mode.
2041 
2042   // Since max_byte_size is aligned to the size of a heap region (checked
2043   // above).
2044   Universe::check_alignment(max_byte_size, HeapRegion::GrainBytes, "g1 heap");
2045 
2046   ReservedSpace heap_rs = Universe::reserve_heap(max_byte_size,
2047                                                  HeapRegion::GrainBytes);
2048 
2049   // It is important to do this in a way such that concurrent readers can't
2050   // temporarily think something is in the heap.  (I've actually seen this
2051   // happen in asserts: DLD.)
2052   _reserved.set_word_size(0);
2053   _reserved.set_start((HeapWord*)heap_rs.base());
2054   _reserved.set_end((HeapWord*)(heap_rs.base() + heap_rs.size()));
2055 
2056   _expansion_regions = (uint) (max_byte_size / HeapRegion::GrainBytes);
2057 
2058   // Create the gen rem set (and barrier set) for the entire reserved region.
2059   _rem_set = collector_policy()->create_rem_set(_reserved, 2);
2060   set_barrier_set(rem_set()->bs());
2061   if (barrier_set()->is_a(BarrierSet::ModRef)) {
2062     _mr_bs = (ModRefBarrierSet*)_barrier_set;
2063   } else {
2064     vm_exit_during_initialization("G1 requires a mod ref bs.");
2065     return JNI_ENOMEM;
2066   }
2067 




2002 
2003   G1Log::init();
2004 
2005   // Necessary to satisfy locking discipline assertions.
2006 
2007   MutexLocker x(Heap_lock);
2008 
2009   // We have to initialize the printer before committing the heap, as
2010   // it will be used then.
2011   _hr_printer.set_active(G1PrintHeapRegions);
2012 
2013   // While there are no constraints in the GC code that HeapWordSize
2014   // be any particular value, there are multiple other areas in the
2015   // system which believe this to be true (e.g. oop->object_size in some
2016   // cases incorrectly returns the size in wordSize units rather than
2017   // HeapWordSize).
2018   guarantee(HeapWordSize == wordSize, "HeapWordSize must equal wordSize");
2019 
2020   size_t init_byte_size = collector_policy()->initial_heap_byte_size();
2021   size_t max_byte_size = collector_policy()->max_heap_byte_size();
2022   size_t heap_alignment = collector_policy()->max_alignment();
2023 
2024   // Ensure that the sizes are properly aligned.
2025   Universe::check_alignment(init_byte_size, HeapRegion::GrainBytes, "g1 heap");
2026   Universe::check_alignment(max_byte_size, HeapRegion::GrainBytes, "g1 heap");
2027   Universe::check_alignment(max_byte_size, heap_alignment, "g1 heap");
2028 
2029   _cg1r = new ConcurrentG1Refine(this);
2030 
2031   // Reserve the maximum.
2032 
2033   // When compressed oops are enabled, the preferred heap base
2034   // is calculated by subtracting the requested size from the
2035   // 32Gb boundary and using the result as the base address for
2036   // heap reservation. If the requested size is not aligned to
2037   // HeapRegion::GrainBytes (i.e. the alignment that is passed
2038   // into the ReservedHeapSpace constructor) then the actual
2039   // base of the reserved heap may end up differing from the
2040   // address that was requested (i.e. the preferred heap base).
2041   // If this happens then we could end up using a non-optimal
2042   // compressed oops mode.
2043 




2044   ReservedSpace heap_rs = Universe::reserve_heap(max_byte_size,
2045                                                  heap_alignment);
2046 
2047   // It is important to do this in a way such that concurrent readers can't
2048   // temporarily think something is in the heap.  (I've actually seen this
2049   // happen in asserts: DLD.)
2050   _reserved.set_word_size(0);
2051   _reserved.set_start((HeapWord*)heap_rs.base());
2052   _reserved.set_end((HeapWord*)(heap_rs.base() + heap_rs.size()));
2053 
2054   _expansion_regions = (uint) (max_byte_size / HeapRegion::GrainBytes);
2055 
2056   // Create the gen rem set (and barrier set) for the entire reserved region.
2057   _rem_set = collector_policy()->create_rem_set(_reserved, 2);
2058   set_barrier_set(rem_set()->bs());
2059   if (barrier_set()->is_a(BarrierSet::ModRef)) {
2060     _mr_bs = (ModRefBarrierSet*)_barrier_set;
2061   } else {
2062     vm_exit_during_initialization("G1 requires a mod ref bs.");
2063     return JNI_ENOMEM;
2064   }
2065 


src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File