2145 p2i(class_space_rs.base()), p2i(class_space_rs.end()), class_space_rs.size()); |
2145 p2i(class_space_rs.base()), p2i(class_space_rs.end()), class_space_rs.size()); |
2146 MapArchiveResult static_result = map_archive(static_mapinfo, mapped_base_address, archive_space_rs); |
2146 MapArchiveResult static_result = map_archive(static_mapinfo, mapped_base_address, archive_space_rs); |
2147 MapArchiveResult dynamic_result = (static_result == MAP_ARCHIVE_SUCCESS) ? |
2147 MapArchiveResult dynamic_result = (static_result == MAP_ARCHIVE_SUCCESS) ? |
2148 map_archive(dynamic_mapinfo, mapped_base_address, archive_space_rs) : MAP_ARCHIVE_OTHER_FAILURE; |
2148 map_archive(dynamic_mapinfo, mapped_base_address, archive_space_rs) : MAP_ARCHIVE_OTHER_FAILURE; |
2149 |
2149 |
|
2150 DEBUG_ONLY(if (ArchiveRelocationMode == 1 && use_requested_addr) { |
|
2151 // This is for simulating mmap failures at the requested address. In debug builds, we do it |
|
2152 // here (after all archives have possibly been mapped), so we can thoroughly test the code for |
|
2153 // failure handling (releasing all allocated resource, etc). |
|
2154 log_info(cds)("ArchiveRelocationMode == 1: always map archive(s) at an alternative address"); |
|
2155 if (static_result == MAP_ARCHIVE_SUCCESS) { |
|
2156 static_result = MAP_ARCHIVE_MMAP_FAILURE; |
|
2157 } |
|
2158 if (dynamic_result == MAP_ARCHIVE_SUCCESS) { |
|
2159 dynamic_result = MAP_ARCHIVE_MMAP_FAILURE; |
|
2160 } |
|
2161 }); |
|
2162 |
2150 if (static_result == MAP_ARCHIVE_SUCCESS) { |
2163 if (static_result == MAP_ARCHIVE_SUCCESS) { |
2151 if (dynamic_result == MAP_ARCHIVE_SUCCESS) { |
2164 if (dynamic_result == MAP_ARCHIVE_SUCCESS) { |
2152 result = MAP_ARCHIVE_SUCCESS; |
2165 result = MAP_ARCHIVE_SUCCESS; |
2153 } else if (dynamic_result == MAP_ARCHIVE_OTHER_FAILURE) { |
2166 } else if (dynamic_result == MAP_ARCHIVE_OTHER_FAILURE) { |
2154 assert(dynamic_mapinfo != NULL && !dynamic_mapinfo->is_mapped(), "must have failed"); |
2167 assert(dynamic_mapinfo != NULL && !dynamic_mapinfo->is_mapped(), "must have failed"); |
2296 static int dynamic_regions_count = 3; |
2309 static int dynamic_regions_count = 3; |
2297 |
2310 |
2298 MapArchiveResult MetaspaceShared::map_archive(FileMapInfo* mapinfo, char* mapped_base_address, ReservedSpace rs) { |
2311 MapArchiveResult MetaspaceShared::map_archive(FileMapInfo* mapinfo, char* mapped_base_address, ReservedSpace rs) { |
2299 assert(UseSharedSpaces, "must be runtime"); |
2312 assert(UseSharedSpaces, "must be runtime"); |
2300 if (mapinfo == NULL) { |
2313 if (mapinfo == NULL) { |
2301 return MAP_ARCHIVE_SUCCESS; // no error has happeed -- trivially succeeded. |
2314 return MAP_ARCHIVE_SUCCESS; // The dynamic archive has not been specified. No error has happened -- trivially succeeded. |
2302 } |
2315 } |
2303 |
2316 |
2304 mapinfo->set_is_mapped(false); |
2317 mapinfo->set_is_mapped(false); |
2305 |
2318 |
2306 if (mapinfo->alignment() != (size_t)os::vm_allocation_granularity()) { |
2319 if (mapinfo->alignment() != (size_t)os::vm_allocation_granularity()) { |