687 // Need to keep the bounds of the ro and rw space for the Metaspace::contains |
687 // Need to keep the bounds of the ro and rw space for the Metaspace::contains |
688 // call, or is_in_shared_space. |
688 // call, or is_in_shared_space. |
689 bool MetaspaceShared::map_shared_spaces(FileMapInfo* mapinfo) { |
689 bool MetaspaceShared::map_shared_spaces(FileMapInfo* mapinfo) { |
690 size_t image_alignment = mapinfo->alignment(); |
690 size_t image_alignment = mapinfo->alignment(); |
691 |
691 |
692 // Map in the shared memory and then map the regions on top of it |
692 #ifndef _WINDOWS |
|
693 // Map in the shared memory and then map the regions on top of it. |
|
694 // On Windows, don't map the memory here because it will cause the |
|
695 // mappings of the regions to fail. |
693 ReservedSpace shared_rs = mapinfo->reserve_shared_memory(); |
696 ReservedSpace shared_rs = mapinfo->reserve_shared_memory(); |
694 if (!shared_rs.is_reserved()) return false; |
697 if (!shared_rs.is_reserved()) return false; |
|
698 #endif |
|
699 |
|
700 assert(!DumpSharedSpaces, "Should not be called with DumpSharedSpaces"); |
695 |
701 |
696 // Map each shared region |
702 // Map each shared region |
697 if ((_ro_base = mapinfo->map_region(ro)) != NULL && |
703 if ((_ro_base = mapinfo->map_region(ro)) != NULL && |
698 (_rw_base = mapinfo->map_region(rw)) != NULL && |
704 (_rw_base = mapinfo->map_region(rw)) != NULL && |
699 (_md_base = mapinfo->map_region(md)) != NULL && |
705 (_md_base = mapinfo->map_region(md)) != NULL && |
706 // that succeeded |
712 // that succeeded |
707 if (_ro_base != NULL) mapinfo->unmap_region(ro); |
713 if (_ro_base != NULL) mapinfo->unmap_region(ro); |
708 if (_rw_base != NULL) mapinfo->unmap_region(rw); |
714 if (_rw_base != NULL) mapinfo->unmap_region(rw); |
709 if (_md_base != NULL) mapinfo->unmap_region(md); |
715 if (_md_base != NULL) mapinfo->unmap_region(md); |
710 if (_mc_base != NULL) mapinfo->unmap_region(mc); |
716 if (_mc_base != NULL) mapinfo->unmap_region(mc); |
|
717 #ifndef _WINDOWS |
711 // Release the entire mapped region |
718 // Release the entire mapped region |
712 shared_rs.release(); |
719 shared_rs.release(); |
|
720 #endif |
713 // If -Xshare:on is specified, print out the error message and exit VM, |
721 // If -Xshare:on is specified, print out the error message and exit VM, |
714 // otherwise, set UseSharedSpaces to false and continue. |
722 // otherwise, set UseSharedSpaces to false and continue. |
715 if (RequireSharedSpaces) { |
723 if (RequireSharedSpaces) { |
716 vm_exit_during_initialization("Unable to use shared archive.", NULL); |
724 vm_exit_during_initialization("Unable to use shared archive.", NULL); |
717 } else { |
725 } else { |