1728 // could instead use the remove_all_pending() method on free_list to
1729 // remove only the ones that we need to remove.
1730 tear_down_region_sets(true /* free_list_only */);
1731 shrink_helper(shrink_bytes);
1732 rebuild_region_sets(true /* free_list_only */);
1733
1734 _hrm.verify_optional();
1735 verify_region_sets_optional();
1736 }
1737
1738 // Public methods.
1739
1740 G1CollectedHeap::G1CollectedHeap(G1CollectorPolicy* policy_) :
1741 CollectedHeap(),
1742 _g1_policy(policy_),
1743 _dirty_card_queue_set(false),
1744 _is_alive_closure_cm(this),
1745 _is_alive_closure_stw(this),
1746 _ref_processor_cm(NULL),
1747 _ref_processor_stw(NULL),
1748 _bot_shared(NULL),
1749 _cg1r(NULL),
1750 _g1mm(NULL),
1751 _refine_cte_cl(NULL),
1752 _secondary_free_list("Secondary Free List", new SecondaryFreeRegionListMtSafeChecker()),
1753 _old_set("Old Set", false /* humongous */, new OldRegionSetMtSafeChecker()),
1754 _humongous_set("Master Humongous Set", true /* humongous */, new HumongousRegionSetMtSafeChecker()),
1755 _humongous_reclaim_candidates(),
1756 _has_humongous_reclaim_candidates(false),
1757 _archive_allocator(NULL),
1758 _free_regions_coming(false),
1759 _young_list(new YoungList(this)),
1760 _gc_time_stamp(0),
1761 _summary_bytes_used(0),
1762 _survivor_evac_stats(YoungPLABSize, PLABWeight),
1763 _old_evac_stats(OldPLABSize, PLABWeight),
1764 _expand_heap_after_alloc_failure(true),
1765 _old_marking_cycles_started(0),
1766 _old_marking_cycles_completed(0),
1767 _heap_summary_sent(false),
1768 _in_cset_fast_test(),
1889
1890 // Carve out the G1 part of the heap.
1891 ReservedSpace g1_rs = heap_rs.first_part(max_byte_size);
1892 size_t page_size = UseLargePages ? os::large_page_size() : os::vm_page_size();
1893 G1RegionToSpaceMapper* heap_storage =
1894 G1RegionToSpaceMapper::create_mapper(g1_rs,
1895 g1_rs.size(),
1896 page_size,
1897 HeapRegion::GrainBytes,
1898 1,
1899 mtJavaHeap);
1900 os::trace_page_sizes("G1 Heap", collector_policy()->min_heap_byte_size(),
1901 max_byte_size, page_size,
1902 heap_rs.base(),
1903 heap_rs.size());
1904 heap_storage->set_mapping_changed_listener(&_listener);
1905
1906 // Create storage for the BOT, card table, card counts table (hot card cache) and the bitmaps.
1907 G1RegionToSpaceMapper* bot_storage =
1908 create_aux_memory_mapper("Block offset table",
1909 G1BlockOffsetSharedArray::compute_size(g1_rs.size() / HeapWordSize),
1910 G1BlockOffsetSharedArray::heap_map_factor());
1911
1912 ReservedSpace cardtable_rs(G1SATBCardTableLoggingModRefBS::compute_size(g1_rs.size() / HeapWordSize));
1913 G1RegionToSpaceMapper* cardtable_storage =
1914 create_aux_memory_mapper("Card table",
1915 G1SATBCardTableLoggingModRefBS::compute_size(g1_rs.size() / HeapWordSize),
1916 G1SATBCardTableLoggingModRefBS::heap_map_factor());
1917
1918 G1RegionToSpaceMapper* card_counts_storage =
1919 create_aux_memory_mapper("Card counts table",
1920 G1CardCounts::compute_size(g1_rs.size() / HeapWordSize),
1921 G1CardCounts::heap_map_factor());
1922
1923 size_t bitmap_size = CMBitMap::compute_size(g1_rs.size());
1924 G1RegionToSpaceMapper* prev_bitmap_storage =
1925 create_aux_memory_mapper("Prev Bitmap", bitmap_size, CMBitMap::heap_map_factor());
1926 G1RegionToSpaceMapper* next_bitmap_storage =
1927 create_aux_memory_mapper("Next Bitmap", bitmap_size, CMBitMap::heap_map_factor());
1928
1929 _hrm.initialize(heap_storage, prev_bitmap_storage, next_bitmap_storage, bot_storage, cardtable_storage, card_counts_storage);
1930 g1_barrier_set()->initialize(cardtable_storage);
1931 // Do later initialization work for concurrent refinement.
1932 _cg1r->init(card_counts_storage);
1933
1934 // 6843694 - ensure that the maximum region index can fit
1935 // in the remembered set structures.
1936 const uint max_region_idx = (1U << (sizeof(RegionIdx_t)*BitsPerByte-1)) - 1;
1937 guarantee((max_regions() - 1) <= max_region_idx, "too many regions");
1938
1939 G1RemSet::initialize(max_regions());
1940
1941 size_t max_cards_per_region = ((size_t)1 << (sizeof(CardIdx_t)*BitsPerByte-1)) - 1;
1942 guarantee(HeapRegion::CardsPerRegion > 0, "make sure it's initialized");
1943 guarantee(HeapRegion::CardsPerRegion < max_cards_per_region,
1944 "too many cards per region");
1945
1946 FreeRegionList::set_unrealistically_long_length(max_regions() + 1);
1947
1948 _bot_shared = new G1BlockOffsetSharedArray(reserved_region(), bot_storage);
1949
1950 {
1951 HeapWord* start = _hrm.reserved().start();
1952 HeapWord* end = _hrm.reserved().end();
1953 size_t granularity = HeapRegion::GrainBytes;
1954
1955 _in_cset_fast_test.initialize(start, end, granularity);
1956 _humongous_reclaim_candidates.initialize(start, end, granularity);
1957 }
1958
1959 // Create the ConcurrentMark data structure and thread.
1960 // (Must do this late, so that "max_regions" is defined.)
1961 _cm = new ConcurrentMark(this, prev_bitmap_storage, next_bitmap_storage);
1962 if (_cm == NULL || !_cm->completed_initialization()) {
1963 vm_shutdown_during_initialization("Could not create/initialize ConcurrentMark");
1964 return JNI_ENOMEM;
1965 }
1966 _cmThread = _cm->cmThread();
1967
1968 // Now expand into the initial heap size.
|
1728 // could instead use the remove_all_pending() method on free_list to
1729 // remove only the ones that we need to remove.
1730 tear_down_region_sets(true /* free_list_only */);
1731 shrink_helper(shrink_bytes);
1732 rebuild_region_sets(true /* free_list_only */);
1733
1734 _hrm.verify_optional();
1735 verify_region_sets_optional();
1736 }
1737
1738 // Public methods.
1739
1740 G1CollectedHeap::G1CollectedHeap(G1CollectorPolicy* policy_) :
1741 CollectedHeap(),
1742 _g1_policy(policy_),
1743 _dirty_card_queue_set(false),
1744 _is_alive_closure_cm(this),
1745 _is_alive_closure_stw(this),
1746 _ref_processor_cm(NULL),
1747 _ref_processor_stw(NULL),
1748 _bot(NULL),
1749 _cg1r(NULL),
1750 _g1mm(NULL),
1751 _refine_cte_cl(NULL),
1752 _secondary_free_list("Secondary Free List", new SecondaryFreeRegionListMtSafeChecker()),
1753 _old_set("Old Set", false /* humongous */, new OldRegionSetMtSafeChecker()),
1754 _humongous_set("Master Humongous Set", true /* humongous */, new HumongousRegionSetMtSafeChecker()),
1755 _humongous_reclaim_candidates(),
1756 _has_humongous_reclaim_candidates(false),
1757 _archive_allocator(NULL),
1758 _free_regions_coming(false),
1759 _young_list(new YoungList(this)),
1760 _gc_time_stamp(0),
1761 _summary_bytes_used(0),
1762 _survivor_evac_stats(YoungPLABSize, PLABWeight),
1763 _old_evac_stats(OldPLABSize, PLABWeight),
1764 _expand_heap_after_alloc_failure(true),
1765 _old_marking_cycles_started(0),
1766 _old_marking_cycles_completed(0),
1767 _heap_summary_sent(false),
1768 _in_cset_fast_test(),
1889
1890 // Carve out the G1 part of the heap.
1891 ReservedSpace g1_rs = heap_rs.first_part(max_byte_size);
1892 size_t page_size = UseLargePages ? os::large_page_size() : os::vm_page_size();
1893 G1RegionToSpaceMapper* heap_storage =
1894 G1RegionToSpaceMapper::create_mapper(g1_rs,
1895 g1_rs.size(),
1896 page_size,
1897 HeapRegion::GrainBytes,
1898 1,
1899 mtJavaHeap);
1900 os::trace_page_sizes("G1 Heap", collector_policy()->min_heap_byte_size(),
1901 max_byte_size, page_size,
1902 heap_rs.base(),
1903 heap_rs.size());
1904 heap_storage->set_mapping_changed_listener(&_listener);
1905
1906 // Create storage for the BOT, card table, card counts table (hot card cache) and the bitmaps.
1907 G1RegionToSpaceMapper* bot_storage =
1908 create_aux_memory_mapper("Block offset table",
1909 G1BlockOffsetTable::compute_size(g1_rs.size() / HeapWordSize),
1910 G1BlockOffsetTable::heap_map_factor());
1911
1912 ReservedSpace cardtable_rs(G1SATBCardTableLoggingModRefBS::compute_size(g1_rs.size() / HeapWordSize));
1913 G1RegionToSpaceMapper* cardtable_storage =
1914 create_aux_memory_mapper("Card table",
1915 G1SATBCardTableLoggingModRefBS::compute_size(g1_rs.size() / HeapWordSize),
1916 G1SATBCardTableLoggingModRefBS::heap_map_factor());
1917
1918 G1RegionToSpaceMapper* card_counts_storage =
1919 create_aux_memory_mapper("Card counts table",
1920 G1CardCounts::compute_size(g1_rs.size() / HeapWordSize),
1921 G1CardCounts::heap_map_factor());
1922
1923 size_t bitmap_size = CMBitMap::compute_size(g1_rs.size());
1924 G1RegionToSpaceMapper* prev_bitmap_storage =
1925 create_aux_memory_mapper("Prev Bitmap", bitmap_size, CMBitMap::heap_map_factor());
1926 G1RegionToSpaceMapper* next_bitmap_storage =
1927 create_aux_memory_mapper("Next Bitmap", bitmap_size, CMBitMap::heap_map_factor());
1928
1929 _hrm.initialize(heap_storage, prev_bitmap_storage, next_bitmap_storage, bot_storage, cardtable_storage, card_counts_storage);
1930 g1_barrier_set()->initialize(cardtable_storage);
1931 // Do later initialization work for concurrent refinement.
1932 _cg1r->init(card_counts_storage);
1933
1934 // 6843694 - ensure that the maximum region index can fit
1935 // in the remembered set structures.
1936 const uint max_region_idx = (1U << (sizeof(RegionIdx_t)*BitsPerByte-1)) - 1;
1937 guarantee((max_regions() - 1) <= max_region_idx, "too many regions");
1938
1939 G1RemSet::initialize(max_regions());
1940
1941 size_t max_cards_per_region = ((size_t)1 << (sizeof(CardIdx_t)*BitsPerByte-1)) - 1;
1942 guarantee(HeapRegion::CardsPerRegion > 0, "make sure it's initialized");
1943 guarantee(HeapRegion::CardsPerRegion < max_cards_per_region,
1944 "too many cards per region");
1945
1946 FreeRegionList::set_unrealistically_long_length(max_regions() + 1);
1947
1948 _bot = new G1BlockOffsetTable(reserved_region(), bot_storage);
1949
1950 {
1951 HeapWord* start = _hrm.reserved().start();
1952 HeapWord* end = _hrm.reserved().end();
1953 size_t granularity = HeapRegion::GrainBytes;
1954
1955 _in_cset_fast_test.initialize(start, end, granularity);
1956 _humongous_reclaim_candidates.initialize(start, end, granularity);
1957 }
1958
1959 // Create the ConcurrentMark data structure and thread.
1960 // (Must do this late, so that "max_regions" is defined.)
1961 _cm = new ConcurrentMark(this, prev_bitmap_storage, next_bitmap_storage);
1962 if (_cm == NULL || !_cm->completed_initialization()) {
1963 vm_shutdown_during_initialization("Could not create/initialize ConcurrentMark");
1964 return JNI_ENOMEM;
1965 }
1966 _cmThread = _cm->cmThread();
1967
1968 // Now expand into the initial heap size.
|