gettext: update to 0.23.1
[oi-userland.git] / components / runtime / openjdk-24 / patches / illumos-zgc.patch
blob27e410937f2572b380b8199893bd8ce3362c803a
1 --- a/src/hotspot/os/solaris/gc/z/zLargePages_solaris.cpp 1970-01-01 01:00:00.000000000 +0100
2 +++ b/src/hotspot/os/solaris/gc/z/zLargePages_solaris.cpp 2024-11-20 14:18:07.654674076 +0000
3 @@ -0,0 +1,34 @@
4 +/*
5 + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
7 + *
8 + * This code is free software; you can redistribute it and/or modify it
9 + * under the terms of the GNU General Public License version 2 only, as
10 + * published by the Free Software Foundation.
11 + *
12 + * This code is distributed in the hope that it will be useful, but WITHOUT
13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 + * version 2 for more details (a copy is included in the LICENSE file that
16 + * accompanied this code).
17 + *
18 + * You should have received a copy of the GNU General Public License version
19 + * 2 along with this work; if not, write to the Free Software Foundation,
20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21 + *
22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
23 + * or visit www.oracle.com if you need additional information or have any
24 + * questions.
25 + */
27 +#include "precompiled.hpp"
28 +#include "gc/z/zLargePages.hpp"
29 +#include "runtime/globals.hpp"
31 +void ZLargePages::pd_initialize() {
32 + if (UseLargePages) {
33 + _state = Explicit;
34 + } else {
35 + _state = Disabled;
36 + }
38 --- a/src/hotspot/os/solaris/gc/z/zNUMA_solaris.cpp 1970-01-01 01:00:00.000000000 +0100
39 +++ b/src/hotspot/os/solaris/gc/z/zNUMA_solaris.cpp 2024-11-20 14:18:07.654815731 +0000
40 @@ -0,0 +1,43 @@
41 +/*
42 + * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
43 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44 + *
45 + * This code is free software; you can redistribute it and/or modify it
46 + * under the terms of the GNU General Public License version 2 only, as
47 + * published by the Free Software Foundation.
48 + *
49 + * This code is distributed in the hope that it will be useful, but WITHOUT
50 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
51 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
52 + * version 2 for more details (a copy is included in the LICENSE file that
53 + * accompanied this code).
54 + *
55 + * You should have received a copy of the GNU General Public License version
56 + * 2 along with this work; if not, write to the Free Software Foundation,
57 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
58 + *
59 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
60 + * or visit www.oracle.com if you need additional information or have any
61 + * questions.
62 + */
64 +#include "precompiled.hpp"
65 +#include "gc/z/zNUMA.hpp"
66 +#include "utilities/globalDefinitions.hpp"
68 +void ZNUMA::pd_initialize() {
69 + _enabled = false;
72 +uint32_t ZNUMA::count() {
73 + return 1;
76 +uint32_t ZNUMA::id() {
77 + return 0;
80 +uint32_t ZNUMA::memory_id(uintptr_t addr) {
81 + // NUMA support not enabled, assume everything belongs to node zero
82 + return 0;
84 --- a/src/hotspot/os/solaris/gc/z/zPhysicalMemoryBacking_solaris.cpp 1970-01-01 01:00:00.000000000 +0100
85 +++ b/src/hotspot/os/solaris/gc/z/zPhysicalMemoryBacking_solaris.cpp 2024-11-20 14:19:19.132400496 +0000
86 @@ -0,0 +1,148 @@
87 +/*
88 + * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved.
89 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90 + *
91 + * This code is free software; you can redistribute it and/or modify it
92 + * under the terms of the GNU General Public License version 2 only, as
93 + * published by the Free Software Foundation.
94 + *
95 + * This code is distributed in the hope that it will be useful, but WITHOUT
96 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
97 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
98 + * version 2 for more details (a copy is included in the LICENSE file that
99 + * accompanied this code).
101 + * You should have received a copy of the GNU General Public License version
102 + * 2 along with this work; if not, write to the Free Software Foundation,
103 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
105 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
106 + * or visit www.oracle.com if you need additional information or have any
107 + * questions.
108 + */
110 +#include "precompiled.hpp"
111 +#include "gc/z/zAddress.inline.hpp"
112 +#include "gc/z/zErrno.hpp"
113 +#include "gc/z/zGlobals.hpp"
114 +#include "gc/z/zInitialize.hpp"
115 +#include "gc/z/zLargePages.inline.hpp"
116 +#include "gc/z/zPhysicalMemory.inline.hpp"
117 +#include "gc/z/zPhysicalMemoryBacking_solaris.hpp"
118 +#include "logging/log.hpp"
119 +#include "runtime/globals.hpp"
120 +#include "runtime/os.hpp"
121 +#include "utilities/align.hpp"
122 +#include "utilities/debug.hpp"
124 +#include <sys/mman.h>
125 +#include <sys/types.h>
127 +ZPhysicalMemoryBacking::ZPhysicalMemoryBacking(size_t max_capacity)
128 + : _base(0),
129 + _initialized(false) {
131 + // Reserve address space for backing memory
132 + _base = (uintptr_t)os::reserve_memory(max_capacity);
133 + if (_base == 0) {
134 + // Failed
135 + ZInitialize::error("Failed to reserve address space for backing memory");
136 + return;
139 + // Successfully initialized
140 + _initialized = true;
143 +bool ZPhysicalMemoryBacking::is_initialized() const {
144 + return _initialized;
147 +void ZPhysicalMemoryBacking::warn_commit_limits(size_t max_capacity) const {
148 + // Does nothing
151 +bool ZPhysicalMemoryBacking::commit_inner(zoffset offset, size_t length) const {
152 + assert(is_aligned(untype(offset), os::vm_page_size()), "Invalid offset");
153 + assert(is_aligned(length, os::vm_page_size()), "Invalid length");
155 + log_trace(gc, heap)("Committing memory: " SIZE_FORMAT "M-" SIZE_FORMAT "M (" SIZE_FORMAT "M)",
156 + untype(offset) / M, untype(to_zoffset_end(offset, length)) / M, length / M);
158 + const uintptr_t addr = _base + untype(offset);
159 + const void* const res = mmap((void*)addr, length, PROT_READ | PROT_WRITE, MAP_FIXED | MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
160 + if (res == MAP_FAILED) {
161 + ZErrno err;
162 + log_error(gc)("Failed to commit memory (%s)", err.to_string());
163 + return false;
166 + // Success
167 + return true;
170 +size_t ZPhysicalMemoryBacking::commit(zoffset offset, size_t length) const {
171 + // Try to commit the whole region
172 + if (commit_inner(offset, length)) {
173 + // Success
174 + return length;
177 + // Failed, try to commit as much as possible
178 + zoffset start = offset;
179 + zoffset end = offset + length;
181 + for (;;) {
182 + length = align_down((end - start) / 2, ZGranuleSize);
183 + if (length == 0) {
184 + // Done, don't commit more
185 + return start - offset;
188 + if (commit_inner(start, length)) {
189 + // Success, try commit more
190 + start += length;
191 + } else {
192 + // Failed, try commit less
193 + end -= length;
198 +size_t ZPhysicalMemoryBacking::uncommit(zoffset offset, size_t length) const {
199 + assert(is_aligned(untype(offset), os::vm_page_size()), "Invalid offset");
200 + assert(is_aligned(length, os::vm_page_size()), "Invalid length");
202 + log_trace(gc, heap)("Uncommitting memory: " SIZE_FORMAT "M-" SIZE_FORMAT "M (" SIZE_FORMAT "M)",
203 + untype(offset) / M, untype(to_zoffset_end(offset, length)) / M, length / M);
205 + const uintptr_t start = _base + untype(offset);
206 + const void* const res = mmap((void*)start, length, PROT_NONE, MAP_FIXED | MAP_ANONYMOUS | MAP_PRIVATE | MAP_NORESERVE, -1, 0);
207 + if (res == MAP_FAILED) {
208 + ZErrno err;
209 + log_error(gc)("Failed to uncommit memory (%s)", err.to_string());
210 + return 0;
213 + return length;
216 +void ZPhysicalMemoryBacking::map(zaddress_unsafe addr, size_t size, zoffset offset) const {
217 + const void* const res = mmap((void*)untype(addr), size, PROT_READ|PROT_WRITE,
218 +MAP_FIXED|MAP_SHARED|MAP_ANONYMOUS, -1, untype(offset));
219 + if (res == MAP_FAILED) {
220 + ZErrno err;
221 + fatal("Failed to map memory (%s)", err.to_string());
225 +void ZPhysicalMemoryBacking::unmap(zaddress_unsafe addr, size_t size) const {
226 + // Note that we must keep the address space reservation intact and just detach
227 + // the backing memory. For this reason we map a new anonymous, non-accessible
228 + // and non-reserved page over the mapping instead of actually unmapping.
229 + const void* const res = mmap((void*)untype(addr), size, PROT_NONE, MAP_FIXED | MAP_ANONYMOUS | MAP_PRIVATE | MAP_NORESERVE, -1, 0);
230 + if (res == MAP_FAILED) {
231 + ZErrno err;
232 + fatal("Failed to map memory (%s)", err.to_string());
235 --- a/src/hotspot/os/solaris/gc/z/zPhysicalMemoryBacking_solaris.hpp 1970-01-01 01:00:00.000000000 +0100
236 +++ b/src/hotspot/os/solaris/gc/z/zPhysicalMemoryBacking_solaris.hpp 2024-11-20 14:18:07.655201364 +0000
237 @@ -0,0 +1,50 @@
239 + * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved.
240 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
242 + * This code is free software; you can redistribute it and/or modify it
243 + * under the terms of the GNU General Public License version 2 only, as
244 + * published by the Free Software Foundation.
246 + * This code is distributed in the hope that it will be useful, but WITHOUT
247 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
248 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
249 + * version 2 for more details (a copy is included in the LICENSE file that
250 + * accompanied this code).
252 + * You should have received a copy of the GNU General Public License version
253 + * 2 along with this work; if not, write to the Free Software Foundation,
254 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
256 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
257 + * or visit www.oracle.com if you need additional information or have any
258 + * questions.
259 + */
261 +#ifndef OS_SOLARIS_GC_Z_ZPHYSICALMEMORYBACKING_SOLARIS_HPP
262 +#define OS_SOLARIS_GC_Z_ZPHYSICALMEMORYBACKING_SOLARIS_HPP
264 +#include "gc/z/zAddress.hpp"
266 +class ZPhysicalMemoryBacking {
267 +private:
268 + uintptr_t _base;
269 + bool _initialized;
271 + bool commit_inner(zoffset offset, size_t length) const;
273 +public:
274 + ZPhysicalMemoryBacking(size_t max_capacity);
276 + bool is_initialized() const;
278 + void warn_commit_limits(size_t max_capacity) const;
280 + size_t commit(zoffset offset, size_t length) const;
281 + size_t uncommit(zoffset offset, size_t length) const;
283 + void map(zaddress_unsafe addr, size_t size, zoffset offset) const;
284 + void unmap(zaddress_unsafe addr, size_t size) const;
287 +#endif // OS_SOLARIS_GC_Z_ZPHYSICALMEMORYBACKING_SOLARIS_HPP
288 --- a/make/autoconf/jvm-features.m4 Wed Nov 6 16:41:41 2024
289 +++ b/make/autoconf/jvm-features.m4 Wed Nov 20 14:20:08 2024
290 @@ -319,6 +319,7 @@
291 if test "x$OPENJDK_TARGET_CPU" = "xx86_64"; then
292 if test "x$OPENJDK_TARGET_OS" = "xlinux" || \
293 test "x$OPENJDK_TARGET_OS" = "xwindows" || \
294 + test "x$OPENJDK_TARGET_OS" = "xsolaris" || \
295 test "x$OPENJDK_TARGET_OS" = "xmacosx"; then
296 AC_MSG_RESULT([yes])
297 else