Skip to content

Commit f84240b

Browse files
committed
8338011: CDS archived heap object support for 64-bit Windows
Reviewed-by: stuefe, shade, ccheung
1 parent 04b146a commit f84240b

File tree

3 files changed

+30
-17
lines changed

3 files changed

+30
-17
lines changed

src/hotspot/share/cds/filemap.cpp

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2178,21 +2178,35 @@ bool FileMapInfo::map_heap_region_impl() {
21782178
// Map the archived heap data. No need to call MemTracker::record_virtual_memory_type()
21792179
// for mapped region as it is part of the reserved java heap, which is already recorded.
21802180
char* addr = (char*)_mapped_heap_memregion.start();
2181-
char* base = map_memory(_fd, _full_path, r->file_offset(),
2182-
addr, _mapped_heap_memregion.byte_size(), r->read_only(),
2183-
r->allow_exec());
2184-
if (base == nullptr || base != addr) {
2185-
dealloc_heap_region();
2186-
log_info(cds)("UseSharedSpaces: Unable to map at required address in java heap. "
2187-
INTPTR_FORMAT ", size = " SIZE_FORMAT " bytes",
2188-
p2i(addr), _mapped_heap_memregion.byte_size());
2189-
return false;
2190-
}
2181+
char* base;
21912182

2192-
if (VerifySharedSpaces && !r->check_region_crc(base)) {
2193-
dealloc_heap_region();
2194-
log_info(cds)("UseSharedSpaces: mapped heap region is corrupt");
2195-
return false;
2183+
if (MetaspaceShared::use_windows_memory_mapping()) {
2184+
if (!read_region(MetaspaceShared::hp, addr,
2185+
align_up(_mapped_heap_memregion.byte_size(), os::vm_page_size()),
2186+
/* do_commit = */ true)) {
2187+
dealloc_heap_region();
2188+
log_error(cds)("Failed to read archived heap region into " INTPTR_FORMAT, p2i(addr));
2189+
return false;
2190+
}
2191+
// Checks for VerifySharedSpaces is already done inside read_region()
2192+
base = addr;
2193+
} else {
2194+
base = map_memory(_fd, _full_path, r->file_offset(),
2195+
addr, _mapped_heap_memregion.byte_size(), r->read_only(),
2196+
r->allow_exec());
2197+
if (base == nullptr || base != addr) {
2198+
dealloc_heap_region();
2199+
log_info(cds)("UseSharedSpaces: Unable to map at required address in java heap. "
2200+
INTPTR_FORMAT ", size = " SIZE_FORMAT " bytes",
2201+
p2i(addr), _mapped_heap_memregion.byte_size());
2202+
return false;
2203+
}
2204+
2205+
if (VerifySharedSpaces && !r->check_region_crc(base)) {
2206+
dealloc_heap_region();
2207+
log_info(cds)("UseSharedSpaces: mapped heap region is corrupt");
2208+
return false;
2209+
}
21962210
}
21972211

21982212
r->set_mapped_base(base);

src/hotspot/share/cds/heapShared.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1554,7 +1554,6 @@ void HeapShared::archive_object_subgraphs(ArchivableStaticFieldInfo fields[],
15541554
// by any of these static fields.
15551555
// At runtime, these classes are initialized before X's archived fields
15561556
// are restored by HeapShared::initialize_from_archived_subgraph().
1557-
int i;
15581557
for (int i = 0; fields[i].valid(); ) {
15591558
ArchivableStaticFieldInfo* info = &fields[i];
15601559
const char* klass_name = info->klass_name;

src/hotspot/share/utilities/macros.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -621,7 +621,7 @@
621621
#define COMPILER_HEADER(basename) XSTR(COMPILER_HEADER_STEM(basename).hpp)
622622
#define COMPILER_HEADER_INLINE(basename) XSTR(COMPILER_HEADER_STEM(basename).inline.hpp)
623623

624-
#if INCLUDE_CDS && INCLUDE_G1GC && defined(_LP64) && !defined(_WINDOWS)
624+
#if INCLUDE_CDS && INCLUDE_G1GC && defined(_LP64)
625625
#define INCLUDE_CDS_JAVA_HEAP 1
626626
#define CDS_JAVA_HEAP_ONLY(x) x
627627
#define NOT_CDS_JAVA_HEAP(x)

0 commit comments

Comments
 (0)