< prev index next >

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

Print this page
rev 7989 : 8058354: SPECjvm2008-Derby -2.7% performance regression on Solaris-X64 starting with 9-b29
Summary: Allow partial use of large pages for auxiliary data structures in G1.
Reviewed-by: jmasa
rev 7990 : imported patch 8058354-stefank-review
rev 7991 : imported patch 8058354-more-stefank-review
rev 7992 : imported patch 8058354-more-more-stefank-review


1815   assert(n_rem_sets > 0, "Invariant.");
1816 
1817   _worker_cset_start_region = NEW_C_HEAP_ARRAY(HeapRegion*, n_queues, mtGC);
1818   _worker_cset_start_region_time_stamp = NEW_C_HEAP_ARRAY(uint, n_queues, mtGC);
1819   _evacuation_failed_info_array = NEW_C_HEAP_ARRAY(EvacuationFailedInfo, n_queues, mtGC);
1820 
1821   for (int i = 0; i < n_queues; i++) {
1822     RefToScanQueue* q = new RefToScanQueue();
1823     q->initialize();
1824     _task_queues->register_queue(i, q);
1825     ::new (&_evacuation_failed_info_array[i]) EvacuationFailedInfo();
1826   }
1827   clear_cset_start_regions();
1828 
1829   // Initialize the G1EvacuationFailureALot counters and flags.
1830   NOT_PRODUCT(reset_evacuation_should_fail();)
1831 
1832   guarantee(_task_queues != NULL, "task_queues allocation failure.");
1833 }
1834 



















