1855 if (!shared_rs.is_reserved()) return false; |
1850 if (!shared_rs.is_reserved()) return false; |
1856 #endif |
1851 #endif |
1857 |
1852 |
1858 assert(!DumpSharedSpaces, "Should not be called with DumpSharedSpaces"); |
1853 assert(!DumpSharedSpaces, "Should not be called with DumpSharedSpaces"); |
1859 |
1854 |
1860 char* _ro_base = NULL; |
1855 char* ro_base = NULL; char* ro_top; |
1861 char* _rw_base = NULL; |
1856 char* rw_base = NULL; char* rw_top; |
1862 char* _mc_base = NULL; |
1857 char* mc_base = NULL; char* mc_top; |
1863 char* _md_base = NULL; |
1858 char* md_base = NULL; char* md_top; |
1864 char* _od_base = NULL; |
1859 char* od_base = NULL; char* od_top; |
1865 |
1860 |
1866 // Map each shared region |
1861 // Map each shared region |
1867 if ((_mc_base = mapinfo->map_region(mc)) != NULL && |
1862 if ((mc_base = mapinfo->map_region(mc, &mc_top)) != NULL && |
1868 mapinfo->verify_region_checksum(mc) && |
1863 (rw_base = mapinfo->map_region(rw, &rw_top)) != NULL && |
1869 (_rw_base = mapinfo->map_region(rw)) != NULL && |
1864 (ro_base = mapinfo->map_region(ro, &ro_top)) != NULL && |
1870 mapinfo->verify_region_checksum(rw) && |
1865 (md_base = mapinfo->map_region(md, &md_top)) != NULL && |
1871 (_ro_base = mapinfo->map_region(ro)) != NULL && |
1866 (od_base = mapinfo->map_region(od, &od_top)) != NULL && |
1872 mapinfo->verify_region_checksum(ro) && |
|
1873 (_md_base = mapinfo->map_region(md)) != NULL && |
|
1874 mapinfo->verify_region_checksum(md) && |
|
1875 (_od_base = mapinfo->map_region(od)) != NULL && |
|
1876 mapinfo->verify_region_checksum(od) && |
|
1877 (image_alignment == (size_t)os::vm_allocation_granularity()) && |
1867 (image_alignment == (size_t)os::vm_allocation_granularity()) && |
1878 mapinfo->validate_classpath_entry_table()) { |
1868 mapinfo->validate_classpath_entry_table()) { |
1879 // Success (no need to do anything) |
1869 // Success -- set up MetaspaceObj::_shared_metaspace_{base,top} for |
|
1870 // fast checking in MetaspaceShared::is_in_shared_metaspace() and |
|
1871 // MetaspaceObj::is_shared(). |
|
1872 // |
|
1873 // We require that mc->rw->ro->md->od to be laid out consecutively, with no |
|
1874 // gaps between them. That way, we can ensure that the OS won't be able to |
|
1875 // allocate any new memory spaces inside _shared_metaspace_{base,top}, which |
|
1876 // would mess up the simple comparision in MetaspaceShared::is_in_shared_metaspace(). |
|
1877 assert(mc_base < ro_base && mc_base < rw_base && mc_base < md_base && mc_base < od_base, "must be"); |
|
1878 assert(od_top > ro_top && od_top > rw_top && od_top > md_top && od_top > mc_top , "must be"); |
|
1879 assert(mc_top == rw_base, "must be"); |
|
1880 assert(rw_top == ro_base, "must be"); |
|
1881 assert(ro_top == md_base, "must be"); |
|
1882 assert(md_top == od_base, "must be"); |
|
1883 |
|
1884 MetaspaceObj::_shared_metaspace_base = (void*)mc_base; |
|
1885 MetaspaceObj::_shared_metaspace_top = (void*)od_top; |
1880 return true; |
1886 return true; |
1881 } else { |
1887 } else { |
1882 // If there was a failure in mapping any of the spaces, unmap the ones |
1888 // If there was a failure in mapping any of the spaces, unmap the ones |
1883 // that succeeded |
1889 // that succeeded |
1884 if (_ro_base != NULL) mapinfo->unmap_region(ro); |
1890 if (ro_base != NULL) mapinfo->unmap_region(ro); |
1885 if (_rw_base != NULL) mapinfo->unmap_region(rw); |
1891 if (rw_base != NULL) mapinfo->unmap_region(rw); |
1886 if (_mc_base != NULL) mapinfo->unmap_region(mc); |
1892 if (mc_base != NULL) mapinfo->unmap_region(mc); |
1887 if (_md_base != NULL) mapinfo->unmap_region(md); |
1893 if (md_base != NULL) mapinfo->unmap_region(md); |
1888 if (_od_base != NULL) mapinfo->unmap_region(od); |
1894 if (od_base != NULL) mapinfo->unmap_region(od); |
1889 #ifndef _WINDOWS |
1895 #ifndef _WINDOWS |
1890 // Release the entire mapped region |
1896 // Release the entire mapped region |
1891 shared_rs.release(); |
1897 shared_rs.release(); |
1892 #endif |
1898 #endif |
1893 // If -Xshare:on is specified, print out the error message and exit VM, |
1899 // If -Xshare:on is specified, print out the error message and exit VM, |