1643 // Allocate a new reserved space, preferring to use large pages.
1644 ReservedSpace rs(size, preferred_page_size);
1645 G1RegionToSpaceMapper* result =
1646 G1RegionToSpaceMapper::create_mapper(rs,
1647 size,
1648 rs.alignment(),
1649 HeapRegion::GrainBytes,
1650 translation_factor,
1651 mtGC);
1652
1653 os::trace_page_sizes_for_requested_size(description,
1654 size,
1655 preferred_page_size,
1656 rs.alignment(),
1657 rs.base(),
1658 rs.size());
1659
1660 return result;
1661 }
1662
1663 jint G1CollectedHeap::initialize() {
1664 CollectedHeap::pre_initialize();
1665 os::enable_vtime();
1666
1667 // Necessary to satisfy locking discipline assertions.
1668
1669 MutexLocker x(Heap_lock);
1670
1671 // While there are no constraints in the GC code that HeapWordSize
1672 // be any particular value, there are multiple other areas in the
1673 // system which believe this to be true (e.g. oop->object_size in some
1674 // cases incorrectly returns the size in wordSize units rather than
1675 // HeapWordSize).
1676 guarantee(HeapWordSize == wordSize, "HeapWordSize must equal wordSize");
1677
1678 size_t init_byte_size = collector_policy()->initial_heap_byte_size();
1679 size_t max_byte_size = collector_policy()->max_heap_byte_size();
1680 size_t heap_alignment = collector_policy()->heap_alignment();
1681
1682 // Ensure that the sizes are properly aligned.
1791 if (_cm == NULL || !_cm->completed_initialization()) {
1792 vm_shutdown_during_initialization("Could not create/initialize G1ConcurrentMark");
1793 return JNI_ENOMEM;
1794 }
1795 _cmThread = _cm->cmThread();
1796
1797 // Now expand into the initial heap size.
1798 if (!expand(init_byte_size, _workers)) {
1799 vm_shutdown_during_initialization("Failed to allocate initial heap.");
1800 return JNI_ENOMEM;
1801 }
1802
1803 // Perform any initialization actions delegated to the policy.
1804 g1_policy()->init(this, &_collection_set);
1805
1806 JavaThread::satb_mark_queue_set().initialize(SATB_Q_CBL_mon,
1807 SATB_Q_FL_lock,
1808 G1SATBProcessCompletedThreshold,
1809 Shared_SATB_Q_lock);
1810
1811 _refine_cte_cl = new RefineCardTableEntryClosure();
1812
1813 jint ecode = JNI_OK;
1814 _cg1r = ConcurrentG1Refine::create(_refine_cte_cl, &ecode);
1815 if (_cg1r == NULL) {
1816 return ecode;
1817 }
1818
1819 JavaThread::dirty_card_queue_set().initialize(_refine_cte_cl,
1820 DirtyCardQ_CBL_mon,
1821 DirtyCardQ_FL_lock,
1822 (int)concurrent_g1_refine()->yellow_zone(),
1823 (int)concurrent_g1_refine()->red_zone(),
1824 Shared_DirtyCardQ_lock,
1825 NULL, // fl_owner
1826 true); // init_free_ids
1827
1828 dirty_card_queue_set().initialize(NULL, // Should never be called by the Java code
1829 DirtyCardQ_CBL_mon,
1830 DirtyCardQ_FL_lock,
1831 -1, // never trigger processing
1832 -1, // no limit on length
1833 Shared_DirtyCardQ_lock,
1834 &JavaThread::dirty_card_queue_set());
1835
1840 // We'll re-use the same region whether the alloc region will
1841 // require BOT updates or not and, if it doesn't, then a non-young
1842 // region will complain that it cannot support allocations without
1843 // BOT updates. So we'll tag the dummy region as eden to avoid that.
1844 dummy_region->set_eden();
1845 // Make sure it's full.
1846 dummy_region->set_top(dummy_region->end());
1847 G1AllocRegion::setup(this, dummy_region);
1848
1849 _allocator->init_mutator_alloc_region();
1850
1851 // Do create of the monitoring and management support so that
1852 // values in the heap have been properly initialized.
1853 _g1mm = new G1MonitoringSupport(this);
1854
1855 G1StringDedup::initialize();
1856
1857 _preserved_marks_set.init(ParallelGCThreads);
1858
1859 _collection_set.initialize(max_regions());
1860
1861 _g1_rem_set->initialize_periodic_summary_info();
1862
1863 return JNI_OK;
1864 }
1865
1866 void G1CollectedHeap::stop() {
1867 // Stop all concurrent threads. We do this to make sure these threads
1868 // do not continue to execute and access resources (e.g. logging)
1869 // that are destroyed during shutdown.
1870 _cg1r->stop();
1871 _cmThread->stop();
1872 if (G1StringDedup::is_enabled()) {
1873 G1StringDedup::stop();
1874 }
1875 }
1876
1877 size_t G1CollectedHeap::conservative_max_heap_alignment() {
1878 return HeapRegion::max_region_size();
1879 }
1880
1881 void G1CollectedHeap::post_initialize() {
|
1643 // Allocate a new reserved space, preferring to use large pages.
1644 ReservedSpace rs(size, preferred_page_size);
1645 G1RegionToSpaceMapper* result =
1646 G1RegionToSpaceMapper::create_mapper(rs,
1647 size,
1648 rs.alignment(),
1649 HeapRegion::GrainBytes,
1650 translation_factor,
1651 mtGC);
1652
1653 os::trace_page_sizes_for_requested_size(description,
1654 size,
1655 preferred_page_size,
1656 rs.alignment(),
1657 rs.base(),
1658 rs.size());
1659
1660 return result;
1661 }
1662
1663 jint G1CollectedHeap::initialize_concurrent_refinement() {
1664 _refine_cte_cl = new RefineCardTableEntryClosure();
1665
1666 jint ecode = JNI_OK;
1667 _cg1r = ConcurrentG1Refine::create(_refine_cte_cl, &ecode);
1668 return ecode;
1669 }
1670
1671 jint G1CollectedHeap::initialize() {
1672 CollectedHeap::pre_initialize();
1673 os::enable_vtime();
1674
1675 // Necessary to satisfy locking discipline assertions.
1676
1677 MutexLocker x(Heap_lock);
1678
1679 // While there are no constraints in the GC code that HeapWordSize
1680 // be any particular value, there are multiple other areas in the
1681 // system which believe this to be true (e.g. oop->object_size in some
1682 // cases incorrectly returns the size in wordSize units rather than
1683 // HeapWordSize).
1684 guarantee(HeapWordSize == wordSize, "HeapWordSize must equal wordSize");
1685
1686 size_t init_byte_size = collector_policy()->initial_heap_byte_size();
1687 size_t max_byte_size = collector_policy()->max_heap_byte_size();
1688 size_t heap_alignment = collector_policy()->heap_alignment();
1689
1690 // Ensure that the sizes are properly aligned.
1799 if (_cm == NULL || !_cm->completed_initialization()) {
1800 vm_shutdown_during_initialization("Could not create/initialize G1ConcurrentMark");
1801 return JNI_ENOMEM;
1802 }
1803 _cmThread = _cm->cmThread();
1804
1805 // Now expand into the initial heap size.
1806 if (!expand(init_byte_size, _workers)) {
1807 vm_shutdown_during_initialization("Failed to allocate initial heap.");
1808 return JNI_ENOMEM;
1809 }
1810
1811 // Perform any initialization actions delegated to the policy.
1812 g1_policy()->init(this, &_collection_set);
1813
1814 JavaThread::satb_mark_queue_set().initialize(SATB_Q_CBL_mon,
1815 SATB_Q_FL_lock,
1816 G1SATBProcessCompletedThreshold,
1817 Shared_SATB_Q_lock);
1818
1819 jint ecode = initialize_concurrent_refinement();
1820 if (ecode != JNI_OK) {
1821 return ecode;
1822 }
1823
1824 JavaThread::dirty_card_queue_set().initialize(_refine_cte_cl,
1825 DirtyCardQ_CBL_mon,
1826 DirtyCardQ_FL_lock,
1827 (int)concurrent_g1_refine()->yellow_zone(),
1828 (int)concurrent_g1_refine()->red_zone(),
1829 Shared_DirtyCardQ_lock,
1830 NULL, // fl_owner
1831 true); // init_free_ids
1832
1833 dirty_card_queue_set().initialize(NULL, // Should never be called by the Java code
1834 DirtyCardQ_CBL_mon,
1835 DirtyCardQ_FL_lock,
1836 -1, // never trigger processing
1837 -1, // no limit on length
1838 Shared_DirtyCardQ_lock,
1839 &JavaThread::dirty_card_queue_set());
1840
1845 // We'll re-use the same region whether the alloc region will
1846 // require BOT updates or not and, if it doesn't, then a non-young
1847 // region will complain that it cannot support allocations without
1848 // BOT updates. So we'll tag the dummy region as eden to avoid that.
1849 dummy_region->set_eden();
1850 // Make sure it's full.
1851 dummy_region->set_top(dummy_region->end());
1852 G1AllocRegion::setup(this, dummy_region);
1853
1854 _allocator->init_mutator_alloc_region();
1855
1856 // Do create of the monitoring and management support so that
1857 // values in the heap have been properly initialized.
1858 _g1mm = new G1MonitoringSupport(this);
1859
1860 G1StringDedup::initialize();
1861
1862 _preserved_marks_set.init(ParallelGCThreads);
1863
1864 _collection_set.initialize(max_regions());
1865
1866 return JNI_OK;
1867 }
1868
1869 void G1CollectedHeap::stop() {
1870 // Stop all concurrent threads. We do this to make sure these threads
1871 // do not continue to execute and access resources (e.g. logging)
1872 // that are destroyed during shutdown.
1873 _cg1r->stop();
1874 _cmThread->stop();
1875 if (G1StringDedup::is_enabled()) {
1876 G1StringDedup::stop();
1877 }
1878 }
1879
1880 size_t G1CollectedHeap::conservative_max_heap_alignment() {
1881 return HeapRegion::max_region_size();
1882 }
1883
1884 void G1CollectedHeap::post_initialize() {
|