1835 jint G1CollectedHeap::initialize() {
1836   CollectedHeap::pre_initialize();
1837   os::enable_vtime();
1838 
1839   G1Log::init();
1840 
1841   // Necessary to satisfy locking discipline assertions.
1842 
1843   MutexLocker x(Heap_lock);
1844 
1845   // We have to initialize the printer before committing the heap, as
1846   // it will be used then.
1847   _hr_printer.set_active(G1PrintHeapRegions);
1848 
1849   // While there are no constraints in the GC code that HeapWordSize
1850   // be any particular value, there are multiple other areas in the
1851   // system which believe this to be true (e.g. oop->object_size in some
1852   // cases incorrectly returns the size in wordSize units rather than
1853   // HeapWordSize).
1854   guarantee(HeapWordSize == wordSize, "HeapWordSize must equal wordSize");


1882   ReservedSpace heap_rs = Universe::reserve_heap(max_byte_size,
1883                                                  heap_alignment);
1884 
1885   initialize_reserved_region((HeapWord*)heap_rs.base(), (HeapWord*)(heap_rs.base() + heap_rs.size()));
1886 
1887   // Create the barrier set for the entire reserved region.
1888   G1SATBCardTableLoggingModRefBS* bs
1889     = new G1SATBCardTableLoggingModRefBS(reserved_region());
1890   bs->initialize();
1891   assert(bs->is_a(BarrierSet::G1SATBCTLogging), "sanity");
1892   set_barrier_set(bs);
1893 
1894   // Also create a G1 rem set.
1895   _g1_rem_set = new G1RemSet(this, g1_barrier_set());
1896 
1897   // Carve out the G1 part of the heap.
1898 
1899   ReservedSpace g1_rs = heap_rs.first_part(max_byte_size);
1900   G1RegionToSpaceMapper* heap_storage =
1901     G1RegionToSpaceMapper::create_mapper(g1_rs,

1902                                          UseLargePages ? os::large_page_size() : os::vm_page_size(),
1903                                          HeapRegion::GrainBytes,
1904                                          1,
1905                                          mtJavaHeap);
1906   heap_storage->set_mapping_changed_listener(&_listener);
1907 
1908   // Reserve space for the block offset table. We do not support automatic uncommit
1909   // for the card table at this time. BOT only.
1910   ReservedSpace bot_rs(G1BlockOffsetSharedArray::compute_size(g1_rs.size() / HeapWordSize));
1911   G1RegionToSpaceMapper* bot_storage =
1912     G1RegionToSpaceMapper::create_mapper(bot_rs,
1913                                          os::vm_page_size(),
1914                                          HeapRegion::GrainBytes,
1915                                          G1BlockOffsetSharedArray::N_bytes,
1916                                          mtGC);
1917 
1918   ReservedSpace cardtable_rs(G1SATBCardTableLoggingModRefBS::compute_size(g1_rs.size() / HeapWordSize));
1919   G1RegionToSpaceMapper* cardtable_storage =
1920     G1RegionToSpaceMapper::create_mapper(cardtable_rs,
1921                                          os::vm_page_size(),
1922                                          HeapRegion::GrainBytes,
1923                                          G1BlockOffsetSharedArray::N_bytes,
1924                                          mtGC);
1925 
1926   // Reserve space for the card counts table.
1927   ReservedSpace card_counts_rs(G1BlockOffsetSharedArray::compute_size(g1_rs.size() / HeapWordSize));
1928   G1RegionToSpaceMapper* card_counts_storage =
1929     G1RegionToSpaceMapper::create_mapper(card_counts_rs,
1930                                          os::vm_page_size(),
1931                                          HeapRegion::GrainBytes,
1932                                          G1BlockOffsetSharedArray::N_bytes,
1933                                          mtGC);
1934 
1935   // Reserve space for prev and next bitmap.
1936   size_t bitmap_size = CMBitMap::compute_size(g1_rs.size());
1937 
1938   ReservedSpace prev_bitmap_rs(ReservedSpace::allocation_align_size_up(bitmap_size));
1939   G1RegionToSpaceMapper* prev_bitmap_storage =
1940     G1RegionToSpaceMapper::create_mapper(prev_bitmap_rs,
1941                                          os::vm_page_size(),
1942                                          HeapRegion::GrainBytes,
1943                                          CMBitMap::mark_distance(),
1944                                          mtGC);
1945 
1946   ReservedSpace next_bitmap_rs(ReservedSpace::allocation_align_size_up(bitmap_size));
1947   G1RegionToSpaceMapper* next_bitmap_storage =
1948     G1RegionToSpaceMapper::create_mapper(next_bitmap_rs,
1949                                          os::vm_page_size(),
1950                                          HeapRegion::GrainBytes,
1951                                          CMBitMap::mark_distance(),
1952                                          mtGC);
1953 
1954   _hrm.initialize(heap_storage, prev_bitmap_storage, next_bitmap_storage, bot_storage, cardtable_storage, card_counts_storage);
1955   g1_barrier_set()->initialize(cardtable_storage);
1956    // Do later initialization work for concurrent refinement.
1957   _cg1r->init(card_counts_storage);
1958 
1959   // 6843694 - ensure that the maximum region index can fit
1960   // in the remembered set structures.
1961   const uint max_region_idx = (1U << (sizeof(RegionIdx_t)*BitsPerByte-1)) - 1;
1962   guarantee((max_regions() - 1) <= max_region_idx, "too many regions");
1963 
1964   size_t max_cards_per_region = ((size_t)1 << (sizeof(CardIdx_t)*BitsPerByte-1)) - 1;
1965   guarantee(HeapRegion::CardsPerRegion > 0, "make sure it's initialized");
1966   guarantee(HeapRegion::CardsPerRegion < max_cards_per_region,
1967             "too many cards per region");
1968 
1969   FreeRegionList::set_unrealistically_long_length(max_regions() + 1);
1970 
1971   _bot_shared = new G1BlockOffsetSharedArray(reserved_region(), bot_storage);
1972 




1815   assert(n_rem_sets > 0, "Invariant.");
1816 
1817   _worker_cset_start_region = NEW_C_HEAP_ARRAY(HeapRegion*, n_queues, mtGC);
1818   _worker_cset_start_region_time_stamp = NEW_C_HEAP_ARRAY(uint, n_queues, mtGC);
1819   _evacuation_failed_info_array = NEW_C_HEAP_ARRAY(EvacuationFailedInfo, n_queues, mtGC);
1820 
1821   for (int i = 0; i < n_queues; i++) {
1822     RefToScanQueue* q = new RefToScanQueue();
1823     q->initialize();
1824     _task_queues->register_queue(i, q);
1825     ::new (&_evacuation_failed_info_array[i]) EvacuationFailedInfo();
1826   }
1827   clear_cset_start_regions();
1828 
1829   // Initialize the G1EvacuationFailureALot counters and flags.
1830   NOT_PRODUCT(reset_evacuation_should_fail();)
1831 
1832   guarantee(_task_queues != NULL, "task_queues allocation failure.");
1833 }
1834 
1835 G1RegionToSpaceMapper* G1CollectedHeap::create_aux_memory_mapper(const char* description,
1836                                                                  size_t size,
1837                                                                  size_t translation_factor) {
1838   // Allocate a new reserved space, preferring to use large pages.
1839   ReservedSpace rs(size, true);
1840   G1RegionToSpaceMapper* result  =
1841     G1RegionToSpaceMapper::create_mapper(rs,
1842                                          size,
1843                                          rs.alignment(),
1844                                          HeapRegion::GrainBytes,
1845                                          translation_factor,
1846                                          mtGC);
1847   if (TracePageSizes) {
1848     gclog_or_tty->print_cr("G1 '%s': pg_sz=" SIZE_FORMAT " base=" PTR_FORMAT " size=" SIZE_FORMAT " alignment=" SIZE_FORMAT " reqsize=" SIZE_FORMAT,
1849                            description, rs.alignment(), p2i(rs.base()), rs.size(), rs.alignment(), size);
1850   }
1851   return result;
1852 }
1853 
1854 jint G1CollectedHeap::initialize() {
1855   CollectedHeap::pre_initialize();
1856   os::enable_vtime();
1857 
1858   G1Log::init();
1859 
1860   // Necessary to satisfy locking discipline assertions.
1861 
1862   MutexLocker x(Heap_lock);
1863 
1864   // We have to initialize the printer before committing the heap, as
1865   // it will be used then.
1866   _hr_printer.set_active(G1PrintHeapRegions);
1867 
1868   // While there are no constraints in the GC code that HeapWordSize
1869   // be any particular value, there are multiple other areas in the
1870   // system which believe this to be true (e.g. oop->object_size in some
1871   // cases incorrectly returns the size in wordSize units rather than
1872   // HeapWordSize).
1873   guarantee(HeapWordSize == wordSize, "HeapWordSize must equal wordSize");


1901   ReservedSpace heap_rs = Universe::reserve_heap(max_byte_size,
1902                                                  heap_alignment);
1903 
1904   initialize_reserved_region((HeapWord*)heap_rs.base(), (HeapWord*)(heap_rs.base() + heap_rs.size()));
1905 
1906   // Create the barrier set for the entire reserved region.
1907   G1SATBCardTableLoggingModRefBS* bs
1908     = new G1SATBCardTableLoggingModRefBS(reserved_region());
1909   bs->initialize();
1910   assert(bs->is_a(BarrierSet::G1SATBCTLogging), "sanity");
1911   set_barrier_set(bs);
1912 
1913   // Also create a G1 rem set.
1914   _g1_rem_set = new G1RemSet(this, g1_barrier_set());
1915 
1916   // Carve out the G1 part of the heap.
1917 
1918   ReservedSpace g1_rs = heap_rs.first_part(max_byte_size);
1919   G1RegionToSpaceMapper* heap_storage =
1920     G1RegionToSpaceMapper::create_mapper(g1_rs,
1921                                          g1_rs.size(),
1922                                          UseLargePages ? os::large_page_size() : os::vm_page_size(),
1923                                          HeapRegion::GrainBytes,
1924                                          1,
1925                                          mtJavaHeap);
1926   heap_storage->set_mapping_changed_listener(&_listener);
1927 
1928   // Create storage for the BOT, card table, card counts table (hot card cache) and the bitmaps.


1929   G1RegionToSpaceMapper* bot_storage =
1930     create_aux_memory_mapper("Block offset table",
1931                              G1BlockOffsetSharedArray::compute_size(g1_rs.size() / HeapWordSize),
1932                              G1BlockOffsetSharedArray::N_bytes);


1933 
1934   ReservedSpace cardtable_rs(G1SATBCardTableLoggingModRefBS::compute_size(g1_rs.size() / HeapWordSize));
1935   G1RegionToSpaceMapper* cardtable_storage =
1936     create_aux_memory_mapper("Card table",
1937                              G1SATBCardTableLoggingModRefBS::compute_size(g1_rs.size() / HeapWordSize),
1938                              G1BlockOffsetSharedArray::N_bytes);


1939 


1940   G1RegionToSpaceMapper* card_counts_storage =
1941     create_aux_memory_mapper("Card counts table",
1942                              G1BlockOffsetSharedArray::compute_size(g1_rs.size() / HeapWordSize),
1943                              G1BlockOffsetSharedArray::N_bytes);


1944 

1945   size_t bitmap_size = CMBitMap::compute_size(g1_rs.size());


1946   G1RegionToSpaceMapper* prev_bitmap_storage =
1947     create_aux_memory_mapper("Prev Bitmap", bitmap_size, CMBitMap::mark_distance());






1948   G1RegionToSpaceMapper* next_bitmap_storage =
1949     create_aux_memory_mapper("Next Bitmap", bitmap_size, CMBitMap::mark_distance());




1950 
1951   _hrm.initialize(heap_storage, prev_bitmap_storage, next_bitmap_storage, bot_storage, cardtable_storage, card_counts_storage);
1952   g1_barrier_set()->initialize(cardtable_storage);
1953    // Do later initialization work for concurrent refinement.
1954   _cg1r->init(card_counts_storage);
1955 
1956   // 6843694 - ensure that the maximum region index can fit
1957   // in the remembered set structures.
1958   const uint max_region_idx = (1U << (sizeof(RegionIdx_t)*BitsPerByte-1)) - 1;
1959   guarantee((max_regions() - 1) <= max_region_idx, "too many regions");
1960 
1961   size_t max_cards_per_region = ((size_t)1 << (sizeof(CardIdx_t)*BitsPerByte-1)) - 1;
1962   guarantee(HeapRegion::CardsPerRegion > 0, "make sure it's initialized");
1963   guarantee(HeapRegion::CardsPerRegion < max_cards_per_region,
1964             "too many cards per region");
1965 
1966   FreeRegionList::set_unrealistically_long_length(max_regions() + 1);
1967 
1968   _bot_shared = new G1BlockOffsetSharedArray(reserved_region(), bot_storage);
1969 


< prev index next >