8232069: Enable CDS even when UseCompressedClassPointers and/or UseCompressedOops are false

Fix to save UseCompressedOops and UseCompressedClassPointers in shared archive and at runtime run with CDS only if they are matched the stored versions.

Reviewed-by: iklam, ccheung
This commit is contained in:
Yumin Qi 2020-02-11 12:16:23 -08:00
parent 56a7631555
commit c37ebcd730
14 changed files with 363 additions and 141 deletions

View file

@ -210,6 +210,8 @@ void FileMapHeader::populate(FileMapInfo* mapinfo, size_t alignment) {
_narrow_oop_mode = CompressedOops::mode();
_narrow_oop_base = CompressedOops::base();
_narrow_oop_shift = CompressedOops::shift();
_compressed_oops = UseCompressedOops;
_compressed_class_ptrs = UseCompressedClassPointers;
_max_heap_size = MaxHeapSize;
_narrow_klass_shift = CompressedKlassPointers::shift();
if (HeapShared::is_heap_object_archiving_allowed()) {
@ -2041,6 +2043,14 @@ bool FileMapHeader::validate() {
"for testing purposes only and should not be used in a production environment");
}
log_info(cds)("Archive was created with UseCompressedOops = %d, UseCompressedClassPointers = %d",
compressed_oops(), compressed_class_pointers());
if (compressed_oops() != UseCompressedOops || compressed_class_pointers() != UseCompressedClassPointers) {
FileMapInfo::fail_continue("Unable to use shared archive.\nThe saved state of UseCompressedOops and UseCompressedClassPointers is "
"different from runtime, CDS will be disabled.");
return false;
}
return true;
}