Skip to content

Commit 6ba58f7

Browse files
committed
8233299: Implementation: JEP 365: ZGC on Windows
Reviewed-by: pliden, eosterlund
1 parent 802580b commit 6ba58f7

15 files changed

+1200
-2
lines changed

make/autoconf/hotspot.m4

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,8 @@ AC_DEFUN_ONCE([HOTSPOT_SETUP_JVM_FEATURES],
347347
# Only enable ZGC on supported platforms
348348
AC_MSG_CHECKING([if zgc can be built])
349349
if (test "x$OPENJDK_TARGET_OS" = "xlinux" && test "x$OPENJDK_TARGET_CPU" = "xx86_64") || \
350-
(test "x$OPENJDK_TARGET_OS" = "xlinux" && test "x$OPENJDK_TARGET_CPU" = "xaarch64") ||
350+
(test "x$OPENJDK_TARGET_OS" = "xlinux" && test "x$OPENJDK_TARGET_CPU" = "xaarch64") || \
351+
(test "x$OPENJDK_TARGET_OS" = "xwindows" && test "x$OPENJDK_TARGET_CPU" = "xx86_64") || \
351352
(test "x$OPENJDK_TARGET_OS" = "xmacosx" && test "x$OPENJDK_TARGET_CPU" = "xx86_64"); then
352353
AC_MSG_RESULT([yes])
353354
else

src/hotspot/cpu/x86/gc/z/zBarrierSetAssembler_x86.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,8 +517,11 @@ class ZSaveLiveRegisters {
517517
// Sort by size, largest first
518518
_xmm_registers.sort(xmm_compare_register_size);
519519

520+
// On Windows, the caller reserves stack space for spilling register arguments
521+
const int arg_spill_size = frame::arg_reg_save_area_bytes;
522+
520523
// Stack pointer must be 16 bytes aligned for the call
521-
_spill_offset = _spill_size = align_up(xmm_spill_size + gp_spill_size, 16);
524+
_spill_offset = _spill_size = align_up(xmm_spill_size + gp_spill_size + arg_spill_size, 16);
522525
}
523526

524527
public:
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
/*
2+
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
24+
#include "precompiled.hpp"
25+
#include "gc/z/zBackingFile_windows.hpp"
26+
#include "gc/z/zGlobals.hpp"
27+
#include "gc/z/zGranuleMap.inline.hpp"
28+
#include "gc/z/zMapper_windows.hpp"
29+
#include "logging/log.hpp"
30+
#include "runtime/globals.hpp"
31+
#include "utilities/debug.hpp"
32+
33+
// The backing file commits and uncommits physical memory, that can be
34+
// multi-mapped into the virtual address space. To support fine-graned
35+
// committing and uncommitting, each ZGranuleSize chunked is mapped to
36+
// a separate paging file mapping.
37+
38+
ZBackingFile::ZBackingFile() :
39+
_handles(MaxHeapSize),
40+
_size(0) {}
41+
42+
size_t ZBackingFile::size() const {
43+
return _size;
44+
}
45+
46+
HANDLE ZBackingFile::get_handle(uintptr_t offset) const {
47+
HANDLE const handle = _handles.get(offset);
48+
assert(handle != 0, "Should be set");
49+
return handle;
50+
}
51+
52+
void ZBackingFile::put_handle(uintptr_t offset, HANDLE handle) {
53+
assert(handle != INVALID_HANDLE_VALUE, "Invalid handle");
54+
assert(_handles.get(offset) == 0, "Should be cleared");
55+
_handles.put(offset, handle);
56+
}
57+
58+
void ZBackingFile::clear_handle(uintptr_t offset) {
59+
assert(_handles.get(offset) != 0, "Should be set");
60+
_handles.put(offset, 0);
61+
}
62+
63+
size_t ZBackingFile::commit_from_paging_file(size_t offset, size_t size) {
64+
for (size_t i = 0; i < size; i += ZGranuleSize) {
65+
HANDLE const handle = ZMapper::create_and_commit_paging_file_mapping(ZGranuleSize);
66+
if (handle == 0) {
67+
return i;
68+
}
69+
70+
put_handle(offset + i, handle);
71+
}
72+
73+
return size;
74+
}
75+
76+
size_t ZBackingFile::uncommit_from_paging_file(size_t offset, size_t size) {
77+
for (size_t i = 0; i < size; i += ZGranuleSize) {
78+
HANDLE const handle = get_handle(offset + i);
79+
clear_handle(offset + i);
80+
ZMapper::close_paging_file_mapping(handle);
81+
}
82+
83+
return size;
84+
}
85+
86+
size_t ZBackingFile::commit(size_t offset, size_t length) {
87+
log_trace(gc, heap)("Committing memory: " SIZE_FORMAT "M-" SIZE_FORMAT "M (" SIZE_FORMAT "M)",
88+
offset / M, (offset + length) / M, length / M);
89+
90+
const size_t committed = commit_from_paging_file(offset, length);
91+
92+
const size_t end = offset + committed;
93+
if (end > _size) {
94+
// Update size
95+
_size = end;
96+
}
97+
98+
return committed;
99+
}
100+
101+
size_t ZBackingFile::uncommit(size_t offset, size_t length) {
102+
log_trace(gc, heap)("Uncommitting memory: " SIZE_FORMAT "M-" SIZE_FORMAT "M (" SIZE_FORMAT "M)",
103+
offset / M, (offset + length) / M, length / M);
104+
105+
return uncommit_from_paging_file(offset, length);
106+
}
107+
108+
void ZBackingFile::map(uintptr_t addr, size_t size, size_t offset) const {
109+
assert(is_aligned(offset, ZGranuleSize), "Misaligned");
110+
assert(is_aligned(addr, ZGranuleSize), "Misaligned");
111+
assert(is_aligned(size, ZGranuleSize), "Misaligned");
112+
113+
for (size_t i = 0; i < size; i += ZGranuleSize) {
114+
HANDLE const handle = get_handle(offset + i);
115+
ZMapper::map_view_replace_placeholder(handle, 0 /* offset */, addr + i, ZGranuleSize);
116+
}
117+
}
118+
119+
void ZBackingFile::unmap(uintptr_t addr, size_t size) const {
120+
assert(is_aligned(addr, ZGranuleSize), "Misaligned");
121+
assert(is_aligned(size, ZGranuleSize), "Misaligned");
122+
123+
for (size_t i = 0; i < size; i += ZGranuleSize) {
124+
ZMapper::unmap_view_preserve_placeholder(addr + i, ZGranuleSize);
125+
}
126+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
/*
2+
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
24+
#ifndef OS_WINDOWS_GC_Z_ZBACKINGFILE_WINDOWS_HPP
25+
#define OS_WINDOWS_GC_Z_ZBACKINGFILE_WINDOWS_HPP
26+
27+
#include "gc/z/zGranuleMap.hpp"
28+
#include "memory/allocation.hpp"
29+
30+
#include <Windows.h>
31+
32+
class ZBackingFile {
33+
private:
34+
ZGranuleMap<HANDLE> _handles;
35+
size_t _size;
36+
37+
HANDLE get_handle(uintptr_t offset) const;
38+
void put_handle(uintptr_t offset, HANDLE handle);
39+
void clear_handle(uintptr_t offset);
40+
41+
size_t commit_from_paging_file(size_t offset, size_t size);
42+
size_t uncommit_from_paging_file(size_t offset, size_t size);
43+
44+
public:
45+
ZBackingFile();
46+
47+
size_t size() const;
48+
49+
size_t commit(size_t offset, size_t length);
50+
size_t uncommit(size_t offset, size_t length);
51+
52+
void map(uintptr_t addr, size_t size, size_t offset) const;
53+
void unmap(uintptr_t addr, size_t size) const;
54+
};
55+
56+
#endif // OS_WINDOWS_GC_Z_ZBACKINGFILE_WINDOWS_HPP
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
24+
#include "precompiled.hpp"
25+
#include "gc/z/zInitialize.hpp"
26+
#include "gc/z/zSyscall_windows.hpp"
27+
28+
void ZInitialize::initialize_os() {
29+
ZSyscall::initialize();
30+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
24+
#include "precompiled.hpp"
25+
#include "gc/z/zLargePages.hpp"
26+
27+
void ZLargePages::initialize_platform() {
28+
_state = Disabled;
29+
}

0 commit comments

Comments
 (0)