8338011: CDS archived heap object support for 64-bit Windows

Reviewed-by: stuefe, shade, ccheung
This commit is contained in:
Ioi Lam 2024-08-12 16:03:41 +00:00
parent 04b146a31f
commit f84240bca8
3 changed files with 30 additions and 17 deletions
src/hotspot/share

@ -2178,21 +2178,35 @@ bool FileMapInfo::map_heap_region_impl() {
// Map the archived heap data. No need to call MemTracker::record_virtual_memory_type()
// for mapped region as it is part of the reserved java heap, which is already recorded.
char* addr = (char*)_mapped_heap_memregion.start();
char* base = map_memory(_fd, _full_path, r->file_offset(),
addr, _mapped_heap_memregion.byte_size(), r->read_only(),
r->allow_exec());
if (base == nullptr || base != addr) {
dealloc_heap_region();
log_info(cds)("UseSharedSpaces: Unable to map at required address in java heap. "
INTPTR_FORMAT ", size = " SIZE_FORMAT " bytes",
p2i(addr), _mapped_heap_memregion.byte_size());
return false;
}
char* base;
if (VerifySharedSpaces && !r->check_region_crc(base)) {
dealloc_heap_region();
log_info(cds)("UseSharedSpaces: mapped heap region is corrupt");
return false;
if (MetaspaceShared::use_windows_memory_mapping()) {
if (!read_region(MetaspaceShared::hp, addr,
align_up(_mapped_heap_memregion.byte_size(), os::vm_page_size()),
/* do_commit = */ true)) {
dealloc_heap_region();
log_error(cds)("Failed to read archived heap region into " INTPTR_FORMAT, p2i(addr));
return false;
}
// Checks for VerifySharedSpaces is already done inside read_region()
base = addr;
} else {
base = map_memory(_fd, _full_path, r->file_offset(),
addr, _mapped_heap_memregion.byte_size(), r->read_only(),
r->allow_exec());
if (base == nullptr || base != addr) {
dealloc_heap_region();
log_info(cds)("UseSharedSpaces: Unable to map at required address in java heap. "
INTPTR_FORMAT ", size = " SIZE_FORMAT " bytes",
p2i(addr), _mapped_heap_memregion.byte_size());
return false;
}
if (VerifySharedSpaces && !r->check_region_crc(base)) {
dealloc_heap_region();
log_info(cds)("UseSharedSpaces: mapped heap region is corrupt");
return false;
}
}
r->set_mapped_base(base);

@ -1554,7 +1554,6 @@ void HeapShared::archive_object_subgraphs(ArchivableStaticFieldInfo fields[],
// by any of these static fields.
// At runtime, these classes are initialized before X's archived fields
// are restored by HeapShared::initialize_from_archived_subgraph().
int i;
for (int i = 0; fields[i].valid(); ) {
ArchivableStaticFieldInfo* info = &fields[i];
const char* klass_name = info->klass_name;

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -621,7 +621,7 @@
#define COMPILER_HEADER(basename) XSTR(COMPILER_HEADER_STEM(basename).hpp)
#define COMPILER_HEADER_INLINE(basename) XSTR(COMPILER_HEADER_STEM(basename).inline.hpp)
#if INCLUDE_CDS && INCLUDE_G1GC && defined(_LP64) && !defined(_WINDOWS)
#if INCLUDE_CDS && INCLUDE_G1GC && defined(_LP64)
#define INCLUDE_CDS_JAVA_HEAP 1
#define CDS_JAVA_HEAP_ONLY(x) x
#define NOT_CDS_JAVA_HEAP(x)