diff --git a/doc/building.html b/doc/building.html
index feb699fd24d62..3601fa8af16c4 100644
--- a/doc/building.html
+++ b/doc/building.html
@@ -819,11 +819,11 @@
Some command line examples:
bash configure --with-freetype=/cygdrive/c/freetype-i586 --with-target-bits=32
Create a debug build with the server
JVM and DTrace
-enabled:
-bash configure --enable-debug --with-jvm-variants=server --enable-dtrace
+enabled:
+bash configure --enable-debug --with-jvm-variants=server --enable-dtrace
Here follows some of the most common and important
@@ -1331,14 +1331,12 @@
ALSA
libasound2-dev
packages for your target system.
Download them to /tmp.
Install the libraries into the cross-compilation toolchain. For
-instance:
-
+instance:
cd /tools/gcc-linaro-arm-linux-gnueabihf-raspbian-2012.09-20120921_linux/arm-linux-gnueabihf/libc
dpkg-deb -x /tmp/libasound2_1.0.25-4_armhf.deb .
-dpkg-deb -x /tmp/libasound2-dev_1.0.25-4_armhf.deb .
-
X11
You will need X11 libraries suitable for your target system.
@@ -1372,21 +1370,18 @@
X11
Install the libraries into the cross-compilation toolchain. For
instance:
- cd /tools/gcc-linaro-arm-linux-gnueabihf-raspbian-2012.09-20120921_linux/arm-linux-gnueabihf/libc/usr
- mkdir X11R6
- cd X11R6
- for deb in /tmp/target-x11/*.deb ; do dpkg-deb -x $deb . ; done
- mv usr/* .
- cd lib
- cp arm-linux-gnueabihf/* .
- ```
-
-You can ignore the following messages. These libraries are not needed to
-successfully complete a full JDK build.
-cp: cannot stat
-arm-linux-gnueabihf/libICE.so': No such file or directory cp: cannot stat
arm-linux-gnueabihf/libSM.so':
-No such file or directory cp: cannot stat
-`arm-linux-gnueabihf/libXt.so': No such file or directory ```
+cd /tools/gcc-linaro-arm-linux-gnueabihf-raspbian-2012.09-20120921_linux/arm-linux-gnueabihf/libc/usr
+mkdir X11R6
+cd X11R6
+for deb in /tmp/target-x11/*.deb ; do dpkg-deb -x $deb . ; done
+mv usr/* .
+cd lib
+cp arm-linux-gnueabihf/* .
+You can ignore the following messages. These libraries are not needed
+to successfully complete a full JDK build.
+cp: cannot stat `arm-linux-gnueabihf/libICE.so': No such file or directory
+cp: cannot stat `arm-linux-gnueabihf/libSM.so': No such file or directory
+cp: cannot stat `arm-linux-gnueabihf/libXt.so': No such file or directory
If the X11 libraries are not properly detected by
configure
, you can point them out by
--with-x
.
@@ -1404,17 +1399,41 @@ Cross compiling with
For example, cross-compiling to AArch64 from x86_64 could be done
like this:
-Install cross-compiler on the build system:
-apt install g++-aarch64-linux-gnu gcc-aarch64-linux-gnu
+Install cross-compiler on the build system:
+apt install g++-aarch64-linux-gnu gcc-aarch64-linux-gnu
Create chroot on the build system, configuring it for
-target system:
-sudo debootstrap \ --arch=arm64 \ --verbose \ --include=fakeroot,symlinks,build-essential,libx11-dev,libxext-dev,libxrender-dev,libxrandr-dev,libxtst-dev,libxt-dev,libcups2-dev,libfontconfig1-dev,libasound2-dev,libfreetype6-dev,libpng-dev,libffi-dev \ --resolve-deps \ buster \ ~/sysroot-arm64 \ http://httpredir.debian.org/debian/ # If the target architecture is `riscv64`, # the path should be `debian-ports` instead of `debian`.
+target system:
+
sudo debootstrap \
+ --arch=arm64 \
+ --verbose \
+ --include=fakeroot,symlinks,build-essential,libx11-dev,libxext-dev,libxrender-dev,libxrandr-dev,libxtst-dev,libxt-dev,libcups2-dev,libfontconfig1-dev,libasound2-dev,libfreetype6-dev,libpng-dev,libffi-dev \
+ --resolve-deps \
+ buster \
+ ~/sysroot-arm64 \
+ http://httpredir.debian.org/debian/
+# If the target architecture is `riscv64`,
+# the path should be `debian-ports` instead of `debian`.
+To create a Ubuntu-based chroot:
+sudo debootstrap \
+ --arch=arm64 \
+ --verbose \
+ --components=main,universe \
+ --include=fakeroot,symlinks,build-essential,libx11-dev,libxext-dev,libxrender-dev,libxrandr-dev,libxtst-dev,libxt-dev,libcups2-dev,libfontconfig1-dev,libasound2-dev,libfreetype6-dev,libpng-dev,libffi-dev \
+ --resolve-deps \
+ jammy \
+ ~/sysroot-arm64 \
+ http://ports.ubuntu.com/ubuntu-ports/
+# symlinks is in the universe repository
Make sure the symlinks inside the newly created chroot point to
-proper locations:
-sudo chroot ~/sysroot-arm64 symlinks -cr .
+proper locations:
+sudo chroot ~/sysroot-arm64 symlinks -cr .
Configure and build with newly created chroot as
-sysroot/toolchain-path:
-sh ./configure \ --openjdk-target=aarch64-linux-gnu \ --with-sysroot=~/sysroot-arm64 make images ls build/linux-aarch64-server-release/
+sysroot/toolchain-path:
+sh ./configure \
+ --openjdk-target=aarch64-linux-gnu \
+ --with-sysroot=~/sysroot-arm64
+make images
+ls build/linux-aarch64-server-release/
The build does not create new files in that chroot, so it can be
reused for multiple builds without additional cleanup.
@@ -1566,12 +1585,27 @@ Building for RISC-V
placeholder <toolchain-installed-path>
shown below is
the path where you want to install the toolchain.
-Install the RISC-V GNU compiler toolchain:
-git clone --recursive https://github.com/riscv-collab/riscv-gnu-toolchain cd riscv-gnu-toolchain ./configure --prefix=<toolchain-installed-path> make linux export PATH=<toolchain-installed-path>/bin:$PATH
-Cross-compile all the required libraries:
-# An example for libffi git clone https://github.com/libffi/libffi cd libffi ./configure --host=riscv64-unknown-linux-gnu --prefix=<toolchain-installed-path>/sysroot/usr make make install
-Configure and build OpenJDK:
-bash configure \ --with-boot-jdk=$BOOT_JDK \ --openjdk-target=riscv64-linux-gnu \ --with-sysroot=<toolchain-installed-path>/sysroot \ --with-toolchain-path=<toolchain-installed-path>/bin \ --with-extra-path=<toolchain-installed-path>/bin make images
+Install the RISC-V GNU compiler toolchain:
+git clone --recursive https://github.com/riscv-collab/riscv-gnu-toolchain
+cd riscv-gnu-toolchain
+./configure --prefix=<toolchain-installed-path>
+make linux
+export PATH=<toolchain-installed-path>/bin:$PATH
+Cross-compile all the required libraries:
+# An example for libffi
+git clone https://github.com/libffi/libffi
+cd libffi
+./configure --host=riscv64-unknown-linux-gnu --prefix=<toolchain-installed-path>/sysroot/usr
+make
+make install
+Configure and build OpenJDK:
+bash configure \
+ --with-boot-jdk=$BOOT_JDK \
+ --openjdk-target=riscv64-linux-gnu \
+ --with-sysroot=<toolchain-installed-path>/sysroot \
+ --with-toolchain-path=<toolchain-installed-path>/bin \
+ --with-extra-path=<toolchain-installed-path>/bin
+make images
Building for musl
Just like it's possible to cross-compile for a different CPU, it's
diff --git a/doc/building.md b/doc/building.md
index 415454cf6c36c..68c65bf0517a4 100644
--- a/doc/building.md
+++ b/doc/building.md
@@ -626,11 +626,13 @@ automatically, it will exit and inform you about the problem.
Some command line examples:
* Create a 32-bit build for Windows with FreeType2 in `C:\freetype-i586`:
+
```
bash configure --with-freetype=/cygdrive/c/freetype-i586 --with-target-bits=32
```
* Create a debug build with the `server` JVM and DTrace enabled:
+
```
bash configure --enable-debug --with-jvm-variants=server --enable-dtrace
```
@@ -1100,11 +1102,12 @@ Note that alsa is needed even if you only want to build a headless JDK.
system. Download them to /tmp.
* Install the libraries into the cross-compilation toolchain. For instance:
-```
-cd /tools/gcc-linaro-arm-linux-gnueabihf-raspbian-2012.09-20120921_linux/arm-linux-gnueabihf/libc
-dpkg-deb -x /tmp/libasound2_1.0.25-4_armhf.deb .
-dpkg-deb -x /tmp/libasound2-dev_1.0.25-4_armhf.deb .
-```
+
+ ```
+ cd /tools/gcc-linaro-arm-linux-gnueabihf-raspbian-2012.09-20120921_linux/arm-linux-gnueabihf/libc
+ dpkg-deb -x /tmp/libasound2_1.0.25-4_armhf.deb .
+ dpkg-deb -x /tmp/libasound2-dev_1.0.25-4_armhf.deb .
+ ```
* If alsa is not properly detected by `configure`, you can point it out by
`--with-alsa`.
@@ -1140,6 +1143,7 @@ Note that X11 is needed even if you only want to build a headless JDK.
* libxext-dev
* Install the libraries into the cross-compilation toolchain. For instance:
+
```
cd /tools/gcc-linaro-arm-linux-gnueabihf-raspbian-2012.09-20120921_linux/arm-linux-gnueabihf/libc/usr
mkdir X11R6
@@ -1173,11 +1177,13 @@ for foreign architectures with native compilation speed.
For example, cross-compiling to AArch64 from x86_64 could be done like this:
* Install cross-compiler on the *build* system:
+
```
apt install g++-aarch64-linux-gnu gcc-aarch64-linux-gnu
```
* Create chroot on the *build* system, configuring it for *target* system:
+
```
sudo debootstrap \
--arch=arm64 \
@@ -1191,12 +1197,29 @@ For example, cross-compiling to AArch64 from x86_64 could be done like this:
# the path should be `debian-ports` instead of `debian`.
```
+ * To create a Ubuntu-based chroot:
+
+ ```
+ sudo debootstrap \
+ --arch=arm64 \
+ --verbose \
+ --components=main,universe \
+ --include=fakeroot,symlinks,build-essential,libx11-dev,libxext-dev,libxrender-dev,libxrandr-dev,libxtst-dev,libxt-dev,libcups2-dev,libfontconfig1-dev,libasound2-dev,libfreetype6-dev,libpng-dev,libffi-dev \
+ --resolve-deps \
+ jammy \
+ ~/sysroot-arm64 \
+ http://ports.ubuntu.com/ubuntu-ports/
+ # symlinks is in the universe repository
+ ```
+
* Make sure the symlinks inside the newly created chroot point to proper locations:
+
```
sudo chroot ~/sysroot-arm64 symlinks -cr .
```
* Configure and build with newly created chroot as sysroot/toolchain-path:
+
```
sh ./configure \
--openjdk-target=aarch64-linux-gnu \
@@ -1255,6 +1278,7 @@ complicate the building process. The placeholder ``
shown below is the path where you want to install the toolchain.
* Install the RISC-V GNU compiler toolchain:
+
```
git clone --recursive https://github.com/riscv-collab/riscv-gnu-toolchain
cd riscv-gnu-toolchain
@@ -1264,6 +1288,7 @@ shown below is the path where you want to install the toolchain.
```
* Cross-compile all the required libraries:
+
```
# An example for libffi
git clone https://github.com/libffi/libffi
@@ -1274,6 +1299,7 @@ shown below is the path where you want to install the toolchain.
```
* Configure and build OpenJDK:
+
```
bash configure \
--with-boot-jdk=$BOOT_JDK \
diff --git a/make/CreateJmods.gmk b/make/CreateJmods.gmk
index 2901930cf8814..6fbaef6bdf1c4 100644
--- a/make/CreateJmods.gmk
+++ b/make/CreateJmods.gmk
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2014, 2023, 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
@@ -81,13 +81,11 @@ endif
ifneq ($(CMDS_DIR), )
DEPS += $(call FindFiles, $(CMDS_DIR))
ifeq ($(call isTargetOs, windows)+$(SHIP_DEBUG_SYMBOLS), true+public)
- # For public debug symbols on Windows, we have to use stripped pdbs, rename them
- # and filter out a few launcher pdbs where there's a lib that goes by the same name
+ # For public debug symbols on Windows, we have to use stripped pdbs and rename them
rename_stripped = $(patsubst %.stripped.pdb,%.pdb,$1)
CMDS_DIR_FILTERED := $(subst modules_cmds,modules_cmds_filtered, $(CMDS_DIR))
FILES_CMDS := $(filter-out %.pdb, $(call FindFiles, $(CMDS_DIR))) \
- $(filter-out %jimage.stripped.pdb %jpackage.stripped.pdb %java.stripped.pdb, \
- $(filter %.stripped.pdb, $(call FindFiles, $(CMDS_DIR))))
+ $(filter %.stripped.pdb, $(call FindFiles, $(CMDS_DIR)))
$(eval $(call SetupCopyFiles, COPY_FILTERED_CMDS, \
SRC := $(CMDS_DIR), \
DEST := $(CMDS_DIR_FILTERED), \
@@ -96,18 +94,6 @@ ifneq ($(CMDS_DIR), )
))
DEPS += $(COPY_FILTERED_CMDS)
JMOD_FLAGS += --cmds $(CMDS_DIR_FILTERED)
- else ifeq ($(call isTargetOs, windows)+$(SHIP_DEBUG_SYMBOLS), true+full)
- # For full debug symbols on Windows, we have to filter out a few launcher pdbs
- # where there's a lib that goes by the same name
- CMDS_DIR_FILTERED := $(subst modules_cmds,modules_cmds_filtered, $(CMDS_DIR))
- $(eval $(call SetupCopyFiles, COPY_FILTERED_CMDS, \
- SRC := $(CMDS_DIR), \
- DEST := $(CMDS_DIR_FILTERED), \
- FILES := $(filter-out %jimage.pdb %jpackage.pdb %java.pdb, \
- $(call FindFiles, $(CMDS_DIR))), \
- ))
- DEPS += $(COPY_FILTERED_CMDS)
- JMOD_FLAGS += --cmds $(CMDS_DIR_FILTERED)
else
JMOD_FLAGS += --cmds $(CMDS_DIR)
endif
diff --git a/make/Images.gmk b/make/Images.gmk
index aeda1e2f0d6c1..adf53a83c4f4c 100644
--- a/make/Images.gmk
+++ b/make/Images.gmk
@@ -274,9 +274,6 @@ else
endif
endif
-FILTERED_PDBS := %jimage.stripped.pdb %jpackage.stripped.pdb %java.stripped.pdb \
- %jimage.pdb %jpackage.pdb %java.pdb %jimage.map %jpackage.map %java.map
-
# Param 1 - either JDK or JRE
SetupCopyDebuginfo = \
$(foreach m, $(ALL_$1_MODULES), \
@@ -290,8 +287,8 @@ SetupCopyDebuginfo = \
$(eval $(call SetupCopyFiles, COPY_$1_CMDS_DEBUGINFO_$m, \
SRC := $(SUPPORT_OUTPUTDIR)/modules_cmds/$m, \
DEST := $($1_IMAGE_DIR)/$(CMDS_TARGET_SUBDIR), \
- FILES := $(filter-out $(FILTERED_PDBS), $(call FindDebuginfoFiles, \
- $(SUPPORT_OUTPUTDIR)/modules_cmds/$m)), \
+ FILES := $(call FindDebuginfoFiles, \
+ $(SUPPORT_OUTPUTDIR)/modules_cmds/$m), \
)) \
$(eval $1_TARGETS += $$(COPY_$1_CMDS_DEBUGINFO_$m)) \
)
diff --git a/make/RunTestsPrebuilt.gmk b/make/RunTestsPrebuilt.gmk
index ae14b1e533652..93febe5ed31d9 100644
--- a/make/RunTestsPrebuilt.gmk
+++ b/make/RunTestsPrebuilt.gmk
@@ -158,6 +158,10 @@ ifeq ($(UNAME_OS), CYGWIN)
OPENJDK_TARGET_OS := windows
OPENJDK_TARGET_OS_TYPE := windows
OPENJDK_TARGET_OS_ENV := windows.cygwin
+else ifeq ($(UNAME_OS), MINGW64)
+ OPENJDK_TARGET_OS := windows
+ OPENJDK_TARGET_OS_TYPE := windows
+ OPENJDK_TARGET_OS_ENV := windows.msys2
else
OPENJDK_TARGET_OS_TYPE:=unix
ifeq ($(UNAME_OS), Linux)
@@ -170,6 +174,9 @@ else
OPENJDK_TARGET_OS_ENV := $(OPENJDK_TARGET_OS)
endif
+# Sanity check env detection
+$(info Detected target OS, type and env: [$(OPENJDK_TARGET_OS)] [$(OPENJDK_TARGET_OS_TYPE)] [$(OPENJDK_TARGET_OS_ENV)])
+
# Assume little endian unless otherwise specified
OPENJDK_TARGET_CPU_ENDIAN := little
diff --git a/make/ZipSecurity.gmk b/make/ZipSecurity.gmk
index 4f960cd2fcd4b..00b552fae0af8 100644
--- a/make/ZipSecurity.gmk
+++ b/make/ZipSecurity.gmk
@@ -87,9 +87,9 @@ ifeq ($(call isTargetOs, windows), true)
$(eval $(call SetupZipArchive,BUILD_JGSS_BIN_ZIP, \
SRC := $(SUPPORT_OUTPUTDIR), \
INCLUDE_FILES := modules_libs/java.security.jgss/w2k_lsa_auth.dll \
- modules_libs/java.security.jgss/w2k_lsa_auth.diz \
- modules_libs/java.security.jgss/w2k_lsa_auth.map \
- modules_libs/java.security.jgss/w2k_lsa_auth.pdb, \
+ modules_libs/java.security.jgss/w2k_lsa_auth.dll.diz \
+ modules_libs/java.security.jgss/w2k_lsa_auth.dll.map \
+ modules_libs/java.security.jgss/w2k_lsa_auth.dll.pdb, \
ZIP := $(IMAGES_OUTPUTDIR)/$(JGSS_ZIP_NAME)))
TARGETS += $(IMAGES_OUTPUTDIR)/$(JGSS_ZIP_NAME)
diff --git a/make/common/NativeCompilation.gmk b/make/common/NativeCompilation.gmk
index 6056f4632a525..68d1dba27ffcc 100644
--- a/make/common/NativeCompilation.gmk
+++ b/make/common/NativeCompilation.gmk
@@ -1073,13 +1073,13 @@ define SetupNativeCompilationBody
ifneq ($$($1_TYPE), STATIC_LIBRARY)
# Generate debuginfo files.
ifeq ($(call isTargetOs, windows), true)
- $1_EXTRA_LDFLAGS += -debug "-pdb:$$($1_SYMBOLS_DIR)/$$($1_NOSUFFIX).pdb" \
- "-map:$$($1_SYMBOLS_DIR)/$$($1_NOSUFFIX).map"
+ $1_EXTRA_LDFLAGS += -debug "-pdb:$$($1_SYMBOLS_DIR)/$$($1_BASENAME).pdb" \
+ "-map:$$($1_SYMBOLS_DIR)/$$($1_BASENAME).map"
ifeq ($(SHIP_DEBUG_SYMBOLS), public)
- $1_EXTRA_LDFLAGS += "-pdbstripped:$$($1_SYMBOLS_DIR)/$$($1_NOSUFFIX).stripped.pdb"
+ $1_EXTRA_LDFLAGS += "-pdbstripped:$$($1_SYMBOLS_DIR)/$$($1_BASENAME).stripped.pdb"
endif
- $1_DEBUGINFO_FILES := $$($1_SYMBOLS_DIR)/$$($1_NOSUFFIX).pdb \
- $$($1_SYMBOLS_DIR)/$$($1_NOSUFFIX).map
+ $1_DEBUGINFO_FILES := $$($1_SYMBOLS_DIR)/$$($1_BASENAME).pdb \
+ $$($1_SYMBOLS_DIR)/$$($1_BASENAME).map
else ifeq ($(call isTargetOs, linux), true)
$1_DEBUGINFO_FILES := $$($1_SYMBOLS_DIR)/$$($1_NOSUFFIX).debuginfo
@@ -1127,7 +1127,11 @@ define SetupNativeCompilationBody
$1 += $$($1_DEBUGINFO_FILES)
ifeq ($$($1_ZIP_EXTERNAL_DEBUG_SYMBOLS), true)
- $1_DEBUGINFO_ZIP := $$($1_SYMBOLS_DIR)/$$($1_NOSUFFIX).diz
+ ifeq ($(call isTargetOs, windows), true)
+ $1_DEBUGINFO_ZIP := $$($1_SYMBOLS_DIR)/$$($1_BASENAME).diz
+ else
+ $1_DEBUGINFO_ZIP := $$($1_SYMBOLS_DIR)/$$($1_NOSUFFIX).diz
+ endif
$1 += $$($1_DEBUGINFO_ZIP)
# The dependency on TARGET is needed for debuginfo files
diff --git a/make/hotspot/test/GtestImage.gmk b/make/hotspot/test/GtestImage.gmk
index d216328e5674e..9b2a37962cddd 100644
--- a/make/hotspot/test/GtestImage.gmk
+++ b/make/hotspot/test/GtestImage.gmk
@@ -61,7 +61,7 @@ ifeq ($(call isTargetOs, windows), true)
$(eval $(call SetupCopyFiles, COPY_GTEST_PDB_$v, \
SRC := $(HOTSPOT_OUTPUTDIR)/variant-$v/libjvm/gtest, \
DEST := $(TEST_IMAGE_DIR)/hotspot/gtest/$v, \
- FILES := jvm.pdb gtestLauncher.pdb, \
+ FILES := jvm.dll.pdb gtestLauncher.exe.pdb, \
)) \
$(eval TARGETS += $$(COPY_GTEST_PDB_$v)) \
) \
diff --git a/make/ide/visualstudio/hotspot/src/classes/build/tools/projectcreator/WinGammaPlatformVC10.java b/make/ide/visualstudio/hotspot/src/classes/build/tools/projectcreator/WinGammaPlatformVC10.java
index 092e5afd3e8fe..ed085dae09562 100644
--- a/make/ide/visualstudio/hotspot/src/classes/build/tools/projectcreator/WinGammaPlatformVC10.java
+++ b/make/ide/visualstudio/hotspot/src/classes/build/tools/projectcreator/WinGammaPlatformVC10.java
@@ -329,7 +329,7 @@ Vector getBaseCompilerFlags(Vector defines, Vector includes, String outDir) {
addAttr(rv, "PrecompiledHeaderOutputFile", outDir+Util.sep+"vm.pch");
addAttr(rv, "AssemblerListingLocation", outDir);
addAttr(rv, "ObjectFileName", outDir+Util.sep);
- addAttr(rv, "ProgramDataBaseFileName", outDir+Util.sep+"jvm.pdb");
+ addAttr(rv, "ProgramDataBaseFileName", outDir+Util.sep+"jvm.dll.pdb");
// Set /nologo option
addAttr(rv, "SuppressStartupBanner", "true");
// Surpass the default /Tc or /Tp.
@@ -409,7 +409,7 @@ Vector getBaseLinkerFlags(String outDir, String outDll, String platformName) {
addAttr(rv, "OutputFile", outDll);
addAttr(rv, "SuppressStartupBanner", "true");
addAttr(rv, "ModuleDefinitionFile", outDir+Util.sep+"vm.def");
- addAttr(rv, "ProgramDatabaseFile", outDir+Util.sep+"jvm.pdb");
+ addAttr(rv, "ProgramDatabaseFile", outDir+Util.sep+"jvm.dll.pdb");
addAttr(rv, "SubSystem", "Windows");
addAttr(rv, "BaseAddress", "0x8000000");
addAttr(rv, "ImportLibrary", outDir+Util.sep+"jvm.lib");
diff --git a/make/scripts/compare_exceptions.sh.incl b/make/scripts/compare_exceptions.sh.incl
index d9f62aa113222..d5043637145b2 100644
--- a/make/scripts/compare_exceptions.sh.incl
+++ b/make/scripts/compare_exceptions.sh.incl
@@ -49,8 +49,8 @@ elif [ "$OPENJDK_TARGET_OS" = "windows" ]; then
SKIP_BIN_DIFF="true"
SKIP_FULLDUMP_DIFF="true"
ACCEPTED_JARZIP_CONTENTS="
- /modules_libs/java.security.jgss/w2k_lsa_auth.pdb
- /modules_libs/java.security.jgss/w2k_lsa_auth.map
+ /modules_libs/java.security.jgss/w2k_lsa_auth.dll.pdb
+ /modules_libs/java.security.jgss/w2k_lsa_auth.dll.map
/modules_libs/java.security.jgss/w2k_lsa_auth.dll
"
elif [ "$OPENJDK_TARGET_OS" = "macosx" ]; then
diff --git a/src/hotspot/cpu/riscv/riscv.ad b/src/hotspot/cpu/riscv/riscv.ad
index bcdf7b4137071..c28184e7ae5ff 100644
--- a/src/hotspot/cpu/riscv/riscv.ad
+++ b/src/hotspot/cpu/riscv/riscv.ad
@@ -983,8 +983,8 @@ definitions %{
int_def XFER_COST ( 300, 3 * DEFAULT_COST); // mfc, mtc, fcvt, fmove, fcmp
int_def BRANCH_COST ( 200, 2 * DEFAULT_COST); // branch, jmp, call
int_def IMUL_COST ( 1000, 10 * DEFAULT_COST); // imul
- int_def IDIVSI_COST ( 3400, 34 * DEFAULT_COST); // idivdi
- int_def IDIVDI_COST ( 6600, 66 * DEFAULT_COST); // idivsi
+ int_def IDIVSI_COST ( 3400, 34 * DEFAULT_COST); // idivsi
+ int_def IDIVDI_COST ( 6600, 66 * DEFAULT_COST); // idivdi
int_def FMUL_SINGLE_COST ( 500, 5 * DEFAULT_COST); // fmul, fmadd
int_def FMUL_DOUBLE_COST ( 700, 7 * DEFAULT_COST); // fmul, fmadd
int_def FDIV_COST ( 2000, 20 * DEFAULT_COST); // fdiv
diff --git a/src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp b/src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp
index 2154601f2f26f..29413e5457c57 100644
--- a/src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp
+++ b/src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp
@@ -3853,13 +3853,11 @@ void C2_MacroAssembler::count_positives(Register ary1, Register len,
VM_Version::supports_bmi2()) {
Label test_64_loop, test_tail, BREAK_LOOP;
- Register tmp3_aliased = len;
-
movl(tmp1, len);
vpxor(vec2, vec2, vec2, Assembler::AVX_512bit);
- andl(tmp1, 64 - 1); // tail count (in chars) 0x3F
- andl(len, ~(64 - 1)); // vector count (in chars)
+ andl(tmp1, 0x0000003f); // tail count (in chars) 0x3F
+ andl(len, 0xffffffc0); // vector count (in chars)
jccb(Assembler::zero, test_tail);
lea(ary1, Address(ary1, len, Address::times_1));
@@ -3879,12 +3877,17 @@ void C2_MacroAssembler::count_positives(Register ary1, Register len,
testl(tmp1, -1);
jcc(Assembler::zero, DONE);
+
+ // check the tail for absense of negatives
// ~(~0 << len) applied up to two times (for 32-bit scenario)
#ifdef _LP64
- mov64(tmp3_aliased, 0xFFFFFFFFFFFFFFFF);
- shlxq(tmp3_aliased, tmp3_aliased, tmp1);
- notq(tmp3_aliased);
- kmovql(mask2, tmp3_aliased);
+ {
+ Register tmp3_aliased = len;
+ mov64(tmp3_aliased, 0xFFFFFFFFFFFFFFFF);
+ shlxq(tmp3_aliased, tmp3_aliased, tmp1);
+ notq(tmp3_aliased);
+ kmovql(mask2, tmp3_aliased);
+ }
#else
Label k_init;
jmp(k_init);
@@ -3916,8 +3919,13 @@ void C2_MacroAssembler::count_positives(Register ary1, Register len,
ktestq(mask1, mask2);
jcc(Assembler::zero, DONE);
+ // do a full check for negative registers in the tail
+ movl(len, tmp1); // tmp1 holds low 6-bit from original len;
+ // ary1 already pointing to the right place
+ jmpb(TAIL_START);
+
bind(BREAK_LOOP);
- // At least one byte in the last 64 bytes is negative.
+ // At least one byte in the last 64 byte block was negative.
// Set up to look at the last 64 bytes as if they were a tail
lea(ary1, Address(ary1, len, Address::times_1));
addptr(result, len);
diff --git a/src/hotspot/os/aix/safepointMechanism_aix.cpp b/src/hotspot/os/aix/safepointMechanism_aix.cpp
index ef39149d74098..0a36c89bec6a9 100644
--- a/src/hotspot/os/aix/safepointMechanism_aix.cpp
+++ b/src/hotspot/os/aix/safepointMechanism_aix.cpp
@@ -24,10 +24,10 @@
#include "precompiled.hpp"
#include "logging/log.hpp"
+#include "nmt/memTracker.hpp"
#include "runtime/globals.hpp"
#include "runtime/os.hpp"
#include "runtime/safepointMechanism.hpp"
-#include "services/memTracker.hpp"
#include
void SafepointMechanism::pd_initialize() {
diff --git a/src/hotspot/os/bsd/os_bsd.cpp b/src/hotspot/os/bsd/os_bsd.cpp
index 31c33d43612f6..20eb3bec17fd9 100644
--- a/src/hotspot/os/bsd/os_bsd.cpp
+++ b/src/hotspot/os/bsd/os_bsd.cpp
@@ -34,6 +34,7 @@
#include "logging/log.hpp"
#include "logging/logStream.hpp"
#include "memory/allocation.inline.hpp"
+#include "nmt/memTracker.hpp"
#include "oops/oop.inline.hpp"
#include "os_bsd.inline.hpp"
#include "os_posix.inline.hpp"
@@ -60,7 +61,6 @@
#include "runtime/threads.hpp"
#include "runtime/timer.hpp"
#include "services/attachListener.hpp"
-#include "services/memTracker.hpp"
#include "services/runtimeService.hpp"
#include "signals_posix.hpp"
#include "utilities/align.hpp"
@@ -202,11 +202,13 @@ static char cpu_arch[] = "ppc";
#error Add appropriate cpu_arch setting
#endif
-// Compiler variant
-#ifdef COMPILER2
- #define COMPILER_VARIANT "server"
+// JVM variant
+#if defined(ZERO)
+ #define JVM_VARIANT "zero"
+#elif defined(COMPILER2)
+ #define JVM_VARIANT "server"
#else
- #define COMPILER_VARIANT "client"
+ #define JVM_VARIANT "client"
#endif
@@ -1501,10 +1503,10 @@ void os::jvm_path(char *buf, jint buflen) {
snprintf(jrelib_p, buflen-len, "/lib");
}
- // Add the appropriate client or server subdir
+ // Add the appropriate JVM variant subdir
len = strlen(buf);
jrelib_p = buf + len;
- snprintf(jrelib_p, buflen-len, "/%s", COMPILER_VARIANT);
+ snprintf(jrelib_p, buflen-len, "/%s", JVM_VARIANT);
if (0 != access(buf, F_OK)) {
snprintf(jrelib_p, buflen-len, "%s", "");
}
diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp
index db942feabcf52..6063e23da701a 100644
--- a/src/hotspot/os/linux/os_linux.cpp
+++ b/src/hotspot/os/linux/os_linux.cpp
@@ -36,10 +36,11 @@
#include "logging/log.hpp"
#include "logging/logStream.hpp"
#include "memory/allocation.inline.hpp"
+#include "nmt/memTracker.hpp"
#include "oops/oop.inline.hpp"
+#include "osContainer_linux.hpp"
#include "os_linux.inline.hpp"
#include "os_posix.inline.hpp"
-#include "osContainer_linux.hpp"
#include "prims/jniFastGetField.hpp"
#include "prims/jvm_misc.hpp"
#include "runtime/arguments.hpp"
@@ -64,19 +65,18 @@
#include "runtime/threadSMR.hpp"
#include "runtime/timer.hpp"
#include "runtime/vm_version.hpp"
-#include "signals_posix.hpp"
#include "semaphore_posix.hpp"
-#include "services/memTracker.hpp"
#include "services/runtimeService.hpp"
+#include "signals_posix.hpp"
#include "utilities/align.hpp"
#include "utilities/checkedCast.hpp"
#include "utilities/debug.hpp"
#include "utilities/decoder.hpp"
#include "utilities/defaultStream.hpp"
-#include "utilities/events.hpp"
#include "utilities/elfFile.hpp"
-#include "utilities/growableArray.hpp"
+#include "utilities/events.hpp"
#include "utilities/globalDefinitions.hpp"
+#include "utilities/growableArray.hpp"
#include "utilities/macros.hpp"
#include "utilities/powerOfTwo.hpp"
#include "utilities/vmError.hpp"
diff --git a/src/hotspot/os/posix/os_posix.cpp b/src/hotspot/os/posix/os_posix.cpp
index 11dbead5d39ed..2df2220441262 100644
--- a/src/hotspot/os/posix/os_posix.cpp
+++ b/src/hotspot/os/posix/os_posix.cpp
@@ -27,20 +27,20 @@
#include "jvmtifiles/jvmti.h"
#include "logging/log.hpp"
#include "memory/allocation.inline.hpp"
+#include "nmt/memTracker.hpp"
#include "os_posix.inline.hpp"
-#include "runtime/globals_extension.hpp"
-#include "runtime/osThread.hpp"
-#include "runtime/frame.inline.hpp"
-#include "runtime/interfaceSupport.inline.hpp"
-#include "runtime/sharedRuntime.hpp"
-#include "services/attachListener.hpp"
-#include "services/memTracker.hpp"
#include "runtime/arguments.hpp"
#include "runtime/atomic.hpp"
+#include "runtime/frame.inline.hpp"
+#include "runtime/globals_extension.hpp"
+#include "runtime/interfaceSupport.inline.hpp"
#include "runtime/java.hpp"
#include "runtime/orderAccess.hpp"
+#include "runtime/osThread.hpp"
#include "runtime/park.hpp"
#include "runtime/perfMemory.hpp"
+#include "runtime/sharedRuntime.hpp"
+#include "services/attachListener.hpp"
#include "utilities/align.hpp"
#include "utilities/checkedCast.hpp"
#include "utilities/debug.hpp"
diff --git a/src/hotspot/os/posix/perfMemory_posix.cpp b/src/hotspot/os/posix/perfMemory_posix.cpp
index 7c39c5af466dc..8736e05bc62ae 100644
--- a/src/hotspot/os/posix/perfMemory_posix.cpp
+++ b/src/hotspot/os/posix/perfMemory_posix.cpp
@@ -29,13 +29,13 @@
#include "logging/log.hpp"
#include "memory/allocation.inline.hpp"
#include "memory/resourceArea.hpp"
+#include "nmt/memTracker.hpp"
#include "oops/oop.inline.hpp"
#include "os_posix.inline.hpp"
#include "runtime/globals_extension.hpp"
#include "runtime/handles.inline.hpp"
#include "runtime/os.hpp"
#include "runtime/perfMemory.hpp"
-#include "services/memTracker.hpp"
#include "utilities/exceptions.hpp"
#if defined(LINUX)
#include "os_linux.hpp"
diff --git a/src/hotspot/os/windows/os_windows.cpp b/src/hotspot/os/windows/os_windows.cpp
index 45a240fea27b4..2cb3f7e754a9b 100644
--- a/src/hotspot/os/windows/os_windows.cpp
+++ b/src/hotspot/os/windows/os_windows.cpp
@@ -38,6 +38,7 @@
#include "logging/log.hpp"
#include "logging/logStream.hpp"
#include "memory/allocation.inline.hpp"
+#include "nmt/memTracker.hpp"
#include "oops/oop.inline.hpp"
#include "os_windows.inline.hpp"
#include "prims/jniFastGetField.hpp"
@@ -63,12 +64,11 @@
#include "runtime/sharedRuntime.hpp"
#include "runtime/statSampler.hpp"
#include "runtime/stubRoutines.hpp"
-#include "runtime/threads.hpp"
#include "runtime/threadCritical.hpp"
+#include "runtime/threads.hpp"
#include "runtime/timer.hpp"
#include "runtime/vm_version.hpp"
#include "services/attachListener.hpp"
-#include "services/memTracker.hpp"
#include "services/runtimeService.hpp"
#include "symbolengine.hpp"
#include "utilities/align.hpp"
diff --git a/src/hotspot/os/windows/perfMemory_windows.cpp b/src/hotspot/os/windows/perfMemory_windows.cpp
index 8fa1aa5c34d5b..5a4f95d044fc8 100644
--- a/src/hotspot/os/windows/perfMemory_windows.cpp
+++ b/src/hotspot/os/windows/perfMemory_windows.cpp
@@ -27,13 +27,13 @@
#include "logging/log.hpp"
#include "memory/allocation.inline.hpp"
#include "memory/resourceArea.hpp"
+#include "nmt/memTracker.hpp"
#include "oops/oop.inline.hpp"
#include "os_windows.inline.hpp"
#include "runtime/globals_extension.hpp"
#include "runtime/handles.inline.hpp"
#include "runtime/os.hpp"
#include "runtime/perfMemory.hpp"
-#include "services/memTracker.hpp"
#include "utilities/exceptions.hpp"
#include "utilities/formatBuffer.hpp"
diff --git a/src/hotspot/os_cpu/bsd_x86/atomic_bsd_x86.hpp b/src/hotspot/os_cpu/bsd_x86/atomic_bsd_x86.hpp
index 77104194b0b78..9ba246f553d88 100644
--- a/src/hotspot/os_cpu/bsd_x86/atomic_bsd_x86.hpp
+++ b/src/hotspot/os_cpu/bsd_x86/atomic_bsd_x86.hpp
@@ -153,6 +153,14 @@ inline T Atomic::PlatformCmpxchg<8>::operator()(T volatile* dest,
return cmpxchg_using_helper(_Atomic_cmpxchg_long, dest, compare_value, exchange_value);
}
+// No direct support for 8-byte xchg; emulate using cmpxchg.
+template<>
+struct Atomic::PlatformXchg<8> : Atomic::XchgUsingCmpxchg<8> {};
+
+// No direct support for 8-byte add; emulate using cmpxchg.
+template<>
+struct Atomic::PlatformAdd<8> : Atomic::AddUsingCmpxchg<8> {};
+
template<>
template
inline T Atomic::PlatformLoad<8>::operator()(T const volatile* src) const {
diff --git a/src/hotspot/os_cpu/linux_arm/atomic_linux_arm.hpp b/src/hotspot/os_cpu/linux_arm/atomic_linux_arm.hpp
index 814dbd9aab501..513217649e633 100644
--- a/src/hotspot/os_cpu/linux_arm/atomic_linux_arm.hpp
+++ b/src/hotspot/os_cpu/linux_arm/atomic_linux_arm.hpp
@@ -128,6 +128,13 @@ inline T Atomic::PlatformXchg<4>::operator()(T volatile* dest,
return xchg_using_helper(ARMAtomicFuncs::_xchg_func, dest, exchange_value);
}
+// No direct support for 8-byte xchg; emulate using cmpxchg.
+template<>
+struct Atomic::PlatformXchg<8> : Atomic::XchgUsingCmpxchg<8> {};
+
+// No direct support for 8-byte add; emulate using cmpxchg.
+template<>
+struct Atomic::PlatformAdd<8> : Atomic::AddUsingCmpxchg<8> {};
// The memory_order parameter is ignored - we always provide the strongest/most-conservative ordering
diff --git a/src/hotspot/os_cpu/linux_x86/atomic_linux_x86.hpp b/src/hotspot/os_cpu/linux_x86/atomic_linux_x86.hpp
index 2e472a020683a..0156546ba9b77 100644
--- a/src/hotspot/os_cpu/linux_x86/atomic_linux_x86.hpp
+++ b/src/hotspot/os_cpu/linux_x86/atomic_linux_x86.hpp
@@ -153,6 +153,14 @@ inline T Atomic::PlatformCmpxchg<8>::operator()(T volatile* dest,
return cmpxchg_using_helper(_Atomic_cmpxchg_long, dest, compare_value, exchange_value);
}
+// No direct support for 8-byte xchg; emulate using cmpxchg.
+template<>
+struct Atomic::PlatformXchg<8> : Atomic::XchgUsingCmpxchg<8> {};
+
+// No direct support for 8-byte add; emulate using cmpxchg.
+template<>
+struct Atomic::PlatformAdd<8> : Atomic::AddUsingCmpxchg<8> {};
+
template<>
template
inline T Atomic::PlatformLoad<8>::operator()(T const volatile* src) const {
diff --git a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
index db5e1ed4bf212..b211330409d59 100644
--- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
+++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp
@@ -32,6 +32,7 @@
#include "jvm.h"
#include "logging/log.hpp"
#include "memory/allocation.inline.hpp"
+#include "nmt/memTracker.hpp"
#include "os_linux.hpp"
#include "os_posix.hpp"
#include "prims/jniFastGetField.hpp"
@@ -48,7 +49,6 @@
#include "runtime/stubRoutines.hpp"
#include "runtime/timer.hpp"
#include "signals_posix.hpp"
-#include "services/memTracker.hpp"
#include "utilities/align.hpp"
#include "utilities/debug.hpp"
#include "utilities/events.hpp"
diff --git a/src/hotspot/share/cds/filemap.cpp b/src/hotspot/share/cds/filemap.cpp
index daab34857c0b7..14e901d7b08c6 100644
--- a/src/hotspot/share/cds/filemap.cpp
+++ b/src/hotspot/share/cds/filemap.cpp
@@ -45,13 +45,14 @@
#include "classfile/vmSymbols.hpp"
#include "jvm.h"
#include "logging/log.hpp"
-#include "logging/logStream.hpp"
#include "logging/logMessage.hpp"
+#include "logging/logStream.hpp"
#include "memory/iterator.inline.hpp"
#include "memory/metadataFactory.hpp"
#include "memory/metaspaceClosure.hpp"
#include "memory/oopFactory.hpp"
#include "memory/universe.hpp"
+#include "nmt/memTracker.hpp"
#include "oops/compressedOops.hpp"
#include "oops/compressedOops.inline.hpp"
#include "oops/objArrayOop.hpp"
@@ -63,7 +64,6 @@
#include "runtime/mutexLocker.hpp"
#include "runtime/os.hpp"
#include "runtime/vm_version.hpp"
-#include "services/memTracker.hpp"
#include "utilities/align.hpp"
#include "utilities/bitMap.inline.hpp"
#include "utilities/classpathStream.hpp"
diff --git a/src/hotspot/share/cds/metaspaceShared.cpp b/src/hotspot/share/cds/metaspaceShared.cpp
index 0713212c10047..9f3a554bd1158 100644
--- a/src/hotspot/share/cds/metaspaceShared.cpp
+++ b/src/hotspot/share/cds/metaspaceShared.cpp
@@ -29,8 +29,9 @@
#include "cds/cds_globals.hpp"
#include "cds/cdsConfig.hpp"
#include "cds/cdsProtectionDomain.hpp"
-#include "cds/classListWriter.hpp"
+#include "cds/cds_globals.hpp"
#include "cds/classListParser.hpp"
+#include "cds/classListWriter.hpp"
#include "cds/classPrelinker.hpp"
#include "cds/cppVtables.hpp"
#include "cds/dumpAllocStats.hpp"
@@ -45,8 +46,8 @@
#include "classfile/javaClasses.inline.hpp"
#include "classfile/loaderConstraints.hpp"
#include "classfile/placeholders.hpp"
-#include "classfile/symbolTable.hpp"
#include "classfile/stringTable.hpp"
+#include "classfile/symbolTable.hpp"
#include "classfile/systemDictionary.hpp"
#include "classfile/systemDictionaryShared.hpp"
#include "classfile/vmClasses.hpp"
@@ -63,6 +64,7 @@
#include "memory/metaspaceClosure.hpp"
#include "memory/resourceArea.hpp"
#include "memory/universe.hpp"
+#include "nmt/memTracker.hpp"
#include "oops/compressedKlass.hpp"
#include "oops/instanceMirrorKlass.hpp"
#include "oops/klass.inline.hpp"
@@ -77,14 +79,13 @@
#include "runtime/os.inline.hpp"
#include "runtime/safepointVerifiers.hpp"
#include "runtime/sharedRuntime.hpp"
-#include "runtime/vmThread.hpp"
#include "runtime/vmOperations.hpp"
+#include "runtime/vmThread.hpp"
#include "sanitizers/leak.hpp"
-#include "services/memTracker.hpp"
#include "utilities/align.hpp"
#include "utilities/bitMap.inline.hpp"
-#include "utilities/ostream.hpp"
#include "utilities/defaultStream.hpp"
+#include "utilities/ostream.hpp"
#include "utilities/resourceHash.hpp"
ReservedSpace MetaspaceShared::_symbol_rs;
diff --git a/src/hotspot/share/compiler/compilationMemoryStatistic.cpp b/src/hotspot/share/compiler/compilationMemoryStatistic.cpp
index 182ab9fd2ed2e..8395d221c9244 100644
--- a/src/hotspot/share/compiler/compilationMemoryStatistic.cpp
+++ b/src/hotspot/share/compiler/compilationMemoryStatistic.cpp
@@ -34,12 +34,12 @@
#include "compiler/compilerThread.hpp"
#include "memory/arena.hpp"
#include "memory/resourceArea.hpp"
+#include "nmt/nmtCommon.hpp"
#include "oops/symbol.hpp"
#ifdef COMPILER2
#include "opto/node.hpp" // compile.hpp is not self-contained
#include "opto/compile.hpp"
#endif
-#include "services/nmtCommon.hpp"
#include "runtime/mutexLocker.hpp"
#include "runtime/os.hpp"
#include "utilities/globalDefinitions.hpp"
diff --git a/src/hotspot/share/compiler/compileBroker.cpp b/src/hotspot/share/compiler/compileBroker.cpp
index f265271857dc1..22a9eb4dcaa55 100644
--- a/src/hotspot/share/compiler/compileBroker.cpp
+++ b/src/hotspot/share/compiler/compileBroker.cpp
@@ -2211,7 +2211,9 @@ void CompileBroker::invoke_compiler_on_method(CompileTask* task) {
} else {
JVMCIEnv env(thread, &compile_state, __FILE__, __LINE__);
if (env.init_error() != JNI_OK) {
- failure_reason = os::strdup(err_msg("Error attaching to libjvmci (err: %d)", env.init_error()), mtJVMCI);
+ const char* msg = env.init_error_msg();
+ failure_reason = os::strdup(err_msg("Error attaching to libjvmci (err: %d, %s)",
+ env.init_error(), msg == nullptr ? "unknown" : msg), mtJVMCI);
bool reason_on_C_heap = true;
// In case of JNI_ENOMEM, there's a good chance a subsequent attempt to create libjvmci or attach to it
// might succeed. Other errors most likely indicate a non-recoverable error in the JVMCI runtime.
diff --git a/src/hotspot/share/gc/g1/g1BlockOffsetTable.cpp b/src/hotspot/share/gc/g1/g1BlockOffsetTable.cpp
index c8b60b4c98236..71107387564a2 100644
--- a/src/hotspot/share/gc/g1/g1BlockOffsetTable.cpp
+++ b/src/hotspot/share/gc/g1/g1BlockOffsetTable.cpp
@@ -27,11 +27,9 @@
#include "gc/g1/g1CollectedHeap.inline.hpp"
#include "gc/g1/heapRegion.inline.hpp"
#include "logging/log.hpp"
+#include "nmt/memTracker.hpp"
#include "oops/oop.inline.hpp"
#include "runtime/java.hpp"
-#include "services/memTracker.hpp"
-
-
//////////////////////////////////////////////////////////////////////
// G1BlockOffsetTable
diff --git a/src/hotspot/share/gc/g1/g1CodeRootSet.cpp b/src/hotspot/share/gc/g1/g1CodeRootSet.cpp
index 8b32d3c295685..59d877554ea4e 100644
--- a/src/hotspot/share/gc/g1/g1CodeRootSet.cpp
+++ b/src/hotspot/share/gc/g1/g1CodeRootSet.cpp
@@ -143,8 +143,11 @@ class G1CodeRootSetHashTable : public CHeapObj {
}
void clear() {
- _table.unsafe_reset();
- Atomic::store(&_num_entries, (size_t)0);
+ // Remove all entries.
+ auto always_true = [] (nmethod** value) {
+ return true;
+ };
+ clean(always_true);
}
void iterate_at_safepoint(CodeBlobClosure* blk) {
diff --git a/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp b/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp
index f46ac31ceeb8d..c30ea3d69d01a 100644
--- a/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp
+++ b/src/hotspot/share/gc/g1/g1ConcurrentMark.cpp
@@ -64,6 +64,7 @@
#include "memory/metaspaceUtils.hpp"
#include "memory/resourceArea.hpp"
#include "memory/universe.hpp"
+#include "nmt/memTracker.hpp"
#include "oops/access.inline.hpp"
#include "oops/oop.inline.hpp"
#include "runtime/atomic.hpp"
@@ -73,7 +74,6 @@
#include "runtime/orderAccess.hpp"
#include "runtime/prefetch.inline.hpp"
#include "runtime/threads.hpp"
-#include "services/memTracker.hpp"
#include "utilities/align.hpp"
#include "utilities/formatBuffer.hpp"
#include "utilities/growableArray.hpp"
diff --git a/src/hotspot/share/gc/g1/g1HeapTransition.cpp b/src/hotspot/share/gc/g1/g1HeapTransition.cpp
index 49ba19dfdba6d..a2097041b2093 100644
--- a/src/hotspot/share/gc/g1/g1HeapTransition.cpp
+++ b/src/hotspot/share/gc/g1/g1HeapTransition.cpp
@@ -143,11 +143,11 @@ void G1HeapTransition::print() {
usage = blk._usage;
assert(usage._eden_region_count == 0, "Expected no eden regions, but got " SIZE_FORMAT, usage._eden_region_count);
assert(usage._survivor_region_count == after._survivor_length, "Expected survivors to be " SIZE_FORMAT " but was " SIZE_FORMAT,
- after._survivor_length, usage._survivor_region_count);
+ after._survivor_length, usage._survivor_region_count);
assert(usage._old_region_count == after._old_length, "Expected old to be " SIZE_FORMAT " but was " SIZE_FORMAT,
- after._old_length, usage._old_region_count);
+ after._old_length, usage._old_region_count);
assert(usage._humongous_region_count == after._humongous_length, "Expected humongous to be " SIZE_FORMAT " but was " SIZE_FORMAT,
- after._humongous_length, usage._humongous_region_count);
+ after._humongous_length, usage._humongous_region_count);
}
log_regions("Eden", _before._eden_length, after._eden_length, eden_capacity_length_after_gc,
@@ -157,17 +157,17 @@ void G1HeapTransition::print() {
log_regions("Survivor", _before._survivor_length, after._survivor_length, survivor_capacity_length_before_gc,
_before._survivor_length_per_node, after._survivor_length_per_node);
log_trace(gc, heap)(" Used: " SIZE_FORMAT "K, Waste: " SIZE_FORMAT "K",
- usage._survivor_used / K, ((after._survivor_length * HeapRegion::GrainBytes) - usage._survivor_used) / K);
+ usage._survivor_used / K, ((after._survivor_length * HeapRegion::GrainBytes) - usage._survivor_used) / K);
log_info(gc, heap)("Old regions: " SIZE_FORMAT "->" SIZE_FORMAT,
_before._old_length, after._old_length);
log_trace(gc, heap)(" Used: " SIZE_FORMAT "K, Waste: " SIZE_FORMAT "K",
- usage._old_used / K, ((after._old_length * HeapRegion::GrainBytes) - usage._old_used) / K);
+ usage._old_used / K, ((after._old_length * HeapRegion::GrainBytes) - usage._old_used) / K);
log_info(gc, heap)("Humongous regions: " SIZE_FORMAT "->" SIZE_FORMAT,
_before._humongous_length, after._humongous_length);
log_trace(gc, heap)(" Used: " SIZE_FORMAT "K, Waste: " SIZE_FORMAT "K",
- usage._humongous_used / K, ((after._humongous_length * HeapRegion::GrainBytes) - usage._humongous_used) / K);
+ usage._humongous_used / K, ((after._humongous_length * HeapRegion::GrainBytes) - usage._humongous_used) / K);
MetaspaceUtils::print_metaspace_change(_before._meta_sizes);
}
diff --git a/src/hotspot/share/gc/g1/g1PageBasedVirtualSpace.cpp b/src/hotspot/share/gc/g1/g1PageBasedVirtualSpace.cpp
index 5265d23b555a8..bdb732f6ebb39 100644
--- a/src/hotspot/share/gc/g1/g1PageBasedVirtualSpace.cpp
+++ b/src/hotspot/share/gc/g1/g1PageBasedVirtualSpace.cpp
@@ -26,11 +26,11 @@
#include "gc/g1/g1PageBasedVirtualSpace.hpp"
#include "gc/shared/pretouchTask.hpp"
#include "gc/shared/workerThread.hpp"
+#include "nmt/memTracker.hpp"
#include "oops/markWord.hpp"
#include "oops/oop.inline.hpp"
#include "runtime/atomic.hpp"
#include "runtime/os.hpp"
-#include "services/memTracker.hpp"
#include "utilities/align.hpp"
#include "utilities/bitMap.inline.hpp"
diff --git a/src/hotspot/share/gc/g1/g1Policy.cpp b/src/hotspot/share/gc/g1/g1Policy.cpp
index 13736b891e208..1bc1d44691bbb 100644
--- a/src/hotspot/share/gc/g1/g1Policy.cpp
+++ b/src/hotspot/share/gc/g1/g1Policy.cpp
@@ -1099,7 +1099,7 @@ double G1Policy::predict_eden_copy_time_ms(uint count, size_t* bytes_to_copy) co
if (count == 0) {
return 0.0;
}
- size_t const expected_bytes = _eden_surv_rate_group->accum_surv_rate_pred(count) * HeapRegion::GrainBytes;
+ size_t const expected_bytes = _eden_surv_rate_group->accum_surv_rate_pred(count - 1) * HeapRegion::GrainBytes;
if (bytes_to_copy != nullptr) {
*bytes_to_copy = expected_bytes;
}
diff --git a/src/hotspot/share/gc/g1/g1RegionToSpaceMapper.cpp b/src/hotspot/share/gc/g1/g1RegionToSpaceMapper.cpp
index 028b2a0748778..5f903960cce8c 100644
--- a/src/hotspot/share/gc/g1/g1RegionToSpaceMapper.cpp
+++ b/src/hotspot/share/gc/g1/g1RegionToSpaceMapper.cpp
@@ -29,8 +29,8 @@
#include "gc/shared/gc_globals.hpp"
#include "memory/allocation.inline.hpp"
#include "memory/virtualspace.hpp"
+#include "nmt/memTracker.hpp"
#include "runtime/mutexLocker.hpp"
-#include "services/memTracker.hpp"
#include "utilities/align.hpp"
#include "utilities/bitMap.inline.hpp"
#include "utilities/powerOfTwo.hpp"
diff --git a/src/hotspot/share/gc/parallel/objectStartArray.cpp b/src/hotspot/share/gc/parallel/objectStartArray.cpp
index 3e4820aa9414f..804b936393c45 100644
--- a/src/hotspot/share/gc/parallel/objectStartArray.cpp
+++ b/src/hotspot/share/gc/parallel/objectStartArray.cpp
@@ -26,9 +26,9 @@
#include "gc/parallel/objectStartArray.inline.hpp"
#include "gc/shared/cardTableBarrierSet.hpp"
#include "memory/allocation.inline.hpp"
+#include "nmt/memTracker.hpp"
#include "oops/oop.inline.hpp"
#include "runtime/java.hpp"
-#include "services/memTracker.hpp"
#include "utilities/align.hpp"
uint ObjectStartArray::_card_shift = 0;
diff --git a/src/hotspot/share/gc/parallel/parMarkBitMap.cpp b/src/hotspot/share/gc/parallel/parMarkBitMap.cpp
index 9cdd91652f054..54db633af5289 100644
--- a/src/hotspot/share/gc/parallel/parMarkBitMap.cpp
+++ b/src/hotspot/share/gc/parallel/parMarkBitMap.cpp
@@ -26,10 +26,10 @@
#include "gc/parallel/parMarkBitMap.inline.hpp"
#include "gc/parallel/psCompactionManager.inline.hpp"
#include "gc/parallel/psParallelCompact.inline.hpp"
+#include "nmt/memTracker.hpp"
#include "oops/oop.inline.hpp"
#include "runtime/atomic.hpp"
#include "runtime/os.hpp"
-#include "services/memTracker.hpp"
#include "utilities/align.hpp"
#include "utilities/bitMap.inline.hpp"
diff --git a/src/hotspot/share/gc/parallel/parallelScavengeHeap.cpp b/src/hotspot/share/gc/parallel/parallelScavengeHeap.cpp
index 57452cf07e5ae..190e01d96740d 100644
--- a/src/hotspot/share/gc/parallel/parallelScavengeHeap.cpp
+++ b/src/hotspot/share/gc/parallel/parallelScavengeHeap.cpp
@@ -24,8 +24,8 @@
#include "precompiled.hpp"
#include "code/codeCache.hpp"
-#include "gc/parallel/parallelArguments.hpp"
#include "gc/parallel/objectStartArray.inline.hpp"
+#include "gc/parallel/parallelArguments.hpp"
#include "gc/parallel/parallelInitLogger.hpp"
#include "gc/parallel/parallelScavengeHeap.inline.hpp"
#include "gc/parallel/psAdaptiveSizePolicy.hpp"
@@ -35,10 +35,10 @@
#include "gc/parallel/psScavenge.hpp"
#include "gc/parallel/psVMOperations.hpp"
#include "gc/shared/gcHeapSummary.hpp"
+#include "gc/shared/gcInitLogger.hpp"
#include "gc/shared/gcLocker.inline.hpp"
#include "gc/shared/gcWhen.hpp"
#include "gc/shared/genArguments.hpp"
-#include "gc/shared/gcInitLogger.hpp"
#include "gc/shared/locationPrinter.inline.hpp"
#include "gc/shared/scavengableNMethods.hpp"
#include "gc/shared/suspendibleThreadSet.hpp"
@@ -47,12 +47,12 @@
#include "memory/metaspaceCounters.hpp"
#include "memory/metaspaceUtils.hpp"
#include "memory/universe.hpp"
+#include "nmt/memTracker.hpp"
#include "oops/oop.inline.hpp"
#include "runtime/handles.inline.hpp"
#include "runtime/java.hpp"
#include "runtime/vmThread.hpp"
#include "services/memoryManager.hpp"
-#include "services/memTracker.hpp"
#include "utilities/macros.hpp"
#include "utilities/vmError.hpp"
diff --git a/src/hotspot/share/gc/parallel/psCardTable.cpp b/src/hotspot/share/gc/parallel/psCardTable.cpp
index 4d63cdb9a3f3a..06fd02b0da81e 100644
--- a/src/hotspot/share/gc/parallel/psCardTable.cpp
+++ b/src/hotspot/share/gc/parallel/psCardTable.cpp
@@ -95,29 +95,6 @@ class CheckForUnmarkedObjects : public ObjectClosure {
}
};
-// Checks for precise marking of oops as newgen.
-class CheckForPreciseMarks : public BasicOopIterateClosure {
- private:
- PSYoungGen* _young_gen;
- PSCardTable* _card_table;
-
- protected:
- template void do_oop_work(T* p) {
- oop obj = RawAccess::oop_load(p);
- if (_young_gen->is_in_reserved(obj)) {
- assert(_card_table->addr_is_marked_precise(p), "Found unmarked precise oop");
- _card_table->set_card_newgen(p);
- }
- }
-
- public:
- CheckForPreciseMarks(PSYoungGen* young_gen, PSCardTable* card_table) :
- _young_gen(young_gen), _card_table(card_table) { }
-
- virtual void do_oop(oop* p) { CheckForPreciseMarks::do_oop_work(p); }
- virtual void do_oop(narrowOop* p) { CheckForPreciseMarks::do_oop_work(p); }
-};
-
static void prefetch_write(void *p) {
if (PrefetchScanIntervalInBytes >= 0) {
Prefetch::write(p, PrefetchScanIntervalInBytes);
@@ -410,29 +387,6 @@ void PSCardTable::verify_all_young_refs_imprecise() {
old_gen->object_iterate(&check);
}
-// This should be called immediately after a scavenge, before mutators resume.
-void PSCardTable::verify_all_young_refs_precise() {
- ParallelScavengeHeap* heap = ParallelScavengeHeap::heap();
- PSOldGen* old_gen = heap->old_gen();
-
- CheckForPreciseMarks check(heap->young_gen(), this);
-
- old_gen->oop_iterate(&check);
-
- verify_all_young_refs_precise_helper(old_gen->object_space()->used_region());
-}
-
-void PSCardTable::verify_all_young_refs_precise_helper(MemRegion mr) {
- CardValue* bot = byte_for(mr.start());
- CardValue* top = byte_for(mr.end());
- while (bot <= top) {
- assert(*bot == clean_card || *bot == verify_card, "Found unwanted or unknown card mark");
- if (*bot == verify_card)
- *bot = youngergen_card;
- bot++;
- }
-}
-
bool PSCardTable::addr_is_marked_imprecise(void *addr) {
CardValue* p = byte_for(addr);
CardValue val = *p;
@@ -451,28 +405,6 @@ bool PSCardTable::addr_is_marked_imprecise(void *addr) {
return false;
}
-// Also includes verify_card
-bool PSCardTable::addr_is_marked_precise(void *addr) {
- CardValue* p = byte_for(addr);
- CardValue val = *p;
-
- if (card_is_newgen(val))
- return true;
-
- if (card_is_verify(val))
- return true;
-
- if (card_is_clean(val))
- return false;
-
- if (card_is_dirty(val))
- return false;
-
- assert(false, "Found unhandled card mark type");
-
- return false;
-}
-
bool PSCardTable::is_in_young(const void* p) const {
return ParallelScavengeHeap::heap()->is_in_young(p);
}
diff --git a/src/hotspot/share/gc/parallel/psCardTable.hpp b/src/hotspot/share/gc/parallel/psCardTable.hpp
index b0634d5c0b084..b34d5961d6cae 100644
--- a/src/hotspot/share/gc/parallel/psCardTable.hpp
+++ b/src/hotspot/share/gc/parallel/psCardTable.hpp
@@ -63,8 +63,6 @@ class PSCardTable: public CardTable {
HeapWord* const start,
HeapWord* const end);
- void verify_all_young_refs_precise_helper(MemRegion mr);
-
enum ExtendedCardValue {
youngergen_card = CT_MR_BS_last_reserved + 1,
verify_card = CT_MR_BS_last_reserved + 5
@@ -93,7 +91,6 @@ class PSCardTable: public CardTable {
uint n_stripes);
bool addr_is_marked_imprecise(void *addr);
- bool addr_is_marked_precise(void *addr);
void set_card_newgen(void* addr) { CardValue* p = byte_for(addr); *p = verify_card; }
@@ -120,7 +117,6 @@ class PSCardTable: public CardTable {
// Verification
void verify_all_young_refs_imprecise();
- void verify_all_young_refs_precise();
};
#endif // SHARE_GC_PARALLEL_PSCARDTABLE_HPP
diff --git a/src/hotspot/share/gc/parallel/psParallelCompact.cpp b/src/hotspot/share/gc/parallel/psParallelCompact.cpp
index b8ee8ef6163ac..496f6dd35295f 100644
--- a/src/hotspot/share/gc/parallel/psParallelCompact.cpp
+++ b/src/hotspot/share/gc/parallel/psParallelCompact.cpp
@@ -67,6 +67,7 @@
#include "memory/metaspaceUtils.hpp"
#include "memory/resourceArea.hpp"
#include "memory/universe.hpp"
+#include "nmt/memTracker.hpp"
#include "oops/access.inline.hpp"
#include "oops/instanceClassLoaderKlass.inline.hpp"
#include "oops/instanceKlass.inline.hpp"
@@ -80,7 +81,6 @@
#include "runtime/safepoint.hpp"
#include "runtime/threads.hpp"
#include "runtime/vmThread.hpp"
-#include "services/memTracker.hpp"
#include "services/memoryService.hpp"
#include "utilities/align.hpp"
#include "utilities/debug.hpp"
diff --git a/src/hotspot/share/gc/parallel/psScavenge.cpp b/src/hotspot/share/gc/parallel/psScavenge.cpp
index 5354d9257b9fe..2f114e1e2cecc 100644
--- a/src/hotspot/share/gc/parallel/psScavenge.cpp
+++ b/src/hotspot/share/gc/parallel/psScavenge.cpp
@@ -643,11 +643,7 @@ bool PSScavenge::invoke_no_policy() {
old_gen->verify_object_start_array();
}
- // Verify all old -> young cards are now precise
if (VerifyRememberedSets) {
- // Precise verification will give false positives. Until this is fixed,
- // use imprecise verification.
- // heap->card_table()->verify_all_young_refs_precise();
heap->card_table()->verify_all_young_refs_imprecise();
}
diff --git a/src/hotspot/share/gc/serial/serialBlockOffsetTable.cpp b/src/hotspot/share/gc/serial/serialBlockOffsetTable.cpp
index 0fdeab92bab62..721a8de5abc36 100644
--- a/src/hotspot/share/gc/serial/serialBlockOffsetTable.cpp
+++ b/src/hotspot/share/gc/serial/serialBlockOffsetTable.cpp
@@ -30,9 +30,9 @@
#include "logging/log.hpp"
#include "memory/iterator.hpp"
#include "memory/universe.hpp"
+#include "nmt/memTracker.hpp"
#include "oops/oop.inline.hpp"
#include "runtime/java.hpp"
-#include "services/memTracker.hpp"
//////////////////////////////////////////////////////////////////////
// BlockOffsetSharedArray
diff --git a/src/hotspot/share/gc/shared/cardTable.cpp b/src/hotspot/share/gc/shared/cardTable.cpp
index ea173af015a14..a5025a4e5a211 100644
--- a/src/hotspot/share/gc/shared/cardTable.cpp
+++ b/src/hotspot/share/gc/shared/cardTable.cpp
@@ -30,10 +30,10 @@
#include "gc/shared/space.inline.hpp"
#include "logging/log.hpp"
#include "memory/virtualspace.hpp"
+#include "nmt/memTracker.hpp"
#include "runtime/init.hpp"
#include "runtime/java.hpp"
#include "runtime/os.hpp"
-#include "services/memTracker.hpp"
#include "utilities/align.hpp"
#if INCLUDE_PARALLELGC
#include "gc/parallel/objectStartArray.hpp"
diff --git a/src/hotspot/share/gc/shared/cardTableBarrierSet.cpp b/src/hotspot/share/gc/shared/cardTableBarrierSet.cpp
index 24448b61e192e..b7d706df6e395 100644
--- a/src/hotspot/share/gc/shared/cardTableBarrierSet.cpp
+++ b/src/hotspot/share/gc/shared/cardTableBarrierSet.cpp
@@ -25,15 +25,15 @@
#include "precompiled.hpp"
#include "compiler/compilerDefinitions.inline.hpp"
#include "gc/shared/cardTable.hpp"
-#include "gc/shared/cardTableBarrierSetAssembler.hpp"
#include "gc/shared/cardTableBarrierSet.inline.hpp"
+#include "gc/shared/cardTableBarrierSetAssembler.hpp"
#include "gc/shared/collectedHeap.hpp"
#include "gc/shared/space.inline.hpp"
#include "logging/log.hpp"
#include "memory/virtualspace.hpp"
+#include "nmt/memTracker.hpp"
#include "oops/oop.inline.hpp"
#include "runtime/javaThread.hpp"
-#include "services/memTracker.hpp"
#include "utilities/align.hpp"
#include "utilities/macros.hpp"
#ifdef COMPILER1
diff --git a/src/hotspot/share/gc/shared/oopStorage.cpp b/src/hotspot/share/gc/shared/oopStorage.cpp
index e91f9f2cd416a..4d1a720bb3430 100644
--- a/src/hotspot/share/gc/shared/oopStorage.cpp
+++ b/src/hotspot/share/gc/shared/oopStorage.cpp
@@ -28,6 +28,7 @@
#include "logging/log.hpp"
#include "logging/logStream.hpp"
#include "memory/allocation.inline.hpp"
+#include "nmt/memTracker.hpp"
#include "runtime/atomic.hpp"
#include "runtime/globals.hpp"
#include "runtime/handles.inline.hpp"
@@ -39,7 +40,6 @@
#include "runtime/os.hpp"
#include "runtime/safefetch.hpp"
#include "runtime/safepoint.hpp"
-#include "services/memTracker.hpp"
#include "utilities/align.hpp"
#include "utilities/count_trailing_zeros.hpp"
#include "utilities/debug.hpp"
diff --git a/src/hotspot/share/gc/shenandoah/shenandoahCollectionSet.cpp b/src/hotspot/share/gc/shenandoah/shenandoahCollectionSet.cpp
index cc5e58aee25b8..25062c5317dcb 100644
--- a/src/hotspot/share/gc/shenandoah/shenandoahCollectionSet.cpp
+++ b/src/hotspot/share/gc/shenandoah/shenandoahCollectionSet.cpp
@@ -30,7 +30,7 @@
#include "gc/shenandoah/shenandoahHeapRegionSet.hpp"
#include "gc/shenandoah/shenandoahUtils.hpp"
#include "runtime/atomic.hpp"
-#include "services/memTracker.hpp"
+#include "nmt/memTracker.hpp"
#include "utilities/copy.hpp"
ShenandoahCollectionSet::ShenandoahCollectionSet(ShenandoahHeap* heap, ReservedSpace space, char* heap_base) :
diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp b/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp
index b6d77d1147eee..13f9d430ca56a 100644
--- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp
+++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp
@@ -76,6 +76,8 @@
#include "code/codeCache.hpp"
#include "memory/classLoaderMetaspace.hpp"
#include "memory/metaspaceUtils.hpp"
+#include "nmt/mallocTracker.hpp"
+#include "nmt/memTracker.hpp"
#include "oops/compressedOops.inline.hpp"
#include "prims/jvmtiTagMap.hpp"
#include "runtime/atomic.hpp"
@@ -85,8 +87,6 @@
#include "runtime/orderAccess.hpp"
#include "runtime/safepointMechanism.hpp"
#include "runtime/vmThread.hpp"
-#include "services/mallocTracker.hpp"
-#include "services/memTracker.hpp"
#include "utilities/events.hpp"
#include "utilities/powerOfTwo.hpp"
diff --git a/src/hotspot/share/gc/x/xPhysicalMemory.cpp b/src/hotspot/share/gc/x/xPhysicalMemory.cpp
index 9519ae93ee1b4..ca093f73d71de 100644
--- a/src/hotspot/share/gc/x/xPhysicalMemory.cpp
+++ b/src/hotspot/share/gc/x/xPhysicalMemory.cpp
@@ -31,11 +31,11 @@
#include "gc/x/xNUMA.inline.hpp"
#include "gc/x/xPhysicalMemory.inline.hpp"
#include "logging/log.hpp"
+#include "nmt/memTracker.hpp"
#include "runtime/globals.hpp"
#include "runtime/globals_extension.hpp"
#include "runtime/init.hpp"
#include "runtime/os.hpp"
-#include "services/memTracker.hpp"
#include "utilities/align.hpp"
#include "utilities/debug.hpp"
#include "utilities/globalDefinitions.hpp"
diff --git a/src/hotspot/share/gc/x/xVirtualMemory.cpp b/src/hotspot/share/gc/x/xVirtualMemory.cpp
index 650f22f328392..1d66cdd069ef7 100644
--- a/src/hotspot/share/gc/x/xVirtualMemory.cpp
+++ b/src/hotspot/share/gc/x/xVirtualMemory.cpp
@@ -27,7 +27,7 @@
#include "gc/x/xAddressSpaceLimit.hpp"
#include "gc/x/xGlobals.hpp"
#include "gc/x/xVirtualMemory.inline.hpp"
-#include "services/memTracker.hpp"
+#include "nmt/memTracker.hpp"
#include "utilities/align.hpp"
#include "utilities/debug.hpp"
diff --git a/src/hotspot/share/gc/z/zNMT.cpp b/src/hotspot/share/gc/z/zNMT.cpp
index d8753dc22833c..fa6c3cd6540ad 100644
--- a/src/hotspot/share/gc/z/zNMT.cpp
+++ b/src/hotspot/share/gc/z/zNMT.cpp
@@ -27,7 +27,7 @@
#include "gc/z/zNMT.hpp"
#include "gc/z/zVirtualMemory.hpp"
#include "memory/allocation.hpp"
-#include "services/memTracker.hpp"
+#include "nmt/memTracker.hpp"
#include "utilities/nativeCallStack.hpp"
ZNMT::Reservation ZNMT::_reservations[ZMaxVirtualReservations] = {};
diff --git a/src/hotspot/share/jfr/periodic/jfrNativeMemoryEvent.cpp b/src/hotspot/share/jfr/periodic/jfrNativeMemoryEvent.cpp
index d440a5070b854..2b86108121586 100644
--- a/src/hotspot/share/jfr/periodic/jfrNativeMemoryEvent.cpp
+++ b/src/hotspot/share/jfr/periodic/jfrNativeMemoryEvent.cpp
@@ -25,8 +25,8 @@
#include "precompiled.hpp"
#include "jfr/jfrEvents.hpp"
#include "jfr/periodic/jfrNativeMemoryEvent.hpp"
-#include "services/memTracker.hpp"
-#include "services/nmtUsage.hpp"
+#include "nmt/memTracker.hpp"
+#include "nmt/nmtUsage.hpp"
#include "utilities/globalDefinitions.hpp"
#include "utilities/ticks.hpp"
diff --git a/src/hotspot/share/jfr/periodic/jfrNativeMemoryEvent.hpp b/src/hotspot/share/jfr/periodic/jfrNativeMemoryEvent.hpp
index fde4c284ab31a..710198efdddc3 100644
--- a/src/hotspot/share/jfr/periodic/jfrNativeMemoryEvent.hpp
+++ b/src/hotspot/share/jfr/periodic/jfrNativeMemoryEvent.hpp
@@ -26,7 +26,7 @@
#define SHARE_JFR_PERIODIC_JFRNATIVEMEMORYEVENT_HPP
#include "memory/allocation.hpp"
-#include "services/nmtUsage.hpp"
+#include "nmt/nmtUsage.hpp"
#include "utilities/globalDefinitions.hpp"
#include "utilities/ticks.hpp"
diff --git a/src/hotspot/share/jfr/recorder/checkpoint/jfrCheckpointManager.cpp b/src/hotspot/share/jfr/recorder/checkpoint/jfrCheckpointManager.cpp
index 118813ef88e82..eb1258e35a200 100644
--- a/src/hotspot/share/jfr/recorder/checkpoint/jfrCheckpointManager.cpp
+++ b/src/hotspot/share/jfr/recorder/checkpoint/jfrCheckpointManager.cpp
@@ -109,6 +109,9 @@ bool JfrCheckpointManager::initialize() {
// preallocate buffer count to each of the epoch live lists
for (size_t i = 0; i < global_buffer_prealloc_count * 2; ++i) {
Buffer* const buffer = mspace_allocate(global_buffer_size, _global_mspace);
+ if (buffer == nullptr) {
+ return false;
+ }
_global_mspace->add_to_live_list(buffer, i % 2 == 0);
}
assert(_global_mspace->free_list_is_empty(), "invariant");
diff --git a/src/hotspot/share/jfr/recorder/checkpoint/types/jfrType.cpp b/src/hotspot/share/jfr/recorder/checkpoint/types/jfrType.cpp
index 78ef7f5b523c9..5cd9e6b253b1e 100644
--- a/src/hotspot/share/jfr/recorder/checkpoint/types/jfrType.cpp
+++ b/src/hotspot/share/jfr/recorder/checkpoint/types/jfrType.cpp
@@ -33,18 +33,19 @@
#include "gc/shared/gcWhen.hpp"
#include "jfr/leakprofiler/leakProfiler.hpp"
#include "jfr/recorder/checkpoint/jfrCheckpointWriter.hpp"
-#include "jfr/recorder/checkpoint/types/jfrType.hpp"
-#include "jfr/recorder/jfrRecorder.hpp"
#include "jfr/recorder/checkpoint/types/jfrThreadGroup.hpp"
#include "jfr/recorder/checkpoint/types/jfrThreadState.hpp"
+#include "jfr/recorder/checkpoint/types/jfrType.hpp"
+#include "jfr/recorder/jfrRecorder.hpp"
#include "jfr/support/jfrThreadLocal.hpp"
-#include "jfr/writers/jfrJavaEventWriter.hpp"
#include "jfr/utilities/jfrThreadIterator.hpp"
+#include "jfr/writers/jfrJavaEventWriter.hpp"
#include "memory/iterator.hpp"
#include "memory/metaspace.hpp"
#include "memory/metaspaceUtils.hpp"
#include "memory/referenceType.hpp"
#include "memory/universe.hpp"
+#include "nmt/nmtCommon.hpp"
#include "oops/compressedOops.hpp"
#include "runtime/flags/jvmFlag.hpp"
#include "runtime/javaThread.hpp"
@@ -53,7 +54,6 @@
#include "runtime/safepoint.hpp"
#include "runtime/synchronizer.hpp"
#include "runtime/vmOperations.hpp"
-#include "services/nmtCommon.hpp"
#ifdef COMPILER2
#include "opto/compile.hpp"
#include "opto/node.hpp"
diff --git a/src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeManager.cpp b/src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeManager.cpp
index 6f73fdece3c35..20c1100994722 100644
--- a/src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeManager.cpp
+++ b/src/hotspot/share/jfr/recorder/checkpoint/types/jfrTypeManager.cpp
@@ -34,10 +34,10 @@
#include "jfr/utilities/jfrIterator.hpp"
#include "jfr/utilities/jfrLinkedList.inline.hpp"
#include "memory/resourceArea.hpp"
+#include "nmt/memTracker.hpp"
#include "runtime/javaThread.hpp"
#include "runtime/semaphore.hpp"
#include "runtime/thread.inline.hpp"
-#include "services/memTracker.hpp"
#include "utilities/macros.hpp"
class JfrSerializerRegistration : public JfrCHeapObj {
diff --git a/src/hotspot/share/jfr/recorder/storage/jfrVirtualMemory.cpp b/src/hotspot/share/jfr/recorder/storage/jfrVirtualMemory.cpp
index 254869c03b117..78309f00913cc 100644
--- a/src/hotspot/share/jfr/recorder/storage/jfrVirtualMemory.cpp
+++ b/src/hotspot/share/jfr/recorder/storage/jfrVirtualMemory.cpp
@@ -25,9 +25,9 @@
#include "precompiled.hpp"
#include "jfr/recorder/storage/jfrVirtualMemory.hpp"
#include "memory/virtualspace.hpp"
+#include "nmt/memTracker.hpp"
#include "runtime/globals.hpp"
#include "runtime/os.hpp"
-#include "services/memTracker.hpp"
#include "utilities/globalDefinitions.hpp"
/*
diff --git a/src/hotspot/share/jfr/recorder/stringpool/jfrStringPool.cpp b/src/hotspot/share/jfr/recorder/stringpool/jfrStringPool.cpp
index 47cfca6b89210..217b6dbddc3c4 100644
--- a/src/hotspot/share/jfr/recorder/stringpool/jfrStringPool.cpp
+++ b/src/hotspot/share/jfr/recorder/stringpool/jfrStringPool.cpp
@@ -131,6 +131,9 @@ bool JfrStringPool::initialize() {
// preallocate buffer count to each of the epoch live lists
for (size_t i = 0; i < string_pool_cache_count * 2; ++i) {
Buffer* const buffer = mspace_allocate(string_pool_buffer_size, _mspace);
+ if (buffer == nullptr) {
+ return false;
+ }
_mspace->add_to_live_list(buffer, i % 2 == 0);
}
assert(_mspace->free_list_is_empty(), "invariant");
diff --git a/src/hotspot/share/jfr/utilities/jfrAllocation.cpp b/src/hotspot/share/jfr/utilities/jfrAllocation.cpp
index a9d164c40b030..e9e41ac7cd875 100644
--- a/src/hotspot/share/jfr/utilities/jfrAllocation.cpp
+++ b/src/hotspot/share/jfr/utilities/jfrAllocation.cpp
@@ -27,9 +27,9 @@
#include "jfr/utilities/jfrAllocation.hpp"
#include "logging/log.hpp"
#include "memory/allocation.inline.hpp"
+#include "nmt/memTracker.hpp"
#include "runtime/atomic.hpp"
#include "runtime/vm_version.hpp"
-#include "services/memTracker.hpp"
#include "utilities/debug.hpp"
#include "utilities/macros.hpp"
#include "utilities/nativeCallStack.hpp"
diff --git a/src/hotspot/share/jfr/utilities/jfrHashtable.hpp b/src/hotspot/share/jfr/utilities/jfrHashtable.hpp
index 54ba3eef04423..530f19ac2c684 100644
--- a/src/hotspot/share/jfr/utilities/jfrHashtable.hpp
+++ b/src/hotspot/share/jfr/utilities/jfrHashtable.hpp
@@ -26,8 +26,8 @@
#define SHARE_JFR_UTILITIES_JFRHASHTABLE_HPP
#include "jfr/utilities/jfrAllocation.hpp"
+#include "nmt/memTracker.hpp"
#include "runtime/atomic.hpp"
-#include "services/memTracker.hpp"
#include "utilities/debug.hpp"
#include "utilities/macros.hpp"
diff --git a/src/hotspot/share/jfr/writers/jfrJavaEventWriter.cpp b/src/hotspot/share/jfr/writers/jfrJavaEventWriter.cpp
index 5ff319782b265..9b27f06df7a12 100644
--- a/src/hotspot/share/jfr/writers/jfrJavaEventWriter.cpp
+++ b/src/hotspot/share/jfr/writers/jfrJavaEventWriter.cpp
@@ -260,7 +260,6 @@ jobject JfrJavaEventWriter::new_event_writer(TRAPS) {
DEBUG_ONLY(JfrJavaSupport::check_java_thread_in_vm(THREAD));
assert(event_writer(THREAD) == nullptr, "invariant");
JfrThreadLocal* const tl = THREAD->jfr_thread_local();
- assert(!tl->has_java_buffer(), "invariant");
JfrBuffer* const buffer = tl->java_buffer();
if (buffer == nullptr) {
JfrJavaSupport::throw_out_of_memory_error("OOME for thread local buffer", THREAD);
diff --git a/src/hotspot/share/jvmci/jvmciEnv.cpp b/src/hotspot/share/jvmci/jvmciEnv.cpp
index bab3de8c3355d..24af7715a5b1e 100644
--- a/src/hotspot/share/jvmci/jvmciEnv.cpp
+++ b/src/hotspot/share/jvmci/jvmciEnv.cpp
@@ -147,13 +147,14 @@ void JVMCIEnv::init_env_mode_runtime(JavaThread* thread, JNIEnv* parent_env) {
_is_hotspot = false;
_runtime = JVMCI::compiler_runtime(thread);
- _env = _runtime->init_shared_library_javavm(&_init_error);
+ _env = _runtime->init_shared_library_javavm(&_init_error, &_init_error_msg);
if (_env != nullptr) {
// Creating the JVMCI shared library VM also attaches the current thread
_detach_on_close = true;
} else if (_init_error != JNI_OK) {
// Caller creating this JVMCIEnv must handle the error.
- JVMCI_event_1("[%s:%d] Error creating libjvmci (err: %d)", _file, _line, _init_error);
+ JVMCI_event_1("[%s:%d] Error creating libjvmci (err: %d, %s)", _file, _line,
+ _init_error, _init_error_msg == nullptr ? "unknown" : _init_error_msg);
return;
} else {
_runtime->GetEnv(thread, (void**)&parent_env, JNI_VERSION_1_2);
@@ -195,17 +196,17 @@ void JVMCIEnv::init_env_mode_runtime(JavaThread* thread, JNIEnv* parent_env) {
}
JVMCIEnv::JVMCIEnv(JavaThread* thread, JVMCICompileState* compile_state, const char* file, int line):
- _throw_to_caller(false), _file(file), _line(line), _init_error(JNI_OK), _compile_state(compile_state) {
+ _throw_to_caller(false), _file(file), _line(line), _init_error(JNI_OK), _init_error_msg(nullptr), _compile_state(compile_state) {
init_env_mode_runtime(thread, nullptr);
}
JVMCIEnv::JVMCIEnv(JavaThread* thread, const char* file, int line):
- _throw_to_caller(false), _file(file), _line(line), _init_error(JNI_OK), _compile_state(nullptr) {
+ _throw_to_caller(false), _file(file), _line(line), _init_error(JNI_OK), _init_error_msg(nullptr), _compile_state(nullptr) {
init_env_mode_runtime(thread, nullptr);
}
JVMCIEnv::JVMCIEnv(JavaThread* thread, JNIEnv* parent_env, const char* file, int line):
- _throw_to_caller(true), _file(file), _line(line), _init_error(JNI_OK), _compile_state(nullptr) {
+ _throw_to_caller(true), _file(file), _line(line), _init_error(JNI_OK), _init_error_msg(nullptr), _compile_state(nullptr) {
assert(parent_env != nullptr, "npe");
init_env_mode_runtime(thread, parent_env);
assert(_env == nullptr || parent_env == _env, "mismatched JNIEnvironment");
@@ -218,6 +219,7 @@ void JVMCIEnv::init(JavaThread* thread, bool is_hotspot, const char* file, int l
_file = file;
_line = line;
_init_error = JNI_OK;
+ _init_error_msg = nullptr;
if (is_hotspot) {
_env = nullptr;
_pop_frame_on_close = false;
@@ -237,7 +239,8 @@ void JVMCIEnv::check_init(JVMCI_TRAPS) {
if (_init_error == JNI_ENOMEM) {
JVMCI_THROW_MSG(OutOfMemoryError, "JNI_ENOMEM creating or attaching to libjvmci");
}
- JVMCI_THROW_MSG(InternalError, err_msg("Error creating or attaching to libjvmci (err: %d)", _init_error));
+ JVMCI_THROW_MSG(InternalError, err_msg("Error creating or attaching to libjvmci (err: %d, description: %s)",
+ _init_error, _init_error_msg == nullptr ? "unknown" : _init_error_msg));
}
void JVMCIEnv::check_init(TRAPS) {
@@ -247,7 +250,8 @@ void JVMCIEnv::check_init(TRAPS) {
if (_init_error == JNI_ENOMEM) {
THROW_MSG(vmSymbols::java_lang_OutOfMemoryError(), "JNI_ENOMEM creating or attaching to libjvmci");
}
- THROW_MSG(vmSymbols::java_lang_OutOfMemoryError(), err_msg("Error creating or attaching to libjvmci (err: %d)", _init_error));
+ THROW_MSG(vmSymbols::java_lang_OutOfMemoryError(), err_msg("Error creating or attaching to libjvmci (err: %d, description: %s)",
+ _init_error, _init_error_msg == nullptr ? "unknown" : _init_error_msg));
}
// Prints a pending exception (if any) and its stack trace to st.
@@ -572,6 +576,9 @@ jboolean JVMCIEnv::transfer_pending_exception(JavaThread* THREAD, JVMCIEnv* peer
}
JVMCIEnv::~JVMCIEnv() {
+ if (_init_error_msg != nullptr) {
+ os::free((void*) _init_error_msg);
+ }
if (_init_error != JNI_OK) {
return;
}
diff --git a/src/hotspot/share/jvmci/jvmciEnv.hpp b/src/hotspot/share/jvmci/jvmciEnv.hpp
index 59600b97fe15a..ace0cc53352c3 100644
--- a/src/hotspot/share/jvmci/jvmciEnv.hpp
+++ b/src/hotspot/share/jvmci/jvmciEnv.hpp
@@ -172,6 +172,7 @@ class JVMCIEnv : public ResourceObj {
int _init_error; // JNI code returned when creating or attaching to a libjvmci isolate.
// If not JNI_OK, the JVMCIEnv is invalid and should not be used apart from
// calling init_error().
+ const char* _init_error_msg; // Message for _init_error if available. C heap allocated.
// Translates an exception on the HotSpot heap (i.e., hotspot_env) to an exception on
// the shared library heap (i.e., jni_env). The translation includes the stack and cause(s) of `throwable`.
@@ -217,6 +218,12 @@ class JVMCIEnv : public ResourceObj {
return _init_error;
}
+ // Gets a message describing a non-zero init_error().
+ // Valid as long as this JVMCIEnv is valid.
+ const char* init_error_msg() {
+ return _init_error_msg;
+ }
+
// Checks the value of init_error() and throws an exception in `JVMCI_TRAPS`
// (which must not be this) if it is not JNI_OK.
void check_init(JVMCI_TRAPS);
diff --git a/src/hotspot/share/jvmci/jvmciRuntime.cpp b/src/hotspot/share/jvmci/jvmciRuntime.cpp
index 68177fa8acd0f..226c4f5dea199 100644
--- a/src/hotspot/share/jvmci/jvmciRuntime.cpp
+++ b/src/hotspot/share/jvmci/jvmciRuntime.cpp
@@ -1253,7 +1253,7 @@ bool JVMCIRuntime::detach_thread(JavaThread* thread, const char* reason, bool ca
return destroyed_javavm;
}
-JNIEnv* JVMCIRuntime::init_shared_library_javavm(int* create_JavaVM_err) {
+JNIEnv* JVMCIRuntime::init_shared_library_javavm(int* create_JavaVM_err, const char** err_msg) {
MutexLocker locker(_lock);
JavaVM* javaVM = _shared_library_javavm;
if (javaVM == nullptr) {
@@ -1280,7 +1280,7 @@ JNIEnv* JVMCIRuntime::init_shared_library_javavm(int* create_JavaVM_err) {
JavaVMInitArgs vm_args;
vm_args.version = JNI_VERSION_1_2;
vm_args.ignoreUnrecognized = JNI_TRUE;
- JavaVMOption options[5];
+ JavaVMOption options[6];
jlong javaVM_id = 0;
// Protocol: JVMCI shared library JavaVM should support a non-standard "_javavm_id"
@@ -1297,6 +1297,8 @@ JNIEnv* JVMCIRuntime::init_shared_library_javavm(int* create_JavaVM_err) {
options[3].extraInfo = (void*) _fatal;
options[4].optionString = (char*) "_fatal_log";
options[4].extraInfo = (void*) _fatal_log;
+ options[5].optionString = (char*) "_createvm_errorstr";
+ options[5].extraInfo = (void*) err_msg;
vm_args.version = JNI_VERSION_1_2;
vm_args.options = options;
diff --git a/src/hotspot/share/jvmci/jvmciRuntime.hpp b/src/hotspot/share/jvmci/jvmciRuntime.hpp
index a3f464cd724c1..d3898be4ce0ae 100644
--- a/src/hotspot/share/jvmci/jvmciRuntime.hpp
+++ b/src/hotspot/share/jvmci/jvmciRuntime.hpp
@@ -280,8 +280,10 @@ class JVMCIRuntime: public CHeapObj {
// If the JavaVM was created by this call, then the thread-local JNI
// interface pointer for the JavaVM is returned otherwise null is returned.
// If this method tried to create the JavaVM but failed, the error code returned
- // by JNI_CreateJavaVM is returned in create_JavaVM_err.
- JNIEnv* init_shared_library_javavm(int* create_JavaVM_err);
+ // by JNI_CreateJavaVM is returned in create_JavaVM_err and, if available, an
+ // error message is malloc'ed and assigned to err_msg. The caller is responsible
+ // for freeing err_msg.
+ JNIEnv* init_shared_library_javavm(int* create_JavaVM_err, const char** err_msg);
// Determines if the JVMCI shared library JavaVM exists for this runtime.
bool has_shared_library_javavm() { return _shared_library_javavm != nullptr; }
diff --git a/src/hotspot/share/memory/allocation.cpp b/src/hotspot/share/memory/allocation.cpp
index 64b00a1369427..57dc88620c089 100644
--- a/src/hotspot/share/memory/allocation.cpp
+++ b/src/hotspot/share/memory/allocation.cpp
@@ -28,10 +28,10 @@
#include "memory/arena.hpp"
#include "memory/metaspace.hpp"
#include "memory/resourceArea.hpp"
+#include "nmt/memTracker.hpp"
#include "runtime/os.hpp"
#include "runtime/task.hpp"
#include "runtime/threadCritical.hpp"
-#include "services/memTracker.hpp"
#include "utilities/ostream.hpp"
// allocate using malloc; will fail if no memory available
diff --git a/src/hotspot/share/memory/arena.cpp b/src/hotspot/share/memory/arena.cpp
index f767255116c07..44f1648921f6f 100644
--- a/src/hotspot/share/memory/arena.cpp
+++ b/src/hotspot/share/memory/arena.cpp
@@ -29,11 +29,11 @@
#include "memory/allocation.inline.hpp"
#include "memory/arena.hpp"
#include "memory/resourceArea.hpp"
+#include "nmt/memTracker.inline.hpp"
#include "runtime/os.hpp"
#include "runtime/task.hpp"
#include "runtime/threadCritical.hpp"
#include "runtime/trimNativeHeap.hpp"
-#include "services/memTracker.inline.hpp"
#include "utilities/align.hpp"
#include "utilities/debug.hpp"
#include "utilities/ostream.hpp"
diff --git a/src/hotspot/share/memory/heap.cpp b/src/hotspot/share/memory/heap.cpp
index 3f584ccd1f1b7..98e59f5818432 100644
--- a/src/hotspot/share/memory/heap.cpp
+++ b/src/hotspot/share/memory/heap.cpp
@@ -24,10 +24,10 @@
#include "precompiled.hpp"
#include "memory/heap.hpp"
+#include "nmt/memTracker.hpp"
#include "oops/oop.inline.hpp"
-#include "runtime/os.hpp"
#include "runtime/mutexLocker.hpp"
-#include "services/memTracker.hpp"
+#include "runtime/os.hpp"
#include "utilities/align.hpp"
#include "utilities/checkedCast.hpp"
#include "utilities/powerOfTwo.hpp"
diff --git a/src/hotspot/share/memory/heapInspection.cpp b/src/hotspot/share/memory/heapInspection.cpp
index 820814f755cac..262dc62d977de 100644
--- a/src/hotspot/share/memory/heapInspection.cpp
+++ b/src/hotspot/share/memory/heapInspection.cpp
@@ -33,10 +33,10 @@
#include "memory/heapInspection.hpp"
#include "memory/resourceArea.hpp"
#include "memory/universe.hpp"
+#include "nmt/memTracker.hpp"
#include "oops/oop.inline.hpp"
#include "runtime/atomic.hpp"
#include "runtime/os.hpp"
-#include "services/memTracker.hpp"
#include "utilities/globalDefinitions.hpp"
#include "utilities/macros.hpp"
#include "utilities/stack.inline.hpp"
diff --git a/src/hotspot/share/memory/metaspace.cpp b/src/hotspot/share/memory/metaspace.cpp
index b0d47dcce0d16..de36cd8c7a860 100644
--- a/src/hotspot/share/memory/metaspace.cpp
+++ b/src/hotspot/share/memory/metaspace.cpp
@@ -31,7 +31,6 @@
#include "logging/logStream.hpp"
#include "memory/classLoaderMetaspace.hpp"
#include "memory/metaspace.hpp"
-#include "memory/metaspaceCriticalAllocation.hpp"
#include "memory/metaspace/chunkHeaderPool.hpp"
#include "memory/metaspace/chunkManager.hpp"
#include "memory/metaspace/commitLimiter.hpp"
@@ -42,11 +41,13 @@
#include "memory/metaspace/metaspaceSettings.hpp"
#include "memory/metaspace/runningCounters.hpp"
#include "memory/metaspace/virtualSpaceList.hpp"
-#include "memory/metaspaceTracer.hpp"
+#include "memory/metaspaceCriticalAllocation.hpp"
#include "memory/metaspaceStats.hpp"
+#include "memory/metaspaceTracer.hpp"
#include "memory/metaspaceUtils.hpp"
#include "memory/resourceArea.hpp"
#include "memory/universe.hpp"
+#include "nmt/memTracker.hpp"
#include "oops/compressedKlass.inline.hpp"
#include "oops/compressedOops.hpp"
#include "prims/jvmtiExport.hpp"
@@ -54,7 +55,6 @@
#include "runtime/globals_extension.hpp"
#include "runtime/init.hpp"
#include "runtime/java.hpp"
-#include "services/memTracker.hpp"
#include "utilities/copy.hpp"
#include "utilities/debug.hpp"
#include "utilities/formatBuffer.hpp"
diff --git a/src/hotspot/share/memory/metaspace/metaspaceDCmd.cpp b/src/hotspot/share/memory/metaspace/metaspaceDCmd.cpp
index db6d36314507b..32fee96ad7d09 100644
--- a/src/hotspot/share/memory/metaspace/metaspaceDCmd.cpp
+++ b/src/hotspot/share/memory/metaspace/metaspaceDCmd.cpp
@@ -29,9 +29,9 @@
#include "memory/metaspace/metaspaceReporter.hpp"
#include "memory/metaspaceUtils.hpp"
#include "memory/resourceArea.hpp"
+#include "nmt/nmtCommon.hpp"
#include "runtime/vmOperations.hpp"
#include "services/diagnosticCommand.hpp"
-#include "services/nmtCommon.hpp"
namespace metaspace {
diff --git a/src/hotspot/share/memory/metaspace/virtualSpaceNode.cpp b/src/hotspot/share/memory/metaspace/virtualSpaceNode.cpp
index 1ebda015eb3c8..dc5f7a6cdf110 100644
--- a/src/hotspot/share/memory/metaspace/virtualSpaceNode.cpp
+++ b/src/hotspot/share/memory/metaspace/virtualSpaceNode.cpp
@@ -39,12 +39,12 @@
#include "memory/metaspace/rootChunkArea.hpp"
#include "memory/metaspace/runningCounters.hpp"
#include "memory/metaspace/virtualSpaceNode.hpp"
+#include "nmt/memTracker.hpp"
#include "runtime/globals.hpp"
#include "runtime/mutexLocker.hpp"
#include "runtime/os.hpp"
#include "sanitizers/address.hpp"
#include "sanitizers/leak.hpp"
-#include "services/memTracker.hpp"
#include "utilities/align.hpp"
#include "utilities/debug.hpp"
#include "utilities/globalDefinitions.hpp"
diff --git a/src/hotspot/share/memory/resourceArea.cpp b/src/hotspot/share/memory/resourceArea.cpp
index bc01a7baaaa29..f281274d98a3d 100644
--- a/src/hotspot/share/memory/resourceArea.cpp
+++ b/src/hotspot/share/memory/resourceArea.cpp
@@ -25,9 +25,9 @@
#include "precompiled.hpp"
#include "memory/allocation.inline.hpp"
#include "memory/resourceArea.inline.hpp"
+#include "nmt/memTracker.hpp"
#include "runtime/atomic.hpp"
#include "runtime/javaThread.hpp"
-#include "services/memTracker.hpp"
#include "utilities/vmError.hpp"
void ResourceArea::bias_to(MEMFLAGS new_flags) {
diff --git a/src/hotspot/share/memory/resourceArea.inline.hpp b/src/hotspot/share/memory/resourceArea.inline.hpp
index 0cd7b8a28b956..d3e8364773ac4 100644
--- a/src/hotspot/share/memory/resourceArea.inline.hpp
+++ b/src/hotspot/share/memory/resourceArea.inline.hpp
@@ -26,8 +26,7 @@
#define SHARE_MEMORY_RESOURCEAREA_INLINE_HPP
#include "memory/resourceArea.hpp"
-
-#include "services/memTracker.hpp"
+#include "nmt/memTracker.hpp"
inline char* ResourceArea::allocate_bytes(size_t size, AllocFailType alloc_failmode) {
#ifdef ASSERT
diff --git a/src/hotspot/share/memory/virtualspace.cpp b/src/hotspot/share/memory/virtualspace.cpp
index 1a99b9674364c..fd73cbb3362b3 100644
--- a/src/hotspot/share/memory/virtualspace.cpp
+++ b/src/hotspot/share/memory/virtualspace.cpp
@@ -26,6 +26,7 @@
#include "logging/log.hpp"
#include "memory/resourceArea.hpp"
#include "memory/virtualspace.hpp"
+#include "nmt/memTracker.hpp"
#include "oops/compressedKlass.hpp"
#include "oops/compressedOops.hpp"
#include "oops/markWord.hpp"
@@ -33,7 +34,6 @@
#include "runtime/globals_extension.hpp"
#include "runtime/java.hpp"
#include "runtime/os.hpp"
-#include "services/memTracker.hpp"
#include "utilities/align.hpp"
#include "utilities/formatBuffer.hpp"
#include "utilities/powerOfTwo.hpp"
diff --git a/src/hotspot/share/services/allocationSite.hpp b/src/hotspot/share/nmt/allocationSite.hpp
similarity index 93%
rename from src/hotspot/share/services/allocationSite.hpp
rename to src/hotspot/share/nmt/allocationSite.hpp
index 41ff262950936..5093bb39f0c6a 100644
--- a/src/hotspot/share/services/allocationSite.hpp
+++ b/src/hotspot/share/nmt/allocationSite.hpp
@@ -22,8 +22,8 @@
*
*/
-#ifndef SHARE_SERVICES_ALLOCATIONSITE_HPP
-#define SHARE_SERVICES_ALLOCATIONSITE_HPP
+#ifndef SHARE_NMT_ALLOCATIONSITE_HPP
+#define SHARE_NMT_ALLOCATIONSITE_HPP
#include "memory/allocation.hpp"
#include "utilities/nativeCallStack.hpp"
@@ -52,4 +52,4 @@ class AllocationSite {
MEMFLAGS flag() const { return _flag; }
};
-#endif // SHARE_SERVICES_ALLOCATIONSITE_HPP
+#endif // SHARE_NMT_ALLOCATIONSITE_HPP
diff --git a/src/hotspot/share/services/mallocHeader.cpp b/src/hotspot/share/nmt/mallocHeader.cpp
similarity index 96%
rename from src/hotspot/share/services/mallocHeader.cpp
rename to src/hotspot/share/nmt/mallocHeader.cpp
index 55f8169851ae0..57d1c4a313ab9 100644
--- a/src/hotspot/share/services/mallocHeader.cpp
+++ b/src/hotspot/share/nmt/mallocHeader.cpp
@@ -24,15 +24,13 @@
*/
#include "precompiled.hpp"
-#include "services/mallocHeader.inline.hpp"
-
+#include "nmt/mallocHeader.inline.hpp"
+#include "nmt/mallocSiteTable.hpp"
#include "runtime/os.hpp"
-#include "services/mallocSiteTable.hpp"
#include "utilities/globalDefinitions.hpp"
#include "utilities/nativeCallStack.hpp"
#include "utilities/ostream.hpp"
-
void MallocHeader::print_block_on_error(outputStream* st, address bad_address) const {
assert(bad_address >= (address)this, "sanity");
diff --git a/src/hotspot/share/services/mallocHeader.hpp b/src/hotspot/share/nmt/mallocHeader.hpp
similarity index 98%
rename from src/hotspot/share/services/mallocHeader.hpp
rename to src/hotspot/share/nmt/mallocHeader.hpp
index 9a2ba3ff053c6..c0fae5803cec4 100644
--- a/src/hotspot/share/services/mallocHeader.hpp
+++ b/src/hotspot/share/nmt/mallocHeader.hpp
@@ -23,8 +23,8 @@
*
*/
-#ifndef SHARE_SERVICES_MALLOCHEADER_HPP
-#define SHARE_SERVICES_MALLOCHEADER_HPP
+#ifndef SHARE_NMT_MALLOCHEADER_HPP
+#define SHARE_NMT_MALLOCHEADER_HPP
#include "memory/allocation.hpp"
#include "utilities/globalDefinitions.hpp"
@@ -165,4 +165,4 @@ class MallocHeader {
STATIC_ASSERT(sizeof(MallocHeader) == (sizeof(uint64_t) * 2));
-#endif // SHARE_SERVICES_MALLOCHEADER_HPP
+#endif // SHARE_NMT_MALLOCHEADER_HPP
diff --git a/src/hotspot/share/services/mallocHeader.inline.hpp b/src/hotspot/share/nmt/mallocHeader.inline.hpp
similarity index 97%
rename from src/hotspot/share/services/mallocHeader.inline.hpp
rename to src/hotspot/share/nmt/mallocHeader.inline.hpp
index 669438c85fa4e..d763241b36d8c 100644
--- a/src/hotspot/share/services/mallocHeader.inline.hpp
+++ b/src/hotspot/share/nmt/mallocHeader.inline.hpp
@@ -23,10 +23,10 @@
*
*/
-#ifndef SHARE_SERVICES_MALLOCHEADER_INLINE_HPP
-#define SHARE_SERVICES_MALLOCHEADER_INLINE_HPP
+#ifndef SHARE_NMT_MALLOCHEADER_INLINE_HPP
+#define SHARE_NMT_MALLOCHEADER_INLINE_HPP
-#include "services/mallocHeader.hpp"
+#include "nmt/mallocHeader.hpp"
#include "jvm_io.h"
#include "utilities/debug.hpp"
@@ -163,4 +163,4 @@ inline bool MallocHeader::check_block_integrity(char* msg, size_t msglen, addres
return true;
}
-#endif // SHARE_SERVICES_MALLOCHEADER_INLINE_HPP
+#endif // SHARE_NMT_MALLOCHEADER_INLINE_HPP
diff --git a/src/hotspot/share/services/mallocSiteTable.cpp b/src/hotspot/share/nmt/mallocSiteTable.cpp
similarity index 99%
rename from src/hotspot/share/services/mallocSiteTable.cpp
rename to src/hotspot/share/nmt/mallocSiteTable.cpp
index 2780e86d8924e..0fdf9e0f83dcc 100644
--- a/src/hotspot/share/services/mallocSiteTable.cpp
+++ b/src/hotspot/share/nmt/mallocSiteTable.cpp
@@ -23,10 +23,9 @@
*/
#include "precompiled.hpp"
-
#include "memory/allocation.inline.hpp"
+#include "nmt/mallocSiteTable.hpp"
#include "runtime/atomic.hpp"
-#include "services/mallocSiteTable.hpp"
// Malloc site hashtable buckets
MallocSiteHashtableEntry** MallocSiteTable::_table = nullptr;
diff --git a/src/hotspot/share/services/mallocSiteTable.hpp b/src/hotspot/share/nmt/mallocSiteTable.hpp
similarity index 96%
rename from src/hotspot/share/services/mallocSiteTable.hpp
rename to src/hotspot/share/nmt/mallocSiteTable.hpp
index 2b602527e9875..47fe82b590a9f 100644
--- a/src/hotspot/share/services/mallocSiteTable.hpp
+++ b/src/hotspot/share/nmt/mallocSiteTable.hpp
@@ -22,14 +22,14 @@
*
*/
-#ifndef SHARE_SERVICES_MALLOCSITETABLE_HPP
-#define SHARE_SERVICES_MALLOCSITETABLE_HPP
+#ifndef SHARE_NMT_MALLOCSITETABLE_HPP
+#define SHARE_NMT_MALLOCSITETABLE_HPP
#include "memory/allocation.hpp"
+#include "nmt/allocationSite.hpp"
+#include "nmt/mallocTracker.hpp"
+#include "nmt/nmtCommon.hpp"
#include "runtime/atomic.hpp"
-#include "services/allocationSite.hpp"
-#include "services/mallocTracker.hpp"
-#include "services/nmtCommon.hpp"
#include "utilities/macros.hpp"
#include "utilities/nativeCallStack.hpp"
@@ -198,4 +198,4 @@ class MallocSiteTable : AllStatic {
static const MallocSiteHashtableEntry* _hash_entry_allocation_site;
};
-#endif // SHARE_SERVICES_MALLOCSITETABLE_HPP
+#endif // SHARE_NMT_MALLOCSITETABLE_HPP
diff --git a/src/hotspot/share/services/mallocTracker.cpp b/src/hotspot/share/nmt/mallocTracker.cpp
similarity index 98%
rename from src/hotspot/share/services/mallocTracker.cpp
rename to src/hotspot/share/nmt/mallocTracker.cpp
index 0793ca6f4e9a8..5c02226654c57 100644
--- a/src/hotspot/share/services/mallocTracker.cpp
+++ b/src/hotspot/share/nmt/mallocTracker.cpp
@@ -29,16 +29,16 @@
#include "jvm_io.h"
#include "logging/log.hpp"
#include "logging/logStream.hpp"
+#include "nmt/mallocHeader.inline.hpp"
+#include "nmt/mallocSiteTable.hpp"
+#include "nmt/mallocTracker.hpp"
+#include "nmt/memTracker.hpp"
#include "runtime/arguments.hpp"
#include "runtime/atomic.hpp"
#include "runtime/globals.hpp"
#include "runtime/os.hpp"
#include "runtime/safefetch.hpp"
-#include "services/mallocHeader.inline.hpp"
#include "services/mallocLimit.hpp"
-#include "services/mallocSiteTable.hpp"
-#include "services/mallocTracker.hpp"
-#include "services/memTracker.hpp"
#include "utilities/debug.hpp"
#include "utilities/ostream.hpp"
#include "utilities/vmError.hpp"
diff --git a/src/hotspot/share/services/mallocTracker.hpp b/src/hotspot/share/nmt/mallocTracker.hpp
similarity index 98%
rename from src/hotspot/share/services/mallocTracker.hpp
rename to src/hotspot/share/nmt/mallocTracker.hpp
index cf9a623c0bd92..ae56d31d786d1 100644
--- a/src/hotspot/share/services/mallocTracker.hpp
+++ b/src/hotspot/share/nmt/mallocTracker.hpp
@@ -23,14 +23,14 @@
*
*/
-#ifndef SHARE_SERVICES_MALLOCTRACKER_HPP
-#define SHARE_SERVICES_MALLOCTRACKER_HPP
+#ifndef SHARE_NMT_MALLOCTRACKER_HPP
+#define SHARE_NMT_MALLOCTRACKER_HPP
#include "memory/allocation.hpp"
+#include "nmt/mallocHeader.hpp"
+#include "nmt/nmtCommon.hpp"
#include "runtime/atomic.hpp"
#include "runtime/threadCritical.hpp"
-#include "services/mallocHeader.hpp"
-#include "services/nmtCommon.hpp"
#include "utilities/nativeCallStack.hpp"
class outputStream;
@@ -315,4 +315,4 @@ class MallocTracker : AllStatic {
}
};
-#endif // SHARE_SERVICES_MALLOCTRACKER_HPP
+#endif // SHARE_NMT_MALLOCTRACKER_HPP
diff --git a/src/hotspot/share/services/mallocTracker.inline.hpp b/src/hotspot/share/nmt/mallocTracker.inline.hpp
similarity index 93%
rename from src/hotspot/share/services/mallocTracker.inline.hpp
rename to src/hotspot/share/nmt/mallocTracker.inline.hpp
index 75eaf7c1054ee..f226d56bc3d22 100644
--- a/src/hotspot/share/services/mallocTracker.inline.hpp
+++ b/src/hotspot/share/nmt/mallocTracker.inline.hpp
@@ -23,11 +23,11 @@
*
*/
-#ifndef SHARE_SERVICES_MALLOCTRACKER_INLINE_HPP
-#define SHARE_SERVICES_MALLOCTRACKER_INLINE_HPP
+#ifndef SHARE_NMT_MALLOCTRACKER_INLINE_HPP
+#define SHARE_NMT_MALLOCTRACKER_INLINE_HPP
+#include "nmt/mallocTracker.hpp"
#include "services/mallocLimit.hpp"
-#include "services/mallocTracker.hpp"
#include "utilities/debug.hpp"
#include "utilities/globalDefinitions.hpp"
@@ -69,4 +69,4 @@ inline bool MallocTracker::check_exceeds_limit(size_t s, MEMFLAGS f) {
}
-#endif // SHARE_SERVICES_MALLOCTRACKER_INLINE_HPP
+#endif // SHARE_NMT_MALLOCTRACKER_INLINE_HPP
diff --git a/src/hotspot/share/services/memBaseline.cpp b/src/hotspot/share/nmt/memBaseline.cpp
similarity index 99%
rename from src/hotspot/share/services/memBaseline.cpp
rename to src/hotspot/share/nmt/memBaseline.cpp
index df9c4d85aa84a..637acc5245811 100644
--- a/src/hotspot/share/services/memBaseline.cpp
+++ b/src/hotspot/share/nmt/memBaseline.cpp
@@ -26,10 +26,10 @@
#include "classfile/classLoaderDataGraph.inline.hpp"
#include "memory/allocation.hpp"
#include "memory/metaspaceUtils.hpp"
+#include "nmt/memBaseline.hpp"
+#include "nmt/memTracker.hpp"
#include "runtime/javaThread.hpp"
#include "runtime/safepoint.hpp"
-#include "services/memBaseline.hpp"
-#include "services/memTracker.hpp"
/*
* Sizes are sorted in descenting order for reporting
diff --git a/src/hotspot/share/services/memBaseline.hpp b/src/hotspot/share/nmt/memBaseline.hpp
similarity index 96%
rename from src/hotspot/share/services/memBaseline.hpp
rename to src/hotspot/share/nmt/memBaseline.hpp
index fa44a45470461..903f558051103 100644
--- a/src/hotspot/share/services/memBaseline.hpp
+++ b/src/hotspot/share/nmt/memBaseline.hpp
@@ -22,15 +22,15 @@
*
*/
-#ifndef SHARE_SERVICES_MEMBASELINE_HPP
-#define SHARE_SERVICES_MEMBASELINE_HPP
+#ifndef SHARE_NMT_MEMBASELINE_HPP
+#define SHARE_NMT_MEMBASELINE_HPP
#include "memory/metaspaceStats.hpp"
+#include "nmt/mallocSiteTable.hpp"
+#include "nmt/mallocTracker.hpp"
+#include "nmt/nmtCommon.hpp"
+#include "nmt/virtualMemoryTracker.hpp"
#include "runtime/mutex.hpp"
-#include "services/mallocSiteTable.hpp"
-#include "services/mallocTracker.hpp"
-#include "services/nmtCommon.hpp"
-#include "services/virtualMemoryTracker.hpp"
#include "utilities/linkedlist.hpp"
typedef LinkedListIterator MallocSiteIterator;
@@ -212,4 +212,4 @@ class MemBaseline {
void virtual_memory_sites_to_reservation_site_order();
};
-#endif // SHARE_SERVICES_MEMBASELINE_HPP
+#endif // SHARE_NMT_MEMBASELINE_HPP
diff --git a/src/hotspot/share/services/memReporter.cpp b/src/hotspot/share/nmt/memReporter.cpp
similarity index 99%
rename from src/hotspot/share/services/memReporter.cpp
rename to src/hotspot/share/nmt/memReporter.cpp
index 235ce96dba7fe..48470478b9bb8 100644
--- a/src/hotspot/share/services/memReporter.cpp
+++ b/src/hotspot/share/nmt/memReporter.cpp
@@ -26,10 +26,10 @@
#include "memory/allocation.hpp"
#include "memory/metaspace.hpp"
#include "memory/metaspaceUtils.hpp"
-#include "services/mallocTracker.hpp"
-#include "services/memReporter.hpp"
-#include "services/threadStackTracker.hpp"
-#include "services/virtualMemoryTracker.hpp"
+#include "nmt/mallocTracker.hpp"
+#include "nmt/memReporter.hpp"
+#include "nmt/threadStackTracker.hpp"
+#include "nmt/virtualMemoryTracker.hpp"
#include "utilities/globalDefinitions.hpp"
// Diff two counters, express them as signed, with range checks
diff --git a/src/hotspot/share/services/memReporter.hpp b/src/hotspot/share/nmt/memReporter.hpp
similarity index 97%
rename from src/hotspot/share/services/memReporter.hpp
rename to src/hotspot/share/nmt/memReporter.hpp
index b9e31d4bc4bee..875f5b1d45334 100644
--- a/src/hotspot/share/services/memReporter.hpp
+++ b/src/hotspot/share/nmt/memReporter.hpp
@@ -22,15 +22,15 @@
*
*/
-#ifndef SHARE_SERVICES_MEMREPORTER_HPP
-#define SHARE_SERVICES_MEMREPORTER_HPP
+#ifndef SHARE_NMT_MEMREPORTER_HPP
+#define SHARE_NMT_MEMREPORTER_HPP
#include "memory/metaspace.hpp"
+#include "nmt/mallocTracker.hpp"
+#include "nmt/memBaseline.hpp"
+#include "nmt/nmtCommon.hpp"
+#include "nmt/virtualMemoryTracker.hpp"
#include "oops/instanceKlass.hpp"
-#include "services/memBaseline.hpp"
-#include "services/nmtCommon.hpp"
-#include "services/mallocTracker.hpp"
-#include "services/virtualMemoryTracker.hpp"
/*
* Base class that provides helpers
@@ -265,4 +265,4 @@ class MemDetailDiffReporter : public MemSummaryDiffReporter {
size_t current_committed, size_t early_reserved, size_t early_committed, MEMFLAGS flag) const;
};
-#endif // SHARE_SERVICES_MEMREPORTER_HPP
+#endif // SHARE_NMT_MEMREPORTER_HPP
diff --git a/src/hotspot/share/services/memTracker.cpp b/src/hotspot/share/nmt/memTracker.cpp
similarity index 95%
rename from src/hotspot/share/services/memTracker.cpp
rename to src/hotspot/share/nmt/memTracker.cpp
index fa2f78abc43f0..192be9ecc1dd3 100644
--- a/src/hotspot/share/services/memTracker.cpp
+++ b/src/hotspot/share/nmt/memTracker.cpp
@@ -27,19 +27,19 @@
#include "logging/log.hpp"
#include "logging/logStream.hpp"
#include "memory/metaspaceUtils.hpp"
+#include "nmt/mallocTracker.hpp"
+#include "nmt/memBaseline.hpp"
+#include "nmt/memReporter.hpp"
+#include "nmt/memTracker.hpp"
+#include "nmt/nmtCommon.hpp"
+#include "nmt/nmtPreInit.hpp"
+#include "nmt/threadStackTracker.hpp"
#include "runtime/atomic.hpp"
#include "runtime/globals.hpp"
#include "runtime/orderAccess.hpp"
-#include "runtime/vmThread.hpp"
#include "runtime/vmOperations.hpp"
-#include "services/memBaseline.hpp"
-#include "services/memReporter.hpp"
+#include "runtime/vmThread.hpp"
#include "services/mallocLimit.hpp"
-#include "services/mallocTracker.hpp"
-#include "services/memTracker.hpp"
-#include "services/nmtCommon.hpp"
-#include "services/nmtPreInit.hpp"
-#include "services/threadStackTracker.hpp"
#include "utilities/debug.hpp"
#include "utilities/defaultStream.hpp"
#include "utilities/vmError.hpp"
diff --git a/src/hotspot/share/services/memTracker.hpp b/src/hotspot/share/nmt/memTracker.hpp
similarity index 96%
rename from src/hotspot/share/services/memTracker.hpp
rename to src/hotspot/share/nmt/memTracker.hpp
index fb687c202b028..a863c45a65854 100644
--- a/src/hotspot/share/services/memTracker.hpp
+++ b/src/hotspot/share/nmt/memTracker.hpp
@@ -22,15 +22,15 @@
*
*/
-#ifndef SHARE_SERVICES_MEMTRACKER_HPP
-#define SHARE_SERVICES_MEMTRACKER_HPP
+#ifndef SHARE_NMT_MEMTRACKER_HPP
+#define SHARE_NMT_MEMTRACKER_HPP
+#include "nmt/mallocTracker.hpp"
+#include "nmt/nmtCommon.hpp"
+#include "nmt/threadStackTracker.hpp"
+#include "nmt/virtualMemoryTracker.hpp"
#include "runtime/mutexLocker.hpp"
#include "runtime/threadCritical.hpp"
-#include "services/mallocTracker.hpp"
-#include "services/nmtCommon.hpp"
-#include "services/threadStackTracker.hpp"
-#include "services/virtualMemoryTracker.hpp"
#include "utilities/debug.hpp"
#include "utilities/nativeCallStack.hpp"
@@ -250,4 +250,4 @@ class MemTracker : AllStatic {
static Mutex* _query_lock;
};
-#endif // SHARE_SERVICES_MEMTRACKER_HPP
+#endif // SHARE_NMT_MEMTRACKER_HPP
diff --git a/src/hotspot/share/services/memTracker.inline.hpp b/src/hotspot/share/nmt/memTracker.inline.hpp
similarity index 85%
rename from src/hotspot/share/services/memTracker.inline.hpp
rename to src/hotspot/share/nmt/memTracker.inline.hpp
index 6c08f1154d0e5..500f2a75d8cf7 100644
--- a/src/hotspot/share/services/memTracker.inline.hpp
+++ b/src/hotspot/share/nmt/memTracker.inline.hpp
@@ -23,11 +23,12 @@
*
*/
-#ifndef SHARE_SERVICES_MEMTRACKER_INLINE_HPP
-#define SHARE_SERVICES_MEMTRACKER_INLINE_HPP
+#ifndef SHARE_NMT_MEMTRACKER_INLINE_HPP
+#define SHARE_NMT_MEMTRACKER_INLINE_HPP
-#include "services/mallocTracker.inline.hpp"
-#include "services/memTracker.hpp"
+#include "nmt/memTracker.hpp"
+
+#include "nmt/mallocTracker.inline.hpp"
inline bool MemTracker::check_exceeds_limit(size_t s, MEMFLAGS f) {
if (!enabled()) {
@@ -36,4 +37,4 @@ inline bool MemTracker::check_exceeds_limit(size_t s, MEMFLAGS f) {
return MallocTracker::check_exceeds_limit(s, f);
}
-#endif // SHARE_SERVICES_MEMTRACKER_INLINE_HPP
+#endif // SHARE_NMT_MEMTRACKER_INLINE_HPP
diff --git a/src/hotspot/share/services/nmtCommon.cpp b/src/hotspot/share/nmt/nmtCommon.cpp
similarity index 98%
rename from src/hotspot/share/services/nmtCommon.cpp
rename to src/hotspot/share/nmt/nmtCommon.cpp
index 53d9daa5b5269..dadb830f29182 100644
--- a/src/hotspot/share/services/nmtCommon.cpp
+++ b/src/hotspot/share/nmt/nmtCommon.cpp
@@ -22,7 +22,7 @@
*
*/
#include "precompiled.hpp"
-#include "services/nmtCommon.hpp"
+#include "nmt/nmtCommon.hpp"
#include "utilities/globalDefinitions.hpp"
STATIC_ASSERT(NMT_off > NMT_unknown);
diff --git a/src/hotspot/share/services/nmtCommon.hpp b/src/hotspot/share/nmt/nmtCommon.hpp
similarity index 97%
rename from src/hotspot/share/services/nmtCommon.hpp
rename to src/hotspot/share/nmt/nmtCommon.hpp
index 71a48f656d084..4dafaed04ce0e 100644
--- a/src/hotspot/share/services/nmtCommon.hpp
+++ b/src/hotspot/share/nmt/nmtCommon.hpp
@@ -24,8 +24,8 @@
*
*/
-#ifndef SHARE_SERVICES_NMTCOMMON_HPP
-#define SHARE_SERVICES_NMTCOMMON_HPP
+#ifndef SHARE_NMT_NMTCOMMON_HPP
+#define SHARE_NMT_NMTCOMMON_HPP
#include "memory/allocation.hpp" // for MEMFLAGS only
#include "utilities/align.hpp"
@@ -139,4 +139,4 @@ class NMTUtil : AllStatic {
};
-#endif // SHARE_SERVICES_NMTCOMMON_HPP
+#endif // SHARE_NMT_NMTCOMMON_HPP
diff --git a/src/hotspot/share/services/nmtDCmd.cpp b/src/hotspot/share/nmt/nmtDCmd.cpp
similarity index 98%
rename from src/hotspot/share/services/nmtDCmd.cpp
rename to src/hotspot/share/nmt/nmtDCmd.cpp
index d6f80613b37c3..80b2ed6141aaf 100644
--- a/src/hotspot/share/services/nmtDCmd.cpp
+++ b/src/hotspot/share/nmt/nmtDCmd.cpp
@@ -23,12 +23,12 @@
*/
#include "precompiled.hpp"
#include "memory/resourceArea.hpp"
+#include "nmt/memReporter.hpp"
+#include "nmt/memTracker.hpp"
+#include "nmt/nmtDCmd.hpp"
#include "runtime/mutexLocker.hpp"
-#include "runtime/vmThread.hpp"
#include "runtime/vmOperations.hpp"
-#include "services/nmtDCmd.hpp"
-#include "services/memReporter.hpp"
-#include "services/memTracker.hpp"
+#include "runtime/vmThread.hpp"
#include "utilities/globalDefinitions.hpp"
NMTDCmd::NMTDCmd(outputStream* output,
diff --git a/src/hotspot/share/services/nmtDCmd.hpp b/src/hotspot/share/nmt/nmtDCmd.hpp
similarity index 92%
rename from src/hotspot/share/services/nmtDCmd.hpp
rename to src/hotspot/share/nmt/nmtDCmd.hpp
index 9a06abb91441f..c70d17a481fb4 100644
--- a/src/hotspot/share/services/nmtDCmd.hpp
+++ b/src/hotspot/share/nmt/nmtDCmd.hpp
@@ -22,13 +22,13 @@
*
*/
-#ifndef SHARE_SERVICES_NMTDCMD_HPP
-#define SHARE_SERVICES_NMTDCMD_HPP
+#ifndef SHARE_NMT_NMTDCMD_HPP
+#define SHARE_NMT_NMTDCMD_HPP
+#include "nmt/mallocTracker.hpp"
+#include "nmt/memBaseline.hpp"
#include "services/diagnosticArgument.hpp"
#include "services/diagnosticFramework.hpp"
-#include "services/memBaseline.hpp"
-#include "services/mallocTracker.hpp"
/**
* Native memory tracking DCmd implementation
@@ -70,4 +70,4 @@ class NMTDCmd: public DCmdWithParser {
bool check_detail_tracking_level(outputStream* out);
};
-#endif // SHARE_SERVICES_NMTDCMD_HPP
+#endif // SHARE_NMT_NMTDCMD_HPP
diff --git a/src/hotspot/share/services/nmtPreInit.cpp b/src/hotspot/share/nmt/nmtPreInit.cpp
similarity index 99%
rename from src/hotspot/share/services/nmtPreInit.cpp
rename to src/hotspot/share/nmt/nmtPreInit.cpp
index 35aec38a6f45a..a8ff18f3b62b2 100644
--- a/src/hotspot/share/services/nmtPreInit.cpp
+++ b/src/hotspot/share/nmt/nmtPreInit.cpp
@@ -24,12 +24,12 @@
*/
#include "precompiled.hpp"
+#include "nmt/nmtPreInit.hpp"
#include "runtime/os.hpp"
-#include "services/nmtPreInit.hpp"
#include "utilities/align.hpp"
#include "utilities/debug.hpp"
-#include "utilities/ostream.hpp"
#include "utilities/globalDefinitions.hpp"
+#include "utilities/ostream.hpp"
// Obviously we cannot use os::malloc for any dynamic allocation during pre-NMT-init, so we must use
// raw malloc; to make this very clear, wrap them.
diff --git a/src/hotspot/share/services/nmtPreInit.hpp b/src/hotspot/share/nmt/nmtPreInit.hpp
similarity index 98%
rename from src/hotspot/share/services/nmtPreInit.hpp
rename to src/hotspot/share/nmt/nmtPreInit.hpp
index 7705c5180d38c..38a34616b3f38 100644
--- a/src/hotspot/share/services/nmtPreInit.hpp
+++ b/src/hotspot/share/nmt/nmtPreInit.hpp
@@ -23,18 +23,17 @@
*
*/
-#ifndef SHARE_SERVICES_NMT_PREINIT_HPP
-#define SHARE_SERVICES_NMT_PREINIT_HPP
+#ifndef SHARE_NMT_NMT_PREINIT_HPP
+#define SHARE_NMT_NMT_PREINIT_HPP
#include "memory/allStatic.hpp"
-#ifdef ASSERT
-#include "runtime/atomic.hpp"
-#endif
-#include "services/memTracker.hpp"
-#include "utilities/checkedCast.hpp"
+#include "nmt/memTracker.hpp"
#include "utilities/debug.hpp"
#include "utilities/globalDefinitions.hpp"
#include "utilities/macros.hpp"
+#ifdef ASSERT
+#include "runtime/atomic.hpp"
+#endif
class outputStream;
@@ -378,5 +377,5 @@ class NMTPreInit : public AllStatic {
DEBUG_ONLY(static void verify();)
};
-#endif // SHARE_SERVICES_NMT_PREINIT_HPP
+#endif // SHARE_NMT_NMT_PREINIT_HPP
diff --git a/src/hotspot/share/services/nmtUsage.cpp b/src/hotspot/share/nmt/nmtUsage.cpp
similarity index 95%
rename from src/hotspot/share/services/nmtUsage.cpp
rename to src/hotspot/share/nmt/nmtUsage.cpp
index 03229ce417157..a00b3cdc90df3 100644
--- a/src/hotspot/share/services/nmtUsage.cpp
+++ b/src/hotspot/share/nmt/nmtUsage.cpp
@@ -23,12 +23,12 @@
*/
#include "precompiled.hpp"
+#include "nmt/mallocTracker.hpp"
+#include "nmt/nmtCommon.hpp"
+#include "nmt/nmtUsage.hpp"
+#include "nmt/threadStackTracker.hpp"
+#include "nmt/virtualMemoryTracker.hpp"
#include "runtime/threadCritical.hpp"
-#include "services/nmtCommon.hpp"
-#include "services/nmtUsage.hpp"
-#include "services/mallocTracker.hpp"
-#include "services/threadStackTracker.hpp"
-#include "services/virtualMemoryTracker.hpp"
// Enabled all options for snapshot.
const NMTUsageOptions NMTUsage::OptionsAll = { true, true, true };
diff --git a/src/hotspot/share/services/nmtUsage.hpp b/src/hotspot/share/nmt/nmtUsage.hpp
similarity index 94%
rename from src/hotspot/share/services/nmtUsage.hpp
rename to src/hotspot/share/nmt/nmtUsage.hpp
index 38b7b43913fcf..cfff59db9af85 100644
--- a/src/hotspot/share/services/nmtUsage.hpp
+++ b/src/hotspot/share/nmt/nmtUsage.hpp
@@ -22,8 +22,8 @@
*
*/
-#ifndef SHARE_SERVICES_NMTUSAGE_HPP
-#define SHARE_SERVICES_NMTUSAGE_HPP
+#ifndef SHARE_NMT_NMTUSAGE_HPP
+#define SHARE_NMT_NMTUSAGE_HPP
#include "memory/allocation.hpp"
#include "utilities/globalDefinitions.hpp"
@@ -65,4 +65,4 @@ class NMTUsage : public CHeapObj {
size_t committed(MEMFLAGS flag) const;
};
-#endif // SHARE_SERVICES_NMTUSAGE_HPP
+#endif // SHARE_NMT_NMTUSAGE_HPP
diff --git a/src/hotspot/share/services/threadStackTracker.cpp b/src/hotspot/share/nmt/threadStackTracker.cpp
similarity index 96%
rename from src/hotspot/share/services/threadStackTracker.cpp
rename to src/hotspot/share/nmt/threadStackTracker.cpp
index decacc64c5d1a..6060b636153d0 100644
--- a/src/hotspot/share/services/threadStackTracker.cpp
+++ b/src/hotspot/share/nmt/threadStackTracker.cpp
@@ -24,11 +24,11 @@
#include "precompiled.hpp"
+#include "nmt/mallocTracker.hpp"
+#include "nmt/memTracker.hpp"
+#include "nmt/threadStackTracker.hpp"
+#include "nmt/virtualMemoryTracker.hpp"
#include "runtime/threadCritical.hpp"
-#include "services/mallocTracker.hpp"
-#include "services/memTracker.hpp"
-#include "services/virtualMemoryTracker.hpp"
-#include "services/threadStackTracker.hpp"
volatile size_t ThreadStackTracker::_thread_count = 0;
SortedLinkedList* ThreadStackTracker::_simple_thread_stacks = nullptr;
diff --git a/src/hotspot/share/services/threadStackTracker.hpp b/src/hotspot/share/nmt/threadStackTracker.hpp
similarity index 92%
rename from src/hotspot/share/services/threadStackTracker.hpp
rename to src/hotspot/share/nmt/threadStackTracker.hpp
index db7fc0e8569f4..6e2ec361954ba 100644
--- a/src/hotspot/share/services/threadStackTracker.hpp
+++ b/src/hotspot/share/nmt/threadStackTracker.hpp
@@ -22,14 +22,14 @@
*
*/
-#ifndef SHARE_SERVICES_THREADSTACKTRACKER_HPP
-#define SHARE_SERVICES_THREADSTACKTRACKER_HPP
+#ifndef SHARE_NMT_THREADSTACKTRACKER_HPP
+#define SHARE_NMT_THREADSTACKTRACKER_HPP
-#include "services/allocationSite.hpp"
-#include "services/mallocSiteTable.hpp"
-#include "services/nmtCommon.hpp"
-#include "utilities/nativeCallStack.hpp"
+#include "nmt/allocationSite.hpp"
+#include "nmt/mallocSiteTable.hpp"
+#include "nmt/nmtCommon.hpp"
#include "utilities/linkedlist.hpp"
+#include "utilities/nativeCallStack.hpp"
class SimpleThreadStackSite : public AllocationSite {
const address _base;
@@ -82,5 +82,5 @@ class ThreadStackTracker : AllStatic {
static bool walk_simple_thread_stack_site(MallocSiteWalker* walker);
};
-#endif // SHARE_SERVICES_THREADSTACKTRACKER_HPP
+#endif // SHARE_NMT_THREADSTACKTRACKER_HPP
diff --git a/src/hotspot/share/services/virtualMemoryTracker.cpp b/src/hotspot/share/nmt/virtualMemoryTracker.cpp
similarity index 99%
rename from src/hotspot/share/services/virtualMemoryTracker.cpp
rename to src/hotspot/share/nmt/virtualMemoryTracker.cpp
index ebb32ecbeebc3..65bd9afa2d661 100644
--- a/src/hotspot/share/services/virtualMemoryTracker.cpp
+++ b/src/hotspot/share/nmt/virtualMemoryTracker.cpp
@@ -23,13 +23,13 @@
*/
#include "precompiled.hpp"
#include "logging/log.hpp"
-#include "memory/metaspaceUtils.hpp"
#include "memory/metaspaceStats.hpp"
+#include "memory/metaspaceUtils.hpp"
+#include "nmt/memTracker.hpp"
+#include "nmt/threadStackTracker.hpp"
+#include "nmt/virtualMemoryTracker.hpp"
#include "runtime/os.hpp"
#include "runtime/threadCritical.hpp"
-#include "services/memTracker.hpp"
-#include "services/threadStackTracker.hpp"
-#include "services/virtualMemoryTracker.hpp"
#include "utilities/ostream.hpp"
size_t VirtualMemorySummary::_snapshot[CALC_OBJ_SIZE_IN_TYPE(VirtualMemorySnapshot, size_t)];
diff --git a/src/hotspot/share/services/virtualMemoryTracker.hpp b/src/hotspot/share/nmt/virtualMemoryTracker.hpp
similarity index 98%
rename from src/hotspot/share/services/virtualMemoryTracker.hpp
rename to src/hotspot/share/nmt/virtualMemoryTracker.hpp
index 172c3cc7d0cb0..b6f89c278ce15 100644
--- a/src/hotspot/share/services/virtualMemoryTracker.hpp
+++ b/src/hotspot/share/nmt/virtualMemoryTracker.hpp
@@ -22,19 +22,18 @@
*
*/
-#ifndef SHARE_SERVICES_VIRTUALMEMORYTRACKER_HPP
-#define SHARE_SERVICES_VIRTUALMEMORYTRACKER_HPP
+#ifndef SHARE_NMT_VIRTUALMEMORYTRACKER_HPP
+#define SHARE_NMT_VIRTUALMEMORYTRACKER_HPP
#include "memory/allocation.hpp"
#include "memory/metaspace.hpp" // For MetadataType
#include "memory/metaspaceStats.hpp"
-#include "services/allocationSite.hpp"
-#include "services/nmtCommon.hpp"
+#include "nmt/allocationSite.hpp"
+#include "nmt/nmtCommon.hpp"
#include "utilities/linkedlist.hpp"
#include "utilities/nativeCallStack.hpp"
#include "utilities/ostream.hpp"
-
/*
* Virtual memory counter
*/
@@ -413,5 +412,5 @@ class VirtualMemoryTracker : AllStatic {
static SortedLinkedList* _reserved_regions;
};
-#endif // SHARE_SERVICES_VIRTUALMEMORYTRACKER_HPP
+#endif // SHARE_NMT_VIRTUALMEMORYTRACKER_HPP
diff --git a/src/hotspot/share/oops/method.cpp b/src/hotspot/share/oops/method.cpp
index 003f47b1e9c50..c408bc23be7c7 100644
--- a/src/hotspot/share/oops/method.cpp
+++ b/src/hotspot/share/oops/method.cpp
@@ -41,14 +41,15 @@
#include "interpreter/interpreter.hpp"
#include "interpreter/oopMapCache.hpp"
#include "logging/log.hpp"
-#include "logging/logTag.hpp"
#include "logging/logStream.hpp"
+#include "logging/logTag.hpp"
#include "memory/allocation.inline.hpp"
#include "memory/metadataFactory.hpp"
#include "memory/metaspaceClosure.hpp"
#include "memory/oopFactory.hpp"
#include "memory/resourceArea.hpp"
#include "memory/universe.hpp"
+#include "nmt/memTracker.hpp"
#include "oops/constMethod.hpp"
#include "oops/constantPool.hpp"
#include "oops/klass.inline.hpp"
@@ -72,7 +73,6 @@
#include "runtime/sharedRuntime.hpp"
#include "runtime/signature.hpp"
#include "runtime/vm_version.hpp"
-#include "services/memTracker.hpp"
#include "utilities/align.hpp"
#include "utilities/quickSort.hpp"
#include "utilities/vmError.hpp"
diff --git a/src/hotspot/share/opto/library_call.cpp b/src/hotspot/share/opto/library_call.cpp
index 4a9d7fb161667..62d785809531e 100644
--- a/src/hotspot/share/opto/library_call.cpp
+++ b/src/hotspot/share/opto/library_call.cpp
@@ -5367,8 +5367,6 @@ void LibraryCallKit::create_new_uncommon_trap(CallStaticJavaNode* uncommon_trap_
//------------------------------inline_array_partition-----------------------
bool LibraryCallKit::inline_array_partition() {
- const char *stubName = "array_partition_stub";
-
Node* elementType = null_check(argument(0));
Node* obj = argument(1);
Node* offset = argument(2);
@@ -5377,38 +5375,48 @@ bool LibraryCallKit::inline_array_partition() {
Node* indexPivot1 = argument(6);
Node* indexPivot2 = argument(7);
- const TypeInstPtr* elem_klass = gvn().type(elementType)->isa_instptr();
- ciType* elem_type = elem_klass->const_oop()->as_instance()->java_mirror_type();
- BasicType bt = elem_type->basic_type();
- address stubAddr = nullptr;
- stubAddr = StubRoutines::select_array_partition_function();
- // stub not loaded
- if (stubAddr == nullptr) {
- return false;
- }
- // get the address of the array
- const TypeAryPtr* obj_t = _gvn.type(obj)->isa_aryptr();
- if (obj_t == nullptr || obj_t->elem() == Type::BOTTOM ) {
- return false; // failed input validation
- }
- Node* obj_adr = make_unsafe_address(obj, offset);
+ Node* pivotIndices = nullptr;
- // create the pivotIndices array of type int and size = 2
- Node* size = intcon(2);
- Node* klass_node = makecon(TypeKlassPtr::make(ciTypeArrayKlass::make(T_INT)));
- Node* pivotIndices = new_array(klass_node, size, 0); // no arguments to push
- AllocateArrayNode* alloc = tightly_coupled_allocation(pivotIndices);
- guarantee(alloc != nullptr, "created above");
- Node* pivotIndices_adr = basic_plus_adr(pivotIndices, arrayOopDesc::base_offset_in_bytes(T_INT));
+ // Set the original stack and the reexecute bit for the interpreter to reexecute
+ // the bytecode that invokes DualPivotQuicksort.partition() if deoptimization happens.
+ { PreserveReexecuteState preexecs(this);
+ jvms()->set_should_reexecute(true);
- // pass the basic type enum to the stub
- Node* elemType = intcon(bt);
+ const TypeInstPtr* elem_klass = gvn().type(elementType)->isa_instptr();
+ ciType* elem_type = elem_klass->const_oop()->as_instance()->java_mirror_type();
+ BasicType bt = elem_type->basic_type();
+ address stubAddr = nullptr;
+ stubAddr = StubRoutines::select_array_partition_function();
+ // stub not loaded
+ if (stubAddr == nullptr) {
+ return false;
+ }
+ // get the address of the array
+ const TypeAryPtr* obj_t = _gvn.type(obj)->isa_aryptr();
+ if (obj_t == nullptr || obj_t->elem() == Type::BOTTOM ) {
+ return false; // failed input validation
+ }
+ Node* obj_adr = make_unsafe_address(obj, offset);
- // Call the stub
- make_runtime_call(RC_LEAF|RC_NO_FP, OptoRuntime::array_partition_Type(),
- stubAddr, stubName, TypePtr::BOTTOM,
- obj_adr, elemType, fromIndex, toIndex, pivotIndices_adr,
- indexPivot1, indexPivot2);
+ // create the pivotIndices array of type int and size = 2
+ Node* size = intcon(2);
+ Node* klass_node = makecon(TypeKlassPtr::make(ciTypeArrayKlass::make(T_INT)));
+ pivotIndices = new_array(klass_node, size, 0); // no arguments to push
+ AllocateArrayNode* alloc = tightly_coupled_allocation(pivotIndices);
+ guarantee(alloc != nullptr, "created above");
+ Node* pivotIndices_adr = basic_plus_adr(pivotIndices, arrayOopDesc::base_offset_in_bytes(T_INT));
+
+ // pass the basic type enum to the stub
+ Node* elemType = intcon(bt);
+
+ // Call the stub
+ const char *stubName = "array_partition_stub";
+ make_runtime_call(RC_LEAF|RC_NO_FP, OptoRuntime::array_partition_Type(),
+ stubAddr, stubName, TypePtr::BOTTOM,
+ obj_adr, elemType, fromIndex, toIndex, pivotIndices_adr,
+ indexPivot1, indexPivot2);
+
+ } // original reexecute is set back here
if (!stopped()) {
set_result(pivotIndices);
@@ -5421,9 +5429,6 @@ bool LibraryCallKit::inline_array_partition() {
//------------------------------inline_array_sort-----------------------
bool LibraryCallKit::inline_array_sort() {
- const char *stubName;
- stubName = "arraysort_stub";
-
Node* elementType = null_check(argument(0));
Node* obj = argument(1);
Node* offset = argument(2);
@@ -5451,6 +5456,7 @@ bool LibraryCallKit::inline_array_sort() {
Node* elemType = intcon(bt);
// Call the stub.
+ const char *stubName = "arraysort_stub";
make_runtime_call(RC_LEAF|RC_NO_FP, OptoRuntime::array_sort_Type(),
stubAddr, stubName, TypePtr::BOTTOM,
obj_adr, elemType, fromIndex, toIndex);
diff --git a/src/hotspot/share/opto/replacednodes.cpp b/src/hotspot/share/opto/replacednodes.cpp
index 78c1703799e5e..56c5ee1c0bfb7 100644
--- a/src/hotspot/share/opto/replacednodes.cpp
+++ b/src/hotspot/share/opto/replacednodes.cpp
@@ -106,88 +106,175 @@ void ReplacedNodes::apply(Node* n, uint idx) {
}
}
-static void enqueue_use(Node* n, Node* use, Unique_Node_List& work) {
- if (use->is_Phi()) {
- Node* r = use->in(0);
- assert(r->is_Region(), "Phi should have Region");
- for (uint i = 1; i < use->req(); i++) {
- if (use->in(i) == n) {
- work.push(r->in(i));
- }
- }
- } else {
- work.push(use);
- }
-}
-
// Perform node replacement following late inlining.
void ReplacedNodes::apply(Compile* C, Node* ctl) {
// ctl is the control on exit of the method that was late inlined
if (is_empty()) {
return;
}
+ ResourceMark rm;
+ Node_Stack stack(0);
+ Unique_Node_List to_fix; // nodes to clone + uses at the end of the chain that need to updated
+ VectorSet seen;
+ VectorSet valid_control;
+
for (int i = 0; i < _replaced_nodes->length(); i++) {
ReplacedNode replaced = _replaced_nodes->at(i);
Node* initial = replaced.initial();
Node* improved = replaced.improved();
assert (ctl != nullptr && !ctl->is_top(), "replaced node should have actual control");
- ResourceMark rm;
- Unique_Node_List work;
- // Go over all the uses of the node that is considered for replacement...
- for (DUIterator j = initial->outs(); initial->has_out(j); j++) {
- Node* use = initial->out(j);
+ if (initial->outcnt() == 0) {
+ continue;
+ }
- if (use == improved || use->outcnt() == 0) {
- continue;
- }
- work.clear();
- enqueue_use(initial, use, work);
- bool replace = true;
- // Check that this use is dominated by ctl. Go ahead with the replacement if it is.
- while (work.size() != 0 && replace) {
- Node* n = work.pop();
- if (use->outcnt() == 0) {
- continue;
+ // Find uses of initial that are dominated by ctl so, initial can be replaced by improved.
+ // Proving domination here is not straightforward. To do so, we follow uses of initial, and uses of uses until we
+ // encounter a node which is a control node or is pinned at some control. Then, we try to prove this control is
+ // dominated by ctl. If that's the case, it's legal to replace initial by improved but for this chain of uses only.
+ // It may not be the case for some other chain of uses, so we clone that chain and perform the replacement only for
+ // these uses.
+ assert(stack.is_empty(), "");
+ stack.push(initial, 1);
+ Node* use = initial->raw_out(0);
+ stack.push(use, 0);
+
+ while (!stack.is_empty()) {
+ assert(stack.size() > 1, "at least initial + one use");
+ Node* n = stack.node();
+
+ uint current_size = stack.size();
+
+ if (seen.test_set(n->_idx)) {
+ if (to_fix.member(n)) {
+ collect_nodes_to_clone(stack, to_fix);
}
- if (n->is_CFG() || (n->in(0) != nullptr && !n->in(0)->is_top())) {
- // Skip projections, since some of the multi nodes aren't CFG (e.g., LoadStore and SCMemProj).
- if (n->is_Proj()) {
- n = n->in(0);
+ } else if (n->outcnt() != 0 && n != improved) {
+ if (n->is_Phi()) {
+ Node* region = n->in(0);
+ Node* prev = stack.node_at(stack.size() - 2);
+ for (uint j = 1; j < region->req(); ++j) {
+ if (n->in(j) == prev) {
+ Node* in = region->in(j);
+ if (in != nullptr && !in->is_top()) {
+ if (is_dominator(ctl, in)) {
+ valid_control.set(in->_idx);
+ collect_nodes_to_clone(stack, to_fix);
+ }
+ }
+ }
}
- if (!n->is_CFG()) {
- n = n->in(0);
+ } else if (n->is_CFG()) {
+ if (is_dominator(ctl, n)) {
+ collect_nodes_to_clone(stack, to_fix);
}
- assert(n->is_CFG(), "should be CFG now");
- int depth = 0;
- while(n != ctl) {
- n = IfNode::up_one_dom(n);
- depth++;
- // limit search depth
- if (depth >= 100 || n == nullptr) {
- replace = false;
- break;
- }
+ } else if (n->in(0) != nullptr && n->in(0)->is_CFG()) {
+ Node* c = n->in(0);
+ if (is_dominator(ctl, c)) {
+ collect_nodes_to_clone(stack, to_fix);
}
} else {
- for (DUIterator k = n->outs(); n->has_out(k); k++) {
- enqueue_use(n, n->out(k), work);
+ uint idx = stack.index();
+ if (idx < n->outcnt()) {
+ stack.set_index(idx + 1);
+ stack.push(n->raw_out(idx), 0);
}
}
}
- if (replace) {
- bool is_in_table = C->initial_gvn()->hash_delete(use);
- int replaced = use->replace_edge(initial, improved);
- if (is_in_table) {
- C->initial_gvn()->hash_find_insert(use);
+ if (stack.size() == current_size) {
+ for (;;) {
+ stack.pop();
+ if (stack.is_empty()) {
+ break;
+ }
+ n = stack.node();
+ uint idx = stack.index();
+ if (idx < n->outcnt()) {
+ stack.set_index(idx + 1);
+ stack.push(n->raw_out(idx), 0);
+ break;
+ }
}
- C->record_for_igvn(use);
+ }
+ }
+ }
+ if (to_fix.size() > 0) {
+ uint hash_table_size = _replaced_nodes->length();
+ for (uint i = 0; i < to_fix.size(); ++i) {
+ Node* n = to_fix.at(i);
+ if (n->is_CFG() || n->in(0) != nullptr) { // End of a chain is not cloned
+ continue;
+ }
+ hash_table_size++;
+ }
+ // Map from current node to cloned/replaced node
+ ResizeableResourceHashtable clones(hash_table_size, hash_table_size);
+ // Record mapping from initial to improved nodes
+ for (int i = 0; i < _replaced_nodes->length(); i++) {
+ ReplacedNode replaced = _replaced_nodes->at(i);
+ Node* initial = replaced.initial();
+ Node* improved = replaced.improved();
+ clones.put(initial, improved);
+ // If initial needs to be cloned but is also improved then there's no need to clone it.
+ if (to_fix.member(initial)) {
+ to_fix.remove(initial);
+ }
+ }
- assert(replaced > 0, "inconsistent");
- --j;
+ // Clone nodes and record mapping from current to cloned nodes
+ for (uint i = 0; i < to_fix.size(); ++i) {
+ Node* n = to_fix.at(i);
+ if (n->is_CFG() || n->in(0) != nullptr) { // End of a chain
+ continue;
}
+ Node* clone = n->clone();
+ bool added = clones.put(n, clone);
+ assert(added, "clone node must be added to mapping");
+ C->initial_gvn()->set_type_bottom(clone);
+ to_fix.map(i, clone); // Update list of nodes with cloned node
+ }
+
+ // Fix edges in cloned nodes and use at the end of the chain
+ for (uint i = 0; i < to_fix.size(); ++i) {
+ Node* n = to_fix.at(i);
+ bool is_in_table = C->initial_gvn()->hash_delete(n);
+ uint updates = 0;
+ for (uint j = 0; j < n->req(); ++j) {
+ Node* in = n->in(j);
+ if (in == nullptr || (n->is_Phi() && n->in(0)->in(j) == nullptr)) {
+ continue;
+ }
+ if (n->is_Phi() && !valid_control.test(n->in(0)->in(j)->_idx)) {
+ continue;
+ }
+ Node** clone_ptr = clones.get(in);
+ if (clone_ptr != nullptr) {
+ Node* clone = *clone_ptr;
+ n->set_req(j, clone);
+ updates++;
+ }
+ }
+ assert(updates > 0, "");
+ C->record_for_igvn(n);
+ if (is_in_table) {
+ C->initial_gvn()->hash_find_insert(n);
+ }
+ }
+ }
+}
+
+bool ReplacedNodes::is_dominator(const Node* ctl, Node* n) const {
+ assert(n->is_CFG(), "should be CFG now");
+ int depth = 0;
+ while (n != ctl) {
+ n = IfNode::up_one_dom(n);
+ depth++;
+ // limit search depth
+ if (depth >= 100 || n == nullptr) {
+ return false;
}
}
+ return true;
}
void ReplacedNodes::dump(outputStream *st) const {
@@ -224,3 +311,10 @@ void ReplacedNodes::merge_with(const ReplacedNodes& other) {
_replaced_nodes->trunc_to(len - shift);
}
}
+
+void ReplacedNodes::collect_nodes_to_clone(const Node_Stack& stack, Unique_Node_List& to_fix) {
+ for (uint i = stack.size() - 1; i >= 1; i--) {
+ Node* n = stack.node_at(i);
+ to_fix.push(n);
+ }
+}
diff --git a/src/hotspot/share/opto/replacednodes.hpp b/src/hotspot/share/opto/replacednodes.hpp
index c569e55ce5ff2..9b66a2c5f49b8 100644
--- a/src/hotspot/share/opto/replacednodes.hpp
+++ b/src/hotspot/share/opto/replacednodes.hpp
@@ -76,6 +76,10 @@ class ReplacedNodes {
bool is_empty() const;
void dump(outputStream *st) const;
void apply(Compile* C, Node* ctl);
+
+ bool is_dominator(const Node* ctl, Node* n) const;
+
+ void collect_nodes_to_clone(const Node_Stack& stack, Unique_Node_List& to_fix);
};
#endif // SHARE_OPTO_REPLACEDNODES_HPP
diff --git a/src/hotspot/share/precompiled/precompiled.hpp b/src/hotspot/share/precompiled/precompiled.hpp
index c6b8668010ed3..c53a78de87bca 100644
--- a/src/hotspot/share/precompiled/precompiled.hpp
+++ b/src/hotspot/share/precompiled/precompiled.hpp
@@ -42,6 +42,7 @@
#include "memory/memRegion.hpp"
#include "memory/resourceArea.hpp"
#include "memory/universe.hpp"
+#include "nmt/memTracker.hpp"
#include "oops/instanceKlass.hpp"
#include "oops/klass.hpp"
#include "oops/method.hpp"
@@ -57,7 +58,6 @@
#include "runtime/orderAccess.hpp"
#include "runtime/os.hpp"
#include "runtime/timer.hpp"
-#include "services/memTracker.hpp"
#include "utilities/align.hpp"
#include "utilities/bitMap.hpp"
#include "utilities/copy.hpp"
diff --git a/src/hotspot/share/prims/jni.cpp b/src/hotspot/share/prims/jni.cpp
index 2d73feba6137c..33dcfb6c3fe5e 100644
--- a/src/hotspot/share/prims/jni.cpp
+++ b/src/hotspot/share/prims/jni.cpp
@@ -52,6 +52,7 @@
#include "memory/oopFactory.hpp"
#include "memory/resourceArea.hpp"
#include "memory/universe.hpp"
+#include "nmt/memTracker.hpp"
#include "oops/access.inline.hpp"
#include "oops/arrayOop.hpp"
#include "oops/instanceKlass.inline.hpp"
@@ -88,7 +89,6 @@
#include "runtime/synchronizer.hpp"
#include "runtime/thread.inline.hpp"
#include "runtime/vmOperations.hpp"
-#include "services/memTracker.hpp"
#include "services/runtimeService.hpp"
#include "utilities/defaultStream.hpp"
#include "utilities/dtrace.hpp"
diff --git a/src/hotspot/share/prims/whitebox.cpp b/src/hotspot/share/prims/whitebox.cpp
index e86217f8de694..7afc0ea2c0c61 100644
--- a/src/hotspot/share/prims/whitebox.cpp
+++ b/src/hotspot/share/prims/whitebox.cpp
@@ -56,6 +56,8 @@
#include "memory/oopFactory.hpp"
#include "memory/resourceArea.hpp"
#include "memory/universe.hpp"
+#include "nmt/mallocSiteTable.hpp"
+#include "nmt/memTracker.hpp"
#include "oops/array.hpp"
#include "oops/compressedOops.hpp"
#include "oops/constantPool.inline.hpp"
@@ -88,9 +90,7 @@
#include "runtime/threadSMR.hpp"
#include "runtime/vframe.hpp"
#include "runtime/vm_version.hpp"
-#include "services/mallocSiteTable.hpp"
#include "services/memoryService.hpp"
-#include "services/memTracker.hpp"
#include "utilities/align.hpp"
#include "utilities/checkedCast.hpp"
#include "utilities/debug.hpp"
@@ -121,9 +121,9 @@
#include "jvmci/jvmciRuntime.hpp"
#endif
#ifdef LINUX
-#include "os_linux.hpp"
-#include "osContainer_linux.hpp"
#include "cgroupSubsystem_linux.hpp"
+#include "osContainer_linux.hpp"
+#include "os_linux.hpp"
#endif
#define CHECK_JNI_EXCEPTION_(env, value) \
@@ -381,7 +381,7 @@ WB_ENTRY(jboolean, WB_IsGCSupportedByJVMCICompiler(JNIEnv* env, jobject o, jint
if (EnableJVMCI) {
// Enter the JVMCI env that will be used by the CompileBroker.
JVMCIEnv jvmciEnv(thread, __FILE__, __LINE__);
- return jvmciEnv.runtime()->is_gc_supported(&jvmciEnv, (CollectedHeap::Name)name);
+ return jvmciEnv.init_error() == JNI_OK && jvmciEnv.runtime()->is_gc_supported(&jvmciEnv, (CollectedHeap::Name)name);
}
#endif
return false;
diff --git a/src/hotspot/share/runtime/arguments.cpp b/src/hotspot/share/runtime/arguments.cpp
index 33686a3b6e911..9b229c171c050 100644
--- a/src/hotspot/share/runtime/arguments.cpp
+++ b/src/hotspot/share/runtime/arguments.cpp
@@ -42,6 +42,7 @@
#include "logging/logStream.hpp"
#include "logging/logTag.hpp"
#include "memory/allocation.inline.hpp"
+#include "nmt/nmtCommon.hpp"
#include "oops/compressedKlass.hpp"
#include "oops/instanceKlass.hpp"
#include "oops/oop.inline.hpp"
@@ -59,7 +60,6 @@
#include "runtime/synchronizer.hpp"
#include "runtime/vm_version.hpp"
#include "services/management.hpp"
-#include "services/nmtCommon.hpp"
#include "utilities/align.hpp"
#include "utilities/checkedCast.hpp"
#include "utilities/debug.hpp"
diff --git a/src/hotspot/share/runtime/atomic.hpp b/src/hotspot/share/runtime/atomic.hpp
index c85bf9055ab39..ac0ce49d26e56 100644
--- a/src/hotspot/share/runtime/atomic.hpp
+++ b/src/hotspot/share/runtime/atomic.hpp
@@ -398,11 +398,15 @@ class Atomic : AllStatic {
T compare_value,
T exchange_value);
- // Support platforms that do not provide Read-Modify-Write
- // byte-level atomic access. To use, derive PlatformCmpxchg<1> from
- // this class.
+ // Support platforms that do not provide Read-Modify-Write atomic
+ // accesses for 1-byte and 8-byte widths. To use, derive PlatformCmpxchg<1>,
+ // PlatformAdd, PlatformXchg from these classes.
public: // Temporary, can't be private: C++03 11.4/2. Fixed by C++11.
struct CmpxchgByteUsingInt;
+ template
+ struct XchgUsingCmpxchg;
+ template
+ class AddUsingCmpxchg;
private:
// Dispatch handler for xchg. Provides type-based validity
@@ -677,6 +681,47 @@ struct Atomic::CmpxchgByteUsingInt {
atomic_memory_order order) const;
};
+// Define the class before including platform file, which may use this
+// as a base class, requiring it be complete. The definition is later
+// in this file, near the other definitions related to xchg.
+template
+struct Atomic::XchgUsingCmpxchg {
+ template
+ T operator()(T volatile* dest,
+ T exchange_value,
+ atomic_memory_order order) const;
+};
+
+// Define the class before including platform file, which may use this
+// as a base class, requiring it be complete.
+template
+class Atomic::AddUsingCmpxchg {
+public:
+ template
+ static inline D add_then_fetch(D volatile* dest,
+ I add_value,
+ atomic_memory_order order) {
+ D addend = add_value;
+ return fetch_then_add(dest, add_value, order) + add_value;
+ }
+
+ template
+ static inline D fetch_then_add(D volatile* dest,
+ I add_value,
+ atomic_memory_order order) {
+ STATIC_ASSERT(byte_size == sizeof(I));
+ STATIC_ASSERT(byte_size == sizeof(D));
+
+ D old_value;
+ D new_value;
+ do {
+ old_value = Atomic::load(dest);
+ new_value = old_value + add_value;
+ } while (old_value != Atomic::cmpxchg(dest, old_value, new_value, order));
+ return old_value;
+ }
+};
+
// Define the class before including platform file, which may specialize
// the operator definition. No generic definition of specializations
// of the operator template are provided, nor are there any generic
@@ -1170,4 +1215,18 @@ inline D Atomic::xchg(volatile D* dest, T exchange_value, atomic_memory_order or
return XchgImpl()(dest, exchange_value, order);
}
+template
+template
+inline T Atomic::XchgUsingCmpxchg::operator()(T volatile* dest,
+ T exchange_value,
+ atomic_memory_order order) const {
+ STATIC_ASSERT(byte_size == sizeof(T));
+
+ T old_value;
+ do {
+ old_value = Atomic::load(dest);
+ } while (old_value != Atomic::cmpxchg(dest, old_value, exchange_value, order));
+ return old_value;
+}
+
#endif // SHARE_RUNTIME_ATOMIC_HPP
diff --git a/src/hotspot/share/runtime/init.cpp b/src/hotspot/share/runtime/init.cpp
index 17dfb44579292..3343521af62a4 100644
--- a/src/hotspot/share/runtime/init.cpp
+++ b/src/hotspot/share/runtime/init.cpp
@@ -32,20 +32,20 @@
#include "interpreter/bytecodes.hpp"
#include "logging/logAsyncWriter.hpp"
#include "memory/universe.hpp"
+#include "nmt/memTracker.hpp"
+#include "prims/downcallLinker.hpp"
#include "prims/jvmtiExport.hpp"
#include "prims/methodHandles.hpp"
-#include "prims/downcallLinker.hpp"
-#include "runtime/globals.hpp"
#include "runtime/atomic.hpp"
#include "runtime/continuation.hpp"
#include "runtime/flags/jvmFlag.hpp"
+#include "runtime/globals.hpp"
#include "runtime/handles.inline.hpp"
#include "runtime/icache.hpp"
#include "runtime/init.hpp"
#include "runtime/safepoint.hpp"
#include "runtime/sharedRuntime.hpp"
#include "sanitizers/leak.hpp"
-#include "services/memTracker.hpp"
#include "utilities/macros.hpp"
#if INCLUDE_JVMCI
#include "jvmci/jvmci.hpp"
diff --git a/src/hotspot/share/runtime/java.cpp b/src/hotspot/share/runtime/java.cpp
index d075b6cb9c83e..a5e0d55fe1483 100644
--- a/src/hotspot/share/runtime/java.cpp
+++ b/src/hotspot/share/runtime/java.cpp
@@ -46,6 +46,7 @@
#include "memory/oopFactory.hpp"
#include "memory/resourceArea.hpp"
#include "memory/universe.hpp"
+#include "nmt/memTracker.hpp"
#include "oops/constantPool.hpp"
#include "oops/generateOopMap.hpp"
#include "oops/instanceKlass.hpp"
@@ -76,7 +77,6 @@
#include "runtime/vmThread.hpp"
#include "runtime/vm_version.hpp"
#include "sanitizers/leak.hpp"
-#include "services/memTracker.hpp"
#include "utilities/dtrace.hpp"
#include "utilities/globalDefinitions.hpp"
#include "utilities/macros.hpp"
diff --git a/src/hotspot/share/runtime/os.cpp b/src/hotspot/share/runtime/os.cpp
index 41b951b880144..0fea576269b32 100644
--- a/src/hotspot/share/runtime/os.cpp
+++ b/src/hotspot/share/runtime/os.cpp
@@ -39,10 +39,15 @@
#include "memory/allocation.inline.hpp"
#include "memory/resourceArea.hpp"
#include "memory/universe.hpp"
+#include "nmt/mallocHeader.inline.hpp"
+#include "nmt/mallocTracker.hpp"
+#include "nmt/memTracker.inline.hpp"
+#include "nmt/nmtCommon.hpp"
+#include "nmt/nmtPreInit.hpp"
#include "oops/compressedKlass.inline.hpp"
#include "oops/oop.inline.hpp"
-#include "prims/jvmtiAgent.hpp"
#include "prims/jvm_misc.hpp"
+#include "prims/jvmtiAgent.hpp"
#include "runtime/arguments.hpp"
#include "runtime/atomic.hpp"
#include "runtime/frame.inline.hpp"
@@ -63,11 +68,6 @@
#include "runtime/vm_version.hpp"
#include "sanitizers/address.hpp"
#include "services/attachListener.hpp"
-#include "services/mallocTracker.hpp"
-#include "services/mallocHeader.inline.hpp"
-#include "services/memTracker.inline.hpp"
-#include "services/nmtPreInit.hpp"
-#include "services/nmtCommon.hpp"
#include "services/threadService.hpp"
#include "utilities/align.hpp"
#include "utilities/checkedCast.hpp"
diff --git a/src/hotspot/share/runtime/park.cpp b/src/hotspot/share/runtime/park.cpp
index 03560974d0598..56eb00b50199f 100644
--- a/src/hotspot/share/runtime/park.cpp
+++ b/src/hotspot/share/runtime/park.cpp
@@ -24,8 +24,8 @@
#include "precompiled.hpp"
#include "memory/allocation.inline.hpp"
+#include "nmt/memTracker.hpp"
#include "runtime/javaThread.hpp"
-#include "services/memTracker.hpp"
// Lifecycle management for TSM ParkEvents.
// ParkEvents are type-stable (TSM).
diff --git a/src/hotspot/share/runtime/safepointMechanism.cpp b/src/hotspot/share/runtime/safepointMechanism.cpp
index 63f237df7e80e..624583db3d130 100644
--- a/src/hotspot/share/runtime/safepointMechanism.cpp
+++ b/src/hotspot/share/runtime/safepointMechanism.cpp
@@ -24,6 +24,7 @@
#include "precompiled.hpp"
#include "logging/log.hpp"
+#include "nmt/memTracker.hpp"
#include "runtime/globals.hpp"
#include "runtime/javaThread.inline.hpp"
#include "runtime/orderAccess.hpp"
@@ -31,7 +32,6 @@
#include "runtime/osThread.hpp"
#include "runtime/safepointMechanism.inline.hpp"
#include "runtime/stackWatermarkSet.hpp"
-#include "services/memTracker.hpp"
#include "utilities/globalDefinitions.hpp"
uintptr_t SafepointMechanism::_poll_word_armed_value;
diff --git a/src/hotspot/share/runtime/thread.cpp b/src/hotspot/share/runtime/thread.cpp
index 1023ab8bac2ae..851e5139f8aad 100644
--- a/src/hotspot/share/runtime/thread.cpp
+++ b/src/hotspot/share/runtime/thread.cpp
@@ -34,6 +34,7 @@
#include "memory/allocation.inline.hpp"
#include "memory/iterator.hpp"
#include "memory/resourceArea.hpp"
+#include "nmt/memTracker.hpp"
#include "oops/oop.inline.hpp"
#include "runtime/atomic.hpp"
#include "runtime/handles.inline.hpp"
@@ -45,7 +46,6 @@
#include "runtime/safepointMechanism.inline.hpp"
#include "runtime/thread.inline.hpp"
#include "runtime/threadSMR.inline.hpp"
-#include "services/memTracker.hpp"
#include "utilities/macros.hpp"
#include "utilities/spinYield.hpp"
#if INCLUDE_JFR
diff --git a/src/hotspot/share/runtime/threads.cpp b/src/hotspot/share/runtime/threads.cpp
index 276c3e362f030..b07f6e21d20df 100644
--- a/src/hotspot/share/runtime/threads.cpp
+++ b/src/hotspot/share/runtime/threads.cpp
@@ -52,17 +52,18 @@
#include "memory/oopFactory.hpp"
#include "memory/resourceArea.hpp"
#include "memory/universe.hpp"
+#include "nmt/memTracker.hpp"
#include "oops/instanceKlass.hpp"
#include "oops/klass.inline.hpp"
#include "oops/oop.inline.hpp"
#include "oops/symbol.hpp"
-#include "prims/jvmtiAgentList.hpp"
#include "prims/jvm_misc.hpp"
+#include "prims/jvmtiAgentList.hpp"
#include "runtime/arguments.hpp"
#include "runtime/fieldDescriptor.inline.hpp"
#include "runtime/flags/jvmFlagLimit.hpp"
-#include "runtime/handles.inline.hpp"
#include "runtime/globals.hpp"
+#include "runtime/handles.inline.hpp"
#include "runtime/interfaceSupport.inline.hpp"
#include "runtime/java.hpp"
#include "runtime/javaCalls.hpp"
@@ -83,8 +84,8 @@
#include "runtime/statSampler.hpp"
#include "runtime/stubCodeGenerator.hpp"
#include "runtime/thread.inline.hpp"
-#include "runtime/threads.hpp"
#include "runtime/threadSMR.inline.hpp"
+#include "runtime/threads.hpp"
#include "runtime/timer.hpp"
#include "runtime/timerTrace.hpp"
#include "runtime/trimNativeHeap.hpp"
@@ -92,7 +93,6 @@
#include "runtime/vm_version.hpp"
#include "services/attachListener.hpp"
#include "services/management.hpp"
-#include "services/memTracker.hpp"
#include "services/threadIdTable.hpp"
#include "services/threadService.hpp"
#include "utilities/dtrace.hpp"
diff --git a/src/hotspot/share/services/diagnosticCommand.cpp b/src/hotspot/share/services/diagnosticCommand.cpp
index a54f2ebaa707b..98bfcbafd290e 100644
--- a/src/hotspot/share/services/diagnosticCommand.cpp
+++ b/src/hotspot/share/services/diagnosticCommand.cpp
@@ -24,9 +24,9 @@
#include "precompiled.hpp"
#include "cds/cds_globals.hpp"
+#include "classfile/classLoaderDataGraph.hpp"
#include "classfile/classLoaderHierarchyDCmd.hpp"
#include "classfile/classLoaderStats.hpp"
-#include "classfile/classLoaderDataGraph.hpp"
#include "classfile/javaClasses.hpp"
#include "classfile/systemDictionary.hpp"
#include "classfile/vmClasses.hpp"
@@ -40,6 +40,7 @@
#include "memory/metaspace/metaspaceDCmd.hpp"
#include "memory/resourceArea.hpp"
#include "memory/universe.hpp"
+#include "nmt/nmtDCmd.hpp"
#include "oops/instanceKlass.hpp"
#include "oops/objArrayOop.inline.hpp"
#include "oops/oop.inline.hpp"
@@ -59,7 +60,6 @@
#include "services/diagnosticFramework.hpp"
#include "services/heapDumper.hpp"
#include "services/management.hpp"
-#include "services/nmtDCmd.hpp"
#include "services/writeableFlags.hpp"
#include "utilities/debug.hpp"
#include "utilities/events.hpp"
@@ -67,8 +67,8 @@
#include "utilities/macros.hpp"
#include "utilities/parseInteger.hpp"
#ifdef LINUX
-#include "trimCHeapDCmd.hpp"
#include "mallocInfoDcmd.hpp"
+#include "trimCHeapDCmd.hpp"
#endif
static void loadAgentModule(TRAPS) {
diff --git a/src/hotspot/share/services/mallocLimit.cpp b/src/hotspot/share/services/mallocLimit.cpp
index 4f96bb582f29e..392b20f61ef50 100644
--- a/src/hotspot/share/services/mallocLimit.cpp
+++ b/src/hotspot/share/services/mallocLimit.cpp
@@ -26,10 +26,10 @@
#include "precompiled.hpp"
#include "memory/allocation.hpp"
+#include "nmt/nmtCommon.hpp"
#include "runtime/java.hpp"
#include "runtime/globals.hpp"
#include "services/mallocLimit.hpp"
-#include "services/nmtCommon.hpp"
#include "utilities/globalDefinitions.hpp"
#include "utilities/parseInteger.hpp"
#include "utilities/ostream.hpp"
diff --git a/src/hotspot/share/utilities/debug.cpp b/src/hotspot/share/utilities/debug.cpp
index c918d8d04b36f..d39335c6307f4 100644
--- a/src/hotspot/share/utilities/debug.cpp
+++ b/src/hotspot/share/utilities/debug.cpp
@@ -37,6 +37,9 @@
#include "memory/allocation.hpp"
#include "memory/resourceArea.hpp"
#include "memory/universe.hpp"
+#include "nmt/mallocTracker.hpp"
+#include "nmt/memTracker.hpp"
+#include "nmt/virtualMemoryTracker.hpp"
#include "oops/klass.inline.hpp"
#include "oops/oop.inline.hpp"
#include "runtime/atomic.hpp"
@@ -54,9 +57,6 @@
#include "runtime/vframe.hpp"
#include "runtime/vm_version.hpp"
#include "services/heapDumper.hpp"
-#include "services/mallocTracker.hpp"
-#include "services/memTracker.hpp"
-#include "services/virtualMemoryTracker.hpp"
#include "utilities/defaultStream.hpp"
#include "utilities/events.hpp"
#include "utilities/formatBuffer.hpp"
diff --git a/src/hotspot/share/utilities/nativeCallStack.hpp b/src/hotspot/share/utilities/nativeCallStack.hpp
index 841b2cb204563..d61867c1dea9a 100644
--- a/src/hotspot/share/utilities/nativeCallStack.hpp
+++ b/src/hotspot/share/utilities/nativeCallStack.hpp
@@ -26,7 +26,7 @@
#define SHARE_UTILITIES_NATIVECALLSTACK_HPP
#include "memory/allocation.hpp"
-#include "services/nmtCommon.hpp"
+#include "nmt/nmtCommon.hpp"
#include "utilities/ostream.hpp"
/*
diff --git a/src/hotspot/share/utilities/vmError.cpp b/src/hotspot/share/utilities/vmError.cpp
index 2f4aec97868a4..9cf434fa2189e 100644
--- a/src/hotspot/share/utilities/vmError.cpp
+++ b/src/hotspot/share/utilities/vmError.cpp
@@ -38,14 +38,15 @@
#include "memory/metaspaceUtils.hpp"
#include "memory/resourceArea.inline.hpp"
#include "memory/universe.hpp"
+#include "nmt/memTracker.hpp"
#include "oops/compressedOops.hpp"
#include "prims/whitebox.hpp"
#include "runtime/arguments.hpp"
#include "runtime/atomic.hpp"
#include "runtime/flags/jvmFlag.hpp"
#include "runtime/frame.inline.hpp"
-#include "runtime/javaThread.inline.hpp"
#include "runtime/init.hpp"
+#include "runtime/javaThread.inline.hpp"
#include "runtime/os.inline.hpp"
#include "runtime/osThread.hpp"
#include "runtime/safefetch.hpp"
@@ -55,10 +56,9 @@
#include "runtime/threads.hpp"
#include "runtime/threadSMR.hpp"
#include "runtime/trimNativeHeap.hpp"
-#include "runtime/vmThread.hpp"
#include "runtime/vmOperations.hpp"
+#include "runtime/vmThread.hpp"
#include "runtime/vm_version.hpp"
-#include "services/memTracker.hpp"
#include "utilities/debug.hpp"
#include "utilities/decoder.hpp"
#include "utilities/defaultStream.hpp"
diff --git a/src/java.base/share/classes/java/text/ChoiceFormat.java b/src/java.base/share/classes/java/text/ChoiceFormat.java
index 538454d669a91..6f27137ea0d58 100644
--- a/src/java.base/share/classes/java/text/ChoiceFormat.java
+++ b/src/java.base/share/classes/java/text/ChoiceFormat.java
@@ -235,8 +235,9 @@ public class ChoiceFormat extends NumberFormat {
/**
* Apply the given pattern to this ChoiceFormat object. The syntax
* for the ChoiceFormat pattern can be seen in the {@linkplain ##patterns
- * Patterns} section.
- *
+ * Patterns} section. Unlike {@link #setChoices(double[], String[])} this
+ * method will throw an {@code IllegalArgumentException} if the {@code
+ * limits} are not in ascending order.
* @param newPattern a pattern string
* @throws NullPointerException if {@code newPattern}
* is {@code null}
diff --git a/src/java.base/share/classes/java/text/ListFormat.java b/src/java.base/share/classes/java/text/ListFormat.java
index d0b1b2aaf2aec..cd26f68bf4639 100644
--- a/src/java.base/share/classes/java/text/ListFormat.java
+++ b/src/java.base/share/classes/java/text/ListFormat.java
@@ -322,6 +322,26 @@ public static ListFormat getInstance(String[] patterns) {
return new ListFormat(Locale.ROOT, Arrays.copyOf(patterns, PATTERN_ARRAY_LENGTH));
}
+ /**
+ * {@return the {@code Locale} of this ListFormat}
+ *
+ * The {@code locale} is defined by {@link #getInstance(Locale, Type, Style)} or
+ * {@link #getInstance(String[])}.
+ */
+ public Locale getLocale() {
+ return locale;
+ }
+
+ /**
+ * {@return the patterns used in this ListFormat}
+ *
+ * The {@code patterns} are defined by {@link #getInstance(Locale, Type, Style)} or
+ * {@link #getInstance(String[])}.
+ */
+ public String[] getPatterns() {
+ return Arrays.copyOf(patterns, patterns.length);
+ }
+
/**
* {@return the string that consists of the input strings, concatenated with the
* patterns of this {@code ListFormat}}
@@ -480,11 +500,12 @@ public AttributedCharacterIterator formatToCharacterIterator(Object arguments) {
}
/**
- * Checks if this {@code ListFormat} is equal to another {@code ListFormat}.
- * The comparison is based on the {@code Locale} and formatting patterns, given or
- * generated with {@code Locale}, {@code Type}, and {@code Style}.
- * @param obj the object to check, {@code null} returns {@code false}
- * @return {@code true} if this is equals to the other {@code ListFormat}
+ * Compares the specified object with this {@code ListFormat} for equality.
+ * Returns {@code true} if the specified object is also a {@code ListFormat}, and
+ * {@code locale} and {@code patterns}, returned from {@link #getLocale()}
+ * and {@link #getPatterns()} respectively, are equal.
+ * @param obj the object to be compared for equality.
+ * @return {@code true} if the specified object is equal to this {@code ListFormat}
*/
@Override
public boolean equals(Object obj) {
diff --git a/src/java.base/share/classes/java/time/Duration.java b/src/java.base/share/classes/java/time/Duration.java
index c1894e2db5a7c..ab46159efd6a2 100644
--- a/src/java.base/share/classes/java/time/Duration.java
+++ b/src/java.base/share/classes/java/time/Duration.java
@@ -486,23 +486,26 @@ private static Duration create(boolean negate, long daysAsSecs, long hoursAsSecs
* @throws ArithmeticException if the calculation exceeds the capacity of {@code Duration}
*/
public static Duration between(Temporal startInclusive, Temporal endExclusive) {
- try {
+ long secs = startInclusive.until(endExclusive, SECONDS);
+ if (secs == 0) {
+ // We don't know which Temporal is earlier, so the adjustment below would not work.
+ // But we do know that there's no danger of until(NANOS) overflowing in that case.
return ofNanos(startInclusive.until(endExclusive, NANOS));
- } catch (DateTimeException | ArithmeticException ex) {
- long secs = startInclusive.until(endExclusive, SECONDS);
- long nanos;
- try {
- nanos = endExclusive.getLong(NANO_OF_SECOND) - startInclusive.getLong(NANO_OF_SECOND);
- if (secs > 0 && nanos < 0) {
- secs++;
- } else if (secs < 0 && nanos > 0) {
- secs--;
- }
- } catch (DateTimeException ex2) {
- nanos = 0;
- }
- return ofSeconds(secs, nanos);
}
+ long nanos;
+ try {
+ nanos = endExclusive.getLong(NANO_OF_SECOND) - startInclusive.getLong(NANO_OF_SECOND);
+ } catch (DateTimeException ex2) {
+ nanos = 0;
+ }
+ if (nanos < 0 && secs > 0) {
+ // ofSeconds will subtract one even though until(SECONDS) already gave the correct
+ // number of seconds. So compensate. Similarly for the secs < 0 case below.
+ secs++;
+ } else if (nanos > 0 && secs < 0) {
+ secs--;
+ }
+ return ofSeconds(secs, nanos);
}
//-----------------------------------------------------------------------
diff --git a/src/java.base/share/classes/sun/security/tools/keytool/Main.java b/src/java.base/share/classes/sun/security/tools/keytool/Main.java
index 2effa3425d71a..b094acc51fe96 100644
--- a/src/java.base/share/classes/sun/security/tools/keytool/Main.java
+++ b/src/java.base/share/classes/sun/security/tools/keytool/Main.java
@@ -405,26 +405,38 @@ public String toString() {
collator.setStrength(Collator.PRIMARY);
}
- private Main() { }
-
public static void main(String[] args) throws Exception {
Main kt = new Main();
- kt.run(args, System.out);
+ int exitCode = kt.run(args, System.out);
+ if (exitCode != 0) {
+ System.exit(exitCode);
+ }
+ }
+
+ private static class ExitException extends RuntimeException {
+ @java.io.Serial
+ static final long serialVersionUID = 0L;
+ private final int errorCode;
+ public ExitException(int errorCode) {
+ this.errorCode = errorCode;
+ }
}
- private void run(String[] args, PrintStream out) throws Exception {
+ public int run(String[] args, PrintStream out) throws Exception {
try {
- args = parseArgs(args);
+ parseArgs(args);
if (command != null) {
doCommands(out);
}
+ } catch (ExitException ee) {
+ return ee.errorCode;
} catch (Exception e) {
System.out.println(rb.getString("keytool.error.") + e);
if (verbose) {
e.printStackTrace(System.out);
}
if (!debug) {
- System.exit(1);
+ return 1;
} else {
throw e;
}
@@ -441,6 +453,7 @@ private void run(String[] args, PrintStream out) throws Exception {
ksStream.close();
}
}
+ return 0;
}
/**
@@ -5247,7 +5260,7 @@ private void tinyHelp() {
if (debug) {
throw new RuntimeException("NO BIG ERROR, SORRY");
} else {
- System.exit(1);
+ throw new ExitException(1);
}
}
diff --git a/src/java.desktop/macosx/classes/sun/java2d/MacOSFlags.java b/src/java.desktop/macosx/classes/sun/java2d/MacOSFlags.java
index 5e09d39692b9c..37b573a339b25 100644
--- a/src/java.desktop/macosx/classes/sun/java2d/MacOSFlags.java
+++ b/src/java.desktop/macosx/classes/sun/java2d/MacOSFlags.java
@@ -125,16 +125,7 @@ private static void initJavaFlags() {
System.out.println("Could not enable OpenGL pipeline (CGL not available)");
}
oglEnabled = false;
- metalEnabled = MTLGraphicsConfig.isMetalAvailable();
- }
- } else if (metalEnabled && !oglEnabled) {
- // Check whether Metal framework is available
- if (!MTLGraphicsConfig.isMetalAvailable()) {
- if (metalVerbose) {
- System.out.println("Could not enable Metal pipeline (Metal framework not available)");
- }
- metalEnabled = false;
- oglEnabled = CGLGraphicsConfig.isCGLAvailable();
+ metalEnabled = true;
}
}
diff --git a/src/java.desktop/macosx/classes/sun/java2d/metal/MTLGraphicsConfig.java b/src/java.desktop/macosx/classes/sun/java2d/metal/MTLGraphicsConfig.java
index 64117b8999e19..8a992361b9628 100644
--- a/src/java.desktop/macosx/classes/sun/java2d/metal/MTLGraphicsConfig.java
+++ b/src/java.desktop/macosx/classes/sun/java2d/metal/MTLGraphicsConfig.java
@@ -72,7 +72,6 @@
public final class MTLGraphicsConfig extends CGraphicsConfig
implements AccelGraphicsConfig, SurfaceManager.ProxiedGraphicsConfig
{
- private static boolean mtlAvailable;
private static ImageCapabilities imageCaps = new MTLImageCaps();
@SuppressWarnings("removal")
@@ -89,7 +88,6 @@ public final class MTLGraphicsConfig extends CGraphicsConfig
private final Object disposerReferent = new Object();
private final int maxTextureSize;
- private static native boolean isMetalFrameworkAvailable();
private static native boolean tryLoadMetalLibrary(int displayID, String shaderLib);
private static native long getMTLConfigInfo(int displayID, String mtlShadersLib);
@@ -99,10 +97,6 @@ public final class MTLGraphicsConfig extends CGraphicsConfig
*/
private static native int nativeGetMaxTextureSize();
- static {
- mtlAvailable = isMetalFrameworkAvailable();
- }
-
private MTLGraphicsConfig(CGraphicsDevice device,
long configInfo, int maxTextureSize,
ContextCapabilities mtlCaps) {
@@ -133,10 +127,6 @@ public SurfaceData createManagedSurface(int w, int h, int transparency) {
public static MTLGraphicsConfig getConfig(CGraphicsDevice device,
int displayID)
{
- if (!mtlAvailable) {
- return null;
- }
-
if (!tryLoadMetalLibrary(displayID, mtlShadersLib)) {
return null;
}
@@ -171,10 +161,6 @@ public static MTLGraphicsConfig getConfig(CGraphicsDevice device,
return new MTLGraphicsConfig(device, cfginfo, textureSize, caps);
}
- public static boolean isMetalAvailable() {
- return mtlAvailable;
- }
-
/**
* Returns true if the provided capability bit is present for this config.
* See MTLContext.java for a list of supported capabilities.
diff --git a/src/java.desktop/macosx/native/libawt_lwawt/awt/CSystemColors.m b/src/java.desktop/macosx/native/libawt_lwawt/awt/CSystemColors.m
index 40ef6e67d0173..1bd767c320b52 100644
--- a/src/java.desktop/macosx/native/libawt_lwawt/awt/CSystemColors.m
+++ b/src/java.desktop/macosx/native/libawt_lwawt/awt/CSystemColors.m
@@ -96,11 +96,7 @@ + (void)reloadColors {
sColors[java_awt_SystemColor_TEXT_INACTIVE_TEXT] = [NSColor disabledControlTextColor];
sColors[java_awt_SystemColor_CONTROL] = [NSColor controlColor];
sColors[java_awt_SystemColor_CONTROL_TEXT] = [NSColor controlTextColor];
- if (@available(macOS 10.14, *)) {
- sColors[java_awt_SystemColor_CONTROL_HIGHLIGHT] = [NSColor selectedContentBackgroundColor];
- } else {
- sColors[java_awt_SystemColor_CONTROL_HIGHLIGHT] = [NSColor alternateSelectedControlColor];
- }
+ sColors[java_awt_SystemColor_CONTROL_HIGHLIGHT] = [NSColor selectedContentBackgroundColor];
sColors[java_awt_SystemColor_CONTROL_LT_HIGHLIGHT] = [NSColor alternateSelectedControlTextColor];
sColors[java_awt_SystemColor_CONTROL_SHADOW] = [NSColor controlShadowColor];
sColors[java_awt_SystemColor_CONTROL_DK_SHADOW] = [NSColor controlDarkShadowColor];
@@ -121,11 +117,7 @@ + (void)reloadColors {
}
// added for JTable Focus Ring
- if (@available(macOS 10.14, *)) {
- appleColors[sun_lwawt_macosx_LWCToolkit_CELL_HIGHLIGHT_COLOR] = [NSColor controlAccentColor];
- } else {
- appleColors[sun_lwawt_macosx_LWCToolkit_CELL_HIGHLIGHT_COLOR] = [NSColor keyboardFocusIndicatorColor];
- }
+ appleColors[sun_lwawt_macosx_LWCToolkit_CELL_HIGHLIGHT_COLOR] = [NSColor controlAccentColor];
appleColors[sun_lwawt_macosx_LWCToolkit_KEYBOARD_FOCUS_COLOR] = [NSColor keyboardFocusIndicatorColor];
appleColors[sun_lwawt_macosx_LWCToolkit_INACTIVE_SELECTION_BACKGROUND_COLOR] = [NSColor secondarySelectedControlColor];
appleColors[sun_lwawt_macosx_LWCToolkit_INACTIVE_SELECTION_FOREGROUND_COLOR] = [NSColor controlDarkShadowColor];
diff --git a/src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLGraphicsConfig.m b/src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLGraphicsConfig.m
index af6662cecf2ab..7b165a668b3a2 100644
--- a/src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLGraphicsConfig.m
+++ b/src/java.desktop/macosx/native/libawt_lwawt/java2d/metal/MTLGraphicsConfig.m
@@ -54,22 +54,6 @@
free(mtlinfo);
}
-JNIEXPORT jboolean JNICALL
-Java_sun_java2d_metal_MTLGraphicsConfig_isMetalFrameworkAvailable
- (JNIEnv *env, jclass mtlgc)
-{
- jboolean metalSupported = JNI_FALSE;
-
- // It is guaranteed that metal supported GPU is available since macOS 10.14
- if (@available(macOS 10.14, *)) {
- metalSupported = JNI_TRUE;
- }
-
- J2dRlsTraceLn1(J2D_TRACE_INFO, "MTLGraphicsConfig_isMetalFrameworkAvailable : %d", metalSupported);
-
- return metalSupported;
-}
-
JNIEXPORT jboolean JNICALL
Java_sun_java2d_metal_MTLGraphicsConfig_tryLoadMetalLibrary
(JNIEnv *env, jclass mtlgc, jint displayID, jstring shadersLibName)
diff --git a/src/java.desktop/share/native/common/font/fontscalerdefs.h b/src/java.desktop/share/native/common/font/fontscalerdefs.h
index 520ba406e04c4..4b39146640348 100644
--- a/src/java.desktop/share/native/common/font/fontscalerdefs.h
+++ b/src/java.desktop/share/native/common/font/fontscalerdefs.h
@@ -103,7 +103,7 @@ typedef struct GlyphInfo {
* FileFontStrike logic - presence of context is used as marker to
* free the memory.
*/
-JNIEXPORT int isNullScalerContext(void *context);
+int isNullScalerContext(void *context);
#ifdef __cplusplus
}
diff --git a/src/java.desktop/share/native/common/font/sunfontids.h b/src/java.desktop/share/native/common/font/sunfontids.h
index 2301f80b5bcbf..5f764e241cb91 100644
--- a/src/java.desktop/share/native/common/font/sunfontids.h
+++ b/src/java.desktop/share/native/common/font/sunfontids.h
@@ -82,10 +82,7 @@ typedef struct FontManagerNativeIDs {
glyphImages, glyphListUsePos, glyphListPos, lcdRGBOrder, lcdSubPixPos;
} FontManagerNativeIDs;
-/* Note: we share variable in the context of fontmanager lib
- but we need access method to use it from separate rasterizer lib */
extern FontManagerNativeIDs sunFontIDs;
-JNIEXPORT FontManagerNativeIDs getSunFontIDs(JNIEnv* env);
#ifdef __cplusplus
}
diff --git a/src/java.desktop/share/native/libawt/awt/image/imageInitIDs.h b/src/java.desktop/share/native/libawt/awt/image/imageInitIDs.h
index 031d133edaebd..62c52450f552e 100644
--- a/src/java.desktop/share/native/libawt/awt/image/imageInitIDs.h
+++ b/src/java.desktop/share/native/libawt/awt/image/imageInitIDs.h
@@ -74,7 +74,6 @@ IMGEXTERN jfieldID g_ICRdataOffsetsID;
IMGEXTERN jfieldID g_ICRtypeID;
/* Color Model ids */
-JNIEXPORT
IMGEXTERN jfieldID g_CMnBitsID;
IMGEXTERN jfieldID g_CMcspaceID;
IMGEXTERN jfieldID g_CMnumComponentsID;
diff --git a/src/java.desktop/share/native/libawt/java2d/SurfaceData.c b/src/java.desktop/share/native/libawt/java2d/SurfaceData.c
index ffff2bd09b48c..4d96a2d3ff40d 100644
--- a/src/java.desktop/share/native/libawt/java2d/SurfaceData.c
+++ b/src/java.desktop/share/native/libawt/java2d/SurfaceData.c
@@ -139,13 +139,13 @@ SurfaceData_GetOps(JNIEnv *env, jobject sData)
return GetSDOps(env, sData, JNI_TRUE);
}
-JNIEXPORT SurfaceDataOps * JNICALL
+SurfaceDataOps *
SurfaceData_GetOpsNoSetup(JNIEnv *env, jobject sData)
{
return GetSDOps(env, sData, JNI_FALSE);
}
-JNIEXPORT void JNICALL
+void
SurfaceData_SetOps(JNIEnv *env, jobject sData, SurfaceDataOps *ops)
{
if (JNU_GetLongFieldAsPtr(env, sData, pDataID) == NULL) {
diff --git a/src/java.desktop/share/native/libawt/java2d/SurfaceData.h b/src/java.desktop/share/native/libawt/java2d/SurfaceData.h
index 745fd012e8655..c4eae3c19aa78 100644
--- a/src/java.desktop/share/native/libawt/java2d/SurfaceData.h
+++ b/src/java.desktop/share/native/libawt/java2d/SurfaceData.h
@@ -553,7 +553,7 @@ SurfaceData_GetOps(JNIEnv *env, jobject sData);
* Does the same as the above, but doesn't call Setup function
* even if it's set.
*/
-JNIEXPORT SurfaceDataOps * JNICALL
+SurfaceDataOps *
SurfaceData_GetOpsNoSetup(JNIEnv *env, jobject sData);
/*
@@ -569,7 +569,7 @@ SurfaceData_GetOpsNoSetup(JNIEnv *env, jobject sData);
* is called since this function will not leave any outstanding
* JNI Critical locks unreleased.
*/
-JNIEXPORT void JNICALL
+void
SurfaceData_SetOps(JNIEnv *env, jobject sData, SurfaceDataOps *ops);
/*
diff --git a/src/java.desktop/share/native/libawt/java2d/Trace.c b/src/java.desktop/share/native/libawt/java2d/Trace.c
index bba31f8b837f7..a2783a9b64c6d 100644
--- a/src/java.desktop/share/native/libawt/java2d/Trace.c
+++ b/src/java.desktop/share/native/libawt/java2d/Trace.c
@@ -31,6 +31,9 @@
static int j2dTraceLevel = J2D_TRACE_INVALID;
static FILE *j2dTraceFile = NULL;
+static void
+J2dTraceInit();
+
JNIEXPORT void JNICALL
J2dTraceImpl(int level, jboolean cr, const char *string, ...)
{
@@ -72,7 +75,7 @@ J2dTraceImpl(int level, jboolean cr, const char *string, ...)
}
}
-JNIEXPORT void JNICALL
+static void
J2dTraceInit()
{
char *j2dTraceLevelString = getenv("J2D_TRACE_LEVEL");
diff --git a/src/java.desktop/share/native/libawt/java2d/Trace.h b/src/java.desktop/share/native/libawt/java2d/Trace.h
index 322c63b0a60a6..b4fe41f77b02b 100644
--- a/src/java.desktop/share/native/libawt/java2d/Trace.h
+++ b/src/java.desktop/share/native/libawt/java2d/Trace.h
@@ -52,8 +52,6 @@ extern "C" {
JNIEXPORT void JNICALL
J2dTraceImpl(int level, jboolean cr, const char *string, ...);
-JNIEXPORT void JNICALL
-J2dTraceInit();
#ifndef DEBUG
#define J2dTrace(level, string)
diff --git a/src/java.desktop/share/native/libawt/java2d/loops/GraphicsPrimitiveMgr.c b/src/java.desktop/share/native/libawt/java2d/loops/GraphicsPrimitiveMgr.c
index cb0dafe3dbcee..3ff40a4ef4ddc 100644
--- a/src/java.desktop/share/native/libawt/java2d/loops/GraphicsPrimitiveMgr.c
+++ b/src/java.desktop/share/native/libawt/java2d/loops/GraphicsPrimitiveMgr.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2023, 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
@@ -470,7 +470,7 @@ GrPrim_Sg2dGetCompInfo(JNIEnv *env, jobject sg2d,
(*env)->DeleteLocalRef(env, comp);
}
-JNIEXPORT jint JNICALL
+jint
GrPrim_CompGetXorColor(JNIEnv *env, jobject comp)
{
jobject color;
@@ -511,7 +511,7 @@ GrPrim_Sg2dGetLCDTextContrast(JNIEnv *env, jobject sg2d)
/*
* Helper function for CompositeTypes.Xor
*/
-JNIEXPORT void JNICALL
+static void JNICALL
GrPrim_CompGetXorInfo(JNIEnv *env, CompositeInfo *pCompInfo, jobject comp)
{
pCompInfo->rule = RULE_Xor;
@@ -522,7 +522,7 @@ GrPrim_CompGetXorInfo(JNIEnv *env, CompositeInfo *pCompInfo, jobject comp)
/*
* Helper function for CompositeTypes.AnyAlpha
*/
-JNIEXPORT void JNICALL
+static void JNICALL
GrPrim_CompGetAlphaInfo(JNIEnv *env, CompositeInfo *pCompInfo, jobject comp)
{
pCompInfo->rule =
@@ -531,7 +531,7 @@ GrPrim_CompGetAlphaInfo(JNIEnv *env, CompositeInfo *pCompInfo, jobject comp)
(*env)->GetFloatField(env, comp, extraAlphaID);
}
-JNIEXPORT void JNICALL
+void
Transform_GetInfo(JNIEnv *env, jobject txform, TransformInfo *pTxInfo)
{
pTxInfo->dxdx = (*env)->GetDoubleField(env, txform, m00ID);
@@ -542,7 +542,7 @@ Transform_GetInfo(JNIEnv *env, jobject txform, TransformInfo *pTxInfo)
pTxInfo->ty = (*env)->GetDoubleField(env, txform, m12ID);
}
-JNIEXPORT void JNICALL
+void
Transform_transform(TransformInfo *pTxInfo, jdouble *pX, jdouble *pY)
{
jdouble x = *pX;
diff --git a/src/java.desktop/share/native/libawt/java2d/loops/GraphicsPrimitiveMgr.h b/src/java.desktop/share/native/libawt/java2d/loops/GraphicsPrimitiveMgr.h
index 3ba7574a0d5dd..c3a42eee5394e 100644
--- a/src/java.desktop/share/native/libawt/java2d/loops/GraphicsPrimitiveMgr.h
+++ b/src/java.desktop/share/native/libawt/java2d/loops/GraphicsPrimitiveMgr.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2023, 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
@@ -510,12 +510,8 @@ extern JNIEXPORT void JNICALL
GrPrim_Sg2dGetCompInfo(JNIEnv *env, jobject sg2d,
NativePrimitive *pPrim,
CompositeInfo *pCompInfo);
-extern JNIEXPORT jint JNICALL
+extern jint
GrPrim_CompGetXorColor(JNIEnv *env, jobject comp);
-extern JNIEXPORT void JNICALL
-GrPrim_CompGetXorInfo(JNIEnv *env, CompositeInfo *pCompInfo, jobject comp);
-extern JNIEXPORT void JNICALL
-GrPrim_CompGetAlphaInfo(JNIEnv *env, CompositeInfo *pCompInfo, jobject comp);
extern JNIEXPORT void JNICALL
GrPrim_Sg2dGetClip(JNIEnv *env, jobject sg2d,
@@ -541,9 +537,9 @@ typedef struct {
jdouble ty;
} TransformInfo;
-extern JNIEXPORT void JNICALL
+extern void
Transform_GetInfo(JNIEnv *env, jobject txform, TransformInfo *pTxInfo);
-extern JNIEXPORT void JNICALL
+extern void
Transform_transform(TransformInfo *pTxInfo, jdouble *pX, jdouble *pY);
void GrPrim_RefineBounds(SurfaceDataBounds *bounds, jint transX, jint transY,
diff --git a/src/java.desktop/share/native/libfontmanager/sunFont.c b/src/java.desktop/share/native/libfontmanager/sunFont.c
index 661dccae0c5c6..0461d61c26cf4 100644
--- a/src/java.desktop/share/native/libfontmanager/sunFont.c
+++ b/src/java.desktop/share/native/libfontmanager/sunFont.c
@@ -201,12 +201,6 @@ Java_sun_font_SunFontManager_initIDs
initFontIDs(env);
}
-JNIEXPORT FontManagerNativeIDs getSunFontIDs(JNIEnv *env) {
-
- initFontIDs(env);
- return sunFontIDs;
-}
-
/*
* Class: sun_font_StrikeCache
* Method: freeIntPointer
diff --git a/src/java.desktop/unix/native/common/awt/X11Color.c b/src/java.desktop/unix/native/common/awt/X11Color.c
index b754f77537c44..b1602bb5ae41b 100644
--- a/src/java.desktop/unix/native/common/awt/X11Color.c
+++ b/src/java.desktop/unix/native/common/awt/X11Color.c
@@ -1230,8 +1230,6 @@ jobject awtJNI_GetColorModel(JNIEnv *env, AwtGraphicsConfigDataPtr aData)
}
#endif /* !HEADLESS */
-extern jfieldID colorValueID;
-
#ifndef HEADLESS
void
awt_allocate_systemrgbcolors (jint *rgbColors, int num_colors,
diff --git a/src/java.desktop/unix/native/common/java2d/x11/X11SurfaceData.c b/src/java.desktop/unix/native/common/java2d/x11/X11SurfaceData.c
index 1be65e546cab7..36d6feb6029a7 100644
--- a/src/java.desktop/unix/native/common/java2d/x11/X11SurfaceData.c
+++ b/src/java.desktop/unix/native/common/java2d/x11/X11SurfaceData.c
@@ -291,7 +291,7 @@ Java_sun_java2d_x11_XSurfaceData_flushNativeSurface(JNIEnv *env, jobject xsd)
}
-JNIEXPORT X11SDOps * JNICALL
+X11SDOps *
X11SurfaceData_GetOps(JNIEnv *env, jobject sData)
{
#ifdef HEADLESS
diff --git a/src/java.desktop/unix/native/common/java2d/x11/X11SurfaceData.h b/src/java.desktop/unix/native/common/java2d/x11/X11SurfaceData.h
index 66022f2426edd..860c45f7fb0ae 100644
--- a/src/java.desktop/unix/native/common/java2d/x11/X11SurfaceData.h
+++ b/src/java.desktop/unix/native/common/java2d/x11/X11SurfaceData.h
@@ -163,5 +163,5 @@ jboolean XShared_initSurface(JNIEnv *env, X11SDOps *xsdo, jint depth, jint width
* is called since this function will not leave any outstanding
* JNI Critical locks unreleased.
*/
-JNIEXPORT X11SDOps * JNICALL
+X11SDOps *
X11SurfaceData_GetOps(JNIEnv *env, jobject sData);
diff --git a/src/java.desktop/unix/native/libawt/awt/initIDs.c b/src/java.desktop/unix/native/libawt/awt/initIDs.c
index c5a8c0ea58db9..d1c24c76af6d1 100644
--- a/src/java.desktop/unix/native/libawt/awt/initIDs.c
+++ b/src/java.desktop/unix/native/libawt/awt/initIDs.c
@@ -40,13 +40,10 @@
* which are used in the win32 awt.
*/
-JNIEXPORT jfieldID colorValueID;
-
JNIEXPORT void JNICALL
Java_java_awt_Color_initIDs
(JNIEnv *env, jclass clazz)
{
- colorValueID = (*env)->GetFieldID(env, clazz, "value", "I");
}
JNIEXPORT void JNICALL
diff --git a/src/java.desktop/windows/native/libawt/java2d/windows/GDIWindowSurfaceData.cpp b/src/java.desktop/windows/native/libawt/java2d/windows/GDIWindowSurfaceData.cpp
index 77528dc333069..6dae331f88f64 100644
--- a/src/java.desktop/windows/native/libawt/java2d/windows/GDIWindowSurfaceData.cpp
+++ b/src/java.desktop/windows/native/libawt/java2d/windows/GDIWindowSurfaceData.cpp
@@ -471,7 +471,7 @@ Java_sun_java2d_windows_GDIWindowSurfaceData_initOps(JNIEnv *env, jobject wsd,
wsdo->bmCopyToScreen = FALSE;
}
-JNIEXPORT GDIWinSDOps * JNICALL
+GDIWinSDOps *
GDIWindowSurfaceData_GetOps(JNIEnv *env, jobject sData)
{
SurfaceDataOps *ops = SurfaceData_GetOps(env, sData);
@@ -484,7 +484,7 @@ GDIWindowSurfaceData_GetOps(JNIEnv *env, jobject sData)
return (GDIWinSDOps *) ops;
}
-JNIEXPORT GDIWinSDOps * JNICALL
+GDIWinSDOps *
GDIWindowSurfaceData_GetOpsNoSetup(JNIEnv *env, jobject sData)
{
// use the 'no setup' version of GetOps
@@ -492,7 +492,7 @@ GDIWindowSurfaceData_GetOpsNoSetup(JNIEnv *env, jobject sData)
return (GDIWinSDOps *) ops;
}
-JNIEXPORT AwtComponent * JNICALL
+AwtComponent *
GDIWindowSurfaceData_GetComp(JNIEnv *env, GDIWinSDOps *wsdo)
{
PDATA pData = NULL;
@@ -524,7 +524,7 @@ GDIWindowSurfaceData_GetComp(JNIEnv *env, GDIWinSDOps *wsdo)
return static_cast(pData);
}
-JNIEXPORT HWND JNICALL
+HWND
GDIWindowSurfaceData_GetWindow(JNIEnv *env, GDIWinSDOps *wsdo)
{
HWND window = wsdo->window;
@@ -1019,7 +1019,7 @@ static HDC GDIWinSD_GetDC(JNIEnv *env, GDIWinSDOps *wsdo,
return env->ExceptionCheck() ? (HDC)NULL : info->hDC;
}
-JNIEXPORT void JNICALL
+void
GDIWinSD_InitDC(JNIEnv *env, GDIWinSDOps *wsdo, ThreadGraphicsInfo *info,
jint type, jint *patrop,
jobject clip, jobject comp, jint color)
diff --git a/src/java.desktop/windows/native/libawt/java2d/windows/GDIWindowSurfaceData.h b/src/java.desktop/windows/native/libawt/java2d/windows/GDIWindowSurfaceData.h
index 2825d495e0407..830ada4335894 100644
--- a/src/java.desktop/windows/native/libawt/java2d/windows/GDIWindowSurfaceData.h
+++ b/src/java.desktop/windows/native/libawt/java2d/windows/GDIWindowSurfaceData.h
@@ -236,21 +236,21 @@ typedef struct {
* is called since this function will not leave any outstanding
* JNI Critical locks unreleased.
*/
-JNIEXPORT GDIWinSDOps * JNICALL
+GDIWinSDOps *
GDIWindowSurfaceData_GetOps(JNIEnv *env, jobject sData);
-JNIEXPORT GDIWinSDOps * JNICALL
+GDIWinSDOps *
GDIWindowSurfaceData_GetOpsNoSetup(JNIEnv *env, jobject sData);
-JNIEXPORT HWND JNICALL
+HWND
GDIWindowSurfaceData_GetWindow(JNIEnv *env, GDIWinSDOps *wsdo);
-JNIEXPORT void JNICALL
+void
GDIWinSD_InitDC(JNIEnv *env, GDIWinSDOps *wsdo, ThreadGraphicsInfo *info,
jint type, jint *patrop,
jobject clip, jobject comp, jint color);
-JNIEXPORT AwtComponent * JNICALL
+AwtComponent *
GDIWindowSurfaceData_GetComp(JNIEnv *env, GDIWinSDOps *wsdo);
} /* extern "C" */
diff --git a/src/java.desktop/windows/native/libawt/windows/awt_Mlib.h b/src/java.desktop/windows/native/libawt/windows/awt_Mlib.h
index db0406245a639..55099bf369888 100644
--- a/src/java.desktop/windows/native/libawt/windows/awt_Mlib.h
+++ b/src/java.desktop/windows/native/libawt/windows/awt_Mlib.h
@@ -34,10 +34,10 @@ extern "C" {
typedef void (*mlib_start_timer)(int);
typedef void (*mlib_stop_timer)(int, int);
-JNIEXPORT mlib_status awt_getImagingLib(JNIEnv *env, mlibFnS_t *sMlibFns,
+mlib_status awt_getImagingLib(JNIEnv *env, mlibFnS_t *sMlibFns,
mlibSysFnS_t *sMlibSysFns);
-JNIEXPORT mlib_start_timer awt_setMlibStartTimer();
-JNIEXPORT mlib_stop_timer awt_setMlibStopTimer();
+mlib_start_timer awt_setMlibStartTimer();
+mlib_stop_timer awt_setMlibStopTimer();
#ifdef __cplusplus
} /* end of extern "C" */
diff --git a/src/java.security.jgss/windows/classes/sun/security/krb5/internal/tools/Kinit.java b/src/java.security.jgss/windows/classes/sun/security/krb5/internal/tools/Kinit.java
index 813939643c3cf..a14ece6ee0e02 100644
--- a/src/java.security.jgss/windows/classes/sun/security/krb5/internal/tools/Kinit.java
+++ b/src/java.security.jgss/windows/classes/sun/security/krb5/internal/tools/Kinit.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2023, 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
@@ -92,14 +92,44 @@ public class Kinit {
*/
public static void main(String[] args) {
- try {
- Kinit self = new Kinit(args);
+ Kinit kinit = new Kinit();
+ int exitCode = kinit.run(args);
+ if (exitCode != 0) {
+ System.exit(exitCode);
}
- catch (Exception e) {
- String msg = null;
- if (e instanceof KrbException) {
- msg = ((KrbException)e).krbErrorMessage() + " " +
- ((KrbException)e).returnCodeMessage();
+ }
+
+ /**
+ * Run the Kinit command.
+ * @param args array of ticket request options.
+ * Available options are: -f, -p, -c, principal, password.
+ * @return the exit code
+ */
+ public int run(String[] args) {
+ try {
+ if (args == null || args.length == 0) {
+ options = new KinitOptions();
+ } else {
+ options = new KinitOptions(args);
+ }
+ switch (options.action) {
+ case 0:
+ // Help, already displayed in new KinitOptions().
+ break;
+ case 1:
+ acquire();
+ break;
+ case 2:
+ renew();
+ break;
+ default:
+ throw new KrbException("kinit does not support action "
+ + options.action);
+ }
+ } catch (Exception e) {
+ String msg;
+ if (e instanceof KrbException ke) {
+ msg = ke.krbErrorMessage() + " " + ke.returnCodeMessage();
} else {
msg = e.getMessage();
}
@@ -109,37 +139,9 @@ public static void main(String[] args) {
System.out.println("Exception: " + e);
}
e.printStackTrace();
- System.exit(-1);
- }
- return;
- }
-
- /**
- * Constructs a new Kinit object.
- * @param args array of ticket request options.
- * Available options are: -f, -p, -c, principal, password.
- * @exception IOException if an I/O error occurs.
- * @exception RealmException if the Realm could not be instantiated.
- * @exception KrbException if error occurs during Kerberos operation.
- */
- private Kinit(String[] args)
- throws IOException, RealmException, KrbException {
- if (args == null || args.length == 0) {
- options = new KinitOptions();
- } else {
- options = new KinitOptions(args);
- }
- switch (options.action) {
- case 1:
- acquire();
- break;
- case 2:
- renew();
- break;
- default:
- throw new KrbException("kinit does not support action "
- + options.action);
+ return -1;
}
+ return 0;
}
private void renew()
diff --git a/src/java.security.jgss/windows/classes/sun/security/krb5/internal/tools/KinitOptions.java b/src/java.security.jgss/windows/classes/sun/security/krb5/internal/tools/KinitOptions.java
index 5cfc574d95acf..445b806bb50cf 100644
--- a/src/java.security.jgss/windows/classes/sun/security/krb5/internal/tools/KinitOptions.java
+++ b/src/java.security.jgss/windows/classes/sun/security/krb5/internal/tools/KinitOptions.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2023, 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
@@ -46,7 +46,7 @@
*/
class KinitOptions {
- // 1. acquire, 2. renew, 3. validate
+ // 0. Help, 1. acquire, 2. renew, 3. validate
public int action = 1;
// forwardable and proxiable flags have two states:
@@ -143,7 +143,8 @@ public KinitOptions(String[] args)
// -help: legacy.
args[i].equalsIgnoreCase("-help")) {
printHelp();
- System.exit(0);
+ action = 0;
+ return;
} else if (p == null) { // Haven't yet processed a "principal"
p = args[i];
try {
diff --git a/src/java.security.jgss/windows/classes/sun/security/krb5/internal/tools/Klist.java b/src/java.security.jgss/windows/classes/sun/security/krb5/internal/tools/Klist.java
index 5a0c3bee0776e..16c9fd99ec406 100644
--- a/src/java.security.jgss/windows/classes/sun/security/krb5/internal/tools/Klist.java
+++ b/src/java.security.jgss/windows/classes/sun/security/krb5/internal/tools/Klist.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2023, 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
@@ -78,115 +78,111 @@ public class Klist {
*/
public static void main(String[] args) {
Klist klist = new Klist();
+ int exitCode = klist.run(args);
+ if (exitCode != 0) {
+ System.exit(exitCode);
+ }
+ }
+
+ public int run(String[] args) {
if ((args == null) || (args.length == 0)) {
- klist.action = 'c'; // default will list default credentials cache.
+ action = 'c'; // default will list default credentials cache.
} else {
- klist.processArgs(args);
+ Character arg;
+ for (int i = 0; i < args.length; i++) {
+ if (args[i].equals("-?") ||
+ args[i].equals("-h") ||
+ args[i].equals("--help")) {
+ printHelp();
+ return 0;
+ }
+ if ((args[i].length() >= 2) && (args[i].startsWith("-"))) {
+ arg = Character.valueOf(args[i].charAt(1));
+ switch (arg.charValue()) {
+ case 'c':
+ action = 'c';
+ break;
+ case 'k':
+ action = 'k';
+ break;
+ case 'a':
+ options[2] = 'a';
+ break;
+ case 'n':
+ options[3] = 'n';
+ break;
+ case 'f':
+ options[1] = 'f';
+ break;
+ case 'e':
+ options[0] = 'e';
+ break;
+ case 'K':
+ options[1] = 'K';
+ break;
+ case 't':
+ options[2] = 't';
+ break;
+ default:
+ System.out.println("Invalid argument: " + args[i]);
+ printHelp();
+ return -1;
+ }
+ } else {
+ if (!args[i].startsWith("-") && (i == args.length - 1)) {
+ // the argument is the last one.
+ name = args[i];
+ } else {
+ System.out.println("Invalid argument: " + args[i]);
+ printHelp(); // incorrect input format.
+ return -1;
+ }
+ }
+ }
}
- switch (klist.action) {
+ switch (action) {
case 'c':
- if (klist.name == null) {
- klist.target = CredentialsCache.getInstance();
- klist.name = CredentialsCache.cacheName();
+ if (name == null) {
+ target = CredentialsCache.getInstance();
+ name = CredentialsCache.cacheName();
} else
- klist.target = CredentialsCache.getInstance(klist.name);
+ target = CredentialsCache.getInstance(name);
- if (klist.target != null) {
- klist.displayCache();
+ if (target != null) {
+ return displayCache();
} else {
- klist.displayMessage("Credentials cache");
- System.exit(-1);
+ return displayError("Credentials cache");
}
- break;
case 'k':
- KeyTab ktab = KeyTab.getInstance(klist.name);
+ KeyTab ktab = KeyTab.getInstance(name);
if (ktab.isMissing()) {
- System.out.println("KeyTab " + klist.name + " not found.");
- System.exit(-1);
+ System.out.println("KeyTab " + name + " not found.");
+ return -1;
} else if (!ktab.isValid()) {
- System.out.println("KeyTab " + klist.name
+ System.out.println("KeyTab " + name
+ " format not supported.");
- System.exit(-1);
+ return -1;
}
- klist.target = ktab;
- klist.name = ktab.tabName();
- klist.displayTab();
- break;
+ target = ktab;
+ name = ktab.tabName();
+ return displayTab();
default:
- if (klist.name != null) {
- klist.printHelp();
- System.exit(-1);
- } else {
- klist.target = CredentialsCache.getInstance();
- klist.name = CredentialsCache.cacheName();
- if (klist.target != null) {
- klist.displayCache();
- } else {
- klist.displayMessage("Credentials cache");
- System.exit(-1);
- }
- }
- }
- }
-
- /**
- * Parses the command line arguments.
- */
- void processArgs(String[] args) {
- Character arg;
- for (int i = 0; i < args.length; i++) {
- if (args[i].equals("-?") ||
- args[i].equals("-h") ||
- args[i].equals("--help")) {
+ if (name != null) {
printHelp();
- System.exit(0);
- }
- if ((args[i].length() >= 2) && (args[i].startsWith("-"))) {
- arg = Character.valueOf(args[i].charAt(1));
- switch (arg.charValue()) {
- case 'c':
- action = 'c';
- break;
- case 'k':
- action = 'k';
- break;
- case 'a':
- options[2] = 'a';
- break;
- case 'n':
- options[3] = 'n';
- break;
- case 'f':
- options[1] = 'f';
- break;
- case 'e':
- options[0] = 'e';
- break;
- case 'K':
- options[1] = 'K';
- break;
- case 't':
- options[2] = 't';
- break;
- default:
- printHelp();
- System.exit(-1);
- }
-
+ return -1;
} else {
- if (!args[i].startsWith("-") && (i == args.length - 1)) {
- // the argument is the last one.
- name = args[i];
- arg = null;
+ target = CredentialsCache.getInstance();
+ name = CredentialsCache.cacheName();
+ if (target != null) {
+ return displayCache();
} else {
- printHelp(); // incorrect input format.
- System.exit(-1);
+ return displayError("Credentials cache");
}
}
}
}
- void displayTab() {
+ int displayTab() {
KeyTab table = (KeyTab)target;
KeyTabEntry[] entries = table.getEntries();
if (entries.length == 0) {
@@ -201,7 +197,7 @@ void displayTab() {
entries.length + " entries found.\n");
for (int i = 0; i < entries.length; i++) {
System.out.println("[" + (i + 1) + "] " +
- "Service principal: " +
+ "Service principal: " +
entries[i].getService().toString());
System.out.println("\t KVNO: " +
entries[i].getKey().getKeyVersionNumber());
@@ -221,18 +217,19 @@ void displayTab() {
}
}
}
+ return 0;
}
- void displayCache() {
+ int displayCache() {
CredentialsCache cache = (CredentialsCache)target;
sun.security.krb5.internal.ccache.Credentials[] creds =
cache.getCredsList();
if (creds == null) {
System.out.println ("No credentials available in the cache " +
name);
- System.exit(-1);
+ return -1;
}
- System.out.println("\nCredentials cache: " + name);
+ System.out.println("\nCredentials cache: " + name);
String defaultPrincipal = cache.getPrimaryPrincipal().toString();
int num = creds.length;
@@ -327,7 +324,7 @@ void displayCache() {
if (DEBUG) {
e.printStackTrace();
}
- System.exit(-1);
+ return -1;
}
}
} else {
@@ -342,14 +339,17 @@ void displayCache() {
System.out.println(" " + e);
}
}
+
+ return 0;
}
- void displayMessage(String target) {
+ int displayError(String target) {
if (name == null) {
System.out.println("Default " + target + " not found.");
} else {
System.out.println(target + " " + name + " not found.");
}
+ return -1;
}
/**
* Reformats the date from the form -
@@ -359,7 +359,7 @@ void displayMessage(String target) {
* the day, mm is the minute within the hour,
* ss is the second within the minute, zzz is the time zone,
* and yyyy is the year.
- * @param date the string form of Date object.
+ * @param kt the string form of Date object.
*/
private String format(KerberosTime kt) {
String date = kt.toDate().toString();
diff --git a/src/java.security.jgss/windows/classes/sun/security/krb5/internal/tools/Ktab.java b/src/java.security.jgss/windows/classes/sun/security/krb5/internal/tools/Ktab.java
index df12b2d6c11dd..21002f3369a03 100644
--- a/src/java.security.jgss/windows/classes/sun/security/krb5/internal/tools/Ktab.java
+++ b/src/java.security.jgss/windows/classes/sun/security/krb5/internal/tools/Ktab.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2023, 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
@@ -73,52 +73,76 @@ public class Ktab {
*/
public static void main(String[] args) {
Ktab ktab = new Ktab();
+ int exitCode = ktab.run(args);
+ if (exitCode != 0) {
+ System.exit(exitCode);
+ }
+ }
+
+ private static class ExitException extends RuntimeException {
+ @java.io.Serial
+ static final long serialVersionUID = 0L;
+ private final int errorCode;
+ public ExitException(int errorCode) {
+ this.errorCode = errorCode;
+ }
+ }
+
+ public int run(String[] args) {
+ try {
+ run0(args);
+ return 0;
+ } catch (ExitException ee) {
+ return ee.errorCode;
+ }
+ }
+
+ private void run0(String[] args) throws ExitException {
if ((args.length == 1) &&
((args[0].equalsIgnoreCase("-?")) ||
(args[0].equalsIgnoreCase("-h")) ||
(args[0].equalsIgnoreCase("--help")) ||
// -help: legacy.
(args[0].equalsIgnoreCase("-help")))) {
- ktab.printHelp();
- System.exit(0);
+ printHelp();
return;
} else if ((args == null) || (args.length == 0)) {
- ktab.action = 'l';
+ action = 'l';
} else {
- ktab.processArgs(args);
+ processArgs(args);
}
- ktab.table = KeyTab.getInstance(ktab.name);
- if (ktab.table.isMissing() && ktab.action != 'a') {
- if (ktab.name == null) {
+ table = KeyTab.getInstance(name);
+ if (table.isMissing() && action != 'a') {
+ if (name == null) {
System.out.println("No default key table exists.");
} else {
System.out.println("Key table " +
- ktab.name + " does not exist.");
+ name + " does not exist.");
}
- System.exit(-1);
+ throw new ExitException(-1);
}
- if (!ktab.table.isValid()) {
- if (ktab.name == null) {
+ if (!table.isValid()) {
+ if (name == null) {
System.out.println("The format of the default key table " +
" is incorrect.");
} else {
System.out.println("The format of key table " +
- ktab.name + " is incorrect.");
+ name + " is incorrect.");
}
- System.exit(-1);
+ throw new ExitException(-1);
}
- switch (ktab.action) {
+ switch (action) {
case 'l':
- ktab.listKt();
+ listKt();
break;
case 'a':
- ktab.addEntry();
+ addEntry();
break;
case 'd':
- ktab.deleteEntry();
+ deleteEntry();
break;
default:
- ktab.error("A command must be provided");
+ error("A command must be provided");
}
}
@@ -267,7 +291,7 @@ void processArgs(String[] args) {
void addEntry() {
if (salt != null && fopt) {
System.err.println("-s and -f cannot coexist when adding a keytab entry.");
- System.exit(-1);
+ throw new ExitException(-1);
}
PrincipalName pname = null;
try {
@@ -276,7 +300,7 @@ void addEntry() {
System.err.println("Failed to add " + principal +
" to keytab.");
e.printStackTrace();
- System.exit(-1);
+ throw new ExitException(-1);
}
if (password == null) {
try {
@@ -288,7 +312,7 @@ void addEntry() {
} catch (IOException e) {
System.err.println("Failed to read the password.");
e.printStackTrace();
- System.exit(-1);
+ throw new ExitException(-1);
}
}
@@ -313,11 +337,11 @@ void addEntry() {
} catch (KrbException e) {
System.err.println("Failed to add " + principal + " to keytab.");
e.printStackTrace();
- System.exit(-1);
+ throw new ExitException(-1);
} catch (IOException e) {
System.err.println("Failed to save new entry.");
e.printStackTrace();
- System.exit(-1);
+ throw new ExitException(-1);
}
}
@@ -399,22 +423,23 @@ void deleteEntry() {
System.out.flush();
answer = cis.readLine();
if (answer.equalsIgnoreCase("Y") ||
- answer.equalsIgnoreCase("Yes"));
- else {
+ answer.equalsIgnoreCase("Yes")) {
+ ;
+ } else {
// no error, the user did not want to delete the entry
- System.exit(0);
+ return;
}
}
} catch (KrbException e) {
System.err.println("Error occurred while deleting the entry. "+
"Deletion failed.");
e.printStackTrace();
- System.exit(-1);
+ throw new ExitException(-1);
} catch (IOException e) {
System.err.println("Error occurred while deleting the entry. "+
" Deletion failed.");
e.printStackTrace();
- System.exit(-1);
+ throw new ExitException(-1);
}
int count = table.deleteEntries(pname, etype, vDel);
@@ -422,7 +447,7 @@ void deleteEntry() {
if (count == 0) {
System.err.println("No matched entry in the keytab. " +
"Deletion fails.");
- System.exit(-1);
+ throw new ExitException(-1);
} else {
try {
table.save();
@@ -430,7 +455,7 @@ void deleteEntry() {
System.err.println("Error occurs while saving the keytab. " +
"Deletion fails.");
e.printStackTrace();
- System.exit(-1);
+ throw new ExitException(-1);
}
System.out.println("Done! " + count + " entries removed.");
}
@@ -441,7 +466,7 @@ void error(String... errors) {
System.out.println("Error: " + error + ".");
}
printHelp();
- System.exit(-1);
+ throw new ExitException(-1);
}
/**
diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java
index 295bb192a4288..ab84d372bd72d 100644
--- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java
+++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Resolve.java
@@ -3605,6 +3605,18 @@ ReferenceKind referenceKind(Symbol sym) {
ReferenceKind.BOUND;
}
}
+
+ @Override
+ Symbol access(Env env, DiagnosticPosition pos, Symbol location, Symbol sym) {
+ if (originalSite.hasTag(TYPEVAR) && sym.kind == MTH) {
+ sym = (sym.flags() & Flags.PRIVATE) != 0 ?
+ new AccessError(env, site, sym) :
+ sym;
+ return accessBase(sym, pos, location, originalSite, name, true);
+ } else {
+ return super.access(env, pos, location, sym);
+ }
+ }
}
/**
diff --git a/src/jdk.jartool/share/classes/sun/security/tools/jarsigner/Main.java b/src/jdk.jartool/share/classes/sun/security/tools/jarsigner/Main.java
index 117fea688c71b..ed2c9be854310 100644
--- a/src/jdk.jartool/share/classes/sun/security/tools/jarsigner/Main.java
+++ b/src/jdk.jartool/share/classes/sun/security/tools/jarsigner/Main.java
@@ -135,7 +135,19 @@ public class Main {
// This is the entry that get launched by the security tool jarsigner.
public static void main(String args[]) throws Exception {
Main js = new Main();
- js.run(args);
+ int exitCode = js.run(args);
+ if (exitCode != 0) {
+ System.exit(exitCode);
+ }
+ }
+
+ private static class ExitException extends RuntimeException {
+ @java.io.Serial
+ static final long serialVersionUID = 0L;
+ private final int errorCode;
+ public ExitException(int errorCode) {
+ this.errorCode = errorCode;
+ }
}
X509Certificate[] certChain; // signer's cert chain (when composing)
@@ -230,13 +242,13 @@ public static void main(String args[]) throws Exception {
PKIXBuilderParameters pkixParameters;
Set trustedCerts = new HashSet<>();
- public void run(String args[]) {
+ public int run(String args[]) {
try {
- args = parseArgs(args);
+ parseArgs(args);
// Try to load and install the specified providers
if (providers != null) {
- for (String provName: providers) {
+ for (String provName : providers) {
try {
KeyStoreUtil.loadProviderByName(provName,
providerArgs.get(provName));
@@ -263,7 +275,7 @@ public void run(String args[]) {
} else {
cl = ClassLoader.getSystemClassLoader();
}
- for (String provClass: providerClasses) {
+ for (String provClass : providerClasses) {
try {
KeyStoreUtil.loadProviderByClass(provClass,
providerArgs.get(provClass), cl);
@@ -285,19 +297,9 @@ public void run(String args[]) {
loadKeyStore(keystore, false);
} catch (Exception e) {
if ((keystore != null) || (storepass != null)) {
- System.out.println(rb.getString("jarsigner.error.") +
- e.getMessage());
- if (debug) {
- e.printStackTrace();
- }
- System.exit(1);
+ throw e;
}
}
- /* if (debug) {
- SignatureFileVerifier.setDebug(true);
- ManifestEntryVerifier.setDebug(true);
- }
- */
verifyJar(jarfile);
} else {
loadKeyStore(keystore, true);
@@ -305,12 +307,14 @@ public void run(String args[]) {
signJar(jarfile, alias);
}
+ } catch (ExitException ee) {
+ return ee.errorCode;
} catch (Exception e) {
System.out.println(rb.getString("jarsigner.error.") + e);
if (debug) {
e.printStackTrace();
}
- System.exit(1);
+ return 1;
} finally {
// zero-out private key password
if (keypass != null) {
@@ -343,10 +347,10 @@ public void run(String args[]) {
if (tsaChainNotValidated) {
exitCode |= 64;
}
- if (exitCode != 0) {
- System.exit(exitCode);
- }
+ return exitCode;
}
+
+ return 0;
}
/*
@@ -612,12 +616,12 @@ static void usageNoArg() {
static void usage() {
System.out.println();
System.out.println(rb.getString("Please.type.jarsigner.help.for.usage"));
- System.exit(1);
+ throw new ExitException(1);
}
static void doPrintVersion() {
System.out.println("jarsigner " + System.getProperty("java.version"));
- System.exit(0);
+ throw new ExitException(0);
}
static void fullusage() {
@@ -719,7 +723,7 @@ static void fullusage() {
(".print.this.help.message"));
System.out.println();
- System.exit(0);
+ throw new ExitException(0);
}
void verifyJar(String jarName)
@@ -1105,19 +1109,11 @@ void verifyJar(String jarName)
} else {
displayMessagesAndResult(false);
}
- return;
- } catch (Exception e) {
- System.out.println(rb.getString("jarsigner.") + e);
- if (debug) {
- e.printStackTrace();
- }
} finally { // close the resource
if (jf != null) {
jf.close();
}
}
-
- System.exit(1);
}
private void displayMessagesAndResult(boolean isSigning) {
@@ -2469,7 +2465,7 @@ void getAliasInfo(String alias) throws Exception {
void error(String message) {
System.out.println(rb.getString("jarsigner.")+message);
- System.exit(1);
+ throw new ExitException(1);
}
@@ -2478,7 +2474,7 @@ void error(String message, Throwable e) {
if (debug) {
e.printStackTrace();
}
- System.exit(1);
+ throw new ExitException(1);
}
/**
diff --git a/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacAppBundler.java b/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacAppBundler.java
index cf031cb47a5ee..06796db98847a 100644
--- a/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacAppBundler.java
+++ b/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacAppBundler.java
@@ -85,6 +85,13 @@ public MacAppBundler() {
},
(s, p) -> s);
+ public static final BundlerParamInfo APP_IMAGE_SIGN_IDENTITY =
+ new StandardBundlerParam<>(
+ Arguments.CLIOptions.MAC_APP_IMAGE_SIGN_IDENTITY.getId(),
+ String.class,
+ params -> "",
+ null);
+
public static final BundlerParamInfo BUNDLE_ID_SIGNING_PREFIX =
new StandardBundlerParam<>(
Arguments.CLIOptions.MAC_BUNDLE_SIGNING_PREFIX.getId(),
@@ -127,14 +134,21 @@ private static void doValidate(Map params)
// reject explicitly set sign to true and no valid signature key
if (Optional.ofNullable(
SIGN_BUNDLE.fetchFrom(params)).orElse(Boolean.FALSE)) {
- String signingIdentity =
- DEVELOPER_ID_APP_SIGNING_KEY.fetchFrom(params);
- if (signingIdentity == null) {
- throw new ConfigException(
- I18N.getString("error.explicit-sign-no-cert"),
- I18N.getString("error.explicit-sign-no-cert.advice"));
+ // Validate DEVELOPER_ID_APP_SIGNING_KEY only if user provided
+ // SIGNING_KEY_USER.
+ if (!SIGNING_KEY_USER.getIsDefaultValue(params)) { // --mac-signing-key-user-name
+ String signingIdentity =
+ DEVELOPER_ID_APP_SIGNING_KEY.fetchFrom(params);
+ if (signingIdentity == null) {
+ throw new ConfigException(
+ I18N.getString("error.explicit-sign-no-cert"),
+ I18N.getString("error.explicit-sign-no-cert.advice"));
+ }
}
+ // No need to validate --mac-app-image-sign-identity, since it is
+ // pass through option.
+
// Signing will not work without Xcode with command line developer tools
try {
ProcessBuilder pb = new ProcessBuilder("/usr/bin/xcrun", "--help");
diff --git a/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacAppImageBuilder.java b/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacAppImageBuilder.java
index d9250ae147409..ea86c41d98128 100644
--- a/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacAppImageBuilder.java
+++ b/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacAppImageBuilder.java
@@ -25,8 +25,10 @@
package jdk.jpackage.internal;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.io.PrintStream;
import java.io.Writer;
import java.nio.file.Files;
import java.nio.file.Path;
@@ -53,7 +55,10 @@
import jdk.internal.util.OSVersion;
import static jdk.jpackage.internal.MacAppBundler.BUNDLE_ID_SIGNING_PREFIX;
import static jdk.jpackage.internal.MacAppBundler.DEVELOPER_ID_APP_SIGNING_KEY;
+import static jdk.jpackage.internal.MacAppBundler.APP_IMAGE_SIGN_IDENTITY;
import static jdk.jpackage.internal.MacBaseInstallerBundler.SIGNING_KEYCHAIN;
+import static jdk.jpackage.internal.MacBaseInstallerBundler.SIGNING_KEY_USER;
+import static jdk.jpackage.internal.MacBaseInstallerBundler.INSTALLER_SIGN_IDENTITY;
import static jdk.jpackage.internal.OverridableResource.createResource;
import static jdk.jpackage.internal.StandardBundlerParam.APP_NAME;
import static jdk.jpackage.internal.StandardBundlerParam.CONFIG_ROOT;
@@ -395,12 +400,25 @@ private void doSigning(Map params)
} catch (InterruptedException e) {
Log.error(e.getMessage());
}
- String signingIdentity =
- DEVELOPER_ID_APP_SIGNING_KEY.fetchFrom(params);
+ String signingIdentity = null;
+ // Try --mac-app-image-sign-identity first if set
+ if (!APP_IMAGE_SIGN_IDENTITY.getIsDefaultValue(params)) {
+ signingIdentity = APP_IMAGE_SIGN_IDENTITY.fetchFrom(params);
+ } else {
+ // Check if INSTALLER_SIGN_IDENTITY is set and if it is set
+ // then do not sign app image, otherwise use --mac-signing-key-user-name
+ if (INSTALLER_SIGN_IDENTITY.getIsDefaultValue(params)) {
+ // --mac-sign and/or --mac-signing-key-user-name case
+ signingIdentity = DEVELOPER_ID_APP_SIGNING_KEY.fetchFrom(params);
+ }
+ }
if (signingIdentity != null) {
signAppBundle(params, root, signingIdentity,
BUNDLE_ID_SIGNING_PREFIX.fetchFrom(params),
ENTITLEMENTS.fetchFrom(params));
+ } else {
+ // Case when user requested to sign installer only
+ signAppBundle(params, root, "-", null, null);
}
restoreKeychainList(params);
} else if (OperatingSystem.isMacOS()) {
@@ -715,6 +733,25 @@ private static List getCodesignArgs(
return args;
}
+ private static void runCodesign(ProcessBuilder pb, boolean quiet)
+ throws IOException {
+ try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ PrintStream ps = new PrintStream(baos)) {
+ try {
+ IOUtils.exec(pb, false, ps, false,
+ Executor.INFINITE_TIMEOUT, quiet);
+ } catch (IOException ioe) {
+ // Log output of "codesign" in case of
+ // error. It should help user to diagnose
+ // issue when using --mac-app-image-sign-identity
+ Log.info(MessageFormat.format(I18N.getString(
+ "error.tool.failed.with.output"), "codesign"));
+ Log.info(baos.toString().strip());
+ throw ioe;
+ }
+ }
+ }
+
static void signAppBundle(
Map params, Path appLocation,
String signingIdentity, String identifierPrefix, Path entitlements)
@@ -781,8 +818,7 @@ static void signAppBundle(
p.toFile().setWritable(true, true);
ProcessBuilder pb = new ProcessBuilder(args);
// run quietly
- IOUtils.exec(pb, false, null, false,
- Executor.INFINITE_TIMEOUT, true);
+ runCodesign(pb, true);
Files.setPosixFilePermissions(p, oldPermissions);
} catch (IOException ioe) {
toThrow.set(ioe);
@@ -810,8 +846,7 @@ static void signAppBundle(
List args = getCodesignArgs(true, path, signingIdentity,
identifierPrefix, entitlements, keyChain);
ProcessBuilder pb = new ProcessBuilder(args);
-
- IOUtils.exec(pb);
+ runCodesign(pb, false);
} catch (IOException e) {
toThrow.set(e);
}
@@ -842,8 +877,7 @@ static void signAppBundle(
List args = getCodesignArgs(true, appLocation, signingIdentity,
identifierPrefix, entitlements, keyChain);
ProcessBuilder pb = new ProcessBuilder(args);
-
- IOUtils.exec(pb);
+ runCodesign(pb, false);
}
private static String extractBundleIdentifier(Map params) {
diff --git a/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacBaseInstallerBundler.java b/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacBaseInstallerBundler.java
index b4f63d66f5722..8d9db0a007783 100644
--- a/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacBaseInstallerBundler.java
+++ b/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacBaseInstallerBundler.java
@@ -79,6 +79,13 @@ public abstract class MacBaseInstallerBundler extends AbstractBundler {
params -> "",
null);
+ public static final BundlerParamInfo INSTALLER_SIGN_IDENTITY =
+ new StandardBundlerParam<>(
+ Arguments.CLIOptions.MAC_INSTALLER_SIGN_IDENTITY.getId(),
+ String.class,
+ params -> "",
+ null);
+
public static final BundlerParamInfo MAC_INSTALLER_NAME =
new StandardBundlerParam<> (
"mac.installerName",
diff --git a/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacPkgBundler.java b/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacPkgBundler.java
index 60cd11b6f06f8..6ac84975451b4 100644
--- a/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacPkgBundler.java
+++ b/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacPkgBundler.java
@@ -28,7 +28,9 @@
import jdk.internal.util.Architecture;
import jdk.internal.util.OSVersion;
+import java.io.ByteArrayOutputStream;
import java.io.IOException;
+import java.io.PrintStream;
import java.io.PrintWriter;
import java.net.URI;
import java.net.URISyntaxException;
@@ -54,6 +56,8 @@
import static jdk.jpackage.internal.StandardBundlerParam.SIGN_BUNDLE;
import static jdk.jpackage.internal.MacBaseInstallerBundler.SIGNING_KEYCHAIN;
import static jdk.jpackage.internal.MacBaseInstallerBundler.SIGNING_KEY_USER;
+import static jdk.jpackage.internal.MacBaseInstallerBundler.INSTALLER_SIGN_IDENTITY;
+import static jdk.jpackage.internal.MacAppBundler.APP_IMAGE_SIGN_IDENTITY;
import static jdk.jpackage.internal.StandardBundlerParam.APP_STORE;
import static jdk.jpackage.internal.MacAppImageBuilder.MAC_CF_BUNDLE_IDENTIFIER;
import static jdk.jpackage.internal.OverridableResource.createResource;
@@ -605,8 +609,19 @@ private Path createPKG(Map params,
Log.verbose(I18N.getString("message.signing.pkg"));
}
- String signingIdentity =
- DEVELOPER_ID_INSTALLER_SIGNING_KEY.fetchFrom(params);
+ String signingIdentity = null;
+ // --mac-installer-sign-identity
+ if (!INSTALLER_SIGN_IDENTITY.getIsDefaultValue(params)) {
+ signingIdentity = INSTALLER_SIGN_IDENTITY.fetchFrom(params);
+ } else {
+ // Use --mac-signing-key-user-name if user did not request
+ // to sign just app image using --mac-app-image-sign-identity
+ if (APP_IMAGE_SIGN_IDENTITY.getIsDefaultValue(params)) {
+ // --mac-signing-key-user-name
+ signingIdentity = DEVELOPER_ID_INSTALLER_SIGNING_KEY.fetchFrom(params);
+ }
+ }
+
if (signingIdentity != null) {
commandLine.add("--sign");
commandLine.add(signingIdentity);
@@ -638,7 +653,21 @@ private Path createPKG(Map params,
commandLine.add(finalPKG.toAbsolutePath().toString());
pb = new ProcessBuilder(commandLine);
- IOUtils.exec(pb, false, null, true, Executor.INFINITE_TIMEOUT);
+
+ try (ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ PrintStream ps = new PrintStream(baos)) {
+ try {
+ IOUtils.exec(pb, false, ps, true, Executor.INFINITE_TIMEOUT);
+ } catch (IOException ioe) {
+ // Log output of "productbuild" in case of
+ // error. It should help user to diagnose
+ // issue when using --mac-installer-sign-identity
+ Log.info(MessageFormat.format(I18N.getString(
+ "error.tool.failed.with.output"), "productbuild"));
+ Log.info(baos.toString().strip());
+ throw ioe;
+ }
+ }
return finalPKG;
} catch (Exception ignored) {
@@ -702,14 +731,19 @@ public boolean validate(Map params)
// reject explicitly set sign to true and no valid signature key
if (Optional.ofNullable(
SIGN_BUNDLE.fetchFrom(params)).orElse(Boolean.FALSE)) {
- String signingIdentity =
- DEVELOPER_ID_INSTALLER_SIGNING_KEY.fetchFrom(params);
- if (signingIdentity == null) {
- throw new ConfigException(
- I18N.getString("error.explicit-sign-no-cert"),
- I18N.getString(
- "error.explicit-sign-no-cert.advice"));
+ if (!SIGNING_KEY_USER.getIsDefaultValue(params)) {
+ String signingIdentity =
+ DEVELOPER_ID_INSTALLER_SIGNING_KEY.fetchFrom(params);
+ if (signingIdentity == null) {
+ throw new ConfigException(
+ I18N.getString("error.explicit-sign-no-cert"),
+ I18N.getString(
+ "error.explicit-sign-no-cert.advice"));
+ }
}
+
+ // No need to validate --mac-installer-sign-identity, since it is
+ // pass through option.
}
// hdiutil is always available so there's no need
diff --git a/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/resources/MacResources.properties b/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/resources/MacResources.properties
index c575df2494e02..de4e7157b2ae3 100644
--- a/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/resources/MacResources.properties
+++ b/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/resources/MacResources.properties
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2017, 2023, 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
@@ -44,6 +44,7 @@ error.no.xcode.signing.advice=Install Xcode with command line developer tools.
error.cert.not.found=No certificate found matching [{0}] using keychain [{1}]
error.multiple.certs.found=WARNING: Multiple certificates found matching [{0}] using keychain [{1}], using first one
error.app-image.mac-sign.required=Error: --mac-sign option is required with predefined application image and with type [app-image]
+error.tool.failed.with.output=Error: "{0}" failed with following output:
resource.bundle-config-file=Bundle config file
resource.app-info-plist=Application Info.plist
resource.runtime-info-plist=Java Runtime Info.plist
diff --git a/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/resources/MacResources_de.properties b/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/resources/MacResources_de.properties
index 6dd037c9bce05..8586041d417f9 100644
--- a/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/resources/MacResources_de.properties
+++ b/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/resources/MacResources_de.properties
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2017, 2023, 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
@@ -44,6 +44,7 @@ error.no.xcode.signing.advice=Installieren Sie Xcode mit Befehlszeilen-Entwickle
error.cert.not.found=Kein Zertifikat gefunden, das [{0}] mit Schlรผsselbund [{1}] entspricht
error.multiple.certs.found=WARNUNG: Mehrere Zertifikate gefunden, die [{0}] mit Schlรผsselbund [{1}] entsprechen. Es wird das erste Zertifikat verwendet
error.app-image.mac-sign.required=Fehler: Die Option "--mac-sign" ist mit einem vordefinierten Anwendungsimage und Typ [app-image] erforderlich
+error.tool.failed.with.output=Error: "{0}" failed with following output:
resource.bundle-config-file=Bundle-Konfigurationsdatei
resource.app-info-plist=Info.plist der Anwendung
resource.runtime-info-plist=Info.plist von Java Runtime
diff --git a/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/resources/MacResources_ja.properties b/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/resources/MacResources_ja.properties
index b75d1dc465f36..518e3e45f97e9 100644
--- a/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/resources/MacResources_ja.properties
+++ b/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/resources/MacResources_ja.properties
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2017, 2023, 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
@@ -44,6 +44,7 @@ error.no.xcode.signing.advice=Xcodeใจใณใใณใใฉใคใณใปใใใญใใใป
error.cert.not.found=ใญใผใใงใผใณ[{1}]ใไฝฟ็จใใ[{0}]ใจไธ่ดใใ่จผๆๆธใ่ฆใคใใใพใใ
error.multiple.certs.found=่ญฆๅ: ใญใผใใงใผใณ[{1}]ใไฝฟ็จใใ[{0}]ใจไธ่ดใใ่คๆฐใฎ่จผๆๆธใ่ฆใคใใใพใใใๆๅใฎใใฎใไฝฟ็จใใพใ
error.app-image.mac-sign.required=ใจใฉใผ: --mac-signใชใใทใงใณใฏใไบๅๅฎ็พฉๆธใขใใชใฑใผใทใงใณใปใคใกใผใธใใใณใฟใคใ[app-image]ใงๅฟ
่ฆใงใ
+error.tool.failed.with.output=Error: "{0}" failed with following output:
resource.bundle-config-file=ใใณใใซๆงๆใใกใคใซ
resource.app-info-plist=ใขใใชใฑใผใทใงใณใฎInfo.plist
resource.runtime-info-plist=Javaใฉใณใฟใคใ ใฎInfo.plist
diff --git a/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/resources/MacResources_zh_CN.properties b/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/resources/MacResources_zh_CN.properties
index dc1f592852dd9..c4e4bd2293950 100644
--- a/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/resources/MacResources_zh_CN.properties
+++ b/src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/resources/MacResources_zh_CN.properties
@@ -1,5 +1,5 @@
#
-# Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2017, 2023, 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
@@ -44,6 +44,7 @@ error.no.xcode.signing.advice=ๅฎ่ฃ
ๅธฆๅฝไปค่กๅผๅไบบๅๅทฅๅ
ท็ Xcodeใ
error.cert.not.found=ไฝฟ็จๅฏ้ฅ้พ [{1}] ๆพไธๅฐไธ [{0}] ๅน้
็่ฏไนฆ
error.multiple.certs.found=่ญฆๅ๏ผไฝฟ็จๅฏ้ฅ้พ [{1}] ๆพๅฐๅคไธชไธ [{0}] ๅน้
็่ฏไนฆ๏ผๅฐไฝฟ็จ็ฌฌไธไธช่ฏไนฆ
error.app-image.mac-sign.required=้่ฏฏ๏ผ้ขๅฎไน็ๅบ็จ็จๅบๆ ๅๅ็ฑปๅ [app image] ้่ฆ --mac-sign ้้กน
+error.tool.failed.with.output=Error: "{0}" failed with following output:
resource.bundle-config-file=ๅ
้
็ฝฎๆไปถ
resource.app-info-plist=ๅบ็จ็จๅบ Info.plist
resource.runtime-info-plist=Java ่ฟ่กๆถ Info.plist
diff --git a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/Arguments.java b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/Arguments.java
index b4a28e7fb3c4e..16cd89d9d52d0 100644
--- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/Arguments.java
+++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/Arguments.java
@@ -338,6 +338,12 @@ public enum CLIOptions {
MAC_SIGNING_KEY_NAME ("mac-signing-key-user-name",
OptionCategories.PLATFORM_MAC),
+ MAC_APP_IMAGE_SIGN_IDENTITY ("mac-app-image-sign-identity",
+ OptionCategories.PLATFORM_MAC),
+
+ MAC_INSTALLER_SIGN_IDENTITY ("mac-installer-sign-identity",
+ OptionCategories.PLATFORM_MAC),
+
MAC_SIGNING_KEYCHAIN ("mac-signing-keychain",
OptionCategories.PLATFORM_MAC),
@@ -631,6 +637,24 @@ private void validateArguments() throws PackagerException {
CLIOptions.JLINK_OPTIONS.getIdWithPrefix());
}
}
+ if (allOptions.contains(CLIOptions.MAC_SIGNING_KEY_NAME) &&
+ allOptions.contains(CLIOptions.MAC_APP_IMAGE_SIGN_IDENTITY)) {
+ throw new PackagerException("ERR_MutuallyExclusiveOptions",
+ CLIOptions.MAC_SIGNING_KEY_NAME.getIdWithPrefix(),
+ CLIOptions.MAC_APP_IMAGE_SIGN_IDENTITY.getIdWithPrefix());
+ }
+ if (allOptions.contains(CLIOptions.MAC_SIGNING_KEY_NAME) &&
+ allOptions.contains(CLIOptions.MAC_INSTALLER_SIGN_IDENTITY)) {
+ throw new PackagerException("ERR_MutuallyExclusiveOptions",
+ CLIOptions.MAC_SIGNING_KEY_NAME.getIdWithPrefix(),
+ CLIOptions.MAC_INSTALLER_SIGN_IDENTITY.getIdWithPrefix());
+ }
+ if (isMac && (imageOnly || "dmg".equals(type)) &&
+ allOptions.contains(CLIOptions.MAC_INSTALLER_SIGN_IDENTITY)) {
+ throw new PackagerException("ERR_InvalidTypeOption",
+ CLIOptions.MAC_INSTALLER_SIGN_IDENTITY.getIdWithPrefix(),
+ type);
+ }
if (allOptions.contains(CLIOptions.DMG_CONTENT)
&& !("dmg".equals(type))) {
throw new PackagerException("ERR_InvalidTypeOption",
diff --git a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/BundlerParamInfo.java b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/BundlerParamInfo.java
index 4173980002bb8..fa99073ff7f79 100644
--- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/BundlerParamInfo.java
+++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/BundlerParamInfo.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2014, 2023, 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
@@ -46,11 +46,6 @@ class BundlerParamInfo {
*/
Class valueType;
- /**
- * Indicates if value was set using default value function
- */
- boolean isDefaultValue;
-
/**
* If the value is not set, and no fallback value is found,
* the parameter uses the value returned by the producer.
@@ -70,8 +65,24 @@ Class getValueType() {
return valueType;
}
- boolean getIsDefaultValue() {
- return isDefaultValue;
+ /**
+ * Returns true if value was not provided on command line for this
+ * parameter.
+ *
+ * @param params - params from which value will be fetch
+ * @return true if value was not provided on command line, false otherwise
+ */
+ boolean getIsDefaultValue(Map params) {
+ Object o = params.get(getID());
+ if (o != null) {
+ return false; // We have user provided value
+ }
+
+ if (params.containsKey(getID())) {
+ return false; // explicit nulls are allowed for provided value
+ }
+
+ return true;
}
Function