--- old/src/hotspot/share/include/cds.h 2019-10-28 17:14:22.082012323 -0700 +++ new/src/hotspot/share/include/cds.h 2019-10-28 17:14:21.649996863 -0700 @@ -43,7 +43,8 @@ int _crc; // CRC checksum of this region. int _read_only; // read only region? int _allow_exec; // executable code in this region? - int _is_heap_region; // Used in debug build only. + int _is_heap_region; // Used by SA and debug build. + int _is_bitmap_region; // Relocation bitmap for RO/RW/MC/MD regions (used by SA and debug build). int _mapped_from_file; // Is this region mapped from a file? // If false, this region was initialized using os::read(). size_t _file_offset; // Data for this region starts at this offset in the archive file. --- old/src/hotspot/share/memory/filemap.cpp 2019-10-28 17:14:23.458061565 -0700 +++ new/src/hotspot/share/memory/filemap.cpp 2019-10-28 17:14:23.066047537 -0700 @@ -1122,12 +1122,13 @@ return align_up(used(), os::vm_allocation_granularity()); } -void FileMapRegion::init(bool is_heap_region, char* base, size_t size, bool read_only, +void FileMapRegion::init(int region_index, char* base, size_t size, bool read_only, bool allow_exec, int crc) { - _is_heap_region = is_heap_region; + _is_heap_region = HeapShared::is_heap_region(region_index); + _is_bitmap_region = (region_index == MetaspaceShared::bm); _mapping_offset = 0; - if (is_heap_region) { + if (_is_heap_region) { assert(!DynamicDumpSharedSpaces, "must be"); assert((base - (char*)CompressedKlassPointers::base()) % HeapWordSize == 0, "Sanity"); if (base != NULL) { @@ -1169,7 +1170,7 @@ region, size, p2i(requested_base), _file_offset); int crc = ClassLoader::crc32(0, base, (jint)size); - si->init(HeapShared::is_heap_region(region), target_base, size, read_only, allow_exec, crc); + si->init(region, target_base, size, read_only, allow_exec, crc); if (base != NULL) { write_bytes_aligned(base, size); @@ -1468,6 +1469,7 @@ // When mapping on Windows with (addr_delta == 0), we don't reserve the address space for the regions // (Windows can't mmap into a ReservedSpace). In this case, NMT requires we call it after // os::map_memory has succeeded. + assert(MetaspaceShared::use_windows_memory_mapping(), "Windows memory mapping only"); MemTracker::record_virtual_memory_type((address)requested_addr, mtClassShared); } --- old/src/hotspot/share/memory/filemap.hpp 2019-10-28 17:14:25.314127985 -0700 +++ new/src/hotspot/share/memory/filemap.hpp 2019-10-28 17:14:24.882112525 -0700 @@ -161,7 +161,7 @@ void set_read_only(bool v) { _read_only = v; } void set_mapped_base(char* p) { _mapped_base = p; } void set_mapped_from_file(bool v) { _mapped_from_file = v; } - void init(bool is_heap_region, char* base, size_t size, bool read_only, + void init(int region_index, char* base, size_t size, bool read_only, bool allow_exec, int crc); void init_oopmap(size_t oopmap_offset, size_t size_in_bits) { @@ -289,11 +289,6 @@ _shared_path_table_size = table.size(); } - void set_shared_path_table(size_t offset, int size) { - _shared_path_table_offset = offset; - _shared_path_table_size = size; - } - void set_final_requested_base(char* b) { _requested_base_address = b; _mapped_base_address = 0; --- old/src/hotspot/share/memory/metaspaceShared.cpp 2019-10-28 17:14:26.430167923 -0700 +++ new/src/hotspot/share/memory/metaspaceShared.cpp 2019-10-28 17:14:26.054154467 -0700 @@ -1230,7 +1230,6 @@ newtop = _rw_region.top(); } memcpy(p, obj, bytes); - assert(_new_loc_table->lookup(obj) == NULL, "each object can be relocated at most once"); _new_loc_table->add(obj, (address)p); log_trace(cds)("Copy: " PTR_FORMAT " ==> " PTR_FORMAT " %d", p2i(obj), p2i(p), bytes); @@ -1354,6 +1353,7 @@ } #endif + // cleanup _ssc = NULL; } --- old/src/jdk.hotspot.agent/share/native/libsaproc/ps_core_common.c 2019-10-28 17:14:27.498206143 -0700 +++ new/src/jdk.hotspot.agent/share/native/libsaproc/ps_core_common.c 2019-10-28 17:14:27.102191971 -0700 @@ -283,7 +283,7 @@ char classes_jsa[PATH_MAX]; CDSFileMapHeaderBase header; int fd = -1; - uintptr_t base = 0, useSharedSpacesAddr = 0; + uintptr_t useSharedSpacesAddr = 0; uintptr_t sharedBaseAddressAddr = 0, sharedBaseAddress = 0; uintptr_t sharedArchivePathAddrAddr = 0, sharedArchivePathAddr = 0; jboolean useSharedSpaces = 0; @@ -377,19 +377,19 @@ ph->core->classes_jsa_fd = fd; // add read-only maps from classes.jsa to the list of maps for (m = 0; m < NUM_CDS_REGIONS; m++) { - if (header._space[m]._read_only) { + if (header._space[m]._read_only && + !header._space[m]._is_heap_region && + !header._space[m]._is_bitmap_region) { // With *some* linux versions, the core file doesn't include read-only mmap'ed // files regions, so let's add them here. This is harmless if the core file also // include these regions. - base = (uintptr_t) header._space[m]._mapping_offset; - if (base != 0) { - base = sharedBaseAddress + base; - // no need to worry about the fractional pages at-the-end. - // possible fractional pages are handled by core_read_data. - add_class_share_map_info(ph, (off_t) header._space[m]._file_offset, - base, (size_t) header._space[m]._used); - print_debug("added a share archive map at 0x%lx\n", base); - } + uintptr_t base = sharedBaseAddress + (uintptr_t) header._space[m]._mapping_offset; + size_t size = header._space[m]._used; + // no need to worry about the fractional pages at-the-end. + // possible fractional pages are handled by core_read_data. + add_class_share_map_info(ph, (off_t) header._space[m]._file_offset, + base, size); + print_debug("added a share archive map [%d] at 0x%lx (size 0x%lx bytes)\n", m, base, size); } } return true; --- old/src/jdk.hotspot.agent/solaris/native/libsaproc/saproc.cpp 2019-10-28 17:14:28.590245222 -0700 +++ new/src/jdk.hotspot.agent/solaris/native/libsaproc/saproc.cpp 2019-10-28 17:14:28.182230621 -0700 @@ -663,11 +663,14 @@ if (_libsaproc_debug) { for (int m = 0; m < NUM_CDS_REGIONS; m++) { - jlong mapping_offset = pheader->_space[m]._mapping_offset; - jlong baseAddress = (mapping_offset == 0) ? 0 : (mapping_offset + (jlong)sharedBaseAddress); - print_debug("shared file offset %d mapped at 0x%lx, size = %ld, read only? = %d\n", - pheader->_space[m]._file_offset, baseAddress, - pheader->_space[m]._used, pheader->_space[m]._read_only); + if (!pheader->_space[m]._is_heap_region && + !pheader->_space[m]._is_bitmap_region) { + jlong mapping_offset = pheader->_space[m]._mapping_offset; + jlong baseAddress = mapping_offset + (jlong)sharedBaseAddress; + print_debug("shared file offset %d mapped at 0x%lx, size = %ld, read only? = %d\n", + pheader->_space[m]._file_offset, baseAddress, + pheader->_space[m]._used, pheader->_space[m]._read_only); + } } } @@ -1069,11 +1072,13 @@ // We can skip the non-read-only maps. These are mapped as MAP_PRIVATE // and hence will be read by libproc. Besides, the file copy may be // stale because the process might have modified those pages. - if (pheader->_space[m]._read_only) { + if (pheader->_space[m]._read_only && + !pheader->_space[m]._is_heap_region && + !pheader->_space[m]._is_bitmap_region) { jlong mapping_offset = (jlong) (uintptr_t) pheader->_space[m]._mapping_offset; jlong baseAddress = mapping_offset + (jlong)sharedBaseAddress; size_t usedSize = pheader->_space[m]._used; - if (mapping_offset != 0 && address >= baseAddress && address < (baseAddress + usedSize)) { + if (address >= baseAddress && address < (baseAddress + usedSize)) { // the given address falls in this shared metadata area print_debug("found shared map at 0x%lx\n", (long) baseAddress);