--- old/src/hotspot/share/memory/filemap.cpp 2018-08-21 10:35:49.625383296 -0700 +++ new/src/hotspot/share/memory/filemap.cpp 2018-08-21 10:35:49.109363692 -0700 @@ -192,11 +192,9 @@ _shared_path_table_size = mapinfo->_shared_path_table_size; _shared_path_table = mapinfo->_shared_path_table; _shared_path_entry_size = mapinfo->_shared_path_entry_size; -#if INCLUDE_CDS_JAVA_HEAP if (MetaspaceShared::is_heap_object_archiving_allowed()) { - _g1_reserved = G1CollectedHeap::heap()->g1_reserved(); + _heap_reserved = Universe::heap()->reserved_region(); } -#endif // The following fields are for sanity checks for whether this archive // will function correctly with this JVM and the bootclasspath it's @@ -855,7 +853,6 @@ return base; } - address FileMapInfo::FileMapHeader::space_info::decode_start_address(bool with_current_oop_encoding_mode) { if (with_current_oop_encoding_mode) { return (address)CompressedOops::decode_not_null(offset()); @@ -874,8 +871,10 @@ return (_header->_space[MetaspaceShared::first_string]._used > 0); } -// Returns the address range where the heap regions would occupy using the -// current oop encoding mode. +// Returns the address range of the archived heap regions computed using the +// current oop encoding mode. This range may be different than the one seen at +// dump time due to encoding mode differences. The result is used in determining +// if/how these regions should be relocated at run time. MemRegion FileMapInfo::get_heap_regions_range_with_current_oop_encoding_mode() { address start = (address) max_uintx; address end = NULL; @@ -902,9 +901,9 @@ // Map the shared string objects and open archive heap objects to the runtime // java heap. // -// The shared strings are mapped near the runtime java heap top. The -// mapped strings contain no out-going references to any other java heap -// regions. GC does not write into the mapped shared strings. +// The shared strings are mapped close to the end of the java heap top in +// closed archive regions. The mapped strings contain no out-going references +// to any other java heap regions. GC does not write into the mapped shared strings. // // The open archive heap objects are mapped below the shared strings in // the runtime java heap. The mapped open archive heap data only contain @@ -919,17 +918,17 @@ return; } - MemRegion g1_reserved = G1CollectedHeap::heap()->g1_reserved(); + MemRegion heap_reserved = Universe::heap()->reserved_region(); - log_info(cds)("CDS archive was created with max heap size = " UINTX_FORMAT "M, and the following configuration:", + log_info(cds)("CDS archive was created with max heap size = " SIZE_FORMAT "M, and the following configuration:", max_heap_size()/M); log_info(cds)(" narrow_klass_base = " PTR_FORMAT ", narrow_klass_shift = %d", p2i(narrow_klass_base()), narrow_klass_shift()); log_info(cds)(" narrow_oop_mode = %d, narrow_oop_base = " PTR_FORMAT ", narrow_oop_shift = %d", narrow_oop_mode(), p2i(narrow_oop_base()), narrow_oop_shift()); - log_info(cds)("The current max heap size = " UINTX_FORMAT "M, HeapRegion::GrainBytes = " UINTX_FORMAT, - g1_reserved.byte_size()/M, HeapRegion::GrainBytes); + log_info(cds)("The current max heap size = " SIZE_FORMAT "M, HeapRegion::GrainBytes = " SIZE_FORMAT, + heap_reserved.byte_size()/M, HeapRegion::GrainBytes); log_info(cds)(" narrow_klass_base = " PTR_FORMAT ", narrow_klass_shift = %d", p2i(Universe::narrow_klass_base()), Universe::narrow_klass_shift()); log_info(cds)(" narrow_oop_mode = %d, narrow_oop_base = " PTR_FORMAT ", narrow_oop_shift = %d", @@ -937,21 +936,21 @@ if (narrow_klass_base() != Universe::narrow_klass_base() || narrow_klass_shift() != Universe::narrow_klass_shift()) { - log_info(cds)("CDS heap data cannot be used because the archive was created with an incompatible heap size."); + log_info(cds)("CDS heap data cannot be used because the archive was created with an incompatible oop encoding mode."); return; } if (narrow_oop_mode() != Universe::narrow_oop_mode() || narrow_oop_base() != Universe::narrow_oop_base() || narrow_oop_shift() != Universe::narrow_oop_shift()) { - log_info(cds)("CDS heap data need to be relocated because the archive was created with an incompatible heap size."); + log_info(cds)("CDS heap data need to be relocated because the archive was created with an incompatible oop encoding mode."); _heap_pointers_need_patching = true; } else { MemRegion range = get_heap_regions_range_with_current_oop_encoding_mode(); - if (!g1_reserved.contains(range)) { + if (!heap_reserved.contains(range)) { log_info(cds)("CDS heap data need to be relocated because"); log_info(cds)("the desired range " PTR_FORMAT " - " PTR_FORMAT, p2i(range.start()), p2i(range.end())); - log_info(cds)("is outside of the heap " PTR_FORMAT " - " PTR_FORMAT, p2i(g1_reserved.start()), p2i(g1_reserved.end())); + log_info(cds)("is outside of the heap " PTR_FORMAT " - " PTR_FORMAT, p2i(heap_reserved.start()), p2i(heap_reserved.end())); _heap_pointers_need_patching = true; } } @@ -967,8 +966,8 @@ // At run time, they may not be inside the heap, so we move them so // that they are now near the top of the runtime time. This can be done by // the simple math of adding the delta as shown above. - address dumptime_heap_end = (address)_header->_g1_reserved.end(); - address runtime_heap_end = (address)g1_reserved.end(); + address dumptime_heap_end = (address)_header->_heap_reserved.end(); + address runtime_heap_end = (address)heap_reserved.end(); delta = runtime_heap_end - dumptime_heap_end; } @@ -985,7 +984,7 @@ delta -= align; assert(is_aligned(relocated_strings_bottom + delta, HeapRegion::GrainBytes), "must be"); - log_info(cds)("CDS heap data need to be relocated lower by a further " UINTX_FORMAT + log_info(cds)("CDS heap data need to be relocated lower by a further " SIZE_FORMAT " bytes to be aligned with HeapRegion::GrainBytes", align); HeapShared::init_narrow_oop_decoding(narrow_oop_base() + delta, narrow_oop_shift()); @@ -1039,8 +1038,8 @@ HeapWord* start = (HeapWord*)si->start_address_with_archived_oop_encoding_mode(); regions[region_num] = MemRegion(start, size / HeapWordSize); region_num ++; - log_info(cds)("Trying to map heap data: region[%d] at " INTPTR_FORMAT ", size = %8d bytes", - i, p2i(start), int(size)); + log_info(cds)("Trying to map heap data: region[%d] at " INTPTR_FORMAT ", size = " SIZE_FORMAT_W(8) " bytes", + i, p2i(start), size); } } @@ -1074,7 +1073,7 @@ // dealloc the regions from java heap dealloc_archive_heap_regions(regions, region_num); log_info(cds)("UseSharedSpaces: Unable to map at required address in java heap. " - INTPTR_FORMAT ", size = " UINTX_FORMAT " bytes", + INTPTR_FORMAT ", size = " SIZE_FORMAT " bytes", p2i(addr), regions[i].byte_size()); return false; }