diff --git a/.github/actions/build-jtreg/action.yml b/.github/actions/build-jtreg/action.yml new file mode 100644 index 00000000000..3e5ced8a7f8 --- /dev/null +++ b/.github/actions/build-jtreg/action.yml @@ -0,0 +1,84 @@ +# +# Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +name: 'Build JTReg' +description: 'Build JTReg' + +runs: + using: composite + steps: + - name: 'Get JTReg version configuration' + id: version + uses: ./.github/actions/config + with: + var: JTREG_VERSION + + - name: 'Check cache for already built JTReg' + id: get-cached + uses: actions/cache@v4 + with: + path: jtreg/installed + key: jtreg-${{ steps.version.outputs.value }} + + - name: 'Checkout the JTReg source' + uses: actions/checkout@v4 + with: + repository: openjdk/jtreg + ref: jtreg-${{ steps.version.outputs.value }} + path: jtreg/src + if: (steps.get-cached.outputs.cache-hit != 'true') + + - name: 'Build JTReg' + run: | + # Try building JTReg several times, backing off exponentially on failure. + # ~500 seconds in total should be enough to capture most of the transient + # failures. + for I in `seq 0 8`; do + rm -rf build/images/jtreg + bash make/build.sh --jdk "$JAVA_HOME_17_X64" && break + S=$(( 2 ** $I )) + echo "Failure. Waiting $S seconds before retrying" + sleep $S + done + + # Check if build was successful + if [ ! -d build/images/jtreg ]; then + echo "Build failed" + exit 1; + fi + + # Move files to the proper locations + mkdir ../installed + mv build/images/jtreg/* ../installed + working-directory: jtreg/src + shell: bash + if: (steps.get-cached.outputs.cache-hit != 'true') + + - name: 'Upload JTReg artifact' + uses: actions/upload-artifact@v4 + with: + name: bundles-jtreg-${{ steps.version.outputs.value }} + path: jtreg/installed + retention-days: 1 diff --git a/.github/actions/get-jtreg/action.yml b/.github/actions/get-jtreg/action.yml index faedcc18807..78a3a4c9edd 100644 --- a/.github/actions/get-jtreg/action.yml +++ b/.github/actions/get-jtreg/action.yml @@ -24,7 +24,7 @@ # name: 'Get JTReg' -description: 'Download JTReg from cache or source location' +description: 'Get JTReg' outputs: path: description: 'Path to the installed JTReg' @@ -39,36 +39,12 @@ runs: with: var: JTREG_VERSION - - name: 'Check cache for JTReg' - id: get-cached-jtreg - uses: actions/cache@v4 + - name: 'Download JTReg artifact' + id: download-jtreg + uses: actions/download-artifact@v4 with: + name: bundles-jtreg-${{ steps.version.outputs.value }} path: jtreg/installed - key: jtreg-${{ steps.version.outputs.value }} - - - name: 'Checkout the JTReg source' - uses: actions/checkout@v4 - with: - repository: openjdk/jtreg - ref: jtreg-${{ steps.version.outputs.value }} - path: jtreg/src - if: steps.get-cached-jtreg.outputs.cache-hit != 'true' - - - name: 'Build JTReg' - run: | - # If runner architecture is x64 set JAVA_HOME_17_X64 otherwise set to JAVA_HOME_17_arm64 - if [[ '${{ runner.arch }}' == 'X64' ]]; then - JDK="$JAVA_HOME_17_X64" - else - JDK="$JAVA_HOME_17_arm64" - fi - # Build JTReg and move files to the proper locations - bash make/build.sh --jdk "$JDK" - mkdir ../installed - mv build/images/jtreg/* ../installed - working-directory: jtreg/src - shell: bash - if: steps.get-cached-jtreg.outputs.cache-hit != 'true' - name: 'Export path to where JTReg is installed' id: path-name diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d5958853701..00f64d2aedf 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -54,8 +54,8 @@ jobs: ### Determine platforms to include ### - select: - name: 'Select platforms' + prepare: + name: 'Prepare the run' runs-on: ubuntu-22.04 env: # List of platforms to exclude by default @@ -73,7 +73,19 @@ jobs: docs: ${{ steps.include.outputs.docs }} steps: - # This function must be inlined in main.yml, or we'd be forced to checkout the repo + - name: 'Checkout the scripts' + uses: actions/checkout@v4 + with: + sparse-checkout: | + .github + make/conf/github-actions.conf + + - name: 'Build JTReg' + id: jtreg + uses: ./.github/actions/build-jtreg + + # TODO: Now that we are checking out the repo scripts, we can put the following code + # into a separate file - name: 'Check what jobs to run' id: include run: | @@ -149,18 +161,18 @@ jobs: build-linux-x64: name: linux-x64 - needs: select + needs: prepare uses: ./.github/workflows/build-linux.yml with: platform: linux-x64 gcc-major-version: '10' configure-arguments: ${{ github.event.inputs.configure-arguments }} make-arguments: ${{ github.event.inputs.make-arguments }} - if: needs.select.outputs.linux-x64 == 'true' + if: needs.prepare.outputs.linux-x64 == 'true' build-linux-x86-hs: name: linux-x86-hs - needs: select + needs: prepare uses: ./.github/workflows/build-linux.yml with: platform: linux-x86 @@ -174,11 +186,11 @@ jobs: extra-conf-options: '--with-target-bits=32 --enable-fallback-linker --enable-libffi-bundling' configure-arguments: ${{ github.event.inputs.configure-arguments }} make-arguments: ${{ github.event.inputs.make-arguments }} - if: needs.select.outputs.linux-x86-hs == 'true' + if: needs.prepare.outputs.linux-x86-hs == 'true' build-linux-x64-hs-nopch: name: linux-x64-hs-nopch - needs: select + needs: prepare uses: ./.github/workflows/build-linux.yml with: platform: linux-x64 @@ -188,11 +200,11 @@ jobs: extra-conf-options: '--disable-precompiled-headers' configure-arguments: ${{ github.event.inputs.configure-arguments }} make-arguments: ${{ github.event.inputs.make-arguments }} - if: needs.select.outputs.linux-x64-variants == 'true' + if: needs.prepare.outputs.linux-x64-variants == 'true' build-linux-x64-hs-zero: name: linux-x64-hs-zero - needs: select + needs: prepare uses: ./.github/workflows/build-linux.yml with: platform: linux-x64 @@ -202,11 +214,11 @@ jobs: extra-conf-options: '--with-jvm-variants=zero --disable-precompiled-headers' configure-arguments: ${{ github.event.inputs.configure-arguments }} make-arguments: ${{ github.event.inputs.make-arguments }} - if: needs.select.outputs.linux-x64-variants == 'true' + if: needs.prepare.outputs.linux-x64-variants == 'true' build-linux-x64-hs-minimal: name: linux-x64-hs-minimal - needs: select + needs: prepare uses: ./.github/workflows/build-linux.yml with: platform: linux-x64 @@ -216,11 +228,11 @@ jobs: extra-conf-options: '--with-jvm-variants=minimal --disable-precompiled-headers' configure-arguments: ${{ github.event.inputs.configure-arguments }} make-arguments: ${{ github.event.inputs.make-arguments }} - if: needs.select.outputs.linux-x64-variants == 'true' + if: needs.prepare.outputs.linux-x64-variants == 'true' build-linux-x64-hs-optimized: name: linux-x64-hs-optimized - needs: select + needs: prepare uses: ./.github/workflows/build-linux.yml with: platform: linux-x64 @@ -231,32 +243,31 @@ jobs: extra-conf-options: '--with-debug-level=optimized --disable-precompiled-headers' configure-arguments: ${{ github.event.inputs.configure-arguments }} make-arguments: ${{ github.event.inputs.make-arguments }} - if: needs.select.outputs.linux-x64-variants == 'true' + if: needs.prepare.outputs.linux-x64-variants == 'true' build-linux-cross-compile: name: linux-cross-compile - needs: - - select + needs: prepare uses: ./.github/workflows/build-cross-compile.yml with: gcc-major-version: '10' configure-arguments: ${{ github.event.inputs.configure-arguments }} make-arguments: ${{ github.event.inputs.make-arguments }} - if: needs.select.outputs.linux-cross-compile == 'true' + if: needs.prepare.outputs.linux-cross-compile == 'true' build-alpine-linux-x64: name: alpine-linux-x64 - needs: select + needs: prepare uses: ./.github/workflows/build-alpine-linux.yml with: platform: alpine-linux-x64 configure-arguments: ${{ github.event.inputs.configure-arguments }} make-arguments: ${{ github.event.inputs.make-arguments }} - if: needs.select.outputs.alpine-linux-x64 == 'true' + if: needs.prepare.outputs.alpine-linux-x64 == 'true' build-macos-x64: name: macos-x64 - needs: select + needs: prepare uses: ./.github/workflows/build-macos.yml with: platform: macos-x64 @@ -264,11 +275,11 @@ jobs: xcode-toolset-version: '14.3.1' configure-arguments: ${{ github.event.inputs.configure-arguments }} make-arguments: ${{ github.event.inputs.make-arguments }} - if: needs.select.outputs.macos-x64 == 'true' + if: needs.prepare.outputs.macos-x64 == 'true' build-macos-aarch64: name: macos-aarch64 - needs: select + needs: prepare uses: ./.github/workflows/build-macos.yml with: platform: macos-aarch64 @@ -276,11 +287,11 @@ jobs: xcode-toolset-version: '14.3.1' configure-arguments: ${{ github.event.inputs.configure-arguments }} make-arguments: ${{ github.event.inputs.make-arguments }} - if: needs.select.outputs.macos-aarch64 == 'true' + if: needs.prepare.outputs.macos-aarch64 == 'true' build-windows-x64: name: windows-x64 - needs: select + needs: prepare uses: ./.github/workflows/build-windows.yml with: platform: windows-x64 @@ -288,11 +299,11 @@ jobs: msvc-toolset-architecture: 'x86.x64' configure-arguments: ${{ github.event.inputs.configure-arguments }} make-arguments: ${{ github.event.inputs.make-arguments }} - if: needs.select.outputs.windows-x64 == 'true' + if: needs.prepare.outputs.windows-x64 == 'true' build-windows-aarch64: name: windows-aarch64 - needs: select + needs: prepare uses: ./.github/workflows/build-windows.yml with: platform: windows-aarch64 @@ -302,11 +313,11 @@ jobs: extra-conf-options: '--openjdk-target=aarch64-unknown-cygwin' configure-arguments: ${{ github.event.inputs.configure-arguments }} make-arguments: ${{ github.event.inputs.make-arguments }} - if: needs.select.outputs.windows-aarch64 == 'true' + if: needs.prepare.outputs.windows-aarch64 == 'true' build-docs: name: docs - needs: select + needs: prepare uses: ./.github/workflows/build-linux.yml with: platform: linux-x64 @@ -318,7 +329,7 @@ jobs: gcc-major-version: '10' configure-arguments: ${{ github.event.inputs.configure-arguments }} make-arguments: ${{ github.event.inputs.make-arguments }} - if: needs.select.outputs.docs == 'true' + if: needs.prepare.outputs.docs == 'true' ### ### Test jobs @@ -363,48 +374,3 @@ jobs: platform: windows-x64 bootjdk-platform: windows-x64 runs-on: windows-2019 - - # Remove bundles so they are not misconstrued as binary distributions from the JDK project - remove-bundles: - name: 'Remove bundle artifacts' - runs-on: ubuntu-22.04 - if: always() - needs: - - build-linux-x64 - - build-linux-x86-hs - - build-linux-x64-hs-nopch - - build-linux-x64-hs-zero - - build-linux-x64-hs-minimal - - build-linux-x64-hs-optimized - - build-linux-cross-compile - - build-alpine-linux-x64 - - build-macos-x64 - - build-macos-aarch64 - - build-windows-x64 - - build-windows-aarch64 - - test-linux-x64 - - test-macos-x64 - - test-macos-aarch64 - - test-windows-x64 - - steps: - - name: 'Remove bundle artifacts' - run: | - # Find and remove all bundle artifacts - # See: https://docs.github.com/en/rest/actions/artifacts?apiVersion=2022-11-28 - ALL_ARTIFACT_IDS="$(curl -sL \ - -H 'Accept: application/vnd.github+json' \ - -H 'Authorization: Bearer ${{ github.token }}' \ - -H 'X-GitHub-Api-Version: 2022-11-28' \ - '${{ github.api_url }}/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts?per_page=100')" - BUNDLE_ARTIFACT_IDS="$(echo "$ALL_ARTIFACT_IDS" | jq -r -c '.artifacts | map(select(.name|startswith("bundles-"))) | .[].id')" - for id in $BUNDLE_ARTIFACT_IDS; do - echo "Removing $id" - curl -sL \ - -X DELETE \ - -H 'Accept: application/vnd.github+json' \ - -H 'Authorization: Bearer ${{ github.token }}' \ - -H 'X-GitHub-Api-Version: 2022-11-28' \ - "${{ github.api_url }}/repos/${{ github.repository }}/actions/artifacts/$id" \ - || echo "Failed to remove bundle" - done diff --git a/doc/building.html b/doc/building.html index c91d876246c..63af224584a 100644 --- a/doc/building.html +++ b/doc/building.html @@ -2016,10 +2016,18 @@

Spaces in Path

have short paths. You can run fsutil file setshortname in -cmd on certain directories, such as -Microsoft Visual Studio or Windows Kits, to -assign arbitrary short paths so configure can access -them.

+cmd on directories to assign arbitrary short paths so +configure can access them. If the result says "Access +denied", it may be that there are processes running in that directory; +in this case, you can reboot Windows in safe mode and run the command on +those directories again.

+

The only directories required to have short paths are +Microsoft Visual Studio and Windows Kits; the +rest of the "contains space" warnings from configure, such +as IntelliJ IDEA, can be ignored. You can choose any short +name; once it is set, configure's tools like +cygpath can convert the directory with spaces to your +chosen short name and pass it to the build system.

Getting Help

If none of the suggestions in this document helps you, or if you find what you believe is a bug in the build system, please contact the Build diff --git a/doc/building.md b/doc/building.md index 47ad9e7c72b..466e8d7edf8 100644 --- a/doc/building.md +++ b/doc/building.md @@ -1800,9 +1800,17 @@ temporarily. On Windows, when configuring, `fixpath.sh` may report that some directory names have spaces. Usually, it assumes those directories have [short paths](https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/fsutil-8dot3name). -You can run `fsutil file setshortname` in `cmd` on certain directories, such as -`Microsoft Visual Studio` or `Windows Kits`, to assign arbitrary short paths so -`configure` can access them. +You can run `fsutil file setshortname` in `cmd` on directories to assign +arbitrary short paths so `configure` can access them. If the result says "Access +denied", it may be that there are processes running in that directory; in this +case, you can reboot Windows in safe mode and run the command on those directories +again. + +The only directories required to have short paths are `Microsoft Visual Studio` +and `Windows Kits`; the rest of the "contains space" warnings from `configure`, +such as `IntelliJ IDEA`, can be ignored. You can choose any short name; once it +is set, `configure`'s tools like `cygpath` can convert the directory with spaces +to your chosen short name and pass it to the build system. ### Getting Help diff --git a/doc/testing.html b/doc/testing.html index b74661b3924..6285fab1682 100644 --- a/doc/testing.html +++ b/doc/testing.html @@ -72,6 +72,9 @@

Testing the JDK

  • Non-US locale
  • PKCS11 Tests
  • +
  • Testing with +alternative security providers
  • Client UI Tests
  • @@ -586,6 +589,18 @@

    PKCS11 Tests

    JTREG="JAVA_OPTIONS=-Djdk.test.lib.artifacts.nsslib-linux_aarch64=/path/to/NSS-libs"

    For more notes about the PKCS11 tests, please refer to test/jdk/sun/security/pkcs11/README.

    +

    Testing with +alternative security providers

    +

    Some security tests use a hardcoded provider for +KeyFactory, Cipher, +KeyPairGenerator, KeyGenerator, +AlgorithmParameterGenerator, KeyAgreement, +Mac, MessageDigest, SecureRandom, +Signature, AlgorithmParameters, +Configuration, Policy, or +SecretKeyFactory objects. Specify the +-Dtest.provider.name=NAME property to use a different +provider for the service(s).

    Client UI Tests

    System key shortcuts

    Some Client UI tests use key sequences which may be reserved by the diff --git a/doc/testing.md b/doc/testing.md index cdc9bbd2182..351690c5e60 100644 --- a/doc/testing.md +++ b/doc/testing.md @@ -603,6 +603,15 @@ $ make test TEST="jtreg:sun/security/pkcs11/Secmod/AddTrustedCert.java" \ For more notes about the PKCS11 tests, please refer to test/jdk/sun/security/pkcs11/README. +### Testing with alternative security providers + +Some security tests use a hardcoded provider for `KeyFactory`, `Cipher`, +`KeyPairGenerator`, `KeyGenerator`, `AlgorithmParameterGenerator`, +`KeyAgreement`, `Mac`, `MessageDigest`, `SecureRandom`, `Signature`, +`AlgorithmParameters`, `Configuration`, `Policy`, or `SecretKeyFactory` objects. +Specify the `-Dtest.provider.name=NAME` property to use a different provider for +the service(s). + ### Client UI Tests #### System key shortcuts diff --git a/make/RunTests.gmk b/make/RunTests.gmk index 45494b859b7..bfd55394b2f 100644 --- a/make/RunTests.gmk +++ b/make/RunTests.gmk @@ -853,11 +853,7 @@ define SetupRunJtregTestBody endif ifneq ($$(findstring -XX:+UseZGC, $$(JTREG_ALL_OPTIONS)), ) - ifneq ($$(findstring -XX:-ZGenerational, $$(JTREG_ALL_OPTIONS)), ) - JTREG_AUTO_PROBLEM_LISTS += ProblemList-zgc.txt - else - JTREG_AUTO_PROBLEM_LISTS += ProblemList-generational-zgc.txt - endif + JTREG_AUTO_PROBLEM_LISTS += ProblemList-zgc.txt endif ifneq ($$(JTREG_EXTRA_PROBLEM_LISTS), ) diff --git a/make/autoconf/lib-hsdis.m4 b/make/autoconf/lib-hsdis.m4 index bd78768d03e..a4d2c5f81f3 100644 --- a/make/autoconf/lib-hsdis.m4 +++ b/make/autoconf/lib-hsdis.m4 @@ -266,8 +266,10 @@ AC_DEFUN([LIB_SETUP_HSDIS_BINUTILS], HSDIS_CFLAGS="-DLIBARCH_$OPENJDK_TARGET_CPU_LEGACY_LIB" elif test "x$BINUTILS_INSTALL_DIR" != x; then disasm_header="\"$BINUTILS_INSTALL_DIR/include/dis-asm.h\"" - if test -e $BINUTILS_INSTALL_DIR/lib/libbfd.a && \ - test -e $BINUTILS_INSTALL_DIR/lib/libopcodes.a && \ + if (test -e $BINUTILS_INSTALL_DIR/lib/libbfd.a || \ + test -e $BINUTILS_INSTALL_DIR/lib64/libbfd.a) && \ + (test -e $BINUTILS_INSTALL_DIR/lib/libopcodes.a || \ + test -e $BINUTILS_INSTALL_DIR/lib64/libopcodes.a) && \ (test -e $BINUTILS_INSTALL_DIR/lib/libiberty.a || \ test -e $BINUTILS_INSTALL_DIR/lib64/libiberty.a || \ test -e $BINUTILS_INSTALL_DIR/lib32/libiberty.a); then @@ -275,7 +277,19 @@ AC_DEFUN([LIB_SETUP_HSDIS_BINUTILS], # libiberty ignores --libdir and may be installed in $BINUTILS_INSTALL_DIR/lib, $BINUTILS_INSTALL_DIR/lib32 # or $BINUTILS_INSTALL_DIR/lib64, depending on system setup + LIBOPCODES_LIB="" + LIBBFD_LIB="" LIBIBERTY_LIB="" + if test -e $BINUTILS_INSTALL_DIR/lib/libbfd.a; then + LIBBFD_LIB="$BINUTILS_INSTALL_DIR/lib/libbfd.a" + else + LIBBFD_LIB="$BINUTILS_INSTALL_DIR/lib64/libbfd.a" + fi + if test -e $BINUTILS_INSTALL_DIR/lib/libopcodes.a; then + LIBOPCODES_LIB="$BINUTILS_INSTALL_DIR/lib/libopcodes.a" + else + LIBOPCODES_LIB="$BINUTILS_INSTALL_DIR/lib64/libopcodes.a" + fi if test -e $BINUTILS_INSTALL_DIR/lib/libiberty.a; then LIBIBERTY_LIB="$BINUTILS_INSTALL_DIR/lib/libiberty.a" elif test -e $BINUTILS_INSTALL_DIR/lib32/libiberty.a; then @@ -283,7 +297,7 @@ AC_DEFUN([LIB_SETUP_HSDIS_BINUTILS], else LIBIBERTY_LIB="$BINUTILS_INSTALL_DIR/lib64/libiberty.a" fi - HSDIS_LIBS="$BINUTILS_INSTALL_DIR/lib/libbfd.a $BINUTILS_INSTALL_DIR/lib/libopcodes.a $LIBIBERTY_LIB" + HSDIS_LIBS="$LIBBFD_LIB $LIBOPCODES_LIB $LIBIBERTY_LIB" # If we have libsframe add it. if test -e $BINUTILS_INSTALL_DIR/lib/libsframe.a; then HSDIS_LIBS="$HSDIS_LIBS $BINUTILS_INSTALL_DIR/lib/libsframe.a" diff --git a/make/hotspot/gensrc/GensrcAdlc.gmk b/make/hotspot/gensrc/GensrcAdlc.gmk index ddb2c3e33e5..ce3f2684026 100644 --- a/make/hotspot/gensrc/GensrcAdlc.gmk +++ b/make/hotspot/gensrc/GensrcAdlc.gmk @@ -193,8 +193,6 @@ ifeq ($(call check-jvm-feature, compiler2), true) ifeq ($(call check-jvm-feature, zgc), true) AD_SRC_FILES += $(call uniq, $(wildcard $(foreach d, $(AD_SRC_ROOTS), \ - $d/cpu/$(HOTSPOT_TARGET_CPU_ARCH)/gc/x/x_$(HOTSPOT_TARGET_CPU).ad \ - $d/cpu/$(HOTSPOT_TARGET_CPU_ARCH)/gc/x/x_$(HOTSPOT_TARGET_CPU_ARCH).ad \ $d/cpu/$(HOTSPOT_TARGET_CPU_ARCH)/gc/z/z_$(HOTSPOT_TARGET_CPU).ad \ $d/cpu/$(HOTSPOT_TARGET_CPU_ARCH)/gc/z/z_$(HOTSPOT_TARGET_CPU_ARCH).ad \ ))) diff --git a/make/hotspot/lib/JvmFeatures.gmk b/make/hotspot/lib/JvmFeatures.gmk index c4c030810fc..b94031515f7 100644 --- a/make/hotspot/lib/JvmFeatures.gmk +++ b/make/hotspot/lib/JvmFeatures.gmk @@ -150,7 +150,6 @@ endif ifneq ($(call check-jvm-feature, zgc), true) JVM_CFLAGS_FEATURES += -DINCLUDE_ZGC=0 JVM_EXCLUDE_PATTERNS += gc/z - JVM_EXCLUDE_PATTERNS += gc/x endif ifneq ($(call check-jvm-feature, shenandoahgc), true) diff --git a/src/hotspot/cpu/aarch64/c1_LIRAssembler_aarch64.cpp b/src/hotspot/cpu/aarch64/c1_LIRAssembler_aarch64.cpp index ebd83027151..3d1be91e9b2 100644 --- a/src/hotspot/cpu/aarch64/c1_LIRAssembler_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/c1_LIRAssembler_aarch64.cpp @@ -990,10 +990,7 @@ void LIR_Assembler::mem2reg(LIR_Opr src, LIR_Opr dest, BasicType type, LIR_Patch __ decode_heap_oop(dest->as_register()); } - if (!(UseZGC && !ZGenerational)) { - // Load barrier has not yet been applied, so ZGC can't verify the oop here - __ verify_oop(dest->as_register()); - } + __ verify_oop(dest->as_register()); } } diff --git a/src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.cpp b/src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.cpp index 62831ee72ba..b29be7213ba 100644 --- a/src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/c2_MacroAssembler_aarch64.cpp @@ -217,7 +217,7 @@ void C2_MacroAssembler::fast_unlock(Register objectReg, Register boxReg, Registe // StoreLoad achieves this. membar(StoreLoad); - // Check if the entry lists are empty. + // Check if the entry lists are empty (EntryList first - by convention). ldr(rscratch1, Address(tmp, ObjectMonitor::EntryList_offset())); ldr(tmpReg, Address(tmp, ObjectMonitor::cxq_offset())); orr(rscratch1, rscratch1, tmpReg); @@ -538,7 +538,7 @@ void C2_MacroAssembler::fast_unlock_lightweight(Register obj, Register box, Regi // StoreLoad achieves this. membar(StoreLoad); - // Check if the entry lists are empty. + // Check if the entry lists are empty (EntryList first - by convention). ldr(rscratch1, Address(t1_monitor, ObjectMonitor::EntryList_offset())); ldr(t3_t, Address(t1_monitor, ObjectMonitor::cxq_offset())); orr(rscratch1, rscratch1, t3_t); diff --git a/src/hotspot/cpu/aarch64/gc/x/xBarrierSetAssembler_aarch64.cpp b/src/hotspot/cpu/aarch64/gc/x/xBarrierSetAssembler_aarch64.cpp deleted file mode 100644 index 5c891e8c170..00000000000 --- a/src/hotspot/cpu/aarch64/gc/x/xBarrierSetAssembler_aarch64.cpp +++ /dev/null @@ -1,462 +0,0 @@ -/* - * Copyright (c) 2019, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "asm/macroAssembler.inline.hpp" -#include "code/codeBlob.hpp" -#include "code/vmreg.inline.hpp" -#include "gc/x/xBarrier.inline.hpp" -#include "gc/x/xBarrierSet.hpp" -#include "gc/x/xBarrierSetAssembler.hpp" -#include "gc/x/xBarrierSetRuntime.hpp" -#include "gc/x/xThreadLocalData.hpp" -#include "memory/resourceArea.hpp" -#include "runtime/sharedRuntime.hpp" -#include "utilities/macros.hpp" -#ifdef COMPILER1 -#include "c1/c1_LIRAssembler.hpp" -#include "c1/c1_MacroAssembler.hpp" -#include "gc/x/c1/xBarrierSetC1.hpp" -#endif // COMPILER1 -#ifdef COMPILER2 -#include "gc/x/c2/xBarrierSetC2.hpp" -#endif // COMPILER2 - -#ifdef PRODUCT -#define BLOCK_COMMENT(str) /* nothing */ -#else -#define BLOCK_COMMENT(str) __ block_comment(str) -#endif - -#undef __ -#define __ masm-> - -void XBarrierSetAssembler::load_at(MacroAssembler* masm, - DecoratorSet decorators, - BasicType type, - Register dst, - Address src, - Register tmp1, - Register tmp2) { - if (!XBarrierSet::barrier_needed(decorators, type)) { - // Barrier not needed - BarrierSetAssembler::load_at(masm, decorators, type, dst, src, tmp1, tmp2); - return; - } - - assert_different_registers(rscratch1, rscratch2, src.base()); - assert_different_registers(rscratch1, rscratch2, dst); - - Label done; - - // Load bad mask into scratch register. - __ ldr(rscratch1, address_bad_mask_from_thread(rthread)); - __ lea(rscratch2, src); - __ ldr(dst, src); - - // Test reference against bad mask. If mask bad, then we need to fix it up. - __ tst(dst, rscratch1); - __ br(Assembler::EQ, done); - - __ enter(/*strip_ret_addr*/true); - - __ push_call_clobbered_registers_except(RegSet::of(dst)); - - if (c_rarg0 != dst) { - __ mov(c_rarg0, dst); - } - __ mov(c_rarg1, rscratch2); - - __ call_VM_leaf(XBarrierSetRuntime::load_barrier_on_oop_field_preloaded_addr(decorators), 2); - - // Make sure dst has the return value. - if (dst != r0) { - __ mov(dst, r0); - } - - __ pop_call_clobbered_registers_except(RegSet::of(dst)); - __ leave(); - - __ bind(done); -} - -#ifdef ASSERT - -void XBarrierSetAssembler::store_at(MacroAssembler* masm, - DecoratorSet decorators, - BasicType type, - Address dst, - Register val, - Register tmp1, - Register tmp2, - Register tmp3) { - // Verify value - if (is_reference_type(type)) { - // Note that src could be noreg, which means we - // are storing null and can skip verification. - if (val != noreg) { - Label done; - - // tmp1, tmp2 and tmp3 are often set to noreg. - RegSet savedRegs = RegSet::of(rscratch1); - __ push(savedRegs, sp); - - __ ldr(rscratch1, address_bad_mask_from_thread(rthread)); - __ tst(val, rscratch1); - __ br(Assembler::EQ, done); - __ stop("Verify oop store failed"); - __ should_not_reach_here(); - __ bind(done); - __ pop(savedRegs, sp); - } - } - - // Store value - BarrierSetAssembler::store_at(masm, decorators, type, dst, val, tmp1, tmp2, noreg); -} - -#endif // ASSERT - -void XBarrierSetAssembler::arraycopy_prologue(MacroAssembler* masm, - DecoratorSet decorators, - bool is_oop, - Register src, - Register dst, - Register count, - RegSet saved_regs) { - if (!is_oop) { - // Barrier not needed - return; - } - - BLOCK_COMMENT("XBarrierSetAssembler::arraycopy_prologue {"); - - assert_different_registers(src, count, rscratch1); - - __ push(saved_regs, sp); - - if (count == c_rarg0) { - if (src == c_rarg1) { - // exactly backwards!! - __ mov(rscratch1, c_rarg0); - __ mov(c_rarg0, c_rarg1); - __ mov(c_rarg1, rscratch1); - } else { - __ mov(c_rarg1, count); - __ mov(c_rarg0, src); - } - } else { - __ mov(c_rarg0, src); - __ mov(c_rarg1, count); - } - - __ call_VM_leaf(XBarrierSetRuntime::load_barrier_on_oop_array_addr(), 2); - - __ pop(saved_regs, sp); - - BLOCK_COMMENT("} XBarrierSetAssembler::arraycopy_prologue"); -} - -void XBarrierSetAssembler::try_resolve_jobject_in_native(MacroAssembler* masm, - Register jni_env, - Register robj, - Register tmp, - Label& slowpath) { - BLOCK_COMMENT("XBarrierSetAssembler::try_resolve_jobject_in_native {"); - - assert_different_registers(jni_env, robj, tmp); - - // Resolve jobject - BarrierSetAssembler::try_resolve_jobject_in_native(masm, jni_env, robj, tmp, slowpath); - - // The Address offset is too large to direct load - -784. Our range is +127, -128. - __ mov(tmp, (int64_t)(in_bytes(XThreadLocalData::address_bad_mask_offset()) - - in_bytes(JavaThread::jni_environment_offset()))); - - // Load address bad mask - __ add(tmp, jni_env, tmp); - __ ldr(tmp, Address(tmp)); - - // Check address bad mask - __ tst(robj, tmp); - __ br(Assembler::NE, slowpath); - - BLOCK_COMMENT("} XBarrierSetAssembler::try_resolve_jobject_in_native"); -} - -#ifdef COMPILER1 - -#undef __ -#define __ ce->masm()-> - -void XBarrierSetAssembler::generate_c1_load_barrier_test(LIR_Assembler* ce, - LIR_Opr ref) const { - assert_different_registers(rscratch1, rthread, ref->as_register()); - - __ ldr(rscratch1, address_bad_mask_from_thread(rthread)); - __ tst(ref->as_register(), rscratch1); -} - -void XBarrierSetAssembler::generate_c1_load_barrier_stub(LIR_Assembler* ce, - XLoadBarrierStubC1* stub) const { - // Stub entry - __ bind(*stub->entry()); - - Register ref = stub->ref()->as_register(); - Register ref_addr = noreg; - Register tmp = noreg; - - if (stub->tmp()->is_valid()) { - // Load address into tmp register - ce->leal(stub->ref_addr(), stub->tmp()); - ref_addr = tmp = stub->tmp()->as_pointer_register(); - } else { - // Address already in register - ref_addr = stub->ref_addr()->as_address_ptr()->base()->as_pointer_register(); - } - - assert_different_registers(ref, ref_addr, noreg); - - // Save r0 unless it is the result or tmp register - // Set up SP to accommodate parameters and maybe r0.. - if (ref != r0 && tmp != r0) { - __ sub(sp, sp, 32); - __ str(r0, Address(sp, 16)); - } else { - __ sub(sp, sp, 16); - } - - // Setup arguments and call runtime stub - ce->store_parameter(ref_addr, 1); - ce->store_parameter(ref, 0); - - __ far_call(stub->runtime_stub()); - - // Verify result - __ verify_oop(r0); - - // Move result into place - if (ref != r0) { - __ mov(ref, r0); - } - - // Restore r0 unless it is the result or tmp register - if (ref != r0 && tmp != r0) { - __ ldr(r0, Address(sp, 16)); - __ add(sp, sp, 32); - } else { - __ add(sp, sp, 16); - } - - // Stub exit - __ b(*stub->continuation()); -} - -#undef __ -#define __ sasm-> - -void XBarrierSetAssembler::generate_c1_load_barrier_runtime_stub(StubAssembler* sasm, - DecoratorSet decorators) const { - __ prologue("zgc_load_barrier stub", false); - - __ push_call_clobbered_registers_except(RegSet::of(r0)); - - // Setup arguments - __ load_parameter(0, c_rarg0); - __ load_parameter(1, c_rarg1); - - __ call_VM_leaf(XBarrierSetRuntime::load_barrier_on_oop_field_preloaded_addr(decorators), 2); - - __ pop_call_clobbered_registers_except(RegSet::of(r0)); - - __ epilogue(); -} -#endif // COMPILER1 - -#ifdef COMPILER2 - -OptoReg::Name XBarrierSetAssembler::refine_register(const Node* node, OptoReg::Name opto_reg) { - if (!OptoReg::is_reg(opto_reg)) { - return OptoReg::Bad; - } - - const VMReg vm_reg = OptoReg::as_VMReg(opto_reg); - if (vm_reg->is_FloatRegister()) { - return opto_reg & ~1; - } - - return opto_reg; -} - -#undef __ -#define __ _masm-> - -class XSaveLiveRegisters { -private: - MacroAssembler* const _masm; - RegSet _gp_regs; - FloatRegSet _fp_regs; - PRegSet _p_regs; - -public: - void initialize(XLoadBarrierStubC2* stub) { - // Record registers that needs to be saved/restored - RegMaskIterator rmi(stub->live()); - while (rmi.has_next()) { - const OptoReg::Name opto_reg = rmi.next(); - if (OptoReg::is_reg(opto_reg)) { - const VMReg vm_reg = OptoReg::as_VMReg(opto_reg); - if (vm_reg->is_Register()) { - _gp_regs += RegSet::of(vm_reg->as_Register()); - } else if (vm_reg->is_FloatRegister()) { - _fp_regs += FloatRegSet::of(vm_reg->as_FloatRegister()); - } else if (vm_reg->is_PRegister()) { - _p_regs += PRegSet::of(vm_reg->as_PRegister()); - } else { - fatal("Unknown register type"); - } - } - } - - // Remove C-ABI SOE registers, scratch regs and _ref register that will be updated - _gp_regs -= RegSet::range(r19, r30) + RegSet::of(r8, r9, stub->ref()); - } - - XSaveLiveRegisters(MacroAssembler* masm, XLoadBarrierStubC2* stub) : - _masm(masm), - _gp_regs(), - _fp_regs(), - _p_regs() { - - // Figure out what registers to save/restore - initialize(stub); - - // Save registers - __ push(_gp_regs, sp); - __ push_fp(_fp_regs, sp); - __ push_p(_p_regs, sp); - } - - ~XSaveLiveRegisters() { - // Restore registers - __ pop_p(_p_regs, sp); - __ pop_fp(_fp_regs, sp); - - // External runtime call may clobber ptrue reg - __ reinitialize_ptrue(); - - __ pop(_gp_regs, sp); - } -}; - -#undef __ -#define __ _masm-> - -class XSetupArguments { -private: - MacroAssembler* const _masm; - const Register _ref; - const Address _ref_addr; - -public: - XSetupArguments(MacroAssembler* masm, XLoadBarrierStubC2* stub) : - _masm(masm), - _ref(stub->ref()), - _ref_addr(stub->ref_addr()) { - - // Setup arguments - if (_ref_addr.base() == noreg) { - // No self healing - if (_ref != c_rarg0) { - __ mov(c_rarg0, _ref); - } - __ mov(c_rarg1, 0); - } else { - // Self healing - if (_ref == c_rarg0) { - // _ref is already at correct place - __ lea(c_rarg1, _ref_addr); - } else if (_ref != c_rarg1) { - // _ref is in wrong place, but not in c_rarg1, so fix it first - __ lea(c_rarg1, _ref_addr); - __ mov(c_rarg0, _ref); - } else if (_ref_addr.base() != c_rarg0 && _ref_addr.index() != c_rarg0) { - assert(_ref == c_rarg1, "Mov ref first, vacating c_rarg0"); - __ mov(c_rarg0, _ref); - __ lea(c_rarg1, _ref_addr); - } else { - assert(_ref == c_rarg1, "Need to vacate c_rarg1 and _ref_addr is using c_rarg0"); - if (_ref_addr.base() == c_rarg0 || _ref_addr.index() == c_rarg0) { - __ mov(rscratch2, c_rarg1); - __ lea(c_rarg1, _ref_addr); - __ mov(c_rarg0, rscratch2); - } else { - ShouldNotReachHere(); - } - } - } - } - - ~XSetupArguments() { - // Transfer result - if (_ref != r0) { - __ mov(_ref, r0); - } - } -}; - -#undef __ -#define __ masm-> - -void XBarrierSetAssembler::generate_c2_load_barrier_stub(MacroAssembler* masm, XLoadBarrierStubC2* stub) const { - BLOCK_COMMENT("XLoadBarrierStubC2"); - - // Stub entry - __ bind(*stub->entry()); - - { - XSaveLiveRegisters save_live_registers(masm, stub); - XSetupArguments setup_arguments(masm, stub); - __ mov(rscratch1, stub->slow_path()); - __ blr(rscratch1); - } - // Stub exit - __ b(*stub->continuation()); -} - -#endif // COMPILER2 - -#undef __ -#define __ masm-> - -void XBarrierSetAssembler::check_oop(MacroAssembler* masm, Register obj, Register tmp1, Register tmp2, Label& error) { - // Check if mask is good. - // verifies that XAddressBadMask & r0 == 0 - __ ldr(tmp2, Address(rthread, XThreadLocalData::address_bad_mask_offset())); - __ andr(tmp1, obj, tmp2); - __ cbnz(tmp1, error); - - BarrierSetAssembler::check_oop(masm, obj, tmp1, tmp2, error); -} - -#undef __ diff --git a/src/hotspot/cpu/aarch64/gc/x/xBarrierSetAssembler_aarch64.hpp b/src/hotspot/cpu/aarch64/gc/x/xBarrierSetAssembler_aarch64.hpp deleted file mode 100644 index 8c1e9521757..00000000000 --- a/src/hotspot/cpu/aarch64/gc/x/xBarrierSetAssembler_aarch64.hpp +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (c) 2019, 2022, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef CPU_AARCH64_GC_X_XBARRIERSETASSEMBLER_AARCH64_HPP -#define CPU_AARCH64_GC_X_XBARRIERSETASSEMBLER_AARCH64_HPP - -#include "code/vmreg.hpp" -#include "oops/accessDecorators.hpp" -#ifdef COMPILER2 -#include "opto/optoreg.hpp" -#endif // COMPILER2 - -#ifdef COMPILER1 -class LIR_Assembler; -class LIR_Opr; -class StubAssembler; -#endif // COMPILER1 - -#ifdef COMPILER2 -class Node; -#endif // COMPILER2 - -#ifdef COMPILER1 -class XLoadBarrierStubC1; -#endif // COMPILER1 - -#ifdef COMPILER2 -class XLoadBarrierStubC2; -#endif // COMPILER2 - -class XBarrierSetAssembler : public XBarrierSetAssemblerBase { -public: - virtual void load_at(MacroAssembler* masm, - DecoratorSet decorators, - BasicType type, - Register dst, - Address src, - Register tmp1, - Register tmp2); - -#ifdef ASSERT - virtual void store_at(MacroAssembler* masm, - DecoratorSet decorators, - BasicType type, - Address dst, - Register val, - Register tmp1, - Register tmp2, - Register tmp3); -#endif // ASSERT - - virtual void arraycopy_prologue(MacroAssembler* masm, - DecoratorSet decorators, - bool is_oop, - Register src, - Register dst, - Register count, - RegSet saved_regs); - - virtual void try_resolve_jobject_in_native(MacroAssembler* masm, - Register jni_env, - Register robj, - Register tmp, - Label& slowpath); - - virtual NMethodPatchingType nmethod_patching_type() { return NMethodPatchingType::conc_data_patch; } - -#ifdef COMPILER1 - void generate_c1_load_barrier_test(LIR_Assembler* ce, - LIR_Opr ref) const; - - void generate_c1_load_barrier_stub(LIR_Assembler* ce, - XLoadBarrierStubC1* stub) const; - - void generate_c1_load_barrier_runtime_stub(StubAssembler* sasm, - DecoratorSet decorators) const; -#endif // COMPILER1 - -#ifdef COMPILER2 - OptoReg::Name refine_register(const Node* node, - OptoReg::Name opto_reg); - - void generate_c2_load_barrier_stub(MacroAssembler* masm, - XLoadBarrierStubC2* stub) const; -#endif // COMPILER2 - - void check_oop(MacroAssembler* masm, Register obj, Register tmp1, Register tmp2, Label& error); -}; - -#endif // CPU_AARCH64_GC_X_XBARRIERSETASSEMBLER_AARCH64_HPP diff --git a/src/hotspot/cpu/aarch64/gc/x/xGlobals_aarch64.cpp b/src/hotspot/cpu/aarch64/gc/x/xGlobals_aarch64.cpp deleted file mode 100644 index a9c53da3d01..00000000000 --- a/src/hotspot/cpu/aarch64/gc/x/xGlobals_aarch64.cpp +++ /dev/null @@ -1,212 +0,0 @@ -/* - * Copyright (c) 2017, 2022, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/shared/gcLogPrecious.hpp" -#include "gc/shared/gc_globals.hpp" -#include "gc/x/xGlobals.hpp" -#include "runtime/globals.hpp" -#include "runtime/os.hpp" -#include "utilities/globalDefinitions.hpp" -#include "utilities/powerOfTwo.hpp" - -#ifdef LINUX -#include -#endif // LINUX - -// -// The heap can have three different layouts, depending on the max heap size. -// -// Address Space & Pointer Layout 1 -// -------------------------------- -// -// +--------------------------------+ 0x00007FFFFFFFFFFF (127TB) -// . . -// . . -// . . -// +--------------------------------+ 0x0000014000000000 (20TB) -// | Remapped View | -// +--------------------------------+ 0x0000010000000000 (16TB) -// . . -// +--------------------------------+ 0x00000c0000000000 (12TB) -// | Marked1 View | -// +--------------------------------+ 0x0000080000000000 (8TB) -// | Marked0 View | -// +--------------------------------+ 0x0000040000000000 (4TB) -// . . -// +--------------------------------+ 0x0000000000000000 -// -// 6 4 4 4 4 -// 3 6 5 2 1 0 -// +--------------------+----+-----------------------------------------------+ -// |00000000 00000000 00|1111|11 11111111 11111111 11111111 11111111 11111111| -// +--------------------+----+-----------------------------------------------+ -// | | | -// | | * 41-0 Object Offset (42-bits, 4TB address space) -// | | -// | * 45-42 Metadata Bits (4-bits) 0001 = Marked0 (Address view 4-8TB) -// | 0010 = Marked1 (Address view 8-12TB) -// | 0100 = Remapped (Address view 16-20TB) -// | 1000 = Finalizable (Address view N/A) -// | -// * 63-46 Fixed (18-bits, always zero) -// -// -// Address Space & Pointer Layout 2 -// -------------------------------- -// -// +--------------------------------+ 0x00007FFFFFFFFFFF (127TB) -// . . -// . . -// . . -// +--------------------------------+ 0x0000280000000000 (40TB) -// | Remapped View | -// +--------------------------------+ 0x0000200000000000 (32TB) -// . . -// +--------------------------------+ 0x0000180000000000 (24TB) -// | Marked1 View | -// +--------------------------------+ 0x0000100000000000 (16TB) -// | Marked0 View | -// +--------------------------------+ 0x0000080000000000 (8TB) -// . . -// +--------------------------------+ 0x0000000000000000 -// -// 6 4 4 4 4 -// 3 7 6 3 2 0 -// +------------------+-----+------------------------------------------------+ -// |00000000 00000000 0|1111|111 11111111 11111111 11111111 11111111 11111111| -// +-------------------+----+------------------------------------------------+ -// | | | -// | | * 42-0 Object Offset (43-bits, 8TB address space) -// | | -// | * 46-43 Metadata Bits (4-bits) 0001 = Marked0 (Address view 8-16TB) -// | 0010 = Marked1 (Address view 16-24TB) -// | 0100 = Remapped (Address view 32-40TB) -// | 1000 = Finalizable (Address view N/A) -// | -// * 63-47 Fixed (17-bits, always zero) -// -// -// Address Space & Pointer Layout 3 -// -------------------------------- -// -// +--------------------------------+ 0x00007FFFFFFFFFFF (127TB) -// . . -// . . -// . . -// +--------------------------------+ 0x0000500000000000 (80TB) -// | Remapped View | -// +--------------------------------+ 0x0000400000000000 (64TB) -// . . -// +--------------------------------+ 0x0000300000000000 (48TB) -// | Marked1 View | -// +--------------------------------+ 0x0000200000000000 (32TB) -// | Marked0 View | -// +--------------------------------+ 0x0000100000000000 (16TB) -// . . -// +--------------------------------+ 0x0000000000000000 -// -// 6 4 4 4 4 -// 3 8 7 4 3 0 -// +------------------+----+-------------------------------------------------+ -// |00000000 00000000 |1111|1111 11111111 11111111 11111111 11111111 11111111| -// +------------------+----+-------------------------------------------------+ -// | | | -// | | * 43-0 Object Offset (44-bits, 16TB address space) -// | | -// | * 47-44 Metadata Bits (4-bits) 0001 = Marked0 (Address view 16-32TB) -// | 0010 = Marked1 (Address view 32-48TB) -// | 0100 = Remapped (Address view 64-80TB) -// | 1000 = Finalizable (Address view N/A) -// | -// * 63-48 Fixed (16-bits, always zero) -// - -// Default value if probing is not implemented for a certain platform -// Max address bit is restricted by implicit assumptions in the code, for instance -// the bit layout of XForwardingEntry or Partial array entry (see XMarkStackEntry) in mark stack -static const size_t DEFAULT_MAX_ADDRESS_BIT = 46; -// Minimum value returned, if probing fails -static const size_t MINIMUM_MAX_ADDRESS_BIT = 36; - -static size_t probe_valid_max_address_bit() { -#ifdef LINUX - size_t max_address_bit = 0; - const size_t page_size = os::vm_page_size(); - for (size_t i = DEFAULT_MAX_ADDRESS_BIT; i > MINIMUM_MAX_ADDRESS_BIT; --i) { - const uintptr_t base_addr = ((uintptr_t) 1U) << i; - if (msync((void*)base_addr, page_size, MS_ASYNC) == 0) { - // msync succeeded, the address is valid, and maybe even already mapped. - max_address_bit = i; - break; - } - if (errno != ENOMEM) { - // Some error occurred. This should never happen, but msync - // has some undefined behavior, hence ignore this bit. -#ifdef ASSERT - fatal("Received '%s' while probing the address space for the highest valid bit", os::errno_name(errno)); -#else // ASSERT - log_warning_p(gc)("Received '%s' while probing the address space for the highest valid bit", os::errno_name(errno)); -#endif // ASSERT - continue; - } - // Since msync failed with ENOMEM, the page might not be mapped. - // Try to map it, to see if the address is valid. - void* const result_addr = mmap((void*) base_addr, page_size, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0); - if (result_addr != MAP_FAILED) { - munmap(result_addr, page_size); - } - if ((uintptr_t) result_addr == base_addr) { - // address is valid - max_address_bit = i; - break; - } - } - if (max_address_bit == 0) { - // probing failed, allocate a very high page and take that bit as the maximum - const uintptr_t high_addr = ((uintptr_t) 1U) << DEFAULT_MAX_ADDRESS_BIT; - void* const result_addr = mmap((void*) high_addr, page_size, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0); - if (result_addr != MAP_FAILED) { - max_address_bit = BitsPerSize_t - count_leading_zeros((size_t) result_addr) - 1; - munmap(result_addr, page_size); - } - } - log_info_p(gc, init)("Probing address space for the highest valid bit: " SIZE_FORMAT, max_address_bit); - return MAX2(max_address_bit, MINIMUM_MAX_ADDRESS_BIT); -#else // LINUX - return DEFAULT_MAX_ADDRESS_BIT; -#endif // LINUX -} - -size_t XPlatformAddressOffsetBits() { - const static size_t valid_max_address_offset_bits = probe_valid_max_address_bit() + 1; - const size_t max_address_offset_bits = valid_max_address_offset_bits - 3; - const size_t min_address_offset_bits = max_address_offset_bits - 2; - const size_t address_offset = round_up_power_of_2(MaxHeapSize * XVirtualToPhysicalRatio); - const size_t address_offset_bits = log2i_exact(address_offset); - return clamp(address_offset_bits, min_address_offset_bits, max_address_offset_bits); -} - -size_t XPlatformAddressMetadataShift() { - return XPlatformAddressOffsetBits(); -} diff --git a/src/hotspot/cpu/aarch64/gc/x/xGlobals_aarch64.hpp b/src/hotspot/cpu/aarch64/gc/x/xGlobals_aarch64.hpp deleted file mode 100644 index 870b0d74d57..00000000000 --- a/src/hotspot/cpu/aarch64/gc/x/xGlobals_aarch64.hpp +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2015, 2022, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef CPU_AARCH64_GC_X_XGLOBALS_AARCH64_HPP -#define CPU_AARCH64_GC_X_XGLOBALS_AARCH64_HPP - -const size_t XPlatformHeapViews = 3; -const size_t XPlatformCacheLineSize = 64; - -size_t XPlatformAddressOffsetBits(); -size_t XPlatformAddressMetadataShift(); - -#endif // CPU_AARCH64_GC_X_XGLOBALS_AARCH64_HPP diff --git a/src/hotspot/cpu/aarch64/gc/x/x_aarch64.ad b/src/hotspot/cpu/aarch64/gc/x/x_aarch64.ad deleted file mode 100644 index 6e401724baa..00000000000 --- a/src/hotspot/cpu/aarch64/gc/x/x_aarch64.ad +++ /dev/null @@ -1,249 +0,0 @@ -// -// Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. -// DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -// -// This code is free software; you can redistribute it and/or modify it -// under the terms of the GNU General Public License version 2 only, as -// published by the Free Software Foundation. -// -// This code is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -// version 2 for more details (a copy is included in the LICENSE file that -// accompanied this code). -// -// You should have received a copy of the GNU General Public License version -// 2 along with this work; if not, write to the Free Software Foundation, -// Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -// -// Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -// or visit www.oracle.com if you need additional information or have any -// questions. -// - -source_hpp %{ - -#include "gc/shared/gc_globals.hpp" -#include "gc/x/c2/xBarrierSetC2.hpp" -#include "gc/x/xThreadLocalData.hpp" - -%} - -source %{ - -static void x_load_barrier(MacroAssembler* masm, const MachNode* node, Address ref_addr, Register ref, Register tmp, uint8_t barrier_data) { - if (barrier_data == XLoadBarrierElided) { - return; - } - XLoadBarrierStubC2* const stub = XLoadBarrierStubC2::create(node, ref_addr, ref, tmp, barrier_data); - __ ldr(tmp, Address(rthread, XThreadLocalData::address_bad_mask_offset())); - __ andr(tmp, tmp, ref); - __ cbnz(tmp, *stub->entry()); - __ bind(*stub->continuation()); -} - -static void x_load_barrier_slow_path(MacroAssembler* masm, const MachNode* node, Address ref_addr, Register ref, Register tmp) { - XLoadBarrierStubC2* const stub = XLoadBarrierStubC2::create(node, ref_addr, ref, tmp, XLoadBarrierStrong); - __ b(*stub->entry()); - __ bind(*stub->continuation()); -} - -%} - -// Load Pointer -instruct xLoadP(iRegPNoSp dst, memory8 mem, rFlagsReg cr) -%{ - match(Set dst (LoadP mem)); - predicate(UseZGC && !ZGenerational && !needs_acquiring_load(n) && (n->as_Load()->barrier_data() != 0)); - effect(TEMP dst, KILL cr); - - ins_cost(4 * INSN_COST); - - format %{ "ldr $dst, $mem" %} - - ins_encode %{ - Address ref_addr = mem2address($mem->opcode(), as_Register($mem$$base), $mem$$index, $mem$$scale, $mem$$disp); - if (ref_addr.getMode() == Address::base_plus_offset) { - // Fix up any out-of-range offsets. - assert_different_registers(rscratch1, as_Register($mem$$base)); - assert_different_registers(rscratch1, $dst$$Register); - ref_addr = __ legitimize_address(ref_addr, 8, rscratch1); - } - __ ldr($dst$$Register, ref_addr); - x_load_barrier(masm, this, ref_addr, $dst$$Register, rscratch2 /* tmp */, barrier_data()); - %} - - ins_pipe(iload_reg_mem); -%} - -// Load Pointer Volatile -instruct xLoadPVolatile(iRegPNoSp dst, indirect mem /* sync_memory */, rFlagsReg cr) -%{ - match(Set dst (LoadP mem)); - predicate(UseZGC && !ZGenerational && needs_acquiring_load(n) && n->as_Load()->barrier_data() != 0); - effect(TEMP dst, KILL cr); - - ins_cost(VOLATILE_REF_COST); - - format %{ "ldar $dst, $mem\t" %} - - ins_encode %{ - __ ldar($dst$$Register, $mem$$Register); - x_load_barrier(masm, this, Address($mem$$Register), $dst$$Register, rscratch2 /* tmp */, barrier_data()); - %} - - ins_pipe(pipe_serial); -%} - -instruct xCompareAndSwapP(iRegINoSp res, indirect mem, iRegP oldval, iRegP newval, rFlagsReg cr) %{ - match(Set res (CompareAndSwapP mem (Binary oldval newval))); - match(Set res (WeakCompareAndSwapP mem (Binary oldval newval))); - predicate(UseZGC && !ZGenerational && !needs_acquiring_load_exclusive(n) && n->as_LoadStore()->barrier_data() == XLoadBarrierStrong); - effect(KILL cr, TEMP_DEF res); - - ins_cost(2 * VOLATILE_REF_COST); - - format %{ "cmpxchg $mem, $oldval, $newval\n\t" - "cset $res, EQ" %} - - ins_encode %{ - guarantee($mem$$index == -1 && $mem$$disp == 0, "impossible encoding"); - __ cmpxchg($mem$$Register, $oldval$$Register, $newval$$Register, Assembler::xword, - false /* acquire */, true /* release */, false /* weak */, rscratch2); - __ cset($res$$Register, Assembler::EQ); - if (barrier_data() != XLoadBarrierElided) { - Label good; - __ ldr(rscratch1, Address(rthread, XThreadLocalData::address_bad_mask_offset())); - __ andr(rscratch1, rscratch1, rscratch2); - __ cbz(rscratch1, good); - x_load_barrier_slow_path(masm, this, Address($mem$$Register), rscratch2 /* ref */, rscratch1 /* tmp */); - __ cmpxchg($mem$$Register, $oldval$$Register, $newval$$Register, Assembler::xword, - false /* acquire */, true /* release */, false /* weak */, rscratch2); - __ cset($res$$Register, Assembler::EQ); - __ bind(good); - } - %} - - ins_pipe(pipe_slow); -%} - -instruct xCompareAndSwapPAcq(iRegINoSp res, indirect mem, iRegP oldval, iRegP newval, rFlagsReg cr) %{ - match(Set res (CompareAndSwapP mem (Binary oldval newval))); - match(Set res (WeakCompareAndSwapP mem (Binary oldval newval))); - predicate(UseZGC && !ZGenerational && needs_acquiring_load_exclusive(n) && (n->as_LoadStore()->barrier_data() == XLoadBarrierStrong)); - effect(KILL cr, TEMP_DEF res); - - ins_cost(2 * VOLATILE_REF_COST); - - format %{ "cmpxchg $mem, $oldval, $newval\n\t" - "cset $res, EQ" %} - - ins_encode %{ - guarantee($mem$$index == -1 && $mem$$disp == 0, "impossible encoding"); - __ cmpxchg($mem$$Register, $oldval$$Register, $newval$$Register, Assembler::xword, - true /* acquire */, true /* release */, false /* weak */, rscratch2); - __ cset($res$$Register, Assembler::EQ); - if (barrier_data() != XLoadBarrierElided) { - Label good; - __ ldr(rscratch1, Address(rthread, XThreadLocalData::address_bad_mask_offset())); - __ andr(rscratch1, rscratch1, rscratch2); - __ cbz(rscratch1, good); - x_load_barrier_slow_path(masm, this, Address($mem$$Register), rscratch2 /* ref */, rscratch1 /* tmp */ ); - __ cmpxchg($mem$$Register, $oldval$$Register, $newval$$Register, Assembler::xword, - true /* acquire */, true /* release */, false /* weak */, rscratch2); - __ cset($res$$Register, Assembler::EQ); - __ bind(good); - } - %} - - ins_pipe(pipe_slow); -%} - -instruct xCompareAndExchangeP(iRegPNoSp res, indirect mem, iRegP oldval, iRegP newval, rFlagsReg cr) %{ - match(Set res (CompareAndExchangeP mem (Binary oldval newval))); - predicate(UseZGC && !ZGenerational && !needs_acquiring_load_exclusive(n) && n->as_LoadStore()->barrier_data() == XLoadBarrierStrong); - effect(TEMP_DEF res, KILL cr); - - ins_cost(2 * VOLATILE_REF_COST); - - format %{ "cmpxchg $res = $mem, $oldval, $newval" %} - - ins_encode %{ - guarantee($mem$$index == -1 && $mem$$disp == 0, "impossible encoding"); - __ cmpxchg($mem$$Register, $oldval$$Register, $newval$$Register, Assembler::xword, - false /* acquire */, true /* release */, false /* weak */, $res$$Register); - if (barrier_data() != XLoadBarrierElided) { - Label good; - __ ldr(rscratch1, Address(rthread, XThreadLocalData::address_bad_mask_offset())); - __ andr(rscratch1, rscratch1, $res$$Register); - __ cbz(rscratch1, good); - x_load_barrier_slow_path(masm, this, Address($mem$$Register), $res$$Register /* ref */, rscratch1 /* tmp */); - __ cmpxchg($mem$$Register, $oldval$$Register, $newval$$Register, Assembler::xword, - false /* acquire */, true /* release */, false /* weak */, $res$$Register); - __ bind(good); - } - %} - - ins_pipe(pipe_slow); -%} - -instruct xCompareAndExchangePAcq(iRegPNoSp res, indirect mem, iRegP oldval, iRegP newval, rFlagsReg cr) %{ - match(Set res (CompareAndExchangeP mem (Binary oldval newval))); - predicate(UseZGC && !ZGenerational && needs_acquiring_load_exclusive(n) && n->as_LoadStore()->barrier_data() == XLoadBarrierStrong); - effect(TEMP_DEF res, KILL cr); - - ins_cost(2 * VOLATILE_REF_COST); - - format %{ "cmpxchg $res = $mem, $oldval, $newval" %} - - ins_encode %{ - guarantee($mem$$index == -1 && $mem$$disp == 0, "impossible encoding"); - __ cmpxchg($mem$$Register, $oldval$$Register, $newval$$Register, Assembler::xword, - true /* acquire */, true /* release */, false /* weak */, $res$$Register); - if (barrier_data() != XLoadBarrierElided) { - Label good; - __ ldr(rscratch1, Address(rthread, XThreadLocalData::address_bad_mask_offset())); - __ andr(rscratch1, rscratch1, $res$$Register); - __ cbz(rscratch1, good); - x_load_barrier_slow_path(masm, this, Address($mem$$Register), $res$$Register /* ref */, rscratch1 /* tmp */); - __ cmpxchg($mem$$Register, $oldval$$Register, $newval$$Register, Assembler::xword, - true /* acquire */, true /* release */, false /* weak */, $res$$Register); - __ bind(good); - } - %} - - ins_pipe(pipe_slow); -%} - -instruct xGetAndSetP(indirect mem, iRegP newv, iRegPNoSp prev, rFlagsReg cr) %{ - match(Set prev (GetAndSetP mem newv)); - predicate(UseZGC && !ZGenerational && !needs_acquiring_load_exclusive(n) && n->as_LoadStore()->barrier_data() != 0); - effect(TEMP_DEF prev, KILL cr); - - ins_cost(2 * VOLATILE_REF_COST); - - format %{ "atomic_xchg $prev, $newv, [$mem]" %} - - ins_encode %{ - __ atomic_xchg($prev$$Register, $newv$$Register, $mem$$Register); - x_load_barrier(masm, this, Address(noreg, 0), $prev$$Register, rscratch2 /* tmp */, barrier_data()); - %} - - ins_pipe(pipe_serial); -%} - -instruct xGetAndSetPAcq(indirect mem, iRegP newv, iRegPNoSp prev, rFlagsReg cr) %{ - match(Set prev (GetAndSetP mem newv)); - predicate(UseZGC && !ZGenerational && needs_acquiring_load_exclusive(n) && (n->as_LoadStore()->barrier_data() != 0)); - effect(TEMP_DEF prev, KILL cr); - - ins_cost(VOLATILE_REF_COST); - - format %{ "atomic_xchg_acq $prev, $newv, [$mem]" %} - - ins_encode %{ - __ atomic_xchgal($prev$$Register, $newv$$Register, $mem$$Register); - x_load_barrier(masm, this, Address(noreg, 0), $prev$$Register, rscratch2 /* tmp */, barrier_data()); - %} - ins_pipe(pipe_serial); -%} diff --git a/src/hotspot/cpu/aarch64/gc/z/z_aarch64.ad b/src/hotspot/cpu/aarch64/gc/z/z_aarch64.ad index 088f92a0157..47abaae3d5b 100644 --- a/src/hotspot/cpu/aarch64/gc/z/z_aarch64.ad +++ b/src/hotspot/cpu/aarch64/gc/z/z_aarch64.ad @@ -104,7 +104,7 @@ static void z_store_barrier(MacroAssembler* masm, const MachNode* node, Address instruct zLoadP(iRegPNoSp dst, memory8 mem, rFlagsReg cr) %{ match(Set dst (LoadP mem)); - predicate(UseZGC && ZGenerational && !needs_acquiring_load(n) && n->as_Load()->barrier_data() != 0); + predicate(UseZGC && !needs_acquiring_load(n) && n->as_Load()->barrier_data() != 0); effect(TEMP dst, KILL cr); ins_cost(4 * INSN_COST); @@ -130,7 +130,7 @@ instruct zLoadP(iRegPNoSp dst, memory8 mem, rFlagsReg cr) instruct zLoadPVolatile(iRegPNoSp dst, indirect mem /* sync_memory */, rFlagsReg cr) %{ match(Set dst (LoadP mem)); - predicate(UseZGC && ZGenerational && needs_acquiring_load(n) && n->as_Load()->barrier_data() != 0); + predicate(UseZGC && needs_acquiring_load(n) && n->as_Load()->barrier_data() != 0); effect(TEMP dst, KILL cr); ins_cost(VOLATILE_REF_COST); @@ -149,7 +149,7 @@ instruct zLoadPVolatile(iRegPNoSp dst, indirect mem /* sync_memory */, rFlagsReg // Store Pointer instruct zStoreP(memory mem, iRegP src, iRegPNoSp tmp, rFlagsReg cr) %{ - predicate(UseZGC && ZGenerational && !needs_releasing_store(n) && n->as_Store()->barrier_data() != 0); + predicate(UseZGC && !needs_releasing_store(n) && n->as_Store()->barrier_data() != 0); match(Set mem (StoreP mem src)); effect(TEMP tmp, KILL cr); @@ -166,7 +166,7 @@ instruct zStoreP(memory mem, iRegP src, iRegPNoSp tmp, rFlagsReg cr) // Store Pointer Volatile instruct zStorePVolatile(indirect mem, iRegP src, iRegPNoSp tmp, rFlagsReg cr) %{ - predicate(UseZGC && ZGenerational && needs_releasing_store(n) && n->as_Store()->barrier_data() != 0); + predicate(UseZGC && needs_releasing_store(n) && n->as_Store()->barrier_data() != 0); match(Set mem (StoreP mem src)); effect(TEMP tmp, KILL cr); @@ -183,7 +183,7 @@ instruct zStorePVolatile(indirect mem, iRegP src, iRegPNoSp tmp, rFlagsReg cr) instruct zCompareAndSwapP(iRegINoSp res, indirect mem, iRegP oldval, iRegP newval, iRegPNoSp oldval_tmp, iRegPNoSp newval_tmp, rFlagsReg cr) %{ match(Set res (CompareAndSwapP mem (Binary oldval newval))); match(Set res (WeakCompareAndSwapP mem (Binary oldval newval))); - predicate(UseZGC && ZGenerational && !needs_acquiring_load_exclusive(n) && n->as_LoadStore()->barrier_data() != 0); + predicate(UseZGC && !needs_acquiring_load_exclusive(n) && n->as_LoadStore()->barrier_data() != 0); effect(TEMP oldval_tmp, TEMP newval_tmp, TEMP res, KILL cr); ins_cost(2 * VOLATILE_REF_COST); @@ -207,7 +207,7 @@ instruct zCompareAndSwapP(iRegINoSp res, indirect mem, iRegP oldval, iRegP newva instruct zCompareAndSwapPAcq(iRegINoSp res, indirect mem, iRegP oldval, iRegP newval, iRegPNoSp oldval_tmp, iRegPNoSp newval_tmp, rFlagsReg cr) %{ match(Set res (CompareAndSwapP mem (Binary oldval newval))); match(Set res (WeakCompareAndSwapP mem (Binary oldval newval))); - predicate(UseZGC && ZGenerational && needs_acquiring_load_exclusive(n) && n->as_LoadStore()->barrier_data() != 0); + predicate(UseZGC && needs_acquiring_load_exclusive(n) && n->as_LoadStore()->barrier_data() != 0); effect(TEMP oldval_tmp, TEMP newval_tmp, TEMP res, KILL cr); ins_cost(2 * VOLATILE_REF_COST); @@ -231,7 +231,7 @@ instruct zCompareAndSwapPAcq(iRegINoSp res, indirect mem, iRegP oldval, iRegP ne instruct zCompareAndExchangeP(iRegPNoSp res, indirect mem, iRegP oldval, iRegP newval, iRegPNoSp oldval_tmp, iRegPNoSp newval_tmp, rFlagsReg cr) %{ match(Set res (CompareAndExchangeP mem (Binary oldval newval))); - predicate(UseZGC && ZGenerational && !needs_acquiring_load_exclusive(n) && n->as_LoadStore()->barrier_data() != 0); + predicate(UseZGC && !needs_acquiring_load_exclusive(n) && n->as_LoadStore()->barrier_data() != 0); effect(TEMP oldval_tmp, TEMP newval_tmp, TEMP res, KILL cr); ins_cost(2 * VOLATILE_REF_COST); @@ -254,7 +254,7 @@ instruct zCompareAndExchangeP(iRegPNoSp res, indirect mem, iRegP oldval, iRegP n instruct zCompareAndExchangePAcq(iRegPNoSp res, indirect mem, iRegP oldval, iRegP newval, iRegPNoSp oldval_tmp, iRegPNoSp newval_tmp, rFlagsReg cr) %{ match(Set res (CompareAndExchangeP mem (Binary oldval newval))); - predicate(UseZGC && ZGenerational && needs_acquiring_load_exclusive(n) && n->as_LoadStore()->barrier_data() != 0); + predicate(UseZGC && needs_acquiring_load_exclusive(n) && n->as_LoadStore()->barrier_data() != 0); effect(TEMP oldval_tmp, TEMP newval_tmp, TEMP res, KILL cr); ins_cost(2 * VOLATILE_REF_COST); @@ -277,7 +277,7 @@ instruct zCompareAndExchangePAcq(iRegPNoSp res, indirect mem, iRegP oldval, iReg instruct zGetAndSetP(indirect mem, iRegP newv, iRegPNoSp prev, rFlagsReg cr) %{ match(Set prev (GetAndSetP mem newv)); - predicate(UseZGC && ZGenerational && !needs_acquiring_load_exclusive(n) && n->as_LoadStore()->barrier_data() != 0); + predicate(UseZGC && !needs_acquiring_load_exclusive(n) && n->as_LoadStore()->barrier_data() != 0); effect(TEMP prev, KILL cr); ins_cost(2 * VOLATILE_REF_COST); @@ -295,7 +295,7 @@ instruct zGetAndSetP(indirect mem, iRegP newv, iRegPNoSp prev, rFlagsReg cr) %{ instruct zGetAndSetPAcq(indirect mem, iRegP newv, iRegPNoSp prev, rFlagsReg cr) %{ match(Set prev (GetAndSetP mem newv)); - predicate(UseZGC && ZGenerational && needs_acquiring_load_exclusive(n) && n->as_LoadStore()->barrier_data() != 0); + predicate(UseZGC && needs_acquiring_load_exclusive(n) && n->as_LoadStore()->barrier_data() != 0); effect(TEMP prev, KILL cr); ins_cost(2 * VOLATILE_REF_COST); diff --git a/src/hotspot/cpu/aarch64/globals_aarch64.hpp b/src/hotspot/cpu/aarch64/globals_aarch64.hpp index 9c20e3737c8..800e7718921 100644 --- a/src/hotspot/cpu/aarch64/globals_aarch64.hpp +++ b/src/hotspot/cpu/aarch64/globals_aarch64.hpp @@ -38,7 +38,7 @@ define_pd_global(bool, UncommonNullCast, true); // Uncommon-trap nulls define_pd_global(bool, DelayCompilerStubsGeneration, COMPILER2_OR_JVMCI); -define_pd_global(uintx, CodeCacheSegmentSize, 64 COMPILER1_AND_COMPILER2_PRESENT(+64)); // Tiered compilation has large code-entry alignment. +define_pd_global(uintx, CodeCacheSegmentSize, 64); define_pd_global(intx, CodeEntryAlignment, 64); define_pd_global(intx, OptoLoopAlignment, 16); diff --git a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp index 9835fb5aca1..252f4232115 100644 --- a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.cpp @@ -4782,23 +4782,6 @@ void MacroAssembler::kernel_crc32_common_fold_using_crypto_pmull(Register crc, R mov(tmp1, v0, D, 1); } -SkipIfEqual::SkipIfEqual( - MacroAssembler* masm, const bool* flag_addr, bool value) { - _masm = masm; - uint64_t offset; - _masm->adrp(rscratch1, ExternalAddress((address)flag_addr), offset); - _masm->ldrb(rscratch1, Address(rscratch1, offset)); - if (value) { - _masm->cbnzw(rscratch1, _label); - } else { - _masm->cbzw(rscratch1, _label); - } -} - -SkipIfEqual::~SkipIfEqual() { - _masm->bind(_label); -} - void MacroAssembler::addptr(const Address &dst, int32_t src) { Address adr; switch(dst.getMode()) { diff --git a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp index e49f0c49ef6..48fb3c2b071 100644 --- a/src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp +++ b/src/hotspot/cpu/aarch64/macroAssembler_aarch64.hpp @@ -1652,24 +1652,6 @@ class MacroAssembler: public Assembler { inline bool AbstractAssembler::pd_check_instruction_mark() { return false; } #endif -/** - * class SkipIfEqual: - * - * Instantiating this class will result in assembly code being output that will - * jump around any code emitted between the creation of the instance and it's - * automatic destruction at the end of a scope block, depending on the value of - * the flag passed to the constructor, which will be checked at run-time. - */ -class SkipIfEqual { - private: - MacroAssembler* _masm; - Label _label; - - public: - SkipIfEqual(MacroAssembler*, const bool* flag_addr, bool value); - ~SkipIfEqual(); -}; - struct tableswitch { Register _reg; int _insn_index; jint _first_key; jint _last_key; diff --git a/src/hotspot/cpu/aarch64/vm_version_aarch64.cpp b/src/hotspot/cpu/aarch64/vm_version_aarch64.cpp index d71162ac568..f18cec16488 100644 --- a/src/hotspot/cpu/aarch64/vm_version_aarch64.cpp +++ b/src/hotspot/cpu/aarch64/vm_version_aarch64.cpp @@ -259,6 +259,9 @@ void VM_Version::initialize() { if (FLAG_IS_DEFAULT(UseCryptoPmullForCRC32)) { FLAG_SET_DEFAULT(UseCryptoPmullForCRC32, true); } + if (FLAG_IS_DEFAULT(CodeEntryAlignment)) { + FLAG_SET_DEFAULT(CodeEntryAlignment, 32); + } } if (UseCryptoPmullForCRC32 && (!VM_Version::supports_pmull() || !VM_Version::supports_sha3() || !VM_Version::supports_crc32())) { diff --git a/src/hotspot/cpu/arm/globals_arm.hpp b/src/hotspot/cpu/arm/globals_arm.hpp index 084d10beea1..9c4b8500e18 100644 --- a/src/hotspot/cpu/arm/globals_arm.hpp +++ b/src/hotspot/cpu/arm/globals_arm.hpp @@ -36,7 +36,7 @@ define_pd_global(bool, TrapBasedNullChecks, false); // Not needed define_pd_global(bool, DelayCompilerStubsGeneration, false); // No need - only few compiler's stubs -define_pd_global(uintx, CodeCacheSegmentSize, 64 COMPILER1_AND_COMPILER2_PRESENT(+64)); // Tiered compilation has large code-entry alignment. +define_pd_global(uintx, CodeCacheSegmentSize, 64); define_pd_global(intx, CodeEntryAlignment, 16); define_pd_global(intx, OptoLoopAlignment, 16); diff --git a/src/hotspot/cpu/ppc/assembler_ppc.hpp b/src/hotspot/cpu/ppc/assembler_ppc.hpp index d445108098b..b2711ac43b0 100644 --- a/src/hotspot/cpu/ppc/assembler_ppc.hpp +++ b/src/hotspot/cpu/ppc/assembler_ppc.hpp @@ -2502,19 +2502,19 @@ class Assembler : public AbstractAssembler { // load the constant are emitted beforehand. Store instructions need a // tmp reg if the constant is not encodable as immediate. // Size unpredictable. - void ld( Register d, RegisterOrConstant roc, Register s1 = noreg); - void lwa( Register d, RegisterOrConstant roc, Register s1 = noreg); - void lwz( Register d, RegisterOrConstant roc, Register s1 = noreg); - void lha( Register d, RegisterOrConstant roc, Register s1 = noreg); - void lhz( Register d, RegisterOrConstant roc, Register s1 = noreg); - void lbz( Register d, RegisterOrConstant roc, Register s1 = noreg); - void std( Register d, RegisterOrConstant roc, Register s1 = noreg, Register tmp = noreg); - void stw( Register d, RegisterOrConstant roc, Register s1 = noreg, Register tmp = noreg); - void sth( Register d, RegisterOrConstant roc, Register s1 = noreg, Register tmp = noreg); - void stb( Register d, RegisterOrConstant roc, Register s1 = noreg, Register tmp = noreg); - void add( Register d, Register s, RegisterOrConstant roc); - void add( Register d, RegisterOrConstant roc, Register s) { add(d, s, roc); } - void sub( Register d, Register s, RegisterOrConstant roc); + void ld( Register d, RegisterOrConstant roc, Register s1 = noreg); + void lwa(Register d, RegisterOrConstant roc, Register s1 = noreg); + void lwz(Register d, RegisterOrConstant roc, Register s1 = noreg); + void lha(Register d, RegisterOrConstant roc, Register s1 = noreg); + void lhz(Register d, RegisterOrConstant roc, Register s1 = noreg); + void lbz(Register d, RegisterOrConstant roc, Register s1 = noreg); + void std(Register d, RegisterOrConstant roc, Register s1 = noreg, Register tmp = noreg); + void stw(Register d, RegisterOrConstant roc, Register s1 = noreg, Register tmp = noreg); + void sth(Register d, RegisterOrConstant roc, Register s1 = noreg, Register tmp = noreg); + void stb(Register d, RegisterOrConstant roc, Register s1 = noreg, Register tmp = noreg); + void add(Register d, Register s, RegisterOrConstant roc); + void add(Register d, RegisterOrConstant roc, Register s) { add(d, s, roc); } + void sub(Register d, Register s, RegisterOrConstant roc); void xorr(Register d, Register s, RegisterOrConstant roc); void xorr(Register d, RegisterOrConstant roc, Register s) { xorr(d, s, roc); } void cmpw(ConditionRegister d, Register s, RegisterOrConstant roc); @@ -2522,6 +2522,17 @@ class Assembler : public AbstractAssembler { // Load pointer d from s1+roc. void ld_ptr(Register d, RegisterOrConstant roc, Register s1 = noreg) { ld(d, roc, s1); } + void ld( Register d, Address &a); + void lwa(Register d, Address &a); + void lwz(Register d, Address &a); + void lha(Register d, Address &a); + void lhz(Register d, Address &a); + void lbz(Register d, Address &a); + void std(Register d, Address &a, Register tmp = noreg); + void stw(Register d, Address &a, Register tmp = noreg); + void sth(Register d, Address &a, Register tmp = noreg); + void stb(Register d, Address &a, Register tmp = noreg); + // Emit several instructions to load a 64 bit constant. This issues a fixed // instruction pattern so that the constant can be patched later on. enum { diff --git a/src/hotspot/cpu/ppc/assembler_ppc.inline.hpp b/src/hotspot/cpu/ppc/assembler_ppc.inline.hpp index 98c8b629844..b0eaaccf0d0 100644 --- a/src/hotspot/cpu/ppc/assembler_ppc.inline.hpp +++ b/src/hotspot/cpu/ppc/assembler_ppc.inline.hpp @@ -338,28 +338,46 @@ inline void Assembler::insrwi( Register a, Register s, int n, int b) // PPC 1, section 3.3.2 Fixed-Point Load Instructions inline void Assembler::lwzx( Register d, Register s1, Register s2) { emit_int32(LWZX_OPCODE | rt(d) | ra0mem(s1) | rb(s2));} +inline void Assembler::lwz( Register d, Address &a) { + lwz(d, a.index() != noreg ? RegisterOrConstant(a.index()) : RegisterOrConstant(a.disp()), a.base()); +} inline void Assembler::lwz( Register d, int si16, Register s1) { emit_int32(LWZ_OPCODE | rt(d) | d1(si16) | ra0mem(s1));} inline void Assembler::lwzu( Register d, int si16, Register s1) { assert(d != s1, "according to ibm manual"); emit_int32(LWZU_OPCODE | rt(d) | d1(si16) | rta0mem(s1));} inline void Assembler::lwax( Register d, Register s1, Register s2) { emit_int32(LWAX_OPCODE | rt(d) | ra0mem(s1) | rb(s2));} +inline void Assembler::lwa( Register d, Address &a) { + lwa(d, a.index() != noreg ? RegisterOrConstant(a.index()) : RegisterOrConstant(a.disp()), a.base()); +} inline void Assembler::lwa( Register d, int si16, Register s1) { emit_int32(LWA_OPCODE | rt(d) | ds(si16) | ra0mem(s1));} inline void Assembler::lwbrx( Register d, Register s1, Register s2) { emit_int32(LWBRX_OPCODE | rt(d) | ra0mem(s1) | rb(s2));} inline void Assembler::lhzx( Register d, Register s1, Register s2) { emit_int32(LHZX_OPCODE | rt(d) | ra0mem(s1) | rb(s2));} +inline void Assembler::lhz( Register d, Address &a) { + lhz(d, a.index() != noreg ? RegisterOrConstant(a.index()) : RegisterOrConstant(a.disp()), a.base()); +} inline void Assembler::lhz( Register d, int si16, Register s1) { emit_int32(LHZ_OPCODE | rt(d) | d1(si16) | ra0mem(s1));} inline void Assembler::lhzu( Register d, int si16, Register s1) { assert(d != s1, "according to ibm manual"); emit_int32(LHZU_OPCODE | rt(d) | d1(si16) | rta0mem(s1));} inline void Assembler::lhbrx( Register d, Register s1, Register s2) { emit_int32(LHBRX_OPCODE | rt(d) | ra0mem(s1) | rb(s2));} inline void Assembler::lhax( Register d, Register s1, Register s2) { emit_int32(LHAX_OPCODE | rt(d) | ra0mem(s1) | rb(s2));} +inline void Assembler::lha( Register d, Address &a) { + lha(d, a.index() != noreg ? RegisterOrConstant(a.index()) : RegisterOrConstant(a.disp()), a.base()); +} inline void Assembler::lha( Register d, int si16, Register s1) { emit_int32(LHA_OPCODE | rt(d) | d1(si16) | ra0mem(s1));} inline void Assembler::lhau( Register d, int si16, Register s1) { assert(d != s1, "according to ibm manual"); emit_int32(LHAU_OPCODE | rt(d) | d1(si16) | rta0mem(s1));} inline void Assembler::lbzx( Register d, Register s1, Register s2) { emit_int32(LBZX_OPCODE | rt(d) | ra0mem(s1) | rb(s2));} +inline void Assembler::lbz( Register d, Address &a) { + lbz(d, a.index() != noreg ? RegisterOrConstant(a.index()) : RegisterOrConstant(a.disp()), a.base()); +} inline void Assembler::lbz( Register d, int si16, Register s1) { emit_int32(LBZ_OPCODE | rt(d) | d1(si16) | ra0mem(s1));} inline void Assembler::lbzu( Register d, int si16, Register s1) { assert(d != s1, "according to ibm manual"); emit_int32(LBZU_OPCODE | rt(d) | d1(si16) | rta0mem(s1));} +inline void Assembler::ld( Register d, Address &a) { + ld(d, a.index() != noreg ? RegisterOrConstant(a.index()) : RegisterOrConstant(a.disp()), a.base()); +} inline void Assembler::ld( Register d, int si16, Register s1) { emit_int32(LD_OPCODE | rt(d) | ds(si16) | ra0mem(s1));} inline void Assembler::ld( Register d, ByteSize si16, Register s1) { assert(in_bytes(si16) < 0x7fff, "overflow"); ld(d, in_bytes(si16), s1); } inline void Assembler::ldx( Register d, Register s1, Register s2) { emit_int32(LDX_OPCODE | rt(d) | ra0mem(s1) | rb(s2));} @@ -371,19 +389,31 @@ inline void Assembler::ld_ptr(Register d, ByteSize b, Register s1) { ld(d, in_by // PPC 1, section 3.3.3 Fixed-Point Store Instructions inline void Assembler::stwx( Register d, Register s1, Register s2) { emit_int32(STWX_OPCODE | rs(d) | ra0mem(s1) | rb(s2));} +inline void Assembler::stw( Register d, Address &a, Register tmp) { + stw(d, a.index() != noreg ? RegisterOrConstant(a.index()) : RegisterOrConstant(a.disp()), a.base(), tmp); +} inline void Assembler::stw( Register d, int si16, Register s1) { emit_int32(STW_OPCODE | rs(d) | d1(si16) | ra0mem(s1));} inline void Assembler::stwu( Register d, int si16, Register s1) { emit_int32(STWU_OPCODE | rs(d) | d1(si16) | rta0mem(s1));} inline void Assembler::stwbrx( Register d, Register s1, Register s2) { emit_int32(STWBRX_OPCODE | rs(d) | ra0mem(s1) | rb(s2));} inline void Assembler::sthx( Register d, Register s1, Register s2) { emit_int32(STHX_OPCODE | rs(d) | ra0mem(s1) | rb(s2));} +inline void Assembler::sth( Register d, Address &a, Register tmp) { + sth(d, a.index() != noreg ? RegisterOrConstant(a.index()) : RegisterOrConstant(a.disp()), a.base(), tmp); +} inline void Assembler::sth( Register d, int si16, Register s1) { emit_int32(STH_OPCODE | rs(d) | d1(si16) | ra0mem(s1));} inline void Assembler::sthu( Register d, int si16, Register s1) { emit_int32(STHU_OPCODE | rs(d) | d1(si16) | rta0mem(s1));} inline void Assembler::sthbrx( Register d, Register s1, Register s2) { emit_int32(STHBRX_OPCODE | rs(d) | ra0mem(s1) | rb(s2));} inline void Assembler::stbx( Register d, Register s1, Register s2) { emit_int32(STBX_OPCODE | rs(d) | ra0mem(s1) | rb(s2));} +inline void Assembler::stb( Register d, Address &a, Register tmp) { + stb(d, a.index() != noreg ? RegisterOrConstant(a.index()) : RegisterOrConstant(a.disp()), a.base(), tmp); +} inline void Assembler::stb( Register d, int si16, Register s1) { emit_int32(STB_OPCODE | rs(d) | d1(si16) | ra0mem(s1));} inline void Assembler::stbu( Register d, int si16, Register s1) { emit_int32(STBU_OPCODE | rs(d) | d1(si16) | rta0mem(s1));} +inline void Assembler::std( Register d, Address &a, Register tmp) { + std(d, a.index() != noreg ? RegisterOrConstant(a.index()) : RegisterOrConstant(a.disp()), a.base(), tmp); +} inline void Assembler::std( Register d, int si16, Register s1) { emit_int32(STD_OPCODE | rs(d) | ds(si16) | ra0mem(s1));} inline void Assembler::stdx( Register d, Register s1, Register s2) { emit_int32(STDX_OPCODE | rs(d) | ra0mem(s1) | rb(s2));} inline void Assembler::stdu( Register d, int si16, Register s1) { emit_int32(STDU_OPCODE | rs(d) | ds(si16) | rta0mem(s1));} diff --git a/src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp b/src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp index 57e5f65d2f9..36e1ac82334 100644 --- a/src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp +++ b/src/hotspot/cpu/ppc/c1_LIRAssembler_ppc.cpp @@ -168,9 +168,9 @@ void LIR_Assembler::osr_entry() { mo = frame_map()->address_for_monitor_object(i); assert(ml.index() == noreg && mo.index() == noreg, "sanity"); __ ld(R0, slot_offset + 0, OSR_buf); - __ std(R0, ml.disp(), ml.base()); + __ std(R0, ml); __ ld(R0, slot_offset + 1*BytesPerWord, OSR_buf); - __ std(R0, mo.disp(), mo.base()); + __ std(R0, mo); } if (use_OSR_bias) { @@ -601,7 +601,7 @@ void LIR_Assembler::emit_opConvert(LIR_OpConvert* op) { __ fcmpu(CCR0, rsrc, rsrc); if (dst_in_memory) { __ li(R0, 0); // 0 in case of NAN - __ std(R0, addr.disp(), addr.base()); + __ std(R0, addr); } else { __ li(dst->as_register(), 0); } @@ -625,7 +625,7 @@ void LIR_Assembler::emit_opConvert(LIR_OpConvert* op) { __ fcmpu(CCR0, rsrc, rsrc); if (dst_in_memory) { __ li(R0, 0); // 0 in case of NAN - __ std(R0, addr.disp(), addr.base()); + __ std(R0, addr); } else { __ li(dst->as_register_lo(), 0); } @@ -893,20 +893,20 @@ void LIR_Assembler::const2stack(LIR_Opr src, LIR_Opr dest) { int value = c->as_jint_bits(); __ load_const_optimized(src_reg, value); Address addr = frame_map()->address_for_slot(dest->single_stack_ix()); - __ stw(src_reg, addr.disp(), addr.base()); + __ stw(src_reg, addr); break; } case T_ADDRESS: { int value = c->as_jint_bits(); __ load_const_optimized(src_reg, value); Address addr = frame_map()->address_for_slot(dest->single_stack_ix()); - __ std(src_reg, addr.disp(), addr.base()); + __ std(src_reg, addr); break; } case T_OBJECT: { jobject2reg(c->as_jobject(), src_reg); Address addr = frame_map()->address_for_slot(dest->single_stack_ix()); - __ std(src_reg, addr.disp(), addr.base()); + __ std(src_reg, addr); break; } case T_LONG: @@ -914,7 +914,7 @@ void LIR_Assembler::const2stack(LIR_Opr src, LIR_Opr dest) { int value = c->as_jlong_bits(); __ load_const_optimized(src_reg, value); Address addr = frame_map()->address_for_double_slot(dest->double_stack_ix()); - __ std(src_reg, addr.disp(), addr.base()); + __ std(src_reg, addr); break; } default: @@ -1090,24 +1090,24 @@ void LIR_Assembler::stack2stack(LIR_Opr src, LIR_Opr dest, BasicType type) { case T_FLOAT: { Address from = frame_map()->address_for_slot(src->single_stack_ix()); Address to = frame_map()->address_for_slot(dest->single_stack_ix()); - __ lwz(tmp, from.disp(), from.base()); - __ stw(tmp, to.disp(), to.base()); + __ lwz(tmp, from); + __ stw(tmp, to); break; } case T_ADDRESS: case T_OBJECT: { Address from = frame_map()->address_for_slot(src->single_stack_ix()); Address to = frame_map()->address_for_slot(dest->single_stack_ix()); - __ ld(tmp, from.disp(), from.base()); - __ std(tmp, to.disp(), to.base()); + __ ld(tmp, from); + __ std(tmp, to); break; } case T_LONG: case T_DOUBLE: { Address from = frame_map()->address_for_double_slot(src->double_stack_ix()); Address to = frame_map()->address_for_double_slot(dest->double_stack_ix()); - __ ld(tmp, from.disp(), from.base()); - __ std(tmp, to.disp(), to.base()); + __ ld(tmp, from); + __ std(tmp, to); break; } diff --git a/src/hotspot/cpu/ppc/gc/x/xBarrierSetAssembler_ppc.cpp b/src/hotspot/cpu/ppc/gc/x/xBarrierSetAssembler_ppc.cpp deleted file mode 100644 index ca826e47352..00000000000 --- a/src/hotspot/cpu/ppc/gc/x/xBarrierSetAssembler_ppc.cpp +++ /dev/null @@ -1,585 +0,0 @@ -/* - * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2021, 2024 SAP SE. 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "asm/register.hpp" -#include "asm/macroAssembler.inline.hpp" -#include "code/codeBlob.hpp" -#include "code/vmreg.inline.hpp" -#include "gc/x/xBarrier.inline.hpp" -#include "gc/x/xBarrierSet.hpp" -#include "gc/x/xBarrierSetAssembler.hpp" -#include "gc/x/xBarrierSetRuntime.hpp" -#include "gc/x/xThreadLocalData.hpp" -#include "memory/resourceArea.hpp" -#include "register_ppc.hpp" -#include "runtime/sharedRuntime.hpp" -#include "utilities/globalDefinitions.hpp" -#include "utilities/macros.hpp" -#ifdef COMPILER1 -#include "c1/c1_LIRAssembler.hpp" -#include "c1/c1_MacroAssembler.hpp" -#include "gc/x/c1/xBarrierSetC1.hpp" -#endif // COMPILER1 -#ifdef COMPILER2 -#include "gc/x/c2/xBarrierSetC2.hpp" -#endif // COMPILER2 - -#undef __ -#define __ masm-> - -void XBarrierSetAssembler::load_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type, - Register base, RegisterOrConstant ind_or_offs, Register dst, - Register tmp1, Register tmp2, - MacroAssembler::PreservationLevel preservation_level, Label *L_handle_null) { - __ block_comment("load_at (zgc) {"); - - // Check whether a special gc barrier is required for this particular load - // (e.g. whether it's a reference load or not) - if (!XBarrierSet::barrier_needed(decorators, type)) { - BarrierSetAssembler::load_at(masm, decorators, type, base, ind_or_offs, dst, - tmp1, tmp2, preservation_level, L_handle_null); - return; - } - - if (ind_or_offs.is_register()) { - assert_different_registers(base, ind_or_offs.as_register(), tmp1, tmp2, R0, noreg); - assert_different_registers(dst, ind_or_offs.as_register(), tmp1, tmp2, R0, noreg); - } else { - assert_different_registers(base, tmp1, tmp2, R0, noreg); - assert_different_registers(dst, tmp1, tmp2, R0, noreg); - } - - /* ==== Load the pointer using the standard implementation for the actual heap access - and the decompression of compressed pointers ==== */ - // Result of 'load_at' (standard implementation) will be written back to 'dst'. - // As 'base' is required for the C-call, it must be reserved in case of a register clash. - Register saved_base = base; - if (base == dst) { - __ mr(tmp2, base); - saved_base = tmp2; - } - - BarrierSetAssembler::load_at(masm, decorators, type, base, ind_or_offs, dst, - tmp1, noreg, preservation_level, L_handle_null); - - /* ==== Check whether pointer is dirty ==== */ - Label skip_barrier; - - // Load bad mask into scratch register. - __ ld(tmp1, (intptr_t) XThreadLocalData::address_bad_mask_offset(), R16_thread); - - // The color bits of the to-be-tested pointer do not have to be equivalent to the 'bad_mask' testing bits. - // A pointer is classified as dirty if any of the color bits that also match the bad mask is set. - // Conversely, it follows that the logical AND of the bad mask and the pointer must be zero - // if the pointer is not dirty. - // Only dirty pointers must be processed by this barrier, so we can skip it in case the latter condition holds true. - __ and_(tmp1, tmp1, dst); - __ beq(CCR0, skip_barrier); - - /* ==== Invoke barrier ==== */ - int nbytes_save = 0; - - const bool needs_frame = preservation_level >= MacroAssembler::PRESERVATION_FRAME_LR; - const bool preserve_gp_registers = preservation_level >= MacroAssembler::PRESERVATION_FRAME_LR_GP_REGS; - const bool preserve_fp_registers = preservation_level >= MacroAssembler::PRESERVATION_FRAME_LR_GP_FP_REGS; - - const bool preserve_R3 = dst != R3_ARG1; - - if (needs_frame) { - if (preserve_gp_registers) { - nbytes_save = (preserve_fp_registers - ? MacroAssembler::num_volatile_gp_regs + MacroAssembler::num_volatile_fp_regs - : MacroAssembler::num_volatile_gp_regs) * BytesPerWord; - nbytes_save -= preserve_R3 ? 0 : BytesPerWord; - __ save_volatile_gprs(R1_SP, -nbytes_save, preserve_fp_registers, preserve_R3); - } - - __ save_LR(tmp1); - __ push_frame_reg_args(nbytes_save, tmp1); - } - - // Setup arguments - if (saved_base != R3_ARG1) { - __ mr_if_needed(R3_ARG1, dst); - __ add(R4_ARG2, ind_or_offs, saved_base); - } else if (dst != R4_ARG2) { - __ add(R4_ARG2, ind_or_offs, saved_base); - __ mr(R3_ARG1, dst); - } else { - __ add(R0, ind_or_offs, saved_base); - __ mr(R3_ARG1, dst); - __ mr(R4_ARG2, R0); - } - - __ call_VM_leaf(XBarrierSetRuntime::load_barrier_on_oop_field_preloaded_addr(decorators)); - - Register result = R3_RET; - if (needs_frame) { - __ pop_frame(); - __ restore_LR(tmp1); - - if (preserve_R3) { - __ mr(R0, R3_RET); - result = R0; - } - - if (preserve_gp_registers) { - __ restore_volatile_gprs(R1_SP, -nbytes_save, preserve_fp_registers, preserve_R3); - } - } - __ mr_if_needed(dst, result); - - __ bind(skip_barrier); - __ block_comment("} load_at (zgc)"); -} - -#ifdef ASSERT -// The Z store barrier only verifies the pointers it is operating on and is thus a sole debugging measure. -void XBarrierSetAssembler::store_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type, - Register base, RegisterOrConstant ind_or_offs, Register val, - Register tmp1, Register tmp2, Register tmp3, - MacroAssembler::PreservationLevel preservation_level) { - __ block_comment("store_at (zgc) {"); - - // If the 'val' register is 'noreg', the to-be-stored value is a null pointer. - if (is_reference_type(type) && val != noreg) { - __ ld(tmp1, in_bytes(XThreadLocalData::address_bad_mask_offset()), R16_thread); - __ and_(tmp1, tmp1, val); - __ asm_assert_eq("Detected dirty pointer on the heap in Z store barrier"); - } - - // Store value - BarrierSetAssembler::store_at(masm, decorators, type, base, ind_or_offs, val, tmp1, tmp2, tmp3, preservation_level); - - __ block_comment("} store_at (zgc)"); -} -#endif // ASSERT - -void XBarrierSetAssembler::arraycopy_prologue(MacroAssembler *masm, DecoratorSet decorators, BasicType component_type, - Register src, Register dst, Register count, - Register preserve1, Register preserve2) { - __ block_comment("arraycopy_prologue (zgc) {"); - - /* ==== Check whether a special gc barrier is required for this particular load ==== */ - if (!is_reference_type(component_type)) { - return; - } - - Label skip_barrier; - - // Fast path: Array is of length zero - __ cmpdi(CCR0, count, 0); - __ beq(CCR0, skip_barrier); - - /* ==== Ensure register sanity ==== */ - Register tmp_R11 = R11_scratch1; - - assert_different_registers(src, dst, count, tmp_R11, noreg); - if (preserve1 != noreg) { - // Not technically required, but unlikely being intended. - assert_different_registers(preserve1, preserve2); - } - - /* ==== Invoke barrier (slowpath) ==== */ - int nbytes_save = 0; - - { - assert(!noreg->is_volatile(), "sanity"); - - if (preserve1->is_volatile()) { - __ std(preserve1, -BytesPerWord * ++nbytes_save, R1_SP); - } - - if (preserve2->is_volatile() && preserve1 != preserve2) { - __ std(preserve2, -BytesPerWord * ++nbytes_save, R1_SP); - } - - __ std(src, -BytesPerWord * ++nbytes_save, R1_SP); - __ std(dst, -BytesPerWord * ++nbytes_save, R1_SP); - __ std(count, -BytesPerWord * ++nbytes_save, R1_SP); - - __ save_LR(tmp_R11); - __ push_frame_reg_args(nbytes_save, tmp_R11); - } - - // XBarrierSetRuntime::load_barrier_on_oop_array_addr(src, count) - if (count == R3_ARG1) { - if (src == R4_ARG2) { - // Arguments are provided in reverse order - __ mr(tmp_R11, count); - __ mr(R3_ARG1, src); - __ mr(R4_ARG2, tmp_R11); - } else { - __ mr(R4_ARG2, count); - __ mr(R3_ARG1, src); - } - } else { - __ mr_if_needed(R3_ARG1, src); - __ mr_if_needed(R4_ARG2, count); - } - - __ call_VM_leaf(XBarrierSetRuntime::load_barrier_on_oop_array_addr()); - - __ pop_frame(); - __ restore_LR(tmp_R11); - - { - __ ld(count, -BytesPerWord * nbytes_save--, R1_SP); - __ ld(dst, -BytesPerWord * nbytes_save--, R1_SP); - __ ld(src, -BytesPerWord * nbytes_save--, R1_SP); - - if (preserve2->is_volatile() && preserve1 != preserve2) { - __ ld(preserve2, -BytesPerWord * nbytes_save--, R1_SP); - } - - if (preserve1->is_volatile()) { - __ ld(preserve1, -BytesPerWord * nbytes_save--, R1_SP); - } - } - - __ bind(skip_barrier); - - __ block_comment("} arraycopy_prologue (zgc)"); -} - -void XBarrierSetAssembler::try_resolve_jobject_in_native(MacroAssembler* masm, Register dst, Register jni_env, - Register obj, Register tmp, Label& slowpath) { - __ block_comment("try_resolve_jobject_in_native (zgc) {"); - - assert_different_registers(jni_env, obj, tmp); - - // Resolve the pointer using the standard implementation for weak tag handling and pointer verification. - BarrierSetAssembler::try_resolve_jobject_in_native(masm, dst, jni_env, obj, tmp, slowpath); - - // Check whether pointer is dirty. - __ ld(tmp, - in_bytes(XThreadLocalData::address_bad_mask_offset() - JavaThread::jni_environment_offset()), - jni_env); - - __ and_(tmp, obj, tmp); - __ bne(CCR0, slowpath); - - __ block_comment("} try_resolve_jobject_in_native (zgc)"); -} - -#undef __ - -#ifdef COMPILER1 -#define __ ce->masm()-> - -// Code emitted by LIR node "LIR_OpXLoadBarrierTest" which in turn is emitted by XBarrierSetC1::load_barrier. -// The actual compare and branch instructions are represented as stand-alone LIR nodes. -void XBarrierSetAssembler::generate_c1_load_barrier_test(LIR_Assembler* ce, - LIR_Opr ref) const { - __ block_comment("load_barrier_test (zgc) {"); - - __ ld(R0, in_bytes(XThreadLocalData::address_bad_mask_offset()), R16_thread); - __ andr(R0, R0, ref->as_pointer_register()); - __ cmpdi(CCR5 /* as mandated by LIR node */, R0, 0); - - __ block_comment("} load_barrier_test (zgc)"); -} - -// Code emitted by code stub "XLoadBarrierStubC1" which in turn is emitted by XBarrierSetC1::load_barrier. -// Invokes the runtime stub which is defined just below. -void XBarrierSetAssembler::generate_c1_load_barrier_stub(LIR_Assembler* ce, - XLoadBarrierStubC1* stub) const { - __ block_comment("c1_load_barrier_stub (zgc) {"); - - __ bind(*stub->entry()); - - /* ==== Determine relevant data registers and ensure register sanity ==== */ - Register ref = stub->ref()->as_register(); - Register ref_addr = noreg; - - // Determine reference address - if (stub->tmp()->is_valid()) { - // 'tmp' register is given, so address might have an index or a displacement. - ce->leal(stub->ref_addr(), stub->tmp()); - ref_addr = stub->tmp()->as_pointer_register(); - } else { - // 'tmp' register is not given, so address must have neither an index nor a displacement. - // The address' base register is thus usable as-is. - assert(stub->ref_addr()->as_address_ptr()->disp() == 0, "illegal displacement"); - assert(!stub->ref_addr()->as_address_ptr()->index()->is_valid(), "illegal index"); - - ref_addr = stub->ref_addr()->as_address_ptr()->base()->as_pointer_register(); - } - - assert_different_registers(ref, ref_addr, R0, noreg); - - /* ==== Invoke stub ==== */ - // Pass arguments via stack. The stack pointer will be bumped by the stub. - __ std(ref, (intptr_t) -1 * BytesPerWord, R1_SP); - __ std(ref_addr, (intptr_t) -2 * BytesPerWord, R1_SP); - - __ load_const_optimized(R0, stub->runtime_stub()); - __ call_stub(R0); - - // The runtime stub passes the result via the R0 register, overriding the previously-loaded stub address. - __ mr_if_needed(ref, R0); - __ b(*stub->continuation()); - - __ block_comment("} c1_load_barrier_stub (zgc)"); -} - -#undef __ -#define __ sasm-> - -// Code emitted by runtime code stub which in turn is emitted by XBarrierSetC1::generate_c1_runtime_stubs. -void XBarrierSetAssembler::generate_c1_load_barrier_runtime_stub(StubAssembler* sasm, - DecoratorSet decorators) const { - __ block_comment("c1_load_barrier_runtime_stub (zgc) {"); - - const int stack_parameters = 2; - const int nbytes_save = (MacroAssembler::num_volatile_regs + stack_parameters) * BytesPerWord; - - __ save_volatile_gprs(R1_SP, -nbytes_save); - __ save_LR(R0); - - // Load arguments back again from the stack. - __ ld(R3_ARG1, (intptr_t) -1 * BytesPerWord, R1_SP); // ref - __ ld(R4_ARG2, (intptr_t) -2 * BytesPerWord, R1_SP); // ref_addr - - __ push_frame_reg_args(nbytes_save, R0); - - __ call_VM_leaf(XBarrierSetRuntime::load_barrier_on_oop_field_preloaded_addr(decorators)); - - __ verify_oop(R3_RET, "Bad pointer after barrier invocation"); - __ mr(R0, R3_RET); - - __ pop_frame(); - __ restore_LR(R3_RET); - __ restore_volatile_gprs(R1_SP, -nbytes_save); - - __ blr(); - - __ block_comment("} c1_load_barrier_runtime_stub (zgc)"); -} - -#undef __ -#endif // COMPILER1 - -#ifdef COMPILER2 - -OptoReg::Name XBarrierSetAssembler::refine_register(const Node* node, OptoReg::Name opto_reg) const { - if (!OptoReg::is_reg(opto_reg)) { - return OptoReg::Bad; - } - - VMReg vm_reg = OptoReg::as_VMReg(opto_reg); - if ((vm_reg->is_Register() || vm_reg ->is_FloatRegister()) && (opto_reg & 1) != 0) { - return OptoReg::Bad; - } - - return opto_reg; -} - -#define __ _masm-> - -class XSaveLiveRegisters { - MacroAssembler* _masm; - RegMask _reg_mask; - Register _result_reg; - int _frame_size; - - public: - XSaveLiveRegisters(MacroAssembler *masm, XLoadBarrierStubC2 *stub) - : _masm(masm), _reg_mask(stub->live()), _result_reg(stub->ref()) { - - const int register_save_size = iterate_over_register_mask(ACTION_COUNT_ONLY) * BytesPerWord; - _frame_size = align_up(register_save_size, frame::alignment_in_bytes) - + frame::native_abi_reg_args_size; - - __ save_LR_CR(R0); - __ push_frame(_frame_size, R0); - - iterate_over_register_mask(ACTION_SAVE, _frame_size); - } - - ~XSaveLiveRegisters() { - iterate_over_register_mask(ACTION_RESTORE, _frame_size); - - __ addi(R1_SP, R1_SP, _frame_size); - __ restore_LR_CR(R0); - } - - private: - enum IterationAction : int { - ACTION_SAVE, - ACTION_RESTORE, - ACTION_COUNT_ONLY - }; - - int iterate_over_register_mask(IterationAction action, int offset = 0) { - int reg_save_index = 0; - RegMaskIterator live_regs_iterator(_reg_mask); - - while(live_regs_iterator.has_next()) { - const OptoReg::Name opto_reg = live_regs_iterator.next(); - - // Filter out stack slots (spilled registers, i.e., stack-allocated registers). - if (!OptoReg::is_reg(opto_reg)) { - continue; - } - - const VMReg vm_reg = OptoReg::as_VMReg(opto_reg); - if (vm_reg->is_Register()) { - Register std_reg = vm_reg->as_Register(); - - // '_result_reg' will hold the end result of the operation. Its content must thus not be preserved. - if (std_reg == _result_reg) { - continue; - } - - if (std_reg->encoding() >= R2->encoding() && std_reg->encoding() <= R12->encoding()) { - reg_save_index++; - - if (action == ACTION_SAVE) { - _masm->std(std_reg, offset - reg_save_index * BytesPerWord, R1_SP); - } else if (action == ACTION_RESTORE) { - _masm->ld(std_reg, offset - reg_save_index * BytesPerWord, R1_SP); - } else { - assert(action == ACTION_COUNT_ONLY, "Sanity"); - } - } - } else if (vm_reg->is_FloatRegister()) { - FloatRegister fp_reg = vm_reg->as_FloatRegister(); - if (fp_reg->encoding() >= F0->encoding() && fp_reg->encoding() <= F13->encoding()) { - reg_save_index++; - - if (action == ACTION_SAVE) { - _masm->stfd(fp_reg, offset - reg_save_index * BytesPerWord, R1_SP); - } else if (action == ACTION_RESTORE) { - _masm->lfd(fp_reg, offset - reg_save_index * BytesPerWord, R1_SP); - } else { - assert(action == ACTION_COUNT_ONLY, "Sanity"); - } - } - } else if (vm_reg->is_ConditionRegister()) { - // NOP. Conditions registers are covered by save_LR_CR - } else if (vm_reg->is_VectorSRegister()) { - assert(SuperwordUseVSX, "or should not reach here"); - VectorSRegister vs_reg = vm_reg->as_VectorSRegister(); - if (vs_reg->encoding() >= VSR32->encoding() && vs_reg->encoding() <= VSR51->encoding()) { - reg_save_index += 2; - - Register spill_addr = R0; - if (action == ACTION_SAVE) { - _masm->addi(spill_addr, R1_SP, offset - reg_save_index * BytesPerWord); - _masm->stxvd2x(vs_reg, spill_addr); - } else if (action == ACTION_RESTORE) { - _masm->addi(spill_addr, R1_SP, offset - reg_save_index * BytesPerWord); - _masm->lxvd2x(vs_reg, spill_addr); - } else { - assert(action == ACTION_COUNT_ONLY, "Sanity"); - } - } - } else { - if (vm_reg->is_SpecialRegister()) { - fatal("Special registers are unsupported. Found register %s", vm_reg->name()); - } else { - fatal("Register type is not known"); - } - } - } - - return reg_save_index; - } -}; - -#undef __ -#define __ _masm-> - -class XSetupArguments { - MacroAssembler* const _masm; - const Register _ref; - const Address _ref_addr; - - public: - XSetupArguments(MacroAssembler* masm, XLoadBarrierStubC2* stub) : - _masm(masm), - _ref(stub->ref()), - _ref_addr(stub->ref_addr()) { - - // Desired register/argument configuration: - // _ref: R3_ARG1 - // _ref_addr: R4_ARG2 - - // '_ref_addr' can be unspecified. In that case, the barrier will not heal the reference. - if (_ref_addr.base() == noreg) { - assert_different_registers(_ref, R0, noreg); - - __ mr_if_needed(R3_ARG1, _ref); - __ li(R4_ARG2, 0); - } else { - assert_different_registers(_ref, _ref_addr.base(), R0, noreg); - assert(!_ref_addr.index()->is_valid(), "reference addresses must not contain an index component"); - - if (_ref != R4_ARG2) { - // Calculate address first as the address' base register might clash with R4_ARG2 - __ addi(R4_ARG2, _ref_addr.base(), _ref_addr.disp()); - __ mr_if_needed(R3_ARG1, _ref); - } else if (_ref_addr.base() != R3_ARG1) { - __ mr(R3_ARG1, _ref); - __ addi(R4_ARG2, _ref_addr.base(), _ref_addr.disp()); // Clobbering _ref - } else { - // Arguments are provided in inverse order (i.e. _ref == R4_ARG2, _ref_addr == R3_ARG1) - __ mr(R0, _ref); - __ addi(R4_ARG2, _ref_addr.base(), _ref_addr.disp()); - __ mr(R3_ARG1, R0); - } - } - } -}; - -#undef __ -#define __ masm-> - -void XBarrierSetAssembler::generate_c2_load_barrier_stub(MacroAssembler* masm, XLoadBarrierStubC2* stub) const { - __ block_comment("generate_c2_load_barrier_stub (zgc) {"); - - __ bind(*stub->entry()); - - Register ref = stub->ref(); - Address ref_addr = stub->ref_addr(); - - assert_different_registers(ref, ref_addr.base()); - - { - XSaveLiveRegisters save_live_registers(masm, stub); - XSetupArguments setup_arguments(masm, stub); - - __ call_VM_leaf(stub->slow_path()); - __ mr_if_needed(ref, R3_RET); - } - - __ b(*stub->continuation()); - - __ block_comment("} generate_c2_load_barrier_stub (zgc)"); -} - -#undef __ -#endif // COMPILER2 diff --git a/src/hotspot/cpu/ppc/gc/x/xBarrierSetAssembler_ppc.hpp b/src/hotspot/cpu/ppc/gc/x/xBarrierSetAssembler_ppc.hpp deleted file mode 100644 index 8dfd4524dfe..00000000000 --- a/src/hotspot/cpu/ppc/gc/x/xBarrierSetAssembler_ppc.hpp +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2021, 2022 SAP SE. 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef CPU_PPC_GC_X_XBARRIERSETASSEMBLER_PPC_HPP -#define CPU_PPC_GC_X_XBARRIERSETASSEMBLER_PPC_HPP - -#include "code/vmreg.hpp" -#include "oops/accessDecorators.hpp" -#ifdef COMPILER2 -#include "opto/optoreg.hpp" -#endif // COMPILER2 - -#ifdef COMPILER1 -class LIR_Assembler; -class LIR_Opr; -class StubAssembler; -#endif // COMPILER1 - -#ifdef COMPILER2 -class Node; -#endif // COMPILER2 - -#ifdef COMPILER1 -class XLoadBarrierStubC1; -#endif // COMPILER1 - -#ifdef COMPILER2 -class XLoadBarrierStubC2; -#endif // COMPILER2 - -class XBarrierSetAssembler : public XBarrierSetAssemblerBase { -public: - virtual void load_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type, - Register base, RegisterOrConstant ind_or_offs, Register dst, - Register tmp1, Register tmp2, - MacroAssembler::PreservationLevel preservation_level, Label *L_handle_null = nullptr); - -#ifdef ASSERT - virtual void store_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type, - Register base, RegisterOrConstant ind_or_offs, Register val, - Register tmp1, Register tmp2, Register tmp3, - MacroAssembler::PreservationLevel preservation_level); -#endif // ASSERT - - virtual void arraycopy_prologue(MacroAssembler* masm, DecoratorSet decorators, BasicType type, - Register src, Register dst, Register count, - Register preserve1, Register preserve2); - - virtual void try_resolve_jobject_in_native(MacroAssembler* masm, Register dst, Register jni_env, - Register obj, Register tmp, Label& slowpath); - - virtual NMethodPatchingType nmethod_patching_type() { return NMethodPatchingType::conc_data_patch; } - -#ifdef COMPILER1 - void generate_c1_load_barrier_test(LIR_Assembler* ce, - LIR_Opr ref) const; - - void generate_c1_load_barrier_stub(LIR_Assembler* ce, - XLoadBarrierStubC1* stub) const; - - void generate_c1_load_barrier_runtime_stub(StubAssembler* sasm, - DecoratorSet decorators) const; -#endif // COMPILER1 - -#ifdef COMPILER2 - OptoReg::Name refine_register(const Node* node, OptoReg::Name opto_reg) const; - - void generate_c2_load_barrier_stub(MacroAssembler* masm, XLoadBarrierStubC2* stub) const; -#endif // COMPILER2 -}; - -#endif // CPU_PPC_GC_X_XBARRIERSETASSEMBLER_PPC_HPP diff --git a/src/hotspot/cpu/ppc/gc/x/xGlobals_ppc.cpp b/src/hotspot/cpu/ppc/gc/x/xGlobals_ppc.cpp deleted file mode 100644 index 3218a765fc7..00000000000 --- a/src/hotspot/cpu/ppc/gc/x/xGlobals_ppc.cpp +++ /dev/null @@ -1,203 +0,0 @@ -/* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2021 SAP SE. 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/shared/gcLogPrecious.hpp" -#include "gc/shared/gc_globals.hpp" -#include "gc/x/xGlobals.hpp" -#include "runtime/globals.hpp" -#include "runtime/os.hpp" -#include "utilities/globalDefinitions.hpp" -#include "utilities/powerOfTwo.hpp" -#include - -#ifdef LINUX -#include -#endif // LINUX - -// -// The overall memory layouts across different power platforms are similar and only differ with regards to -// the position of the highest addressable bit; the position of the metadata bits and the size of the actual -// addressable heap address space are adjusted accordingly. -// -// The following memory schema shows an exemplary layout in which bit '45' is the highest addressable bit. -// It is assumed that this virtual memory address space layout is predominant on the power platform. -// -// Standard Address Space & Pointer Layout -// --------------------------------------- -// -// +--------------------------------+ 0x00007FFFFFFFFFFF (127 TiB - 1) -// . . -// . . -// . . -// +--------------------------------+ 0x0000140000000000 (20 TiB) -// | Remapped View | -// +--------------------------------+ 0x0000100000000000 (16 TiB) -// . . -// +--------------------------------+ 0x00000c0000000000 (12 TiB) -// | Marked1 View | -// +--------------------------------+ 0x0000080000000000 (8 TiB) -// | Marked0 View | -// +--------------------------------+ 0x0000040000000000 (4 TiB) -// . . -// +--------------------------------+ 0x0000000000000000 -// -// 6 4 4 4 4 -// 3 6 5 2 1 0 -// +--------------------+----+-----------------------------------------------+ -// |00000000 00000000 00|1111|11 11111111 11111111 11111111 11111111 11111111| -// +--------------------+----+-----------------------------------------------+ -// | | | -// | | * 41-0 Object Offset (42-bits, 4TB address space) -// | | -// | * 45-42 Metadata Bits (4-bits) 0001 = Marked0 (Address view 4-8TB) -// | 0010 = Marked1 (Address view 8-12TB) -// | 0100 = Remapped (Address view 16-20TB) -// | 1000 = Finalizable (Address view N/A) -// | -// * 63-46 Fixed (18-bits, always zero) -// - -// Maximum value as per spec (Power ISA v2.07): 2 ^ 60 bytes, i.e. 1 EiB (exbibyte) -static const unsigned int MAXIMUM_MAX_ADDRESS_BIT = 60; - -// Most modern power processors provide an address space with not more than 45 bit addressable bit, -// that is an address space of 32 TiB in size. -static const unsigned int DEFAULT_MAX_ADDRESS_BIT = 45; - -// Minimum value returned, if probing fails: 64 GiB -static const unsigned int MINIMUM_MAX_ADDRESS_BIT = 36; - -// Determines the highest addressable bit of the virtual address space (depends on platform) -// by trying to interact with memory in that address range, -// i.e. by syncing existing mappings (msync) or by temporarily mapping the memory area (mmap). -// If one of those operations succeeds, it is proven that the targeted memory area is within the virtual address space. -// -// To reduce the number of required system calls to a bare minimum, the DEFAULT_MAX_ADDRESS_BIT is intentionally set -// lower than what the ABI would theoretically permit. -// Such an avoidance strategy, however, might impose unnecessary limits on processors that exceed this limit. -// If DEFAULT_MAX_ADDRESS_BIT is addressable, the next higher bit will be tested as well to ensure that -// the made assumption does not artificially restrict the memory availability. -static unsigned int probe_valid_max_address_bit(size_t init_bit, size_t min_bit) { - assert(init_bit >= min_bit, "Sanity"); - assert(init_bit <= MAXIMUM_MAX_ADDRESS_BIT, "Test bit is outside the assumed address space range"); - -#ifdef LINUX - unsigned int max_valid_address_bit = 0; - void* last_allocatable_address = nullptr; - - const size_t page_size = os::vm_page_size(); - - for (size_t i = init_bit; i >= min_bit; --i) { - void* base_addr = (void*) (((unsigned long) 1U) << i); - - /* ==== Try msync-ing already mapped memory page ==== */ - if (msync(base_addr, page_size, MS_ASYNC) == 0) { - // The page of the given address was synced by the linux kernel and must thus be both, mapped and valid. - max_valid_address_bit = i; - break; - } - if (errno != ENOMEM) { - // An unexpected error occurred, i.e. an error not indicating that the targeted memory page is unmapped, - // but pointing out another type of issue. - // Even though this should never happen, those issues may come up due to undefined behavior. -#ifdef ASSERT - fatal("Received '%s' while probing the address space for the highest valid bit", os::errno_name(errno)); -#else // ASSERT - log_warning_p(gc)("Received '%s' while probing the address space for the highest valid bit", os::errno_name(errno)); -#endif // ASSERT - continue; - } - - /* ==== Try mapping memory page on our own ==== */ - last_allocatable_address = mmap(base_addr, page_size, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0); - if (last_allocatable_address != MAP_FAILED) { - munmap(last_allocatable_address, page_size); - } - - if (last_allocatable_address == base_addr) { - // As the linux kernel mapped exactly the page we have requested, the address must be valid. - max_valid_address_bit = i; - break; - } - - log_info_p(gc, init)("Probe failed for bit '%zu'", i); - } - - if (max_valid_address_bit == 0) { - // Probing did not bring up any usable address bit. - // As an alternative, the VM evaluates the address returned by mmap as it is expected that the reserved page - // will be close to the probed address that was out-of-range. - // As per mmap(2), "the kernel [will take] [the address] as a hint about where to - // place the mapping; on Linux, the mapping will be created at a nearby page boundary". - // It should thus be a "close enough" approximation to the real virtual memory address space limit. - // - // This recovery strategy is only applied in production builds. - // In debug builds, an assertion in 'XPlatformAddressOffsetBits' will bail out the VM to indicate that - // the assumed address space is no longer up-to-date. - if (last_allocatable_address != MAP_FAILED) { - const unsigned int bitpos = BitsPerSize_t - count_leading_zeros((size_t) last_allocatable_address) - 1; - log_info_p(gc, init)("Did not find any valid addresses within the range, using address '%u' instead", bitpos); - return bitpos; - } - -#ifdef ASSERT - fatal("Available address space can not be determined"); -#else // ASSERT - log_warning_p(gc)("Cannot determine available address space. Falling back to default value."); - return DEFAULT_MAX_ADDRESS_BIT; -#endif // ASSERT - } else { - if (max_valid_address_bit == init_bit) { - // An usable address bit has been found immediately. - // To ensure that the entire virtual address space is exploited, the next highest bit will be tested as well. - log_info_p(gc, init)("Hit valid address '%u' on first try, retrying with next higher bit", max_valid_address_bit); - return MAX2(max_valid_address_bit, probe_valid_max_address_bit(init_bit + 1, init_bit + 1)); - } - } - - log_info_p(gc, init)("Found valid address '%u'", max_valid_address_bit); - return max_valid_address_bit; -#else // LINUX - return DEFAULT_MAX_ADDRESS_BIT; -#endif // LINUX -} - -size_t XPlatformAddressOffsetBits() { - const static unsigned int valid_max_address_offset_bits = - probe_valid_max_address_bit(DEFAULT_MAX_ADDRESS_BIT, MINIMUM_MAX_ADDRESS_BIT) + 1; - assert(valid_max_address_offset_bits >= MINIMUM_MAX_ADDRESS_BIT, - "Highest addressable bit is outside the assumed address space range"); - - const size_t max_address_offset_bits = valid_max_address_offset_bits - 3; - const size_t min_address_offset_bits = max_address_offset_bits - 2; - const size_t address_offset = round_up_power_of_2(MaxHeapSize * XVirtualToPhysicalRatio); - const size_t address_offset_bits = log2i_exact(address_offset); - - return clamp(address_offset_bits, min_address_offset_bits, max_address_offset_bits); -} - -size_t XPlatformAddressMetadataShift() { - return XPlatformAddressOffsetBits(); -} diff --git a/src/hotspot/cpu/ppc/gc/x/xGlobals_ppc.hpp b/src/hotspot/cpu/ppc/gc/x/xGlobals_ppc.hpp deleted file mode 100644 index be88b05b02a..00000000000 --- a/src/hotspot/cpu/ppc/gc/x/xGlobals_ppc.hpp +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2021 SAP SE. 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef CPU_PPC_GC_X_XGLOBALS_PPC_HPP -#define CPU_PPC_GC_X_XGLOBALS_PPC_HPP - -#include "globalDefinitions_ppc.hpp" - -const size_t XPlatformHeapViews = 3; -const size_t XPlatformCacheLineSize = DEFAULT_CACHE_LINE_SIZE; - -size_t XPlatformAddressOffsetBits(); -size_t XPlatformAddressMetadataShift(); - -#endif // CPU_PPC_GC_X_XGLOBALS_PPC_HPP diff --git a/src/hotspot/cpu/ppc/gc/x/x_ppc.ad b/src/hotspot/cpu/ppc/gc/x/x_ppc.ad deleted file mode 100644 index b206b6593fb..00000000000 --- a/src/hotspot/cpu/ppc/gc/x/x_ppc.ad +++ /dev/null @@ -1,298 +0,0 @@ -// -// Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. -// Copyright (c) 2021 SAP SE. 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 -// under the terms of the GNU General Public License version 2 only, as -// published by the Free Software Foundation. -// -// This code is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -// version 2 for more details (a copy is included in the LICENSE file that -// accompanied this code). -// -// You should have received a copy of the GNU General Public License version -// 2 along with this work; if not, write to the Free Software Foundation, -// Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -// -// Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -// or visit www.oracle.com if you need additional information or have any -// questions. -// - -source_hpp %{ - -#include "gc/shared/gc_globals.hpp" -#include "gc/x/c2/xBarrierSetC2.hpp" -#include "gc/x/xThreadLocalData.hpp" - -%} - -source %{ - -static void x_load_barrier(MacroAssembler* masm, const MachNode* node, Address ref_addr, Register ref, - Register tmp, uint8_t barrier_data) { - if (barrier_data == XLoadBarrierElided) { - return; - } - - XLoadBarrierStubC2* const stub = XLoadBarrierStubC2::create(node, ref_addr, ref, tmp, barrier_data); - __ ld(tmp, in_bytes(XThreadLocalData::address_bad_mask_offset()), R16_thread); - __ and_(tmp, tmp, ref); - __ bne_far(CCR0, *stub->entry(), MacroAssembler::bc_far_optimize_on_relocate); - __ bind(*stub->continuation()); -} - -static void x_load_barrier_slow_path(MacroAssembler* masm, const MachNode* node, Address ref_addr, Register ref, - Register tmp) { - XLoadBarrierStubC2* const stub = XLoadBarrierStubC2::create(node, ref_addr, ref, tmp, XLoadBarrierStrong); - __ b(*stub->entry()); - __ bind(*stub->continuation()); -} - -static void x_compare_and_swap(MacroAssembler* masm, const MachNode* node, - Register res, Register mem, Register oldval, Register newval, - Register tmp_xchg, Register tmp_mask, - bool weak, bool acquire) { - // z-specific load barrier requires strong CAS operations. - // Weak CAS operations are thus only emitted if the barrier is elided. - __ cmpxchgd(CCR0, tmp_xchg, oldval, newval, mem, - MacroAssembler::MemBarNone, MacroAssembler::cmpxchgx_hint_atomic_update(), res, nullptr, true, - weak && node->barrier_data() == XLoadBarrierElided); - - if (node->barrier_data() != XLoadBarrierElided) { - Label skip_barrier; - - __ ld(tmp_mask, in_bytes(XThreadLocalData::address_bad_mask_offset()), R16_thread); - __ and_(tmp_mask, tmp_mask, tmp_xchg); - __ beq(CCR0, skip_barrier); - - // CAS must have failed because pointer in memory is bad. - x_load_barrier_slow_path(masm, node, Address(mem), tmp_xchg, res /* used as tmp */); - - __ cmpxchgd(CCR0, tmp_xchg, oldval, newval, mem, - MacroAssembler::MemBarNone, MacroAssembler::cmpxchgx_hint_atomic_update(), res, nullptr, true, weak); - - __ bind(skip_barrier); - } - - if (acquire) { - if (support_IRIW_for_not_multiple_copy_atomic_cpu) { - // Uses the isync instruction as an acquire barrier. - // This exploits the compare and the branch in the z load barrier (load, compare and branch, isync). - __ isync(); - } else { - __ sync(); - } - } -} - -static void x_compare_and_exchange(MacroAssembler* masm, const MachNode* node, - Register res, Register mem, Register oldval, Register newval, Register tmp, - bool weak, bool acquire) { - // z-specific load barrier requires strong CAS operations. - // Weak CAS operations are thus only emitted if the barrier is elided. - __ cmpxchgd(CCR0, res, oldval, newval, mem, - MacroAssembler::MemBarNone, MacroAssembler::cmpxchgx_hint_atomic_update(), noreg, nullptr, true, - weak && node->barrier_data() == XLoadBarrierElided); - - if (node->barrier_data() != XLoadBarrierElided) { - Label skip_barrier; - __ ld(tmp, in_bytes(XThreadLocalData::address_bad_mask_offset()), R16_thread); - __ and_(tmp, tmp, res); - __ beq(CCR0, skip_barrier); - - x_load_barrier_slow_path(masm, node, Address(mem), res, tmp); - - __ cmpxchgd(CCR0, res, oldval, newval, mem, - MacroAssembler::MemBarNone, MacroAssembler::cmpxchgx_hint_atomic_update(), noreg, nullptr, true, weak); - - __ bind(skip_barrier); - } - - if (acquire) { - if (support_IRIW_for_not_multiple_copy_atomic_cpu) { - // Uses the isync instruction as an acquire barrier. - // This exploits the compare and the branch in the z load barrier (load, compare and branch, isync). - __ isync(); - } else { - __ sync(); - } - } -} - -%} - -instruct xLoadP(iRegPdst dst, memoryAlg4 mem, iRegPdst tmp, flagsRegCR0 cr0) -%{ - match(Set dst (LoadP mem)); - effect(TEMP_DEF dst, TEMP tmp, KILL cr0); - ins_cost(MEMORY_REF_COST); - - predicate((UseZGC && !ZGenerational && n->as_Load()->barrier_data() != 0) - && (n->as_Load()->is_unordered() || followed_by_acquire(n))); - - format %{ "LD $dst, $mem" %} - ins_encode %{ - assert($mem$$index == 0, "sanity"); - __ ld($dst$$Register, $mem$$disp, $mem$$base$$Register); - x_load_barrier(masm, this, Address($mem$$base$$Register, $mem$$disp), $dst$$Register, $tmp$$Register, barrier_data()); - %} - ins_pipe(pipe_class_default); -%} - -// Load Pointer Volatile -instruct xLoadP_acq(iRegPdst dst, memoryAlg4 mem, iRegPdst tmp, flagsRegCR0 cr0) -%{ - match(Set dst (LoadP mem)); - effect(TEMP_DEF dst, TEMP tmp, KILL cr0); - ins_cost(3 * MEMORY_REF_COST); - - // Predicate on instruction order is implicitly present due to the predicate of the cheaper zLoadP operation - predicate(UseZGC && !ZGenerational && n->as_Load()->barrier_data() != 0); - - format %{ "LD acq $dst, $mem" %} - ins_encode %{ - __ ld($dst$$Register, $mem$$disp, $mem$$base$$Register); - x_load_barrier(masm, this, Address($mem$$base$$Register, $mem$$disp), $dst$$Register, $tmp$$Register, barrier_data()); - - // Uses the isync instruction as an acquire barrier. - // This exploits the compare and the branch in the z load barrier (load, compare and branch, isync). - __ isync(); - %} - ins_pipe(pipe_class_default); -%} - -instruct xCompareAndSwapP(iRegIdst res, iRegPdst mem, iRegPsrc oldval, iRegPsrc newval, - iRegPdst tmp_xchg, iRegPdst tmp_mask, flagsRegCR0 cr0) %{ - match(Set res (CompareAndSwapP mem (Binary oldval newval))); - effect(TEMP_DEF res, TEMP tmp_xchg, TEMP tmp_mask, KILL cr0); - - predicate((UseZGC && !ZGenerational && n->as_LoadStore()->barrier_data() == XLoadBarrierStrong) - && (((CompareAndSwapNode*)n)->order() != MemNode::acquire && ((CompareAndSwapNode*) n)->order() != MemNode::seqcst)); - - format %{ "CMPXCHG $res, $mem, $oldval, $newval; as bool; ptr" %} - ins_encode %{ - x_compare_and_swap(masm, this, - $res$$Register, $mem$$Register, $oldval$$Register, $newval$$Register, - $tmp_xchg$$Register, $tmp_mask$$Register, - false /* weak */, false /* acquire */); - %} - ins_pipe(pipe_class_default); -%} - -instruct xCompareAndSwapP_acq(iRegIdst res, iRegPdst mem, iRegPsrc oldval, iRegPsrc newval, - iRegPdst tmp_xchg, iRegPdst tmp_mask, flagsRegCR0 cr0) %{ - match(Set res (CompareAndSwapP mem (Binary oldval newval))); - effect(TEMP_DEF res, TEMP tmp_xchg, TEMP tmp_mask, KILL cr0); - - predicate((UseZGC && !ZGenerational && n->as_LoadStore()->barrier_data() == XLoadBarrierStrong) - && (((CompareAndSwapNode*)n)->order() == MemNode::acquire || ((CompareAndSwapNode*) n)->order() == MemNode::seqcst)); - - format %{ "CMPXCHG acq $res, $mem, $oldval, $newval; as bool; ptr" %} - ins_encode %{ - x_compare_and_swap(masm, this, - $res$$Register, $mem$$Register, $oldval$$Register, $newval$$Register, - $tmp_xchg$$Register, $tmp_mask$$Register, - false /* weak */, true /* acquire */); - %} - ins_pipe(pipe_class_default); -%} - -instruct xCompareAndSwapPWeak(iRegIdst res, iRegPdst mem, iRegPsrc oldval, iRegPsrc newval, - iRegPdst tmp_xchg, iRegPdst tmp_mask, flagsRegCR0 cr0) %{ - match(Set res (WeakCompareAndSwapP mem (Binary oldval newval))); - effect(TEMP_DEF res, TEMP tmp_xchg, TEMP tmp_mask, KILL cr0); - - predicate((UseZGC && !ZGenerational && n->as_LoadStore()->barrier_data() == XLoadBarrierStrong) - && ((CompareAndSwapNode*)n)->order() != MemNode::acquire && ((CompareAndSwapNode*) n)->order() != MemNode::seqcst); - - format %{ "weak CMPXCHG $res, $mem, $oldval, $newval; as bool; ptr" %} - ins_encode %{ - x_compare_and_swap(masm, this, - $res$$Register, $mem$$Register, $oldval$$Register, $newval$$Register, - $tmp_xchg$$Register, $tmp_mask$$Register, - true /* weak */, false /* acquire */); - %} - ins_pipe(pipe_class_default); -%} - -instruct xCompareAndSwapPWeak_acq(iRegIdst res, iRegPdst mem, iRegPsrc oldval, iRegPsrc newval, - iRegPdst tmp_xchg, iRegPdst tmp_mask, flagsRegCR0 cr0) %{ - match(Set res (WeakCompareAndSwapP mem (Binary oldval newval))); - effect(TEMP_DEF res, TEMP tmp_xchg, TEMP tmp_mask, KILL cr0); - - predicate((UseZGC && !ZGenerational && n->as_LoadStore()->barrier_data() == XLoadBarrierStrong) - && (((CompareAndSwapNode*)n)->order() == MemNode::acquire || ((CompareAndSwapNode*) n)->order() == MemNode::seqcst)); - - format %{ "weak CMPXCHG acq $res, $mem, $oldval, $newval; as bool; ptr" %} - ins_encode %{ - x_compare_and_swap(masm, this, - $res$$Register, $mem$$Register, $oldval$$Register, $newval$$Register, - $tmp_xchg$$Register, $tmp_mask$$Register, - true /* weak */, true /* acquire */); - %} - ins_pipe(pipe_class_default); -%} - -instruct xCompareAndExchangeP(iRegPdst res, iRegPdst mem, iRegPsrc oldval, iRegPsrc newval, - iRegPdst tmp, flagsRegCR0 cr0) %{ - match(Set res (CompareAndExchangeP mem (Binary oldval newval))); - effect(TEMP_DEF res, TEMP tmp, KILL cr0); - - predicate((UseZGC && !ZGenerational && n->as_LoadStore()->barrier_data() == XLoadBarrierStrong) - && ( - ((CompareAndSwapNode*)n)->order() != MemNode::acquire - && ((CompareAndSwapNode*)n)->order() != MemNode::seqcst - )); - - format %{ "CMPXCHG $res, $mem, $oldval, $newval; as ptr; ptr" %} - ins_encode %{ - x_compare_and_exchange(masm, this, - $res$$Register, $mem$$Register, $oldval$$Register, $newval$$Register, $tmp$$Register, - false /* weak */, false /* acquire */); - %} - ins_pipe(pipe_class_default); -%} - -instruct xCompareAndExchangeP_acq(iRegPdst res, iRegPdst mem, iRegPsrc oldval, iRegPsrc newval, - iRegPdst tmp, flagsRegCR0 cr0) %{ - match(Set res (CompareAndExchangeP mem (Binary oldval newval))); - effect(TEMP_DEF res, TEMP tmp, KILL cr0); - - predicate((UseZGC && !ZGenerational && n->as_LoadStore()->barrier_data() == XLoadBarrierStrong) - && ( - ((CompareAndSwapNode*)n)->order() == MemNode::acquire - || ((CompareAndSwapNode*)n)->order() == MemNode::seqcst - )); - - format %{ "CMPXCHG acq $res, $mem, $oldval, $newval; as ptr; ptr" %} - ins_encode %{ - x_compare_and_exchange(masm, this, - $res$$Register, $mem$$Register, $oldval$$Register, $newval$$Register, $tmp$$Register, - false /* weak */, true /* acquire */); - %} - ins_pipe(pipe_class_default); -%} - -instruct xGetAndSetP(iRegPdst res, iRegPdst mem, iRegPsrc newval, iRegPdst tmp, flagsRegCR0 cr0) %{ - match(Set res (GetAndSetP mem newval)); - effect(TEMP_DEF res, TEMP tmp, KILL cr0); - - predicate(UseZGC && !ZGenerational && n->as_LoadStore()->barrier_data() != 0); - - format %{ "GetAndSetP $res, $mem, $newval" %} - ins_encode %{ - __ getandsetd($res$$Register, $newval$$Register, $mem$$Register, MacroAssembler::cmpxchgx_hint_atomic_update()); - x_load_barrier(masm, this, Address(noreg, (intptr_t) 0), $res$$Register, $tmp$$Register, barrier_data()); - - if (support_IRIW_for_not_multiple_copy_atomic_cpu) { - __ isync(); - } else { - __ sync(); - } - %} - ins_pipe(pipe_class_default); -%} diff --git a/src/hotspot/cpu/ppc/gc/z/zBarrierSetAssembler_ppc.cpp b/src/hotspot/cpu/ppc/gc/z/zBarrierSetAssembler_ppc.cpp index 8a65022126e..b9ea67dabe3 100644 --- a/src/hotspot/cpu/ppc/gc/z/zBarrierSetAssembler_ppc.cpp +++ b/src/hotspot/cpu/ppc/gc/z/zBarrierSetAssembler_ppc.cpp @@ -610,14 +610,14 @@ void ZBarrierSetAssembler::try_resolve_jobject_in_native(MacroAssembler* masm, R // Resolve global handle __ ld(dst, 0, dst); - __ ld(tmp, load_bad_mask.disp(), load_bad_mask.base()); + __ ld(tmp, load_bad_mask); __ b(check_color); __ bind(weak_tagged); // Resolve weak handle __ ld(dst, 0, dst); - __ ld(tmp, mark_bad_mask.disp(), mark_bad_mask.base()); + __ ld(tmp, mark_bad_mask); __ bind(check_color); __ and_(tmp, tmp, dst); diff --git a/src/hotspot/cpu/ppc/gc/z/z_ppc.ad b/src/hotspot/cpu/ppc/gc/z/z_ppc.ad index bb696a4738f..97b49bc1b02 100644 --- a/src/hotspot/cpu/ppc/gc/z/z_ppc.ad +++ b/src/hotspot/cpu/ppc/gc/z/z_ppc.ad @@ -143,7 +143,7 @@ instruct zLoadP(iRegPdst dst, memoryAlg4 mem, flagsRegCR0 cr0) effect(TEMP_DEF dst, KILL cr0); ins_cost(MEMORY_REF_COST); - predicate((UseZGC && ZGenerational && n->as_Load()->barrier_data() != 0) + predicate((UseZGC && n->as_Load()->barrier_data() != 0) && (n->as_Load()->is_unordered() || followed_by_acquire(n))); format %{ "LD $dst, $mem" %} @@ -163,7 +163,7 @@ instruct zLoadP_acq(iRegPdst dst, memoryAlg4 mem, flagsRegCR0 cr0) ins_cost(3 * MEMORY_REF_COST); // Predicate on instruction order is implicitly present due to the predicate of the cheaper zLoadP operation - predicate(UseZGC && ZGenerational && n->as_Load()->barrier_data() != 0); + predicate(UseZGC && n->as_Load()->barrier_data() != 0); format %{ "LD acq $dst, $mem" %} ins_encode %{ @@ -181,7 +181,7 @@ instruct zLoadP_acq(iRegPdst dst, memoryAlg4 mem, flagsRegCR0 cr0) // Store Pointer instruct zStoreP(memoryAlg4 mem, iRegPsrc src, iRegPdst tmp, flagsRegCR0 cr0) %{ - predicate(UseZGC && ZGenerational && n->as_Store()->barrier_data() != 0); + predicate(UseZGC && n->as_Store()->barrier_data() != 0); match(Set mem (StoreP mem src)); effect(TEMP tmp, KILL cr0); ins_cost(2 * MEMORY_REF_COST); @@ -195,7 +195,7 @@ instruct zStoreP(memoryAlg4 mem, iRegPsrc src, iRegPdst tmp, flagsRegCR0 cr0) instruct zStorePNull(memoryAlg4 mem, immP_0 zero, iRegPdst tmp, flagsRegCR0 cr0) %{ - predicate(UseZGC && ZGenerational && n->as_Store()->barrier_data() != 0); + predicate(UseZGC && n->as_Store()->barrier_data() != 0); match(Set mem (StoreP mem zero)); effect(TEMP tmp, KILL cr0); ins_cost(MEMORY_REF_COST); @@ -213,7 +213,7 @@ instruct zCompareAndSwapP(iRegIdst res, iRegPdst mem, iRegPsrc oldval, iRegPsrc match(Set res (WeakCompareAndSwapP mem (Binary oldval newval))); effect(TEMP_DEF res, TEMP tmp1, TEMP tmp2, KILL cr0); - predicate((UseZGC && ZGenerational && n->as_LoadStore()->barrier_data() != 0) + predicate((UseZGC && n->as_LoadStore()->barrier_data() != 0) && (((CompareAndSwapNode*)n)->order() != MemNode::acquire && ((CompareAndSwapNode*) n)->order() != MemNode::seqcst)); format %{ "CMPXCHG $res, $mem, $oldval, $newval; as bool; ptr" %} @@ -232,7 +232,7 @@ instruct zCompareAndSwapP_acq(iRegIdst res, iRegPdst mem, iRegPsrc oldval, iRegP match(Set res (WeakCompareAndSwapP mem (Binary oldval newval))); effect(TEMP_DEF res, TEMP tmp1, TEMP tmp2, KILL cr0); - predicate((UseZGC && ZGenerational && n->as_LoadStore()->barrier_data() != 0) + predicate((UseZGC && n->as_LoadStore()->barrier_data() != 0) && (((CompareAndSwapNode*)n)->order() == MemNode::acquire || ((CompareAndSwapNode*) n)->order() == MemNode::seqcst)); format %{ "CMPXCHG acq $res, $mem, $oldval, $newval; as bool; ptr" %} @@ -250,7 +250,7 @@ instruct zCompareAndExchangeP(iRegPdst res, iRegPdst mem, iRegPsrc oldval, iRegP match(Set res (CompareAndExchangeP mem (Binary oldval newval))); effect(TEMP_DEF res, TEMP tmp, KILL cr0); - predicate((UseZGC && ZGenerational && n->as_LoadStore()->barrier_data() != 0) + predicate((UseZGC && n->as_LoadStore()->barrier_data() != 0) && ( ((CompareAndSwapNode*)n)->order() != MemNode::acquire && ((CompareAndSwapNode*)n)->order() != MemNode::seqcst @@ -270,7 +270,7 @@ instruct zCompareAndExchangeP_acq(iRegPdst res, iRegPdst mem, iRegPsrc oldval, i match(Set res (CompareAndExchangeP mem (Binary oldval newval))); effect(TEMP_DEF res, TEMP tmp, KILL cr0); - predicate((UseZGC && ZGenerational && n->as_LoadStore()->barrier_data() != 0) + predicate((UseZGC && n->as_LoadStore()->barrier_data() != 0) && ( ((CompareAndSwapNode*)n)->order() == MemNode::acquire || ((CompareAndSwapNode*)n)->order() == MemNode::seqcst @@ -289,7 +289,7 @@ instruct zGetAndSetP(iRegPdst res, iRegPdst mem, iRegPsrc newval, iRegPdst tmp, match(Set res (GetAndSetP mem newval)); effect(TEMP_DEF res, TEMP tmp, KILL cr0); - predicate(UseZGC && ZGenerational && n->as_LoadStore()->barrier_data() != 0); + predicate(UseZGC && n->as_LoadStore()->barrier_data() != 0); format %{ "GetAndSetP $res, $mem, $newval" %} ins_encode %{ diff --git a/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp b/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp index f036caa0675..c7adbfb52f0 100644 --- a/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp +++ b/src/hotspot/cpu/ppc/macroAssembler_ppc.cpp @@ -2736,7 +2736,7 @@ void MacroAssembler::compiler_fast_unlock_object(ConditionRegister flag, Registe // StoreLoad achieves this. membar(StoreLoad); - // Check if the entry lists are empty. + // Check if the entry lists are empty (EntryList first - by convention). ld(temp, in_bytes(ObjectMonitor::EntryList_offset()), current_header); ld(displaced_header, in_bytes(ObjectMonitor::cxq_offset()), current_header); orr(temp, temp, displaced_header); // Will be 0 if both are 0. @@ -3083,7 +3083,7 @@ void MacroAssembler::compiler_fast_unlock_lightweight_object(ConditionRegister f // StoreLoad achieves this. membar(StoreLoad); - // Check if the entry lists are empty. + // Check if the entry lists are empty (EntryList first - by convention). ld(t, in_bytes(ObjectMonitor::EntryList_offset()), monitor); ld(t2, in_bytes(ObjectMonitor::cxq_offset()), monitor); orr(t, t, t2); @@ -4619,23 +4619,6 @@ void MacroAssembler::zap_from_to(Register low, int before, Register high, int af #endif // !PRODUCT -void SkipIfEqualZero::skip_to_label_if_equal_zero(MacroAssembler* masm, Register temp, - const bool* flag_addr, Label& label) { - int simm16_offset = masm->load_const_optimized(temp, (address)flag_addr, R0, true); - assert(sizeof(bool) == 1, "PowerPC ABI"); - masm->lbz(temp, simm16_offset, temp); - masm->cmpwi(CCR0, temp, 0); - masm->beq(CCR0, label); -} - -SkipIfEqualZero::SkipIfEqualZero(MacroAssembler* masm, Register temp, const bool* flag_addr) : _masm(masm), _label() { - skip_to_label_if_equal_zero(masm, temp, flag_addr, _label); -} - -SkipIfEqualZero::~SkipIfEqualZero() { - _masm->bind(_label); -} - void MacroAssembler::cache_wb(Address line) { assert(line.index() == noreg, "index should be noreg"); assert(line.disp() == 0, "displacement should be 0"); diff --git a/src/hotspot/cpu/ppc/macroAssembler_ppc.hpp b/src/hotspot/cpu/ppc/macroAssembler_ppc.hpp index 224e7bff995..f0e7c644535 100644 --- a/src/hotspot/cpu/ppc/macroAssembler_ppc.hpp +++ b/src/hotspot/cpu/ppc/macroAssembler_ppc.hpp @@ -960,23 +960,4 @@ class MacroAssembler: public Assembler { void zap_from_to(Register low, int before, Register high, int after, Register val, Register addr) PRODUCT_RETURN; }; -// class SkipIfEqualZero: -// -// Instantiating this class will result in assembly code being output that will -// jump around any code emitted between the creation of the instance and it's -// automatic destruction at the end of a scope block, depending on the value of -// the flag passed to the constructor, which will be checked at run-time. -class SkipIfEqualZero : public StackObj { - private: - MacroAssembler* _masm; - Label _label; - - public: - // 'Temp' is a temp register that this object can use (and trash). - explicit SkipIfEqualZero(MacroAssembler*, Register temp, const bool* flag_addr); - static void skip_to_label_if_equal_zero(MacroAssembler*, Register temp, - const bool* flag_addr, Label& label); - ~SkipIfEqualZero(); -}; - #endif // CPU_PPC_MACROASSEMBLER_PPC_HPP diff --git a/src/hotspot/cpu/ppc/stubGenerator_ppc.cpp b/src/hotspot/cpu/ppc/stubGenerator_ppc.cpp index 206c161287f..b3ace8898ad 100644 --- a/src/hotspot/cpu/ppc/stubGenerator_ppc.cpp +++ b/src/hotspot/cpu/ppc/stubGenerator_ppc.cpp @@ -49,7 +49,6 @@ #include "utilities/align.hpp" #include "utilities/powerOfTwo.hpp" #if INCLUDE_ZGC -#include "gc/x/xBarrierSetAssembler.hpp" #include "gc/z/zBarrierSetAssembler.hpp" #endif @@ -1976,7 +1975,7 @@ class StubGenerator: public StubCodeGenerator { generate_conjoint_int_copy_core(aligned); } else { #if INCLUDE_ZGC - if (UseZGC && ZGenerational) { + if (UseZGC) { ZBarrierSetAssembler *zbs = (ZBarrierSetAssembler*)bs; zbs->generate_conjoint_oop_copy(_masm, dest_uninitialized); } else @@ -2019,7 +2018,7 @@ class StubGenerator: public StubCodeGenerator { generate_disjoint_int_copy_core(aligned); } else { #if INCLUDE_ZGC - if (UseZGC && ZGenerational) { + if (UseZGC) { ZBarrierSetAssembler *zbs = (ZBarrierSetAssembler*)bs; zbs->generate_disjoint_oop_copy(_masm, dest_uninitialized); } else @@ -2137,7 +2136,7 @@ class StubGenerator: public StubCodeGenerator { } else { __ bind(store_null); #if INCLUDE_ZGC - if (UseZGC && ZGenerational) { + if (UseZGC) { __ store_heap_oop(R10_oop, R8_offset, R4_to, R11_scratch1, R12_tmp, noreg, MacroAssembler::PRESERVATION_FRAME_LR_GP_REGS, dest_uninitialized ? IS_DEST_UNINITIALIZED : 0); @@ -2153,7 +2152,7 @@ class StubGenerator: public StubCodeGenerator { // ======== loop entry is here ======== __ bind(load_element); #if INCLUDE_ZGC - if (UseZGC && ZGenerational) { + if (UseZGC) { __ load_heap_oop(R10_oop, R8_offset, R3_from, R11_scratch1, R12_tmp, MacroAssembler::PRESERVATION_FRAME_LR_GP_REGS, diff --git a/src/hotspot/cpu/riscv/assembler_riscv.hpp b/src/hotspot/cpu/riscv/assembler_riscv.hpp index 23046419460..7334ec675e3 100644 --- a/src/hotspot/cpu/riscv/assembler_riscv.hpp +++ b/src/hotspot/cpu/riscv/assembler_riscv.hpp @@ -1962,6 +1962,13 @@ enum Nf { INSN(vbrev8_v, 0b1010111, 0b010, 0b01000, 0b010010); // reverse bits in every byte of element INSN(vrev8_v, 0b1010111, 0b010, 0b01001, 0b010010); // reverse bytes in every elememt + // Vector AES instructions (Zvkned extension) + INSN(vaesem_vv, 0b1110111, 0b010, 0b00010, 0b101000); + INSN(vaesef_vv, 0b1110111, 0b010, 0b00011, 0b101000); + + INSN(vaesdm_vv, 0b1110111, 0b010, 0b00000, 0b101000); + INSN(vaesdf_vv, 0b1110111, 0b010, 0b00001, 0b101000); + INSN(vclz_v, 0b1010111, 0b010, 0b01100, 0b010010); // count leading zeros INSN(vctz_v, 0b1010111, 0b010, 0b01101, 0b010010); // count trailing zeros diff --git a/src/hotspot/cpu/riscv/c1_CodeStubs_riscv.cpp b/src/hotspot/cpu/riscv/c1_CodeStubs_riscv.cpp index c5764bcebf7..0be1252f57f 100644 --- a/src/hotspot/cpu/riscv/c1_CodeStubs_riscv.cpp +++ b/src/hotspot/cpu/riscv/c1_CodeStubs_riscv.cpp @@ -43,9 +43,7 @@ void C1SafepointPollStub::emit_code(LIR_Assembler* ce) { __ bind(_entry); InternalAddress safepoint_pc(__ pc() - __ offset() + safepoint_offset()); __ relocate(safepoint_pc.rspec(), [&] { - int32_t offset; - __ la(t0, safepoint_pc.target(), offset); - __ addi(t0, t0, offset); + __ la(t0, safepoint_pc.target()); }); __ sd(t0, Address(xthread, JavaThread::saved_exception_pc_offset())); diff --git a/src/hotspot/cpu/riscv/c1_LIRAssembler_riscv.cpp b/src/hotspot/cpu/riscv/c1_LIRAssembler_riscv.cpp index 828f70e4dec..21bf089118b 100644 --- a/src/hotspot/cpu/riscv/c1_LIRAssembler_riscv.cpp +++ b/src/hotspot/cpu/riscv/c1_LIRAssembler_riscv.cpp @@ -838,10 +838,7 @@ void LIR_Assembler::mem2reg(LIR_Opr src, LIR_Opr dest, BasicType type, LIR_Patch __ decode_heap_oop(dest->as_register()); } - if (!(UseZGC && !ZGenerational)) { - // Load barrier has not yet been applied, so ZGC can't verify the oop here - __ verify_oop(dest->as_register()); - } + __ verify_oop(dest->as_register()); } } @@ -1406,9 +1403,7 @@ void LIR_Assembler::throw_op(LIR_Opr exceptionPC, LIR_Opr exceptionOop, CodeEmit int pc_for_athrow_offset = __ offset(); InternalAddress pc_for_athrow(__ pc()); __ relocate(pc_for_athrow.rspec(), [&] { - int32_t offset; - __ la(exceptionPC->as_register(), pc_for_athrow.target(), offset); - __ addi(exceptionPC->as_register(), exceptionPC->as_register(), offset); + __ la(exceptionPC->as_register(), pc_for_athrow.target()); }); add_call_info(pc_for_athrow_offset, info); // for exception handler diff --git a/src/hotspot/cpu/riscv/c2_CodeStubs_riscv.cpp b/src/hotspot/cpu/riscv/c2_CodeStubs_riscv.cpp index db18525b89c..781f95ab73e 100644 --- a/src/hotspot/cpu/riscv/c2_CodeStubs_riscv.cpp +++ b/src/hotspot/cpu/riscv/c2_CodeStubs_riscv.cpp @@ -45,9 +45,7 @@ void C2SafepointPollStub::emit(C2_MacroAssembler& masm) { __ bind(entry()); InternalAddress safepoint_pc(__ pc() - __ offset() + _safepoint_offset); __ relocate(safepoint_pc.rspec(), [&] { - int32_t offset; - __ la(t0, safepoint_pc.target(), offset); - __ addi(t0, t0, offset); + __ la(t0, safepoint_pc.target()); }); __ sd(t0, Address(xthread, JavaThread::saved_exception_pc_offset())); __ far_jump(callback_addr); diff --git a/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp b/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp index 75f87e35adf..0ffdcbca723 100644 --- a/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp +++ b/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp @@ -234,7 +234,7 @@ void C2_MacroAssembler::fast_unlock(Register objectReg, Register boxReg, // StoreLoad achieves this. membar(StoreLoad); - // Check if the entry lists are empty. + // Check if the entry lists are empty (EntryList first - by convention). ld(t0, Address(tmp, ObjectMonitor::EntryList_offset())); ld(tmp1Reg, Address(tmp, ObjectMonitor::cxq_offset())); orr(t0, t0, tmp1Reg); @@ -566,7 +566,7 @@ void C2_MacroAssembler::fast_unlock_lightweight(Register obj, Register box, // StoreLoad achieves this. membar(StoreLoad); - // Check if the entry lists are empty. + // Check if the entry lists are empty (EntryList first - by convention). ld(t0, Address(tmp1_monitor, ObjectMonitor::EntryList_offset())); ld(tmp3_t, Address(tmp1_monitor, ObjectMonitor::cxq_offset())); orr(t0, t0, tmp3_t); diff --git a/src/hotspot/cpu/riscv/gc/x/xBarrierSetAssembler_riscv.cpp b/src/hotspot/cpu/riscv/gc/x/xBarrierSetAssembler_riscv.cpp deleted file mode 100644 index eb8d4c44b88..00000000000 --- a/src/hotspot/cpu/riscv/gc/x/xBarrierSetAssembler_riscv.cpp +++ /dev/null @@ -1,454 +0,0 @@ -/* - * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2020, 2023, Huawei Technologies Co., Ltd. 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#include "precompiled.hpp" -#include "asm/macroAssembler.inline.hpp" -#include "code/codeBlob.hpp" -#include "code/vmreg.inline.hpp" -#include "gc/x/xBarrier.inline.hpp" -#include "gc/x/xBarrierSet.hpp" -#include "gc/x/xBarrierSetAssembler.hpp" -#include "gc/x/xBarrierSetRuntime.hpp" -#include "gc/x/xThreadLocalData.hpp" -#include "memory/resourceArea.hpp" -#include "runtime/sharedRuntime.hpp" -#include "utilities/macros.hpp" -#ifdef COMPILER1 -#include "c1/c1_LIRAssembler.hpp" -#include "c1/c1_MacroAssembler.hpp" -#include "gc/x/c1/xBarrierSetC1.hpp" -#endif // COMPILER1 -#ifdef COMPILER2 -#include "gc/x/c2/xBarrierSetC2.hpp" -#endif // COMPILER2 - -#ifdef PRODUCT -#define BLOCK_COMMENT(str) /* nothing */ -#else -#define BLOCK_COMMENT(str) __ block_comment(str) -#endif - -#undef __ -#define __ masm-> - -void XBarrierSetAssembler::load_at(MacroAssembler* masm, - DecoratorSet decorators, - BasicType type, - Register dst, - Address src, - Register tmp1, - Register tmp2) { - if (!XBarrierSet::barrier_needed(decorators, type)) { - // Barrier not needed - BarrierSetAssembler::load_at(masm, decorators, type, dst, src, tmp1, tmp2); - return; - } - - assert_different_registers(t1, src.base()); - assert_different_registers(t0, t1, dst); - - Label done; - - // Load bad mask into temp register. - __ la(t0, src); - __ ld(t1, address_bad_mask_from_thread(xthread)); - __ ld(dst, Address(t0)); - - // Test reference against bad mask. If mask bad, then we need to fix it up. - __ andr(t1, dst, t1); - __ beqz(t1, done); - - __ enter(); - - __ push_call_clobbered_registers_except(RegSet::of(dst)); - - if (c_rarg0 != dst) { - __ mv(c_rarg0, dst); - } - - __ mv(c_rarg1, t0); - - __ call_VM_leaf(XBarrierSetRuntime::load_barrier_on_oop_field_preloaded_addr(decorators), 2); - - // Make sure dst has the return value. - if (dst != x10) { - __ mv(dst, x10); - } - - __ pop_call_clobbered_registers_except(RegSet::of(dst)); - __ leave(); - - __ bind(done); -} - -#ifdef ASSERT - -void XBarrierSetAssembler::store_at(MacroAssembler* masm, - DecoratorSet decorators, - BasicType type, - Address dst, - Register val, - Register tmp1, - Register tmp2, - Register tmp3) { - // Verify value - if (is_reference_type(type)) { - // Note that src could be noreg, which means we - // are storing null and can skip verification. - if (val != noreg) { - Label done; - - // tmp1, tmp2 and tmp3 are often set to noreg. - RegSet savedRegs = RegSet::of(t0); - __ push_reg(savedRegs, sp); - - __ ld(t0, address_bad_mask_from_thread(xthread)); - __ andr(t0, val, t0); - __ beqz(t0, done); - __ stop("Verify oop store failed"); - __ should_not_reach_here(); - __ bind(done); - __ pop_reg(savedRegs, sp); - } - } - - // Store value - BarrierSetAssembler::store_at(masm, decorators, type, dst, val, tmp1, tmp2, noreg); -} - -#endif // ASSERT - -void XBarrierSetAssembler::arraycopy_prologue(MacroAssembler* masm, - DecoratorSet decorators, - bool is_oop, - Register src, - Register dst, - Register count, - RegSet saved_regs) { - if (!is_oop) { - // Barrier not needed - return; - } - - BLOCK_COMMENT("XBarrierSetAssembler::arraycopy_prologue {"); - - assert_different_registers(src, count, t0); - - __ push_reg(saved_regs, sp); - - if (count == c_rarg0 && src == c_rarg1) { - // exactly backwards!! - __ xorr(c_rarg0, c_rarg0, c_rarg1); - __ xorr(c_rarg1, c_rarg0, c_rarg1); - __ xorr(c_rarg0, c_rarg0, c_rarg1); - } else { - __ mv(c_rarg0, src); - __ mv(c_rarg1, count); - } - - __ call_VM_leaf(XBarrierSetRuntime::load_barrier_on_oop_array_addr(), 2); - - __ pop_reg(saved_regs, sp); - - BLOCK_COMMENT("} XBarrierSetAssembler::arraycopy_prologue"); -} - -void XBarrierSetAssembler::try_resolve_jobject_in_native(MacroAssembler* masm, - Register jni_env, - Register robj, - Register tmp, - Label& slowpath) { - BLOCK_COMMENT("XBarrierSetAssembler::try_resolve_jobject_in_native {"); - - assert_different_registers(jni_env, robj, tmp); - - // Resolve jobject - BarrierSetAssembler::try_resolve_jobject_in_native(masm, jni_env, robj, tmp, slowpath); - - // Compute the offset of address bad mask from the field of jni_environment - long int bad_mask_relative_offset = (long int) (in_bytes(XThreadLocalData::address_bad_mask_offset()) - - in_bytes(JavaThread::jni_environment_offset())); - - // Load the address bad mask - __ ld(tmp, Address(jni_env, bad_mask_relative_offset)); - - // Check address bad mask - __ andr(tmp, robj, tmp); - __ bnez(tmp, slowpath); - - BLOCK_COMMENT("} XBarrierSetAssembler::try_resolve_jobject_in_native"); -} - -#ifdef COMPILER2 - -OptoReg::Name XBarrierSetAssembler::refine_register(const Node* node, OptoReg::Name opto_reg) { - if (!OptoReg::is_reg(opto_reg)) { - return OptoReg::Bad; - } - - const VMReg vm_reg = OptoReg::as_VMReg(opto_reg); - if (vm_reg->is_FloatRegister()) { - return opto_reg & ~1; - } - - return opto_reg; -} - -#undef __ -#define __ _masm-> - -class XSaveLiveRegisters { -private: - MacroAssembler* const _masm; - RegSet _gp_regs; - FloatRegSet _fp_regs; - VectorRegSet _vp_regs; - -public: - void initialize(XLoadBarrierStubC2* stub) { - // Record registers that needs to be saved/restored - RegMaskIterator rmi(stub->live()); - while (rmi.has_next()) { - const OptoReg::Name opto_reg = rmi.next(); - if (OptoReg::is_reg(opto_reg)) { - const VMReg vm_reg = OptoReg::as_VMReg(opto_reg); - if (vm_reg->is_Register()) { - _gp_regs += RegSet::of(vm_reg->as_Register()); - } else if (vm_reg->is_FloatRegister()) { - _fp_regs += FloatRegSet::of(vm_reg->as_FloatRegister()); - } else if (vm_reg->is_VectorRegister()) { - const VMReg vm_reg_base = OptoReg::as_VMReg(opto_reg & ~(VectorRegister::max_slots_per_register - 1)); - _vp_regs += VectorRegSet::of(vm_reg_base->as_VectorRegister()); - } else { - fatal("Unknown register type"); - } - } - } - - // Remove C-ABI SOE registers, tmp regs and _ref register that will be updated - _gp_regs -= RegSet::range(x18, x27) + RegSet::of(x2) + RegSet::of(x8, x9) + RegSet::of(x5, stub->ref()); - } - - XSaveLiveRegisters(MacroAssembler* masm, XLoadBarrierStubC2* stub) : - _masm(masm), - _gp_regs(), - _fp_regs(), - _vp_regs() { - // Figure out what registers to save/restore - initialize(stub); - - // Save registers - __ push_reg(_gp_regs, sp); - __ push_fp(_fp_regs, sp); - __ push_v(_vp_regs, sp); - } - - ~XSaveLiveRegisters() { - // Restore registers - __ pop_v(_vp_regs, sp); - __ pop_fp(_fp_regs, sp); - __ pop_reg(_gp_regs, sp); - } -}; - -class XSetupArguments { -private: - MacroAssembler* const _masm; - const Register _ref; - const Address _ref_addr; - -public: - XSetupArguments(MacroAssembler* masm, XLoadBarrierStubC2* stub) : - _masm(masm), - _ref(stub->ref()), - _ref_addr(stub->ref_addr()) { - - // Setup arguments - if (_ref_addr.base() == noreg) { - // No self healing - if (_ref != c_rarg0) { - __ mv(c_rarg0, _ref); - } - __ mv(c_rarg1, zr); - } else { - // Self healing - if (_ref == c_rarg0) { - // _ref is already at correct place - __ la(c_rarg1, _ref_addr); - } else if (_ref != c_rarg1) { - // _ref is in wrong place, but not in c_rarg1, so fix it first - __ la(c_rarg1, _ref_addr); - __ mv(c_rarg0, _ref); - } else if (_ref_addr.base() != c_rarg0) { - assert(_ref == c_rarg1, "Mov ref first, vacating c_rarg0"); - __ mv(c_rarg0, _ref); - __ la(c_rarg1, _ref_addr); - } else { - assert(_ref == c_rarg1, "Need to vacate c_rarg1 and _ref_addr is using c_rarg0"); - if (_ref_addr.base() == c_rarg0) { - __ mv(t1, c_rarg1); - __ la(c_rarg1, _ref_addr); - __ mv(c_rarg0, t1); - } else { - ShouldNotReachHere(); - } - } - } - } - - ~XSetupArguments() { - // Transfer result - if (_ref != x10) { - __ mv(_ref, x10); - } - } -}; - -#undef __ -#define __ masm-> - -void XBarrierSetAssembler::generate_c2_load_barrier_stub(MacroAssembler* masm, XLoadBarrierStubC2* stub) const { - BLOCK_COMMENT("XLoadBarrierStubC2"); - - // Stub entry - __ bind(*stub->entry()); - - { - XSaveLiveRegisters save_live_registers(masm, stub); - XSetupArguments setup_arguments(masm, stub); - - __ mv(t1, stub->slow_path()); - __ jalr(t1); - } - - // Stub exit - __ j(*stub->continuation()); -} - -#endif // COMPILER2 - -#ifdef COMPILER1 -#undef __ -#define __ ce->masm()-> - -void XBarrierSetAssembler::generate_c1_load_barrier_test(LIR_Assembler* ce, - LIR_Opr ref) const { - assert_different_registers(xthread, ref->as_register(), t1); - __ ld(t1, address_bad_mask_from_thread(xthread)); - __ andr(t1, t1, ref->as_register()); -} - -void XBarrierSetAssembler::generate_c1_load_barrier_stub(LIR_Assembler* ce, - XLoadBarrierStubC1* stub) const { - // Stub entry - __ bind(*stub->entry()); - - Register ref = stub->ref()->as_register(); - Register ref_addr = noreg; - Register tmp = noreg; - - if (stub->tmp()->is_valid()) { - // Load address into tmp register - ce->leal(stub->ref_addr(), stub->tmp()); - ref_addr = tmp = stub->tmp()->as_pointer_register(); - } else { - // Address already in register - ref_addr = stub->ref_addr()->as_address_ptr()->base()->as_pointer_register(); - } - - assert_different_registers(ref, ref_addr, noreg); - - // Save x10 unless it is the result or tmp register - // Set up SP to accommodate parameters and maybe x10. - if (ref != x10 && tmp != x10) { - __ sub(sp, sp, 32); - __ sd(x10, Address(sp, 16)); - } else { - __ sub(sp, sp, 16); - } - - // Setup arguments and call runtime stub - ce->store_parameter(ref_addr, 1); - ce->store_parameter(ref, 0); - - __ far_call(stub->runtime_stub()); - - // Verify result - __ verify_oop(x10); - - - // Move result into place - if (ref != x10) { - __ mv(ref, x10); - } - - // Restore x10 unless it is the result or tmp register - if (ref != x10 && tmp != x10) { - __ ld(x10, Address(sp, 16)); - __ add(sp, sp, 32); - } else { - __ add(sp, sp, 16); - } - - // Stub exit - __ j(*stub->continuation()); -} - -#undef __ -#define __ sasm-> - -void XBarrierSetAssembler::generate_c1_load_barrier_runtime_stub(StubAssembler* sasm, - DecoratorSet decorators) const { - __ prologue("zgc_load_barrier stub", false); - - __ push_call_clobbered_registers_except(RegSet::of(x10)); - - // Setup arguments - __ load_parameter(0, c_rarg0); - __ load_parameter(1, c_rarg1); - - __ call_VM_leaf(XBarrierSetRuntime::load_barrier_on_oop_field_preloaded_addr(decorators), 2); - - __ pop_call_clobbered_registers_except(RegSet::of(x10)); - - __ epilogue(); -} - -#endif // COMPILER1 - -#undef __ -#define __ masm-> - -void XBarrierSetAssembler::check_oop(MacroAssembler* masm, Register obj, Register tmp1, Register tmp2, Label& error) { - // Check if mask is good. - // verifies that XAddressBadMask & obj == 0 - __ ld(tmp2, Address(xthread, XThreadLocalData::address_bad_mask_offset())); - __ andr(tmp1, obj, tmp2); - __ bnez(tmp1, error); - - BarrierSetAssembler::check_oop(masm, obj, tmp1, tmp2, error); -} - -#undef __ diff --git a/src/hotspot/cpu/riscv/gc/x/xBarrierSetAssembler_riscv.hpp b/src/hotspot/cpu/riscv/gc/x/xBarrierSetAssembler_riscv.hpp deleted file mode 100644 index cbf5077999b..00000000000 --- a/src/hotspot/cpu/riscv/gc/x/xBarrierSetAssembler_riscv.hpp +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2020, 2021, Huawei Technologies Co., Ltd. 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#ifndef CPU_RISCV_GC_X_XBARRIERSETASSEMBLER_RISCV_HPP -#define CPU_RISCV_GC_X_XBARRIERSETASSEMBLER_RISCV_HPP - -#include "code/vmreg.hpp" -#include "oops/accessDecorators.hpp" -#ifdef COMPILER2 -#include "opto/optoreg.hpp" -#endif // COMPILER2 - -#ifdef COMPILER1 -class LIR_Assembler; -class LIR_Opr; -class StubAssembler; -#endif // COMPILER1 - -#ifdef COMPILER2 -class Node; -#endif // COMPILER2 - -#ifdef COMPILER1 -class XLoadBarrierStubC1; -#endif // COMPILER1 - -#ifdef COMPILER2 -class XLoadBarrierStubC2; -#endif // COMPILER2 - -class XBarrierSetAssembler : public XBarrierSetAssemblerBase { -public: - virtual void load_at(MacroAssembler* masm, - DecoratorSet decorators, - BasicType type, - Register dst, - Address src, - Register tmp1, - Register tmp2); - -#ifdef ASSERT - virtual void store_at(MacroAssembler* masm, - DecoratorSet decorators, - BasicType type, - Address dst, - Register val, - Register tmp1, - Register tmp2, - Register tmp3); -#endif // ASSERT - - virtual void arraycopy_prologue(MacroAssembler* masm, - DecoratorSet decorators, - bool is_oop, - Register src, - Register dst, - Register count, - RegSet saved_regs); - - virtual void try_resolve_jobject_in_native(MacroAssembler* masm, - Register jni_env, - Register robj, - Register tmp, - Label& slowpath); - - virtual NMethodPatchingType nmethod_patching_type() { return NMethodPatchingType::conc_data_patch; } - -#ifdef COMPILER1 - void generate_c1_load_barrier_test(LIR_Assembler* ce, - LIR_Opr ref) const; - - void generate_c1_load_barrier_stub(LIR_Assembler* ce, - XLoadBarrierStubC1* stub) const; - - void generate_c1_load_barrier_runtime_stub(StubAssembler* sasm, - DecoratorSet decorators) const; -#endif // COMPILER1 - -#ifdef COMPILER2 - OptoReg::Name refine_register(const Node* node, - OptoReg::Name opto_reg); - - void generate_c2_load_barrier_stub(MacroAssembler* masm, - XLoadBarrierStubC2* stub) const; -#endif // COMPILER2 - - void check_oop(MacroAssembler* masm, Register obj, Register tmp1, Register tmp2, Label& error); -}; - -#endif // CPU_RISCV_GC_X_XBARRIERSETASSEMBLER_RISCV_HPP diff --git a/src/hotspot/cpu/riscv/gc/x/xGlobals_riscv.cpp b/src/hotspot/cpu/riscv/gc/x/xGlobals_riscv.cpp deleted file mode 100644 index 602dab56747..00000000000 --- a/src/hotspot/cpu/riscv/gc/x/xGlobals_riscv.cpp +++ /dev/null @@ -1,212 +0,0 @@ -/* - * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2020, 2021, Huawei Technologies Co., Ltd. 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#include "precompiled.hpp" -#include "gc/shared/gcLogPrecious.hpp" -#include "gc/shared/gc_globals.hpp" -#include "gc/x/xGlobals.hpp" -#include "runtime/globals.hpp" -#include "runtime/os.hpp" -#include "utilities/globalDefinitions.hpp" -#include "utilities/powerOfTwo.hpp" - -#ifdef LINUX -#include -#endif // LINUX - -// -// The heap can have three different layouts, depending on the max heap size. -// -// Address Space & Pointer Layout 1 -// -------------------------------- -// -// +--------------------------------+ 0x00007FFFFFFFFFFF (127TB) -// . . -// . . -// . . -// +--------------------------------+ 0x0000014000000000 (20TB) -// | Remapped View | -// +--------------------------------+ 0x0000010000000000 (16TB) -// . . -// +--------------------------------+ 0x00000c0000000000 (12TB) -// | Marked1 View | -// +--------------------------------+ 0x0000080000000000 (8TB) -// | Marked0 View | -// +--------------------------------+ 0x0000040000000000 (4TB) -// . . -// +--------------------------------+ 0x0000000000000000 -// -// 6 4 4 4 4 -// 3 6 5 2 1 0 -// +--------------------+----+-----------------------------------------------+ -// |00000000 00000000 00|1111|11 11111111 11111111 11111111 11111111 11111111| -// +--------------------+----+-----------------------------------------------+ -// | | | -// | | * 41-0 Object Offset (42-bits, 4TB address space) -// | | -// | * 45-42 Metadata Bits (4-bits) 0001 = Marked0 (Address view 4-8TB) -// | 0010 = Marked1 (Address view 8-12TB) -// | 0100 = Remapped (Address view 16-20TB) -// | 1000 = Finalizable (Address view N/A) -// | -// * 63-46 Fixed (18-bits, always zero) -// -// -// Address Space & Pointer Layout 2 -// -------------------------------- -// -// +--------------------------------+ 0x00007FFFFFFFFFFF (127TB) -// . . -// . . -// . . -// +--------------------------------+ 0x0000280000000000 (40TB) -// | Remapped View | -// +--------------------------------+ 0x0000200000000000 (32TB) -// . . -// +--------------------------------+ 0x0000180000000000 (24TB) -// | Marked1 View | -// +--------------------------------+ 0x0000100000000000 (16TB) -// | Marked0 View | -// +--------------------------------+ 0x0000080000000000 (8TB) -// . . -// +--------------------------------+ 0x0000000000000000 -// -// 6 4 4 4 4 -// 3 7 6 3 2 0 -// +------------------+-----+------------------------------------------------+ -// |00000000 00000000 0|1111|111 11111111 11111111 11111111 11111111 11111111| -// +-------------------+----+------------------------------------------------+ -// | | | -// | | * 42-0 Object Offset (43-bits, 8TB address space) -// | | -// | * 46-43 Metadata Bits (4-bits) 0001 = Marked0 (Address view 8-16TB) -// | 0010 = Marked1 (Address view 16-24TB) -// | 0100 = Remapped (Address view 32-40TB) -// | 1000 = Finalizable (Address view N/A) -// | -// * 63-47 Fixed (17-bits, always zero) -// -// -// Address Space & Pointer Layout 3 -// -------------------------------- -// -// +--------------------------------+ 0x00007FFFFFFFFFFF (127TB) -// . . -// . . -// . . -// +--------------------------------+ 0x0000500000000000 (80TB) -// | Remapped View | -// +--------------------------------+ 0x0000400000000000 (64TB) -// . . -// +--------------------------------+ 0x0000300000000000 (48TB) -// | Marked1 View | -// +--------------------------------+ 0x0000200000000000 (32TB) -// | Marked0 View | -// +--------------------------------+ 0x0000100000000000 (16TB) -// . . -// +--------------------------------+ 0x0000000000000000 -// -// 6 4 4 4 4 -// 3 8 7 4 3 0 -// +------------------+----+-------------------------------------------------+ -// |00000000 00000000 |1111|1111 11111111 11111111 11111111 11111111 11111111| -// +------------------+----+-------------------------------------------------+ -// | | | -// | | * 43-0 Object Offset (44-bits, 16TB address space) -// | | -// | * 47-44 Metadata Bits (4-bits) 0001 = Marked0 (Address view 16-32TB) -// | 0010 = Marked1 (Address view 32-48TB) -// | 0100 = Remapped (Address view 64-80TB) -// | 1000 = Finalizable (Address view N/A) -// | -// * 63-48 Fixed (16-bits, always zero) -// - -// Default value if probing is not implemented for a certain platform: 128TB -static const size_t DEFAULT_MAX_ADDRESS_BIT = 47; -// Minimum value returned, if probing fails: 64GB -static const size_t MINIMUM_MAX_ADDRESS_BIT = 36; - -static size_t probe_valid_max_address_bit() { -#ifdef LINUX - size_t max_address_bit = 0; - const size_t page_size = os::vm_page_size(); - for (size_t i = DEFAULT_MAX_ADDRESS_BIT; i > MINIMUM_MAX_ADDRESS_BIT; --i) { - const uintptr_t base_addr = ((uintptr_t) 1U) << i; - if (msync((void*)base_addr, page_size, MS_ASYNC) == 0) { - // msync succeeded, the address is valid, and maybe even already mapped. - max_address_bit = i; - break; - } - if (errno != ENOMEM) { - // Some error occurred. This should never happen, but msync - // has some undefined behavior, hence ignore this bit. -#ifdef ASSERT - fatal("Received '%s' while probing the address space for the highest valid bit", os::errno_name(errno)); -#else // ASSERT - log_warning_p(gc)("Received '%s' while probing the address space for the highest valid bit", os::errno_name(errno)); -#endif // ASSERT - continue; - } - // Since msync failed with ENOMEM, the page might not be mapped. - // Try to map it, to see if the address is valid. - void* const result_addr = mmap((void*) base_addr, page_size, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0); - if (result_addr != MAP_FAILED) { - munmap(result_addr, page_size); - } - if ((uintptr_t) result_addr == base_addr) { - // address is valid - max_address_bit = i; - break; - } - } - if (max_address_bit == 0) { - // probing failed, allocate a very high page and take that bit as the maximum - const uintptr_t high_addr = ((uintptr_t) 1U) << DEFAULT_MAX_ADDRESS_BIT; - void* const result_addr = mmap((void*) high_addr, page_size, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0); - if (result_addr != MAP_FAILED) { - max_address_bit = BitsPerSize_t - count_leading_zeros((size_t) result_addr) - 1; - munmap(result_addr, page_size); - } - } - log_info_p(gc, init)("Probing address space for the highest valid bit: " SIZE_FORMAT, max_address_bit); - return MAX2(max_address_bit, MINIMUM_MAX_ADDRESS_BIT); -#else // LINUX - return DEFAULT_MAX_ADDRESS_BIT; -#endif // LINUX -} - -size_t XPlatformAddressOffsetBits() { - const static size_t valid_max_address_offset_bits = probe_valid_max_address_bit() + 1; - const size_t max_address_offset_bits = valid_max_address_offset_bits - 3; - const size_t min_address_offset_bits = max_address_offset_bits - 2; - const size_t address_offset = round_up_power_of_2(MaxHeapSize * XVirtualToPhysicalRatio); - const size_t address_offset_bits = log2i_exact(address_offset); - return clamp(address_offset_bits, min_address_offset_bits, max_address_offset_bits); -} - -size_t XPlatformAddressMetadataShift() { - return XPlatformAddressOffsetBits(); -} diff --git a/src/hotspot/cpu/riscv/gc/x/xGlobals_riscv.hpp b/src/hotspot/cpu/riscv/gc/x/xGlobals_riscv.hpp deleted file mode 100644 index 836dc7aac0d..00000000000 --- a/src/hotspot/cpu/riscv/gc/x/xGlobals_riscv.hpp +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2020, 2021, Huawei Technologies Co., Ltd. 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#ifndef CPU_RISCV_GC_X_XGLOBALS_RISCV_HPP -#define CPU_RISCV_GC_X_XGLOBALS_RISCV_HPP - -const size_t XPlatformHeapViews = 3; -const size_t XPlatformCacheLineSize = 64; - -size_t XPlatformAddressOffsetBits(); -size_t XPlatformAddressMetadataShift(); - -#endif // CPU_RISCV_GC_X_XGLOBALS_RISCV_HPP diff --git a/src/hotspot/cpu/riscv/gc/x/x_riscv.ad b/src/hotspot/cpu/riscv/gc/x/x_riscv.ad deleted file mode 100644 index b93b7066425..00000000000 --- a/src/hotspot/cpu/riscv/gc/x/x_riscv.ad +++ /dev/null @@ -1,229 +0,0 @@ -// -// Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. -// Copyright (c) 2020, 2021, Huawei Technologies Co., Ltd. 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 -// under the terms of the GNU General Public License version 2 only, as -// published by the Free Software Foundation. -// -// This code is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -// version 2 for more details (a copy is included in the LICENSE file that -// accompanied this code). -// -// You should have received a copy of the GNU General Public License version -// 2 along with this work; if not, write to the Free Software Foundation, -// Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -// -// Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -// or visit www.oracle.com if you need additional information or have any -// questions. -// - -source_hpp %{ - -#include "gc/shared/gc_globals.hpp" -#include "gc/x/c2/xBarrierSetC2.hpp" -#include "gc/x/xThreadLocalData.hpp" - -%} - -source %{ - -static void x_load_barrier(MacroAssembler* masm, const MachNode* node, Address ref_addr, Register ref, Register tmp, int barrier_data) { - if (barrier_data == XLoadBarrierElided) { - return; - } - XLoadBarrierStubC2* const stub = XLoadBarrierStubC2::create(node, ref_addr, ref, tmp, barrier_data); - __ ld(tmp, Address(xthread, XThreadLocalData::address_bad_mask_offset())); - __ andr(tmp, tmp, ref); - __ bnez(tmp, *stub->entry(), true /* far */); - __ bind(*stub->continuation()); -} - -static void x_load_barrier_slow_path(MacroAssembler* masm, const MachNode* node, Address ref_addr, Register ref, Register tmp) { - XLoadBarrierStubC2* const stub = XLoadBarrierStubC2::create(node, ref_addr, ref, tmp, XLoadBarrierStrong); - __ j(*stub->entry()); - __ bind(*stub->continuation()); -} - -%} - -// Load Pointer -instruct xLoadP(iRegPNoSp dst, memory mem, iRegPNoSp tmp, rFlagsReg cr) -%{ - match(Set dst (LoadP mem)); - predicate(UseZGC && !ZGenerational && (n->as_Load()->barrier_data() != 0)); - effect(TEMP dst, TEMP tmp, KILL cr); - - ins_cost(4 * DEFAULT_COST); - - format %{ "ld $dst, $mem, #@zLoadP" %} - - ins_encode %{ - const Address ref_addr (as_Register($mem$$base), $mem$$disp); - __ ld($dst$$Register, ref_addr); - x_load_barrier(masm, this, ref_addr, $dst$$Register, $tmp$$Register /* tmp */, barrier_data()); - %} - - ins_pipe(iload_reg_mem); -%} - -instruct xCompareAndSwapP(iRegINoSp res, indirect mem, iRegP oldval, iRegP newval, iRegPNoSp tmp, rFlagsReg cr) %{ - match(Set res (CompareAndSwapP mem (Binary oldval newval))); - match(Set res (WeakCompareAndSwapP mem (Binary oldval newval))); - predicate(UseZGC && !ZGenerational && !needs_acquiring_load_reserved(n) && n->as_LoadStore()->barrier_data() == XLoadBarrierStrong); - effect(TEMP_DEF res, TEMP tmp, KILL cr); - - ins_cost(2 * VOLATILE_REF_COST); - - format %{ "cmpxchg $mem, $oldval, $newval, #@zCompareAndSwapP\n\t" - "mv $res, $res == $oldval" %} - - ins_encode %{ - Label failed; - guarantee($mem$$index == -1 && $mem$$disp == 0, "impossible encoding"); - __ cmpxchg($mem$$Register, $oldval$$Register, $newval$$Register, Assembler::int64, - Assembler::relaxed /* acquire */, Assembler::rl /* release */, $tmp$$Register); - __ sub(t0, $tmp$$Register, $oldval$$Register); - __ seqz($res$$Register, t0); - if (barrier_data() != XLoadBarrierElided) { - Label good; - __ ld(t0, Address(xthread, XThreadLocalData::address_bad_mask_offset())); - __ andr(t0, t0, $tmp$$Register); - __ beqz(t0, good); - x_load_barrier_slow_path(masm, this, Address($mem$$Register), $tmp$$Register /* ref */, $res$$Register /* tmp */); - __ cmpxchg($mem$$Register, $oldval$$Register, $newval$$Register, Assembler::int64, - Assembler::relaxed /* acquire */, Assembler::rl /* release */, $res$$Register, - true /* result_as_bool */); - __ bind(good); - } - %} - - ins_pipe(pipe_slow); -%} - -instruct xCompareAndSwapPAcq(iRegINoSp res, indirect mem, iRegP oldval, iRegP newval, iRegPNoSp tmp, rFlagsReg cr) %{ - match(Set res (CompareAndSwapP mem (Binary oldval newval))); - match(Set res (WeakCompareAndSwapP mem (Binary oldval newval))); - predicate(UseZGC && !ZGenerational && needs_acquiring_load_reserved(n) && (n->as_LoadStore()->barrier_data() == XLoadBarrierStrong)); - effect(TEMP_DEF res, TEMP tmp, KILL cr); - - ins_cost(2 * VOLATILE_REF_COST); - - format %{ "cmpxchg $mem, $oldval, $newval, #@zCompareAndSwapPAcq\n\t" - "mv $res, $res == $oldval" %} - - ins_encode %{ - Label failed; - guarantee($mem$$index == -1 && $mem$$disp == 0, "impossible encoding"); - __ cmpxchg($mem$$Register, $oldval$$Register, $newval$$Register, Assembler::int64, - Assembler::aq /* acquire */, Assembler::rl /* release */, $tmp$$Register); - __ sub(t0, $tmp$$Register, $oldval$$Register); - __ seqz($res$$Register, t0); - if (barrier_data() != XLoadBarrierElided) { - Label good; - __ ld(t0, Address(xthread, XThreadLocalData::address_bad_mask_offset())); - __ andr(t0, t0, $tmp$$Register); - __ beqz(t0, good); - x_load_barrier_slow_path(masm, this, Address($mem$$Register), $tmp$$Register /* ref */, $res$$Register /* tmp */); - __ cmpxchg($mem$$Register, $oldval$$Register, $newval$$Register, Assembler::int64, - Assembler::aq /* acquire */, Assembler::rl /* release */, $res$$Register, - true /* result_as_bool */); - __ bind(good); - } - %} - - ins_pipe(pipe_slow); -%} - -instruct xCompareAndExchangeP(iRegPNoSp res, indirect mem, iRegP oldval, iRegP newval, iRegPNoSp tmp, rFlagsReg cr) %{ - match(Set res (CompareAndExchangeP mem (Binary oldval newval))); - predicate(UseZGC && !ZGenerational && !needs_acquiring_load_reserved(n) && n->as_LoadStore()->barrier_data() == XLoadBarrierStrong); - effect(TEMP_DEF res, TEMP tmp, KILL cr); - - ins_cost(2 * VOLATILE_REF_COST); - - format %{ "cmpxchg $res = $mem, $oldval, $newval, #@zCompareAndExchangeP" %} - - ins_encode %{ - guarantee($mem$$index == -1 && $mem$$disp == 0, "impossible encoding"); - __ cmpxchg($mem$$Register, $oldval$$Register, $newval$$Register, Assembler::int64, - Assembler::relaxed /* acquire */, Assembler::rl /* release */, $res$$Register); - if (barrier_data() != XLoadBarrierElided) { - Label good; - __ ld(t0, Address(xthread, XThreadLocalData::address_bad_mask_offset())); - __ andr(t0, t0, $res$$Register); - __ beqz(t0, good); - x_load_barrier_slow_path(masm, this, Address($mem$$Register), $res$$Register /* ref */, $tmp$$Register /* tmp */); - __ cmpxchg($mem$$Register, $oldval$$Register, $newval$$Register, Assembler::int64, - Assembler::relaxed /* acquire */, Assembler::rl /* release */, $res$$Register); - __ bind(good); - } - %} - - ins_pipe(pipe_slow); -%} - -instruct xCompareAndExchangePAcq(iRegPNoSp res, indirect mem, iRegP oldval, iRegP newval, iRegPNoSp tmp, rFlagsReg cr) %{ - match(Set res (CompareAndExchangeP mem (Binary oldval newval))); - predicate(UseZGC && !ZGenerational && needs_acquiring_load_reserved(n) && n->as_LoadStore()->barrier_data() == XLoadBarrierStrong); - effect(TEMP_DEF res, TEMP tmp, KILL cr); - - ins_cost(2 * VOLATILE_REF_COST); - - format %{ "cmpxchg $res = $mem, $oldval, $newval, #@zCompareAndExchangePAcq" %} - - ins_encode %{ - guarantee($mem$$index == -1 && $mem$$disp == 0, "impossible encoding"); - __ cmpxchg($mem$$Register, $oldval$$Register, $newval$$Register, Assembler::int64, - Assembler::aq /* acquire */, Assembler::rl /* release */, $res$$Register); - if (barrier_data() != XLoadBarrierElided) { - Label good; - __ ld(t0, Address(xthread, XThreadLocalData::address_bad_mask_offset())); - __ andr(t0, t0, $res$$Register); - __ beqz(t0, good); - x_load_barrier_slow_path(masm, this, Address($mem$$Register), $res$$Register /* ref */, $tmp$$Register /* tmp */); - __ cmpxchg($mem$$Register, $oldval$$Register, $newval$$Register, Assembler::int64, - Assembler::aq /* acquire */, Assembler::rl /* release */, $res$$Register); - __ bind(good); - } - %} - - ins_pipe(pipe_slow); -%} - -instruct xGetAndSetP(indirect mem, iRegP newv, iRegPNoSp prev, iRegPNoSp tmp, rFlagsReg cr) %{ - match(Set prev (GetAndSetP mem newv)); - predicate(UseZGC && !ZGenerational && !needs_acquiring_load_reserved(n) && n->as_LoadStore()->barrier_data() != 0); - effect(TEMP_DEF prev, TEMP tmp, KILL cr); - - ins_cost(2 * VOLATILE_REF_COST); - - format %{ "atomic_xchg $prev, $newv, [$mem], #@zGetAndSetP" %} - - ins_encode %{ - __ atomic_xchg($prev$$Register, $newv$$Register, as_Register($mem$$base)); - x_load_barrier(masm, this, Address(noreg, 0), $prev$$Register, $tmp$$Register /* tmp */, barrier_data()); - %} - - ins_pipe(pipe_serial); -%} - -instruct xGetAndSetPAcq(indirect mem, iRegP newv, iRegPNoSp prev, iRegPNoSp tmp, rFlagsReg cr) %{ - match(Set prev (GetAndSetP mem newv)); - predicate(UseZGC && !ZGenerational && needs_acquiring_load_reserved(n) && (n->as_LoadStore()->barrier_data() != 0)); - effect(TEMP_DEF prev, TEMP tmp, KILL cr); - - ins_cost(VOLATILE_REF_COST); - - format %{ "atomic_xchg_acq $prev, $newv, [$mem], #@zGetAndSetPAcq" %} - - ins_encode %{ - __ atomic_xchgal($prev$$Register, $newv$$Register, as_Register($mem$$base)); - x_load_barrier(masm, this, Address(noreg, 0), $prev$$Register, $tmp$$Register /* tmp */, barrier_data()); - %} - ins_pipe(pipe_serial); -%} diff --git a/src/hotspot/cpu/riscv/gc/z/z_riscv.ad b/src/hotspot/cpu/riscv/gc/z/z_riscv.ad index 24669f45eb4..8e33d514f46 100644 --- a/src/hotspot/cpu/riscv/gc/z/z_riscv.ad +++ b/src/hotspot/cpu/riscv/gc/z/z_riscv.ad @@ -94,7 +94,7 @@ static void z_store_barrier(MacroAssembler* masm, const MachNode* node, Address instruct zLoadP(iRegPNoSp dst, memory mem, iRegPNoSp tmp, rFlagsReg cr) %{ match(Set dst (LoadP mem)); - predicate(UseZGC && ZGenerational && n->as_Load()->barrier_data() != 0); + predicate(UseZGC && n->as_Load()->barrier_data() != 0); effect(TEMP dst, TEMP tmp, KILL cr); ins_cost(4 * DEFAULT_COST); @@ -113,7 +113,7 @@ instruct zLoadP(iRegPNoSp dst, memory mem, iRegPNoSp tmp, rFlagsReg cr) // Store Pointer instruct zStoreP(memory mem, iRegP src, iRegPNoSp tmp1, iRegPNoSp tmp2, rFlagsReg cr) %{ - predicate(UseZGC && ZGenerational && n->as_Store()->barrier_data() != 0); + predicate(UseZGC && n->as_Store()->barrier_data() != 0); match(Set mem (StoreP mem src)); effect(TEMP tmp1, TEMP tmp2, KILL cr); @@ -131,7 +131,7 @@ instruct zCompareAndSwapP(iRegINoSp res, indirect mem, iRegP oldval, iRegP newva iRegPNoSp oldval_tmp, iRegPNoSp newval_tmp, iRegPNoSp tmp1, rFlagsReg cr) %{ match(Set res (CompareAndSwapP mem (Binary oldval newval))); match(Set res (WeakCompareAndSwapP mem (Binary oldval newval))); - predicate(UseZGC && ZGenerational && !needs_acquiring_load_reserved(n) && n->as_LoadStore()->barrier_data() != 0); + predicate(UseZGC && !needs_acquiring_load_reserved(n) && n->as_LoadStore()->barrier_data() != 0); effect(TEMP oldval_tmp, TEMP newval_tmp, TEMP tmp1, TEMP_DEF res, KILL cr); ins_cost(2 * VOLATILE_REF_COST); @@ -154,7 +154,7 @@ instruct zCompareAndSwapPAcq(iRegINoSp res, indirect mem, iRegP oldval, iRegP ne iRegPNoSp oldval_tmp, iRegPNoSp newval_tmp, iRegPNoSp tmp1, rFlagsReg cr) %{ match(Set res (CompareAndSwapP mem (Binary oldval newval))); match(Set res (WeakCompareAndSwapP mem (Binary oldval newval))); - predicate(UseZGC && ZGenerational && needs_acquiring_load_reserved(n) && n->as_LoadStore()->barrier_data() != 0); + predicate(UseZGC && needs_acquiring_load_reserved(n) && n->as_LoadStore()->barrier_data() != 0); effect(TEMP oldval_tmp, TEMP newval_tmp, TEMP tmp1, TEMP_DEF res, KILL cr); ins_cost(2 * VOLATILE_REF_COST); @@ -176,7 +176,7 @@ instruct zCompareAndSwapPAcq(iRegINoSp res, indirect mem, iRegP oldval, iRegP ne instruct zCompareAndExchangeP(iRegPNoSp res, indirect mem, iRegP oldval, iRegP newval, iRegPNoSp oldval_tmp, iRegPNoSp newval_tmp, iRegPNoSp tmp1, rFlagsReg cr) %{ match(Set res (CompareAndExchangeP mem (Binary oldval newval))); - predicate(UseZGC && ZGenerational && !needs_acquiring_load_reserved(n) && n->as_LoadStore()->barrier_data() != 0); + predicate(UseZGC && !needs_acquiring_load_reserved(n) && n->as_LoadStore()->barrier_data() != 0); effect(TEMP oldval_tmp, TEMP newval_tmp, TEMP tmp1, TEMP_DEF res, KILL cr); ins_cost(2 * VOLATILE_REF_COST); @@ -198,7 +198,7 @@ instruct zCompareAndExchangeP(iRegPNoSp res, indirect mem, iRegP oldval, iRegP n instruct zCompareAndExchangePAcq(iRegPNoSp res, indirect mem, iRegP oldval, iRegP newval, iRegPNoSp oldval_tmp, iRegPNoSp newval_tmp, iRegPNoSp tmp1, rFlagsReg cr) %{ match(Set res (CompareAndExchangeP mem (Binary oldval newval))); - predicate(UseZGC && ZGenerational && needs_acquiring_load_reserved(n) && n->as_LoadStore()->barrier_data() != 0); + predicate(UseZGC && needs_acquiring_load_reserved(n) && n->as_LoadStore()->barrier_data() != 0); effect(TEMP oldval_tmp, TEMP newval_tmp, TEMP tmp1, TEMP_DEF res, KILL cr); ins_cost(2 * VOLATILE_REF_COST); @@ -219,7 +219,7 @@ instruct zCompareAndExchangePAcq(iRegPNoSp res, indirect mem, iRegP oldval, iReg instruct zGetAndSetP(indirect mem, iRegP newv, iRegPNoSp prev, iRegPNoSp tmp, rFlagsReg cr) %{ match(Set prev (GetAndSetP mem newv)); - predicate(UseZGC && ZGenerational && !needs_acquiring_load_reserved(n) && n->as_LoadStore()->barrier_data() != 0); + predicate(UseZGC && !needs_acquiring_load_reserved(n) && n->as_LoadStore()->barrier_data() != 0); effect(TEMP_DEF prev, TEMP tmp, KILL cr); ins_cost(2 * VOLATILE_REF_COST); @@ -237,7 +237,7 @@ instruct zGetAndSetP(indirect mem, iRegP newv, iRegPNoSp prev, iRegPNoSp tmp, rF instruct zGetAndSetPAcq(indirect mem, iRegP newv, iRegPNoSp prev, iRegPNoSp tmp, rFlagsReg cr) %{ match(Set prev (GetAndSetP mem newv)); - predicate(UseZGC && ZGenerational && needs_acquiring_load_reserved(n) && n->as_LoadStore()->barrier_data() != 0); + predicate(UseZGC && needs_acquiring_load_reserved(n) && n->as_LoadStore()->barrier_data() != 0); effect(TEMP_DEF prev, TEMP tmp, KILL cr); ins_cost(2 * VOLATILE_REF_COST); diff --git a/src/hotspot/cpu/riscv/globals_riscv.hpp b/src/hotspot/cpu/riscv/globals_riscv.hpp index dd31de14704..7bd0200f118 100644 --- a/src/hotspot/cpu/riscv/globals_riscv.hpp +++ b/src/hotspot/cpu/riscv/globals_riscv.hpp @@ -112,11 +112,11 @@ define_pd_global(intx, InlineSmallCode, 1000); product(bool, UseZicbom, false, EXPERIMENTAL, "Use Zicbom instructions") \ product(bool, UseZicbop, false, EXPERIMENTAL, "Use Zicbop instructions") \ product(bool, UseZicboz, false, EXPERIMENTAL, "Use Zicboz instructions") \ - product(bool, UseZtso, false, EXPERIMENTAL, "Assume Ztso memory model") \ product(bool, UseZihintpause, false, EXPERIMENTAL, \ "Use Zihintpause instructions") \ + product(bool, UseZtso, false, EXPERIMENTAL, "Assume Ztso memory model") \ product(bool, UseZvbb, false, EXPERIMENTAL, "Use Zvbb instructions") \ - product(bool, UseZvfh, false, EXPERIMENTAL, "Use Zvfh instructions") \ + product(bool, UseZvfh, false, "Use Zvfh instructions") \ product(bool, UseZvkn, false, EXPERIMENTAL, \ "Use Zvkn group extension, Zvkned, Zvknhb, Zvkb, Zvkt") \ product(bool, UseRVVForBigIntegerShiftIntrinsics, true, \ diff --git a/src/hotspot/cpu/riscv/interp_masm_riscv.cpp b/src/hotspot/cpu/riscv/interp_masm_riscv.cpp index fd75bde7655..f383557e43f 100644 --- a/src/hotspot/cpu/riscv/interp_masm_riscv.cpp +++ b/src/hotspot/cpu/riscv/interp_masm_riscv.cpp @@ -193,9 +193,7 @@ void InterpreterMacroAssembler::get_unsigned_2_byte_index_at_bcp(Register reg, i void InterpreterMacroAssembler::get_dispatch() { ExternalAddress target((address)Interpreter::dispatch_table()); relocate(target.rspec(), [&] { - int32_t offset; - la(xdispatch, target.target(), offset); - addi(xdispatch, xdispatch, offset); + la(xdispatch, target.target()); }); } diff --git a/src/hotspot/cpu/riscv/jniFastGetField_riscv.cpp b/src/hotspot/cpu/riscv/jniFastGetField_riscv.cpp index f7d702c6310..2b4a8b87e54 100644 --- a/src/hotspot/cpu/riscv/jniFastGetField_riscv.cpp +++ b/src/hotspot/cpu/riscv/jniFastGetField_riscv.cpp @@ -75,9 +75,7 @@ address JNI_FastGetField::generate_fast_get_int_field0(BasicType type) { Address target(SafepointSynchronize::safepoint_counter_addr()); __ relocate(target.rspec(), [&] { - int32_t offset; - __ la(rcounter_addr, target.target(), offset); - __ addi(rcounter_addr, rcounter_addr, offset); + __ la(rcounter_addr, target.target()); }); Label slow; diff --git a/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp b/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp index 7101f7d726e..b58590e790f 100644 --- a/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp +++ b/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp @@ -530,7 +530,7 @@ void MacroAssembler::_verify_oop(Register reg, const char* s, const char* file, movptr(t0, (address) b); } - // call indirectly to solve generation ordering problem + // Call indirectly to solve generation ordering problem RuntimeAddress target(StubRoutines::verify_oop_subroutine_entry_address()); relocate(target.rspec(), [&] { int32_t offset; @@ -575,7 +575,7 @@ void MacroAssembler::_verify_oop_addr(Address addr, const char* s, const char* f movptr(t0, (address) b); } - // call indirectly to solve generation ordering problem + // Call indirectly to solve generation ordering problem RuntimeAddress target(StubRoutines::verify_oop_subroutine_entry_address()); relocate(target.rspec(), [&] { int32_t offset; @@ -2569,27 +2569,6 @@ void MacroAssembler::bang_stack_size(Register size, Register tmp) { } } -SkipIfEqual::SkipIfEqual(MacroAssembler* masm, const bool* flag_addr, bool value) { - int32_t offset = 0; - _masm = masm; - ExternalAddress target((address)flag_addr); - _masm->relocate(target.rspec(), [&] { - int32_t offset; - _masm->la(t0, target.target(), offset); - _masm->lbu(t0, Address(t0, offset)); - }); - if (value) { - _masm->bnez(t0, _label); - } else { - _masm->beqz(t0, _label); - } -} - -SkipIfEqual::~SkipIfEqual() { - _masm->bind(_label); - _masm = nullptr; -} - void MacroAssembler::load_mirror(Register dst, Register method, Register tmp1, Register tmp2) { const int mirror_offset = in_bytes(Klass::java_mirror_offset()); ld(dst, Address(xmethod, Method::const_offset())); @@ -4210,7 +4189,7 @@ void MacroAssembler::read_polling_page(Register r, int32_t offset, relocInfo::re }); } -void MacroAssembler::set_narrow_oop(Register dst, jobject obj) { +void MacroAssembler::set_narrow_oop(Register dst, jobject obj) { #ifdef ASSERT { ThreadInVMfromUnknown tiv; @@ -4511,14 +4490,15 @@ void MacroAssembler::decrementw(const Address dst, int32_t value, Register tmp1, sw(tmp1, adr); } -void MacroAssembler::cmpptr(Register src1, Address src2, Label& equal) { - assert_different_registers(src1, t0); +void MacroAssembler::cmpptr(Register src1, const Address &src2, Label& equal, Register tmp) { + assert_different_registers(src1, tmp); + assert(src2.getMode() == Address::literal, "must be applied to a literal address"); relocate(src2.rspec(), [&] { int32_t offset; - la(t0, src2.target(), offset); - ld(t0, Address(t0, offset)); + la(tmp, src2.target(), offset); + ld(tmp, Address(tmp, offset)); }); - beq(src1, t0, equal); + beq(src1, tmp, equal); } void MacroAssembler::load_method_holder_cld(Register result, Register method) { diff --git a/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp b/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp index fda3badf350..b248db39933 100644 --- a/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp +++ b/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp @@ -1327,7 +1327,7 @@ class MacroAssembler: public Assembler { void decrement(const Address dst, int64_t value = 1, Register tmp1 = t0, Register tmp2 = t1); void decrementw(const Address dst, int32_t value = 1, Register tmp1 = t0, Register tmp2 = t1); - void cmpptr(Register src1, Address src2, Label& equal); + void cmpptr(Register src1, const Address &src2, Label& equal, Register tmp = t0); void clinit_barrier(Register klass, Register tmp, Label* L_fast_path = nullptr, Label* L_slow_path = nullptr); void load_method_holder_cld(Register result, Register method); @@ -1794,22 +1794,4 @@ class MacroAssembler: public Assembler { inline bool AbstractAssembler::pd_check_instruction_mark() { return false; } #endif -/** - * class SkipIfEqual: - * - * Instantiating this class will result in assembly code being output that will - * jump around any code emitted between the creation of the instance and it's - * automatic destruction at the end of a scope block, depending on the value of - * the flag passed to the constructor, which will be checked at run-time. - */ -class SkipIfEqual { - private: - MacroAssembler* _masm; - Label _label; - - public: - SkipIfEqual(MacroAssembler*, const bool* flag_addr, bool value); - ~SkipIfEqual(); -}; - #endif // CPU_RISCV_MACROASSEMBLER_RISCV_HPP diff --git a/src/hotspot/cpu/riscv/sharedRuntime_riscv.cpp b/src/hotspot/cpu/riscv/sharedRuntime_riscv.cpp index cec6a5f9760..29c96112ead 100644 --- a/src/hotspot/cpu/riscv/sharedRuntime_riscv.cpp +++ b/src/hotspot/cpu/riscv/sharedRuntime_riscv.cpp @@ -2616,19 +2616,18 @@ RuntimeStub* SharedRuntime::generate_resolve_blob(SharedStubId id, address desti __ reset_last_Java_frame(false); // check for pending exceptions Label pending; - __ ld(t0, Address(xthread, Thread::pending_exception_offset())); - __ bnez(t0, pending); + __ ld(t1, Address(xthread, Thread::pending_exception_offset())); + __ bnez(t1, pending); // get the returned Method* __ get_vm_result_2(xmethod, xthread); __ sd(xmethod, Address(sp, reg_saver.reg_offset_in_bytes(xmethod))); - // x10 is where we want to jump, overwrite t0 which is saved and temporary - __ sd(x10, Address(sp, reg_saver.reg_offset_in_bytes(t0))); + // x10 is where we want to jump, overwrite t1 which is saved and temporary + __ sd(x10, Address(sp, reg_saver.reg_offset_in_bytes(t1))); reg_saver.restore_live_registers(masm); // We are back to the original state on entry and ready to go. - __ mv(t1, t0); __ jr(t1); // Pending exception after the safepoint diff --git a/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp b/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp index a4744dfc05c..bce0c8f1f3d 100644 --- a/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp +++ b/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp @@ -946,7 +946,7 @@ class StubGenerator: public StubCodeGenerator { // The size of copy32_loop body increases significantly with ZGC GC barriers. // Need conditional far branches to reach a point beyond the loop in this case. - bool is_far = UseZGC && ZGenerational; + bool is_far = UseZGC; __ beqz(count, done, is_far); __ slli(cnt, count, exact_log2(granularity)); @@ -2276,6 +2276,174 @@ class StubGenerator: public StubCodeGenerator { StubRoutines::_arrayof_jint_fill = generate_fill(T_INT, true, "arrayof_jint_fill"); } + void generate_aes_loadkeys(const Register &key, VectorRegister *working_vregs, int rounds) { + const int step = 16; + for (int i = 0; i < rounds; i++) { + __ vle32_v(working_vregs[i], key); + // The keys are stored in little-endian array, while we need + // to operate in big-endian. + // So performing an endian-swap here with vrev8.v instruction + __ vrev8_v(working_vregs[i], working_vregs[i]); + __ addi(key, key, step); + } + } + + void generate_aes_encrypt(const VectorRegister &res, VectorRegister *working_vregs, int rounds) { + assert(rounds <= 15, "rounds should be less than or equal to working_vregs size"); + + __ vxor_vv(res, res, working_vregs[0]); + for (int i = 1; i < rounds - 1; i++) { + __ vaesem_vv(res, working_vregs[i]); + } + __ vaesef_vv(res, working_vregs[rounds - 1]); + } + + // Arguments: + // + // Inputs: + // c_rarg0 - source byte array address + // c_rarg1 - destination byte array address + // c_rarg2 - K (key) in little endian int array + // + address generate_aescrypt_encryptBlock() { + assert(UseAESIntrinsics, "need AES instructions (Zvkned extension) support"); + + __ align(CodeEntryAlignment); + StubCodeMark mark(this, "StubRoutines", "aescrypt_encryptBlock"); + + Label L_aes128, L_aes192; + + const Register from = c_rarg0; // source array address + const Register to = c_rarg1; // destination array address + const Register key = c_rarg2; // key array address + const Register keylen = c_rarg3; + + VectorRegister working_vregs[] = { + v4, v5, v6, v7, v8, v9, v10, v11, + v12, v13, v14, v15, v16, v17, v18 + }; + const VectorRegister res = v19; + + address start = __ pc(); + __ enter(); + + __ lwu(keylen, Address(key, arrayOopDesc::length_offset_in_bytes() - arrayOopDesc::base_offset_in_bytes(T_INT))); + + __ vsetivli(x0, 4, Assembler::e32, Assembler::m1); + __ vle32_v(res, from); + + __ mv(t2, 52); + __ blt(keylen, t2, L_aes128); + __ beq(keylen, t2, L_aes192); + // Else we fallthrough to the biggest case (256-bit key size) + + // Note: the following function performs key += 15*16 + generate_aes_loadkeys(key, working_vregs, 15); + generate_aes_encrypt(res, working_vregs, 15); + __ vse32_v(res, to); + __ mv(c_rarg0, 0); + __ leave(); + __ ret(); + + __ bind(L_aes192); + // Note: the following function performs key += 13*16 + generate_aes_loadkeys(key, working_vregs, 13); + generate_aes_encrypt(res, working_vregs, 13); + __ vse32_v(res, to); + __ mv(c_rarg0, 0); + __ leave(); + __ ret(); + + __ bind(L_aes128); + // Note: the following function performs key += 11*16 + generate_aes_loadkeys(key, working_vregs, 11); + generate_aes_encrypt(res, working_vregs, 11); + __ vse32_v(res, to); + __ mv(c_rarg0, 0); + __ leave(); + __ ret(); + + return start; + } + + void generate_aes_decrypt(const VectorRegister &res, VectorRegister *working_vregs, int rounds) { + assert(rounds <= 15, "rounds should be less than or equal to working_vregs size"); + + __ vxor_vv(res, res, working_vregs[rounds - 1]); + for (int i = rounds - 2; i > 0; i--) { + __ vaesdm_vv(res, working_vregs[i]); + } + __ vaesdf_vv(res, working_vregs[0]); + } + + // Arguments: + // + // Inputs: + // c_rarg0 - source byte array address + // c_rarg1 - destination byte array address + // c_rarg2 - K (key) in little endian int array + // + address generate_aescrypt_decryptBlock() { + assert(UseAESIntrinsics, "need AES instructions (Zvkned extension) support"); + + __ align(CodeEntryAlignment); + StubCodeMark mark(this, "StubRoutines", "aescrypt_decryptBlock"); + + Label L_aes128, L_aes192; + + const Register from = c_rarg0; // source array address + const Register to = c_rarg1; // destination array address + const Register key = c_rarg2; // key array address + const Register keylen = c_rarg3; + + VectorRegister working_vregs[] = { + v4, v5, v6, v7, v8, v9, v10, v11, + v12, v13, v14, v15, v16, v17, v18 + }; + const VectorRegister res = v19; + + address start = __ pc(); + __ enter(); // required for proper stackwalking of RuntimeStub frame + + __ lwu(keylen, Address(key, arrayOopDesc::length_offset_in_bytes() - arrayOopDesc::base_offset_in_bytes(T_INT))); + + __ vsetivli(x0, 4, Assembler::e32, Assembler::m1); + __ vle32_v(res, from); + + __ mv(t2, 52); + __ blt(keylen, t2, L_aes128); + __ beq(keylen, t2, L_aes192); + // Else we fallthrough to the biggest case (256-bit key size) + + // Note: the following function performs key += 15*16 + generate_aes_loadkeys(key, working_vregs, 15); + generate_aes_decrypt(res, working_vregs, 15); + __ vse32_v(res, to); + __ mv(c_rarg0, 0); + __ leave(); + __ ret(); + + __ bind(L_aes192); + // Note: the following function performs key += 13*16 + generate_aes_loadkeys(key, working_vregs, 13); + generate_aes_decrypt(res, working_vregs, 13); + __ vse32_v(res, to); + __ mv(c_rarg0, 0); + __ leave(); + __ ret(); + + __ bind(L_aes128); + // Note: the following function performs key += 11*16 + generate_aes_loadkeys(key, working_vregs, 11); + generate_aes_decrypt(res, working_vregs, 11); + __ vse32_v(res, to); + __ mv(c_rarg0, 0); + __ leave(); + __ ret(); + + return start; + } + // code for comparing 16 bytes of strings with same encoding void compare_string_16_bytes_same(Label &DIFF1, Label &DIFF2) { const Register result = x10, str1 = x11, cnt1 = x12, str2 = x13, tmp1 = x28, tmp2 = x29, tmp4 = x7, tmp5 = x31; @@ -6294,6 +6462,11 @@ static const int64_t right_3_bits = right_n_bits(3); StubRoutines::_montgomerySquare = g.generate_square(); } + if (UseAESIntrinsics) { + StubRoutines::_aescrypt_encryptBlock = generate_aescrypt_encryptBlock(); + StubRoutines::_aescrypt_decryptBlock = generate_aescrypt_decryptBlock(); + } + if (UsePoly1305Intrinsics) { StubRoutines::_poly1305_processBlocks = generate_poly1305_processBlocks(); } diff --git a/src/hotspot/cpu/riscv/templateTable_riscv.cpp b/src/hotspot/cpu/riscv/templateTable_riscv.cpp index 0c20f0e3f92..9f37774e297 100644 --- a/src/hotspot/cpu/riscv/templateTable_riscv.cpp +++ b/src/hotspot/cpu/riscv/templateTable_riscv.cpp @@ -2465,7 +2465,7 @@ void TemplateTable::jvmti_post_field_access(Register cache, Register index, // take the time to call into the VM. Label L1; assert_different_registers(cache, index, x10); - ExternalAddress target((address) JvmtiExport::get_field_access_count_addr()); + ExternalAddress target(JvmtiExport::get_field_access_count_addr()); __ relocate(target.rspec(), [&] { int32_t offset; __ la(t0, target.target(), offset); @@ -2676,7 +2676,7 @@ void TemplateTable::jvmti_post_field_mod(Register cache, Register index, bool is // we take the time to call into the VM. Label L1; assert_different_registers(cache, index, x10); - ExternalAddress target((address)JvmtiExport::get_field_modification_count_addr()); + ExternalAddress target(JvmtiExport::get_field_modification_count_addr()); __ relocate(target.rspec(), [&] { int32_t offset; __ la(t0, target.target(), offset); @@ -2969,7 +2969,7 @@ void TemplateTable::jvmti_post_fast_field_mod() { // Check to see if a field modification watch has been set before // we take the time to call into the VM. Label L2; - ExternalAddress target((address)JvmtiExport::get_field_modification_count_addr()); + ExternalAddress target(JvmtiExport::get_field_modification_count_addr()); __ relocate(target.rspec(), [&] { int32_t offset; __ la(t0, target.target(), offset); @@ -3101,7 +3101,7 @@ void TemplateTable::fast_accessfield(TosState state) { // Check to see if a field access watch has been set before we // take the time to call into the VM. Label L1; - ExternalAddress target((address)JvmtiExport::get_field_access_count_addr()); + ExternalAddress target(JvmtiExport::get_field_access_count_addr()); __ relocate(target.rspec(), [&] { int32_t offset; __ la(t0, target.target(), offset); diff --git a/src/hotspot/cpu/riscv/vm_version_riscv.cpp b/src/hotspot/cpu/riscv/vm_version_riscv.cpp index e9c6226f446..c32d2af9939 100644 --- a/src/hotspot/cpu/riscv/vm_version_riscv.cpp +++ b/src/hotspot/cpu/riscv/vm_version_riscv.cpp @@ -122,17 +122,6 @@ void VM_Version::common_initialize() { FLAG_SET_DEFAULT(AllocatePrefetchDistance, 0); } - if (UseAES || UseAESIntrinsics) { - if (UseAES && !FLAG_IS_DEFAULT(UseAES)) { - warning("AES instructions are not available on this CPU"); - FLAG_SET_DEFAULT(UseAES, false); - } - if (UseAESIntrinsics && !FLAG_IS_DEFAULT(UseAESIntrinsics)) { - warning("AES intrinsics are not available on this CPU"); - FLAG_SET_DEFAULT(UseAESIntrinsics, false); - } - } - if (UseAESCTRIntrinsics) { warning("AES/CTR intrinsics are not available on this CPU"); FLAG_SET_DEFAULT(UseAESCTRIntrinsics, false); @@ -429,6 +418,23 @@ void VM_Version::c2_initialize() { if (!(UseSHA1Intrinsics || UseSHA256Intrinsics || UseSHA3Intrinsics || UseSHA512Intrinsics)) { FLAG_SET_DEFAULT(UseSHA, false); } + + // AES + if (UseZvkn) { + UseAES = UseAES || FLAG_IS_DEFAULT(UseAES); + UseAESIntrinsics = + UseAESIntrinsics || (UseAES && FLAG_IS_DEFAULT(UseAESIntrinsics)); + if (UseAESIntrinsics && !UseAES) { + warning("UseAESIntrinsics enabled, but UseAES not, enabling"); + UseAES = true; + } + } else if (UseAESIntrinsics || UseAES) { + if (!FLAG_IS_DEFAULT(UseAESIntrinsics) || !FLAG_IS_DEFAULT(UseAES)) { + warning("AES intrinsics require Zvkn extension (not available on this CPU)."); + } + FLAG_SET_DEFAULT(UseAES, false); + FLAG_SET_DEFAULT(UseAESIntrinsics, false); + } } #endif // COMPILER2 diff --git a/src/hotspot/cpu/s390/c1_LIRAssembler_s390.cpp b/src/hotspot/cpu/s390/c1_LIRAssembler_s390.cpp index 8bf11816219..d2e860aa320 100644 --- a/src/hotspot/cpu/s390/c1_LIRAssembler_s390.cpp +++ b/src/hotspot/cpu/s390/c1_LIRAssembler_s390.cpp @@ -131,9 +131,19 @@ void LIR_Assembler::osr_entry() { // copied into place by code emitted in the IR. Register OSR_buf = osrBufferPointer()->as_register(); - { assert(frame::interpreter_frame_monitor_size() == BasicObjectLock::size(), "adjust code below"); - int monitor_offset = BytesPerWord * method()->max_locals() + - (2 * BytesPerWord) * (number_of_locks - 1); + { + assert(frame::interpreter_frame_monitor_size() == BasicObjectLock::size(), "adjust code below"); + + const int locals_space = BytesPerWord * method() -> max_locals(); + int monitor_offset = locals_space + (2 * BytesPerWord) * (number_of_locks - 1); + bool large_offset = !Immediate::is_simm20(monitor_offset + BytesPerWord) && number_of_locks > 0; + + if (large_offset) { + // z_lg can only handle displacement upto 20bit signed binary integer + __ z_algfi(OSR_buf, locals_space); + monitor_offset -= locals_space; + } + // SharedRuntime::OSR_migration_begin() packs BasicObjectLocks in // the OSR buffer using 2 word entries: first the lock and then // the oop. @@ -147,6 +157,10 @@ void LIR_Assembler::osr_entry() { __ z_lg(Z_R1_scratch, slot_offset + 1*BytesPerWord, OSR_buf); __ z_stg(Z_R1_scratch, frame_map()->address_for_monitor_object(i)); } + + if (large_offset) { + __ z_slgfi(OSR_buf, locals_space); + } } } diff --git a/src/hotspot/cpu/s390/interp_masm_s390.cpp b/src/hotspot/cpu/s390/interp_masm_s390.cpp index d00b6c3e2cc..5e80817aaba 100644 --- a/src/hotspot/cpu/s390/interp_masm_s390.cpp +++ b/src/hotspot/cpu/s390/interp_masm_s390.cpp @@ -2131,18 +2131,6 @@ void InterpreterMacroAssembler::notify_method_exit(bool native_method, if (!native_method) pop(state); bind(jvmti_post_done); } - -#if 0 - // Dtrace currently not supported on z/Architecture. - { - SkipIfEqual skip(this, &DTraceMethodProbes, false); - push(state); - get_method(c_rarg1); - call_VM_leaf(CAST_FROM_FN_PTR(address, SharedRuntime::dtrace_method_exit), - r15_thread, c_rarg1); - pop(state); - } -#endif } void InterpreterMacroAssembler::skip_if_jvmti_mode(Label &Lskip, Register Rscratch) { diff --git a/src/hotspot/cpu/s390/macroAssembler_s390.cpp b/src/hotspot/cpu/s390/macroAssembler_s390.cpp index 6bfe5125959..6b739553b15 100644 --- a/src/hotspot/cpu/s390/macroAssembler_s390.cpp +++ b/src/hotspot/cpu/s390/macroAssembler_s390.cpp @@ -3667,7 +3667,7 @@ void MacroAssembler::compiler_fast_unlock_object(Register oop, Register box, Reg // We need a full fence after clearing owner to avoid stranding. z_fence(); - // Check if the entry lists are empty. + // Check if the entry lists are empty (EntryList first - by convention). load_and_test_long(temp, Address(currentHeader, OM_OFFSET_NO_MONITOR_VALUE_TAG(EntryList))); z_brne(check_succ); load_and_test_long(temp, Address(currentHeader, OM_OFFSET_NO_MONITOR_VALUE_TAG(cxq))); @@ -6016,21 +6016,6 @@ void MacroAssembler::zap_from_to(Register low, Register high, Register val, Regi } #endif // !PRODUCT -SkipIfEqual::SkipIfEqual(MacroAssembler* masm, const bool* flag_addr, bool value, Register _rscratch) { - _masm = masm; - _masm->load_absolute_address(_rscratch, (address)flag_addr); - _masm->load_and_test_int(_rscratch, Address(_rscratch)); - if (value) { - _masm->z_brne(_label); // Skip if true, i.e. != 0. - } else { - _masm->z_bre(_label); // Skip if false, i.e. == 0. - } -} - -SkipIfEqual::~SkipIfEqual() { - _masm->bind(_label); -} - // Implements lightweight-locking. // - obj: the object to be locked, contents preserved. // - temp1, temp2: temporary registers, contents destroyed. @@ -6510,7 +6495,7 @@ void MacroAssembler::compiler_fast_unlock_lightweight_object(Register obj, Regis // We need a full fence after clearing owner to avoid stranding. z_fence(); - // Check if the entry lists are empty. + // Check if the entry lists are empty (EntryList first - by convention). load_and_test_long(tmp2, EntryList_address); z_brne(check_succ); load_and_test_long(tmp2, cxq_address); diff --git a/src/hotspot/cpu/s390/macroAssembler_s390.hpp b/src/hotspot/cpu/s390/macroAssembler_s390.hpp index 5d3a4c29940..061817a1289 100644 --- a/src/hotspot/cpu/s390/macroAssembler_s390.hpp +++ b/src/hotspot/cpu/s390/macroAssembler_s390.hpp @@ -1064,24 +1064,6 @@ class MacroAssembler: public Assembler { }; -/** - * class SkipIfEqual: - * - * Instantiating this class will result in assembly code being output that will - * jump around any code emitted between the creation of the instance and it's - * automatic destruction at the end of a scope block, depending on the value of - * the flag passed to the constructor, which will be checked at run-time. - */ -class SkipIfEqual { - private: - MacroAssembler* _masm; - Label _label; - - public: - SkipIfEqual(MacroAssembler*, const bool* flag_addr, bool value, Register _rscratch); - ~SkipIfEqual(); -}; - #ifdef ASSERT // Return false (e.g. important for our impl. of virtual calls). inline bool AbstractAssembler::pd_check_instruction_mark() { return false; } diff --git a/src/hotspot/cpu/x86/assembler_x86.cpp b/src/hotspot/cpu/x86/assembler_x86.cpp index 0b021bbbf5e..e4ab99bf1c3 100644 --- a/src/hotspot/cpu/x86/assembler_x86.cpp +++ b/src/hotspot/cpu/x86/assembler_x86.cpp @@ -557,6 +557,14 @@ bool Assembler::needs_rex2(Register reg1, Register reg2, Register reg3) { return rex2; } +#ifndef PRODUCT +bool Assembler::needs_evex(XMMRegister reg1, XMMRegister reg2, XMMRegister reg3) { + return (reg1->is_valid() && reg1->encoding() >= 16) || + (reg2->is_valid() && reg2->encoding() >= 16) || + (reg3->is_valid() && reg3->encoding() >= 16); +} +#endif + bool Assembler::needs_eevex(Register reg1, Register reg2, Register reg3) { return needs_rex2(reg1, reg2, reg3); } @@ -3525,7 +3533,7 @@ void Assembler::vmaskmovpd(Address dst, XMMRegister src, XMMRegister mask, int v // Move Unaligned EVEX enabled Vector (programmable : 8,16,32,64) void Assembler::evmovdqub(XMMRegister dst, KRegister mask, XMMRegister src, bool merge, int vector_len) { - assert(VM_Version::supports_avx512vlbw(), ""); + assert(VM_Version::supports_avx512bw() && (vector_len == AVX_512bit || VM_Version::supports_avx512vl()), ""); InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ false, /* uses_vl */ true); attributes.set_embedded_opmask_register_specifier(mask); attributes.set_is_evex_instruction(); @@ -3542,7 +3550,7 @@ void Assembler::evmovdqub(XMMRegister dst, XMMRegister src, int vector_len) { } void Assembler::evmovdqub(XMMRegister dst, KRegister mask, Address src, bool merge, int vector_len) { - assert(VM_Version::supports_avx512vlbw(), ""); + assert(VM_Version::supports_avx512bw() && (vector_len == AVX_512bit || VM_Version::supports_avx512vl()), ""); InstructionMark im(this); InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ false, /* uses_vl */ true); attributes.set_address_attributes(/* tuple_type */ EVEX_FVM, /* input_size_in_bits */ EVEX_NObit); @@ -3562,7 +3570,7 @@ void Assembler::evmovdqub(XMMRegister dst, Address src, int vector_len) { } void Assembler::evmovdqub(Address dst, KRegister mask, XMMRegister src, bool merge, int vector_len) { - assert(VM_Version::supports_avx512vlbw(), ""); + assert(VM_Version::supports_avx512bw() && (vector_len == AVX_512bit || VM_Version::supports_avx512vl()), ""); assert(src != xnoreg, "sanity"); InstructionMark im(this); InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ false, /* uses_vl */ true); @@ -3577,13 +3585,18 @@ void Assembler::evmovdqub(Address dst, KRegister mask, XMMRegister src, bool mer emit_operand(src, dst, 0); } +void Assembler::evmovdquw(XMMRegister dst, XMMRegister src, int vector_len) { + // Unmasked instruction + evmovdquw(dst, k0, src, /*merge*/ false, vector_len); +} + void Assembler::evmovdquw(XMMRegister dst, Address src, int vector_len) { // Unmasked instruction evmovdquw(dst, k0, src, /*merge*/ false, vector_len); } void Assembler::evmovdquw(XMMRegister dst, KRegister mask, Address src, bool merge, int vector_len) { - assert(VM_Version::supports_avx512vlbw(), ""); + assert(VM_Version::supports_avx512bw() && (vector_len == AVX_512bit || VM_Version::supports_avx512vl()), ""); InstructionMark im(this); InstructionAttr attributes(vector_len, /* vex_w */ true, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ false, /* uses_vl */ true); attributes.set_address_attributes(/* tuple_type */ EVEX_FVM, /* input_size_in_bits */ EVEX_NObit); @@ -3603,7 +3616,7 @@ void Assembler::evmovdquw(Address dst, XMMRegister src, int vector_len) { } void Assembler::evmovdquw(Address dst, KRegister mask, XMMRegister src, bool merge, int vector_len) { - assert(VM_Version::supports_avx512vlbw(), ""); + assert(VM_Version::supports_avx512bw() && (vector_len == AVX_512bit || VM_Version::supports_avx512vl()), ""); assert(src != xnoreg, "sanity"); InstructionMark im(this); InstructionAttr attributes(vector_len, /* vex_w */ true, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ false, /* uses_vl */ true); @@ -3618,6 +3631,19 @@ void Assembler::evmovdquw(Address dst, KRegister mask, XMMRegister src, bool mer emit_operand(src, dst, 0); } +void Assembler::evmovdquw(XMMRegister dst, KRegister mask, XMMRegister src, bool merge, int vector_len) { + assert(VM_Version::supports_avx512bw() && (vector_len == AVX_512bit || VM_Version::supports_avx512vl()), ""); + InstructionAttr attributes(vector_len, /* vex_w */ true, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ false, /* uses_vl */ true); + attributes.set_embedded_opmask_register_specifier(mask); + attributes.set_is_evex_instruction(); + if (merge) { + attributes.reset_is_clear_context(); + } + int encode = vex_prefix_and_encode(dst->encoding(), 0, src->encoding(), VEX_SIMD_F2, VEX_OPCODE_0F, &attributes); + emit_int16(0x6F, (0xC0 | encode)); +} + + void Assembler::evmovdqul(XMMRegister dst, XMMRegister src, int vector_len) { // Unmasked instruction evmovdqul(dst, k0, src, /*merge*/ false, vector_len); @@ -4805,6 +4831,7 @@ void Assembler::vpcmpeqb(XMMRegister dst, XMMRegister src1, Address src2, int ve // In this context, kdst is written the mask used to process the equal components void Assembler::evpcmpeqb(KRegister kdst, XMMRegister nds, XMMRegister src, int vector_len) { assert(VM_Version::supports_avx512bw(), ""); + assert(vector_len == Assembler::AVX_512bit || VM_Version::supports_avx512vl(), ""); InstructionAttr attributes(vector_len, /* rex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ true); attributes.set_is_evex_instruction(); int encode = vex_prefix_and_encode(kdst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); @@ -4812,7 +4839,8 @@ void Assembler::evpcmpeqb(KRegister kdst, XMMRegister nds, XMMRegister src, int } void Assembler::evpcmpgtb(KRegister kdst, XMMRegister nds, Address src, int vector_len) { - assert(VM_Version::supports_avx512vlbw(), ""); + assert(VM_Version::supports_avx512bw(), ""); + assert(vector_len == Assembler::AVX_512bit || VM_Version::supports_avx512vl(), ""); InstructionMark im(this); InstructionAttr attributes(vector_len, /* rex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ true); attributes.set_address_attributes(/* tuple_type */ EVEX_FVM, /* input_size_in_bits */ EVEX_NObit); @@ -4824,7 +4852,8 @@ void Assembler::evpcmpgtb(KRegister kdst, XMMRegister nds, Address src, int vect } void Assembler::evpcmpgtb(KRegister kdst, KRegister mask, XMMRegister nds, Address src, int vector_len) { - assert(VM_Version::supports_avx512vlbw(), ""); + assert(VM_Version::supports_avx512bw(), ""); + assert(vector_len == Assembler::AVX_512bit || VM_Version::supports_avx512vl(), ""); InstructionMark im(this); InstructionAttr attributes(vector_len, /* rex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true); attributes.set_address_attributes(/* tuple_type */ EVEX_FVM, /* input_size_in_bits */ EVEX_NObit); @@ -4837,16 +4866,34 @@ void Assembler::evpcmpgtb(KRegister kdst, KRegister mask, XMMRegister nds, Addre emit_operand(as_Register(dst_enc), src, 0); } +void Assembler::evpcmpub(KRegister kdst, XMMRegister nds, XMMRegister src, ComparisonPredicate vcc, int vector_len) { + assert(VM_Version::supports_avx512bw(), ""); + assert(vector_len == Assembler::AVX_512bit || VM_Version::supports_avx512vl(), ""); + InstructionAttr attributes(vector_len, /* rex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ true); + attributes.set_is_evex_instruction(); + int encode = vex_prefix_and_encode(kdst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes); + emit_int24(0x3E, (0xC0 | encode), vcc); +} + void Assembler::evpcmpuw(KRegister kdst, XMMRegister nds, XMMRegister src, ComparisonPredicate vcc, int vector_len) { - assert(VM_Version::supports_avx512vlbw(), ""); + assert(VM_Version::supports_avx512bw(), ""); + assert(vector_len == Assembler::AVX_512bit || VM_Version::supports_avx512vl(), ""); InstructionAttr attributes(vector_len, /* rex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ true); attributes.set_is_evex_instruction(); int encode = vex_prefix_and_encode(kdst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes); emit_int24(0x3E, (0xC0 | encode), vcc); } +void Assembler::evpcmpud(KRegister kdst, XMMRegister nds, XMMRegister src, ComparisonPredicate vcc, int vector_len) { + assert(vector_len == Assembler::AVX_512bit || VM_Version::supports_avx512vl(), ""); + InstructionAttr attributes(vector_len, /* rex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ true); + attributes.set_is_evex_instruction(); + int encode = vex_prefix_and_encode(kdst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes); + emit_int24(0x1E, (0xC0 | encode), vcc); +} + void Assembler::evpcmpuq(KRegister kdst, XMMRegister nds, XMMRegister src, ComparisonPredicate vcc, int vector_len) { - assert(VM_Version::supports_avx512vl(), ""); + assert(vector_len == Assembler::AVX_512bit || VM_Version::supports_avx512vl(), ""); InstructionAttr attributes(vector_len, /* rex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ true); attributes.set_is_evex_instruction(); int encode = vex_prefix_and_encode(kdst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_3A, &attributes); @@ -4854,7 +4901,8 @@ void Assembler::evpcmpuq(KRegister kdst, XMMRegister nds, XMMRegister src, Compa } void Assembler::evpcmpuw(KRegister kdst, XMMRegister nds, Address src, ComparisonPredicate vcc, int vector_len) { - assert(VM_Version::supports_avx512vlbw(), ""); + assert(VM_Version::supports_avx512bw(), ""); + assert(vector_len == Assembler::AVX_512bit || VM_Version::supports_avx512vl(), ""); InstructionMark im(this); InstructionAttr attributes(vector_len, /* rex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ true); attributes.set_address_attributes(/* tuple_type */ EVEX_FVM, /* input_size_in_bits */ EVEX_NObit); @@ -4868,6 +4916,7 @@ void Assembler::evpcmpuw(KRegister kdst, XMMRegister nds, Address src, Compariso void Assembler::evpcmpeqb(KRegister kdst, XMMRegister nds, Address src, int vector_len) { assert(VM_Version::supports_avx512bw(), ""); + assert(vector_len == Assembler::AVX_512bit || VM_Version::supports_avx512vl(), ""); InstructionMark im(this); InstructionAttr attributes(vector_len, /* rex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ true); attributes.set_is_evex_instruction(); @@ -4879,7 +4928,8 @@ void Assembler::evpcmpeqb(KRegister kdst, XMMRegister nds, Address src, int vect } void Assembler::evpcmpeqb(KRegister kdst, KRegister mask, XMMRegister nds, Address src, int vector_len) { - assert(VM_Version::supports_avx512vlbw(), ""); + assert(VM_Version::supports_avx512bw(), ""); + assert(vector_len == Assembler::AVX_512bit || VM_Version::supports_avx512vl(), ""); InstructionMark im(this); InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true); attributes.set_address_attributes(/* tuple_type */ EVEX_FVM, /* input_size_in_bits */ EVEX_NObit); @@ -8353,6 +8403,161 @@ void Assembler::vpaddq(XMMRegister dst, XMMRegister nds, Address src, int vector emit_operand(dst, src, 0); } +void Assembler::vpaddsb(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) { + assert(UseAVX > 0 && (vector_len == Assembler::AVX_512bit || (!needs_evex(dst, nds, src) || VM_Version::supports_avx512vl())), ""); + assert(!needs_evex(dst, nds, src) || VM_Version::supports_avx512bw(), ""); + InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ true); + int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); + emit_int16((unsigned char)0xEC, (0xC0 | encode)); +} + +void Assembler::vpaddsb(XMMRegister dst, XMMRegister nds, Address src, int vector_len) { + assert(UseAVX > 0 && (vector_len == Assembler::AVX_512bit || (!needs_evex(dst, nds) || VM_Version::supports_avx512vl())), ""); + assert(!needs_evex(dst, nds) || VM_Version::supports_avx512bw(), ""); + InstructionMark im(this); + InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ true); + attributes.set_address_attributes(/* tuple_type */ EVEX_FV, /* input_size_in_bits */ EVEX_NObit); + vex_prefix(src, nds->encoding(), dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); + emit_int8((unsigned char)0xEC); + emit_operand(dst, src, 0); +} + +void Assembler::vpaddsw(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) { + assert(UseAVX > 0 && (vector_len == Assembler::AVX_512bit || (!needs_evex(dst, nds, src) || VM_Version::supports_avx512vl())), ""); + assert(!needs_evex(dst, nds, src) || VM_Version::supports_avx512bw(), ""); + InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ true); + int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); + emit_int16((unsigned char)0xED, (0xC0 | encode)); +} + +void Assembler::vpaddsw(XMMRegister dst, XMMRegister nds, Address src, int vector_len) { + assert(UseAVX > 0 && (vector_len == Assembler::AVX_512bit || (!needs_evex(dst, nds) || VM_Version::supports_avx512vl())), ""); + assert(!needs_evex(dst, nds) || VM_Version::supports_avx512bw(), ""); + InstructionMark im(this); + InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ true); + attributes.set_address_attributes(/* tuple_type */ EVEX_FV, /* input_size_in_bits */ EVEX_NObit); + vex_prefix(src, nds->encoding(), dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); + emit_int8((unsigned char)0xED); + emit_operand(dst, src, 0); +} + +void Assembler::vpaddusb(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) { + assert(UseAVX > 0 && (vector_len == Assembler::AVX_512bit || (!needs_evex(dst, nds, src) || VM_Version::supports_avx512vl())), ""); + assert(!needs_evex(dst, nds, src) || VM_Version::supports_avx512bw(), ""); + InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ true); + int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); + emit_int16((unsigned char)0xDC, (0xC0 | encode)); +} + +void Assembler::vpaddusb(XMMRegister dst, XMMRegister nds, Address src, int vector_len) { + assert(UseAVX > 0 && (vector_len == Assembler::AVX_512bit || (!needs_evex(dst, nds) || VM_Version::supports_avx512vl())), ""); + assert(!needs_evex(dst, nds) || VM_Version::supports_avx512bw(), ""); + InstructionMark im(this); + InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ true); + attributes.set_address_attributes(/* tuple_type */ EVEX_FV, /* input_size_in_bits */ EVEX_NObit); + vex_prefix(src, nds->encoding(), dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); + emit_int8((unsigned char)0xDC); + emit_operand(dst, src, 0); +} + + +void Assembler::vpaddusw(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) { + assert(UseAVX > 0 && (vector_len == Assembler::AVX_512bit || (!needs_evex(dst, nds, src) || VM_Version::supports_avx512vl())), ""); + assert(!needs_evex(dst, nds, src) || VM_Version::supports_avx512bw(), ""); + InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ true); + int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); + emit_int16((unsigned char)0xDD, (0xC0 | encode)); +} + +void Assembler::vpaddusw(XMMRegister dst, XMMRegister nds, Address src, int vector_len) { + assert(UseAVX > 0 && (vector_len == Assembler::AVX_512bit || (!needs_evex(dst, nds) || VM_Version::supports_avx512vl())), ""); + assert(!needs_evex(dst, nds) || VM_Version::supports_avx512bw(), ""); + InstructionMark im(this); + InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ true); + attributes.set_address_attributes(/* tuple_type */ EVEX_FV, /* input_size_in_bits */ EVEX_NObit); + vex_prefix(src, nds->encoding(), dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); + emit_int8((unsigned char)0xDD); + emit_operand(dst, src, 0); +} + + +void Assembler::vpsubsb(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) { + assert(UseAVX > 0 && (vector_len == Assembler::AVX_512bit || (!needs_evex(dst, nds, src) || VM_Version::supports_avx512vl())), ""); + assert(!needs_evex(dst, nds, src) || VM_Version::supports_avx512bw(), ""); + InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ true); + int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); + emit_int16((unsigned char)0xE8, (0xC0 | encode)); +} + +void Assembler::vpsubsb(XMMRegister dst, XMMRegister nds, Address src, int vector_len) { + assert(UseAVX > 0 && (vector_len == Assembler::AVX_512bit || (!needs_evex(dst, nds) || VM_Version::supports_avx512vl())), ""); + assert(!needs_evex(dst, nds) || VM_Version::supports_avx512bw(), ""); + InstructionMark im(this); + InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ true); + attributes.set_address_attributes(/* tuple_type */ EVEX_FV, /* input_size_in_bits */ EVEX_NObit); + vex_prefix(src, nds->encoding(), dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); + emit_int8((unsigned char)0xE8); + emit_operand(dst, src, 0); +} + +void Assembler::vpsubsw(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) { + assert(UseAVX > 0 && (vector_len == Assembler::AVX_512bit || (!needs_evex(dst, nds, src) || VM_Version::supports_avx512vl())), ""); + assert(!needs_evex(dst, nds, src) || VM_Version::supports_avx512bw(), ""); + InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ true); + int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); + emit_int16((unsigned char)0xE9, (0xC0 | encode)); +} + +void Assembler::vpsubsw(XMMRegister dst, XMMRegister nds, Address src, int vector_len) { + assert(UseAVX > 0 && (vector_len == Assembler::AVX_512bit || (!needs_evex(dst, nds) || VM_Version::supports_avx512vl())), ""); + assert(!needs_evex(dst, nds) || VM_Version::supports_avx512bw(), ""); + InstructionMark im(this); + InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ true); + attributes.set_address_attributes(/* tuple_type */ EVEX_FV, /* input_size_in_bits */ EVEX_NObit); + vex_prefix(src, nds->encoding(), dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); + emit_int8((unsigned char)0xE9); + emit_operand(dst, src, 0); +} + +void Assembler::vpsubusb(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) { + assert(UseAVX > 0 && (vector_len == Assembler::AVX_512bit || (!needs_evex(dst, nds, src) || VM_Version::supports_avx512vl())), ""); + assert(!needs_evex(dst, nds, src) || VM_Version::supports_avx512bw(), ""); + InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ true); + int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); + emit_int16((unsigned char)0xD8, (0xC0 | encode)); +} + +void Assembler::vpsubusb(XMMRegister dst, XMMRegister nds, Address src, int vector_len) { + assert(UseAVX > 0 && (vector_len == Assembler::AVX_512bit || (!needs_evex(dst, nds) || VM_Version::supports_avx512vl())), ""); + assert(!needs_evex(dst, nds) || VM_Version::supports_avx512bw(), ""); + InstructionMark im(this); + InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ true); + attributes.set_address_attributes(/* tuple_type */ EVEX_FV, /* input_size_in_bits */ EVEX_NObit); + vex_prefix(src, nds->encoding(), dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); + emit_int8((unsigned char)0xD8); + emit_operand(dst, src, 0); +} + +void Assembler::vpsubusw(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) { + assert(UseAVX > 0 && (vector_len == Assembler::AVX_512bit || (!needs_evex(dst, nds, src) || VM_Version::supports_avx512vl())), ""); + assert(!needs_evex(dst, nds, src) || VM_Version::supports_avx512bw(), ""); + InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ true); + int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); + emit_int16((unsigned char)0xD9, (0xC0 | encode)); +} + +void Assembler::vpsubusw(XMMRegister dst, XMMRegister nds, Address src, int vector_len) { + assert(UseAVX > 0 && (vector_len == Assembler::AVX_512bit || (!needs_evex(dst, nds) || VM_Version::supports_avx512vl())), ""); + assert(!needs_evex(dst, nds) || VM_Version::supports_avx512bw(), ""); + InstructionMark im(this); + InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ true); + attributes.set_address_attributes(/* tuple_type */ EVEX_FV, /* input_size_in_bits */ EVEX_NObit); + vex_prefix(src, nds->encoding(), dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); + emit_int8((unsigned char)0xD9); + emit_operand(dst, src, 0); +} + + void Assembler::psubb(XMMRegister dst, XMMRegister src) { NOT_LP64(assert(VM_Version::supports_sse2(), "")); InstructionAttr attributes(AVX_128bit, /* rex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ true); @@ -8382,13 +8587,6 @@ void Assembler::psubq(XMMRegister dst, XMMRegister src) { emit_int8((0xC0 | encode)); } -void Assembler::vpsubusb(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) { - assert(UseAVX > 0, "requires some form of AVX"); - InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ true); - int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); - emit_int16((unsigned char)0xD8, (0xC0 | encode)); -} - void Assembler::vpsubb(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) { assert(UseAVX > 0, "requires some form of AVX"); InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ true); @@ -8518,6 +8716,15 @@ void Assembler::vpmuludq(XMMRegister dst, XMMRegister nds, XMMRegister src, int emit_int16((unsigned char)0xF4, (0xC0 | encode)); } +void Assembler::vpmuldq(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) { + assert(vector_len == AVX_128bit ? VM_Version::supports_avx() : + (vector_len == AVX_256bit ? VM_Version::supports_avx2() : VM_Version::supports_evex()), ""); + InstructionAttr attributes(vector_len, /* vex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ true); + attributes.set_rex_vex_w_reverted(); + int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes); + emit_int16(0x28, (0xC0 | encode)); +} + void Assembler::vpmullw(XMMRegister dst, XMMRegister nds, Address src, int vector_len) { assert(UseAVX > 0, "requires some form of AVX"); InstructionMark im(this); @@ -8565,14 +8772,6 @@ void Assembler::vpminsb(XMMRegister dst, XMMRegister nds, XMMRegister src, int v emit_int16(0x38, (0xC0 | encode)); } -void Assembler::vpminub(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) { - assert(vector_len == AVX_128bit ? VM_Version::supports_avx() : - (vector_len == AVX_256bit ? VM_Version::supports_avx2() : VM_Version::supports_avx512bw()), ""); - InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ true); - int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); - emit_int16(0xDA, (0xC0 | encode)); -} - void Assembler::pminsw(XMMRegister dst, XMMRegister src) { assert(VM_Version::supports_sse2(), ""); InstructionAttr attributes(AVX_128bit, /* rex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ true); @@ -8718,66 +8917,406 @@ void Assembler::vmaxpd(XMMRegister dst, XMMRegister nds, XMMRegister src, int ve emit_int16(0x5F, (0xC0 | encode)); } -// Shift packed integers left by specified number of bits. -void Assembler::psllw(XMMRegister dst, int shift) { - NOT_LP64(assert(VM_Version::supports_sse2(), "")); - InstructionAttr attributes(AVX_128bit, /* rex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ true); - // XMM6 is for /6 encoding: 66 0F 71 /6 ib - int encode = simd_prefix_and_encode(xmm6, dst, dst, VEX_SIMD_66, VEX_OPCODE_0F, &attributes); - emit_int24(0x71, (0xC0 | encode), shift & 0xFF); -} - -void Assembler::pslld(XMMRegister dst, int shift) { - NOT_LP64(assert(VM_Version::supports_sse2(), "")); - InstructionAttr attributes(AVX_128bit, /* rex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ true); - // XMM6 is for /6 encoding: 66 0F 72 /6 ib - int encode = simd_prefix_and_encode(xmm6, dst, dst, VEX_SIMD_66, VEX_OPCODE_0F, &attributes); - emit_int24(0x72, (0xC0 | encode), shift & 0xFF); +void Assembler::vpminub(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) { + assert(UseAVX > 0 && (vector_len == Assembler::AVX_512bit || (!needs_evex(dst, nds, src) || VM_Version::supports_avx512vl())), ""); + assert(!needs_evex(dst, nds, src) || VM_Version::supports_avx512bw(), ""); + InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ true); + int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); + emit_int16((unsigned char)0xDA, (0xC0 | encode)); } -void Assembler::psllq(XMMRegister dst, int shift) { - NOT_LP64(assert(VM_Version::supports_sse2(), "")); - InstructionAttr attributes(AVX_128bit, /* rex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ true); - // XMM6 is for /6 encoding: 66 0F 73 /6 ib - int encode = simd_prefix_and_encode(xmm6, dst, dst, VEX_SIMD_66, VEX_OPCODE_0F, &attributes); - emit_int24(0x73, (0xC0 | encode), shift & 0xFF); +void Assembler::vpminub(XMMRegister dst, XMMRegister nds, Address src, int vector_len) { + assert(UseAVX > 0 && (vector_len == Assembler::AVX_512bit || (!needs_evex(dst, nds) || VM_Version::supports_avx512vl())), ""); + assert(!needs_evex(dst, nds) || VM_Version::supports_avx512bw(), ""); + InstructionMark im(this); + InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ true); + attributes.set_address_attributes(/* tuple_type */ EVEX_FV, /* input_size_in_bits */ EVEX_NObit); + vex_prefix(src, nds->encoding(), dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); + emit_int8((unsigned char)0xDA); + emit_operand(dst, src, 0); } -void Assembler::psllw(XMMRegister dst, XMMRegister shift) { - NOT_LP64(assert(VM_Version::supports_sse2(), "")); - InstructionAttr attributes(AVX_128bit, /* rex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ true); - int encode = simd_prefix_and_encode(dst, dst, shift, VEX_SIMD_66, VEX_OPCODE_0F, &attributes); - emit_int16((unsigned char)0xF1, (0xC0 | encode)); +void Assembler::evpminub(XMMRegister dst, KRegister mask, XMMRegister nds, XMMRegister src, bool merge, int vector_len) { + assert(VM_Version::supports_avx512bw() && (vector_len == AVX_512bit || VM_Version::supports_avx512vl()), ""); + InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true); + attributes.set_is_evex_instruction(); + attributes.set_embedded_opmask_register_specifier(mask); + if (merge) { + attributes.reset_is_clear_context(); + } + int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); + emit_int16((unsigned char)0xDA, (0xC0 | encode)); } -void Assembler::pslld(XMMRegister dst, XMMRegister shift) { - NOT_LP64(assert(VM_Version::supports_sse2(), "")); - InstructionAttr attributes(AVX_128bit, /* rex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ true); - int encode = simd_prefix_and_encode(dst, dst, shift, VEX_SIMD_66, VEX_OPCODE_0F, &attributes); - emit_int16((unsigned char)0xF2, (0xC0 | encode)); +void Assembler::evpminub(XMMRegister dst, KRegister mask, XMMRegister nds, Address src, bool merge, int vector_len) { + assert(VM_Version::supports_avx512bw() && (vector_len == AVX_512bit || VM_Version::supports_avx512vl()), ""); + InstructionMark im(this); + InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true); + attributes.set_is_evex_instruction(); + attributes.set_address_attributes(/* tuple_type */ EVEX_FV, /* input_size_in_bits */ EVEX_NObit); + attributes.set_embedded_opmask_register_specifier(mask); + if (merge) { + attributes.reset_is_clear_context(); + } + vex_prefix(src, nds->encoding(), dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); + emit_int8((unsigned char)0xDA); + emit_operand(dst, src, 0); } -void Assembler::psllq(XMMRegister dst, XMMRegister shift) { - NOT_LP64(assert(VM_Version::supports_sse2(), "")); - InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ true); - attributes.set_rex_vex_w_reverted(); - int encode = simd_prefix_and_encode(dst, dst, shift, VEX_SIMD_66, VEX_OPCODE_0F, &attributes); - emit_int16((unsigned char)0xF3, (0xC0 | encode)); +void Assembler::vpminuw(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) { + assert(UseAVX > 0 && (vector_len == Assembler::AVX_512bit || (!needs_evex(dst, nds, src) || VM_Version::supports_avx512vl())), ""); + assert(!needs_evex(dst, nds) || VM_Version::supports_avx512bw(), ""); + InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ true); + int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes); + emit_int16(0x3A, (0xC0 | encode)); } -void Assembler::vpsllw(XMMRegister dst, XMMRegister src, int shift, int vector_len) { - assert(UseAVX > 0, "requires some form of AVX"); +void Assembler::vpminuw(XMMRegister dst, XMMRegister nds, Address src, int vector_len) { + assert(UseAVX > 0 && (vector_len == Assembler::AVX_512bit || (!needs_evex(dst, nds) || VM_Version::supports_avx512vl())), ""); + assert(!needs_evex(dst, nds) || VM_Version::supports_avx512bw(), ""); + InstructionMark im(this); InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ true); - // XMM6 is for /6 encoding: 66 0F 71 /6 ib - int encode = vex_prefix_and_encode(xmm6->encoding(), dst->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); - emit_int24(0x71, (0xC0 | encode), shift & 0xFF); + attributes.set_address_attributes(/* tuple_type */ EVEX_FV, /* input_size_in_bits */ EVEX_NObit); + vex_prefix(src, nds->encoding(), dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes); + emit_int8((unsigned char)0x3A); + emit_operand(dst, src, 0); } -void Assembler::vpslld(XMMRegister dst, XMMRegister src, int shift, int vector_len) { - assert(UseAVX > 0, "requires some form of AVX"); - NOT_LP64(assert(VM_Version::supports_sse2(), "")); - InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ true); - // XMM6 is for /6 encoding: 66 0F 72 /6 ib +void Assembler::evpminuw(XMMRegister dst, KRegister mask, XMMRegister nds, XMMRegister src, bool merge, int vector_len) { + assert(VM_Version::supports_avx512bw() && (vector_len == AVX_512bit || VM_Version::supports_avx512vl()), ""); + InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true); + attributes.set_is_evex_instruction(); + attributes.set_embedded_opmask_register_specifier(mask); + if (merge) { + attributes.reset_is_clear_context(); + } + int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes); + emit_int16(0x3A, (0xC0 | encode)); +} + +void Assembler::evpminuw(XMMRegister dst, KRegister mask, XMMRegister nds, Address src, bool merge, int vector_len) { + assert(VM_Version::supports_avx512bw() && (vector_len == AVX_512bit || VM_Version::supports_avx512vl()), ""); + InstructionMark im(this); + InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true); + attributes.set_is_evex_instruction(); + attributes.set_address_attributes(/* tuple_type */ EVEX_FV, /* input_size_in_bits */ EVEX_NObit); + attributes.set_embedded_opmask_register_specifier(mask); + if (merge) { + attributes.reset_is_clear_context(); + } + vex_prefix(src, nds->encoding(), dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes); + emit_int8(0x3A); + emit_operand(dst, src, 0); +} + +void Assembler::vpminud(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) { + assert(UseAVX > 0 && (vector_len == Assembler::AVX_512bit || (!needs_evex(dst, nds, src) || VM_Version::supports_avx512vl())), ""); + InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ true); + int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes); + emit_int16(0x3B, (0xC0 | encode)); +} + +void Assembler::vpminud(XMMRegister dst, XMMRegister nds, Address src, int vector_len) { + assert(UseAVX > 0 && (vector_len == Assembler::AVX_512bit || (!needs_evex(dst, nds) || VM_Version::supports_avx512vl())), ""); + InstructionMark im(this); + InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ true); + attributes.set_address_attributes(/* tuple_type */ EVEX_FV, /* input_size_in_bits */ EVEX_NObit); + vex_prefix(src, nds->encoding(), dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes); + emit_int8((unsigned char)0x3B); + emit_operand(dst, src, 0); +} + +void Assembler::evpminud(XMMRegister dst, KRegister mask, XMMRegister nds, XMMRegister src, bool merge, int vector_len) { + assert(VM_Version::supports_evex(), ""); + assert(vector_len == AVX_512bit || VM_Version::supports_avx512vl(), ""); + InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true); + attributes.set_is_evex_instruction(); + attributes.set_embedded_opmask_register_specifier(mask); + if (merge) { + attributes.reset_is_clear_context(); + } + int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes); + emit_int16(0x3B, (0xC0 | encode)); +} + +void Assembler::evpminud(XMMRegister dst, KRegister mask, XMMRegister nds, Address src, bool merge, int vector_len) { + assert(VM_Version::supports_evex(), ""); + assert(vector_len == AVX_512bit || VM_Version::supports_avx512vl(), ""); + InstructionMark im(this); + InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true); + attributes.set_address_attributes(/* tuple_type */ EVEX_FV, /* input_size_in_bits */ EVEX_NObit); + attributes.set_is_evex_instruction(); + attributes.set_embedded_opmask_register_specifier(mask); + if (merge) { + attributes.reset_is_clear_context(); + } + vex_prefix(src, nds->encoding(), dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes); + emit_int8(0x3B); + emit_operand(dst, src, 0); +} + +void Assembler::evpminuq(XMMRegister dst, KRegister mask, XMMRegister nds, XMMRegister src, bool merge, int vector_len) { + assert(VM_Version::supports_evex(), ""); + assert(vector_len == AVX_512bit || VM_Version::supports_avx512vl(), ""); + InstructionAttr attributes(vector_len, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true); + attributes.set_is_evex_instruction(); + attributes.set_embedded_opmask_register_specifier(mask); + if (merge) { + attributes.reset_is_clear_context(); + } + int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes); + emit_int16(0x3B, (0xC0 | encode)); +} + +void Assembler::evpminuq(XMMRegister dst, KRegister mask, XMMRegister nds, Address src, bool merge, int vector_len) { + assert(VM_Version::supports_evex(), ""); + assert(vector_len == AVX_512bit || VM_Version::supports_avx512vl(), ""); + InstructionMark im(this); + InstructionAttr attributes(vector_len, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true); + attributes.set_is_evex_instruction(); + attributes.set_address_attributes(/* tuple_type */ EVEX_FV, /* input_size_in_bits */ EVEX_NObit); + attributes.set_embedded_opmask_register_specifier(mask); + if (merge) { + attributes.reset_is_clear_context(); + } + vex_prefix(src, nds->encoding(), dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes); + emit_int8(0x3B); + emit_operand(dst, src, 0); +} + +void Assembler::vpmaxub(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) { + assert(vector_len == AVX_128bit ? VM_Version::supports_avx() : + (vector_len == AVX_256bit ? VM_Version::supports_avx2() : VM_Version::supports_avx512bw()), ""); + assert(UseAVX > 0 && (vector_len == Assembler::AVX_512bit || (!needs_evex(dst, nds, src) || VM_Version::supports_avx512vl())), ""); + InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ true); + int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); + emit_int16((unsigned char)0xDE, (0xC0 | encode)); +} + +void Assembler::vpmaxub(XMMRegister dst, XMMRegister nds, Address src, int vector_len) { + assert(vector_len == AVX_128bit ? VM_Version::supports_avx() : + (vector_len == AVX_256bit ? VM_Version::supports_avx2() : VM_Version::supports_avx512bw()), ""); + assert(UseAVX > 0 && (vector_len == Assembler::AVX_512bit || (!needs_evex(dst, nds) || VM_Version::supports_avx512vl())), ""); + InstructionMark im(this); + InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ true); + attributes.set_address_attributes(/* tuple_type */ EVEX_FV, /* input_size_in_bits */ EVEX_NObit); + vex_prefix(src, nds->encoding(), dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); + emit_int8((unsigned char)0xDE); + emit_operand(dst, src, 0); +} + +void Assembler::evpmaxub(XMMRegister dst, KRegister mask, XMMRegister nds, XMMRegister src, bool merge, int vector_len) { + assert(VM_Version::supports_avx512bw() && (vector_len == AVX_512bit || VM_Version::supports_avx512vl()), ""); + InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true); + attributes.set_is_evex_instruction(); + attributes.set_embedded_opmask_register_specifier(mask); + if (merge) { + attributes.reset_is_clear_context(); + } + int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); + emit_int16((unsigned char)0xDE, (0xC0 | encode)); +} + +void Assembler::evpmaxub(XMMRegister dst, KRegister mask, XMMRegister nds, Address src, bool merge, int vector_len) { + assert(VM_Version::supports_avx512bw() && (vector_len == AVX_512bit || VM_Version::supports_avx512vl()), ""); + InstructionMark im(this); + InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true); + attributes.set_is_evex_instruction(); + attributes.set_address_attributes(/* tuple_type */ EVEX_FV, /* input_size_in_bits */ EVEX_NObit); + attributes.set_embedded_opmask_register_specifier(mask); + if (merge) { + attributes.reset_is_clear_context(); + } + vex_prefix(src, nds->encoding(), dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); + emit_int8((unsigned char)0xDE); + emit_operand(dst, src, 0); +} + +void Assembler::vpmaxuw(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) { + assert(vector_len == AVX_128bit ? VM_Version::supports_avx() : + (vector_len == AVX_256bit ? VM_Version::supports_avx2() : VM_Version::supports_avx512bw()), ""); + assert(UseAVX > 0 && (vector_len == Assembler::AVX_512bit || (!needs_evex(dst, nds, src) || VM_Version::supports_avx512vl())), ""); + InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ true); + int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes); + emit_int16(0x3E, (0xC0 | encode)); +} + +void Assembler::vpmaxuw(XMMRegister dst, XMMRegister nds, Address src, int vector_len) { + assert(vector_len == AVX_128bit ? VM_Version::supports_avx() : + (vector_len == AVX_256bit ? VM_Version::supports_avx2() : VM_Version::supports_avx512bw()), ""); + assert(UseAVX > 0 && (vector_len == Assembler::AVX_512bit || (!needs_evex(dst, nds) || VM_Version::supports_avx512vl())), ""); + InstructionMark im(this); + InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ true); + attributes.set_address_attributes(/* tuple_type */ EVEX_FV, /* input_size_in_bits */ EVEX_NObit); + vex_prefix(src, nds->encoding(), dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes); + emit_int8((unsigned char)0x3E); + emit_operand(dst, src, 0); +} + +void Assembler::evpmaxuw(XMMRegister dst, KRegister mask, XMMRegister nds, XMMRegister src, bool merge, int vector_len) { + assert(VM_Version::supports_avx512bw() && (vector_len == AVX_512bit || VM_Version::supports_avx512vl()), ""); + InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true); + attributes.set_is_evex_instruction(); + attributes.set_embedded_opmask_register_specifier(mask); + if (merge) { + attributes.reset_is_clear_context(); + } + int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes); + emit_int16(0x3E, (0xC0 | encode)); +} + +void Assembler::evpmaxuw(XMMRegister dst, KRegister mask, XMMRegister nds, Address src, bool merge, int vector_len) { + assert(VM_Version::supports_avx512bw() && (vector_len == AVX_512bit || VM_Version::supports_avx512vl()), ""); + InstructionMark im(this); + InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true); + attributes.set_is_evex_instruction(); + attributes.set_address_attributes(/* tuple_type */ EVEX_FV, /* input_size_in_bits */ EVEX_NObit); + attributes.set_embedded_opmask_register_specifier(mask); + if (merge) { + attributes.reset_is_clear_context(); + } + vex_prefix(src, nds->encoding(), dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes); + emit_int8(0x3E); + emit_operand(dst, src, 0); +} + +void Assembler::vpmaxud(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) { + assert(UseAVX > 0, ""); + assert((vector_len == Assembler::AVX_512bit || (!needs_evex(dst, nds, src) || VM_Version::supports_avx512vl())), ""); + InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ true); + int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes); + emit_int16(0x3F, (0xC0 | encode)); +} + +void Assembler::vpmaxud(XMMRegister dst, XMMRegister nds, Address src, int vector_len) { + assert(UseAVX > 0, ""); + assert((vector_len == Assembler::AVX_512bit || (!needs_evex(dst, nds) || VM_Version::supports_avx512vl())), ""); + InstructionMark im(this); + InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ true); + attributes.set_address_attributes(/* tuple_type */ EVEX_FV, /* input_size_in_bits */ EVEX_NObit); + vex_prefix(src, nds->encoding(), dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes); + emit_int8((unsigned char)0x3F); + emit_operand(dst, src, 0); +} + +void Assembler::evpmaxud(XMMRegister dst, KRegister mask, XMMRegister nds, XMMRegister src, bool merge, int vector_len) { + assert(VM_Version::supports_evex(), ""); + assert(vector_len == AVX_512bit || VM_Version::supports_avx512vl(), ""); + InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true); + attributes.set_is_evex_instruction(); + attributes.set_embedded_opmask_register_specifier(mask); + if (merge) { + attributes.reset_is_clear_context(); + } + int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes); + emit_int16(0x3F, (0xC0 | encode)); +} + +void Assembler::evpmaxud(XMMRegister dst, KRegister mask, XMMRegister nds, Address src, bool merge, int vector_len) { + assert(VM_Version::supports_evex(), ""); + assert(vector_len == AVX_512bit || VM_Version::supports_avx512vl(), ""); + InstructionMark im(this); + InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true); + attributes.set_is_evex_instruction(); + attributes.set_address_attributes(/* tuple_type */ EVEX_FV, /* input_size_in_bits */ EVEX_NObit); + attributes.set_embedded_opmask_register_specifier(mask); + if (merge) { + attributes.reset_is_clear_context(); + } + vex_prefix(src, nds->encoding(), dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes); + emit_int8(0x3F); + emit_operand(dst, src, 0); +} + +void Assembler::evpmaxuq(XMMRegister dst, KRegister mask, XMMRegister nds, XMMRegister src, bool merge, int vector_len) { + assert(VM_Version::supports_evex(), ""); + assert(vector_len == AVX_512bit || VM_Version::supports_avx512vl(), ""); + InstructionAttr attributes(vector_len, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true); + attributes.set_is_evex_instruction(); + attributes.set_embedded_opmask_register_specifier(mask); + if (merge) { + attributes.reset_is_clear_context(); + } + int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes); + emit_int16(0x3F, (0xC0 | encode)); +} + +void Assembler::evpmaxuq(XMMRegister dst, KRegister mask, XMMRegister nds, Address src, bool merge, int vector_len) { + assert(VM_Version::supports_evex(), ""); + assert(vector_len == AVX_512bit || VM_Version::supports_avx512vl(), ""); + InstructionMark im(this); + InstructionAttr attributes(vector_len, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ false, /* uses_vl */ true); + attributes.set_is_evex_instruction(); + attributes.set_address_attributes(/* tuple_type */ EVEX_FV, /* input_size_in_bits */ EVEX_NObit); + attributes.set_embedded_opmask_register_specifier(mask); + if (merge) { + attributes.reset_is_clear_context(); + } + vex_prefix(src, nds->encoding(), dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes); + emit_int8(0x3F); + emit_operand(dst, src, 0); +} + +// Shift packed integers left by specified number of bits. +void Assembler::psllw(XMMRegister dst, int shift) { + NOT_LP64(assert(VM_Version::supports_sse2(), "")); + InstructionAttr attributes(AVX_128bit, /* rex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ true); + // XMM6 is for /6 encoding: 66 0F 71 /6 ib + int encode = simd_prefix_and_encode(xmm6, dst, dst, VEX_SIMD_66, VEX_OPCODE_0F, &attributes); + emit_int24(0x71, (0xC0 | encode), shift & 0xFF); +} + +void Assembler::pslld(XMMRegister dst, int shift) { + NOT_LP64(assert(VM_Version::supports_sse2(), "")); + InstructionAttr attributes(AVX_128bit, /* rex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ true); + // XMM6 is for /6 encoding: 66 0F 72 /6 ib + int encode = simd_prefix_and_encode(xmm6, dst, dst, VEX_SIMD_66, VEX_OPCODE_0F, &attributes); + emit_int24(0x72, (0xC0 | encode), shift & 0xFF); +} + +void Assembler::psllq(XMMRegister dst, int shift) { + NOT_LP64(assert(VM_Version::supports_sse2(), "")); + InstructionAttr attributes(AVX_128bit, /* rex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ true); + // XMM6 is for /6 encoding: 66 0F 73 /6 ib + int encode = simd_prefix_and_encode(xmm6, dst, dst, VEX_SIMD_66, VEX_OPCODE_0F, &attributes); + emit_int24(0x73, (0xC0 | encode), shift & 0xFF); +} + +void Assembler::psllw(XMMRegister dst, XMMRegister shift) { + NOT_LP64(assert(VM_Version::supports_sse2(), "")); + InstructionAttr attributes(AVX_128bit, /* rex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ true); + int encode = simd_prefix_and_encode(dst, dst, shift, VEX_SIMD_66, VEX_OPCODE_0F, &attributes); + emit_int16((unsigned char)0xF1, (0xC0 | encode)); +} + +void Assembler::pslld(XMMRegister dst, XMMRegister shift) { + NOT_LP64(assert(VM_Version::supports_sse2(), "")); + InstructionAttr attributes(AVX_128bit, /* rex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ true); + int encode = simd_prefix_and_encode(dst, dst, shift, VEX_SIMD_66, VEX_OPCODE_0F, &attributes); + emit_int16((unsigned char)0xF2, (0xC0 | encode)); +} + +void Assembler::psllq(XMMRegister dst, XMMRegister shift) { + NOT_LP64(assert(VM_Version::supports_sse2(), "")); + InstructionAttr attributes(AVX_128bit, /* rex_w */ VM_Version::supports_evex(), /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ true); + attributes.set_rex_vex_w_reverted(); + int encode = simd_prefix_and_encode(dst, dst, shift, VEX_SIMD_66, VEX_OPCODE_0F, &attributes); + emit_int16((unsigned char)0xF3, (0xC0 | encode)); +} + +void Assembler::vpsllw(XMMRegister dst, XMMRegister src, int shift, int vector_len) { + assert(UseAVX > 0, "requires some form of AVX"); + InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ _legacy_mode_bw, /* no_mask_reg */ true, /* uses_vl */ true); + // XMM6 is for /6 encoding: 66 0F 71 /6 ib + int encode = vex_prefix_and_encode(xmm6->encoding(), dst->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); + emit_int24(0x71, (0xC0 | encode), shift & 0xFF); +} + +void Assembler::vpslld(XMMRegister dst, XMMRegister src, int shift, int vector_len) { + assert(UseAVX > 0, "requires some form of AVX"); + NOT_LP64(assert(VM_Version::supports_sse2(), "")); + InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ true); + // XMM6 is for /6 encoding: 66 0F 72 /6 ib int encode = vex_prefix_and_encode(xmm6->encoding(), dst->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); emit_int24(0x72, (0xC0 | encode), shift & 0xFF); } @@ -10421,6 +10960,223 @@ void Assembler::evsubpd(XMMRegister dst, KRegister mask, XMMRegister nds, Addres emit_operand(dst, src, 0); } +void Assembler::evpaddsb(XMMRegister dst, KRegister mask, XMMRegister nds, XMMRegister src, bool merge, int vector_len) { + assert(VM_Version::supports_avx512bw() && (vector_len == AVX_512bit || VM_Version::supports_avx512vl()), ""); + InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ false,/* uses_vl */ true); + attributes.set_is_evex_instruction(); + attributes.set_embedded_opmask_register_specifier(mask); + if (merge) { + attributes.reset_is_clear_context(); + } + int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); + emit_int16((unsigned char)0xEC, (0xC0 | encode)); +} + +void Assembler::evpaddsb(XMMRegister dst, KRegister mask, XMMRegister nds, Address src, bool merge, int vector_len) { + InstructionMark im(this); + assert(VM_Version::supports_avx512bw() && (vector_len == AVX_512bit || VM_Version::supports_avx512vl()), ""); + InstructionAttr attributes(vector_len, /* vex_w */ false,/* legacy_mode */ false, /* no_mask_reg */ false,/* uses_vl */ true); + attributes.set_address_attributes(/* tuple_type */ EVEX_FV,/* input_size_in_bits */ EVEX_NObit); + attributes.set_is_evex_instruction(); + attributes.set_embedded_opmask_register_specifier(mask); + if (merge) { + attributes.reset_is_clear_context(); + } + vex_prefix(src, nds->encoding(), dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); + emit_int8((unsigned char)0xEC); + emit_operand(dst, src, 0); +} + +void Assembler::evpaddsw(XMMRegister dst, KRegister mask, XMMRegister nds, XMMRegister src, bool merge, int vector_len) { + assert(VM_Version::supports_avx512bw() && (vector_len == AVX_512bit || VM_Version::supports_avx512vl()), ""); + InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ false,/* uses_vl */ true); + attributes.set_is_evex_instruction(); + attributes.set_embedded_opmask_register_specifier(mask); + if (merge) { + attributes.reset_is_clear_context(); + } + int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); + emit_int16((unsigned char)0xED, (0xC0 | encode)); +} + +void Assembler::evpaddsw(XMMRegister dst, KRegister mask, XMMRegister nds, Address src, bool merge, int vector_len) { + InstructionMark im(this); + assert(VM_Version::supports_avx512bw() && (vector_len == AVX_512bit || VM_Version::supports_avx512vl()), ""); + InstructionAttr attributes(vector_len, /* vex_w */ false,/* legacy_mode */ false, /* no_mask_reg */ false,/* uses_vl */ true); + attributes.set_address_attributes(/* tuple_type */ EVEX_FV,/* input_size_in_bits */ EVEX_NObit); + attributes.set_is_evex_instruction(); + attributes.set_embedded_opmask_register_specifier(mask); + if (merge) { + attributes.reset_is_clear_context(); + } + vex_prefix(src, nds->encoding(), dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); + emit_int8((unsigned char)0xED); + emit_operand(dst, src, 0); +} + +void Assembler::evpaddusb(XMMRegister dst, KRegister mask, XMMRegister nds, XMMRegister src, bool merge, int vector_len) { + assert(VM_Version::supports_avx512bw() && (vector_len == AVX_512bit || VM_Version::supports_avx512vl()), ""); + InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ false,/* uses_vl */ true); + attributes.set_is_evex_instruction(); + attributes.set_embedded_opmask_register_specifier(mask); + if (merge) { + attributes.reset_is_clear_context(); + } + int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); + emit_int16((unsigned char)0xDC, (0xC0 | encode)); +} + +void Assembler::evpaddusb(XMMRegister dst, KRegister mask, XMMRegister nds, Address src, bool merge, int vector_len) { + InstructionMark im(this); + assert(VM_Version::supports_avx512bw() && (vector_len == AVX_512bit || VM_Version::supports_avx512vl()), ""); + InstructionAttr attributes(vector_len, /* vex_w */ false,/* legacy_mode */ false, /* no_mask_reg */ false,/* uses_vl */ true); + attributes.set_address_attributes(/* tuple_type */ EVEX_FV,/* input_size_in_bits */ EVEX_NObit); + attributes.set_is_evex_instruction(); + attributes.set_embedded_opmask_register_specifier(mask); + if (merge) { + attributes.reset_is_clear_context(); + } + vex_prefix(src, nds->encoding(), dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); + emit_int8((unsigned char)0xDC); + emit_operand(dst, src, 0); +} + +void Assembler::evpaddusw(XMMRegister dst, KRegister mask, XMMRegister nds, XMMRegister src, bool merge, int vector_len) { + assert(VM_Version::supports_avx512bw() && (vector_len == AVX_512bit || VM_Version::supports_avx512vl()), ""); + InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ false,/* uses_vl */ true); + attributes.set_is_evex_instruction(); + attributes.set_embedded_opmask_register_specifier(mask); + if (merge) { + attributes.reset_is_clear_context(); + } + int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); + emit_int16((unsigned char)0xDD, (0xC0 | encode)); +} + +void Assembler::evpaddusw(XMMRegister dst, KRegister mask, XMMRegister nds, Address src, bool merge, int vector_len) { + InstructionMark im(this); + assert(VM_Version::supports_avx512bw() && (vector_len == AVX_512bit || VM_Version::supports_avx512vl()), ""); + InstructionAttr attributes(vector_len, /* vex_w */ false,/* legacy_mode */ false, /* no_mask_reg */ false,/* uses_vl */ true); + attributes.set_address_attributes(/* tuple_type */ EVEX_FV,/* input_size_in_bits */ EVEX_NObit); + attributes.set_is_evex_instruction(); + attributes.set_embedded_opmask_register_specifier(mask); + if (merge) { + attributes.reset_is_clear_context(); + } + vex_prefix(src, nds->encoding(), dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); + emit_int8((unsigned char)0xDD); + emit_operand(dst, src, 0); +} + +void Assembler::evpsubsb(XMMRegister dst, KRegister mask, XMMRegister nds, XMMRegister src, bool merge, int vector_len) { + assert(VM_Version::supports_avx512bw() && (vector_len == AVX_512bit || VM_Version::supports_avx512vl()), ""); + InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ false,/* uses_vl */ true); + attributes.set_is_evex_instruction(); + attributes.set_embedded_opmask_register_specifier(mask); + if (merge) { + attributes.reset_is_clear_context(); + } + int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); + emit_int16((unsigned char)0xE8, (0xC0 | encode)); +} + +void Assembler::evpsubsb(XMMRegister dst, KRegister mask, XMMRegister nds, Address src, bool merge, int vector_len) { + InstructionMark im(this); + assert(VM_Version::supports_avx512bw() && (vector_len == AVX_512bit || VM_Version::supports_avx512vl()), ""); + InstructionAttr attributes(vector_len, /* vex_w */ false,/* legacy_mode */ false, /* no_mask_reg */ false,/* uses_vl */ true); + attributes.set_address_attributes(/* tuple_type */ EVEX_FV,/* input_size_in_bits */ EVEX_NObit); + attributes.set_is_evex_instruction(); + attributes.set_embedded_opmask_register_specifier(mask); + if (merge) { + attributes.reset_is_clear_context(); + } + vex_prefix(src, nds->encoding(), dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); + emit_int8((unsigned char)0xE8); + emit_operand(dst, src, 0); +} + +void Assembler::evpsubsw(XMMRegister dst, KRegister mask, XMMRegister nds, XMMRegister src, bool merge, int vector_len) { + assert(VM_Version::supports_avx512bw() && (vector_len == AVX_512bit || VM_Version::supports_avx512vl()), ""); + InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ false,/* uses_vl */ true); + attributes.set_is_evex_instruction(); + attributes.set_embedded_opmask_register_specifier(mask); + if (merge) { + attributes.reset_is_clear_context(); + } + int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); + emit_int16((unsigned char)0xE9, (0xC0 | encode)); +} + +void Assembler::evpsubsw(XMMRegister dst, KRegister mask, XMMRegister nds, Address src, bool merge, int vector_len) { + InstructionMark im(this); + assert(VM_Version::supports_avx512bw() && (vector_len == AVX_512bit || VM_Version::supports_avx512vl()), ""); + InstructionAttr attributes(vector_len, /* vex_w */ false,/* legacy_mode */ false, /* no_mask_reg */ false,/* uses_vl */ true); + attributes.set_address_attributes(/* tuple_type */ EVEX_FV,/* input_size_in_bits */ EVEX_NObit); + attributes.set_is_evex_instruction(); + attributes.set_embedded_opmask_register_specifier(mask); + if (merge) { + attributes.reset_is_clear_context(); + } + vex_prefix(src, nds->encoding(), dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); + emit_int8((unsigned char)0xE9); + emit_operand(dst, src, 0); +} + +void Assembler::evpsubusb(XMMRegister dst, KRegister mask, XMMRegister nds, XMMRegister src, bool merge, int vector_len) { + assert(VM_Version::supports_avx512bw() && (vector_len == AVX_512bit || VM_Version::supports_avx512vl()), ""); + InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ false,/* uses_vl */ true); + attributes.set_is_evex_instruction(); + attributes.set_embedded_opmask_register_specifier(mask); + if (merge) { + attributes.reset_is_clear_context(); + } + int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); + emit_int16((unsigned char)0xD8, (0xC0 | encode)); +} + +void Assembler::evpsubusb(XMMRegister dst, KRegister mask, XMMRegister nds, Address src, bool merge, int vector_len) { + InstructionMark im(this); + assert(VM_Version::supports_avx512bw() && (vector_len == AVX_512bit || VM_Version::supports_avx512vl()), ""); + InstructionAttr attributes(vector_len, /* vex_w */ false,/* legacy_mode */ false, /* no_mask_reg */ false,/* uses_vl */ true); + attributes.set_address_attributes(/* tuple_type */ EVEX_FV,/* input_size_in_bits */ EVEX_NObit); + attributes.set_is_evex_instruction(); + attributes.set_embedded_opmask_register_specifier(mask); + if (merge) { + attributes.reset_is_clear_context(); + } + vex_prefix(src, nds->encoding(), dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); + emit_int8((unsigned char)0xD8); + emit_operand(dst, src, 0); +} + +void Assembler::evpsubusw(XMMRegister dst, KRegister mask, XMMRegister nds, XMMRegister src, bool merge, int vector_len) { + assert(VM_Version::supports_avx512bw() && (vector_len == AVX_512bit || VM_Version::supports_avx512vl()), ""); + InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ false,/* uses_vl */ true); + attributes.set_is_evex_instruction(); + attributes.set_embedded_opmask_register_specifier(mask); + if (merge) { + attributes.reset_is_clear_context(); + } + int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); + emit_int16((unsigned char)0xD9, (0xC0 | encode)); +} + + +void Assembler::evpsubusw(XMMRegister dst, KRegister mask, XMMRegister nds, Address src, bool merge, int vector_len) { + InstructionMark im(this); + assert(VM_Version::supports_avx512bw() && (vector_len == AVX_512bit || VM_Version::supports_avx512vl()), ""); + InstructionAttr attributes(vector_len, /* vex_w */ false,/* legacy_mode */ false, /* no_mask_reg */ false,/* uses_vl */ true); + attributes.set_address_attributes(/* tuple_type */ EVEX_FV,/* input_size_in_bits */ EVEX_NObit); + attributes.set_is_evex_instruction(); + attributes.set_embedded_opmask_register_specifier(mask); + if (merge) { + attributes.reset_is_clear_context(); + } + vex_prefix(src, nds->encoding(), dst->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); + emit_int8((unsigned char)0xD9); + emit_operand(dst, src, 0); +} + void Assembler::evpmullw(XMMRegister dst, KRegister mask, XMMRegister nds, XMMRegister src, bool merge, int vector_len) { assert(VM_Version::supports_avx512bw() && (vector_len == AVX_512bit || VM_Version::supports_avx512vl()), ""); InstructionAttr attributes(vector_len, /* vex_w */ false,/* legacy_mode */ false, /* no_mask_reg */ false,/* uses_vl */ true); @@ -10504,6 +11260,18 @@ void Assembler::evpmullq(XMMRegister dst, KRegister mask, XMMRegister nds, Addre emit_operand(dst, src, 0); } +void Assembler::evpmulhw(XMMRegister dst, KRegister mask, XMMRegister nds, XMMRegister src, bool merge, int vector_len) { + assert(VM_Version::supports_avx512bw() && (vector_len == AVX_512bit || VM_Version::supports_avx512vl()), ""); + InstructionAttr attributes(vector_len, /* vex_w */ false,/* legacy_mode */ false, /* no_mask_reg */ false,/* uses_vl */ true); + attributes.set_is_evex_instruction(); + attributes.set_embedded_opmask_register_specifier(mask); + if (merge) { + attributes.reset_is_clear_context(); + } + int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F, &attributes); + emit_int16((unsigned char)0xE5, (0xC0 | encode)); +} + void Assembler::evmulps(XMMRegister dst, KRegister mask, XMMRegister nds, XMMRegister src, bool merge, int vector_len) { assert(VM_Version::supports_evex(), ""); assert(vector_len == AVX_512bit || VM_Version::supports_avx512vl(), ""); @@ -16172,3 +16940,28 @@ void Assembler::evpermt2b(XMMRegister dst, XMMRegister nds, XMMRegister src, int int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes); emit_int16(0x7D, (0xC0 | encode)); } + +void Assembler::evpermt2w(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) { + assert(vector_len <= AVX_256bit ? VM_Version::supports_avx512vlbw() : VM_Version::supports_avx512bw(), ""); + InstructionAttr attributes(vector_len, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ true); + attributes.set_is_evex_instruction(); + int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes); + emit_int16(0x7D, (0xC0 | encode)); +} + +void Assembler::evpermt2d(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) { + assert(VM_Version::supports_evex() && (vector_len == Assembler::AVX_512bit || VM_Version::supports_avx512vl()), ""); + InstructionAttr attributes(vector_len, /* vex_w */ false, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ true); + attributes.set_is_evex_instruction(); + int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes); + emit_int16(0x7E, (0xC0 | encode)); +} + +void Assembler::evpermt2q(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) { + assert(VM_Version::supports_evex() && (vector_len == Assembler::AVX_512bit || VM_Version::supports_avx512vl()), ""); + InstructionAttr attributes(vector_len, /* vex_w */ true, /* legacy_mode */ false, /* no_mask_reg */ true, /* uses_vl */ true); + attributes.set_is_evex_instruction(); + int encode = vex_prefix_and_encode(dst->encoding(), nds->encoding(), src->encoding(), VEX_SIMD_66, VEX_OPCODE_0F_38, &attributes); + emit_int16(0x7E, (0xC0 | encode)); +} + diff --git a/src/hotspot/cpu/x86/assembler_x86.hpp b/src/hotspot/cpu/x86/assembler_x86.hpp index 36dfafc8b5d..420c28254d5 100644 --- a/src/hotspot/cpu/x86/assembler_x86.hpp +++ b/src/hotspot/cpu/x86/assembler_x86.hpp @@ -780,6 +780,7 @@ class Assembler : public AbstractAssembler { bool needs_eevex(Register reg1, Register reg2 = noreg, Register reg3 = noreg); bool needs_eevex(int enc1, int enc2 = -1, int enc3 = -1); + NOT_PRODUCT(bool needs_evex(XMMRegister reg1, XMMRegister reg2 = xnoreg, XMMRegister reg3 = xnoreg);) void rex_prefix(Address adr, XMMRegister xreg, VexSimdPrefix pre, VexOpcode opc, bool rex_w); @@ -1756,6 +1757,7 @@ class Assembler : public AbstractAssembler { void evmovdqub(XMMRegister dst, KRegister mask, Address src, bool merge, int vector_len); void evmovdqub(Address dst, KRegister mask, XMMRegister src, bool merge, int vector_len); + void evmovdquw(XMMRegister dst, XMMRegister src, int vector_len); void evmovdquw(XMMRegister dst, Address src, int vector_len); void evmovdquw(Address dst, XMMRegister src, int vector_len); void evmovdquw(XMMRegister dst, KRegister mask, XMMRegister src, bool merge, int vector_len); @@ -1969,6 +1971,9 @@ class Assembler : public AbstractAssembler { void evpermi2ps(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len); void evpermi2pd(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len); void evpermt2b(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len); + void evpermt2w(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len); + void evpermt2d(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len); + void evpermt2q(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len); void pause(); @@ -1992,9 +1997,12 @@ class Assembler : public AbstractAssembler { void evpcmpgtb(KRegister kdst, XMMRegister nds, Address src, int vector_len); void evpcmpgtb(KRegister kdst, KRegister mask, XMMRegister nds, Address src, int vector_len); + void evpcmpub(KRegister kdst, XMMRegister nds, XMMRegister src, ComparisonPredicate vcc, int vector_len); + void evpcmpuw(KRegister kdst, XMMRegister nds, XMMRegister src, ComparisonPredicate vcc, int vector_len); void evpcmpuw(KRegister kdst, XMMRegister nds, Address src, ComparisonPredicate vcc, int vector_len); + void evpcmpud(KRegister kdst, XMMRegister nds, XMMRegister src, ComparisonPredicate vcc, int vector_len); void evpcmpuq(KRegister kdst, XMMRegister nds, XMMRegister src, ComparisonPredicate vcc, int vector_len); void pcmpeqw(XMMRegister dst, XMMRegister src); @@ -2678,6 +2686,40 @@ class Assembler : public AbstractAssembler { void vpaddd(XMMRegister dst, XMMRegister nds, Address src, int vector_len); void vpaddq(XMMRegister dst, XMMRegister nds, Address src, int vector_len); + // Saturating packed insturctions. + void vpaddsb(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len); + void vpaddsw(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len); + void vpaddusb(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len); + void vpaddusw(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len); + void evpaddsb(XMMRegister dst, KRegister mask, XMMRegister nds, XMMRegister src, bool merge, int vector_len); + void evpaddsw(XMMRegister dst, KRegister mask, XMMRegister nds, XMMRegister src, bool merge, int vector_len); + void evpaddusb(XMMRegister dst, KRegister mask, XMMRegister nds, XMMRegister src, bool merge, int vector_len); + void evpaddusw(XMMRegister dst, KRegister mask, XMMRegister nds, XMMRegister src, bool merge, int vector_len); + void vpsubsb(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len); + void vpsubsw(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len); + void vpsubusb(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len); + void vpsubusw(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len); + void evpsubsb(XMMRegister dst, KRegister mask, XMMRegister nds, XMMRegister src, bool merge, int vector_len); + void evpsubsw(XMMRegister dst, KRegister mask, XMMRegister nds, XMMRegister src, bool merge, int vector_len); + void evpsubusb(XMMRegister dst, KRegister mask, XMMRegister nds, XMMRegister src, bool merge, int vector_len); + void evpsubusw(XMMRegister dst, KRegister mask, XMMRegister nds, XMMRegister src, bool merge, int vector_len); + void vpaddsb(XMMRegister dst, XMMRegister nds, Address src, int vector_len); + void vpaddsw(XMMRegister dst, XMMRegister nds, Address src, int vector_len); + void vpaddusb(XMMRegister dst, XMMRegister nds, Address src, int vector_len); + void vpaddusw(XMMRegister dst, XMMRegister nds, Address src, int vector_len); + void evpaddsb(XMMRegister dst, KRegister mask, XMMRegister nds, Address src, bool merge, int vector_len); + void evpaddsw(XMMRegister dst, KRegister mask, XMMRegister nds, Address src, bool merge, int vector_len); + void evpaddusb(XMMRegister dst, KRegister mask, XMMRegister nds, Address src, bool merge, int vector_len); + void evpaddusw(XMMRegister dst, KRegister mask, XMMRegister nds, Address src, bool merge, int vector_len); + void vpsubsb(XMMRegister dst, XMMRegister nds, Address src, int vector_len); + void vpsubsw(XMMRegister dst, XMMRegister nds, Address src, int vector_len); + void vpsubusb(XMMRegister dst, XMMRegister nds, Address src, int vector_len); + void vpsubusw(XMMRegister dst, XMMRegister nds, Address src, int vector_len); + void evpsubsb(XMMRegister dst, KRegister mask, XMMRegister nds, Address src, bool merge, int vector_len); + void evpsubsw(XMMRegister dst, KRegister mask, XMMRegister nds, Address src, bool merge, int vector_len); + void evpsubusb(XMMRegister dst, KRegister mask, XMMRegister nds, Address src, bool merge, int vector_len); + void evpsubusw(XMMRegister dst, KRegister mask, XMMRegister nds, Address src, bool merge, int vector_len); + // Leaf level assembler routines for masked operations. void evpaddb(XMMRegister dst, KRegister mask, XMMRegister nds, XMMRegister src, bool merge, int vector_len); void evpaddb(XMMRegister dst, KRegister mask, XMMRegister nds, Address src, bool merge, int vector_len); @@ -2703,6 +2745,7 @@ class Assembler : public AbstractAssembler { void evsubps(XMMRegister dst, KRegister mask, XMMRegister nds, Address src, bool merge, int vector_len); void evsubpd(XMMRegister dst, KRegister mask, XMMRegister nds, XMMRegister src, bool merge, int vector_len); void evsubpd(XMMRegister dst, KRegister mask, XMMRegister nds, Address src, bool merge, int vector_len); + void evpmulhw(XMMRegister dst, KRegister mask, XMMRegister nds, XMMRegister src, bool merge, int vector_len); void evpmullw(XMMRegister dst, KRegister mask, XMMRegister nds, XMMRegister src, bool merge, int vector_len); void evpmullw(XMMRegister dst, KRegister mask, XMMRegister nds, Address src, bool merge, int vector_len); void evpmulld(XMMRegister dst, KRegister mask, XMMRegister nds, XMMRegister src, bool merge, int vector_len); @@ -2821,7 +2864,6 @@ class Assembler : public AbstractAssembler { void psubw(XMMRegister dst, XMMRegister src); void psubd(XMMRegister dst, XMMRegister src); void psubq(XMMRegister dst, XMMRegister src); - void vpsubusb(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len); void vpsubb(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len); void vpsubw(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len); void vpsubd(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len); @@ -2839,6 +2881,7 @@ class Assembler : public AbstractAssembler { void vpmulld(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len); void evpmullq(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len); void vpmuludq(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len); + void vpmuldq(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len); void vpmullw(XMMRegister dst, XMMRegister nds, Address src, int vector_len); void vpmulld(XMMRegister dst, XMMRegister nds, Address src, int vector_len); void evpmullq(XMMRegister dst, XMMRegister nds, Address src, int vector_len); @@ -2847,7 +2890,6 @@ class Assembler : public AbstractAssembler { // Minimum of packed integers void pminsb(XMMRegister dst, XMMRegister src); void vpminsb(XMMRegister dst, XMMRegister src1, XMMRegister src2, int vector_len); - void vpminub(XMMRegister dst, XMMRegister src1, XMMRegister src2, int vector_len); void pminsw(XMMRegister dst, XMMRegister src); void vpminsw(XMMRegister dst, XMMRegister src1, XMMRegister src2, int vector_len); void pminsd(XMMRegister dst, XMMRegister src); @@ -2871,6 +2913,38 @@ class Assembler : public AbstractAssembler { void maxpd(XMMRegister dst, XMMRegister src); void vmaxpd(XMMRegister dst, XMMRegister src1, XMMRegister src2, int vector_len); + // Unsigned maximum packed integers. + void vpmaxub(XMMRegister dst, XMMRegister src1, XMMRegister src2, int vector_len); + void vpmaxuw(XMMRegister dst, XMMRegister src1, XMMRegister src2, int vector_len); + void vpmaxud(XMMRegister dst, XMMRegister src1, XMMRegister src2, int vector_len); + void vpmaxub(XMMRegister dst, XMMRegister src1, Address src2, int vector_len); + void vpmaxuw(XMMRegister dst, XMMRegister src1, Address src2, int vector_len); + void vpmaxud(XMMRegister dst, XMMRegister src1, Address src2, int vector_len); + void evpmaxub(XMMRegister dst, KRegister mask, XMMRegister nds, XMMRegister src, bool merge, int vector_len); + void evpmaxuw(XMMRegister dst, KRegister mask, XMMRegister nds, XMMRegister src, bool merge, int vector_len); + void evpmaxud(XMMRegister dst, KRegister mask, XMMRegister nds, XMMRegister src, bool merge, int vector_len); + void evpmaxuq(XMMRegister dst, KRegister mask, XMMRegister nds, XMMRegister src, bool merge, int vector_len); + void evpmaxub(XMMRegister dst, KRegister mask, XMMRegister nds, Address src, bool merge, int vector_len); + void evpmaxuw(XMMRegister dst, KRegister mask, XMMRegister nds, Address src, bool merge, int vector_len); + void evpmaxud(XMMRegister dst, KRegister mask, XMMRegister nds, Address src, bool merge, int vector_len); + void evpmaxuq(XMMRegister dst, KRegister mask, XMMRegister nds, Address src, bool merge, int vector_len); + + // Unsigned minimum packed integers. + void vpminub(XMMRegister dst, XMMRegister src1, XMMRegister src2, int vector_len); + void vpminuw(XMMRegister dst, XMMRegister src1, XMMRegister src2, int vector_len); + void vpminud(XMMRegister dst, XMMRegister src1, XMMRegister src2, int vector_len); + void vpminub(XMMRegister dst, XMMRegister src1, Address src2, int vector_len); + void vpminuw(XMMRegister dst, XMMRegister src1, Address src2, int vector_len); + void vpminud(XMMRegister dst, XMMRegister src1, Address src2, int vector_len); + void evpminub(XMMRegister dst, KRegister mask, XMMRegister nds, XMMRegister src, bool merge, int vector_len); + void evpminuw(XMMRegister dst, KRegister mask, XMMRegister nds, XMMRegister src, bool merge, int vector_len); + void evpminud(XMMRegister dst, KRegister mask, XMMRegister nds, XMMRegister src, bool merge, int vector_len); + void evpminuq(XMMRegister dst, KRegister mask, XMMRegister nds, XMMRegister src, bool merge, int vector_len); + void evpminub(XMMRegister dst, KRegister mask, XMMRegister nds, Address src, bool merge, int vector_len); + void evpminuw(XMMRegister dst, KRegister mask, XMMRegister nds, Address src, bool merge, int vector_len); + void evpminud(XMMRegister dst, KRegister mask, XMMRegister nds, Address src, bool merge, int vector_len); + void evpminuq(XMMRegister dst, KRegister mask, XMMRegister nds, Address src, bool merge, int vector_len); + // Shift left packed integers void psllw(XMMRegister dst, int shift); void pslld(XMMRegister dst, int shift); diff --git a/src/hotspot/cpu/x86/c1_LIRAssembler_x86.cpp b/src/hotspot/cpu/x86/c1_LIRAssembler_x86.cpp index 6d9812c11ae..64265a96909 100644 --- a/src/hotspot/cpu/x86/c1_LIRAssembler_x86.cpp +++ b/src/hotspot/cpu/x86/c1_LIRAssembler_x86.cpp @@ -1333,10 +1333,7 @@ void LIR_Assembler::mem2reg(LIR_Opr src, LIR_Opr dest, BasicType type, LIR_Patch } #endif - if (!(UseZGC && !ZGenerational)) { - // Load barrier has not yet been applied, so ZGC can't verify the oop here - __ verify_oop(dest->as_register()); - } + __ verify_oop(dest->as_register()); } } diff --git a/src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp b/src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp index 879f33ede2d..61c8036b1ce 100644 --- a/src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp +++ b/src/hotspot/cpu/x86/c2_MacroAssembler_x86.cpp @@ -477,9 +477,9 @@ void C2_MacroAssembler::fast_unlock(Register objReg, Register boxReg, Register t // StoreLoad achieves this. membar(StoreLoad); - // Check if the entry lists are empty. - movptr(boxReg, Address(tmpReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(cxq))); - orptr(boxReg, Address(tmpReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(EntryList))); + // Check if the entry lists are empty (EntryList first - by convention). + movptr(boxReg, Address(tmpReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(EntryList))); + orptr(boxReg, Address(tmpReg, OM_OFFSET_NO_MONITOR_VALUE_TAG(cxq))); jccb(Assembler::zero, LSuccess); // If so we are done. // Check if there is a successor. @@ -806,9 +806,9 @@ void C2_MacroAssembler::fast_unlock_lightweight(Register obj, Register reg_rax, // StoreLoad achieves this. membar(StoreLoad); - // Check if the entry lists are empty. - movptr(reg_rax, cxq_address); - orptr(reg_rax, EntryList_address); + // Check if the entry lists are empty (EntryList first - by convention). + movptr(reg_rax, EntryList_address); + orptr(reg_rax, cxq_address); jccb(Assembler::zero, unlocked); // If so we are done. // Check if there is a successor. @@ -939,6 +939,72 @@ void C2_MacroAssembler::pminmax(int opcode, BasicType elem_bt, XMMRegister dst, } } +void C2_MacroAssembler::vpuminmax(int opcode, BasicType elem_bt, XMMRegister dst, + XMMRegister src1, Address src2, int vlen_enc) { + assert(opcode == Op_UMinV || opcode == Op_UMaxV, "sanity"); + if (opcode == Op_UMinV) { + switch(elem_bt) { + case T_BYTE: vpminub(dst, src1, src2, vlen_enc); break; + case T_SHORT: vpminuw(dst, src1, src2, vlen_enc); break; + case T_INT: vpminud(dst, src1, src2, vlen_enc); break; + case T_LONG: evpminuq(dst, k0, src1, src2, false, vlen_enc); break; + default: fatal("Unsupported type %s", type2name(elem_bt)); break; + } + } else { + assert(opcode == Op_UMaxV, "required"); + switch(elem_bt) { + case T_BYTE: vpmaxub(dst, src1, src2, vlen_enc); break; + case T_SHORT: vpmaxuw(dst, src1, src2, vlen_enc); break; + case T_INT: vpmaxud(dst, src1, src2, vlen_enc); break; + case T_LONG: evpmaxuq(dst, k0, src1, src2, false, vlen_enc); break; + default: fatal("Unsupported type %s", type2name(elem_bt)); break; + } + } +} + +void C2_MacroAssembler::vpuminmaxq(int opcode, XMMRegister dst, XMMRegister src1, XMMRegister src2, XMMRegister xtmp1, XMMRegister xtmp2, int vlen_enc) { + // T1 = -1 + vpcmpeqq(xtmp1, xtmp1, xtmp1, vlen_enc); + // T1 = -1 << 63 + vpsllq(xtmp1, xtmp1, 63, vlen_enc); + // Convert SRC2 to signed value i.e. T2 = T1 + SRC2 + vpaddq(xtmp2, xtmp1, src2, vlen_enc); + // Convert SRC1 to signed value i.e. T1 = T1 + SRC1 + vpaddq(xtmp1, xtmp1, src1, vlen_enc); + // Mask = T2 > T1 + vpcmpgtq(xtmp1, xtmp2, xtmp1, vlen_enc); + if (opcode == Op_UMaxV) { + // Res = Mask ? Src2 : Src1 + vpblendvb(dst, src1, src2, xtmp1, vlen_enc); + } else { + // Res = Mask ? Src1 : Src2 + vpblendvb(dst, src2, src1, xtmp1, vlen_enc); + } +} + +void C2_MacroAssembler::vpuminmax(int opcode, BasicType elem_bt, XMMRegister dst, + XMMRegister src1, XMMRegister src2, int vlen_enc) { + assert(opcode == Op_UMinV || opcode == Op_UMaxV, "sanity"); + if (opcode == Op_UMinV) { + switch(elem_bt) { + case T_BYTE: vpminub(dst, src1, src2, vlen_enc); break; + case T_SHORT: vpminuw(dst, src1, src2, vlen_enc); break; + case T_INT: vpminud(dst, src1, src2, vlen_enc); break; + case T_LONG: evpminuq(dst, k0, src1, src2, false, vlen_enc); break; + default: fatal("Unsupported type %s", type2name(elem_bt)); break; + } + } else { + assert(opcode == Op_UMaxV, "required"); + switch(elem_bt) { + case T_BYTE: vpmaxub(dst, src1, src2, vlen_enc); break; + case T_SHORT: vpmaxuw(dst, src1, src2, vlen_enc); break; + case T_INT: vpmaxud(dst, src1, src2, vlen_enc); break; + case T_LONG: evpmaxuq(dst, k0, src1, src2, false, vlen_enc); break; + default: fatal("Unsupported type %s", type2name(elem_bt)); break; + } + } +} + void C2_MacroAssembler::vpminmax(int opcode, BasicType elem_bt, XMMRegister dst, XMMRegister src1, XMMRegister src2, int vlen_enc) { @@ -2362,6 +2428,10 @@ void C2_MacroAssembler::evmovdqu(BasicType type, KRegister kmask, Address dst, X MacroAssembler::evmovdqu(type, kmask, dst, src, merge, vector_len); } +void C2_MacroAssembler::evmovdqu(BasicType type, KRegister kmask, XMMRegister dst, XMMRegister src, bool merge, int vector_len) { + MacroAssembler::evmovdqu(type, kmask, dst, src, merge, vector_len); +} + void C2_MacroAssembler::vmovmask(BasicType elem_bt, XMMRegister dst, Address src, XMMRegister mask, int vec_enc) { switch(elem_bt) { @@ -2660,7 +2730,6 @@ void C2_MacroAssembler::vectortest(BasicType bt, XMMRegister src1, XMMRegister s } void C2_MacroAssembler::vpadd(BasicType elem_bt, XMMRegister dst, XMMRegister src1, XMMRegister src2, int vlen_enc) { - assert(UseAVX >= 2, "required"); #ifdef ASSERT bool is_bw = ((elem_bt == T_BYTE) || (elem_bt == T_SHORT)); bool is_bw_supported = VM_Version::supports_avx512bw(); @@ -4634,7 +4703,126 @@ void C2_MacroAssembler::evmasked_op(int ideal_opc, BasicType eType, KRegister ma case Op_RotateLeftV: evrold(eType, dst, mask, src1, imm8, merge, vlen_enc); break; default: - fatal("Unsupported masked operation"); break; + fatal("Unsupported operation %s", NodeClassNames[ideal_opc]); + break; + } +} + +void C2_MacroAssembler::evmasked_saturating_op(int ideal_opc, BasicType elem_bt, KRegister mask, XMMRegister dst, XMMRegister src1, + XMMRegister src2, bool is_unsigned, bool merge, int vlen_enc) { + if (is_unsigned) { + evmasked_saturating_unsigned_op(ideal_opc, elem_bt, mask, dst, src1, src2, merge, vlen_enc); + } else { + evmasked_saturating_signed_op(ideal_opc, elem_bt, mask, dst, src1, src2, merge, vlen_enc); + } +} + +void C2_MacroAssembler::evmasked_saturating_signed_op(int ideal_opc, BasicType elem_bt, KRegister mask, XMMRegister dst, + XMMRegister src1, XMMRegister src2, bool merge, int vlen_enc) { + switch (elem_bt) { + case T_BYTE: + if (ideal_opc == Op_SaturatingAddV) { + evpaddsb(dst, mask, src1, src2, merge, vlen_enc); + } else { + assert(ideal_opc == Op_SaturatingSubV, ""); + evpsubsb(dst, mask, src1, src2, merge, vlen_enc); + } + break; + case T_SHORT: + if (ideal_opc == Op_SaturatingAddV) { + evpaddsw(dst, mask, src1, src2, merge, vlen_enc); + } else { + assert(ideal_opc == Op_SaturatingSubV, ""); + evpsubsw(dst, mask, src1, src2, merge, vlen_enc); + } + break; + default: + fatal("Unsupported type %s", type2name(elem_bt)); + break; + } +} + +void C2_MacroAssembler::evmasked_saturating_unsigned_op(int ideal_opc, BasicType elem_bt, KRegister mask, XMMRegister dst, + XMMRegister src1, XMMRegister src2, bool merge, int vlen_enc) { + switch (elem_bt) { + case T_BYTE: + if (ideal_opc == Op_SaturatingAddV) { + evpaddusb(dst, mask, src1, src2, merge, vlen_enc); + } else { + assert(ideal_opc == Op_SaturatingSubV, ""); + evpsubusb(dst, mask, src1, src2, merge, vlen_enc); + } + break; + case T_SHORT: + if (ideal_opc == Op_SaturatingAddV) { + evpaddusw(dst, mask, src1, src2, merge, vlen_enc); + } else { + assert(ideal_opc == Op_SaturatingSubV, ""); + evpsubusw(dst, mask, src1, src2, merge, vlen_enc); + } + break; + default: + fatal("Unsupported type %s", type2name(elem_bt)); + break; + } +} + +void C2_MacroAssembler::evmasked_saturating_op(int ideal_opc, BasicType elem_bt, KRegister mask, XMMRegister dst, XMMRegister src1, + Address src2, bool is_unsigned, bool merge, int vlen_enc) { + if (is_unsigned) { + evmasked_saturating_unsigned_op(ideal_opc, elem_bt, mask, dst, src1, src2, merge, vlen_enc); + } else { + evmasked_saturating_signed_op(ideal_opc, elem_bt, mask, dst, src1, src2, merge, vlen_enc); + } +} + +void C2_MacroAssembler::evmasked_saturating_signed_op(int ideal_opc, BasicType elem_bt, KRegister mask, XMMRegister dst, + XMMRegister src1, Address src2, bool merge, int vlen_enc) { + switch (elem_bt) { + case T_BYTE: + if (ideal_opc == Op_SaturatingAddV) { + evpaddsb(dst, mask, src1, src2, merge, vlen_enc); + } else { + assert(ideal_opc == Op_SaturatingSubV, ""); + evpsubsb(dst, mask, src1, src2, merge, vlen_enc); + } + break; + case T_SHORT: + if (ideal_opc == Op_SaturatingAddV) { + evpaddsw(dst, mask, src1, src2, merge, vlen_enc); + } else { + assert(ideal_opc == Op_SaturatingSubV, ""); + evpsubsw(dst, mask, src1, src2, merge, vlen_enc); + } + break; + default: + fatal("Unsupported type %s", type2name(elem_bt)); + break; + } +} + +void C2_MacroAssembler::evmasked_saturating_unsigned_op(int ideal_opc, BasicType elem_bt, KRegister mask, XMMRegister dst, + XMMRegister src1, Address src2, bool merge, int vlen_enc) { + switch (elem_bt) { + case T_BYTE: + if (ideal_opc == Op_SaturatingAddV) { + evpaddusb(dst, mask, src1, src2, merge, vlen_enc); + } else { + assert(ideal_opc == Op_SaturatingSubV, ""); + evpsubusb(dst, mask, src1, src2, merge, vlen_enc); + } + break; + case T_SHORT: + if (ideal_opc == Op_SaturatingAddV) { + evpaddusw(dst, mask, src1, src2, merge, vlen_enc); + } else { + assert(ideal_opc == Op_SaturatingSubV, ""); + evpsubusw(dst, mask, src1, src2, merge, vlen_enc); + } + break; + default: + fatal("Unsupported type %s", type2name(elem_bt)); + break; } } @@ -4724,6 +4912,10 @@ void C2_MacroAssembler::evmasked_op(int ideal_opc, BasicType eType, KRegister ma evpmaxs(eType, dst, mask, src1, src2, merge, vlen_enc); break; case Op_MinV: evpmins(eType, dst, mask, src1, src2, merge, vlen_enc); break; + case Op_UMinV: + evpminu(eType, dst, mask, src1, src2, merge, vlen_enc); break; + case Op_UMaxV: + evpmaxu(eType, dst, mask, src1, src2, merge, vlen_enc); break; case Op_XorV: evxor(eType, dst, mask, src1, src2, merge, vlen_enc); break; case Op_OrV: @@ -4731,7 +4923,8 @@ void C2_MacroAssembler::evmasked_op(int ideal_opc, BasicType eType, KRegister ma case Op_AndV: evand(eType, dst, mask, src1, src2, merge, vlen_enc); break; default: - fatal("Unsupported masked operation"); break; + fatal("Unsupported operation %s", NodeClassNames[ideal_opc]); + break; } } @@ -4784,6 +4977,10 @@ void C2_MacroAssembler::evmasked_op(int ideal_opc, BasicType eType, KRegister ma evpmaxs(eType, dst, mask, src1, src2, merge, vlen_enc); break; case Op_MinV: evpmins(eType, dst, mask, src1, src2, merge, vlen_enc); break; + case Op_UMaxV: + evpmaxu(eType, dst, mask, src1, src2, merge, vlen_enc); break; + case Op_UMinV: + evpminu(eType, dst, mask, src1, src2, merge, vlen_enc); break; case Op_XorV: evxor(eType, dst, mask, src1, src2, merge, vlen_enc); break; case Op_OrV: @@ -4791,7 +4988,8 @@ void C2_MacroAssembler::evmasked_op(int ideal_opc, BasicType eType, KRegister ma case Op_AndV: evand(eType, dst, mask, src1, src2, merge, vlen_enc); break; default: - fatal("Unsupported masked operation"); break; + fatal("Unsupported operation %s", NodeClassNames[ideal_opc]); + break; } } @@ -6479,6 +6677,369 @@ void C2_MacroAssembler::vector_rearrange_int_float(BasicType bt, XMMRegister dst } } +void C2_MacroAssembler::vector_saturating_op(int ideal_opc, BasicType elem_bt, XMMRegister dst, XMMRegister src1, XMMRegister src2, int vlen_enc) { + switch(elem_bt) { + case T_BYTE: + if (ideal_opc == Op_SaturatingAddV) { + vpaddsb(dst, src1, src2, vlen_enc); + } else { + assert(ideal_opc == Op_SaturatingSubV, ""); + vpsubsb(dst, src1, src2, vlen_enc); + } + break; + case T_SHORT: + if (ideal_opc == Op_SaturatingAddV) { + vpaddsw(dst, src1, src2, vlen_enc); + } else { + assert(ideal_opc == Op_SaturatingSubV, ""); + vpsubsw(dst, src1, src2, vlen_enc); + } + break; + default: + fatal("Unsupported type %s", type2name(elem_bt)); + break; + } +} + +void C2_MacroAssembler::vector_saturating_unsigned_op(int ideal_opc, BasicType elem_bt, XMMRegister dst, XMMRegister src1, XMMRegister src2, int vlen_enc) { + switch(elem_bt) { + case T_BYTE: + if (ideal_opc == Op_SaturatingAddV) { + vpaddusb(dst, src1, src2, vlen_enc); + } else { + assert(ideal_opc == Op_SaturatingSubV, ""); + vpsubusb(dst, src1, src2, vlen_enc); + } + break; + case T_SHORT: + if (ideal_opc == Op_SaturatingAddV) { + vpaddusw(dst, src1, src2, vlen_enc); + } else { + assert(ideal_opc == Op_SaturatingSubV, ""); + vpsubusw(dst, src1, src2, vlen_enc); + } + break; + default: + fatal("Unsupported type %s", type2name(elem_bt)); + break; + } +} + +void C2_MacroAssembler::vector_sub_dq_saturating_unsigned_evex(BasicType elem_bt, XMMRegister dst, XMMRegister src1, + XMMRegister src2, KRegister ktmp, int vlen_enc) { + // For unsigned subtraction, overflow happens when magnitude of second input is greater than first input. + // overflow_mask = Inp1 Inp1 + MIN_VALUE < Inp2 + MIN_VALUE + vpgenmin_value(elem_bt, xtmp1, xtmp1, vlen_enc, true); + vpadd(elem_bt, xtmp2, src1, xtmp1, vlen_enc); + vpadd(elem_bt, xtmp1, src2, xtmp1, vlen_enc); + + vpcmpgt(elem_bt, xtmp2, xtmp1, xtmp2, vlen_enc); + + // Res = INP1 - INP2 (non-commutative and non-associative) + vpsub(elem_bt, dst, src1, src2, vlen_enc); + // Res = Mask ? Zero : Res + vpxor(xtmp1, xtmp1, xtmp1, vlen_enc); + vpblendvb(dst, dst, xtmp1, xtmp2, vlen_enc); +} + +void C2_MacroAssembler::vector_add_dq_saturating_unsigned_evex(BasicType elem_bt, XMMRegister dst, XMMRegister src1, XMMRegister src2, + XMMRegister xtmp1, XMMRegister xtmp2, KRegister ktmp, int vlen_enc) { + // Unsigned values ranges comprise of only +ve numbers, thus there exist only an upper bound saturation. + // overflow_mask = (SRC1 + SRC2) >> 31 == 1 +// +// We empirically determined its semantic equivalence to following reduced expression +// overflow_mask = (a + b) = Res + MIN_VALUE + vpadd(elem_bt, xtmp2, xtmp2, dst, vlen_enc); + // Compute overflow detection mask = Res<1> >> 31(I)/63(L)) == 1 + vpxor(xtmp1, dst, src1, vlen_enc); + vpxor(xtmp2, dst, src2, vlen_enc); + vpand(xtmp2, xtmp1, xtmp2, vlen_enc); + } else { + assert(ideal_opc == Op_SaturatingSubV, ""); + // res = src1 - src2 + vpsub(elem_bt, dst, src1, src2, vlen_enc); + // Overflow occurs when both inputs have opposite polarity and + // result polarity does not comply with first input polarity. + // overflow = ((src1 ^ src2) & (res ^ src1) >>> 31(I)/63(L)) == 1; + vpxor(xtmp1, src1, src2, vlen_enc); + vpxor(xtmp2, dst, src1, vlen_enc); + vpand(xtmp2, xtmp1, xtmp2, vlen_enc); + } + + // Compute overflow detection mask. + evpmov_vec_to_mask(elem_bt, ktmp1, xtmp2, xtmp2, xtmp1, vlen_enc); + // Note: xtmp1 hold -1 in all its lanes after above call. + + // Compute mask based on first input polarity. + evpmov_vec_to_mask(elem_bt, ktmp2, src1, xtmp2, xtmp1, vlen_enc, true); + + vpgenmax_value(elem_bt, xtmp2, xtmp1, vlen_enc, true); + vpgenmin_value(elem_bt, xtmp1, xtmp1, vlen_enc); + + // Compose a vector of saturating (MAX/MIN) values, where lanes corresponding to + // set bits in first input polarity mask holds a min value. + evpblend(elem_bt, xtmp2, ktmp2, xtmp2, xtmp1, true, vlen_enc); + // Blend destination lanes with saturated values using overflow detection mask. + evpblend(elem_bt, dst, ktmp1, dst, xtmp2, true, vlen_enc); +} + + +void C2_MacroAssembler::vector_addsub_dq_saturating_avx(int ideal_opc, BasicType elem_bt, XMMRegister dst, XMMRegister src1, + XMMRegister src2, XMMRegister xtmp1, XMMRegister xtmp2, + XMMRegister xtmp3, XMMRegister xtmp4, int vlen_enc) { + assert(elem_bt == T_INT || elem_bt == T_LONG, ""); + // Addition/Subtraction happens over two's compliment representation of numbers and is agnostic to signed'ness. + // Overflow detection based on Hacker's delight section 2-13. + if (ideal_opc == Op_SaturatingAddV) { + // res = src1 + src2 + vpadd(elem_bt, dst, src1, src2, vlen_enc); + // Overflow occurs if result polarity does not comply with equivalent polarity inputs. + // overflow = (((res ^ src1) & (res ^ src2)) >>> 31(I)/63(L)) == 1 + vpxor(xtmp1, dst, src1, vlen_enc); + vpxor(xtmp2, dst, src2, vlen_enc); + vpand(xtmp2, xtmp1, xtmp2, vlen_enc); + } else { + assert(ideal_opc == Op_SaturatingSubV, ""); + // res = src1 - src2 + vpsub(elem_bt, dst, src1, src2, vlen_enc); + // Overflow occurs when both inputs have opposite polarity and + // result polarity does not comply with first input polarity. + // overflow = ((src1 ^ src2) & (res ^ src1) >>> 31(I)/63(L)) == 1; + vpxor(xtmp1, src1, src2, vlen_enc); + vpxor(xtmp2, dst, src1, vlen_enc); + vpand(xtmp2, xtmp1, xtmp2, vlen_enc); + } + + // Sign-extend to compute overflow detection mask. + vpsign_extend_dq(elem_bt, xtmp3, xtmp2, vlen_enc); + + vpcmpeqd(xtmp1, xtmp1, xtmp1, vlen_enc); + vpgenmax_value(elem_bt, xtmp2, xtmp1, vlen_enc); + vpgenmin_value(elem_bt, xtmp1, xtmp1, vlen_enc); + + // Compose saturating min/max vector using first input polarity mask. + vpsign_extend_dq(elem_bt, xtmp4, src1, vlen_enc); + vpblendvb(xtmp1, xtmp2, xtmp1, xtmp4, vlen_enc); + + // Blend result with saturating vector using overflow detection mask. + vpblendvb(dst, dst, xtmp1, xtmp3, vlen_enc); +} + +void C2_MacroAssembler::vector_saturating_op(int ideal_opc, BasicType elem_bt, XMMRegister dst, XMMRegister src1, Address src2, int vlen_enc) { + switch(elem_bt) { + case T_BYTE: + if (ideal_opc == Op_SaturatingAddV) { + vpaddsb(dst, src1, src2, vlen_enc); + } else { + assert(ideal_opc == Op_SaturatingSubV, ""); + vpsubsb(dst, src1, src2, vlen_enc); + } + break; + case T_SHORT: + if (ideal_opc == Op_SaturatingAddV) { + vpaddsw(dst, src1, src2, vlen_enc); + } else { + assert(ideal_opc == Op_SaturatingSubV, ""); + vpsubsw(dst, src1, src2, vlen_enc); + } + break; + default: + fatal("Unsupported type %s", type2name(elem_bt)); + break; + } +} + +void C2_MacroAssembler::vector_saturating_unsigned_op(int ideal_opc, BasicType elem_bt, XMMRegister dst, XMMRegister src1, Address src2, int vlen_enc) { + switch(elem_bt) { + case T_BYTE: + if (ideal_opc == Op_SaturatingAddV) { + vpaddusb(dst, src1, src2, vlen_enc); + } else { + assert(ideal_opc == Op_SaturatingSubV, ""); + vpsubusb(dst, src1, src2, vlen_enc); + } + break; + case T_SHORT: + if (ideal_opc == Op_SaturatingAddV) { + vpaddusw(dst, src1, src2, vlen_enc); + } else { + assert(ideal_opc == Op_SaturatingSubV, ""); + vpsubusw(dst, src1, src2, vlen_enc); + } + break; + default: + fatal("Unsupported type %s", type2name(elem_bt)); + break; + } +} + void C2_MacroAssembler::select_from_two_vectors_evex(BasicType elem_bt, XMMRegister dst, XMMRegister src1, XMMRegister src2, int vlen_enc) { switch(elem_bt) { @@ -6505,3 +7066,19 @@ void C2_MacroAssembler::select_from_two_vectors_evex(BasicType elem_bt, XMMRegis break; } } + +void C2_MacroAssembler::vector_saturating_op(int ideal_opc, BasicType elem_bt, XMMRegister dst, XMMRegister src1, XMMRegister src2, bool is_unsigned, int vlen_enc) { + if (is_unsigned) { + vector_saturating_unsigned_op(ideal_opc, elem_bt, dst, src1, src2, vlen_enc); + } else { + vector_saturating_op(ideal_opc, elem_bt, dst, src1, src2, vlen_enc); + } +} + +void C2_MacroAssembler::vector_saturating_op(int ideal_opc, BasicType elem_bt, XMMRegister dst, XMMRegister src1, Address src2, bool is_unsigned, int vlen_enc) { + if (is_unsigned) { + vector_saturating_unsigned_op(ideal_opc, elem_bt, dst, src1, src2, vlen_enc); + } else { + vector_saturating_op(ideal_opc, elem_bt, dst, src1, src2, vlen_enc); + } +} diff --git a/src/hotspot/cpu/x86/c2_MacroAssembler_x86.hpp b/src/hotspot/cpu/x86/c2_MacroAssembler_x86.hpp index 5744fedcc64..3a36fd75e3f 100644 --- a/src/hotspot/cpu/x86/c2_MacroAssembler_x86.hpp +++ b/src/hotspot/cpu/x86/c2_MacroAssembler_x86.hpp @@ -56,10 +56,21 @@ XMMRegister dst, XMMRegister src1, XMMRegister src2, int vlen_enc); + void vpuminmax(int opcode, BasicType elem_bt, + XMMRegister dst, XMMRegister src1, XMMRegister src2, + int vlen_enc); + + void vpuminmax(int opcode, BasicType elem_bt, + XMMRegister dst, XMMRegister src1, Address src2, + int vlen_enc); + void vminmax_fp(int opcode, BasicType elem_bt, XMMRegister dst, XMMRegister a, XMMRegister b, XMMRegister tmp, XMMRegister atmp, XMMRegister btmp, int vlen_enc); + + void vpuminmaxq(int opcode, XMMRegister dst, XMMRegister src1, XMMRegister src2, XMMRegister xtmp1, XMMRegister xtmp2, int vlen_enc); + void evminmax_fp(int opcode, BasicType elem_bt, XMMRegister dst, XMMRegister a, XMMRegister b, KRegister ktmp, XMMRegister atmp, XMMRegister btmp, @@ -105,6 +116,7 @@ void evmovdqu(BasicType type, KRegister kmask, XMMRegister dst, Address src, bool merge, int vector_len); void evmovdqu(BasicType type, KRegister kmask, Address dst, XMMRegister src, bool merge, int vector_len); + void evmovdqu(BasicType type, KRegister kmask, XMMRegister dst, XMMRegister src, bool merge, int vector_len); // extract void extract(BasicType typ, Register dst, XMMRegister src, int idx); @@ -505,6 +517,70 @@ void vgather8b_offset(BasicType elem_bt, XMMRegister dst, Register base, Register idx_base, Register offset, Register rtmp, int vlen_enc); + void vector_saturating_op(int opc, BasicType elem_bt, XMMRegister dst, XMMRegister src1, XMMRegister src2, bool is_unsigned, int vlen_enc); + + void vector_saturating_op(int opc, BasicType elem_bt, XMMRegister dst, XMMRegister src1, Address src2, bool is_unsigned, int vlen_enc); + + void vector_saturating_op(int opc, BasicType elem_bt, XMMRegister dst, XMMRegister src1, XMMRegister src2, int vlen_enc); + + void vector_saturating_op(int opc, BasicType elem_bt, XMMRegister dst, XMMRegister src1, Address src2, int vlen_enc); + + void vector_saturating_unsigned_op(int opc, BasicType elem_bt, XMMRegister dst, XMMRegister src1, XMMRegister src2, int vlen_enc); + + void vector_saturating_unsigned_op(int opc, BasicType elem_bt, XMMRegister dst, XMMRegister src1, Address src2, int vlen_enc); + + void vector_sub_dq_saturating_unsigned_evex(BasicType elem_bt, XMMRegister dst, XMMRegister src1, XMMRegister src2, KRegister ktmp, int vlen_enc); + + void vector_sub_dq_saturating_unsigned_avx(BasicType elem_bt, XMMRegister dst, XMMRegister src1, XMMRegister src2, + XMMRegister xtmp1, XMMRegister xtmp2, int vlen_enc); + + void vector_add_dq_saturating_unsigned_evex(BasicType elem_bt, XMMRegister dst, XMMRegister src1, XMMRegister src2, + XMMRegister xtmp1, XMMRegister xtmp2, KRegister ktmp, int vlen_enc); + + void vector_add_dq_saturating_unsigned_avx(BasicType elem_bt, XMMRegister dst, XMMRegister src1, XMMRegister src2, + XMMRegister xtmp1, XMMRegister xtmp2, XMMRegister xtmp3, int vlen_enc); + + void vector_addsub_dq_saturating_avx(int opc, BasicType elem_bt, XMMRegister dst, XMMRegister src1, XMMRegister src2, + XMMRegister xtmp1, XMMRegister xtmp2, XMMRegister xtmp3, XMMRegister xtmp4, int vlen_enc); + + void vector_addsub_dq_saturating_evex(int opc, BasicType elem_bt, XMMRegister dst, XMMRegister src1, XMMRegister src2, + XMMRegister xtmp1, XMMRegister xtmp2, KRegister ktmp1, KRegister ktmp2, int vlen_enc); + + void evpmovd2m_emu(KRegister ktmp, XMMRegister src, XMMRegister xtmp1, XMMRegister xtmp2, int vlen_enc, bool xtmp2_hold_M1 = false); + + void evpmovq2m_emu(KRegister ktmp, XMMRegister src, XMMRegister xtmp1, XMMRegister xtmp2, int vlen_enc, bool xtmp2_hold_M1 = false); + + void vpsign_extend_dq(BasicType etype, XMMRegister dst, XMMRegister src, int vlen_enc); + + void vpgenmin_value(BasicType etype, XMMRegister dst, XMMRegister allones, int vlen_enc, bool compute_allones = false); + + void vpgenmax_value(BasicType etype, XMMRegister dst, XMMRegister allones, int vlen_enc, bool compute_allones = false); + + void evpcmpu(BasicType etype, KRegister kmask, XMMRegister src1, XMMRegister src2, Assembler::ComparisonPredicate cond, int vlen_enc); + + void vpcmpgt(BasicType etype, XMMRegister dst, XMMRegister src1, XMMRegister src2, int vlen_enc); + + void evpmov_vec_to_mask(BasicType etype, KRegister ktmp, XMMRegister src, XMMRegister xtmp1, XMMRegister xtmp2, + int vlen_enc, bool xtmp2_hold_M1 = false); + + void evmasked_saturating_op(int ideal_opc, BasicType elem_bt, KRegister mask, XMMRegister dst, XMMRegister src1, XMMRegister src2, + bool is_unsigned, bool merge, int vlen_enc); + + void evmasked_saturating_op(int ideal_opc, BasicType elem_bt, KRegister mask, XMMRegister dst, XMMRegister src1, Address src2, + bool is_unsigned, bool merge, int vlen_enc); + + void evmasked_saturating_signed_op(int ideal_opc, BasicType elem_bt, KRegister mask, XMMRegister dst, XMMRegister src1, XMMRegister src2, + bool merge, int vlen_enc); + + void evmasked_saturating_signed_op(int ideal_opc, BasicType elem_bt, KRegister mask, XMMRegister dst, XMMRegister src1, Address src2, + bool merge, int vlen_enc); + + void evmasked_saturating_unsigned_op(int ideal_opc, BasicType elem_bt, KRegister mask, XMMRegister dst, XMMRegister src1, + XMMRegister src2, bool merge, int vlen_enc); + + void evmasked_saturating_unsigned_op(int ideal_opc, BasicType elem_bt, KRegister mask, XMMRegister dst, XMMRegister src1, + Address src2, bool merge, int vlen_enc); + void select_from_two_vectors_evex(BasicType elem_bt, XMMRegister dst, XMMRegister src1, XMMRegister src2, int vlen_enc); #endif // CPU_X86_C2_MACROASSEMBLER_X86_HPP diff --git a/src/hotspot/cpu/x86/gc/x/xBarrierSetAssembler_x86.cpp b/src/hotspot/cpu/x86/gc/x/xBarrierSetAssembler_x86.cpp deleted file mode 100644 index a7dc34b17b1..00000000000 --- a/src/hotspot/cpu/x86/gc/x/xBarrierSetAssembler_x86.cpp +++ /dev/null @@ -1,734 +0,0 @@ -/* - * Copyright (c) 2018, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "asm/macroAssembler.inline.hpp" -#include "code/codeBlob.hpp" -#include "code/vmreg.inline.hpp" -#include "gc/x/xBarrier.inline.hpp" -#include "gc/x/xBarrierSet.hpp" -#include "gc/x/xBarrierSetAssembler.hpp" -#include "gc/x/xBarrierSetRuntime.hpp" -#include "gc/x/xThreadLocalData.hpp" -#include "memory/resourceArea.hpp" -#include "runtime/sharedRuntime.hpp" -#include "utilities/macros.hpp" -#ifdef COMPILER1 -#include "c1/c1_LIRAssembler.hpp" -#include "c1/c1_MacroAssembler.hpp" -#include "gc/x/c1/xBarrierSetC1.hpp" -#endif // COMPILER1 -#ifdef COMPILER2 -#include "gc/x/c2/xBarrierSetC2.hpp" -#endif // COMPILER2 - -#ifdef PRODUCT -#define BLOCK_COMMENT(str) /* nothing */ -#else -#define BLOCK_COMMENT(str) __ block_comment(str) -#endif - -#undef __ -#define __ masm-> - -static void call_vm(MacroAssembler* masm, - address entry_point, - Register arg0, - Register arg1) { - // Setup arguments - if (arg1 == c_rarg0) { - if (arg0 == c_rarg1) { - __ xchgptr(c_rarg1, c_rarg0); - } else { - __ movptr(c_rarg1, arg1); - __ movptr(c_rarg0, arg0); - } - } else { - if (arg0 != c_rarg0) { - __ movptr(c_rarg0, arg0); - } - if (arg1 != c_rarg1) { - __ movptr(c_rarg1, arg1); - } - } - - // Call VM - __ MacroAssembler::call_VM_leaf_base(entry_point, 2); -} - -void XBarrierSetAssembler::load_at(MacroAssembler* masm, - DecoratorSet decorators, - BasicType type, - Register dst, - Address src, - Register tmp1, - Register tmp_thread) { - if (!XBarrierSet::barrier_needed(decorators, type)) { - // Barrier not needed - BarrierSetAssembler::load_at(masm, decorators, type, dst, src, tmp1, tmp_thread); - return; - } - - BLOCK_COMMENT("XBarrierSetAssembler::load_at {"); - - // Allocate scratch register - Register scratch = tmp1; - if (tmp1 == noreg) { - scratch = r12; - __ push(scratch); - } - - assert_different_registers(dst, scratch); - - Label done; - - // - // Fast Path - // - - // Load address - __ lea(scratch, src); - - // Load oop at address - __ movptr(dst, Address(scratch, 0)); - - // Test address bad mask - __ testptr(dst, address_bad_mask_from_thread(r15_thread)); - __ jcc(Assembler::zero, done); - - // - // Slow path - // - - // Save registers - __ push(rax); - __ push(rcx); - __ push(rdx); - __ push(rdi); - __ push(rsi); - __ push(r8); - __ push(r9); - __ push(r10); - __ push(r11); - - // We may end up here from generate_native_wrapper, then the method may have - // floats as arguments, and we must spill them before calling the VM runtime - // leaf. From the interpreter all floats are passed on the stack. - assert(Argument::n_float_register_parameters_j == 8, "Assumption"); - const int xmm_size = wordSize * 2; - const int xmm_spill_size = xmm_size * Argument::n_float_register_parameters_j; - __ subptr(rsp, xmm_spill_size); - __ movdqu(Address(rsp, xmm_size * 7), xmm7); - __ movdqu(Address(rsp, xmm_size * 6), xmm6); - __ movdqu(Address(rsp, xmm_size * 5), xmm5); - __ movdqu(Address(rsp, xmm_size * 4), xmm4); - __ movdqu(Address(rsp, xmm_size * 3), xmm3); - __ movdqu(Address(rsp, xmm_size * 2), xmm2); - __ movdqu(Address(rsp, xmm_size * 1), xmm1); - __ movdqu(Address(rsp, xmm_size * 0), xmm0); - - // Call VM - call_vm(masm, XBarrierSetRuntime::load_barrier_on_oop_field_preloaded_addr(decorators), dst, scratch); - - __ movdqu(xmm0, Address(rsp, xmm_size * 0)); - __ movdqu(xmm1, Address(rsp, xmm_size * 1)); - __ movdqu(xmm2, Address(rsp, xmm_size * 2)); - __ movdqu(xmm3, Address(rsp, xmm_size * 3)); - __ movdqu(xmm4, Address(rsp, xmm_size * 4)); - __ movdqu(xmm5, Address(rsp, xmm_size * 5)); - __ movdqu(xmm6, Address(rsp, xmm_size * 6)); - __ movdqu(xmm7, Address(rsp, xmm_size * 7)); - __ addptr(rsp, xmm_spill_size); - - __ pop(r11); - __ pop(r10); - __ pop(r9); - __ pop(r8); - __ pop(rsi); - __ pop(rdi); - __ pop(rdx); - __ pop(rcx); - - if (dst == rax) { - __ addptr(rsp, wordSize); - } else { - __ movptr(dst, rax); - __ pop(rax); - } - - __ bind(done); - - // Restore scratch register - if (tmp1 == noreg) { - __ pop(scratch); - } - - BLOCK_COMMENT("} XBarrierSetAssembler::load_at"); -} - -#ifdef ASSERT - -void XBarrierSetAssembler::store_at(MacroAssembler* masm, - DecoratorSet decorators, - BasicType type, - Address dst, - Register src, - Register tmp1, - Register tmp2, - Register tmp3) { - BLOCK_COMMENT("XBarrierSetAssembler::store_at {"); - - // Verify oop store - if (is_reference_type(type)) { - // Note that src could be noreg, which means we - // are storing null and can skip verification. - if (src != noreg) { - Label done; - __ testptr(src, address_bad_mask_from_thread(r15_thread)); - __ jcc(Assembler::zero, done); - __ stop("Verify oop store failed"); - __ should_not_reach_here(); - __ bind(done); - } - } - - // Store value - BarrierSetAssembler::store_at(masm, decorators, type, dst, src, tmp1, tmp2, tmp3); - - BLOCK_COMMENT("} XBarrierSetAssembler::store_at"); -} - -#endif // ASSERT - -void XBarrierSetAssembler::arraycopy_prologue(MacroAssembler* masm, - DecoratorSet decorators, - BasicType type, - Register src, - Register dst, - Register count) { - if (!XBarrierSet::barrier_needed(decorators, type)) { - // Barrier not needed - return; - } - - BLOCK_COMMENT("XBarrierSetAssembler::arraycopy_prologue {"); - - // Save registers - __ pusha(); - - // Call VM - call_vm(masm, XBarrierSetRuntime::load_barrier_on_oop_array_addr(), src, count); - - // Restore registers - __ popa(); - - BLOCK_COMMENT("} XBarrierSetAssembler::arraycopy_prologue"); -} - -void XBarrierSetAssembler::try_resolve_jobject_in_native(MacroAssembler* masm, - Register jni_env, - Register obj, - Register tmp, - Label& slowpath) { - BLOCK_COMMENT("XBarrierSetAssembler::try_resolve_jobject_in_native {"); - - // Resolve jobject - BarrierSetAssembler::try_resolve_jobject_in_native(masm, jni_env, obj, tmp, slowpath); - - // Test address bad mask - __ testptr(obj, address_bad_mask_from_jni_env(jni_env)); - __ jcc(Assembler::notZero, slowpath); - - BLOCK_COMMENT("} XBarrierSetAssembler::try_resolve_jobject_in_native"); -} - -#ifdef COMPILER1 - -#undef __ -#define __ ce->masm()-> - -void XBarrierSetAssembler::generate_c1_load_barrier_test(LIR_Assembler* ce, - LIR_Opr ref) const { - __ testptr(ref->as_register(), address_bad_mask_from_thread(r15_thread)); -} - -void XBarrierSetAssembler::generate_c1_load_barrier_stub(LIR_Assembler* ce, - XLoadBarrierStubC1* stub) const { - // Stub entry - __ bind(*stub->entry()); - - Register ref = stub->ref()->as_register(); - Register ref_addr = noreg; - Register tmp = noreg; - - if (stub->tmp()->is_valid()) { - // Load address into tmp register - ce->leal(stub->ref_addr(), stub->tmp()); - ref_addr = tmp = stub->tmp()->as_pointer_register(); - } else { - // Address already in register - ref_addr = stub->ref_addr()->as_address_ptr()->base()->as_pointer_register(); - } - - assert_different_registers(ref, ref_addr, noreg); - - // Save rax unless it is the result or tmp register - if (ref != rax && tmp != rax) { - __ push(rax); - } - - // Setup arguments and call runtime stub - __ subptr(rsp, 2 * BytesPerWord); - ce->store_parameter(ref_addr, 1); - ce->store_parameter(ref, 0); - __ call(RuntimeAddress(stub->runtime_stub())); - __ addptr(rsp, 2 * BytesPerWord); - - // Verify result - __ verify_oop(rax); - - // Move result into place - if (ref != rax) { - __ movptr(ref, rax); - } - - // Restore rax unless it is the result or tmp register - if (ref != rax && tmp != rax) { - __ pop(rax); - } - - // Stub exit - __ jmp(*stub->continuation()); -} - -#undef __ -#define __ sasm-> - -void XBarrierSetAssembler::generate_c1_load_barrier_runtime_stub(StubAssembler* sasm, - DecoratorSet decorators) const { - // Enter and save registers - __ enter(); - __ save_live_registers_no_oop_map(true /* save_fpu_registers */); - - // Setup arguments - __ load_parameter(1, c_rarg1); - __ load_parameter(0, c_rarg0); - - // Call VM - __ call_VM_leaf(XBarrierSetRuntime::load_barrier_on_oop_field_preloaded_addr(decorators), c_rarg0, c_rarg1); - - // Restore registers and return - __ restore_live_registers_except_rax(true /* restore_fpu_registers */); - __ leave(); - __ ret(0); -} - -#endif // COMPILER1 - -#ifdef COMPILER2 - -OptoReg::Name XBarrierSetAssembler::refine_register(const Node* node, OptoReg::Name opto_reg) { - if (!OptoReg::is_reg(opto_reg)) { - return OptoReg::Bad; - } - - const VMReg vm_reg = OptoReg::as_VMReg(opto_reg); - if (vm_reg->is_XMMRegister()) { - opto_reg &= ~15; - switch (node->ideal_reg()) { - case Op_VecX: - opto_reg |= 2; - break; - case Op_VecY: - opto_reg |= 4; - break; - case Op_VecZ: - opto_reg |= 8; - break; - default: - opto_reg |= 1; - break; - } - } - - return opto_reg; -} - -// We use the vec_spill_helper from the x86.ad file to avoid reinventing this wheel -extern void vec_spill_helper(C2_MacroAssembler *masm, bool is_load, - int stack_offset, int reg, uint ireg, outputStream* st); - -#undef __ -#define __ _masm-> - -class XSaveLiveRegisters { -private: - struct XMMRegisterData { - XMMRegister _reg; - int _size; - - // Used by GrowableArray::find() - bool operator == (const XMMRegisterData& other) { - return _reg == other._reg; - } - }; - - MacroAssembler* const _masm; - GrowableArray _gp_registers; - GrowableArray _opmask_registers; - GrowableArray _xmm_registers; - int _spill_size; - int _spill_offset; - - static int xmm_compare_register_size(XMMRegisterData* left, XMMRegisterData* right) { - if (left->_size == right->_size) { - return 0; - } - - return (left->_size < right->_size) ? -1 : 1; - } - - static int xmm_slot_size(OptoReg::Name opto_reg) { - // The low order 4 bytes denote what size of the XMM register is live - return (opto_reg & 15) << 3; - } - - static uint xmm_ideal_reg_for_size(int reg_size) { - switch (reg_size) { - case 8: - return Op_VecD; - case 16: - return Op_VecX; - case 32: - return Op_VecY; - case 64: - return Op_VecZ; - default: - fatal("Invalid register size %d", reg_size); - return 0; - } - } - - bool xmm_needs_vzeroupper() const { - return _xmm_registers.is_nonempty() && _xmm_registers.at(0)._size > 16; - } - - void xmm_register_save(const XMMRegisterData& reg_data) { - const OptoReg::Name opto_reg = OptoReg::as_OptoReg(reg_data._reg->as_VMReg()); - const uint ideal_reg = xmm_ideal_reg_for_size(reg_data._size); - _spill_offset -= reg_data._size; - C2_MacroAssembler c2_masm(__ code()); - vec_spill_helper(&c2_masm, false /* is_load */, _spill_offset, opto_reg, ideal_reg, tty); - } - - void xmm_register_restore(const XMMRegisterData& reg_data) { - const OptoReg::Name opto_reg = OptoReg::as_OptoReg(reg_data._reg->as_VMReg()); - const uint ideal_reg = xmm_ideal_reg_for_size(reg_data._size); - C2_MacroAssembler c2_masm(__ code()); - vec_spill_helper(&c2_masm, true /* is_load */, _spill_offset, opto_reg, ideal_reg, tty); - _spill_offset += reg_data._size; - } - - void gp_register_save(Register reg) { - _spill_offset -= 8; - __ movq(Address(rsp, _spill_offset), reg); - } - - void opmask_register_save(KRegister reg) { - _spill_offset -= 8; - __ kmov(Address(rsp, _spill_offset), reg); - } - - void gp_register_restore(Register reg) { - __ movq(reg, Address(rsp, _spill_offset)); - _spill_offset += 8; - } - - void opmask_register_restore(KRegister reg) { - __ kmov(reg, Address(rsp, _spill_offset)); - _spill_offset += 8; - } - - void initialize(XLoadBarrierStubC2* stub) { - // Create mask of caller saved registers that need to - // be saved/restored if live - RegMask caller_saved; - caller_saved.Insert(OptoReg::as_OptoReg(rax->as_VMReg())); - caller_saved.Insert(OptoReg::as_OptoReg(rcx->as_VMReg())); - caller_saved.Insert(OptoReg::as_OptoReg(rdx->as_VMReg())); - caller_saved.Insert(OptoReg::as_OptoReg(rsi->as_VMReg())); - caller_saved.Insert(OptoReg::as_OptoReg(rdi->as_VMReg())); - caller_saved.Insert(OptoReg::as_OptoReg(r8->as_VMReg())); - caller_saved.Insert(OptoReg::as_OptoReg(r9->as_VMReg())); - caller_saved.Insert(OptoReg::as_OptoReg(r10->as_VMReg())); - caller_saved.Insert(OptoReg::as_OptoReg(r11->as_VMReg())); - caller_saved.Remove(OptoReg::as_OptoReg(stub->ref()->as_VMReg())); - - if (UseAPX) { - caller_saved.Insert(OptoReg::as_OptoReg(r16->as_VMReg())); - caller_saved.Insert(OptoReg::as_OptoReg(r17->as_VMReg())); - caller_saved.Insert(OptoReg::as_OptoReg(r18->as_VMReg())); - caller_saved.Insert(OptoReg::as_OptoReg(r19->as_VMReg())); - caller_saved.Insert(OptoReg::as_OptoReg(r20->as_VMReg())); - caller_saved.Insert(OptoReg::as_OptoReg(r21->as_VMReg())); - caller_saved.Insert(OptoReg::as_OptoReg(r22->as_VMReg())); - caller_saved.Insert(OptoReg::as_OptoReg(r23->as_VMReg())); - caller_saved.Insert(OptoReg::as_OptoReg(r24->as_VMReg())); - caller_saved.Insert(OptoReg::as_OptoReg(r25->as_VMReg())); - caller_saved.Insert(OptoReg::as_OptoReg(r26->as_VMReg())); - caller_saved.Insert(OptoReg::as_OptoReg(r27->as_VMReg())); - caller_saved.Insert(OptoReg::as_OptoReg(r28->as_VMReg())); - caller_saved.Insert(OptoReg::as_OptoReg(r29->as_VMReg())); - caller_saved.Insert(OptoReg::as_OptoReg(r30->as_VMReg())); - caller_saved.Insert(OptoReg::as_OptoReg(r31->as_VMReg())); - } - - // Create mask of live registers - RegMask live = stub->live(); - if (stub->tmp() != noreg) { - live.Insert(OptoReg::as_OptoReg(stub->tmp()->as_VMReg())); - } - - int gp_spill_size = 0; - int opmask_spill_size = 0; - int xmm_spill_size = 0; - - // Record registers that needs to be saved/restored - RegMaskIterator rmi(live); - while (rmi.has_next()) { - const OptoReg::Name opto_reg = rmi.next(); - const VMReg vm_reg = OptoReg::as_VMReg(opto_reg); - - if (vm_reg->is_Register()) { - if (caller_saved.Member(opto_reg)) { - _gp_registers.append(vm_reg->as_Register()); - gp_spill_size += 8; - } - } else if (vm_reg->is_KRegister()) { - // All opmask registers are caller saved, thus spill the ones - // which are live. - if (_opmask_registers.find(vm_reg->as_KRegister()) == -1) { - _opmask_registers.append(vm_reg->as_KRegister()); - opmask_spill_size += 8; - } - } else if (vm_reg->is_XMMRegister()) { - // We encode in the low order 4 bits of the opto_reg, how large part of the register is live - const VMReg vm_reg_base = OptoReg::as_VMReg(opto_reg & ~15); - const int reg_size = xmm_slot_size(opto_reg); - const XMMRegisterData reg_data = { vm_reg_base->as_XMMRegister(), reg_size }; - const int reg_index = _xmm_registers.find(reg_data); - if (reg_index == -1) { - // Not previously appended - _xmm_registers.append(reg_data); - xmm_spill_size += reg_size; - } else { - // Previously appended, update size - const int reg_size_prev = _xmm_registers.at(reg_index)._size; - if (reg_size > reg_size_prev) { - _xmm_registers.at_put(reg_index, reg_data); - xmm_spill_size += reg_size - reg_size_prev; - } - } - } else { - fatal("Unexpected register type"); - } - } - - // Sort by size, largest first - _xmm_registers.sort(xmm_compare_register_size); - - // On Windows, the caller reserves stack space for spilling register arguments - const int arg_spill_size = frame::arg_reg_save_area_bytes; - - // Stack pointer must be 16 bytes aligned for the call - _spill_offset = _spill_size = align_up(xmm_spill_size + gp_spill_size + opmask_spill_size + arg_spill_size, 16); - } - -public: - XSaveLiveRegisters(MacroAssembler* masm, XLoadBarrierStubC2* stub) : - _masm(masm), - _gp_registers(), - _opmask_registers(), - _xmm_registers(), - _spill_size(0), - _spill_offset(0) { - - // - // Stack layout after registers have been spilled: - // - // | ... | original rsp, 16 bytes aligned - // ------------------ - // | zmm0 high | - // | ... | - // | zmm0 low | 16 bytes aligned - // | ... | - // | ymm1 high | - // | ... | - // | ymm1 low | 16 bytes aligned - // | ... | - // | xmmN high | - // | ... | - // | xmmN low | 8 bytes aligned - // | reg0 | 8 bytes aligned - // | reg1 | - // | ... | - // | regN | new rsp, if 16 bytes aligned - // | | else new rsp, 16 bytes aligned - // ------------------ - // - - // Figure out what registers to save/restore - initialize(stub); - - // Allocate stack space - if (_spill_size > 0) { - __ subptr(rsp, _spill_size); - } - - // Save XMM/YMM/ZMM registers - for (int i = 0; i < _xmm_registers.length(); i++) { - xmm_register_save(_xmm_registers.at(i)); - } - - if (xmm_needs_vzeroupper()) { - __ vzeroupper(); - } - - // Save general purpose registers - for (int i = 0; i < _gp_registers.length(); i++) { - gp_register_save(_gp_registers.at(i)); - } - - // Save opmask registers - for (int i = 0; i < _opmask_registers.length(); i++) { - opmask_register_save(_opmask_registers.at(i)); - } - } - - ~XSaveLiveRegisters() { - // Restore opmask registers - for (int i = _opmask_registers.length() - 1; i >= 0; i--) { - opmask_register_restore(_opmask_registers.at(i)); - } - - // Restore general purpose registers - for (int i = _gp_registers.length() - 1; i >= 0; i--) { - gp_register_restore(_gp_registers.at(i)); - } - - __ vzeroupper(); - - // Restore XMM/YMM/ZMM registers - for (int i = _xmm_registers.length() - 1; i >= 0; i--) { - xmm_register_restore(_xmm_registers.at(i)); - } - - // Free stack space - if (_spill_size > 0) { - __ addptr(rsp, _spill_size); - } - } -}; - -class XSetupArguments { -private: - MacroAssembler* const _masm; - const Register _ref; - const Address _ref_addr; - -public: - XSetupArguments(MacroAssembler* masm, XLoadBarrierStubC2* stub) : - _masm(masm), - _ref(stub->ref()), - _ref_addr(stub->ref_addr()) { - - // Setup arguments - if (_ref_addr.base() == noreg) { - // No self healing - if (_ref != c_rarg0) { - __ movq(c_rarg0, _ref); - } - __ xorq(c_rarg1, c_rarg1); - } else { - // Self healing - if (_ref == c_rarg0) { - __ lea(c_rarg1, _ref_addr); - } else if (_ref != c_rarg1) { - __ lea(c_rarg1, _ref_addr); - __ movq(c_rarg0, _ref); - } else if (_ref_addr.base() != c_rarg0 && _ref_addr.index() != c_rarg0) { - __ movq(c_rarg0, _ref); - __ lea(c_rarg1, _ref_addr); - } else { - __ xchgq(c_rarg0, c_rarg1); - if (_ref_addr.base() == c_rarg0) { - __ lea(c_rarg1, Address(c_rarg1, _ref_addr.index(), _ref_addr.scale(), _ref_addr.disp())); - } else if (_ref_addr.index() == c_rarg0) { - __ lea(c_rarg1, Address(_ref_addr.base(), c_rarg1, _ref_addr.scale(), _ref_addr.disp())); - } else { - ShouldNotReachHere(); - } - } - } - } - - ~XSetupArguments() { - // Transfer result - if (_ref != rax) { - __ movq(_ref, rax); - } - } -}; - -#undef __ -#define __ masm-> - -void XBarrierSetAssembler::generate_c2_load_barrier_stub(MacroAssembler* masm, XLoadBarrierStubC2* stub) const { - BLOCK_COMMENT("XLoadBarrierStubC2"); - - // Stub entry - __ bind(*stub->entry()); - - { - XSaveLiveRegisters save_live_registers(masm, stub); - XSetupArguments setup_arguments(masm, stub); - __ call(RuntimeAddress(stub->slow_path())); - } - - // Stub exit - __ jmp(*stub->continuation()); -} - -#endif // COMPILER2 - -#undef __ -#define __ masm-> - -void XBarrierSetAssembler::check_oop(MacroAssembler* masm, Register obj, Register tmp1, Register tmp2, Label& error) { - // Check if metadata bits indicate a bad oop - __ testptr(obj, Address(r15_thread, XThreadLocalData::address_bad_mask_offset())); - __ jcc(Assembler::notZero, error); - BarrierSetAssembler::check_oop(masm, obj, tmp1, tmp2, error); -} - -#undef __ diff --git a/src/hotspot/cpu/x86/gc/x/xBarrierSetAssembler_x86.hpp b/src/hotspot/cpu/x86/gc/x/xBarrierSetAssembler_x86.hpp deleted file mode 100644 index 52034ab786e..00000000000 --- a/src/hotspot/cpu/x86/gc/x/xBarrierSetAssembler_x86.hpp +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) 2018, 2019, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef CPU_X86_GC_X_XBARRIERSETASSEMBLER_X86_HPP -#define CPU_X86_GC_X_XBARRIERSETASSEMBLER_X86_HPP - -#include "code/vmreg.hpp" -#include "oops/accessDecorators.hpp" -#ifdef COMPILER2 -#include "opto/optoreg.hpp" -#endif // COMPILER2 - -class MacroAssembler; - -#ifdef COMPILER1 -class LIR_Assembler; -class LIR_Opr; -class StubAssembler; -#endif // COMPILER1 - -#ifdef COMPILER2 -class Node; -#endif // COMPILER2 - -#ifdef COMPILER1 -class XLoadBarrierStubC1; -#endif // COMPILER1 - -#ifdef COMPILER2 -class XLoadBarrierStubC2; -#endif // COMPILER2 - -class XBarrierSetAssembler : public XBarrierSetAssemblerBase { -public: - virtual void load_at(MacroAssembler* masm, - DecoratorSet decorators, - BasicType type, - Register dst, - Address src, - Register tmp1, - Register tmp_thread); - -#ifdef ASSERT - virtual void store_at(MacroAssembler* masm, - DecoratorSet decorators, - BasicType type, - Address dst, - Register src, - Register tmp1, - Register tmp2, - Register tmp3); -#endif // ASSERT - - virtual void arraycopy_prologue(MacroAssembler* masm, - DecoratorSet decorators, - BasicType type, - Register src, - Register dst, - Register count); - - virtual void try_resolve_jobject_in_native(MacroAssembler* masm, - Register jni_env, - Register obj, - Register tmp, - Label& slowpath); - -#ifdef COMPILER1 - void generate_c1_load_barrier_test(LIR_Assembler* ce, - LIR_Opr ref) const; - - void generate_c1_load_barrier_stub(LIR_Assembler* ce, - XLoadBarrierStubC1* stub) const; - - void generate_c1_load_barrier_runtime_stub(StubAssembler* sasm, - DecoratorSet decorators) const; -#endif // COMPILER1 - -#ifdef COMPILER2 - OptoReg::Name refine_register(const Node* node, - OptoReg::Name opto_reg); - - void generate_c2_load_barrier_stub(MacroAssembler* masm, - XLoadBarrierStubC2* stub) const; -#endif // COMPILER2 - - void check_oop(MacroAssembler* masm, Register obj, Register tmp1, Register tmp2, Label& error); -}; - -#endif // CPU_X86_GC_X_XBARRIERSETASSEMBLER_X86_HPP diff --git a/src/hotspot/cpu/x86/gc/x/xGlobals_x86.cpp b/src/hotspot/cpu/x86/gc/x/xGlobals_x86.cpp deleted file mode 100644 index baa99ddd60d..00000000000 --- a/src/hotspot/cpu/x86/gc/x/xGlobals_x86.cpp +++ /dev/null @@ -1,149 +0,0 @@ -/* - * Copyright (c) 2017, 2021, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/shared/gc_globals.hpp" -#include "gc/x/xGlobals.hpp" -#include "runtime/globals.hpp" -#include "utilities/globalDefinitions.hpp" -#include "utilities/powerOfTwo.hpp" - -// -// The heap can have three different layouts, depending on the max heap size. -// -// Address Space & Pointer Layout 1 -// -------------------------------- -// -// +--------------------------------+ 0x00007FFFFFFFFFFF (127TB) -// . . -// . . -// . . -// +--------------------------------+ 0x0000014000000000 (20TB) -// | Remapped View | -// +--------------------------------+ 0x0000010000000000 (16TB) -// . . -// +--------------------------------+ 0x00000c0000000000 (12TB) -// | Marked1 View | -// +--------------------------------+ 0x0000080000000000 (8TB) -// | Marked0 View | -// +--------------------------------+ 0x0000040000000000 (4TB) -// . . -// +--------------------------------+ 0x0000000000000000 -// -// 6 4 4 4 4 -// 3 6 5 2 1 0 -// +--------------------+----+-----------------------------------------------+ -// |00000000 00000000 00|1111|11 11111111 11111111 11111111 11111111 11111111| -// +--------------------+----+-----------------------------------------------+ -// | | | -// | | * 41-0 Object Offset (42-bits, 4TB address space) -// | | -// | * 45-42 Metadata Bits (4-bits) 0001 = Marked0 (Address view 4-8TB) -// | 0010 = Marked1 (Address view 8-12TB) -// | 0100 = Remapped (Address view 16-20TB) -// | 1000 = Finalizable (Address view N/A) -// | -// * 63-46 Fixed (18-bits, always zero) -// -// -// Address Space & Pointer Layout 2 -// -------------------------------- -// -// +--------------------------------+ 0x00007FFFFFFFFFFF (127TB) -// . . -// . . -// . . -// +--------------------------------+ 0x0000280000000000 (40TB) -// | Remapped View | -// +--------------------------------+ 0x0000200000000000 (32TB) -// . . -// +--------------------------------+ 0x0000180000000000 (24TB) -// | Marked1 View | -// +--------------------------------+ 0x0000100000000000 (16TB) -// | Marked0 View | -// +--------------------------------+ 0x0000080000000000 (8TB) -// . . -// +--------------------------------+ 0x0000000000000000 -// -// 6 4 4 4 4 -// 3 7 6 3 2 0 -// +------------------+-----+------------------------------------------------+ -// |00000000 00000000 0|1111|111 11111111 11111111 11111111 11111111 11111111| -// +-------------------+----+------------------------------------------------+ -// | | | -// | | * 42-0 Object Offset (43-bits, 8TB address space) -// | | -// | * 46-43 Metadata Bits (4-bits) 0001 = Marked0 (Address view 8-16TB) -// | 0010 = Marked1 (Address view 16-24TB) -// | 0100 = Remapped (Address view 32-40TB) -// | 1000 = Finalizable (Address view N/A) -// | -// * 63-47 Fixed (17-bits, always zero) -// -// -// Address Space & Pointer Layout 3 -// -------------------------------- -// -// +--------------------------------+ 0x00007FFFFFFFFFFF (127TB) -// . . -// . . -// . . -// +--------------------------------+ 0x0000500000000000 (80TB) -// | Remapped View | -// +--------------------------------+ 0x0000400000000000 (64TB) -// . . -// +--------------------------------+ 0x0000300000000000 (48TB) -// | Marked1 View | -// +--------------------------------+ 0x0000200000000000 (32TB) -// | Marked0 View | -// +--------------------------------+ 0x0000100000000000 (16TB) -// . . -// +--------------------------------+ 0x0000000000000000 -// -// 6 4 4 4 4 -// 3 8 7 4 3 0 -// +------------------+----+-------------------------------------------------+ -// |00000000 00000000 |1111|1111 11111111 11111111 11111111 11111111 11111111| -// +------------------+----+-------------------------------------------------+ -// | | | -// | | * 43-0 Object Offset (44-bits, 16TB address space) -// | | -// | * 47-44 Metadata Bits (4-bits) 0001 = Marked0 (Address view 16-32TB) -// | 0010 = Marked1 (Address view 32-48TB) -// | 0100 = Remapped (Address view 64-80TB) -// | 1000 = Finalizable (Address view N/A) -// | -// * 63-48 Fixed (16-bits, always zero) -// - -size_t XPlatformAddressOffsetBits() { - const size_t min_address_offset_bits = 42; // 4TB - const size_t max_address_offset_bits = 44; // 16TB - const size_t address_offset = round_up_power_of_2(MaxHeapSize * XVirtualToPhysicalRatio); - const size_t address_offset_bits = log2i_exact(address_offset); - return clamp(address_offset_bits, min_address_offset_bits, max_address_offset_bits); -} - -size_t XPlatformAddressMetadataShift() { - return XPlatformAddressOffsetBits(); -} diff --git a/src/hotspot/cpu/x86/gc/x/xGlobals_x86.hpp b/src/hotspot/cpu/x86/gc/x/xGlobals_x86.hpp deleted file mode 100644 index dd00d4ddadc..00000000000 --- a/src/hotspot/cpu/x86/gc/x/xGlobals_x86.hpp +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2015, 2022, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef CPU_X86_GC_X_XGLOBALS_X86_HPP -#define CPU_X86_GC_X_XGLOBALS_X86_HPP - -const size_t XPlatformHeapViews = 3; -const size_t XPlatformCacheLineSize = 64; - -size_t XPlatformAddressOffsetBits(); -size_t XPlatformAddressMetadataShift(); - -#endif // CPU_X86_GC_X_XGLOBALS_X86_HPP diff --git a/src/hotspot/cpu/x86/gc/x/x_x86_64.ad b/src/hotspot/cpu/x86/gc/x/x_x86_64.ad deleted file mode 100644 index ba4b3cb6df0..00000000000 --- a/src/hotspot/cpu/x86/gc/x/x_x86_64.ad +++ /dev/null @@ -1,156 +0,0 @@ -// -// Copyright (c) 2015, 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 -// under the terms of the GNU General Public License version 2 only, as -// published by the Free Software Foundation. -// -// This code is distributed in the hope that it will be useful, but WITHOUT -// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -// version 2 for more details (a copy is included in the LICENSE file that -// accompanied this code). -// -// You should have received a copy of the GNU General Public License version -// 2 along with this work; if not, write to the Free Software Foundation, -// Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -// -// Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -// or visit www.oracle.com if you need additional information or have any -// questions. -// - -source_hpp %{ - -#include "gc/shared/gc_globals.hpp" -#include "gc/x/c2/xBarrierSetC2.hpp" -#include "gc/x/xThreadLocalData.hpp" - -%} - -source %{ - -#include "c2_intelJccErratum_x86.hpp" - -static void x_load_barrier(MacroAssembler* masm, const MachNode* node, Address ref_addr, Register ref, Register tmp, uint8_t barrier_data) { - if (barrier_data == XLoadBarrierElided) { - return; - } - XLoadBarrierStubC2* const stub = XLoadBarrierStubC2::create(node, ref_addr, ref, tmp, barrier_data); - { - IntelJccErratumAlignment intel_alignment(masm, 10 /* jcc_size */); - __ testptr(ref, Address(r15_thread, XThreadLocalData::address_bad_mask_offset())); - __ jcc(Assembler::notZero, *stub->entry()); - } - __ bind(*stub->continuation()); -} - -static void x_load_barrier_cmpxchg(MacroAssembler* masm, const MachNode* node, Address ref_addr, Register ref, Register tmp, Label& good) { - XLoadBarrierStubC2* const stub = XLoadBarrierStubC2::create(node, ref_addr, ref, tmp, XLoadBarrierStrong); - { - IntelJccErratumAlignment intel_alignment(masm, 10 /* jcc_size */); - __ testptr(ref, Address(r15_thread, XThreadLocalData::address_bad_mask_offset())); - __ jcc(Assembler::zero, good); - } - { - IntelJccErratumAlignment intel_alignment(masm, 5 /* jcc_size */); - __ jmp(*stub->entry()); - } - __ bind(*stub->continuation()); -} - -static void x_cmpxchg_common(MacroAssembler* masm, const MachNode* node, Register mem_reg, Register newval, Register tmp) { - // Compare value (oldval) is in rax - const Address mem = Address(mem_reg, 0); - - if (node->barrier_data() != XLoadBarrierElided) { - __ movptr(tmp, rax); - } - - __ lock(); - __ cmpxchgptr(newval, mem); - - if (node->barrier_data() != XLoadBarrierElided) { - Label good; - x_load_barrier_cmpxchg(masm, node, mem, rax, tmp, good); - __ movptr(rax, tmp); - __ lock(); - __ cmpxchgptr(newval, mem); - __ bind(good); - } -} - -%} - -// Load Pointer -instruct xLoadP(rRegP dst, memory mem, rFlagsReg cr) -%{ - predicate(UseZGC && !ZGenerational && n->as_Load()->barrier_data() != 0); - match(Set dst (LoadP mem)); - effect(KILL cr, TEMP dst); - - ins_cost(125); - - format %{ "movq $dst, $mem" %} - - ins_encode %{ - __ movptr($dst$$Register, $mem$$Address); - x_load_barrier(masm, this, $mem$$Address, $dst$$Register, noreg /* tmp */, barrier_data()); - %} - - ins_pipe(ialu_reg_mem); -%} - -instruct xCompareAndExchangeP(indirect mem, rax_RegP oldval, rRegP newval, rRegP tmp, rFlagsReg cr) %{ - match(Set oldval (CompareAndExchangeP mem (Binary oldval newval))); - predicate(UseZGC && !ZGenerational && n->as_LoadStore()->barrier_data() == XLoadBarrierStrong); - effect(KILL cr, TEMP tmp); - - format %{ "lock\n\t" - "cmpxchgq $newval, $mem" %} - - ins_encode %{ - precond($oldval$$Register == rax); - x_cmpxchg_common(masm, this, $mem$$Register, $newval$$Register, $tmp$$Register); - %} - - ins_pipe(pipe_cmpxchg); -%} - -instruct xCompareAndSwapP(rRegI res, indirect mem, rRegP newval, rRegP tmp, rFlagsReg cr, rax_RegP oldval) %{ - match(Set res (CompareAndSwapP mem (Binary oldval newval))); - match(Set res (WeakCompareAndSwapP mem (Binary oldval newval))); - predicate(UseZGC && !ZGenerational && n->as_LoadStore()->barrier_data() == XLoadBarrierStrong); - effect(KILL cr, KILL oldval, TEMP tmp); - - format %{ "lock\n\t" - "cmpxchgq $newval, $mem\n\t" - "setcc $res \t# emits sete + movzbl or setzue for APX" %} - - ins_encode %{ - precond($oldval$$Register == rax); - x_cmpxchg_common(masm, this, $mem$$Register, $newval$$Register, $tmp$$Register); - if (barrier_data() != XLoadBarrierElided) { - __ cmpptr($tmp$$Register, rax); - } - __ setcc(Assembler::equal, $res$$Register); - %} - - ins_pipe(pipe_cmpxchg); -%} - -instruct xXChgP(indirect mem, rRegP newval, rFlagsReg cr) %{ - match(Set newval (GetAndSetP mem newval)); - predicate(UseZGC && !ZGenerational && n->as_LoadStore()->barrier_data() != 0); - effect(KILL cr); - - format %{ "xchgq $newval, $mem" %} - - ins_encode %{ - __ xchgptr($newval$$Register, Address($mem$$Register, 0)); - x_load_barrier(masm, this, Address(noreg, 0), $newval$$Register, noreg /* tmp */, barrier_data()); - %} - - ins_pipe(pipe_cmpxchg); -%} diff --git a/src/hotspot/cpu/x86/gc/z/zBarrierSetAssembler_x86.cpp b/src/hotspot/cpu/x86/gc/z/zBarrierSetAssembler_x86.cpp index bc51a2b4468..3795b1fc176 100644 --- a/src/hotspot/cpu/x86/gc/z/zBarrierSetAssembler_x86.cpp +++ b/src/hotspot/cpu/x86/gc/z/zBarrierSetAssembler_x86.cpp @@ -363,8 +363,12 @@ static void emit_store_fast_path_check_c2(MacroAssembler* masm, Address ref_addr } static bool is_c2_compilation() { +#ifdef COMPILER2 CompileTask* task = ciEnv::current()->task(); return task != nullptr && is_c2_compile(task->comp_level()); +#else + return false; +#endif } void ZBarrierSetAssembler::store_barrier_fast(MacroAssembler* masm, diff --git a/src/hotspot/cpu/x86/gc/z/z_x86_64.ad b/src/hotspot/cpu/x86/gc/z/z_x86_64.ad index f55ad70e861..9555cadd022 100644 --- a/src/hotspot/cpu/x86/gc/z/z_x86_64.ad +++ b/src/hotspot/cpu/x86/gc/z/z_x86_64.ad @@ -115,7 +115,7 @@ operand no_rax_RegP() // Load Pointer instruct zLoadP(rRegP dst, memory mem, rFlagsReg cr) %{ - predicate(UseZGC && ZGenerational && n->as_Load()->barrier_data() != 0); + predicate(UseZGC && n->as_Load()->barrier_data() != 0); match(Set dst (LoadP mem)); effect(TEMP dst, KILL cr); @@ -134,7 +134,7 @@ instruct zLoadP(rRegP dst, memory mem, rFlagsReg cr) // Load Pointer and Null Check instruct zLoadPNullCheck(rFlagsReg cr, memory op, immP0 zero) %{ - predicate(UseZGC && ZGenerational && n->in(1)->as_Load()->barrier_data() != 0); + predicate(UseZGC && n->in(1)->as_Load()->barrier_data() != 0); match(Set cr (CmpP (LoadP op) zero)); ins_cost(500); // XXX @@ -150,7 +150,7 @@ instruct zLoadPNullCheck(rFlagsReg cr, memory op, immP0 zero) // Store Pointer instruct zStoreP(memory mem, any_RegP src, rRegP tmp, rFlagsReg cr) %{ - predicate(UseZGC && ZGenerational && n->as_Store()->barrier_data() != 0); + predicate(UseZGC && n->as_Store()->barrier_data() != 0); match(Set mem (StoreP mem src)); effect(TEMP tmp, KILL cr); @@ -166,7 +166,7 @@ instruct zStoreP(memory mem, any_RegP src, rRegP tmp, rFlagsReg cr) // Store Null Pointer instruct zStorePNull(memory mem, immP0 zero, rRegP tmp, rFlagsReg cr) %{ - predicate(UseZGC && ZGenerational && n->as_Store()->barrier_data() != 0); + predicate(UseZGC && n->as_Store()->barrier_data() != 0); match(Set mem (StoreP mem zero)); effect(TEMP tmp, KILL cr); @@ -185,7 +185,7 @@ instruct zStorePNull(memory mem, immP0 zero, rRegP tmp, rFlagsReg cr) instruct zCompareAndExchangeP(indirect mem, no_rax_RegP newval, rRegP tmp, rax_RegP oldval, rFlagsReg cr) %{ match(Set oldval (CompareAndExchangeP mem (Binary oldval newval))); - predicate(UseZGC && ZGenerational && n->as_LoadStore()->barrier_data() != 0); + predicate(UseZGC && n->as_LoadStore()->barrier_data() != 0); effect(TEMP tmp, KILL cr); format %{ "lock\n\t" @@ -208,7 +208,7 @@ instruct zCompareAndExchangeP(indirect mem, no_rax_RegP newval, rRegP tmp, rax_R instruct zCompareAndSwapP(rRegI res, indirect mem, rRegP newval, rRegP tmp, rax_RegP oldval, rFlagsReg cr) %{ match(Set res (CompareAndSwapP mem (Binary oldval newval))); match(Set res (WeakCompareAndSwapP mem (Binary oldval newval))); - predicate(UseZGC && ZGenerational && n->as_LoadStore()->barrier_data() != 0); + predicate(UseZGC && n->as_LoadStore()->barrier_data() != 0); effect(TEMP tmp, KILL oldval, KILL cr); format %{ "lock\n\t" @@ -230,7 +230,7 @@ instruct zCompareAndSwapP(rRegI res, indirect mem, rRegP newval, rRegP tmp, rax_ instruct zXChgP(indirect mem, rRegP newval, rRegP tmp, rFlagsReg cr) %{ match(Set newval (GetAndSetP mem newval)); - predicate(UseZGC && ZGenerational && n->as_LoadStore()->barrier_data() != 0); + predicate(UseZGC && n->as_LoadStore()->barrier_data() != 0); effect(TEMP tmp, KILL cr); format %{ "xchgq $newval, $mem" %} diff --git a/src/hotspot/cpu/x86/macroAssembler_x86.cpp b/src/hotspot/cpu/x86/macroAssembler_x86.cpp index 1a69b4c1ad7..55c4e29b8a3 100644 --- a/src/hotspot/cpu/x86/macroAssembler_x86.cpp +++ b/src/hotspot/cpu/x86/macroAssembler_x86.cpp @@ -9314,6 +9314,30 @@ void MacroAssembler::byte_array_inflate(Register src, Register dst, Register len bind(done); } +void MacroAssembler::evmovdqu(BasicType type, KRegister kmask, XMMRegister dst, XMMRegister src, bool merge, int vector_len) { + switch(type) { + case T_BYTE: + case T_BOOLEAN: + evmovdqub(dst, kmask, src, merge, vector_len); + break; + case T_CHAR: + case T_SHORT: + evmovdquw(dst, kmask, src, merge, vector_len); + break; + case T_INT: + case T_FLOAT: + evmovdqul(dst, kmask, src, merge, vector_len); + break; + case T_LONG: + case T_DOUBLE: + evmovdquq(dst, kmask, src, merge, vector_len); + break; + default: + fatal("Unexpected type argument %s", type2name(type)); + break; + } +} + void MacroAssembler::evmovdqu(BasicType type, KRegister kmask, XMMRegister dst, Address src, bool merge, int vector_len) { switch(type) { @@ -9505,6 +9529,66 @@ void MacroAssembler::evperm(BasicType type, XMMRegister dst, KRegister mask, XMM } } +void MacroAssembler::evpminu(BasicType type, XMMRegister dst, KRegister mask, XMMRegister nds, Address src, bool merge, int vector_len) { + switch(type) { + case T_BYTE: + evpminub(dst, mask, nds, src, merge, vector_len); break; + case T_SHORT: + evpminuw(dst, mask, nds, src, merge, vector_len); break; + case T_INT: + evpminud(dst, mask, nds, src, merge, vector_len); break; + case T_LONG: + evpminuq(dst, mask, nds, src, merge, vector_len); break; + default: + fatal("Unexpected type argument %s", type2name(type)); break; + } +} + +void MacroAssembler::evpmaxu(BasicType type, XMMRegister dst, KRegister mask, XMMRegister nds, Address src, bool merge, int vector_len) { + switch(type) { + case T_BYTE: + evpmaxub(dst, mask, nds, src, merge, vector_len); break; + case T_SHORT: + evpmaxuw(dst, mask, nds, src, merge, vector_len); break; + case T_INT: + evpmaxud(dst, mask, nds, src, merge, vector_len); break; + case T_LONG: + evpmaxuq(dst, mask, nds, src, merge, vector_len); break; + default: + fatal("Unexpected type argument %s", type2name(type)); break; + } +} + +void MacroAssembler::evpminu(BasicType type, XMMRegister dst, KRegister mask, XMMRegister nds, XMMRegister src, bool merge, int vector_len) { + switch(type) { + case T_BYTE: + evpminub(dst, mask, nds, src, merge, vector_len); break; + case T_SHORT: + evpminuw(dst, mask, nds, src, merge, vector_len); break; + case T_INT: + evpminud(dst, mask, nds, src, merge, vector_len); break; + case T_LONG: + evpminuq(dst, mask, nds, src, merge, vector_len); break; + default: + fatal("Unexpected type argument %s", type2name(type)); break; + } +} + +void MacroAssembler::evpmaxu(BasicType type, XMMRegister dst, KRegister mask, XMMRegister nds, XMMRegister src, bool merge, int vector_len) { + switch(type) { + case T_BYTE: + evpmaxub(dst, mask, nds, src, merge, vector_len); break; + case T_SHORT: + evpmaxuw(dst, mask, nds, src, merge, vector_len); break; + case T_INT: + evpmaxud(dst, mask, nds, src, merge, vector_len); break; + case T_LONG: + evpmaxuq(dst, mask, nds, src, merge, vector_len); break; + default: + fatal("Unexpected type argument %s", type2name(type)); break; + } +} + void MacroAssembler::evpmins(BasicType type, XMMRegister dst, KRegister mask, XMMRegister nds, Address src, bool merge, int vector_len) { switch(type) { case T_BYTE: @@ -10213,17 +10297,6 @@ Assembler::Condition MacroAssembler::negate_condition(Assembler::Condition cond) ShouldNotReachHere(); return Assembler::overflow; } -SkipIfEqual::SkipIfEqual( - MacroAssembler* masm, const bool* flag_addr, bool value, Register rscratch) { - _masm = masm; - _masm->cmp8(ExternalAddress((address)flag_addr), value, rscratch); - _masm->jcc(Assembler::equal, _label); -} - -SkipIfEqual::~SkipIfEqual() { - _masm->bind(_label); -} - // 32-bit Windows has its own fast-path implementation // of get_thread #if !defined(WIN32) || defined(_LP64) diff --git a/src/hotspot/cpu/x86/macroAssembler_x86.hpp b/src/hotspot/cpu/x86/macroAssembler_x86.hpp index e6de99eb207..d508feed93c 100644 --- a/src/hotspot/cpu/x86/macroAssembler_x86.hpp +++ b/src/hotspot/cpu/x86/macroAssembler_x86.hpp @@ -1282,6 +1282,7 @@ class MacroAssembler: public Assembler { // AVX512 Unaligned void evmovdqu(BasicType type, KRegister kmask, Address dst, XMMRegister src, bool merge, int vector_len); void evmovdqu(BasicType type, KRegister kmask, XMMRegister dst, Address src, bool merge, int vector_len); + void evmovdqu(BasicType type, KRegister kmask, XMMRegister dst, XMMRegister src, bool merge, int vector_len); void evmovdqub(XMMRegister dst, XMMRegister src, int vector_len) { Assembler::evmovdqub(dst, src, vector_len); } void evmovdqub(XMMRegister dst, Address src, int vector_len) { Assembler::evmovdqub(dst, src, vector_len); } @@ -1295,6 +1296,7 @@ class MacroAssembler: public Assembler { void evmovdqub(XMMRegister dst, KRegister mask, Address src, bool merge, int vector_len) { Assembler::evmovdqub(dst, mask, src, merge, vector_len); } void evmovdqub(XMMRegister dst, KRegister mask, AddressLiteral src, bool merge, int vector_len, Register rscratch = noreg); + void evmovdquw(XMMRegister dst, XMMRegister src, int vector_len) { Assembler::evmovdquw(dst, src, vector_len); } void evmovdquw(Address dst, XMMRegister src, int vector_len) { Assembler::evmovdquw(dst, src, vector_len); } void evmovdquw(XMMRegister dst, Address src, int vector_len) { Assembler::evmovdquw(dst, src, vector_len); } @@ -1505,6 +1507,8 @@ class MacroAssembler: public Assembler { void vpmulld(XMMRegister dst, XMMRegister nds, Address src, int vector_len) { Assembler::vpmulld(dst, nds, src, vector_len); } void vpmulld(XMMRegister dst, XMMRegister nds, AddressLiteral src, int vector_len, Register rscratch = noreg); + void vpmuldq(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len) { Assembler::vpmuldq(dst, nds, src, vector_len); } + void vpsubb(XMMRegister dst, XMMRegister nds, XMMRegister src, int vector_len); void vpsubb(XMMRegister dst, XMMRegister nds, Address src, int vector_len); @@ -1514,9 +1518,13 @@ class MacroAssembler: public Assembler { void vpsraw(XMMRegister dst, XMMRegister nds, XMMRegister shift, int vector_len); void vpsraw(XMMRegister dst, XMMRegister nds, int shift, int vector_len); + void evpsrad(XMMRegister dst, XMMRegister nds, XMMRegister shift, int vector_len); + void evpsrad(XMMRegister dst, XMMRegister nds, int shift, int vector_len); + void evpsraq(XMMRegister dst, XMMRegister nds, XMMRegister shift, int vector_len); void evpsraq(XMMRegister dst, XMMRegister nds, int shift, int vector_len); + using Assembler::evpsllw; void evpsllw(XMMRegister dst, KRegister mask, XMMRegister nds, XMMRegister src, bool merge, int vector_len, bool is_varshift) { if (!is_varshift) { Assembler::evpsllw(dst, mask, nds, src, merge, vector_len); @@ -1561,6 +1569,7 @@ class MacroAssembler: public Assembler { Assembler::evpsrlvq(dst, mask, nds, src, merge, vector_len); } } + using Assembler::evpsraw; void evpsraw(XMMRegister dst, KRegister mask, XMMRegister nds, XMMRegister src, bool merge, int vector_len, bool is_varshift) { if (!is_varshift) { Assembler::evpsraw(dst, mask, nds, src, merge, vector_len); @@ -1568,6 +1577,7 @@ class MacroAssembler: public Assembler { Assembler::evpsravw(dst, mask, nds, src, merge, vector_len); } } + using Assembler::evpsrad; void evpsrad(XMMRegister dst, KRegister mask, XMMRegister nds, XMMRegister src, bool merge, int vector_len, bool is_varshift) { if (!is_varshift) { Assembler::evpsrad(dst, mask, nds, src, merge, vector_len); @@ -1589,6 +1599,11 @@ class MacroAssembler: public Assembler { void evpmins(BasicType type, XMMRegister dst, KRegister mask, XMMRegister nds, Address src, bool merge, int vector_len); void evpmaxs(BasicType type, XMMRegister dst, KRegister mask, XMMRegister nds, Address src, bool merge, int vector_len); + void evpminu(BasicType type, XMMRegister dst, KRegister mask, XMMRegister nds, XMMRegister src, bool merge, int vector_len); + void evpmaxu(BasicType type, XMMRegister dst, KRegister mask, XMMRegister nds, XMMRegister src, bool merge, int vector_len); + void evpminu(BasicType type, XMMRegister dst, KRegister mask, XMMRegister nds, Address src, bool merge, int vector_len); + void evpmaxu(BasicType type, XMMRegister dst, KRegister mask, XMMRegister nds, Address src, bool merge, int vector_len); + void vpsrlw(XMMRegister dst, XMMRegister nds, XMMRegister shift, int vector_len); void vpsrlw(XMMRegister dst, XMMRegister nds, int shift, int vector_len); @@ -2162,22 +2177,4 @@ class MacroAssembler: public Assembler { #endif }; -/** - * class SkipIfEqual: - * - * Instantiating this class will result in assembly code being output that will - * jump around any code emitted between the creation of the instance and it's - * automatic destruction at the end of a scope block, depending on the value of - * the flag passed to the constructor, which will be checked at run-time. - */ -class SkipIfEqual { - private: - MacroAssembler* _masm; - Label _label; - - public: - SkipIfEqual(MacroAssembler*, const bool* flag_addr, bool value, Register rscratch); - ~SkipIfEqual(); -}; - #endif // CPU_X86_MACROASSEMBLER_X86_HPP diff --git a/src/hotspot/cpu/x86/stubGenerator_x86_64.cpp b/src/hotspot/cpu/x86/stubGenerator_x86_64.cpp index e23c83ed197..93b1618024e 100644 --- a/src/hotspot/cpu/x86/stubGenerator_x86_64.cpp +++ b/src/hotspot/cpu/x86/stubGenerator_x86_64.cpp @@ -4032,6 +4032,8 @@ void StubGenerator::generate_compiler_stubs() { generate_chacha_stubs(); + generate_sha3_stubs(); + #ifdef COMPILER2 if ((UseAVX == 2) && EnableX86ECoreOpts) { generate_string_indexof(StubRoutines::_string_indexof_array); diff --git a/src/hotspot/cpu/x86/stubGenerator_x86_64.hpp b/src/hotspot/cpu/x86/stubGenerator_x86_64.hpp index 7280e9fbe95..c6fa31c5213 100644 --- a/src/hotspot/cpu/x86/stubGenerator_x86_64.hpp +++ b/src/hotspot/cpu/x86/stubGenerator_x86_64.hpp @@ -497,6 +497,10 @@ class StubGenerator: public StubCodeGenerator { address generate_intpoly_montgomeryMult_P256(); address generate_intpoly_assign(); + // SHA3 stubs + void generate_sha3_stubs(); + address generate_sha3_implCompress(bool multiBlock, const char *name); + // BASE64 stubs address base64_shuffle_addr(); diff --git a/src/hotspot/cpu/x86/stubGenerator_x86_64_sha3.cpp b/src/hotspot/cpu/x86/stubGenerator_x86_64_sha3.cpp new file mode 100644 index 00000000000..49c39226708 --- /dev/null +++ b/src/hotspot/cpu/x86/stubGenerator_x86_64_sha3.cpp @@ -0,0 +1,326 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +#include "precompiled.hpp" +#include "asm/assembler.hpp" +#include "asm/assembler.inline.hpp" +#include "runtime/stubRoutines.hpp" +#include "macroAssembler_x86.hpp" +#include "stubGenerator_x86_64.hpp" + +#define __ _masm-> + +#ifdef PRODUCT +#define BLOCK_COMMENT(str) /* nothing */ +#else +#define BLOCK_COMMENT(str) __ block_comment(str) +#endif // PRODUCT + +#define BIND(label) bind(label); BLOCK_COMMENT(#label ":") + +// Constants +ATTRIBUTE_ALIGNED(64) static const uint64_t round_consts_arr[24] = { + 0x0000000000000001L, 0x0000000000008082L, 0x800000000000808AL, + 0x8000000080008000L, 0x000000000000808BL, 0x0000000080000001L, + 0x8000000080008081L, 0x8000000000008009L, 0x000000000000008AL, + 0x0000000000000088L, 0x0000000080008009L, 0x000000008000000AL, + 0x000000008000808BL, 0x800000000000008BL, 0x8000000000008089L, + 0x8000000000008003L, 0x8000000000008002L, 0x8000000000000080L, + 0x000000000000800AL, 0x800000008000000AL, 0x8000000080008081L, + 0x8000000000008080L, 0x0000000080000001L, 0x8000000080008008L + }; + +ATTRIBUTE_ALIGNED(64) static const uint64_t permsAndRots[] = { + // permutation in combined rho and pi + 9, 2, 11, 0, 1, 2, 3, 4, // step 1 and 3 + 8, 1, 9, 2, 11, 4, 12, 0, // step 2 + 9, 2, 10, 3, 11, 4, 12, 0, // step 4 + 8, 9, 2, 3, 4, 5, 6, 7, // step 5 + 0, 8, 9, 10, 15, 0, 0, 0, // step 6 + 4, 5, 8, 9, 6, 7, 10, 11, // step 7 and 8 + 0, 1, 2, 3, 13, 0, 0, 0, // step 9 + 2, 3, 0, 1, 11, 0, 0, 0, // step 10 + 4, 5, 6, 7, 14, 0, 0, 0, // step 11 + 14, 15, 12, 13, 4, 0, 0, 0, // step 12 + // size of rotations (after step 5) + 1, 6, 62, 55, 28, 20, 27, 36, + 3, 45, 10, 15, 25, 8, 39, 41, + 44, 43, 21, 18, 2, 61, 56, 14, + // rotation of row elements + 12, 8, 9, 10, 11, 5, 6, 7, + 9, 10, 11, 12, 8, 5, 6, 7 +}; + +static address round_constsAddr() { + return (address) round_consts_arr; +} + +static address permsAndRotsAddr() { + return (address) permsAndRots; +} + +void StubGenerator::generate_sha3_stubs() { + if (UseSHA3Intrinsics) { + StubRoutines::_sha3_implCompress = generate_sha3_implCompress(false,"sha3_implCompress"); + StubRoutines::_sha3_implCompressMB = generate_sha3_implCompress(true, "sha3_implCompressMB"); + } +} + +// Arguments: +// +// Inputs: +// c_rarg0 - byte[] source+offset +// c_rarg1 - long[] SHA3.state +// c_rarg2 - int block_size +// c_rarg3 - int offset +// c_rarg4 - int limit +// +address StubGenerator::generate_sha3_implCompress(bool multiBlock, const char *name) { + __ align(CodeEntryAlignment); + StubCodeMark mark(this, "StubRoutines", name); + address start = __ pc(); + + const Register buf = c_rarg0; + const Register state = c_rarg1; + const Register block_size = c_rarg2; + const Register ofs = c_rarg3; +#ifndef _WIN64 + const Register limit = c_rarg4; +#else + const Address limit_mem(rbp, 6 * wordSize); + const Register limit = r12; +#endif + + const Register permsAndRots = r10; + const Register round_consts = r11; + const Register constant2use = r13; + const Register roundsLeft = r14; + + Label sha3_loop; + Label rounds24_loop, block104, block136, block144, block168; + + __ enter(); + + __ push(r12); + __ push(r13); + __ push(r14); + +#ifdef _WIN64 + // on win64, fill limit from stack position + __ movptr(limit, limit_mem); +#endif + + __ lea(permsAndRots, ExternalAddress(permsAndRotsAddr())); + __ lea(round_consts, ExternalAddress(round_constsAddr())); + + // set up the masks + __ movl(rax, 0x1F); + __ kmovwl(k5, rax); + __ kshiftrwl(k4, k5, 1); + __ kshiftrwl(k3, k5, 2); + __ kshiftrwl(k2, k5, 3); + __ kshiftrwl(k1, k5, 4); + + // load the state + __ evmovdquq(xmm0, k5, Address(state, 0), false, Assembler::AVX_512bit); + __ evmovdquq(xmm1, k5, Address(state, 40), false, Assembler::AVX_512bit); + __ evmovdquq(xmm2, k5, Address(state, 80), false, Assembler::AVX_512bit); + __ evmovdquq(xmm3, k5, Address(state, 120), false, Assembler::AVX_512bit); + __ evmovdquq(xmm4, k5, Address(state, 160), false, Assembler::AVX_512bit); + + // load the permutation and rotation constants + __ evmovdquq(xmm17, Address(permsAndRots, 0), Assembler::AVX_512bit); + __ evmovdquq(xmm18, Address(permsAndRots, 64), Assembler::AVX_512bit); + __ evmovdquq(xmm19, Address(permsAndRots, 128), Assembler::AVX_512bit); + __ evmovdquq(xmm20, Address(permsAndRots, 192), Assembler::AVX_512bit); + __ evmovdquq(xmm21, Address(permsAndRots, 256), Assembler::AVX_512bit); + __ evmovdquq(xmm22, Address(permsAndRots, 320), Assembler::AVX_512bit); + __ evmovdquq(xmm23, Address(permsAndRots, 384), Assembler::AVX_512bit); + __ evmovdquq(xmm24, Address(permsAndRots, 448), Assembler::AVX_512bit); + __ evmovdquq(xmm25, Address(permsAndRots, 512), Assembler::AVX_512bit); + __ evmovdquq(xmm26, Address(permsAndRots, 576), Assembler::AVX_512bit); + __ evmovdquq(xmm27, Address(permsAndRots, 640), Assembler::AVX_512bit); + __ evmovdquq(xmm28, Address(permsAndRots, 704), Assembler::AVX_512bit); + __ evmovdquq(xmm29, Address(permsAndRots, 768), Assembler::AVX_512bit); + __ evmovdquq(xmm30, Address(permsAndRots, 832), Assembler::AVX_512bit); + __ evmovdquq(xmm31, Address(permsAndRots, 896), Assembler::AVX_512bit); + + __ BIND(sha3_loop); + + // there will be 24 keccak rounds + __ movl(roundsLeft, 24); + // load round_constants base + __ movptr(constant2use, round_consts); + + // load input: 72, 104, 136, 144 or 168 bytes + // i.e. 5+4, 2*5+3, 3*5+2, 3*5+3 or 4*5+1 longs + __ evpxorq(xmm0, k5, xmm0, Address(buf, 0), true, Assembler::AVX_512bit); + + // if(blockSize == 72) SHA3-512 + __ cmpl(block_size, 72); + __ jcc(Assembler::notEqual, block104); + __ evpxorq(xmm1, k4, xmm1, Address(buf, 40), true, Assembler::AVX_512bit); + __ jmp(rounds24_loop); + + // if(blockSize == 104) SHA3-384 + __ BIND(block104); + __ cmpl(block_size, 104); + __ jcc(Assembler::notEqual, block136); + __ evpxorq(xmm1, k5, xmm1, Address(buf, 40), true, Assembler::AVX_512bit); + __ evpxorq(xmm2, k3, xmm2, Address(buf, 80), true, Assembler::AVX_512bit); + __ jmp(rounds24_loop); + + // if(blockSize == 136) SHA3-256 and SHAKE256 + __ BIND(block136); + __ cmpl(block_size, 136); + __ jcc(Assembler::notEqual, block144); + __ evpxorq(xmm1, k5, xmm1, Address(buf, 40), true, Assembler::AVX_512bit); + __ evpxorq(xmm2, k5, xmm2, Address(buf, 80), true, Assembler::AVX_512bit); + __ evpxorq(xmm3, k2, xmm3, Address(buf, 120), true, Assembler::AVX_512bit); + __ jmp(rounds24_loop); + + // if(blockSize == 144) SHA3-224 + __ BIND(block144); + __ cmpl(block_size, 144); + __ jcc(Assembler::notEqual, block168); + __ evpxorq(xmm1, k5, xmm1, Address(buf, 40), true, Assembler::AVX_512bit); + __ evpxorq(xmm2, k5, xmm2, Address(buf, 80), true, Assembler::AVX_512bit); + __ evpxorq(xmm3, k3, xmm3, Address(buf, 120), true, Assembler::AVX_512bit); + __ jmp(rounds24_loop); + + // if(blockSize == 168) SHAKE128 + __ BIND(block168); + __ evpxorq(xmm1, k5, xmm1, Address(buf, 40), true, Assembler::AVX_512bit); + __ evpxorq(xmm2, k5, xmm2, Address(buf, 80), true, Assembler::AVX_512bit); + __ evpxorq(xmm3, k5, xmm3, Address(buf, 120), true, Assembler::AVX_512bit); + __ evpxorq(xmm4, k1, xmm4, Address(buf, 160), true, Assembler::AVX_512bit); + + // The 24 rounds of the keccak transformation. + // The implementation closely follows the Java version, with the state + // array "rows" in the lowest 5 64-bit slots of zmm0 - zmm4, i.e. + // each row of the SHA3 specification is located in one zmm register. + __ BIND(rounds24_loop); + __ subl(roundsLeft, 1); + + __ evmovdquw(xmm5, xmm0, Assembler::AVX_512bit); + // vpternlogq(x, 150, y, z) does x = x ^ y ^ z + __ vpternlogq(xmm5, 150, xmm1, xmm2, Assembler::AVX_512bit); + __ vpternlogq(xmm5, 150, xmm3, xmm4, Assembler::AVX_512bit); + // Now the "c row", i.e. c0-c4 are in zmm5. + // Rotate each element of the c row by one bit to zmm6, call the + // rotated version c'. + __ evprolq(xmm6, xmm5, 1, Assembler::AVX_512bit); + // Rotate elementwise the c row so that c4 becomes c0, + // c0 becomes c1, etc. + __ evpermt2q(xmm5, xmm30, xmm5, Assembler::AVX_512bit); + // rotate elementwise the c' row so that c'0 becomes c'4, + // c'1 becomes c'0, etc. + __ evpermt2q(xmm6, xmm31, xmm6, Assembler::AVX_512bit); + __ vpternlogq(xmm0, 150, xmm5, xmm6, Assembler::AVX_512bit); + __ vpternlogq(xmm1, 150, xmm5, xmm6, Assembler::AVX_512bit); + __ vpternlogq(xmm2, 150, xmm5, xmm6, Assembler::AVX_512bit); + __ vpternlogq(xmm3, 150, xmm5, xmm6, Assembler::AVX_512bit); + __ vpternlogq(xmm4, 150, xmm5, xmm6, Assembler::AVX_512bit); + // Now the theta mapping has been finished. + + // Do the cyclical permutation of the 24 moving state elements + // and the required rotations within each element (the combined + // rho and sigma steps). + __ evpermt2q(xmm4, xmm17, xmm3, Assembler::AVX_512bit); + __ evpermt2q(xmm3, xmm18, xmm2, Assembler::AVX_512bit); + __ evpermt2q(xmm2, xmm17, xmm1, Assembler::AVX_512bit); + __ evpermt2q(xmm1, xmm19, xmm0, Assembler::AVX_512bit); + __ evpermt2q(xmm4, xmm20, xmm2, Assembler::AVX_512bit); + // The 24 moving elements are now in zmm1, zmm3 and zmm4, + // do the rotations now. + __ evprolvq(xmm1, xmm1, xmm27, Assembler::AVX_512bit); + __ evprolvq(xmm3, xmm3, xmm28, Assembler::AVX_512bit); + __ evprolvq(xmm4, xmm4, xmm29, Assembler::AVX_512bit); + __ evmovdquw(xmm2, xmm1, Assembler::AVX_512bit); + __ evmovdquw(xmm5, xmm3, Assembler::AVX_512bit); + __ evpermt2q(xmm0, xmm21, xmm4, Assembler::AVX_512bit); + __ evpermt2q(xmm1, xmm22, xmm3, Assembler::AVX_512bit); + __ evpermt2q(xmm5, xmm22, xmm2, Assembler::AVX_512bit); + __ evmovdquw(xmm3, xmm1, Assembler::AVX_512bit); + __ evmovdquw(xmm2, xmm5, Assembler::AVX_512bit); + __ evpermt2q(xmm1, xmm23, xmm4, Assembler::AVX_512bit); + __ evpermt2q(xmm2, xmm24, xmm4, Assembler::AVX_512bit); + __ evpermt2q(xmm3, xmm25, xmm4, Assembler::AVX_512bit); + __ evpermt2q(xmm4, xmm26, xmm5, Assembler::AVX_512bit); + // The combined rho and sigma steps are done. + + // Do the chi step (the same operation on all 5 rows). + // vpternlogq(x, 180, y, z) does x = x ^ (y & ~z). + __ evpermt2q(xmm5, xmm31, xmm0, Assembler::AVX_512bit); + __ evpermt2q(xmm6, xmm31, xmm5, Assembler::AVX_512bit); + __ vpternlogq(xmm0, 180, xmm6, xmm5, Assembler::AVX_512bit); + + __ evpermt2q(xmm5, xmm31, xmm1, Assembler::AVX_512bit); + __ evpermt2q(xmm6, xmm31, xmm5, Assembler::AVX_512bit); + __ vpternlogq(xmm1, 180, xmm6, xmm5, Assembler::AVX_512bit); + + // xor the round constant into a0 (the lowest 64 bits of zmm0 + __ evpxorq(xmm0, k1, xmm0, Address(constant2use, 0), true, Assembler::AVX_512bit); + __ addptr(constant2use, 8); + + __ evpermt2q(xmm5, xmm31, xmm2, Assembler::AVX_512bit); + __ evpermt2q(xmm6, xmm31, xmm5, Assembler::AVX_512bit); + __ vpternlogq(xmm2, 180, xmm6, xmm5, Assembler::AVX_512bit); + + __ evpermt2q(xmm5, xmm31, xmm3, Assembler::AVX_512bit); + __ evpermt2q(xmm6, xmm31, xmm5, Assembler::AVX_512bit); + __ vpternlogq(xmm3, 180, xmm6, xmm5, Assembler::AVX_512bit); + + __ evpermt2q(xmm5, xmm31, xmm4, Assembler::AVX_512bit); + __ evpermt2q(xmm6, xmm31, xmm5, Assembler::AVX_512bit); + __ vpternlogq(xmm4, 180, xmm6, xmm5, Assembler::AVX_512bit); + __ cmpl(roundsLeft, 0); + __ jcc(Assembler::notEqual, rounds24_loop); + + if (multiBlock) { + __ addptr(buf, block_size); + __ addl(ofs, block_size); + __ cmpl(ofs, limit); + __ jcc(Assembler::lessEqual, sha3_loop); + __ movq(rax, ofs); // return ofs + } else { + __ xorq(rax, rax); // return 0 + } + + // store the state + __ evmovdquq(Address(state, 0), k5, xmm0, true, Assembler::AVX_512bit); + __ evmovdquq(Address(state, 40), k5, xmm1, true, Assembler::AVX_512bit); + __ evmovdquq(Address(state, 80), k5, xmm2, true, Assembler::AVX_512bit); + __ evmovdquq(Address(state, 120), k5, xmm3, true, Assembler::AVX_512bit); + __ evmovdquq(Address(state, 160), k5, xmm4, true, Assembler::AVX_512bit); + + __ pop(r14); + __ pop(r13); + __ pop(r12); + + __ leave(); // required for proper stackwalking of RuntimeStub frame + __ ret(0); + + return start; +} diff --git a/src/hotspot/cpu/x86/vm_version_x86.cpp b/src/hotspot/cpu/x86/vm_version_x86.cpp index 63347c51d60..f8c5de551cd 100644 --- a/src/hotspot/cpu/x86/vm_version_x86.cpp +++ b/src/hotspot/cpu/x86/vm_version_x86.cpp @@ -1316,9 +1316,16 @@ void VM_Version::get_processor_features() { FLAG_SET_DEFAULT(UseSHA512Intrinsics, false); } - if (UseSHA3Intrinsics) { - warning("Intrinsics for SHA3-224, SHA3-256, SHA3-384 and SHA3-512 crypto hash functions not available on this CPU."); - FLAG_SET_DEFAULT(UseSHA3Intrinsics, false); +#ifdef _LP64 + if (supports_evex() && supports_avx512bw()) { + if (FLAG_IS_DEFAULT(UseSHA3Intrinsics)) { + UseSHA3Intrinsics = true; + } + } else +#endif + if (UseSHA3Intrinsics) { + warning("Intrinsics for SHA3-224, SHA3-256, SHA3-384 and SHA3-512 crypto hash functions not available on this CPU."); + FLAG_SET_DEFAULT(UseSHA3Intrinsics, false); } if (!(UseSHA1Intrinsics || UseSHA256Intrinsics || UseSHA512Intrinsics)) { diff --git a/src/hotspot/cpu/x86/x86.ad b/src/hotspot/cpu/x86/x86.ad index 43c959bb917..cbe05429fc4 100644 --- a/src/hotspot/cpu/x86/x86.ad +++ b/src/hotspot/cpu/x86/x86.ad @@ -1765,6 +1765,12 @@ bool Matcher::match_rule_supported_vector(int opcode, int vlen, BasicType bt) { return false; } break; + case Op_UMinV: + case Op_UMaxV: + if (UseAVX == 0) { + return false; + } + break; case Op_MaxV: case Op_MinV: if (UseSSE < 4 && is_integral_type(bt)) { @@ -1935,6 +1941,15 @@ bool Matcher::match_rule_supported_vector(int opcode, int vlen, BasicType bt) { return false; } break; + case Op_SaturatingAddV: + case Op_SaturatingSubV: + if (UseAVX < 1) { + return false; // Implementation limitation + } + if (is_subword_type(bt) && size_in_bits == 512 && !VM_Version::supports_avx512bw()) { + return false; + } + break; case Op_SelectFromTwoVector: if (size_in_bits < 128 || (size_in_bits < 512 && !VM_Version::supports_avx512vl())) { return false; @@ -2125,6 +2140,8 @@ bool Matcher::match_rule_supported_vector_masked(int opcode, int vlen, BasicType case Op_MaxV: case Op_MinV: + case Op_UMinV: + case Op_UMaxV: if (is_subword_type(bt) && !VM_Version::supports_avx512bw()) { return false; // Implementation limitation } @@ -2132,6 +2149,15 @@ bool Matcher::match_rule_supported_vector_masked(int opcode, int vlen, BasicType return false; // Implementation limitation } return true; + case Op_SaturatingAddV: + case Op_SaturatingSubV: + if (!is_subword_type(bt)) { + return false; + } + if (size_in_bits < 128 || !VM_Version::supports_avx512bw()) { + return false; // Implementation limitation + } + return true; case Op_VectorMaskCmp: if (is_subword_type(bt) && !VM_Version::supports_avx512bw()) { @@ -6492,6 +6518,80 @@ instruct evminmaxFP_reg_eavx(vec dst, vec a, vec b, vec atmp, vec btmp, kReg ktm ins_pipe( pipe_slow ); %} +// ------------------------------ Unsigned vector Min/Max ---------------------- + +instruct vector_uminmax_reg(vec dst, vec a, vec b) %{ + predicate(VM_Version::supports_avx512vl() || Matcher::vector_element_basic_type(n) != T_LONG); + match(Set dst (UMinV a b)); + match(Set dst (UMaxV a b)); + format %{ "vector_uminmax $dst,$a,$b\t!" %} + ins_encode %{ + int opcode = this->ideal_Opcode(); + int vlen_enc = vector_length_encoding(this); + BasicType elem_bt = Matcher::vector_element_basic_type(this); + assert(is_integral_type(elem_bt), ""); + __ vpuminmax(opcode, elem_bt, $dst$$XMMRegister, $a$$XMMRegister, $b$$XMMRegister, vlen_enc); + %} + ins_pipe( pipe_slow ); +%} + +instruct vector_uminmax_mem(vec dst, vec a, memory b) %{ + predicate(VM_Version::supports_avx512vl() || Matcher::vector_element_basic_type(n) != T_LONG); + match(Set dst (UMinV a (LoadVector b))); + match(Set dst (UMaxV a (LoadVector b))); + format %{ "vector_uminmax $dst,$a,$b\t!" %} + ins_encode %{ + int opcode = this->ideal_Opcode(); + int vlen_enc = vector_length_encoding(this); + BasicType elem_bt = Matcher::vector_element_basic_type(this); + assert(is_integral_type(elem_bt), ""); + __ vpuminmax(opcode, elem_bt, $dst$$XMMRegister, $a$$XMMRegister, $b$$Address, vlen_enc); + %} + ins_pipe( pipe_slow ); +%} + +instruct vector_uminmaxq_reg(vec dst, vec a, vec b, vec xtmp1, vec xtmp2) %{ + predicate(!VM_Version::supports_avx512vl() && Matcher::vector_element_basic_type(n) == T_LONG); + match(Set dst (UMinV a b)); + match(Set dst (UMaxV a b)); + effect(TEMP xtmp1, TEMP xtmp2); + format %{ "vector_uminmaxq $dst,$a,$b\t! using xtmp1 and xtmp2 as TEMP" %} + ins_encode %{ + int opcode = this->ideal_Opcode(); + int vlen_enc = vector_length_encoding(this); + __ vpuminmaxq(opcode, $dst$$XMMRegister, $a$$XMMRegister, $b$$XMMRegister, $xtmp1$$XMMRegister, $xtmp2$$XMMRegister, vlen_enc); + %} + ins_pipe( pipe_slow ); +%} + +instruct vector_uminmax_reg_masked(vec dst, vec src1, vec src2, kReg mask) %{ + match(Set dst (UMinV (Binary src1 src2) mask)); + match(Set dst (UMaxV (Binary src1 src2) mask)); + format %{ "vector_uminmax_masked $dst, $src1, $src2, $mask\t! umin/max masked operation" %} + ins_encode %{ + int vlen_enc = vector_length_encoding(this); + BasicType bt = Matcher::vector_element_basic_type(this); + int opc = this->ideal_Opcode(); + __ evmasked_op(opc, bt, $mask$$KRegister, $dst$$XMMRegister, + $dst$$XMMRegister, $src2$$XMMRegister, true, vlen_enc); + %} + ins_pipe( pipe_slow ); +%} + +instruct vector_uminmax_mem_masked(vec dst, vec src1, memory src2, kReg mask) %{ + match(Set dst (UMinV (Binary src1 (LoadVector src2)) mask)); + match(Set dst (UMaxV (Binary src1 (LoadVector src2)) mask)); + format %{ "vector_uminmax_masked $dst, $dst, $src2, $mask\t! umin/max masked operation" %} + ins_encode %{ + int vlen_enc = vector_length_encoding(this); + BasicType bt = Matcher::vector_element_basic_type(this); + int opc = this->ideal_Opcode(); + __ evmasked_op(opc, bt, $mask$$KRegister, $dst$$XMMRegister, + $src1$$XMMRegister, $src2$$Address, true, vlen_enc); + %} + ins_pipe( pipe_slow ); +%} + // --------------------------------- Signum/CopySign --------------------------- instruct signumF_reg(regF dst, regF zero, regF one, rFlagsReg cr) %{ @@ -10484,6 +10584,236 @@ instruct DoubleClassCheck_reg_reg_vfpclass(rRegI dst, regD src, kReg ktmp, rFlag ins_pipe(pipe_slow); %} +instruct vector_addsub_saturating_subword_reg(vec dst, vec src1, vec src2) +%{ + predicate(is_subword_type(Matcher::vector_element_basic_type(n)) && + n->is_SaturatingVector() && !n->as_SaturatingVector()->is_unsigned()); + match(Set dst (SaturatingAddV src1 src2)); + match(Set dst (SaturatingSubV src1 src2)); + format %{ "vector_addsub_saturating_subword $dst, $src1, $src2" %} + ins_encode %{ + int vlen_enc = vector_length_encoding(this); + BasicType elem_bt = Matcher::vector_element_basic_type(this); + __ vector_saturating_op(this->ideal_Opcode(), elem_bt, $dst$$XMMRegister, + $src1$$XMMRegister, $src2$$XMMRegister, false, vlen_enc); + %} + ins_pipe(pipe_slow); +%} + +instruct vector_addsub_saturating_unsigned_subword_reg(vec dst, vec src1, vec src2) +%{ + predicate(is_subword_type(Matcher::vector_element_basic_type(n)) && + n->is_SaturatingVector() && n->as_SaturatingVector()->is_unsigned()); + match(Set dst (SaturatingAddV src1 src2)); + match(Set dst (SaturatingSubV src1 src2)); + format %{ "vector_addsub_saturating_unsigned_subword $dst, $src1, $src2" %} + ins_encode %{ + int vlen_enc = vector_length_encoding(this); + BasicType elem_bt = Matcher::vector_element_basic_type(this); + __ vector_saturating_op(this->ideal_Opcode(), elem_bt, $dst$$XMMRegister, + $src1$$XMMRegister, $src2$$XMMRegister, true, vlen_enc); + %} + ins_pipe(pipe_slow); +%} + +instruct vector_addsub_saturating_reg_evex(vec dst, vec src1, vec src2, vec xtmp1, vec xtmp2, kReg ktmp1, kReg ktmp2) +%{ + predicate(!is_subword_type(Matcher::vector_element_basic_type(n)) && + n->is_SaturatingVector() && !n->as_SaturatingVector()->is_unsigned() && + (Matcher::vector_length_in_bytes(n) == 64 || VM_Version::supports_avx512vl())); + match(Set dst (SaturatingAddV src1 src2)); + match(Set dst (SaturatingSubV src1 src2)); + effect(TEMP dst, TEMP xtmp1, TEMP xtmp2, TEMP ktmp1, TEMP ktmp2); + format %{ "vector_addsub_saturating_evex $dst, $src1, $src2 \t! using $xtmp1, $xtmp2, $ktmp1 and $ktmp2 as TEMP" %} + ins_encode %{ + int vlen_enc = vector_length_encoding(this); + BasicType elem_bt = Matcher::vector_element_basic_type(this); + __ vector_addsub_dq_saturating_evex(this->ideal_Opcode(), elem_bt, $dst$$XMMRegister, + $src1$$XMMRegister, $src2$$XMMRegister, + $xtmp1$$XMMRegister, $xtmp2$$XMMRegister, + $ktmp1$$KRegister, $ktmp2$$KRegister, vlen_enc); + %} + ins_pipe(pipe_slow); +%} + +instruct vector_addsub_saturating_reg_avx(vec dst, vec src1, vec src2, vec xtmp1, vec xtmp2, vec xtmp3, vec xtmp4) +%{ + predicate(!is_subword_type(Matcher::vector_element_basic_type(n)) && + n->is_SaturatingVector() && !n->as_SaturatingVector()->is_unsigned() && + Matcher::vector_length_in_bytes(n) <= 32 && !VM_Version::supports_avx512vl()); + match(Set dst (SaturatingAddV src1 src2)); + match(Set dst (SaturatingSubV src1 src2)); + effect(TEMP dst, TEMP xtmp1, TEMP xtmp2, TEMP xtmp3, TEMP xtmp4); + format %{ "vector_addsub_saturating_avx $dst, $src1, $src2 \t! using $xtmp1, $xtmp2, $xtmp3 and $xtmp4 as TEMP" %} + ins_encode %{ + int vlen_enc = vector_length_encoding(this); + BasicType elem_bt = Matcher::vector_element_basic_type(this); + __ vector_addsub_dq_saturating_avx(this->ideal_Opcode(), elem_bt, $dst$$XMMRegister, $src1$$XMMRegister, + $src2$$XMMRegister, $xtmp1$$XMMRegister, $xtmp2$$XMMRegister, + $xtmp3$$XMMRegister, $xtmp4$$XMMRegister, vlen_enc); + %} + ins_pipe(pipe_slow); +%} + +instruct vector_add_saturating_unsigned_reg_evex(vec dst, vec src1, vec src2, vec xtmp1, vec xtmp2, kReg ktmp) +%{ + predicate(!is_subword_type(Matcher::vector_element_basic_type(n)) && + n->is_SaturatingVector() && n->as_SaturatingVector()->is_unsigned() && + (Matcher::vector_length_in_bytes(n) == 64 || VM_Version::supports_avx512vl())); + match(Set dst (SaturatingAddV src1 src2)); + effect(TEMP dst, TEMP xtmp1, TEMP xtmp2, TEMP ktmp); + format %{ "vector_add_saturating_unsigned_evex $dst, $src1, $src2 \t! using $xtmp1, $xtmp2 and $ktmp as TEMP" %} + ins_encode %{ + int vlen_enc = vector_length_encoding(this); + BasicType elem_bt = Matcher::vector_element_basic_type(this); + __ vector_add_dq_saturating_unsigned_evex(elem_bt, $dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, + $xtmp1$$XMMRegister, $xtmp2$$XMMRegister, $ktmp$$KRegister, vlen_enc); + %} + ins_pipe(pipe_slow); +%} + +instruct vector_add_saturating_unsigned_reg_avx(vec dst, vec src1, vec src2, vec xtmp1, vec xtmp2, vec xtmp3) +%{ + predicate(!is_subword_type(Matcher::vector_element_basic_type(n)) && + n->is_SaturatingVector() && n->as_SaturatingVector()->is_unsigned() && + Matcher::vector_length_in_bytes(n) <= 32 && !VM_Version::supports_avx512vl()); + match(Set dst (SaturatingAddV src1 src2)); + effect(TEMP dst, TEMP xtmp1, TEMP xtmp2, TEMP xtmp3); + format %{ "vector_add_saturating_unsigned_avx $dst, $src1, $src2 \t! using $xtmp1, $xtmp2 and $xtmp3 as TEMP" %} + ins_encode %{ + int vlen_enc = vector_length_encoding(this); + BasicType elem_bt = Matcher::vector_element_basic_type(this); + __ vector_add_dq_saturating_unsigned_avx(elem_bt, $dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, + $xtmp1$$XMMRegister, $xtmp2$$XMMRegister, $xtmp3$$XMMRegister, vlen_enc); + %} + ins_pipe(pipe_slow); +%} + +instruct vector_sub_saturating_unsigned_reg_evex(vec dst, vec src1, vec src2, kReg ktmp) +%{ + predicate(!is_subword_type(Matcher::vector_element_basic_type(n)) && + n->is_SaturatingVector() && n->as_SaturatingVector()->is_unsigned() && + (Matcher::vector_length_in_bytes(n) == 64 || VM_Version::supports_avx512vl())); + match(Set dst (SaturatingSubV src1 src2)); + effect(TEMP ktmp); + format %{ "vector_sub_saturating_unsigned_evex $dst, $src1, $src2 \t! using $ktmp as TEMP" %} + ins_encode %{ + int vlen_enc = vector_length_encoding(this); + BasicType elem_bt = Matcher::vector_element_basic_type(this); + __ vector_sub_dq_saturating_unsigned_evex(elem_bt, $dst$$XMMRegister, $src1$$XMMRegister, + $src2$$XMMRegister, $ktmp$$KRegister, vlen_enc); + %} + ins_pipe(pipe_slow); +%} + +instruct vector_sub_saturating_unsigned_reg_avx(vec dst, vec src1, vec src2, vec xtmp1, vec xtmp2) +%{ + predicate(!is_subword_type(Matcher::vector_element_basic_type(n)) && + n->is_SaturatingVector() && n->as_SaturatingVector()->is_unsigned() && + Matcher::vector_length_in_bytes(n) <= 32 && !VM_Version::supports_avx512vl()); + match(Set dst (SaturatingSubV src1 src2)); + effect(TEMP dst, TEMP xtmp1, TEMP xtmp2); + format %{ "vector_sub_saturating_unsigned_avx $dst, $src1, $src2 \t! using $xtmp1 and $xtmp2 as TEMP" %} + ins_encode %{ + int vlen_enc = vector_length_encoding(this); + BasicType elem_bt = Matcher::vector_element_basic_type(this); + __ vector_sub_dq_saturating_unsigned_avx(elem_bt, $dst$$XMMRegister, $src1$$XMMRegister, $src2$$XMMRegister, + $xtmp1$$XMMRegister, $xtmp2$$XMMRegister, vlen_enc); + %} + ins_pipe(pipe_slow); +%} + +instruct vector_addsub_saturating_subword_mem(vec dst, vec src1, memory src2) +%{ + predicate(is_subword_type(Matcher::vector_element_basic_type(n)) && + n->is_SaturatingVector() && !n->as_SaturatingVector()->is_unsigned()); + match(Set dst (SaturatingAddV src1 (LoadVector src2))); + match(Set dst (SaturatingSubV src1 (LoadVector src2))); + format %{ "vector_addsub_saturating_subword $dst, $src1, $src2" %} + ins_encode %{ + int vlen_enc = vector_length_encoding(this); + BasicType elem_bt = Matcher::vector_element_basic_type(this); + __ vector_saturating_op(this->ideal_Opcode(), elem_bt, $dst$$XMMRegister, + $src1$$XMMRegister, $src2$$Address, false, vlen_enc); + %} + ins_pipe(pipe_slow); +%} + +instruct vector_addsub_saturating_unsigned_subword_mem(vec dst, vec src1, memory src2) +%{ + predicate(is_subword_type(Matcher::vector_element_basic_type(n)) && + n->is_SaturatingVector() && n->as_SaturatingVector()->is_unsigned()); + match(Set dst (SaturatingAddV src1 (LoadVector src2))); + match(Set dst (SaturatingSubV src1 (LoadVector src2))); + format %{ "vector_addsub_saturating_unsigned_subword $dst, $src1, $src2" %} + ins_encode %{ + int vlen_enc = vector_length_encoding(this); + BasicType elem_bt = Matcher::vector_element_basic_type(this); + __ vector_saturating_op(this->ideal_Opcode(), elem_bt, $dst$$XMMRegister, + $src1$$XMMRegister, $src2$$Address, true, vlen_enc); + %} + ins_pipe(pipe_slow); +%} + +instruct vector_addsub_saturating_subword_masked_reg(vec dst, vec src, kReg mask) %{ + predicate(is_subword_type(Matcher::vector_element_basic_type(n)) && + n->is_SaturatingVector() && !n->as_SaturatingVector()->is_unsigned()); + match(Set dst (SaturatingAddV (Binary dst src) mask)); + match(Set dst (SaturatingSubV (Binary dst src) mask)); + format %{ "vector_addsub_saturating_subword_masked $dst, $mask, $src" %} + ins_encode %{ + int vlen_enc = vector_length_encoding(this); + BasicType elem_bt = Matcher::vector_element_basic_type(this); + __ evmasked_saturating_op(this->ideal_Opcode(), elem_bt, $mask$$KRegister, $dst$$XMMRegister, + $dst$$XMMRegister, $src$$XMMRegister, false, true, vlen_enc); + %} + ins_pipe( pipe_slow ); +%} + +instruct vector_addsub_saturating_unsigned_subword_masked_reg(vec dst, vec src, kReg mask) %{ + predicate(is_subword_type(Matcher::vector_element_basic_type(n)) && + n->is_SaturatingVector() && n->as_SaturatingVector()->is_unsigned()); + match(Set dst (SaturatingAddV (Binary dst src) mask)); + match(Set dst (SaturatingSubV (Binary dst src) mask)); + format %{ "vector_addsub_saturating_unsigned_subword_masked $dst, $mask, $src" %} + ins_encode %{ + int vlen_enc = vector_length_encoding(this); + BasicType elem_bt = Matcher::vector_element_basic_type(this); + __ evmasked_saturating_op(this->ideal_Opcode(), elem_bt, $mask$$KRegister, $dst$$XMMRegister, + $dst$$XMMRegister, $src$$XMMRegister, true, true, vlen_enc); + %} + ins_pipe( pipe_slow ); +%} + +instruct vector_addsub_saturating_subword_masked_mem(vec dst, memory src, kReg mask) %{ + predicate(is_subword_type(Matcher::vector_element_basic_type(n)) && + n->is_SaturatingVector() && !n->as_SaturatingVector()->is_unsigned()); + match(Set dst (SaturatingAddV (Binary dst (LoadVector src)) mask)); + match(Set dst (SaturatingSubV (Binary dst (LoadVector src)) mask)); + format %{ "vector_addsub_saturating_subword_masked $dst, $mask, $src" %} + ins_encode %{ + int vlen_enc = vector_length_encoding(this); + BasicType elem_bt = Matcher::vector_element_basic_type(this); + __ evmasked_saturating_op(this->ideal_Opcode(), elem_bt, $mask$$KRegister, $dst$$XMMRegister, + $dst$$XMMRegister, $src$$Address, false, true, vlen_enc); + %} + ins_pipe( pipe_slow ); +%} + +instruct vector_addsub_saturating_unsigned_subword_masked_mem(vec dst, memory src, kReg mask) %{ + predicate(is_subword_type(Matcher::vector_element_basic_type(n)) && + n->is_SaturatingVector() && n->as_SaturatingVector()->is_unsigned()); + match(Set dst (SaturatingAddV (Binary dst (LoadVector src)) mask)); + match(Set dst (SaturatingSubV (Binary dst (LoadVector src)) mask)); + format %{ "vector_addsub_saturating_unsigned_subword_masked $dst, $mask, $src" %} + ins_encode %{ + int vlen_enc = vector_length_encoding(this); + BasicType elem_bt = Matcher::vector_element_basic_type(this); + __ evmasked_saturating_op(this->ideal_Opcode(), elem_bt, $mask$$KRegister, $dst$$XMMRegister, + $dst$$XMMRegister, $src$$Address, true, true, vlen_enc); + %} + ins_pipe( pipe_slow ); +%} instruct vector_selectfrom_twovectors_reg_evex(vec index, vec src1, vec src2) %{ diff --git a/src/hotspot/os/bsd/gc/x/xNUMA_bsd.cpp b/src/hotspot/os/bsd/gc/x/xNUMA_bsd.cpp deleted file mode 100644 index b0e23a1716a..00000000000 --- a/src/hotspot/os/bsd/gc/x/xNUMA_bsd.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2019, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/x/xNUMA.hpp" -#include "utilities/globalDefinitions.hpp" - -void XNUMA::pd_initialize() { - _enabled = false; -} - -uint32_t XNUMA::count() { - return 1; -} - -uint32_t XNUMA::id() { - return 0; -} - -uint32_t XNUMA::memory_id(uintptr_t addr) { - // NUMA support not enabled, assume everything belongs to node zero - return 0; -} diff --git a/src/hotspot/os/bsd/gc/x/xPhysicalMemoryBacking_bsd.cpp b/src/hotspot/os/bsd/gc/x/xPhysicalMemoryBacking_bsd.cpp deleted file mode 100644 index 2c64c3788d3..00000000000 --- a/src/hotspot/os/bsd/gc/x/xPhysicalMemoryBacking_bsd.cpp +++ /dev/null @@ -1,181 +0,0 @@ -/* - * Copyright (c) 2019, 2020, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/shared/gcLogPrecious.hpp" -#include "gc/x/xErrno.hpp" -#include "gc/x/xGlobals.hpp" -#include "gc/x/xLargePages.inline.hpp" -#include "gc/x/xPhysicalMemory.inline.hpp" -#include "gc/x/xPhysicalMemoryBacking_bsd.hpp" -#include "logging/log.hpp" -#include "runtime/globals.hpp" -#include "runtime/os.hpp" -#include "utilities/align.hpp" -#include "utilities/debug.hpp" - -#include -#include -#include -#include - -// The backing is represented by a reserved virtual address space, in which -// we commit and uncommit physical memory. Multi-mapping the different heap -// views is done by simply remapping the backing memory using mach_vm_remap(). - -static int vm_flags_superpage() { - if (!XLargePages::is_explicit()) { - return 0; - } - - const int page_size_in_megabytes = XGranuleSize >> 20; - return page_size_in_megabytes << VM_FLAGS_SUPERPAGE_SHIFT; -} - -static XErrno mremap(uintptr_t from_addr, uintptr_t to_addr, size_t size) { - mach_vm_address_t remap_addr = to_addr; - vm_prot_t remap_cur_prot; - vm_prot_t remap_max_prot; - - // Remap memory to an additional location - const kern_return_t res = mach_vm_remap(mach_task_self(), - &remap_addr, - size, - 0 /* mask */, - VM_FLAGS_FIXED | VM_FLAGS_OVERWRITE | vm_flags_superpage(), - mach_task_self(), - from_addr, - FALSE /* copy */, - &remap_cur_prot, - &remap_max_prot, - VM_INHERIT_COPY); - - return (res == KERN_SUCCESS) ? XErrno(0) : XErrno(EINVAL); -} - -XPhysicalMemoryBacking::XPhysicalMemoryBacking(size_t max_capacity) : - _base(0), - _initialized(false) { - - // Reserve address space for backing memory - _base = (uintptr_t)os::reserve_memory(max_capacity); - if (_base == 0) { - // Failed - log_error_pd(gc)("Failed to reserve address space for backing memory"); - return; - } - - // Successfully initialized - _initialized = true; -} - -bool XPhysicalMemoryBacking::is_initialized() const { - return _initialized; -} - -void XPhysicalMemoryBacking::warn_commit_limits(size_t max_capacity) const { - // Does nothing -} - -bool XPhysicalMemoryBacking::commit_inner(size_t offset, size_t length) const { - assert(is_aligned(offset, os::vm_page_size()), "Invalid offset"); - assert(is_aligned(length, os::vm_page_size()), "Invalid length"); - - log_trace(gc, heap)("Committing memory: " SIZE_FORMAT "M-" SIZE_FORMAT "M (" SIZE_FORMAT "M)", - offset / M, (offset + length) / M, length / M); - - const uintptr_t addr = _base + offset; - const void* const res = mmap((void*)addr, length, PROT_READ | PROT_WRITE, MAP_FIXED | MAP_ANONYMOUS | MAP_PRIVATE, -1, 0); - if (res == MAP_FAILED) { - XErrno err; - log_error(gc)("Failed to commit memory (%s)", err.to_string()); - return false; - } - - // Success - return true; -} - -size_t XPhysicalMemoryBacking::commit(size_t offset, size_t length) const { - // Try to commit the whole region - if (commit_inner(offset, length)) { - // Success - return length; - } - - // Failed, try to commit as much as possible - size_t start = offset; - size_t end = offset + length; - - for (;;) { - length = align_down((end - start) / 2, XGranuleSize); - if (length == 0) { - // Done, don't commit more - return start - offset; - } - - if (commit_inner(start, length)) { - // Success, try commit more - start += length; - } else { - // Failed, try commit less - end -= length; - } - } -} - -size_t XPhysicalMemoryBacking::uncommit(size_t offset, size_t length) const { - assert(is_aligned(offset, os::vm_page_size()), "Invalid offset"); - assert(is_aligned(length, os::vm_page_size()), "Invalid length"); - - log_trace(gc, heap)("Uncommitting memory: " SIZE_FORMAT "M-" SIZE_FORMAT "M (" SIZE_FORMAT "M)", - offset / M, (offset + length) / M, length / M); - - const uintptr_t start = _base + offset; - const void* const res = mmap((void*)start, length, PROT_NONE, MAP_FIXED | MAP_ANONYMOUS | MAP_PRIVATE | MAP_NORESERVE, -1, 0); - if (res == MAP_FAILED) { - XErrno err; - log_error(gc)("Failed to uncommit memory (%s)", err.to_string()); - return 0; - } - - return length; -} - -void XPhysicalMemoryBacking::map(uintptr_t addr, size_t size, uintptr_t offset) const { - const XErrno err = mremap(_base + offset, addr, size); - if (err) { - fatal("Failed to remap memory (%s)", err.to_string()); - } -} - -void XPhysicalMemoryBacking::unmap(uintptr_t addr, size_t size) const { - // Note that we must keep the address space reservation intact and just detach - // the backing memory. For this reason we map a new anonymous, non-accessible - // and non-reserved page over the mapping instead of actually unmapping. - const void* const res = mmap((void*)addr, size, PROT_NONE, MAP_FIXED | MAP_ANONYMOUS | MAP_PRIVATE | MAP_NORESERVE, -1, 0); - if (res == MAP_FAILED) { - XErrno err; - fatal("Failed to map memory (%s)", err.to_string()); - } -} diff --git a/src/hotspot/os/bsd/gc/x/xPhysicalMemoryBacking_bsd.hpp b/src/hotspot/os/bsd/gc/x/xPhysicalMemoryBacking_bsd.hpp deleted file mode 100644 index 8b4747026ff..00000000000 --- a/src/hotspot/os/bsd/gc/x/xPhysicalMemoryBacking_bsd.hpp +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2019, 2020, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef OS_BSD_GC_X_XPHYSICALMEMORYBACKING_BSD_HPP -#define OS_BSD_GC_X_XPHYSICALMEMORYBACKING_BSD_HPP - -class XPhysicalMemoryBacking { -private: - uintptr_t _base; - bool _initialized; - - bool commit_inner(size_t offset, size_t length) const; - -public: - XPhysicalMemoryBacking(size_t max_capacity); - - bool is_initialized() const; - - void warn_commit_limits(size_t max_capacity) const; - - size_t commit(size_t offset, size_t length) const; - size_t uncommit(size_t offset, size_t length) const; - - void map(uintptr_t addr, size_t size, uintptr_t offset) const; - void unmap(uintptr_t addr, size_t size) const; -}; - -#endif // OS_BSD_GC_X_XPHYSICALMEMORYBACKING_BSD_HPP diff --git a/src/hotspot/os/linux/gc/x/xLargePages_linux.cpp b/src/hotspot/os/linux/gc/x/xLargePages_linux.cpp deleted file mode 100644 index 6ad956b1e63..00000000000 --- a/src/hotspot/os/linux/gc/x/xLargePages_linux.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2017, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/x/xLargePages.hpp" -#include "runtime/globals.hpp" - -void XLargePages::pd_initialize() { - if (UseLargePages) { - if (UseTransparentHugePages) { - _state = Transparent; - } else { - _state = Explicit; - } - } else { - _state = Disabled; - } -} diff --git a/src/hotspot/os/linux/gc/x/xMountPoint_linux.cpp b/src/hotspot/os/linux/gc/x/xMountPoint_linux.cpp deleted file mode 100644 index 96c0f2f92db..00000000000 --- a/src/hotspot/os/linux/gc/x/xMountPoint_linux.cpp +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Copyright (c) 2016, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/shared/gcLogPrecious.hpp" -#include "gc/x/xArray.inline.hpp" -#include "gc/x/xErrno.hpp" -#include "gc/x/xMountPoint_linux.hpp" -#include "runtime/globals.hpp" -#include "runtime/os.hpp" -#include "utilities/globalDefinitions.hpp" - -#include -#include - -// Mount information, see proc(5) for more details. -#define PROC_SELF_MOUNTINFO "/proc/self/mountinfo" - -XMountPoint::XMountPoint(const char* filesystem, const char** preferred_mountpoints) { - if (AllocateHeapAt != nullptr) { - // Use specified path - _path = os::strdup(AllocateHeapAt, mtGC); - } else { - // Find suitable path - _path = find_mountpoint(filesystem, preferred_mountpoints); - } -} - -XMountPoint::~XMountPoint() { - os::free(_path); - _path = nullptr; -} - -char* XMountPoint::get_mountpoint(const char* line, const char* filesystem) const { - char* line_mountpoint = nullptr; - char* line_filesystem = nullptr; - - // Parse line and return a newly allocated string containing the mount point if - // the line contains a matching filesystem and the mount point is accessible by - // the current user. - // sscanf, using %m, will return malloced memory. Need raw ::free, not os::free. - if (sscanf(line, "%*u %*u %*u:%*u %*s %ms %*[^-]- %ms", &line_mountpoint, &line_filesystem) != 2 || - strcmp(line_filesystem, filesystem) != 0 || - access(line_mountpoint, R_OK|W_OK|X_OK) != 0) { - // Not a matching or accessible filesystem - ALLOW_C_FUNCTION(::free, ::free(line_mountpoint);) - line_mountpoint = nullptr; - } - - ALLOW_C_FUNCTION(::free, ::free(line_filesystem);) - - return line_mountpoint; -} - -void XMountPoint::get_mountpoints(const char* filesystem, XArray* mountpoints) const { - FILE* fd = os::fopen(PROC_SELF_MOUNTINFO, "r"); - if (fd == nullptr) { - XErrno err; - log_error_p(gc)("Failed to open %s: %s", PROC_SELF_MOUNTINFO, err.to_string()); - return; - } - - char* line = nullptr; - size_t length = 0; - - while (getline(&line, &length, fd) != -1) { - char* const mountpoint = get_mountpoint(line, filesystem); - if (mountpoint != nullptr) { - mountpoints->append(mountpoint); - } - } - - // readline will return malloced memory. Need raw ::free, not os::free. - ALLOW_C_FUNCTION(::free, ::free(line);) - fclose(fd); -} - -void XMountPoint::free_mountpoints(XArray* mountpoints) const { - XArrayIterator iter(mountpoints); - for (char* mountpoint; iter.next(&mountpoint);) { - ALLOW_C_FUNCTION(::free, ::free(mountpoint);) // *not* os::free - } - mountpoints->clear(); -} - -char* XMountPoint::find_preferred_mountpoint(const char* filesystem, - XArray* mountpoints, - const char** preferred_mountpoints) const { - // Find preferred mount point - XArrayIterator iter1(mountpoints); - for (char* mountpoint; iter1.next(&mountpoint);) { - for (const char** preferred = preferred_mountpoints; *preferred != nullptr; preferred++) { - if (!strcmp(mountpoint, *preferred)) { - // Preferred mount point found - return os::strdup(mountpoint, mtGC); - } - } - } - - // Preferred mount point not found - log_error_p(gc)("More than one %s filesystem found:", filesystem); - XArrayIterator iter2(mountpoints); - for (char* mountpoint; iter2.next(&mountpoint);) { - log_error_p(gc)(" %s", mountpoint); - } - - return nullptr; -} - -char* XMountPoint::find_mountpoint(const char* filesystem, const char** preferred_mountpoints) const { - char* path = nullptr; - XArray mountpoints; - - get_mountpoints(filesystem, &mountpoints); - - if (mountpoints.length() == 0) { - // No mount point found - log_error_p(gc)("Failed to find an accessible %s filesystem", filesystem); - } else if (mountpoints.length() == 1) { - // One mount point found - path = os::strdup(mountpoints.at(0), mtGC); - } else { - // More than one mount point found - path = find_preferred_mountpoint(filesystem, &mountpoints, preferred_mountpoints); - } - - free_mountpoints(&mountpoints); - - return path; -} - -const char* XMountPoint::get() const { - return _path; -} diff --git a/src/hotspot/os/linux/gc/x/xMountPoint_linux.hpp b/src/hotspot/os/linux/gc/x/xMountPoint_linux.hpp deleted file mode 100644 index e0ca126e066..00000000000 --- a/src/hotspot/os/linux/gc/x/xMountPoint_linux.hpp +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2016, 2020, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef OS_LINUX_GC_X_XMOUNTPOINT_LINUX_HPP -#define OS_LINUX_GC_X_XMOUNTPOINT_LINUX_HPP - -#include "gc/x/xArray.hpp" -#include "memory/allocation.hpp" - -class XMountPoint : public StackObj { -private: - char* _path; - - char* get_mountpoint(const char* line, - const char* filesystem) const; - void get_mountpoints(const char* filesystem, - XArray* mountpoints) const; - void free_mountpoints(XArray* mountpoints) const; - char* find_preferred_mountpoint(const char* filesystem, - XArray* mountpoints, - const char** preferred_mountpoints) const; - char* find_mountpoint(const char* filesystem, - const char** preferred_mountpoints) const; - -public: - XMountPoint(const char* filesystem, const char** preferred_mountpoints); - ~XMountPoint(); - - const char* get() const; -}; - -#endif // OS_LINUX_GC_X_XMOUNTPOINT_LINUX_HPP diff --git a/src/hotspot/os/linux/gc/x/xNUMA_linux.cpp b/src/hotspot/os/linux/gc/x/xNUMA_linux.cpp deleted file mode 100644 index 0cc557dde6e..00000000000 --- a/src/hotspot/os/linux/gc/x/xNUMA_linux.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2016, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "gc/x/xCPU.inline.hpp" -#include "gc/x/xErrno.hpp" -#include "gc/x/xNUMA.hpp" -#include "gc/x/xSyscall_linux.hpp" -#include "os_linux.hpp" -#include "runtime/globals.hpp" -#include "runtime/os.hpp" -#include "utilities/debug.hpp" - -void XNUMA::pd_initialize() { - _enabled = UseNUMA; -} - -uint32_t XNUMA::count() { - if (!_enabled) { - // NUMA support not enabled - return 1; - } - - return os::Linux::numa_max_node() + 1; -} - -uint32_t XNUMA::id() { - if (!_enabled) { - // NUMA support not enabled - return 0; - } - - return os::Linux::get_node_by_cpu(XCPU::id()); -} - -uint32_t XNUMA::memory_id(uintptr_t addr) { - if (!_enabled) { - // NUMA support not enabled, assume everything belongs to node zero - return 0; - } - - uint32_t id = (uint32_t)-1; - - if (XSyscall::get_mempolicy((int*)&id, nullptr, 0, (void*)addr, MPOL_F_NODE | MPOL_F_ADDR) == -1) { - XErrno err; - fatal("Failed to get NUMA id for memory at " PTR_FORMAT " (%s)", addr, err.to_string()); - } - - assert(id < count(), "Invalid NUMA id"); - - return id; -} diff --git a/src/hotspot/os/linux/gc/x/xPhysicalMemoryBacking_linux.cpp b/src/hotspot/os/linux/gc/x/xPhysicalMemoryBacking_linux.cpp deleted file mode 100644 index 35625f613d3..00000000000 --- a/src/hotspot/os/linux/gc/x/xPhysicalMemoryBacking_linux.cpp +++ /dev/null @@ -1,724 +0,0 @@ -/* - * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/shared/gcLogPrecious.hpp" -#include "gc/x/xArray.inline.hpp" -#include "gc/x/xErrno.hpp" -#include "gc/x/xGlobals.hpp" -#include "gc/x/xLargePages.inline.hpp" -#include "gc/x/xMountPoint_linux.hpp" -#include "gc/x/xNUMA.inline.hpp" -#include "gc/x/xPhysicalMemoryBacking_linux.hpp" -#include "gc/x/xSyscall_linux.hpp" -#include "logging/log.hpp" -#include "os_linux.hpp" -#include "runtime/init.hpp" -#include "runtime/os.hpp" -#include "runtime/safefetch.hpp" -#include "utilities/align.hpp" -#include "utilities/debug.hpp" -#include "utilities/growableArray.hpp" - -#include -#include -#include -#include -#include -#include -#include - -// -// Support for building on older Linux systems -// - -// memfd_create(2) flags -#ifndef MFD_CLOEXEC -#define MFD_CLOEXEC 0x0001U -#endif -#ifndef MFD_HUGETLB -#define MFD_HUGETLB 0x0004U -#endif -#ifndef MFD_HUGE_2MB -#define MFD_HUGE_2MB 0x54000000U -#endif - -// open(2) flags -#ifndef O_CLOEXEC -#define O_CLOEXEC 02000000 -#endif -#ifndef O_TMPFILE -#define O_TMPFILE (020000000 | O_DIRECTORY) -#endif - -// fallocate(2) flags -#ifndef FALLOC_FL_KEEP_SIZE -#define FALLOC_FL_KEEP_SIZE 0x01 -#endif -#ifndef FALLOC_FL_PUNCH_HOLE -#define FALLOC_FL_PUNCH_HOLE 0x02 -#endif - -// Filesystem types, see statfs(2) -#ifndef TMPFS_MAGIC -#define TMPFS_MAGIC 0x01021994 -#endif -#ifndef HUGETLBFS_MAGIC -#define HUGETLBFS_MAGIC 0x958458f6 -#endif - -// Filesystem names -#define XFILESYSTEM_TMPFS "tmpfs" -#define XFILESYSTEM_HUGETLBFS "hugetlbfs" - -// Proc file entry for max map mount -#define XFILENAME_PROC_MAX_MAP_COUNT "/proc/sys/vm/max_map_count" - -// Sysfs file for transparent huge page on tmpfs -#define XFILENAME_SHMEM_ENABLED "/sys/kernel/mm/transparent_hugepage/shmem_enabled" - -// Java heap filename -#define XFILENAME_HEAP "java_heap" - -// Preferred tmpfs mount points, ordered by priority -static const char* z_preferred_tmpfs_mountpoints[] = { - "/dev/shm", - "/run/shm", - nullptr -}; - -// Preferred hugetlbfs mount points, ordered by priority -static const char* z_preferred_hugetlbfs_mountpoints[] = { - "/dev/hugepages", - "/hugepages", - nullptr -}; - -static int z_fallocate_hugetlbfs_attempts = 3; -static bool z_fallocate_supported = true; - -XPhysicalMemoryBacking::XPhysicalMemoryBacking(size_t max_capacity) : - _fd(-1), - _filesystem(0), - _block_size(0), - _available(0), - _initialized(false) { - - // Create backing file - _fd = create_fd(XFILENAME_HEAP); - if (_fd == -1) { - return; - } - - // Truncate backing file - while (ftruncate(_fd, max_capacity) == -1) { - if (errno != EINTR) { - XErrno err; - log_error_p(gc)("Failed to truncate backing file (%s)", err.to_string()); - return; - } - } - - // Get filesystem statistics - struct statfs buf; - if (fstatfs(_fd, &buf) == -1) { - XErrno err; - log_error_p(gc)("Failed to determine filesystem type for backing file (%s)", err.to_string()); - return; - } - - _filesystem = buf.f_type; - _block_size = buf.f_bsize; - _available = buf.f_bavail * _block_size; - - log_info_p(gc, init)("Heap Backing Filesystem: %s (" UINT64_FORMAT_X ")", - is_tmpfs() ? XFILESYSTEM_TMPFS : is_hugetlbfs() ? XFILESYSTEM_HUGETLBFS : "other", _filesystem); - - // Make sure the filesystem type matches requested large page type - if (XLargePages::is_transparent() && !is_tmpfs()) { - log_error_p(gc)("-XX:+UseTransparentHugePages can only be enabled when using a %s filesystem", - XFILESYSTEM_TMPFS); - return; - } - - if (XLargePages::is_transparent() && !tmpfs_supports_transparent_huge_pages()) { - log_error_p(gc)("-XX:+UseTransparentHugePages on a %s filesystem not supported by kernel", - XFILESYSTEM_TMPFS); - return; - } - - if (XLargePages::is_explicit() && !is_hugetlbfs()) { - log_error_p(gc)("-XX:+UseLargePages (without -XX:+UseTransparentHugePages) can only be enabled " - "when using a %s filesystem", XFILESYSTEM_HUGETLBFS); - return; - } - - if (!XLargePages::is_explicit() && is_hugetlbfs()) { - log_error_p(gc)("-XX:+UseLargePages must be enabled when using a %s filesystem", - XFILESYSTEM_HUGETLBFS); - return; - } - - // Make sure the filesystem block size is compatible - if (XGranuleSize % _block_size != 0) { - log_error_p(gc)("Filesystem backing the heap has incompatible block size (" SIZE_FORMAT ")", - _block_size); - return; - } - - if (is_hugetlbfs() && _block_size != XGranuleSize) { - log_error_p(gc)("%s filesystem has unexpected block size " SIZE_FORMAT " (expected " SIZE_FORMAT ")", - XFILESYSTEM_HUGETLBFS, _block_size, XGranuleSize); - return; - } - - // Successfully initialized - _initialized = true; -} - -int XPhysicalMemoryBacking::create_mem_fd(const char* name) const { - assert(XGranuleSize == 2 * M, "Granule size must match MFD_HUGE_2MB"); - - // Create file name - char filename[PATH_MAX]; - snprintf(filename, sizeof(filename), "%s%s", name, XLargePages::is_explicit() ? ".hugetlb" : ""); - - // Create file - const int extra_flags = XLargePages::is_explicit() ? (MFD_HUGETLB | MFD_HUGE_2MB) : 0; - const int fd = XSyscall::memfd_create(filename, MFD_CLOEXEC | extra_flags); - if (fd == -1) { - XErrno err; - log_debug_p(gc, init)("Failed to create memfd file (%s)", - (XLargePages::is_explicit() && (err == EINVAL || err == ENODEV)) ? - "Hugepages (2M) not available" : err.to_string()); - return -1; - } - - log_info_p(gc, init)("Heap Backing File: /memfd:%s", filename); - - return fd; -} - -int XPhysicalMemoryBacking::create_file_fd(const char* name) const { - const char* const filesystem = XLargePages::is_explicit() - ? XFILESYSTEM_HUGETLBFS - : XFILESYSTEM_TMPFS; - const char** const preferred_mountpoints = XLargePages::is_explicit() - ? z_preferred_hugetlbfs_mountpoints - : z_preferred_tmpfs_mountpoints; - - // Find mountpoint - XMountPoint mountpoint(filesystem, preferred_mountpoints); - if (mountpoint.get() == nullptr) { - log_error_p(gc)("Use -XX:AllocateHeapAt to specify the path to a %s filesystem", filesystem); - return -1; - } - - // Try to create an anonymous file using the O_TMPFILE flag. Note that this - // flag requires kernel >= 3.11. If this fails we fall back to open/unlink. - const int fd_anon = os::open(mountpoint.get(), O_TMPFILE|O_EXCL|O_RDWR|O_CLOEXEC, S_IRUSR|S_IWUSR); - if (fd_anon == -1) { - XErrno err; - log_debug_p(gc, init)("Failed to create anonymous file in %s (%s)", mountpoint.get(), - (err == EINVAL ? "Not supported" : err.to_string())); - } else { - // Get inode number for anonymous file - struct stat stat_buf; - if (fstat(fd_anon, &stat_buf) == -1) { - XErrno err; - log_error_pd(gc)("Failed to determine inode number for anonymous file (%s)", err.to_string()); - return -1; - } - - log_info_p(gc, init)("Heap Backing File: %s/#" UINT64_FORMAT, mountpoint.get(), (uint64_t)stat_buf.st_ino); - - return fd_anon; - } - - log_debug_p(gc, init)("Falling back to open/unlink"); - - // Create file name - char filename[PATH_MAX]; - snprintf(filename, sizeof(filename), "%s/%s.%d", mountpoint.get(), name, os::current_process_id()); - - // Create file - const int fd = os::open(filename, O_CREAT|O_EXCL|O_RDWR|O_CLOEXEC, S_IRUSR|S_IWUSR); - if (fd == -1) { - XErrno err; - log_error_p(gc)("Failed to create file %s (%s)", filename, err.to_string()); - return -1; - } - - // Unlink file - if (unlink(filename) == -1) { - XErrno err; - log_error_p(gc)("Failed to unlink file %s (%s)", filename, err.to_string()); - return -1; - } - - log_info_p(gc, init)("Heap Backing File: %s", filename); - - return fd; -} - -int XPhysicalMemoryBacking::create_fd(const char* name) const { - if (AllocateHeapAt == nullptr) { - // If the path is not explicitly specified, then we first try to create a memfd file - // instead of looking for a tmpfd/hugetlbfs mount point. Note that memfd_create() might - // not be supported at all (requires kernel >= 3.17), or it might not support large - // pages (requires kernel >= 4.14). If memfd_create() fails, then we try to create a - // file on an accessible tmpfs or hugetlbfs mount point. - const int fd = create_mem_fd(name); - if (fd != -1) { - return fd; - } - - log_debug_p(gc)("Falling back to searching for an accessible mount point"); - } - - return create_file_fd(name); -} - -bool XPhysicalMemoryBacking::is_initialized() const { - return _initialized; -} - -void XPhysicalMemoryBacking::warn_available_space(size_t max_capacity) const { - // Note that the available space on a tmpfs or a hugetlbfs filesystem - // will be zero if no size limit was specified when it was mounted. - if (_available == 0) { - // No size limit set, skip check - log_info_p(gc, init)("Available space on backing filesystem: N/A"); - return; - } - - log_info_p(gc, init)("Available space on backing filesystem: " SIZE_FORMAT "M", _available / M); - - // Warn if the filesystem doesn't currently have enough space available to hold - // the max heap size. The max heap size will be capped if we later hit this limit - // when trying to expand the heap. - if (_available < max_capacity) { - log_warning_p(gc)("***** WARNING! INCORRECT SYSTEM CONFIGURATION DETECTED! *****"); - log_warning_p(gc)("Not enough space available on the backing filesystem to hold the current max Java heap"); - log_warning_p(gc)("size (" SIZE_FORMAT "M). Please adjust the size of the backing filesystem accordingly " - "(available", max_capacity / M); - log_warning_p(gc)("space is currently " SIZE_FORMAT "M). Continuing execution with the current filesystem " - "size could", _available / M); - log_warning_p(gc)("lead to a premature OutOfMemoryError being thrown, due to failure to commit memory."); - } -} - -void XPhysicalMemoryBacking::warn_max_map_count(size_t max_capacity) const { - const char* const filename = XFILENAME_PROC_MAX_MAP_COUNT; - FILE* const file = os::fopen(filename, "r"); - if (file == nullptr) { - // Failed to open file, skip check - log_debug_p(gc, init)("Failed to open %s", filename); - return; - } - - size_t actual_max_map_count = 0; - const int result = fscanf(file, SIZE_FORMAT, &actual_max_map_count); - fclose(file); - if (result != 1) { - // Failed to read file, skip check - log_debug_p(gc, init)("Failed to read %s", filename); - return; - } - - // The required max map count is impossible to calculate exactly since subsystems - // other than ZGC are also creating memory mappings, and we have no control over that. - // However, ZGC tends to create the most mappings and dominate the total count. - // In the worst cases, ZGC will map each granule three times, i.e. once per heap view. - // We speculate that we need another 20% to allow for non-ZGC subsystems to map memory. - const size_t required_max_map_count = (max_capacity / XGranuleSize) * 3 * 1.2; - if (actual_max_map_count < required_max_map_count) { - log_warning_p(gc)("***** WARNING! INCORRECT SYSTEM CONFIGURATION DETECTED! *****"); - log_warning_p(gc)("The system limit on number of memory mappings per process might be too low for the given"); - log_warning_p(gc)("max Java heap size (" SIZE_FORMAT "M). Please adjust %s to allow for at", - max_capacity / M, filename); - log_warning_p(gc)("least " SIZE_FORMAT " mappings (current limit is " SIZE_FORMAT "). Continuing execution " - "with the current", required_max_map_count, actual_max_map_count); - log_warning_p(gc)("limit could lead to a premature OutOfMemoryError being thrown, due to failure to map memory."); - } -} - -void XPhysicalMemoryBacking::warn_commit_limits(size_t max_capacity) const { - // Warn if available space is too low - warn_available_space(max_capacity); - - // Warn if max map count is too low - warn_max_map_count(max_capacity); -} - -bool XPhysicalMemoryBacking::is_tmpfs() const { - return _filesystem == TMPFS_MAGIC; -} - -bool XPhysicalMemoryBacking::is_hugetlbfs() const { - return _filesystem == HUGETLBFS_MAGIC; -} - -bool XPhysicalMemoryBacking::tmpfs_supports_transparent_huge_pages() const { - // If the shmem_enabled file exists and is readable then we - // know the kernel supports transparent huge pages for tmpfs. - return access(XFILENAME_SHMEM_ENABLED, R_OK) == 0; -} - -XErrno XPhysicalMemoryBacking::fallocate_compat_mmap_hugetlbfs(size_t offset, size_t length, bool touch) const { - // On hugetlbfs, mapping a file segment will fail immediately, without - // the need to touch the mapped pages first, if there aren't enough huge - // pages available to back the mapping. - void* const addr = mmap(nullptr, length, PROT_READ|PROT_WRITE, MAP_SHARED, _fd, offset); - if (addr == MAP_FAILED) { - // Failed - return errno; - } - - // Once mapped, the huge pages are only reserved. We need to touch them - // to associate them with the file segment. Note that we can not punch - // hole in file segments which only have reserved pages. - if (touch) { - char* const start = (char*)addr; - char* const end = start + length; - os::pretouch_memory(start, end, _block_size); - } - - // Unmap again. From now on, the huge pages that were mapped are allocated - // to this file. There's no risk of getting a SIGBUS when mapping and - // touching these pages again. - if (munmap(addr, length) == -1) { - // Failed - return errno; - } - - // Success - return 0; -} - -static bool safe_touch_mapping(void* addr, size_t length, size_t page_size) { - char* const start = (char*)addr; - char* const end = start + length; - - // Touching a mapping that can't be backed by memory will generate a - // SIGBUS. By using SafeFetch32 any SIGBUS will be safely caught and - // handled. On tmpfs, doing a fetch (rather than a store) is enough - // to cause backing pages to be allocated (there's no zero-page to - // worry about). - for (char *p = start; p < end; p += page_size) { - if (SafeFetch32((int*)p, -1) == -1) { - // Failed - return false; - } - } - - // Success - return true; -} - -XErrno XPhysicalMemoryBacking::fallocate_compat_mmap_tmpfs(size_t offset, size_t length) const { - // On tmpfs, we need to touch the mapped pages to figure out - // if there are enough pages available to back the mapping. - void* const addr = mmap(nullptr, length, PROT_READ|PROT_WRITE, MAP_SHARED, _fd, offset); - if (addr == MAP_FAILED) { - // Failed - return errno; - } - - // Advise mapping to use transparent huge pages - os::realign_memory((char*)addr, length, XGranuleSize); - - // Touch the mapping (safely) to make sure it's backed by memory - const bool backed = safe_touch_mapping(addr, length, _block_size); - - // Unmap again. If successfully touched, the backing memory will - // be allocated to this file. There's no risk of getting a SIGBUS - // when mapping and touching these pages again. - if (munmap(addr, length) == -1) { - // Failed - return errno; - } - - // Success - return backed ? 0 : ENOMEM; -} - -XErrno XPhysicalMemoryBacking::fallocate_compat_pwrite(size_t offset, size_t length) const { - uint8_t data = 0; - - // Allocate backing memory by writing to each block - for (size_t pos = offset; pos < offset + length; pos += _block_size) { - if (pwrite(_fd, &data, sizeof(data), pos) == -1) { - // Failed - return errno; - } - } - - // Success - return 0; -} - -XErrno XPhysicalMemoryBacking::fallocate_fill_hole_compat(size_t offset, size_t length) const { - // fallocate(2) is only supported by tmpfs since Linux 3.5, and by hugetlbfs - // since Linux 4.3. When fallocate(2) is not supported we emulate it using - // mmap/munmap (for hugetlbfs and tmpfs with transparent huge pages) or pwrite - // (for tmpfs without transparent huge pages and other filesystem types). - if (XLargePages::is_explicit()) { - return fallocate_compat_mmap_hugetlbfs(offset, length, false /* touch */); - } else if (XLargePages::is_transparent()) { - return fallocate_compat_mmap_tmpfs(offset, length); - } else { - return fallocate_compat_pwrite(offset, length); - } -} - -XErrno XPhysicalMemoryBacking::fallocate_fill_hole_syscall(size_t offset, size_t length) const { - const int mode = 0; // Allocate - const int res = XSyscall::fallocate(_fd, mode, offset, length); - if (res == -1) { - // Failed - return errno; - } - - // Success - return 0; -} - -XErrno XPhysicalMemoryBacking::fallocate_fill_hole(size_t offset, size_t length) const { - // Using compat mode is more efficient when allocating space on hugetlbfs. - // Note that allocating huge pages this way will only reserve them, and not - // associate them with segments of the file. We must guarantee that we at - // some point touch these segments, otherwise we can not punch hole in them. - // Also note that we need to use compat mode when using transparent huge pages, - // since we need to use madvise(2) on the mapping before the page is allocated. - if (z_fallocate_supported && !XLargePages::is_enabled()) { - const XErrno err = fallocate_fill_hole_syscall(offset, length); - if (!err) { - // Success - return 0; - } - - if (err != ENOSYS && err != EOPNOTSUPP) { - // Failed - return err; - } - - // Not supported - log_debug_p(gc)("Falling back to fallocate() compatibility mode"); - z_fallocate_supported = false; - } - - return fallocate_fill_hole_compat(offset, length); -} - -XErrno XPhysicalMemoryBacking::fallocate_punch_hole(size_t offset, size_t length) const { - if (XLargePages::is_explicit()) { - // We can only punch hole in pages that have been touched. Non-touched - // pages are only reserved, and not associated with any specific file - // segment. We don't know which pages have been previously touched, so - // we always touch them here to guarantee that we can punch hole. - const XErrno err = fallocate_compat_mmap_hugetlbfs(offset, length, true /* touch */); - if (err) { - // Failed - return err; - } - } - - const int mode = FALLOC_FL_PUNCH_HOLE|FALLOC_FL_KEEP_SIZE; - if (XSyscall::fallocate(_fd, mode, offset, length) == -1) { - // Failed - return errno; - } - - // Success - return 0; -} - -XErrno XPhysicalMemoryBacking::split_and_fallocate(bool punch_hole, size_t offset, size_t length) const { - // Try first half - const size_t offset0 = offset; - const size_t length0 = align_up(length / 2, _block_size); - const XErrno err0 = fallocate(punch_hole, offset0, length0); - if (err0) { - return err0; - } - - // Try second half - const size_t offset1 = offset0 + length0; - const size_t length1 = length - length0; - const XErrno err1 = fallocate(punch_hole, offset1, length1); - if (err1) { - return err1; - } - - // Success - return 0; -} - -XErrno XPhysicalMemoryBacking::fallocate(bool punch_hole, size_t offset, size_t length) const { - assert(is_aligned(offset, _block_size), "Invalid offset"); - assert(is_aligned(length, _block_size), "Invalid length"); - - const XErrno err = punch_hole ? fallocate_punch_hole(offset, length) : fallocate_fill_hole(offset, length); - if (err == EINTR && length > _block_size) { - // Calling fallocate(2) with a large length can take a long time to - // complete. When running profilers, such as VTune, this syscall will - // be constantly interrupted by signals. Expanding the file in smaller - // steps avoids this problem. - return split_and_fallocate(punch_hole, offset, length); - } - - return err; -} - -bool XPhysicalMemoryBacking::commit_inner(size_t offset, size_t length) const { - log_trace(gc, heap)("Committing memory: " SIZE_FORMAT "M-" SIZE_FORMAT "M (" SIZE_FORMAT "M)", - offset / M, (offset + length) / M, length / M); - -retry: - const XErrno err = fallocate(false /* punch_hole */, offset, length); - if (err) { - if (err == ENOSPC && !is_init_completed() && XLargePages::is_explicit() && z_fallocate_hugetlbfs_attempts-- > 0) { - // If we fail to allocate during initialization, due to lack of space on - // the hugetlbfs filesystem, then we wait and retry a few times before - // giving up. Otherwise there is a risk that running JVMs back-to-back - // will fail, since there is a delay between process termination and the - // huge pages owned by that process being returned to the huge page pool - // and made available for new allocations. - log_debug_p(gc, init)("Failed to commit memory (%s), retrying", err.to_string()); - - // Wait and retry in one second, in the hope that huge pages will be - // available by then. - sleep(1); - goto retry; - } - - // Failed - log_error_p(gc)("Failed to commit memory (%s)", err.to_string()); - return false; - } - - // Success - return true; -} - -static int offset_to_node(size_t offset) { - const GrowableArray* mapping = os::Linux::numa_nindex_to_node(); - const size_t nindex = (offset >> XGranuleSizeShift) % mapping->length(); - return mapping->at((int)nindex); -} - -size_t XPhysicalMemoryBacking::commit_numa_interleaved(size_t offset, size_t length) const { - size_t committed = 0; - - // Commit one granule at a time, so that each granule - // can be allocated from a different preferred node. - while (committed < length) { - const size_t granule_offset = offset + committed; - - // Setup NUMA policy to allocate memory from a preferred node - os::Linux::numa_set_preferred(offset_to_node(granule_offset)); - - if (!commit_inner(granule_offset, XGranuleSize)) { - // Failed - break; - } - - committed += XGranuleSize; - } - - // Restore NUMA policy - os::Linux::numa_set_preferred(-1); - - return committed; -} - -size_t XPhysicalMemoryBacking::commit_default(size_t offset, size_t length) const { - // Try to commit the whole region - if (commit_inner(offset, length)) { - // Success - return length; - } - - // Failed, try to commit as much as possible - size_t start = offset; - size_t end = offset + length; - - for (;;) { - length = align_down((end - start) / 2, XGranuleSize); - if (length < XGranuleSize) { - // Done, don't commit more - return start - offset; - } - - if (commit_inner(start, length)) { - // Success, try commit more - start += length; - } else { - // Failed, try commit less - end -= length; - } - } -} - -size_t XPhysicalMemoryBacking::commit(size_t offset, size_t length) const { - if (XNUMA::is_enabled() && !XLargePages::is_explicit()) { - // To get granule-level NUMA interleaving when using non-large pages, - // we must explicitly interleave the memory at commit/fallocate time. - return commit_numa_interleaved(offset, length); - } - - return commit_default(offset, length); -} - -size_t XPhysicalMemoryBacking::uncommit(size_t offset, size_t length) const { - log_trace(gc, heap)("Uncommitting memory: " SIZE_FORMAT "M-" SIZE_FORMAT "M (" SIZE_FORMAT "M)", - offset / M, (offset + length) / M, length / M); - - const XErrno err = fallocate(true /* punch_hole */, offset, length); - if (err) { - log_error(gc)("Failed to uncommit memory (%s)", err.to_string()); - return 0; - } - - return length; -} - -void XPhysicalMemoryBacking::map(uintptr_t addr, size_t size, uintptr_t offset) const { - const void* const res = mmap((void*)addr, size, PROT_READ|PROT_WRITE, MAP_FIXED|MAP_SHARED, _fd, offset); - if (res == MAP_FAILED) { - XErrno err; - fatal("Failed to map memory (%s)", err.to_string()); - } -} - -void XPhysicalMemoryBacking::unmap(uintptr_t addr, size_t size) const { - // Note that we must keep the address space reservation intact and just detach - // the backing memory. For this reason we map a new anonymous, non-accessible - // and non-reserved page over the mapping instead of actually unmapping. - const void* const res = mmap((void*)addr, size, PROT_NONE, MAP_FIXED | MAP_ANONYMOUS | MAP_PRIVATE | MAP_NORESERVE, -1, 0); - if (res == MAP_FAILED) { - XErrno err; - fatal("Failed to map memory (%s)", err.to_string()); - } -} diff --git a/src/hotspot/os/linux/gc/x/xPhysicalMemoryBacking_linux.hpp b/src/hotspot/os/linux/gc/x/xPhysicalMemoryBacking_linux.hpp deleted file mode 100644 index 253a3f87ef4..00000000000 --- a/src/hotspot/os/linux/gc/x/xPhysicalMemoryBacking_linux.hpp +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2015, 2020, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef OS_LINUX_GC_X_XPHYSICALMEMORYBACKING_LINUX_HPP -#define OS_LINUX_GC_X_XPHYSICALMEMORYBACKING_LINUX_HPP - -class XErrno; - -class XPhysicalMemoryBacking { -private: - int _fd; - size_t _size; - uint64_t _filesystem; - size_t _block_size; - size_t _available; - bool _initialized; - - void warn_available_space(size_t max_capacity) const; - void warn_max_map_count(size_t max_capacity) const; - - int create_mem_fd(const char* name) const; - int create_file_fd(const char* name) const; - int create_fd(const char* name) const; - - bool is_tmpfs() const; - bool is_hugetlbfs() const; - bool tmpfs_supports_transparent_huge_pages() const; - - XErrno fallocate_compat_mmap_hugetlbfs(size_t offset, size_t length, bool touch) const; - XErrno fallocate_compat_mmap_tmpfs(size_t offset, size_t length) const; - XErrno fallocate_compat_pwrite(size_t offset, size_t length) const; - XErrno fallocate_fill_hole_compat(size_t offset, size_t length) const; - XErrno fallocate_fill_hole_syscall(size_t offset, size_t length) const; - XErrno fallocate_fill_hole(size_t offset, size_t length) const; - XErrno fallocate_punch_hole(size_t offset, size_t length) const; - XErrno split_and_fallocate(bool punch_hole, size_t offset, size_t length) const; - XErrno fallocate(bool punch_hole, size_t offset, size_t length) const; - - bool commit_inner(size_t offset, size_t length) const; - size_t commit_numa_interleaved(size_t offset, size_t length) const; - size_t commit_default(size_t offset, size_t length) const; - -public: - XPhysicalMemoryBacking(size_t max_capacity); - - bool is_initialized() const; - - void warn_commit_limits(size_t max_capacity) const; - - size_t commit(size_t offset, size_t length) const; - size_t uncommit(size_t offset, size_t length) const; - - void map(uintptr_t addr, size_t size, uintptr_t offset) const; - void unmap(uintptr_t addr, size_t size) const; -}; - -#endif // OS_LINUX_GC_X_XPHYSICALMEMORYBACKING_LINUX_HPP diff --git a/src/hotspot/os/linux/gc/x/xSyscall_linux.cpp b/src/hotspot/os/linux/gc/x/xSyscall_linux.cpp deleted file mode 100644 index 6035eaae61b..00000000000 --- a/src/hotspot/os/linux/gc/x/xSyscall_linux.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2019, 2020, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/x/xSyscall_linux.hpp" -#include OS_CPU_HEADER(gc/x/xSyscall) - -#include - -int XSyscall::memfd_create(const char *name, unsigned int flags) { - return syscall(SYS_memfd_create, name, flags); -} - -int XSyscall::fallocate(int fd, int mode, size_t offset, size_t length) { - return syscall(SYS_fallocate, fd, mode, offset, length); -} - -long XSyscall::get_mempolicy(int* mode, unsigned long* nodemask, unsigned long maxnode, void* addr, unsigned long flags) { - return syscall(SYS_get_mempolicy, mode, nodemask, maxnode, addr, flags); -} diff --git a/src/hotspot/os/linux/gc/x/xSyscall_linux.hpp b/src/hotspot/os/linux/gc/x/xSyscall_linux.hpp deleted file mode 100644 index f16d2b2ffdc..00000000000 --- a/src/hotspot/os/linux/gc/x/xSyscall_linux.hpp +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2019, 2022, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef OS_LINUX_GC_X_XSYSCALL_LINUX_HPP -#define OS_LINUX_GC_X_XSYSCALL_LINUX_HPP - -#include "memory/allStatic.hpp" -#include "utilities/globalDefinitions.hpp" - -// Flags for get_mempolicy() -#ifndef MPOL_F_NODE -#define MPOL_F_NODE (1<<0) -#endif -#ifndef MPOL_F_ADDR -#define MPOL_F_ADDR (1<<1) -#endif - -class XSyscall : public AllStatic { -public: - static int memfd_create(const char* name, unsigned int flags); - static int fallocate(int fd, int mode, size_t offset, size_t length); - static long get_mempolicy(int* mode, unsigned long* nodemask, unsigned long maxnode, void* addr, unsigned long flags); -}; - -#endif // OS_LINUX_GC_X_XSYSCALL_LINUX_HPP diff --git a/src/hotspot/os/posix/gc/x/xArguments_posix.cpp b/src/hotspot/os/posix/gc/x/xArguments_posix.cpp deleted file mode 100644 index 6df0a9bd074..00000000000 --- a/src/hotspot/os/posix/gc/x/xArguments_posix.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2019, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/x/xArguments.hpp" - -bool XArguments::is_os_supported() { - return true; -} diff --git a/src/hotspot/os/posix/gc/x/xInitialize_posix.cpp b/src/hotspot/os/posix/gc/x/xInitialize_posix.cpp deleted file mode 100644 index acf71e98901..00000000000 --- a/src/hotspot/os/posix/gc/x/xInitialize_posix.cpp +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2019, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/x/xInitialize.hpp" - -void XInitialize::pd_initialize() { - // Does nothing -} diff --git a/src/hotspot/os/posix/gc/x/xUtils_posix.cpp b/src/hotspot/os/posix/gc/x/xUtils_posix.cpp deleted file mode 100644 index eee3e5cfbe6..00000000000 --- a/src/hotspot/os/posix/gc/x/xUtils_posix.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2015, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/x/xUtils.hpp" -#include "utilities/debug.hpp" -#include "utilities/globalDefinitions.hpp" - -#include - -uintptr_t XUtils::alloc_aligned(size_t alignment, size_t size) { - void* res = nullptr; - - // Use raw posix_memalign as long as we have no wrapper for it - ALLOW_C_FUNCTION(::posix_memalign, int rc = posix_memalign(&res, alignment, size);) - if (rc != 0) { - fatal("posix_memalign() failed"); - } - - memset(res, 0, size); - - return (uintptr_t)res; -} diff --git a/src/hotspot/os/posix/gc/x/xVirtualMemory_posix.cpp b/src/hotspot/os/posix/gc/x/xVirtualMemory_posix.cpp deleted file mode 100644 index e2422eb0978..00000000000 --- a/src/hotspot/os/posix/gc/x/xVirtualMemory_posix.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2015, 2019, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/x/xAddress.inline.hpp" -#include "gc/x/xVirtualMemory.hpp" -#include "logging/log.hpp" - -#include -#include - -void XVirtualMemoryManager::pd_initialize_before_reserve() { - // Does nothing -} - -void XVirtualMemoryManager::pd_initialize_after_reserve() { - // Does nothing -} - -bool XVirtualMemoryManager::pd_reserve(uintptr_t addr, size_t size) { - const uintptr_t res = (uintptr_t)mmap((void*)addr, size, PROT_NONE, MAP_ANONYMOUS|MAP_PRIVATE|MAP_NORESERVE, -1, 0); - if (res == (uintptr_t)MAP_FAILED) { - // Failed to reserve memory - return false; - } - - if (res != addr) { - // Failed to reserve memory at the requested address - munmap((void*)res, size); - return false; - } - - // Success - return true; -} - -void XVirtualMemoryManager::pd_unreserve(uintptr_t addr, size_t size) { - const int res = munmap((void*)addr, size); - assert(res == 0, "Failed to unmap memory"); -} diff --git a/src/hotspot/os/posix/perfMemory_posix.cpp b/src/hotspot/os/posix/perfMemory_posix.cpp index 4eb46169878..17bf63092c2 100644 --- a/src/hotspot/os/posix/perfMemory_posix.cpp +++ b/src/hotspot/os/posix/perfMemory_posix.cpp @@ -1086,7 +1086,7 @@ static char* mmap_create_shared(size_t size) { static void unmap_shared(char* addr, size_t bytes) { int res; if (MemTracker::enabled()) { - ThreadCritical tc; + NmtVirtualMemoryLocker ml; res = ::munmap(addr, bytes); if (res == 0) { MemTracker::record_virtual_memory_release((address)addr, bytes); diff --git a/src/hotspot/os/windows/attachListener_windows.cpp b/src/hotspot/os/windows/attachListener_windows.cpp index 3f6ca941c20..bfa377d52cf 100644 --- a/src/hotspot/os/windows/attachListener_windows.cpp +++ b/src/hotspot/os/windows/attachListener_windows.cpp @@ -32,17 +32,24 @@ #include // SIGBREAK #include -// The AttachListener thread services a queue of operations. It blocks in the dequeue -// function until an operation is enqueued. A client enqueues an operation by creating +// The AttachListener thread services a queue of operation requests. It blocks in the dequeue +// function until a request is enqueued. A client enqueues a request by creating // a thread in this process using the Win32 CreateRemoteThread function. That thread // executes a small stub generated by the client. The stub invokes the -// JVM_EnqueueOperation function which checks the operation parameters and enqueues -// the operation to the queue serviced by the attach listener. The thread created by +// JVM_EnqueueOperation or JVM_EnqueueOperation_v2 function which checks the operation parameters +// and enqueues the operation request to the queue. The thread created by // the client is a native thread and is restricted to a single page of stack. To keep -// it simple operations are pre-allocated at initialization time. An enqueue thus -// takes a preallocated operation, populates the operation parameters, adds it to +// it simple operation requests are pre-allocated at initialization time. An enqueue thus +// takes a preallocated request, populates the operation parameters, adds it to // queue and wakes up the attach listener. // +// Differences between Attach API v1 and v2: +// In v1 (jdk6+) client calls JVM_EnqueueOperation function and passes all operation parameters +// as arguments of the function. +// In v2 (jdk24+) client calls JVM_EnqueueOperation_v2 function and passes only pipe name. +// Attach listeners connects to the pipe (in read/write mode) and reads all operation parameters +// (the same way as other platform implementations read them using sockets). +// // When an operation has completed the attach listener is required to send the // operation result and any result data to the client. In this implementation the // client is a pipe server. In the enqueue operation it provides the name of pipe @@ -55,8 +62,154 @@ // this wasn't worth worrying about. -// forward reference -class Win32AttachOperation; +class PipeChannel : public AttachOperation::RequestReader, public AttachOperation::ReplyWriter { +private: + HANDLE _hPipe; +public: + PipeChannel() : _hPipe(INVALID_HANDLE_VALUE) {} + ~PipeChannel() { + close(); + } + + bool opened() const { + return _hPipe != INVALID_HANDLE_VALUE; + } + + bool open(const char* pipe, bool write_only) { + _hPipe = ::CreateFile(pipe, + GENERIC_WRITE | (write_only ? 0 : GENERIC_READ), + 0, // no sharing + nullptr, // default security attributes + OPEN_EXISTING, // opens existing pipe + 0, // default attributes + nullptr); // no template file + if (_hPipe == INVALID_HANDLE_VALUE) { + log_error(attach)("could not open (%d) pipe %s", GetLastError(), pipe); + return false; + } + return true; + } + + void close() { + if (opened()) { + CloseHandle(_hPipe); + _hPipe = INVALID_HANDLE_VALUE; + } + } + + // RequestReader + int read(void* buffer, int size) override { + assert(opened(), "must be"); + DWORD nread; + BOOL fSuccess = ReadFile(_hPipe, + buffer, + (DWORD)size, + &nread, + nullptr); // not overlapped + return fSuccess ? (int)nread : -1; + } + + // ReplyWriter + int write(const void* buffer, int size) override { + assert(opened(), "must be"); + DWORD written; + BOOL fSuccess = WriteFile(_hPipe, + buffer, + (DWORD)size, + &written, + nullptr); // not overlapped + return fSuccess ? (int)written : -1; + } + + void flush() override { + assert(opened(), "must be"); + FlushFileBuffers(_hPipe); + } +}; + +class Win32AttachOperation: public AttachOperation { +public: + enum { + pipe_name_max = 256 // maximum pipe name + }; + +private: + PipeChannel _pipe; + +public: + // for v1 pipe must be write-only + void open_pipe(const char* pipe_name, bool write_only) { + _pipe.open(pipe_name, write_only); + } + + bool read_request() { + return AttachOperation::read_request(&_pipe); + } + +public: + void complete(jint result, bufferedStream* result_stream) override; +}; + + +// Win32AttachOperationRequest is an element of AttachOperation request list. +class Win32AttachOperationRequest { +private: + AttachAPIVersion _ver; + char _name[AttachOperation::name_length_max + 1]; + char _arg[AttachOperation::arg_count_max][AttachOperation::arg_length_max + 1]; + char _pipe[Win32AttachOperation::pipe_name_max + 1]; + + Win32AttachOperationRequest* _next; + + void set_value(char* dst, const char* str, size_t dst_size) { + if (str != nullptr) { + assert(strlen(str) < dst_size, "exceeds maximum length"); + strncpy(dst, str, dst_size - 1); + dst[dst_size - 1] = '\0'; + } else { + strcpy(dst, ""); + } + } + +public: + void set(AttachAPIVersion ver, const char* pipename, + const char* cmd = nullptr, + const char* arg0 = nullptr, + const char* arg1 = nullptr, + const char* arg2 = nullptr) { + _ver = ver; + set_value(_name, cmd, sizeof(_name)); + set_value(_arg[0], arg0, sizeof(_arg[0])); + set_value(_arg[1], arg1, sizeof(_arg[1])); + set_value(_arg[2], arg2, sizeof(_arg[2])); + set_value(_pipe, pipename, sizeof(_pipe)); + } + AttachAPIVersion ver() const { + return _ver; + } + const char* cmd() const { + return _name; + } + const char* arg(int i) const { + return (i >= 0 && i < AttachOperation::arg_count_max) ? _arg[i] : nullptr; + } + const char* pipe() const { + return _pipe; + } + + Win32AttachOperationRequest* next() const { + return _next; + } + void set_next(Win32AttachOperationRequest* next) { + _next = next; + } + + // noarg constructor as operation is preallocated + Win32AttachOperationRequest() { + set(ATTACH_API_V1, ""); + set_next(nullptr); + } +}; class Win32AttachListener: AllStatic { @@ -69,18 +222,18 @@ class Win32AttachListener: AllStatic { static HANDLE _mutex; // head of preallocated operations list - static Win32AttachOperation* _avail; + static Win32AttachOperationRequest* _avail; // head and tail of enqueue operations list - static Win32AttachOperation* _head; - static Win32AttachOperation* _tail; + static Win32AttachOperationRequest* _head; + static Win32AttachOperationRequest* _tail; - static Win32AttachOperation* head() { return _head; } - static void set_head(Win32AttachOperation* head) { _head = head; } + static Win32AttachOperationRequest* head() { return _head; } + static void set_head(Win32AttachOperationRequest* head) { _head = head; } - static Win32AttachOperation* tail() { return _tail; } - static void set_tail(Win32AttachOperation* tail) { _tail = tail; } + static Win32AttachOperationRequest* tail() { return _tail; } + static void set_tail(Win32AttachOperationRequest* tail) { _tail = tail; } // A semaphore is used for communication about enqueued operations. @@ -101,11 +254,12 @@ class Win32AttachListener: AllStatic { static int init(); static HANDLE mutex() { return _mutex; } - static Win32AttachOperation* available() { return _avail; } - static void set_available(Win32AttachOperation* avail) { _avail = avail; } + static Win32AttachOperationRequest* available() { return _avail; } + static void set_available(Win32AttachOperationRequest* avail) { _avail = avail; } // enqueue an operation to the end of the list - static int enqueue(char* cmd, char* arg1, char* arg2, char* arg3, char* pipename); + static int enqueue(AttachAPIVersion ver, const char* cmd, + const char* arg1, const char* arg2, const char* arg3, const char* pipename); // dequeue an operation from from head of the list static Win32AttachOperation* dequeue(); @@ -114,48 +268,9 @@ class Win32AttachListener: AllStatic { // statics HANDLE Win32AttachListener::_mutex; HANDLE Win32AttachListener::_enqueued_ops_semaphore; -Win32AttachOperation* Win32AttachListener::_avail; -Win32AttachOperation* Win32AttachListener::_head; -Win32AttachOperation* Win32AttachListener::_tail; - - -// Win32AttachOperation is an AttachOperation that additionally encapsulates the name -// of a pipe which is used to send the operation reply/output to the client. -// Win32AttachOperation can also be linked in a list. - -class Win32AttachOperation: public AttachOperation { - private: - friend class Win32AttachListener; - - enum { - pipe_name_max = 256 // maximum pipe name - }; - - char _pipe[pipe_name_max + 1]; - - const char* pipe() const { return _pipe; } - void set_pipe(const char* pipe) { - assert(strlen(pipe) <= pipe_name_max, "exceeds maximum length of pipe name"); - os::snprintf(_pipe, sizeof(_pipe), "%s", pipe); - } - - HANDLE open_pipe(); - static BOOL write_pipe(HANDLE hPipe, char* buf, int len); - - Win32AttachOperation* _next; - - Win32AttachOperation* next() const { return _next; } - void set_next(Win32AttachOperation* next) { _next = next; } - - // noarg constructor as operation is preallocated - Win32AttachOperation() : AttachOperation("") { - set_pipe(""); - set_next(nullptr); - } - - public: - void complete(jint result, bufferedStream* result_stream); -}; +Win32AttachOperationRequest* Win32AttachListener::_avail; +Win32AttachOperationRequest* Win32AttachListener::_head; +Win32AttachOperationRequest* Win32AttachListener::_tail; // Preallocate the maximum number of operations that can be enqueued. @@ -171,18 +286,24 @@ int Win32AttachListener::init() { set_available(nullptr); for (int i=0; iset_next(available()); set_available(op); } + AttachListener::set_supported_version(ATTACH_API_V2); + return 0; } // Enqueue an operation. This is called from a native thread that is not attached to VM. // Also we need to be careful not to execute anything that results in more than a 4k stack. // -int Win32AttachListener::enqueue(char* cmd, char* arg0, char* arg1, char* arg2, char* pipename) { +int Win32AttachListener::enqueue(AttachAPIVersion ver, const char* cmd, + const char* arg0, const char* arg1, const char* arg2, const char* pipename) { + + log_debug(attach)("AttachListener::enqueue, ver = %d, cmd = %s", (int)ver, cmd); + // wait up to 10 seconds for listener to be up and running int sleep_count = 0; while (!AttachListener::is_initialized()) { @@ -210,7 +331,7 @@ int Win32AttachListener::enqueue(char* cmd, char* arg0, char* arg1, char* arg2, } // try to get an operation from the available list - Win32AttachOperation* op = available(); + Win32AttachOperationRequest* op = available(); if (op != nullptr) { set_available(op->next()); @@ -223,11 +344,7 @@ int Win32AttachListener::enqueue(char* cmd, char* arg0, char* arg1, char* arg2, } set_tail(op); - op->set_name(cmd); - op->set_arg(0, arg0); - op->set_arg(1, arg1); - op->set_arg(2, arg2); - op->set_pipe(pipename); + op->set(ver, pipename, cmd, arg0, arg1, arg2); // Increment number of enqueued operations. // Side effect: Semaphore will be signaled and will release @@ -236,6 +353,7 @@ int Win32AttachListener::enqueue(char* cmd, char* arg0, char* arg1, char* arg2, ::ReleaseSemaphore(enqueued_ops_semaphore(), 1, nullptr); guarantee(not_exceeding_semaphore_maximum_count, "invariant"); } + ::ReleaseMutex(mutex()); return (op != nullptr) ? 0 : ATTACH_ERROR_RESOURCE; @@ -255,107 +373,63 @@ Win32AttachOperation* Win32AttachListener::dequeue() { guarantee(res != WAIT_FAILED, "WaitForSingleObject failed with error code: %lu", GetLastError()); guarantee(res == WAIT_OBJECT_0, "WaitForSingleObject failed with return value: %lu", res); + Win32AttachOperation* op = nullptr; + Win32AttachOperationRequest* request = head(); + if (request != nullptr) { + log_debug(attach)("AttachListener::dequeue, got request, ver = %d, cmd = %s", request->ver(), request->cmd()); - Win32AttachOperation* op = head(); - if (op != nullptr) { - set_head(op->next()); + set_head(request->next()); if (head() == nullptr) { // list is empty set_tail(nullptr); } + + switch (request->ver()) { + case ATTACH_API_V1: + op = new Win32AttachOperation(); + op->set_name(request->cmd()); + for (int i = 0; i < AttachOperation::arg_count_max; i++) { + op->append_arg(request->arg(i)); + } + op->open_pipe(request->pipe(), true/*write-only*/); + break; + case ATTACH_API_V2: + op = new Win32AttachOperation(); + op->open_pipe(request->pipe(), false/*write-only*/); + if (!op->read_request()) { + log_error(attach)("AttachListener::dequeue, reading request ERROR"); + delete op; + op = nullptr; + } + break; + default: + log_error(attach)("AttachListener::dequeue, unsupported version: %d", request->ver(), request->cmd()); + break; + } } + // put the operation back on the available list + request->set_next(Win32AttachListener::available()); + Win32AttachListener::set_available(request); + ::ReleaseMutex(mutex()); if (op != nullptr) { + log_debug(attach)("AttachListener::dequeue, return op: %s", op->name()); return op; } } } - -// open the pipe to the client -HANDLE Win32AttachOperation::open_pipe() { - HANDLE hPipe = ::CreateFile( pipe(), // pipe name - GENERIC_WRITE, // write only - 0, // no sharing - nullptr, // default security attributes - OPEN_EXISTING, // opens existing pipe - 0, // default attributes - nullptr); // no template file - return hPipe; -} - -// write to the pipe -BOOL Win32AttachOperation::write_pipe(HANDLE hPipe, char* buf, int len) { - do { - DWORD nwrote; - - BOOL fSuccess = WriteFile( hPipe, // pipe handle - (LPCVOID)buf, // message - (DWORD)len, // message length - &nwrote, // bytes written - nullptr); // not overlapped - if (!fSuccess) { - return fSuccess; - } - buf += nwrote; - len -= nwrote; - } while (len > 0); - return TRUE; -} - -// Complete the operation: -// - open the pipe to the client -// - write the operation result (a jint) -// - write the operation output (the result stream) -// void Win32AttachOperation::complete(jint result, bufferedStream* result_stream) { JavaThread* thread = JavaThread::current(); ThreadBlockInVM tbivm(thread); - HANDLE hPipe = open_pipe(); - int lastError = (int)::GetLastError(); - if (hPipe != INVALID_HANDLE_VALUE) { - BOOL fSuccess; - - char msg[32]; - os::snprintf(msg, sizeof(msg), "%d\n", result); - msg[sizeof(msg) - 1] = '\0'; - - fSuccess = write_pipe(hPipe, msg, (int)strlen(msg)); - if (fSuccess) { - fSuccess = write_pipe(hPipe, (char*)result_stream->base(), (int)(result_stream->size())); - } - lastError = (int)::GetLastError(); - - // Need to flush buffers - FlushFileBuffers(hPipe); - CloseHandle(hPipe); + write_reply(&_pipe, result, result_stream); - if (fSuccess) { - log_debug(attach)("wrote result of attach operation %s to pipe %s", name(), pipe()); - } else { - log_error(attach)("failure (%d) writing result of operation %s to pipe %s", lastError, name(), pipe()); - } - } else { - log_error(attach)("could not open (%d) pipe %s to send result of operation %s", lastError, pipe(), name()); - } - - DWORD res = ::WaitForSingleObject(Win32AttachListener::mutex(), INFINITE); - assert(res != WAIT_FAILED, "WaitForSingleObject failed with error code: %lu", GetLastError()); - assert(res == WAIT_OBJECT_0, "WaitForSingleObject failed with return value: %lu", res); - - if (res == WAIT_OBJECT_0) { - - // put the operation back on the available list - set_next(Win32AttachListener::available()); - Win32AttachListener::set_available(this); - - ::ReleaseMutex(Win32AttachListener::mutex()); - } + delete this; } -// AttachOperation functions +// AttachListener functions AttachOperation* AttachListener::dequeue() { JavaThread* thread = JavaThread::current(); @@ -404,8 +478,12 @@ void AttachListener::pd_detachall() { // Native thread started by remote client executes this. extern "C" { JNIEXPORT jint JNICALL - JVM_EnqueueOperation(char* cmd, char* arg0, char* arg1, char* arg2, char* pipename) { - return (jint)Win32AttachListener::enqueue(cmd, arg0, arg1, arg2, pipename); - } + JVM_EnqueueOperation(char* cmd, char* arg0, char* arg1, char* arg2, char* pipename) { + return (jint)Win32AttachListener::enqueue(ATTACH_API_V1, cmd, arg0, arg1, arg2, pipename); + } + JNIEXPORT jint JNICALL + JVM_EnqueueOperation_v2(char* pipename) { + return (jint)Win32AttachListener::enqueue(ATTACH_API_V2, "", "", "", "", pipename); + } } // extern diff --git a/src/hotspot/os/windows/gc/x/xArguments_windows.cpp b/src/hotspot/os/windows/gc/x/xArguments_windows.cpp deleted file mode 100644 index fc5f7eccb91..00000000000 --- a/src/hotspot/os/windows/gc/x/xArguments_windows.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2019, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/x/xArguments.hpp" -#include "gc/x/xSyscall_windows.hpp" - -bool XArguments::is_os_supported() { - return XSyscall::is_supported(); -} diff --git a/src/hotspot/os/windows/gc/x/xInitialize_windows.cpp b/src/hotspot/os/windows/gc/x/xInitialize_windows.cpp deleted file mode 100644 index 99f64328033..00000000000 --- a/src/hotspot/os/windows/gc/x/xInitialize_windows.cpp +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright (c) 2019, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/x/xInitialize.hpp" -#include "gc/x/xSyscall_windows.hpp" - -void XInitialize::pd_initialize() { - XSyscall::initialize(); -} diff --git a/src/hotspot/os/windows/gc/x/xLargePages_windows.cpp b/src/hotspot/os/windows/gc/x/xLargePages_windows.cpp deleted file mode 100644 index 20b3c4911fc..00000000000 --- a/src/hotspot/os/windows/gc/x/xLargePages_windows.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2019, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/shared/gcLogPrecious.hpp" -#include "gc/x/xLargePages.hpp" -#include "gc/x/xSyscall_windows.hpp" -#include "runtime/globals.hpp" - -void XLargePages::pd_initialize() { - if (UseLargePages) { - if (XSyscall::is_large_pages_supported()) { - _state = Explicit; - return; - } - log_info_p(gc, init)("Shared large pages not supported on this OS version"); - } - - _state = Disabled; -} diff --git a/src/hotspot/os/windows/gc/x/xMapper_windows.cpp b/src/hotspot/os/windows/gc/x/xMapper_windows.cpp deleted file mode 100644 index e69b6ec56e2..00000000000 --- a/src/hotspot/os/windows/gc/x/xMapper_windows.cpp +++ /dev/null @@ -1,310 +0,0 @@ -/* - * Copyright (c) 2019, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/x/xMapper_windows.hpp" -#include "gc/x/xSyscall_windows.hpp" -#include "logging/log.hpp" -#include "utilities/debug.hpp" - -#include - -// Memory reservation, commit, views, and placeholders. -// -// To be able to up-front reserve address space for the heap views, and later -// multi-map the heap views to the same physical memory, without ever losing the -// reservation of the reserved address space, we use "placeholders". -// -// These placeholders block out the address space from being used by other parts -// of the process. To commit memory in this address space, the placeholder must -// be replaced by anonymous memory, or replaced by mapping a view against a -// paging file mapping. We use the later to support multi-mapping. -// -// We want to be able to dynamically commit and uncommit the physical memory of -// the heap (and also unmap ZPages), in granules of ZGranuleSize bytes. There is -// no way to grow and shrink the committed memory of a paging file mapping. -// Therefore, we create multiple granule-sized page file mappings. The memory is -// committed by creating a page file mapping, map a view against it, commit the -// memory, unmap the view. The memory will stay committed until all views are -// unmapped, and the paging file mapping handle is closed. -// -// When replacing a placeholder address space reservation with a mapped view -// against a paging file mapping, the virtual address space must exactly match -// an existing placeholder's address and size. Therefore we only deal with -// granule-sized placeholders at this layer. Higher layers that keep track of -// reserved available address space can (and will) coalesce placeholders, but -// they will be split before being used. - -#define fatal_error(msg, addr, size) \ - fatal(msg ": " PTR_FORMAT " " SIZE_FORMAT "M (%d)", \ - (addr), (size) / M, GetLastError()) - -uintptr_t XMapper::reserve(uintptr_t addr, size_t size) { - void* const res = XSyscall::VirtualAlloc2( - GetCurrentProcess(), // Process - (void*)addr, // BaseAddress - size, // Size - MEM_RESERVE | MEM_RESERVE_PLACEHOLDER, // AllocationType - PAGE_NOACCESS, // PageProtection - nullptr, // ExtendedParameters - 0 // ParameterCount - ); - - // Caller responsible for error handling - return (uintptr_t)res; -} - -void XMapper::unreserve(uintptr_t addr, size_t size) { - const bool res = XSyscall::VirtualFreeEx( - GetCurrentProcess(), // hProcess - (void*)addr, // lpAddress - size, // dwSize - MEM_RELEASE // dwFreeType - ); - - if (!res) { - fatal_error("Failed to unreserve memory", addr, size); - } -} - -HANDLE XMapper::create_paging_file_mapping(size_t size) { - // Create mapping with SEC_RESERVE instead of SEC_COMMIT. - // - // We use MapViewOfFile3 for two different reasons: - // 1) When committing memory for the created paging file - // 2) When mapping a view of the memory created in (2) - // - // The non-platform code is only setup to deal with out-of-memory - // errors in (1). By using SEC_RESERVE, we prevent MapViewOfFile3 - // from failing because of "commit limit" checks. To actually commit - // memory in (1), a call to VirtualAlloc2 is done. - - HANDLE const res = XSyscall::CreateFileMappingW( - INVALID_HANDLE_VALUE, // hFile - nullptr, // lpFileMappingAttribute - PAGE_READWRITE | SEC_RESERVE, // flProtect - size >> 32, // dwMaximumSizeHigh - size & 0xFFFFFFFF, // dwMaximumSizeLow - nullptr // lpName - ); - - // Caller responsible for error handling - return res; -} - -bool XMapper::commit_paging_file_mapping(HANDLE file_handle, uintptr_t file_offset, size_t size) { - const uintptr_t addr = map_view_no_placeholder(file_handle, file_offset, size); - if (addr == 0) { - log_error(gc)("Failed to map view of paging file mapping (%d)", GetLastError()); - return false; - } - - const uintptr_t res = commit(addr, size); - if (res != addr) { - log_error(gc)("Failed to commit memory (%d)", GetLastError()); - } - - unmap_view_no_placeholder(addr, size); - - return res == addr; -} - -uintptr_t XMapper::map_view_no_placeholder(HANDLE file_handle, uintptr_t file_offset, size_t size) { - void* const res = XSyscall::MapViewOfFile3( - file_handle, // FileMapping - GetCurrentProcess(), // ProcessHandle - nullptr, // BaseAddress - file_offset, // Offset - size, // ViewSize - 0, // AllocationType - PAGE_NOACCESS, // PageProtection - nullptr, // ExtendedParameters - 0 // ParameterCount - ); - - // Caller responsible for error handling - return (uintptr_t)res; -} - -void XMapper::unmap_view_no_placeholder(uintptr_t addr, size_t size) { - const bool res = XSyscall::UnmapViewOfFile2( - GetCurrentProcess(), // ProcessHandle - (void*)addr, // BaseAddress - 0 // UnmapFlags - ); - - if (!res) { - fatal_error("Failed to unmap memory", addr, size); - } -} - -uintptr_t XMapper::commit(uintptr_t addr, size_t size) { - void* const res = XSyscall::VirtualAlloc2( - GetCurrentProcess(), // Process - (void*)addr, // BaseAddress - size, // Size - MEM_COMMIT, // AllocationType - PAGE_NOACCESS, // PageProtection - nullptr, // ExtendedParameters - 0 // ParameterCount - ); - - // Caller responsible for error handling - return (uintptr_t)res; -} - -HANDLE XMapper::create_and_commit_paging_file_mapping(size_t size) { - HANDLE const file_handle = create_paging_file_mapping(size); - if (file_handle == 0) { - log_error(gc)("Failed to create paging file mapping (%d)", GetLastError()); - return 0; - } - - const bool res = commit_paging_file_mapping(file_handle, 0 /* file_offset */, size); - if (!res) { - close_paging_file_mapping(file_handle); - return 0; - } - - return file_handle; -} - -void XMapper::close_paging_file_mapping(HANDLE file_handle) { - const bool res = CloseHandle( - file_handle // hObject - ); - - if (!res) { - fatal("Failed to close paging file handle (%d)", GetLastError()); - } -} - -HANDLE XMapper::create_shared_awe_section() { - MEM_EXTENDED_PARAMETER parameter = { 0 }; - parameter.Type = MemSectionExtendedParameterUserPhysicalFlags; - parameter.ULong64 = 0; - - HANDLE section = XSyscall::CreateFileMapping2( - INVALID_HANDLE_VALUE, // File - nullptr, // SecurityAttributes - SECTION_MAP_READ | SECTION_MAP_WRITE, // DesiredAccess - PAGE_READWRITE, // PageProtection - SEC_RESERVE | SEC_LARGE_PAGES, // AllocationAttributes - 0, // MaximumSize - nullptr, // Name - ¶meter, // ExtendedParameters - 1 // ParameterCount - ); - - if (section == nullptr) { - fatal("Could not create shared AWE section (%d)", GetLastError()); - } - - return section; -} - -uintptr_t XMapper::reserve_for_shared_awe(HANDLE awe_section, uintptr_t addr, size_t size) { - MEM_EXTENDED_PARAMETER parameter = { 0 }; - parameter.Type = MemExtendedParameterUserPhysicalHandle; - parameter.Handle = awe_section; - - void* const res = XSyscall::VirtualAlloc2( - GetCurrentProcess(), // Process - (void*)addr, // BaseAddress - size, // Size - MEM_RESERVE | MEM_PHYSICAL, // AllocationType - PAGE_READWRITE, // PageProtection - ¶meter, // ExtendedParameters - 1 // ParameterCount - ); - - // Caller responsible for error handling - return (uintptr_t)res; -} - -void XMapper::unreserve_for_shared_awe(uintptr_t addr, size_t size) { - bool res = VirtualFree( - (void*)addr, // lpAddress - 0, // dwSize - MEM_RELEASE // dwFreeType - ); - - if (!res) { - fatal("Failed to unreserve memory: " PTR_FORMAT " " SIZE_FORMAT "M (%d)", - addr, size / M, GetLastError()); - } -} - -void XMapper::split_placeholder(uintptr_t addr, size_t size) { - const bool res = VirtualFree( - (void*)addr, // lpAddress - size, // dwSize - MEM_RELEASE | MEM_PRESERVE_PLACEHOLDER // dwFreeType - ); - - if (!res) { - fatal_error("Failed to split placeholder", addr, size); - } -} - -void XMapper::coalesce_placeholders(uintptr_t addr, size_t size) { - const bool res = VirtualFree( - (void*)addr, // lpAddress - size, // dwSize - MEM_RELEASE | MEM_COALESCE_PLACEHOLDERS // dwFreeType - ); - - if (!res) { - fatal_error("Failed to coalesce placeholders", addr, size); - } -} - -void XMapper::map_view_replace_placeholder(HANDLE file_handle, uintptr_t file_offset, uintptr_t addr, size_t size) { - void* const res = XSyscall::MapViewOfFile3( - file_handle, // FileMapping - GetCurrentProcess(), // ProcessHandle - (void*)addr, // BaseAddress - file_offset, // Offset - size, // ViewSize - MEM_REPLACE_PLACEHOLDER, // AllocationType - PAGE_READWRITE, // PageProtection - nullptr, // ExtendedParameters - 0 // ParameterCount - ); - - if (res == nullptr) { - fatal_error("Failed to map memory", addr, size); - } -} - -void XMapper::unmap_view_preserve_placeholder(uintptr_t addr, size_t size) { - const bool res = XSyscall::UnmapViewOfFile2( - GetCurrentProcess(), // ProcessHandle - (void*)addr, // BaseAddress - MEM_PRESERVE_PLACEHOLDER // UnmapFlags - ); - - if (!res) { - fatal_error("Failed to unmap memory", addr, size); - } -} diff --git a/src/hotspot/os/windows/gc/x/xMapper_windows.hpp b/src/hotspot/os/windows/gc/x/xMapper_windows.hpp deleted file mode 100644 index 0f266d3fab7..00000000000 --- a/src/hotspot/os/windows/gc/x/xMapper_windows.hpp +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2019, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef OS_WINDOWS_GC_X_XMAPPER_WINDOWS_HPP -#define OS_WINDOWS_GC_X_XMAPPER_WINDOWS_HPP - -#include "memory/allStatic.hpp" -#include "utilities/globalDefinitions.hpp" - -#include - -class XMapper : public AllStatic { -private: - // Create paging file mapping - static HANDLE create_paging_file_mapping(size_t size); - - // Commit paging file mapping - static bool commit_paging_file_mapping(HANDLE file_handle, uintptr_t file_offset, size_t size); - - // Map a view anywhere without a placeholder - static uintptr_t map_view_no_placeholder(HANDLE file_handle, uintptr_t file_offset, size_t size); - - // Unmap a view without preserving a placeholder - static void unmap_view_no_placeholder(uintptr_t addr, size_t size); - - // Commit memory covering the given virtual address range - static uintptr_t commit(uintptr_t addr, size_t size); - -public: - // Reserve memory with a placeholder - static uintptr_t reserve(uintptr_t addr, size_t size); - - // Unreserve memory - static void unreserve(uintptr_t addr, size_t size); - - // Create and commit paging file mapping - static HANDLE create_and_commit_paging_file_mapping(size_t size); - - // Close paging file mapping - static void close_paging_file_mapping(HANDLE file_handle); - - // Create a shared AWE section - static HANDLE create_shared_awe_section(); - - // Reserve memory attached to the shared AWE section - static uintptr_t reserve_for_shared_awe(HANDLE awe_section, uintptr_t addr, size_t size); - - // Unreserve memory attached to a shared AWE section - static void unreserve_for_shared_awe(uintptr_t addr, size_t size); - - // Split a placeholder - // - // A view can only replace an entire placeholder, so placeholders need to be - // split and coalesced to be the exact size of the new views. - // [addr, addr + size) needs to be a proper sub-placeholder of an existing - // placeholder. - static void split_placeholder(uintptr_t addr, size_t size); - - // Coalesce a placeholder - // - // [addr, addr + size) is the new placeholder. A sub-placeholder needs to - // exist within that range. - static void coalesce_placeholders(uintptr_t addr, size_t size); - - // Map a view of the file handle and replace the placeholder covering the - // given virtual address range - static void map_view_replace_placeholder(HANDLE file_handle, uintptr_t file_offset, uintptr_t addr, size_t size); - - // Unmap the view and reinstate a placeholder covering the given virtual - // address range - static void unmap_view_preserve_placeholder(uintptr_t addr, size_t size); -}; - -#endif // OS_WINDOWS_GC_X_XMAPPER_WINDOWS_HPP diff --git a/src/hotspot/os/windows/gc/x/xNUMA_windows.cpp b/src/hotspot/os/windows/gc/x/xNUMA_windows.cpp deleted file mode 100644 index 47a84df962e..00000000000 --- a/src/hotspot/os/windows/gc/x/xNUMA_windows.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2019, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/x/xNUMA.hpp" - -void XNUMA::pd_initialize() { - _enabled = false; -} - -uint32_t XNUMA::count() { - return 1; -} - -uint32_t XNUMA::id() { - return 0; -} - -uint32_t XNUMA::memory_id(uintptr_t addr) { - // NUMA support not enabled, assume everything belongs to node zero - return 0; -} diff --git a/src/hotspot/os/windows/gc/x/xPhysicalMemoryBacking_windows.cpp b/src/hotspot/os/windows/gc/x/xPhysicalMemoryBacking_windows.cpp deleted file mode 100644 index 92d47dfb7c8..00000000000 --- a/src/hotspot/os/windows/gc/x/xPhysicalMemoryBacking_windows.cpp +++ /dev/null @@ -1,252 +0,0 @@ -/* - * Copyright (c) 2019, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/x/xGlobals.hpp" -#include "gc/x/xGranuleMap.inline.hpp" -#include "gc/x/xLargePages.inline.hpp" -#include "gc/x/xMapper_windows.hpp" -#include "gc/x/xPhysicalMemoryBacking_windows.hpp" -#include "logging/log.hpp" -#include "runtime/globals.hpp" -#include "utilities/debug.hpp" - -class XPhysicalMemoryBackingImpl : public CHeapObj { -public: - virtual size_t commit(size_t offset, size_t size) = 0; - virtual size_t uncommit(size_t offset, size_t size) = 0; - virtual void map(uintptr_t addr, size_t size, size_t offset) const = 0; - virtual void unmap(uintptr_t addr, size_t size) const = 0; -}; - -// Implements small pages (paged) support using placeholder reservation. -// -// The backing commits and uncommits physical memory, that can be -// multi-mapped into the virtual address space. To support fine-graned -// committing and uncommitting, each XGranuleSize'd chunk is mapped to -// a separate paging file mapping. - -class XPhysicalMemoryBackingSmallPages : public XPhysicalMemoryBackingImpl { -private: - XGranuleMap _handles; - - HANDLE get_handle(uintptr_t offset) const { - HANDLE const handle = _handles.get(offset); - assert(handle != 0, "Should be set"); - return handle; - } - - void put_handle(uintptr_t offset, HANDLE handle) { - assert(handle != INVALID_HANDLE_VALUE, "Invalid handle"); - assert(_handles.get(offset) == 0, "Should be cleared"); - _handles.put(offset, handle); - } - - void clear_handle(uintptr_t offset) { - assert(_handles.get(offset) != 0, "Should be set"); - _handles.put(offset, 0); - } - -public: - XPhysicalMemoryBackingSmallPages(size_t max_capacity) : - XPhysicalMemoryBackingImpl(), - _handles(max_capacity) {} - - size_t commit(size_t offset, size_t size) { - for (size_t i = 0; i < size; i += XGranuleSize) { - HANDLE const handle = XMapper::create_and_commit_paging_file_mapping(XGranuleSize); - if (handle == 0) { - return i; - } - - put_handle(offset + i, handle); - } - - return size; - } - - size_t uncommit(size_t offset, size_t size) { - for (size_t i = 0; i < size; i += XGranuleSize) { - HANDLE const handle = get_handle(offset + i); - clear_handle(offset + i); - XMapper::close_paging_file_mapping(handle); - } - - return size; - } - - void map(uintptr_t addr, size_t size, size_t offset) const { - assert(is_aligned(offset, XGranuleSize), "Misaligned"); - assert(is_aligned(addr, XGranuleSize), "Misaligned"); - assert(is_aligned(size, XGranuleSize), "Misaligned"); - - for (size_t i = 0; i < size; i += XGranuleSize) { - HANDLE const handle = get_handle(offset + i); - XMapper::map_view_replace_placeholder(handle, 0 /* offset */, addr + i, XGranuleSize); - } - } - - void unmap(uintptr_t addr, size_t size) const { - assert(is_aligned(addr, XGranuleSize), "Misaligned"); - assert(is_aligned(size, XGranuleSize), "Misaligned"); - - for (size_t i = 0; i < size; i += XGranuleSize) { - XMapper::unmap_view_preserve_placeholder(addr + i, XGranuleSize); - } - } -}; - -// Implements Large Pages (locked) support using shared AWE physical memory. -// -// Shared AWE physical memory also works with small pages, but it has -// a few drawbacks that makes it a no-go to use it at this point: -// -// 1) It seems to use 8 bytes of committed memory per *reserved* memory. -// Given our scheme to use a large address space range this turns out to -// use too much memory. -// -// 2) It requires memory locking privileges, even for small pages. This -// has always been a requirement for large pages, and would be an extra -// restriction for usage with small pages. -// -// Note: The large pages size is tied to our XGranuleSize. - -extern HANDLE XAWESection; - -class XPhysicalMemoryBackingLargePages : public XPhysicalMemoryBackingImpl { -private: - ULONG_PTR* const _page_array; - - static ULONG_PTR* alloc_page_array(size_t max_capacity) { - const size_t npages = max_capacity / XGranuleSize; - const size_t array_size = npages * sizeof(ULONG_PTR); - - return (ULONG_PTR*)os::malloc(array_size, mtGC); - } - -public: - XPhysicalMemoryBackingLargePages(size_t max_capacity) : - XPhysicalMemoryBackingImpl(), - _page_array(alloc_page_array(max_capacity)) {} - - size_t commit(size_t offset, size_t size) { - const size_t index = offset >> XGranuleSizeShift; - const size_t npages = size >> XGranuleSizeShift; - - size_t npages_res = npages; - const bool res = AllocateUserPhysicalPages(XAWESection, &npages_res, &_page_array[index]); - if (!res) { - fatal("Failed to allocate physical memory " SIZE_FORMAT "M @ " PTR_FORMAT " (%d)", - size / M, offset, GetLastError()); - } else { - log_debug(gc)("Allocated physical memory: " SIZE_FORMAT "M @ " PTR_FORMAT, size / M, offset); - } - - // AllocateUserPhysicalPages might not be able to allocate the requested amount of memory. - // The allocated number of pages are written in npages_res. - return npages_res << XGranuleSizeShift; - } - - size_t uncommit(size_t offset, size_t size) { - const size_t index = offset >> XGranuleSizeShift; - const size_t npages = size >> XGranuleSizeShift; - - size_t npages_res = npages; - const bool res = FreeUserPhysicalPages(XAWESection, &npages_res, &_page_array[index]); - if (!res) { - fatal("Failed to uncommit physical memory " SIZE_FORMAT "M @ " PTR_FORMAT " (%d)", - size, offset, GetLastError()); - } - - return npages_res << XGranuleSizeShift; - } - - void map(uintptr_t addr, size_t size, size_t offset) const { - const size_t npages = size >> XGranuleSizeShift; - const size_t index = offset >> XGranuleSizeShift; - - const bool res = MapUserPhysicalPages((char*)addr, npages, &_page_array[index]); - if (!res) { - fatal("Failed to map view " PTR_FORMAT " " SIZE_FORMAT "M @ " PTR_FORMAT " (%d)", - addr, size / M, offset, GetLastError()); - } - } - - void unmap(uintptr_t addr, size_t size) const { - const size_t npages = size >> XGranuleSizeShift; - - const bool res = MapUserPhysicalPages((char*)addr, npages, nullptr); - if (!res) { - fatal("Failed to unmap view " PTR_FORMAT " " SIZE_FORMAT "M (%d)", - addr, size / M, GetLastError()); - } - } -}; - -static XPhysicalMemoryBackingImpl* select_impl(size_t max_capacity) { - if (XLargePages::is_enabled()) { - return new XPhysicalMemoryBackingLargePages(max_capacity); - } - - return new XPhysicalMemoryBackingSmallPages(max_capacity); -} - -XPhysicalMemoryBacking::XPhysicalMemoryBacking(size_t max_capacity) : - _impl(select_impl(max_capacity)) {} - -bool XPhysicalMemoryBacking::is_initialized() const { - return true; -} - -void XPhysicalMemoryBacking::warn_commit_limits(size_t max_capacity) const { - // Does nothing -} - -size_t XPhysicalMemoryBacking::commit(size_t offset, size_t length) { - log_trace(gc, heap)("Committing memory: " SIZE_FORMAT "M-" SIZE_FORMAT "M (" SIZE_FORMAT "M)", - offset / M, (offset + length) / M, length / M); - - return _impl->commit(offset, length); -} - -size_t XPhysicalMemoryBacking::uncommit(size_t offset, size_t length) { - log_trace(gc, heap)("Uncommitting memory: " SIZE_FORMAT "M-" SIZE_FORMAT "M (" SIZE_FORMAT "M)", - offset / M, (offset + length) / M, length / M); - - return _impl->uncommit(offset, length); -} - -void XPhysicalMemoryBacking::map(uintptr_t addr, size_t size, size_t offset) const { - assert(is_aligned(offset, XGranuleSize), "Misaligned: " PTR_FORMAT, offset); - assert(is_aligned(addr, XGranuleSize), "Misaligned: " PTR_FORMAT, addr); - assert(is_aligned(size, XGranuleSize), "Misaligned: " PTR_FORMAT, size); - - _impl->map(addr, size, offset); -} - -void XPhysicalMemoryBacking::unmap(uintptr_t addr, size_t size) const { - assert(is_aligned(addr, XGranuleSize), "Misaligned"); - assert(is_aligned(size, XGranuleSize), "Misaligned"); - - _impl->unmap(addr, size); -} diff --git a/src/hotspot/os/windows/gc/x/xPhysicalMemoryBacking_windows.hpp b/src/hotspot/os/windows/gc/x/xPhysicalMemoryBacking_windows.hpp deleted file mode 100644 index d6e123f21e5..00000000000 --- a/src/hotspot/os/windows/gc/x/xPhysicalMemoryBacking_windows.hpp +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2019, 2020, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef OS_WINDOWS_GC_X_XPHYSICALMEMORYBACKING_WINDOWS_HPP -#define OS_WINDOWS_GC_X_XPHYSICALMEMORYBACKING_WINDOWS_HPP - -#include "utilities/globalDefinitions.hpp" - -#include - -class XPhysicalMemoryBackingImpl; - -class XPhysicalMemoryBacking { -private: - XPhysicalMemoryBackingImpl* _impl; - -public: - XPhysicalMemoryBacking(size_t max_capacity); - - bool is_initialized() const; - - void warn_commit_limits(size_t max_capacity) const; - - size_t commit(size_t offset, size_t length); - size_t uncommit(size_t offset, size_t length); - - void map(uintptr_t addr, size_t size, size_t offset) const; - void unmap(uintptr_t addr, size_t size) const; -}; - -#endif // OS_WINDOWS_GC_X_XPHYSICALMEMORYBACKING_WINDOWS_HPP diff --git a/src/hotspot/os/windows/gc/x/xSyscall_windows.cpp b/src/hotspot/os/windows/gc/x/xSyscall_windows.cpp deleted file mode 100644 index f22966a5489..00000000000 --- a/src/hotspot/os/windows/gc/x/xSyscall_windows.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2019, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/shared/gcLogPrecious.hpp" -#include "gc/x/xSyscall_windows.hpp" -#include "runtime/java.hpp" -#include "runtime/os.hpp" - -XSyscall::CreateFileMappingWFn XSyscall::CreateFileMappingW; -XSyscall::CreateFileMapping2Fn XSyscall::CreateFileMapping2; -XSyscall::VirtualAlloc2Fn XSyscall::VirtualAlloc2; -XSyscall::VirtualFreeExFn XSyscall::VirtualFreeEx; -XSyscall::MapViewOfFile3Fn XSyscall::MapViewOfFile3; -XSyscall::UnmapViewOfFile2Fn XSyscall::UnmapViewOfFile2; - -static void* lookup_kernelbase_library() { - const char* const name = "KernelBase"; - char ebuf[1024]; - void* const handle = os::dll_load(name, ebuf, sizeof(ebuf)); - if (handle == nullptr) { - log_error_p(gc)("Failed to load library: %s", name); - } - return handle; -} - -static void* lookup_kernelbase_symbol(const char* name) { - static void* const handle = lookup_kernelbase_library(); - if (handle == nullptr) { - return nullptr; - } - return os::dll_lookup(handle, name); -} - -static bool has_kernelbase_symbol(const char* name) { - return lookup_kernelbase_symbol(name) != nullptr; -} - -template -static void install_kernelbase_symbol(Fn*& fn, const char* name) { - fn = reinterpret_cast(lookup_kernelbase_symbol(name)); -} - -template -static void install_kernelbase_1803_symbol_or_exit(Fn*& fn, const char* name) { - install_kernelbase_symbol(fn, name); - if (fn == nullptr) { - log_error_p(gc)("Failed to lookup symbol: %s", name); - vm_exit_during_initialization("ZGC requires Windows version 1803 or later"); - } -} - -void XSyscall::initialize() { - // Required - install_kernelbase_1803_symbol_or_exit(CreateFileMappingW, "CreateFileMappingW"); - install_kernelbase_1803_symbol_or_exit(VirtualAlloc2, "VirtualAlloc2"); - install_kernelbase_1803_symbol_or_exit(VirtualFreeEx, "VirtualFreeEx"); - install_kernelbase_1803_symbol_or_exit(MapViewOfFile3, "MapViewOfFile3"); - install_kernelbase_1803_symbol_or_exit(UnmapViewOfFile2, "UnmapViewOfFile2"); - - // Optional - for large pages support - install_kernelbase_symbol(CreateFileMapping2, "CreateFileMapping2"); -} - -bool XSyscall::is_supported() { - // Available in Windows version 1803 and later - return has_kernelbase_symbol("VirtualAlloc2"); -} - -bool XSyscall::is_large_pages_supported() { - // Available in Windows version 1809 and later - return has_kernelbase_symbol("CreateFileMapping2"); -} diff --git a/src/hotspot/os/windows/gc/x/xSyscall_windows.hpp b/src/hotspot/os/windows/gc/x/xSyscall_windows.hpp deleted file mode 100644 index 89ba2573b10..00000000000 --- a/src/hotspot/os/windows/gc/x/xSyscall_windows.hpp +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2019, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef OS_WINDOWS_GC_X_XSYSCALL_WINDOWS_HPP -#define OS_WINDOWS_GC_X_XSYSCALL_WINDOWS_HPP - -#include "utilities/globalDefinitions.hpp" - -#include -#include - -class XSyscall { -private: - typedef HANDLE (*CreateFileMappingWFn)(HANDLE, LPSECURITY_ATTRIBUTES, DWORD, DWORD, DWORD, LPCWSTR); - typedef HANDLE (*CreateFileMapping2Fn)(HANDLE, LPSECURITY_ATTRIBUTES, ULONG, ULONG, ULONG, ULONG64, PCWSTR, PMEM_EXTENDED_PARAMETER, ULONG); - typedef PVOID (*VirtualAlloc2Fn)(HANDLE, PVOID, SIZE_T, ULONG, ULONG, MEM_EXTENDED_PARAMETER*, ULONG); - typedef BOOL (*VirtualFreeExFn)(HANDLE, LPVOID, SIZE_T, DWORD); - typedef PVOID (*MapViewOfFile3Fn)(HANDLE, HANDLE, PVOID, ULONG64, SIZE_T, ULONG, ULONG, MEM_EXTENDED_PARAMETER*, ULONG); - typedef BOOL (*UnmapViewOfFile2Fn)(HANDLE, PVOID, ULONG); - -public: - static CreateFileMappingWFn CreateFileMappingW; - static CreateFileMapping2Fn CreateFileMapping2; - static VirtualAlloc2Fn VirtualAlloc2; - static VirtualFreeExFn VirtualFreeEx; - static MapViewOfFile3Fn MapViewOfFile3; - static UnmapViewOfFile2Fn UnmapViewOfFile2; - - static void initialize(); - - static bool is_supported(); - static bool is_large_pages_supported(); -}; - -#endif // OS_WINDOWS_GC_X_XSYSCALL_WINDOWS_HPP diff --git a/src/hotspot/os/windows/gc/x/xUtils_windows.cpp b/src/hotspot/os/windows/gc/x/xUtils_windows.cpp deleted file mode 100644 index 788da80834a..00000000000 --- a/src/hotspot/os/windows/gc/x/xUtils_windows.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2019, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/x/xUtils.hpp" -#include "utilities/debug.hpp" - -#include - -uintptr_t XUtils::alloc_aligned(size_t alignment, size_t size) { - void* const res = _aligned_malloc(size, alignment); - - if (res == nullptr) { - fatal("_aligned_malloc failed"); - } - - memset(res, 0, size); - - return (uintptr_t)res; -} diff --git a/src/hotspot/os/windows/gc/x/xVirtualMemory_windows.cpp b/src/hotspot/os/windows/gc/x/xVirtualMemory_windows.cpp deleted file mode 100644 index a54f1e3cbae..00000000000 --- a/src/hotspot/os/windows/gc/x/xVirtualMemory_windows.cpp +++ /dev/null @@ -1,195 +0,0 @@ -/* - * Copyright (c) 2019, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/x/xAddress.inline.hpp" -#include "gc/x/xGlobals.hpp" -#include "gc/x/xLargePages.inline.hpp" -#include "gc/x/xMapper_windows.hpp" -#include "gc/x/xSyscall_windows.hpp" -#include "gc/x/xVirtualMemory.inline.hpp" -#include "utilities/align.hpp" -#include "utilities/debug.hpp" - -class XVirtualMemoryManagerImpl : public CHeapObj { -public: - virtual void initialize_before_reserve() {} - virtual void initialize_after_reserve(XMemoryManager* manager) {} - virtual bool reserve(uintptr_t addr, size_t size) = 0; - virtual void unreserve(uintptr_t addr, size_t size) = 0; -}; - -// Implements small pages (paged) support using placeholder reservation. -class XVirtualMemoryManagerSmallPages : public XVirtualMemoryManagerImpl { -private: - class PlaceholderCallbacks : public AllStatic { - public: - static void split_placeholder(uintptr_t start, size_t size) { - XMapper::split_placeholder(XAddress::marked0(start), size); - XMapper::split_placeholder(XAddress::marked1(start), size); - XMapper::split_placeholder(XAddress::remapped(start), size); - } - - static void coalesce_placeholders(uintptr_t start, size_t size) { - XMapper::coalesce_placeholders(XAddress::marked0(start), size); - XMapper::coalesce_placeholders(XAddress::marked1(start), size); - XMapper::coalesce_placeholders(XAddress::remapped(start), size); - } - - static void split_into_placeholder_granules(uintptr_t start, size_t size) { - for (uintptr_t addr = start; addr < start + size; addr += XGranuleSize) { - split_placeholder(addr, XGranuleSize); - } - } - - static void coalesce_into_one_placeholder(uintptr_t start, size_t size) { - assert(is_aligned(size, XGranuleSize), "Must be granule aligned"); - - if (size > XGranuleSize) { - coalesce_placeholders(start, size); - } - } - - static void create_callback(const XMemory* area) { - assert(is_aligned(area->size(), XGranuleSize), "Must be granule aligned"); - coalesce_into_one_placeholder(area->start(), area->size()); - } - - static void destroy_callback(const XMemory* area) { - assert(is_aligned(area->size(), XGranuleSize), "Must be granule aligned"); - // Don't try split the last granule - VirtualFree will fail - split_into_placeholder_granules(area->start(), area->size() - XGranuleSize); - } - - static void shrink_from_front_callback(const XMemory* area, size_t size) { - assert(is_aligned(size, XGranuleSize), "Must be granule aligned"); - split_into_placeholder_granules(area->start(), size); - } - - static void shrink_from_back_callback(const XMemory* area, size_t size) { - assert(is_aligned(size, XGranuleSize), "Must be granule aligned"); - // Don't try split the last granule - VirtualFree will fail - split_into_placeholder_granules(area->end() - size, size - XGranuleSize); - } - - static void grow_from_front_callback(const XMemory* area, size_t size) { - assert(is_aligned(area->size(), XGranuleSize), "Must be granule aligned"); - coalesce_into_one_placeholder(area->start() - size, area->size() + size); - } - - static void grow_from_back_callback(const XMemory* area, size_t size) { - assert(is_aligned(area->size(), XGranuleSize), "Must be granule aligned"); - coalesce_into_one_placeholder(area->start(), area->size() + size); - } - - static void register_with(XMemoryManager* manager) { - // Each reserved virtual memory address area registered in _manager is - // exactly covered by a single placeholder. Callbacks are installed so - // that whenever a memory area changes, the corresponding placeholder - // is adjusted. - // - // The create and grow callbacks are called when virtual memory is - // returned to the memory manager. The new memory area is then covered - // by a new single placeholder. - // - // The destroy and shrink callbacks are called when virtual memory is - // allocated from the memory manager. The memory area is then is split - // into granule-sized placeholders. - // - // See comment in zMapper_windows.cpp explaining why placeholders are - // split into XGranuleSize sized placeholders. - - XMemoryManager::Callbacks callbacks; - - callbacks._create = &create_callback; - callbacks._destroy = &destroy_callback; - callbacks._shrink_from_front = &shrink_from_front_callback; - callbacks._shrink_from_back = &shrink_from_back_callback; - callbacks._grow_from_front = &grow_from_front_callback; - callbacks._grow_from_back = &grow_from_back_callback; - - manager->register_callbacks(callbacks); - } - }; - - virtual void initialize_after_reserve(XMemoryManager* manager) { - PlaceholderCallbacks::register_with(manager); - } - - virtual bool reserve(uintptr_t addr, size_t size) { - const uintptr_t res = XMapper::reserve(addr, size); - - assert(res == addr || res == 0, "Should not reserve other memory than requested"); - return res == addr; - } - - virtual void unreserve(uintptr_t addr, size_t size) { - XMapper::unreserve(addr, size); - } -}; - -// Implements Large Pages (locked) support using shared AWE physical memory. - -// XPhysicalMemory layer needs access to the section -HANDLE XAWESection; - -class XVirtualMemoryManagerLargePages : public XVirtualMemoryManagerImpl { -private: - virtual void initialize_before_reserve() { - XAWESection = XMapper::create_shared_awe_section(); - } - - virtual bool reserve(uintptr_t addr, size_t size) { - const uintptr_t res = XMapper::reserve_for_shared_awe(XAWESection, addr, size); - - assert(res == addr || res == 0, "Should not reserve other memory than requested"); - return res == addr; - } - - virtual void unreserve(uintptr_t addr, size_t size) { - XMapper::unreserve_for_shared_awe(addr, size); - } -}; - -static XVirtualMemoryManagerImpl* _impl = nullptr; - -void XVirtualMemoryManager::pd_initialize_before_reserve() { - if (XLargePages::is_enabled()) { - _impl = new XVirtualMemoryManagerLargePages(); - } else { - _impl = new XVirtualMemoryManagerSmallPages(); - } - _impl->initialize_before_reserve(); -} - -void XVirtualMemoryManager::pd_initialize_after_reserve() { - _impl->initialize_after_reserve(&_manager); -} - -bool XVirtualMemoryManager::pd_reserve(uintptr_t addr, size_t size) { - return _impl->reserve(addr, size); -} - -void XVirtualMemoryManager::pd_unreserve(uintptr_t addr, size_t size) { - _impl->unreserve(addr, size); -} diff --git a/src/hotspot/os/windows/os_windows.cpp b/src/hotspot/os/windows/os_windows.cpp index 4dafef0c098..71efb57e0f2 100644 --- a/src/hotspot/os/windows/os_windows.cpp +++ b/src/hotspot/os/windows/os_windows.cpp @@ -3825,7 +3825,8 @@ bool os::pd_release_memory(char* addr, size_t bytes) { if (err != nullptr) { log_warning(os)("bad release: [" PTR_FORMAT "-" PTR_FORMAT "): %s", p2i(start), p2i(end), err); #ifdef ASSERT - os::print_memory_mappings((char*)start, bytes, tty); + fileStream fs(stdout); + os::print_memory_mappings((char*)start, bytes, &fs); assert(false, "bad release: [" PTR_FORMAT "-" PTR_FORMAT "): %s", p2i(start), p2i(end), err); #endif return false; diff --git a/src/hotspot/os/windows/perfMemory_windows.cpp b/src/hotspot/os/windows/perfMemory_windows.cpp index 06b057315cb..959be982fab 100644 --- a/src/hotspot/os/windows/perfMemory_windows.cpp +++ b/src/hotspot/os/windows/perfMemory_windows.cpp @@ -1803,7 +1803,7 @@ void PerfMemory::detach(char* addr, size_t bytes) { if (MemTracker::enabled()) { // it does not go through os api, the operation has to record from here - ThreadCritical tc; + NmtVirtualMemoryLocker ml; remove_file_mapping(addr); MemTracker::record_virtual_memory_release((address)addr, bytes); } else { diff --git a/src/hotspot/os_cpu/aix_ppc/os_aix_ppc.cpp b/src/hotspot/os_cpu/aix_ppc/os_aix_ppc.cpp index b45d38650c0..f83aa603062 100644 --- a/src/hotspot/os_cpu/aix_ppc/os_aix_ppc.cpp +++ b/src/hotspot/os_cpu/aix_ppc/os_aix_ppc.cpp @@ -462,12 +462,6 @@ void os::print_tos_pc(outputStream *st, const void *context) { address pc = os::Posix::ucontext_get_pc(uc); print_instructions(st, pc); st->cr(); - - // Try to decode the instructions. - st->print_cr("Decoded instructions: (pc=" PTR_FORMAT ")", p2i(pc)); - st->print(""); - // TODO: PPC port Disassembler::decode(pc, 16, 16, st); - st->cr(); } void os::print_register_info(outputStream *st, const void *context, int& continuation) { diff --git a/src/hotspot/os_cpu/linux_aarch64/gc/x/xSyscall_linux_aarch64.hpp b/src/hotspot/os_cpu/linux_aarch64/gc/x/xSyscall_linux_aarch64.hpp deleted file mode 100644 index b4c49f477a6..00000000000 --- a/src/hotspot/os_cpu/linux_aarch64/gc/x/xSyscall_linux_aarch64.hpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2019, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef OS_CPU_LINUX_AARCH64_GC_X_XSYSCALL_LINUX_AARCH64_HPP -#define OS_CPU_LINUX_AARCH64_GC_X_XSYSCALL_LINUX_AARCH64_HPP - -#include - -// -// Support for building on older Linux systems -// - -#ifndef SYS_memfd_create -#define SYS_memfd_create 279 -#endif -#ifndef SYS_fallocate -#define SYS_fallocate 47 -#endif - -#endif // OS_CPU_LINUX_AARCH64_GC_X_XSYSCALL_LINUX_AARCH64_HPP diff --git a/src/hotspot/os_cpu/linux_ppc/gc/x/xSyscall_linux_ppc.hpp b/src/hotspot/os_cpu/linux_ppc/gc/x/xSyscall_linux_ppc.hpp deleted file mode 100644 index 22d51cd58f5..00000000000 --- a/src/hotspot/os_cpu/linux_ppc/gc/x/xSyscall_linux_ppc.hpp +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2021 SAP SE. 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef OS_CPU_LINUX_PPC_GC_X_XSYSCALL_LINUX_PPC_HPP -#define OS_CPU_LINUX_PPC_GC_X_XSYSCALL_LINUX_PPC_HPP - -#include - -// -// Support for building on older Linux systems -// - - -#ifndef SYS_memfd_create -#define SYS_memfd_create 360 -#endif -#ifndef SYS_fallocate -#define SYS_fallocate 309 -#endif - -#endif // OS_CPU_LINUX_PPC_GC_X_XSYSCALL_LINUX_PPC_HPP diff --git a/src/hotspot/os_cpu/linux_riscv/gc/x/xSyscall_linux_riscv.hpp b/src/hotspot/os_cpu/linux_riscv/gc/x/xSyscall_linux_riscv.hpp deleted file mode 100644 index bfd49b0bf4e..00000000000 --- a/src/hotspot/os_cpu/linux_riscv/gc/x/xSyscall_linux_riscv.hpp +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2020, 2021, Huawei Technologies Co., Ltd. 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#ifndef OS_CPU_LINUX_RISCV_GC_X_XSYSCALL_LINUX_RISCV_HPP -#define OS_CPU_LINUX_RISCV_GC_X_XSYSCALL_LINUX_RISCV_HPP - -#include - -// -// Support for building on older Linux systems -// - -#ifndef SYS_memfd_create -#define SYS_memfd_create 279 -#endif -#ifndef SYS_fallocate -#define SYS_fallocate 47 -#endif - -#endif // OS_CPU_LINUX_RISCV_GC_X_XSYSCALL_LINUX_RISCV_HPP diff --git a/src/hotspot/os_cpu/linux_riscv/riscv_hwprobe.cpp b/src/hotspot/os_cpu/linux_riscv/riscv_hwprobe.cpp index df4a2e347cc..2020e2fdb24 100644 --- a/src/hotspot/os_cpu/linux_riscv/riscv_hwprobe.cpp +++ b/src/hotspot/os_cpu/linux_riscv/riscv_hwprobe.cpp @@ -74,7 +74,7 @@ #define RISCV_HWPROBE_EXT_ZFHMIN (1 << 28) #define RISCV_HWPROBE_EXT_ZIHINTNTL (1 << 29) #define RISCV_HWPROBE_EXT_ZVFH (1 << 30) -#define RISCV_HWPROBE_EXT_ZVFHMIN (1 << 31) +#define RISCV_HWPROBE_EXT_ZVFHMIN (1ULL << 31) #define RISCV_HWPROBE_EXT_ZFA (1ULL << 32) #define RISCV_HWPROBE_EXT_ZTSO (1ULL << 33) #define RISCV_HWPROBE_EXT_ZACAS (1ULL << 34) @@ -178,6 +178,9 @@ void RiscvHwprobe::add_features_from_query_result() { if (is_set(RISCV_HWPROBE_KEY_IMA_EXT_0, RISCV_HWPROBE_EXT_ZFH)) { VM_Version::ext_Zfh.enable_feature(); } + if (is_set(RISCV_HWPROBE_KEY_IMA_EXT_0, RISCV_HWPROBE_EXT_ZVFH)) { + VM_Version::ext_Zvfh.enable_feature(); + } if (is_valid(RISCV_HWPROBE_KEY_CPUPERF_0)) { VM_Version::unaligned_access.enable_feature( query[RISCV_HWPROBE_KEY_CPUPERF_0].value & RISCV_HWPROBE_MISALIGNED_MASK); diff --git a/src/hotspot/os_cpu/linux_x86/gc/x/xSyscall_linux_x86.hpp b/src/hotspot/os_cpu/linux_x86/gc/x/xSyscall_linux_x86.hpp deleted file mode 100644 index 2709b373b28..00000000000 --- a/src/hotspot/os_cpu/linux_x86/gc/x/xSyscall_linux_x86.hpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2019, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef OS_CPU_LINUX_X86_GC_X_XSYSCALL_LINUX_X86_HPP -#define OS_CPU_LINUX_X86_GC_X_XSYSCALL_LINUX_X86_HPP - -#include - -// -// Support for building on older Linux systems -// - -#ifndef SYS_memfd_create -#define SYS_memfd_create 319 -#endif -#ifndef SYS_fallocate -#define SYS_fallocate 285 -#endif - -#endif // OS_CPU_LINUX_X86_GC_X_XSYSCALL_LINUX_X86_HPP 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 0d5d07fc8a8..8fdcbe63c7e 100644 --- a/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp +++ b/src/hotspot/os_cpu/linux_x86/os_linux_x86.cpp @@ -544,6 +544,21 @@ void os::print_context(outputStream *st, const void *context) { st->print(", ERR=" INTPTR_FORMAT, (intptr_t)uc->uc_mcontext.gregs[REG_ERR]); st->cr(); st->print(" TRAPNO=" INTPTR_FORMAT, (intptr_t)uc->uc_mcontext.gregs[REG_TRAPNO]); + // Add XMM registers + MXCSR. Note that C2 uses XMM to spill GPR values including pointers. + st->cr(); + st->cr(); + // Sanity check: fpregs should point into the context. + if ((address)uc->uc_mcontext.fpregs < (address)uc || + pointer_delta(uc->uc_mcontext.fpregs, uc, 1) >= sizeof(ucontext_t)) { + st->print_cr("bad uc->uc_mcontext.fpregs: " INTPTR_FORMAT " (uc: " INTPTR_FORMAT ")", + p2i(uc->uc_mcontext.fpregs), p2i(uc)); + } else { + for (int i = 0; i < 16; ++i) { + const int64_t* xmm_val_addr = (int64_t*)&(uc->uc_mcontext.fpregs->_xmm[i]); + st->print_cr("XMM[%d]=" INTPTR_FORMAT " " INTPTR_FORMAT, i, xmm_val_addr[1], xmm_val_addr[0]); + } + st->print(" MXCSR=" UINT32_FORMAT_X_0, uc->uc_mcontext.fpregs->mxcsr); + } #else st->print( "EAX=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_EAX]); st->print(", EBX=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_EBX]); diff --git a/src/hotspot/os_cpu/windows_x86/os_windows_x86.cpp b/src/hotspot/os_cpu/windows_x86/os_windows_x86.cpp index 62022d780a2..de59a74cc24 100644 --- a/src/hotspot/os_cpu/windows_x86/os_windows_x86.cpp +++ b/src/hotspot/os_cpu/windows_x86/os_windows_x86.cpp @@ -437,6 +437,15 @@ void os::print_context(outputStream *st, const void *context) { st->cr(); st->print( "RIP=" INTPTR_FORMAT, uc->Rip); st->print(", EFLAGS=" INTPTR_FORMAT, uc->EFlags); + // Add XMM registers + MXCSR. Note that C2 uses XMM to spill GPR values including pointers. + st->cr(); + st->cr(); + for (int i = 0; i < 16; ++i) { + const uint64_t *xmm = ((const uint64_t*)&(uc->Xmm0)) + 2 * i; + st->print_cr("XMM[%d]=" INTPTR_FORMAT " " INTPTR_FORMAT, + i, xmm[1], xmm[0]); + } + st->print(" MXCSR=" UINT32_FORMAT_X_0, uc->MxCsr); #else st->print( "EAX=" INTPTR_FORMAT, uc->Eax); st->print(", EBX=" INTPTR_FORMAT, uc->Ebx); diff --git a/src/hotspot/share/adlc/formsopt.cpp b/src/hotspot/share/adlc/formsopt.cpp index e1e4ed96c2e..5de8974e2c0 100644 --- a/src/hotspot/share/adlc/formsopt.cpp +++ b/src/hotspot/share/adlc/formsopt.cpp @@ -171,9 +171,13 @@ int RegisterForm::RegMask_Size() { // on the stack (stack registers) up to some interesting limit. Methods // that need more parameters will NOT be compiled. On Intel, the limit // is something like 90+ parameters. - // Add a few (3 words == 96 bits) for incoming & outgoing arguments to calls. - // Round up to the next doubleword size. - return (words_for_regs + 3 + 1) & ~1; + // - Add a few (3 words == 96 bits) for incoming & outgoing arguments to + // calls. + // - Round up to the next doubleword size. + // - Add one more word to accommodate a reasonable number of stack locations + // in the register mask regardless of how much slack is created by rounding. + // This was found necessary after adding 16 new registers for APX. + return (words_for_regs + 3 + 1 + 1) & ~1; } void RegisterForm::dump() { // Debug printer diff --git a/src/hotspot/share/adlc/formssel.cpp b/src/hotspot/share/adlc/formssel.cpp index e7dd00fa390..dfa414ef564 100644 --- a/src/hotspot/share/adlc/formssel.cpp +++ b/src/hotspot/share/adlc/formssel.cpp @@ -3957,15 +3957,15 @@ void MatchNode::count_commutative_op(int& count) { "AndI","AndL", "MaxI","MinI","MaxF","MinF","MaxD","MinD", "MulI","MulL","MulF","MulD", - "OrI","OrL", - "XorI","XorL" + "OrI","OrL", "XorI","XorL", + "UMax","UMin" }; static const char *commut_vector_op_list[] = { "AddVB", "AddVS", "AddVI", "AddVL", "AddVF", "AddVD", "MulVB", "MulVS", "MulVI", "MulVL", "MulVF", "MulVD", "AndV", "OrV", "XorV", - "MaxV", "MinV" + "MaxV", "MinV", "UMax","UMin" }; if (_lChild && _rChild && (_lChild->_lChild || _rChild->_lChild)) { @@ -4339,7 +4339,7 @@ bool MatchRule::is_vector() const { "NegVF","NegVD","NegVI","NegVL", "SqrtVD","SqrtVF", "AndV" ,"XorV" ,"OrV", - "MaxV", "MinV", + "MaxV", "MinV", "UMinV", "UMaxV", "CompressV", "ExpandV", "CompressM", "CompressBitsV", "ExpandBitsV", "AddReductionVI", "AddReductionVL", "AddReductionVF", "AddReductionVD", @@ -4362,7 +4362,7 @@ bool MatchRule::is_vector() const { "VectorUCastB2X", "VectorUCastS2X", "VectorUCastI2X", "VectorMaskWrapper","VectorMaskCmp","VectorReinterpret","LoadVectorMasked","StoreVectorMasked", "FmaVD","FmaVF","PopCountVI","PopCountVL","PopulateIndex","VectorLongToMask", - "CountLeadingZerosV", "CountTrailingZerosV", "SignumVF", "SignumVD", + "CountLeadingZerosV", "CountTrailingZerosV", "SignumVF", "SignumVD", "SaturatingAddV", "SaturatingSubV", // Next are vector mask ops. "MaskAll", "AndVMask", "OrVMask", "XorVMask", "VectorMaskCast", "RoundVF", "RoundVD", diff --git a/src/hotspot/share/cds/archiveHeapLoader.cpp b/src/hotspot/share/cds/archiveHeapLoader.cpp index 0e7ef08064c..01831cf0f3e 100644 --- a/src/hotspot/share/cds/archiveHeapLoader.cpp +++ b/src/hotspot/share/cds/archiveHeapLoader.cpp @@ -142,15 +142,22 @@ class PatchCompressedEmbeddedPointersQuick: public BitMapClosure { class PatchUncompressedEmbeddedPointers: public BitMapClosure { oop* _start; + intptr_t _delta; public: - PatchUncompressedEmbeddedPointers(oop* start) : _start(start) {} + PatchUncompressedEmbeddedPointers(oop* start, intx runtime_offset) : + _start(start), + _delta(runtime_offset) {} + + PatchUncompressedEmbeddedPointers(oop* start) : + _start(start), + _delta(ArchiveHeapLoader::mapped_heap_delta()) {} bool do_bit(size_t offset) { oop* p = _start + offset; intptr_t dumptime_oop = (intptr_t)((void*)*p); assert(dumptime_oop != 0, "null oops should have been filtered out at dump time"); - intptr_t runtime_oop = dumptime_oop + ArchiveHeapLoader::mapped_heap_delta(); + intptr_t runtime_oop = dumptime_oop + _delta; RawAccess::oop_store(p, cast_to_oop(runtime_oop)); return true; } @@ -221,10 +228,6 @@ void ArchiveHeapLoader::init_loaded_heap_relocation(LoadedArchiveHeapRegion* loa } bool ArchiveHeapLoader::can_load() { - if (!UseCompressedOops) { - // Pointer relocation for uncompressed oops is unimplemented. - return false; - } return Universe::heap()->can_load_archived_objects(); } @@ -312,13 +315,18 @@ bool ArchiveHeapLoader::load_heap_region_impl(FileMapInfo* mapinfo, LoadedArchiv uintptr_t oopmap = bitmap_base + r->oopmap_offset(); BitMapView bm((BitMap::bm_word_t*)oopmap, r->oopmap_size_in_bits()); - PatchLoadedRegionPointers patcher((narrowOop*)load_address + FileMapInfo::current_info()->heap_oopmap_start_pos(), loaded_region); - bm.iterate(&patcher); + if (UseCompressedOops) { + PatchLoadedRegionPointers patcher((narrowOop*)load_address + FileMapInfo::current_info()->heap_oopmap_start_pos(), loaded_region); + bm.iterate(&patcher); + } else { + PatchUncompressedEmbeddedPointers patcher((oop*)load_address + FileMapInfo::current_info()->heap_oopmap_start_pos(), loaded_region->_runtime_offset); + bm.iterate(&patcher); + } return true; } bool ArchiveHeapLoader::load_heap_region(FileMapInfo* mapinfo) { - assert(UseCompressedOops, "loaded heap for !UseCompressedOops is unimplemented"); + assert(can_load(), "loaded heap for must be supported"); init_narrow_oop_decoding(mapinfo->narrow_oop_base(), mapinfo->narrow_oop_shift()); LoadedArchiveHeapRegion loaded_region; @@ -358,8 +366,12 @@ class VerifyLoadedHeapEmbeddedPointers: public BasicOopIterateClosure { } } virtual void do_oop(oop* p) { - // Uncompressed oops are not supported by loaded heaps. - Unimplemented(); + oop v = *p; + if(v != nullptr) { + uintptr_t u = cast_from_oop(v); + ArchiveHeapLoader::assert_in_loaded_heap(u); + guarantee(_table->contains(u), "must point to beginning of object in loaded archived region"); + } } }; diff --git a/src/hotspot/share/cds/archiveHeapLoader.hpp b/src/hotspot/share/cds/archiveHeapLoader.hpp index 700135a3816..8b9fab91aa3 100644 --- a/src/hotspot/share/cds/archiveHeapLoader.hpp +++ b/src/hotspot/share/cds/archiveHeapLoader.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -146,6 +146,7 @@ class ArchiveHeapLoader : AllStatic { inline static oop decode_from_archive_impl(narrowOop v) NOT_CDS_JAVA_HEAP_RETURN_(nullptr); class PatchLoadedRegionPointers; + class PatchUncompressedLoadedRegionPointers; public: diff --git a/src/hotspot/share/cds/cdsConfig.cpp b/src/hotspot/share/cds/cdsConfig.cpp index 5915424c4fe..9e8a46e105e 100644 --- a/src/hotspot/share/cds/cdsConfig.cpp +++ b/src/hotspot/share/cds/cdsConfig.cpp @@ -236,7 +236,9 @@ void CDSConfig::init_shared_archive_paths() { } void CDSConfig::check_internal_module_property(const char* key, const char* value) { - if (Arguments::is_internal_module_property(key) && !Arguments::is_module_path_property(key)) { + if (Arguments::is_internal_module_property(key) && + !Arguments::is_module_path_property(key) && + !Arguments::is_add_modules_property(key)) { stop_using_optimized_module_handling(); log_info(cds)("optimized module handling: disabled due to incompatible property: %s=%s", key, value); } diff --git a/src/hotspot/share/cds/filemap.cpp b/src/hotspot/share/cds/filemap.cpp index 715fce5f3fc..33a81a81da0 100644 --- a/src/hotspot/share/cds/filemap.cpp +++ b/src/hotspot/share/cds/filemap.cpp @@ -934,7 +934,7 @@ void FileMapInfo::extract_module_paths(const char* runtime_path, GrowableArraysort(ClassLoaderExt::compare_module_path_by_name); + module_paths->sort(ClassLoaderExt::compare_module_names); } bool FileMapInfo::check_module_paths() { @@ -2054,8 +2054,7 @@ void FileMapInfo::map_or_load_heap_region() { success = ArchiveHeapLoader::load_heap_region(this); } else { if (!UseCompressedOops && !ArchiveHeapLoader::can_map()) { - // TODO - remove implicit knowledge of G1 - log_info(cds)("Cannot use CDS heap data. UseG1GC is required for -XX:-UseCompressedOops"); + log_info(cds)("Cannot use CDS heap data. Selected GC not compatible -XX:-UseCompressedOops"); } else { log_info(cds)("Cannot use CDS heap data. UseEpsilonGC, UseG1GC, UseSerialGC, UseParallelGC, or UseShenandoahGC are required."); } @@ -2135,7 +2134,7 @@ address FileMapInfo::heap_region_requested_address() { assert(CDSConfig::is_using_archive(), "runtime only"); FileMapRegion* r = region_at(MetaspaceShared::hp); assert(is_aligned(r->mapping_offset(), sizeof(HeapWord)), "must be"); - assert(ArchiveHeapLoader::can_map(), "cannot be used by ArchiveHeapLoader::can_load() mode"); + assert(ArchiveHeapLoader::can_use(), "GC must support mapping or loading"); if (UseCompressedOops) { // We can avoid relocation if each region's offset from the runtime CompressedOops::base() // is the same as its offset from the CompressedOops::base() during dumptime. diff --git a/src/hotspot/share/cds/metaspaceShared.cpp b/src/hotspot/share/cds/metaspaceShared.cpp index efd7a906a46..2a43fd2dd4f 100644 --- a/src/hotspot/share/cds/metaspaceShared.cpp +++ b/src/hotspot/share/cds/metaspaceShared.cpp @@ -403,6 +403,7 @@ void MetaspaceShared::serialize(SerializeClosure* soc) { soc->do_tag(--tag); CDS_JAVA_HEAP_ONLY(Modules::serialize(soc);) + CDS_JAVA_HEAP_ONLY(Modules::serialize_addmods_names(soc);) CDS_JAVA_HEAP_ONLY(ClassLoaderDataShared::serialize(soc);) LambdaFormInvokers::serialize(soc); @@ -502,6 +503,8 @@ char* VM_PopulateDumpSharedSpace::dump_read_only_tables() { LambdaFormInvokers::dump_static_archive_invokers(); // Write module name into archive CDS_JAVA_HEAP_ONLY(Modules::dump_main_module_name();) + // Write module names from --add-modules into archive + CDS_JAVA_HEAP_ONLY(Modules::dump_addmods_names();) // Write the other data to the output array. DumpRegion* ro_region = ArchiveBuilder::current()->ro_region(); char* start = ro_region->top(); diff --git a/src/hotspot/share/ci/ciEnv.cpp b/src/hotspot/share/ci/ciEnv.cpp index 155ce032400..6bf8f44553d 100644 --- a/src/hotspot/share/ci/ciEnv.cpp +++ b/src/hotspot/share/ci/ciEnv.cpp @@ -1597,6 +1597,8 @@ void ciEnv::dump_replay_data_helper(outputStream* out) { NoSafepointVerifier no_safepoint; ResourceMark rm; + assert(this->task() != nullptr, "task must not be null"); + dump_replay_data_version(out); #if INCLUDE_JVMTI out->print_cr("JvmtiExport can_access_local_variables %d", _jvmti_can_access_local_variables); @@ -1617,9 +1619,7 @@ void ciEnv::dump_replay_data_helper(outputStream* out) { objects->at(i)->dump_replay_data(out); } - if (this->task() != nullptr) { - dump_compile_data(out); - } + dump_compile_data(out); out->flush(); } diff --git a/src/hotspot/share/classfile/classFileParser.cpp b/src/hotspot/share/classfile/classFileParser.cpp index dd7cecdd9c2..93dd0af65e7 100644 --- a/src/hotspot/share/classfile/classFileParser.cpp +++ b/src/hotspot/share/classfile/classFileParser.cpp @@ -926,6 +926,7 @@ class AnnotationCollector : public ResourceObj{ _method_ForceInline, _method_DontInline, _method_ChangesCurrentThread, + _method_JvmtiHideEvents, _method_JvmtiMountTransition, _method_InjectedProfile, _method_LambdaForm_Compiled, @@ -1830,6 +1831,11 @@ AnnotationCollector::annotation_index(const ClassLoaderData* loader_data, if (!privileged) break; // only allow in privileged code return _method_ChangesCurrentThread; } + case VM_SYMBOL_ENUM_NAME(jdk_internal_vm_annotation_JvmtiHideEvents_signature): { + if (_location != _in_method) break; // only allow for methods + if (!privileged) break; // only allow in privileged code + return _method_JvmtiHideEvents; + } case VM_SYMBOL_ENUM_NAME(jdk_internal_vm_annotation_JvmtiMountTransition_signature): { if (_location != _in_method) break; // only allow for methods if (!privileged) break; // only allow in privileged code @@ -1917,6 +1923,8 @@ void MethodAnnotationCollector::apply_to(const methodHandle& m) { m->set_dont_inline(); if (has_annotation(_method_ChangesCurrentThread)) m->set_changes_current_thread(); + if (has_annotation(_method_JvmtiHideEvents)) + m->set_jvmti_hide_events(); if (has_annotation(_method_JvmtiMountTransition)) m->set_jvmti_mount_transition(); if (has_annotation(_method_InjectedProfile)) diff --git a/src/hotspot/share/classfile/classLoaderExt.cpp b/src/hotspot/share/classfile/classLoaderExt.cpp index 16981669deb..b9e420899c2 100644 --- a/src/hotspot/share/classfile/classLoaderExt.cpp +++ b/src/hotspot/share/classfile/classLoaderExt.cpp @@ -90,7 +90,7 @@ void ClassLoaderExt::setup_app_search_path(JavaThread* current) { os::free(app_class_path); } -int ClassLoaderExt::compare_module_path_by_name(const char** p1, const char** p2) { +int ClassLoaderExt::compare_module_names(const char** p1, const char** p2) { return strcmp(*p1, *p2); } @@ -121,7 +121,7 @@ void ClassLoaderExt::process_module_table(JavaThread* current, ModuleEntryTable* // Sort the module paths before storing into CDS archive for simpler // checking at runtime. - module_paths->sort(compare_module_path_by_name); + module_paths->sort(compare_module_names); for (int i = 0; i < module_paths->length(); i++) { ClassLoader::setup_module_search_path(current, module_paths->at(i)); diff --git a/src/hotspot/share/classfile/classLoaderExt.hpp b/src/hotspot/share/classfile/classLoaderExt.hpp index c3c0b00d55e..1f1b38cd312 100644 --- a/src/hotspot/share/classfile/classLoaderExt.hpp +++ b/src/hotspot/share/classfile/classLoaderExt.hpp @@ -72,7 +72,7 @@ class ClassLoaderExt: public ClassLoader { // AllStatic static void setup_search_paths(JavaThread* current); static void setup_module_paths(JavaThread* current); static void extract_jar_files_from_path(const char* path, GrowableArray* module_paths); - static int compare_module_path_by_name(const char** p1, const char** p2); + static int compare_module_names(const char** p1, const char** p2); static char* read_manifest(JavaThread* current, ClassPathEntry* entry, jint *manifest_size) { // Remove all the new-line continuations (which wrap long lines at 72 characters, see diff --git a/src/hotspot/share/classfile/modules.cpp b/src/hotspot/share/classfile/modules.cpp index dee67ce1dde..94e407d045f 100644 --- a/src/hotspot/share/classfile/modules.cpp +++ b/src/hotspot/share/classfile/modules.cpp @@ -30,6 +30,7 @@ #include "classfile/classLoader.hpp" #include "classfile/classLoaderData.inline.hpp" #include "classfile/classLoaderDataShared.hpp" +#include "classfile/classLoaderExt.hpp" #include "classfile/javaAssertions.hpp" #include "classfile/javaClasses.hpp" #include "classfile/javaClasses.inline.hpp" @@ -560,6 +561,7 @@ void Modules::verify_archived_modules() { } char* Modules::_archived_main_module_name = nullptr; +char* Modules::_archived_addmods_names = nullptr; void Modules::dump_main_module_name() { const char* module_name = Arguments::get_property("jdk.module.main"); @@ -600,6 +602,100 @@ void Modules::serialize(SerializeClosure* soc) { } } +void Modules::dump_addmods_names() { + unsigned int count = Arguments::addmods_count(); + const char* addmods_names = get_addmods_names_as_sorted_string(); + if (addmods_names != nullptr) { + _archived_addmods_names = ArchiveBuilder::current()->ro_strdup(addmods_names); + } + ArchivePtrMarker::mark_pointer(&_archived_addmods_names); +} + +void Modules::serialize_addmods_names(SerializeClosure* soc) { + soc->do_ptr(&_archived_addmods_names); + if (soc->reading()) { + bool disable = false; + if (_archived_addmods_names[0] != '\0') { + if (Arguments::addmods_count() == 0) { + log_info(cds)("--add-modules module name(s) found in archive but not specified during runtime: %s", + _archived_addmods_names); + disable = true; + } else { + const char* addmods_names = get_addmods_names_as_sorted_string(); + if (strcmp((const char*)_archived_addmods_names, addmods_names) != 0) { + log_info(cds)("Mismatched --add-modules module name(s)."); + log_info(cds)(" dump time: %s runtime: %s", _archived_addmods_names, addmods_names); + disable = true; + } + } + } else { + if (Arguments::addmods_count() > 0) { + log_info(cds)("--add-modules module name(s) specified during runtime but not found in archive: %s", + get_addmods_names_as_sorted_string()); + disable = true; + } + } + if (disable) { + log_info(cds)("Disabling optimized module handling"); + CDSConfig::stop_using_optimized_module_handling(); + } + log_info(cds)("optimized module handling: %s", CDSConfig::is_using_optimized_module_handling() ? "enabled" : "disabled"); + log_info(cds)("full module graph: %s", CDSConfig::is_using_full_module_graph() ? "enabled" : "disabled"); + } +} + +const char* Modules::get_addmods_names_as_sorted_string() { + ResourceMark rm; + const int max_digits = 3; + const int extra_symbols_count = 2; // includes '.', '\0' + size_t prop_len = strlen("jdk.module.addmods") + max_digits + extra_symbols_count; + char* prop_name = resource_allocate_bytes(prop_len); + GrowableArray list; + for (unsigned int i = 0; i < Arguments::addmods_count(); i++) { + jio_snprintf(prop_name, prop_len, "jdk.module.addmods.%d", i); + const char* prop_value = Arguments::get_property(prop_name); + char* p = resource_allocate_bytes(strlen(prop_value) + 1); + strcpy(p, prop_value); + while (*p == ',') p++; // skip leading commas + while (*p) { + char* next = strchr(p, ','); + if (next == nullptr) { + // no more commas, p is the last element + list.append(p); + break; + } else { + *next = 0; + list.append(p); + p = next + 1; + } + } + } + + // Example: + // --add-modules=java.compiler --add-modules=java.base,java.base,, + // + // list[0] = "java.compiler" + // list[1] = "java.base" + // list[2] = "java.base" + // list[3] = "" + // list[4] = "" + list.sort(ClassLoaderExt::compare_module_names); + + const char* prefix = ""; + stringStream st; + const char* last_string = ""; // This also filters out all empty strings + for (int i = 0; i < list.length(); i++) { + const char* m = list.at(i); + if (strcmp(m, last_string) != 0) { // filter out duplicates + st.print("%s%s", prefix, m); + last_string = m; + prefix = "\n"; + } + } + + return (const char*)os::strdup(st.as_string()); // Example: "java.base,java.compiler" +} + void Modules::define_archived_modules(Handle h_platform_loader, Handle h_system_loader, TRAPS) { assert(CDSConfig::is_using_full_module_graph(), "must be"); diff --git a/src/hotspot/share/classfile/modules.hpp b/src/hotspot/share/classfile/modules.hpp index 3866f0d6f9b..3ef6f57a57b 100644 --- a/src/hotspot/share/classfile/modules.hpp +++ b/src/hotspot/share/classfile/modules.hpp @@ -61,9 +61,13 @@ class Modules : AllStatic { static void verify_archived_modules() NOT_CDS_JAVA_HEAP_RETURN; static void dump_main_module_name() NOT_CDS_JAVA_HEAP_RETURN; static void serialize(SerializeClosure* soc) NOT_CDS_JAVA_HEAP_RETURN; + static void dump_addmods_names() NOT_CDS_JAVA_HEAP_RETURN; + static void serialize_addmods_names(SerializeClosure* soc) NOT_CDS_JAVA_HEAP_RETURN; + static const char* get_addmods_names_as_sorted_string() NOT_CDS_JAVA_HEAP_RETURN_(nullptr); #if INCLUDE_CDS_JAVA_HEAP static char* _archived_main_module_name; + static char* _archived_addmods_names; #endif // Provides the java.lang.Module for the unnamed module defined diff --git a/src/hotspot/share/classfile/vmIntrinsics.hpp b/src/hotspot/share/classfile/vmIntrinsics.hpp index 54912a5ded7..68121c56c32 100644 --- a/src/hotspot/share/classfile/vmIntrinsics.hpp +++ b/src/hotspot/share/classfile/vmIntrinsics.hpp @@ -611,7 +611,6 @@ class methodHandle; do_intrinsic(_notifyJvmtiVThreadEnd, java_lang_VirtualThread, notifyJvmtiEnd_name, void_method_signature, F_RN) \ do_intrinsic(_notifyJvmtiVThreadMount, java_lang_VirtualThread, notifyJvmtiMount_name, bool_void_signature, F_RN) \ do_intrinsic(_notifyJvmtiVThreadUnmount, java_lang_VirtualThread, notifyJvmtiUnmount_name, bool_void_signature, F_RN) \ - do_intrinsic(_notifyJvmtiVThreadHideFrames, java_lang_VirtualThread, notifyJvmtiHideFrames_name, bool_void_signature, F_SN) \ do_intrinsic(_notifyJvmtiVThreadDisableSuspend, java_lang_VirtualThread, notifyJvmtiDisableSuspend_name, bool_void_signature, F_SN) \ \ /* support for UnsafeConstants */ \ diff --git a/src/hotspot/share/classfile/vmSymbols.hpp b/src/hotspot/share/classfile/vmSymbols.hpp index 58e1551e20c..d8018cd0c8a 100644 --- a/src/hotspot/share/classfile/vmSymbols.hpp +++ b/src/hotspot/share/classfile/vmSymbols.hpp @@ -306,6 +306,7 @@ class SerializeClosure; template(jdk_internal_vm_annotation_Stable_signature, "Ljdk/internal/vm/annotation/Stable;") \ \ template(jdk_internal_vm_annotation_ChangesCurrentThread_signature, "Ljdk/internal/vm/annotation/ChangesCurrentThread;") \ + template(jdk_internal_vm_annotation_JvmtiHideEvents_signature, "Ljdk/internal/vm/annotation/JvmtiHideEvents;") \ template(jdk_internal_vm_annotation_JvmtiMountTransition_signature, "Ljdk/internal/vm/annotation/JvmtiMountTransition;") \ \ /* Support for JSR 292 & invokedynamic (JDK 1.7 and above) */ \ @@ -397,7 +398,6 @@ class SerializeClosure; template(notifyJvmtiEnd_name, "notifyJvmtiEnd") \ template(notifyJvmtiMount_name, "notifyJvmtiMount") \ template(notifyJvmtiUnmount_name, "notifyJvmtiUnmount") \ - template(notifyJvmtiHideFrames_name, "notifyJvmtiHideFrames") \ template(notifyJvmtiDisableSuspend_name, "notifyJvmtiDisableSuspend") \ template(doYield_name, "doYield") \ template(enter_name, "enter") \ diff --git a/src/hotspot/share/gc/epsilon/epsilonHeap.hpp b/src/hotspot/share/gc/epsilon/epsilonHeap.hpp index f22d1c22ac8..b2b522c1435 100644 --- a/src/hotspot/share/gc/epsilon/epsilonHeap.hpp +++ b/src/hotspot/share/gc/epsilon/epsilonHeap.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2017, 2022, Red Hat, Inc. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -128,7 +128,7 @@ class EpsilonHeap : public CollectedHeap { bool is_in_reserved(const void* addr) const { return _reserved.contains(addr); } // Support for loading objects from CDS archive into the heap - bool can_load_archived_objects() const override { return UseCompressedOops; } + bool can_load_archived_objects() const override { return true; } HeapWord* allocate_loaded_archive_space(size_t size) override; void print_on(outputStream* st) const override; diff --git a/src/hotspot/share/gc/parallel/mutableSpace.cpp b/src/hotspot/share/gc/parallel/mutableSpace.cpp index d90121b0eaf..01d4e6bb04d 100644 --- a/src/hotspot/share/gc/parallel/mutableSpace.cpp +++ b/src/hotspot/share/gc/parallel/mutableSpace.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ #include "precompiled.hpp" #include "gc/parallel/mutableSpace.hpp" #include "gc/shared/pretouchTask.hpp" +#include "gc/shared/spaceDecorator.hpp" #include "memory/iterator.inline.hpp" #include "memory/universe.hpp" #include "oops/oop.inline.hpp" diff --git a/src/hotspot/share/gc/parallel/parallelScavengeHeap.hpp b/src/hotspot/share/gc/parallel/parallelScavengeHeap.hpp index a6601611c9b..22d1296507d 100644 --- a/src/hotspot/share/gc/parallel/parallelScavengeHeap.hpp +++ b/src/hotspot/share/gc/parallel/parallelScavengeHeap.hpp @@ -246,7 +246,7 @@ class ParallelScavengeHeap : public CollectedHeap { } // Support for loading objects from CDS archive into the heap - bool can_load_archived_objects() const override { return UseCompressedOops; } + bool can_load_archived_objects() const override { return true; } HeapWord* allocate_loaded_archive_space(size_t size) override; void complete_loaded_archive_space(MemRegion archive_space) override; diff --git a/src/hotspot/share/gc/parallel/psOldGen.cpp b/src/hotspot/share/gc/parallel/psOldGen.cpp index 2715ab90768..52ea4dc042c 100644 --- a/src/hotspot/share/gc/parallel/psOldGen.cpp +++ b/src/hotspot/share/gc/parallel/psOldGen.cpp @@ -31,6 +31,7 @@ #include "gc/parallel/psOldGen.hpp" #include "gc/shared/cardTableBarrierSet.hpp" #include "gc/shared/gcLocker.hpp" +#include "gc/shared/spaceDecorator.hpp" #include "logging/log.hpp" #include "oops/oop.inline.hpp" #include "runtime/java.hpp" diff --git a/src/hotspot/share/gc/parallel/psParallelCompact.cpp b/src/hotspot/share/gc/parallel/psParallelCompact.cpp index 1ab7b2af7ed..66ce20295f5 100644 --- a/src/hotspot/share/gc/parallel/psParallelCompact.cpp +++ b/src/hotspot/share/gc/parallel/psParallelCompact.cpp @@ -60,6 +60,7 @@ #include "gc/shared/referencePolicy.hpp" #include "gc/shared/referenceProcessor.hpp" #include "gc/shared/referenceProcessorPhaseTimes.hpp" +#include "gc/shared/spaceDecorator.hpp" #include "gc/shared/strongRootsScope.hpp" #include "gc/shared/taskTerminator.hpp" #include "gc/shared/weakProcessor.inline.hpp" diff --git a/src/hotspot/share/gc/parallel/psScavenge.cpp b/src/hotspot/share/gc/parallel/psScavenge.cpp index 7df2143ccbb..7701cea313b 100644 --- a/src/hotspot/share/gc/parallel/psScavenge.cpp +++ b/src/hotspot/share/gc/parallel/psScavenge.cpp @@ -51,6 +51,7 @@ #include "gc/shared/referenceProcessor.hpp" #include "gc/shared/referenceProcessorPhaseTimes.hpp" #include "gc/shared/scavengableNMethods.hpp" +#include "gc/shared/spaceDecorator.hpp" #include "gc/shared/strongRootsScope.hpp" #include "gc/shared/taskTerminator.hpp" #include "gc/shared/weakProcessor.inline.hpp" diff --git a/src/hotspot/share/gc/parallel/psYoungGen.cpp b/src/hotspot/share/gc/parallel/psYoungGen.cpp index 7b0d3b21507..dd9619e4546 100644 --- a/src/hotspot/share/gc/parallel/psYoungGen.cpp +++ b/src/hotspot/share/gc/parallel/psYoungGen.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,6 +29,7 @@ #include "gc/parallel/psYoungGen.hpp" #include "gc/shared/gcUtil.hpp" #include "gc/shared/genArguments.hpp" +#include "gc/shared/spaceDecorator.hpp" #include "logging/log.hpp" #include "oops/oop.inline.hpp" #include "runtime/java.hpp" diff --git a/src/hotspot/share/gc/serial/serialHeap.hpp b/src/hotspot/share/gc/serial/serialHeap.hpp index 750bb322b2a..d787d216e37 100644 --- a/src/hotspot/share/gc/serial/serialHeap.hpp +++ b/src/hotspot/share/gc/serial/serialHeap.hpp @@ -291,7 +291,7 @@ class SerialHeap : public CollectedHeap { void safepoint_synchronize_end() override; // Support for loading objects from CDS archive into the heap - bool can_load_archived_objects() const override { return UseCompressedOops; } + bool can_load_archived_objects() const override { return true; } HeapWord* allocate_loaded_archive_space(size_t size) override; void complete_loaded_archive_space(MemRegion archive_space) override; diff --git a/src/hotspot/share/gc/shared/barrierSetConfig.hpp b/src/hotspot/share/gc/shared/barrierSetConfig.hpp index 76681aa8986..368312af06b 100644 --- a/src/hotspot/share/gc/shared/barrierSetConfig.hpp +++ b/src/hotspot/share/gc/shared/barrierSetConfig.hpp @@ -33,7 +33,6 @@ EPSILONGC_ONLY(f(EpsilonBarrierSet)) \ G1GC_ONLY(f(G1BarrierSet)) \ SHENANDOAHGC_ONLY(f(ShenandoahBarrierSet)) \ - ZGC_ONLY(f(XBarrierSet)) \ ZGC_ONLY(f(ZBarrierSet)) #define FOR_EACH_ABSTRACT_BARRIER_SET_DO(f) \ diff --git a/src/hotspot/share/gc/shared/barrierSetConfig.inline.hpp b/src/hotspot/share/gc/shared/barrierSetConfig.inline.hpp index 9523428821b..001b5b00372 100644 --- a/src/hotspot/share/gc/shared/barrierSetConfig.inline.hpp +++ b/src/hotspot/share/gc/shared/barrierSetConfig.inline.hpp @@ -40,7 +40,6 @@ #include "gc/shenandoah/shenandoahBarrierSet.inline.hpp" #endif #if INCLUDE_ZGC -#include "gc/x/xBarrierSet.inline.hpp" #include "gc/z/zBarrierSet.inline.hpp" #endif diff --git a/src/hotspot/share/gc/shared/gcConfig.cpp b/src/hotspot/share/gc/shared/gcConfig.cpp index 506b368d6cf..8eb265b54d9 100644 --- a/src/hotspot/share/gc/shared/gcConfig.cpp +++ b/src/hotspot/share/gc/shared/gcConfig.cpp @@ -44,7 +44,7 @@ #include "gc/shenandoah/shenandoahArguments.hpp" #endif #if INCLUDE_ZGC -#include "gc/z/shared/zSharedArguments.hpp" +#include "gc/z/zArguments.hpp" #endif struct IncludedGC { @@ -62,7 +62,7 @@ struct IncludedGC { PARALLELGC_ONLY(static ParallelArguments parallelArguments;) SERIALGC_ONLY(static SerialArguments serialArguments;) SHENANDOAHGC_ONLY(static ShenandoahArguments shenandoahArguments;) - ZGC_ONLY(static ZSharedArguments zArguments;) + ZGC_ONLY(static ZArguments zArguments;) // Table of included GCs, for translating between command // line flag, CollectedHeap::Name and GCArguments instance. diff --git a/src/hotspot/share/gc/shared/gcConfiguration.cpp b/src/hotspot/share/gc/shared/gcConfiguration.cpp index 2e8d3eb2a51..824e119e696 100644 --- a/src/hotspot/share/gc/shared/gcConfiguration.cpp +++ b/src/hotspot/share/gc/shared/gcConfiguration.cpp @@ -43,11 +43,7 @@ GCName GCConfiguration::young_collector() const { } if (UseZGC) { - if (ZGenerational) { - return ZMinor; - } else { - return NA; - } + return ZMinor; } if (UseShenandoahGC) { @@ -66,12 +62,8 @@ GCName GCConfiguration::old_collector() const { return ParallelOld; } - if (UseZGC) { - if (ZGenerational) { - return ZMajor; - } else { - return Z; - } +if (UseZGC) { + return ZMajor; } if (UseShenandoahGC) { diff --git a/src/hotspot/share/gc/shared/gcName.hpp b/src/hotspot/share/gc/shared/gcName.hpp index 3d2dd350ac1..b9b87c231ca 100644 --- a/src/hotspot/share/gc/shared/gcName.hpp +++ b/src/hotspot/share/gc/shared/gcName.hpp @@ -37,7 +37,6 @@ enum GCName { G1Full, ZMinor, ZMajor, - Z, // Support for the legacy, single-gen mode Shenandoah, NA, GCNameEndSentinel @@ -56,7 +55,6 @@ class GCNameHelper { case G1Full: return "G1Full"; case ZMinor: return "ZGC Minor"; case ZMajor: return "ZGC Major"; - case Z: return "Z"; case Shenandoah: return "Shenandoah"; case NA: return "N/A"; default: ShouldNotReachHere(); return nullptr; diff --git a/src/hotspot/share/gc/shared/gc_globals.hpp b/src/hotspot/share/gc/shared/gc_globals.hpp index 34bc638c9ba..9086c25ee48 100644 --- a/src/hotspot/share/gc/shared/gc_globals.hpp +++ b/src/hotspot/share/gc/shared/gc_globals.hpp @@ -43,7 +43,7 @@ #include "gc/shenandoah/shenandoah_globals.hpp" #endif #if INCLUDE_ZGC -#include "gc/z/shared/z_shared_globals.hpp" +#include "gc/z/z_globals.hpp" #endif #define GC_FLAGS(develop, \ @@ -93,7 +93,7 @@ range, \ constraint)) \ \ - ZGC_ONLY(GC_Z_SHARED_FLAGS( \ + ZGC_ONLY(GC_Z_FLAGS( \ develop, \ develop_pd, \ product, \ @@ -118,9 +118,6 @@ product(bool, UseZGC, false, \ "Use the Z garbage collector") \ \ - product(bool, ZGenerational, true, \ - "Use the generational version of ZGC") \ - \ product(bool, UseShenandoahGC, false, \ "Use the Shenandoah garbage collector") \ \ diff --git a/src/hotspot/share/gc/shared/vmStructs_gc.hpp b/src/hotspot/share/gc/shared/vmStructs_gc.hpp index c4acb0b1ed6..bba9c9e099f 100644 --- a/src/hotspot/share/gc/shared/vmStructs_gc.hpp +++ b/src/hotspot/share/gc/shared/vmStructs_gc.hpp @@ -46,7 +46,7 @@ #include "gc/shenandoah/vmStructs_shenandoah.hpp" #endif #if INCLUDE_ZGC -#include "gc/z/shared/vmStructs_z_shared.hpp" +#include "gc/z/vmStructs_z.hpp" #endif #define VM_STRUCTS_GC(nonstatic_field, \ @@ -69,7 +69,7 @@ SHENANDOAHGC_ONLY(VM_STRUCTS_SHENANDOAH(nonstatic_field, \ volatile_nonstatic_field, \ static_field)) \ - ZGC_ONLY(VM_STRUCTS_Z_SHARED(nonstatic_field, \ + ZGC_ONLY(VM_STRUCTS_Z(nonstatic_field, \ volatile_nonstatic_field, \ static_field)) \ \ @@ -91,6 +91,7 @@ nonstatic_field(CardTableBarrierSet, _defer_initial_card_mark, bool) \ nonstatic_field(CardTableBarrierSet, _card_table, CardTable*) \ \ + static_field(CollectedHeap, _lab_alignment_reserve, size_t) \ nonstatic_field(CollectedHeap, _reserved, MemRegion) \ nonstatic_field(CollectedHeap, _is_stw_gc_active, bool) \ nonstatic_field(CollectedHeap, _total_collections, unsigned int) \ @@ -120,7 +121,7 @@ SHENANDOAHGC_ONLY(VM_TYPES_SHENANDOAH(declare_type, \ declare_toplevel_type, \ declare_integer_type)) \ - ZGC_ONLY(VM_TYPES_Z_SHARED(declare_type, \ + ZGC_ONLY(VM_TYPES_Z(declare_type, \ declare_toplevel_type, \ declare_integer_type)) \ \ @@ -174,7 +175,7 @@ declare_constant_with_value)) \ SHENANDOAHGC_ONLY(VM_INT_CONSTANTS_SHENANDOAH(declare_constant, \ declare_constant_with_value)) \ - ZGC_ONLY(VM_INT_CONSTANTS_Z_SHARED(declare_constant, \ + ZGC_ONLY(VM_INT_CONSTANTS_Z(declare_constant, \ declare_constant_with_value)) \ \ /********************************************/ \ @@ -198,6 +199,6 @@ declare_constant(CollectedHeap::G1) \ #define VM_LONG_CONSTANTS_GC(declare_constant) \ - ZGC_ONLY(VM_LONG_CONSTANTS_Z_SHARED(declare_constant)) + ZGC_ONLY(VM_LONG_CONSTANTS_Z(declare_constant)) #endif // SHARE_GC_SHARED_VMSTRUCTS_GC_HPP diff --git a/src/hotspot/share/gc/shenandoah/shenandoahClosures.hpp b/src/hotspot/share/gc/shenandoah/shenandoahClosures.hpp index 2291015edc6..58527e808e4 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahClosures.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahClosures.hpp @@ -25,18 +25,78 @@ #define SHARE_GC_SHENANDOAH_SHENANDOAHCLOSURES_HPP #include "code/nmethod.hpp" +#include "gc/shared/stringdedup/stringDedup.hpp" +#include "gc/shenandoah/shenandoahGenerationType.hpp" +#include "gc/shenandoah/shenandoahTaskqueue.hpp" #include "memory/iterator.hpp" -#include "oops/accessDecorators.hpp" -#include "runtime/handshake.hpp" +#include "runtime/javaThread.hpp" class BarrierSetNMethod; class ShenandoahBarrierSet; class ShenandoahHeap; class ShenandoahMarkingContext; -class ShenandoahHeapRegionSet; -class Thread; +class ShenandoahReferenceProcessor; -class ShenandoahForwardedIsAliveClosure: public BoolObjectClosure { +// +// ========= Super +// + +class ShenandoahSuperClosure : public MetadataVisitingOopIterateClosure { +protected: + ShenandoahHeap* const _heap; + +public: + inline ShenandoahSuperClosure(); + inline ShenandoahSuperClosure(ShenandoahReferenceProcessor* rp); + inline void do_nmethod(nmethod* nm); +}; + +// +// ========= Marking +// + +class ShenandoahMarkRefsSuperClosure : public ShenandoahSuperClosure { +private: + ShenandoahObjToScanQueue* _queue; + ShenandoahMarkingContext* const _mark_context; + bool _weak; + +protected: + template + void work(T *p); + +public: + inline ShenandoahMarkRefsSuperClosure(ShenandoahObjToScanQueue* q, ShenandoahReferenceProcessor* rp); + + bool is_weak() const { + return _weak; + } + + void set_weak(bool weak) { + _weak = weak; + } + + virtual void do_nmethod(nmethod* nm) { + assert(!is_weak(), "Can't handle weak marking of nmethods"); + ShenandoahSuperClosure::do_nmethod(nm); + } +}; + +template +class ShenandoahMarkRefsClosure : public ShenandoahMarkRefsSuperClosure { +private: + template + inline void do_oop_work(T* p) { work(p); } + +public: + ShenandoahMarkRefsClosure(ShenandoahObjToScanQueue* q, ShenandoahReferenceProcessor* rp) : + ShenandoahMarkRefsSuperClosure(q, rp) {}; + + virtual void do_oop(narrowOop* p) { do_oop_work(p); } + virtual void do_oop(oop* p) { do_oop_work(p); } +}; + +class ShenandoahForwardedIsAliveClosure : public BoolObjectClosure { private: ShenandoahMarkingContext* const _mark_context; public: @@ -44,7 +104,7 @@ class ShenandoahForwardedIsAliveClosure: public BoolObjectClosure { inline bool do_object_b(oop obj); }; -class ShenandoahIsAliveClosure: public BoolObjectClosure { +class ShenandoahIsAliveClosure : public BoolObjectClosure { private: ShenandoahMarkingContext* const _mark_context; public: @@ -63,27 +123,29 @@ class ShenandoahIsAliveSelector : public StackObj { class ShenandoahKeepAliveClosure : public OopClosure { private: ShenandoahBarrierSet* const _bs; -public: - inline ShenandoahKeepAliveClosure(); - inline void do_oop(oop* p); - inline void do_oop(narrowOop* p); -private: template void do_oop_work(T* p); -}; -class ShenandoahOopClosureBase : public MetadataVisitingOopIterateClosure { public: - inline void do_nmethod(nmethod* nm); + inline ShenandoahKeepAliveClosure(); + inline void do_oop(oop* p) { do_oop_work(p); } + inline void do_oop(narrowOop* p) { do_oop_work(p); } }; -template -class ShenandoahEvacuateUpdateRootClosureBase : public ShenandoahOopClosureBase { + +// +// ========= Evacuating + Roots +// + +template +class ShenandoahEvacuateUpdateRootClosureBase : public ShenandoahSuperClosure { protected: - ShenandoahHeap* const _heap; Thread* const _thread; public: - inline ShenandoahEvacuateUpdateRootClosureBase(); + inline ShenandoahEvacuateUpdateRootClosureBase() : + ShenandoahSuperClosure(), + _thread(STABLE_THREAD ? Thread::current() : nullptr) {} + inline void do_oop(oop* p); inline void do_oop(narrowOop* p); protected: @@ -91,10 +153,11 @@ class ShenandoahEvacuateUpdateRootClosureBase : public ShenandoahOopClosureBase inline void do_oop_work(T* p); }; -using ShenandoahEvacuateUpdateMetadataClosure = ShenandoahEvacuateUpdateRootClosureBase; -using ShenandoahEvacuateUpdateRootsClosure = ShenandoahEvacuateUpdateRootClosureBase; +using ShenandoahEvacuateUpdateMetadataClosure = ShenandoahEvacuateUpdateRootClosureBase; +using ShenandoahEvacuateUpdateRootsClosure = ShenandoahEvacuateUpdateRootClosureBase; using ShenandoahContextEvacuateUpdateRootsClosure = ShenandoahEvacuateUpdateRootClosureBase; + template class ShenandoahCleanUpdateWeakOopsClosure : public OopClosure { private: @@ -107,7 +170,7 @@ class ShenandoahCleanUpdateWeakOopsClosure : public OopClosure { inline void do_oop(narrowOop* p); }; -class ShenandoahNMethodAndDisarmClosure: public NMethodToOopClosure { +class ShenandoahNMethodAndDisarmClosure : public NMethodToOopClosure { private: BarrierSetNMethod* const _bs; @@ -116,6 +179,51 @@ class ShenandoahNMethodAndDisarmClosure: public NMethodToOopClosure { inline void do_nmethod(nmethod* nm); }; + +// +// ========= Update References +// + +template +class ShenandoahMarkUpdateRefsClosure : public ShenandoahMarkRefsSuperClosure { +private: + template + inline void work(T* p); + +public: + ShenandoahMarkUpdateRefsClosure(ShenandoahObjToScanQueue* q, ShenandoahReferenceProcessor* rp); + + virtual void do_oop(narrowOop* p) { work(p); } + virtual void do_oop(oop* p) { work(p); } +}; + +class ShenandoahUpdateRefsSuperClosure : public ShenandoahSuperClosure {}; + +class ShenandoahNonConcUpdateRefsClosure : public ShenandoahUpdateRefsSuperClosure { +private: + template + inline void work(T* p); + +public: + virtual void do_oop(narrowOop* p) { work(p); } + virtual void do_oop(oop* p) { work(p); } +}; + +class ShenandoahConcUpdateRefsClosure : public ShenandoahUpdateRefsSuperClosure { +private: + template + inline void work(T* p); + +public: + virtual void do_oop(narrowOop* p) { work(p); } + virtual void do_oop(oop* p) { work(p); } +}; + + +// +// ========= Utilities +// + #ifdef ASSERT class ShenandoahAssertNotForwardedClosure : public OopClosure { private: diff --git a/src/hotspot/share/gc/shenandoah/shenandoahClosures.inline.hpp b/src/hotspot/share/gc/shenandoah/shenandoahClosures.inline.hpp index 53921be8d20..edfb62b4046 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahClosures.inline.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahClosures.inline.hpp @@ -33,15 +33,46 @@ #include "gc/shenandoah/shenandoahMarkingContext.inline.hpp" #include "gc/shenandoah/shenandoahHeap.inline.hpp" #include "gc/shenandoah/shenandoahNMethod.inline.hpp" +#include "gc/shenandoah/shenandoahMark.inline.hpp" +#include "gc/shenandoah/shenandoahReferenceProcessor.hpp" +#include "gc/shenandoah/shenandoahTaskqueue.inline.hpp" #include "memory/iterator.inline.hpp" #include "oops/compressedOops.inline.hpp" #include "runtime/atomic.hpp" #include "runtime/javaThread.hpp" -ShenandoahForwardedIsAliveClosure::ShenandoahForwardedIsAliveClosure() : - _mark_context(ShenandoahHeap::heap()->marking_context()) { +// +// ========= Super +// + +ShenandoahSuperClosure::ShenandoahSuperClosure() : + MetadataVisitingOopIterateClosure(), _heap(ShenandoahHeap::heap()) {} + +ShenandoahSuperClosure::ShenandoahSuperClosure(ShenandoahReferenceProcessor* rp) : + MetadataVisitingOopIterateClosure(rp), _heap(ShenandoahHeap::heap()) {} + +void ShenandoahSuperClosure::do_nmethod(nmethod* nm) { + nm->run_nmethod_entry_barrier(); +} + +// +// ========= Marking +// + +ShenandoahMarkRefsSuperClosure::ShenandoahMarkRefsSuperClosure(ShenandoahObjToScanQueue* q, ShenandoahReferenceProcessor* rp) : + ShenandoahSuperClosure(rp), + _queue(q), + _mark_context(ShenandoahHeap::heap()->marking_context()), + _weak(false) {} + +template +inline void ShenandoahMarkRefsSuperClosure::work(T* p) { + ShenandoahMark::mark_through_ref(p, _queue, _mark_context, _weak); } +ShenandoahForwardedIsAliveClosure::ShenandoahForwardedIsAliveClosure() : + _mark_context(ShenandoahHeap::heap()->marking_context()) {} + bool ShenandoahForwardedIsAliveClosure::do_object_b(oop obj) { if (CompressedOops::is_null(obj)) { return false; @@ -52,8 +83,7 @@ bool ShenandoahForwardedIsAliveClosure::do_object_b(oop obj) { } ShenandoahIsAliveClosure::ShenandoahIsAliveClosure() : - _mark_context(ShenandoahHeap::heap()->marking_context()) { -} + _mark_context(ShenandoahHeap::heap()->marking_context()) {} bool ShenandoahIsAliveClosure::do_object_b(oop obj) { if (CompressedOops::is_null(obj)) { @@ -69,21 +99,8 @@ BoolObjectClosure* ShenandoahIsAliveSelector::is_alive_closure() { reinterpret_cast(&_alive_cl); } -void ShenandoahOopClosureBase::do_nmethod(nmethod* nm) { - nm->run_nmethod_entry_barrier(); -} - ShenandoahKeepAliveClosure::ShenandoahKeepAliveClosure() : - _bs(ShenandoahBarrierSet::barrier_set()) { -} - -void ShenandoahKeepAliveClosure::do_oop(oop* p) { - do_oop_work(p); -} - -void ShenandoahKeepAliveClosure::do_oop(narrowOop* p) { - do_oop_work(p); -} + _bs(ShenandoahBarrierSet::barrier_set()) {} template void ShenandoahKeepAliveClosure::do_oop_work(T* p) { @@ -97,14 +114,14 @@ void ShenandoahKeepAliveClosure::do_oop_work(T* p) { } } -template -ShenandoahEvacuateUpdateRootClosureBase::ShenandoahEvacuateUpdateRootClosureBase() : - _heap(ShenandoahHeap::heap()), _thread(stable_thread ? Thread::current() : nullptr) { -} -template -void ShenandoahEvacuateUpdateRootClosureBase::do_oop(oop* p) { - if (concurrent) { +// +// ========= Evacuating + Roots +// + +template +void ShenandoahEvacuateUpdateRootClosureBase::do_oop(oop* p) { + if (CONCURRENT) { ShenandoahEvacOOMScope scope; do_oop_work(p); } else { @@ -112,9 +129,9 @@ void ShenandoahEvacuateUpdateRootClosureBase::do_oop( } } -template -void ShenandoahEvacuateUpdateRootClosureBase::do_oop(narrowOop* p) { - if (concurrent) { +template +void ShenandoahEvacuateUpdateRootClosureBase::do_oop(narrowOop* p) { + if (CONCURRENT) { ShenandoahEvacOOMScope scope; do_oop_work(p); } else { @@ -122,9 +139,9 @@ void ShenandoahEvacuateUpdateRootClosureBase::do_oop( } } -template +template template -void ShenandoahEvacuateUpdateRootClosureBase::do_oop_work(T* p) { +void ShenandoahEvacuateUpdateRootClosureBase::do_oop_work(T* p) { assert(_heap->is_concurrent_weak_root_in_progress() || _heap->is_concurrent_strong_root_in_progress(), "Only do this in root processing phase"); @@ -137,12 +154,12 @@ void ShenandoahEvacuateUpdateRootClosureBase::do_oop_work shenandoah_assert_marked(p, obj); oop resolved = ShenandoahBarrierSet::resolve_forwarded_not_null(obj); if (resolved == obj) { - Thread* thr = stable_thread ? _thread : Thread::current(); + Thread* thr = STABLE_THREAD ? _thread : Thread::current(); assert(thr == Thread::current(), "Wrong thread"); resolved = _heap->evacuate_object(obj, thr); } - if (atomic) { + if (CONCURRENT) { ShenandoahHeap::atomic_update_oop(resolved, p, o); } else { RawAccess::oop_store(p, resolved); @@ -192,6 +209,42 @@ void ShenandoahNMethodAndDisarmClosure::do_nmethod(nmethod* nm) { _bs->disarm(nm); } + +// +// ========= Update References +// + +template +ShenandoahMarkUpdateRefsClosure::ShenandoahMarkUpdateRefsClosure(ShenandoahObjToScanQueue* q, ShenandoahReferenceProcessor* rp) : + ShenandoahMarkRefsSuperClosure(q, rp) { + assert(_heap->is_stw_gc_in_progress(), "Can only be used for STW GC"); +} + +template +template +inline void ShenandoahMarkUpdateRefsClosure::work(T* p) { + // Update the location + _heap->non_conc_update_with_forwarded(p); + + // ...then do the usual thing + ShenandoahMarkRefsSuperClosure::work(p); +} + +template +inline void ShenandoahNonConcUpdateRefsClosure::work(T* p) { + _heap->non_conc_update_with_forwarded(p); +} + +template +inline void ShenandoahConcUpdateRefsClosure::work(T* p) { + _heap->conc_update_with_forwarded(p); +} + + +// +// ========= Utilities +// + #ifdef ASSERT template void ShenandoahAssertNotForwardedClosure::do_oop_work(T* p) { diff --git a/src/hotspot/share/gc/shenandoah/shenandoahConcurrentGC.cpp b/src/hotspot/share/gc/shenandoah/shenandoahConcurrentGC.cpp index 6da2d2e83f7..d801dda372e 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahConcurrentGC.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahConcurrentGC.cpp @@ -29,13 +29,13 @@ #include "gc/shared/collectorCounters.hpp" #include "gc/shared/continuationGCSupport.inline.hpp" #include "gc/shenandoah/shenandoahBreakpoint.hpp" +#include "gc/shenandoah/shenandoahClosures.inline.hpp" #include "gc/shenandoah/shenandoahCollectorPolicy.hpp" #include "gc/shenandoah/shenandoahConcurrentGC.hpp" #include "gc/shenandoah/shenandoahFreeSet.hpp" #include "gc/shenandoah/shenandoahLock.hpp" #include "gc/shenandoah/shenandoahMark.inline.hpp" #include "gc/shenandoah/shenandoahMonitoringSupport.hpp" -#include "gc/shenandoah/shenandoahOopClosures.inline.hpp" #include "gc/shenandoah/shenandoahPhaseTimings.hpp" #include "gc/shenandoah/shenandoahReferenceProcessor.hpp" #include "gc/shenandoah/shenandoahRootProcessor.inline.hpp" diff --git a/src/hotspot/share/gc/shenandoah/shenandoahConcurrentMark.cpp b/src/hotspot/share/gc/shenandoah/shenandoahConcurrentMark.cpp index 75cdb99e177..0e2ef4144ad 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahConcurrentMark.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahConcurrentMark.cpp @@ -34,7 +34,6 @@ #include "gc/shenandoah/shenandoahMark.inline.hpp" #include "gc/shenandoah/shenandoahReferenceProcessor.hpp" #include "gc/shenandoah/shenandoahRootProcessor.inline.hpp" -#include "gc/shenandoah/shenandoahOopClosures.inline.hpp" #include "gc/shenandoah/shenandoahPhaseTimings.hpp" #include "gc/shenandoah/shenandoahStringDedup.hpp" #include "gc/shenandoah/shenandoahTaskqueue.inline.hpp" diff --git a/src/hotspot/share/gc/shenandoah/shenandoahDegeneratedGC.cpp b/src/hotspot/share/gc/shenandoah/shenandoahDegeneratedGC.cpp index 81d07a414cd..2249c38455f 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahDegeneratedGC.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahDegeneratedGC.cpp @@ -32,7 +32,6 @@ #include "gc/shenandoah/shenandoahHeap.inline.hpp" #include "gc/shenandoah/shenandoahMetrics.hpp" #include "gc/shenandoah/shenandoahMonitoringSupport.hpp" -#include "gc/shenandoah/shenandoahOopClosures.inline.hpp" #include "gc/shenandoah/shenandoahRootProcessor.inline.hpp" #include "gc/shenandoah/shenandoahSTWMark.hpp" #include "gc/shenandoah/shenandoahUtils.hpp" diff --git a/src/hotspot/share/gc/shenandoah/shenandoahFullGC.cpp b/src/hotspot/share/gc/shenandoah/shenandoahFullGC.cpp index de7d81d0f43..c2d94353d54 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahFullGC.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahFullGC.cpp @@ -31,6 +31,7 @@ #include "gc/shared/tlab_globals.hpp" #include "gc/shared/workerThread.hpp" #include "gc/shenandoah/heuristics/shenandoahHeuristics.hpp" +#include "gc/shenandoah/shenandoahClosures.inline.hpp" #include "gc/shenandoah/shenandoahCollectorPolicy.hpp" #include "gc/shenandoah/shenandoahConcurrentGC.hpp" #include "gc/shenandoah/shenandoahCollectionSet.hpp" @@ -44,7 +45,6 @@ #include "gc/shenandoah/shenandoahHeapRegion.inline.hpp" #include "gc/shenandoah/shenandoahMarkingContext.inline.hpp" #include "gc/shenandoah/shenandoahMetrics.hpp" -#include "gc/shenandoah/shenandoahOopClosures.inline.hpp" #include "gc/shenandoah/shenandoahReferenceProcessor.hpp" #include "gc/shenandoah/shenandoahRootProcessor.inline.hpp" #include "gc/shenandoah/shenandoahSTWMark.hpp" diff --git a/src/hotspot/share/gc/shenandoah/shenandoahGC.cpp b/src/hotspot/share/gc/shenandoah/shenandoahGC.cpp index 6195f445f7b..719abde4b16 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahGC.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahGC.cpp @@ -29,7 +29,6 @@ #include "gc/shenandoah/shenandoahClosures.inline.hpp" #include "gc/shenandoah/shenandoahGC.hpp" #include "gc/shenandoah/shenandoahHeap.hpp" -#include "gc/shenandoah/shenandoahOopClosures.inline.hpp" #include "gc/shenandoah/shenandoahPhaseTimings.hpp" #include "gc/shenandoah/shenandoahRootProcessor.inline.hpp" #include "gc/shenandoah/shenandoahUtils.hpp" diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp b/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp index e94f43b8886..07914947ead 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp @@ -53,7 +53,6 @@ #include "gc/shenandoah/shenandoahMemoryPool.hpp" #include "gc/shenandoah/shenandoahMetrics.hpp" #include "gc/shenandoah/shenandoahMonitoringSupport.hpp" -#include "gc/shenandoah/shenandoahOopClosures.inline.hpp" #include "gc/shenandoah/shenandoahPacer.inline.hpp" #include "gc/shenandoah/shenandoahPadding.hpp" #include "gc/shenandoah/shenandoahParallelCleaning.inline.hpp" diff --git a/src/hotspot/share/gc/shenandoah/shenandoahHeap.hpp b/src/hotspot/share/gc/shenandoah/shenandoahHeap.hpp index a3e0b9397da..7e616f925d0 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahHeap.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahHeap.hpp @@ -543,7 +543,7 @@ class ShenandoahHeap : public CollectedHeap, public ShenandoahSpaceInfo { // ---------- CDS archive support - bool can_load_archived_objects() const override { return UseCompressedOops; } + bool can_load_archived_objects() const override { return true; } HeapWord* allocate_loaded_archive_space(size_t size) override; void complete_loaded_archive_space(MemRegion archive_space) override; diff --git a/src/hotspot/share/gc/shenandoah/shenandoahMark.cpp b/src/hotspot/share/gc/shenandoah/shenandoahMark.cpp index 4c45f4a7659..775b84a8966 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahMark.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahMark.cpp @@ -28,19 +28,11 @@ #include "gc/shenandoah/shenandoahBarrierSet.hpp" #include "gc/shenandoah/shenandoahClosures.inline.hpp" #include "gc/shenandoah/shenandoahMark.inline.hpp" -#include "gc/shenandoah/shenandoahOopClosures.inline.hpp" #include "gc/shenandoah/shenandoahReferenceProcessor.hpp" #include "gc/shenandoah/shenandoahTaskqueue.inline.hpp" #include "gc/shenandoah/shenandoahUtils.hpp" #include "gc/shenandoah/shenandoahVerifier.hpp" -ShenandoahMarkRefsSuperClosure::ShenandoahMarkRefsSuperClosure(ShenandoahObjToScanQueue* q, ShenandoahReferenceProcessor* rp) : - MetadataVisitingOopIterateClosure(rp), - _queue(q), - _mark_context(ShenandoahHeap::heap()->marking_context()), - _weak(false) -{ } - ShenandoahMark::ShenandoahMark() : _task_queues(ShenandoahHeap::heap()->marking_context()->task_queues()) { } diff --git a/src/hotspot/share/gc/shenandoah/shenandoahMark.inline.hpp b/src/hotspot/share/gc/shenandoah/shenandoahMark.inline.hpp index 99995c469eb..2eca17bde27 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahMark.inline.hpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahMark.inline.hpp @@ -30,9 +30,9 @@ #include "gc/shared/continuationGCSupport.inline.hpp" #include "gc/shenandoah/shenandoahAsserts.hpp" #include "gc/shenandoah/shenandoahBarrierSet.inline.hpp" +#include "gc/shenandoah/shenandoahClosures.inline.hpp" #include "gc/shenandoah/shenandoahHeap.inline.hpp" #include "gc/shenandoah/shenandoahMarkingContext.inline.hpp" -#include "gc/shenandoah/shenandoahOopClosures.inline.hpp" #include "gc/shenandoah/shenandoahStringDedup.inline.hpp" #include "gc/shenandoah/shenandoahTaskqueue.inline.hpp" #include "gc/shenandoah/shenandoahUtils.hpp" diff --git a/src/hotspot/share/gc/shenandoah/shenandoahNMethod.cpp b/src/hotspot/share/gc/shenandoah/shenandoahNMethod.cpp index 5eb0b277b5e..75687302ca5 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahNMethod.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahNMethod.cpp @@ -28,7 +28,6 @@ #include "gc/shenandoah/shenandoahClosures.inline.hpp" #include "gc/shenandoah/shenandoahHeap.inline.hpp" #include "gc/shenandoah/shenandoahNMethod.inline.hpp" -#include "gc/shenandoah/shenandoahOopClosures.inline.hpp" #include "memory/resourceArea.hpp" #include "runtime/continuation.hpp" #include "runtime/safepointVerifiers.hpp" diff --git a/src/hotspot/share/gc/shenandoah/shenandoahOopClosures.hpp b/src/hotspot/share/gc/shenandoah/shenandoahOopClosures.hpp deleted file mode 100644 index a2869b6ead6..00000000000 --- a/src/hotspot/share/gc/shenandoah/shenandoahOopClosures.hpp +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright (c) 2015, 2022, Red Hat, Inc. 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#ifndef SHARE_GC_SHENANDOAH_SHENANDOAHOOPCLOSURES_HPP -#define SHARE_GC_SHENANDOAH_SHENANDOAHOOPCLOSURES_HPP - -#include "gc/shared/stringdedup/stringDedup.hpp" -#include "gc/shenandoah/shenandoahClosures.inline.hpp" -#include "gc/shenandoah/shenandoahGenerationType.hpp" -#include "gc/shenandoah/shenandoahHeap.inline.hpp" -#include "gc/shenandoah/shenandoahTaskqueue.hpp" -#include "gc/shenandoah/shenandoahUtils.hpp" -#include "memory/iterator.hpp" -#include "runtime/javaThread.hpp" - -class ShenandoahMarkRefsSuperClosure : public MetadataVisitingOopIterateClosure { -private: - ShenandoahObjToScanQueue* _queue; - ShenandoahMarkingContext* const _mark_context; - bool _weak; - -protected: - template - void work(T *p); - -public: - ShenandoahMarkRefsSuperClosure(ShenandoahObjToScanQueue* q, ShenandoahReferenceProcessor* rp); - - bool is_weak() const { - return _weak; - } - - void set_weak(bool weak) { - _weak = weak; - } - - virtual void do_nmethod(nmethod* nm) { - assert(!is_weak(), "Can't handle weak marking of nmethods"); - nm->run_nmethod_entry_barrier(); - } -}; - -template -class ShenandoahMarkUpdateRefsClosure : public ShenandoahMarkRefsSuperClosure { -private: - ShenandoahHeap* const _heap; - - template - inline void work(T* p); - -public: - ShenandoahMarkUpdateRefsClosure(ShenandoahObjToScanQueue* q, ShenandoahReferenceProcessor* rp) : - ShenandoahMarkRefsSuperClosure(q, rp), - _heap(ShenandoahHeap::heap()) { - assert(_heap->is_stw_gc_in_progress(), "Can only be used for STW GC"); - } - - virtual void do_oop(narrowOop* p) { work(p); } - virtual void do_oop(oop* p) { work(p); } -}; - -template -class ShenandoahMarkRefsClosure : public ShenandoahMarkRefsSuperClosure { -private: - template - inline void do_oop_work(T* p) { work(p); } - -public: - ShenandoahMarkRefsClosure(ShenandoahObjToScanQueue* q, ShenandoahReferenceProcessor* rp) : - ShenandoahMarkRefsSuperClosure(q, rp) {}; - - virtual void do_oop(narrowOop* p) { do_oop_work(p); } - virtual void do_oop(oop* p) { do_oop_work(p); } -}; - -class ShenandoahUpdateRefsSuperClosure : public ShenandoahOopClosureBase { -protected: - ShenandoahHeap* _heap; - -public: - ShenandoahUpdateRefsSuperClosure() : _heap(ShenandoahHeap::heap()) {} -}; - -class ShenandoahNonConcUpdateRefsClosure : public ShenandoahUpdateRefsSuperClosure { -private: - template - inline void work(T* p); - -public: - ShenandoahNonConcUpdateRefsClosure() : ShenandoahUpdateRefsSuperClosure() {} - - virtual void do_oop(narrowOop* p) { work(p); } - virtual void do_oop(oop* p) { work(p); } -}; - -class ShenandoahConcUpdateRefsClosure : public ShenandoahUpdateRefsSuperClosure { -private: - template - inline void work(T* p); - -public: - ShenandoahConcUpdateRefsClosure() : ShenandoahUpdateRefsSuperClosure() {} - - virtual void do_oop(narrowOop* p) { work(p); } - virtual void do_oop(oop* p) { work(p); } -}; - -#endif // SHARE_GC_SHENANDOAH_SHENANDOAHOOPCLOSURES_HPP diff --git a/src/hotspot/share/gc/shenandoah/shenandoahOopClosures.inline.hpp b/src/hotspot/share/gc/shenandoah/shenandoahOopClosures.inline.hpp deleted file mode 100644 index e614893aab9..00000000000 --- a/src/hotspot/share/gc/shenandoah/shenandoahOopClosures.inline.hpp +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2015, 2021, Red Hat, Inc. 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#ifndef SHARE_GC_SHENANDOAH_SHENANDOAHOOPCLOSURES_INLINE_HPP -#define SHARE_GC_SHENANDOAH_SHENANDOAHOOPCLOSURES_INLINE_HPP - -#include "gc/shenandoah/shenandoahOopClosures.hpp" - -#include "gc/shenandoah/shenandoahHeap.inline.hpp" -#include "gc/shenandoah/shenandoahMark.inline.hpp" - -template -inline void ShenandoahMarkRefsSuperClosure::work(T* p) { - ShenandoahMark::mark_through_ref(p, _queue, _mark_context, _weak); -} - -template -template -inline void ShenandoahMarkUpdateRefsClosure::work(T* p) { - // Update the location - _heap->non_conc_update_with_forwarded(p); - - // ...then do the usual thing - ShenandoahMarkRefsSuperClosure::work(p); -} - -template -inline void ShenandoahNonConcUpdateRefsClosure::work(T* p) { - _heap->non_conc_update_with_forwarded(p); -} - -template -inline void ShenandoahConcUpdateRefsClosure::work(T* p) { - _heap->conc_update_with_forwarded(p); -} - -#endif // SHARE_GC_SHENANDOAH_SHENANDOAHOOPCLOSURES_INLINE_HPP diff --git a/src/hotspot/share/gc/shenandoah/shenandoahReferenceProcessor.cpp b/src/hotspot/share/gc/shenandoah/shenandoahReferenceProcessor.cpp index 42c8d0ad271..fe1d6d69bd8 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahReferenceProcessor.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahReferenceProcessor.cpp @@ -26,7 +26,7 @@ #include "precompiled.hpp" #include "classfile/javaClasses.hpp" #include "gc/shared/workerThread.hpp" -#include "gc/shenandoah/shenandoahOopClosures.inline.hpp" +#include "gc/shenandoah/shenandoahClosures.inline.hpp" #include "gc/shenandoah/shenandoahReferenceProcessor.hpp" #include "gc/shenandoah/shenandoahThreadLocalData.hpp" #include "gc/shenandoah/shenandoahUtils.hpp" diff --git a/src/hotspot/share/gc/shenandoah/shenandoahSTWMark.cpp b/src/hotspot/share/gc/shenandoah/shenandoahSTWMark.cpp index 83e897994cb..2e581d918d4 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahSTWMark.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahSTWMark.cpp @@ -31,7 +31,6 @@ #include "gc/shenandoah/shenandoahClosures.inline.hpp" #include "gc/shenandoah/shenandoahGenerationType.hpp" #include "gc/shenandoah/shenandoahMark.inline.hpp" -#include "gc/shenandoah/shenandoahOopClosures.inline.hpp" #include "gc/shenandoah/shenandoahReferenceProcessor.hpp" #include "gc/shenandoah/shenandoahRootProcessor.inline.hpp" #include "gc/shenandoah/shenandoahSTWMark.hpp" diff --git a/src/hotspot/share/gc/shenandoah/shenandoahVMOperations.cpp b/src/hotspot/share/gc/shenandoah/shenandoahVMOperations.cpp index 9d2782502fe..2dd6018ecd4 100644 --- a/src/hotspot/share/gc/shenandoah/shenandoahVMOperations.cpp +++ b/src/hotspot/share/gc/shenandoah/shenandoahVMOperations.cpp @@ -28,8 +28,6 @@ #include "gc/shenandoah/shenandoahDegeneratedGC.hpp" #include "gc/shenandoah/shenandoahFullGC.hpp" #include "gc/shenandoah/shenandoahHeap.inline.hpp" -#include "gc/shenandoah/shenandoahMark.inline.hpp" -#include "gc/shenandoah/shenandoahOopClosures.inline.hpp" #include "gc/shenandoah/shenandoahUtils.hpp" #include "gc/shenandoah/shenandoahVMOperations.hpp" #include "interpreter/oopMapCache.hpp" diff --git a/src/hotspot/share/gc/x/c1/xBarrierSetC1.cpp b/src/hotspot/share/gc/x/c1/xBarrierSetC1.cpp deleted file mode 100644 index 6f64392cefc..00000000000 --- a/src/hotspot/share/gc/x/c1/xBarrierSetC1.cpp +++ /dev/null @@ -1,237 +0,0 @@ -/* - * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "c1/c1_LIR.hpp" -#include "c1/c1_LIRGenerator.hpp" -#include "c1/c1_CodeStubs.hpp" -#include "gc/x/c1/xBarrierSetC1.hpp" -#include "gc/x/xBarrierSet.hpp" -#include "gc/x/xBarrierSetAssembler.hpp" -#include "gc/x/xThreadLocalData.hpp" -#include "utilities/macros.hpp" - -XLoadBarrierStubC1::XLoadBarrierStubC1(LIRAccess& access, LIR_Opr ref, address runtime_stub) : - _decorators(access.decorators()), - _ref_addr(access.resolved_addr()), - _ref(ref), - _tmp(LIR_OprFact::illegalOpr), - _runtime_stub(runtime_stub) { - - assert(_ref_addr->is_address(), "Must be an address"); - assert(_ref->is_register(), "Must be a register"); - - // Allocate tmp register if needed - if (_ref_addr->as_address_ptr()->index()->is_valid() || - _ref_addr->as_address_ptr()->disp() != 0) { - // Has index or displacement, need tmp register to load address into - _tmp = access.gen()->new_pointer_register(); - } - - FrameMap* f = Compilation::current()->frame_map(); - f->update_reserved_argument_area_size(2 * BytesPerWord); -} - -DecoratorSet XLoadBarrierStubC1::decorators() const { - return _decorators; -} - -LIR_Opr XLoadBarrierStubC1::ref() const { - return _ref; -} - -LIR_Opr XLoadBarrierStubC1::ref_addr() const { - return _ref_addr; -} - -LIR_Opr XLoadBarrierStubC1::tmp() const { - return _tmp; -} - -address XLoadBarrierStubC1::runtime_stub() const { - return _runtime_stub; -} - -void XLoadBarrierStubC1::visit(LIR_OpVisitState* visitor) { - visitor->do_slow_case(); - visitor->do_input(_ref_addr); - visitor->do_output(_ref); - if (_tmp->is_valid()) { - visitor->do_temp(_tmp); - } -} - -void XLoadBarrierStubC1::emit_code(LIR_Assembler* ce) { - XBarrierSet::assembler()->generate_c1_load_barrier_stub(ce, this); -} - -#ifndef PRODUCT -void XLoadBarrierStubC1::print_name(outputStream* out) const { - out->print("XLoadBarrierStubC1"); -} -#endif // PRODUCT - -class LIR_OpXLoadBarrierTest : public LIR_Op { -private: - LIR_Opr _opr; - -public: - LIR_OpXLoadBarrierTest(LIR_Opr opr) : - LIR_Op(lir_xloadbarrier_test, LIR_OprFact::illegalOpr, nullptr), - _opr(opr) {} - - virtual void visit(LIR_OpVisitState* state) { - state->do_input(_opr); - } - - virtual void emit_code(LIR_Assembler* ce) { - XBarrierSet::assembler()->generate_c1_load_barrier_test(ce, _opr); - } - - virtual void print_instr(outputStream* out) const { - _opr->print(out); - out->print(" "); - } - -#ifndef PRODUCT - virtual const char* name() const { - return "lir_z_load_barrier_test"; - } -#endif // PRODUCT -}; - -static bool barrier_needed(LIRAccess& access) { - return XBarrierSet::barrier_needed(access.decorators(), access.type()); -} - -XBarrierSetC1::XBarrierSetC1() : - _load_barrier_on_oop_field_preloaded_runtime_stub(nullptr), - _load_barrier_on_weak_oop_field_preloaded_runtime_stub(nullptr) {} - -address XBarrierSetC1::load_barrier_on_oop_field_preloaded_runtime_stub(DecoratorSet decorators) const { - assert((decorators & ON_PHANTOM_OOP_REF) == 0, "Unsupported decorator"); - //assert((decorators & ON_UNKNOWN_OOP_REF) == 0, "Unsupported decorator"); - - if ((decorators & ON_WEAK_OOP_REF) != 0) { - return _load_barrier_on_weak_oop_field_preloaded_runtime_stub; - } else { - return _load_barrier_on_oop_field_preloaded_runtime_stub; - } -} - -#ifdef ASSERT -#define __ access.gen()->lir(__FILE__, __LINE__)-> -#else -#define __ access.gen()->lir()-> -#endif - -void XBarrierSetC1::load_barrier(LIRAccess& access, LIR_Opr result) const { - // Fast path - __ append(new LIR_OpXLoadBarrierTest(result)); - - // Slow path - const address runtime_stub = load_barrier_on_oop_field_preloaded_runtime_stub(access.decorators()); - CodeStub* const stub = new XLoadBarrierStubC1(access, result, runtime_stub); - __ branch(lir_cond_notEqual, stub); - __ branch_destination(stub->continuation()); -} - -LIR_Opr XBarrierSetC1::resolve_address(LIRAccess& access, bool resolve_in_register) { - // We must resolve in register when patching. This is to avoid - // having a patch area in the load barrier stub, since the call - // into the runtime to patch will not have the proper oop map. - const bool patch_before_barrier = barrier_needed(access) && (access.decorators() & C1_NEEDS_PATCHING) != 0; - return BarrierSetC1::resolve_address(access, resolve_in_register || patch_before_barrier); -} - -#undef __ - -void XBarrierSetC1::load_at_resolved(LIRAccess& access, LIR_Opr result) { - BarrierSetC1::load_at_resolved(access, result); - - if (barrier_needed(access)) { - load_barrier(access, result); - } -} - -static void pre_load_barrier(LIRAccess& access) { - DecoratorSet decorators = access.decorators(); - - // Downgrade access to MO_UNORDERED - decorators = (decorators & ~MO_DECORATOR_MASK) | MO_UNORDERED; - - // Remove ACCESS_WRITE - decorators = (decorators & ~ACCESS_WRITE); - - // Generate synthetic load at - access.gen()->access_load_at(decorators, - access.type(), - access.base().item(), - access.offset().opr(), - access.gen()->new_register(access.type()), - nullptr /* patch_emit_info */, - nullptr /* load_emit_info */); -} - -LIR_Opr XBarrierSetC1::atomic_xchg_at_resolved(LIRAccess& access, LIRItem& value) { - if (barrier_needed(access)) { - pre_load_barrier(access); - } - - return BarrierSetC1::atomic_xchg_at_resolved(access, value); -} - -LIR_Opr XBarrierSetC1::atomic_cmpxchg_at_resolved(LIRAccess& access, LIRItem& cmp_value, LIRItem& new_value) { - if (barrier_needed(access)) { - pre_load_barrier(access); - } - - return BarrierSetC1::atomic_cmpxchg_at_resolved(access, cmp_value, new_value); -} - -class XLoadBarrierRuntimeStubCodeGenClosure : public StubAssemblerCodeGenClosure { -private: - const DecoratorSet _decorators; - -public: - XLoadBarrierRuntimeStubCodeGenClosure(DecoratorSet decorators) : - _decorators(decorators) {} - - virtual OopMapSet* generate_code(StubAssembler* sasm) { - XBarrierSet::assembler()->generate_c1_load_barrier_runtime_stub(sasm, _decorators); - return nullptr; - } -}; - -static address generate_c1_runtime_stub(BufferBlob* blob, DecoratorSet decorators, const char* name) { - XLoadBarrierRuntimeStubCodeGenClosure cl(decorators); - CodeBlob* const code_blob = Runtime1::generate_blob(blob, C1StubId::NO_STUBID /* stub_id */, name, false /* expect_oop_map*/, &cl); - return code_blob->code_begin(); -} - -void XBarrierSetC1::generate_c1_runtime_stubs(BufferBlob* blob) { - _load_barrier_on_oop_field_preloaded_runtime_stub = - generate_c1_runtime_stub(blob, ON_STRONG_OOP_REF, "load_barrier_on_oop_field_preloaded_runtime_stub"); - _load_barrier_on_weak_oop_field_preloaded_runtime_stub = - generate_c1_runtime_stub(blob, ON_WEAK_OOP_REF, "load_barrier_on_weak_oop_field_preloaded_runtime_stub"); -} diff --git a/src/hotspot/share/gc/x/c1/xBarrierSetC1.hpp b/src/hotspot/share/gc/x/c1/xBarrierSetC1.hpp deleted file mode 100644 index 26c2e142cdf..00000000000 --- a/src/hotspot/share/gc/x/c1/xBarrierSetC1.hpp +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2015, 2019, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_C1_XBARRIERSETC1_HPP -#define SHARE_GC_X_C1_XBARRIERSETC1_HPP - -#include "c1/c1_CodeStubs.hpp" -#include "c1/c1_IR.hpp" -#include "c1/c1_LIR.hpp" -#include "gc/shared/c1/barrierSetC1.hpp" -#include "oops/accessDecorators.hpp" - -class XLoadBarrierStubC1 : public CodeStub { -private: - DecoratorSet _decorators; - LIR_Opr _ref_addr; - LIR_Opr _ref; - LIR_Opr _tmp; - address _runtime_stub; - -public: - XLoadBarrierStubC1(LIRAccess& access, LIR_Opr ref, address runtime_stub); - - DecoratorSet decorators() const; - LIR_Opr ref() const; - LIR_Opr ref_addr() const; - LIR_Opr tmp() const; - address runtime_stub() const; - - virtual void emit_code(LIR_Assembler* ce); - virtual void visit(LIR_OpVisitState* visitor); - -#ifndef PRODUCT - virtual void print_name(outputStream* out) const; -#endif // PRODUCT -}; - -class XBarrierSetC1 : public BarrierSetC1 { -private: - address _load_barrier_on_oop_field_preloaded_runtime_stub; - address _load_barrier_on_weak_oop_field_preloaded_runtime_stub; - - address load_barrier_on_oop_field_preloaded_runtime_stub(DecoratorSet decorators) const; - void load_barrier(LIRAccess& access, LIR_Opr result) const; - -protected: - virtual LIR_Opr resolve_address(LIRAccess& access, bool resolve_in_register); - virtual void load_at_resolved(LIRAccess& access, LIR_Opr result); - virtual LIR_Opr atomic_xchg_at_resolved(LIRAccess& access, LIRItem& value); - virtual LIR_Opr atomic_cmpxchg_at_resolved(LIRAccess& access, LIRItem& cmp_value, LIRItem& new_value); - -public: - XBarrierSetC1(); - - virtual void generate_c1_runtime_stubs(BufferBlob* blob); -}; - -#endif // SHARE_GC_X_C1_XBARRIERSETC1_HPP diff --git a/src/hotspot/share/gc/x/c2/xBarrierSetC2.cpp b/src/hotspot/share/gc/x/c2/xBarrierSetC2.cpp deleted file mode 100644 index d006b37e7d2..00000000000 --- a/src/hotspot/share/gc/x/c2/xBarrierSetC2.cpp +++ /dev/null @@ -1,583 +0,0 @@ -/* - * Copyright (c) 2015, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "classfile/javaClasses.hpp" -#include "gc/x/c2/xBarrierSetC2.hpp" -#include "gc/x/xBarrierSet.hpp" -#include "gc/x/xBarrierSetAssembler.hpp" -#include "gc/x/xBarrierSetRuntime.hpp" -#include "opto/arraycopynode.hpp" -#include "opto/addnode.hpp" -#include "opto/block.hpp" -#include "opto/compile.hpp" -#include "opto/graphKit.hpp" -#include "opto/machnode.hpp" -#include "opto/macro.hpp" -#include "opto/memnode.hpp" -#include "opto/node.hpp" -#include "opto/output.hpp" -#include "opto/regalloc.hpp" -#include "opto/rootnode.hpp" -#include "opto/runtime.hpp" -#include "opto/type.hpp" -#include "utilities/growableArray.hpp" -#include "utilities/macros.hpp" - -class XBarrierSetC2State : public ArenaObj { -private: - GrowableArray* _stubs; - Node_Array _live; - -public: - XBarrierSetC2State(Arena* arena) : - _stubs(new (arena) GrowableArray(arena, 8, 0, nullptr)), - _live(arena) {} - - GrowableArray* stubs() { - return _stubs; - } - - RegMask* live(const Node* node) { - if (!node->is_Mach()) { - // Don't need liveness for non-MachNodes - return nullptr; - } - - const MachNode* const mach = node->as_Mach(); - if (mach->barrier_data() == XLoadBarrierElided) { - // Don't need liveness data for nodes without barriers - return nullptr; - } - - RegMask* live = (RegMask*)_live[node->_idx]; - if (live == nullptr) { - live = new (Compile::current()->comp_arena()->AmallocWords(sizeof(RegMask))) RegMask(); - _live.map(node->_idx, (Node*)live); - } - - return live; - } -}; - -static XBarrierSetC2State* barrier_set_state() { - return reinterpret_cast(Compile::current()->barrier_set_state()); -} - -XLoadBarrierStubC2* XLoadBarrierStubC2::create(const MachNode* node, Address ref_addr, Register ref, Register tmp, uint8_t barrier_data) { - XLoadBarrierStubC2* const stub = new (Compile::current()->comp_arena()) XLoadBarrierStubC2(node, ref_addr, ref, tmp, barrier_data); - if (!Compile::current()->output()->in_scratch_emit_size()) { - barrier_set_state()->stubs()->append(stub); - } - - return stub; -} - -XLoadBarrierStubC2::XLoadBarrierStubC2(const MachNode* node, Address ref_addr, Register ref, Register tmp, uint8_t barrier_data) : - _node(node), - _ref_addr(ref_addr), - _ref(ref), - _tmp(tmp), - _barrier_data(barrier_data), - _entry(), - _continuation() { - assert_different_registers(ref, ref_addr.base()); - assert_different_registers(ref, ref_addr.index()); -} - -Address XLoadBarrierStubC2::ref_addr() const { - return _ref_addr; -} - -Register XLoadBarrierStubC2::ref() const { - return _ref; -} - -Register XLoadBarrierStubC2::tmp() const { - return _tmp; -} - -address XLoadBarrierStubC2::slow_path() const { - DecoratorSet decorators = DECORATORS_NONE; - if (_barrier_data & XLoadBarrierStrong) { - decorators |= ON_STRONG_OOP_REF; - } - if (_barrier_data & XLoadBarrierWeak) { - decorators |= ON_WEAK_OOP_REF; - } - if (_barrier_data & XLoadBarrierPhantom) { - decorators |= ON_PHANTOM_OOP_REF; - } - if (_barrier_data & XLoadBarrierNoKeepalive) { - decorators |= AS_NO_KEEPALIVE; - } - return XBarrierSetRuntime::load_barrier_on_oop_field_preloaded_addr(decorators); -} - -RegMask& XLoadBarrierStubC2::live() const { - RegMask* mask = barrier_set_state()->live(_node); - assert(mask != nullptr, "must be mach-node with barrier"); - return *mask; -} - -Label* XLoadBarrierStubC2::entry() { - // The _entry will never be bound when in_scratch_emit_size() is true. - // However, we still need to return a label that is not bound now, but - // will eventually be bound. Any label will do, as it will only act as - // a placeholder, so we return the _continuation label. - return Compile::current()->output()->in_scratch_emit_size() ? &_continuation : &_entry; -} - -Label* XLoadBarrierStubC2::continuation() { - return &_continuation; -} - -void* XBarrierSetC2::create_barrier_state(Arena* comp_arena) const { - return new (comp_arena) XBarrierSetC2State(comp_arena); -} - -void XBarrierSetC2::late_barrier_analysis() const { - analyze_dominating_barriers(); - compute_liveness_at_stubs(); -} - -void XBarrierSetC2::emit_stubs(CodeBuffer& cb) const { - MacroAssembler masm(&cb); - GrowableArray* const stubs = barrier_set_state()->stubs(); - - for (int i = 0; i < stubs->length(); i++) { - // Make sure there is enough space in the code buffer - if (cb.insts()->maybe_expand_to_ensure_remaining(PhaseOutput::MAX_inst_size) && cb.blob() == nullptr) { - ciEnv::current()->record_failure("CodeCache is full"); - return; - } - - XBarrierSet::assembler()->generate_c2_load_barrier_stub(&masm, stubs->at(i)); - } - - masm.flush(); -} - -int XBarrierSetC2::estimate_stub_size() const { - Compile* const C = Compile::current(); - BufferBlob* const blob = C->output()->scratch_buffer_blob(); - GrowableArray* const stubs = barrier_set_state()->stubs(); - int size = 0; - - for (int i = 0; i < stubs->length(); i++) { - CodeBuffer cb(blob->content_begin(), (address)C->output()->scratch_locs_memory() - blob->content_begin()); - MacroAssembler masm(&cb); - XBarrierSet::assembler()->generate_c2_load_barrier_stub(&masm, stubs->at(i)); - size += cb.insts_size(); - } - - return size; -} - -static void set_barrier_data(C2Access& access) { - if (XBarrierSet::barrier_needed(access.decorators(), access.type())) { - uint8_t barrier_data = 0; - - if (access.decorators() & ON_PHANTOM_OOP_REF) { - barrier_data |= XLoadBarrierPhantom; - } else if (access.decorators() & ON_WEAK_OOP_REF) { - barrier_data |= XLoadBarrierWeak; - } else { - barrier_data |= XLoadBarrierStrong; - } - - if (access.decorators() & AS_NO_KEEPALIVE) { - barrier_data |= XLoadBarrierNoKeepalive; - } - - access.set_barrier_data(barrier_data); - } -} - -Node* XBarrierSetC2::load_at_resolved(C2Access& access, const Type* val_type) const { - set_barrier_data(access); - return BarrierSetC2::load_at_resolved(access, val_type); -} - -Node* XBarrierSetC2::atomic_cmpxchg_val_at_resolved(C2AtomicParseAccess& access, Node* expected_val, - Node* new_val, const Type* val_type) const { - set_barrier_data(access); - return BarrierSetC2::atomic_cmpxchg_val_at_resolved(access, expected_val, new_val, val_type); -} - -Node* XBarrierSetC2::atomic_cmpxchg_bool_at_resolved(C2AtomicParseAccess& access, Node* expected_val, - Node* new_val, const Type* value_type) const { - set_barrier_data(access); - return BarrierSetC2::atomic_cmpxchg_bool_at_resolved(access, expected_val, new_val, value_type); -} - -Node* XBarrierSetC2::atomic_xchg_at_resolved(C2AtomicParseAccess& access, Node* new_val, const Type* val_type) const { - set_barrier_data(access); - return BarrierSetC2::atomic_xchg_at_resolved(access, new_val, val_type); -} - -bool XBarrierSetC2::array_copy_requires_gc_barriers(bool tightly_coupled_alloc, BasicType type, - bool is_clone, bool is_clone_instance, - ArrayCopyPhase phase) const { - if (phase == ArrayCopyPhase::Parsing) { - return false; - } - if (phase == ArrayCopyPhase::Optimization) { - return is_clone_instance; - } - // else ArrayCopyPhase::Expansion - return type == T_OBJECT || type == T_ARRAY; -} - -// This TypeFunc assumes a 64bit system -static const TypeFunc* clone_type() { - // Create input type (domain) - const Type** domain_fields = TypeTuple::fields(4); - domain_fields[TypeFunc::Parms + 0] = TypeInstPtr::NOTNULL; // src - domain_fields[TypeFunc::Parms + 1] = TypeInstPtr::NOTNULL; // dst - domain_fields[TypeFunc::Parms + 2] = TypeLong::LONG; // size lower - domain_fields[TypeFunc::Parms + 3] = Type::HALF; // size upper - const TypeTuple* domain = TypeTuple::make(TypeFunc::Parms + 4, domain_fields); - - // Create result type (range) - const Type** range_fields = TypeTuple::fields(0); - const TypeTuple* range = TypeTuple::make(TypeFunc::Parms + 0, range_fields); - - return TypeFunc::make(domain, range); -} - -#define XTOP LP64_ONLY(COMMA phase->top()) - -void XBarrierSetC2::clone_at_expansion(PhaseMacroExpand* phase, ArrayCopyNode* ac) const { - Node* const src = ac->in(ArrayCopyNode::Src); - const TypeAryPtr* ary_ptr = src->get_ptr_type()->isa_aryptr(); - - if (ac->is_clone_array() && ary_ptr != nullptr) { - BasicType bt = ary_ptr->elem()->array_element_basic_type(); - if (is_reference_type(bt)) { - // Clone object array - bt = T_OBJECT; - } else { - // Clone primitive array - bt = T_LONG; - } - - Node* ctrl = ac->in(TypeFunc::Control); - Node* mem = ac->in(TypeFunc::Memory); - Node* src = ac->in(ArrayCopyNode::Src); - Node* src_offset = ac->in(ArrayCopyNode::SrcPos); - Node* dest = ac->in(ArrayCopyNode::Dest); - Node* dest_offset = ac->in(ArrayCopyNode::DestPos); - Node* length = ac->in(ArrayCopyNode::Length); - - if (bt == T_OBJECT) { - // BarrierSetC2::clone sets the offsets via BarrierSetC2::arraycopy_payload_base_offset - // which 8-byte aligns them to allow for word size copies. Make sure the offsets point - // to the first element in the array when cloning object arrays. Otherwise, load - // barriers are applied to parts of the header. Also adjust the length accordingly. - assert(src_offset == dest_offset, "should be equal"); - jlong offset = src_offset->get_long(); - if (offset != arrayOopDesc::base_offset_in_bytes(T_OBJECT)) { - assert(!UseCompressedClassPointers, "should only happen without compressed class pointers"); - assert((arrayOopDesc::base_offset_in_bytes(T_OBJECT) - offset) == BytesPerLong, "unexpected offset"); - length = phase->transform_later(new SubLNode(length, phase->longcon(1))); // Size is in longs - src_offset = phase->longcon(arrayOopDesc::base_offset_in_bytes(T_OBJECT)); - dest_offset = src_offset; - } - } - Node* payload_src = phase->basic_plus_adr(src, src_offset); - Node* payload_dst = phase->basic_plus_adr(dest, dest_offset); - - const char* copyfunc_name = "arraycopy"; - address copyfunc_addr = phase->basictype2arraycopy(bt, nullptr, nullptr, true, copyfunc_name, true); - - const TypePtr* raw_adr_type = TypeRawPtr::BOTTOM; - const TypeFunc* call_type = OptoRuntime::fast_arraycopy_Type(); - - Node* call = phase->make_leaf_call(ctrl, mem, call_type, copyfunc_addr, copyfunc_name, raw_adr_type, payload_src, payload_dst, length XTOP); - phase->transform_later(call); - - phase->igvn().replace_node(ac, call); - return; - } - - // Clone instance - Node* const ctrl = ac->in(TypeFunc::Control); - Node* const mem = ac->in(TypeFunc::Memory); - Node* const dst = ac->in(ArrayCopyNode::Dest); - Node* const size = ac->in(ArrayCopyNode::Length); - - assert(size->bottom_type()->is_long(), "Should be long"); - - // The native clone we are calling here expects the instance size in words - // Add header/offset size to payload size to get instance size. - Node* const base_offset = phase->longcon(arraycopy_payload_base_offset(ac->is_clone_array()) >> LogBytesPerLong); - Node* const full_size = phase->transform_later(new AddLNode(size, base_offset)); - - Node* const call = phase->make_leaf_call(ctrl, - mem, - clone_type(), - XBarrierSetRuntime::clone_addr(), - "XBarrierSetRuntime::clone", - TypeRawPtr::BOTTOM, - src, - dst, - full_size, - phase->top()); - phase->transform_later(call); - phase->igvn().replace_node(ac, call); -} - -#undef XTOP - -// == Dominating barrier elision == - -static bool block_has_safepoint(const Block* block, uint from, uint to) { - for (uint i = from; i < to; i++) { - if (block->get_node(i)->is_MachSafePoint()) { - // Safepoint found - return true; - } - } - - // Safepoint not found - return false; -} - -static bool block_has_safepoint(const Block* block) { - return block_has_safepoint(block, 0, block->number_of_nodes()); -} - -static uint block_index(const Block* block, const Node* node) { - for (uint j = 0; j < block->number_of_nodes(); ++j) { - if (block->get_node(j) == node) { - return j; - } - } - ShouldNotReachHere(); - return 0; -} - -void XBarrierSetC2::analyze_dominating_barriers() const { - ResourceMark rm; - Compile* const C = Compile::current(); - PhaseCFG* const cfg = C->cfg(); - Block_List worklist; - Node_List mem_ops; - Node_List barrier_loads; - - // Step 1 - Find accesses, and track them in lists - for (uint i = 0; i < cfg->number_of_blocks(); ++i) { - const Block* const block = cfg->get_block(i); - for (uint j = 0; j < block->number_of_nodes(); ++j) { - const Node* const node = block->get_node(j); - if (!node->is_Mach()) { - continue; - } - - MachNode* const mach = node->as_Mach(); - switch (mach->ideal_Opcode()) { - case Op_LoadP: - if ((mach->barrier_data() & XLoadBarrierStrong) != 0) { - barrier_loads.push(mach); - } - if ((mach->barrier_data() & (XLoadBarrierStrong | XLoadBarrierNoKeepalive)) == - XLoadBarrierStrong) { - mem_ops.push(mach); - } - break; - case Op_CompareAndExchangeP: - case Op_CompareAndSwapP: - case Op_GetAndSetP: - if ((mach->barrier_data() & XLoadBarrierStrong) != 0) { - barrier_loads.push(mach); - } - case Op_StoreP: - mem_ops.push(mach); - break; - - default: - break; - } - } - } - - // Step 2 - Find dominating accesses for each load - for (uint i = 0; i < barrier_loads.size(); i++) { - MachNode* const load = barrier_loads.at(i)->as_Mach(); - const TypePtr* load_adr_type = nullptr; - intptr_t load_offset = 0; - const Node* const load_obj = load->get_base_and_disp(load_offset, load_adr_type); - Block* const load_block = cfg->get_block_for_node(load); - const uint load_index = block_index(load_block, load); - - for (uint j = 0; j < mem_ops.size(); j++) { - MachNode* mem = mem_ops.at(j)->as_Mach(); - const TypePtr* mem_adr_type = nullptr; - intptr_t mem_offset = 0; - const Node* mem_obj = mem->get_base_and_disp(mem_offset, mem_adr_type); - Block* mem_block = cfg->get_block_for_node(mem); - uint mem_index = block_index(mem_block, mem); - - if (load_obj == NodeSentinel || mem_obj == NodeSentinel || - load_obj == nullptr || mem_obj == nullptr || - load_offset < 0 || mem_offset < 0) { - continue; - } - - if (mem_obj != load_obj || mem_offset != load_offset) { - // Not the same addresses, not a candidate - continue; - } - - if (load_block == mem_block) { - // Earlier accesses in the same block - if (mem_index < load_index && !block_has_safepoint(mem_block, mem_index + 1, load_index)) { - load->set_barrier_data(XLoadBarrierElided); - } - } else if (mem_block->dominates(load_block)) { - // Dominating block? Look around for safepoints - ResourceMark rm; - Block_List stack; - VectorSet visited; - stack.push(load_block); - bool safepoint_found = block_has_safepoint(load_block); - while (!safepoint_found && stack.size() > 0) { - Block* block = stack.pop(); - if (visited.test_set(block->_pre_order)) { - continue; - } - if (block_has_safepoint(block)) { - safepoint_found = true; - break; - } - if (block == mem_block) { - continue; - } - - // Push predecessor blocks - for (uint p = 1; p < block->num_preds(); ++p) { - Block* pred = cfg->get_block_for_node(block->pred(p)); - stack.push(pred); - } - } - - if (!safepoint_found) { - load->set_barrier_data(XLoadBarrierElided); - } - } - } - } -} - -// == Reduced spilling optimization == - -void XBarrierSetC2::compute_liveness_at_stubs() const { - ResourceMark rm; - Compile* const C = Compile::current(); - Arena* const A = Thread::current()->resource_area(); - PhaseCFG* const cfg = C->cfg(); - PhaseRegAlloc* const regalloc = C->regalloc(); - RegMask* const live = NEW_ARENA_ARRAY(A, RegMask, cfg->number_of_blocks() * sizeof(RegMask)); - XBarrierSetAssembler* const bs = XBarrierSet::assembler(); - Block_List worklist; - - for (uint i = 0; i < cfg->number_of_blocks(); ++i) { - new ((void*)(live + i)) RegMask(); - worklist.push(cfg->get_block(i)); - } - - while (worklist.size() > 0) { - const Block* const block = worklist.pop(); - RegMask& old_live = live[block->_pre_order]; - RegMask new_live; - - // Initialize to union of successors - for (uint i = 0; i < block->_num_succs; i++) { - const uint succ_id = block->_succs[i]->_pre_order; - new_live.OR(live[succ_id]); - } - - // Walk block backwards, computing liveness - for (int i = block->number_of_nodes() - 1; i >= 0; --i) { - const Node* const node = block->get_node(i); - - // Remove def bits - const OptoReg::Name first = bs->refine_register(node, regalloc->get_reg_first(node)); - const OptoReg::Name second = bs->refine_register(node, regalloc->get_reg_second(node)); - if (first != OptoReg::Bad) { - new_live.Remove(first); - } - if (second != OptoReg::Bad) { - new_live.Remove(second); - } - - // Add use bits - for (uint j = 1; j < node->req(); ++j) { - const Node* const use = node->in(j); - const OptoReg::Name first = bs->refine_register(use, regalloc->get_reg_first(use)); - const OptoReg::Name second = bs->refine_register(use, regalloc->get_reg_second(use)); - if (first != OptoReg::Bad) { - new_live.Insert(first); - } - if (second != OptoReg::Bad) { - new_live.Insert(second); - } - } - - // If this node tracks liveness, update it - RegMask* const regs = barrier_set_state()->live(node); - if (regs != nullptr) { - regs->OR(new_live); - } - } - - // Now at block top, see if we have any changes - new_live.SUBTRACT(old_live); - if (new_live.is_NotEmpty()) { - // Liveness has refined, update and propagate to prior blocks - old_live.OR(new_live); - for (uint i = 1; i < block->num_preds(); ++i) { - Block* const pred = cfg->get_block_for_node(block->pred(i)); - worklist.push(pred); - } - } - } -} - -#ifndef PRODUCT -void XBarrierSetC2::dump_barrier_data(const MachNode* mach, outputStream* st) const { - if ((mach->barrier_data() & XLoadBarrierStrong) != 0) { - st->print("strong "); - } - if ((mach->barrier_data() & XLoadBarrierWeak) != 0) { - st->print("weak "); - } - if ((mach->barrier_data() & XLoadBarrierPhantom) != 0) { - st->print("phantom "); - } - if ((mach->barrier_data() & XLoadBarrierNoKeepalive) != 0) { - st->print("nokeepalive "); - } -} -#endif // !PRODUCT diff --git a/src/hotspot/share/gc/x/c2/xBarrierSetC2.hpp b/src/hotspot/share/gc/x/c2/xBarrierSetC2.hpp deleted file mode 100644 index 91835338fd7..00000000000 --- a/src/hotspot/share/gc/x/c2/xBarrierSetC2.hpp +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (c) 2015, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_C2_XBARRIERSETC2_HPP -#define SHARE_GC_X_C2_XBARRIERSETC2_HPP - -#include "gc/shared/c2/barrierSetC2.hpp" -#include "memory/allocation.hpp" -#include "opto/node.hpp" -#include "utilities/growableArray.hpp" - -const uint8_t XLoadBarrierElided = 0; -const uint8_t XLoadBarrierStrong = 1; -const uint8_t XLoadBarrierWeak = 2; -const uint8_t XLoadBarrierPhantom = 4; -const uint8_t XLoadBarrierNoKeepalive = 8; - -class XLoadBarrierStubC2 : public ArenaObj { -private: - const MachNode* _node; - const Address _ref_addr; - const Register _ref; - const Register _tmp; - const uint8_t _barrier_data; - Label _entry; - Label _continuation; - - XLoadBarrierStubC2(const MachNode* node, Address ref_addr, Register ref, Register tmp, uint8_t barrier_data); - -public: - static XLoadBarrierStubC2* create(const MachNode* node, Address ref_addr, Register ref, Register tmp, uint8_t barrier_data); - - Address ref_addr() const; - Register ref() const; - Register tmp() const; - address slow_path() const; - RegMask& live() const; - Label* entry(); - Label* continuation(); -}; - -class XBarrierSetC2 : public BarrierSetC2 { -private: - void compute_liveness_at_stubs() const; - void analyze_dominating_barriers() const; - -protected: - virtual Node* load_at_resolved(C2Access& access, const Type* val_type) const; - virtual Node* atomic_cmpxchg_val_at_resolved(C2AtomicParseAccess& access, - Node* expected_val, - Node* new_val, - const Type* val_type) const; - virtual Node* atomic_cmpxchg_bool_at_resolved(C2AtomicParseAccess& access, - Node* expected_val, - Node* new_val, - const Type* value_type) const; - virtual Node* atomic_xchg_at_resolved(C2AtomicParseAccess& access, - Node* new_val, - const Type* val_type) const; - -public: - virtual void* create_barrier_state(Arena* comp_arena) const; - virtual bool array_copy_requires_gc_barriers(bool tightly_coupled_alloc, - BasicType type, - bool is_clone, - bool is_clone_instance, - ArrayCopyPhase phase) const; - virtual void clone_at_expansion(PhaseMacroExpand* phase, - ArrayCopyNode* ac) const; - - virtual void late_barrier_analysis() const; - virtual int estimate_stub_size() const; - virtual void emit_stubs(CodeBuffer& cb) const; - -#ifndef PRODUCT - virtual void dump_barrier_data(const MachNode* mach, outputStream* st) const; -#endif -}; - -#endif // SHARE_GC_X_C2_XBARRIERSETC2_HPP diff --git a/src/hotspot/share/gc/x/vmStructs_x.cpp b/src/hotspot/share/gc/x/vmStructs_x.cpp deleted file mode 100644 index 4c7d63f41b4..00000000000 --- a/src/hotspot/share/gc/x/vmStructs_x.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2018, 2021, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/x/vmStructs_x.hpp" - -XGlobalsForVMStructs::XGlobalsForVMStructs() : - _XGlobalPhase(&XGlobalPhase), - _XGlobalSeqNum(&XGlobalSeqNum), - _XAddressOffsetMask(&XAddressOffsetMask), - _XAddressMetadataMask(&XAddressMetadataMask), - _XAddressMetadataFinalizable(&XAddressMetadataFinalizable), - _XAddressGoodMask(&XAddressGoodMask), - _XAddressBadMask(&XAddressBadMask), - _XAddressWeakBadMask(&XAddressWeakBadMask), - _XObjectAlignmentSmallShift(&XObjectAlignmentSmallShift), - _XObjectAlignmentSmall(&XObjectAlignmentSmall) { -} - -XGlobalsForVMStructs XGlobalsForVMStructs::_instance; -XGlobalsForVMStructs* XGlobalsForVMStructs::_instance_p = &XGlobalsForVMStructs::_instance; diff --git a/src/hotspot/share/gc/x/vmStructs_x.hpp b/src/hotspot/share/gc/x/vmStructs_x.hpp deleted file mode 100644 index b911c21be23..00000000000 --- a/src/hotspot/share/gc/x/vmStructs_x.hpp +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Copyright (c) 2017, 2021, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_VMSTRUCTS_X_HPP -#define SHARE_GC_X_VMSTRUCTS_X_HPP - -#include "gc/x/xAttachedArray.hpp" -#include "gc/x/xCollectedHeap.hpp" -#include "gc/x/xForwarding.hpp" -#include "gc/x/xGranuleMap.hpp" -#include "gc/x/xHeap.hpp" -#include "gc/x/xPageAllocator.hpp" -#include "utilities/macros.hpp" - -// Expose some ZGC globals to the SA agent. -class XGlobalsForVMStructs { - static XGlobalsForVMStructs _instance; - -public: - static XGlobalsForVMStructs* _instance_p; - - XGlobalsForVMStructs(); - - uint32_t* _XGlobalPhase; - - uint32_t* _XGlobalSeqNum; - - uintptr_t* _XAddressOffsetMask; - uintptr_t* _XAddressMetadataMask; - uintptr_t* _XAddressMetadataFinalizable; - uintptr_t* _XAddressGoodMask; - uintptr_t* _XAddressBadMask; - uintptr_t* _XAddressWeakBadMask; - - const int* _XObjectAlignmentSmallShift; - const int* _XObjectAlignmentSmall; -}; - -typedef XGranuleMap XGranuleMapForPageTable; -typedef XGranuleMap XGranuleMapForForwarding; -typedef XAttachedArray XAttachedArrayForForwarding; - -#define VM_STRUCTS_X(nonstatic_field, volatile_nonstatic_field, static_field) \ - static_field(XGlobalsForVMStructs, _instance_p, XGlobalsForVMStructs*) \ - nonstatic_field(XGlobalsForVMStructs, _XGlobalPhase, uint32_t*) \ - nonstatic_field(XGlobalsForVMStructs, _XGlobalSeqNum, uint32_t*) \ - nonstatic_field(XGlobalsForVMStructs, _XAddressOffsetMask, uintptr_t*) \ - nonstatic_field(XGlobalsForVMStructs, _XAddressMetadataMask, uintptr_t*) \ - nonstatic_field(XGlobalsForVMStructs, _XAddressMetadataFinalizable, uintptr_t*) \ - nonstatic_field(XGlobalsForVMStructs, _XAddressGoodMask, uintptr_t*) \ - nonstatic_field(XGlobalsForVMStructs, _XAddressBadMask, uintptr_t*) \ - nonstatic_field(XGlobalsForVMStructs, _XAddressWeakBadMask, uintptr_t*) \ - nonstatic_field(XGlobalsForVMStructs, _XObjectAlignmentSmallShift, const int*) \ - nonstatic_field(XGlobalsForVMStructs, _XObjectAlignmentSmall, const int*) \ - \ - nonstatic_field(XCollectedHeap, _heap, XHeap) \ - \ - nonstatic_field(XHeap, _page_allocator, XPageAllocator) \ - nonstatic_field(XHeap, _page_table, XPageTable) \ - nonstatic_field(XHeap, _forwarding_table, XForwardingTable) \ - nonstatic_field(XHeap, _relocate, XRelocate) \ - \ - nonstatic_field(XPage, _type, const uint8_t) \ - nonstatic_field(XPage, _seqnum, uint32_t) \ - nonstatic_field(XPage, _virtual, const XVirtualMemory) \ - volatile_nonstatic_field(XPage, _top, uintptr_t) \ - \ - nonstatic_field(XPageAllocator, _max_capacity, const size_t) \ - volatile_nonstatic_field(XPageAllocator, _capacity, size_t) \ - volatile_nonstatic_field(XPageAllocator, _used, size_t) \ - \ - nonstatic_field(XPageTable, _map, XGranuleMapForPageTable) \ - \ - nonstatic_field(XGranuleMapForPageTable, _map, XPage** const) \ - nonstatic_field(XGranuleMapForForwarding, _map, XForwarding** const) \ - \ - nonstatic_field(XForwardingTable, _map, XGranuleMapForForwarding) \ - \ - nonstatic_field(XVirtualMemory, _start, const uintptr_t) \ - nonstatic_field(XVirtualMemory, _end, const uintptr_t) \ - \ - nonstatic_field(XForwarding, _virtual, const XVirtualMemory) \ - nonstatic_field(XForwarding, _object_alignment_shift, const size_t) \ - volatile_nonstatic_field(XForwarding, _ref_count, int) \ - nonstatic_field(XForwarding, _entries, const XAttachedArrayForForwarding) \ - nonstatic_field(XForwardingEntry, _entry, uint64_t) \ - nonstatic_field(XAttachedArrayForForwarding, _length, const size_t) - -#define VM_INT_CONSTANTS_X(declare_constant, declare_constant_with_value) \ - declare_constant(XPhaseRelocate) \ - declare_constant(XPageTypeSmall) \ - declare_constant(XPageTypeMedium) \ - declare_constant(XPageTypeLarge) \ - declare_constant(XObjectAlignmentMediumShift) \ - declare_constant(XObjectAlignmentLargeShift) - -#define VM_LONG_CONSTANTS_X(declare_constant) \ - declare_constant(XGranuleSizeShift) \ - declare_constant(XPageSizeSmallShift) \ - declare_constant(XPageSizeMediumShift) \ - declare_constant(XAddressOffsetShift) \ - declare_constant(XAddressOffsetBits) \ - declare_constant(XAddressOffsetMask) \ - declare_constant(XAddressOffsetMax) - -#define VM_TYPES_X(declare_type, declare_toplevel_type, declare_integer_type) \ - declare_toplevel_type(XGlobalsForVMStructs) \ - declare_type(XCollectedHeap, CollectedHeap) \ - declare_toplevel_type(XHeap) \ - declare_toplevel_type(XRelocate) \ - declare_toplevel_type(XPage) \ - declare_toplevel_type(XPageAllocator) \ - declare_toplevel_type(XPageTable) \ - declare_toplevel_type(XAttachedArrayForForwarding) \ - declare_toplevel_type(XGranuleMapForPageTable) \ - declare_toplevel_type(XGranuleMapForForwarding) \ - declare_toplevel_type(XVirtualMemory) \ - declare_toplevel_type(XForwardingTable) \ - declare_toplevel_type(XForwarding) \ - declare_toplevel_type(XForwardingEntry) \ - declare_toplevel_type(XPhysicalMemoryManager) - -#endif // SHARE_GC_X_VMSTRUCTS_X_HPP diff --git a/src/hotspot/share/gc/x/xAbort.cpp b/src/hotspot/share/gc/x/xAbort.cpp deleted file mode 100644 index 11b8d840d22..00000000000 --- a/src/hotspot/share/gc/x/xAbort.cpp +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Copyright (c) 2021, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/x/xAbort.hpp" -#include "runtime/atomic.hpp" - -volatile bool XAbort::_should_abort = false; - -void XAbort::abort() { - Atomic::release_store_fence(&_should_abort, true); -} diff --git a/src/hotspot/share/gc/x/xAbort.hpp b/src/hotspot/share/gc/x/xAbort.hpp deleted file mode 100644 index 808a350584b..00000000000 --- a/src/hotspot/share/gc/x/xAbort.hpp +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2021, 2022, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XABORT_HPP -#define SHARE_GC_X_XABORT_HPP - -#include "memory/allStatic.hpp" - -class XAbort : public AllStatic { -private: - static volatile bool _should_abort; - -public: - static bool should_abort(); - static void abort(); -}; - -#endif // SHARE_GC_X_XABORT_HPP diff --git a/src/hotspot/share/gc/x/xAbort.inline.hpp b/src/hotspot/share/gc/x/xAbort.inline.hpp deleted file mode 100644 index 8ef1219330a..00000000000 --- a/src/hotspot/share/gc/x/xAbort.inline.hpp +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2021, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XABORT_INLINE_HPP -#define SHARE_GC_X_XABORT_INLINE_HPP - -#include "gc/x/xAbort.hpp" - -#include "runtime/atomic.hpp" - -inline bool XAbort::should_abort() { - return Atomic::load_acquire(&_should_abort); -} - -#endif // SHARE_GC_X_XABORT_INLINE_HPP diff --git a/src/hotspot/share/gc/x/xAddress.cpp b/src/hotspot/share/gc/x/xAddress.cpp deleted file mode 100644 index 33dffc662f1..00000000000 --- a/src/hotspot/share/gc/x/xAddress.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2015, 2019, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/x/xAddress.hpp" -#include "gc/x/xGlobals.hpp" - -void XAddress::set_good_mask(uintptr_t mask) { - XAddressGoodMask = mask; - XAddressBadMask = XAddressGoodMask ^ XAddressMetadataMask; - XAddressWeakBadMask = (XAddressGoodMask | XAddressMetadataRemapped | XAddressMetadataFinalizable) ^ XAddressMetadataMask; -} - -void XAddress::initialize() { - XAddressOffsetBits = XPlatformAddressOffsetBits(); - XAddressOffsetMask = (((uintptr_t)1 << XAddressOffsetBits) - 1) << XAddressOffsetShift; - XAddressOffsetMax = (uintptr_t)1 << XAddressOffsetBits; - - XAddressMetadataShift = XPlatformAddressMetadataShift(); - XAddressMetadataMask = (((uintptr_t)1 << XAddressMetadataBits) - 1) << XAddressMetadataShift; - - XAddressMetadataMarked0 = (uintptr_t)1 << (XAddressMetadataShift + 0); - XAddressMetadataMarked1 = (uintptr_t)1 << (XAddressMetadataShift + 1); - XAddressMetadataRemapped = (uintptr_t)1 << (XAddressMetadataShift + 2); - XAddressMetadataFinalizable = (uintptr_t)1 << (XAddressMetadataShift + 3); - - XAddressMetadataMarked = XAddressMetadataMarked0; - set_good_mask(XAddressMetadataRemapped); -} - -void XAddress::flip_to_marked() { - XAddressMetadataMarked ^= (XAddressMetadataMarked0 | XAddressMetadataMarked1); - set_good_mask(XAddressMetadataMarked); -} - -void XAddress::flip_to_remapped() { - set_good_mask(XAddressMetadataRemapped); -} diff --git a/src/hotspot/share/gc/x/xAddress.hpp b/src/hotspot/share/gc/x/xAddress.hpp deleted file mode 100644 index ff9d548f1af..00000000000 --- a/src/hotspot/share/gc/x/xAddress.hpp +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2015, 2022, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XADDRESS_HPP -#define SHARE_GC_X_XADDRESS_HPP - -#include "memory/allStatic.hpp" -#include "utilities/globalDefinitions.hpp" - -class XAddress : public AllStatic { - friend class XAddressTest; - -private: - static void set_good_mask(uintptr_t mask); - -public: - static void initialize(); - - static void flip_to_marked(); - static void flip_to_remapped(); - - static bool is_null(uintptr_t value); - static bool is_bad(uintptr_t value); - static bool is_good(uintptr_t value); - static bool is_good_or_null(uintptr_t value); - static bool is_weak_bad(uintptr_t value); - static bool is_weak_good(uintptr_t value); - static bool is_weak_good_or_null(uintptr_t value); - static bool is_marked(uintptr_t value); - static bool is_marked_or_null(uintptr_t value); - static bool is_finalizable(uintptr_t value); - static bool is_finalizable_good(uintptr_t value); - static bool is_remapped(uintptr_t value); - static bool is_in(uintptr_t value); - - static uintptr_t offset(uintptr_t value); - static uintptr_t good(uintptr_t value); - static uintptr_t good_or_null(uintptr_t value); - static uintptr_t finalizable_good(uintptr_t value); - static uintptr_t marked(uintptr_t value); - static uintptr_t marked0(uintptr_t value); - static uintptr_t marked1(uintptr_t value); - static uintptr_t remapped(uintptr_t value); - static uintptr_t remapped_or_null(uintptr_t value); -}; - -#endif // SHARE_GC_X_XADDRESS_HPP diff --git a/src/hotspot/share/gc/x/xAddress.inline.hpp b/src/hotspot/share/gc/x/xAddress.inline.hpp deleted file mode 100644 index 046ee10af00..00000000000 --- a/src/hotspot/share/gc/x/xAddress.inline.hpp +++ /dev/null @@ -1,137 +0,0 @@ -/* - * Copyright (c) 2015, 2019, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XADDRESS_INLINE_HPP -#define SHARE_GC_X_XADDRESS_INLINE_HPP - -#include "gc/x/xAddress.hpp" - -#include "gc/x/xGlobals.hpp" -#include "utilities/globalDefinitions.hpp" -#include "utilities/macros.hpp" -#include "utilities/powerOfTwo.hpp" - -inline bool XAddress::is_null(uintptr_t value) { - return value == 0; -} - -inline bool XAddress::is_bad(uintptr_t value) { - return value & XAddressBadMask; -} - -inline bool XAddress::is_good(uintptr_t value) { - return !is_bad(value) && !is_null(value); -} - -inline bool XAddress::is_good_or_null(uintptr_t value) { - // Checking if an address is "not bad" is an optimized version of - // checking if it's "good or null", which eliminates an explicit - // null check. However, the implicit null check only checks that - // the mask bits are zero, not that the entire address is zero. - // This means that an address without mask bits would pass through - // the barrier as if it was null. This should be harmless as such - // addresses should ever be passed through the barrier. - const bool result = !is_bad(value); - assert((is_good(value) || is_null(value)) == result, "Bad address"); - return result; -} - -inline bool XAddress::is_weak_bad(uintptr_t value) { - return value & XAddressWeakBadMask; -} - -inline bool XAddress::is_weak_good(uintptr_t value) { - return !is_weak_bad(value) && !is_null(value); -} - -inline bool XAddress::is_weak_good_or_null(uintptr_t value) { - return !is_weak_bad(value); -} - -inline bool XAddress::is_marked(uintptr_t value) { - return value & XAddressMetadataMarked; -} - -inline bool XAddress::is_marked_or_null(uintptr_t value) { - return is_marked(value) || is_null(value); -} - -inline bool XAddress::is_finalizable(uintptr_t value) { - return value & XAddressMetadataFinalizable; -} - -inline bool XAddress::is_finalizable_good(uintptr_t value) { - return is_finalizable(value) && is_good(value ^ XAddressMetadataFinalizable); -} - -inline bool XAddress::is_remapped(uintptr_t value) { - return value & XAddressMetadataRemapped; -} - -inline bool XAddress::is_in(uintptr_t value) { - // Check that exactly one non-offset bit is set - if (!is_power_of_2(value & ~XAddressOffsetMask)) { - return false; - } - - // Check that one of the non-finalizable metadata is set - return value & (XAddressMetadataMask & ~XAddressMetadataFinalizable); -} - -inline uintptr_t XAddress::offset(uintptr_t value) { - return value & XAddressOffsetMask; -} - -inline uintptr_t XAddress::good(uintptr_t value) { - return offset(value) | XAddressGoodMask; -} - -inline uintptr_t XAddress::good_or_null(uintptr_t value) { - return is_null(value) ? 0 : good(value); -} - -inline uintptr_t XAddress::finalizable_good(uintptr_t value) { - return offset(value) | XAddressMetadataFinalizable | XAddressGoodMask; -} - -inline uintptr_t XAddress::marked(uintptr_t value) { - return offset(value) | XAddressMetadataMarked; -} - -inline uintptr_t XAddress::marked0(uintptr_t value) { - return offset(value) | XAddressMetadataMarked0; -} - -inline uintptr_t XAddress::marked1(uintptr_t value) { - return offset(value) | XAddressMetadataMarked1; -} - -inline uintptr_t XAddress::remapped(uintptr_t value) { - return offset(value) | XAddressMetadataRemapped; -} - -inline uintptr_t XAddress::remapped_or_null(uintptr_t value) { - return is_null(value) ? 0 : remapped(value); -} - -#endif // SHARE_GC_X_XADDRESS_INLINE_HPP diff --git a/src/hotspot/share/gc/x/xAddressSpaceLimit.cpp b/src/hotspot/share/gc/x/xAddressSpaceLimit.cpp deleted file mode 100644 index 6d3c7a295df..00000000000 --- a/src/hotspot/share/gc/x/xAddressSpaceLimit.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2019, 2021, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/shared/gc_globals.hpp" -#include "gc/x/xAddressSpaceLimit.hpp" -#include "gc/x/xGlobals.hpp" -#include "runtime/globals.hpp" -#include "runtime/os.hpp" -#include "utilities/align.hpp" - -static size_t address_space_limit() { - size_t limit = 0; - - if (os::has_allocatable_memory_limit(&limit)) { - return limit; - } - - // No limit - return SIZE_MAX; -} - -size_t XAddressSpaceLimit::mark_stack() { - // Allow mark stacks to occupy 10% of the address space - const size_t limit = address_space_limit() / 10; - return align_up(limit, XMarkStackSpaceExpandSize); -} - -size_t XAddressSpaceLimit::heap_view() { - // Allow all heap views to occupy 50% of the address space - const size_t limit = address_space_limit() / MaxVirtMemFraction / XHeapViews; - return align_up(limit, XGranuleSize); -} diff --git a/src/hotspot/share/gc/x/xAddressSpaceLimit.hpp b/src/hotspot/share/gc/x/xAddressSpaceLimit.hpp deleted file mode 100644 index 9a3fcc27a29..00000000000 --- a/src/hotspot/share/gc/x/xAddressSpaceLimit.hpp +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2019, 2022, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XADDRESSSPACELIMIT_HPP -#define SHARE_GC_X_XADDRESSSPACELIMIT_HPP - -#include "memory/allStatic.hpp" -#include "utilities/globalDefinitions.hpp" - -class XAddressSpaceLimit : public AllStatic { -public: - static size_t mark_stack(); - static size_t heap_view(); -}; - -#endif // SHARE_GC_X_XADDRESSSPACELIMIT_HPP diff --git a/src/hotspot/share/gc/x/xAllocationFlags.hpp b/src/hotspot/share/gc/x/xAllocationFlags.hpp deleted file mode 100644 index 307d68c65ac..00000000000 --- a/src/hotspot/share/gc/x/xAllocationFlags.hpp +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2017, 2020, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XALLOCATIONFLAGS_HPP -#define SHARE_GC_X_XALLOCATIONFLAGS_HPP - -#include "gc/x/xBitField.hpp" -#include "memory/allocation.hpp" - -// -// Allocation flags layout -// ----------------------- -// -// 7 2 1 0 -// +-----+-+-+-+ -// |00000|1|1|1| -// +-----+-+-+-+ -// | | | | -// | | | * 0-0 Non-Blocking Flag (1-bit) -// | | | -// | | * 1-1 Worker Relocation Flag (1-bit) -// | | -// | * 2-2 Low Address Flag (1-bit) -// | -// * 7-3 Unused (5-bits) -// - -class XAllocationFlags { -private: - typedef XBitField field_non_blocking; - typedef XBitField field_worker_relocation; - typedef XBitField field_low_address; - - uint8_t _flags; - -public: - XAllocationFlags() : - _flags(0) {} - - void set_non_blocking() { - _flags |= field_non_blocking::encode(true); - } - - void set_worker_relocation() { - _flags |= field_worker_relocation::encode(true); - } - - void set_low_address() { - _flags |= field_low_address::encode(true); - } - - bool non_blocking() const { - return field_non_blocking::decode(_flags); - } - - bool worker_relocation() const { - return field_worker_relocation::decode(_flags); - } - - bool low_address() const { - return field_low_address::decode(_flags); - } -}; - -#endif // SHARE_GC_X_XALLOCATIONFLAGS_HPP diff --git a/src/hotspot/share/gc/x/xArguments.cpp b/src/hotspot/share/gc/x/xArguments.cpp deleted file mode 100644 index 13cb302d14a..00000000000 --- a/src/hotspot/share/gc/x/xArguments.cpp +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright (c) 2017, 2021, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/x/xAddressSpaceLimit.hpp" -#include "gc/x/xArguments.hpp" -#include "gc/x/xCollectedHeap.hpp" -#include "gc/x/xGlobals.hpp" -#include "gc/x/xHeuristics.hpp" -#include "gc/shared/gcArguments.hpp" -#include "runtime/globals.hpp" -#include "runtime/globals_extension.hpp" -#include "runtime/java.hpp" - -void XArguments::initialize_alignments() { - SpaceAlignment = XGranuleSize; - HeapAlignment = SpaceAlignment; -} - -void XArguments::initialize_heap_flags_and_sizes() { - // Nothing extra to do -} - -void XArguments::initialize() { - warning("Non-generational ZGC is deprecated."); - - // Check mark stack size - const size_t mark_stack_space_limit = XAddressSpaceLimit::mark_stack(); - if (ZMarkStackSpaceLimit > mark_stack_space_limit) { - if (!FLAG_IS_DEFAULT(ZMarkStackSpaceLimit)) { - vm_exit_during_initialization("ZMarkStackSpaceLimit too large for limited address space"); - } - FLAG_SET_DEFAULT(ZMarkStackSpaceLimit, mark_stack_space_limit); - } - - // Enable NUMA by default - if (FLAG_IS_DEFAULT(UseNUMA)) { - FLAG_SET_DEFAULT(UseNUMA, true); - } - - if (FLAG_IS_DEFAULT(ZFragmentationLimit)) { - FLAG_SET_DEFAULT(ZFragmentationLimit, 25.0); - } - - // Select number of parallel threads - if (FLAG_IS_DEFAULT(ParallelGCThreads)) { - FLAG_SET_DEFAULT(ParallelGCThreads, XHeuristics::nparallel_workers()); - } - - if (ParallelGCThreads == 0) { - vm_exit_during_initialization("The flag -XX:+UseZGC can not be combined with -XX:ParallelGCThreads=0"); - } - - // Select number of concurrent threads - if (FLAG_IS_DEFAULT(ConcGCThreads)) { - FLAG_SET_DEFAULT(ConcGCThreads, XHeuristics::nconcurrent_workers()); - } - - if (ConcGCThreads == 0) { - vm_exit_during_initialization("The flag -XX:+UseZGC can not be combined with -XX:ConcGCThreads=0"); - } - - // Large page size must match granule size - if (!FLAG_IS_DEFAULT(LargePageSizeInBytes) && LargePageSizeInBytes != XGranuleSize) { - vm_exit_during_initialization(err_msg("Incompatible -XX:LargePageSizeInBytes, only " - SIZE_FORMAT "M large pages are supported by ZGC", - XGranuleSize / M)); - } - - // The heuristics used when UseDynamicNumberOfGCThreads is - // enabled defaults to using a ZAllocationSpikeTolerance of 1. - if (UseDynamicNumberOfGCThreads && FLAG_IS_DEFAULT(ZAllocationSpikeTolerance)) { - FLAG_SET_DEFAULT(ZAllocationSpikeTolerance, 1); - } - -#ifdef COMPILER2 - // Enable loop strip mining by default - if (FLAG_IS_DEFAULT(UseCountedLoopSafepoints)) { - FLAG_SET_DEFAULT(UseCountedLoopSafepoints, true); - if (FLAG_IS_DEFAULT(LoopStripMiningIter)) { - FLAG_SET_DEFAULT(LoopStripMiningIter, 1000); - } - } -#endif - - // CompressedOops not supported - FLAG_SET_DEFAULT(UseCompressedOops, false); - - // Verification before startup and after exit not (yet) supported - FLAG_SET_DEFAULT(VerifyDuringStartup, false); - FLAG_SET_DEFAULT(VerifyBeforeExit, false); - - if (VerifyBeforeGC || VerifyDuringGC || VerifyAfterGC) { - FLAG_SET_DEFAULT(ZVerifyRoots, true); - FLAG_SET_DEFAULT(ZVerifyObjects, true); - } -} - -size_t XArguments::heap_virtual_to_physical_ratio() { - return XHeapViews * XVirtualToPhysicalRatio; -} - -CollectedHeap* XArguments::create_heap() { - return new XCollectedHeap(); -} - -bool XArguments::is_supported() { - return is_os_supported(); -} diff --git a/src/hotspot/share/gc/x/xArguments.hpp b/src/hotspot/share/gc/x/xArguments.hpp deleted file mode 100644 index 196dd994cad..00000000000 --- a/src/hotspot/share/gc/x/xArguments.hpp +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2017, 2020, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XARGUMENTS_HPP -#define SHARE_GC_X_XARGUMENTS_HPP - -#include "gc/shared/gcArguments.hpp" - -class CollectedHeap; - -class XArguments : AllStatic { -public: - static void initialize_alignments(); - static void initialize_heap_flags_and_sizes(); - static void initialize(); - static size_t heap_virtual_to_physical_ratio(); - static CollectedHeap* create_heap(); - - static bool is_supported(); - - static bool is_os_supported(); -}; - -#endif // SHARE_GC_X_XARGUMENTS_HPP diff --git a/src/hotspot/share/gc/x/xArray.hpp b/src/hotspot/share/gc/x/xArray.hpp deleted file mode 100644 index b0b4b5bd81e..00000000000 --- a/src/hotspot/share/gc/x/xArray.hpp +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2015, 2020, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XARRAY_HPP -#define SHARE_GC_X_XARRAY_HPP - -#include "memory/allocation.hpp" -#include "utilities/growableArray.hpp" - -template using XArray = GrowableArrayCHeap; - -template -class XArrayIteratorImpl : public StackObj { -private: - const T* _next; - const T* const _end; - - bool next_serial(T* elem); - bool next_parallel(T* elem); - -public: - XArrayIteratorImpl(const T* array, size_t length); - XArrayIteratorImpl(const XArray* array); - - bool next(T* elem); -}; - -template using XArrayIterator = XArrayIteratorImpl; -template using XArrayParallelIterator = XArrayIteratorImpl; - -#endif // SHARE_GC_X_XARRAY_HPP diff --git a/src/hotspot/share/gc/x/xArray.inline.hpp b/src/hotspot/share/gc/x/xArray.inline.hpp deleted file mode 100644 index 721e3130095..00000000000 --- a/src/hotspot/share/gc/x/xArray.inline.hpp +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2015, 2020, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XARRAY_INLINE_HPP -#define SHARE_GC_X_XARRAY_INLINE_HPP - -#include "gc/x/xArray.hpp" - -#include "runtime/atomic.hpp" - -template -inline bool XArrayIteratorImpl::next_serial(T* elem) { - if (_next == _end) { - return false; - } - - *elem = *_next; - _next++; - - return true; -} - -template -inline bool XArrayIteratorImpl::next_parallel(T* elem) { - const T* old_next = Atomic::load(&_next); - - for (;;) { - if (old_next == _end) { - return false; - } - - const T* const new_next = old_next + 1; - const T* const prev_next = Atomic::cmpxchg(&_next, old_next, new_next); - if (prev_next == old_next) { - *elem = *old_next; - return true; - } - - old_next = prev_next; - } -} - -template -inline XArrayIteratorImpl::XArrayIteratorImpl(const T* array, size_t length) : - _next(array), - _end(array + length) {} - -template -inline XArrayIteratorImpl::XArrayIteratorImpl(const XArray* array) : - XArrayIteratorImpl(array->is_empty() ? nullptr : array->adr_at(0), array->length()) {} - -template -inline bool XArrayIteratorImpl::next(T* elem) { - if (Parallel) { - return next_parallel(elem); - } else { - return next_serial(elem); - } -} - -#endif // SHARE_GC_X_XARRAY_INLINE_HPP diff --git a/src/hotspot/share/gc/x/xAttachedArray.hpp b/src/hotspot/share/gc/x/xAttachedArray.hpp deleted file mode 100644 index f039f602aab..00000000000 --- a/src/hotspot/share/gc/x/xAttachedArray.hpp +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2019, 2021, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XATTACHEDARRAY_HPP -#define SHARE_GC_X_XATTACHEDARRAY_HPP - -#include "utilities/globalDefinitions.hpp" - -class VMStructs; - -template -class XAttachedArray { - friend class ::VMStructs; - -private: - const size_t _length; - - static size_t object_size(); - static size_t array_size(size_t length); - -public: - template - static void* alloc(Allocator* allocator, size_t length); - - static void* alloc(size_t length); - static void free(ObjectT* obj); - - XAttachedArray(size_t length); - - size_t length() const; - ArrayT* operator()(const ObjectT* obj) const; -}; - -#endif // SHARE_GC_X_XATTACHEDARRAY_HPP diff --git a/src/hotspot/share/gc/x/xAttachedArray.inline.hpp b/src/hotspot/share/gc/x/xAttachedArray.inline.hpp deleted file mode 100644 index ba10de99673..00000000000 --- a/src/hotspot/share/gc/x/xAttachedArray.inline.hpp +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (c) 2019, 2020, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XATTACHEDARRAY_INLINE_HPP -#define SHARE_GC_X_XATTACHEDARRAY_INLINE_HPP - -#include "gc/x/xAttachedArray.hpp" - -#include "memory/allocation.hpp" -#include "utilities/align.hpp" - -template -inline size_t XAttachedArray::object_size() { - return align_up(sizeof(ObjectT), sizeof(ArrayT)); -} - -template -inline size_t XAttachedArray::array_size(size_t length) { - return sizeof(ArrayT) * length; -} - -template -template -inline void* XAttachedArray::alloc(Allocator* allocator, size_t length) { - // Allocate memory for object and array - const size_t size = object_size() + array_size(length); - void* const addr = allocator->alloc(size); - - // Placement new array - void* const array_addr = reinterpret_cast(addr) + object_size(); - ::new (array_addr) ArrayT[length]; - - // Return pointer to object - return addr; -} - -template -inline void* XAttachedArray::alloc(size_t length) { - struct Allocator { - void* alloc(size_t size) const { - return AllocateHeap(size, mtGC); - } - } allocator; - return alloc(&allocator, length); -} - -template -inline void XAttachedArray::free(ObjectT* obj) { - FreeHeap(obj); -} - -template -inline XAttachedArray::XAttachedArray(size_t length) : - _length(length) {} - -template -inline size_t XAttachedArray::length() const { - return _length; -} - -template -inline ArrayT* XAttachedArray::operator()(const ObjectT* obj) const { - return reinterpret_cast(reinterpret_cast(obj) + object_size()); -} - -#endif // SHARE_GC_X_XATTACHEDARRAY_INLINE_HPP diff --git a/src/hotspot/share/gc/x/xBarrier.cpp b/src/hotspot/share/gc/x/xBarrier.cpp deleted file mode 100644 index 726950092b2..00000000000 --- a/src/hotspot/share/gc/x/xBarrier.cpp +++ /dev/null @@ -1,275 +0,0 @@ -/* - * Copyright (c) 2015, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "classfile/javaClasses.hpp" -#include "gc/x/xBarrier.inline.hpp" -#include "gc/x/xHeap.inline.hpp" -#include "gc/x/xOop.inline.hpp" -#include "gc/x/xThread.inline.hpp" -#include "memory/iterator.inline.hpp" -#include "oops/oop.inline.hpp" -#include "runtime/safepoint.hpp" -#include "utilities/debug.hpp" - -template -bool XBarrier::should_mark_through(uintptr_t addr) { - // Finalizable marked oops can still exists on the heap after marking - // has completed, in which case we just want to convert this into a - // good oop and not push it on the mark stack. - if (!during_mark()) { - assert(XAddress::is_marked(addr), "Should be marked"); - assert(XAddress::is_finalizable(addr), "Should be finalizable"); - return false; - } - - // During marking, we mark through already marked oops to avoid having - // some large part of the object graph hidden behind a pushed, but not - // yet flushed, entry on a mutator mark stack. Always marking through - // allows the GC workers to proceed through the object graph even if a - // mutator touched an oop first, which in turn will reduce the risk of - // having to flush mark stacks multiple times to terminate marking. - // - // However, when doing finalizable marking we don't always want to mark - // through. First, marking through an already strongly marked oop would - // be wasteful, since we will then proceed to do finalizable marking on - // an object which is, or will be, marked strongly. Second, marking - // through an already finalizable marked oop would also be wasteful, - // since such oops can never end up on a mutator mark stack and can - // therefore not hide some part of the object graph from GC workers. - if (finalizable) { - return !XAddress::is_marked(addr); - } - - // Mark through - return true; -} - -template -uintptr_t XBarrier::mark(uintptr_t addr) { - uintptr_t good_addr; - - if (XAddress::is_marked(addr)) { - // Already marked, but try to mark though anyway - good_addr = XAddress::good(addr); - } else if (XAddress::is_remapped(addr)) { - // Already remapped, but also needs to be marked - good_addr = XAddress::good(addr); - } else { - // Needs to be both remapped and marked - good_addr = remap(addr); - } - - // Mark - if (should_mark_through(addr)) { - XHeap::heap()->mark_object(good_addr); - } - - if (finalizable) { - // Make the oop finalizable marked/good, instead of normal marked/good. - // This is needed because an object might first becomes finalizable - // marked by the GC, and then loaded by a mutator thread. In this case, - // the mutator thread must be able to tell that the object needs to be - // strongly marked. The finalizable bit in the oop exists to make sure - // that a load of a finalizable marked oop will fall into the barrier - // slow path so that we can mark the object as strongly reachable. - return XAddress::finalizable_good(good_addr); - } - - return good_addr; -} - -uintptr_t XBarrier::remap(uintptr_t addr) { - assert(!XAddress::is_good(addr), "Should not be good"); - assert(!XAddress::is_weak_good(addr), "Should not be weak good"); - return XHeap::heap()->remap_object(addr); -} - -uintptr_t XBarrier::relocate(uintptr_t addr) { - assert(!XAddress::is_good(addr), "Should not be good"); - assert(!XAddress::is_weak_good(addr), "Should not be weak good"); - return XHeap::heap()->relocate_object(addr); -} - -uintptr_t XBarrier::relocate_or_mark(uintptr_t addr) { - return during_relocate() ? relocate(addr) : mark(addr); -} - -uintptr_t XBarrier::relocate_or_mark_no_follow(uintptr_t addr) { - return during_relocate() ? relocate(addr) : mark(addr); -} - -uintptr_t XBarrier::relocate_or_remap(uintptr_t addr) { - return during_relocate() ? relocate(addr) : remap(addr); -} - -// -// Load barrier -// -uintptr_t XBarrier::load_barrier_on_oop_slow_path(uintptr_t addr) { - return relocate_or_mark(addr); -} - -uintptr_t XBarrier::load_barrier_on_invisible_root_oop_slow_path(uintptr_t addr) { - return relocate_or_mark_no_follow(addr); -} - -void XBarrier::load_barrier_on_oop_fields(oop o) { - assert(XAddress::is_good(XOop::to_address(o)), "Should be good"); - XLoadBarrierOopClosure cl; - o->oop_iterate(&cl); -} - -// -// Weak load barrier -// -uintptr_t XBarrier::weak_load_barrier_on_oop_slow_path(uintptr_t addr) { - return XAddress::is_weak_good(addr) ? XAddress::good(addr) : relocate_or_remap(addr); -} - -uintptr_t XBarrier::weak_load_barrier_on_weak_oop_slow_path(uintptr_t addr) { - const uintptr_t good_addr = weak_load_barrier_on_oop_slow_path(addr); - if (XHeap::heap()->is_object_strongly_live(good_addr)) { - return good_addr; - } - - // Not strongly live - return 0; -} - -uintptr_t XBarrier::weak_load_barrier_on_phantom_oop_slow_path(uintptr_t addr) { - const uintptr_t good_addr = weak_load_barrier_on_oop_slow_path(addr); - if (XHeap::heap()->is_object_live(good_addr)) { - return good_addr; - } - - // Not live - return 0; -} - -// -// Keep alive barrier -// -uintptr_t XBarrier::keep_alive_barrier_on_oop_slow_path(uintptr_t addr) { - assert(during_mark(), "Invalid phase"); - - // Mark - return mark(addr); -} - -uintptr_t XBarrier::keep_alive_barrier_on_weak_oop_slow_path(uintptr_t addr) { - assert(XResurrection::is_blocked(), "This operation is only valid when resurrection is blocked"); - const uintptr_t good_addr = weak_load_barrier_on_oop_slow_path(addr); - assert(XHeap::heap()->is_object_strongly_live(good_addr), "Should be live"); - return good_addr; -} - -uintptr_t XBarrier::keep_alive_barrier_on_phantom_oop_slow_path(uintptr_t addr) { - assert(XResurrection::is_blocked(), "This operation is only valid when resurrection is blocked"); - const uintptr_t good_addr = weak_load_barrier_on_oop_slow_path(addr); - assert(XHeap::heap()->is_object_live(good_addr), "Should be live"); - return good_addr; -} - -// -// Mark barrier -// -uintptr_t XBarrier::mark_barrier_on_oop_slow_path(uintptr_t addr) { - assert(during_mark(), "Invalid phase"); - assert(XThread::is_worker(), "Invalid thread"); - - // Mark - return mark(addr); -} - -uintptr_t XBarrier::mark_barrier_on_finalizable_oop_slow_path(uintptr_t addr) { - assert(during_mark(), "Invalid phase"); - assert(XThread::is_worker(), "Invalid thread"); - - // Mark - return mark(addr); -} - -// -// Narrow oop variants, never used. -// -oop XBarrier::load_barrier_on_oop_field(volatile narrowOop* p) { - ShouldNotReachHere(); - return nullptr; -} - -oop XBarrier::load_barrier_on_oop_field_preloaded(volatile narrowOop* p, oop o) { - ShouldNotReachHere(); - return nullptr; -} - -void XBarrier::load_barrier_on_oop_array(volatile narrowOop* p, size_t length) { - ShouldNotReachHere(); -} - -oop XBarrier::load_barrier_on_weak_oop_field_preloaded(volatile narrowOop* p, oop o) { - ShouldNotReachHere(); - return nullptr; -} - -oop XBarrier::load_barrier_on_phantom_oop_field_preloaded(volatile narrowOop* p, oop o) { - ShouldNotReachHere(); - return nullptr; -} - -oop XBarrier::weak_load_barrier_on_oop_field_preloaded(volatile narrowOop* p, oop o) { - ShouldNotReachHere(); - return nullptr; -} - -oop XBarrier::weak_load_barrier_on_weak_oop_field_preloaded(volatile narrowOop* p, oop o) { - ShouldNotReachHere(); - return nullptr; -} - -oop XBarrier::weak_load_barrier_on_phantom_oop_field_preloaded(volatile narrowOop* p, oop o) { - ShouldNotReachHere(); - return nullptr; -} - -#ifdef ASSERT - -// ON_WEAK barriers should only ever be applied to j.l.r.Reference.referents. -void XBarrier::verify_on_weak(volatile oop* referent_addr) { - if (referent_addr != nullptr) { - uintptr_t base = (uintptr_t)referent_addr - java_lang_ref_Reference::referent_offset(); - oop obj = cast_to_oop(base); - assert(oopDesc::is_oop(obj), "Verification failed for: ref " PTR_FORMAT " obj: " PTR_FORMAT, (uintptr_t)referent_addr, base); - assert(java_lang_ref_Reference::is_referent_field(obj, java_lang_ref_Reference::referent_offset()), "Sanity"); - } -} - -#endif - -void XLoadBarrierOopClosure::do_oop(oop* p) { - XBarrier::load_barrier_on_oop_field(p); -} - -void XLoadBarrierOopClosure::do_oop(narrowOop* p) { - ShouldNotReachHere(); -} diff --git a/src/hotspot/share/gc/x/xBarrier.hpp b/src/hotspot/share/gc/x/xBarrier.hpp deleted file mode 100644 index e2ef210d7d2..00000000000 --- a/src/hotspot/share/gc/x/xBarrier.hpp +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright (c) 2015, 2022, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XBARRIER_HPP -#define SHARE_GC_X_XBARRIER_HPP - -#include "memory/allStatic.hpp" -#include "memory/iterator.hpp" -#include "oops/oop.hpp" - -typedef bool (*XBarrierFastPath)(uintptr_t); -typedef uintptr_t (*XBarrierSlowPath)(uintptr_t); - -class XBarrier : public AllStatic { -private: - static const bool GCThread = true; - static const bool AnyThread = false; - - static const bool Follow = true; - static const bool DontFollow = false; - - static const bool Strong = false; - static const bool Finalizable = true; - - static const bool Publish = true; - static const bool Overflow = false; - - template static void self_heal(volatile oop* p, uintptr_t addr, uintptr_t heal_addr); - - template static oop barrier(volatile oop* p, oop o); - template static oop weak_barrier(volatile oop* p, oop o); - template static void root_barrier(oop* p, oop o); - - static bool is_good_or_null_fast_path(uintptr_t addr); - static bool is_weak_good_or_null_fast_path(uintptr_t addr); - static bool is_marked_or_null_fast_path(uintptr_t addr); - - static bool during_mark(); - static bool during_relocate(); - template static bool should_mark_through(uintptr_t addr); - template static uintptr_t mark(uintptr_t addr); - static uintptr_t remap(uintptr_t addr); - static uintptr_t relocate(uintptr_t addr); - static uintptr_t relocate_or_mark(uintptr_t addr); - static uintptr_t relocate_or_mark_no_follow(uintptr_t addr); - static uintptr_t relocate_or_remap(uintptr_t addr); - - static uintptr_t load_barrier_on_oop_slow_path(uintptr_t addr); - static uintptr_t load_barrier_on_invisible_root_oop_slow_path(uintptr_t addr); - - static uintptr_t weak_load_barrier_on_oop_slow_path(uintptr_t addr); - static uintptr_t weak_load_barrier_on_weak_oop_slow_path(uintptr_t addr); - static uintptr_t weak_load_barrier_on_phantom_oop_slow_path(uintptr_t addr); - - static uintptr_t keep_alive_barrier_on_oop_slow_path(uintptr_t addr); - static uintptr_t keep_alive_barrier_on_weak_oop_slow_path(uintptr_t addr); - static uintptr_t keep_alive_barrier_on_phantom_oop_slow_path(uintptr_t addr); - - static uintptr_t mark_barrier_on_oop_slow_path(uintptr_t addr); - static uintptr_t mark_barrier_on_finalizable_oop_slow_path(uintptr_t addr); - - static void verify_on_weak(volatile oop* referent_addr) NOT_DEBUG_RETURN; - -public: - // Load barrier - static oop load_barrier_on_oop(oop o); - static oop load_barrier_on_oop_field(volatile oop* p); - static oop load_barrier_on_oop_field_preloaded(volatile oop* p, oop o); - static void load_barrier_on_oop_array(volatile oop* p, size_t length); - static void load_barrier_on_oop_fields(oop o); - static oop load_barrier_on_weak_oop_field_preloaded(volatile oop* p, oop o); - static oop load_barrier_on_phantom_oop_field_preloaded(volatile oop* p, oop o); - static void load_barrier_on_root_oop_field(oop* p); - static void load_barrier_on_invisible_root_oop_field(oop* p); - - // Weak load barrier - static oop weak_load_barrier_on_oop_field(volatile oop* p); - static oop weak_load_barrier_on_oop_field_preloaded(volatile oop* p, oop o); - static oop weak_load_barrier_on_weak_oop(oop o); - static oop weak_load_barrier_on_weak_oop_field_preloaded(volatile oop* p, oop o); - static oop weak_load_barrier_on_phantom_oop(oop o); - static oop weak_load_barrier_on_phantom_oop_field_preloaded(volatile oop* p, oop o); - - // Is alive barrier - static bool is_alive_barrier_on_weak_oop(oop o); - static bool is_alive_barrier_on_phantom_oop(oop o); - - // Keep alive barrier - static void keep_alive_barrier_on_oop(oop o); - static void keep_alive_barrier_on_weak_oop_field(volatile oop* p); - static void keep_alive_barrier_on_phantom_oop_field(volatile oop* p); - static void keep_alive_barrier_on_phantom_root_oop_field(oop* p); - - // Mark barrier - static void mark_barrier_on_oop_field(volatile oop* p, bool finalizable); - static void mark_barrier_on_oop_array(volatile oop* p, size_t length, bool finalizable); - - // Narrow oop variants, never used. - static oop load_barrier_on_oop_field(volatile narrowOop* p); - static oop load_barrier_on_oop_field_preloaded(volatile narrowOop* p, oop o); - static void load_barrier_on_oop_array(volatile narrowOop* p, size_t length); - static oop load_barrier_on_weak_oop_field_preloaded(volatile narrowOop* p, oop o); - static oop load_barrier_on_phantom_oop_field_preloaded(volatile narrowOop* p, oop o); - static oop weak_load_barrier_on_oop_field_preloaded(volatile narrowOop* p, oop o); - static oop weak_load_barrier_on_weak_oop_field_preloaded(volatile narrowOop* p, oop o); - static oop weak_load_barrier_on_phantom_oop_field_preloaded(volatile narrowOop* p, oop o); -}; - -class XLoadBarrierOopClosure : public BasicOopIterateClosure { -public: - virtual void do_oop(oop* p); - virtual void do_oop(narrowOop* p); -}; - -#endif // SHARE_GC_X_XBARRIER_HPP diff --git a/src/hotspot/share/gc/x/xBarrier.inline.hpp b/src/hotspot/share/gc/x/xBarrier.inline.hpp deleted file mode 100644 index 2319bda4d74..00000000000 --- a/src/hotspot/share/gc/x/xBarrier.inline.hpp +++ /dev/null @@ -1,394 +0,0 @@ -/* - * Copyright (c) 2015, 2022, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XBARRIER_INLINE_HPP -#define SHARE_GC_X_XBARRIER_INLINE_HPP - -#include "gc/x/xBarrier.hpp" - -#include "code/codeCache.hpp" -#include "gc/x/xAddress.inline.hpp" -#include "gc/x/xOop.inline.hpp" -#include "gc/x/xResurrection.inline.hpp" -#include "oops/oop.hpp" -#include "runtime/atomic.hpp" -#include "runtime/continuation.hpp" - -// A self heal must always "upgrade" the address metadata bits in -// accordance with the metadata bits state machine, which has the -// valid state transitions as described below (where N is the GC -// cycle). -// -// Note the subtleness of overlapping GC cycles. Specifically that -// oops are colored Remapped(N) starting at relocation N and ending -// at marking N + 1. -// -// +--- Mark Start -// | +--- Mark End -// | | +--- Relocate Start -// | | | +--- Relocate End -// | | | | -// Marked |---N---|--N+1--|--N+2--|---- -// Finalizable |---N---|--N+1--|--N+2--|---- -// Remapped ----|---N---|--N+1--|--N+2--| -// -// VALID STATE TRANSITIONS -// -// Marked(N) -> Remapped(N) -// -> Marked(N + 1) -// -> Finalizable(N + 1) -// -// Finalizable(N) -> Marked(N) -// -> Remapped(N) -// -> Marked(N + 1) -// -> Finalizable(N + 1) -// -// Remapped(N) -> Marked(N + 1) -// -> Finalizable(N + 1) -// -// PHASE VIEW -// -// XPhaseMark -// Load & Mark -// Marked(N) <- Marked(N - 1) -// <- Finalizable(N - 1) -// <- Remapped(N - 1) -// <- Finalizable(N) -// -// Mark(Finalizable) -// Finalizable(N) <- Marked(N - 1) -// <- Finalizable(N - 1) -// <- Remapped(N - 1) -// -// Load(AS_NO_KEEPALIVE) -// Remapped(N - 1) <- Marked(N - 1) -// <- Finalizable(N - 1) -// -// XPhaseMarkCompleted (Resurrection blocked) -// Load & Load(ON_WEAK/PHANTOM_OOP_REF | AS_NO_KEEPALIVE) & KeepAlive -// Marked(N) <- Marked(N - 1) -// <- Finalizable(N - 1) -// <- Remapped(N - 1) -// <- Finalizable(N) -// -// Load(ON_STRONG_OOP_REF | AS_NO_KEEPALIVE) -// Remapped(N - 1) <- Marked(N - 1) -// <- Finalizable(N - 1) -// -// XPhaseMarkCompleted (Resurrection unblocked) -// Load -// Marked(N) <- Finalizable(N) -// -// XPhaseRelocate -// Load & Load(AS_NO_KEEPALIVE) -// Remapped(N) <- Marked(N) -// <- Finalizable(N) - -template -inline void XBarrier::self_heal(volatile oop* p, uintptr_t addr, uintptr_t heal_addr) { - if (heal_addr == 0) { - // Never heal with null since it interacts badly with reference processing. - // A mutator clearing an oop would be similar to calling Reference.clear(), - // which would make the reference non-discoverable or silently dropped - // by the reference processor. - return; - } - - assert(!fast_path(addr), "Invalid self heal"); - assert(fast_path(heal_addr), "Invalid self heal"); - - for (;;) { - // Heal - const uintptr_t prev_addr = Atomic::cmpxchg((volatile uintptr_t*)p, addr, heal_addr, memory_order_relaxed); - if (prev_addr == addr) { - // Success - return; - } - - if (fast_path(prev_addr)) { - // Must not self heal - return; - } - - // The oop location was healed by another barrier, but still needs upgrading. - // Re-apply healing to make sure the oop is not left with weaker (remapped or - // finalizable) metadata bits than what this barrier tried to apply. - assert(XAddress::offset(prev_addr) == XAddress::offset(heal_addr), "Invalid offset"); - addr = prev_addr; - } -} - -template -inline oop XBarrier::barrier(volatile oop* p, oop o) { - const uintptr_t addr = XOop::to_address(o); - - // Fast path - if (fast_path(addr)) { - return XOop::from_address(addr); - } - - // Slow path - const uintptr_t good_addr = slow_path(addr); - - if (p != nullptr) { - self_heal(p, addr, good_addr); - } - - return XOop::from_address(good_addr); -} - -template -inline oop XBarrier::weak_barrier(volatile oop* p, oop o) { - const uintptr_t addr = XOop::to_address(o); - - // Fast path - if (fast_path(addr)) { - // Return the good address instead of the weak good address - // to ensure that the currently active heap view is used. - return XOop::from_address(XAddress::good_or_null(addr)); - } - - // Slow path - const uintptr_t good_addr = slow_path(addr); - - if (p != nullptr) { - // The slow path returns a good/marked address or null, but we never mark - // oops in a weak load barrier so we always heal with the remapped address. - self_heal(p, addr, XAddress::remapped_or_null(good_addr)); - } - - return XOop::from_address(good_addr); -} - -template -inline void XBarrier::root_barrier(oop* p, oop o) { - const uintptr_t addr = XOop::to_address(o); - - // Fast path - if (fast_path(addr)) { - return; - } - - // Slow path - const uintptr_t good_addr = slow_path(addr); - - // Non-atomic healing helps speed up root scanning. This is safe to do - // since we are always healing roots in a safepoint, or under a lock, - // which ensures we are never racing with mutators modifying roots while - // we are healing them. It's also safe in case multiple GC threads try - // to heal the same root if it is aligned, since they would always heal - // the root in the same way and it does not matter in which order it - // happens. For misaligned oops, there needs to be mutual exclusion. - *p = XOop::from_address(good_addr); -} - -inline bool XBarrier::is_good_or_null_fast_path(uintptr_t addr) { - return XAddress::is_good_or_null(addr); -} - -inline bool XBarrier::is_weak_good_or_null_fast_path(uintptr_t addr) { - return XAddress::is_weak_good_or_null(addr); -} - -inline bool XBarrier::is_marked_or_null_fast_path(uintptr_t addr) { - return XAddress::is_marked_or_null(addr); -} - -inline bool XBarrier::during_mark() { - return XGlobalPhase == XPhaseMark; -} - -inline bool XBarrier::during_relocate() { - return XGlobalPhase == XPhaseRelocate; -} - -// -// Load barrier -// -inline oop XBarrier::load_barrier_on_oop(oop o) { - return load_barrier_on_oop_field_preloaded((oop*)nullptr, o); -} - -inline oop XBarrier::load_barrier_on_oop_field(volatile oop* p) { - const oop o = Atomic::load(p); - return load_barrier_on_oop_field_preloaded(p, o); -} - -inline oop XBarrier::load_barrier_on_oop_field_preloaded(volatile oop* p, oop o) { - return barrier(p, o); -} - -inline void XBarrier::load_barrier_on_oop_array(volatile oop* p, size_t length) { - for (volatile const oop* const end = p + length; p < end; p++) { - load_barrier_on_oop_field(p); - } -} - -inline oop XBarrier::load_barrier_on_weak_oop_field_preloaded(volatile oop* p, oop o) { - verify_on_weak(p); - - if (XResurrection::is_blocked()) { - return barrier(p, o); - } - - return load_barrier_on_oop_field_preloaded(p, o); -} - -inline oop XBarrier::load_barrier_on_phantom_oop_field_preloaded(volatile oop* p, oop o) { - if (XResurrection::is_blocked()) { - return barrier(p, o); - } - - return load_barrier_on_oop_field_preloaded(p, o); -} - -inline void XBarrier::load_barrier_on_root_oop_field(oop* p) { - const oop o = *p; - root_barrier(p, o); -} - -inline void XBarrier::load_barrier_on_invisible_root_oop_field(oop* p) { - const oop o = *p; - root_barrier(p, o); -} - -// -// Weak load barrier -// -inline oop XBarrier::weak_load_barrier_on_oop_field(volatile oop* p) { - assert(!XResurrection::is_blocked(), "Should not be called during resurrection blocked phase"); - const oop o = Atomic::load(p); - return weak_load_barrier_on_oop_field_preloaded(p, o); -} - -inline oop XBarrier::weak_load_barrier_on_oop_field_preloaded(volatile oop* p, oop o) { - return weak_barrier(p, o); -} - -inline oop XBarrier::weak_load_barrier_on_weak_oop(oop o) { - return weak_load_barrier_on_weak_oop_field_preloaded((oop*)nullptr, o); -} - -inline oop XBarrier::weak_load_barrier_on_weak_oop_field_preloaded(volatile oop* p, oop o) { - verify_on_weak(p); - - if (XResurrection::is_blocked()) { - return barrier(p, o); - } - - return weak_load_barrier_on_oop_field_preloaded(p, o); -} - -inline oop XBarrier::weak_load_barrier_on_phantom_oop(oop o) { - return weak_load_barrier_on_phantom_oop_field_preloaded((oop*)nullptr, o); -} - -inline oop XBarrier::weak_load_barrier_on_phantom_oop_field_preloaded(volatile oop* p, oop o) { - if (XResurrection::is_blocked()) { - return barrier(p, o); - } - - return weak_load_barrier_on_oop_field_preloaded(p, o); -} - -// -// Is alive barrier -// -inline bool XBarrier::is_alive_barrier_on_weak_oop(oop o) { - // Check if oop is logically non-null. This operation - // is only valid when resurrection is blocked. - assert(XResurrection::is_blocked(), "Invalid phase"); - return weak_load_barrier_on_weak_oop(o) != nullptr; -} - -inline bool XBarrier::is_alive_barrier_on_phantom_oop(oop o) { - // Check if oop is logically non-null. This operation - // is only valid when resurrection is blocked. - assert(XResurrection::is_blocked(), "Invalid phase"); - return weak_load_barrier_on_phantom_oop(o) != nullptr; -} - -// -// Keep alive barrier -// -inline void XBarrier::keep_alive_barrier_on_weak_oop_field(volatile oop* p) { - assert(XResurrection::is_blocked(), "This operation is only valid when resurrection is blocked"); - const oop o = Atomic::load(p); - barrier(p, o); -} - -inline void XBarrier::keep_alive_barrier_on_phantom_oop_field(volatile oop* p) { - assert(XResurrection::is_blocked(), "This operation is only valid when resurrection is blocked"); - const oop o = Atomic::load(p); - barrier(p, o); -} - -inline void XBarrier::keep_alive_barrier_on_phantom_root_oop_field(oop* p) { - // The keep alive operation is only valid when resurrection is blocked. - // - // Except with Loom, where we intentionally trigger arms nmethods after - // unlinking, to get a sense of what nmethods are alive. This will trigger - // the keep alive barriers, but the oops are healed and the slow-paths - // will not trigger. We have stronger checks in the slow-paths. - assert(XResurrection::is_blocked() || (CodeCache::contains((void*)p)), - "This operation is only valid when resurrection is blocked"); - const oop o = *p; - root_barrier(p, o); -} - -inline void XBarrier::keep_alive_barrier_on_oop(oop o) { - const uintptr_t addr = XOop::to_address(o); - assert(XAddress::is_good(addr), "Invalid address"); - - if (during_mark()) { - keep_alive_barrier_on_oop_slow_path(addr); - } -} - -// -// Mark barrier -// -inline void XBarrier::mark_barrier_on_oop_field(volatile oop* p, bool finalizable) { - const oop o = Atomic::load(p); - - if (finalizable) { - barrier(p, o); - } else { - const uintptr_t addr = XOop::to_address(o); - if (XAddress::is_good(addr)) { - // Mark through good oop - mark_barrier_on_oop_slow_path(addr); - } else { - // Mark through bad oop - barrier(p, o); - } - } -} - -inline void XBarrier::mark_barrier_on_oop_array(volatile oop* p, size_t length, bool finalizable) { - for (volatile const oop* const end = p + length; p < end; p++) { - mark_barrier_on_oop_field(p, finalizable); - } -} - -#endif // SHARE_GC_X_XBARRIER_INLINE_HPP diff --git a/src/hotspot/share/gc/x/xBarrierSet.cpp b/src/hotspot/share/gc/x/xBarrierSet.cpp deleted file mode 100644 index cee53e8c3fa..00000000000 --- a/src/hotspot/share/gc/x/xBarrierSet.cpp +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (c) 2018, 2021, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/x/xBarrierSet.hpp" -#include "gc/x/xBarrierSetAssembler.hpp" -#include "gc/x/xBarrierSetNMethod.hpp" -#include "gc/x/xBarrierSetStackChunk.hpp" -#include "gc/x/xGlobals.hpp" -#include "gc/x/xHeap.inline.hpp" -#include "gc/x/xStackWatermark.hpp" -#include "gc/x/xThreadLocalData.hpp" -#include "runtime/javaThread.hpp" -#include "utilities/macros.hpp" -#ifdef COMPILER1 -#include "gc/x/c1/xBarrierSetC1.hpp" -#endif -#ifdef COMPILER2 -#include "gc/x/c2/xBarrierSetC2.hpp" -#endif - -class XBarrierSetC1; -class XBarrierSetC2; - -XBarrierSet::XBarrierSet() : - BarrierSet(make_barrier_set_assembler(), - make_barrier_set_c1(), - make_barrier_set_c2(), - new XBarrierSetNMethod(), - new XBarrierSetStackChunk(), - BarrierSet::FakeRtti(BarrierSet::XBarrierSet)) {} - -XBarrierSetAssembler* XBarrierSet::assembler() { - BarrierSetAssembler* const bsa = BarrierSet::barrier_set()->barrier_set_assembler(); - return reinterpret_cast(bsa); -} - -bool XBarrierSet::barrier_needed(DecoratorSet decorators, BasicType type) { - assert((decorators & AS_RAW) == 0, "Unexpected decorator"); - //assert((decorators & ON_UNKNOWN_OOP_REF) == 0, "Unexpected decorator"); - - if (is_reference_type(type)) { - assert((decorators & (IN_HEAP | IN_NATIVE)) != 0, "Where is reference?"); - // Barrier needed even when IN_NATIVE, to allow concurrent scanning. - return true; - } - - // Barrier not needed - return false; -} - -void XBarrierSet::on_thread_create(Thread* thread) { - // Create thread local data - XThreadLocalData::create(thread); -} - -void XBarrierSet::on_thread_destroy(Thread* thread) { - // Destroy thread local data - XThreadLocalData::destroy(thread); -} - -void XBarrierSet::on_thread_attach(Thread* thread) { - // Set thread local address bad mask - XThreadLocalData::set_address_bad_mask(thread, XAddressBadMask); - if (thread->is_Java_thread()) { - JavaThread* const jt = JavaThread::cast(thread); - StackWatermark* const watermark = new XStackWatermark(jt); - StackWatermarkSet::add_watermark(jt, watermark); - } -} - -void XBarrierSet::on_thread_detach(Thread* thread) { - // Flush and free any remaining mark stacks - XHeap::heap()->mark_flush_and_free(thread); -} - -void XBarrierSet::print_on(outputStream* st) const { - st->print_cr("XBarrierSet"); -} diff --git a/src/hotspot/share/gc/x/xBarrierSet.hpp b/src/hotspot/share/gc/x/xBarrierSet.hpp deleted file mode 100644 index 3f1eb760033..00000000000 --- a/src/hotspot/share/gc/x/xBarrierSet.hpp +++ /dev/null @@ -1,109 +0,0 @@ -/* - * Copyright (c) 2015, 2019, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XBARRIERSET_HPP -#define SHARE_GC_X_XBARRIERSET_HPP - -#include "gc/shared/barrierSet.hpp" - -class XBarrierSetAssembler; - -class XBarrierSet : public BarrierSet { -public: - XBarrierSet(); - - static XBarrierSetAssembler* assembler(); - static bool barrier_needed(DecoratorSet decorators, BasicType type); - - virtual void on_thread_create(Thread* thread); - virtual void on_thread_destroy(Thread* thread); - virtual void on_thread_attach(Thread* thread); - virtual void on_thread_detach(Thread* thread); - - virtual void print_on(outputStream* st) const; - - template - class AccessBarrier : public BarrierSet::AccessBarrier { - private: - typedef BarrierSet::AccessBarrier Raw; - - template - static void verify_decorators_present(); - - template - static void verify_decorators_absent(); - - static oop* field_addr(oop base, ptrdiff_t offset); - - template - static oop load_barrier_on_oop_field_preloaded(T* addr, oop o); - - template - static oop load_barrier_on_unknown_oop_field_preloaded(oop base, ptrdiff_t offset, T* addr, oop o); - - public: - // - // In heap - // - template - static oop oop_load_in_heap(T* addr); - static oop oop_load_in_heap_at(oop base, ptrdiff_t offset); - - template - static oop oop_atomic_cmpxchg_in_heap(T* addr, oop compare_value, oop new_value); - static oop oop_atomic_cmpxchg_in_heap_at(oop base, ptrdiff_t offset, oop compare_value, oop new_value); - - template - static oop oop_atomic_xchg_in_heap(T* addr, oop new_value); - static oop oop_atomic_xchg_in_heap_at(oop base, ptrdiff_t offset, oop new_value); - - template - static bool oop_arraycopy_in_heap(arrayOop src_obj, size_t src_offset_in_bytes, T* src_raw, - arrayOop dst_obj, size_t dst_offset_in_bytes, T* dst_raw, - size_t length); - - static void clone_in_heap(oop src, oop dst, size_t size); - - // - // Not in heap - // - template - static oop oop_load_not_in_heap(T* addr); - - template - static oop oop_atomic_cmpxchg_not_in_heap(T* addr, oop compare_value, oop new_value); - - template - static oop oop_atomic_xchg_not_in_heap(T* addr, oop new_value); - }; -}; - -template<> struct BarrierSet::GetName { - static const BarrierSet::Name value = BarrierSet::XBarrierSet; -}; - -template<> struct BarrierSet::GetType { - typedef ::XBarrierSet type; -}; - -#endif // SHARE_GC_X_XBARRIERSET_HPP diff --git a/src/hotspot/share/gc/x/xBarrierSet.inline.hpp b/src/hotspot/share/gc/x/xBarrierSet.inline.hpp deleted file mode 100644 index 3d92c38647d..00000000000 --- a/src/hotspot/share/gc/x/xBarrierSet.inline.hpp +++ /dev/null @@ -1,242 +0,0 @@ -/* - * Copyright (c) 2017, 2018, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XBARRIERSET_INLINE_HPP -#define SHARE_GC_X_XBARRIERSET_INLINE_HPP - -#include "gc/x/xBarrierSet.hpp" - -#include "gc/shared/accessBarrierSupport.inline.hpp" -#include "gc/x/xBarrier.inline.hpp" -#include "utilities/debug.hpp" - -template -template -inline void XBarrierSet::AccessBarrier::verify_decorators_present() { - if ((decorators & expected) == 0) { - fatal("Using unsupported access decorators"); - } -} - -template -template -inline void XBarrierSet::AccessBarrier::verify_decorators_absent() { - if ((decorators & expected) != 0) { - fatal("Using unsupported access decorators"); - } -} - -template -inline oop* XBarrierSet::AccessBarrier::field_addr(oop base, ptrdiff_t offset) { - assert(base != nullptr, "Invalid base"); - return reinterpret_cast(reinterpret_cast((void*)base) + offset); -} - -template -template -inline oop XBarrierSet::AccessBarrier::load_barrier_on_oop_field_preloaded(T* addr, oop o) { - verify_decorators_absent(); - - if (HasDecorator::value) { - if (HasDecorator::value) { - return XBarrier::weak_load_barrier_on_oop_field_preloaded(addr, o); - } else if (HasDecorator::value) { - return XBarrier::weak_load_barrier_on_weak_oop_field_preloaded(addr, o); - } else { - assert((HasDecorator::value), "Must be"); - return XBarrier::weak_load_barrier_on_phantom_oop_field_preloaded(addr, o); - } - } else { - if (HasDecorator::value) { - return XBarrier::load_barrier_on_oop_field_preloaded(addr, o); - } else if (HasDecorator::value) { - return XBarrier::load_barrier_on_weak_oop_field_preloaded(addr, o); - } else { - assert((HasDecorator::value), "Must be"); - return XBarrier::load_barrier_on_phantom_oop_field_preloaded(addr, o); - } - } -} - -template -template -inline oop XBarrierSet::AccessBarrier::load_barrier_on_unknown_oop_field_preloaded(oop base, ptrdiff_t offset, T* addr, oop o) { - verify_decorators_present(); - - const DecoratorSet decorators_known_strength = - AccessBarrierSupport::resolve_possibly_unknown_oop_ref_strength(base, offset); - - if (HasDecorator::value) { - if (decorators_known_strength & ON_STRONG_OOP_REF) { - return XBarrier::weak_load_barrier_on_oop_field_preloaded(addr, o); - } else if (decorators_known_strength & ON_WEAK_OOP_REF) { - return XBarrier::weak_load_barrier_on_weak_oop_field_preloaded(addr, o); - } else { - assert(decorators_known_strength & ON_PHANTOM_OOP_REF, "Must be"); - return XBarrier::weak_load_barrier_on_phantom_oop_field_preloaded(addr, o); - } - } else { - if (decorators_known_strength & ON_STRONG_OOP_REF) { - return XBarrier::load_barrier_on_oop_field_preloaded(addr, o); - } else if (decorators_known_strength & ON_WEAK_OOP_REF) { - return XBarrier::load_barrier_on_weak_oop_field_preloaded(addr, o); - } else { - assert(decorators_known_strength & ON_PHANTOM_OOP_REF, "Must be"); - return XBarrier::load_barrier_on_phantom_oop_field_preloaded(addr, o); - } - } -} - -// -// In heap -// -template -template -inline oop XBarrierSet::AccessBarrier::oop_load_in_heap(T* addr) { - verify_decorators_absent(); - - const oop o = Raw::oop_load_in_heap(addr); - return load_barrier_on_oop_field_preloaded(addr, o); -} - -template -inline oop XBarrierSet::AccessBarrier::oop_load_in_heap_at(oop base, ptrdiff_t offset) { - oop* const addr = field_addr(base, offset); - const oop o = Raw::oop_load_in_heap(addr); - - if (HasDecorator::value) { - return load_barrier_on_unknown_oop_field_preloaded(base, offset, addr, o); - } - - return load_barrier_on_oop_field_preloaded(addr, o); -} - -template -template -inline oop XBarrierSet::AccessBarrier::oop_atomic_cmpxchg_in_heap(T* addr, oop compare_value, oop new_value) { - verify_decorators_present(); - verify_decorators_absent(); - - XBarrier::load_barrier_on_oop_field(addr); - return Raw::oop_atomic_cmpxchg_in_heap(addr, compare_value, new_value); -} - -template -inline oop XBarrierSet::AccessBarrier::oop_atomic_cmpxchg_in_heap_at(oop base, ptrdiff_t offset, oop compare_value, oop new_value) { - verify_decorators_present(); - verify_decorators_absent(); - - // Through Unsafe.CompareAndExchangeObject()/CompareAndSetObject() we can receive - // calls with ON_UNKNOWN_OOP_REF set. However, we treat these as ON_STRONG_OOP_REF, - // with the motivation that if you're doing Unsafe operations on a Reference.referent - // field, then you're on your own anyway. - XBarrier::load_barrier_on_oop_field(field_addr(base, offset)); - return Raw::oop_atomic_cmpxchg_in_heap_at(base, offset, compare_value, new_value); -} - -template -template -inline oop XBarrierSet::AccessBarrier::oop_atomic_xchg_in_heap(T* addr, oop new_value) { - verify_decorators_present(); - verify_decorators_absent(); - - const oop o = Raw::oop_atomic_xchg_in_heap(addr, new_value); - return XBarrier::load_barrier_on_oop(o); -} - -template -inline oop XBarrierSet::AccessBarrier::oop_atomic_xchg_in_heap_at(oop base, ptrdiff_t offset, oop new_value) { - verify_decorators_present(); - verify_decorators_absent(); - - const oop o = Raw::oop_atomic_xchg_in_heap_at(base, offset, new_value); - return XBarrier::load_barrier_on_oop(o); -} - -template -template -inline bool XBarrierSet::AccessBarrier::oop_arraycopy_in_heap(arrayOop src_obj, size_t src_offset_in_bytes, T* src_raw, - arrayOop dst_obj, size_t dst_offset_in_bytes, T* dst_raw, - size_t length) { - T* src = arrayOopDesc::obj_offset_to_raw(src_obj, src_offset_in_bytes, src_raw); - T* dst = arrayOopDesc::obj_offset_to_raw(dst_obj, dst_offset_in_bytes, dst_raw); - - if (!HasDecorator::value) { - // No check cast, bulk barrier and bulk copy - XBarrier::load_barrier_on_oop_array(src, length); - return Raw::oop_arraycopy_in_heap(nullptr, 0, src, nullptr, 0, dst, length); - } - - // Check cast and copy each elements - Klass* const dst_klass = objArrayOop(dst_obj)->element_klass(); - for (const T* const end = src + length; src < end; src++, dst++) { - const oop elem = XBarrier::load_barrier_on_oop_field(src); - if (!oopDesc::is_instanceof_or_null(elem, dst_klass)) { - // Check cast failed - return false; - } - - // Cast is safe, since we know it's never a narrowOop - *(oop*)dst = elem; - } - - return true; -} - -template -inline void XBarrierSet::AccessBarrier::clone_in_heap(oop src, oop dst, size_t size) { - XBarrier::load_barrier_on_oop_fields(src); - Raw::clone_in_heap(src, dst, size); -} - -// -// Not in heap -// -template -template -inline oop XBarrierSet::AccessBarrier::oop_load_not_in_heap(T* addr) { - verify_decorators_absent(); - - const oop o = Raw::oop_load_not_in_heap(addr); - return load_barrier_on_oop_field_preloaded(addr, o); -} - -template -template -inline oop XBarrierSet::AccessBarrier::oop_atomic_cmpxchg_not_in_heap(T* addr, oop compare_value, oop new_value) { - verify_decorators_present(); - verify_decorators_absent(); - - return Raw::oop_atomic_cmpxchg_not_in_heap(addr, compare_value, new_value); -} - -template -template -inline oop XBarrierSet::AccessBarrier::oop_atomic_xchg_not_in_heap(T* addr, oop new_value) { - verify_decorators_present(); - verify_decorators_absent(); - - return Raw::oop_atomic_xchg_not_in_heap(addr, new_value); -} - -#endif // SHARE_GC_X_XBARRIERSET_INLINE_HPP diff --git a/src/hotspot/share/gc/x/xBarrierSetAssembler.cpp b/src/hotspot/share/gc/x/xBarrierSetAssembler.cpp deleted file mode 100644 index d00c12ed291..00000000000 --- a/src/hotspot/share/gc/x/xBarrierSetAssembler.cpp +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2018, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/x/xBarrierSetAssembler.hpp" -#include "gc/x/xThreadLocalData.hpp" -#include "runtime/javaThread.hpp" - -Address XBarrierSetAssemblerBase::address_bad_mask_from_thread(Register thread) { - return Address(thread, XThreadLocalData::address_bad_mask_offset()); -} - -Address XBarrierSetAssemblerBase::address_bad_mask_from_jni_env(Register env) { - return Address(env, XThreadLocalData::address_bad_mask_offset() - JavaThread::jni_environment_offset()); -} diff --git a/src/hotspot/share/gc/x/xBarrierSetAssembler.hpp b/src/hotspot/share/gc/x/xBarrierSetAssembler.hpp deleted file mode 100644 index 2f733465bfb..00000000000 --- a/src/hotspot/share/gc/x/xBarrierSetAssembler.hpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2018, 2019, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XBARRIERSETASSEMBLER_HPP -#define SHARE_GC_X_XBARRIERSETASSEMBLER_HPP - -#include "gc/shared/barrierSetAssembler.hpp" -#include "utilities/macros.hpp" - -class XBarrierSetAssemblerBase : public BarrierSetAssembler { -public: - static Address address_bad_mask_from_thread(Register thread); - static Address address_bad_mask_from_jni_env(Register env); -}; - -// Needs to be included after definition of XBarrierSetAssemblerBase -#include CPU_HEADER(gc/x/xBarrierSetAssembler) - -#endif // SHARE_GC_X_XBARRIERSETASSEMBLER_HPP diff --git a/src/hotspot/share/gc/x/xBarrierSetNMethod.cpp b/src/hotspot/share/gc/x/xBarrierSetNMethod.cpp deleted file mode 100644 index 3dc76463028..00000000000 --- a/src/hotspot/share/gc/x/xBarrierSetNMethod.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2018, 2022, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "code/nmethod.hpp" -#include "gc/x/xBarrierSetNMethod.hpp" -#include "gc/x/xGlobals.hpp" -#include "gc/x/xLock.inline.hpp" -#include "gc/x/xNMethod.hpp" -#include "gc/x/xThreadLocalData.hpp" -#include "logging/log.hpp" -#include "runtime/threadWXSetters.inline.hpp" - -bool XBarrierSetNMethod::nmethod_entry_barrier(nmethod* nm) { - if (!is_armed(nm)) { - // Some other thread got here first and healed the oops - // and disarmed the nmethod. No need to continue. - return true; - } - - XLocker locker(XNMethod::lock_for_nmethod(nm)); - log_trace(nmethod, barrier)("Entered critical zone for %p", nm); - - if (!is_armed(nm)) { - // Some other thread managed to complete while we were - // waiting for lock. No need to continue. - return true; - } - - MACOS_AARCH64_ONLY(ThreadWXEnable wx(WXWrite, Thread::current())); - - if (nm->is_unloading()) { - // We don't need to take the lock when unlinking nmethods from - // the Method, because it is only concurrently unlinked by - // the entry barrier, which acquires the per nmethod lock. - nm->unlink_from_method(); - - // We can end up calling nmethods that are unloading - // since we clear compiled ICs lazily. Returning false - // will re-resovle the call and update the compiled IC. - return false; - } - - // Heal oops - XNMethod::nmethod_oops_barrier(nm); - - - // CodeCache unloading support - nm->mark_as_maybe_on_stack(); - - // Disarm - disarm(nm); - - return true; -} - -int* XBarrierSetNMethod::disarmed_guard_value_address() const { - return (int*)XAddressBadMaskHighOrderBitsAddr; -} - -ByteSize XBarrierSetNMethod::thread_disarmed_guard_value_offset() const { - return XThreadLocalData::nmethod_disarmed_offset(); -} diff --git a/src/hotspot/share/gc/x/xBarrierSetNMethod.hpp b/src/hotspot/share/gc/x/xBarrierSetNMethod.hpp deleted file mode 100644 index db1ee8c4e8f..00000000000 --- a/src/hotspot/share/gc/x/xBarrierSetNMethod.hpp +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2018, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XBARRIERSETNMETHOD_HPP -#define SHARE_GC_X_XBARRIERSETNMETHOD_HPP - -#include "gc/shared/barrierSetNMethod.hpp" -#include "memory/allocation.hpp" - -class nmethod; - -class XBarrierSetNMethod : public BarrierSetNMethod { -protected: - virtual bool nmethod_entry_barrier(nmethod* nm); - -public: - virtual ByteSize thread_disarmed_guard_value_offset() const; - virtual int* disarmed_guard_value_address() const; -}; - -#endif // SHARE_GC_X_XBARRIERSETNMETHOD_HPP diff --git a/src/hotspot/share/gc/x/xBarrierSetRuntime.cpp b/src/hotspot/share/gc/x/xBarrierSetRuntime.cpp deleted file mode 100644 index d87df24b9d8..00000000000 --- a/src/hotspot/share/gc/x/xBarrierSetRuntime.cpp +++ /dev/null @@ -1,114 +0,0 @@ -/* - * Copyright (c) 2018, 2021, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/x/xBarrier.inline.hpp" -#include "gc/x/xBarrierSetRuntime.hpp" -#include "oops/access.hpp" -#include "runtime/interfaceSupport.inline.hpp" - -JRT_LEAF(oopDesc*, XBarrierSetRuntime::load_barrier_on_oop_field_preloaded(oopDesc* o, oop* p)) - return XBarrier::load_barrier_on_oop_field_preloaded(p, o); -JRT_END - -JRT_LEAF(oopDesc*, XBarrierSetRuntime::weak_load_barrier_on_oop_field_preloaded(oopDesc* o, oop* p)) - return XBarrier::weak_load_barrier_on_oop_field_preloaded(p, o); -JRT_END - -JRT_LEAF(oopDesc*, XBarrierSetRuntime::weak_load_barrier_on_weak_oop_field_preloaded(oopDesc* o, oop* p)) - return XBarrier::weak_load_barrier_on_weak_oop_field_preloaded(p, o); -JRT_END - -JRT_LEAF(oopDesc*, XBarrierSetRuntime::weak_load_barrier_on_phantom_oop_field_preloaded(oopDesc* o, oop* p)) - return XBarrier::weak_load_barrier_on_phantom_oop_field_preloaded(p, o); -JRT_END - -JRT_LEAF(oopDesc*, XBarrierSetRuntime::load_barrier_on_weak_oop_field_preloaded(oopDesc* o, oop* p)) - return XBarrier::load_barrier_on_weak_oop_field_preloaded(p, o); -JRT_END - -JRT_LEAF(oopDesc*, XBarrierSetRuntime::load_barrier_on_phantom_oop_field_preloaded(oopDesc* o, oop* p)) - return XBarrier::load_barrier_on_phantom_oop_field_preloaded(p, o); -JRT_END - -JRT_LEAF(void, XBarrierSetRuntime::load_barrier_on_oop_array(oop* p, size_t length)) - XBarrier::load_barrier_on_oop_array(p, length); -JRT_END - -JRT_LEAF(void, XBarrierSetRuntime::clone(oopDesc* src, oopDesc* dst, size_t size)) - HeapAccess<>::clone(src, dst, size); -JRT_END - -address XBarrierSetRuntime::load_barrier_on_oop_field_preloaded_addr(DecoratorSet decorators) { - if (decorators & ON_PHANTOM_OOP_REF) { - if (decorators & AS_NO_KEEPALIVE) { - return weak_load_barrier_on_phantom_oop_field_preloaded_addr(); - } else { - return load_barrier_on_phantom_oop_field_preloaded_addr(); - } - } else if (decorators & ON_WEAK_OOP_REF) { - if (decorators & AS_NO_KEEPALIVE) { - return weak_load_barrier_on_weak_oop_field_preloaded_addr(); - } else { - return load_barrier_on_weak_oop_field_preloaded_addr(); - } - } else { - if (decorators & AS_NO_KEEPALIVE) { - return weak_load_barrier_on_oop_field_preloaded_addr(); - } else { - return load_barrier_on_oop_field_preloaded_addr(); - } - } -} - -address XBarrierSetRuntime::load_barrier_on_oop_field_preloaded_addr() { - return reinterpret_cast

    (load_barrier_on_oop_field_preloaded); -} - -address XBarrierSetRuntime::load_barrier_on_weak_oop_field_preloaded_addr() { - return reinterpret_cast
    (load_barrier_on_weak_oop_field_preloaded); -} - -address XBarrierSetRuntime::load_barrier_on_phantom_oop_field_preloaded_addr() { - return reinterpret_cast
    (load_barrier_on_phantom_oop_field_preloaded); -} - -address XBarrierSetRuntime::weak_load_barrier_on_oop_field_preloaded_addr() { - return reinterpret_cast
    (weak_load_barrier_on_oop_field_preloaded); -} - -address XBarrierSetRuntime::weak_load_barrier_on_weak_oop_field_preloaded_addr() { - return reinterpret_cast
    (weak_load_barrier_on_weak_oop_field_preloaded); -} - -address XBarrierSetRuntime::weak_load_barrier_on_phantom_oop_field_preloaded_addr() { - return reinterpret_cast
    (weak_load_barrier_on_phantom_oop_field_preloaded); -} - -address XBarrierSetRuntime::load_barrier_on_oop_array_addr() { - return reinterpret_cast
    (load_barrier_on_oop_array); -} - -address XBarrierSetRuntime::clone_addr() { - return reinterpret_cast
    (clone); -} diff --git a/src/hotspot/share/gc/x/xBarrierSetRuntime.hpp b/src/hotspot/share/gc/x/xBarrierSetRuntime.hpp deleted file mode 100644 index 6302f1ce36d..00000000000 --- a/src/hotspot/share/gc/x/xBarrierSetRuntime.hpp +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright (c) 2018, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XBARRIERSETRUNTIME_HPP -#define SHARE_GC_X_XBARRIERSETRUNTIME_HPP - -#include "memory/allStatic.hpp" -#include "oops/accessDecorators.hpp" -#include "utilities/globalDefinitions.hpp" - -class oopDesc; - -class XBarrierSetRuntime : public AllStatic { -private: - static oopDesc* load_barrier_on_oop_field_preloaded(oopDesc* o, oop* p); - static oopDesc* load_barrier_on_weak_oop_field_preloaded(oopDesc* o, oop* p); - static oopDesc* load_barrier_on_phantom_oop_field_preloaded(oopDesc* o, oop* p); - static oopDesc* weak_load_barrier_on_oop_field_preloaded(oopDesc* o, oop* p); - static oopDesc* weak_load_barrier_on_weak_oop_field_preloaded(oopDesc* o, oop* p); - static oopDesc* weak_load_barrier_on_phantom_oop_field_preloaded(oopDesc* o, oop* p); - static void load_barrier_on_oop_array(oop* p, size_t length); - static void clone(oopDesc* src, oopDesc* dst, size_t size); - -public: - static address load_barrier_on_oop_field_preloaded_addr(DecoratorSet decorators); - static address load_barrier_on_oop_field_preloaded_addr(); - static address load_barrier_on_weak_oop_field_preloaded_addr(); - static address load_barrier_on_phantom_oop_field_preloaded_addr(); - static address weak_load_barrier_on_oop_field_preloaded_addr(); - static address weak_load_barrier_on_weak_oop_field_preloaded_addr(); - static address weak_load_barrier_on_phantom_oop_field_preloaded_addr(); - static address load_barrier_on_oop_array_addr(); - static address clone_addr(); -}; - -#endif // SHARE_GC_X_XBARRIERSETRUNTIME_HPP diff --git a/src/hotspot/share/gc/x/xBarrierSetStackChunk.cpp b/src/hotspot/share/gc/x/xBarrierSetStackChunk.cpp deleted file mode 100644 index 1670a00434f..00000000000 --- a/src/hotspot/share/gc/x/xBarrierSetStackChunk.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2022, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#include "precompiled.hpp" -#include "gc/x/xBarrier.inline.hpp" -#include "gc/x/xBarrierSetStackChunk.hpp" -#include "runtime/atomic.hpp" -#include "utilities/debug.hpp" - -void XBarrierSetStackChunk::encode_gc_mode(stackChunkOop chunk, OopIterator* iterator) { - // Do nothing -} - -void XBarrierSetStackChunk::decode_gc_mode(stackChunkOop chunk, OopIterator* iterator) { - // Do nothing -} - -oop XBarrierSetStackChunk::load_oop(stackChunkOop chunk, oop* addr) { - oop obj = Atomic::load(addr); - return XBarrier::load_barrier_on_oop_field_preloaded((volatile oop*)nullptr, obj); -} - -oop XBarrierSetStackChunk::load_oop(stackChunkOop chunk, narrowOop* addr) { - ShouldNotReachHere(); - return nullptr; -} diff --git a/src/hotspot/share/gc/x/xBarrierSetStackChunk.hpp b/src/hotspot/share/gc/x/xBarrierSetStackChunk.hpp deleted file mode 100644 index 36180db7b8c..00000000000 --- a/src/hotspot/share/gc/x/xBarrierSetStackChunk.hpp +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2022, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -#ifndef SHARE_GC_X_XBARRIERSETSTACKCHUNK_HPP -#define SHARE_GC_X_XBARRIERSETSTACKCHUNK_HPP - -#include "gc/shared/barrierSetStackChunk.hpp" -#include "memory/iterator.hpp" -#include "oops/oopsHierarchy.hpp" -#include "utilities/globalDefinitions.hpp" - -class OopClosure; - -class XBarrierSetStackChunk : public BarrierSetStackChunk { -public: - virtual void encode_gc_mode(stackChunkOop chunk, OopIterator* iterator) override; - virtual void decode_gc_mode(stackChunkOop chunk, OopIterator* iterator) override; - - virtual oop load_oop(stackChunkOop chunk, oop* addr) override; - virtual oop load_oop(stackChunkOop chunk, narrowOop* addr) override; -}; - -#endif // SHARE_GC_X_XBARRIERSETSTACKCHUNK_HPP diff --git a/src/hotspot/share/gc/x/xBitField.hpp b/src/hotspot/share/gc/x/xBitField.hpp deleted file mode 100644 index f11d7cf7ef7..00000000000 --- a/src/hotspot/share/gc/x/xBitField.hpp +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2017, 2022, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XBITFIELD_HPP -#define SHARE_GC_X_XBITFIELD_HPP - -#include "memory/allStatic.hpp" -#include "utilities/debug.hpp" -#include "utilities/globalDefinitions.hpp" - -// -// Example -// ------- -// -// typedef XBitField field_word_aligned_size; -// typedef XBitField field_length; -// -// -// 6 3 3 -// 3 2 1 2 10 -// +-----------------------------------+---------------------------------+--+ -// |11111111 11111111 11111111 11111111|11111111 11111111 11111111 111111|11| -// +-----------------------------------+---------------------------------+--+ -// | | | -// | 31-2 field_length (30-bits) * | -// | | -// | 1-0 field_word_aligned_size (2-bits) * -// | -// * 63-32 Unused (32-bits) -// -// -// field_word_aligned_size::encode(16) = 2 -// field_length::encode(2342) = 9368 -// -// field_word_aligned_size::decode(9368 | 2) = 16 -// field_length::decode(9368 | 2) = 2342 -// - -template -class XBitField : public AllStatic { -private: - static const int ContainerBits = sizeof(ContainerType) * BitsPerByte; - - static_assert(FieldBits < ContainerBits, "Field too large"); - static_assert(FieldShift + FieldBits <= ContainerBits, "Field too large"); - static_assert(ValueShift + FieldBits <= ContainerBits, "Field too large"); - - static const ContainerType FieldMask = (((ContainerType)1 << FieldBits) - 1); - -public: - static ValueType decode(ContainerType container) { - return (ValueType)(((container >> FieldShift) & FieldMask) << ValueShift); - } - - static ContainerType encode(ValueType value) { - assert(((ContainerType)value & (FieldMask << ValueShift)) == (ContainerType)value, "Invalid value"); - return ((ContainerType)value >> ValueShift) << FieldShift; - } -}; - -#endif // SHARE_GC_X_XBITFIELD_HPP diff --git a/src/hotspot/share/gc/x/xBitMap.hpp b/src/hotspot/share/gc/x/xBitMap.hpp deleted file mode 100644 index c96f63b4c89..00000000000 --- a/src/hotspot/share/gc/x/xBitMap.hpp +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XBITMAP_HPP -#define SHARE_GC_X_XBITMAP_HPP - -#include "utilities/bitMap.hpp" - -class XBitMap : public CHeapBitMap { -private: - static bm_word_t bit_mask_pair(idx_t bit); - - bool par_set_bit_pair_finalizable(idx_t bit, bool& inc_live); - bool par_set_bit_pair_strong(idx_t bit, bool& inc_live); - -public: - XBitMap(idx_t size_in_bits); - - bool par_set_bit_pair(idx_t bit, bool finalizable, bool& inc_live); -}; - -#endif // SHARE_GC_X_XBITMAP_HPP diff --git a/src/hotspot/share/gc/x/xBitMap.inline.hpp b/src/hotspot/share/gc/x/xBitMap.inline.hpp deleted file mode 100644 index e35f59eeb88..00000000000 --- a/src/hotspot/share/gc/x/xBitMap.inline.hpp +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XBITMAP_INLINE_HPP -#define SHARE_GC_X_XBITMAP_INLINE_HPP - -#include "gc/x/xBitMap.hpp" - -#include "runtime/atomic.hpp" -#include "utilities/bitMap.inline.hpp" -#include "utilities/debug.hpp" - -inline XBitMap::XBitMap(idx_t size_in_bits) : - CHeapBitMap(size_in_bits, mtGC, false /* clear */) {} - -inline BitMap::bm_word_t XBitMap::bit_mask_pair(idx_t bit) { - assert(bit_in_word(bit) < BitsPerWord - 1, "Invalid bit index"); - return (bm_word_t)3 << bit_in_word(bit); -} - -inline bool XBitMap::par_set_bit_pair_finalizable(idx_t bit, bool& inc_live) { - inc_live = par_set_bit(bit); - return inc_live; -} - -inline bool XBitMap::par_set_bit_pair_strong(idx_t bit, bool& inc_live) { - verify_index(bit); - volatile bm_word_t* const addr = word_addr(bit); - const bm_word_t pair_mask = bit_mask_pair(bit); - bm_word_t old_val = *addr; - - do { - const bm_word_t new_val = old_val | pair_mask; - if (new_val == old_val) { - // Someone else beat us to it - inc_live = false; - return false; - } - const bm_word_t cur_val = Atomic::cmpxchg(addr, old_val, new_val); - if (cur_val == old_val) { - // Success - const bm_word_t marked_mask = bit_mask(bit); - inc_live = !(old_val & marked_mask); - return true; - } - - // The value changed, retry - old_val = cur_val; - } while (true); -} - -inline bool XBitMap::par_set_bit_pair(idx_t bit, bool finalizable, bool& inc_live) { - if (finalizable) { - return par_set_bit_pair_finalizable(bit, inc_live); - } else { - return par_set_bit_pair_strong(bit, inc_live); - } -} - -#endif // SHARE_GC_X_XBITMAP_INLINE_HPP diff --git a/src/hotspot/share/gc/x/xBreakpoint.cpp b/src/hotspot/share/gc/x/xBreakpoint.cpp deleted file mode 100644 index e053ceaedb9..00000000000 --- a/src/hotspot/share/gc/x/xBreakpoint.cpp +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2020, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/shared/concurrentGCBreakpoints.hpp" -#include "gc/x/xBreakpoint.hpp" -#include "runtime/mutexLocker.hpp" -#include "utilities/debug.hpp" - -bool XBreakpoint::_start_gc = false; - -void XBreakpoint::start_gc() { - MonitorLocker ml(ConcurrentGCBreakpoints::monitor()); - assert(ConcurrentGCBreakpoints::is_controlled(), "Invalid state"); - assert(!_start_gc, "Invalid state"); - _start_gc = true; - ml.notify_all(); -} - -void XBreakpoint::at_before_gc() { - MonitorLocker ml(ConcurrentGCBreakpoints::monitor(), Mutex::_no_safepoint_check_flag); - while (ConcurrentGCBreakpoints::is_controlled() && !_start_gc) { - ml.wait(); - } - _start_gc = false; - ConcurrentGCBreakpoints::notify_idle_to_active(); -} - -void XBreakpoint::at_after_gc() { - ConcurrentGCBreakpoints::notify_active_to_idle(); -} - -void XBreakpoint::at_after_marking_started() { - ConcurrentGCBreakpoints::at("AFTER MARKING STARTED"); -} - -void XBreakpoint::at_before_marking_completed() { - ConcurrentGCBreakpoints::at("BEFORE MARKING COMPLETED"); -} - -void XBreakpoint::at_after_reference_processing_started() { - ConcurrentGCBreakpoints::at("AFTER CONCURRENT REFERENCE PROCESSING STARTED"); -} diff --git a/src/hotspot/share/gc/x/xBreakpoint.hpp b/src/hotspot/share/gc/x/xBreakpoint.hpp deleted file mode 100644 index 0c0b9d3c90f..00000000000 --- a/src/hotspot/share/gc/x/xBreakpoint.hpp +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2020, 2022, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XBREAKPOINT_HPP -#define SHARE_GC_X_XBREAKPOINT_HPP - -#include "memory/allStatic.hpp" - -class XBreakpoint : public AllStatic { -private: - static bool _start_gc; - -public: - static void start_gc(); - - static void at_before_gc(); - static void at_after_gc(); - static void at_after_marking_started(); - static void at_before_marking_completed(); - static void at_after_reference_processing_started(); -}; - -#endif // SHARE_GC_X_XBREAKPOINT_HPP diff --git a/src/hotspot/share/gc/x/xCPU.cpp b/src/hotspot/share/gc/x/xCPU.cpp deleted file mode 100644 index d21d32aeb35..00000000000 --- a/src/hotspot/share/gc/x/xCPU.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2015, 2019, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/shared/gcLogPrecious.hpp" -#include "gc/x/xCPU.inline.hpp" -#include "memory/padded.inline.hpp" -#include "runtime/javaThread.hpp" -#include "runtime/os.hpp" -#include "utilities/debug.hpp" - -#define XCPU_UNKNOWN_AFFINITY ((Thread*)-1) -#define XCPU_UNKNOWN_SELF ((Thread*)-2) - -PaddedEnd* XCPU::_affinity = nullptr; -THREAD_LOCAL Thread* XCPU::_self = XCPU_UNKNOWN_SELF; -THREAD_LOCAL uint32_t XCPU::_cpu = 0; - -void XCPU::initialize() { - assert(_affinity == nullptr, "Already initialized"); - const uint32_t ncpus = count(); - - _affinity = PaddedArray::create_unfreeable(ncpus); - - for (uint32_t i = 0; i < ncpus; i++) { - _affinity[i]._thread = XCPU_UNKNOWN_AFFINITY; - } - - log_info_p(gc, init)("CPUs: %u total, %u available", - os::processor_count(), - os::initial_active_processor_count()); -} - -uint32_t XCPU::id_slow() { - // Set current thread - if (_self == XCPU_UNKNOWN_SELF) { - _self = Thread::current(); - } - - // Set current CPU - _cpu = os::processor_id(); - - // Update affinity table - _affinity[_cpu]._thread = _self; - - return _cpu; -} diff --git a/src/hotspot/share/gc/x/xCPU.hpp b/src/hotspot/share/gc/x/xCPU.hpp deleted file mode 100644 index fd931956c4b..00000000000 --- a/src/hotspot/share/gc/x/xCPU.hpp +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2015, 2022, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XCPU_HPP -#define SHARE_GC_X_XCPU_HPP - -#include "memory/allStatic.hpp" -#include "memory/padded.hpp" -#include "utilities/globalDefinitions.hpp" - -class Thread; - -class XCPU : public AllStatic { -private: - struct XCPUAffinity { - Thread* _thread; - }; - - static PaddedEnd* _affinity; - static THREAD_LOCAL Thread* _self; - static THREAD_LOCAL uint32_t _cpu; - - static uint32_t id_slow(); - -public: - static void initialize(); - - static uint32_t count(); - static uint32_t id(); -}; - -#endif // SHARE_GC_X_XCPU_HPP diff --git a/src/hotspot/share/gc/x/xCPU.inline.hpp b/src/hotspot/share/gc/x/xCPU.inline.hpp deleted file mode 100644 index 3cf5bfa96e0..00000000000 --- a/src/hotspot/share/gc/x/xCPU.inline.hpp +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2019, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XCPU_INLINE_HPP -#define SHARE_GC_X_XCPU_INLINE_HPP - -#include "gc/x/xCPU.hpp" - -#include "runtime/os.hpp" -#include "utilities/debug.hpp" - -inline uint32_t XCPU::count() { - return os::processor_count(); -} - -inline uint32_t XCPU::id() { - assert(_affinity != nullptr, "Not initialized"); - - // Fast path - if (_affinity[_cpu]._thread == _self) { - return _cpu; - } - - // Slow path - return id_slow(); -} - -#endif // SHARE_GC_X_XCPU_INLINE_HPP diff --git a/src/hotspot/share/gc/x/xCollectedHeap.cpp b/src/hotspot/share/gc/x/xCollectedHeap.cpp deleted file mode 100644 index d03b6312a67..00000000000 --- a/src/hotspot/share/gc/x/xCollectedHeap.cpp +++ /dev/null @@ -1,344 +0,0 @@ -/* - * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "classfile/classLoaderData.hpp" -#include "gc/shared/gcHeapSummary.hpp" -#include "gc/shared/gcLocker.inline.hpp" -#include "gc/shared/suspendibleThreadSet.hpp" -#include "gc/x/xCollectedHeap.hpp" -#include "gc/x/xDirector.hpp" -#include "gc/x/xDriver.hpp" -#include "gc/x/xGlobals.hpp" -#include "gc/x/xHeap.inline.hpp" -#include "gc/x/xNMethod.hpp" -#include "gc/x/xObjArrayAllocator.hpp" -#include "gc/x/xOop.inline.hpp" -#include "gc/x/xServiceability.hpp" -#include "gc/x/xStat.hpp" -#include "gc/x/xUtils.inline.hpp" -#include "memory/classLoaderMetaspace.hpp" -#include "memory/iterator.hpp" -#include "memory/metaspaceCriticalAllocation.hpp" -#include "memory/universe.hpp" -#include "oops/stackChunkOop.hpp" -#include "runtime/continuationJavaClasses.hpp" -#include "runtime/stackWatermarkSet.hpp" -#include "utilities/align.hpp" - -XCollectedHeap* XCollectedHeap::heap() { - return named_heap(CollectedHeap::Z); -} - -XCollectedHeap::XCollectedHeap() : - _barrier_set(), - _initialize(&_barrier_set), - _heap(), - _driver(new XDriver()), - _director(new XDirector(_driver)), - _stat(new XStat()), - _runtime_workers() {} - -CollectedHeap::Name XCollectedHeap::kind() const { - return CollectedHeap::Z; -} - -const char* XCollectedHeap::name() const { - return XName; -} - -jint XCollectedHeap::initialize() { - if (!_heap.is_initialized()) { - return JNI_ENOMEM; - } - - Universe::calculate_verify_data((HeapWord*)0, (HeapWord*)UINTPTR_MAX); - - return JNI_OK; -} - -void XCollectedHeap::initialize_serviceability() { - _heap.serviceability_initialize(); -} - -class XStopConcurrentGCThreadClosure : public ThreadClosure { -public: - virtual void do_thread(Thread* thread) { - if (thread->is_ConcurrentGC_thread()) { - ConcurrentGCThread::cast(thread)->stop(); - } - } -}; - -void XCollectedHeap::stop() { - XStopConcurrentGCThreadClosure cl; - gc_threads_do(&cl); -} - -size_t XCollectedHeap::max_capacity() const { - return _heap.max_capacity(); -} - -size_t XCollectedHeap::capacity() const { - return _heap.capacity(); -} - -size_t XCollectedHeap::used() const { - return _heap.used(); -} - -size_t XCollectedHeap::unused() const { - return _heap.unused(); -} - -bool XCollectedHeap::is_maximal_no_gc() const { - // Not supported - ShouldNotReachHere(); - return false; -} - -bool XCollectedHeap::is_in(const void* p) const { - return _heap.is_in((uintptr_t)p); -} - -bool XCollectedHeap::requires_barriers(stackChunkOop obj) const { - uintptr_t* cont_addr = obj->field_addr(jdk_internal_vm_StackChunk::cont_offset()); - - if (!_heap.is_allocating(cast_from_oop(obj))) { - // An object that isn't allocating, is visible from GC tracing. Such - // stack chunks require barriers. - return true; - } - - if (!XAddress::is_good_or_null(*cont_addr)) { - // If a chunk is allocated after a GC started, but before relocate start - // we can have an allocating chunk that isn't deeply good. That means that - // the contained oops might be bad and require GC barriers. - return true; - } - - // The chunk is allocating and its pointers are good. This chunk needs no - // GC barriers - return false; -} - -HeapWord* XCollectedHeap::allocate_new_tlab(size_t min_size, size_t requested_size, size_t* actual_size) { - const size_t size_in_bytes = XUtils::words_to_bytes(align_object_size(requested_size)); - const uintptr_t addr = _heap.alloc_tlab(size_in_bytes); - - if (addr != 0) { - *actual_size = requested_size; - } - - return (HeapWord*)addr; -} - -oop XCollectedHeap::array_allocate(Klass* klass, size_t size, int length, bool do_zero, TRAPS) { - XObjArrayAllocator allocator(klass, size, length, do_zero, THREAD); - return allocator.allocate(); -} - -HeapWord* XCollectedHeap::mem_allocate(size_t size, bool* gc_overhead_limit_was_exceeded) { - const size_t size_in_bytes = XUtils::words_to_bytes(align_object_size(size)); - return (HeapWord*)_heap.alloc_object(size_in_bytes); -} - -MetaWord* XCollectedHeap::satisfy_failed_metadata_allocation(ClassLoaderData* loader_data, - size_t size, - Metaspace::MetadataType mdtype) { - // Start asynchronous GC - collect(GCCause::_metadata_GC_threshold); - - // Expand and retry allocation - MetaWord* const result = loader_data->metaspace_non_null()->expand_and_allocate(size, mdtype); - if (result != nullptr) { - return result; - } - - // As a last resort, try a critical allocation, riding on a synchronous full GC - return MetaspaceCriticalAllocation::allocate(loader_data, size, mdtype); -} - -void XCollectedHeap::collect(GCCause::Cause cause) { - _driver->collect(cause); -} - -void XCollectedHeap::collect_as_vm_thread(GCCause::Cause cause) { - // These collection requests are ignored since ZGC can't run a synchronous - // GC cycle from within the VM thread. This is considered benign, since the - // only GC causes coming in here should be heap dumper and heap inspector. - // If the heap dumper or heap inspector explicitly requests a gc and the - // caller is not the VM thread a synchronous GC cycle is performed from the - // caller thread in the prologue. - assert(Thread::current()->is_VM_thread(), "Should be the VM thread"); - guarantee(cause == GCCause::_heap_dump || - cause == GCCause::_heap_inspection, "Invalid cause"); -} - -void XCollectedHeap::do_full_collection(bool clear_all_soft_refs) { - // Not supported - ShouldNotReachHere(); -} - -size_t XCollectedHeap::tlab_capacity(Thread* ignored) const { - return _heap.tlab_capacity(); -} - -size_t XCollectedHeap::tlab_used(Thread* ignored) const { - return _heap.tlab_used(); -} - -size_t XCollectedHeap::max_tlab_size() const { - return _heap.max_tlab_size(); -} - -size_t XCollectedHeap::unsafe_max_tlab_alloc(Thread* ignored) const { - return _heap.unsafe_max_tlab_alloc(); -} - -MemoryUsage XCollectedHeap::memory_usage() { - return _heap.serviceability_memory_pool()->get_memory_usage(); -} - -GrowableArray XCollectedHeap::memory_managers() { - GrowableArray memory_managers(2); - memory_managers.append(_heap.serviceability_cycle_memory_manager()); - memory_managers.append(_heap.serviceability_pause_memory_manager()); - return memory_managers; -} - -GrowableArray XCollectedHeap::memory_pools() { - GrowableArray memory_pools(1); - memory_pools.append(_heap.serviceability_memory_pool()); - return memory_pools; -} - -void XCollectedHeap::object_iterate(ObjectClosure* cl) { - _heap.object_iterate(cl, true /* visit_weaks */); -} - -ParallelObjectIteratorImpl* XCollectedHeap::parallel_object_iterator(uint nworkers) { - return _heap.parallel_object_iterator(nworkers, true /* visit_weaks */); -} - -void XCollectedHeap::keep_alive(oop obj) { - _heap.keep_alive(obj); -} - -void XCollectedHeap::register_nmethod(nmethod* nm) { - XNMethod::register_nmethod(nm); -} - -void XCollectedHeap::unregister_nmethod(nmethod* nm) { - XNMethod::unregister_nmethod(nm); -} - -void XCollectedHeap::verify_nmethod(nmethod* nm) { - // Does nothing -} - -WorkerThreads* XCollectedHeap::safepoint_workers() { - return _runtime_workers.workers(); -} - -void XCollectedHeap::gc_threads_do(ThreadClosure* tc) const { - tc->do_thread(_director); - tc->do_thread(_driver); - tc->do_thread(_stat); - _heap.threads_do(tc); - _runtime_workers.threads_do(tc); -} - -VirtualSpaceSummary XCollectedHeap::create_heap_space_summary() { - return VirtualSpaceSummary((HeapWord*)0, (HeapWord*)capacity(), (HeapWord*)max_capacity()); -} - -void XCollectedHeap::safepoint_synchronize_begin() { - StackWatermarkSet::safepoint_synchronize_begin(); - SuspendibleThreadSet::synchronize(); -} - -void XCollectedHeap::safepoint_synchronize_end() { - SuspendibleThreadSet::desynchronize(); -} - -void XCollectedHeap::pin_object(JavaThread* thread, oop obj) { - GCLocker::lock_critical(thread); -} - -void XCollectedHeap::unpin_object(JavaThread* thread, oop obj) { - GCLocker::unlock_critical(thread); -} - -void XCollectedHeap::prepare_for_verify() { - // Does nothing -} - -void XCollectedHeap::print_on(outputStream* st) const { - _heap.print_on(st); -} - -void XCollectedHeap::print_on_error(outputStream* st) const { - st->print_cr("ZGC Globals:"); - st->print_cr(" GlobalPhase: %u (%s)", XGlobalPhase, XGlobalPhaseToString()); - st->print_cr(" GlobalSeqNum: %u", XGlobalSeqNum); - st->print_cr(" Offset Max: " SIZE_FORMAT "%s (" PTR_FORMAT ")", - byte_size_in_exact_unit(XAddressOffsetMax), - exact_unit_for_byte_size(XAddressOffsetMax), - XAddressOffsetMax); - st->print_cr(" Page Size Small: " SIZE_FORMAT "M", XPageSizeSmall / M); - st->print_cr(" Page Size Medium: " SIZE_FORMAT "M", XPageSizeMedium / M); - st->cr(); - st->print_cr("ZGC Metadata Bits:"); - st->print_cr(" Good: " PTR_FORMAT, XAddressGoodMask); - st->print_cr(" Bad: " PTR_FORMAT, XAddressBadMask); - st->print_cr(" WeakBad: " PTR_FORMAT, XAddressWeakBadMask); - st->print_cr(" Marked: " PTR_FORMAT, XAddressMetadataMarked); - st->print_cr(" Remapped: " PTR_FORMAT, XAddressMetadataRemapped); - st->cr(); - CollectedHeap::print_on_error(st); -} - -void XCollectedHeap::print_extended_on(outputStream* st) const { - _heap.print_extended_on(st); -} - -void XCollectedHeap::print_tracing_info() const { - // Does nothing -} - -bool XCollectedHeap::print_location(outputStream* st, void* addr) const { - return _heap.print_location(st, (uintptr_t)addr); -} - -void XCollectedHeap::verify(VerifyOption option /* ignored */) { - _heap.verify(); -} - -bool XCollectedHeap::is_oop(oop object) const { - return _heap.is_oop(XOop::to_address(object)); -} - -bool XCollectedHeap::supports_concurrent_gc_breakpoints() const { - return true; -} diff --git a/src/hotspot/share/gc/x/xCollectedHeap.hpp b/src/hotspot/share/gc/x/xCollectedHeap.hpp deleted file mode 100644 index 250c882d15e..00000000000 --- a/src/hotspot/share/gc/x/xCollectedHeap.hpp +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XCOLLECTEDHEAP_HPP -#define SHARE_GC_X_XCOLLECTEDHEAP_HPP - -#include "gc/shared/collectedHeap.hpp" -#include "gc/shared/softRefPolicy.hpp" -#include "gc/x/xBarrierSet.hpp" -#include "gc/x/xHeap.hpp" -#include "gc/x/xInitialize.hpp" -#include "gc/x/xRuntimeWorkers.hpp" -#include "memory/metaspace.hpp" -#include "services/memoryUsage.hpp" - -class VMStructs; -class XDirector; -class XDriver; -class XStat; - -class XCollectedHeap : public CollectedHeap { - friend class ::VMStructs; - -private: - XBarrierSet _barrier_set; - XInitialize _initialize; - XHeap _heap; - XDriver* _driver; - XDirector* _director; - XStat* _stat; - XRuntimeWorkers _runtime_workers; - - HeapWord* allocate_new_tlab(size_t min_size, - size_t requested_size, - size_t* actual_size) override; - -public: - static XCollectedHeap* heap(); - - XCollectedHeap(); - Name kind() const override; - const char* name() const override; - jint initialize() override; - void initialize_serviceability() override; - void stop() override; - - size_t max_capacity() const override; - size_t capacity() const override; - size_t used() const override; - size_t unused() const override; - - bool is_maximal_no_gc() const override; - bool is_in(const void* p) const override; - bool requires_barriers(stackChunkOop obj) const override; - - oop array_allocate(Klass* klass, size_t size, int length, bool do_zero, TRAPS) override; - HeapWord* mem_allocate(size_t size, bool* gc_overhead_limit_was_exceeded) override; - MetaWord* satisfy_failed_metadata_allocation(ClassLoaderData* loader_data, - size_t size, - Metaspace::MetadataType mdtype) override; - void collect(GCCause::Cause cause) override; - void collect_as_vm_thread(GCCause::Cause cause) override; - void do_full_collection(bool clear_all_soft_refs) override; - - size_t tlab_capacity(Thread* thr) const override; - size_t tlab_used(Thread* thr) const override; - size_t max_tlab_size() const override; - size_t unsafe_max_tlab_alloc(Thread* thr) const override; - - MemoryUsage memory_usage() override; - GrowableArray memory_managers() override; - GrowableArray memory_pools() override; - - void object_iterate(ObjectClosure* cl) override; - ParallelObjectIteratorImpl* parallel_object_iterator(uint nworkers) override; - - void keep_alive(oop obj) override; - - void register_nmethod(nmethod* nm) override; - void unregister_nmethod(nmethod* nm) override; - void verify_nmethod(nmethod* nmethod) override; - - WorkerThreads* safepoint_workers() override; - - void gc_threads_do(ThreadClosure* tc) const override; - - VirtualSpaceSummary create_heap_space_summary() override; - - void safepoint_synchronize_begin() override; - void safepoint_synchronize_end() override; - - void pin_object(JavaThread* thread, oop obj) override; - void unpin_object(JavaThread* thread, oop obj) override; - - void print_on(outputStream* st) const override; - void print_on_error(outputStream* st) const override; - void print_extended_on(outputStream* st) const override; - void print_tracing_info() const override; - bool print_location(outputStream* st, void* addr) const override; - - void prepare_for_verify() override; - void verify(VerifyOption option /* ignored */) override; - bool is_oop(oop object) const override; - bool supports_concurrent_gc_breakpoints() const override; -}; - -#endif // SHARE_GC_X_XCOLLECTEDHEAP_HPP diff --git a/src/hotspot/share/gc/x/xDebug.gdb b/src/hotspot/share/gc/x/xDebug.gdb deleted file mode 100644 index 2dbf578b07b..00000000000 --- a/src/hotspot/share/gc/x/xDebug.gdb +++ /dev/null @@ -1,148 +0,0 @@ -# -# GDB functions for debugging the Z Garbage Collector -# - -printf "Loading zDebug.gdb\n" - -# Print Klass* -define zpk - printf "Klass: %s\n", (char*)((Klass*)($arg0))->_name->_body -end - -# Print oop -define zpo - set $obj = (oopDesc*)($arg0) - - printf "Oop: 0x%016llx\tState: ", (uintptr_t)$obj - if ((uintptr_t)$obj & (uintptr_t)XAddressGoodMask) - printf "Good " - if ((uintptr_t)$obj & (uintptr_t)XAddressMetadataRemapped) - printf "(Remapped)" - else - if ((uintptr_t)$obj & (uintptr_t)XAddressMetadataMarked) - printf "(Marked)" - else - printf "(Unknown)" - end - end - else - printf "Bad " - if ((uintptr_t)XAddressGoodMask & (uintptr_t)XAddressMetadataMarked) - # Should be marked - if ((uintptr_t)$obj & (uintptr_t)XAddressMetadataRemapped) - printf "(Not Marked, Remapped)" - else - printf "(Not Marked, Not Remapped)" - end - else - if ((uintptr_t)XAddressGoodMask & (uintptr_t)XAddressMetadataRemapped) - # Should be remapped - if ((uintptr_t)$obj & (uintptr_t)XAddressMetadataMarked) - printf "(Marked, Not Remapped)" - else - printf "(Not Marked, Not Remapped)" - end - else - # Unknown - printf "(Unknown)" - end - end - end - printf "\t Page: %llu\n", ((uintptr_t)$obj & XAddressOffsetMask) >> XGranuleSizeShift - x/16gx $obj - if (UseCompressedClassPointers) - set $klass = (Klass*)(void*)((uintptr_t)CompressedKlassPointers::_base +((uintptr_t)$obj->_metadata->_compressed_klass << CompressedKlassPointers::_shift)) - else - set $klass = $obj->_metadata->_klass - end - printf "Mark: 0x%016llx\tKlass: %s\n", (uintptr_t)$obj->_mark, (char*)$klass->_name->_body -end - -# Print heap page by page table index -define zpp - set $page = (XPage*)((uintptr_t)XHeap::_heap._page_table._map._map[($arg0)] & ~1) - printf "Page %p\n", $page - print *$page -end - -# Print page_table -define zpt - printf "Pagetable (first 128 slots)\n" - x/128gx XHeap::_heap._page_table._map._map -end - -# Print live map -define __zmarked - set $livemap = $arg0 - set $bit = $arg1 - set $size = $livemap._bitmap._size - set $segment = $size / XLiveMap::nsegments - set $segment_bit = 1 << $segment - - printf "Segment is " - if !($livemap._segment_live_bits & $segment_bit) - printf "NOT " - end - printf "live (segment %d)\n", $segment - - if $bit >= $size - print "Error: Bit %z out of bounds (bitmap size %z)\n", $bit, $size - else - set $word_index = $bit / 64 - set $bit_index = $bit % 64 - set $word = $livemap._bitmap._map[$word_index] - set $live_bit = $word & (1 << $bit_index) - - printf "Object is " - if $live_bit == 0 - printf "NOT " - end - printf "live (word index %d, bit index %d)\n", $word_index, $bit_index - end -end - -define zmarked - set $addr = $arg0 - set $obj = ((uintptr_t)$addr & XAddressOffsetMask) - set $page_index = $obj >> XGranuleSizeShift - set $page_entry = (uintptr_t)XHeap::_heap._page_table._map._map[$page_index] - set $page = (XPage*)($page_entry & ~1) - set $page_start = (uintptr_t)$page._virtual._start - set $page_end = (uintptr_t)$page._virtual._end - set $page_seqnum = $page._livemap._seqnum - set $global_seqnum = XGlobalSeqNum - - if $obj < $page_start || $obj >= $page_end - printf "Error: %p not in page %p (start %p, end %p)\n", $obj, $page, $page_start, $page_end - else - printf "Page is " - if $page_seqnum != $global_seqnum - printf "NOT " - end - printf "live (page %p, page seqnum %d, global seqnum %d)\n", $page, $page_seqnum, $global_seqnum - - #if $page_seqnum == $global_seqnum - set $offset = $obj - $page_start - set $bit = $offset / 8 - __zmarked $page._livemap $bit - #end - end -end - -# Print heap information -define zph - printf "Heap\n" - printf " GlobalPhase: %u\n", XGlobalPhase - printf " GlobalSeqNum: %u\n", XGlobalSeqNum - printf " Offset Max: %-15llu (0x%llx)\n", XAddressOffsetMax, XAddressOffsetMax - printf " Page Size Small: %-15llu (0x%llx)\n", XPageSizeSmall, XPageSizeSmall - printf " Page Size Medium: %-15llu (0x%llx)\n", XPageSizeMedium, XPageSizeMedium - printf "Metadata Bits\n" - printf " Good: 0x%016llx\n", XAddressGoodMask - printf " Bad: 0x%016llx\n", XAddressBadMask - printf " WeakBad: 0x%016llx\n", XAddressWeakBadMask - printf " Marked: 0x%016llx\n", XAddressMetadataMarked - printf " Remapped: 0x%016llx\n", XAddressMetadataRemapped -end - -# End of file diff --git a/src/hotspot/share/gc/x/xDirector.cpp b/src/hotspot/share/gc/x/xDirector.cpp deleted file mode 100644 index e1c69bd05b7..00000000000 --- a/src/hotspot/share/gc/x/xDirector.cpp +++ /dev/null @@ -1,406 +0,0 @@ -/* - * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/shared/gc_globals.hpp" -#include "gc/x/xDirector.hpp" -#include "gc/x/xDriver.hpp" -#include "gc/x/xHeap.inline.hpp" -#include "gc/x/xHeuristics.hpp" -#include "gc/x/xStat.hpp" -#include "logging/log.hpp" - -constexpr double one_in_1000 = 3.290527; -constexpr double sample_interval = 1.0 / XStatAllocRate::sample_hz; - -XDirector::XDirector(XDriver* driver) : - _driver(driver), - _metronome(XStatAllocRate::sample_hz) { - set_name("XDirector"); - create_and_start(); -} - -static void sample_allocation_rate() { - // Sample allocation rate. This is needed by rule_allocation_rate() - // below to estimate the time we have until we run out of memory. - const double bytes_per_second = XStatAllocRate::sample_and_reset(); - - log_debug(gc, alloc)("Allocation Rate: %.1fMB/s, Predicted: %.1fMB/s, Avg: %.1f(+/-%.1f)MB/s", - bytes_per_second / M, - XStatAllocRate::predict() / M, - XStatAllocRate::avg() / M, - XStatAllocRate::sd() / M); -} - -static XDriverRequest rule_allocation_stall() { - // Perform GC if we've observed at least one allocation stall since - // the last GC started. - if (!XHeap::heap()->has_alloc_stalled()) { - return GCCause::_no_gc; - } - - log_debug(gc, director)("Rule: Allocation Stall Observed"); - - return GCCause::_z_allocation_stall; -} - -static XDriverRequest rule_warmup() { - if (XStatCycle::is_warm()) { - // Rule disabled - return GCCause::_no_gc; - } - - // Perform GC if heap usage passes 10/20/30% and no other GC has been - // performed yet. This allows us to get some early samples of the GC - // duration, which is needed by the other rules. - const size_t soft_max_capacity = XHeap::heap()->soft_max_capacity(); - const size_t used = XHeap::heap()->used(); - const double used_threshold_percent = (XStatCycle::nwarmup_cycles() + 1) * 0.1; - const size_t used_threshold = soft_max_capacity * used_threshold_percent; - - log_debug(gc, director)("Rule: Warmup %.0f%%, Used: " SIZE_FORMAT "MB, UsedThreshold: " SIZE_FORMAT "MB", - used_threshold_percent * 100, used / M, used_threshold / M); - - if (used < used_threshold) { - return GCCause::_no_gc; - } - - return GCCause::_z_warmup; -} - -static XDriverRequest rule_timer() { - if (ZCollectionInterval <= 0) { - // Rule disabled - return GCCause::_no_gc; - } - - // Perform GC if timer has expired. - const double time_since_last_gc = XStatCycle::time_since_last(); - const double time_until_gc = ZCollectionInterval - time_since_last_gc; - - log_debug(gc, director)("Rule: Timer, Interval: %.3fs, TimeUntilGC: %.3fs", - ZCollectionInterval, time_until_gc); - - if (time_until_gc > 0) { - return GCCause::_no_gc; - } - - return GCCause::_z_timer; -} - -static double estimated_gc_workers(double serial_gc_time, double parallelizable_gc_time, double time_until_deadline) { - const double parallelizable_time_until_deadline = MAX2(time_until_deadline - serial_gc_time, 0.001); - return parallelizable_gc_time / parallelizable_time_until_deadline; -} - -static uint discrete_gc_workers(double gc_workers) { - return clamp(ceil(gc_workers), 1, ConcGCThreads); -} - -static double select_gc_workers(double serial_gc_time, double parallelizable_gc_time, double alloc_rate_sd_percent, double time_until_oom) { - // Use all workers until we're warm - if (!XStatCycle::is_warm()) { - const double not_warm_gc_workers = ConcGCThreads; - log_debug(gc, director)("Select GC Workers (Not Warm), GCWorkers: %.3f", not_warm_gc_workers); - return not_warm_gc_workers; - } - - // Calculate number of GC workers needed to avoid a long GC cycle and to avoid OOM. - const double avoid_long_gc_workers = estimated_gc_workers(serial_gc_time, parallelizable_gc_time, 10 /* seconds */); - const double avoid_oom_gc_workers = estimated_gc_workers(serial_gc_time, parallelizable_gc_time, time_until_oom); - - const double gc_workers = MAX2(avoid_long_gc_workers, avoid_oom_gc_workers); - const uint actual_gc_workers = discrete_gc_workers(gc_workers); - const uint last_gc_workers = XStatCycle::last_active_workers(); - - // More than 15% division from the average is considered unsteady - if (alloc_rate_sd_percent >= 0.15) { - const double half_gc_workers = ConcGCThreads / 2.0; - const double unsteady_gc_workers = MAX3(gc_workers, last_gc_workers, half_gc_workers); - log_debug(gc, director)("Select GC Workers (Unsteady), " - "AvoidLongGCWorkers: %.3f, AvoidOOMGCWorkers: %.3f, LastGCWorkers: %.3f, HalfGCWorkers: %.3f, GCWorkers: %.3f", - avoid_long_gc_workers, avoid_oom_gc_workers, (double)last_gc_workers, half_gc_workers, unsteady_gc_workers); - return unsteady_gc_workers; - } - - if (actual_gc_workers < last_gc_workers) { - // Before decreasing number of GC workers compared to the previous GC cycle, check if the - // next GC cycle will need to increase it again. If so, use the same number of GC workers - // that will be needed in the next cycle. - const double gc_duration_delta = (parallelizable_gc_time / actual_gc_workers) - (parallelizable_gc_time / last_gc_workers); - const double additional_time_for_allocations = XStatCycle::time_since_last() - gc_duration_delta - sample_interval; - const double next_time_until_oom = time_until_oom + additional_time_for_allocations; - const double next_avoid_oom_gc_workers = estimated_gc_workers(serial_gc_time, parallelizable_gc_time, next_time_until_oom); - - // Add 0.5 to increase friction and avoid lowering too eagerly - const double next_gc_workers = next_avoid_oom_gc_workers + 0.5; - const double try_lowering_gc_workers = clamp(next_gc_workers, actual_gc_workers, last_gc_workers); - - log_debug(gc, director)("Select GC Workers (Try Lowering), " - "AvoidLongGCWorkers: %.3f, AvoidOOMGCWorkers: %.3f, NextAvoidOOMGCWorkers: %.3f, LastGCWorkers: %.3f, GCWorkers: %.3f", - avoid_long_gc_workers, avoid_oom_gc_workers, next_avoid_oom_gc_workers, (double)last_gc_workers, try_lowering_gc_workers); - return try_lowering_gc_workers; - } - - log_debug(gc, director)("Select GC Workers (Normal), " - "AvoidLongGCWorkers: %.3f, AvoidOOMGCWorkers: %.3f, LastGCWorkers: %.3f, GCWorkers: %.3f", - avoid_long_gc_workers, avoid_oom_gc_workers, (double)last_gc_workers, gc_workers); - return gc_workers; -} - -static XDriverRequest rule_allocation_rate_dynamic() { - if (!XStatCycle::is_time_trustable()) { - // Rule disabled - return GCCause::_no_gc; - } - - // Calculate amount of free memory available. Note that we take the - // relocation headroom into account to avoid in-place relocation. - const size_t soft_max_capacity = XHeap::heap()->soft_max_capacity(); - const size_t used = XHeap::heap()->used(); - const size_t free_including_headroom = soft_max_capacity - MIN2(soft_max_capacity, used); - const size_t free = free_including_headroom - MIN2(free_including_headroom, XHeuristics::relocation_headroom()); - - // Calculate time until OOM given the max allocation rate and the amount - // of free memory. The allocation rate is a moving average and we multiply - // that with an allocation spike tolerance factor to guard against unforeseen - // phase changes in the allocate rate. We then add ~3.3 sigma to account for - // the allocation rate variance, which means the probability is 1 in 1000 - // that a sample is outside of the confidence interval. - const double alloc_rate_predict = XStatAllocRate::predict(); - const double alloc_rate_avg = XStatAllocRate::avg(); - const double alloc_rate_sd = XStatAllocRate::sd(); - const double alloc_rate_sd_percent = alloc_rate_sd / (alloc_rate_avg + 1.0); - const double alloc_rate = (MAX2(alloc_rate_predict, alloc_rate_avg) * ZAllocationSpikeTolerance) + (alloc_rate_sd * one_in_1000) + 1.0; - const double time_until_oom = (free / alloc_rate) / (1.0 + alloc_rate_sd_percent); - - // Calculate max serial/parallel times of a GC cycle. The times are - // moving averages, we add ~3.3 sigma to account for the variance. - const double serial_gc_time = XStatCycle::serial_time().davg() + (XStatCycle::serial_time().dsd() * one_in_1000); - const double parallelizable_gc_time = XStatCycle::parallelizable_time().davg() + (XStatCycle::parallelizable_time().dsd() * one_in_1000); - - // Calculate number of GC workers needed to avoid OOM. - const double gc_workers = select_gc_workers(serial_gc_time, parallelizable_gc_time, alloc_rate_sd_percent, time_until_oom); - - // Convert to a discrete number of GC workers within limits. - const uint actual_gc_workers = discrete_gc_workers(gc_workers); - - // Calculate GC duration given number of GC workers needed. - const double actual_gc_duration = serial_gc_time + (parallelizable_gc_time / actual_gc_workers); - const uint last_gc_workers = XStatCycle::last_active_workers(); - - // Calculate time until GC given the time until OOM and GC duration. - // We also subtract the sample interval, so that we don't overshoot the - // target time and end up starting the GC too late in the next interval. - const double time_until_gc = time_until_oom - actual_gc_duration - sample_interval; - - log_debug(gc, director)("Rule: Allocation Rate (Dynamic GC Workers), " - "MaxAllocRate: %.1fMB/s (+/-%.1f%%), Free: " SIZE_FORMAT "MB, GCCPUTime: %.3f, " - "GCDuration: %.3fs, TimeUntilOOM: %.3fs, TimeUntilGC: %.3fs, GCWorkers: %u -> %u", - alloc_rate / M, - alloc_rate_sd_percent * 100, - free / M, - serial_gc_time + parallelizable_gc_time, - serial_gc_time + (parallelizable_gc_time / actual_gc_workers), - time_until_oom, - time_until_gc, - last_gc_workers, - actual_gc_workers); - - if (actual_gc_workers <= last_gc_workers && time_until_gc > 0) { - return XDriverRequest(GCCause::_no_gc, actual_gc_workers); - } - - return XDriverRequest(GCCause::_z_allocation_rate, actual_gc_workers); -} - -static XDriverRequest rule_allocation_rate_static() { - if (!XStatCycle::is_time_trustable()) { - // Rule disabled - return GCCause::_no_gc; - } - - // Perform GC if the estimated max allocation rate indicates that we - // will run out of memory. The estimated max allocation rate is based - // on the moving average of the sampled allocation rate plus a safety - // margin based on variations in the allocation rate and unforeseen - // allocation spikes. - - // Calculate amount of free memory available. Note that we take the - // relocation headroom into account to avoid in-place relocation. - const size_t soft_max_capacity = XHeap::heap()->soft_max_capacity(); - const size_t used = XHeap::heap()->used(); - const size_t free_including_headroom = soft_max_capacity - MIN2(soft_max_capacity, used); - const size_t free = free_including_headroom - MIN2(free_including_headroom, XHeuristics::relocation_headroom()); - - // Calculate time until OOM given the max allocation rate and the amount - // of free memory. The allocation rate is a moving average and we multiply - // that with an allocation spike tolerance factor to guard against unforeseen - // phase changes in the allocate rate. We then add ~3.3 sigma to account for - // the allocation rate variance, which means the probability is 1 in 1000 - // that a sample is outside of the confidence interval. - const double max_alloc_rate = (XStatAllocRate::avg() * ZAllocationSpikeTolerance) + (XStatAllocRate::sd() * one_in_1000); - const double time_until_oom = free / (max_alloc_rate + 1.0); // Plus 1.0B/s to avoid division by zero - - // Calculate max serial/parallel times of a GC cycle. The times are - // moving averages, we add ~3.3 sigma to account for the variance. - const double serial_gc_time = XStatCycle::serial_time().davg() + (XStatCycle::serial_time().dsd() * one_in_1000); - const double parallelizable_gc_time = XStatCycle::parallelizable_time().davg() + (XStatCycle::parallelizable_time().dsd() * one_in_1000); - - // Calculate GC duration given number of GC workers needed. - const double gc_duration = serial_gc_time + (parallelizable_gc_time / ConcGCThreads); - - // Calculate time until GC given the time until OOM and max duration of GC. - // We also deduct the sample interval, so that we don't overshoot the target - // time and end up starting the GC too late in the next interval. - const double time_until_gc = time_until_oom - gc_duration - sample_interval; - - log_debug(gc, director)("Rule: Allocation Rate (Static GC Workers), MaxAllocRate: %.1fMB/s, Free: " SIZE_FORMAT "MB, GCDuration: %.3fs, TimeUntilGC: %.3fs", - max_alloc_rate / M, free / M, gc_duration, time_until_gc); - - if (time_until_gc > 0) { - return GCCause::_no_gc; - } - - return GCCause::_z_allocation_rate; -} - -static XDriverRequest rule_allocation_rate() { - if (UseDynamicNumberOfGCThreads) { - return rule_allocation_rate_dynamic(); - } else { - return rule_allocation_rate_static(); - } -} - -static XDriverRequest rule_high_usage() { - // Perform GC if the amount of free memory is 5% or less. This is a preventive - // meassure in the case where the application has a very low allocation rate, - // such that the allocation rate rule doesn't trigger, but the amount of free - // memory is still slowly but surely heading towards zero. In this situation, - // we start a GC cycle to avoid a potential allocation stall later. - - // Calculate amount of free memory available. Note that we take the - // relocation headroom into account to avoid in-place relocation. - const size_t soft_max_capacity = XHeap::heap()->soft_max_capacity(); - const size_t used = XHeap::heap()->used(); - const size_t free_including_headroom = soft_max_capacity - MIN2(soft_max_capacity, used); - const size_t free = free_including_headroom - MIN2(free_including_headroom, XHeuristics::relocation_headroom()); - const double free_percent = percent_of(free, soft_max_capacity); - - log_debug(gc, director)("Rule: High Usage, Free: " SIZE_FORMAT "MB(%.1f%%)", - free / M, free_percent); - - if (free_percent > 5.0) { - return GCCause::_no_gc; - } - - return GCCause::_z_high_usage; -} - -static XDriverRequest rule_proactive() { - if (!ZProactive || !XStatCycle::is_warm()) { - // Rule disabled - return GCCause::_no_gc; - } - - // Perform GC if the impact of doing so, in terms of application throughput - // reduction, is considered acceptable. This rule allows us to keep the heap - // size down and allow reference processing to happen even when we have a lot - // of free space on the heap. - - // Only consider doing a proactive GC if the heap usage has grown by at least - // 10% of the max capacity since the previous GC, or more than 5 minutes has - // passed since the previous GC. This helps avoid superfluous GCs when running - // applications with very low allocation rate. - const size_t used_after_last_gc = XStatHeap::used_at_relocate_end(); - const size_t used_increase_threshold = XHeap::heap()->soft_max_capacity() * 0.10; // 10% - const size_t used_threshold = used_after_last_gc + used_increase_threshold; - const size_t used = XHeap::heap()->used(); - const double time_since_last_gc = XStatCycle::time_since_last(); - const double time_since_last_gc_threshold = 5 * 60; // 5 minutes - if (used < used_threshold && time_since_last_gc < time_since_last_gc_threshold) { - // Don't even consider doing a proactive GC - log_debug(gc, director)("Rule: Proactive, UsedUntilEnabled: " SIZE_FORMAT "MB, TimeUntilEnabled: %.3fs", - (used_threshold - used) / M, - time_since_last_gc_threshold - time_since_last_gc); - return GCCause::_no_gc; - } - - const double assumed_throughput_drop_during_gc = 0.50; // 50% - const double acceptable_throughput_drop = 0.01; // 1% - const double serial_gc_time = XStatCycle::serial_time().davg() + (XStatCycle::serial_time().dsd() * one_in_1000); - const double parallelizable_gc_time = XStatCycle::parallelizable_time().davg() + (XStatCycle::parallelizable_time().dsd() * one_in_1000); - const double gc_duration = serial_gc_time + (parallelizable_gc_time / ConcGCThreads); - const double acceptable_gc_interval = gc_duration * ((assumed_throughput_drop_during_gc / acceptable_throughput_drop) - 1.0); - const double time_until_gc = acceptable_gc_interval - time_since_last_gc; - - log_debug(gc, director)("Rule: Proactive, AcceptableGCInterval: %.3fs, TimeSinceLastGC: %.3fs, TimeUntilGC: %.3fs", - acceptable_gc_interval, time_since_last_gc, time_until_gc); - - if (time_until_gc > 0) { - return GCCause::_no_gc; - } - - return GCCause::_z_proactive; -} - -static XDriverRequest make_gc_decision() { - // List of rules - using XDirectorRule = XDriverRequest (*)(); - const XDirectorRule rules[] = { - rule_allocation_stall, - rule_warmup, - rule_timer, - rule_allocation_rate, - rule_high_usage, - rule_proactive, - }; - - // Execute rules - for (size_t i = 0; i < ARRAY_SIZE(rules); i++) { - const XDriverRequest request = rules[i](); - if (request.cause() != GCCause::_no_gc) { - return request; - } - } - - return GCCause::_no_gc; -} - -void XDirector::run_service() { - // Main loop - while (_metronome.wait_for_tick()) { - sample_allocation_rate(); - if (!_driver->is_busy()) { - const XDriverRequest request = make_gc_decision(); - if (request.cause() != GCCause::_no_gc) { - _driver->collect(request); - } - } - } -} - -void XDirector::stop_service() { - _metronome.stop(); -} diff --git a/src/hotspot/share/gc/x/xDirector.hpp b/src/hotspot/share/gc/x/xDirector.hpp deleted file mode 100644 index eacce20e8c9..00000000000 --- a/src/hotspot/share/gc/x/xDirector.hpp +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2015, 2021, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XDIRECTOR_HPP -#define SHARE_GC_X_XDIRECTOR_HPP - -#include "gc/shared/concurrentGCThread.hpp" -#include "gc/x/xMetronome.hpp" - -class XDriver; - -class XDirector : public ConcurrentGCThread { -private: - XDriver* const _driver; - XMetronome _metronome; - -protected: - virtual void run_service(); - virtual void stop_service(); - -public: - XDirector(XDriver* driver); -}; - -#endif // SHARE_GC_X_XDIRECTOR_HPP diff --git a/src/hotspot/share/gc/x/xDriver.cpp b/src/hotspot/share/gc/x/xDriver.cpp deleted file mode 100644 index 3e6fd03134e..00000000000 --- a/src/hotspot/share/gc/x/xDriver.cpp +++ /dev/null @@ -1,518 +0,0 @@ -/* - * Copyright (c) 2015, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/shared/gcId.hpp" -#include "gc/shared/gcLocker.hpp" -#include "gc/shared/gcVMOperations.hpp" -#include "gc/shared/isGCActiveMark.hpp" -#include "gc/x/xAbort.inline.hpp" -#include "gc/x/xBreakpoint.hpp" -#include "gc/x/xCollectedHeap.hpp" -#include "gc/x/xDriver.hpp" -#include "gc/x/xHeap.inline.hpp" -#include "gc/x/xMessagePort.inline.hpp" -#include "gc/x/xServiceability.hpp" -#include "gc/x/xStat.hpp" -#include "gc/x/xVerify.hpp" -#include "interpreter/oopMapCache.hpp" -#include "logging/log.hpp" -#include "memory/universe.hpp" -#include "runtime/threads.hpp" -#include "runtime/vmOperations.hpp" -#include "runtime/vmThread.hpp" - -static const XStatPhaseCycle XPhaseCycle("Garbage Collection Cycle"); -static const XStatPhasePause XPhasePauseMarkStart("Pause Mark Start"); -static const XStatPhaseConcurrent XPhaseConcurrentMark("Concurrent Mark"); -static const XStatPhaseConcurrent XPhaseConcurrentMarkContinue("Concurrent Mark Continue"); -static const XStatPhaseConcurrent XPhaseConcurrentMarkFree("Concurrent Mark Free"); -static const XStatPhasePause XPhasePauseMarkEnd("Pause Mark End"); -static const XStatPhaseConcurrent XPhaseConcurrentProcessNonStrongReferences("Concurrent Process Non-Strong References"); -static const XStatPhaseConcurrent XPhaseConcurrentResetRelocationSet("Concurrent Reset Relocation Set"); -static const XStatPhaseConcurrent XPhaseConcurrentSelectRelocationSet("Concurrent Select Relocation Set"); -static const XStatPhasePause XPhasePauseRelocateStart("Pause Relocate Start"); -static const XStatPhaseConcurrent XPhaseConcurrentRelocated("Concurrent Relocate"); -static const XStatCriticalPhase XCriticalPhaseGCLockerStall("GC Locker Stall", false /* verbose */); -static const XStatSampler XSamplerJavaThreads("System", "Java Threads", XStatUnitThreads); - -XDriverRequest::XDriverRequest() : - XDriverRequest(GCCause::_no_gc) {} - -XDriverRequest::XDriverRequest(GCCause::Cause cause) : - XDriverRequest(cause, ConcGCThreads) {} - -XDriverRequest::XDriverRequest(GCCause::Cause cause, uint nworkers) : - _cause(cause), - _nworkers(nworkers) {} - -bool XDriverRequest::operator==(const XDriverRequest& other) const { - return _cause == other._cause; -} - -GCCause::Cause XDriverRequest::cause() const { - return _cause; -} - -uint XDriverRequest::nworkers() const { - return _nworkers; -} - -class VM_XOperation : public VM_Operation { -private: - const uint _gc_id; - bool _gc_locked; - bool _success; - -public: - VM_XOperation() : - _gc_id(GCId::current()), - _gc_locked(false), - _success(false) {} - - virtual bool needs_inactive_gc_locker() const { - // An inactive GC locker is needed in operations where we change the bad - // mask or move objects. Changing the bad mask will invalidate all oops, - // which makes it conceptually the same thing as moving all objects. - return false; - } - - virtual bool skip_thread_oop_barriers() const { - return true; - } - - virtual bool do_operation() = 0; - - virtual bool doit_prologue() { - Heap_lock->lock(); - return true; - } - - virtual void doit() { - // Abort if GC locker state is incompatible - if (needs_inactive_gc_locker() && GCLocker::check_active_before_gc()) { - _gc_locked = true; - return; - } - - // Setup GC id and active marker - GCIdMark gc_id_mark(_gc_id); - IsSTWGCActiveMark gc_active_mark; - - // Verify before operation - XVerify::before_zoperation(); - - // Execute operation - _success = do_operation(); - - // Update statistics - XStatSample(XSamplerJavaThreads, Threads::number_of_threads()); - } - - virtual void doit_epilogue() { - Heap_lock->unlock(); - - // GC thread root traversal likely used OopMapCache a lot, which - // might have created lots of old entries. Trigger the cleanup now. - OopMapCache::try_trigger_cleanup(); - } - - bool gc_locked() const { - return _gc_locked; - } - - bool success() const { - return _success; - } -}; - -class VM_XMarkStart : public VM_XOperation { -public: - virtual VMOp_Type type() const { - return VMOp_XMarkStart; - } - - virtual bool needs_inactive_gc_locker() const { - return true; - } - - virtual bool do_operation() { - XStatTimer timer(XPhasePauseMarkStart); - XServiceabilityPauseTracer tracer; - - XCollectedHeap::heap()->increment_total_collections(true /* full */); - - XHeap::heap()->mark_start(); - return true; - } -}; - -class VM_XMarkEnd : public VM_XOperation { -public: - virtual VMOp_Type type() const { - return VMOp_XMarkEnd; - } - - virtual bool do_operation() { - XStatTimer timer(XPhasePauseMarkEnd); - XServiceabilityPauseTracer tracer; - return XHeap::heap()->mark_end(); - } -}; - -class VM_XRelocateStart : public VM_XOperation { -public: - virtual VMOp_Type type() const { - return VMOp_XRelocateStart; - } - - virtual bool needs_inactive_gc_locker() const { - return true; - } - - virtual bool do_operation() { - XStatTimer timer(XPhasePauseRelocateStart); - XServiceabilityPauseTracer tracer; - XHeap::heap()->relocate_start(); - return true; - } -}; - -class VM_XVerify : public VM_Operation { -public: - virtual VMOp_Type type() const { - return VMOp_XVerify; - } - - virtual bool skip_thread_oop_barriers() const { - return true; - } - - virtual void doit() { - XVerify::after_weak_processing(); - } -}; - -XDriver::XDriver() : - _gc_cycle_port(), - _gc_locker_port() { - set_name("XDriver"); - create_and_start(); -} - -bool XDriver::is_busy() const { - return _gc_cycle_port.is_busy(); -} - -void XDriver::collect(const XDriverRequest& request) { - switch (request.cause()) { - case GCCause::_heap_dump: - case GCCause::_heap_inspection: - case GCCause::_wb_young_gc: - case GCCause::_wb_full_gc: - case GCCause::_dcmd_gc_run: - case GCCause::_java_lang_system_gc: - case GCCause::_full_gc_alot: - case GCCause::_scavenge_alot: - case GCCause::_jvmti_force_gc: - case GCCause::_metadata_GC_clear_soft_refs: - case GCCause::_codecache_GC_aggressive: - // Start synchronous GC - _gc_cycle_port.send_sync(request); - break; - - case GCCause::_z_timer: - case GCCause::_z_warmup: - case GCCause::_z_allocation_rate: - case GCCause::_z_allocation_stall: - case GCCause::_z_proactive: - case GCCause::_z_high_usage: - case GCCause::_codecache_GC_threshold: - case GCCause::_metadata_GC_threshold: - // Start asynchronous GC - _gc_cycle_port.send_async(request); - break; - - case GCCause::_gc_locker: - // Restart VM operation previously blocked by the GC locker - _gc_locker_port.signal(); - break; - - case GCCause::_wb_breakpoint: - XBreakpoint::start_gc(); - _gc_cycle_port.send_async(request); - break; - - default: - // Other causes not supported - fatal("Unsupported GC cause (%s)", GCCause::to_string(request.cause())); - break; - } -} - -template -bool XDriver::pause() { - for (;;) { - T op; - VMThread::execute(&op); - if (op.gc_locked()) { - // Wait for GC to become unlocked and restart the VM operation - XStatTimer timer(XCriticalPhaseGCLockerStall); - _gc_locker_port.wait(); - continue; - } - - // Notify VM operation completed - _gc_locker_port.ack(); - - return op.success(); - } -} - -void XDriver::pause_mark_start() { - pause(); -} - -void XDriver::concurrent_mark() { - XStatTimer timer(XPhaseConcurrentMark); - XBreakpoint::at_after_marking_started(); - XHeap::heap()->mark(true /* initial */); - XBreakpoint::at_before_marking_completed(); -} - -bool XDriver::pause_mark_end() { - return pause(); -} - -void XDriver::concurrent_mark_continue() { - XStatTimer timer(XPhaseConcurrentMarkContinue); - XHeap::heap()->mark(false /* initial */); -} - -void XDriver::concurrent_mark_free() { - XStatTimer timer(XPhaseConcurrentMarkFree); - XHeap::heap()->mark_free(); -} - -void XDriver::concurrent_process_non_strong_references() { - XStatTimer timer(XPhaseConcurrentProcessNonStrongReferences); - XBreakpoint::at_after_reference_processing_started(); - XHeap::heap()->process_non_strong_references(); -} - -void XDriver::concurrent_reset_relocation_set() { - XStatTimer timer(XPhaseConcurrentResetRelocationSet); - XHeap::heap()->reset_relocation_set(); -} - -void XDriver::pause_verify() { - if (ZVerifyRoots || ZVerifyObjects) { - VM_XVerify op; - VMThread::execute(&op); - } -} - -void XDriver::concurrent_select_relocation_set() { - XStatTimer timer(XPhaseConcurrentSelectRelocationSet); - XHeap::heap()->select_relocation_set(); -} - -void XDriver::pause_relocate_start() { - pause(); -} - -void XDriver::concurrent_relocate() { - XStatTimer timer(XPhaseConcurrentRelocated); - XHeap::heap()->relocate(); -} - -void XDriver::check_out_of_memory() { - XHeap::heap()->check_out_of_memory(); -} - -static bool should_clear_soft_references(const XDriverRequest& request) { - // Clear soft references if implied by the GC cause - if (request.cause() == GCCause::_wb_full_gc || - request.cause() == GCCause::_metadata_GC_clear_soft_refs || - request.cause() == GCCause::_z_allocation_stall) { - // Clear - return true; - } - - // Don't clear - return false; -} - -static uint select_active_worker_threads_dynamic(const XDriverRequest& request) { - // Use requested number of worker threads - return request.nworkers(); -} - -static uint select_active_worker_threads_static(const XDriverRequest& request) { - const GCCause::Cause cause = request.cause(); - const uint nworkers = request.nworkers(); - - // Boost number of worker threads if implied by the GC cause - if (cause == GCCause::_wb_full_gc || - cause == GCCause::_java_lang_system_gc || - cause == GCCause::_metadata_GC_clear_soft_refs || - cause == GCCause::_z_allocation_stall) { - // Boost - const uint boosted_nworkers = MAX2(nworkers, ParallelGCThreads); - return boosted_nworkers; - } - - // Use requested number of worker threads - return nworkers; -} - -static uint select_active_worker_threads(const XDriverRequest& request) { - if (UseDynamicNumberOfGCThreads) { - return select_active_worker_threads_dynamic(request); - } else { - return select_active_worker_threads_static(request); - } -} - -class XDriverGCScope : public StackObj { -private: - GCIdMark _gc_id; - GCCause::Cause _gc_cause; - GCCauseSetter _gc_cause_setter; - XStatTimer _timer; - XServiceabilityCycleTracer _tracer; - -public: - XDriverGCScope(const XDriverRequest& request) : - _gc_id(), - _gc_cause(request.cause()), - _gc_cause_setter(XCollectedHeap::heap(), _gc_cause), - _timer(XPhaseCycle), - _tracer() { - // Update statistics - XStatCycle::at_start(); - - // Set up soft reference policy - const bool clear = should_clear_soft_references(request); - XHeap::heap()->set_soft_reference_policy(clear); - - // Select number of worker threads to use - const uint nworkers = select_active_worker_threads(request); - XHeap::heap()->set_active_workers(nworkers); - } - - ~XDriverGCScope() { - // Update statistics - XStatCycle::at_end(_gc_cause, XHeap::heap()->active_workers()); - - // Update data used by soft reference policy - Universe::heap()->update_capacity_and_used_at_gc(); - - // Signal that we have completed a visit to all live objects - Universe::heap()->record_whole_heap_examined_timestamp(); - } -}; - -// Macro to execute a termination check after a concurrent phase. Note -// that it's important that the termination check comes after the call -// to the function f, since we can't abort between pause_relocate_start() -// and concurrent_relocate(). We need to let concurrent_relocate() call -// abort_page() on the remaining entries in the relocation set. -#define concurrent(f) \ - do { \ - concurrent_##f(); \ - if (should_terminate()) { \ - return; \ - } \ - } while (false) - -void XDriver::gc(const XDriverRequest& request) { - XDriverGCScope scope(request); - - // Phase 1: Pause Mark Start - pause_mark_start(); - - // Phase 2: Concurrent Mark - concurrent(mark); - - // Phase 3: Pause Mark End - while (!pause_mark_end()) { - // Phase 3.5: Concurrent Mark Continue - concurrent(mark_continue); - } - - // Phase 4: Concurrent Mark Free - concurrent(mark_free); - - // Phase 5: Concurrent Process Non-Strong References - concurrent(process_non_strong_references); - - // Phase 6: Concurrent Reset Relocation Set - concurrent(reset_relocation_set); - - // Phase 7: Pause Verify - pause_verify(); - - // Phase 8: Concurrent Select Relocation Set - concurrent(select_relocation_set); - - // Phase 9: Pause Relocate Start - pause_relocate_start(); - - // Phase 10: Concurrent Relocate - concurrent(relocate); -} - -void XDriver::run_service() { - // Main loop - while (!should_terminate()) { - // Wait for GC request - const XDriverRequest request = _gc_cycle_port.receive(); - if (request.cause() == GCCause::_no_gc) { - continue; - } - - XBreakpoint::at_before_gc(); - - // Run GC - gc(request); - - if (should_terminate()) { - // Abort - break; - } - - // Notify GC completed - _gc_cycle_port.ack(); - - // Check for out of memory condition - check_out_of_memory(); - - XBreakpoint::at_after_gc(); - } -} - -void XDriver::stop_service() { - XAbort::abort(); - _gc_cycle_port.send_async(GCCause::_no_gc); -} diff --git a/src/hotspot/share/gc/x/xDriver.hpp b/src/hotspot/share/gc/x/xDriver.hpp deleted file mode 100644 index 3803b699b85..00000000000 --- a/src/hotspot/share/gc/x/xDriver.hpp +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright (c) 2015, 2021, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XDRIVER_HPP -#define SHARE_GC_X_XDRIVER_HPP - -#include "gc/shared/concurrentGCThread.hpp" -#include "gc/shared/gcCause.hpp" -#include "gc/x/xMessagePort.hpp" - -class VM_XOperation; - -class XDriverRequest { -private: - GCCause::Cause _cause; - uint _nworkers; - -public: - XDriverRequest(); - XDriverRequest(GCCause::Cause cause); - XDriverRequest(GCCause::Cause cause, uint nworkers); - - bool operator==(const XDriverRequest& other) const; - - GCCause::Cause cause() const; - uint nworkers() const; -}; - -class XDriver : public ConcurrentGCThread { -private: - XMessagePort _gc_cycle_port; - XRendezvousPort _gc_locker_port; - - template bool pause(); - - void pause_mark_start(); - void concurrent_mark(); - bool pause_mark_end(); - void concurrent_mark_continue(); - void concurrent_mark_free(); - void concurrent_process_non_strong_references(); - void concurrent_reset_relocation_set(); - void pause_verify(); - void concurrent_select_relocation_set(); - void pause_relocate_start(); - void concurrent_relocate(); - - void check_out_of_memory(); - - void gc(const XDriverRequest& request); - -protected: - virtual void run_service(); - virtual void stop_service(); - -public: - XDriver(); - - bool is_busy() const; - - void collect(const XDriverRequest& request); -}; - -#endif // SHARE_GC_X_XDRIVER_HPP diff --git a/src/hotspot/share/gc/x/xErrno.cpp b/src/hotspot/share/gc/x/xErrno.cpp deleted file mode 100644 index 64951bc47ab..00000000000 --- a/src/hotspot/share/gc/x/xErrno.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2015, 2021, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/x/xErrno.hpp" -#include "runtime/os.hpp" - -#include -#include - -XErrno::XErrno() : - _error(errno) {} - -XErrno::XErrno(int error) : - _error(error) {} - -XErrno::operator bool() const { - return _error != 0; -} - -bool XErrno::operator==(int error) const { - return _error == error; -} - -bool XErrno::operator!=(int error) const { - return _error != error; -} - -const char* XErrno::to_string() const { - return os::strerror(_error); -} diff --git a/src/hotspot/share/gc/x/xErrno.hpp b/src/hotspot/share/gc/x/xErrno.hpp deleted file mode 100644 index eb72d43da3f..00000000000 --- a/src/hotspot/share/gc/x/xErrno.hpp +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2015, 2017, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XERRNO_HPP -#define SHARE_GC_X_XERRNO_HPP - -#include "memory/allocation.hpp" - -class XErrno : public StackObj { -private: - const int _error; - -public: - XErrno(); - XErrno(int error); - - operator bool() const; - bool operator==(int error) const; - bool operator!=(int error) const; - const char* to_string() const; -}; - -#endif // SHARE_GC_X_XERRNO_HPP diff --git a/src/hotspot/share/gc/x/xForwarding.cpp b/src/hotspot/share/gc/x/xForwarding.cpp deleted file mode 100644 index aa0cd4dff0b..00000000000 --- a/src/hotspot/share/gc/x/xForwarding.cpp +++ /dev/null @@ -1,210 +0,0 @@ -/* - * Copyright (c) 2015, 2020, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/x/xAddress.inline.hpp" -#include "gc/x/xForwarding.inline.hpp" -#include "gc/x/xStat.hpp" -#include "gc/x/xUtils.inline.hpp" -#include "utilities/align.hpp" - -// -// Reference count states: -// -// * If the reference count is zero, it will never change again. -// -// * If the reference count is positive, it can be both retained -// (increased) and released (decreased). -// -// * If the reference count is negative, is can only be released -// (increased). A negative reference count means that one or more -// threads are waiting for one or more other threads to release -// their references. -// -// The reference lock is used for waiting until the reference -// count has become zero (released) or negative one (claimed). -// - -static const XStatCriticalPhase XCriticalPhaseRelocationStall("Relocation Stall"); - -bool XForwarding::retain_page() { - for (;;) { - const int32_t ref_count = Atomic::load_acquire(&_ref_count); - - if (ref_count == 0) { - // Released - return false; - } - - if (ref_count < 0) { - // Claimed - const bool success = wait_page_released(); - assert(success, "Should always succeed"); - return false; - } - - if (Atomic::cmpxchg(&_ref_count, ref_count, ref_count + 1) == ref_count) { - // Retained - return true; - } - } -} - -XPage* XForwarding::claim_page() { - for (;;) { - const int32_t ref_count = Atomic::load(&_ref_count); - assert(ref_count > 0, "Invalid state"); - - // Invert reference count - if (Atomic::cmpxchg(&_ref_count, ref_count, -ref_count) != ref_count) { - continue; - } - - // If the previous reference count was 1, then we just changed it to -1, - // and we have now claimed the page. Otherwise we wait until it is claimed. - if (ref_count != 1) { - XLocker locker(&_ref_lock); - while (Atomic::load_acquire(&_ref_count) != -1) { - _ref_lock.wait(); - } - } - - return _page; - } -} - -void XForwarding::release_page() { - for (;;) { - const int32_t ref_count = Atomic::load(&_ref_count); - assert(ref_count != 0, "Invalid state"); - - if (ref_count > 0) { - // Decrement reference count - if (Atomic::cmpxchg(&_ref_count, ref_count, ref_count - 1) != ref_count) { - continue; - } - - // If the previous reference count was 1, then we just decremented - // it to 0 and we should signal that the page is now released. - if (ref_count == 1) { - // Notify released - XLocker locker(&_ref_lock); - _ref_lock.notify_all(); - } - } else { - // Increment reference count - if (Atomic::cmpxchg(&_ref_count, ref_count, ref_count + 1) != ref_count) { - continue; - } - - // If the previous reference count was -2 or -1, then we just incremented it - // to -1 or 0, and we should signal the that page is now claimed or released. - if (ref_count == -2 || ref_count == -1) { - // Notify claimed or released - XLocker locker(&_ref_lock); - _ref_lock.notify_all(); - } - } - - return; - } -} - -bool XForwarding::wait_page_released() const { - if (Atomic::load_acquire(&_ref_count) != 0) { - XStatTimer timer(XCriticalPhaseRelocationStall); - XLocker locker(&_ref_lock); - while (Atomic::load_acquire(&_ref_count) != 0) { - if (_ref_abort) { - return false; - } - - _ref_lock.wait(); - } - } - - return true; -} - -XPage* XForwarding::detach_page() { - // Wait until released - if (Atomic::load_acquire(&_ref_count) != 0) { - XLocker locker(&_ref_lock); - while (Atomic::load_acquire(&_ref_count) != 0) { - _ref_lock.wait(); - } - } - - // Detach and return page - XPage* const page = _page; - _page = nullptr; - return page; -} - -void XForwarding::abort_page() { - XLocker locker(&_ref_lock); - assert(Atomic::load(&_ref_count) > 0, "Invalid state"); - assert(!_ref_abort, "Invalid state"); - _ref_abort = true; - _ref_lock.notify_all(); -} - -void XForwarding::verify() const { - guarantee(_ref_count != 0, "Invalid reference count"); - guarantee(_page != nullptr, "Invalid page"); - - uint32_t live_objects = 0; - size_t live_bytes = 0; - - for (XForwardingCursor i = 0; i < _entries.length(); i++) { - const XForwardingEntry entry = at(&i); - if (!entry.populated()) { - // Skip empty entries - continue; - } - - // Check from index - guarantee(entry.from_index() < _page->object_max_count(), "Invalid from index"); - - // Check for duplicates - for (XForwardingCursor j = i + 1; j < _entries.length(); j++) { - const XForwardingEntry other = at(&j); - if (!other.populated()) { - // Skip empty entries - continue; - } - - guarantee(entry.from_index() != other.from_index(), "Duplicate from"); - guarantee(entry.to_offset() != other.to_offset(), "Duplicate to"); - } - - const uintptr_t to_addr = XAddress::good(entry.to_offset()); - const size_t size = XUtils::object_size(to_addr); - const size_t aligned_size = align_up(size, _page->object_alignment()); - live_bytes += aligned_size; - live_objects++; - } - - // Verify number of live objects and bytes - _page->verify_live(live_objects, live_bytes); -} diff --git a/src/hotspot/share/gc/x/xForwarding.hpp b/src/hotspot/share/gc/x/xForwarding.hpp deleted file mode 100644 index a6185e23ced..00000000000 --- a/src/hotspot/share/gc/x/xForwarding.hpp +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2015, 2020, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XFORWARDING_HPP -#define SHARE_GC_X_XFORWARDING_HPP - -#include "gc/x/xAttachedArray.hpp" -#include "gc/x/xForwardingEntry.hpp" -#include "gc/x/xLock.hpp" -#include "gc/x/xVirtualMemory.hpp" - -class ObjectClosure; -class VMStructs; -class XForwardingAllocator; -class XPage; - -typedef size_t XForwardingCursor; - -class XForwarding { - friend class ::VMStructs; - friend class XForwardingTest; - -private: - typedef XAttachedArray AttachedArray; - - const XVirtualMemory _virtual; - const size_t _object_alignment_shift; - const AttachedArray _entries; - XPage* _page; - mutable XConditionLock _ref_lock; - volatile int32_t _ref_count; - bool _ref_abort; - bool _in_place; - - XForwardingEntry* entries() const; - XForwardingEntry at(XForwardingCursor* cursor) const; - XForwardingEntry first(uintptr_t from_index, XForwardingCursor* cursor) const; - XForwardingEntry next(XForwardingCursor* cursor) const; - - XForwarding(XPage* page, size_t nentries); - -public: - static uint32_t nentries(const XPage* page); - static XForwarding* alloc(XForwardingAllocator* allocator, XPage* page); - - uint8_t type() const; - uintptr_t start() const; - size_t size() const; - size_t object_alignment_shift() const; - void object_iterate(ObjectClosure *cl); - - bool retain_page(); - XPage* claim_page(); - void release_page(); - bool wait_page_released() const; - XPage* detach_page(); - void abort_page(); - - void set_in_place(); - bool in_place() const; - - XForwardingEntry find(uintptr_t from_index, XForwardingCursor* cursor) const; - uintptr_t insert(uintptr_t from_index, uintptr_t to_offset, XForwardingCursor* cursor); - - void verify() const; -}; - -#endif // SHARE_GC_X_XFORWARDING_HPP diff --git a/src/hotspot/share/gc/x/xForwarding.inline.hpp b/src/hotspot/share/gc/x/xForwarding.inline.hpp deleted file mode 100644 index 257109f3de9..00000000000 --- a/src/hotspot/share/gc/x/xForwarding.inline.hpp +++ /dev/null @@ -1,163 +0,0 @@ -/* - * Copyright (c) 2015, 2020, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XFORWARDING_INLINE_HPP -#define SHARE_GC_X_XFORWARDING_INLINE_HPP - -#include "gc/x/xForwarding.hpp" - -#include "gc/x/xAttachedArray.inline.hpp" -#include "gc/x/xForwardingAllocator.inline.hpp" -#include "gc/x/xHash.inline.hpp" -#include "gc/x/xHeap.hpp" -#include "gc/x/xLock.inline.hpp" -#include "gc/x/xPage.inline.hpp" -#include "gc/x/xVirtualMemory.inline.hpp" -#include "runtime/atomic.hpp" -#include "utilities/debug.hpp" -#include "utilities/powerOfTwo.hpp" - -inline uint32_t XForwarding::nentries(const XPage* page) { - // The number returned by the function is used to size the hash table of - // forwarding entries for this page. This hash table uses linear probing. - // The size of the table must be a power of two to allow for quick and - // inexpensive indexing/masking. The table is also sized to have a load - // factor of 50%, i.e. sized to have double the number of entries actually - // inserted, to allow for good lookup/insert performance. - return round_up_power_of_2(page->live_objects() * 2); -} - -inline XForwarding* XForwarding::alloc(XForwardingAllocator* allocator, XPage* page) { - const size_t nentries = XForwarding::nentries(page); - void* const addr = AttachedArray::alloc(allocator, nentries); - return ::new (addr) XForwarding(page, nentries); -} - -inline XForwarding::XForwarding(XPage* page, size_t nentries) : - _virtual(page->virtual_memory()), - _object_alignment_shift(page->object_alignment_shift()), - _entries(nentries), - _page(page), - _ref_lock(), - _ref_count(1), - _ref_abort(false), - _in_place(false) {} - -inline uint8_t XForwarding::type() const { - return _page->type(); -} - -inline uintptr_t XForwarding::start() const { - return _virtual.start(); -} - -inline size_t XForwarding::size() const { - return _virtual.size(); -} - -inline size_t XForwarding::object_alignment_shift() const { - return _object_alignment_shift; -} - -inline void XForwarding::object_iterate(ObjectClosure *cl) { - return _page->object_iterate(cl); -} - -inline void XForwarding::set_in_place() { - _in_place = true; -} - -inline bool XForwarding::in_place() const { - return _in_place; -} - -inline XForwardingEntry* XForwarding::entries() const { - return _entries(this); -} - -inline XForwardingEntry XForwarding::at(XForwardingCursor* cursor) const { - // Load acquire for correctness with regards to - // accesses to the contents of the forwarded object. - return Atomic::load_acquire(entries() + *cursor); -} - -inline XForwardingEntry XForwarding::first(uintptr_t from_index, XForwardingCursor* cursor) const { - const size_t mask = _entries.length() - 1; - const size_t hash = XHash::uint32_to_uint32((uint32_t)from_index); - *cursor = hash & mask; - return at(cursor); -} - -inline XForwardingEntry XForwarding::next(XForwardingCursor* cursor) const { - const size_t mask = _entries.length() - 1; - *cursor = (*cursor + 1) & mask; - return at(cursor); -} - -inline XForwardingEntry XForwarding::find(uintptr_t from_index, XForwardingCursor* cursor) const { - // Reading entries in the table races with the atomic CAS done for - // insertion into the table. This is safe because each entry is at - // most updated once (from zero to something else). - XForwardingEntry entry = first(from_index, cursor); - while (entry.populated()) { - if (entry.from_index() == from_index) { - // Match found, return matching entry - return entry; - } - - entry = next(cursor); - } - - // Match not found, return empty entry - return entry; -} - -inline uintptr_t XForwarding::insert(uintptr_t from_index, uintptr_t to_offset, XForwardingCursor* cursor) { - const XForwardingEntry new_entry(from_index, to_offset); - const XForwardingEntry old_entry; // Empty - - // Make sure that object copy is finished - // before forwarding table installation - OrderAccess::release(); - - for (;;) { - const XForwardingEntry prev_entry = Atomic::cmpxchg(entries() + *cursor, old_entry, new_entry, memory_order_relaxed); - if (!prev_entry.populated()) { - // Success - return to_offset; - } - - // Find next empty or matching entry - XForwardingEntry entry = at(cursor); - while (entry.populated()) { - if (entry.from_index() == from_index) { - // Match found, return already inserted address - return entry.to_offset(); - } - - entry = next(cursor); - } - } -} - -#endif // SHARE_GC_X_XFORWARDING_INLINE_HPP diff --git a/src/hotspot/share/gc/x/xForwardingAllocator.cpp b/src/hotspot/share/gc/x/xForwardingAllocator.cpp deleted file mode 100644 index c8368fde5f5..00000000000 --- a/src/hotspot/share/gc/x/xForwardingAllocator.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright (c) 2020, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/x/xForwardingAllocator.hpp" -#include "memory/allocation.inline.hpp" - -XForwardingAllocator::XForwardingAllocator() : - _start(nullptr), - _end(nullptr), - _top(nullptr) {} - -XForwardingAllocator::~XForwardingAllocator() { - FREE_C_HEAP_ARRAY(char, _start); -} - -void XForwardingAllocator::reset(size_t size) { - _start = _top = REALLOC_C_HEAP_ARRAY(char, _start, size, mtGC); - _end = _start + size; -} diff --git a/src/hotspot/share/gc/x/xForwardingAllocator.hpp b/src/hotspot/share/gc/x/xForwardingAllocator.hpp deleted file mode 100644 index 75495944e8a..00000000000 --- a/src/hotspot/share/gc/x/xForwardingAllocator.hpp +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2020, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XFORWARDINGALLOCATOR_HPP -#define SHARE_GC_X_XFORWARDINGALLOCATOR_HPP - -#include "utilities/globalDefinitions.hpp" - -class XForwardingAllocator { -private: - char* _start; - char* _end; - char* _top; - -public: - XForwardingAllocator(); - ~XForwardingAllocator(); - - void reset(size_t size); - size_t size() const; - bool is_full() const; - - void* alloc(size_t size); -}; - -#endif // SHARE_GC_X_XFORWARDINGALLOCATOR_HPP diff --git a/src/hotspot/share/gc/x/xForwardingAllocator.inline.hpp b/src/hotspot/share/gc/x/xForwardingAllocator.inline.hpp deleted file mode 100644 index e70986f5206..00000000000 --- a/src/hotspot/share/gc/x/xForwardingAllocator.inline.hpp +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (c) 2020, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XFORWARDINGALLOCATOR_INLINE_HPP -#define SHARE_GC_X_XFORWARDINGALLOCATOR_INLINE_HPP - -#include "gc/x/xForwardingAllocator.hpp" - -#include "runtime/atomic.hpp" -#include "utilities/debug.hpp" - -inline size_t XForwardingAllocator::size() const { - return _end - _start; -} - -inline bool XForwardingAllocator::is_full() const { - return _top == _end; -} - -inline void* XForwardingAllocator::alloc(size_t size) { - char* const addr = Atomic::fetch_then_add(&_top, size); - assert(addr + size <= _end, "Allocation should never fail"); - return addr; -} - -#endif // SHARE_GC_X_XFORWARDINGALLOCATOR_INLINE_HPP diff --git a/src/hotspot/share/gc/x/xForwardingEntry.hpp b/src/hotspot/share/gc/x/xForwardingEntry.hpp deleted file mode 100644 index 3f8846abbaa..00000000000 --- a/src/hotspot/share/gc/x/xForwardingEntry.hpp +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (c) 2017, 2021, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XFORWARDINGENTRY_HPP -#define SHARE_GC_X_XFORWARDINGENTRY_HPP - -#include "gc/x/xBitField.hpp" -#include "memory/allocation.hpp" -#include "metaprogramming/primitiveConversions.hpp" - -#include - -class VMStructs; - -// -// Forwarding entry layout -// ----------------------- -// -// 6 4 4 -// 3 6 5 1 0 -// +--------------------+--------------------------------------------------+-+ -// |11111111 11111111 11|111111 11111111 11111111 11111111 11111111 1111111|1| -// +--------------------+--------------------------------------------------+-+ -// | | | -// | | 0-0 Populated Flag (1-bits) * -// | | -// | * 45-1 To Object Offset (45-bits) -// | -// * 63-46 From Object Index (18-bits) -// - -class XForwardingEntry { - friend struct PrimitiveConversions::Translate; - friend class ::VMStructs; - -private: - typedef XBitField field_populated; - typedef XBitField field_to_offset; - typedef XBitField field_from_index; - - uint64_t _entry; - -public: - XForwardingEntry() : - _entry(0) {} - - XForwardingEntry(size_t from_index, size_t to_offset) : - _entry(field_populated::encode(true) | - field_to_offset::encode(to_offset) | - field_from_index::encode(from_index)) {} - - bool populated() const { - return field_populated::decode(_entry); - } - - size_t to_offset() const { - return field_to_offset::decode(_entry); - } - - size_t from_index() const { - return field_from_index::decode(_entry); - } -}; - -// Needed to allow atomic operations on XForwardingEntry -template <> -struct PrimitiveConversions::Translate : public std::true_type { - typedef XForwardingEntry Value; - typedef uint64_t Decayed; - - static Decayed decay(Value v) { - return v._entry; - } - - static Value recover(Decayed d) { - XForwardingEntry entry; - entry._entry = d; - return entry; - } -}; - -#endif // SHARE_GC_X_XFORWARDINGENTRY_HPP diff --git a/src/hotspot/share/gc/x/xForwardingTable.hpp b/src/hotspot/share/gc/x/xForwardingTable.hpp deleted file mode 100644 index 1f110292be5..00000000000 --- a/src/hotspot/share/gc/x/xForwardingTable.hpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2019, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XFORWARDINGTABLE_HPP -#define SHARE_GC_X_XFORWARDINGTABLE_HPP - -#include "gc/x/xGranuleMap.hpp" - -class VMStructs; -class XForwarding; - -class XForwardingTable { - friend class ::VMStructs; - -private: - XGranuleMap _map; - -public: - XForwardingTable(); - - XForwarding* get(uintptr_t addr) const; - - void insert(XForwarding* forwarding); - void remove(XForwarding* forwarding); -}; - -#endif // SHARE_GC_X_XFORWARDINGTABLE_HPP diff --git a/src/hotspot/share/gc/x/xForwardingTable.inline.hpp b/src/hotspot/share/gc/x/xForwardingTable.inline.hpp deleted file mode 100644 index b65b68da4e2..00000000000 --- a/src/hotspot/share/gc/x/xForwardingTable.inline.hpp +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2019, 2020, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XFORWARDINGTABLE_INLINE_HPP -#define SHARE_GC_X_XFORWARDINGTABLE_INLINE_HPP - -#include "gc/x/xForwardingTable.hpp" - -#include "gc/x/xAddress.inline.hpp" -#include "gc/x/xForwarding.inline.hpp" -#include "gc/x/xGlobals.hpp" -#include "gc/x/xGranuleMap.inline.hpp" -#include "utilities/debug.hpp" - -inline XForwardingTable::XForwardingTable() : - _map(XAddressOffsetMax) {} - -inline XForwarding* XForwardingTable::get(uintptr_t addr) const { - assert(!XAddress::is_null(addr), "Invalid address"); - return _map.get(XAddress::offset(addr)); -} - -inline void XForwardingTable::insert(XForwarding* forwarding) { - const uintptr_t offset = forwarding->start(); - const size_t size = forwarding->size(); - - assert(_map.get(offset) == nullptr, "Invalid entry"); - _map.put(offset, size, forwarding); -} - -inline void XForwardingTable::remove(XForwarding* forwarding) { - const uintptr_t offset = forwarding->start(); - const size_t size = forwarding->size(); - - assert(_map.get(offset) == forwarding, "Invalid entry"); - _map.put(offset, size, nullptr); -} - -#endif // SHARE_GC_X_XFORWARDINGTABLE_INLINE_HPP diff --git a/src/hotspot/share/gc/x/xFuture.hpp b/src/hotspot/share/gc/x/xFuture.hpp deleted file mode 100644 index 931f4b58f12..00000000000 --- a/src/hotspot/share/gc/x/xFuture.hpp +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2015, 2020, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XFUTURE_HPP -#define SHARE_GC_X_XFUTURE_HPP - -#include "memory/allocation.hpp" -#include "runtime/semaphore.hpp" - -template -class XFuture { -private: - Semaphore _sema; - T _value; - -public: - XFuture(); - - void set(T value); - T get(); -}; - -#endif // SHARE_GC_X_XFUTURE_HPP diff --git a/src/hotspot/share/gc/x/xFuture.inline.hpp b/src/hotspot/share/gc/x/xFuture.inline.hpp deleted file mode 100644 index d3dba3b7151..00000000000 --- a/src/hotspot/share/gc/x/xFuture.inline.hpp +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2015, 2021, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XFUTURE_INLINE_HPP -#define SHARE_GC_X_XFUTURE_INLINE_HPP - -#include "gc/x/xFuture.hpp" - -#include "runtime/javaThread.hpp" -#include "runtime/semaphore.inline.hpp" - -template -inline XFuture::XFuture() : - _value() {} - -template -inline void XFuture::set(T value) { - // Set value - _value = value; - - // Notify waiter - _sema.signal(); -} - -template -inline T XFuture::get() { - // Wait for notification - Thread* const thread = Thread::current(); - if (thread->is_Java_thread()) { - _sema.wait_with_safepoint_check(JavaThread::cast(thread)); - } else { - _sema.wait(); - } - - // Return value - return _value; -} - -#endif // SHARE_GC_X_XFUTURE_INLINE_HPP diff --git a/src/hotspot/share/gc/x/xGlobals.cpp b/src/hotspot/share/gc/x/xGlobals.cpp deleted file mode 100644 index b247565bc01..00000000000 --- a/src/hotspot/share/gc/x/xGlobals.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2015, 2020, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/x/xGlobals.hpp" - -uint32_t XGlobalPhase = XPhaseRelocate; -uint32_t XGlobalSeqNum = 1; - -size_t XPageSizeMediumShift; -size_t XPageSizeMedium; - -size_t XObjectSizeLimitMedium; - -const int& XObjectAlignmentSmallShift = LogMinObjAlignmentInBytes; -int XObjectAlignmentMediumShift; - -const int& XObjectAlignmentSmall = MinObjAlignmentInBytes; -int XObjectAlignmentMedium; - -uintptr_t XAddressGoodMask; -uintptr_t XAddressBadMask; -uintptr_t XAddressWeakBadMask; - -static uint32_t* XAddressCalculateBadMaskHighOrderBitsAddr() { - const uintptr_t addr = reinterpret_cast(&XAddressBadMask); - return reinterpret_cast(addr + XAddressBadMaskHighOrderBitsOffset); -} - -uint32_t* XAddressBadMaskHighOrderBitsAddr = XAddressCalculateBadMaskHighOrderBitsAddr(); - -size_t XAddressOffsetBits; -uintptr_t XAddressOffsetMask; -size_t XAddressOffsetMax; - -size_t XAddressMetadataShift; -uintptr_t XAddressMetadataMask; - -uintptr_t XAddressMetadataMarked; -uintptr_t XAddressMetadataMarked0; -uintptr_t XAddressMetadataMarked1; -uintptr_t XAddressMetadataRemapped; -uintptr_t XAddressMetadataFinalizable; - -const char* XGlobalPhaseToString() { - switch (XGlobalPhase) { - case XPhaseMark: - return "Mark"; - - case XPhaseMarkCompleted: - return "MarkCompleted"; - - case XPhaseRelocate: - return "Relocate"; - - default: - return "Unknown"; - } -} diff --git a/src/hotspot/share/gc/x/xGlobals.hpp b/src/hotspot/share/gc/x/xGlobals.hpp deleted file mode 100644 index 662a502a79f..00000000000 --- a/src/hotspot/share/gc/x/xGlobals.hpp +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Copyright (c) 2015, 2022, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XGLOBALS_HPP -#define SHARE_GC_X_XGLOBALS_HPP - -#include "utilities/globalDefinitions.hpp" -#include "utilities/macros.hpp" -#include CPU_HEADER(gc/x/xGlobals) - -// Collector name -const char* const XName = "The Z Garbage Collector"; - -// Global phase state -extern uint32_t XGlobalPhase; -const uint32_t XPhaseMark = 0; -const uint32_t XPhaseMarkCompleted = 1; -const uint32_t XPhaseRelocate = 2; -const char* XGlobalPhaseToString(); - -// Global sequence number -extern uint32_t XGlobalSeqNum; - -// Granule shift/size -const size_t XGranuleSizeShift = 21; // 2MB -const size_t XGranuleSize = (size_t)1 << XGranuleSizeShift; - -// Number of heap views -const size_t XHeapViews = XPlatformHeapViews; - -// Virtual memory to physical memory ratio -const size_t XVirtualToPhysicalRatio = 16; // 16:1 - -// Page types -const uint8_t XPageTypeSmall = 0; -const uint8_t XPageTypeMedium = 1; -const uint8_t XPageTypeLarge = 2; - -// Page size shifts -const size_t XPageSizeSmallShift = XGranuleSizeShift; -extern size_t XPageSizeMediumShift; - -// Page sizes -const size_t XPageSizeSmall = (size_t)1 << XPageSizeSmallShift; -extern size_t XPageSizeMedium; - -// Object size limits -const size_t XObjectSizeLimitSmall = XPageSizeSmall / 8; // 12.5% max waste -extern size_t XObjectSizeLimitMedium; - -// Object alignment shifts -extern const int& XObjectAlignmentSmallShift; -extern int XObjectAlignmentMediumShift; -const int XObjectAlignmentLargeShift = XGranuleSizeShift; - -// Object alignments -extern const int& XObjectAlignmentSmall; -extern int XObjectAlignmentMedium; -const int XObjectAlignmentLarge = 1 << XObjectAlignmentLargeShift; - -// -// Good/Bad mask states -// -------------------- -// -// GoodMask BadMask WeakGoodMask WeakBadMask -// -------------------------------------------------------------- -// Marked0 001 110 101 010 -// Marked1 010 101 110 001 -// Remapped 100 011 100 011 -// - -// Good/bad masks -extern uintptr_t XAddressGoodMask; -extern uintptr_t XAddressBadMask; -extern uintptr_t XAddressWeakBadMask; - -// The bad mask is 64 bit. Its high order 32 bits contain all possible value combinations -// that this mask will have. Therefore, the memory where the 32 high order bits are stored, -// can be used as a 32 bit GC epoch counter, that has a different bit pattern every time -// the bad mask is flipped. This provides a pointer to said 32 bits. -extern uint32_t* XAddressBadMaskHighOrderBitsAddr; -const int XAddressBadMaskHighOrderBitsOffset = LITTLE_ENDIAN_ONLY(4) BIG_ENDIAN_ONLY(0); - -// Pointer part of address -extern size_t XAddressOffsetBits; -const size_t XAddressOffsetShift = 0; -extern uintptr_t XAddressOffsetMask; -extern size_t XAddressOffsetMax; - -// Metadata part of address -const size_t XAddressMetadataBits = 4; -extern size_t XAddressMetadataShift; -extern uintptr_t XAddressMetadataMask; - -// Metadata types -extern uintptr_t XAddressMetadataMarked; -extern uintptr_t XAddressMetadataMarked0; -extern uintptr_t XAddressMetadataMarked1; -extern uintptr_t XAddressMetadataRemapped; -extern uintptr_t XAddressMetadataFinalizable; - -// Cache line size -const size_t XCacheLineSize = XPlatformCacheLineSize; -#define XCACHE_ALIGNED ATTRIBUTE_ALIGNED(XCacheLineSize) - -// Mark stack space -extern uintptr_t XMarkStackSpaceStart; -const size_t XMarkStackSpaceExpandSize = (size_t)1 << 25; // 32M - -// Mark stack and magazine sizes -const size_t XMarkStackSizeShift = 11; // 2K -const size_t XMarkStackSize = (size_t)1 << XMarkStackSizeShift; -const size_t XMarkStackHeaderSize = (size_t)1 << 4; // 16B -const size_t XMarkStackSlots = (XMarkStackSize - XMarkStackHeaderSize) / sizeof(uintptr_t); -const size_t XMarkStackMagazineSize = (size_t)1 << 15; // 32K -const size_t XMarkStackMagazineSlots = (XMarkStackMagazineSize / XMarkStackSize) - 1; - -// Mark stripe size -const size_t XMarkStripeShift = XGranuleSizeShift; - -// Max number of mark stripes -const size_t XMarkStripesMax = 16; // Must be a power of two - -// Mark cache size -const size_t XMarkCacheSize = 1024; // Must be a power of two - -// Partial array minimum size -const size_t XMarkPartialArrayMinSizeShift = 12; // 4K -const size_t XMarkPartialArrayMinSize = (size_t)1 << XMarkPartialArrayMinSizeShift; - -// Max number of proactive/terminate flush attempts -const size_t XMarkProactiveFlushMax = 10; -const size_t XMarkTerminateFlushMax = 3; - -// Try complete mark timeout -const uint64_t XMarkCompleteTimeout = 200; // us - -#endif // SHARE_GC_X_XGLOBALS_HPP diff --git a/src/hotspot/share/gc/x/xGranuleMap.hpp b/src/hotspot/share/gc/x/xGranuleMap.hpp deleted file mode 100644 index a9447e1469c..00000000000 --- a/src/hotspot/share/gc/x/xGranuleMap.hpp +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2017, 2020, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XGRANULEMAP_HPP -#define SHARE_GC_X_XGRANULEMAP_HPP - -#include "gc/x/xArray.hpp" -#include "memory/allocation.hpp" - -class VMStructs; - -template -class XGranuleMap { - friend class ::VMStructs; - template friend class XGranuleMapIterator; - -private: - const size_t _size; - T* const _map; - - size_t index_for_offset(uintptr_t offset) const; - -public: - XGranuleMap(size_t max_offset); - ~XGranuleMap(); - - T get(uintptr_t offset) const; - void put(uintptr_t offset, T value); - void put(uintptr_t offset, size_t size, T value); - - T get_acquire(uintptr_t offset) const; - void release_put(uintptr_t offset, T value); -}; - -template -class XGranuleMapIterator : public XArrayIteratorImpl { -public: - XGranuleMapIterator(const XGranuleMap* granule_map); -}; - -#endif // SHARE_GC_X_XGRANULEMAP_HPP diff --git a/src/hotspot/share/gc/x/xGranuleMap.inline.hpp b/src/hotspot/share/gc/x/xGranuleMap.inline.hpp deleted file mode 100644 index 95ef5ee2b2d..00000000000 --- a/src/hotspot/share/gc/x/xGranuleMap.inline.hpp +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (c) 2017, 2020, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XGRANULEMAP_INLINE_HPP -#define SHARE_GC_X_XGRANULEMAP_INLINE_HPP - -#include "gc/x/xGranuleMap.hpp" - -#include "gc/x/xArray.inline.hpp" -#include "gc/x/xGlobals.hpp" -#include "memory/allocation.inline.hpp" -#include "runtime/atomic.hpp" -#include "utilities/align.hpp" -#include "utilities/debug.hpp" - -template -inline XGranuleMap::XGranuleMap(size_t max_offset) : - _size(max_offset >> XGranuleSizeShift), - _map(MmapArrayAllocator::allocate(_size, mtGC)) { - assert(is_aligned(max_offset, XGranuleSize), "Misaligned"); -} - -template -inline XGranuleMap::~XGranuleMap() { - MmapArrayAllocator::free(_map, _size); -} - -template -inline size_t XGranuleMap::index_for_offset(uintptr_t offset) const { - const size_t index = offset >> XGranuleSizeShift; - assert(index < _size, "Invalid index"); - return index; -} - -template -inline T XGranuleMap::get(uintptr_t offset) const { - const size_t index = index_for_offset(offset); - return _map[index]; -} - -template -inline void XGranuleMap::put(uintptr_t offset, T value) { - const size_t index = index_for_offset(offset); - _map[index] = value; -} - -template -inline void XGranuleMap::put(uintptr_t offset, size_t size, T value) { - assert(is_aligned(size, XGranuleSize), "Misaligned"); - - const size_t start_index = index_for_offset(offset); - const size_t end_index = start_index + (size >> XGranuleSizeShift); - for (size_t index = start_index; index < end_index; index++) { - _map[index] = value; - } -} - -template -inline T XGranuleMap::get_acquire(uintptr_t offset) const { - const size_t index = index_for_offset(offset); - return Atomic::load_acquire(_map + index); -} - -template -inline void XGranuleMap::release_put(uintptr_t offset, T value) { - const size_t index = index_for_offset(offset); - Atomic::release_store(_map + index, value); -} - -template -inline XGranuleMapIterator::XGranuleMapIterator(const XGranuleMap* granule_map) : - XArrayIteratorImpl(granule_map->_map, granule_map->_size) {} - -#endif // SHARE_GC_X_XGRANULEMAP_INLINE_HPP diff --git a/src/hotspot/share/gc/x/xHash.hpp b/src/hotspot/share/gc/x/xHash.hpp deleted file mode 100644 index 253f4d231c1..00000000000 --- a/src/hotspot/share/gc/x/xHash.hpp +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2015, 2022, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XHASH_HPP -#define SHARE_GC_X_XHASH_HPP - -#include "memory/allStatic.hpp" -#include "utilities/globalDefinitions.hpp" - -class XHash : public AllStatic { -public: - static uint32_t uint32_to_uint32(uint32_t key); - static uint32_t address_to_uint32(uintptr_t key); -}; - -#endif // SHARE_GC_X_XHASH_HPP diff --git a/src/hotspot/share/gc/x/xHash.inline.hpp b/src/hotspot/share/gc/x/xHash.inline.hpp deleted file mode 100644 index 5ff5f540821..00000000000 --- a/src/hotspot/share/gc/x/xHash.inline.hpp +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2015, 2018, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -/* - * This file is available under and governed by the GNU General Public - * License version 2 only, as published by the Free Software Foundation. - * However, the following notice accompanied the original version of this - * file: - * - * (C) 2009 by Remo Dentato (rdentato@gmail.com) - * - * - * Redistribution and use in source and binary forms, with or without modification, - * are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR - * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * http://opensource.org/licenses/bsd-license.php - */ - -#ifndef SHARE_GC_X_XHASH_INLINE_HPP -#define SHARE_GC_X_XHASH_INLINE_HPP - -#include "gc/x/xHash.hpp" - -#include "gc/x/xAddress.inline.hpp" - -inline uint32_t XHash::uint32_to_uint32(uint32_t key) { - key = ~key + (key << 15); - key = key ^ (key >> 12); - key = key + (key << 2); - key = key ^ (key >> 4); - key = key * 2057; - key = key ^ (key >> 16); - return key; -} - -inline uint32_t XHash::address_to_uint32(uintptr_t key) { - return uint32_to_uint32((uint32_t)(key >> 3)); -} - -#endif // SHARE_GC_X_XHASH_INLINE_HPP diff --git a/src/hotspot/share/gc/x/xHeap.cpp b/src/hotspot/share/gc/x/xHeap.cpp deleted file mode 100644 index 3872db785f3..00000000000 --- a/src/hotspot/share/gc/x/xHeap.cpp +++ /dev/null @@ -1,541 +0,0 @@ -/* - * Copyright (c) 2015, 2022, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "classfile/classLoaderDataGraph.hpp" -#include "gc/shared/gc_globals.hpp" -#include "gc/shared/classUnloadingContext.hpp" -#include "gc/shared/locationPrinter.hpp" -#include "gc/shared/tlab_globals.hpp" -#include "gc/x/xAddress.inline.hpp" -#include "gc/x/xArray.inline.hpp" -#include "gc/x/xGlobals.hpp" -#include "gc/x/xHeap.inline.hpp" -#include "gc/x/xHeapIterator.hpp" -#include "gc/x/xHeuristics.hpp" -#include "gc/x/xMark.inline.hpp" -#include "gc/x/xPage.inline.hpp" -#include "gc/x/xPageTable.inline.hpp" -#include "gc/x/xRelocationSet.inline.hpp" -#include "gc/x/xRelocationSetSelector.inline.hpp" -#include "gc/x/xResurrection.hpp" -#include "gc/x/xStat.hpp" -#include "gc/x/xThread.inline.hpp" -#include "gc/x/xVerify.hpp" -#include "gc/x/xWorkers.hpp" -#include "logging/log.hpp" -#include "memory/iterator.hpp" -#include "memory/metaspaceUtils.hpp" -#include "memory/resourceArea.hpp" -#include "prims/jvmtiTagMap.hpp" -#include "runtime/handshake.hpp" -#include "runtime/javaThread.hpp" -#include "runtime/safepoint.hpp" -#include "utilities/debug.hpp" - -static const XStatCounter XCounterUndoPageAllocation("Memory", "Undo Page Allocation", XStatUnitOpsPerSecond); -static const XStatCounter XCounterOutOfMemory("Memory", "Out Of Memory", XStatUnitOpsPerSecond); - -XHeap* XHeap::_heap = nullptr; - -XHeap::XHeap() : - _workers(), - _object_allocator(), - _page_allocator(&_workers, MinHeapSize, InitialHeapSize, MaxHeapSize), - _page_table(), - _forwarding_table(), - _mark(&_workers, &_page_table), - _reference_processor(&_workers), - _weak_roots_processor(&_workers), - _relocate(&_workers), - _relocation_set(&_workers), - _unload(&_workers), - _serviceability(min_capacity(), max_capacity()) { - // Install global heap instance - assert(_heap == nullptr, "Already initialized"); - _heap = this; - - // Update statistics - XStatHeap::set_at_initialize(_page_allocator.stats()); -} - -bool XHeap::is_initialized() const { - return _page_allocator.is_initialized() && _mark.is_initialized(); -} - -size_t XHeap::min_capacity() const { - return _page_allocator.min_capacity(); -} - -size_t XHeap::max_capacity() const { - return _page_allocator.max_capacity(); -} - -size_t XHeap::soft_max_capacity() const { - return _page_allocator.soft_max_capacity(); -} - -size_t XHeap::capacity() const { - return _page_allocator.capacity(); -} - -size_t XHeap::used() const { - return _page_allocator.used(); -} - -size_t XHeap::unused() const { - return _page_allocator.unused(); -} - -size_t XHeap::tlab_capacity() const { - return capacity(); -} - -size_t XHeap::tlab_used() const { - return _object_allocator.used(); -} - -size_t XHeap::max_tlab_size() const { - return XObjectSizeLimitSmall; -} - -size_t XHeap::unsafe_max_tlab_alloc() const { - size_t size = _object_allocator.remaining(); - - if (size < MinTLABSize) { - // The remaining space in the allocator is not enough to - // fit the smallest possible TLAB. This means that the next - // TLAB allocation will force the allocator to get a new - // backing page anyway, which in turn means that we can then - // fit the largest possible TLAB. - size = max_tlab_size(); - } - - return MIN2(size, max_tlab_size()); -} - -bool XHeap::is_in(uintptr_t addr) const { - // An address is considered to be "in the heap" if it points into - // the allocated part of a page, regardless of which heap view is - // used. Note that an address with the finalizable metadata bit set - // is not pointing into a heap view, and therefore not considered - // to be "in the heap". - - if (XAddress::is_in(addr)) { - const XPage* const page = _page_table.get(addr); - if (page != nullptr) { - return page->is_in(addr); - } - } - - return false; -} - -uint XHeap::active_workers() const { - return _workers.active_workers(); -} - -void XHeap::set_active_workers(uint nworkers) { - _workers.set_active_workers(nworkers); -} - -void XHeap::threads_do(ThreadClosure* tc) const { - _page_allocator.threads_do(tc); - _workers.threads_do(tc); -} - -void XHeap::out_of_memory() { - ResourceMark rm; - - XStatInc(XCounterOutOfMemory); - log_info(gc)("Out Of Memory (%s)", Thread::current()->name()); -} - -XPage* XHeap::alloc_page(uint8_t type, size_t size, XAllocationFlags flags) { - XPage* const page = _page_allocator.alloc_page(type, size, flags); - if (page != nullptr) { - // Insert page table entry - _page_table.insert(page); - } - - return page; -} - -void XHeap::undo_alloc_page(XPage* page) { - assert(page->is_allocating(), "Invalid page state"); - - XStatInc(XCounterUndoPageAllocation); - log_trace(gc)("Undo page allocation, thread: " PTR_FORMAT " (%s), page: " PTR_FORMAT ", size: " SIZE_FORMAT, - XThread::id(), XThread::name(), p2i(page), page->size()); - - free_page(page, false /* reclaimed */); -} - -void XHeap::free_page(XPage* page, bool reclaimed) { - // Remove page table entry - _page_table.remove(page); - - // Free page - _page_allocator.free_page(page, reclaimed); -} - -void XHeap::free_pages(const XArray* pages, bool reclaimed) { - // Remove page table entries - XArrayIterator iter(pages); - for (XPage* page; iter.next(&page);) { - _page_table.remove(page); - } - - // Free pages - _page_allocator.free_pages(pages, reclaimed); -} - -void XHeap::flip_to_marked() { - XVerifyViewsFlip flip(&_page_allocator); - XAddress::flip_to_marked(); -} - -void XHeap::flip_to_remapped() { - XVerifyViewsFlip flip(&_page_allocator); - XAddress::flip_to_remapped(); -} - -void XHeap::mark_start() { - assert(SafepointSynchronize::is_at_safepoint(), "Should be at safepoint"); - - // Verification - ClassLoaderDataGraph::verify_claimed_marks_cleared(ClassLoaderData::_claim_strong); - - if (XHeap::heap()->has_alloc_stalled()) { - // If there are stalled allocations, ensure that regardless of the - // cause of the GC, we have to clear soft references, as we are just - // about to increment the sequence number, and all previous allocations - // will throw if not presented with enough memory. - XHeap::heap()->set_soft_reference_policy(true); - } - - // Flip address view - flip_to_marked(); - - // Retire allocating pages - _object_allocator.retire_pages(); - - // Reset allocated/reclaimed/used statistics - _page_allocator.reset_statistics(); - - // Reset encountered/dropped/enqueued statistics - _reference_processor.reset_statistics(); - - // Enter mark phase - XGlobalPhase = XPhaseMark; - - // Reset marking information - _mark.start(); - - // Update statistics - XStatHeap::set_at_mark_start(_page_allocator.stats()); -} - -void XHeap::mark(bool initial) { - _mark.mark(initial); -} - -void XHeap::mark_flush_and_free(Thread* thread) { - _mark.flush_and_free(thread); -} - -bool XHeap::mark_end() { - assert(SafepointSynchronize::is_at_safepoint(), "Should be at safepoint"); - - // Try end marking - if (!_mark.end()) { - // Marking not completed, continue concurrent mark - return false; - } - - // Enter mark completed phase - XGlobalPhase = XPhaseMarkCompleted; - - // Verify after mark - XVerify::after_mark(); - - // Update statistics - XStatHeap::set_at_mark_end(_page_allocator.stats()); - - // Block resurrection of weak/phantom references - XResurrection::block(); - - // Prepare to unload stale metadata and nmethods - _unload.prepare(); - - // Notify JVMTI that some tagmap entry objects may have died. - JvmtiTagMap::set_needs_cleaning(); - - return true; -} - -void XHeap::mark_free() { - _mark.free(); -} - -void XHeap::keep_alive(oop obj) { - XBarrier::keep_alive_barrier_on_oop(obj); -} - -void XHeap::set_soft_reference_policy(bool clear) { - _reference_processor.set_soft_reference_policy(clear); -} - -class XRendezvousClosure : public HandshakeClosure { -public: - XRendezvousClosure() : - HandshakeClosure("XRendezvous") {} - - void do_thread(Thread* thread) {} -}; - -void XHeap::process_non_strong_references() { - // Process Soft/Weak/Final/PhantomReferences - _reference_processor.process_references(); - - // Process weak roots - _weak_roots_processor.process_weak_roots(); - - ClassUnloadingContext ctx(_workers.active_workers(), - true /* unregister_nmethods_during_purge */, - true /* lock_nmethod_free_separately */); - - // Unlink stale metadata and nmethods - _unload.unlink(); - - // Perform a handshake. This is needed 1) to make sure that stale - // metadata and nmethods are no longer observable. And 2), to - // prevent the race where a mutator first loads an oop, which is - // logically null but not yet cleared. Then this oop gets cleared - // by the reference processor and resurrection is unblocked. At - // this point the mutator could see the unblocked state and pass - // this invalid oop through the normal barrier path, which would - // incorrectly try to mark the oop. - XRendezvousClosure cl; - Handshake::execute(&cl); - - // Unblock resurrection of weak/phantom references - XResurrection::unblock(); - - // Purge stale metadata and nmethods that were unlinked - _unload.purge(); - - // Enqueue Soft/Weak/Final/PhantomReferences. Note that this - // must be done after unblocking resurrection. Otherwise the - // Finalizer thread could call Reference.get() on the Finalizers - // that were just enqueued, which would incorrectly return null - // during the resurrection block window, since such referents - // are only Finalizable marked. - _reference_processor.enqueue_references(); - - // Clear old markings claim bits. - // Note: Clearing _claim_strong also clears _claim_finalizable. - ClassLoaderDataGraph::clear_claimed_marks(ClassLoaderData::_claim_strong); -} - -void XHeap::free_empty_pages(XRelocationSetSelector* selector, int bulk) { - // Freeing empty pages in bulk is an optimization to avoid grabbing - // the page allocator lock, and trying to satisfy stalled allocations - // too frequently. - if (selector->should_free_empty_pages(bulk)) { - free_pages(selector->empty_pages(), true /* reclaimed */); - selector->clear_empty_pages(); - } -} - -void XHeap::select_relocation_set() { - // Do not allow pages to be deleted - _page_allocator.enable_deferred_delete(); - - // Register relocatable pages with selector - XRelocationSetSelector selector; - XPageTableIterator pt_iter(&_page_table); - for (XPage* page; pt_iter.next(&page);) { - if (!page->is_relocatable()) { - // Not relocatable, don't register - continue; - } - - if (page->is_marked()) { - // Register live page - selector.register_live_page(page); - } else { - // Register empty page - selector.register_empty_page(page); - - // Reclaim empty pages in bulk - free_empty_pages(&selector, 64 /* bulk */); - } - } - - // Reclaim remaining empty pages - free_empty_pages(&selector, 0 /* bulk */); - - // Allow pages to be deleted - _page_allocator.disable_deferred_delete(); - - // Select relocation set - selector.select(); - - // Install relocation set - _relocation_set.install(&selector); - - // Setup forwarding table - XRelocationSetIterator rs_iter(&_relocation_set); - for (XForwarding* forwarding; rs_iter.next(&forwarding);) { - _forwarding_table.insert(forwarding); - } - - // Update statistics - XStatRelocation::set_at_select_relocation_set(selector.stats()); - XStatHeap::set_at_select_relocation_set(selector.stats()); -} - -void XHeap::reset_relocation_set() { - // Reset forwarding table - XRelocationSetIterator iter(&_relocation_set); - for (XForwarding* forwarding; iter.next(&forwarding);) { - _forwarding_table.remove(forwarding); - } - - // Reset relocation set - _relocation_set.reset(); -} - -void XHeap::relocate_start() { - assert(SafepointSynchronize::is_at_safepoint(), "Should be at safepoint"); - - // Finish unloading stale metadata and nmethods - _unload.finish(); - - // Flip address view - flip_to_remapped(); - - // Enter relocate phase - XGlobalPhase = XPhaseRelocate; - - // Update statistics - XStatHeap::set_at_relocate_start(_page_allocator.stats()); -} - -void XHeap::relocate() { - // Relocate relocation set - _relocate.relocate(&_relocation_set); - - // Update statistics - XStatHeap::set_at_relocate_end(_page_allocator.stats(), _object_allocator.relocated()); -} - -bool XHeap::is_allocating(uintptr_t addr) const { - const XPage* const page = _page_table.get(addr); - return page->is_allocating(); -} - -void XHeap::object_iterate(ObjectClosure* cl, bool visit_weaks) { - assert(SafepointSynchronize::is_at_safepoint(), "Should be at safepoint"); - XHeapIterator iter(1 /* nworkers */, visit_weaks); - iter.object_iterate(cl, 0 /* worker_id */); -} - -ParallelObjectIteratorImpl* XHeap::parallel_object_iterator(uint nworkers, bool visit_weaks) { - assert(SafepointSynchronize::is_at_safepoint(), "Should be at safepoint"); - return new XHeapIterator(nworkers, visit_weaks); -} - -void XHeap::pages_do(XPageClosure* cl) { - XPageTableIterator iter(&_page_table); - for (XPage* page; iter.next(&page);) { - cl->do_page(page); - } - _page_allocator.pages_do(cl); -} - -void XHeap::serviceability_initialize() { - _serviceability.initialize(); -} - -GCMemoryManager* XHeap::serviceability_cycle_memory_manager() { - return _serviceability.cycle_memory_manager(); -} - -GCMemoryManager* XHeap::serviceability_pause_memory_manager() { - return _serviceability.pause_memory_manager(); -} - -MemoryPool* XHeap::serviceability_memory_pool() { - return _serviceability.memory_pool(); -} - -XServiceabilityCounters* XHeap::serviceability_counters() { - return _serviceability.counters(); -} - -void XHeap::print_on(outputStream* st) const { - st->print_cr(" ZHeap used " SIZE_FORMAT "M, capacity " SIZE_FORMAT "M, max capacity " SIZE_FORMAT "M", - used() / M, - capacity() / M, - max_capacity() / M); - MetaspaceUtils::print_on(st); -} - -void XHeap::print_extended_on(outputStream* st) const { - print_on(st); - st->cr(); - - // Do not allow pages to be deleted - _page_allocator.enable_deferred_delete(); - - // Print all pages - st->print_cr("ZGC Page Table:"); - XPageTableIterator iter(&_page_table); - for (XPage* page; iter.next(&page);) { - page->print_on(st); - } - - // Allow pages to be deleted - _page_allocator.disable_deferred_delete(); -} - -bool XHeap::print_location(outputStream* st, uintptr_t addr) const { - if (LocationPrinter::is_valid_obj((void*)addr)) { - st->print(PTR_FORMAT " is a %s oop: ", addr, XAddress::is_good(addr) ? "good" : "bad"); - XOop::from_address(addr)->print_on(st); - return true; - } - - return false; -} - -void XHeap::verify() { - // Heap verification can only be done between mark end and - // relocate start. This is the only window where all oop are - // good and the whole heap is in a consistent state. - guarantee(XGlobalPhase == XPhaseMarkCompleted, "Invalid phase"); - - XVerify::after_weak_processing(); -} diff --git a/src/hotspot/share/gc/x/xHeap.hpp b/src/hotspot/share/gc/x/xHeap.hpp deleted file mode 100644 index af2c73180d9..00000000000 --- a/src/hotspot/share/gc/x/xHeap.hpp +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Copyright (c) 2015, 2022, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XHEAP_HPP -#define SHARE_GC_X_XHEAP_HPP - -#include "gc/x/xAllocationFlags.hpp" -#include "gc/x/xArray.hpp" -#include "gc/x/xForwardingTable.hpp" -#include "gc/x/xMark.hpp" -#include "gc/x/xObjectAllocator.hpp" -#include "gc/x/xPageAllocator.hpp" -#include "gc/x/xPageTable.hpp" -#include "gc/x/xReferenceProcessor.hpp" -#include "gc/x/xRelocate.hpp" -#include "gc/x/xRelocationSet.hpp" -#include "gc/x/xWeakRootsProcessor.hpp" -#include "gc/x/xServiceability.hpp" -#include "gc/x/xUnload.hpp" -#include "gc/x/xWorkers.hpp" - -class ThreadClosure; -class VMStructs; -class XPage; -class XRelocationSetSelector; - -class XHeap { - friend class ::VMStructs; - -private: - static XHeap* _heap; - - XWorkers _workers; - XObjectAllocator _object_allocator; - XPageAllocator _page_allocator; - XPageTable _page_table; - XForwardingTable _forwarding_table; - XMark _mark; - XReferenceProcessor _reference_processor; - XWeakRootsProcessor _weak_roots_processor; - XRelocate _relocate; - XRelocationSet _relocation_set; - XUnload _unload; - XServiceability _serviceability; - - void flip_to_marked(); - void flip_to_remapped(); - - void free_empty_pages(XRelocationSetSelector* selector, int bulk); - - void out_of_memory(); - -public: - static XHeap* heap(); - - XHeap(); - - bool is_initialized() const; - - // Heap metrics - size_t min_capacity() const; - size_t max_capacity() const; - size_t soft_max_capacity() const; - size_t capacity() const; - size_t used() const; - size_t unused() const; - - size_t tlab_capacity() const; - size_t tlab_used() const; - size_t max_tlab_size() const; - size_t unsafe_max_tlab_alloc() const; - - bool is_in(uintptr_t addr) const; - - // Threads - uint active_workers() const; - void set_active_workers(uint nworkers); - void threads_do(ThreadClosure* tc) const; - - // Reference processing - ReferenceDiscoverer* reference_discoverer(); - void set_soft_reference_policy(bool clear); - - // Non-strong reference processing - void process_non_strong_references(); - - // Page allocation - XPage* alloc_page(uint8_t type, size_t size, XAllocationFlags flags); - void undo_alloc_page(XPage* page); - void free_page(XPage* page, bool reclaimed); - void free_pages(const XArray* pages, bool reclaimed); - - // Object allocation - uintptr_t alloc_tlab(size_t size); - uintptr_t alloc_object(size_t size); - uintptr_t alloc_object_for_relocation(size_t size); - void undo_alloc_object_for_relocation(uintptr_t addr, size_t size); - bool has_alloc_stalled() const; - void check_out_of_memory(); - - // Marking - bool is_object_live(uintptr_t addr) const; - bool is_object_strongly_live(uintptr_t addr) const; - template void mark_object(uintptr_t addr); - void mark_start(); - void mark(bool initial); - void mark_flush_and_free(Thread* thread); - bool mark_end(); - void mark_free(); - void keep_alive(oop obj); - - // Relocation set - void select_relocation_set(); - void reset_relocation_set(); - - // Relocation - void relocate_start(); - uintptr_t relocate_object(uintptr_t addr); - uintptr_t remap_object(uintptr_t addr); - void relocate(); - - // Continuations - bool is_allocating(uintptr_t addr) const; - - // Iteration - void object_iterate(ObjectClosure* cl, bool visit_weaks); - ParallelObjectIteratorImpl* parallel_object_iterator(uint nworkers, bool visit_weaks); - void pages_do(XPageClosure* cl); - - // Serviceability - void serviceability_initialize(); - GCMemoryManager* serviceability_cycle_memory_manager(); - GCMemoryManager* serviceability_pause_memory_manager(); - MemoryPool* serviceability_memory_pool(); - XServiceabilityCounters* serviceability_counters(); - - // Printing - void print_on(outputStream* st) const; - void print_extended_on(outputStream* st) const; - bool print_location(outputStream* st, uintptr_t addr) const; - - // Verification - bool is_oop(uintptr_t addr) const; - void verify(); -}; - -#endif // SHARE_GC_X_XHEAP_HPP diff --git a/src/hotspot/share/gc/x/xHeap.inline.hpp b/src/hotspot/share/gc/x/xHeap.inline.hpp deleted file mode 100644 index 793a7200177..00000000000 --- a/src/hotspot/share/gc/x/xHeap.inline.hpp +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (c) 2015, 2022, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XHEAP_INLINE_HPP -#define SHARE_GC_X_XHEAP_INLINE_HPP - -#include "gc/x/xHeap.hpp" - -#include "gc/x/xAddress.inline.hpp" -#include "gc/x/xForwardingTable.inline.hpp" -#include "gc/x/xMark.inline.hpp" -#include "gc/x/xPage.inline.hpp" -#include "gc/x/xPageTable.inline.hpp" -#include "utilities/debug.hpp" - -inline XHeap* XHeap::heap() { - assert(_heap != nullptr, "Not initialized"); - return _heap; -} - -inline ReferenceDiscoverer* XHeap::reference_discoverer() { - return &_reference_processor; -} - -inline bool XHeap::is_object_live(uintptr_t addr) const { - XPage* page = _page_table.get(addr); - return page->is_object_live(addr); -} - -inline bool XHeap::is_object_strongly_live(uintptr_t addr) const { - XPage* page = _page_table.get(addr); - return page->is_object_strongly_live(addr); -} - -template -inline void XHeap::mark_object(uintptr_t addr) { - assert(XGlobalPhase == XPhaseMark, "Mark not allowed"); - _mark.mark_object(addr); -} - -inline uintptr_t XHeap::alloc_tlab(size_t size) { - guarantee(size <= max_tlab_size(), "TLAB too large"); - return _object_allocator.alloc_object(size); -} - -inline uintptr_t XHeap::alloc_object(size_t size) { - uintptr_t addr = _object_allocator.alloc_object(size); - assert(XAddress::is_good_or_null(addr), "Bad address"); - - if (addr == 0) { - out_of_memory(); - } - - return addr; -} - -inline uintptr_t XHeap::alloc_object_for_relocation(size_t size) { - const uintptr_t addr = _object_allocator.alloc_object_for_relocation(&_page_table, size); - assert(XAddress::is_good_or_null(addr), "Bad address"); - return addr; -} - -inline void XHeap::undo_alloc_object_for_relocation(uintptr_t addr, size_t size) { - XPage* const page = _page_table.get(addr); - _object_allocator.undo_alloc_object_for_relocation(page, addr, size); -} - -inline uintptr_t XHeap::relocate_object(uintptr_t addr) { - assert(XGlobalPhase == XPhaseRelocate, "Relocate not allowed"); - - XForwarding* const forwarding = _forwarding_table.get(addr); - if (forwarding == nullptr) { - // Not forwarding - return XAddress::good(addr); - } - - // Relocate object - return _relocate.relocate_object(forwarding, XAddress::good(addr)); -} - -inline uintptr_t XHeap::remap_object(uintptr_t addr) { - assert(XGlobalPhase == XPhaseMark || - XGlobalPhase == XPhaseMarkCompleted, "Forward not allowed"); - - XForwarding* const forwarding = _forwarding_table.get(addr); - if (forwarding == nullptr) { - // Not forwarding - return XAddress::good(addr); - } - - // Forward object - return _relocate.forward_object(forwarding, XAddress::good(addr)); -} - -inline bool XHeap::has_alloc_stalled() const { - return _page_allocator.has_alloc_stalled(); -} - -inline void XHeap::check_out_of_memory() { - _page_allocator.check_out_of_memory(); -} - -inline bool XHeap::is_oop(uintptr_t addr) const { - return XAddress::is_good(addr) && is_object_aligned(addr) && is_in(addr); -} - -#endif // SHARE_GC_X_XHEAP_INLINE_HPP diff --git a/src/hotspot/share/gc/x/xHeapIterator.cpp b/src/hotspot/share/gc/x/xHeapIterator.cpp deleted file mode 100644 index 47a6db26f69..00000000000 --- a/src/hotspot/share/gc/x/xHeapIterator.cpp +++ /dev/null @@ -1,439 +0,0 @@ -/* - * Copyright (c) 2017, 2022, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "classfile/classLoaderDataGraph.hpp" -#include "gc/shared/barrierSetNMethod.hpp" -#include "gc/shared/gc_globals.hpp" -#include "gc/shared/taskqueue.inline.hpp" -#include "gc/x/xAddress.inline.hpp" -#include "gc/x/xCollectedHeap.hpp" -#include "gc/x/xGlobals.hpp" -#include "gc/x/xGranuleMap.inline.hpp" -#include "gc/x/xHeapIterator.hpp" -#include "gc/x/xLock.inline.hpp" -#include "gc/x/xNMethod.hpp" -#include "gc/x/xOop.inline.hpp" -#include "memory/iterator.inline.hpp" -#include "utilities/bitMap.inline.hpp" - -class XHeapIteratorBitMap : public CHeapObj { -private: - CHeapBitMap _bitmap; - -public: - XHeapIteratorBitMap(size_t size_in_bits) : - _bitmap(size_in_bits, mtGC) {} - - bool try_set_bit(size_t index) { - return _bitmap.par_set_bit(index); - } -}; - -class XHeapIteratorContext { -private: - XHeapIterator* const _iter; - XHeapIteratorQueue* const _queue; - XHeapIteratorArrayQueue* const _array_queue; - const uint _worker_id; - XStatTimerDisable _timer_disable; - -public: - XHeapIteratorContext(XHeapIterator* iter, uint worker_id) : - _iter(iter), - _queue(_iter->_queues.queue(worker_id)), - _array_queue(_iter->_array_queues.queue(worker_id)), - _worker_id(worker_id) {} - - void mark_and_push(oop obj) const { - if (_iter->mark_object(obj)) { - _queue->push(obj); - } - } - - void push_array(const ObjArrayTask& array) const { - _array_queue->push(array); - } - - bool pop(oop& obj) const { - return _queue->pop_overflow(obj) || _queue->pop_local(obj); - } - - bool pop_array(ObjArrayTask& array) const { - return _array_queue->pop_overflow(array) || _array_queue->pop_local(array); - } - - bool steal(oop& obj) const { - return _iter->_queues.steal(_worker_id, obj); - } - - bool steal_array(ObjArrayTask& array) const { - return _iter->_array_queues.steal(_worker_id, array); - } - - bool is_drained() const { - return _queue->is_empty() && _array_queue->is_empty(); - } -}; - -template -class XHeapIteratorRootOopClosure : public OopClosure { -private: - const XHeapIteratorContext& _context; - - oop load_oop(oop* p) { - if (Weak) { - return NativeAccess::oop_load(p); - } - - return NativeAccess::oop_load(p); - } - -public: - XHeapIteratorRootOopClosure(const XHeapIteratorContext& context) : - _context(context) {} - - virtual void do_oop(oop* p) { - const oop obj = load_oop(p); - _context.mark_and_push(obj); - } - - virtual void do_oop(narrowOop* p) { - ShouldNotReachHere(); - } -}; - -template -class XHeapIteratorOopClosure : public OopIterateClosure { -private: - const XHeapIteratorContext& _context; - const oop _base; - - oop load_oop(oop* p) { - assert(XCollectedHeap::heap()->is_in(p), "Should be in heap"); - - if (VisitReferents) { - return HeapAccess::oop_load_at(_base, _base->field_offset(p)); - } - - return HeapAccess::oop_load(p); - } - -public: - XHeapIteratorOopClosure(const XHeapIteratorContext& context, oop base) : - OopIterateClosure(), - _context(context), - _base(base) {} - - virtual ReferenceIterationMode reference_iteration_mode() { - return VisitReferents ? DO_FIELDS : DO_FIELDS_EXCEPT_REFERENT; - } - - virtual void do_oop(oop* p) { - const oop obj = load_oop(p); - _context.mark_and_push(obj); - } - - virtual void do_oop(narrowOop* p) { - ShouldNotReachHere(); - } - - virtual bool do_metadata() { - return true; - } - - virtual void do_klass(Klass* k) { - ClassLoaderData* const cld = k->class_loader_data(); - XHeapIteratorOopClosure::do_cld(cld); - } - - virtual void do_cld(ClassLoaderData* cld) { - class NativeAccessClosure : public OopClosure { - private: - const XHeapIteratorContext& _context; - - public: - explicit NativeAccessClosure(const XHeapIteratorContext& context) : - _context(context) {} - - virtual void do_oop(oop* p) { - assert(!XCollectedHeap::heap()->is_in(p), "Should not be in heap"); - const oop obj = NativeAccess::oop_load(p); - _context.mark_and_push(obj); - } - - virtual void do_oop(narrowOop* p) { - ShouldNotReachHere(); - } - }; - - NativeAccessClosure cl(_context); - cld->oops_do(&cl, ClassLoaderData::_claim_other); - } - - // Don't follow loom stack metadata; it's already followed in other ways through CLDs - virtual void do_nmethod(nmethod* nm) {} - virtual void do_method(Method* m) {} -}; - -XHeapIterator::XHeapIterator(uint nworkers, bool visit_weaks) : - _visit_weaks(visit_weaks), - _timer_disable(), - _bitmaps(XAddressOffsetMax), - _bitmaps_lock(), - _queues(nworkers), - _array_queues(nworkers), - _roots(ClassLoaderData::_claim_other), - _weak_roots(), - _terminator(nworkers, &_queues) { - - // Create queues - for (uint i = 0; i < _queues.size(); i++) { - XHeapIteratorQueue* const queue = new XHeapIteratorQueue(); - _queues.register_queue(i, queue); - } - - // Create array queues - for (uint i = 0; i < _array_queues.size(); i++) { - XHeapIteratorArrayQueue* const array_queue = new XHeapIteratorArrayQueue(); - _array_queues.register_queue(i, array_queue); - } -} - -XHeapIterator::~XHeapIterator() { - // Destroy bitmaps - XHeapIteratorBitMapsIterator iter(&_bitmaps); - for (XHeapIteratorBitMap* bitmap; iter.next(&bitmap);) { - delete bitmap; - } - - // Destroy array queues - for (uint i = 0; i < _array_queues.size(); i++) { - delete _array_queues.queue(i); - } - - // Destroy queues - for (uint i = 0; i < _queues.size(); i++) { - delete _queues.queue(i); - } - - // Clear claimed CLD bits - ClassLoaderDataGraph::clear_claimed_marks(ClassLoaderData::_claim_other); -} - -static size_t object_index_max() { - return XGranuleSize >> XObjectAlignmentSmallShift; -} - -static size_t object_index(oop obj) { - const uintptr_t addr = XOop::to_address(obj); - const uintptr_t offset = XAddress::offset(addr); - const uintptr_t mask = XGranuleSize - 1; - return (offset & mask) >> XObjectAlignmentSmallShift; -} - -XHeapIteratorBitMap* XHeapIterator::object_bitmap(oop obj) { - const uintptr_t offset = XAddress::offset(XOop::to_address(obj)); - XHeapIteratorBitMap* bitmap = _bitmaps.get_acquire(offset); - if (bitmap == nullptr) { - XLocker locker(&_bitmaps_lock); - bitmap = _bitmaps.get(offset); - if (bitmap == nullptr) { - // Install new bitmap - bitmap = new XHeapIteratorBitMap(object_index_max()); - _bitmaps.release_put(offset, bitmap); - } - } - - return bitmap; -} - -bool XHeapIterator::mark_object(oop obj) { - if (obj == nullptr) { - return false; - } - - XHeapIteratorBitMap* const bitmap = object_bitmap(obj); - const size_t index = object_index(obj); - return bitmap->try_set_bit(index); -} - -typedef ClaimingCLDToOopClosure XHeapIteratorCLDCLosure; - -class XHeapIteratorNMethodClosure : public NMethodClosure { -private: - OopClosure* const _cl; - BarrierSetNMethod* const _bs_nm; - -public: - XHeapIteratorNMethodClosure(OopClosure* cl) : - _cl(cl), - _bs_nm(BarrierSet::barrier_set()->barrier_set_nmethod()) {} - - virtual void do_nmethod(nmethod* nm) { - // If ClassUnloading is turned off, all nmethods are considered strong, - // not only those on the call stacks. The heap iteration might happen - // before the concurrent processign of the code cache, make sure that - // all nmethods have been processed before visiting the oops. - _bs_nm->nmethod_entry_barrier(nm); - - XNMethod::nmethod_oops_do(nm, _cl); - } -}; - -class XHeapIteratorThreadClosure : public ThreadClosure { -private: - OopClosure* const _cl; - NMethodClosure* const _nm_cl; - -public: - XHeapIteratorThreadClosure(OopClosure* cl, NMethodClosure* nm_cl) : - _cl(cl), - _nm_cl(nm_cl) {} - - void do_thread(Thread* thread) { - thread->oops_do(_cl, _nm_cl); - } -}; - -void XHeapIterator::push_strong_roots(const XHeapIteratorContext& context) { - XHeapIteratorRootOopClosure cl(context); - XHeapIteratorCLDCLosure cld_cl(&cl); - XHeapIteratorNMethodClosure nm_cl(&cl); - XHeapIteratorThreadClosure thread_cl(&cl, &nm_cl); - - _roots.apply(&cl, - &cld_cl, - &thread_cl, - &nm_cl); -} - -void XHeapIterator::push_weak_roots(const XHeapIteratorContext& context) { - XHeapIteratorRootOopClosure cl(context); - _weak_roots.apply(&cl); -} - -template -void XHeapIterator::push_roots(const XHeapIteratorContext& context) { - push_strong_roots(context); - if (VisitWeaks) { - push_weak_roots(context); - } -} - -template -void XHeapIterator::follow_object(const XHeapIteratorContext& context, oop obj) { - XHeapIteratorOopClosure cl(context, obj); - obj->oop_iterate(&cl); -} - -void XHeapIterator::follow_array(const XHeapIteratorContext& context, oop obj) { - // Follow klass - XHeapIteratorOopClosure cl(context, obj); - cl.do_klass(obj->klass()); - - // Push array chunk - context.push_array(ObjArrayTask(obj, 0 /* index */)); -} - -void XHeapIterator::follow_array_chunk(const XHeapIteratorContext& context, const ObjArrayTask& array) { - const objArrayOop obj = objArrayOop(array.obj()); - const int length = obj->length(); - const int start = array.index(); - const int stride = MIN2(length - start, ObjArrayMarkingStride); - const int end = start + stride; - - // Push remaining array chunk first - if (end < length) { - context.push_array(ObjArrayTask(obj, end)); - } - - // Follow array chunk - XHeapIteratorOopClosure cl(context, obj); - obj->oop_iterate_range(&cl, start, end); -} - -template -void XHeapIterator::visit_and_follow(const XHeapIteratorContext& context, ObjectClosure* cl, oop obj) { - // Visit - cl->do_object(obj); - - // Follow - if (obj->is_objArray()) { - follow_array(context, obj); - } else { - follow_object(context, obj); - } -} - -template -void XHeapIterator::drain(const XHeapIteratorContext& context, ObjectClosure* cl) { - ObjArrayTask array; - oop obj; - - do { - while (context.pop(obj)) { - visit_and_follow(context, cl, obj); - } - - if (context.pop_array(array)) { - follow_array_chunk(context, array); - } - } while (!context.is_drained()); -} - -template -void XHeapIterator::steal(const XHeapIteratorContext& context, ObjectClosure* cl) { - ObjArrayTask array; - oop obj; - - if (context.steal_array(array)) { - follow_array_chunk(context, array); - } else if (context.steal(obj)) { - visit_and_follow(context, cl, obj); - } -} - -template -void XHeapIterator::drain_and_steal(const XHeapIteratorContext& context, ObjectClosure* cl) { - do { - drain(context, cl); - steal(context, cl); - } while (!context.is_drained() || !_terminator.offer_termination()); -} - -template -void XHeapIterator::object_iterate_inner(const XHeapIteratorContext& context, ObjectClosure* object_cl) { - push_roots(context); - drain_and_steal(context, object_cl); -} - -void XHeapIterator::object_iterate(ObjectClosure* cl, uint worker_id) { - XHeapIteratorContext context(this, worker_id); - - if (_visit_weaks) { - object_iterate_inner(context, cl); - } else { - object_iterate_inner(context, cl); - } -} diff --git a/src/hotspot/share/gc/x/xHeapIterator.hpp b/src/hotspot/share/gc/x/xHeapIterator.hpp deleted file mode 100644 index 0d990a616f8..00000000000 --- a/src/hotspot/share/gc/x/xHeapIterator.hpp +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2017, 2020, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XHEAPITERATOR_HPP -#define SHARE_GC_X_XHEAPITERATOR_HPP - -#include "gc/shared/collectedHeap.hpp" -#include "gc/shared/taskTerminator.hpp" -#include "gc/shared/taskqueue.hpp" -#include "gc/x/xGranuleMap.hpp" -#include "gc/x/xLock.hpp" -#include "gc/x/xRootsIterator.hpp" -#include "gc/x/xStat.hpp" - -class XHeapIteratorBitMap; -class XHeapIteratorContext; - -using XHeapIteratorBitMaps = XGranuleMap; -using XHeapIteratorBitMapsIterator = XGranuleMapIterator; -using XHeapIteratorQueue = OverflowTaskQueue; -using XHeapIteratorQueues = GenericTaskQueueSet; -using XHeapIteratorArrayQueue = OverflowTaskQueue; -using XHeapIteratorArrayQueues = GenericTaskQueueSet; - -class XHeapIterator : public ParallelObjectIteratorImpl { - friend class XHeapIteratorContext; - -private: - const bool _visit_weaks; - XStatTimerDisable _timer_disable; - XHeapIteratorBitMaps _bitmaps; - XLock _bitmaps_lock; - XHeapIteratorQueues _queues; - XHeapIteratorArrayQueues _array_queues; - XRootsIterator _roots; - XWeakRootsIterator _weak_roots; - TaskTerminator _terminator; - - XHeapIteratorBitMap* object_bitmap(oop obj); - - bool mark_object(oop obj); - - void push_strong_roots(const XHeapIteratorContext& context); - void push_weak_roots(const XHeapIteratorContext& context); - - template - void push_roots(const XHeapIteratorContext& context); - - template - void follow_object(const XHeapIteratorContext& context, oop obj); - - void follow_array(const XHeapIteratorContext& context, oop obj); - void follow_array_chunk(const XHeapIteratorContext& context, const ObjArrayTask& array); - - template - void visit_and_follow(const XHeapIteratorContext& context, ObjectClosure* cl, oop obj); - - template - void drain(const XHeapIteratorContext& context, ObjectClosure* cl); - - template - void steal(const XHeapIteratorContext& context, ObjectClosure* cl); - - template - void drain_and_steal(const XHeapIteratorContext& context, ObjectClosure* cl); - - template - void object_iterate_inner(const XHeapIteratorContext& context, ObjectClosure* cl); - -public: - XHeapIterator(uint nworkers, bool visit_weaks); - virtual ~XHeapIterator(); - - virtual void object_iterate(ObjectClosure* cl, uint worker_id); -}; - -#endif // SHARE_GC_X_XHEAPITERATOR_HPP diff --git a/src/hotspot/share/gc/x/xHeuristics.cpp b/src/hotspot/share/gc/x/xHeuristics.cpp deleted file mode 100644 index ec89fa41919..00000000000 --- a/src/hotspot/share/gc/x/xHeuristics.cpp +++ /dev/null @@ -1,104 +0,0 @@ -/* - * Copyright (c) 2019, 2021, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/shared/gcLogPrecious.hpp" -#include "gc/shared/gc_globals.hpp" -#include "gc/x/xCPU.inline.hpp" -#include "gc/x/xGlobals.hpp" -#include "gc/x/xHeuristics.hpp" -#include "runtime/globals.hpp" -#include "runtime/os.hpp" -#include "utilities/globalDefinitions.hpp" -#include "utilities/powerOfTwo.hpp" - -void XHeuristics::set_medium_page_size() { - // Set XPageSizeMedium so that a medium page occupies at most 3.125% of the - // max heap size. XPageSizeMedium is initially set to 0, which means medium - // pages are effectively disabled. It is adjusted only if XPageSizeMedium - // becomes larger than XPageSizeSmall. - const size_t min = XGranuleSize; - const size_t max = XGranuleSize * 16; - const size_t unclamped = MaxHeapSize * 0.03125; - const size_t clamped = clamp(unclamped, min, max); - const size_t size = round_down_power_of_2(clamped); - - if (size > XPageSizeSmall) { - // Enable medium pages - XPageSizeMedium = size; - XPageSizeMediumShift = log2i_exact(XPageSizeMedium); - XObjectSizeLimitMedium = XPageSizeMedium / 8; - XObjectAlignmentMediumShift = (int)XPageSizeMediumShift - 13; - XObjectAlignmentMedium = 1 << XObjectAlignmentMediumShift; - } -} - -size_t XHeuristics::relocation_headroom() { - // Calculate headroom needed to avoid in-place relocation. Each worker will try - // to allocate a small page, and all workers will share a single medium page. - const uint nworkers = UseDynamicNumberOfGCThreads ? ConcGCThreads : MAX2(ConcGCThreads, ParallelGCThreads); - return (nworkers * XPageSizeSmall) + XPageSizeMedium; -} - -bool XHeuristics::use_per_cpu_shared_small_pages() { - // Use per-CPU shared small pages only if these pages occupy at most 3.125% - // of the max heap size. Otherwise fall back to using a single shared small - // page. This is useful when using small heaps on large machines. - const size_t per_cpu_share = (MaxHeapSize * 0.03125) / XCPU::count(); - return per_cpu_share >= XPageSizeSmall; -} - -static uint nworkers_based_on_ncpus(double cpu_share_in_percent) { - return ceil(os::initial_active_processor_count() * cpu_share_in_percent / 100.0); -} - -static uint nworkers_based_on_heap_size(double heap_share_in_percent) { - const int nworkers = (MaxHeapSize * (heap_share_in_percent / 100.0)) / XPageSizeSmall; - return MAX2(nworkers, 1); -} - -static uint nworkers(double cpu_share_in_percent) { - // Cap number of workers so that they don't use more than 2% of the max heap - // during relocation. This is useful when using small heaps on large machines. - return MIN2(nworkers_based_on_ncpus(cpu_share_in_percent), - nworkers_based_on_heap_size(2.0)); -} - -uint XHeuristics::nparallel_workers() { - // Use 60% of the CPUs, rounded up. We would like to use as many threads as - // possible to increase parallelism. However, using a thread count that is - // close to the number of processors tends to lead to over-provisioning and - // scheduling latency issues. Using 60% of the active processors appears to - // be a fairly good balance. - return nworkers(60.0); -} - -uint XHeuristics::nconcurrent_workers() { - // The number of concurrent threads we would like to use heavily depends - // on the type of workload we are running. Using too many threads will have - // a negative impact on the application throughput, while using too few - // threads will prolong the GC-cycle and we then risk being out-run by the - // application. When in dynamic mode, use up to 25% of the active processors. - // When in non-dynamic mode, use 12.5% of the active processors. - return nworkers(UseDynamicNumberOfGCThreads ? 25.0 : 12.5); -} diff --git a/src/hotspot/share/gc/x/xHeuristics.hpp b/src/hotspot/share/gc/x/xHeuristics.hpp deleted file mode 100644 index 2ca798257b2..00000000000 --- a/src/hotspot/share/gc/x/xHeuristics.hpp +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2019, 2022, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XHEURISTICS_HPP -#define SHARE_GC_X_XHEURISTICS_HPP - -#include "memory/allStatic.hpp" - -class XHeuristics : public AllStatic { -public: - static void set_medium_page_size(); - - static size_t relocation_headroom(); - - static bool use_per_cpu_shared_small_pages(); - - static uint nparallel_workers(); - static uint nconcurrent_workers(); -}; - -#endif // SHARE_GC_X_XHEURISTICS_HPP diff --git a/src/hotspot/share/gc/x/xInitialize.cpp b/src/hotspot/share/gc/x/xInitialize.cpp deleted file mode 100644 index 156be17971f..00000000000 --- a/src/hotspot/share/gc/x/xInitialize.cpp +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2016, 2020, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/x/xAddress.hpp" -#include "gc/x/xBarrierSet.hpp" -#include "gc/x/xCPU.hpp" -#include "gc/x/xGlobals.hpp" -#include "gc/x/xHeuristics.hpp" -#include "gc/x/xInitialize.hpp" -#include "gc/x/xLargePages.hpp" -#include "gc/x/xNUMA.hpp" -#include "gc/x/xStat.hpp" -#include "gc/x/xThreadLocalAllocBuffer.hpp" -#include "gc/x/xTracer.hpp" -#include "logging/log.hpp" -#include "runtime/vm_version.hpp" - -XInitialize::XInitialize(XBarrierSet* barrier_set) { - log_info(gc, init)("Initializing %s", XName); - log_info(gc, init)("Version: %s (%s)", - VM_Version::vm_release(), - VM_Version::jdk_debug_level()); - log_info(gc, init)("Using deprecated non-generational mode"); - - // Early initialization - XAddress::initialize(); - XNUMA::initialize(); - XCPU::initialize(); - XStatValue::initialize(); - XThreadLocalAllocBuffer::initialize(); - XTracer::initialize(); - XLargePages::initialize(); - XHeuristics::set_medium_page_size(); - XBarrierSet::set_barrier_set(barrier_set); - - pd_initialize(); -} diff --git a/src/hotspot/share/gc/x/xInitialize.hpp b/src/hotspot/share/gc/x/xInitialize.hpp deleted file mode 100644 index 30e7b65293e..00000000000 --- a/src/hotspot/share/gc/x/xInitialize.hpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XINITIALIZE_HPP -#define SHARE_GC_X_XINITIALIZE_HPP - -#include "memory/allocation.hpp" - -class XBarrierSet; - -class XInitialize { -private: - void pd_initialize(); - -public: - XInitialize(XBarrierSet* barrier_set); -}; - -#endif // SHARE_GC_X_XINITIALIZE_HPP diff --git a/src/hotspot/share/gc/x/xLargePages.cpp b/src/hotspot/share/gc/x/xLargePages.cpp deleted file mode 100644 index 13da763c6a3..00000000000 --- a/src/hotspot/share/gc/x/xLargePages.cpp +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2017, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/shared/gcLogPrecious.hpp" -#include "gc/x/xLargePages.hpp" -#include "runtime/os.hpp" - -XLargePages::State XLargePages::_state; - -void XLargePages::initialize() { - pd_initialize(); - - log_info_p(gc, init)("Memory: " JULONG_FORMAT "M", os::physical_memory() / M); - log_info_p(gc, init)("Large Page Support: %s", to_string()); -} - -const char* XLargePages::to_string() { - switch (_state) { - case Explicit: - return "Enabled (Explicit)"; - - case Transparent: - return "Enabled (Transparent)"; - - default: - return "Disabled"; - } -} diff --git a/src/hotspot/share/gc/x/xLargePages.hpp b/src/hotspot/share/gc/x/xLargePages.hpp deleted file mode 100644 index 562e83ffbd0..00000000000 --- a/src/hotspot/share/gc/x/xLargePages.hpp +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2017, 2022, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XLARGEPAGES_HPP -#define SHARE_GC_X_XLARGEPAGES_HPP - -#include "memory/allStatic.hpp" - -class XLargePages : public AllStatic { -private: - enum State { - Disabled, - Explicit, - Transparent - }; - - static State _state; - - static void pd_initialize(); - -public: - static void initialize(); - - static bool is_enabled(); - static bool is_explicit(); - static bool is_transparent(); - - static const char* to_string(); -}; - -#endif // SHARE_GC_X_XLARGEPAGES_HPP diff --git a/src/hotspot/share/gc/x/xLargePages.inline.hpp b/src/hotspot/share/gc/x/xLargePages.inline.hpp deleted file mode 100644 index 2f027c3b176..00000000000 --- a/src/hotspot/share/gc/x/xLargePages.inline.hpp +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2017, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XLARGEPAGES_INLINE_HPP -#define SHARE_GC_X_XLARGEPAGES_INLINE_HPP - -#include "gc/x/xLargePages.hpp" - -inline bool XLargePages::is_enabled() { - return _state != Disabled; -} - -inline bool XLargePages::is_explicit() { - return _state == Explicit; -} - -inline bool XLargePages::is_transparent() { - return _state == Transparent; -} - -#endif // SHARE_GC_X_XLARGEPAGES_INLINE_HPP diff --git a/src/hotspot/share/gc/x/xList.hpp b/src/hotspot/share/gc/x/xList.hpp deleted file mode 100644 index d689704d653..00000000000 --- a/src/hotspot/share/gc/x/xList.hpp +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) 2015, 2020, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XLIST_HPP -#define SHARE_GC_X_XLIST_HPP - -#include "memory/allocation.hpp" -#include "utilities/globalDefinitions.hpp" - -template class XList; - -// Element in a doubly linked list -template -class XListNode { - friend class XList; - -private: - XListNode* _next; - XListNode* _prev; - - NONCOPYABLE(XListNode); - - void verify_links() const; - void verify_links_linked() const; - void verify_links_unlinked() const; - -public: - XListNode(); - ~XListNode(); -}; - -// Doubly linked list -template -class XList { -private: - XListNode _head; - size_t _size; - - NONCOPYABLE(XList); - - void verify_head() const; - - void insert(XListNode* before, XListNode* node); - - XListNode* cast_to_inner(T* elem) const; - T* cast_to_outer(XListNode* node) const; - -public: - XList(); - - size_t size() const; - bool is_empty() const; - - T* first() const; - T* last() const; - T* next(T* elem) const; - T* prev(T* elem) const; - - void insert_first(T* elem); - void insert_last(T* elem); - void insert_before(T* before, T* elem); - void insert_after(T* after, T* elem); - - void remove(T* elem); - T* remove_first(); - T* remove_last(); -}; - -template -class XListIteratorImpl : public StackObj { -private: - const XList* const _list; - T* _next; - -public: - XListIteratorImpl(const XList* list); - - bool next(T** elem); -}; - -template -class XListRemoveIteratorImpl : public StackObj { -private: - XList* const _list; - -public: - XListRemoveIteratorImpl(XList* list); - - bool next(T** elem); -}; - -template using XListIterator = XListIteratorImpl; -template using XListReverseIterator = XListIteratorImpl; -template using XListRemoveIterator = XListRemoveIteratorImpl; - -#endif // SHARE_GC_X_XLIST_HPP diff --git a/src/hotspot/share/gc/x/xList.inline.hpp b/src/hotspot/share/gc/x/xList.inline.hpp deleted file mode 100644 index 22ca5b82059..00000000000 --- a/src/hotspot/share/gc/x/xList.inline.hpp +++ /dev/null @@ -1,238 +0,0 @@ -/* - * Copyright (c) 2015, 2020, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XLIST_INLINE_HPP -#define SHARE_GC_X_XLIST_INLINE_HPP - -#include "gc/x/xList.hpp" - -#include "utilities/debug.hpp" - -template -inline XListNode::XListNode() : - _next(this), - _prev(this) {} - -template -inline XListNode::~XListNode() { - verify_links_unlinked(); -} - -template -inline void XListNode::verify_links() const { - assert(_next->_prev == this, "Corrupt list node"); - assert(_prev->_next == this, "Corrupt list node"); -} - -template -inline void XListNode::verify_links_linked() const { - assert(_next != this, "Should be in a list"); - assert(_prev != this, "Should be in a list"); - verify_links(); -} - -template -inline void XListNode::verify_links_unlinked() const { - assert(_next == this, "Should not be in a list"); - assert(_prev == this, "Should not be in a list"); -} - -template -inline void XList::verify_head() const { - _head.verify_links(); -} - -template -inline void XList::insert(XListNode* before, XListNode* node) { - verify_head(); - - before->verify_links(); - node->verify_links_unlinked(); - - node->_prev = before; - node->_next = before->_next; - before->_next = node; - node->_next->_prev = node; - - before->verify_links_linked(); - node->verify_links_linked(); - - _size++; -} - -template -inline XListNode* XList::cast_to_inner(T* elem) const { - return &elem->_node; -} - -template -inline T* XList::cast_to_outer(XListNode* node) const { - return (T*)((uintptr_t)node - offset_of(T, _node)); -} - -template -inline XList::XList() : - _head(), - _size(0) { - verify_head(); -} - -template -inline size_t XList::size() const { - verify_head(); - return _size; -} - -template -inline bool XList::is_empty() const { - return size() == 0; -} - -template -inline T* XList::first() const { - return is_empty() ? nullptr : cast_to_outer(_head._next); -} - -template -inline T* XList::last() const { - return is_empty() ? nullptr : cast_to_outer(_head._prev); -} - -template -inline T* XList::next(T* elem) const { - verify_head(); - - XListNode* const node = cast_to_inner(elem); - node->verify_links_linked(); - - XListNode* const next = node->_next; - next->verify_links_linked(); - - return (next == &_head) ? nullptr : cast_to_outer(next); -} - -template -inline T* XList::prev(T* elem) const { - verify_head(); - - XListNode* const node = cast_to_inner(elem); - node->verify_links_linked(); - - XListNode* const prev = node->_prev; - prev->verify_links_linked(); - - return (prev == &_head) ? nullptr : cast_to_outer(prev); -} - -template -inline void XList::insert_first(T* elem) { - insert(&_head, cast_to_inner(elem)); -} - -template -inline void XList::insert_last(T* elem) { - insert(_head._prev, cast_to_inner(elem)); -} - -template -inline void XList::insert_before(T* before, T* elem) { - insert(cast_to_inner(before)->_prev, cast_to_inner(elem)); -} - -template -inline void XList::insert_after(T* after, T* elem) { - insert(cast_to_inner(after), cast_to_inner(elem)); -} - -template -inline void XList::remove(T* elem) { - verify_head(); - - XListNode* const node = cast_to_inner(elem); - node->verify_links_linked(); - - XListNode* const next = node->_next; - XListNode* const prev = node->_prev; - next->verify_links_linked(); - prev->verify_links_linked(); - - node->_next = prev->_next; - node->_prev = next->_prev; - node->verify_links_unlinked(); - - next->_prev = prev; - prev->_next = next; - next->verify_links(); - prev->verify_links(); - - _size--; -} - -template -inline T* XList::remove_first() { - T* elem = first(); - if (elem != nullptr) { - remove(elem); - } - - return elem; -} - -template -inline T* XList::remove_last() { - T* elem = last(); - if (elem != nullptr) { - remove(elem); - } - - return elem; -} - -template -inline XListIteratorImpl::XListIteratorImpl(const XList* list) : - _list(list), - _next(Forward ? list->first() : list->last()) {} - -template -inline bool XListIteratorImpl::next(T** elem) { - if (_next != nullptr) { - *elem = _next; - _next = Forward ? _list->next(_next) : _list->prev(_next); - return true; - } - - // No more elements - return false; -} - -template -inline XListRemoveIteratorImpl::XListRemoveIteratorImpl(XList* list) : - _list(list) {} - -template -inline bool XListRemoveIteratorImpl::next(T** elem) { - *elem = Forward ? _list->remove_first() : _list->remove_last(); - return *elem != nullptr; -} - -#endif // SHARE_GC_X_XLIST_INLINE_HPP diff --git a/src/hotspot/share/gc/x/xLiveMap.cpp b/src/hotspot/share/gc/x/xLiveMap.cpp deleted file mode 100644 index 91ef99754f7..00000000000 --- a/src/hotspot/share/gc/x/xLiveMap.cpp +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright (c) 2015, 2019, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/x/xHeap.inline.hpp" -#include "gc/x/xLiveMap.inline.hpp" -#include "gc/x/xStat.hpp" -#include "gc/x/xThread.inline.hpp" -#include "logging/log.hpp" -#include "runtime/atomic.hpp" -#include "utilities/debug.hpp" -#include "utilities/powerOfTwo.hpp" - -static const XStatCounter XCounterMarkSeqNumResetContention("Contention", "Mark SeqNum Reset Contention", XStatUnitOpsPerSecond); -static const XStatCounter XCounterMarkSegmentResetContention("Contention", "Mark Segment Reset Contention", XStatUnitOpsPerSecond); - -static size_t bitmap_size(uint32_t size, size_t nsegments) { - // We need at least one bit per segment - return MAX2(size, nsegments) * 2; -} - -XLiveMap::XLiveMap(uint32_t size) : - _seqnum(0), - _live_objects(0), - _live_bytes(0), - _segment_live_bits(0), - _segment_claim_bits(0), - _bitmap(bitmap_size(size, nsegments)), - _segment_shift(exact_log2(segment_size())) {} - -void XLiveMap::reset(size_t index) { - const uint32_t seqnum_initializing = (uint32_t)-1; - bool contention = false; - - // Multiple threads can enter here, make sure only one of them - // resets the marking information while the others busy wait. - for (uint32_t seqnum = Atomic::load_acquire(&_seqnum); - seqnum != XGlobalSeqNum; - seqnum = Atomic::load_acquire(&_seqnum)) { - if ((seqnum != seqnum_initializing) && - (Atomic::cmpxchg(&_seqnum, seqnum, seqnum_initializing) == seqnum)) { - // Reset marking information - _live_bytes = 0; - _live_objects = 0; - - // Clear segment claimed/live bits - segment_live_bits().clear(); - segment_claim_bits().clear(); - - assert(_seqnum == seqnum_initializing, "Invalid"); - - // Make sure the newly reset marking information is ordered - // before the update of the page seqnum, such that when the - // up-to-date seqnum is load acquired, the bit maps will not - // contain stale information. - Atomic::release_store(&_seqnum, XGlobalSeqNum); - break; - } - - // Mark reset contention - if (!contention) { - // Count contention once - XStatInc(XCounterMarkSeqNumResetContention); - contention = true; - - log_trace(gc)("Mark seqnum reset contention, thread: " PTR_FORMAT " (%s), map: " PTR_FORMAT ", bit: " SIZE_FORMAT, - XThread::id(), XThread::name(), p2i(this), index); - } - } -} - -void XLiveMap::reset_segment(BitMap::idx_t segment) { - bool contention = false; - - if (!claim_segment(segment)) { - // Already claimed, wait for live bit to be set - while (!is_segment_live(segment)) { - // Mark reset contention - if (!contention) { - // Count contention once - XStatInc(XCounterMarkSegmentResetContention); - contention = true; - - log_trace(gc)("Mark segment reset contention, thread: " PTR_FORMAT " (%s), map: " PTR_FORMAT ", segment: " SIZE_FORMAT, - XThread::id(), XThread::name(), p2i(this), segment); - } - } - - // Segment is live - return; - } - - // Segment claimed, clear it - const BitMap::idx_t start_index = segment_start(segment); - const BitMap::idx_t end_index = segment_end(segment); - if (segment_size() / BitsPerWord >= 32) { - _bitmap.clear_large_range(start_index, end_index); - } else { - _bitmap.clear_range(start_index, end_index); - } - - // Set live bit - const bool success = set_segment_live(segment); - assert(success, "Should never fail"); -} - -void XLiveMap::resize(uint32_t size) { - const size_t new_bitmap_size = bitmap_size(size, nsegments); - if (_bitmap.size() != new_bitmap_size) { - _bitmap.reinitialize(new_bitmap_size, false /* clear */); - _segment_shift = exact_log2(segment_size()); - } -} diff --git a/src/hotspot/share/gc/x/xLiveMap.hpp b/src/hotspot/share/gc/x/xLiveMap.hpp deleted file mode 100644 index 7bad774c6c6..00000000000 --- a/src/hotspot/share/gc/x/xLiveMap.hpp +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (c) 2015, 2019, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XLIVEMAP_HPP -#define SHARE_GC_X_XLIVEMAP_HPP - -#include "gc/x/xBitMap.hpp" -#include "memory/allocation.hpp" - -class ObjectClosure; - -class XLiveMap { - friend class XLiveMapTest; - -private: - static const size_t nsegments = 64; - - volatile uint32_t _seqnum; - volatile uint32_t _live_objects; - volatile size_t _live_bytes; - BitMap::bm_word_t _segment_live_bits; - BitMap::bm_word_t _segment_claim_bits; - XBitMap _bitmap; - size_t _segment_shift; - - const BitMapView segment_live_bits() const; - const BitMapView segment_claim_bits() const; - - BitMapView segment_live_bits(); - BitMapView segment_claim_bits(); - - BitMap::idx_t segment_size() const; - - BitMap::idx_t segment_start(BitMap::idx_t segment) const; - BitMap::idx_t segment_end(BitMap::idx_t segment) const; - - bool is_segment_live(BitMap::idx_t segment) const; - bool set_segment_live(BitMap::idx_t segment); - - BitMap::idx_t first_live_segment() const; - BitMap::idx_t next_live_segment(BitMap::idx_t segment) const; - BitMap::idx_t index_to_segment(BitMap::idx_t index) const; - - bool claim_segment(BitMap::idx_t segment); - - void reset(size_t index); - void reset_segment(BitMap::idx_t segment); - - void iterate_segment(ObjectClosure* cl, BitMap::idx_t segment, uintptr_t page_start, size_t page_object_alignment_shift); - -public: - XLiveMap(uint32_t size); - - void reset(); - void resize(uint32_t size); - - bool is_marked() const; - - uint32_t live_objects() const; - size_t live_bytes() const; - - bool get(size_t index) const; - bool set(size_t index, bool finalizable, bool& inc_live); - - void inc_live(uint32_t objects, size_t bytes); - - void iterate(ObjectClosure* cl, uintptr_t page_start, size_t page_object_alignment_shift); -}; - -#endif // SHARE_GC_X_XLIVEMAP_HPP diff --git a/src/hotspot/share/gc/x/xLiveMap.inline.hpp b/src/hotspot/share/gc/x/xLiveMap.inline.hpp deleted file mode 100644 index f836f9ab4c2..00000000000 --- a/src/hotspot/share/gc/x/xLiveMap.inline.hpp +++ /dev/null @@ -1,175 +0,0 @@ -/* - * Copyright (c) 2015, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XLIVEMAP_INLINE_HPP -#define SHARE_GC_X_XLIVEMAP_INLINE_HPP - -#include "gc/x/xLiveMap.hpp" - -#include "gc/x/xBitMap.inline.hpp" -#include "gc/x/xMark.hpp" -#include "gc/x/xOop.inline.hpp" -#include "gc/x/xUtils.inline.hpp" -#include "runtime/atomic.hpp" -#include "utilities/bitMap.inline.hpp" -#include "utilities/debug.hpp" - -inline void XLiveMap::reset() { - _seqnum = 0; -} - -inline bool XLiveMap::is_marked() const { - return Atomic::load_acquire(&_seqnum) == XGlobalSeqNum; -} - -inline uint32_t XLiveMap::live_objects() const { - assert(XGlobalPhase != XPhaseMark, "Invalid phase"); - return _live_objects; -} - -inline size_t XLiveMap::live_bytes() const { - assert(XGlobalPhase != XPhaseMark, "Invalid phase"); - return _live_bytes; -} - -inline const BitMapView XLiveMap::segment_live_bits() const { - return BitMapView(const_cast(&_segment_live_bits), nsegments); -} - -inline const BitMapView XLiveMap::segment_claim_bits() const { - return BitMapView(const_cast(&_segment_claim_bits), nsegments); -} - -inline BitMapView XLiveMap::segment_live_bits() { - return BitMapView(&_segment_live_bits, nsegments); -} - -inline BitMapView XLiveMap::segment_claim_bits() { - return BitMapView(&_segment_claim_bits, nsegments); -} - -inline bool XLiveMap::is_segment_live(BitMap::idx_t segment) const { - return segment_live_bits().par_at(segment); -} - -inline bool XLiveMap::set_segment_live(BitMap::idx_t segment) { - return segment_live_bits().par_set_bit(segment, memory_order_release); -} - -inline bool XLiveMap::claim_segment(BitMap::idx_t segment) { - return segment_claim_bits().par_set_bit(segment, memory_order_acq_rel); -} - -inline BitMap::idx_t XLiveMap::first_live_segment() const { - return segment_live_bits().find_first_set_bit(0, nsegments); -} - -inline BitMap::idx_t XLiveMap::next_live_segment(BitMap::idx_t segment) const { - return segment_live_bits().find_first_set_bit(segment + 1, nsegments); -} - -inline BitMap::idx_t XLiveMap::segment_size() const { - return _bitmap.size() / nsegments; -} - -inline BitMap::idx_t XLiveMap::index_to_segment(BitMap::idx_t index) const { - return index >> _segment_shift; -} - -inline bool XLiveMap::get(size_t index) const { - BitMap::idx_t segment = index_to_segment(index); - return is_marked() && // Page is marked - is_segment_live(segment) && // Segment is marked - _bitmap.par_at(index, memory_order_relaxed); // Object is marked -} - -inline bool XLiveMap::set(size_t index, bool finalizable, bool& inc_live) { - if (!is_marked()) { - // First object to be marked during this - // cycle, reset marking information. - reset(index); - } - - const BitMap::idx_t segment = index_to_segment(index); - if (!is_segment_live(segment)) { - // First object to be marked in this segment during - // this cycle, reset segment bitmap. - reset_segment(segment); - } - - return _bitmap.par_set_bit_pair(index, finalizable, inc_live); -} - -inline void XLiveMap::inc_live(uint32_t objects, size_t bytes) { - Atomic::add(&_live_objects, objects); - Atomic::add(&_live_bytes, bytes); -} - -inline BitMap::idx_t XLiveMap::segment_start(BitMap::idx_t segment) const { - return segment_size() * segment; -} - -inline BitMap::idx_t XLiveMap::segment_end(BitMap::idx_t segment) const { - return segment_start(segment) + segment_size(); -} - -inline void XLiveMap::iterate_segment(ObjectClosure* cl, BitMap::idx_t segment, uintptr_t page_start, size_t page_object_alignment_shift) { - assert(is_segment_live(segment), "Must be"); - - const BitMap::idx_t start_index = segment_start(segment); - const BitMap::idx_t end_index = segment_end(segment); - BitMap::idx_t index = _bitmap.find_first_set_bit(start_index, end_index); - - while (index < end_index) { - // Calculate object address - const uintptr_t addr = page_start + ((index / 2) << page_object_alignment_shift); - - // Get the size of the object before calling the closure, which - // might overwrite the object in case we are relocating in-place. - const size_t size = XUtils::object_size(addr); - - // Apply closure - cl->do_object(XOop::from_address(addr)); - - // Find next bit after this object - const uintptr_t next_addr = align_up(addr + size, 1 << page_object_alignment_shift); - const BitMap::idx_t next_index = ((next_addr - page_start) >> page_object_alignment_shift) * 2; - if (next_index >= end_index) { - // End of live map - break; - } - - index = _bitmap.find_first_set_bit(next_index, end_index); - } -} - -inline void XLiveMap::iterate(ObjectClosure* cl, uintptr_t page_start, size_t page_object_alignment_shift) { - if (is_marked()) { - for (BitMap::idx_t segment = first_live_segment(); segment < nsegments; segment = next_live_segment(segment)) { - // For each live segment - iterate_segment(cl, segment, page_start, page_object_alignment_shift); - } - } -} - -#endif // SHARE_GC_X_XLIVEMAP_INLINE_HPP diff --git a/src/hotspot/share/gc/x/xLock.hpp b/src/hotspot/share/gc/x/xLock.hpp deleted file mode 100644 index 2ba612d033c..00000000000 --- a/src/hotspot/share/gc/x/xLock.hpp +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2015, 2022, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XLOCK_HPP -#define SHARE_GC_X_XLOCK_HPP - -#include "memory/allocation.hpp" -#include "runtime/mutex.hpp" - -class XLock { -private: - PlatformMutex _lock; - -public: - void lock(); - bool try_lock(); - void unlock(); -}; - -class XReentrantLock { -private: - XLock _lock; - Thread* volatile _owner; - uint64_t _count; - -public: - XReentrantLock(); - - void lock(); - void unlock(); - - bool is_owned() const; -}; - -class XConditionLock { -private: - PlatformMonitor _lock; - -public: - void lock(); - bool try_lock(); - void unlock(); - - bool wait(uint64_t millis = 0); - void notify(); - void notify_all(); -}; - -template -class XLocker : public StackObj { -private: - T* const _lock; - -public: - XLocker(T* lock); - ~XLocker(); -}; - -#endif // SHARE_GC_X_XLOCK_HPP diff --git a/src/hotspot/share/gc/x/xLock.inline.hpp b/src/hotspot/share/gc/x/xLock.inline.hpp deleted file mode 100644 index a72b65aa228..00000000000 --- a/src/hotspot/share/gc/x/xLock.inline.hpp +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (c) 2015, 2020, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XLOCK_INLINE_HPP -#define SHARE_GC_X_XLOCK_INLINE_HPP - -#include "gc/x/xLock.hpp" - -#include "runtime/atomic.hpp" -#include "runtime/javaThread.hpp" -#include "runtime/os.inline.hpp" -#include "utilities/debug.hpp" - -inline void XLock::lock() { - _lock.lock(); -} - -inline bool XLock::try_lock() { - return _lock.try_lock(); -} - -inline void XLock::unlock() { - _lock.unlock(); -} - -inline XReentrantLock::XReentrantLock() : - _lock(), - _owner(nullptr), - _count(0) {} - -inline void XReentrantLock::lock() { - Thread* const thread = Thread::current(); - Thread* const owner = Atomic::load(&_owner); - - if (owner != thread) { - _lock.lock(); - Atomic::store(&_owner, thread); - } - - _count++; -} - -inline void XReentrantLock::unlock() { - assert(is_owned(), "Invalid owner"); - assert(_count > 0, "Invalid count"); - - _count--; - - if (_count == 0) { - Atomic::store(&_owner, (Thread*)nullptr); - _lock.unlock(); - } -} - -inline bool XReentrantLock::is_owned() const { - Thread* const thread = Thread::current(); - Thread* const owner = Atomic::load(&_owner); - return owner == thread; -} - -inline void XConditionLock::lock() { - _lock.lock(); -} - -inline bool XConditionLock::try_lock() { - return _lock.try_lock(); -} - -inline void XConditionLock::unlock() { - _lock.unlock(); -} - -inline bool XConditionLock::wait(uint64_t millis) { - return _lock.wait(millis) == OS_OK; -} - -inline void XConditionLock::notify() { - _lock.notify(); -} - -inline void XConditionLock::notify_all() { - _lock.notify_all(); -} - -template -inline XLocker::XLocker(T* lock) : - _lock(lock) { - if (_lock != nullptr) { - _lock->lock(); - } -} - -template -inline XLocker::~XLocker() { - if (_lock != nullptr) { - _lock->unlock(); - } -} - -#endif // SHARE_GC_X_XLOCK_INLINE_HPP diff --git a/src/hotspot/share/gc/x/xMark.cpp b/src/hotspot/share/gc/x/xMark.cpp deleted file mode 100644 index 016c5702615..00000000000 --- a/src/hotspot/share/gc/x/xMark.cpp +++ /dev/null @@ -1,877 +0,0 @@ -/* - * Copyright (c) 2015, 2022, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "classfile/classLoaderData.hpp" -#include "classfile/classLoaderDataGraph.hpp" -#include "classfile/javaClasses.inline.hpp" -#include "code/nmethod.hpp" -#include "gc/shared/continuationGCSupport.inline.hpp" -#include "gc/shared/gc_globals.hpp" -#include "gc/shared/stringdedup/stringDedup.hpp" -#include "gc/shared/suspendibleThreadSet.hpp" -#include "gc/x/xAbort.inline.hpp" -#include "gc/x/xBarrier.inline.hpp" -#include "gc/x/xHeap.inline.hpp" -#include "gc/x/xLock.inline.hpp" -#include "gc/x/xMark.inline.hpp" -#include "gc/x/xMarkCache.inline.hpp" -#include "gc/x/xMarkContext.inline.hpp" -#include "gc/x/xMarkStack.inline.hpp" -#include "gc/x/xMarkTerminate.inline.hpp" -#include "gc/x/xNMethod.hpp" -#include "gc/x/xOop.inline.hpp" -#include "gc/x/xPage.hpp" -#include "gc/x/xPageTable.inline.hpp" -#include "gc/x/xRootsIterator.hpp" -#include "gc/x/xStackWatermark.hpp" -#include "gc/x/xStat.hpp" -#include "gc/x/xTask.hpp" -#include "gc/x/xThread.inline.hpp" -#include "gc/x/xThreadLocalAllocBuffer.hpp" -#include "gc/x/xUtils.inline.hpp" -#include "gc/x/xWorkers.hpp" -#include "logging/log.hpp" -#include "memory/iterator.inline.hpp" -#include "oops/objArrayOop.inline.hpp" -#include "oops/oop.inline.hpp" -#include "runtime/atomic.hpp" -#include "runtime/continuation.hpp" -#include "runtime/handshake.hpp" -#include "runtime/javaThread.hpp" -#include "runtime/prefetch.inline.hpp" -#include "runtime/safepointMechanism.hpp" -#include "runtime/stackWatermark.hpp" -#include "runtime/stackWatermarkSet.inline.hpp" -#include "runtime/threads.hpp" -#include "utilities/align.hpp" -#include "utilities/globalDefinitions.hpp" -#include "utilities/powerOfTwo.hpp" -#include "utilities/ticks.hpp" - -static const XStatSubPhase XSubPhaseConcurrentMark("Concurrent Mark"); -static const XStatSubPhase XSubPhaseConcurrentMarkTryFlush("Concurrent Mark Try Flush"); -static const XStatSubPhase XSubPhaseConcurrentMarkTryTerminate("Concurrent Mark Try Terminate"); -static const XStatSubPhase XSubPhaseMarkTryComplete("Pause Mark Try Complete"); - -XMark::XMark(XWorkers* workers, XPageTable* page_table) : - _workers(workers), - _page_table(page_table), - _allocator(), - _stripes(), - _terminate(), - _work_terminateflush(true), - _work_nproactiveflush(0), - _work_nterminateflush(0), - _nproactiveflush(0), - _nterminateflush(0), - _ntrycomplete(0), - _ncontinue(0), - _nworkers(0) {} - -bool XMark::is_initialized() const { - return _allocator.is_initialized(); -} - -size_t XMark::calculate_nstripes(uint nworkers) const { - // Calculate the number of stripes from the number of workers we use, - // where the number of stripes must be a power of two and we want to - // have at least one worker per stripe. - const size_t nstripes = round_down_power_of_2(nworkers); - return MIN2(nstripes, XMarkStripesMax); -} - -void XMark::start() { - // Verification - if (ZVerifyMarking) { - verify_all_stacks_empty(); - } - - // Increment global sequence number to invalidate - // marking information for all pages. - XGlobalSeqNum++; - - // Note that we start a marking cycle. - // Unlike other GCs, the color switch implicitly changes the nmethods - // to be armed, and the thread-local disarm values are lazily updated - // when JavaThreads wake up from safepoints. - CodeCache::on_gc_marking_cycle_start(); - - // Reset flush/continue counters - _nproactiveflush = 0; - _nterminateflush = 0; - _ntrycomplete = 0; - _ncontinue = 0; - - // Set number of workers to use - _nworkers = _workers->active_workers(); - - // Set number of mark stripes to use, based on number - // of workers we will use in the concurrent mark phase. - const size_t nstripes = calculate_nstripes(_nworkers); - _stripes.set_nstripes(nstripes); - - // Update statistics - XStatMark::set_at_mark_start(nstripes); - - // Print worker/stripe distribution - LogTarget(Debug, gc, marking) log; - if (log.is_enabled()) { - log.print("Mark Worker/Stripe Distribution"); - for (uint worker_id = 0; worker_id < _nworkers; worker_id++) { - const XMarkStripe* const stripe = _stripes.stripe_for_worker(_nworkers, worker_id); - const size_t stripe_id = _stripes.stripe_id(stripe); - log.print(" Worker %u(%u) -> Stripe " SIZE_FORMAT "(" SIZE_FORMAT ")", - worker_id, _nworkers, stripe_id, nstripes); - } - } -} - -void XMark::prepare_work() { - assert(_nworkers == _workers->active_workers(), "Invalid number of workers"); - - // Set number of active workers - _terminate.reset(_nworkers); - - // Reset flush counters - _work_nproactiveflush = _work_nterminateflush = 0; - _work_terminateflush = true; -} - -void XMark::finish_work() { - // Accumulate proactive/terminate flush counters - _nproactiveflush += _work_nproactiveflush; - _nterminateflush += _work_nterminateflush; -} - -bool XMark::is_array(uintptr_t addr) const { - return XOop::from_address(addr)->is_objArray(); -} - -void XMark::push_partial_array(uintptr_t addr, size_t size, bool finalizable) { - assert(is_aligned(addr, XMarkPartialArrayMinSize), "Address misaligned"); - XMarkThreadLocalStacks* const stacks = XThreadLocalData::stacks(Thread::current()); - XMarkStripe* const stripe = _stripes.stripe_for_addr(addr); - const uintptr_t offset = XAddress::offset(addr) >> XMarkPartialArrayMinSizeShift; - const uintptr_t length = size / oopSize; - const XMarkStackEntry entry(offset, length, finalizable); - - log_develop_trace(gc, marking)("Array push partial: " PTR_FORMAT " (" SIZE_FORMAT "), stripe: " SIZE_FORMAT, - addr, size, _stripes.stripe_id(stripe)); - - stacks->push(&_allocator, &_stripes, stripe, entry, false /* publish */); -} - -void XMark::follow_small_array(uintptr_t addr, size_t size, bool finalizable) { - assert(size <= XMarkPartialArrayMinSize, "Too large, should be split"); - const size_t length = size / oopSize; - - log_develop_trace(gc, marking)("Array follow small: " PTR_FORMAT " (" SIZE_FORMAT ")", addr, size); - - XBarrier::mark_barrier_on_oop_array((oop*)addr, length, finalizable); -} - -void XMark::follow_large_array(uintptr_t addr, size_t size, bool finalizable) { - assert(size <= (size_t)arrayOopDesc::max_array_length(T_OBJECT) * oopSize, "Too large"); - assert(size > XMarkPartialArrayMinSize, "Too small, should not be split"); - const uintptr_t start = addr; - const uintptr_t end = start + size; - - // Calculate the aligned middle start/end/size, where the middle start - // should always be greater than the start (hence the +1 below) to make - // sure we always do some follow work, not just split the array into pieces. - const uintptr_t middle_start = align_up(start + 1, XMarkPartialArrayMinSize); - const size_t middle_size = align_down(end - middle_start, XMarkPartialArrayMinSize); - const uintptr_t middle_end = middle_start + middle_size; - - log_develop_trace(gc, marking)("Array follow large: " PTR_FORMAT "-" PTR_FORMAT" (" SIZE_FORMAT "), " - "middle: " PTR_FORMAT "-" PTR_FORMAT " (" SIZE_FORMAT ")", - start, end, size, middle_start, middle_end, middle_size); - - // Push unaligned trailing part - if (end > middle_end) { - const uintptr_t trailing_addr = middle_end; - const size_t trailing_size = end - middle_end; - push_partial_array(trailing_addr, trailing_size, finalizable); - } - - // Push aligned middle part(s) - uintptr_t partial_addr = middle_end; - while (partial_addr > middle_start) { - const size_t parts = 2; - const size_t partial_size = align_up((partial_addr - middle_start) / parts, XMarkPartialArrayMinSize); - partial_addr -= partial_size; - push_partial_array(partial_addr, partial_size, finalizable); - } - - // Follow leading part - assert(start < middle_start, "Miscalculated middle start"); - const uintptr_t leading_addr = start; - const size_t leading_size = middle_start - start; - follow_small_array(leading_addr, leading_size, finalizable); -} - -void XMark::follow_array(uintptr_t addr, size_t size, bool finalizable) { - if (size <= XMarkPartialArrayMinSize) { - follow_small_array(addr, size, finalizable); - } else { - follow_large_array(addr, size, finalizable); - } -} - -void XMark::follow_partial_array(XMarkStackEntry entry, bool finalizable) { - const uintptr_t addr = XAddress::good(entry.partial_array_offset() << XMarkPartialArrayMinSizeShift); - const size_t size = entry.partial_array_length() * oopSize; - - follow_array(addr, size, finalizable); -} - -template -class XMarkBarrierOopClosure : public ClaimMetadataVisitingOopIterateClosure { -public: - XMarkBarrierOopClosure() : - ClaimMetadataVisitingOopIterateClosure(finalizable - ? ClassLoaderData::_claim_finalizable - : ClassLoaderData::_claim_strong, - finalizable - ? nullptr - : XHeap::heap()->reference_discoverer()) {} - - virtual void do_oop(oop* p) { - XBarrier::mark_barrier_on_oop_field(p, finalizable); - } - - virtual void do_oop(narrowOop* p) { - ShouldNotReachHere(); - } - - virtual void do_nmethod(nmethod* nm) { - assert(!finalizable, "Can't handle finalizable marking of nmethods"); - nm->run_nmethod_entry_barrier(); - } -}; - -void XMark::follow_array_object(objArrayOop obj, bool finalizable) { - if (finalizable) { - XMarkBarrierOopClosure cl; - cl.do_klass(obj->klass()); - } else { - XMarkBarrierOopClosure cl; - cl.do_klass(obj->klass()); - } - - const uintptr_t addr = (uintptr_t)obj->base(); - const size_t size = (size_t)obj->length() * oopSize; - - follow_array(addr, size, finalizable); -} - -void XMark::follow_object(oop obj, bool finalizable) { - if (ContinuationGCSupport::relativize_stack_chunk(obj)) { - // Loom doesn't support mixing of finalizable marking and strong marking of - // stack chunks. See: RelativizeDerivedOopClosure. - XMarkBarrierOopClosure cl; - obj->oop_iterate(&cl); - return; - } - - if (finalizable) { - XMarkBarrierOopClosure cl; - obj->oop_iterate(&cl); - } else { - XMarkBarrierOopClosure cl; - obj->oop_iterate(&cl); - } -} - -static void try_deduplicate(XMarkContext* context, oop obj) { - if (!StringDedup::is_enabled()) { - // Not enabled - return; - } - - if (!java_lang_String::is_instance(obj)) { - // Not a String object - return; - } - - if (java_lang_String::test_and_set_deduplication_requested(obj)) { - // Already requested deduplication - return; - } - - // Request deduplication - context->string_dedup_requests()->add(obj); -} - -void XMark::mark_and_follow(XMarkContext* context, XMarkStackEntry entry) { - // Decode flags - const bool finalizable = entry.finalizable(); - const bool partial_array = entry.partial_array(); - - if (partial_array) { - follow_partial_array(entry, finalizable); - return; - } - - // Decode object address and additional flags - const uintptr_t addr = entry.object_address(); - const bool mark = entry.mark(); - bool inc_live = entry.inc_live(); - const bool follow = entry.follow(); - - XPage* const page = _page_table->get(addr); - assert(page->is_relocatable(), "Invalid page state"); - - // Mark - if (mark && !page->mark_object(addr, finalizable, inc_live)) { - // Already marked - return; - } - - // Increment live - if (inc_live) { - // Update live objects/bytes for page. We use the aligned object - // size since that is the actual number of bytes used on the page - // and alignment paddings can never be reclaimed. - const size_t size = XUtils::object_size(addr); - const size_t aligned_size = align_up(size, page->object_alignment()); - context->cache()->inc_live(page, aligned_size); - } - - // Follow - if (follow) { - if (is_array(addr)) { - follow_array_object(objArrayOop(XOop::from_address(addr)), finalizable); - } else { - const oop obj = XOop::from_address(addr); - follow_object(obj, finalizable); - - if (!finalizable) { - // Try deduplicate - try_deduplicate(context, obj); - } - } - } -} - -template -bool XMark::drain(XMarkContext* context, T* timeout) { - XMarkStripe* const stripe = context->stripe(); - XMarkThreadLocalStacks* const stacks = context->stacks(); - XMarkStackEntry entry; - - // Drain stripe stacks - while (stacks->pop(&_allocator, &_stripes, stripe, entry)) { - mark_and_follow(context, entry); - - // Check timeout - if (timeout->has_expired()) { - // Timeout - return false; - } - } - - // Success - return !timeout->has_expired(); -} - -bool XMark::try_steal_local(XMarkContext* context) { - XMarkStripe* const stripe = context->stripe(); - XMarkThreadLocalStacks* const stacks = context->stacks(); - - // Try to steal a local stack from another stripe - for (XMarkStripe* victim_stripe = _stripes.stripe_next(stripe); - victim_stripe != stripe; - victim_stripe = _stripes.stripe_next(victim_stripe)) { - XMarkStack* const stack = stacks->steal(&_stripes, victim_stripe); - if (stack != nullptr) { - // Success, install the stolen stack - stacks->install(&_stripes, stripe, stack); - return true; - } - } - - // Nothing to steal - return false; -} - -bool XMark::try_steal_global(XMarkContext* context) { - XMarkStripe* const stripe = context->stripe(); - XMarkThreadLocalStacks* const stacks = context->stacks(); - - // Try to steal a stack from another stripe - for (XMarkStripe* victim_stripe = _stripes.stripe_next(stripe); - victim_stripe != stripe; - victim_stripe = _stripes.stripe_next(victim_stripe)) { - XMarkStack* const stack = victim_stripe->steal_stack(); - if (stack != nullptr) { - // Success, install the stolen stack - stacks->install(&_stripes, stripe, stack); - return true; - } - } - - // Nothing to steal - return false; -} - -bool XMark::try_steal(XMarkContext* context) { - return try_steal_local(context) || try_steal_global(context); -} - -void XMark::idle() const { - os::naked_short_sleep(1); -} - -class XMarkFlushAndFreeStacksClosure : public HandshakeClosure { -private: - XMark* const _mark; - bool _flushed; - -public: - XMarkFlushAndFreeStacksClosure(XMark* mark) : - HandshakeClosure("XMarkFlushAndFreeStacks"), - _mark(mark), - _flushed(false) {} - - void do_thread(Thread* thread) { - if (_mark->flush_and_free(thread)) { - _flushed = true; - } - } - - bool flushed() const { - return _flushed; - } -}; - -bool XMark::flush(bool at_safepoint) { - XMarkFlushAndFreeStacksClosure cl(this); - if (at_safepoint) { - Threads::threads_do(&cl); - } else { - Handshake::execute(&cl); - } - - // Returns true if more work is available - return cl.flushed() || !_stripes.is_empty(); -} - -bool XMark::try_flush(volatile size_t* nflush) { - Atomic::inc(nflush); - - XStatTimer timer(XSubPhaseConcurrentMarkTryFlush); - return flush(false /* at_safepoint */); -} - -bool XMark::try_proactive_flush() { - // Only do proactive flushes from worker 0 - if (XThread::worker_id() != 0) { - return false; - } - - if (Atomic::load(&_work_nproactiveflush) == XMarkProactiveFlushMax || - Atomic::load(&_work_nterminateflush) != 0) { - // Limit reached or we're trying to terminate - return false; - } - - return try_flush(&_work_nproactiveflush); -} - -bool XMark::try_terminate() { - XStatTimer timer(XSubPhaseConcurrentMarkTryTerminate); - - if (_terminate.enter_stage0()) { - // Last thread entered stage 0, flush - if (Atomic::load(&_work_terminateflush) && - Atomic::load(&_work_nterminateflush) != XMarkTerminateFlushMax) { - // Exit stage 0 to allow other threads to continue marking - _terminate.exit_stage0(); - - // Flush before termination - if (!try_flush(&_work_nterminateflush)) { - // No more work available, skip further flush attempts - Atomic::store(&_work_terminateflush, false); - } - - // Don't terminate, regardless of whether we successfully - // flushed out more work or not. We've already exited - // termination stage 0, to allow other threads to continue - // marking, so this thread has to return false and also - // make another round of attempted marking. - return false; - } - } - - for (;;) { - if (_terminate.enter_stage1()) { - // Last thread entered stage 1, terminate - return true; - } - - // Idle to give the other threads - // a chance to enter termination. - idle(); - - if (!_terminate.try_exit_stage1()) { - // All workers in stage 1, terminate - return true; - } - - if (_terminate.try_exit_stage0()) { - // More work available, don't terminate - return false; - } - } -} - -class XMarkNoTimeout : public StackObj { -public: - bool has_expired() { - // No timeout, but check for signal to abort - return XAbort::should_abort(); - } -}; - -void XMark::work_without_timeout(XMarkContext* context) { - XStatTimer timer(XSubPhaseConcurrentMark); - XMarkNoTimeout no_timeout; - - for (;;) { - if (!drain(context, &no_timeout)) { - // Abort - break; - } - - if (try_steal(context)) { - // Stole work - continue; - } - - if (try_proactive_flush()) { - // Work available - continue; - } - - if (try_terminate()) { - // Terminate - break; - } - } -} - -class XMarkTimeout : public StackObj { -private: - const Ticks _start; - const uint64_t _timeout; - const uint64_t _check_interval; - uint64_t _check_at; - uint64_t _check_count; - bool _expired; - -public: - XMarkTimeout(uint64_t timeout_in_micros) : - _start(Ticks::now()), - _timeout(_start.value() + TimeHelper::micros_to_counter(timeout_in_micros)), - _check_interval(200), - _check_at(_check_interval), - _check_count(0), - _expired(false) {} - - ~XMarkTimeout() { - const Tickspan duration = Ticks::now() - _start; - log_debug(gc, marking)("Mark With Timeout (%s): %s, " UINT64_FORMAT " oops, %.3fms", - XThread::name(), _expired ? "Expired" : "Completed", - _check_count, TimeHelper::counter_to_millis(duration.value())); - } - - bool has_expired() { - if (++_check_count == _check_at) { - _check_at += _check_interval; - if ((uint64_t)Ticks::now().value() >= _timeout) { - // Timeout - _expired = true; - } - } - - return _expired; - } -}; - -void XMark::work_with_timeout(XMarkContext* context, uint64_t timeout_in_micros) { - XStatTimer timer(XSubPhaseMarkTryComplete); - XMarkTimeout timeout(timeout_in_micros); - - for (;;) { - if (!drain(context, &timeout)) { - // Timed out - break; - } - - if (try_steal(context)) { - // Stole work - continue; - } - - // Terminate - break; - } -} - -void XMark::work(uint64_t timeout_in_micros) { - XMarkStripe* const stripe = _stripes.stripe_for_worker(_nworkers, XThread::worker_id()); - XMarkThreadLocalStacks* const stacks = XThreadLocalData::stacks(Thread::current()); - XMarkContext context(_stripes.nstripes(), stripe, stacks); - - if (timeout_in_micros == 0) { - work_without_timeout(&context); - } else { - work_with_timeout(&context, timeout_in_micros); - } - - // Flush and publish stacks - stacks->flush(&_allocator, &_stripes); - - // Free remaining stacks - stacks->free(&_allocator); -} - -class XMarkOopClosure : public OopClosure { - virtual void do_oop(oop* p) { - XBarrier::mark_barrier_on_oop_field(p, false /* finalizable */); - } - - virtual void do_oop(narrowOop* p) { - ShouldNotReachHere(); - } -}; - -class XMarkThreadClosure : public ThreadClosure { -private: - OopClosure* const _cl; - -public: - XMarkThreadClosure(OopClosure* cl) : - _cl(cl) { - XThreadLocalAllocBuffer::reset_statistics(); - } - ~XMarkThreadClosure() { - XThreadLocalAllocBuffer::publish_statistics(); - } - virtual void do_thread(Thread* thread) { - JavaThread* const jt = JavaThread::cast(thread); - StackWatermarkSet::finish_processing(jt, _cl, StackWatermarkKind::gc); - XThreadLocalAllocBuffer::update_stats(jt); - } -}; - -class XMarkNMethodClosure : public NMethodClosure { -private: - OopClosure* const _cl; - -public: - XMarkNMethodClosure(OopClosure* cl) : - _cl(cl) {} - - virtual void do_nmethod(nmethod* nm) { - XLocker locker(XNMethod::lock_for_nmethod(nm)); - if (XNMethod::is_armed(nm)) { - XNMethod::nmethod_oops_do_inner(nm, _cl); - - // CodeCache unloading support - nm->mark_as_maybe_on_stack(); - - XNMethod::disarm(nm); - } - } -}; - -typedef ClaimingCLDToOopClosure XMarkCLDClosure; - -class XMarkRootsTask : public XTask { -private: - XMark* const _mark; - SuspendibleThreadSetJoiner _sts_joiner; - XRootsIterator _roots; - - XMarkOopClosure _cl; - XMarkCLDClosure _cld_cl; - XMarkThreadClosure _thread_cl; - XMarkNMethodClosure _nm_cl; - -public: - XMarkRootsTask(XMark* mark) : - XTask("XMarkRootsTask"), - _mark(mark), - _sts_joiner(), - _roots(ClassLoaderData::_claim_strong), - _cl(), - _cld_cl(&_cl), - _thread_cl(&_cl), - _nm_cl(&_cl) { - ClassLoaderDataGraph_lock->lock(); - } - - ~XMarkRootsTask() { - ClassLoaderDataGraph_lock->unlock(); - } - - virtual void work() { - _roots.apply(&_cl, - &_cld_cl, - &_thread_cl, - &_nm_cl); - - // Flush and free worker stacks. Needed here since - // the set of workers executing during root scanning - // can be different from the set of workers executing - // during mark. - _mark->flush_and_free(); - } -}; - -class XMarkTask : public XTask { -private: - XMark* const _mark; - const uint64_t _timeout_in_micros; - -public: - XMarkTask(XMark* mark, uint64_t timeout_in_micros = 0) : - XTask("XMarkTask"), - _mark(mark), - _timeout_in_micros(timeout_in_micros) { - _mark->prepare_work(); - } - - ~XMarkTask() { - _mark->finish_work(); - } - - virtual void work() { - _mark->work(_timeout_in_micros); - } -}; - -void XMark::mark(bool initial) { - if (initial) { - XMarkRootsTask task(this); - _workers->run(&task); - } - - XMarkTask task(this); - _workers->run(&task); -} - -bool XMark::try_complete() { - _ntrycomplete++; - - // Use nconcurrent number of worker threads to maintain the - // worker/stripe distribution used during concurrent mark. - XMarkTask task(this, XMarkCompleteTimeout); - _workers->run(&task); - - // Successful if all stripes are empty - return _stripes.is_empty(); -} - -bool XMark::try_end() { - // Flush all mark stacks - if (!flush(true /* at_safepoint */)) { - // Mark completed - return true; - } - - // Try complete marking by doing a limited - // amount of mark work in this phase. - return try_complete(); -} - -bool XMark::end() { - // Try end marking - if (!try_end()) { - // Mark not completed - _ncontinue++; - return false; - } - - // Verification - if (ZVerifyMarking) { - verify_all_stacks_empty(); - } - - // Update statistics - XStatMark::set_at_mark_end(_nproactiveflush, _nterminateflush, _ntrycomplete, _ncontinue); - - // Note that we finished a marking cycle. - // Unlike other GCs, we do not arm the nmethods - // when marking terminates. - CodeCache::on_gc_marking_cycle_finish(); - - // Mark completed - return true; -} - -void XMark::free() { - // Free any unused mark stack space - _allocator.free(); - - // Update statistics - XStatMark::set_at_mark_free(_allocator.size()); -} - -void XMark::flush_and_free() { - Thread* const thread = Thread::current(); - flush_and_free(thread); -} - -bool XMark::flush_and_free(Thread* thread) { - XMarkThreadLocalStacks* const stacks = XThreadLocalData::stacks(thread); - const bool flushed = stacks->flush(&_allocator, &_stripes); - stacks->free(&_allocator); - return flushed; -} - -class XVerifyMarkStacksEmptyClosure : public ThreadClosure { -private: - const XMarkStripeSet* const _stripes; - -public: - XVerifyMarkStacksEmptyClosure(const XMarkStripeSet* stripes) : - _stripes(stripes) {} - - void do_thread(Thread* thread) { - XMarkThreadLocalStacks* const stacks = XThreadLocalData::stacks(thread); - guarantee(stacks->is_empty(_stripes), "Should be empty"); - } -}; - -void XMark::verify_all_stacks_empty() const { - // Verify thread stacks - XVerifyMarkStacksEmptyClosure cl(&_stripes); - Threads::threads_do(&cl); - - // Verify stripe stacks - guarantee(_stripes.is_empty(), "Should be empty"); -} diff --git a/src/hotspot/share/gc/x/xMark.hpp b/src/hotspot/share/gc/x/xMark.hpp deleted file mode 100644 index 5e40b79f02e..00000000000 --- a/src/hotspot/share/gc/x/xMark.hpp +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (c) 2015, 2021, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XMARK_HPP -#define SHARE_GC_X_XMARK_HPP - -#include "gc/x/xMarkStack.hpp" -#include "gc/x/xMarkStackAllocator.hpp" -#include "gc/x/xMarkStackEntry.hpp" -#include "gc/x/xMarkTerminate.hpp" -#include "oops/oopsHierarchy.hpp" -#include "utilities/globalDefinitions.hpp" - -class Thread; -class XMarkContext; -class XPageTable; -class XWorkers; - -class XMark { - friend class XMarkTask; - -private: - XWorkers* const _workers; - XPageTable* const _page_table; - XMarkStackAllocator _allocator; - XMarkStripeSet _stripes; - XMarkTerminate _terminate; - volatile bool _work_terminateflush; - volatile size_t _work_nproactiveflush; - volatile size_t _work_nterminateflush; - size_t _nproactiveflush; - size_t _nterminateflush; - size_t _ntrycomplete; - size_t _ncontinue; - uint _nworkers; - - size_t calculate_nstripes(uint nworkers) const; - - bool is_array(uintptr_t addr) const; - void push_partial_array(uintptr_t addr, size_t size, bool finalizable); - void follow_small_array(uintptr_t addr, size_t size, bool finalizable); - void follow_large_array(uintptr_t addr, size_t size, bool finalizable); - void follow_array(uintptr_t addr, size_t size, bool finalizable); - void follow_partial_array(XMarkStackEntry entry, bool finalizable); - void follow_array_object(objArrayOop obj, bool finalizable); - void follow_object(oop obj, bool finalizable); - void mark_and_follow(XMarkContext* context, XMarkStackEntry entry); - - template bool drain(XMarkContext* context, T* timeout); - bool try_steal_local(XMarkContext* context); - bool try_steal_global(XMarkContext* context); - bool try_steal(XMarkContext* context); - void idle() const; - bool flush(bool at_safepoint); - bool try_proactive_flush(); - bool try_flush(volatile size_t* nflush); - bool try_terminate(); - bool try_complete(); - bool try_end(); - - void prepare_work(); - void finish_work(); - - void work_without_timeout(XMarkContext* context); - void work_with_timeout(XMarkContext* context, uint64_t timeout_in_micros); - void work(uint64_t timeout_in_micros); - - void verify_all_stacks_empty() const; - -public: - XMark(XWorkers* workers, XPageTable* page_table); - - bool is_initialized() const; - - template void mark_object(uintptr_t addr); - - void start(); - void mark(bool initial); - bool end(); - void free(); - - void flush_and_free(); - bool flush_and_free(Thread* thread); -}; - -#endif // SHARE_GC_X_XMARK_HPP diff --git a/src/hotspot/share/gc/x/xMark.inline.hpp b/src/hotspot/share/gc/x/xMark.inline.hpp deleted file mode 100644 index 1f8fc81f525..00000000000 --- a/src/hotspot/share/gc/x/xMark.inline.hpp +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) 2015, 2021, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XMARK_INLINE_HPP -#define SHARE_GC_X_XMARK_INLINE_HPP - -#include "gc/x/xMark.hpp" - -#include "gc/x/xAddress.inline.hpp" -#include "gc/x/xMarkStack.inline.hpp" -#include "gc/x/xPage.inline.hpp" -#include "gc/x/xPageTable.inline.hpp" -#include "gc/x/xThreadLocalData.hpp" -#include "runtime/javaThread.hpp" -#include "utilities/debug.hpp" - -// Marking before pushing helps reduce mark stack memory usage. However, -// we only mark before pushing in GC threads to avoid burdening Java threads -// with writing to, and potentially first having to clear, mark bitmaps. -// -// It's also worth noting that while marking an object can be done at any -// time in the marking phase, following an object can only be done after -// root processing has called ClassLoaderDataGraph::clear_claimed_marks(), -// since it otherwise would interact badly with claiming of CLDs. - -template -inline void XMark::mark_object(uintptr_t addr) { - assert(XAddress::is_marked(addr), "Should be marked"); - - XPage* const page = _page_table->get(addr); - if (page->is_allocating()) { - // Already implicitly marked - return; - } - - const bool mark_before_push = gc_thread; - bool inc_live = false; - - if (mark_before_push) { - // Try mark object - if (!page->mark_object(addr, finalizable, inc_live)) { - // Already marked - return; - } - } else { - // Don't push if already marked - if (page->is_object_marked(addr)) { - // Already marked - return; - } - } - - // Push - XMarkThreadLocalStacks* const stacks = XThreadLocalData::stacks(Thread::current()); - XMarkStripe* const stripe = _stripes.stripe_for_addr(addr); - XMarkStackEntry entry(addr, !mark_before_push, inc_live, follow, finalizable); - stacks->push(&_allocator, &_stripes, stripe, entry, publish); -} - -#endif // SHARE_GC_X_XMARK_INLINE_HPP diff --git a/src/hotspot/share/gc/x/xMarkCache.cpp b/src/hotspot/share/gc/x/xMarkCache.cpp deleted file mode 100644 index c7e580ed883..00000000000 --- a/src/hotspot/share/gc/x/xMarkCache.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/x/xMarkCache.inline.hpp" -#include "utilities/globalDefinitions.hpp" -#include "utilities/powerOfTwo.hpp" - -XMarkCacheEntry::XMarkCacheEntry() : - _page(nullptr), - _objects(0), - _bytes(0) {} - -XMarkCache::XMarkCache(size_t nstripes) : - _shift(XMarkStripeShift + exact_log2(nstripes)) {} - -XMarkCache::~XMarkCache() { - // Evict all entries - for (size_t i = 0; i < XMarkCacheSize; i++) { - _cache[i].evict(); - } -} diff --git a/src/hotspot/share/gc/x/xMarkCache.hpp b/src/hotspot/share/gc/x/xMarkCache.hpp deleted file mode 100644 index 8fbdc873522..00000000000 --- a/src/hotspot/share/gc/x/xMarkCache.hpp +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XMARKCACHE_HPP -#define SHARE_GC_X_XMARKCACHE_HPP - -#include "gc/x/xGlobals.hpp" -#include "memory/allocation.hpp" - -class XPage; - -class XMarkCacheEntry { -private: - XPage* _page; - uint32_t _objects; - size_t _bytes; - -public: - XMarkCacheEntry(); - - void inc_live(XPage* page, size_t bytes); - void evict(); -}; - -class XMarkCache : public StackObj { -private: - const size_t _shift; - XMarkCacheEntry _cache[XMarkCacheSize]; - -public: - XMarkCache(size_t nstripes); - ~XMarkCache(); - - void inc_live(XPage* page, size_t bytes); -}; - -#endif // SHARE_GC_X_XMARKCACHE_HPP diff --git a/src/hotspot/share/gc/x/xMarkCache.inline.hpp b/src/hotspot/share/gc/x/xMarkCache.inline.hpp deleted file mode 100644 index 27dd1b93339..00000000000 --- a/src/hotspot/share/gc/x/xMarkCache.inline.hpp +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XMARKCACHE_INLINE_HPP -#define SHARE_GC_X_XMARKCACHE_INLINE_HPP - -#include "gc/x/xMarkCache.hpp" - -#include "gc/x/xPage.inline.hpp" - -inline void XMarkCacheEntry::inc_live(XPage* page, size_t bytes) { - if (_page == page) { - // Cache hit - _objects++; - _bytes += bytes; - } else { - // Cache miss - evict(); - _page = page; - _objects = 1; - _bytes = bytes; - } -} - -inline void XMarkCacheEntry::evict() { - if (_page != nullptr) { - // Write cached data out to page - _page->inc_live(_objects, _bytes); - _page = nullptr; - } -} - -inline void XMarkCache::inc_live(XPage* page, size_t bytes) { - const size_t mask = XMarkCacheSize - 1; - const size_t index = (page->start() >> _shift) & mask; - _cache[index].inc_live(page, bytes); -} - -#endif // SHARE_GC_X_XMARKCACHE_INLINE_HPP diff --git a/src/hotspot/share/gc/x/xMarkContext.hpp b/src/hotspot/share/gc/x/xMarkContext.hpp deleted file mode 100644 index 246822931b7..00000000000 --- a/src/hotspot/share/gc/x/xMarkContext.hpp +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2021, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XMARKCONTEXT_HPP -#define SHARE_GC_X_XMARKCONTEXT_HPP - -#include "gc/x/xMarkCache.hpp" -#include "gc/shared/stringdedup/stringDedup.hpp" -#include "memory/allocation.hpp" - -class XMarkStripe; -class XMarkThreadLocalStacks; - -class XMarkContext : public StackObj { -private: - XMarkCache _cache; - XMarkStripe* const _stripe; - XMarkThreadLocalStacks* const _stacks; - StringDedup::Requests _string_dedup_requests; - -public: - XMarkContext(size_t nstripes, - XMarkStripe* stripe, - XMarkThreadLocalStacks* stacks); - - XMarkCache* cache(); - XMarkStripe* stripe(); - XMarkThreadLocalStacks* stacks(); - StringDedup::Requests* string_dedup_requests(); -}; - -#endif // SHARE_GC_X_XMARKCONTEXT_HPP diff --git a/src/hotspot/share/gc/x/xMarkContext.inline.hpp b/src/hotspot/share/gc/x/xMarkContext.inline.hpp deleted file mode 100644 index 74a182b67c3..00000000000 --- a/src/hotspot/share/gc/x/xMarkContext.inline.hpp +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2021, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XMARKCONTEXT_INLINE_HPP -#define SHARE_GC_X_XMARKCONTEXT_INLINE_HPP - -#include "gc/x/xMarkContext.hpp" - -inline XMarkContext::XMarkContext(size_t nstripes, - XMarkStripe* stripe, - XMarkThreadLocalStacks* stacks) : - _cache(nstripes), - _stripe(stripe), - _stacks(stacks), - _string_dedup_requests() {} - -inline XMarkCache* XMarkContext::cache() { - return &_cache; -} - -inline XMarkStripe* XMarkContext::stripe() { - return _stripe; -} - -inline XMarkThreadLocalStacks* XMarkContext::stacks() { - return _stacks; -} - -inline StringDedup::Requests* XMarkContext::string_dedup_requests() { - return &_string_dedup_requests; -} - -#endif // SHARE_GC_X_XMARKCACHE_INLINE_HPP diff --git a/src/hotspot/share/gc/x/xMarkStack.cpp b/src/hotspot/share/gc/x/xMarkStack.cpp deleted file mode 100644 index 6f7619c9a35..00000000000 --- a/src/hotspot/share/gc/x/xMarkStack.cpp +++ /dev/null @@ -1,226 +0,0 @@ -/* - * Copyright (c) 2016, 2018, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/x/xMarkStack.inline.hpp" -#include "gc/x/xMarkStackAllocator.hpp" -#include "logging/log.hpp" -#include "utilities/debug.hpp" -#include "utilities/powerOfTwo.hpp" - -XMarkStripe::XMarkStripe() : - _published(), - _overflowed() {} - -XMarkStripeSet::XMarkStripeSet() : - _nstripes(0), - _nstripes_mask(0), - _stripes() {} - -void XMarkStripeSet::set_nstripes(size_t nstripes) { - assert(is_power_of_2(nstripes), "Must be a power of two"); - assert(is_power_of_2(XMarkStripesMax), "Must be a power of two"); - assert(nstripes >= 1, "Invalid number of stripes"); - assert(nstripes <= XMarkStripesMax, "Invalid number of stripes"); - - _nstripes = nstripes; - _nstripes_mask = nstripes - 1; - - log_debug(gc, marking)("Using " SIZE_FORMAT " mark stripes", _nstripes); -} - -bool XMarkStripeSet::is_empty() const { - for (size_t i = 0; i < _nstripes; i++) { - if (!_stripes[i].is_empty()) { - return false; - } - } - - return true; -} - -XMarkStripe* XMarkStripeSet::stripe_for_worker(uint nworkers, uint worker_id) { - const size_t spillover_limit = (nworkers / _nstripes) * _nstripes; - size_t index; - - if (worker_id < spillover_limit) { - // Not a spillover worker, use natural stripe - index = worker_id & _nstripes_mask; - } else { - // Distribute spillover workers evenly across stripes - const size_t spillover_nworkers = nworkers - spillover_limit; - const size_t spillover_worker_id = worker_id - spillover_limit; - const double spillover_chunk = (double)_nstripes / (double)spillover_nworkers; - index = spillover_worker_id * spillover_chunk; - } - - assert(index < _nstripes, "Invalid index"); - return &_stripes[index]; -} - -XMarkThreadLocalStacks::XMarkThreadLocalStacks() : - _magazine(nullptr) { - for (size_t i = 0; i < XMarkStripesMax; i++) { - _stacks[i] = nullptr; - } -} - -bool XMarkThreadLocalStacks::is_empty(const XMarkStripeSet* stripes) const { - for (size_t i = 0; i < stripes->nstripes(); i++) { - XMarkStack* const stack = _stacks[i]; - if (stack != nullptr) { - return false; - } - } - - return true; -} - -XMarkStack* XMarkThreadLocalStacks::allocate_stack(XMarkStackAllocator* allocator) { - if (_magazine == nullptr) { - // Allocate new magazine - _magazine = allocator->alloc_magazine(); - if (_magazine == nullptr) { - return nullptr; - } - } - - XMarkStack* stack = nullptr; - - if (!_magazine->pop(stack)) { - // Magazine is empty, convert magazine into a new stack - _magazine->~XMarkStackMagazine(); - stack = new ((void*)_magazine) XMarkStack(); - _magazine = nullptr; - } - - return stack; -} - -void XMarkThreadLocalStacks::free_stack(XMarkStackAllocator* allocator, XMarkStack* stack) { - for (;;) { - if (_magazine == nullptr) { - // Convert stack into a new magazine - stack->~XMarkStack(); - _magazine = new ((void*)stack) XMarkStackMagazine(); - return; - } - - if (_magazine->push(stack)) { - // Success - return; - } - - // Free and uninstall full magazine - allocator->free_magazine(_magazine); - _magazine = nullptr; - } -} - -bool XMarkThreadLocalStacks::push_slow(XMarkStackAllocator* allocator, - XMarkStripe* stripe, - XMarkStack** stackp, - XMarkStackEntry entry, - bool publish) { - XMarkStack* stack = *stackp; - - for (;;) { - if (stack == nullptr) { - // Allocate and install new stack - *stackp = stack = allocate_stack(allocator); - if (stack == nullptr) { - // Out of mark stack memory - return false; - } - } - - if (stack->push(entry)) { - // Success - return true; - } - - // Publish/Overflow and uninstall stack - stripe->publish_stack(stack, publish); - *stackp = stack = nullptr; - } -} - -bool XMarkThreadLocalStacks::pop_slow(XMarkStackAllocator* allocator, - XMarkStripe* stripe, - XMarkStack** stackp, - XMarkStackEntry& entry) { - XMarkStack* stack = *stackp; - - for (;;) { - if (stack == nullptr) { - // Try steal and install stack - *stackp = stack = stripe->steal_stack(); - if (stack == nullptr) { - // Nothing to steal - return false; - } - } - - if (stack->pop(entry)) { - // Success - return true; - } - - // Free and uninstall stack - free_stack(allocator, stack); - *stackp = stack = nullptr; - } -} - -bool XMarkThreadLocalStacks::flush(XMarkStackAllocator* allocator, XMarkStripeSet* stripes) { - bool flushed = false; - - // Flush all stacks - for (size_t i = 0; i < stripes->nstripes(); i++) { - XMarkStripe* const stripe = stripes->stripe_at(i); - XMarkStack** const stackp = &_stacks[i]; - XMarkStack* const stack = *stackp; - if (stack == nullptr) { - continue; - } - - // Free/Publish and uninstall stack - if (stack->is_empty()) { - free_stack(allocator, stack); - } else { - stripe->publish_stack(stack); - flushed = true; - } - *stackp = nullptr; - } - - return flushed; -} - -void XMarkThreadLocalStacks::free(XMarkStackAllocator* allocator) { - // Free and uninstall magazine - if (_magazine != nullptr) { - allocator->free_magazine(_magazine); - _magazine = nullptr; - } -} diff --git a/src/hotspot/share/gc/x/xMarkStack.hpp b/src/hotspot/share/gc/x/xMarkStack.hpp deleted file mode 100644 index e012b89749d..00000000000 --- a/src/hotspot/share/gc/x/xMarkStack.hpp +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Copyright (c) 2016, 2020, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XMARKSTACK_HPP -#define SHARE_GC_X_XMARKSTACK_HPP - -#include "gc/x/xGlobals.hpp" -#include "gc/x/xMarkStackEntry.hpp" -#include "utilities/globalDefinitions.hpp" - -template -class XStack { -private: - size_t _top; - XStack* _next; - T _slots[S]; - - bool is_full() const; - -public: - XStack(); - - bool is_empty() const; - - bool push(T value); - bool pop(T& value); - - XStack* next() const; - XStack** next_addr(); -}; - -template -class XStackList { -private: - T* volatile _head; - - T* encode_versioned_pointer(const T* stack, uint32_t version) const; - void decode_versioned_pointer(const T* vstack, T** stack, uint32_t* version) const; - -public: - XStackList(); - - bool is_empty() const; - - void push(T* stack); - T* pop(); - - void clear(); -}; - -using XMarkStack = XStack; -using XMarkStackList = XStackList; -using XMarkStackMagazine = XStack; -using XMarkStackMagazineList = XStackList; - -static_assert(sizeof(XMarkStack) == XMarkStackSize, "XMarkStack size mismatch"); -static_assert(sizeof(XMarkStackMagazine) <= XMarkStackSize, "XMarkStackMagazine size too large"); - -class XMarkStripe { -private: - XCACHE_ALIGNED XMarkStackList _published; - XCACHE_ALIGNED XMarkStackList _overflowed; - -public: - XMarkStripe(); - - bool is_empty() const; - - void publish_stack(XMarkStack* stack, bool publish = true); - XMarkStack* steal_stack(); -}; - -class XMarkStripeSet { -private: - size_t _nstripes; - size_t _nstripes_mask; - XMarkStripe _stripes[XMarkStripesMax]; - -public: - XMarkStripeSet(); - - size_t nstripes() const; - void set_nstripes(size_t nstripes); - - bool is_empty() const; - - size_t stripe_id(const XMarkStripe* stripe) const; - XMarkStripe* stripe_at(size_t index); - XMarkStripe* stripe_next(XMarkStripe* stripe); - XMarkStripe* stripe_for_worker(uint nworkers, uint worker_id); - XMarkStripe* stripe_for_addr(uintptr_t addr); -}; - -class XMarkStackAllocator; - -class XMarkThreadLocalStacks { -private: - XMarkStackMagazine* _magazine; - XMarkStack* _stacks[XMarkStripesMax]; - - XMarkStack* allocate_stack(XMarkStackAllocator* allocator); - void free_stack(XMarkStackAllocator* allocator, XMarkStack* stack); - - bool push_slow(XMarkStackAllocator* allocator, - XMarkStripe* stripe, - XMarkStack** stackp, - XMarkStackEntry entry, - bool publish); - - bool pop_slow(XMarkStackAllocator* allocator, - XMarkStripe* stripe, - XMarkStack** stackp, - XMarkStackEntry& entry); - -public: - XMarkThreadLocalStacks(); - - bool is_empty(const XMarkStripeSet* stripes) const; - - void install(XMarkStripeSet* stripes, - XMarkStripe* stripe, - XMarkStack* stack); - - XMarkStack* steal(XMarkStripeSet* stripes, - XMarkStripe* stripe); - - bool push(XMarkStackAllocator* allocator, - XMarkStripeSet* stripes, - XMarkStripe* stripe, - XMarkStackEntry entry, - bool publish); - - bool pop(XMarkStackAllocator* allocator, - XMarkStripeSet* stripes, - XMarkStripe* stripe, - XMarkStackEntry& entry); - - bool flush(XMarkStackAllocator* allocator, - XMarkStripeSet* stripes); - - void free(XMarkStackAllocator* allocator); -}; - -#endif // SHARE_GC_X_XMARKSTACK_HPP diff --git a/src/hotspot/share/gc/x/xMarkStack.inline.hpp b/src/hotspot/share/gc/x/xMarkStack.inline.hpp deleted file mode 100644 index e643c1e3224..00000000000 --- a/src/hotspot/share/gc/x/xMarkStack.inline.hpp +++ /dev/null @@ -1,266 +0,0 @@ -/* - * Copyright (c) 2016, 2017, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XMARKSTACK_INLINE_HPP -#define SHARE_GC_X_XMARKSTACK_INLINE_HPP - -#include "gc/x/xMarkStack.hpp" - -#include "utilities/debug.hpp" -#include "runtime/atomic.hpp" - -template -inline XStack::XStack() : - _top(0), - _next(nullptr) {} - -template -inline bool XStack::is_empty() const { - return _top == 0; -} - -template -inline bool XStack::is_full() const { - return _top == S; -} - -template -inline bool XStack::push(T value) { - if (is_full()) { - return false; - } - - _slots[_top++] = value; - return true; -} - -template -inline bool XStack::pop(T& value) { - if (is_empty()) { - return false; - } - - value = _slots[--_top]; - return true; -} - -template -inline XStack* XStack::next() const { - return _next; -} - -template -inline XStack** XStack::next_addr() { - return &_next; -} - -template -inline XStackList::XStackList() : - _head(encode_versioned_pointer(nullptr, 0)) {} - -template -inline T* XStackList::encode_versioned_pointer(const T* stack, uint32_t version) const { - uint64_t addr; - - if (stack == nullptr) { - addr = (uint32_t)-1; - } else { - addr = ((uint64_t)stack - XMarkStackSpaceStart) >> XMarkStackSizeShift; - } - - return (T*)((addr << 32) | (uint64_t)version); -} - -template -inline void XStackList::decode_versioned_pointer(const T* vstack, T** stack, uint32_t* version) const { - const uint64_t addr = (uint64_t)vstack >> 32; - - if (addr == (uint32_t)-1) { - *stack = nullptr; - } else { - *stack = (T*)((addr << XMarkStackSizeShift) + XMarkStackSpaceStart); - } - - *version = (uint32_t)(uint64_t)vstack; -} - -template -inline bool XStackList::is_empty() const { - const T* vstack = _head; - T* stack = nullptr; - uint32_t version = 0; - - decode_versioned_pointer(vstack, &stack, &version); - return stack == nullptr; -} - -template -inline void XStackList::push(T* stack) { - T* vstack = _head; - uint32_t version = 0; - - for (;;) { - decode_versioned_pointer(vstack, stack->next_addr(), &version); - T* const new_vstack = encode_versioned_pointer(stack, version + 1); - T* const prev_vstack = Atomic::cmpxchg(&_head, vstack, new_vstack); - if (prev_vstack == vstack) { - // Success - break; - } - - // Retry - vstack = prev_vstack; - } -} - -template -inline T* XStackList::pop() { - T* vstack = _head; - T* stack = nullptr; - uint32_t version = 0; - - for (;;) { - decode_versioned_pointer(vstack, &stack, &version); - if (stack == nullptr) { - return nullptr; - } - - T* const new_vstack = encode_versioned_pointer(stack->next(), version + 1); - T* const prev_vstack = Atomic::cmpxchg(&_head, vstack, new_vstack); - if (prev_vstack == vstack) { - // Success - return stack; - } - - // Retry - vstack = prev_vstack; - } -} - -template -inline void XStackList::clear() { - _head = encode_versioned_pointer(nullptr, 0); -} - -inline bool XMarkStripe::is_empty() const { - return _published.is_empty() && _overflowed.is_empty(); -} - -inline void XMarkStripe::publish_stack(XMarkStack* stack, bool publish) { - // A stack is published either on the published list or the overflowed - // list. The published list is used by mutators publishing stacks for GC - // workers to work on, while the overflowed list is used by GC workers - // to publish stacks that overflowed. The intention here is to avoid - // contention between mutators and GC workers as much as possible, while - // still allowing GC workers to help out and steal work from each other. - if (publish) { - _published.push(stack); - } else { - _overflowed.push(stack); - } -} - -inline XMarkStack* XMarkStripe::steal_stack() { - // Steal overflowed stacks first, then published stacks - XMarkStack* const stack = _overflowed.pop(); - if (stack != nullptr) { - return stack; - } - - return _published.pop(); -} - -inline size_t XMarkStripeSet::nstripes() const { - return _nstripes; -} - -inline size_t XMarkStripeSet::stripe_id(const XMarkStripe* stripe) const { - const size_t index = ((uintptr_t)stripe - (uintptr_t)_stripes) / sizeof(XMarkStripe); - assert(index < _nstripes, "Invalid index"); - return index; -} - -inline XMarkStripe* XMarkStripeSet::stripe_at(size_t index) { - assert(index < _nstripes, "Invalid index"); - return &_stripes[index]; -} - -inline XMarkStripe* XMarkStripeSet::stripe_next(XMarkStripe* stripe) { - const size_t index = (stripe_id(stripe) + 1) & _nstripes_mask; - assert(index < _nstripes, "Invalid index"); - return &_stripes[index]; -} - -inline XMarkStripe* XMarkStripeSet::stripe_for_addr(uintptr_t addr) { - const size_t index = (addr >> XMarkStripeShift) & _nstripes_mask; - assert(index < _nstripes, "Invalid index"); - return &_stripes[index]; -} - -inline void XMarkThreadLocalStacks::install(XMarkStripeSet* stripes, - XMarkStripe* stripe, - XMarkStack* stack) { - XMarkStack** const stackp = &_stacks[stripes->stripe_id(stripe)]; - assert(*stackp == nullptr, "Should be empty"); - *stackp = stack; -} - -inline XMarkStack* XMarkThreadLocalStacks::steal(XMarkStripeSet* stripes, - XMarkStripe* stripe) { - XMarkStack** const stackp = &_stacks[stripes->stripe_id(stripe)]; - XMarkStack* const stack = *stackp; - if (stack != nullptr) { - *stackp = nullptr; - } - - return stack; -} - -inline bool XMarkThreadLocalStacks::push(XMarkStackAllocator* allocator, - XMarkStripeSet* stripes, - XMarkStripe* stripe, - XMarkStackEntry entry, - bool publish) { - XMarkStack** const stackp = &_stacks[stripes->stripe_id(stripe)]; - XMarkStack* const stack = *stackp; - if (stack != nullptr && stack->push(entry)) { - return true; - } - - return push_slow(allocator, stripe, stackp, entry, publish); -} - -inline bool XMarkThreadLocalStacks::pop(XMarkStackAllocator* allocator, - XMarkStripeSet* stripes, - XMarkStripe* stripe, - XMarkStackEntry& entry) { - XMarkStack** const stackp = &_stacks[stripes->stripe_id(stripe)]; - XMarkStack* const stack = *stackp; - if (stack != nullptr && stack->pop(entry)) { - return true; - } - - return pop_slow(allocator, stripe, stackp, entry); -} - -#endif // SHARE_GC_X_XMARKSTACK_INLINE_HPP diff --git a/src/hotspot/share/gc/x/xMarkStackAllocator.cpp b/src/hotspot/share/gc/x/xMarkStackAllocator.cpp deleted file mode 100644 index b5cc3ad641a..00000000000 --- a/src/hotspot/share/gc/x/xMarkStackAllocator.cpp +++ /dev/null @@ -1,221 +0,0 @@ -/* - * Copyright (c) 2016, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/shared/gcLogPrecious.hpp" -#include "gc/shared/gc_globals.hpp" -#include "gc/x/xLock.inline.hpp" -#include "gc/x/xMarkStack.inline.hpp" -#include "gc/x/xMarkStackAllocator.hpp" -#include "logging/log.hpp" -#include "runtime/atomic.hpp" -#include "runtime/os.hpp" -#include "utilities/debug.hpp" - -uintptr_t XMarkStackSpaceStart; - -XMarkStackSpace::XMarkStackSpace() : - _expand_lock(), - _start(0), - _top(0), - _end(0) { - assert(ZMarkStackSpaceLimit >= XMarkStackSpaceExpandSize, "ZMarkStackSpaceLimit too small"); - - // Reserve address space - const size_t size = ZMarkStackSpaceLimit; - const uintptr_t addr = (uintptr_t)os::reserve_memory(size, !ExecMem, mtGC); - if (addr == 0) { - log_error_pd(gc, marking)("Failed to reserve address space for mark stacks"); - return; - } - - // Successfully initialized - _start = _top = _end = addr; - - // Register mark stack space start - XMarkStackSpaceStart = _start; - - // Prime space - _end += expand_space(); -} - -bool XMarkStackSpace::is_initialized() const { - return _start != 0; -} - -size_t XMarkStackSpace::size() const { - return _end - _start; -} - -size_t XMarkStackSpace::used() const { - return _top - _start; -} - -size_t XMarkStackSpace::expand_space() { - const size_t expand_size = XMarkStackSpaceExpandSize; - const size_t old_size = size(); - const size_t new_size = old_size + expand_size; - - if (new_size > ZMarkStackSpaceLimit) { - // Expansion limit reached. This is a fatal error since we - // currently can't recover from running out of mark stack space. - fatal("Mark stack space exhausted. Use -XX:ZMarkStackSpaceLimit= to increase the " - "maximum number of bytes allocated for mark stacks. Current limit is " SIZE_FORMAT "M.", - ZMarkStackSpaceLimit / M); - } - - log_debug(gc, marking)("Expanding mark stack space: " SIZE_FORMAT "M->" SIZE_FORMAT "M", - old_size / M, new_size / M); - - // Expand - os::commit_memory_or_exit((char*)_end, expand_size, false /* executable */, "Mark stack space"); - - return expand_size; -} - -size_t XMarkStackSpace::shrink_space() { - // Shrink to what is currently used - const size_t old_size = size(); - const size_t new_size = align_up(used(), XMarkStackSpaceExpandSize); - const size_t shrink_size = old_size - new_size; - - if (shrink_size > 0) { - // Shrink - log_debug(gc, marking)("Shrinking mark stack space: " SIZE_FORMAT "M->" SIZE_FORMAT "M", - old_size / M, new_size / M); - - const uintptr_t shrink_start = _end - shrink_size; - os::uncommit_memory((char*)shrink_start, shrink_size, false /* executable */); - } - - return shrink_size; -} - -uintptr_t XMarkStackSpace::alloc_space(size_t size) { - uintptr_t top = Atomic::load(&_top); - - for (;;) { - const uintptr_t end = Atomic::load(&_end); - const uintptr_t new_top = top + size; - if (new_top > end) { - // Not enough space left - return 0; - } - - const uintptr_t prev_top = Atomic::cmpxchg(&_top, top, new_top); - if (prev_top == top) { - // Success - return top; - } - - // Retry - top = prev_top; - } -} - -uintptr_t XMarkStackSpace::expand_and_alloc_space(size_t size) { - XLocker locker(&_expand_lock); - - // Retry allocation before expanding - uintptr_t addr = alloc_space(size); - if (addr != 0) { - return addr; - } - - // Expand - const size_t expand_size = expand_space(); - - // Increment top before end to make sure another - // thread can't steal out newly expanded space. - addr = Atomic::fetch_then_add(&_top, size); - Atomic::add(&_end, expand_size); - - return addr; -} - -uintptr_t XMarkStackSpace::alloc(size_t size) { - assert(size <= XMarkStackSpaceExpandSize, "Invalid size"); - - const uintptr_t addr = alloc_space(size); - if (addr != 0) { - return addr; - } - - return expand_and_alloc_space(size); -} - -void XMarkStackSpace::free() { - _end -= shrink_space(); - _top = _start; -} - -XMarkStackAllocator::XMarkStackAllocator() : - _freelist(), - _space() {} - -bool XMarkStackAllocator::is_initialized() const { - return _space.is_initialized(); -} - -size_t XMarkStackAllocator::size() const { - return _space.size(); -} - -XMarkStackMagazine* XMarkStackAllocator::create_magazine_from_space(uintptr_t addr, size_t size) { - assert(is_aligned(size, XMarkStackSize), "Invalid size"); - - // Use first stack as magazine - XMarkStackMagazine* const magazine = new ((void*)addr) XMarkStackMagazine(); - for (size_t i = XMarkStackSize; i < size; i += XMarkStackSize) { - XMarkStack* const stack = new ((void*)(addr + i)) XMarkStack(); - const bool success = magazine->push(stack); - assert(success, "Magazine should never get full"); - } - - return magazine; -} - -XMarkStackMagazine* XMarkStackAllocator::alloc_magazine() { - // Try allocating from the free list first - XMarkStackMagazine* const magazine = _freelist.pop(); - if (magazine != nullptr) { - return magazine; - } - - // Allocate new magazine - const uintptr_t addr = _space.alloc(XMarkStackMagazineSize); - if (addr == 0) { - return nullptr; - } - - return create_magazine_from_space(addr, XMarkStackMagazineSize); -} - -void XMarkStackAllocator::free_magazine(XMarkStackMagazine* magazine) { - _freelist.push(magazine); -} - -void XMarkStackAllocator::free() { - _freelist.clear(); - _space.free(); -} diff --git a/src/hotspot/share/gc/x/xMarkStackAllocator.hpp b/src/hotspot/share/gc/x/xMarkStackAllocator.hpp deleted file mode 100644 index 5e81ae284cf..00000000000 --- a/src/hotspot/share/gc/x/xMarkStackAllocator.hpp +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2016, 2021, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XMARKSTACKALLOCATOR_HPP -#define SHARE_GC_X_XMARKSTACKALLOCATOR_HPP - -#include "gc/x/xGlobals.hpp" -#include "gc/x/xLock.hpp" -#include "utilities/globalDefinitions.hpp" - -class XMarkStackSpace { -private: - XLock _expand_lock; - uintptr_t _start; - volatile uintptr_t _top; - volatile uintptr_t _end; - - size_t used() const; - - size_t expand_space(); - size_t shrink_space(); - - uintptr_t alloc_space(size_t size); - uintptr_t expand_and_alloc_space(size_t size); - -public: - XMarkStackSpace(); - - bool is_initialized() const; - - size_t size() const; - - uintptr_t alloc(size_t size); - void free(); -}; - -class XMarkStackAllocator { -private: - XCACHE_ALIGNED XMarkStackMagazineList _freelist; - XCACHE_ALIGNED XMarkStackSpace _space; - - XMarkStackMagazine* create_magazine_from_space(uintptr_t addr, size_t size); - -public: - XMarkStackAllocator(); - - bool is_initialized() const; - - size_t size() const; - - XMarkStackMagazine* alloc_magazine(); - void free_magazine(XMarkStackMagazine* magazine); - - void free(); -}; - -#endif // SHARE_GC_X_XMARKSTACKALLOCATOR_HPP diff --git a/src/hotspot/share/gc/x/xMarkStackEntry.hpp b/src/hotspot/share/gc/x/xMarkStackEntry.hpp deleted file mode 100644 index 61df1798df2..00000000000 --- a/src/hotspot/share/gc/x/xMarkStackEntry.hpp +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright (c) 2017, 2021, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XMARKSTACKENTRY_HPP -#define SHARE_GC_X_XMARKSTACKENTRY_HPP - -#include "gc/x/xBitField.hpp" -#include "memory/allocation.hpp" - -// -// Mark stack entry layout -// ----------------------- -// -// Object entry -// ------------ -// -// 6 -// 3 5 4 3 2 1 0 -// +------------------------------------------------------------------+-+-+-+-+-+ -// |11111111 11111111 11111111 11111111 11111111 11111111 11111111 111|1|1|1|1|1| -// +------------------------------------------------------------------+-+-+-+-+-+ -// | | | | | | -// | 4-4 Mark Flag (1-bit) * | | | | -// | | | | | -// | 3-3 Increment Live Flag (1-bit) * | | | -// | | | | -// | 2-2 Follow Flag (1-bit) * | | -// | | | -// | 1-1 Partial Array Flag (1-bit) * | -// | | -// | 0-0 Final Flag (1-bit) * -// | -// * 63-5 Object Address (59-bits) -// -// -// Partial array entry -// ------------------- -// -// 6 3 3 -// 3 2 1 2 1 0 -// +------------------------------------+---------------------------------+-+-+ -// |11111111 11111111 11111111 11111111 |11111111 11111111 11111111 111111|1|1| -// +------------------------------------+---------------------------------+-+-+ -// | | | | -// | | 1-1 Partial Array Flag (1-bit) * | -// | | | -// | | 0-0 Final Flag (1-bit) * -// | | -// | * 31-2 Partial Array Length (30-bits) -// | -// * 63-32 Partial Array Address Offset (32-bits) -// - -class XMarkStackEntry { -private: - typedef XBitField field_finalizable; - typedef XBitField field_partial_array; - typedef XBitField field_follow; - typedef XBitField field_inc_live; - typedef XBitField field_mark; - typedef XBitField field_object_address; - typedef XBitField field_partial_array_length; - typedef XBitField field_partial_array_offset; - - uint64_t _entry; - -public: - XMarkStackEntry() { - // This constructor is intentionally left empty and does not initialize - // _entry to allow it to be optimized out when instantiating XMarkStack, - // which has a long array of XMarkStackEntry elements, but doesn't care - // what _entry is initialized to. - } - - XMarkStackEntry(uintptr_t object_address, bool mark, bool inc_live, bool follow, bool finalizable) : - _entry(field_object_address::encode(object_address) | - field_mark::encode(mark) | - field_inc_live::encode(inc_live) | - field_follow::encode(follow) | - field_partial_array::encode(false) | - field_finalizable::encode(finalizable)) {} - - XMarkStackEntry(size_t partial_array_offset, size_t partial_array_length, bool finalizable) : - _entry(field_partial_array_offset::encode(partial_array_offset) | - field_partial_array_length::encode(partial_array_length) | - field_partial_array::encode(true) | - field_finalizable::encode(finalizable)) {} - - bool finalizable() const { - return field_finalizable::decode(_entry); - } - - bool partial_array() const { - return field_partial_array::decode(_entry); - } - - size_t partial_array_offset() const { - return field_partial_array_offset::decode(_entry); - } - - size_t partial_array_length() const { - return field_partial_array_length::decode(_entry); - } - - bool follow() const { - return field_follow::decode(_entry); - } - - bool inc_live() const { - return field_inc_live::decode(_entry); - } - - bool mark() const { - return field_mark::decode(_entry); - } - - uintptr_t object_address() const { - return field_object_address::decode(_entry); - } -}; - -#endif // SHARE_GC_X_XMARKSTACKENTRY_HPP diff --git a/src/hotspot/share/gc/x/xMarkTerminate.hpp b/src/hotspot/share/gc/x/xMarkTerminate.hpp deleted file mode 100644 index 28f18f6e1cb..00000000000 --- a/src/hotspot/share/gc/x/xMarkTerminate.hpp +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2017, 2018, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XMARKTERMINATE_HPP -#define SHARE_GC_X_XMARKTERMINATE_HPP - -#include "gc/x/xGlobals.hpp" -#include "memory/allocation.hpp" -#include "utilities/globalDefinitions.hpp" - -class XMarkTerminate { -private: - uint _nworkers; - XCACHE_ALIGNED volatile uint _nworking_stage0; - volatile uint _nworking_stage1; - - bool enter_stage(volatile uint* nworking_stage); - void exit_stage(volatile uint* nworking_stage); - bool try_exit_stage(volatile uint* nworking_stage); - -public: - XMarkTerminate(); - - void reset(uint nworkers); - - bool enter_stage0(); - void exit_stage0(); - bool try_exit_stage0(); - - bool enter_stage1(); - bool try_exit_stage1(); -}; - -#endif // SHARE_GC_X_XMARKTERMINATE_HPP diff --git a/src/hotspot/share/gc/x/xMarkTerminate.inline.hpp b/src/hotspot/share/gc/x/xMarkTerminate.inline.hpp deleted file mode 100644 index e4b9256ba6b..00000000000 --- a/src/hotspot/share/gc/x/xMarkTerminate.inline.hpp +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2017, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XMARKTERMINATE_INLINE_HPP -#define SHARE_GC_X_XMARKTERMINATE_INLINE_HPP - -#include "gc/x/xMarkTerminate.hpp" - -#include "runtime/atomic.hpp" - -inline XMarkTerminate::XMarkTerminate() : - _nworkers(0), - _nworking_stage0(0), - _nworking_stage1(0) {} - -inline bool XMarkTerminate::enter_stage(volatile uint* nworking_stage) { - return Atomic::sub(nworking_stage, 1u) == 0; -} - -inline void XMarkTerminate::exit_stage(volatile uint* nworking_stage) { - Atomic::add(nworking_stage, 1u); -} - -inline bool XMarkTerminate::try_exit_stage(volatile uint* nworking_stage) { - uint nworking = Atomic::load(nworking_stage); - - for (;;) { - if (nworking == 0) { - return false; - } - - const uint new_nworking = nworking + 1; - const uint prev_nworking = Atomic::cmpxchg(nworking_stage, nworking, new_nworking); - if (prev_nworking == nworking) { - // Success - return true; - } - - // Retry - nworking = prev_nworking; - } -} - -inline void XMarkTerminate::reset(uint nworkers) { - _nworkers = _nworking_stage0 = _nworking_stage1 = nworkers; -} - -inline bool XMarkTerminate::enter_stage0() { - return enter_stage(&_nworking_stage0); -} - -inline void XMarkTerminate::exit_stage0() { - exit_stage(&_nworking_stage0); -} - -inline bool XMarkTerminate::try_exit_stage0() { - return try_exit_stage(&_nworking_stage0); -} - -inline bool XMarkTerminate::enter_stage1() { - return enter_stage(&_nworking_stage1); -} - -inline bool XMarkTerminate::try_exit_stage1() { - return try_exit_stage(&_nworking_stage1); -} - -#endif // SHARE_GC_X_XMARKTERMINATE_INLINE_HPP diff --git a/src/hotspot/share/gc/x/xMemory.cpp b/src/hotspot/share/gc/x/xMemory.cpp deleted file mode 100644 index e394f580ab9..00000000000 --- a/src/hotspot/share/gc/x/xMemory.cpp +++ /dev/null @@ -1,220 +0,0 @@ -/* - * Copyright (c) 2015, 2020, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/x/xList.inline.hpp" -#include "gc/x/xLock.inline.hpp" -#include "gc/x/xMemory.inline.hpp" - -XMemory* XMemoryManager::create(uintptr_t start, size_t size) { - XMemory* const area = new XMemory(start, size); - if (_callbacks._create != nullptr) { - _callbacks._create(area); - } - return area; -} - -void XMemoryManager::destroy(XMemory* area) { - if (_callbacks._destroy != nullptr) { - _callbacks._destroy(area); - } - delete area; -} - -void XMemoryManager::shrink_from_front(XMemory* area, size_t size) { - if (_callbacks._shrink_from_front != nullptr) { - _callbacks._shrink_from_front(area, size); - } - area->shrink_from_front(size); -} - -void XMemoryManager::shrink_from_back(XMemory* area, size_t size) { - if (_callbacks._shrink_from_back != nullptr) { - _callbacks._shrink_from_back(area, size); - } - area->shrink_from_back(size); -} - -void XMemoryManager::grow_from_front(XMemory* area, size_t size) { - if (_callbacks._grow_from_front != nullptr) { - _callbacks._grow_from_front(area, size); - } - area->grow_from_front(size); -} - -void XMemoryManager::grow_from_back(XMemory* area, size_t size) { - if (_callbacks._grow_from_back != nullptr) { - _callbacks._grow_from_back(area, size); - } - area->grow_from_back(size); -} - -XMemoryManager::Callbacks::Callbacks() : - _create(nullptr), - _destroy(nullptr), - _shrink_from_front(nullptr), - _shrink_from_back(nullptr), - _grow_from_front(nullptr), - _grow_from_back(nullptr) {} - -XMemoryManager::XMemoryManager() : - _freelist(), - _callbacks() {} - -void XMemoryManager::register_callbacks(const Callbacks& callbacks) { - _callbacks = callbacks; -} - -uintptr_t XMemoryManager::peek_low_address() const { - XLocker locker(&_lock); - - const XMemory* const area = _freelist.first(); - if (area != nullptr) { - return area->start(); - } - - // Out of memory - return UINTPTR_MAX; -} - -uintptr_t XMemoryManager::alloc_low_address(size_t size) { - XLocker locker(&_lock); - - XListIterator iter(&_freelist); - for (XMemory* area; iter.next(&area);) { - if (area->size() >= size) { - if (area->size() == size) { - // Exact match, remove area - const uintptr_t start = area->start(); - _freelist.remove(area); - destroy(area); - return start; - } else { - // Larger than requested, shrink area - const uintptr_t start = area->start(); - shrink_from_front(area, size); - return start; - } - } - } - - // Out of memory - return UINTPTR_MAX; -} - -uintptr_t XMemoryManager::alloc_low_address_at_most(size_t size, size_t* allocated) { - XLocker locker(&_lock); - - XMemory* area = _freelist.first(); - if (area != nullptr) { - if (area->size() <= size) { - // Smaller than or equal to requested, remove area - const uintptr_t start = area->start(); - *allocated = area->size(); - _freelist.remove(area); - destroy(area); - return start; - } else { - // Larger than requested, shrink area - const uintptr_t start = area->start(); - shrink_from_front(area, size); - *allocated = size; - return start; - } - } - - // Out of memory - *allocated = 0; - return UINTPTR_MAX; -} - -uintptr_t XMemoryManager::alloc_high_address(size_t size) { - XLocker locker(&_lock); - - XListReverseIterator iter(&_freelist); - for (XMemory* area; iter.next(&area);) { - if (area->size() >= size) { - if (area->size() == size) { - // Exact match, remove area - const uintptr_t start = area->start(); - _freelist.remove(area); - destroy(area); - return start; - } else { - // Larger than requested, shrink area - shrink_from_back(area, size); - return area->end(); - } - } - } - - // Out of memory - return UINTPTR_MAX; -} - -void XMemoryManager::free(uintptr_t start, size_t size) { - assert(start != UINTPTR_MAX, "Invalid address"); - const uintptr_t end = start + size; - - XLocker locker(&_lock); - - XListIterator iter(&_freelist); - for (XMemory* area; iter.next(&area);) { - if (start < area->start()) { - XMemory* const prev = _freelist.prev(area); - if (prev != nullptr && start == prev->end()) { - if (end == area->start()) { - // Merge with prev and current area - grow_from_back(prev, size + area->size()); - _freelist.remove(area); - delete area; - } else { - // Merge with prev area - grow_from_back(prev, size); - } - } else if (end == area->start()) { - // Merge with current area - grow_from_front(area, size); - } else { - // Insert new area before current area - assert(end < area->start(), "Areas must not overlap"); - XMemory* const new_area = create(start, size); - _freelist.insert_before(area, new_area); - } - - // Done - return; - } - } - - // Insert last - XMemory* const last = _freelist.last(); - if (last != nullptr && start == last->end()) { - // Merge with last area - grow_from_back(last, size); - } else { - // Insert new area last - XMemory* const new_area = create(start, size); - _freelist.insert_last(new_area); - } -} diff --git a/src/hotspot/share/gc/x/xMemory.hpp b/src/hotspot/share/gc/x/xMemory.hpp deleted file mode 100644 index 2c3739cb44a..00000000000 --- a/src/hotspot/share/gc/x/xMemory.hpp +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2015, 2020, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XMEMORY_HPP -#define SHARE_GC_X_XMEMORY_HPP - -#include "gc/x/xList.hpp" -#include "gc/x/xLock.hpp" -#include "memory/allocation.hpp" - -class XMemory : public CHeapObj { - friend class XList; - -private: - uintptr_t _start; - uintptr_t _end; - XListNode _node; - -public: - XMemory(uintptr_t start, size_t size); - - uintptr_t start() const; - uintptr_t end() const; - size_t size() const; - - void shrink_from_front(size_t size); - void shrink_from_back(size_t size); - void grow_from_front(size_t size); - void grow_from_back(size_t size); -}; - -class XMemoryManager { -public: - typedef void (*CreateDestroyCallback)(const XMemory* area); - typedef void (*ResizeCallback)(const XMemory* area, size_t size); - - struct Callbacks { - CreateDestroyCallback _create; - CreateDestroyCallback _destroy; - ResizeCallback _shrink_from_front; - ResizeCallback _shrink_from_back; - ResizeCallback _grow_from_front; - ResizeCallback _grow_from_back; - - Callbacks(); - }; - -private: - mutable XLock _lock; - XList _freelist; - Callbacks _callbacks; - - XMemory* create(uintptr_t start, size_t size); - void destroy(XMemory* area); - void shrink_from_front(XMemory* area, size_t size); - void shrink_from_back(XMemory* area, size_t size); - void grow_from_front(XMemory* area, size_t size); - void grow_from_back(XMemory* area, size_t size); - -public: - XMemoryManager(); - - void register_callbacks(const Callbacks& callbacks); - - uintptr_t peek_low_address() const; - uintptr_t alloc_low_address(size_t size); - uintptr_t alloc_low_address_at_most(size_t size, size_t* allocated); - uintptr_t alloc_high_address(size_t size); - - void free(uintptr_t start, size_t size); -}; - -#endif // SHARE_GC_X_XMEMORY_HPP diff --git a/src/hotspot/share/gc/x/xMemory.inline.hpp b/src/hotspot/share/gc/x/xMemory.inline.hpp deleted file mode 100644 index 332cdae9160..00000000000 --- a/src/hotspot/share/gc/x/xMemory.inline.hpp +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2015, 2017, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XMEMORY_INLINE_HPP -#define SHARE_GC_X_XMEMORY_INLINE_HPP - -#include "gc/x/xMemory.hpp" - -#include "gc/x/xList.inline.hpp" -#include "utilities/debug.hpp" - -inline XMemory::XMemory(uintptr_t start, size_t size) : - _start(start), - _end(start + size) {} - -inline uintptr_t XMemory::start() const { - return _start; -} - -inline uintptr_t XMemory::end() const { - return _end; -} - -inline size_t XMemory::size() const { - return end() - start(); -} - -inline void XMemory::shrink_from_front(size_t size) { - assert(this->size() > size, "Too small"); - _start += size; -} - -inline void XMemory::shrink_from_back(size_t size) { - assert(this->size() > size, "Too small"); - _end -= size; -} - -inline void XMemory::grow_from_front(size_t size) { - assert(start() >= size, "Too big"); - _start -= size; -} - -inline void XMemory::grow_from_back(size_t size) { - _end += size; -} - -#endif // SHARE_GC_X_XMEMORY_INLINE_HPP diff --git a/src/hotspot/share/gc/x/xMessagePort.hpp b/src/hotspot/share/gc/x/xMessagePort.hpp deleted file mode 100644 index 20565253796..00000000000 --- a/src/hotspot/share/gc/x/xMessagePort.hpp +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (c) 2015, 2021, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XMESSAGEPORT_HPP -#define SHARE_GC_X_XMESSAGEPORT_HPP - -#include "gc/x/xFuture.hpp" -#include "gc/x/xList.hpp" -#include "runtime/mutex.hpp" - -template class XMessageRequest; - -template -class XMessagePort { -private: - typedef XMessageRequest Request; - - mutable Monitor _monitor; - bool _has_message; - T _message; - uint64_t _seqnum; - XList _queue; - -public: - XMessagePort(); - - bool is_busy() const; - - void send_sync(const T& message); - void send_async(const T& message); - - T receive(); - void ack(); -}; - -class XRendezvousPort { -private: - XMessagePort _port; - -public: - void signal(); - void wait(); - void ack(); -}; - -#endif // SHARE_GC_X_XMESSAGEPORT_HPP diff --git a/src/hotspot/share/gc/x/xMessagePort.inline.hpp b/src/hotspot/share/gc/x/xMessagePort.inline.hpp deleted file mode 100644 index 8007a80eacd..00000000000 --- a/src/hotspot/share/gc/x/xMessagePort.inline.hpp +++ /dev/null @@ -1,181 +0,0 @@ -/* - * Copyright (c) 2015, 2021, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XMESSAGEPORT_INLINE_HPP -#define SHARE_GC_X_XMESSAGEPORT_INLINE_HPP - -#include "gc/x/xMessagePort.hpp" - -#include "gc/x/xFuture.inline.hpp" -#include "gc/x/xList.inline.hpp" -#include "runtime/mutexLocker.hpp" - -template -class XMessageRequest : public StackObj { - friend class XList; - -private: - T _message; - uint64_t _seqnum; - XFuture _result; - XListNode _node; - -public: - void initialize(T message, uint64_t seqnum) { - _message = message; - _seqnum = seqnum; - } - - T message() const { - return _message; - } - - uint64_t seqnum() const { - return _seqnum; - } - - void wait() { - const T message = _result.get(); - assert(message == _message, "Message mismatch"); - } - - void satisfy(T message) { - _result.set(message); - } -}; - -template -inline XMessagePort::XMessagePort() : - _monitor(Monitor::nosafepoint, "XMessagePort_lock"), - _has_message(false), - _seqnum(0), - _queue() {} - -template -inline bool XMessagePort::is_busy() const { - MonitorLocker ml(&_monitor, Monitor::_no_safepoint_check_flag); - return _has_message; -} - -template -inline void XMessagePort::send_sync(const T& message) { - Request request; - - { - // Enqueue message - MonitorLocker ml(&_monitor, Monitor::_no_safepoint_check_flag); - request.initialize(message, _seqnum); - _queue.insert_last(&request); - ml.notify(); - } - - // Wait for completion - request.wait(); - - { - // Guard deletion of underlying semaphore. This is a workaround for a - // bug in sem_post() in glibc < 2.21, where it's not safe to destroy - // the semaphore immediately after returning from sem_wait(). The - // reason is that sem_post() can touch the semaphore after a waiting - // thread have returned from sem_wait(). To avoid this race we are - // forcing the waiting thread to acquire/release the lock held by the - // posting thread. https://sourceware.org/bugzilla/show_bug.cgi?id=12674 - MonitorLocker ml(&_monitor, Monitor::_no_safepoint_check_flag); - } -} - -template -inline void XMessagePort::send_async(const T& message) { - MonitorLocker ml(&_monitor, Monitor::_no_safepoint_check_flag); - if (!_has_message) { - // Post message - _message = message; - _has_message = true; - ml.notify(); - } -} - -template -inline T XMessagePort::receive() { - MonitorLocker ml(&_monitor, Monitor::_no_safepoint_check_flag); - - // Wait for message - while (!_has_message && _queue.is_empty()) { - ml.wait(); - } - - // Increment request sequence number - _seqnum++; - - if (!_has_message) { - // Message available in the queue - _message = _queue.first()->message(); - _has_message = true; - } - - return _message; -} - -template -inline void XMessagePort::ack() { - MonitorLocker ml(&_monitor, Monitor::_no_safepoint_check_flag); - - if (!_has_message) { - // Nothing to ack - return; - } - - // Satisfy requests (and duplicates) in queue - XListIterator iter(&_queue); - for (Request* request; iter.next(&request);) { - if (request->message() == _message && request->seqnum() < _seqnum) { - // Dequeue and satisfy request. Note that the dequeue operation must - // happen first, since the request will immediately be deallocated - // once it has been satisfied. - _queue.remove(request); - request->satisfy(_message); - } - } - - if (_queue.is_empty()) { - // Queue is empty - _has_message = false; - } else { - // Post first message in queue - _message = _queue.first()->message(); - } -} - -inline void XRendezvousPort::signal() { - _port.send_sync(true /* ignored */); -} - -inline void XRendezvousPort::wait() { - _port.receive(); -} - -inline void XRendezvousPort::ack() { - _port.ack(); -} - -#endif // SHARE_GC_X_XMESSAGEPORT_INLINE_HPP diff --git a/src/hotspot/share/gc/x/xMetronome.cpp b/src/hotspot/share/gc/x/xMetronome.cpp deleted file mode 100644 index 7f0b649deb4..00000000000 --- a/src/hotspot/share/gc/x/xMetronome.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2015, 2021, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/x/xMetronome.hpp" -#include "runtime/mutexLocker.hpp" -#include "runtime/timer.hpp" -#include "utilities/ticks.hpp" - -XMetronome::XMetronome(uint64_t hz) : - _monitor(Monitor::nosafepoint, "XMetronome_lock"), - _interval_ms(MILLIUNITS / hz), - _start_ms(0), - _nticks(0), - _stopped(false) {} - -bool XMetronome::wait_for_tick() { - if (_nticks++ == 0) { - // First tick, set start time - const Ticks now = Ticks::now(); - _start_ms = TimeHelper::counter_to_millis(now.value()); - } - - MonitorLocker ml(&_monitor, Monitor::_no_safepoint_check_flag); - - while (!_stopped) { - // We might wake up spuriously from wait, so always recalculate - // the timeout after a wakeup to see if we need to wait again. - const Ticks now = Ticks::now(); - const uint64_t now_ms = TimeHelper::counter_to_millis(now.value()); - const uint64_t next_ms = _start_ms + (_interval_ms * _nticks); - const int64_t timeout_ms = next_ms - now_ms; - - if (timeout_ms > 0) { - // Wait - ml.wait(timeout_ms); - } else { - // Tick - if (timeout_ms < 0) { - const uint64_t overslept = -timeout_ms; - if (overslept > _interval_ms) { - // Missed one or more ticks. Bump _nticks accordingly to - // avoid firing a string of immediate ticks to make up - // for the ones we missed. - _nticks += overslept / _interval_ms; - } - } - - return true; - } - } - - // Stopped - return false; -} - -void XMetronome::stop() { - MonitorLocker ml(&_monitor, Monitor::_no_safepoint_check_flag); - _stopped = true; - ml.notify(); -} diff --git a/src/hotspot/share/gc/x/xMetronome.hpp b/src/hotspot/share/gc/x/xMetronome.hpp deleted file mode 100644 index 8a0f27061c3..00000000000 --- a/src/hotspot/share/gc/x/xMetronome.hpp +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2015, 2017, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XMETRONOME_HPP -#define SHARE_GC_X_XMETRONOME_HPP - -#include "memory/allocation.hpp" -#include "runtime/mutex.hpp" - -class XMetronome : public StackObj { -private: - Monitor _monitor; - const uint64_t _interval_ms; - uint64_t _start_ms; - uint64_t _nticks; - bool _stopped; - -public: - XMetronome(uint64_t hz); - - bool wait_for_tick(); - void stop(); -}; - -#endif // SHARE_GC_X_XMETRONOME_HPP diff --git a/src/hotspot/share/gc/x/xNMethod.cpp b/src/hotspot/share/gc/x/xNMethod.cpp deleted file mode 100644 index 24b02b83280..00000000000 --- a/src/hotspot/share/gc/x/xNMethod.cpp +++ /dev/null @@ -1,349 +0,0 @@ -/* - * Copyright (c) 2017, 2022, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "code/relocInfo.hpp" -#include "code/nmethod.hpp" -#include "gc/shared/barrierSet.hpp" -#include "gc/shared/barrierSetNMethod.hpp" -#include "gc/shared/classUnloadingContext.hpp" -#include "gc/shared/suspendibleThreadSet.hpp" -#include "gc/x/xBarrier.inline.hpp" -#include "gc/x/xGlobals.hpp" -#include "gc/x/xLock.inline.hpp" -#include "gc/x/xNMethod.hpp" -#include "gc/x/xNMethodData.hpp" -#include "gc/x/xNMethodTable.hpp" -#include "gc/x/xTask.hpp" -#include "gc/x/xWorkers.hpp" -#include "logging/log.hpp" -#include "memory/allocation.inline.hpp" -#include "memory/iterator.hpp" -#include "memory/resourceArea.hpp" -#include "memory/universe.hpp" -#include "oops/oop.inline.hpp" -#include "runtime/atomic.hpp" -#include "runtime/continuation.hpp" -#include "utilities/debug.hpp" - -static XNMethodData* gc_data(const nmethod* nm) { - return nm->gc_data(); -} - -static void set_gc_data(nmethod* nm, XNMethodData* data) { - return nm->set_gc_data(data); -} - -void XNMethod::attach_gc_data(nmethod* nm) { - GrowableArray immediate_oops; - bool non_immediate_oops = false; - - // Find all oop relocations - RelocIterator iter(nm); - while (iter.next()) { - if (iter.type() != relocInfo::oop_type) { - // Not an oop - continue; - } - - oop_Relocation* r = iter.oop_reloc(); - - if (!r->oop_is_immediate()) { - // Non-immediate oop found - non_immediate_oops = true; - continue; - } - - if (r->oop_value() != nullptr) { - // Non-null immediate oop found. Null oops can safely be - // ignored since the method will be re-registered if they - // are later patched to be non-null. - immediate_oops.push(r->oop_addr()); - } - } - - // Attach GC data to nmethod - XNMethodData* data = gc_data(nm); - if (data == nullptr) { - data = new XNMethodData(); - set_gc_data(nm, data); - } - - // Attach oops in GC data - XNMethodDataOops* const new_oops = XNMethodDataOops::create(immediate_oops, non_immediate_oops); - XNMethodDataOops* const old_oops = data->swap_oops(new_oops); - XNMethodDataOops::destroy(old_oops); -} - -XReentrantLock* XNMethod::lock_for_nmethod(nmethod* nm) { - return gc_data(nm)->lock(); -} - -XReentrantLock* XNMethod::ic_lock_for_nmethod(nmethod* nm) { - return gc_data(nm)->ic_lock(); -} - -void XNMethod::log_register(const nmethod* nm) { - LogTarget(Trace, gc, nmethod) log; - if (!log.is_enabled()) { - return; - } - - const XNMethodDataOops* const oops = gc_data(nm)->oops(); - - log.print("Register NMethod: %s.%s (" PTR_FORMAT "), " - "Compiler: %s, Oops: %d, ImmediateOops: " SIZE_FORMAT ", NonImmediateOops: %s", - nm->method()->method_holder()->external_name(), - nm->method()->name()->as_C_string(), - p2i(nm), - nm->compiler_name(), - nm->oops_count() - 1, - oops->immediates_count(), - oops->has_non_immediates() ? "Yes" : "No"); - - LogTarget(Trace, gc, nmethod, oops) log_oops; - if (!log_oops.is_enabled()) { - return; - } - - // Print nmethod oops table - { - oop* const begin = nm->oops_begin(); - oop* const end = nm->oops_end(); - for (oop* p = begin; p < end; p++) { - const oop o = Atomic::load(p); // C1 PatchingStub may replace it concurrently. - const char* external_name = (o == nullptr) ? "N/A" : o->klass()->external_name(); - log_oops.print(" Oop[" SIZE_FORMAT "] " PTR_FORMAT " (%s)", - (p - begin), p2i(o), external_name); - } - } - - // Print nmethod immediate oops - { - oop** const begin = oops->immediates_begin(); - oop** const end = oops->immediates_end(); - for (oop** p = begin; p < end; p++) { - log_oops.print(" ImmediateOop[" SIZE_FORMAT "] " PTR_FORMAT " @ " PTR_FORMAT " (%s)", - (p - begin), p2i(**p), p2i(*p), (**p)->klass()->external_name()); - } - } -} - -void XNMethod::log_unregister(const nmethod* nm) { - LogTarget(Debug, gc, nmethod) log; - if (!log.is_enabled()) { - return; - } - - log.print("Unregister NMethod: %s.%s (" PTR_FORMAT ")", - nm->method()->method_holder()->external_name(), - nm->method()->name()->as_C_string(), - p2i(nm)); -} - -void XNMethod::register_nmethod(nmethod* nm) { - ResourceMark rm; - - // Create and attach gc data - attach_gc_data(nm); - - log_register(nm); - - XNMethodTable::register_nmethod(nm); - - // Disarm nmethod entry barrier - disarm(nm); -} - -void XNMethod::unregister_nmethod(nmethod* nm) { - ResourceMark rm; - - log_unregister(nm); - - XNMethodTable::unregister_nmethod(nm); - - // Destroy GC data - delete gc_data(nm); -} - -bool XNMethod::supports_entry_barrier(nmethod* nm) { - BarrierSetNMethod* const bs = BarrierSet::barrier_set()->barrier_set_nmethod(); - return bs->supports_entry_barrier(nm); -} - -bool XNMethod::is_armed(nmethod* nm) { - BarrierSetNMethod* const bs = BarrierSet::barrier_set()->barrier_set_nmethod(); - return bs->is_armed(nm); -} - -void XNMethod::disarm(nmethod* nm) { - BarrierSetNMethod* const bs = BarrierSet::barrier_set()->barrier_set_nmethod(); - bs->disarm(nm); -} - -void XNMethod::set_guard_value(nmethod* nm, int value) { - BarrierSetNMethod* const bs = BarrierSet::barrier_set()->barrier_set_nmethod(); - bs->set_guard_value(nm, value); -} - -void XNMethod::nmethod_oops_do(nmethod* nm, OopClosure* cl) { - XLocker locker(XNMethod::lock_for_nmethod(nm)); - XNMethod::nmethod_oops_do_inner(nm, cl); -} - -void XNMethod::nmethod_oops_do_inner(nmethod* nm, OopClosure* cl) { - // Process oops table - { - oop* const begin = nm->oops_begin(); - oop* const end = nm->oops_end(); - for (oop* p = begin; p < end; p++) { - if (!Universe::contains_non_oop_word(p)) { - cl->do_oop(p); - } - } - } - - XNMethodDataOops* const oops = gc_data(nm)->oops(); - - // Process immediate oops - { - oop** const begin = oops->immediates_begin(); - oop** const end = oops->immediates_end(); - for (oop** p = begin; p < end; p++) { - if (*p != Universe::non_oop_word()) { - cl->do_oop(*p); - } - } - } - - // Process non-immediate oops - if (oops->has_non_immediates()) { - nm->fix_oop_relocations(); - } -} - -class XNMethodOopClosure : public OopClosure { -public: - virtual void do_oop(oop* p) { - if (XResurrection::is_blocked()) { - XBarrier::keep_alive_barrier_on_phantom_root_oop_field(p); - } else { - XBarrier::load_barrier_on_root_oop_field(p); - } - } - - virtual void do_oop(narrowOop* p) { - ShouldNotReachHere(); - } -}; - -void XNMethod::nmethod_oops_barrier(nmethod* nm) { - XNMethodOopClosure cl; - nmethod_oops_do_inner(nm, &cl); -} - -void XNMethod::nmethods_do_begin() { - XNMethodTable::nmethods_do_begin(); -} - -void XNMethod::nmethods_do_end() { - XNMethodTable::nmethods_do_end(); -} - -void XNMethod::nmethods_do(NMethodClosure* cl) { - XNMethodTable::nmethods_do(cl); -} - -class XNMethodUnlinkClosure : public NMethodClosure { -private: - bool _unloading_occurred; - volatile bool _failed; - - void set_failed() { - Atomic::store(&_failed, true); - } - -public: - XNMethodUnlinkClosure(bool unloading_occurred) : - _unloading_occurred(unloading_occurred), - _failed(false) {} - - virtual void do_nmethod(nmethod* nm) { - if (failed()) { - return; - } - - if (nm->is_unloading()) { - XLocker locker(XNMethod::lock_for_nmethod(nm)); - nm->unlink(); - return; - } - - { - XLocker locker(XNMethod::lock_for_nmethod(nm)); - - if (XNMethod::is_armed(nm)) { - // Heal oops and arm phase invariantly - XNMethod::nmethod_oops_barrier(nm); - XNMethod::set_guard_value(nm, 0); - } - } - - // Clear compiled ICs and exception caches - XLocker locker(XNMethod::ic_lock_for_nmethod(nm)); - nm->unload_nmethod_caches(_unloading_occurred); - } - - bool failed() const { - return Atomic::load(&_failed); - } -}; - -class XNMethodUnlinkTask : public XTask { -private: - XNMethodUnlinkClosure _cl; - -public: - XNMethodUnlinkTask(bool unloading_occurred) : - XTask("XNMethodUnlinkTask"), - _cl(unloading_occurred) { - XNMethodTable::nmethods_do_begin(); - } - - ~XNMethodUnlinkTask() { - XNMethodTable::nmethods_do_end(); - } - - virtual void work() { - XNMethodTable::nmethods_do(&_cl); - } -}; - -void XNMethod::unlink(XWorkers* workers, bool unloading_occurred) { - XNMethodUnlinkTask task(unloading_occurred); - workers->run(&task); -} - -void XNMethod::purge() { - ClassUnloadingContext::context()->purge_and_free_nmethods(); -} diff --git a/src/hotspot/share/gc/x/xNMethod.hpp b/src/hotspot/share/gc/x/xNMethod.hpp deleted file mode 100644 index 49fdecf584d..00000000000 --- a/src/hotspot/share/gc/x/xNMethod.hpp +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2017, 2022, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XNMETHOD_HPP -#define SHARE_GC_X_XNMETHOD_HPP - -#include "memory/allStatic.hpp" - -class nmethod; -class NMethodClosure; -class XReentrantLock; -class XWorkers; - -class XNMethod : public AllStatic { -private: - static void attach_gc_data(nmethod* nm); - - static void log_register(const nmethod* nm); - static void log_unregister(const nmethod* nm); - -public: - static void register_nmethod(nmethod* nm); - static void unregister_nmethod(nmethod* nm); - - static bool supports_entry_barrier(nmethod* nm); - - static bool is_armed(nmethod* nm); - static void disarm(nmethod* nm); - static void set_guard_value(nmethod* nm, int value); - - static void nmethod_oops_do(nmethod* nm, OopClosure* cl); - static void nmethod_oops_do_inner(nmethod* nm, OopClosure* cl); - - static void nmethod_oops_barrier(nmethod* nm); - - static void nmethods_do_begin(); - static void nmethods_do_end(); - static void nmethods_do(NMethodClosure* cl); - - static XReentrantLock* lock_for_nmethod(nmethod* nm); - static XReentrantLock* ic_lock_for_nmethod(nmethod* nm); - - static void unlink(XWorkers* workers, bool unloading_occurred); - static void purge(); -}; - -#endif // SHARE_GC_X_XNMETHOD_HPP diff --git a/src/hotspot/share/gc/x/xNMethodData.cpp b/src/hotspot/share/gc/x/xNMethodData.cpp deleted file mode 100644 index 63fbfda99e2..00000000000 --- a/src/hotspot/share/gc/x/xNMethodData.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright (c) 2017, 2019, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/x/xAttachedArray.inline.hpp" -#include "gc/x/xLock.inline.hpp" -#include "gc/x/xNMethodData.hpp" -#include "memory/allocation.hpp" -#include "runtime/atomic.hpp" -#include "utilities/align.hpp" -#include "utilities/debug.hpp" -#include "utilities/growableArray.hpp" - -XNMethodDataOops* XNMethodDataOops::create(const GrowableArray& immediates, bool has_non_immediates) { - return ::new (AttachedArray::alloc(immediates.length())) XNMethodDataOops(immediates, has_non_immediates); -} - -void XNMethodDataOops::destroy(XNMethodDataOops* oops) { - AttachedArray::free(oops); -} - -XNMethodDataOops::XNMethodDataOops(const GrowableArray& immediates, bool has_non_immediates) : - _immediates(immediates.length()), - _has_non_immediates(has_non_immediates) { - // Save all immediate oops - for (size_t i = 0; i < immediates_count(); i++) { - immediates_begin()[i] = immediates.at(int(i)); - } -} - -size_t XNMethodDataOops::immediates_count() const { - return _immediates.length(); -} - -oop** XNMethodDataOops::immediates_begin() const { - return _immediates(this); -} - -oop** XNMethodDataOops::immediates_end() const { - return immediates_begin() + immediates_count(); -} - -bool XNMethodDataOops::has_non_immediates() const { - return _has_non_immediates; -} - -XNMethodData::XNMethodData() : - _lock(), - _ic_lock(), - _oops(nullptr) {} - -XNMethodData::~XNMethodData() { - XNMethodDataOops::destroy(_oops); -} - -XReentrantLock* XNMethodData::lock() { - return &_lock; -} - -XReentrantLock* XNMethodData::ic_lock() { - return &_ic_lock; -} - -XNMethodDataOops* XNMethodData::oops() const { - return Atomic::load_acquire(&_oops); -} - -XNMethodDataOops* XNMethodData::swap_oops(XNMethodDataOops* new_oops) { - XLocker locker(&_lock); - XNMethodDataOops* const old_oops = _oops; - _oops = new_oops; - return old_oops; -} diff --git a/src/hotspot/share/gc/x/xNMethodData.hpp b/src/hotspot/share/gc/x/xNMethodData.hpp deleted file mode 100644 index 14549f41342..00000000000 --- a/src/hotspot/share/gc/x/xNMethodData.hpp +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright (c) 2017, 2019, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XNMETHODDATA_HPP -#define SHARE_GC_X_XNMETHODDATA_HPP - -#include "gc/x/xAttachedArray.hpp" -#include "gc/x/xLock.hpp" -#include "memory/allocation.hpp" -#include "oops/oopsHierarchy.hpp" -#include "utilities/globalDefinitions.hpp" - -class nmethod; -template class GrowableArray; - -class XNMethodDataOops { -private: - typedef XAttachedArray AttachedArray; - - const AttachedArray _immediates; - const bool _has_non_immediates; - - XNMethodDataOops(const GrowableArray& immediates, bool has_non_immediates); - -public: - static XNMethodDataOops* create(const GrowableArray& immediates, bool has_non_immediates); - static void destroy(XNMethodDataOops* oops); - - size_t immediates_count() const; - oop** immediates_begin() const; - oop** immediates_end() const; - - bool has_non_immediates() const; -}; - -class XNMethodData : public CHeapObj { -private: - XReentrantLock _lock; - XReentrantLock _ic_lock; - XNMethodDataOops* volatile _oops; - -public: - XNMethodData(); - ~XNMethodData(); - - XReentrantLock* lock(); - XReentrantLock* ic_lock(); - - XNMethodDataOops* oops() const; - XNMethodDataOops* swap_oops(XNMethodDataOops* oops); -}; - -#endif // SHARE_GC_X_XNMETHODDATA_HPP diff --git a/src/hotspot/share/gc/x/xNMethodTable.cpp b/src/hotspot/share/gc/x/xNMethodTable.cpp deleted file mode 100644 index 52fcba755a7..00000000000 --- a/src/hotspot/share/gc/x/xNMethodTable.cpp +++ /dev/null @@ -1,234 +0,0 @@ -/* - * Copyright (c) 2017, 2019, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "code/relocInfo.hpp" -#include "code/nmethod.hpp" -#include "gc/shared/barrierSet.hpp" -#include "gc/shared/barrierSetNMethod.hpp" -#include "gc/x/xGlobals.hpp" -#include "gc/x/xHash.inline.hpp" -#include "gc/x/xLock.inline.hpp" -#include "gc/x/xNMethodData.hpp" -#include "gc/x/xNMethodTable.hpp" -#include "gc/x/xNMethodTableEntry.hpp" -#include "gc/x/xNMethodTableIteration.hpp" -#include "gc/x/xSafeDelete.inline.hpp" -#include "gc/x/xTask.hpp" -#include "gc/x/xWorkers.hpp" -#include "logging/log.hpp" -#include "memory/allocation.hpp" -#include "memory/iterator.hpp" -#include "memory/resourceArea.hpp" -#include "runtime/mutexLocker.hpp" -#include "utilities/debug.hpp" -#include "utilities/powerOfTwo.hpp" - -XNMethodTableEntry* XNMethodTable::_table = nullptr; -size_t XNMethodTable::_size = 0; -size_t XNMethodTable::_nregistered = 0; -size_t XNMethodTable::_nunregistered = 0; -XNMethodTableIteration XNMethodTable::_iteration; -XSafeDeleteNoLock XNMethodTable::_safe_delete; - -size_t XNMethodTable::first_index(const nmethod* nm, size_t size) { - assert(is_power_of_2(size), "Invalid size"); - const size_t mask = size - 1; - const size_t hash = XHash::address_to_uint32((uintptr_t)nm); - return hash & mask; -} - -size_t XNMethodTable::next_index(size_t prev_index, size_t size) { - assert(is_power_of_2(size), "Invalid size"); - const size_t mask = size - 1; - return (prev_index + 1) & mask; -} - -bool XNMethodTable::register_entry(XNMethodTableEntry* table, size_t size, nmethod* nm) { - const XNMethodTableEntry entry(nm); - size_t index = first_index(nm, size); - - for (;;) { - const XNMethodTableEntry table_entry = table[index]; - - if (!table_entry.registered() && !table_entry.unregistered()) { - // Insert new entry - table[index] = entry; - return true; - } - - if (table_entry.registered() && table_entry.method() == nm) { - // Replace existing entry - table[index] = entry; - return false; - } - - index = next_index(index, size); - } -} - -void XNMethodTable::unregister_entry(XNMethodTableEntry* table, size_t size, nmethod* nm) { - size_t index = first_index(nm, size); - - for (;;) { - const XNMethodTableEntry table_entry = table[index]; - assert(table_entry.registered() || table_entry.unregistered(), "Entry not found"); - - if (table_entry.registered() && table_entry.method() == nm) { - // Remove entry - table[index] = XNMethodTableEntry(true /* unregistered */); - return; - } - - index = next_index(index, size); - } -} - -void XNMethodTable::rebuild(size_t new_size) { - assert(CodeCache_lock->owned_by_self(), "Lock must be held"); - - assert(is_power_of_2(new_size), "Invalid size"); - - log_debug(gc, nmethod)("Rebuilding NMethod Table: " - SIZE_FORMAT "->" SIZE_FORMAT " entries, " - SIZE_FORMAT "(%.0f%%->%.0f%%) registered, " - SIZE_FORMAT "(%.0f%%->%.0f%%) unregistered", - _size, new_size, - _nregistered, percent_of(_nregistered, _size), percent_of(_nregistered, new_size), - _nunregistered, percent_of(_nunregistered, _size), 0.0); - - // Allocate new table - XNMethodTableEntry* const new_table = new XNMethodTableEntry[new_size]; - - // Transfer all registered entries - for (size_t i = 0; i < _size; i++) { - const XNMethodTableEntry entry = _table[i]; - if (entry.registered()) { - register_entry(new_table, new_size, entry.method()); - } - } - - // Free old table - _safe_delete(_table); - - // Install new table - _table = new_table; - _size = new_size; - _nunregistered = 0; -} - -void XNMethodTable::rebuild_if_needed() { - // The hash table uses linear probing. To avoid wasting memory while - // at the same time maintaining good hash collision behavior we want - // to keep the table occupancy between 30% and 70%. The table always - // grows/shrinks by doubling/halving its size. Pruning of unregistered - // entries is done by rebuilding the table with or without resizing it. - const size_t min_size = 1024; - const size_t shrink_threshold = _size * 0.30; - const size_t prune_threshold = _size * 0.65; - const size_t grow_threshold = _size * 0.70; - - if (_size == 0) { - // Initialize table - rebuild(min_size); - } else if (_nregistered < shrink_threshold && _size > min_size) { - // Shrink table - rebuild(_size / 2); - } else if (_nregistered + _nunregistered > grow_threshold) { - // Prune or grow table - if (_nregistered < prune_threshold) { - // Prune table - rebuild(_size); - } else { - // Grow table - rebuild(_size * 2); - } - } -} - -size_t XNMethodTable::registered_nmethods() { - return _nregistered; -} - -size_t XNMethodTable::unregistered_nmethods() { - return _nunregistered; -} - -void XNMethodTable::register_nmethod(nmethod* nm) { - assert(CodeCache_lock->owned_by_self(), "Lock must be held"); - - // Grow/Shrink/Prune table if needed - rebuild_if_needed(); - - // Insert new entry - if (register_entry(_table, _size, nm)) { - // New entry registered. When register_entry() instead returns - // false the nmethod was already in the table so we do not want - // to increase number of registered entries in that case. - _nregistered++; - } -} - -void XNMethodTable::wait_until_iteration_done() { - assert(CodeCache_lock->owned_by_self(), "Lock must be held"); - - while (_iteration.in_progress()) { - CodeCache_lock->wait_without_safepoint_check(); - } -} - -void XNMethodTable::unregister_nmethod(nmethod* nm) { - assert(CodeCache_lock->owned_by_self(), "Lock must be held"); - - // Remove entry - unregister_entry(_table, _size, nm); - _nunregistered++; - _nregistered--; -} - -void XNMethodTable::nmethods_do_begin() { - MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); - - // Do not allow the table to be deleted while iterating - _safe_delete.enable_deferred_delete(); - - // Prepare iteration - _iteration.nmethods_do_begin(_table, _size); -} - -void XNMethodTable::nmethods_do_end() { - MutexLocker mu(CodeCache_lock, Mutex::_no_safepoint_check_flag); - - // Finish iteration - _iteration.nmethods_do_end(); - - // Allow the table to be deleted - _safe_delete.disable_deferred_delete(); - - // Notify iteration done - CodeCache_lock->notify_all(); -} - -void XNMethodTable::nmethods_do(NMethodClosure* cl) { - _iteration.nmethods_do(cl); -} diff --git a/src/hotspot/share/gc/x/xNMethodTable.hpp b/src/hotspot/share/gc/x/xNMethodTable.hpp deleted file mode 100644 index ebb7803a083..00000000000 --- a/src/hotspot/share/gc/x/xNMethodTable.hpp +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2017, 2022, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XNMETHODTABLE_HPP -#define SHARE_GC_X_XNMETHODTABLE_HPP - -#include "gc/x/xNMethodTableIteration.hpp" -#include "gc/x/xSafeDelete.hpp" -#include "memory/allStatic.hpp" - -class nmethod; -class NMethodClosure; -class XNMethodTableEntry; -class XWorkers; - -class XNMethodTable : public AllStatic { -private: - static XNMethodTableEntry* _table; - static size_t _size; - static size_t _nregistered; - static size_t _nunregistered; - static XNMethodTableIteration _iteration; - static XSafeDeleteNoLock _safe_delete; - - static XNMethodTableEntry* create(size_t size); - static void destroy(XNMethodTableEntry* table); - - static size_t first_index(const nmethod* nm, size_t size); - static size_t next_index(size_t prev_index, size_t size); - - static bool register_entry(XNMethodTableEntry* table, size_t size, nmethod* nm); - static void unregister_entry(XNMethodTableEntry* table, size_t size, nmethod* nm); - - static void rebuild(size_t new_size); - static void rebuild_if_needed(); - -public: - static size_t registered_nmethods(); - static size_t unregistered_nmethods(); - - static void register_nmethod(nmethod* nm); - static void unregister_nmethod(nmethod* nm); - - static void wait_until_iteration_done(); - - static void nmethods_do_begin(); - static void nmethods_do_end(); - static void nmethods_do(NMethodClosure* cl); - - static void unlink(XWorkers* workers, bool unloading_occurred); - static void purge(XWorkers* workers); -}; - -#endif // SHARE_GC_X_XNMETHODTABLE_HPP diff --git a/src/hotspot/share/gc/x/xNMethodTableEntry.hpp b/src/hotspot/share/gc/x/xNMethodTableEntry.hpp deleted file mode 100644 index 9f06abb0bdb..00000000000 --- a/src/hotspot/share/gc/x/xNMethodTableEntry.hpp +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2017, 2018, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XNMETHODTABLEENTRY_HPP -#define SHARE_GC_X_XNMETHODTABLEENTRY_HPP - -#include "gc/x/xBitField.hpp" -#include "memory/allocation.hpp" - -class nmethod; - -// -// NMethod table entry layout -// -------------------------- -// -// 6 -// 3 2 1 0 -// +---------------------------------------------------------------------+-+-+ -// |11111111 11111111 11111111 11111111 11111111 11111111 11111111 111111|1|1| -// +---------------------------------------------------------------------+-+-+ -// | | | -// | 1-1 Unregistered Flag (1-bits) * | -// | | -// | 0-0 Registered Flag (1-bits) * -// | -// * 63-2 NMethod Address (62-bits) -// - -class XNMethodTableEntry : public CHeapObj { -private: - typedef XBitField field_registered; - typedef XBitField field_unregistered; - typedef XBitField field_method; - - uint64_t _entry; - -public: - explicit XNMethodTableEntry(bool unregistered = false) : - _entry(field_registered::encode(false) | - field_unregistered::encode(unregistered) | - field_method::encode(nullptr)) {} - - explicit XNMethodTableEntry(nmethod* method) : - _entry(field_registered::encode(true) | - field_unregistered::encode(false) | - field_method::encode(method)) {} - - bool registered() const { - return field_registered::decode(_entry); - } - - bool unregistered() const { - return field_unregistered::decode(_entry); - } - - nmethod* method() const { - return field_method::decode(_entry); - } -}; - -#endif // SHARE_GC_X_XNMETHODTABLEENTRY_HPP diff --git a/src/hotspot/share/gc/x/xNMethodTableIteration.cpp b/src/hotspot/share/gc/x/xNMethodTableIteration.cpp deleted file mode 100644 index c9248e63420..00000000000 --- a/src/hotspot/share/gc/x/xNMethodTableIteration.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/* - * 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/x/xNMethodTableEntry.hpp" -#include "gc/x/xNMethodTableIteration.hpp" -#include "memory/iterator.hpp" -#include "runtime/atomic.hpp" -#include "utilities/debug.hpp" -#include "utilities/globalDefinitions.hpp" - -XNMethodTableIteration::XNMethodTableIteration() : - _table(nullptr), - _size(0), - _claimed(0) {} - -bool XNMethodTableIteration::in_progress() const { - return _table != nullptr; -} - -void XNMethodTableIteration::nmethods_do_begin(XNMethodTableEntry* table, size_t size) { - assert(!in_progress(), "precondition"); - - _table = table; - _size = size; - _claimed = 0; -} - -void XNMethodTableIteration::nmethods_do_end() { - assert(_claimed >= _size, "Failed to claim all table entries"); - - // Finish iteration - _table = nullptr; -} - -void XNMethodTableIteration::nmethods_do(NMethodClosure* cl) { - for (;;) { - // Claim table partition. Each partition is currently sized to span - // two cache lines. This number is just a guess, but seems to work well. - const size_t partition_size = (XCacheLineSize * 2) / sizeof(XNMethodTableEntry); - const size_t partition_start = MIN2(Atomic::fetch_then_add(&_claimed, partition_size), _size); - const size_t partition_end = MIN2(partition_start + partition_size, _size); - if (partition_start == partition_end) { - // End of table - break; - } - - // Process table partition - for (size_t i = partition_start; i < partition_end; i++) { - const XNMethodTableEntry entry = _table[i]; - if (entry.registered()) { - cl->do_nmethod(entry.method()); - } - } - } -} diff --git a/src/hotspot/share/gc/x/xNMethodTableIteration.hpp b/src/hotspot/share/gc/x/xNMethodTableIteration.hpp deleted file mode 100644 index 1677b334490..00000000000 --- a/src/hotspot/share/gc/x/xNMethodTableIteration.hpp +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2019, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XNMETHODTABLEITERATION_HPP -#define SHARE_GC_X_XNMETHODTABLEITERATION_HPP - -#include "gc/x/xGlobals.hpp" - -class NMethodClosure; -class XNMethodTableEntry; - -class XNMethodTableIteration { -private: - XNMethodTableEntry* _table; - size_t _size; - XCACHE_ALIGNED volatile size_t _claimed; - -public: - XNMethodTableIteration(); - - bool in_progress() const; - - void nmethods_do_begin(XNMethodTableEntry* table, size_t size); - void nmethods_do_end(); - void nmethods_do(NMethodClosure* cl); -}; - -#endif // SHARE_GC_X_XNMETHODTABLEITERATION_HPP diff --git a/src/hotspot/share/gc/x/xNUMA.cpp b/src/hotspot/share/gc/x/xNUMA.cpp deleted file mode 100644 index fb99878b200..00000000000 --- a/src/hotspot/share/gc/x/xNUMA.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2016, 2020, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/shared/gcLogPrecious.hpp" -#include "gc/x/xNUMA.hpp" - -bool XNUMA::_enabled; - -void XNUMA::initialize() { - pd_initialize(); - - log_info_p(gc, init)("NUMA Support: %s", to_string()); - if (_enabled) { - log_info_p(gc, init)("NUMA Nodes: %u", count()); - } -} - -const char* XNUMA::to_string() { - return _enabled ? "Enabled" : "Disabled"; -} diff --git a/src/hotspot/share/gc/x/xNUMA.hpp b/src/hotspot/share/gc/x/xNUMA.hpp deleted file mode 100644 index 6331a62c042..00000000000 --- a/src/hotspot/share/gc/x/xNUMA.hpp +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2016, 2022, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XNUMA_HPP -#define SHARE_GC_X_XNUMA_HPP - -#include "memory/allStatic.hpp" -#include "utilities/globalDefinitions.hpp" - -class XNUMA : public AllStatic { -private: - static bool _enabled; - - static void pd_initialize(); - -public: - static void initialize(); - static bool is_enabled(); - - static uint32_t count(); - static uint32_t id(); - - static uint32_t memory_id(uintptr_t addr); - - static const char* to_string(); -}; - -#endif // SHARE_GC_X_XNUMA_HPP diff --git a/src/hotspot/share/gc/x/xNUMA.inline.hpp b/src/hotspot/share/gc/x/xNUMA.inline.hpp deleted file mode 100644 index 17f5b831a31..00000000000 --- a/src/hotspot/share/gc/x/xNUMA.inline.hpp +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2019, 2020, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XNUMA_INLINE_HPP -#define SHARE_GC_X_XNUMA_INLINE_HPP - -#include "gc/x/xNUMA.hpp" - -inline bool XNUMA::is_enabled() { - return _enabled; -} - -#endif // SHARE_GC_X_XNUMA_INLINE_HPP diff --git a/src/hotspot/share/gc/x/xObjArrayAllocator.cpp b/src/hotspot/share/gc/x/xObjArrayAllocator.cpp deleted file mode 100644 index 0950b886a9b..00000000000 --- a/src/hotspot/share/gc/x/xObjArrayAllocator.cpp +++ /dev/null @@ -1,103 +0,0 @@ -/* - * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/x/xThreadLocalData.hpp" -#include "gc/x/xObjArrayAllocator.hpp" -#include "gc/x/xUtils.inline.hpp" -#include "oops/arrayKlass.hpp" -#include "runtime/interfaceSupport.inline.hpp" -#include "utilities/debug.hpp" - -XObjArrayAllocator::XObjArrayAllocator(Klass* klass, size_t word_size, int length, bool do_zero, Thread* thread) : - ObjArrayAllocator(klass, word_size, length, do_zero, thread) {} - -void XObjArrayAllocator::yield_for_safepoint() const { - ThreadBlockInVM tbivm(JavaThread::cast(_thread)); -} - -oop XObjArrayAllocator::initialize(HeapWord* mem) const { - // ZGC specializes the initialization by performing segmented clearing - // to allow shorter time-to-safepoints. - - if (!_do_zero) { - // No need for ZGC specialization - return ObjArrayAllocator::initialize(mem); - } - - // A max segment size of 64K was chosen because microbenchmarking - // suggested that it offered a good trade-off between allocation - // time and time-to-safepoint - const size_t segment_max = XUtils::bytes_to_words(64 * K); - const BasicType element_type = ArrayKlass::cast(_klass)->element_type(); - - // Clear leading 32 bits, if necessary. - int base_offset = arrayOopDesc::base_offset_in_bytes(element_type); - if (!is_aligned(base_offset, HeapWordSize)) { - assert(is_aligned(base_offset, BytesPerInt), "array base must be 32 bit aligned"); - *reinterpret_cast(reinterpret_cast(mem) + base_offset) = 0; - base_offset += BytesPerInt; - } - assert(is_aligned(base_offset, HeapWordSize), "remaining array base must be 64 bit aligned"); - - const size_t header = heap_word_size(base_offset); - const size_t payload_size = _word_size - header; - - if (payload_size <= segment_max) { - // To small to use segmented clearing - return ObjArrayAllocator::initialize(mem); - } - - // Segmented clearing - - // The array is going to be exposed before it has been completely - // cleared, therefore we can't expose the header at the end of this - // function. Instead explicitly initialize it according to our needs. - arrayOopDesc::set_mark(mem, markWord::prototype()); - arrayOopDesc::release_set_klass(mem, _klass); - assert(_length >= 0, "length should be non-negative"); - arrayOopDesc::set_length(mem, _length); - - // Keep the array alive across safepoints through an invisible - // root. Invisible roots are not visited by the heap itarator - // and the marking logic will not attempt to follow its elements. - // Relocation knows how to dodge iterating over such objects. - XThreadLocalData::set_invisible_root(_thread, (oop*)&mem); - - for (size_t processed = 0; processed < payload_size; processed += segment_max) { - // Calculate segment - HeapWord* const start = (HeapWord*)(mem + header + processed); - const size_t remaining = payload_size - processed; - const size_t segment_size = MIN2(remaining, segment_max); - - // Clear segment - Copy::zero_to_words(start, segment_size); - - // Safepoint - yield_for_safepoint(); - } - - XThreadLocalData::clear_invisible_root(_thread); - - return cast_to_oop(mem); -} diff --git a/src/hotspot/share/gc/x/xObjArrayAllocator.hpp b/src/hotspot/share/gc/x/xObjArrayAllocator.hpp deleted file mode 100644 index 4a084da3279..00000000000 --- a/src/hotspot/share/gc/x/xObjArrayAllocator.hpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2019, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XOBJARRAYALLOCATOR_HPP -#define SHARE_GC_X_XOBJARRAYALLOCATOR_HPP - -#include "gc/shared/memAllocator.hpp" - -class XObjArrayAllocator : public ObjArrayAllocator { -private: - virtual oop initialize(HeapWord* mem) const override; - - void yield_for_safepoint() const; - -public: - XObjArrayAllocator(Klass* klass, size_t word_size, int length, bool do_zero, Thread* thread); -}; - -#endif // SHARE_GC_X_XOBJARRAYALLOCATOR_HPP diff --git a/src/hotspot/share/gc/x/xObjectAllocator.cpp b/src/hotspot/share/gc/x/xObjectAllocator.cpp deleted file mode 100644 index 26981ce9131..00000000000 --- a/src/hotspot/share/gc/x/xObjectAllocator.cpp +++ /dev/null @@ -1,267 +0,0 @@ -/* - * Copyright (c) 2015, 2021, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/x/xGlobals.hpp" -#include "gc/x/xHeap.inline.hpp" -#include "gc/x/xHeuristics.hpp" -#include "gc/x/xObjectAllocator.hpp" -#include "gc/x/xPage.inline.hpp" -#include "gc/x/xPageTable.inline.hpp" -#include "gc/x/xStat.hpp" -#include "gc/x/xThread.inline.hpp" -#include "gc/x/xValue.inline.hpp" -#include "logging/log.hpp" -#include "runtime/atomic.hpp" -#include "runtime/safepoint.hpp" -#include "utilities/align.hpp" -#include "utilities/debug.hpp" - -static const XStatCounter XCounterUndoObjectAllocationSucceeded("Memory", "Undo Object Allocation Succeeded", XStatUnitOpsPerSecond); -static const XStatCounter XCounterUndoObjectAllocationFailed("Memory", "Undo Object Allocation Failed", XStatUnitOpsPerSecond); - -XObjectAllocator::XObjectAllocator() : - _use_per_cpu_shared_small_pages(XHeuristics::use_per_cpu_shared_small_pages()), - _used(0), - _undone(0), - _alloc_for_relocation(0), - _undo_alloc_for_relocation(0), - _shared_medium_page(nullptr), - _shared_small_page(nullptr) {} - -XPage** XObjectAllocator::shared_small_page_addr() { - return _use_per_cpu_shared_small_pages ? _shared_small_page.addr() : _shared_small_page.addr(0); -} - -XPage* const* XObjectAllocator::shared_small_page_addr() const { - return _use_per_cpu_shared_small_pages ? _shared_small_page.addr() : _shared_small_page.addr(0); -} - -void XObjectAllocator::register_alloc_for_relocation(const XPageTable* page_table, uintptr_t addr, size_t size) { - const XPage* const page = page_table->get(addr); - const size_t aligned_size = align_up(size, page->object_alignment()); - Atomic::add(_alloc_for_relocation.addr(), aligned_size); -} - -void XObjectAllocator::register_undo_alloc_for_relocation(const XPage* page, size_t size) { - const size_t aligned_size = align_up(size, page->object_alignment()); - Atomic::add(_undo_alloc_for_relocation.addr(), aligned_size); -} - -XPage* XObjectAllocator::alloc_page(uint8_t type, size_t size, XAllocationFlags flags) { - XPage* const page = XHeap::heap()->alloc_page(type, size, flags); - if (page != nullptr) { - // Increment used bytes - Atomic::add(_used.addr(), size); - } - - return page; -} - -void XObjectAllocator::undo_alloc_page(XPage* page) { - // Increment undone bytes - Atomic::add(_undone.addr(), page->size()); - - XHeap::heap()->undo_alloc_page(page); -} - -uintptr_t XObjectAllocator::alloc_object_in_shared_page(XPage** shared_page, - uint8_t page_type, - size_t page_size, - size_t size, - XAllocationFlags flags) { - uintptr_t addr = 0; - XPage* page = Atomic::load_acquire(shared_page); - - if (page != nullptr) { - addr = page->alloc_object_atomic(size); - } - - if (addr == 0) { - // Allocate new page - XPage* const new_page = alloc_page(page_type, page_size, flags); - if (new_page != nullptr) { - // Allocate object before installing the new page - addr = new_page->alloc_object(size); - - retry: - // Install new page - XPage* const prev_page = Atomic::cmpxchg(shared_page, page, new_page); - if (prev_page != page) { - if (prev_page == nullptr) { - // Previous page was retired, retry installing the new page - page = prev_page; - goto retry; - } - - // Another page already installed, try allocation there first - const uintptr_t prev_addr = prev_page->alloc_object_atomic(size); - if (prev_addr == 0) { - // Allocation failed, retry installing the new page - page = prev_page; - goto retry; - } - - // Allocation succeeded in already installed page - addr = prev_addr; - - // Undo new page allocation - undo_alloc_page(new_page); - } - } - } - - return addr; -} - -uintptr_t XObjectAllocator::alloc_large_object(size_t size, XAllocationFlags flags) { - uintptr_t addr = 0; - - // Allocate new large page - const size_t page_size = align_up(size, XGranuleSize); - XPage* const page = alloc_page(XPageTypeLarge, page_size, flags); - if (page != nullptr) { - // Allocate the object - addr = page->alloc_object(size); - } - - return addr; -} - -uintptr_t XObjectAllocator::alloc_medium_object(size_t size, XAllocationFlags flags) { - return alloc_object_in_shared_page(_shared_medium_page.addr(), XPageTypeMedium, XPageSizeMedium, size, flags); -} - -uintptr_t XObjectAllocator::alloc_small_object(size_t size, XAllocationFlags flags) { - return alloc_object_in_shared_page(shared_small_page_addr(), XPageTypeSmall, XPageSizeSmall, size, flags); -} - -uintptr_t XObjectAllocator::alloc_object(size_t size, XAllocationFlags flags) { - if (size <= XObjectSizeLimitSmall) { - // Small - return alloc_small_object(size, flags); - } else if (size <= XObjectSizeLimitMedium) { - // Medium - return alloc_medium_object(size, flags); - } else { - // Large - return alloc_large_object(size, flags); - } -} - -uintptr_t XObjectAllocator::alloc_object(size_t size) { - XAllocationFlags flags; - return alloc_object(size, flags); -} - -uintptr_t XObjectAllocator::alloc_object_for_relocation(const XPageTable* page_table, size_t size) { - XAllocationFlags flags; - flags.set_non_blocking(); - - const uintptr_t addr = alloc_object(size, flags); - if (addr != 0) { - register_alloc_for_relocation(page_table, addr, size); - } - - return addr; -} - -void XObjectAllocator::undo_alloc_object_for_relocation(XPage* page, uintptr_t addr, size_t size) { - const uint8_t type = page->type(); - - if (type == XPageTypeLarge) { - register_undo_alloc_for_relocation(page, size); - undo_alloc_page(page); - XStatInc(XCounterUndoObjectAllocationSucceeded); - } else { - if (page->undo_alloc_object_atomic(addr, size)) { - register_undo_alloc_for_relocation(page, size); - XStatInc(XCounterUndoObjectAllocationSucceeded); - } else { - XStatInc(XCounterUndoObjectAllocationFailed); - } - } -} - -size_t XObjectAllocator::used() const { - size_t total_used = 0; - size_t total_undone = 0; - - XPerCPUConstIterator iter_used(&_used); - for (const size_t* cpu_used; iter_used.next(&cpu_used);) { - total_used += *cpu_used; - } - - XPerCPUConstIterator iter_undone(&_undone); - for (const size_t* cpu_undone; iter_undone.next(&cpu_undone);) { - total_undone += *cpu_undone; - } - - return total_used - total_undone; -} - -size_t XObjectAllocator::remaining() const { - assert(XThread::is_java(), "Should be a Java thread"); - - const XPage* const page = Atomic::load_acquire(shared_small_page_addr()); - if (page != nullptr) { - return page->remaining(); - } - - return 0; -} - -size_t XObjectAllocator::relocated() const { - size_t total_alloc = 0; - size_t total_undo_alloc = 0; - - XPerCPUConstIterator iter_alloc(&_alloc_for_relocation); - for (const size_t* alloc; iter_alloc.next(&alloc);) { - total_alloc += Atomic::load(alloc); - } - - XPerCPUConstIterator iter_undo_alloc(&_undo_alloc_for_relocation); - for (const size_t* undo_alloc; iter_undo_alloc.next(&undo_alloc);) { - total_undo_alloc += Atomic::load(undo_alloc); - } - - assert(total_alloc >= total_undo_alloc, "Mismatch"); - - return total_alloc - total_undo_alloc; -} - -void XObjectAllocator::retire_pages() { - assert(SafepointSynchronize::is_at_safepoint(), "Should be at safepoint"); - - // Reset used and undone bytes - _used.set_all(0); - _undone.set_all(0); - - // Reset relocated bytes - _alloc_for_relocation.set_all(0); - _undo_alloc_for_relocation.set_all(0); - - // Reset allocation pages - _shared_medium_page.set(nullptr); - _shared_small_page.set_all(nullptr); -} diff --git a/src/hotspot/share/gc/x/xObjectAllocator.hpp b/src/hotspot/share/gc/x/xObjectAllocator.hpp deleted file mode 100644 index 8880c41f3d5..00000000000 --- a/src/hotspot/share/gc/x/xObjectAllocator.hpp +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2015, 2021, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XOBJECTALLOCATOR_HPP -#define SHARE_GC_X_XOBJECTALLOCATOR_HPP - -#include "gc/x/xAllocationFlags.hpp" -#include "gc/x/xValue.hpp" - -class XPage; -class XPageTable; - -class XObjectAllocator { -private: - const bool _use_per_cpu_shared_small_pages; - XPerCPU _used; - XPerCPU _undone; - XPerCPU _alloc_for_relocation; - XPerCPU _undo_alloc_for_relocation; - XContended _shared_medium_page; - XPerCPU _shared_small_page; - - XPage** shared_small_page_addr(); - XPage* const* shared_small_page_addr() const; - - void register_alloc_for_relocation(const XPageTable* page_table, uintptr_t addr, size_t size); - void register_undo_alloc_for_relocation(const XPage* page, size_t size); - - XPage* alloc_page(uint8_t type, size_t size, XAllocationFlags flags); - void undo_alloc_page(XPage* page); - - // Allocate an object in a shared page. Allocate and - // atomically install a new page if necessary. - uintptr_t alloc_object_in_shared_page(XPage** shared_page, - uint8_t page_type, - size_t page_size, - size_t size, - XAllocationFlags flags); - - uintptr_t alloc_large_object(size_t size, XAllocationFlags flags); - uintptr_t alloc_medium_object(size_t size, XAllocationFlags flags); - uintptr_t alloc_small_object(size_t size, XAllocationFlags flags); - uintptr_t alloc_object(size_t size, XAllocationFlags flags); - -public: - XObjectAllocator(); - - uintptr_t alloc_object(size_t size); - uintptr_t alloc_object_for_relocation(const XPageTable* page_table, size_t size); - void undo_alloc_object_for_relocation(XPage* page, uintptr_t addr, size_t size); - - size_t used() const; - size_t remaining() const; - size_t relocated() const; - - void retire_pages(); -}; - -#endif // SHARE_GC_X_XOBJECTALLOCATOR_HPP diff --git a/src/hotspot/share/gc/x/xOop.hpp b/src/hotspot/share/gc/x/xOop.hpp deleted file mode 100644 index 92cc7a225fe..00000000000 --- a/src/hotspot/share/gc/x/xOop.hpp +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2016, 2022, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XOOP_HPP -#define SHARE_GC_X_XOOP_HPP - -#include "memory/allStatic.hpp" -#include "oops/oopsHierarchy.hpp" - -class XOop : public AllStatic { -public: - static oop from_address(uintptr_t addr); - static uintptr_t to_address(oop o); -}; - -#endif // SHARE_GC_X_XOOP_HPP diff --git a/src/hotspot/share/gc/x/xOop.inline.hpp b/src/hotspot/share/gc/x/xOop.inline.hpp deleted file mode 100644 index 933987577d1..00000000000 --- a/src/hotspot/share/gc/x/xOop.inline.hpp +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2016, 2019, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XOOP_INLINE_HPP -#define SHARE_GC_X_XOOP_INLINE_HPP - -#include "gc/x/xOop.hpp" - -inline oop XOop::from_address(uintptr_t addr) { - return cast_to_oop(addr); -} - -inline uintptr_t XOop::to_address(oop o) { - return cast_from_oop(o); -} - -#endif // SHARE_GC_X_XOOP_INLINE_HPP diff --git a/src/hotspot/share/gc/x/xPage.cpp b/src/hotspot/share/gc/x/xPage.cpp deleted file mode 100644 index b48500ab96e..00000000000 --- a/src/hotspot/share/gc/x/xPage.cpp +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright (c) 2015, 2020, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/x/xList.inline.hpp" -#include "gc/x/xPage.inline.hpp" -#include "gc/x/xPhysicalMemory.inline.hpp" -#include "gc/x/xVirtualMemory.inline.hpp" -#include "utilities/align.hpp" -#include "utilities/debug.hpp" - -XPage::XPage(const XVirtualMemory& vmem, const XPhysicalMemory& pmem) : - XPage(type_from_size(vmem.size()), vmem, pmem) {} - -XPage::XPage(uint8_t type, const XVirtualMemory& vmem, const XPhysicalMemory& pmem) : - _type(type), - _numa_id((uint8_t)-1), - _seqnum(0), - _virtual(vmem), - _top(start()), - _livemap(object_max_count()), - _last_used(0), - _physical(pmem), - _node() { - assert_initialized(); -} - -XPage::~XPage() {} - -void XPage::assert_initialized() const { - assert(!_virtual.is_null(), "Should not be null"); - assert(!_physical.is_null(), "Should not be null"); - assert(_virtual.size() == _physical.size(), "Virtual/Physical size mismatch"); - assert((_type == XPageTypeSmall && size() == XPageSizeSmall) || - (_type == XPageTypeMedium && size() == XPageSizeMedium) || - (_type == XPageTypeLarge && is_aligned(size(), XGranuleSize)), - "Page type/size mismatch"); -} - -void XPage::reset() { - _seqnum = XGlobalSeqNum; - _top = start(); - _livemap.reset(); - _last_used = 0; -} - -void XPage::reset_for_in_place_relocation() { - _seqnum = XGlobalSeqNum; - _top = start(); -} - -XPage* XPage::retype(uint8_t type) { - assert(_type != type, "Invalid retype"); - _type = type; - _livemap.resize(object_max_count()); - return this; -} - -XPage* XPage::split(size_t size) { - return split(type_from_size(size), size); -} - -XPage* XPage::split(uint8_t type, size_t size) { - assert(_virtual.size() > size, "Invalid split"); - - // Resize this page, keep _numa_id, _seqnum, and _last_used - const XVirtualMemory vmem = _virtual.split(size); - const XPhysicalMemory pmem = _physical.split(size); - _type = type_from_size(_virtual.size()); - _top = start(); - _livemap.resize(object_max_count()); - - // Create new page, inherit _seqnum and _last_used - XPage* const page = new XPage(type, vmem, pmem); - page->_seqnum = _seqnum; - page->_last_used = _last_used; - return page; -} - -XPage* XPage::split_committed() { - // Split any committed part of this page into a separate page, - // leaving this page with only uncommitted physical memory. - const XPhysicalMemory pmem = _physical.split_committed(); - if (pmem.is_null()) { - // Nothing committed - return nullptr; - } - - assert(!_physical.is_null(), "Should not be null"); - - // Resize this page - const XVirtualMemory vmem = _virtual.split(pmem.size()); - _type = type_from_size(_virtual.size()); - _top = start(); - _livemap.resize(object_max_count()); - - // Create new page - return new XPage(vmem, pmem); -} - -void XPage::print_on(outputStream* out) const { - out->print_cr(" %-6s " PTR_FORMAT " " PTR_FORMAT " " PTR_FORMAT " %s%s", - type_to_string(), start(), top(), end(), - is_allocating() ? " Allocating" : "", - is_relocatable() ? " Relocatable" : ""); -} - -void XPage::print() const { - print_on(tty); -} - -void XPage::verify_live(uint32_t live_objects, size_t live_bytes) const { - guarantee(live_objects == _livemap.live_objects(), "Invalid number of live objects"); - guarantee(live_bytes == _livemap.live_bytes(), "Invalid number of live bytes"); -} diff --git a/src/hotspot/share/gc/x/xPage.hpp b/src/hotspot/share/gc/x/xPage.hpp deleted file mode 100644 index c1040e034bd..00000000000 --- a/src/hotspot/share/gc/x/xPage.hpp +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright (c) 2015, 2021, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XPAGE_HPP -#define SHARE_GC_X_XPAGE_HPP - -#include "gc/x/xList.hpp" -#include "gc/x/xLiveMap.hpp" -#include "gc/x/xPhysicalMemory.hpp" -#include "gc/x/xVirtualMemory.hpp" -#include "memory/allocation.hpp" - -class VMStructs; - -class XPage : public CHeapObj { - friend class ::VMStructs; - friend class XList; - -private: - uint8_t _type; - uint8_t _numa_id; - uint32_t _seqnum; - XVirtualMemory _virtual; - volatile uintptr_t _top; - XLiveMap _livemap; - uint64_t _last_used; - XPhysicalMemory _physical; - XListNode _node; - - void assert_initialized() const; - - uint8_t type_from_size(size_t size) const; - const char* type_to_string() const; - - bool is_object_marked(uintptr_t addr) const; - bool is_object_strongly_marked(uintptr_t addr) const; - -public: - XPage(const XVirtualMemory& vmem, const XPhysicalMemory& pmem); - XPage(uint8_t type, const XVirtualMemory& vmem, const XPhysicalMemory& pmem); - ~XPage(); - - uint32_t object_max_count() const; - size_t object_alignment_shift() const; - size_t object_alignment() const; - - uint8_t type() const; - uintptr_t start() const; - uintptr_t end() const; - size_t size() const; - uintptr_t top() const; - size_t remaining() const; - - const XVirtualMemory& virtual_memory() const; - const XPhysicalMemory& physical_memory() const; - XPhysicalMemory& physical_memory(); - - uint8_t numa_id(); - - bool is_allocating() const; - bool is_relocatable() const; - - uint64_t last_used() const; - void set_last_used(); - - void reset(); - void reset_for_in_place_relocation(); - - XPage* retype(uint8_t type); - XPage* split(size_t size); - XPage* split(uint8_t type, size_t size); - XPage* split_committed(); - - bool is_in(uintptr_t addr) const; - - bool is_marked() const; - template bool is_object_marked(uintptr_t addr) const; - bool is_object_live(uintptr_t addr) const; - bool is_object_strongly_live(uintptr_t addr) const; - bool mark_object(uintptr_t addr, bool finalizable, bool& inc_live); - - void inc_live(uint32_t objects, size_t bytes); - uint32_t live_objects() const; - size_t live_bytes() const; - - void object_iterate(ObjectClosure* cl); - - uintptr_t alloc_object(size_t size); - uintptr_t alloc_object_atomic(size_t size); - - bool undo_alloc_object(uintptr_t addr, size_t size); - bool undo_alloc_object_atomic(uintptr_t addr, size_t size); - - void print_on(outputStream* out) const; - void print() const; - - void verify_live(uint32_t live_objects, size_t live_bytes) const; -}; - -class XPageClosure { -public: - virtual void do_page(const XPage* page) = 0; -}; - -#endif // SHARE_GC_X_XPAGE_HPP diff --git a/src/hotspot/share/gc/x/xPage.inline.hpp b/src/hotspot/share/gc/x/xPage.inline.hpp deleted file mode 100644 index d9b0fd2039d..00000000000 --- a/src/hotspot/share/gc/x/xPage.inline.hpp +++ /dev/null @@ -1,313 +0,0 @@ -/* - * Copyright (c) 2015, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XPAGE_INLINE_HPP -#define SHARE_GC_X_XPAGE_INLINE_HPP - -#include "gc/x/xPage.hpp" - -#include "gc/x/xAddress.inline.hpp" -#include "gc/x/xGlobals.hpp" -#include "gc/x/xLiveMap.inline.hpp" -#include "gc/x/xNUMA.hpp" -#include "gc/x/xPhysicalMemory.inline.hpp" -#include "gc/x/xVirtualMemory.inline.hpp" -#include "runtime/atomic.hpp" -#include "runtime/os.hpp" -#include "utilities/align.hpp" -#include "utilities/checkedCast.hpp" -#include "utilities/debug.hpp" - -inline uint8_t XPage::type_from_size(size_t size) const { - if (size == XPageSizeSmall) { - return XPageTypeSmall; - } else if (size == XPageSizeMedium) { - return XPageTypeMedium; - } else { - return XPageTypeLarge; - } -} - -inline const char* XPage::type_to_string() const { - switch (type()) { - case XPageTypeSmall: - return "Small"; - - case XPageTypeMedium: - return "Medium"; - - default: - assert(type() == XPageTypeLarge, "Invalid page type"); - return "Large"; - } -} - -inline uint32_t XPage::object_max_count() const { - switch (type()) { - case XPageTypeLarge: - // A large page can only contain a single - // object aligned to the start of the page. - return 1; - - default: - return (uint32_t)(size() >> object_alignment_shift()); - } -} - -inline size_t XPage::object_alignment_shift() const { - switch (type()) { - case XPageTypeSmall: - return XObjectAlignmentSmallShift; - - case XPageTypeMedium: - return XObjectAlignmentMediumShift; - - default: - assert(type() == XPageTypeLarge, "Invalid page type"); - return XObjectAlignmentLargeShift; - } -} - -inline size_t XPage::object_alignment() const { - switch (type()) { - case XPageTypeSmall: - return XObjectAlignmentSmall; - - case XPageTypeMedium: - return XObjectAlignmentMedium; - - default: - assert(type() == XPageTypeLarge, "Invalid page type"); - return XObjectAlignmentLarge; - } -} - -inline uint8_t XPage::type() const { - return _type; -} - -inline uintptr_t XPage::start() const { - return _virtual.start(); -} - -inline uintptr_t XPage::end() const { - return _virtual.end(); -} - -inline size_t XPage::size() const { - return _virtual.size(); -} - -inline uintptr_t XPage::top() const { - return _top; -} - -inline size_t XPage::remaining() const { - return end() - top(); -} - -inline const XVirtualMemory& XPage::virtual_memory() const { - return _virtual; -} - -inline const XPhysicalMemory& XPage::physical_memory() const { - return _physical; -} - -inline XPhysicalMemory& XPage::physical_memory() { - return _physical; -} - -inline uint8_t XPage::numa_id() { - if (_numa_id == (uint8_t)-1) { - _numa_id = checked_cast(XNUMA::memory_id(XAddress::good(start()))); - } - - return _numa_id; -} - -inline bool XPage::is_allocating() const { - return _seqnum == XGlobalSeqNum; -} - -inline bool XPage::is_relocatable() const { - return _seqnum < XGlobalSeqNum; -} - -inline uint64_t XPage::last_used() const { - return _last_used; -} - -inline void XPage::set_last_used() { - _last_used = (uint64_t)ceil(os::elapsedTime()); -} - -inline bool XPage::is_in(uintptr_t addr) const { - const uintptr_t offset = XAddress::offset(addr); - return offset >= start() && offset < top(); -} - -inline bool XPage::is_marked() const { - assert(is_relocatable(), "Invalid page state"); - return _livemap.is_marked(); -} - -inline bool XPage::is_object_marked(uintptr_t addr) const { - assert(is_relocatable(), "Invalid page state"); - const size_t index = ((XAddress::offset(addr) - start()) >> object_alignment_shift()) * 2; - return _livemap.get(index); -} - -inline bool XPage::is_object_strongly_marked(uintptr_t addr) const { - assert(is_relocatable(), "Invalid page state"); - const size_t index = ((XAddress::offset(addr) - start()) >> object_alignment_shift()) * 2; - return _livemap.get(index + 1); -} - -template -inline bool XPage::is_object_marked(uintptr_t addr) const { - return finalizable ? is_object_marked(addr) : is_object_strongly_marked(addr); -} - -inline bool XPage::is_object_live(uintptr_t addr) const { - return is_allocating() || is_object_marked(addr); -} - -inline bool XPage::is_object_strongly_live(uintptr_t addr) const { - return is_allocating() || is_object_strongly_marked(addr); -} - -inline bool XPage::mark_object(uintptr_t addr, bool finalizable, bool& inc_live) { - assert(XAddress::is_marked(addr), "Invalid address"); - assert(is_relocatable(), "Invalid page state"); - assert(is_in(addr), "Invalid address"); - - // Set mark bit - const size_t index = ((XAddress::offset(addr) - start()) >> object_alignment_shift()) * 2; - return _livemap.set(index, finalizable, inc_live); -} - -inline void XPage::inc_live(uint32_t objects, size_t bytes) { - _livemap.inc_live(objects, bytes); -} - -inline uint32_t XPage::live_objects() const { - assert(is_marked(), "Should be marked"); - return _livemap.live_objects(); -} - -inline size_t XPage::live_bytes() const { - assert(is_marked(), "Should be marked"); - return _livemap.live_bytes(); -} - -inline void XPage::object_iterate(ObjectClosure* cl) { - _livemap.iterate(cl, XAddress::good(start()), object_alignment_shift()); -} - -inline uintptr_t XPage::alloc_object(size_t size) { - assert(is_allocating(), "Invalid state"); - - const size_t aligned_size = align_up(size, object_alignment()); - const uintptr_t addr = top(); - const uintptr_t new_top = addr + aligned_size; - - if (new_top > end()) { - // Not enough space left - return 0; - } - - _top = new_top; - - return XAddress::good(addr); -} - -inline uintptr_t XPage::alloc_object_atomic(size_t size) { - assert(is_allocating(), "Invalid state"); - - const size_t aligned_size = align_up(size, object_alignment()); - uintptr_t addr = top(); - - for (;;) { - const uintptr_t new_top = addr + aligned_size; - if (new_top > end()) { - // Not enough space left - return 0; - } - - const uintptr_t prev_top = Atomic::cmpxchg(&_top, addr, new_top); - if (prev_top == addr) { - // Success - return XAddress::good(addr); - } - - // Retry - addr = prev_top; - } -} - -inline bool XPage::undo_alloc_object(uintptr_t addr, size_t size) { - assert(is_allocating(), "Invalid state"); - - const uintptr_t offset = XAddress::offset(addr); - const size_t aligned_size = align_up(size, object_alignment()); - const uintptr_t old_top = top(); - const uintptr_t new_top = old_top - aligned_size; - - if (new_top != offset) { - // Failed to undo allocation, not the last allocated object - return false; - } - - _top = new_top; - - // Success - return true; -} - -inline bool XPage::undo_alloc_object_atomic(uintptr_t addr, size_t size) { - assert(is_allocating(), "Invalid state"); - - const uintptr_t offset = XAddress::offset(addr); - const size_t aligned_size = align_up(size, object_alignment()); - uintptr_t old_top = top(); - - for (;;) { - const uintptr_t new_top = old_top - aligned_size; - if (new_top != offset) { - // Failed to undo allocation, not the last allocated object - return false; - } - - const uintptr_t prev_top = Atomic::cmpxchg(&_top, old_top, new_top); - if (prev_top == old_top) { - // Success - return true; - } - - // Retry - old_top = prev_top; - } -} - -#endif // SHARE_GC_X_XPAGE_INLINE_HPP diff --git a/src/hotspot/share/gc/x/xPageAllocator.cpp b/src/hotspot/share/gc/x/xPageAllocator.cpp deleted file mode 100644 index ccc715682c0..00000000000 --- a/src/hotspot/share/gc/x/xPageAllocator.cpp +++ /dev/null @@ -1,870 +0,0 @@ -/* - * Copyright (c) 2015, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/shared/gcLogPrecious.hpp" -#include "gc/shared/suspendibleThreadSet.hpp" -#include "gc/x/xArray.inline.hpp" -#include "gc/x/xCollectedHeap.hpp" -#include "gc/x/xFuture.inline.hpp" -#include "gc/x/xGlobals.hpp" -#include "gc/x/xLock.inline.hpp" -#include "gc/x/xPage.inline.hpp" -#include "gc/x/xPageAllocator.inline.hpp" -#include "gc/x/xPageCache.hpp" -#include "gc/x/xSafeDelete.inline.hpp" -#include "gc/x/xStat.hpp" -#include "gc/x/xTask.hpp" -#include "gc/x/xUncommitter.hpp" -#include "gc/x/xUnmapper.hpp" -#include "gc/x/xWorkers.hpp" -#include "jfr/jfrEvents.hpp" -#include "logging/log.hpp" -#include "runtime/globals.hpp" -#include "runtime/init.hpp" -#include "runtime/java.hpp" -#include "utilities/debug.hpp" -#include "utilities/globalDefinitions.hpp" - -static const XStatCounter XCounterAllocationRate("Memory", "Allocation Rate", XStatUnitBytesPerSecond); -static const XStatCounter XCounterPageCacheFlush("Memory", "Page Cache Flush", XStatUnitBytesPerSecond); -static const XStatCounter XCounterDefragment("Memory", "Defragment", XStatUnitOpsPerSecond); -static const XStatCriticalPhase XCriticalPhaseAllocationStall("Allocation Stall"); - -enum XPageAllocationStall { - XPageAllocationStallSuccess, - XPageAllocationStallFailed, - XPageAllocationStallStartGC -}; - -class XPageAllocation : public StackObj { - friend class XList; - -private: - const uint8_t _type; - const size_t _size; - const XAllocationFlags _flags; - const uint32_t _seqnum; - size_t _flushed; - size_t _committed; - XList _pages; - XListNode _node; - XFuture _stall_result; - -public: - XPageAllocation(uint8_t type, size_t size, XAllocationFlags flags) : - _type(type), - _size(size), - _flags(flags), - _seqnum(XGlobalSeqNum), - _flushed(0), - _committed(0), - _pages(), - _node(), - _stall_result() {} - - uint8_t type() const { - return _type; - } - - size_t size() const { - return _size; - } - - XAllocationFlags flags() const { - return _flags; - } - - uint32_t seqnum() const { - return _seqnum; - } - - size_t flushed() const { - return _flushed; - } - - void set_flushed(size_t flushed) { - _flushed = flushed; - } - - size_t committed() const { - return _committed; - } - - void set_committed(size_t committed) { - _committed = committed; - } - - XPageAllocationStall wait() { - return _stall_result.get(); - } - - XList* pages() { - return &_pages; - } - - void satisfy(XPageAllocationStall result) { - _stall_result.set(result); - } -}; - -XPageAllocator::XPageAllocator(XWorkers* workers, - size_t min_capacity, - size_t initial_capacity, - size_t max_capacity) : - _lock(), - _cache(), - _virtual(max_capacity), - _physical(max_capacity), - _min_capacity(min_capacity), - _max_capacity(max_capacity), - _current_max_capacity(max_capacity), - _capacity(0), - _claimed(0), - _used(0), - _used_high(0), - _used_low(0), - _reclaimed(0), - _stalled(), - _nstalled(0), - _satisfied(), - _unmapper(new XUnmapper(this)), - _uncommitter(new XUncommitter(this)), - _safe_delete(), - _initialized(false) { - - if (!_virtual.is_initialized() || !_physical.is_initialized()) { - return; - } - - log_info_p(gc, init)("Min Capacity: " SIZE_FORMAT "M", min_capacity / M); - log_info_p(gc, init)("Initial Capacity: " SIZE_FORMAT "M", initial_capacity / M); - log_info_p(gc, init)("Max Capacity: " SIZE_FORMAT "M", max_capacity / M); - if (XPageSizeMedium > 0) { - log_info_p(gc, init)("Medium Page Size: " SIZE_FORMAT "M", XPageSizeMedium / M); - } else { - log_info_p(gc, init)("Medium Page Size: N/A"); - } - log_info_p(gc, init)("Pre-touch: %s", AlwaysPreTouch ? "Enabled" : "Disabled"); - - // Warn if system limits could stop us from reaching max capacity - _physical.warn_commit_limits(max_capacity); - - // Check if uncommit should and can be enabled - _physical.try_enable_uncommit(min_capacity, max_capacity); - - // Pre-map initial capacity - if (!prime_cache(workers, initial_capacity)) { - log_error_p(gc)("Failed to allocate initial Java heap (" SIZE_FORMAT "M)", initial_capacity / M); - return; - } - - // Successfully initialized - _initialized = true; -} - -class XPreTouchTask : public XTask { -private: - const XPhysicalMemoryManager* const _physical; - volatile uintptr_t _start; - const uintptr_t _end; - -public: - XPreTouchTask(const XPhysicalMemoryManager* physical, uintptr_t start, uintptr_t end) : - XTask("XPreTouchTask"), - _physical(physical), - _start(start), - _end(end) {} - - virtual void work() { - for (;;) { - // Get granule offset - const size_t size = XGranuleSize; - const uintptr_t offset = Atomic::fetch_then_add(&_start, size); - if (offset >= _end) { - // Done - break; - } - - // Pre-touch granule - _physical->pretouch(offset, size); - } - } -}; - -bool XPageAllocator::prime_cache(XWorkers* workers, size_t size) { - XAllocationFlags flags; - - flags.set_non_blocking(); - flags.set_low_address(); - - XPage* const page = alloc_page(XPageTypeLarge, size, flags); - if (page == nullptr) { - return false; - } - - if (AlwaysPreTouch) { - // Pre-touch page - XPreTouchTask task(&_physical, page->start(), page->end()); - workers->run_all(&task); - } - - free_page(page, false /* reclaimed */); - - return true; -} - -bool XPageAllocator::is_initialized() const { - return _initialized; -} - -size_t XPageAllocator::min_capacity() const { - return _min_capacity; -} - -size_t XPageAllocator::max_capacity() const { - return _max_capacity; -} - -size_t XPageAllocator::soft_max_capacity() const { - // Note that SoftMaxHeapSize is a manageable flag - const size_t soft_max_capacity = Atomic::load(&SoftMaxHeapSize); - const size_t current_max_capacity = Atomic::load(&_current_max_capacity); - return MIN2(soft_max_capacity, current_max_capacity); -} - -size_t XPageAllocator::capacity() const { - return Atomic::load(&_capacity); -} - -size_t XPageAllocator::used() const { - return Atomic::load(&_used); -} - -size_t XPageAllocator::unused() const { - const ssize_t capacity = (ssize_t)Atomic::load(&_capacity); - const ssize_t used = (ssize_t)Atomic::load(&_used); - const ssize_t claimed = (ssize_t)Atomic::load(&_claimed); - const ssize_t unused = capacity - used - claimed; - return unused > 0 ? (size_t)unused : 0; -} - -XPageAllocatorStats XPageAllocator::stats() const { - XLocker locker(&_lock); - return XPageAllocatorStats(_min_capacity, - _max_capacity, - soft_max_capacity(), - _capacity, - _used, - _used_high, - _used_low, - _reclaimed); -} - -void XPageAllocator::reset_statistics() { - assert(SafepointSynchronize::is_at_safepoint(), "Should be at safepoint"); - _reclaimed = 0; - _used_high = _used_low = _used; - _nstalled = 0; -} - -size_t XPageAllocator::increase_capacity(size_t size) { - const size_t increased = MIN2(size, _current_max_capacity - _capacity); - - if (increased > 0) { - // Update atomically since we have concurrent readers - Atomic::add(&_capacity, increased); - - // Record time of last commit. When allocation, we prefer increasing - // the capacity over flushing the cache. That means there could be - // expired pages in the cache at this time. However, since we are - // increasing the capacity we are obviously in need of committed - // memory and should therefore not be uncommitting memory. - _cache.set_last_commit(); - } - - return increased; -} - -void XPageAllocator::decrease_capacity(size_t size, bool set_max_capacity) { - // Update atomically since we have concurrent readers - Atomic::sub(&_capacity, size); - - if (set_max_capacity) { - // Adjust current max capacity to avoid further attempts to increase capacity - log_error_p(gc)("Forced to lower max Java heap size from " - SIZE_FORMAT "M(%.0f%%) to " SIZE_FORMAT "M(%.0f%%)", - _current_max_capacity / M, percent_of(_current_max_capacity, _max_capacity), - _capacity / M, percent_of(_capacity, _max_capacity)); - - // Update atomically since we have concurrent readers - Atomic::store(&_current_max_capacity, _capacity); - } -} - -void XPageAllocator::increase_used(size_t size, bool worker_relocation) { - if (worker_relocation) { - // Allocating a page for the purpose of worker relocation has - // a negative contribution to the number of reclaimed bytes. - _reclaimed -= size; - } - - // Update atomically since we have concurrent readers - const size_t used = Atomic::add(&_used, size); - if (used > _used_high) { - _used_high = used; - } -} - -void XPageAllocator::decrease_used(size_t size, bool reclaimed) { - // Only pages explicitly released with the reclaimed flag set - // counts as reclaimed bytes. This flag is true when we release - // a page after relocation, and is false when we release a page - // to undo an allocation. - if (reclaimed) { - _reclaimed += size; - } - - // Update atomically since we have concurrent readers - const size_t used = Atomic::sub(&_used, size); - if (used < _used_low) { - _used_low = used; - } -} - -bool XPageAllocator::commit_page(XPage* page) { - // Commit physical memory - return _physical.commit(page->physical_memory()); -} - -void XPageAllocator::uncommit_page(XPage* page) { - if (!ZUncommit) { - return; - } - - // Uncommit physical memory - _physical.uncommit(page->physical_memory()); -} - -void XPageAllocator::map_page(const XPage* page) const { - // Map physical memory - _physical.map(page->start(), page->physical_memory()); -} - -void XPageAllocator::unmap_page(const XPage* page) const { - // Unmap physical memory - _physical.unmap(page->start(), page->size()); -} - -void XPageAllocator::destroy_page(XPage* page) { - // Free virtual memory - _virtual.free(page->virtual_memory()); - - // Free physical memory - _physical.free(page->physical_memory()); - - // Delete page safely - _safe_delete(page); -} - -bool XPageAllocator::is_alloc_allowed(size_t size) const { - const size_t available = _current_max_capacity - _used - _claimed; - return available >= size; -} - -bool XPageAllocator::alloc_page_common_inner(uint8_t type, size_t size, XList* pages) { - if (!is_alloc_allowed(size)) { - // Out of memory - return false; - } - - // Try allocate from the page cache - XPage* const page = _cache.alloc_page(type, size); - if (page != nullptr) { - // Success - pages->insert_last(page); - return true; - } - - // Try increase capacity - const size_t increased = increase_capacity(size); - if (increased < size) { - // Could not increase capacity enough to satisfy the allocation - // completely. Flush the page cache to satisfy the remainder. - const size_t remaining = size - increased; - _cache.flush_for_allocation(remaining, pages); - } - - // Success - return true; -} - -bool XPageAllocator::alloc_page_common(XPageAllocation* allocation) { - const uint8_t type = allocation->type(); - const size_t size = allocation->size(); - const XAllocationFlags flags = allocation->flags(); - XList* const pages = allocation->pages(); - - if (!alloc_page_common_inner(type, size, pages)) { - // Out of memory - return false; - } - - // Updated used statistics - increase_used(size, flags.worker_relocation()); - - // Success - return true; -} - -static void check_out_of_memory_during_initialization() { - if (!is_init_completed()) { - vm_exit_during_initialization("java.lang.OutOfMemoryError", "Java heap too small"); - } -} - -bool XPageAllocator::alloc_page_stall(XPageAllocation* allocation) { - XStatTimer timer(XCriticalPhaseAllocationStall); - EventZAllocationStall event; - XPageAllocationStall result; - - // We can only block if the VM is fully initialized - check_out_of_memory_during_initialization(); - - // Increment stalled counter - Atomic::inc(&_nstalled); - - do { - // Start asynchronous GC - XCollectedHeap::heap()->collect(GCCause::_z_allocation_stall); - - // Wait for allocation to complete, fail or request a GC - result = allocation->wait(); - } while (result == XPageAllocationStallStartGC); - - { - // - // We grab the lock here for two different reasons: - // - // 1) Guard deletion of underlying semaphore. This is a workaround for - // a bug in sem_post() in glibc < 2.21, where it's not safe to destroy - // the semaphore immediately after returning from sem_wait(). The - // reason is that sem_post() can touch the semaphore after a waiting - // thread have returned from sem_wait(). To avoid this race we are - // forcing the waiting thread to acquire/release the lock held by the - // posting thread. https://sourceware.org/bugzilla/show_bug.cgi?id=12674 - // - // 2) Guard the list of satisfied pages. - // - XLocker locker(&_lock); - _satisfied.remove(allocation); - } - - // Send event - event.commit(allocation->type(), allocation->size()); - - return (result == XPageAllocationStallSuccess); -} - -bool XPageAllocator::alloc_page_or_stall(XPageAllocation* allocation) { - { - XLocker locker(&_lock); - - if (alloc_page_common(allocation)) { - // Success - return true; - } - - // Failed - if (allocation->flags().non_blocking()) { - // Don't stall - return false; - } - - // Enqueue allocation request - _stalled.insert_last(allocation); - } - - // Stall - return alloc_page_stall(allocation); -} - -XPage* XPageAllocator::alloc_page_create(XPageAllocation* allocation) { - const size_t size = allocation->size(); - - // Allocate virtual memory. To make error handling a lot more straight - // forward, we allocate virtual memory before destroying flushed pages. - // Flushed pages are also unmapped and destroyed asynchronously, so we - // can't immediately reuse that part of the address space anyway. - const XVirtualMemory vmem = _virtual.alloc(size, allocation->flags().low_address()); - if (vmem.is_null()) { - log_error(gc)("Out of address space"); - return nullptr; - } - - XPhysicalMemory pmem; - size_t flushed = 0; - - // Harvest physical memory from flushed pages - XListRemoveIterator iter(allocation->pages()); - for (XPage* page; iter.next(&page);) { - flushed += page->size(); - - // Harvest flushed physical memory - XPhysicalMemory& fmem = page->physical_memory(); - pmem.add_segments(fmem); - fmem.remove_segments(); - - // Unmap and destroy page - _unmapper->unmap_and_destroy_page(page); - } - - if (flushed > 0) { - allocation->set_flushed(flushed); - - // Update statistics - XStatInc(XCounterPageCacheFlush, flushed); - log_debug(gc, heap)("Page Cache Flushed: " SIZE_FORMAT "M", flushed / M); - } - - // Allocate any remaining physical memory. Capacity and used has - // already been adjusted, we just need to fetch the memory, which - // is guaranteed to succeed. - if (flushed < size) { - const size_t remaining = size - flushed; - allocation->set_committed(remaining); - _physical.alloc(pmem, remaining); - } - - // Create new page - return new XPage(allocation->type(), vmem, pmem); -} - -bool XPageAllocator::should_defragment(const XPage* page) const { - // A small page can end up at a high address (second half of the address space) - // if we've split a larger page or we have a constrained address space. To help - // fight address space fragmentation we remap such pages to a lower address, if - // a lower address is available. - return page->type() == XPageTypeSmall && - page->start() >= _virtual.reserved() / 2 && - page->start() > _virtual.lowest_available_address(); -} - -bool XPageAllocator::is_alloc_satisfied(XPageAllocation* allocation) const { - // The allocation is immediately satisfied if the list of pages contains - // exactly one page, with the type and size that was requested. However, - // even if the allocation is immediately satisfied we might still want to - // return false here to force the page to be remapped to fight address - // space fragmentation. - - if (allocation->pages()->size() != 1) { - // Not a single page - return false; - } - - const XPage* const page = allocation->pages()->first(); - if (page->type() != allocation->type() || - page->size() != allocation->size()) { - // Wrong type or size - return false; - } - - if (should_defragment(page)) { - // Defragment address space - XStatInc(XCounterDefragment); - return false; - } - - // Allocation immediately satisfied - return true; -} - -XPage* XPageAllocator::alloc_page_finalize(XPageAllocation* allocation) { - // Fast path - if (is_alloc_satisfied(allocation)) { - return allocation->pages()->remove_first(); - } - - // Slow path - XPage* const page = alloc_page_create(allocation); - if (page == nullptr) { - // Out of address space - return nullptr; - } - - // Commit page - if (commit_page(page)) { - // Success - map_page(page); - return page; - } - - // Failed or partially failed. Split of any successfully committed - // part of the page into a new page and insert it into list of pages, - // so that it will be re-inserted into the page cache. - XPage* const committed_page = page->split_committed(); - destroy_page(page); - - if (committed_page != nullptr) { - map_page(committed_page); - allocation->pages()->insert_last(committed_page); - } - - return nullptr; -} - -void XPageAllocator::alloc_page_failed(XPageAllocation* allocation) { - XLocker locker(&_lock); - - size_t freed = 0; - - // Free any allocated/flushed pages - XListRemoveIterator iter(allocation->pages()); - for (XPage* page; iter.next(&page);) { - freed += page->size(); - free_page_inner(page, false /* reclaimed */); - } - - // Adjust capacity and used to reflect the failed capacity increase - const size_t remaining = allocation->size() - freed; - decrease_used(remaining, false /* reclaimed */); - decrease_capacity(remaining, true /* set_max_capacity */); - - // Try satisfy stalled allocations - satisfy_stalled(); -} - -XPage* XPageAllocator::alloc_page(uint8_t type, size_t size, XAllocationFlags flags) { - EventZPageAllocation event; - -retry: - XPageAllocation allocation(type, size, flags); - - // Allocate one or more pages from the page cache. If the allocation - // succeeds but the returned pages don't cover the complete allocation, - // then finalize phase is allowed to allocate the remaining memory - // directly from the physical memory manager. Note that this call might - // block in a safepoint if the non-blocking flag is not set. - if (!alloc_page_or_stall(&allocation)) { - // Out of memory - return nullptr; - } - - XPage* const page = alloc_page_finalize(&allocation); - if (page == nullptr) { - // Failed to commit or map. Clean up and retry, in the hope that - // we can still allocate by flushing the page cache (more aggressively). - alloc_page_failed(&allocation); - goto retry; - } - - // Reset page. This updates the page's sequence number and must - // be done after we potentially blocked in a safepoint (stalled) - // where the global sequence number was updated. - page->reset(); - - // Update allocation statistics. Exclude worker relocations to avoid - // artificial inflation of the allocation rate during relocation. - if (!flags.worker_relocation() && is_init_completed()) { - // Note that there are two allocation rate counters, which have - // different purposes and are sampled at different frequencies. - const size_t bytes = page->size(); - XStatInc(XCounterAllocationRate, bytes); - XStatInc(XStatAllocRate::counter(), bytes); - } - - // Send event - event.commit(type, size, allocation.flushed(), allocation.committed(), - page->physical_memory().nsegments(), flags.non_blocking()); - - return page; -} - -void XPageAllocator::satisfy_stalled() { - for (;;) { - XPageAllocation* const allocation = _stalled.first(); - if (allocation == nullptr) { - // Allocation queue is empty - return; - } - - if (!alloc_page_common(allocation)) { - // Allocation could not be satisfied, give up - return; - } - - // Allocation succeeded, dequeue and satisfy allocation request. - // Note that we must dequeue the allocation request first, since - // it will immediately be deallocated once it has been satisfied. - _stalled.remove(allocation); - _satisfied.insert_last(allocation); - allocation->satisfy(XPageAllocationStallSuccess); - } -} - -void XPageAllocator::free_page_inner(XPage* page, bool reclaimed) { - // Update used statistics - decrease_used(page->size(), reclaimed); - - // Set time when last used - page->set_last_used(); - - // Cache page - _cache.free_page(page); -} - -void XPageAllocator::free_page(XPage* page, bool reclaimed) { - XLocker locker(&_lock); - - // Free page - free_page_inner(page, reclaimed); - - // Try satisfy stalled allocations - satisfy_stalled(); -} - -void XPageAllocator::free_pages(const XArray* pages, bool reclaimed) { - XLocker locker(&_lock); - - // Free pages - XArrayIterator iter(pages); - for (XPage* page; iter.next(&page);) { - free_page_inner(page, reclaimed); - } - - // Try satisfy stalled allocations - satisfy_stalled(); -} - -size_t XPageAllocator::uncommit(uint64_t* timeout) { - // We need to join the suspendible thread set while manipulating capacity and - // used, to make sure GC safepoints will have a consistent view. However, when - // ZVerifyViews is enabled we need to join at a broader scope to also make sure - // we don't change the address good mask after pages have been flushed, and - // thereby made invisible to pages_do(), but before they have been unmapped. - SuspendibleThreadSetJoiner joiner(ZVerifyViews); - XList pages; - size_t flushed; - - { - SuspendibleThreadSetJoiner joiner(!ZVerifyViews); - XLocker locker(&_lock); - - // Never uncommit below min capacity. We flush out and uncommit chunks at - // a time (~0.8% of the max capacity, but at least one granule and at most - // 256M), in case demand for memory increases while we are uncommitting. - const size_t retain = MAX2(_used, _min_capacity); - const size_t release = _capacity - retain; - const size_t limit = MIN2(align_up(_current_max_capacity >> 7, XGranuleSize), 256 * M); - const size_t flush = MIN2(release, limit); - - // Flush pages to uncommit - flushed = _cache.flush_for_uncommit(flush, &pages, timeout); - if (flushed == 0) { - // Nothing flushed - return 0; - } - - // Record flushed pages as claimed - Atomic::add(&_claimed, flushed); - } - - // Unmap, uncommit, and destroy flushed pages - XListRemoveIterator iter(&pages); - for (XPage* page; iter.next(&page);) { - unmap_page(page); - uncommit_page(page); - destroy_page(page); - } - - { - SuspendibleThreadSetJoiner joiner(!ZVerifyViews); - XLocker locker(&_lock); - - // Adjust claimed and capacity to reflect the uncommit - Atomic::sub(&_claimed, flushed); - decrease_capacity(flushed, false /* set_max_capacity */); - } - - return flushed; -} - -void XPageAllocator::enable_deferred_delete() const { - _safe_delete.enable_deferred_delete(); -} - -void XPageAllocator::disable_deferred_delete() const { - _safe_delete.disable_deferred_delete(); -} - -void XPageAllocator::debug_map_page(const XPage* page) const { - assert(SafepointSynchronize::is_at_safepoint(), "Should be at safepoint"); - _physical.debug_map(page->start(), page->physical_memory()); -} - -void XPageAllocator::debug_unmap_page(const XPage* page) const { - assert(SafepointSynchronize::is_at_safepoint(), "Should be at safepoint"); - _physical.debug_unmap(page->start(), page->size()); -} - -void XPageAllocator::pages_do(XPageClosure* cl) const { - assert(SafepointSynchronize::is_at_safepoint(), "Should be at safepoint"); - - XListIterator iter_satisfied(&_satisfied); - for (XPageAllocation* allocation; iter_satisfied.next(&allocation);) { - XListIterator iter_pages(allocation->pages()); - for (XPage* page; iter_pages.next(&page);) { - cl->do_page(page); - } - } - - _cache.pages_do(cl); -} - -bool XPageAllocator::has_alloc_stalled() const { - return Atomic::load(&_nstalled) != 0; -} - -void XPageAllocator::check_out_of_memory() { - XLocker locker(&_lock); - - // Fail allocation requests that were enqueued before the - // last GC cycle started, otherwise start a new GC cycle. - for (XPageAllocation* allocation = _stalled.first(); allocation != nullptr; allocation = _stalled.first()) { - if (allocation->seqnum() == XGlobalSeqNum) { - // Start a new GC cycle, keep allocation requests enqueued - allocation->satisfy(XPageAllocationStallStartGC); - return; - } - - // Out of memory, fail allocation request - _stalled.remove(allocation); - _satisfied.insert_last(allocation); - allocation->satisfy(XPageAllocationStallFailed); - } -} - -void XPageAllocator::threads_do(ThreadClosure* tc) const { - tc->do_thread(_unmapper); - tc->do_thread(_uncommitter); -} diff --git a/src/hotspot/share/gc/x/xPageAllocator.hpp b/src/hotspot/share/gc/x/xPageAllocator.hpp deleted file mode 100644 index b907e50043d..00000000000 --- a/src/hotspot/share/gc/x/xPageAllocator.hpp +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Copyright (c) 2015, 2021, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XPAGEALLOCATOR_HPP -#define SHARE_GC_X_XPAGEALLOCATOR_HPP - -#include "gc/x/xAllocationFlags.hpp" -#include "gc/x/xArray.hpp" -#include "gc/x/xList.hpp" -#include "gc/x/xLock.hpp" -#include "gc/x/xPageCache.hpp" -#include "gc/x/xPhysicalMemory.hpp" -#include "gc/x/xSafeDelete.hpp" -#include "gc/x/xVirtualMemory.hpp" - -class ThreadClosure; -class VMStructs; -class XPageAllocation; -class XPageAllocatorStats; -class XWorkers; -class XUncommitter; -class XUnmapper; - -class XPageAllocator { - friend class ::VMStructs; - friend class XUnmapper; - friend class XUncommitter; - -private: - mutable XLock _lock; - XPageCache _cache; - XVirtualMemoryManager _virtual; - XPhysicalMemoryManager _physical; - const size_t _min_capacity; - const size_t _max_capacity; - volatile size_t _current_max_capacity; - volatile size_t _capacity; - volatile size_t _claimed; - volatile size_t _used; - size_t _used_high; - size_t _used_low; - ssize_t _reclaimed; - XList _stalled; - volatile uint64_t _nstalled; - XList _satisfied; - XUnmapper* _unmapper; - XUncommitter* _uncommitter; - mutable XSafeDelete _safe_delete; - bool _initialized; - - bool prime_cache(XWorkers* workers, size_t size); - - size_t increase_capacity(size_t size); - void decrease_capacity(size_t size, bool set_max_capacity); - - void increase_used(size_t size, bool relocation); - void decrease_used(size_t size, bool reclaimed); - - bool commit_page(XPage* page); - void uncommit_page(XPage* page); - - void map_page(const XPage* page) const; - void unmap_page(const XPage* page) const; - - void destroy_page(XPage* page); - - bool is_alloc_allowed(size_t size) const; - - bool alloc_page_common_inner(uint8_t type, size_t size, XList* pages); - bool alloc_page_common(XPageAllocation* allocation); - bool alloc_page_stall(XPageAllocation* allocation); - bool alloc_page_or_stall(XPageAllocation* allocation); - bool should_defragment(const XPage* page) const; - bool is_alloc_satisfied(XPageAllocation* allocation) const; - XPage* alloc_page_create(XPageAllocation* allocation); - XPage* alloc_page_finalize(XPageAllocation* allocation); - void alloc_page_failed(XPageAllocation* allocation); - - void satisfy_stalled(); - - void free_page_inner(XPage* page, bool reclaimed); - - size_t uncommit(uint64_t* timeout); - -public: - XPageAllocator(XWorkers* workers, - size_t min_capacity, - size_t initial_capacity, - size_t max_capacity); - - bool is_initialized() const; - - size_t min_capacity() const; - size_t max_capacity() const; - size_t soft_max_capacity() const; - size_t capacity() const; - size_t used() const; - size_t unused() const; - - XPageAllocatorStats stats() const; - - void reset_statistics(); - - XPage* alloc_page(uint8_t type, size_t size, XAllocationFlags flags); - void free_page(XPage* page, bool reclaimed); - void free_pages(const XArray* pages, bool reclaimed); - - void enable_deferred_delete() const; - void disable_deferred_delete() const; - - void debug_map_page(const XPage* page) const; - void debug_unmap_page(const XPage* page) const; - - bool has_alloc_stalled() const; - void check_out_of_memory(); - - void pages_do(XPageClosure* cl) const; - - void threads_do(ThreadClosure* tc) const; -}; - -class XPageAllocatorStats { -private: - size_t _min_capacity; - size_t _max_capacity; - size_t _soft_max_capacity; - size_t _current_max_capacity; - size_t _capacity; - size_t _used; - size_t _used_high; - size_t _used_low; - size_t _reclaimed; - -public: - XPageAllocatorStats(size_t min_capacity, - size_t max_capacity, - size_t soft_max_capacity, - size_t capacity, - size_t used, - size_t used_high, - size_t used_low, - size_t reclaimed); - - size_t min_capacity() const; - size_t max_capacity() const; - size_t soft_max_capacity() const; - size_t capacity() const; - size_t used() const; - size_t used_high() const; - size_t used_low() const; - size_t reclaimed() const; -}; - -#endif // SHARE_GC_X_XPAGEALLOCATOR_HPP diff --git a/src/hotspot/share/gc/x/xPageAllocator.inline.hpp b/src/hotspot/share/gc/x/xPageAllocator.inline.hpp deleted file mode 100644 index dbaf77f56a0..00000000000 --- a/src/hotspot/share/gc/x/xPageAllocator.inline.hpp +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 2020, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XPAGEALLOCATOR_INLINE_HPP -#define SHARE_GC_X_XPAGEALLOCATOR_INLINE_HPP - -#include "gc/x/xPageAllocator.hpp" - -inline XPageAllocatorStats::XPageAllocatorStats(size_t min_capacity, - size_t max_capacity, - size_t soft_max_capacity, - size_t capacity, - size_t used, - size_t used_high, - size_t used_low, - size_t reclaimed) : - _min_capacity(min_capacity), - _max_capacity(max_capacity), - _soft_max_capacity(soft_max_capacity), - _capacity(capacity), - _used(used), - _used_high(used_high), - _used_low(used_low), - _reclaimed(reclaimed) {} - -inline size_t XPageAllocatorStats::min_capacity() const { - return _min_capacity; -} - -inline size_t XPageAllocatorStats::max_capacity() const { - return _max_capacity; -} - -inline size_t XPageAllocatorStats::soft_max_capacity() const { - return _soft_max_capacity; -} - -inline size_t XPageAllocatorStats::capacity() const { - return _capacity; -} - -inline size_t XPageAllocatorStats::used() const { - return _used; -} - -inline size_t XPageAllocatorStats::used_high() const { - return _used_high; -} - -inline size_t XPageAllocatorStats::used_low() const { - return _used_low; -} - -inline size_t XPageAllocatorStats::reclaimed() const { - return _reclaimed; -} - -#endif // SHARE_GC_X_XPAGEALLOCATOR_INLINE_HPP diff --git a/src/hotspot/share/gc/x/xPageCache.cpp b/src/hotspot/share/gc/x/xPageCache.cpp deleted file mode 100644 index d38b0646a8a..00000000000 --- a/src/hotspot/share/gc/x/xPageCache.cpp +++ /dev/null @@ -1,356 +0,0 @@ -/* - * Copyright (c) 2015, 2020, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/x/xGlobals.hpp" -#include "gc/x/xList.inline.hpp" -#include "gc/x/xNUMA.hpp" -#include "gc/x/xPage.inline.hpp" -#include "gc/x/xPageCache.hpp" -#include "gc/x/xStat.hpp" -#include "gc/x/xValue.inline.hpp" -#include "memory/allocation.hpp" -#include "runtime/globals.hpp" -#include "runtime/os.hpp" - -static const XStatCounter XCounterPageCacheHitL1("Memory", "Page Cache Hit L1", XStatUnitOpsPerSecond); -static const XStatCounter XCounterPageCacheHitL2("Memory", "Page Cache Hit L2", XStatUnitOpsPerSecond); -static const XStatCounter XCounterPageCacheHitL3("Memory", "Page Cache Hit L3", XStatUnitOpsPerSecond); -static const XStatCounter XCounterPageCacheMiss("Memory", "Page Cache Miss", XStatUnitOpsPerSecond); - -class XPageCacheFlushClosure : public StackObj { - friend class XPageCache; - -protected: - const size_t _requested; - size_t _flushed; - -public: - XPageCacheFlushClosure(size_t requested); - virtual bool do_page(const XPage* page) = 0; -}; - -XPageCacheFlushClosure::XPageCacheFlushClosure(size_t requested) : - _requested(requested), - _flushed(0) {} - -XPageCache::XPageCache() : - _small(), - _medium(), - _large(), - _last_commit(0) {} - -XPage* XPageCache::alloc_small_page() { - const uint32_t numa_id = XNUMA::id(); - const uint32_t numa_count = XNUMA::count(); - - // Try NUMA local page cache - XPage* const l1_page = _small.get(numa_id).remove_first(); - if (l1_page != nullptr) { - XStatInc(XCounterPageCacheHitL1); - return l1_page; - } - - // Try NUMA remote page cache(s) - uint32_t remote_numa_id = numa_id + 1; - const uint32_t remote_numa_count = numa_count - 1; - for (uint32_t i = 0; i < remote_numa_count; i++) { - if (remote_numa_id == numa_count) { - remote_numa_id = 0; - } - - XPage* const l2_page = _small.get(remote_numa_id).remove_first(); - if (l2_page != nullptr) { - XStatInc(XCounterPageCacheHitL2); - return l2_page; - } - - remote_numa_id++; - } - - return nullptr; -} - -XPage* XPageCache::alloc_medium_page() { - XPage* const page = _medium.remove_first(); - if (page != nullptr) { - XStatInc(XCounterPageCacheHitL1); - return page; - } - - return nullptr; -} - -XPage* XPageCache::alloc_large_page(size_t size) { - // Find a page with the right size - XListIterator iter(&_large); - for (XPage* page; iter.next(&page);) { - if (size == page->size()) { - // Page found - _large.remove(page); - XStatInc(XCounterPageCacheHitL1); - return page; - } - } - - return nullptr; -} - -XPage* XPageCache::alloc_oversized_medium_page(size_t size) { - if (size <= XPageSizeMedium) { - return _medium.remove_first(); - } - - return nullptr; -} - -XPage* XPageCache::alloc_oversized_large_page(size_t size) { - // Find a page that is large enough - XListIterator iter(&_large); - for (XPage* page; iter.next(&page);) { - if (size <= page->size()) { - // Page found - _large.remove(page); - return page; - } - } - - return nullptr; -} - -XPage* XPageCache::alloc_oversized_page(size_t size) { - XPage* page = alloc_oversized_large_page(size); - if (page == nullptr) { - page = alloc_oversized_medium_page(size); - } - - if (page != nullptr) { - XStatInc(XCounterPageCacheHitL3); - } - - return page; -} - -XPage* XPageCache::alloc_page(uint8_t type, size_t size) { - XPage* page; - - // Try allocate exact page - if (type == XPageTypeSmall) { - page = alloc_small_page(); - } else if (type == XPageTypeMedium) { - page = alloc_medium_page(); - } else { - page = alloc_large_page(size); - } - - if (page == nullptr) { - // Try allocate potentially oversized page - XPage* const oversized = alloc_oversized_page(size); - if (oversized != nullptr) { - if (size < oversized->size()) { - // Split oversized page - page = oversized->split(type, size); - - // Cache remainder - free_page(oversized); - } else { - // Re-type correctly sized page - page = oversized->retype(type); - } - } - } - - if (page == nullptr) { - XStatInc(XCounterPageCacheMiss); - } - - return page; -} - -void XPageCache::free_page(XPage* page) { - const uint8_t type = page->type(); - if (type == XPageTypeSmall) { - _small.get(page->numa_id()).insert_first(page); - } else if (type == XPageTypeMedium) { - _medium.insert_first(page); - } else { - _large.insert_first(page); - } -} - -bool XPageCache::flush_list_inner(XPageCacheFlushClosure* cl, XList* from, XList* to) { - XPage* const page = from->last(); - if (page == nullptr || !cl->do_page(page)) { - // Don't flush page - return false; - } - - // Flush page - from->remove(page); - to->insert_last(page); - return true; -} - -void XPageCache::flush_list(XPageCacheFlushClosure* cl, XList* from, XList* to) { - while (flush_list_inner(cl, from, to)); -} - -void XPageCache::flush_per_numa_lists(XPageCacheFlushClosure* cl, XPerNUMA >* from, XList* to) { - const uint32_t numa_count = XNUMA::count(); - uint32_t numa_done = 0; - uint32_t numa_next = 0; - - // Flush lists round-robin - while (numa_done < numa_count) { - XList* numa_list = from->addr(numa_next); - if (++numa_next == numa_count) { - numa_next = 0; - } - - if (flush_list_inner(cl, numa_list, to)) { - // Not done - numa_done = 0; - } else { - // Done - numa_done++; - } - } -} - -void XPageCache::flush(XPageCacheFlushClosure* cl, XList* to) { - // Prefer flushing large, then medium and last small pages - flush_list(cl, &_large, to); - flush_list(cl, &_medium, to); - flush_per_numa_lists(cl, &_small, to); - - if (cl->_flushed > cl->_requested) { - // Overflushed, re-insert part of last page into the cache - const size_t overflushed = cl->_flushed - cl->_requested; - XPage* const reinsert = to->last()->split(overflushed); - free_page(reinsert); - cl->_flushed -= overflushed; - } -} - -class XPageCacheFlushForAllocationClosure : public XPageCacheFlushClosure { -public: - XPageCacheFlushForAllocationClosure(size_t requested) : - XPageCacheFlushClosure(requested) {} - - virtual bool do_page(const XPage* page) { - if (_flushed < _requested) { - // Flush page - _flushed += page->size(); - return true; - } - - // Don't flush page - return false; - } -}; - -void XPageCache::flush_for_allocation(size_t requested, XList* to) { - XPageCacheFlushForAllocationClosure cl(requested); - flush(&cl, to); -} - -class XPageCacheFlushForUncommitClosure : public XPageCacheFlushClosure { -private: - const uint64_t _now; - uint64_t* _timeout; - -public: - XPageCacheFlushForUncommitClosure(size_t requested, uint64_t now, uint64_t* timeout) : - XPageCacheFlushClosure(requested), - _now(now), - _timeout(timeout) { - // Set initial timeout - *_timeout = ZUncommitDelay; - } - - virtual bool do_page(const XPage* page) { - const uint64_t expires = page->last_used() + ZUncommitDelay; - if (expires > _now) { - // Don't flush page, record shortest non-expired timeout - *_timeout = MIN2(*_timeout, expires - _now); - return false; - } - - if (_flushed >= _requested) { - // Don't flush page, requested amount flushed - return false; - } - - // Flush page - _flushed += page->size(); - return true; - } -}; - -size_t XPageCache::flush_for_uncommit(size_t requested, XList* to, uint64_t* timeout) { - const uint64_t now = os::elapsedTime(); - const uint64_t expires = _last_commit + ZUncommitDelay; - if (expires > now) { - // Delay uncommit, set next timeout - *timeout = expires - now; - return 0; - } - - if (requested == 0) { - // Nothing to flush, set next timeout - *timeout = ZUncommitDelay; - return 0; - } - - XPageCacheFlushForUncommitClosure cl(requested, now, timeout); - flush(&cl, to); - - return cl._flushed; -} - -void XPageCache::set_last_commit() { - _last_commit = ceil(os::elapsedTime()); -} - -void XPageCache::pages_do(XPageClosure* cl) const { - // Small - XPerNUMAConstIterator > iter_numa(&_small); - for (const XList* list; iter_numa.next(&list);) { - XListIterator iter_small(list); - for (XPage* page; iter_small.next(&page);) { - cl->do_page(page); - } - } - - // Medium - XListIterator iter_medium(&_medium); - for (XPage* page; iter_medium.next(&page);) { - cl->do_page(page); - } - - // Large - XListIterator iter_large(&_large); - for (XPage* page; iter_large.next(&page);) { - cl->do_page(page); - } -} diff --git a/src/hotspot/share/gc/x/xPageCache.hpp b/src/hotspot/share/gc/x/xPageCache.hpp deleted file mode 100644 index 9ed80a933f4..00000000000 --- a/src/hotspot/share/gc/x/xPageCache.hpp +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2015, 2020, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XPAGECACHE_HPP -#define SHARE_GC_X_XPAGECACHE_HPP - -#include "gc/x/xList.hpp" -#include "gc/x/xPage.hpp" -#include "gc/x/xValue.hpp" - -class XPageCacheFlushClosure; - -class XPageCache { -private: - XPerNUMA > _small; - XList _medium; - XList _large; - uint64_t _last_commit; - - XPage* alloc_small_page(); - XPage* alloc_medium_page(); - XPage* alloc_large_page(size_t size); - - XPage* alloc_oversized_medium_page(size_t size); - XPage* alloc_oversized_large_page(size_t size); - XPage* alloc_oversized_page(size_t size); - - bool flush_list_inner(XPageCacheFlushClosure* cl, XList* from, XList* to); - void flush_list(XPageCacheFlushClosure* cl, XList* from, XList* to); - void flush_per_numa_lists(XPageCacheFlushClosure* cl, XPerNUMA >* from, XList* to); - void flush(XPageCacheFlushClosure* cl, XList* to); - -public: - XPageCache(); - - XPage* alloc_page(uint8_t type, size_t size); - void free_page(XPage* page); - - void flush_for_allocation(size_t requested, XList* to); - size_t flush_for_uncommit(size_t requested, XList* to, uint64_t* timeout); - - void set_last_commit(); - - void pages_do(XPageClosure* cl) const; -}; - -#endif // SHARE_GC_X_XPAGECACHE_HPP diff --git a/src/hotspot/share/gc/x/xPageTable.cpp b/src/hotspot/share/gc/x/xPageTable.cpp deleted file mode 100644 index c3103e808ca..00000000000 --- a/src/hotspot/share/gc/x/xPageTable.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2015, 2019, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/x/xGlobals.hpp" -#include "gc/x/xGranuleMap.inline.hpp" -#include "gc/x/xPage.inline.hpp" -#include "gc/x/xPageTable.inline.hpp" -#include "runtime/orderAccess.hpp" -#include "utilities/debug.hpp" - -XPageTable::XPageTable() : - _map(XAddressOffsetMax) {} - -void XPageTable::insert(XPage* page) { - const uintptr_t offset = page->start(); - const size_t size = page->size(); - - // Make sure a newly created page is - // visible before updating the page table. - OrderAccess::storestore(); - - assert(_map.get(offset) == nullptr, "Invalid entry"); - _map.put(offset, size, page); -} - -void XPageTable::remove(XPage* page) { - const uintptr_t offset = page->start(); - const size_t size = page->size(); - - assert(_map.get(offset) == page, "Invalid entry"); - _map.put(offset, size, nullptr); -} diff --git a/src/hotspot/share/gc/x/xPageTable.hpp b/src/hotspot/share/gc/x/xPageTable.hpp deleted file mode 100644 index 958dd735557..00000000000 --- a/src/hotspot/share/gc/x/xPageTable.hpp +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2015, 2019, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XPAGETABLE_HPP -#define SHARE_GC_X_XPAGETABLE_HPP - -#include "gc/x/xGranuleMap.hpp" -#include "memory/allocation.hpp" - -class VMStructs; -class XPage; -class XPageTableIterator; - -class XPageTable { - friend class ::VMStructs; - friend class XPageTableIterator; - -private: - XGranuleMap _map; - -public: - XPageTable(); - - XPage* get(uintptr_t addr) const; - - void insert(XPage* page); - void remove(XPage* page); -}; - -class XPageTableIterator : public StackObj { -private: - XGranuleMapIterator _iter; - XPage* _prev; - -public: - XPageTableIterator(const XPageTable* page_table); - - bool next(XPage** page); -}; - -#endif // SHARE_GC_X_XPAGETABLE_HPP diff --git a/src/hotspot/share/gc/x/xPageTable.inline.hpp b/src/hotspot/share/gc/x/xPageTable.inline.hpp deleted file mode 100644 index 65ad223e334..00000000000 --- a/src/hotspot/share/gc/x/xPageTable.inline.hpp +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright (c) 2015, 2019, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XPAGETABLE_INLINE_HPP -#define SHARE_GC_X_XPAGETABLE_INLINE_HPP - -#include "gc/x/xPageTable.hpp" - -#include "gc/x/xAddress.inline.hpp" -#include "gc/x/xGranuleMap.inline.hpp" - -inline XPage* XPageTable::get(uintptr_t addr) const { - assert(!XAddress::is_null(addr), "Invalid address"); - return _map.get(XAddress::offset(addr)); -} - -inline XPageTableIterator::XPageTableIterator(const XPageTable* page_table) : - _iter(&page_table->_map), - _prev(nullptr) {} - -inline bool XPageTableIterator::next(XPage** page) { - for (XPage* entry; _iter.next(&entry);) { - if (entry != nullptr && entry != _prev) { - // Next page found - *page = _prev = entry; - return true; - } - } - - // No more pages - return false; -} - -#endif // SHARE_GC_X_XPAGETABLE_INLINE_HPP diff --git a/src/hotspot/share/gc/x/xPhysicalMemory.cpp b/src/hotspot/share/gc/x/xPhysicalMemory.cpp deleted file mode 100644 index 0269c64f0f1..00000000000 --- a/src/hotspot/share/gc/x/xPhysicalMemory.cpp +++ /dev/null @@ -1,434 +0,0 @@ -/* - * Copyright (c) 2015, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/shared/gcLogPrecious.hpp" -#include "gc/x/xAddress.inline.hpp" -#include "gc/x/xArray.inline.hpp" -#include "gc/x/xGlobals.hpp" -#include "gc/x/xLargePages.inline.hpp" -#include "gc/x/xList.inline.hpp" -#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 "utilities/align.hpp" -#include "utilities/debug.hpp" -#include "utilities/globalDefinitions.hpp" -#include "utilities/powerOfTwo.hpp" - -XPhysicalMemory::XPhysicalMemory() : - _segments() {} - -XPhysicalMemory::XPhysicalMemory(const XPhysicalMemorySegment& segment) : - _segments() { - add_segment(segment); -} - -XPhysicalMemory::XPhysicalMemory(const XPhysicalMemory& pmem) : - _segments() { - add_segments(pmem); -} - -const XPhysicalMemory& XPhysicalMemory::operator=(const XPhysicalMemory& pmem) { - // Free segments - _segments.clear_and_deallocate(); - - // Copy segments - add_segments(pmem); - - return *this; -} - -size_t XPhysicalMemory::size() const { - size_t size = 0; - - for (int i = 0; i < _segments.length(); i++) { - size += _segments.at(i).size(); - } - - return size; -} - -void XPhysicalMemory::insert_segment(int index, uintptr_t start, size_t size, bool committed) { - _segments.insert_before(index, XPhysicalMemorySegment(start, size, committed)); -} - -void XPhysicalMemory::replace_segment(int index, uintptr_t start, size_t size, bool committed) { - _segments.at_put(index, XPhysicalMemorySegment(start, size, committed)); -} - -void XPhysicalMemory::remove_segment(int index) { - _segments.remove_at(index); -} - -void XPhysicalMemory::add_segments(const XPhysicalMemory& pmem) { - for (int i = 0; i < pmem.nsegments(); i++) { - add_segment(pmem.segment(i)); - } -} - -void XPhysicalMemory::remove_segments() { - _segments.clear_and_deallocate(); -} - -static bool is_mergable(const XPhysicalMemorySegment& before, const XPhysicalMemorySegment& after) { - return before.end() == after.start() && before.is_committed() == after.is_committed(); -} - -void XPhysicalMemory::add_segment(const XPhysicalMemorySegment& segment) { - // Insert segments in address order, merge segments when possible - for (int i = _segments.length(); i > 0; i--) { - const int current = i - 1; - - if (_segments.at(current).end() <= segment.start()) { - if (is_mergable(_segments.at(current), segment)) { - if (current + 1 < _segments.length() && is_mergable(segment, _segments.at(current + 1))) { - // Merge with end of current segment and start of next segment - const size_t start = _segments.at(current).start(); - const size_t size = _segments.at(current).size() + segment.size() + _segments.at(current + 1).size(); - replace_segment(current, start, size, segment.is_committed()); - remove_segment(current + 1); - return; - } - - // Merge with end of current segment - const size_t start = _segments.at(current).start(); - const size_t size = _segments.at(current).size() + segment.size(); - replace_segment(current, start, size, segment.is_committed()); - return; - } else if (current + 1 < _segments.length() && is_mergable(segment, _segments.at(current + 1))) { - // Merge with start of next segment - const size_t start = segment.start(); - const size_t size = segment.size() + _segments.at(current + 1).size(); - replace_segment(current + 1, start, size, segment.is_committed()); - return; - } - - // Insert after current segment - insert_segment(current + 1, segment.start(), segment.size(), segment.is_committed()); - return; - } - } - - if (_segments.length() > 0 && is_mergable(segment, _segments.at(0))) { - // Merge with start of first segment - const size_t start = segment.start(); - const size_t size = segment.size() + _segments.at(0).size(); - replace_segment(0, start, size, segment.is_committed()); - return; - } - - // Insert before first segment - insert_segment(0, segment.start(), segment.size(), segment.is_committed()); -} - -bool XPhysicalMemory::commit_segment(int index, size_t size) { - assert(size <= _segments.at(index).size(), "Invalid size"); - assert(!_segments.at(index).is_committed(), "Invalid state"); - - if (size == _segments.at(index).size()) { - // Completely committed - _segments.at(index).set_committed(true); - return true; - } - - if (size > 0) { - // Partially committed, split segment - insert_segment(index + 1, _segments.at(index).start() + size, _segments.at(index).size() - size, false /* committed */); - replace_segment(index, _segments.at(index).start(), size, true /* committed */); - } - - return false; -} - -bool XPhysicalMemory::uncommit_segment(int index, size_t size) { - assert(size <= _segments.at(index).size(), "Invalid size"); - assert(_segments.at(index).is_committed(), "Invalid state"); - - if (size == _segments.at(index).size()) { - // Completely uncommitted - _segments.at(index).set_committed(false); - return true; - } - - if (size > 0) { - // Partially uncommitted, split segment - insert_segment(index + 1, _segments.at(index).start() + size, _segments.at(index).size() - size, true /* committed */); - replace_segment(index, _segments.at(index).start(), size, false /* committed */); - } - - return false; -} - -XPhysicalMemory XPhysicalMemory::split(size_t size) { - XPhysicalMemory pmem; - int nsegments = 0; - - for (int i = 0; i < _segments.length(); i++) { - const XPhysicalMemorySegment& segment = _segments.at(i); - if (pmem.size() < size) { - if (pmem.size() + segment.size() <= size) { - // Transfer segment - pmem.add_segment(segment); - } else { - // Split segment - const size_t split_size = size - pmem.size(); - pmem.add_segment(XPhysicalMemorySegment(segment.start(), split_size, segment.is_committed())); - _segments.at_put(nsegments++, XPhysicalMemorySegment(segment.start() + split_size, segment.size() - split_size, segment.is_committed())); - } - } else { - // Keep segment - _segments.at_put(nsegments++, segment); - } - } - - _segments.trunc_to(nsegments); - - return pmem; -} - -XPhysicalMemory XPhysicalMemory::split_committed() { - XPhysicalMemory pmem; - int nsegments = 0; - - for (int i = 0; i < _segments.length(); i++) { - const XPhysicalMemorySegment& segment = _segments.at(i); - if (segment.is_committed()) { - // Transfer segment - pmem.add_segment(segment); - } else { - // Keep segment - _segments.at_put(nsegments++, segment); - } - } - - _segments.trunc_to(nsegments); - - return pmem; -} - -XPhysicalMemoryManager::XPhysicalMemoryManager(size_t max_capacity) : - _backing(max_capacity) { - // Make the whole range free - _manager.free(0, max_capacity); -} - -bool XPhysicalMemoryManager::is_initialized() const { - return _backing.is_initialized(); -} - -void XPhysicalMemoryManager::warn_commit_limits(size_t max_capacity) const { - _backing.warn_commit_limits(max_capacity); -} - -void XPhysicalMemoryManager::try_enable_uncommit(size_t min_capacity, size_t max_capacity) { - assert(!is_init_completed(), "Invalid state"); - - // If uncommit is not explicitly disabled, max capacity is greater than - // min capacity, and uncommit is supported by the platform, then uncommit - // will be enabled. - if (!ZUncommit) { - log_info_p(gc, init)("Uncommit: Disabled"); - return; - } - - if (max_capacity == min_capacity) { - log_info_p(gc, init)("Uncommit: Implicitly Disabled (-Xms equals -Xmx)"); - FLAG_SET_ERGO(ZUncommit, false); - return; - } - - // Test if uncommit is supported by the operating system by committing - // and then uncommitting a granule. - XPhysicalMemory pmem(XPhysicalMemorySegment(0, XGranuleSize, false /* committed */)); - if (!commit(pmem) || !uncommit(pmem)) { - log_info_p(gc, init)("Uncommit: Implicitly Disabled (Not supported by operating system)"); - FLAG_SET_ERGO(ZUncommit, false); - return; - } - - log_info_p(gc, init)("Uncommit: Enabled"); - log_info_p(gc, init)("Uncommit Delay: " UINTX_FORMAT "s", ZUncommitDelay); -} - -void XPhysicalMemoryManager::nmt_commit(uintptr_t offset, size_t size) const { - // From an NMT point of view we treat the first heap view (marked0) as committed - const uintptr_t addr = XAddress::marked0(offset); - MemTracker::record_virtual_memory_commit((void*)addr, size, CALLER_PC); -} - -void XPhysicalMemoryManager::nmt_uncommit(uintptr_t offset, size_t size) const { - const uintptr_t addr = XAddress::marked0(offset); - ThreadCritical tc; - MemTracker::record_virtual_memory_uncommit((address)addr, size); -} - -void XPhysicalMemoryManager::alloc(XPhysicalMemory& pmem, size_t size) { - assert(is_aligned(size, XGranuleSize), "Invalid size"); - - // Allocate segments - while (size > 0) { - size_t allocated = 0; - const uintptr_t start = _manager.alloc_low_address_at_most(size, &allocated); - assert(start != UINTPTR_MAX, "Allocation should never fail"); - pmem.add_segment(XPhysicalMemorySegment(start, allocated, false /* committed */)); - size -= allocated; - } -} - -void XPhysicalMemoryManager::free(const XPhysicalMemory& pmem) { - // Free segments - for (int i = 0; i < pmem.nsegments(); i++) { - const XPhysicalMemorySegment& segment = pmem.segment(i); - _manager.free(segment.start(), segment.size()); - } -} - -bool XPhysicalMemoryManager::commit(XPhysicalMemory& pmem) { - // Commit segments - for (int i = 0; i < pmem.nsegments(); i++) { - const XPhysicalMemorySegment& segment = pmem.segment(i); - if (segment.is_committed()) { - // Segment already committed - continue; - } - - // Commit segment - const size_t committed = _backing.commit(segment.start(), segment.size()); - if (!pmem.commit_segment(i, committed)) { - // Failed or partially failed - return false; - } - } - - // Success - return true; -} - -bool XPhysicalMemoryManager::uncommit(XPhysicalMemory& pmem) { - // Commit segments - for (int i = 0; i < pmem.nsegments(); i++) { - const XPhysicalMemorySegment& segment = pmem.segment(i); - if (!segment.is_committed()) { - // Segment already uncommitted - continue; - } - - // Uncommit segment - const size_t uncommitted = _backing.uncommit(segment.start(), segment.size()); - if (!pmem.uncommit_segment(i, uncommitted)) { - // Failed or partially failed - return false; - } - } - - // Success - return true; -} - -void XPhysicalMemoryManager::pretouch_view(uintptr_t addr, size_t size) const { - const size_t page_size = XLargePages::is_explicit() ? XGranuleSize : os::vm_page_size(); - os::pretouch_memory((void*)addr, (void*)(addr + size), page_size); -} - -void XPhysicalMemoryManager::map_view(uintptr_t addr, const XPhysicalMemory& pmem) const { - size_t size = 0; - - // Map segments - for (int i = 0; i < pmem.nsegments(); i++) { - const XPhysicalMemorySegment& segment = pmem.segment(i); - _backing.map(addr + size, segment.size(), segment.start()); - size += segment.size(); - } - - // Setup NUMA interleaving for large pages - if (XNUMA::is_enabled() && XLargePages::is_explicit()) { - // To get granule-level NUMA interleaving when using large pages, - // we simply let the kernel interleave the memory for us at page - // fault time. - os::numa_make_global((char*)addr, size); - } -} - -void XPhysicalMemoryManager::unmap_view(uintptr_t addr, size_t size) const { - _backing.unmap(addr, size); -} - -void XPhysicalMemoryManager::pretouch(uintptr_t offset, size_t size) const { - if (ZVerifyViews) { - // Pre-touch good view - pretouch_view(XAddress::good(offset), size); - } else { - // Pre-touch all views - pretouch_view(XAddress::marked0(offset), size); - pretouch_view(XAddress::marked1(offset), size); - pretouch_view(XAddress::remapped(offset), size); - } -} - -void XPhysicalMemoryManager::map(uintptr_t offset, const XPhysicalMemory& pmem) const { - const size_t size = pmem.size(); - - if (ZVerifyViews) { - // Map good view - map_view(XAddress::good(offset), pmem); - } else { - // Map all views - map_view(XAddress::marked0(offset), pmem); - map_view(XAddress::marked1(offset), pmem); - map_view(XAddress::remapped(offset), pmem); - } - - nmt_commit(offset, size); -} - -void XPhysicalMemoryManager::unmap(uintptr_t offset, size_t size) const { - nmt_uncommit(offset, size); - - if (ZVerifyViews) { - // Unmap good view - unmap_view(XAddress::good(offset), size); - } else { - // Unmap all views - unmap_view(XAddress::marked0(offset), size); - unmap_view(XAddress::marked1(offset), size); - unmap_view(XAddress::remapped(offset), size); - } -} - -void XPhysicalMemoryManager::debug_map(uintptr_t offset, const XPhysicalMemory& pmem) const { - // Map good view - assert(ZVerifyViews, "Should be enabled"); - map_view(XAddress::good(offset), pmem); -} - -void XPhysicalMemoryManager::debug_unmap(uintptr_t offset, size_t size) const { - // Unmap good view - assert(ZVerifyViews, "Should be enabled"); - unmap_view(XAddress::good(offset), size); -} diff --git a/src/hotspot/share/gc/x/xPhysicalMemory.hpp b/src/hotspot/share/gc/x/xPhysicalMemory.hpp deleted file mode 100644 index 26d8ed9bb96..00000000000 --- a/src/hotspot/share/gc/x/xPhysicalMemory.hpp +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright (c) 2015, 2020, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XPHYSICALMEMORY_HPP -#define SHARE_GC_X_XPHYSICALMEMORY_HPP - -#include "gc/x/xArray.hpp" -#include "gc/x/xMemory.hpp" -#include "memory/allocation.hpp" -#include OS_HEADER(gc/x/xPhysicalMemoryBacking) - -class XPhysicalMemorySegment : public CHeapObj { -private: - uintptr_t _start; - uintptr_t _end; - bool _committed; - -public: - XPhysicalMemorySegment(); - XPhysicalMemorySegment(uintptr_t start, size_t size, bool committed); - - uintptr_t start() const; - uintptr_t end() const; - size_t size() const; - - bool is_committed() const; - void set_committed(bool committed); -}; - -class XPhysicalMemory { -private: - XArray _segments; - - void insert_segment(int index, uintptr_t start, size_t size, bool committed); - void replace_segment(int index, uintptr_t start, size_t size, bool committed); - void remove_segment(int index); - -public: - XPhysicalMemory(); - XPhysicalMemory(const XPhysicalMemorySegment& segment); - XPhysicalMemory(const XPhysicalMemory& pmem); - const XPhysicalMemory& operator=(const XPhysicalMemory& pmem); - - bool is_null() const; - size_t size() const; - - int nsegments() const; - const XPhysicalMemorySegment& segment(int index) const; - - void add_segments(const XPhysicalMemory& pmem); - void remove_segments(); - - void add_segment(const XPhysicalMemorySegment& segment); - bool commit_segment(int index, size_t size); - bool uncommit_segment(int index, size_t size); - - XPhysicalMemory split(size_t size); - XPhysicalMemory split_committed(); -}; - -class XPhysicalMemoryManager { -private: - XPhysicalMemoryBacking _backing; - XMemoryManager _manager; - - void nmt_commit(uintptr_t offset, size_t size) const; - void nmt_uncommit(uintptr_t offset, size_t size) const; - - void pretouch_view(uintptr_t addr, size_t size) const; - void map_view(uintptr_t addr, const XPhysicalMemory& pmem) const; - void unmap_view(uintptr_t addr, size_t size) const; - -public: - XPhysicalMemoryManager(size_t max_capacity); - - bool is_initialized() const; - - void warn_commit_limits(size_t max_capacity) const; - void try_enable_uncommit(size_t min_capacity, size_t max_capacity); - - void alloc(XPhysicalMemory& pmem, size_t size); - void free(const XPhysicalMemory& pmem); - - bool commit(XPhysicalMemory& pmem); - bool uncommit(XPhysicalMemory& pmem); - - void pretouch(uintptr_t offset, size_t size) const; - - void map(uintptr_t offset, const XPhysicalMemory& pmem) const; - void unmap(uintptr_t offset, size_t size) const; - - void debug_map(uintptr_t offset, const XPhysicalMemory& pmem) const; - void debug_unmap(uintptr_t offset, size_t size) const; -}; - -#endif // SHARE_GC_X_XPHYSICALMEMORY_HPP diff --git a/src/hotspot/share/gc/x/xPhysicalMemory.inline.hpp b/src/hotspot/share/gc/x/xPhysicalMemory.inline.hpp deleted file mode 100644 index 70f38e2abdb..00000000000 --- a/src/hotspot/share/gc/x/xPhysicalMemory.inline.hpp +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2015, 2020, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XPHYSICALMEMORY_INLINE_HPP -#define SHARE_GC_X_XPHYSICALMEMORY_INLINE_HPP - -#include "gc/x/xPhysicalMemory.hpp" - -#include "gc/x/xAddress.inline.hpp" -#include "utilities/debug.hpp" - -inline XPhysicalMemorySegment::XPhysicalMemorySegment() : - _start(UINTPTR_MAX), - _end(UINTPTR_MAX), - _committed(false) {} - -inline XPhysicalMemorySegment::XPhysicalMemorySegment(uintptr_t start, size_t size, bool committed) : - _start(start), - _end(start + size), - _committed(committed) {} - -inline uintptr_t XPhysicalMemorySegment::start() const { - return _start; -} - -inline uintptr_t XPhysicalMemorySegment::end() const { - return _end; -} - -inline size_t XPhysicalMemorySegment::size() const { - return _end - _start; -} - -inline bool XPhysicalMemorySegment::is_committed() const { - return _committed; -} - -inline void XPhysicalMemorySegment::set_committed(bool committed) { - _committed = committed; -} - -inline bool XPhysicalMemory::is_null() const { - return _segments.length() == 0; -} - -inline int XPhysicalMemory::nsegments() const { - return _segments.length(); -} - -inline const XPhysicalMemorySegment& XPhysicalMemory::segment(int index) const { - return _segments.at(index); -} - -#endif // SHARE_GC_X_XPHYSICALMEMORY_INLINE_HPP diff --git a/src/hotspot/share/gc/x/xReferenceProcessor.cpp b/src/hotspot/share/gc/x/xReferenceProcessor.cpp deleted file mode 100644 index acbb96eaf41..00000000000 --- a/src/hotspot/share/gc/x/xReferenceProcessor.cpp +++ /dev/null @@ -1,459 +0,0 @@ -/* - * Copyright (c) 2015, 2021, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "classfile/javaClasses.inline.hpp" -#include "gc/shared/referencePolicy.hpp" -#include "gc/shared/referenceProcessorStats.hpp" -#include "gc/x/xHeap.inline.hpp" -#include "gc/x/xReferenceProcessor.hpp" -#include "gc/x/xStat.hpp" -#include "gc/x/xTask.hpp" -#include "gc/x/xTracer.inline.hpp" -#include "gc/x/xValue.inline.hpp" -#include "memory/universe.hpp" -#include "runtime/atomic.hpp" -#include "runtime/mutexLocker.hpp" -#include "runtime/os.hpp" - -static const XStatSubPhase XSubPhaseConcurrentReferencesProcess("Concurrent References Process"); -static const XStatSubPhase XSubPhaseConcurrentReferencesEnqueue("Concurrent References Enqueue"); - -static ReferenceType reference_type(oop reference) { - return InstanceKlass::cast(reference->klass())->reference_type(); -} - -static const char* reference_type_name(ReferenceType type) { - switch (type) { - case REF_SOFT: - return "Soft"; - - case REF_WEAK: - return "Weak"; - - case REF_FINAL: - return "Final"; - - case REF_PHANTOM: - return "Phantom"; - - default: - ShouldNotReachHere(); - return "Unknown"; - } -} - -static volatile oop* reference_referent_addr(oop reference) { - return (volatile oop*)java_lang_ref_Reference::referent_addr_raw(reference); -} - -static oop reference_referent(oop reference) { - return Atomic::load(reference_referent_addr(reference)); -} - -static void reference_clear_referent(oop reference) { - java_lang_ref_Reference::clear_referent_raw(reference); -} - -static oop* reference_discovered_addr(oop reference) { - return (oop*)java_lang_ref_Reference::discovered_addr_raw(reference); -} - -static oop reference_discovered(oop reference) { - return *reference_discovered_addr(reference); -} - -static void reference_set_discovered(oop reference, oop discovered) { - java_lang_ref_Reference::set_discovered_raw(reference, discovered); -} - -static oop* reference_next_addr(oop reference) { - return (oop*)java_lang_ref_Reference::next_addr_raw(reference); -} - -static oop reference_next(oop reference) { - return *reference_next_addr(reference); -} - -static void reference_set_next(oop reference, oop next) { - java_lang_ref_Reference::set_next_raw(reference, next); -} - -static void soft_reference_update_clock() { - const jlong now = os::javaTimeNanos() / NANOSECS_PER_MILLISEC; - java_lang_ref_SoftReference::set_clock(now); -} - -XReferenceProcessor::XReferenceProcessor(XWorkers* workers) : - _workers(workers), - _soft_reference_policy(nullptr), - _encountered_count(), - _discovered_count(), - _enqueued_count(), - _discovered_list(nullptr), - _pending_list(nullptr), - _pending_list_tail(_pending_list.addr()) {} - -void XReferenceProcessor::set_soft_reference_policy(bool clear) { - static AlwaysClearPolicy always_clear_policy; - static LRUMaxHeapPolicy lru_max_heap_policy; - - if (clear) { - log_info(gc, ref)("Clearing All SoftReferences"); - _soft_reference_policy = &always_clear_policy; - } else { - _soft_reference_policy = &lru_max_heap_policy; - } - - _soft_reference_policy->setup(); -} - -bool XReferenceProcessor::is_inactive(oop reference, oop referent, ReferenceType type) const { - if (type == REF_FINAL) { - // A FinalReference is inactive if its next field is non-null. An application can't - // call enqueue() or clear() on a FinalReference. - return reference_next(reference) != nullptr; - } else { - // A non-FinalReference is inactive if the referent is null. The referent can only - // be null if the application called Reference.enqueue() or Reference.clear(). - return referent == nullptr; - } -} - -bool XReferenceProcessor::is_strongly_live(oop referent) const { - return XHeap::heap()->is_object_strongly_live(XOop::to_address(referent)); -} - -bool XReferenceProcessor::is_softly_live(oop reference, ReferenceType type) const { - if (type != REF_SOFT) { - // Not a SoftReference - return false; - } - - // Ask SoftReference policy - const jlong clock = java_lang_ref_SoftReference::clock(); - assert(clock != 0, "Clock not initialized"); - assert(_soft_reference_policy != nullptr, "Policy not initialized"); - return !_soft_reference_policy->should_clear_reference(reference, clock); -} - -bool XReferenceProcessor::should_discover(oop reference, ReferenceType type) const { - volatile oop* const referent_addr = reference_referent_addr(reference); - const oop referent = XBarrier::weak_load_barrier_on_oop_field(referent_addr); - - if (is_inactive(reference, referent, type)) { - return false; - } - - if (is_strongly_live(referent)) { - return false; - } - - if (is_softly_live(reference, type)) { - return false; - } - - // PhantomReferences with finalizable marked referents should technically not have - // to be discovered. However, InstanceRefKlass::oop_oop_iterate_ref_processing() - // does not know about the finalizable mark concept, and will therefore mark - // referents in non-discovered PhantomReferences as strongly live. To prevent - // this, we always discover PhantomReferences with finalizable marked referents. - // They will automatically be dropped during the reference processing phase. - return true; -} - -bool XReferenceProcessor::should_drop(oop reference, ReferenceType type) const { - const oop referent = reference_referent(reference); - if (referent == nullptr) { - // Reference has been cleared, by a call to Reference.enqueue() - // or Reference.clear() from the application, which means we - // should drop the reference. - return true; - } - - // Check if the referent is still alive, in which case we should - // drop the reference. - if (type == REF_PHANTOM) { - return XBarrier::is_alive_barrier_on_phantom_oop(referent); - } else { - return XBarrier::is_alive_barrier_on_weak_oop(referent); - } -} - -void XReferenceProcessor::keep_alive(oop reference, ReferenceType type) const { - volatile oop* const p = reference_referent_addr(reference); - if (type == REF_PHANTOM) { - XBarrier::keep_alive_barrier_on_phantom_oop_field(p); - } else { - XBarrier::keep_alive_barrier_on_weak_oop_field(p); - } -} - -void XReferenceProcessor::make_inactive(oop reference, ReferenceType type) const { - if (type == REF_FINAL) { - // Don't clear referent. It is needed by the Finalizer thread to make the call - // to finalize(). A FinalReference is instead made inactive by self-looping the - // next field. An application can't call FinalReference.enqueue(), so there is - // no race to worry about when setting the next field. - assert(reference_next(reference) == nullptr, "Already inactive"); - reference_set_next(reference, reference); - } else { - // Clear referent - reference_clear_referent(reference); - } -} - -void XReferenceProcessor::discover(oop reference, ReferenceType type) { - log_trace(gc, ref)("Discovered Reference: " PTR_FORMAT " (%s)", p2i(reference), reference_type_name(type)); - - // Update statistics - _discovered_count.get()[type]++; - - if (type == REF_FINAL) { - // Mark referent (and its reachable subgraph) finalizable. This avoids - // the problem of later having to mark those objects if the referent is - // still final reachable during processing. - volatile oop* const referent_addr = reference_referent_addr(reference); - XBarrier::mark_barrier_on_oop_field(referent_addr, true /* finalizable */); - } - - // Add reference to discovered list - assert(reference_discovered(reference) == nullptr, "Already discovered"); - oop* const list = _discovered_list.addr(); - reference_set_discovered(reference, *list); - *list = reference; -} - -bool XReferenceProcessor::discover_reference(oop reference, ReferenceType type) { - if (!RegisterReferences) { - // Reference processing disabled - return false; - } - - log_trace(gc, ref)("Encountered Reference: " PTR_FORMAT " (%s)", p2i(reference), reference_type_name(type)); - - // Update statistics - _encountered_count.get()[type]++; - - if (!should_discover(reference, type)) { - // Not discovered - return false; - } - - discover(reference, type); - - // Discovered - return true; -} - -oop XReferenceProcessor::drop(oop reference, ReferenceType type) { - log_trace(gc, ref)("Dropped Reference: " PTR_FORMAT " (%s)", p2i(reference), reference_type_name(type)); - - // Keep referent alive - keep_alive(reference, type); - - // Unlink and return next in list - const oop next = reference_discovered(reference); - reference_set_discovered(reference, nullptr); - return next; -} - -oop* XReferenceProcessor::keep(oop reference, ReferenceType type) { - log_trace(gc, ref)("Enqueued Reference: " PTR_FORMAT " (%s)", p2i(reference), reference_type_name(type)); - - // Update statistics - _enqueued_count.get()[type]++; - - // Make reference inactive - make_inactive(reference, type); - - // Return next in list - return reference_discovered_addr(reference); -} - -void XReferenceProcessor::work() { - // Process discovered references - oop* const list = _discovered_list.addr(); - oop* p = list; - - while (*p != nullptr) { - const oop reference = *p; - const ReferenceType type = reference_type(reference); - - if (should_drop(reference, type)) { - *p = drop(reference, type); - } else { - p = keep(reference, type); - } - } - - // Prepend discovered references to internal pending list - if (*list != nullptr) { - *p = Atomic::xchg(_pending_list.addr(), *list); - if (*p == nullptr) { - // First to prepend to list, record tail - _pending_list_tail = p; - } - - // Clear discovered list - *list = nullptr; - } -} - -bool XReferenceProcessor::is_empty() const { - XPerWorkerConstIterator iter(&_discovered_list); - for (const oop* list; iter.next(&list);) { - if (*list != nullptr) { - return false; - } - } - - if (_pending_list.get() != nullptr) { - return false; - } - - return true; -} - -void XReferenceProcessor::reset_statistics() { - assert(is_empty(), "Should be empty"); - - // Reset encountered - XPerWorkerIterator iter_encountered(&_encountered_count); - for (Counters* counters; iter_encountered.next(&counters);) { - for (int i = REF_SOFT; i <= REF_PHANTOM; i++) { - (*counters)[i] = 0; - } - } - - // Reset discovered - XPerWorkerIterator iter_discovered(&_discovered_count); - for (Counters* counters; iter_discovered.next(&counters);) { - for (int i = REF_SOFT; i <= REF_PHANTOM; i++) { - (*counters)[i] = 0; - } - } - - // Reset enqueued - XPerWorkerIterator iter_enqueued(&_enqueued_count); - for (Counters* counters; iter_enqueued.next(&counters);) { - for (int i = REF_SOFT; i <= REF_PHANTOM; i++) { - (*counters)[i] = 0; - } - } -} - -void XReferenceProcessor::collect_statistics() { - Counters encountered = {}; - Counters discovered = {}; - Counters enqueued = {}; - - // Sum encountered - XPerWorkerConstIterator iter_encountered(&_encountered_count); - for (const Counters* counters; iter_encountered.next(&counters);) { - for (int i = REF_SOFT; i <= REF_PHANTOM; i++) { - encountered[i] += (*counters)[i]; - } - } - - // Sum discovered - XPerWorkerConstIterator iter_discovered(&_discovered_count); - for (const Counters* counters; iter_discovered.next(&counters);) { - for (int i = REF_SOFT; i <= REF_PHANTOM; i++) { - discovered[i] += (*counters)[i]; - } - } - - // Sum enqueued - XPerWorkerConstIterator iter_enqueued(&_enqueued_count); - for (const Counters* counters; iter_enqueued.next(&counters);) { - for (int i = REF_SOFT; i <= REF_PHANTOM; i++) { - enqueued[i] += (*counters)[i]; - } - } - - // Update statistics - XStatReferences::set_soft(encountered[REF_SOFT], discovered[REF_SOFT], enqueued[REF_SOFT]); - XStatReferences::set_weak(encountered[REF_WEAK], discovered[REF_WEAK], enqueued[REF_WEAK]); - XStatReferences::set_final(encountered[REF_FINAL], discovered[REF_FINAL], enqueued[REF_FINAL]); - XStatReferences::set_phantom(encountered[REF_PHANTOM], discovered[REF_PHANTOM], enqueued[REF_PHANTOM]); - - // Trace statistics - const ReferenceProcessorStats stats(discovered[REF_SOFT], - discovered[REF_WEAK], - discovered[REF_FINAL], - discovered[REF_PHANTOM]); - XTracer::tracer()->report_gc_reference_stats(stats); -} - -class XReferenceProcessorTask : public XTask { -private: - XReferenceProcessor* const _reference_processor; - -public: - XReferenceProcessorTask(XReferenceProcessor* reference_processor) : - XTask("XReferenceProcessorTask"), - _reference_processor(reference_processor) {} - - virtual void work() { - _reference_processor->work(); - } -}; - -void XReferenceProcessor::process_references() { - XStatTimer timer(XSubPhaseConcurrentReferencesProcess); - - // Process discovered lists - XReferenceProcessorTask task(this); - _workers->run(&task); - - // Update SoftReference clock - soft_reference_update_clock(); - - // Collect, log and trace statistics - collect_statistics(); -} - -void XReferenceProcessor::enqueue_references() { - XStatTimer timer(XSubPhaseConcurrentReferencesEnqueue); - - if (_pending_list.get() == nullptr) { - // Nothing to enqueue - return; - } - - { - // Heap_lock protects external pending list - MonitorLocker ml(Heap_lock); - - // Prepend internal pending list to external pending list - *_pending_list_tail = Universe::swap_reference_pending_list(_pending_list.get()); - - // Notify ReferenceHandler thread - ml.notify_all(); - } - - // Reset internal pending list - _pending_list.set(nullptr); - _pending_list_tail = _pending_list.addr(); -} diff --git a/src/hotspot/share/gc/x/xReferenceProcessor.hpp b/src/hotspot/share/gc/x/xReferenceProcessor.hpp deleted file mode 100644 index 1ff7b14e868..00000000000 --- a/src/hotspot/share/gc/x/xReferenceProcessor.hpp +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2015, 2019, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XREFERENCEPROCESSOR_HPP -#define SHARE_GC_X_XREFERENCEPROCESSOR_HPP - -#include "gc/shared/referenceDiscoverer.hpp" -#include "gc/x/xValue.hpp" - -class ReferencePolicy; -class XWorkers; - -class XReferenceProcessor : public ReferenceDiscoverer { - friend class XReferenceProcessorTask; - -private: - static const size_t reference_type_count = REF_PHANTOM + 1; - typedef size_t Counters[reference_type_count]; - - XWorkers* const _workers; - ReferencePolicy* _soft_reference_policy; - XPerWorker _encountered_count; - XPerWorker _discovered_count; - XPerWorker _enqueued_count; - XPerWorker _discovered_list; - XContended _pending_list; - oop* _pending_list_tail; - - bool is_inactive(oop reference, oop referent, ReferenceType type) const; - bool is_strongly_live(oop referent) const; - bool is_softly_live(oop reference, ReferenceType type) const; - - bool should_discover(oop reference, ReferenceType type) const; - bool should_drop(oop reference, ReferenceType type) const; - void keep_alive(oop reference, ReferenceType type) const; - void make_inactive(oop reference, ReferenceType type) const; - - void discover(oop reference, ReferenceType type); - - oop drop(oop reference, ReferenceType type); - oop* keep(oop reference, ReferenceType type); - - bool is_empty() const; - - void work(); - void collect_statistics(); - -public: - XReferenceProcessor(XWorkers* workers); - - void set_soft_reference_policy(bool clear); - void reset_statistics(); - - virtual bool discover_reference(oop reference, ReferenceType type); - void process_references(); - void enqueue_references(); -}; - -#endif // SHARE_GC_X_XREFERENCEPROCESSOR_HPP diff --git a/src/hotspot/share/gc/x/xRelocate.cpp b/src/hotspot/share/gc/x/xRelocate.cpp deleted file mode 100644 index 645989eaba3..00000000000 --- a/src/hotspot/share/gc/x/xRelocate.cpp +++ /dev/null @@ -1,419 +0,0 @@ -/* - * Copyright (c) 2015, 2021, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/shared/gc_globals.hpp" -#include "gc/x/xAbort.inline.hpp" -#include "gc/x/xAddress.inline.hpp" -#include "gc/x/xBarrier.inline.hpp" -#include "gc/x/xForwarding.inline.hpp" -#include "gc/x/xHeap.inline.hpp" -#include "gc/x/xPage.inline.hpp" -#include "gc/x/xRelocate.hpp" -#include "gc/x/xRelocationSet.inline.hpp" -#include "gc/x/xStat.hpp" -#include "gc/x/xTask.hpp" -#include "gc/x/xThread.inline.hpp" -#include "gc/x/xWorkers.hpp" -#include "prims/jvmtiTagMap.hpp" -#include "runtime/atomic.hpp" -#include "utilities/debug.hpp" - -XRelocate::XRelocate(XWorkers* workers) : - _workers(workers) {} - -static uintptr_t forwarding_index(XForwarding* forwarding, uintptr_t from_addr) { - const uintptr_t from_offset = XAddress::offset(from_addr); - return (from_offset - forwarding->start()) >> forwarding->object_alignment_shift(); -} - -static uintptr_t forwarding_find(XForwarding* forwarding, uintptr_t from_addr, XForwardingCursor* cursor) { - const uintptr_t from_index = forwarding_index(forwarding, from_addr); - const XForwardingEntry entry = forwarding->find(from_index, cursor); - return entry.populated() ? XAddress::good(entry.to_offset()) : 0; -} - -static uintptr_t forwarding_insert(XForwarding* forwarding, uintptr_t from_addr, uintptr_t to_addr, XForwardingCursor* cursor) { - const uintptr_t from_index = forwarding_index(forwarding, from_addr); - const uintptr_t to_offset = XAddress::offset(to_addr); - const uintptr_t to_offset_final = forwarding->insert(from_index, to_offset, cursor); - return XAddress::good(to_offset_final); -} - -static uintptr_t relocate_object_inner(XForwarding* forwarding, uintptr_t from_addr, XForwardingCursor* cursor) { - assert(XHeap::heap()->is_object_live(from_addr), "Should be live"); - - // Allocate object - const size_t size = XUtils::object_size(from_addr); - const uintptr_t to_addr = XHeap::heap()->alloc_object_for_relocation(size); - if (to_addr == 0) { - // Allocation failed - return 0; - } - - // Copy object - XUtils::object_copy_disjoint(from_addr, to_addr, size); - - // Insert forwarding - const uintptr_t to_addr_final = forwarding_insert(forwarding, from_addr, to_addr, cursor); - if (to_addr_final != to_addr) { - // Already relocated, try undo allocation - XHeap::heap()->undo_alloc_object_for_relocation(to_addr, size); - } - - return to_addr_final; -} - -uintptr_t XRelocate::relocate_object(XForwarding* forwarding, uintptr_t from_addr) const { - XForwardingCursor cursor; - - // Lookup forwarding - uintptr_t to_addr = forwarding_find(forwarding, from_addr, &cursor); - if (to_addr != 0) { - // Already relocated - return to_addr; - } - - // Relocate object - if (forwarding->retain_page()) { - to_addr = relocate_object_inner(forwarding, from_addr, &cursor); - forwarding->release_page(); - - if (to_addr != 0) { - // Success - return to_addr; - } - - // Failed to relocate object. Wait for a worker thread to complete - // relocation of this page, and then forward the object. If the GC - // aborts the relocation phase before the page has been relocated, - // then wait return false and we just forward the object in-place. - if (!forwarding->wait_page_released()) { - // Forward object in-place - return forwarding_insert(forwarding, from_addr, from_addr, &cursor); - } - } - - // Forward object - return forward_object(forwarding, from_addr); -} - -uintptr_t XRelocate::forward_object(XForwarding* forwarding, uintptr_t from_addr) const { - XForwardingCursor cursor; - const uintptr_t to_addr = forwarding_find(forwarding, from_addr, &cursor); - assert(to_addr != 0, "Should be forwarded"); - return to_addr; -} - -static XPage* alloc_page(const XForwarding* forwarding) { - if (ZStressRelocateInPlace) { - // Simulate failure to allocate a new page. This will - // cause the page being relocated to be relocated in-place. - return nullptr; - } - - XAllocationFlags flags; - flags.set_non_blocking(); - flags.set_worker_relocation(); - return XHeap::heap()->alloc_page(forwarding->type(), forwarding->size(), flags); -} - -static void free_page(XPage* page) { - XHeap::heap()->free_page(page, true /* reclaimed */); -} - -static bool should_free_target_page(XPage* page) { - // Free target page if it is empty. We can end up with an empty target - // page if we allocated a new target page, and then lost the race to - // relocate the remaining objects, leaving the target page empty when - // relocation completed. - return page != nullptr && page->top() == page->start(); -} - -class XRelocateSmallAllocator { -private: - volatile size_t _in_place_count; - -public: - XRelocateSmallAllocator() : - _in_place_count(0) {} - - XPage* alloc_target_page(XForwarding* forwarding, XPage* target) { - XPage* const page = alloc_page(forwarding); - if (page == nullptr) { - Atomic::inc(&_in_place_count); - } - - return page; - } - - void share_target_page(XPage* page) { - // Does nothing - } - - void free_target_page(XPage* page) { - if (should_free_target_page(page)) { - free_page(page); - } - } - - void free_relocated_page(XPage* page) { - free_page(page); - } - - uintptr_t alloc_object(XPage* page, size_t size) const { - return (page != nullptr) ? page->alloc_object(size) : 0; - } - - void undo_alloc_object(XPage* page, uintptr_t addr, size_t size) const { - page->undo_alloc_object(addr, size); - } - - size_t in_place_count() const { - return _in_place_count; - } -}; - -class XRelocateMediumAllocator { -private: - XConditionLock _lock; - XPage* _shared; - bool _in_place; - volatile size_t _in_place_count; - -public: - XRelocateMediumAllocator() : - _lock(), - _shared(nullptr), - _in_place(false), - _in_place_count(0) {} - - ~XRelocateMediumAllocator() { - if (should_free_target_page(_shared)) { - free_page(_shared); - } - } - - XPage* alloc_target_page(XForwarding* forwarding, XPage* target) { - XLocker locker(&_lock); - - // Wait for any ongoing in-place relocation to complete - while (_in_place) { - _lock.wait(); - } - - // Allocate a new page only if the shared page is the same as the - // current target page. The shared page will be different from the - // current target page if another thread shared a page, or allocated - // a new page. - if (_shared == target) { - _shared = alloc_page(forwarding); - if (_shared == nullptr) { - Atomic::inc(&_in_place_count); - _in_place = true; - } - } - - return _shared; - } - - void share_target_page(XPage* page) { - XLocker locker(&_lock); - - assert(_in_place, "Invalid state"); - assert(_shared == nullptr, "Invalid state"); - assert(page != nullptr, "Invalid page"); - - _shared = page; - _in_place = false; - - _lock.notify_all(); - } - - void free_target_page(XPage* page) { - // Does nothing - } - - void free_relocated_page(XPage* page) { - free_page(page); - } - - uintptr_t alloc_object(XPage* page, size_t size) const { - return (page != nullptr) ? page->alloc_object_atomic(size) : 0; - } - - void undo_alloc_object(XPage* page, uintptr_t addr, size_t size) const { - page->undo_alloc_object_atomic(addr, size); - } - - size_t in_place_count() const { - return _in_place_count; - } -}; - -template -class XRelocateClosure : public ObjectClosure { -private: - Allocator* const _allocator; - XForwarding* _forwarding; - XPage* _target; - - bool relocate_object(uintptr_t from_addr) const { - XForwardingCursor cursor; - - // Lookup forwarding - if (forwarding_find(_forwarding, from_addr, &cursor) != 0) { - // Already relocated - return true; - } - - // Allocate object - const size_t size = XUtils::object_size(from_addr); - const uintptr_t to_addr = _allocator->alloc_object(_target, size); - if (to_addr == 0) { - // Allocation failed - return false; - } - - // Copy object. Use conjoint copying if we are relocating - // in-place and the new object overlapps with the old object. - if (_forwarding->in_place() && to_addr + size > from_addr) { - XUtils::object_copy_conjoint(from_addr, to_addr, size); - } else { - XUtils::object_copy_disjoint(from_addr, to_addr, size); - } - - // Insert forwarding - if (forwarding_insert(_forwarding, from_addr, to_addr, &cursor) != to_addr) { - // Already relocated, undo allocation - _allocator->undo_alloc_object(_target, to_addr, size); - } - - return true; - } - - virtual void do_object(oop obj) { - const uintptr_t addr = XOop::to_address(obj); - assert(XHeap::heap()->is_object_live(addr), "Should be live"); - - while (!relocate_object(addr)) { - // Allocate a new target page, or if that fails, use the page being - // relocated as the new target, which will cause it to be relocated - // in-place. - _target = _allocator->alloc_target_page(_forwarding, _target); - if (_target != nullptr) { - continue; - } - - // Claim the page being relocated to block other threads from accessing - // it, or its forwarding table, until it has been released (relocation - // completed). - _target = _forwarding->claim_page(); - _target->reset_for_in_place_relocation(); - _forwarding->set_in_place(); - } - } - -public: - XRelocateClosure(Allocator* allocator) : - _allocator(allocator), - _forwarding(nullptr), - _target(nullptr) {} - - ~XRelocateClosure() { - _allocator->free_target_page(_target); - } - - void do_forwarding(XForwarding* forwarding) { - _forwarding = forwarding; - - // Check if we should abort - if (XAbort::should_abort()) { - _forwarding->abort_page(); - return; - } - - // Relocate objects - _forwarding->object_iterate(this); - - // Verify - if (ZVerifyForwarding) { - _forwarding->verify(); - } - - // Release relocated page - _forwarding->release_page(); - - if (_forwarding->in_place()) { - // The relocated page has been relocated in-place and should not - // be freed. Keep it as target page until it is full, and offer to - // share it with other worker threads. - _allocator->share_target_page(_target); - } else { - // Detach and free relocated page - XPage* const page = _forwarding->detach_page(); - _allocator->free_relocated_page(page); - } - } -}; - -class XRelocateTask : public XTask { -private: - XRelocationSetParallelIterator _iter; - XRelocateSmallAllocator _small_allocator; - XRelocateMediumAllocator _medium_allocator; - - static bool is_small(XForwarding* forwarding) { - return forwarding->type() == XPageTypeSmall; - } - -public: - XRelocateTask(XRelocationSet* relocation_set) : - XTask("XRelocateTask"), - _iter(relocation_set), - _small_allocator(), - _medium_allocator() {} - - ~XRelocateTask() { - XStatRelocation::set_at_relocate_end(_small_allocator.in_place_count(), - _medium_allocator.in_place_count()); - } - - virtual void work() { - XRelocateClosure small(&_small_allocator); - XRelocateClosure medium(&_medium_allocator); - - for (XForwarding* forwarding; _iter.next(&forwarding);) { - if (is_small(forwarding)) { - small.do_forwarding(forwarding); - } else { - medium.do_forwarding(forwarding); - } - } - } -}; - -void XRelocate::relocate(XRelocationSet* relocation_set) { - XRelocateTask task(relocation_set); - _workers->run(&task); -} diff --git a/src/hotspot/share/gc/x/xRelocate.hpp b/src/hotspot/share/gc/x/xRelocate.hpp deleted file mode 100644 index 46ab39240f6..00000000000 --- a/src/hotspot/share/gc/x/xRelocate.hpp +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2015, 2021, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XRELOCATE_HPP -#define SHARE_GC_X_XRELOCATE_HPP - -#include "gc/x/xRelocationSet.hpp" - -class XForwarding; -class XWorkers; - -class XRelocate { - friend class XRelocateTask; - -private: - XWorkers* const _workers; - - void work(XRelocationSetParallelIterator* iter); - -public: - XRelocate(XWorkers* workers); - - uintptr_t relocate_object(XForwarding* forwarding, uintptr_t from_addr) const; - uintptr_t forward_object(XForwarding* forwarding, uintptr_t from_addr) const; - - void relocate(XRelocationSet* relocation_set); -}; - -#endif // SHARE_GC_X_XRELOCATE_HPP diff --git a/src/hotspot/share/gc/x/xRelocationSet.cpp b/src/hotspot/share/gc/x/xRelocationSet.cpp deleted file mode 100644 index eeb42c4bf32..00000000000 --- a/src/hotspot/share/gc/x/xRelocationSet.cpp +++ /dev/null @@ -1,135 +0,0 @@ -/* - * 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/x/xArray.inline.hpp" -#include "gc/x/xForwarding.inline.hpp" -#include "gc/x/xForwardingAllocator.inline.hpp" -#include "gc/x/xRelocationSet.inline.hpp" -#include "gc/x/xRelocationSetSelector.inline.hpp" -#include "gc/x/xStat.hpp" -#include "gc/x/xTask.hpp" -#include "gc/x/xWorkers.hpp" -#include "runtime/atomic.hpp" -#include "utilities/debug.hpp" - -class XRelocationSetInstallTask : public XTask { -private: - XForwardingAllocator* const _allocator; - XForwarding** _forwardings; - const size_t _nforwardings; - XArrayParallelIterator _small_iter; - XArrayParallelIterator _medium_iter; - volatile size_t _small_next; - volatile size_t _medium_next; - - void install(XForwarding* forwarding, volatile size_t* next) { - const size_t index = Atomic::fetch_then_add(next, 1u); - assert(index < _nforwardings, "Invalid index"); - _forwardings[index] = forwarding; - } - - void install_small(XForwarding* forwarding) { - install(forwarding, &_small_next); - } - - void install_medium(XForwarding* forwarding) { - install(forwarding, &_medium_next); - } - -public: - XRelocationSetInstallTask(XForwardingAllocator* allocator, const XRelocationSetSelector* selector) : - XTask("XRelocationSetInstallTask"), - _allocator(allocator), - _forwardings(nullptr), - _nforwardings(selector->small()->length() + selector->medium()->length()), - _small_iter(selector->small()), - _medium_iter(selector->medium()), - _small_next(selector->medium()->length()), - _medium_next(0) { - - // Reset the allocator to have room for the relocation - // set, all forwardings, and all forwarding entries. - const size_t relocation_set_size = _nforwardings * sizeof(XForwarding*); - const size_t forwardings_size = _nforwardings * sizeof(XForwarding); - const size_t forwarding_entries_size = selector->forwarding_entries() * sizeof(XForwardingEntry); - _allocator->reset(relocation_set_size + forwardings_size + forwarding_entries_size); - - // Allocate relocation set - _forwardings = new (_allocator->alloc(relocation_set_size)) XForwarding*[_nforwardings]; - } - - ~XRelocationSetInstallTask() { - assert(_allocator->is_full(), "Should be full"); - } - - virtual void work() { - // Allocate and install forwardings for small pages - for (XPage* page; _small_iter.next(&page);) { - XForwarding* const forwarding = XForwarding::alloc(_allocator, page); - install_small(forwarding); - } - - // Allocate and install forwardings for medium pages - for (XPage* page; _medium_iter.next(&page);) { - XForwarding* const forwarding = XForwarding::alloc(_allocator, page); - install_medium(forwarding); - } - } - - XForwarding** forwardings() const { - return _forwardings; - } - - size_t nforwardings() const { - return _nforwardings; - } -}; - -XRelocationSet::XRelocationSet(XWorkers* workers) : - _workers(workers), - _allocator(), - _forwardings(nullptr), - _nforwardings(0) {} - -void XRelocationSet::install(const XRelocationSetSelector* selector) { - // Install relocation set - XRelocationSetInstallTask task(&_allocator, selector); - _workers->run(&task); - - _forwardings = task.forwardings(); - _nforwardings = task.nforwardings(); - - // Update statistics - XStatRelocation::set_at_install_relocation_set(_allocator.size()); -} - -void XRelocationSet::reset() { - // Destroy forwardings - XRelocationSetIterator iter(this); - for (XForwarding* forwarding; iter.next(&forwarding);) { - forwarding->~XForwarding(); - } - - _nforwardings = 0; -} diff --git a/src/hotspot/share/gc/x/xRelocationSet.hpp b/src/hotspot/share/gc/x/xRelocationSet.hpp deleted file mode 100644 index bbbb3770516..00000000000 --- a/src/hotspot/share/gc/x/xRelocationSet.hpp +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2017, 2020, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XRELOCATIONSET_HPP -#define SHARE_GC_X_XRELOCATIONSET_HPP - -#include "gc/x/xArray.hpp" -#include "gc/x/xForwardingAllocator.hpp" - -class XForwarding; -class XRelocationSetSelector; -class XWorkers; - -class XRelocationSet { - template friend class XRelocationSetIteratorImpl; - -private: - XWorkers* _workers; - XForwardingAllocator _allocator; - XForwarding** _forwardings; - size_t _nforwardings; - -public: - XRelocationSet(XWorkers* workers); - - void install(const XRelocationSetSelector* selector); - void reset(); -}; - -template -class XRelocationSetIteratorImpl : public XArrayIteratorImpl { -public: - XRelocationSetIteratorImpl(XRelocationSet* relocation_set); -}; - -using XRelocationSetIterator = XRelocationSetIteratorImpl; -using XRelocationSetParallelIterator = XRelocationSetIteratorImpl; - -#endif // SHARE_GC_X_XRELOCATIONSET_HPP diff --git a/src/hotspot/share/gc/x/xRelocationSet.inline.hpp b/src/hotspot/share/gc/x/xRelocationSet.inline.hpp deleted file mode 100644 index 3b76fbce46a..00000000000 --- a/src/hotspot/share/gc/x/xRelocationSet.inline.hpp +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2017, 2020, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XRELOCATIONSET_INLINE_HPP -#define SHARE_GC_X_XRELOCATIONSET_INLINE_HPP - -#include "gc/x/xRelocationSet.hpp" - -#include "gc/x/xArray.inline.hpp" - -template -inline XRelocationSetIteratorImpl::XRelocationSetIteratorImpl(XRelocationSet* relocation_set) : - XArrayIteratorImpl(relocation_set->_forwardings, relocation_set->_nforwardings) {} - -#endif // SHARE_GC_X_XRELOCATIONSET_INLINE_HPP diff --git a/src/hotspot/share/gc/x/xRelocationSetSelector.cpp b/src/hotspot/share/gc/x/xRelocationSetSelector.cpp deleted file mode 100644 index 514e70b8743..00000000000 --- a/src/hotspot/share/gc/x/xRelocationSetSelector.cpp +++ /dev/null @@ -1,213 +0,0 @@ -/* - * Copyright (c) 2017, 2021, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/shared/gc_globals.hpp" -#include "gc/x/xArray.inline.hpp" -#include "gc/x/xForwarding.inline.hpp" -#include "gc/x/xPage.inline.hpp" -#include "gc/x/xRelocationSetSelector.inline.hpp" -#include "jfr/jfrEvents.hpp" -#include "logging/log.hpp" -#include "runtime/globals.hpp" -#include "utilities/debug.hpp" -#include "utilities/powerOfTwo.hpp" - -XRelocationSetSelectorGroupStats::XRelocationSetSelectorGroupStats() : - _npages_candidates(0), - _total(0), - _live(0), - _empty(0), - _npages_selected(0), - _relocate(0) {} - -XRelocationSetSelectorGroup::XRelocationSetSelectorGroup(const char* name, - uint8_t page_type, - size_t page_size, - size_t object_size_limit) : - _name(name), - _page_type(page_type), - _page_size(page_size), - _object_size_limit(object_size_limit), - _fragmentation_limit(page_size * (ZFragmentationLimit / 100)), - _live_pages(), - _forwarding_entries(0), - _stats() {} - -bool XRelocationSetSelectorGroup::is_disabled() { - // Medium pages are disabled when their page size is zero - return _page_type == XPageTypeMedium && _page_size == 0; -} - -bool XRelocationSetSelectorGroup::is_selectable() { - // Large pages are not selectable - return _page_type != XPageTypeLarge; -} - -void XRelocationSetSelectorGroup::semi_sort() { - // Semi-sort live pages by number of live bytes in ascending order - const size_t npartitions_shift = 11; - const size_t npartitions = (size_t)1 << npartitions_shift; - const size_t partition_size = _page_size >> npartitions_shift; - const size_t partition_size_shift = exact_log2(partition_size); - - // Partition slots/fingers - int partitions[npartitions] = { /* zero initialize */ }; - - // Calculate partition slots - XArrayIterator iter1(&_live_pages); - for (XPage* page; iter1.next(&page);) { - const size_t index = page->live_bytes() >> partition_size_shift; - partitions[index]++; - } - - // Calculate partition fingers - int finger = 0; - for (size_t i = 0; i < npartitions; i++) { - const int slots = partitions[i]; - partitions[i] = finger; - finger += slots; - } - - // Allocate destination array - const int npages = _live_pages.length(); - XArray sorted_live_pages(npages, npages, nullptr); - - // Sort pages into partitions - XArrayIterator iter2(&_live_pages); - for (XPage* page; iter2.next(&page);) { - const size_t index = page->live_bytes() >> partition_size_shift; - const int finger = partitions[index]++; - assert(sorted_live_pages.at(finger) == nullptr, "Invalid finger"); - sorted_live_pages.at_put(finger, page); - } - - _live_pages.swap(&sorted_live_pages); -} - -void XRelocationSetSelectorGroup::select_inner() { - // Calculate the number of pages to relocate by successively including pages in - // a candidate relocation set and calculate the maximum space requirement for - // their live objects. - const int npages = _live_pages.length(); - int selected_from = 0; - int selected_to = 0; - size_t npages_selected = 0; - size_t selected_live_bytes = 0; - size_t selected_forwarding_entries = 0; - size_t from_live_bytes = 0; - size_t from_forwarding_entries = 0; - - semi_sort(); - - for (int from = 1; from <= npages; from++) { - // Add page to the candidate relocation set - XPage* const page = _live_pages.at(from - 1); - from_live_bytes += page->live_bytes(); - from_forwarding_entries += XForwarding::nentries(page); - - // Calculate the maximum number of pages needed by the candidate relocation set. - // By subtracting the object size limit from the pages size we get the maximum - // number of pages that the relocation set is guaranteed to fit in, regardless - // of in which order the objects are relocated. - const int to = ceil((double)(from_live_bytes) / (double)(_page_size - _object_size_limit)); - - // Calculate the relative difference in reclaimable space compared to our - // currently selected final relocation set. If this number is larger than the - // acceptable fragmentation limit, then the current candidate relocation set - // becomes our new final relocation set. - const int diff_from = from - selected_from; - const int diff_to = to - selected_to; - const double diff_reclaimable = 100 - percent_of(diff_to, diff_from); - if (diff_reclaimable > ZFragmentationLimit) { - selected_from = from; - selected_to = to; - selected_live_bytes = from_live_bytes; - npages_selected += 1; - selected_forwarding_entries = from_forwarding_entries; - } - - log_trace(gc, reloc)("Candidate Relocation Set (%s Pages): %d->%d, " - "%.1f%% relative defragmentation, " SIZE_FORMAT " forwarding entries, %s", - _name, from, to, diff_reclaimable, from_forwarding_entries, - (selected_from == from) ? "Selected" : "Rejected"); - } - - // Finalize selection - _live_pages.trunc_to(selected_from); - _forwarding_entries = selected_forwarding_entries; - - // Update statistics - _stats._relocate = selected_live_bytes; - _stats._npages_selected = npages_selected; - - log_trace(gc, reloc)("Relocation Set (%s Pages): %d->%d, %d skipped, " SIZE_FORMAT " forwarding entries", - _name, selected_from, selected_to, npages - selected_from, selected_forwarding_entries); -} - -void XRelocationSetSelectorGroup::select() { - if (is_disabled()) { - return; - } - - EventZRelocationSetGroup event; - - if (is_selectable()) { - select_inner(); - } - - // Send event - event.commit(_page_type, _stats.npages_candidates(), _stats.total(), _stats.empty(), _stats.npages_selected(), _stats.relocate()); -} - -XRelocationSetSelector::XRelocationSetSelector() : - _small("Small", XPageTypeSmall, XPageSizeSmall, XObjectSizeLimitSmall), - _medium("Medium", XPageTypeMedium, XPageSizeMedium, XObjectSizeLimitMedium), - _large("Large", XPageTypeLarge, 0 /* page_size */, 0 /* object_size_limit */), - _empty_pages() {} - -void XRelocationSetSelector::select() { - // Select pages to relocate. The resulting relocation set will be - // sorted such that medium pages comes first, followed by small - // pages. Pages within each page group will be semi-sorted by live - // bytes in ascending order. Relocating pages in this order allows - // us to start reclaiming memory more quickly. - - EventZRelocationSet event; - - // Select pages from each group - _large.select(); - _medium.select(); - _small.select(); - - // Send event - event.commit(total(), empty(), relocate()); -} - -XRelocationSetSelectorStats XRelocationSetSelector::stats() const { - XRelocationSetSelectorStats stats; - stats._small = _small.stats(); - stats._medium = _medium.stats(); - stats._large = _large.stats(); - return stats; -} diff --git a/src/hotspot/share/gc/x/xRelocationSetSelector.hpp b/src/hotspot/share/gc/x/xRelocationSetSelector.hpp deleted file mode 100644 index 75e40eeea8c..00000000000 --- a/src/hotspot/share/gc/x/xRelocationSetSelector.hpp +++ /dev/null @@ -1,134 +0,0 @@ -/* - * Copyright (c) 2017, 2020, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XRELOCATIONSETSELECTOR_HPP -#define SHARE_GC_X_XRELOCATIONSETSELECTOR_HPP - -#include "gc/x/xArray.hpp" -#include "memory/allocation.hpp" - -class XPage; - -class XRelocationSetSelectorGroupStats { - friend class XRelocationSetSelectorGroup; - -private: - // Candidate set - size_t _npages_candidates; - size_t _total; - size_t _live; - size_t _empty; - - // Selected set - size_t _npages_selected; - size_t _relocate; - -public: - XRelocationSetSelectorGroupStats(); - - size_t npages_candidates() const; - size_t total() const; - size_t live() const; - size_t empty() const; - - size_t npages_selected() const; - size_t relocate() const; -}; - -class XRelocationSetSelectorStats { - friend class XRelocationSetSelector; - -private: - XRelocationSetSelectorGroupStats _small; - XRelocationSetSelectorGroupStats _medium; - XRelocationSetSelectorGroupStats _large; - -public: - const XRelocationSetSelectorGroupStats& small() const; - const XRelocationSetSelectorGroupStats& medium() const; - const XRelocationSetSelectorGroupStats& large() const; -}; - -class XRelocationSetSelectorGroup { -private: - const char* const _name; - const uint8_t _page_type; - const size_t _page_size; - const size_t _object_size_limit; - const size_t _fragmentation_limit; - XArray _live_pages; - size_t _forwarding_entries; - XRelocationSetSelectorGroupStats _stats; - - bool is_disabled(); - bool is_selectable(); - void semi_sort(); - void select_inner(); - -public: - XRelocationSetSelectorGroup(const char* name, - uint8_t page_type, - size_t page_size, - size_t object_size_limit); - - void register_live_page(XPage* page); - void register_empty_page(XPage* page); - void select(); - - const XArray* selected() const; - size_t forwarding_entries() const; - - const XRelocationSetSelectorGroupStats& stats() const; -}; - -class XRelocationSetSelector : public StackObj { -private: - XRelocationSetSelectorGroup _small; - XRelocationSetSelectorGroup _medium; - XRelocationSetSelectorGroup _large; - XArray _empty_pages; - - size_t total() const; - size_t empty() const; - size_t relocate() const; - -public: - XRelocationSetSelector(); - - void register_live_page(XPage* page); - void register_empty_page(XPage* page); - - bool should_free_empty_pages(int bulk) const; - const XArray* empty_pages() const; - void clear_empty_pages(); - - void select(); - - const XArray* small() const; - const XArray* medium() const; - size_t forwarding_entries() const; - - XRelocationSetSelectorStats stats() const; -}; - -#endif // SHARE_GC_X_XRELOCATIONSETSELECTOR_HPP diff --git a/src/hotspot/share/gc/x/xRelocationSetSelector.inline.hpp b/src/hotspot/share/gc/x/xRelocationSetSelector.inline.hpp deleted file mode 100644 index 25e0ede835d..00000000000 --- a/src/hotspot/share/gc/x/xRelocationSetSelector.inline.hpp +++ /dev/null @@ -1,165 +0,0 @@ -/* - * Copyright (c) 2020, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XRELOCATIONSETSELECTOR_INLINE_HPP -#define SHARE_GC_X_XRELOCATIONSETSELECTOR_INLINE_HPP - -#include "gc/x/xRelocationSetSelector.hpp" - -#include "gc/x/xArray.inline.hpp" -#include "gc/x/xPage.inline.hpp" - -inline size_t XRelocationSetSelectorGroupStats::npages_candidates() const { - return _npages_candidates; -} - -inline size_t XRelocationSetSelectorGroupStats::total() const { - return _total; -} - -inline size_t XRelocationSetSelectorGroupStats::live() const { - return _live; -} - -inline size_t XRelocationSetSelectorGroupStats::empty() const { - return _empty; -} - -inline size_t XRelocationSetSelectorGroupStats::npages_selected() const { - return _npages_selected; -} - -inline size_t XRelocationSetSelectorGroupStats::relocate() const { - return _relocate; -} - -inline const XRelocationSetSelectorGroupStats& XRelocationSetSelectorStats::small() const { - return _small; -} - -inline const XRelocationSetSelectorGroupStats& XRelocationSetSelectorStats::medium() const { - return _medium; -} - -inline const XRelocationSetSelectorGroupStats& XRelocationSetSelectorStats::large() const { - return _large; -} - -inline void XRelocationSetSelectorGroup::register_live_page(XPage* page) { - const uint8_t type = page->type(); - const size_t size = page->size(); - const size_t live = page->live_bytes(); - const size_t garbage = size - live; - - if (garbage > _fragmentation_limit) { - _live_pages.append(page); - } - - _stats._npages_candidates++; - _stats._total += size; - _stats._live += live; -} - -inline void XRelocationSetSelectorGroup::register_empty_page(XPage* page) { - const size_t size = page->size(); - - _stats._npages_candidates++; - _stats._total += size; - _stats._empty += size; -} - -inline const XArray* XRelocationSetSelectorGroup::selected() const { - return &_live_pages; -} - -inline size_t XRelocationSetSelectorGroup::forwarding_entries() const { - return _forwarding_entries; -} - -inline const XRelocationSetSelectorGroupStats& XRelocationSetSelectorGroup::stats() const { - return _stats; -} - -inline void XRelocationSetSelector::register_live_page(XPage* page) { - const uint8_t type = page->type(); - - if (type == XPageTypeSmall) { - _small.register_live_page(page); - } else if (type == XPageTypeMedium) { - _medium.register_live_page(page); - } else { - _large.register_live_page(page); - } -} - -inline void XRelocationSetSelector::register_empty_page(XPage* page) { - const uint8_t type = page->type(); - - if (type == XPageTypeSmall) { - _small.register_empty_page(page); - } else if (type == XPageTypeMedium) { - _medium.register_empty_page(page); - } else { - _large.register_empty_page(page); - } - - _empty_pages.append(page); -} - -inline bool XRelocationSetSelector::should_free_empty_pages(int bulk) const { - return _empty_pages.length() >= bulk && _empty_pages.is_nonempty(); -} - -inline const XArray* XRelocationSetSelector::empty_pages() const { - return &_empty_pages; -} - -inline void XRelocationSetSelector::clear_empty_pages() { - return _empty_pages.clear(); -} - -inline size_t XRelocationSetSelector::total() const { - return _small.stats().total() + _medium.stats().total() + _large.stats().total(); -} - -inline size_t XRelocationSetSelector::empty() const { - return _small.stats().empty() + _medium.stats().empty() + _large.stats().empty(); -} - -inline size_t XRelocationSetSelector::relocate() const { - return _small.stats().relocate() + _medium.stats().relocate() + _large.stats().relocate(); -} - -inline const XArray* XRelocationSetSelector::small() const { - return _small.selected(); -} - -inline const XArray* XRelocationSetSelector::medium() const { - return _medium.selected(); -} - -inline size_t XRelocationSetSelector::forwarding_entries() const { - return _small.forwarding_entries() + _medium.forwarding_entries(); -} - -#endif // SHARE_GC_X_XRELOCATIONSETSELECTOR_INLINE_HPP diff --git a/src/hotspot/share/gc/x/xResurrection.cpp b/src/hotspot/share/gc/x/xResurrection.cpp deleted file mode 100644 index 486f1f8db82..00000000000 --- a/src/hotspot/share/gc/x/xResurrection.cpp +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2016, 2022, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/x/xResurrection.hpp" -#include "runtime/atomic.hpp" -#include "runtime/safepoint.hpp" -#include "utilities/debug.hpp" - -volatile bool XResurrection::_blocked = false; - -void XResurrection::block() { - assert(SafepointSynchronize::is_at_safepoint(), "Should be at safepoint"); - _blocked = true; -} - -void XResurrection::unblock() { - // No need for anything stronger than a relaxed store here. - // The preceding handshake makes sure that all non-strong - // oops have already been healed at this point. - Atomic::store(&_blocked, false); -} diff --git a/src/hotspot/share/gc/x/xResurrection.hpp b/src/hotspot/share/gc/x/xResurrection.hpp deleted file mode 100644 index d6ce9820e02..00000000000 --- a/src/hotspot/share/gc/x/xResurrection.hpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2016, 2022, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XRESURRECTION_HPP -#define SHARE_GC_X_XRESURRECTION_HPP - -#include "memory/allStatic.hpp" - -class XResurrection : public AllStatic { -private: - static volatile bool _blocked; - -public: - static bool is_blocked(); - static void block(); - static void unblock(); -}; - -#endif // SHARE_GC_X_XRESURRECTION_HPP diff --git a/src/hotspot/share/gc/x/xResurrection.inline.hpp b/src/hotspot/share/gc/x/xResurrection.inline.hpp deleted file mode 100644 index af1993945cc..00000000000 --- a/src/hotspot/share/gc/x/xResurrection.inline.hpp +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Copyright (c) 2016, 2018, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XRESURRECTION_INLINE_HPP -#define SHARE_GC_X_XRESURRECTION_INLINE_HPP - -#include "gc/x/xResurrection.hpp" - -#include "runtime/atomic.hpp" - -inline bool XResurrection::is_blocked() { - return Atomic::load(&_blocked); -} - -#endif // SHARE_GC_X_XRESURRECTION_INLINE_HPP diff --git a/src/hotspot/share/gc/x/xRootsIterator.cpp b/src/hotspot/share/gc/x/xRootsIterator.cpp deleted file mode 100644 index 4eaeb8e77c2..00000000000 --- a/src/hotspot/share/gc/x/xRootsIterator.cpp +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright (c) 2015, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "classfile/classLoaderDataGraph.hpp" -#include "gc/shared/oopStorageSetParState.inline.hpp" -#include "gc/x/xNMethod.hpp" -#include "gc/x/xNMethodTable.hpp" -#include "gc/x/xRootsIterator.hpp" -#include "gc/x/xStat.hpp" -#include "memory/resourceArea.hpp" -#include "prims/jvmtiTagMap.hpp" -#include "runtime/atomic.hpp" -#include "runtime/globals.hpp" -#include "runtime/safepoint.hpp" -#include "utilities/debug.hpp" - -static const XStatSubPhase XSubPhaseConcurrentRootsOopStorageSet("Concurrent Roots OopStorageSet"); -static const XStatSubPhase XSubPhaseConcurrentRootsClassLoaderDataGraph("Concurrent Roots ClassLoaderDataGraph"); -static const XStatSubPhase XSubPhaseConcurrentRootsJavaThreads("Concurrent Roots JavaThreads"); -static const XStatSubPhase XSubPhaseConcurrentRootsCodeCache("Concurrent Roots CodeCache"); -static const XStatSubPhase XSubPhaseConcurrentWeakRootsOopStorageSet("Concurrent Weak Roots OopStorageSet"); - -template -template -void XParallelApply::apply(ClosureType* cl) { - if (!Atomic::load(&_completed)) { - _iter.apply(cl); - if (!Atomic::load(&_completed)) { - Atomic::store(&_completed, true); - } - } -} - -XStrongOopStorageSetIterator::XStrongOopStorageSetIterator() : - _iter() {} - -void XStrongOopStorageSetIterator::apply(OopClosure* cl) { - XStatTimer timer(XSubPhaseConcurrentRootsOopStorageSet); - _iter.oops_do(cl); -} - -void XStrongCLDsIterator::apply(CLDClosure* cl) { - XStatTimer timer(XSubPhaseConcurrentRootsClassLoaderDataGraph); - ClassLoaderDataGraph::always_strong_cld_do(cl); -} - -XJavaThreadsIterator::XJavaThreadsIterator() : - _threads(), - _claimed(0) {} - -uint XJavaThreadsIterator::claim() { - return Atomic::fetch_then_add(&_claimed, 1u); -} - -void XJavaThreadsIterator::apply(ThreadClosure* cl) { - XStatTimer timer(XSubPhaseConcurrentRootsJavaThreads); - - // The resource mark is needed because interpreter oop maps are - // not reused in concurrent mode. Instead, they are temporary and - // resource allocated. - ResourceMark _rm; - - for (uint i = claim(); i < _threads.length(); i = claim()) { - cl->do_thread(_threads.thread_at(i)); - } -} - -XNMethodsIterator::XNMethodsIterator() { - if (!ClassUnloading) { - XNMethod::nmethods_do_begin(); - } -} - -XNMethodsIterator::~XNMethodsIterator() { - if (!ClassUnloading) { - XNMethod::nmethods_do_end(); - } -} - -void XNMethodsIterator::apply(NMethodClosure* cl) { - XStatTimer timer(XSubPhaseConcurrentRootsCodeCache); - XNMethod::nmethods_do(cl); -} - -XRootsIterator::XRootsIterator(int cld_claim) { - if (cld_claim != ClassLoaderData::_claim_none) { - ClassLoaderDataGraph::verify_claimed_marks_cleared(cld_claim); - } -} - -void XRootsIterator::apply(OopClosure* cl, - CLDClosure* cld_cl, - ThreadClosure* thread_cl, - NMethodClosure* nm_cl) { - _oop_storage_set.apply(cl); - _class_loader_data_graph.apply(cld_cl); - _java_threads.apply(thread_cl); - if (!ClassUnloading) { - _nmethods.apply(nm_cl); - } -} - -XWeakOopStorageSetIterator::XWeakOopStorageSetIterator() : - _iter() {} - -void XWeakOopStorageSetIterator::apply(OopClosure* cl) { - XStatTimer timer(XSubPhaseConcurrentWeakRootsOopStorageSet); - _iter.oops_do(cl); -} - -void XWeakOopStorageSetIterator::report_num_dead() { - _iter.report_num_dead(); -} - -void XWeakRootsIterator::report_num_dead() { - _oop_storage_set.iter().report_num_dead(); -} - -void XWeakRootsIterator::apply(OopClosure* cl) { - _oop_storage_set.apply(cl); -} diff --git a/src/hotspot/share/gc/x/xRootsIterator.hpp b/src/hotspot/share/gc/x/xRootsIterator.hpp deleted file mode 100644 index 9adc4c02938..00000000000 --- a/src/hotspot/share/gc/x/xRootsIterator.hpp +++ /dev/null @@ -1,124 +0,0 @@ -/* - * Copyright (c) 2015, 2020, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XROOTSITERATOR_HPP -#define SHARE_GC_X_XROOTSITERATOR_HPP - -#include "gc/shared/oopStorageSetParState.hpp" -#include "logging/log.hpp" -#include "memory/iterator.hpp" -#include "runtime/threadSMR.hpp" - -template -class XParallelApply { -private: - Iterator _iter; - volatile bool _completed; - -public: - XParallelApply() : - _iter(), - _completed(false) {} - - template - void apply(ClosureType* cl); - - Iterator& iter() { - return _iter; - } -}; - -class XStrongOopStorageSetIterator { - OopStorageSetStrongParState _iter; - -public: - XStrongOopStorageSetIterator(); - - void apply(OopClosure* cl); -}; - -class XStrongCLDsIterator { -public: - void apply(CLDClosure* cl); -}; - -class XJavaThreadsIterator { -private: - ThreadsListHandle _threads; - volatile uint _claimed; - - uint claim(); - -public: - XJavaThreadsIterator(); - - void apply(ThreadClosure* cl); -}; - -class XNMethodsIterator { -public: - XNMethodsIterator(); - ~XNMethodsIterator(); - - void apply(NMethodClosure* cl); -}; - -class XRootsIterator { -private: - XParallelApply _oop_storage_set; - XParallelApply _class_loader_data_graph; - XParallelApply _java_threads; - XParallelApply _nmethods; - -public: - XRootsIterator(int cld_claim); - - void apply(OopClosure* cl, - CLDClosure* cld_cl, - ThreadClosure* thread_cl, - NMethodClosure* nm_cl); -}; - -class XWeakOopStorageSetIterator { -private: - OopStorageSetWeakParState _iter; - -public: - XWeakOopStorageSetIterator(); - - void apply(OopClosure* cl); - - void report_num_dead(); -}; - -class XWeakRootsIterator { -private: - XParallelApply _oop_storage_set; - -public: - void apply(OopClosure* cl); - - void report_num_dead(); -}; - -#endif // SHARE_GC_X_XROOTSITERATOR_HPP diff --git a/src/hotspot/share/gc/x/xRuntimeWorkers.cpp b/src/hotspot/share/gc/x/xRuntimeWorkers.cpp deleted file mode 100644 index d7e4a1262fc..00000000000 --- a/src/hotspot/share/gc/x/xRuntimeWorkers.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/* - * Copyright (c) 2018, 2021, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/shared/gcLogPrecious.hpp" -#include "gc/shared/gc_globals.hpp" -#include "gc/x/xLock.inline.hpp" -#include "gc/x/xRuntimeWorkers.hpp" -#include "gc/x/xTask.hpp" -#include "gc/x/xThread.hpp" -#include "runtime/java.hpp" - -class XRuntimeWorkersInitializeTask : public WorkerTask { -private: - const uint _nworkers; - uint _started; - XConditionLock _lock; - -public: - XRuntimeWorkersInitializeTask(uint nworkers) : - WorkerTask("XRuntimeWorkersInitializeTask"), - _nworkers(nworkers), - _started(0), - _lock() {} - - virtual void work(uint worker_id) { - // Wait for all threads to start - XLocker locker(&_lock); - if (++_started == _nworkers) { - // All threads started - _lock.notify_all(); - } else { - while (_started != _nworkers) { - _lock.wait(); - } - } - } -}; - -XRuntimeWorkers::XRuntimeWorkers() : - _workers("RuntimeWorker", - ParallelGCThreads) { - - log_info_p(gc, init)("Runtime Workers: %u", _workers.max_workers()); - - // Initialize worker threads - _workers.initialize_workers(); - _workers.set_active_workers(_workers.max_workers()); - if (_workers.active_workers() != _workers.max_workers()) { - vm_exit_during_initialization("Failed to create XRuntimeWorkers"); - } - - // Execute task to reduce latency in early safepoints, - // which otherwise would have to take on any warmup costs. - XRuntimeWorkersInitializeTask task(_workers.max_workers()); - _workers.run_task(&task); -} - -WorkerThreads* XRuntimeWorkers::workers() { - return &_workers; -} - -void XRuntimeWorkers::threads_do(ThreadClosure* tc) const { - _workers.threads_do(tc); -} diff --git a/src/hotspot/share/gc/x/xRuntimeWorkers.hpp b/src/hotspot/share/gc/x/xRuntimeWorkers.hpp deleted file mode 100644 index 114521d6506..00000000000 --- a/src/hotspot/share/gc/x/xRuntimeWorkers.hpp +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2018, 2021, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XRUNTIMEWORKERS_HPP -#define SHARE_GC_X_XRUNTIMEWORKERS_HPP - -#include "gc/shared/workerThread.hpp" - -class ThreadClosure; - -class XRuntimeWorkers { -private: - WorkerThreads _workers; - -public: - XRuntimeWorkers(); - - WorkerThreads* workers(); - - void threads_do(ThreadClosure* tc) const; -}; - -#endif // SHARE_GC_X_XRUNTIMEWORKERS_HPP diff --git a/src/hotspot/share/gc/x/xSafeDelete.hpp b/src/hotspot/share/gc/x/xSafeDelete.hpp deleted file mode 100644 index c41a38ce187..00000000000 --- a/src/hotspot/share/gc/x/xSafeDelete.hpp +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2019, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XSAFEDELETE_HPP -#define SHARE_GC_X_XSAFEDELETE_HPP - -#include "gc/x/xArray.hpp" -#include "gc/x/xLock.hpp" - -#include - -template -class XSafeDeleteImpl { -private: - using ItemT = std::remove_extent_t; - - XLock* _lock; - uint64_t _enabled; - XArray _deferred; - - bool deferred_delete(ItemT* item); - void immediate_delete(ItemT* item); - -public: - XSafeDeleteImpl(XLock* lock); - - void enable_deferred_delete(); - void disable_deferred_delete(); - - void operator()(ItemT* item); -}; - -template -class XSafeDelete : public XSafeDeleteImpl { -private: - XLock _lock; - -public: - XSafeDelete(); -}; - -template -class XSafeDeleteNoLock : public XSafeDeleteImpl { -public: - XSafeDeleteNoLock(); -}; - -#endif // SHARE_GC_X_XSAFEDELETE_HPP diff --git a/src/hotspot/share/gc/x/xSafeDelete.inline.hpp b/src/hotspot/share/gc/x/xSafeDelete.inline.hpp deleted file mode 100644 index 7e428c710e8..00000000000 --- a/src/hotspot/share/gc/x/xSafeDelete.inline.hpp +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (c) 2019, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XSAFEDELETE_INLINE_HPP -#define SHARE_GC_X_XSAFEDELETE_INLINE_HPP - -#include "gc/x/xSafeDelete.hpp" - -#include "gc/x/xArray.inline.hpp" -#include "utilities/debug.hpp" - -#include - -template -XSafeDeleteImpl::XSafeDeleteImpl(XLock* lock) : - _lock(lock), - _enabled(0), - _deferred() {} - -template -bool XSafeDeleteImpl::deferred_delete(ItemT* item) { - XLocker locker(_lock); - if (_enabled > 0) { - _deferred.append(item); - return true; - } - - return false; -} - -template -void XSafeDeleteImpl::immediate_delete(ItemT* item) { - if (std::is_array::value) { - delete [] item; - } else { - delete item; - } -} - -template -void XSafeDeleteImpl::enable_deferred_delete() { - XLocker locker(_lock); - _enabled++; -} - -template -void XSafeDeleteImpl::disable_deferred_delete() { - XArray deferred; - - { - XLocker locker(_lock); - assert(_enabled > 0, "Invalid state"); - if (--_enabled == 0) { - deferred.swap(&_deferred); - } - } - - XArrayIterator iter(&deferred); - for (ItemT* item; iter.next(&item);) { - immediate_delete(item); - } -} - -template -void XSafeDeleteImpl::operator()(ItemT* item) { - if (!deferred_delete(item)) { - immediate_delete(item); - } -} - -template -XSafeDelete::XSafeDelete() : - XSafeDeleteImpl(&_lock), - _lock() {} - -template -XSafeDeleteNoLock::XSafeDeleteNoLock() : - XSafeDeleteImpl(nullptr) {} - -#endif // SHARE_GC_X_XSAFEDELETE_INLINE_HPP diff --git a/src/hotspot/share/gc/x/xServiceability.cpp b/src/hotspot/share/gc/x/xServiceability.cpp deleted file mode 100644 index f3b51b6bb4a..00000000000 --- a/src/hotspot/share/gc/x/xServiceability.cpp +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Copyright (c) 2017, 2021, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/shared/generationCounters.hpp" -#include "gc/shared/hSpaceCounters.hpp" -#include "gc/x/xCollectedHeap.hpp" -#include "gc/x/xHeap.inline.hpp" -#include "gc/x/xServiceability.hpp" -#include "memory/metaspaceCounters.hpp" -#include "runtime/perfData.hpp" - -class XGenerationCounters : public GenerationCounters { -public: - XGenerationCounters(const char* name, int ordinal, int spaces, - size_t min_capacity, size_t max_capacity, size_t curr_capacity) : - GenerationCounters(name, ordinal, spaces, - min_capacity, max_capacity, curr_capacity) {} - - void update_capacity(size_t capacity) { - _current_size->set_value(capacity); - } -}; - -// Class to expose perf counters used by jstat. -class XServiceabilityCounters : public CHeapObj { -private: - XGenerationCounters _generation_counters; - HSpaceCounters _space_counters; - CollectorCounters _collector_counters; - -public: - XServiceabilityCounters(size_t min_capacity, size_t max_capacity); - - CollectorCounters* collector_counters(); - - void update_sizes(); -}; - -XServiceabilityCounters::XServiceabilityCounters(size_t min_capacity, size_t max_capacity) : - // generation.1 - _generation_counters("old" /* name */, - 1 /* ordinal */, - 1 /* spaces */, - min_capacity /* min_capacity */, - max_capacity /* max_capacity */, - min_capacity /* curr_capacity */), - // generation.1.space.0 - _space_counters(_generation_counters.name_space(), - "space" /* name */, - 0 /* ordinal */, - max_capacity /* max_capacity */, - min_capacity /* init_capacity */), - // gc.collector.2 - _collector_counters("Z concurrent cycle pauses" /* name */, - 2 /* ordinal */) {} - -CollectorCounters* XServiceabilityCounters::collector_counters() { - return &_collector_counters; -} - -void XServiceabilityCounters::update_sizes() { - if (UsePerfData) { - const size_t capacity = XHeap::heap()->capacity(); - const size_t used = MIN2(XHeap::heap()->used(), capacity); - - _generation_counters.update_capacity(capacity); - _space_counters.update_capacity(capacity); - _space_counters.update_used(used); - - MetaspaceCounters::update_performance_counters(); - } -} - -XServiceabilityMemoryPool::XServiceabilityMemoryPool(size_t min_capacity, size_t max_capacity) : - CollectedMemoryPool("ZHeap", - min_capacity, - max_capacity, - true /* support_usage_threshold */) {} - -size_t XServiceabilityMemoryPool::used_in_bytes() { - return XHeap::heap()->used(); -} - -MemoryUsage XServiceabilityMemoryPool::get_memory_usage() { - const size_t committed = XHeap::heap()->capacity(); - const size_t used = MIN2(XHeap::heap()->used(), committed); - - return MemoryUsage(initial_size(), used, committed, max_size()); -} - -XServiceabilityMemoryManager::XServiceabilityMemoryManager(const char* name, - XServiceabilityMemoryPool* pool) : - GCMemoryManager(name) { - add_pool(pool); -} - -XServiceability::XServiceability(size_t min_capacity, size_t max_capacity) : - _min_capacity(min_capacity), - _max_capacity(max_capacity), - _memory_pool(_min_capacity, _max_capacity), - _cycle_memory_manager("ZGC Cycles", &_memory_pool), - _pause_memory_manager("ZGC Pauses", &_memory_pool), - _counters(nullptr) {} - -void XServiceability::initialize() { - _counters = new XServiceabilityCounters(_min_capacity, _max_capacity); -} - -MemoryPool* XServiceability::memory_pool() { - return &_memory_pool; -} - -GCMemoryManager* XServiceability::cycle_memory_manager() { - return &_cycle_memory_manager; -} - -GCMemoryManager* XServiceability::pause_memory_manager() { - return &_pause_memory_manager; -} - -XServiceabilityCounters* XServiceability::counters() { - return _counters; -} - -XServiceabilityCycleTracer::XServiceabilityCycleTracer() : - _memory_manager_stats(XHeap::heap()->serviceability_cycle_memory_manager(), - XCollectedHeap::heap()->gc_cause(), - "end of GC cycle", - true /* allMemoryPoolsAffected */, - true /* recordGCBeginTime */, - true /* recordPreGCUsage */, - true /* recordPeakUsage */, - true /* recordPostGCUsage */, - true /* recordAccumulatedGCTime */, - true /* recordGCEndTime */, - true /* countCollection */) {} - -XServiceabilityPauseTracer::XServiceabilityPauseTracer() : - _svc_gc_marker(SvcGCMarker::CONCURRENT), - _counters_stats(XHeap::heap()->serviceability_counters()->collector_counters()), - _memory_manager_stats(XHeap::heap()->serviceability_pause_memory_manager(), - XCollectedHeap::heap()->gc_cause(), - "end of GC pause", - true /* allMemoryPoolsAffected */, - true /* recordGCBeginTime */, - false /* recordPreGCUsage */, - false /* recordPeakUsage */, - false /* recordPostGCUsage */, - true /* recordAccumulatedGCTime */, - true /* recordGCEndTime */, - true /* countCollection */) {} - -XServiceabilityPauseTracer::~XServiceabilityPauseTracer() { - XHeap::heap()->serviceability_counters()->update_sizes(); - MemoryService::track_memory_usage(); -} diff --git a/src/hotspot/share/gc/x/xServiceability.hpp b/src/hotspot/share/gc/x/xServiceability.hpp deleted file mode 100644 index d8e2fc9ba79..00000000000 --- a/src/hotspot/share/gc/x/xServiceability.hpp +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2017, 2021, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XSERVICEABILITY_HPP -#define SHARE_GC_X_XSERVICEABILITY_HPP - -#include "gc/shared/collectorCounters.hpp" -#include "gc/shared/gcVMOperations.hpp" -#include "memory/allocation.hpp" -#include "services/memoryManager.hpp" -#include "services/memoryPool.hpp" -#include "services/memoryService.hpp" - -class XServiceabilityCounters; - -class XServiceabilityMemoryPool : public CollectedMemoryPool { -public: - XServiceabilityMemoryPool(size_t min_capacity, size_t max_capacity); - - virtual size_t used_in_bytes(); - virtual MemoryUsage get_memory_usage(); -}; - -class XServiceabilityMemoryManager : public GCMemoryManager { -public: - XServiceabilityMemoryManager(const char* name, - XServiceabilityMemoryPool* pool); -}; - -class XServiceability { -private: - const size_t _min_capacity; - const size_t _max_capacity; - XServiceabilityMemoryPool _memory_pool; - XServiceabilityMemoryManager _cycle_memory_manager; - XServiceabilityMemoryManager _pause_memory_manager; - XServiceabilityCounters* _counters; - -public: - XServiceability(size_t min_capacity, size_t max_capacity); - - void initialize(); - - MemoryPool* memory_pool(); - GCMemoryManager* cycle_memory_manager(); - GCMemoryManager* pause_memory_manager(); - XServiceabilityCounters* counters(); -}; - -class XServiceabilityCycleTracer : public StackObj { -private: - TraceMemoryManagerStats _memory_manager_stats; - -public: - XServiceabilityCycleTracer(); -}; - -class XServiceabilityPauseTracer : public StackObj { -private: - SvcGCMarker _svc_gc_marker; - TraceCollectorStats _counters_stats; - TraceMemoryManagerStats _memory_manager_stats; - -public: - XServiceabilityPauseTracer(); - ~XServiceabilityPauseTracer(); -}; - -#endif // SHARE_GC_X_XSERVICEABILITY_HPP diff --git a/src/hotspot/share/gc/x/xStackWatermark.cpp b/src/hotspot/share/gc/x/xStackWatermark.cpp deleted file mode 100644 index b75113a7529..00000000000 --- a/src/hotspot/share/gc/x/xStackWatermark.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) 2020, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/x/xAddress.hpp" -#include "gc/x/xBarrier.inline.hpp" -#include "gc/x/xStackWatermark.hpp" -#include "gc/x/xThread.inline.hpp" -#include "gc/x/xThreadLocalAllocBuffer.hpp" -#include "gc/x/xThreadLocalData.hpp" -#include "gc/x/xVerify.hpp" -#include "memory/resourceArea.inline.hpp" -#include "runtime/frame.inline.hpp" -#include "utilities/preserveException.hpp" - -XOnStackNMethodClosure::XOnStackNMethodClosure() : - _bs_nm(BarrierSet::barrier_set()->barrier_set_nmethod()) {} - -void XOnStackNMethodClosure::do_nmethod(nmethod* nm) { - const bool result = _bs_nm->nmethod_entry_barrier(nm); - assert(result, "NMethod on-stack must be alive"); -} - -ThreadLocalAllocStats& XStackWatermark::stats() { - return _stats; -} - -uint32_t XStackWatermark::epoch_id() const { - return *XAddressBadMaskHighOrderBitsAddr; -} - -XStackWatermark::XStackWatermark(JavaThread* jt) : - StackWatermark(jt, StackWatermarkKind::gc, *XAddressBadMaskHighOrderBitsAddr), - _jt_cl(), - _nm_cl(), - _stats() {} - -OopClosure* XStackWatermark::closure_from_context(void* context) { - if (context != nullptr) { - assert(XThread::is_worker(), "Unexpected thread passing in context: " PTR_FORMAT, p2i(context)); - return reinterpret_cast(context); - } else { - return &_jt_cl; - } -} - -void XStackWatermark::start_processing_impl(void* context) { - // Verify the head (no_frames) of the thread is bad before fixing it. - XVerify::verify_thread_head_bad(_jt); - - // Process the non-frame part of the thread - _jt->oops_do_no_frames(closure_from_context(context), &_nm_cl); - XThreadLocalData::do_invisible_root(_jt, XBarrier::load_barrier_on_invisible_root_oop_field); - - // Verification of frames is done after processing of the "head" (no_frames). - // The reason is that the exception oop is fiddled with during frame processing. - XVerify::verify_thread_frames_bad(_jt); - - // Update thread local address bad mask - XThreadLocalData::set_address_bad_mask(_jt, XAddressBadMask); - - // Retire TLAB - if (XGlobalPhase == XPhaseMark) { - XThreadLocalAllocBuffer::retire(_jt, &_stats); - } else { - XThreadLocalAllocBuffer::remap(_jt); - } - - // Publishes the processing start to concurrent threads - StackWatermark::start_processing_impl(context); -} - -void XStackWatermark::process(const frame& fr, RegisterMap& register_map, void* context) { - XVerify::verify_frame_bad(fr, register_map); - fr.oops_do(closure_from_context(context), &_nm_cl, ®ister_map, DerivedPointerIterationMode::_directly); -} diff --git a/src/hotspot/share/gc/x/xStackWatermark.hpp b/src/hotspot/share/gc/x/xStackWatermark.hpp deleted file mode 100644 index 9b73860bed0..00000000000 --- a/src/hotspot/share/gc/x/xStackWatermark.hpp +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2020, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XSTACKWATERMARK_HPP -#define SHARE_GC_X_XSTACKWATERMARK_HPP - -#include "gc/shared/barrierSet.hpp" -#include "gc/shared/barrierSetNMethod.hpp" -#include "gc/shared/threadLocalAllocBuffer.hpp" -#include "gc/x/xBarrier.hpp" -#include "memory/allocation.hpp" -#include "memory/iterator.hpp" -#include "oops/oopsHierarchy.hpp" -#include "runtime/stackWatermark.hpp" -#include "utilities/globalDefinitions.hpp" - -class frame; -class JavaThread; - -class XOnStackNMethodClosure : public NMethodClosure { -private: - BarrierSetNMethod* _bs_nm; - - virtual void do_nmethod(nmethod* nm); - -public: - XOnStackNMethodClosure(); -}; - -class XStackWatermark : public StackWatermark { -private: - XLoadBarrierOopClosure _jt_cl; - XOnStackNMethodClosure _nm_cl; - ThreadLocalAllocStats _stats; - - OopClosure* closure_from_context(void* context); - - virtual uint32_t epoch_id() const; - virtual void start_processing_impl(void* context); - virtual void process(const frame& fr, RegisterMap& register_map, void* context); - -public: - XStackWatermark(JavaThread* jt); - - ThreadLocalAllocStats& stats(); -}; - -#endif // SHARE_GC_X_XSTACKWATERMARK_HPP diff --git a/src/hotspot/share/gc/x/xStat.cpp b/src/hotspot/share/gc/x/xStat.cpp deleted file mode 100644 index c445e951397..00000000000 --- a/src/hotspot/share/gc/x/xStat.cpp +++ /dev/null @@ -1,1513 +0,0 @@ -/* - * Copyright (c) 2015, 2021, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/shared/gc_globals.hpp" -#include "gc/x/xAbort.inline.hpp" -#include "gc/x/xCollectedHeap.hpp" -#include "gc/x/xCPU.inline.hpp" -#include "gc/x/xGlobals.hpp" -#include "gc/x/xNMethodTable.hpp" -#include "gc/x/xPageAllocator.inline.hpp" -#include "gc/x/xRelocationSetSelector.inline.hpp" -#include "gc/x/xStat.hpp" -#include "gc/x/xThread.inline.hpp" -#include "gc/x/xTracer.inline.hpp" -#include "gc/x/xUtils.hpp" -#include "memory/metaspaceUtils.hpp" -#include "memory/resourceArea.hpp" -#include "runtime/atomic.hpp" -#include "runtime/os.hpp" -#include "runtime/timer.hpp" -#include "utilities/align.hpp" -#include "utilities/debug.hpp" -#include "utilities/ticks.hpp" - -#define XSIZE_FMT SIZE_FORMAT "M(%.0f%%)" -#define XSIZE_ARGS_WITH_MAX(size, max) ((size) / M), (percent_of(size, max)) -#define XSIZE_ARGS(size) XSIZE_ARGS_WITH_MAX(size, XStatHeap::max_capacity()) - -#define XTABLE_ARGS_NA "%9s", "-" -#define XTABLE_ARGS(size) SIZE_FORMAT_W(8) "M (%.0f%%)", \ - ((size) / M), (percent_of(size, XStatHeap::max_capacity())) - -// -// Stat sampler/counter data -// -struct XStatSamplerData { - uint64_t _nsamples; - uint64_t _sum; - uint64_t _max; - - XStatSamplerData() : - _nsamples(0), - _sum(0), - _max(0) {} - - void add(const XStatSamplerData& new_sample) { - _nsamples += new_sample._nsamples; - _sum += new_sample._sum; - _max = MAX2(_max, new_sample._max); - } -}; - -struct XStatCounterData { - uint64_t _counter; - - XStatCounterData() : - _counter(0) {} -}; - -// -// Stat sampler history -// -template -class XStatSamplerHistoryInterval { -private: - size_t _next; - XStatSamplerData _samples[size]; - XStatSamplerData _accumulated; - XStatSamplerData _total; - -public: - XStatSamplerHistoryInterval() : - _next(0), - _samples(), - _accumulated(), - _total() {} - - bool add(const XStatSamplerData& new_sample) { - // Insert sample - const XStatSamplerData old_sample = _samples[_next]; - _samples[_next] = new_sample; - - // Adjust accumulated - _accumulated._nsamples += new_sample._nsamples; - _accumulated._sum += new_sample._sum; - _accumulated._max = MAX2(_accumulated._max, new_sample._max); - - // Adjust total - _total._nsamples -= old_sample._nsamples; - _total._sum -= old_sample._sum; - _total._nsamples += new_sample._nsamples; - _total._sum += new_sample._sum; - if (_total._max < new_sample._max) { - // Found new max - _total._max = new_sample._max; - } else if (_total._max == old_sample._max) { - // Removed old max, reset and find new max - _total._max = 0; - for (size_t i = 0; i < size; i++) { - if (_total._max < _samples[i]._max) { - _total._max = _samples[i]._max; - } - } - } - - // Adjust next - if (++_next == size) { - _next = 0; - - // Clear accumulated - const XStatSamplerData zero; - _accumulated = zero; - - // Became full - return true; - } - - // Not yet full - return false; - } - - const XStatSamplerData& total() const { - return _total; - } - - const XStatSamplerData& accumulated() const { - return _accumulated; - } -}; - -class XStatSamplerHistory : public CHeapObj { -private: - XStatSamplerHistoryInterval<10> _10seconds; - XStatSamplerHistoryInterval<60> _10minutes; - XStatSamplerHistoryInterval<60> _10hours; - XStatSamplerData _total; - - uint64_t avg(uint64_t sum, uint64_t nsamples) const { - return (nsamples > 0) ? sum / nsamples : 0; - } - -public: - XStatSamplerHistory() : - _10seconds(), - _10minutes(), - _10hours(), - _total() {} - - void add(const XStatSamplerData& new_sample) { - if (_10seconds.add(new_sample)) { - if (_10minutes.add(_10seconds.total())) { - if (_10hours.add(_10minutes.total())) { - _total.add(_10hours.total()); - } - } - } - } - - uint64_t avg_10_seconds() const { - const uint64_t sum = _10seconds.total()._sum; - const uint64_t nsamples = _10seconds.total()._nsamples; - return avg(sum, nsamples); - } - - uint64_t avg_10_minutes() const { - const uint64_t sum = _10seconds.accumulated()._sum + - _10minutes.total()._sum; - const uint64_t nsamples = _10seconds.accumulated()._nsamples + - _10minutes.total()._nsamples; - return avg(sum, nsamples); - } - - uint64_t avg_10_hours() const { - const uint64_t sum = _10seconds.accumulated()._sum + - _10minutes.accumulated()._sum + - _10hours.total()._sum; - const uint64_t nsamples = _10seconds.accumulated()._nsamples + - _10minutes.accumulated()._nsamples + - _10hours.total()._nsamples; - return avg(sum, nsamples); - } - - uint64_t avg_total() const { - const uint64_t sum = _10seconds.accumulated()._sum + - _10minutes.accumulated()._sum + - _10hours.accumulated()._sum + - _total._sum; - const uint64_t nsamples = _10seconds.accumulated()._nsamples + - _10minutes.accumulated()._nsamples + - _10hours.accumulated()._nsamples + - _total._nsamples; - return avg(sum, nsamples); - } - - uint64_t max_10_seconds() const { - return _10seconds.total()._max; - } - - uint64_t max_10_minutes() const { - return MAX2(_10seconds.accumulated()._max, - _10minutes.total()._max); - } - - uint64_t max_10_hours() const { - return MAX3(_10seconds.accumulated()._max, - _10minutes.accumulated()._max, - _10hours.total()._max); - } - - uint64_t max_total() const { - return MAX4(_10seconds.accumulated()._max, - _10minutes.accumulated()._max, - _10hours.accumulated()._max, - _total._max); - } -}; - -// -// Stat unit printers -// -void XStatUnitTime(LogTargetHandle log, const XStatSampler& sampler, const XStatSamplerHistory& history) { - log.print(" %10s: %-41s " - "%9.3f / %-9.3f " - "%9.3f / %-9.3f " - "%9.3f / %-9.3f " - "%9.3f / %-9.3f ms", - sampler.group(), - sampler.name(), - TimeHelper::counter_to_millis(history.avg_10_seconds()), - TimeHelper::counter_to_millis(history.max_10_seconds()), - TimeHelper::counter_to_millis(history.avg_10_minutes()), - TimeHelper::counter_to_millis(history.max_10_minutes()), - TimeHelper::counter_to_millis(history.avg_10_hours()), - TimeHelper::counter_to_millis(history.max_10_hours()), - TimeHelper::counter_to_millis(history.avg_total()), - TimeHelper::counter_to_millis(history.max_total())); -} - -void XStatUnitBytes(LogTargetHandle log, const XStatSampler& sampler, const XStatSamplerHistory& history) { - log.print(" %10s: %-41s " - UINT64_FORMAT_W(9) " / " UINT64_FORMAT_W(-9) " " - UINT64_FORMAT_W(9) " / " UINT64_FORMAT_W(-9) " " - UINT64_FORMAT_W(9) " / " UINT64_FORMAT_W(-9) " " - UINT64_FORMAT_W(9) " / " UINT64_FORMAT_W(-9) " MB", - sampler.group(), - sampler.name(), - history.avg_10_seconds() / M, - history.max_10_seconds() / M, - history.avg_10_minutes() / M, - history.max_10_minutes() / M, - history.avg_10_hours() / M, - history.max_10_hours() / M, - history.avg_total() / M, - history.max_total() / M); -} - -void XStatUnitThreads(LogTargetHandle log, const XStatSampler& sampler, const XStatSamplerHistory& history) { - log.print(" %10s: %-41s " - UINT64_FORMAT_W(9) " / " UINT64_FORMAT_W(-9) " " - UINT64_FORMAT_W(9) " / " UINT64_FORMAT_W(-9) " " - UINT64_FORMAT_W(9) " / " UINT64_FORMAT_W(-9) " " - UINT64_FORMAT_W(9) " / " UINT64_FORMAT_W(-9) " threads", - sampler.group(), - sampler.name(), - history.avg_10_seconds(), - history.max_10_seconds(), - history.avg_10_minutes(), - history.max_10_minutes(), - history.avg_10_hours(), - history.max_10_hours(), - history.avg_total(), - history.max_total()); -} - -void XStatUnitBytesPerSecond(LogTargetHandle log, const XStatSampler& sampler, const XStatSamplerHistory& history) { - log.print(" %10s: %-41s " - UINT64_FORMAT_W(9) " / " UINT64_FORMAT_W(-9) " " - UINT64_FORMAT_W(9) " / " UINT64_FORMAT_W(-9) " " - UINT64_FORMAT_W(9) " / " UINT64_FORMAT_W(-9) " " - UINT64_FORMAT_W(9) " / " UINT64_FORMAT_W(-9) " MB/s", - sampler.group(), - sampler.name(), - history.avg_10_seconds() / M, - history.max_10_seconds() / M, - history.avg_10_minutes() / M, - history.max_10_minutes() / M, - history.avg_10_hours() / M, - history.max_10_hours() / M, - history.avg_total() / M, - history.max_total() / M); -} - -void XStatUnitOpsPerSecond(LogTargetHandle log, const XStatSampler& sampler, const XStatSamplerHistory& history) { - log.print(" %10s: %-41s " - UINT64_FORMAT_W(9) " / " UINT64_FORMAT_W(-9) " " - UINT64_FORMAT_W(9) " / " UINT64_FORMAT_W(-9) " " - UINT64_FORMAT_W(9) " / " UINT64_FORMAT_W(-9) " " - UINT64_FORMAT_W(9) " / " UINT64_FORMAT_W(-9) " ops/s", - sampler.group(), - sampler.name(), - history.avg_10_seconds(), - history.max_10_seconds(), - history.avg_10_minutes(), - history.max_10_minutes(), - history.avg_10_hours(), - history.max_10_hours(), - history.avg_total(), - history.max_total()); -} - -// -// Stat value -// -uintptr_t XStatValue::_base = 0; -uint32_t XStatValue::_cpu_offset = 0; - -XStatValue::XStatValue(const char* group, - const char* name, - uint32_t id, - uint32_t size) : - _group(group), - _name(name), - _id(id), - _offset(_cpu_offset) { - assert(_base == 0, "Already initialized"); - _cpu_offset += size; -} - -template -T* XStatValue::get_cpu_local(uint32_t cpu) const { - assert(_base != 0, "Not initialized"); - const uintptr_t cpu_base = _base + (_cpu_offset * cpu); - const uintptr_t value_addr = cpu_base + _offset; - return (T*)value_addr; -} - -void XStatValue::initialize() { - // Finalize and align CPU offset - _cpu_offset = align_up(_cpu_offset, (uint32_t)XCacheLineSize); - - // Allocation aligned memory - const size_t size = _cpu_offset * XCPU::count(); - _base = XUtils::alloc_aligned(XCacheLineSize, size); -} - -const char* XStatValue::group() const { - return _group; -} - -const char* XStatValue::name() const { - return _name; -} - -uint32_t XStatValue::id() const { - return _id; -} - -// -// Stat iterable value -// - -template -XStatIterableValue::XStatIterableValue(const char* group, - const char* name, - uint32_t size) : - XStatValue(group, name, _count++, size), - _next(insert()) {} - -template -T* XStatIterableValue::insert() const { - T* const next = _first; - _first = (T*)this; - return next; -} - -template -void XStatIterableValue::sort() { - T* first_unsorted = _first; - _first = nullptr; - - while (first_unsorted != nullptr) { - T* const value = first_unsorted; - first_unsorted = value->_next; - value->_next = nullptr; - - T** current = &_first; - - while (*current != nullptr) { - // First sort by group, then by name - const int group_cmp = strcmp((*current)->group(), value->group()); - if ((group_cmp > 0) || (group_cmp == 0 && strcmp((*current)->name(), value->name()) > 0)) { - break; - } - - current = &(*current)->_next; - } - value->_next = *current; - *current = value; - } -} - -// -// Stat sampler -// -XStatSampler::XStatSampler(const char* group, const char* name, XStatUnitPrinter printer) : - XStatIterableValue(group, name, sizeof(XStatSamplerData)), - _printer(printer) {} - -XStatSamplerData* XStatSampler::get() const { - return get_cpu_local(XCPU::id()); -} - -XStatSamplerData XStatSampler::collect_and_reset() const { - XStatSamplerData all; - - const uint32_t ncpus = XCPU::count(); - for (uint32_t i = 0; i < ncpus; i++) { - XStatSamplerData* const cpu_data = get_cpu_local(i); - if (cpu_data->_nsamples > 0) { - const uint64_t nsamples = Atomic::xchg(&cpu_data->_nsamples, (uint64_t)0); - const uint64_t sum = Atomic::xchg(&cpu_data->_sum, (uint64_t)0); - const uint64_t max = Atomic::xchg(&cpu_data->_max, (uint64_t)0); - all._nsamples += nsamples; - all._sum += sum; - if (all._max < max) { - all._max = max; - } - } - } - - return all; -} - -XStatUnitPrinter XStatSampler::printer() const { - return _printer; -} - -// -// Stat counter -// -XStatCounter::XStatCounter(const char* group, const char* name, XStatUnitPrinter printer) : - XStatIterableValue(group, name, sizeof(XStatCounterData)), - _sampler(group, name, printer) {} - -XStatCounterData* XStatCounter::get() const { - return get_cpu_local(XCPU::id()); -} - -void XStatCounter::sample_and_reset() const { - uint64_t counter = 0; - - const uint32_t ncpus = XCPU::count(); - for (uint32_t i = 0; i < ncpus; i++) { - XStatCounterData* const cpu_data = get_cpu_local(i); - counter += Atomic::xchg(&cpu_data->_counter, (uint64_t)0); - } - - XStatSample(_sampler, counter); -} - -// -// Stat unsampled counter -// -XStatUnsampledCounter::XStatUnsampledCounter(const char* name) : - XStatIterableValue("Unsampled", name, sizeof(XStatCounterData)) {} - -XStatCounterData* XStatUnsampledCounter::get() const { - return get_cpu_local(XCPU::id()); -} - -XStatCounterData XStatUnsampledCounter::collect_and_reset() const { - XStatCounterData all; - - const uint32_t ncpus = XCPU::count(); - for (uint32_t i = 0; i < ncpus; i++) { - XStatCounterData* const cpu_data = get_cpu_local(i); - all._counter += Atomic::xchg(&cpu_data->_counter, (uint64_t)0); - } - - return all; -} - -// -// Stat MMU (Minimum Mutator Utilization) -// -XStatMMUPause::XStatMMUPause() : - _start(0.0), - _end(0.0) {} - -XStatMMUPause::XStatMMUPause(const Ticks& start, const Ticks& end) : - _start(TimeHelper::counter_to_millis(start.value())), - _end(TimeHelper::counter_to_millis(end.value())) {} - -double XStatMMUPause::end() const { - return _end; -} - -double XStatMMUPause::overlap(double start, double end) const { - const double start_max = MAX2(start, _start); - const double end_min = MIN2(end, _end); - - if (end_min > start_max) { - // Overlap found - return end_min - start_max; - } - - // No overlap - return 0.0; -} - -size_t XStatMMU::_next = 0; -size_t XStatMMU::_npauses = 0; -XStatMMUPause XStatMMU::_pauses[200]; -double XStatMMU::_mmu_2ms = 100.0; -double XStatMMU::_mmu_5ms = 100.0; -double XStatMMU::_mmu_10ms = 100.0; -double XStatMMU::_mmu_20ms = 100.0; -double XStatMMU::_mmu_50ms = 100.0; -double XStatMMU::_mmu_100ms = 100.0; - -const XStatMMUPause& XStatMMU::pause(size_t index) { - return _pauses[(_next - index - 1) % ARRAY_SIZE(_pauses)]; -} - -double XStatMMU::calculate_mmu(double time_slice) { - const double end = pause(0).end(); - const double start = end - time_slice; - double time_paused = 0.0; - - // Find all overlapping pauses - for (size_t i = 0; i < _npauses; i++) { - const double overlap = pause(i).overlap(start, end); - if (overlap == 0.0) { - // No overlap - break; - } - - time_paused += overlap; - } - - // Calculate MMU - const double time_mutator = time_slice - time_paused; - return percent_of(time_mutator, time_slice); -} - -void XStatMMU::register_pause(const Ticks& start, const Ticks& end) { - // Add pause - const size_t index = _next++ % ARRAY_SIZE(_pauses); - _pauses[index] = XStatMMUPause(start, end); - _npauses = MIN2(_npauses + 1, ARRAY_SIZE(_pauses)); - - // Recalculate MMUs - _mmu_2ms = MIN2(_mmu_2ms, calculate_mmu(2)); - _mmu_5ms = MIN2(_mmu_5ms, calculate_mmu(5)); - _mmu_10ms = MIN2(_mmu_10ms, calculate_mmu(10)); - _mmu_20ms = MIN2(_mmu_20ms, calculate_mmu(20)); - _mmu_50ms = MIN2(_mmu_50ms, calculate_mmu(50)); - _mmu_100ms = MIN2(_mmu_100ms, calculate_mmu(100)); -} - -void XStatMMU::print() { - log_info(gc, mmu)("MMU: 2ms/%.1f%%, 5ms/%.1f%%, 10ms/%.1f%%, 20ms/%.1f%%, 50ms/%.1f%%, 100ms/%.1f%%", - _mmu_2ms, _mmu_5ms, _mmu_10ms, _mmu_20ms, _mmu_50ms, _mmu_100ms); -} - -// -// Stat phases -// -ConcurrentGCTimer XStatPhase::_timer; - -XStatPhase::XStatPhase(const char* group, const char* name) : - _sampler(group, name, XStatUnitTime) {} - -void XStatPhase::log_start(LogTargetHandle log, bool thread) const { - if (!log.is_enabled()) { - return; - } - - if (thread) { - ResourceMark rm; - log.print("%s (%s)", name(), Thread::current()->name()); - } else { - log.print("%s", name()); - } -} - -void XStatPhase::log_end(LogTargetHandle log, const Tickspan& duration, bool thread) const { - if (!log.is_enabled()) { - return; - } - - if (thread) { - ResourceMark rm; - log.print("%s (%s) %.3fms", name(), Thread::current()->name(), TimeHelper::counter_to_millis(duration.value())); - } else { - log.print("%s %.3fms", name(), TimeHelper::counter_to_millis(duration.value())); - } -} - -ConcurrentGCTimer* XStatPhase::timer() { - return &_timer; -} - -const char* XStatPhase::name() const { - return _sampler.name(); -} - -XStatPhaseCycle::XStatPhaseCycle(const char* name) : - XStatPhase("Collector", name) {} - -void XStatPhaseCycle::register_start(const Ticks& start) const { - timer()->register_gc_start(start); - - XTracer::tracer()->report_gc_start(XCollectedHeap::heap()->gc_cause(), start); - - XCollectedHeap::heap()->print_heap_before_gc(); - XCollectedHeap::heap()->trace_heap_before_gc(XTracer::tracer()); - - log_info(gc, start)("Garbage Collection (%s)", - GCCause::to_string(XCollectedHeap::heap()->gc_cause())); -} - -void XStatPhaseCycle::register_end(const Ticks& start, const Ticks& end) const { - if (XAbort::should_abort()) { - log_info(gc)("Garbage Collection (%s) Aborted", - GCCause::to_string(XCollectedHeap::heap()->gc_cause())); - return; - } - - timer()->register_gc_end(end); - - XCollectedHeap::heap()->print_heap_after_gc(); - XCollectedHeap::heap()->trace_heap_after_gc(XTracer::tracer()); - - XTracer::tracer()->report_gc_end(end, timer()->time_partitions()); - - const Tickspan duration = end - start; - XStatSample(_sampler, duration.value()); - - XStatLoad::print(); - XStatMMU::print(); - XStatMark::print(); - XStatNMethods::print(); - XStatMetaspace::print(); - XStatReferences::print(); - XStatRelocation::print(); - XStatHeap::print(); - - log_info(gc)("Garbage Collection (%s) " XSIZE_FMT "->" XSIZE_FMT, - GCCause::to_string(XCollectedHeap::heap()->gc_cause()), - XSIZE_ARGS(XStatHeap::used_at_mark_start()), - XSIZE_ARGS(XStatHeap::used_at_relocate_end())); -} - -Tickspan XStatPhasePause::_max; - -XStatPhasePause::XStatPhasePause(const char* name) : - XStatPhase("Phase", name) {} - -const Tickspan& XStatPhasePause::max() { - return _max; -} - -void XStatPhasePause::register_start(const Ticks& start) const { - timer()->register_gc_pause_start(name(), start); - - LogTarget(Debug, gc, phases, start) log; - log_start(log); -} - -void XStatPhasePause::register_end(const Ticks& start, const Ticks& end) const { - timer()->register_gc_pause_end(end); - - const Tickspan duration = end - start; - XStatSample(_sampler, duration.value()); - - // Track max pause time - if (_max < duration) { - _max = duration; - } - - // Track minimum mutator utilization - XStatMMU::register_pause(start, end); - - LogTarget(Info, gc, phases) log; - log_end(log, duration); -} - -XStatPhaseConcurrent::XStatPhaseConcurrent(const char* name) : - XStatPhase("Phase", name) {} - -void XStatPhaseConcurrent::register_start(const Ticks& start) const { - timer()->register_gc_concurrent_start(name(), start); - - LogTarget(Debug, gc, phases, start) log; - log_start(log); -} - -void XStatPhaseConcurrent::register_end(const Ticks& start, const Ticks& end) const { - if (XAbort::should_abort()) { - return; - } - - timer()->register_gc_concurrent_end(end); - - const Tickspan duration = end - start; - XStatSample(_sampler, duration.value()); - - LogTarget(Info, gc, phases) log; - log_end(log, duration); -} - -XStatSubPhase::XStatSubPhase(const char* name) : - XStatPhase("Subphase", name) {} - -void XStatSubPhase::register_start(const Ticks& start) const { - if (XThread::is_worker()) { - LogTarget(Trace, gc, phases, start) log; - log_start(log, true /* thread */); - } else { - LogTarget(Debug, gc, phases, start) log; - log_start(log, false /* thread */); - } -} - -void XStatSubPhase::register_end(const Ticks& start, const Ticks& end) const { - if (XAbort::should_abort()) { - return; - } - - XTracer::tracer()->report_thread_phase(name(), start, end); - - const Tickspan duration = end - start; - XStatSample(_sampler, duration.value()); - - if (XThread::is_worker()) { - LogTarget(Trace, gc, phases) log; - log_end(log, duration, true /* thread */); - } else { - LogTarget(Debug, gc, phases) log; - log_end(log, duration, false /* thread */); - } -} - -XStatCriticalPhase::XStatCriticalPhase(const char* name, bool verbose) : - XStatPhase("Critical", name), - _counter("Critical", name, XStatUnitOpsPerSecond), - _verbose(verbose) {} - -void XStatCriticalPhase::register_start(const Ticks& start) const { - // This is called from sensitive contexts, for example before an allocation stall - // has been resolved. This means we must not access any oops in here since that - // could lead to infinite recursion. Without access to the thread name we can't - // really log anything useful here. -} - -void XStatCriticalPhase::register_end(const Ticks& start, const Ticks& end) const { - XTracer::tracer()->report_thread_phase(name(), start, end); - - const Tickspan duration = end - start; - XStatSample(_sampler, duration.value()); - XStatInc(_counter); - - if (_verbose) { - LogTarget(Info, gc) log; - log_end(log, duration, true /* thread */); - } else { - LogTarget(Debug, gc) log; - log_end(log, duration, true /* thread */); - } -} - -// -// Stat timer -// -THREAD_LOCAL uint32_t XStatTimerDisable::_active = 0; - -// -// Stat sample/inc -// -void XStatSample(const XStatSampler& sampler, uint64_t value) { - XStatSamplerData* const cpu_data = sampler.get(); - Atomic::add(&cpu_data->_nsamples, 1u); - Atomic::add(&cpu_data->_sum, value); - - uint64_t max = cpu_data->_max; - for (;;) { - if (max >= value) { - // Not max - break; - } - - const uint64_t new_max = value; - const uint64_t prev_max = Atomic::cmpxchg(&cpu_data->_max, max, new_max); - if (prev_max == max) { - // Success - break; - } - - // Retry - max = prev_max; - } - - XTracer::tracer()->report_stat_sampler(sampler, value); -} - -void XStatInc(const XStatCounter& counter, uint64_t increment) { - XStatCounterData* const cpu_data = counter.get(); - const uint64_t value = Atomic::add(&cpu_data->_counter, increment); - - XTracer::tracer()->report_stat_counter(counter, increment, value); -} - -void XStatInc(const XStatUnsampledCounter& counter, uint64_t increment) { - XStatCounterData* const cpu_data = counter.get(); - Atomic::add(&cpu_data->_counter, increment); -} - -// -// Stat allocation rate -// -const XStatUnsampledCounter XStatAllocRate::_counter("Allocation Rate"); -TruncatedSeq XStatAllocRate::_samples(XStatAllocRate::sample_hz); -TruncatedSeq XStatAllocRate::_rate(XStatAllocRate::sample_hz); - -const XStatUnsampledCounter& XStatAllocRate::counter() { - return _counter; -} - -uint64_t XStatAllocRate::sample_and_reset() { - const XStatCounterData bytes_per_sample = _counter.collect_and_reset(); - _samples.add(bytes_per_sample._counter); - - const uint64_t bytes_per_second = _samples.sum(); - _rate.add(bytes_per_second); - - return bytes_per_second; -} - -double XStatAllocRate::predict() { - return _rate.predict_next(); -} - -double XStatAllocRate::avg() { - return _rate.avg(); -} - -double XStatAllocRate::sd() { - return _rate.sd(); -} - -// -// Stat thread -// -XStat::XStat() : - _metronome(sample_hz) { - set_name("XStat"); - create_and_start(); -} - -void XStat::sample_and_collect(XStatSamplerHistory* history) const { - // Sample counters - for (const XStatCounter* counter = XStatCounter::first(); counter != nullptr; counter = counter->next()) { - counter->sample_and_reset(); - } - - // Collect samples - for (const XStatSampler* sampler = XStatSampler::first(); sampler != nullptr; sampler = sampler->next()) { - XStatSamplerHistory& sampler_history = history[sampler->id()]; - sampler_history.add(sampler->collect_and_reset()); - } -} - -bool XStat::should_print(LogTargetHandle log) const { - static uint64_t print_at = ZStatisticsInterval; - const uint64_t now = os::elapsedTime(); - - if (now < print_at) { - return false; - } - - print_at = ((now / ZStatisticsInterval) * ZStatisticsInterval) + ZStatisticsInterval; - - return log.is_enabled(); -} - -void XStat::print(LogTargetHandle log, const XStatSamplerHistory* history) const { - // Print - log.print("=== Garbage Collection Statistics ======================================================================================================================="); - log.print(" Last 10s Last 10m Last 10h Total"); - log.print(" Avg / Max Avg / Max Avg / Max Avg / Max"); - - for (const XStatSampler* sampler = XStatSampler::first(); sampler != nullptr; sampler = sampler->next()) { - const XStatSamplerHistory& sampler_history = history[sampler->id()]; - const XStatUnitPrinter printer = sampler->printer(); - printer(log, *sampler, sampler_history); - } - - log.print("========================================================================================================================================================="); -} - -void XStat::run_service() { - XStatSamplerHistory* const history = new XStatSamplerHistory[XStatSampler::count()]; - LogTarget(Info, gc, stats) log; - - XStatSampler::sort(); - - // Main loop - while (_metronome.wait_for_tick()) { - sample_and_collect(history); - if (should_print(log)) { - print(log, history); - } - } - - delete [] history; -} - -void XStat::stop_service() { - _metronome.stop(); -} - -// -// Stat table -// -class XStatTablePrinter { -private: - static const size_t _buffer_size = 256; - - const size_t _column0_width; - const size_t _columnN_width; - char _buffer[_buffer_size]; - -public: - class XColumn { - private: - char* const _buffer; - const size_t _position; - const size_t _width; - const size_t _width_next; - - XColumn next() const { - // Insert space between columns - _buffer[_position + _width] = ' '; - return XColumn(_buffer, _position + _width + 1, _width_next, _width_next); - } - - size_t print(size_t position, const char* fmt, va_list va) { - const int res = jio_vsnprintf(_buffer + position, _buffer_size - position, fmt, va); - if (res < 0) { - return 0; - } - - return (size_t)res; - } - - public: - XColumn(char* buffer, size_t position, size_t width, size_t width_next) : - _buffer(buffer), - _position(position), - _width(width), - _width_next(width_next) {} - - XColumn left(const char* fmt, ...) ATTRIBUTE_PRINTF(2, 3) { - va_list va; - - va_start(va, fmt); - const size_t written = print(_position, fmt, va); - va_end(va); - - if (written < _width) { - // Fill empty space - memset(_buffer + _position + written, ' ', _width - written); - } - - return next(); - } - - XColumn right(const char* fmt, ...) ATTRIBUTE_PRINTF(2, 3) { - va_list va; - - va_start(va, fmt); - const size_t written = print(_position, fmt, va); - va_end(va); - - if (written > _width) { - // Line too long - return fill('?'); - } - - if (written < _width) { - // Short line, move all to right - memmove(_buffer + _position + _width - written, _buffer + _position, written); - - // Fill empty space - memset(_buffer + _position, ' ', _width - written); - } - - return next(); - } - - XColumn center(const char* fmt, ...) ATTRIBUTE_PRINTF(2, 3) { - va_list va; - - va_start(va, fmt); - const size_t written = print(_position, fmt, va); - va_end(va); - - if (written > _width) { - // Line too long - return fill('?'); - } - - if (written < _width) { - // Short line, move all to center - const size_t start_space = (_width - written) / 2; - const size_t end_space = _width - written - start_space; - memmove(_buffer + _position + start_space, _buffer + _position, written); - - // Fill empty spaces - memset(_buffer + _position, ' ', start_space); - memset(_buffer + _position + start_space + written, ' ', end_space); - } - - return next(); - } - - XColumn fill(char filler = ' ') { - memset(_buffer + _position, filler, _width); - return next(); - } - - const char* end() { - _buffer[_position] = '\0'; - return _buffer; - } - }; - -public: - XStatTablePrinter(size_t column0_width, size_t columnN_width) : - _column0_width(column0_width), - _columnN_width(columnN_width) {} - - XColumn operator()() { - return XColumn(_buffer, 0, _column0_width, _columnN_width); - } -}; - -// -// Stat cycle -// -uint64_t XStatCycle::_nwarmup_cycles = 0; -Ticks XStatCycle::_start_of_last; -Ticks XStatCycle::_end_of_last; -NumberSeq XStatCycle::_serial_time(0.7 /* alpha */); -NumberSeq XStatCycle::_parallelizable_time(0.7 /* alpha */); -uint XStatCycle::_last_active_workers = 0; - -void XStatCycle::at_start() { - _start_of_last = Ticks::now(); -} - -void XStatCycle::at_end(GCCause::Cause cause, uint active_workers) { - _end_of_last = Ticks::now(); - - if (cause == GCCause::_z_warmup) { - _nwarmup_cycles++; - } - - _last_active_workers = active_workers; - - // Calculate serial and parallelizable GC cycle times - const double duration = (_end_of_last - _start_of_last).seconds(); - const double workers_duration = XStatWorkers::get_and_reset_duration(); - const double serial_time = duration - workers_duration; - const double parallelizable_time = workers_duration * active_workers; - _serial_time.add(serial_time); - _parallelizable_time.add(parallelizable_time); -} - -bool XStatCycle::is_warm() { - return _nwarmup_cycles >= 3; -} - -uint64_t XStatCycle::nwarmup_cycles() { - return _nwarmup_cycles; -} - -bool XStatCycle::is_time_trustable() { - // The times are considered trustable if we - // have completed at least one warmup cycle. - return _nwarmup_cycles > 0; -} - -const AbsSeq& XStatCycle::serial_time() { - return _serial_time; -} - -const AbsSeq& XStatCycle::parallelizable_time() { - return _parallelizable_time; -} - -uint XStatCycle::last_active_workers() { - return _last_active_workers; -} - -double XStatCycle::time_since_last() { - if (_end_of_last.value() == 0) { - // No end recorded yet, return time since VM start - return os::elapsedTime(); - } - - const Ticks now = Ticks::now(); - const Tickspan time_since_last = now - _end_of_last; - return time_since_last.seconds(); -} - -// -// Stat workers -// -Ticks XStatWorkers::_start_of_last; -Tickspan XStatWorkers::_accumulated_duration; - -void XStatWorkers::at_start() { - _start_of_last = Ticks::now(); -} - -void XStatWorkers::at_end() { - const Ticks now = Ticks::now(); - const Tickspan duration = now - _start_of_last; - _accumulated_duration += duration; -} - -double XStatWorkers::get_and_reset_duration() { - const double duration = _accumulated_duration.seconds(); - const Ticks now = Ticks::now(); - _accumulated_duration = now - now; - return duration; -} - -// -// Stat load -// -void XStatLoad::print() { - double loadavg[3] = {}; - os::loadavg(loadavg, ARRAY_SIZE(loadavg)); - log_info(gc, load)("Load: %.2f/%.2f/%.2f", loadavg[0], loadavg[1], loadavg[2]); -} - -// -// Stat mark -// -size_t XStatMark::_nstripes; -size_t XStatMark::_nproactiveflush; -size_t XStatMark::_nterminateflush; -size_t XStatMark::_ntrycomplete; -size_t XStatMark::_ncontinue; -size_t XStatMark::_mark_stack_usage; - -void XStatMark::set_at_mark_start(size_t nstripes) { - _nstripes = nstripes; -} - -void XStatMark::set_at_mark_end(size_t nproactiveflush, - size_t nterminateflush, - size_t ntrycomplete, - size_t ncontinue) { - _nproactiveflush = nproactiveflush; - _nterminateflush = nterminateflush; - _ntrycomplete = ntrycomplete; - _ncontinue = ncontinue; -} - -void XStatMark::set_at_mark_free(size_t mark_stack_usage) { - _mark_stack_usage = mark_stack_usage; -} - -void XStatMark::print() { - log_info(gc, marking)("Mark: " - SIZE_FORMAT " stripe(s), " - SIZE_FORMAT " proactive flush(es), " - SIZE_FORMAT " terminate flush(es), " - SIZE_FORMAT " completion(s), " - SIZE_FORMAT " continuation(s) ", - _nstripes, - _nproactiveflush, - _nterminateflush, - _ntrycomplete, - _ncontinue); - - log_info(gc, marking)("Mark Stack Usage: " SIZE_FORMAT "M", _mark_stack_usage / M); -} - -// -// Stat relocation -// -XRelocationSetSelectorStats XStatRelocation::_selector_stats; -size_t XStatRelocation::_forwarding_usage; -size_t XStatRelocation::_small_in_place_count; -size_t XStatRelocation::_medium_in_place_count; - -void XStatRelocation::set_at_select_relocation_set(const XRelocationSetSelectorStats& selector_stats) { - _selector_stats = selector_stats; -} - -void XStatRelocation::set_at_install_relocation_set(size_t forwarding_usage) { - _forwarding_usage = forwarding_usage; -} - -void XStatRelocation::set_at_relocate_end(size_t small_in_place_count, size_t medium_in_place_count) { - _small_in_place_count = small_in_place_count; - _medium_in_place_count = medium_in_place_count; -} - -void XStatRelocation::print(const char* name, - const XRelocationSetSelectorGroupStats& selector_group, - size_t in_place_count) { - log_info(gc, reloc)("%s Pages: " SIZE_FORMAT " / " SIZE_FORMAT "M, Empty: " SIZE_FORMAT "M, " - "Relocated: " SIZE_FORMAT "M, In-Place: " SIZE_FORMAT, - name, - selector_group.npages_candidates(), - selector_group.total() / M, - selector_group.empty() / M, - selector_group.relocate() / M, - in_place_count); -} - -void XStatRelocation::print() { - print("Small", _selector_stats.small(), _small_in_place_count); - if (XPageSizeMedium != 0) { - print("Medium", _selector_stats.medium(), _medium_in_place_count); - } - print("Large", _selector_stats.large(), 0 /* in_place_count */); - - log_info(gc, reloc)("Forwarding Usage: " SIZE_FORMAT "M", _forwarding_usage / M); -} - -// -// Stat nmethods -// -void XStatNMethods::print() { - log_info(gc, nmethod)("NMethods: " SIZE_FORMAT " registered, " SIZE_FORMAT " unregistered", - XNMethodTable::registered_nmethods(), - XNMethodTable::unregistered_nmethods()); -} - -// -// Stat metaspace -// -void XStatMetaspace::print() { - MetaspaceCombinedStats stats = MetaspaceUtils::get_combined_statistics(); - log_info(gc, metaspace)("Metaspace: " - SIZE_FORMAT "M used, " - SIZE_FORMAT "M committed, " SIZE_FORMAT "M reserved", - stats.used() / M, - stats.committed() / M, - stats.reserved() / M); -} - -// -// Stat references -// -XStatReferences::XCount XStatReferences::_soft; -XStatReferences::XCount XStatReferences::_weak; -XStatReferences::XCount XStatReferences::_final; -XStatReferences::XCount XStatReferences::_phantom; - -void XStatReferences::set(XCount* count, size_t encountered, size_t discovered, size_t enqueued) { - count->encountered = encountered; - count->discovered = discovered; - count->enqueued = enqueued; -} - -void XStatReferences::set_soft(size_t encountered, size_t discovered, size_t enqueued) { - set(&_soft, encountered, discovered, enqueued); -} - -void XStatReferences::set_weak(size_t encountered, size_t discovered, size_t enqueued) { - set(&_weak, encountered, discovered, enqueued); -} - -void XStatReferences::set_final(size_t encountered, size_t discovered, size_t enqueued) { - set(&_final, encountered, discovered, enqueued); -} - -void XStatReferences::set_phantom(size_t encountered, size_t discovered, size_t enqueued) { - set(&_phantom, encountered, discovered, enqueued); -} - -void XStatReferences::print(const char* name, const XStatReferences::XCount& ref) { - log_info(gc, ref)("%s: " - SIZE_FORMAT " encountered, " - SIZE_FORMAT " discovered, " - SIZE_FORMAT " enqueued", - name, - ref.encountered, - ref.discovered, - ref.enqueued); -} - -void XStatReferences::print() { - print("Soft", _soft); - print("Weak", _weak); - print("Final", _final); - print("Phantom", _phantom); -} - -// -// Stat heap -// -XStatHeap::XAtInitialize XStatHeap::_at_initialize; -XStatHeap::XAtMarkStart XStatHeap::_at_mark_start; -XStatHeap::XAtMarkEnd XStatHeap::_at_mark_end; -XStatHeap::XAtRelocateStart XStatHeap::_at_relocate_start; -XStatHeap::XAtRelocateEnd XStatHeap::_at_relocate_end; - -size_t XStatHeap::capacity_high() { - return MAX4(_at_mark_start.capacity, - _at_mark_end.capacity, - _at_relocate_start.capacity, - _at_relocate_end.capacity); -} - -size_t XStatHeap::capacity_low() { - return MIN4(_at_mark_start.capacity, - _at_mark_end.capacity, - _at_relocate_start.capacity, - _at_relocate_end.capacity); -} - -size_t XStatHeap::free(size_t used) { - return _at_initialize.max_capacity - used; -} - -size_t XStatHeap::allocated(size_t used, size_t reclaimed) { - // The amount of allocated memory between point A and B is used(B) - used(A). - // However, we might also have reclaimed memory between point A and B. This - // means the current amount of used memory must be incremented by the amount - // reclaimed, so that used(B) represents the amount of used memory we would - // have had if we had not reclaimed anything. - return (used + reclaimed) - _at_mark_start.used; -} - -size_t XStatHeap::garbage(size_t reclaimed) { - return _at_mark_end.garbage - reclaimed; -} - -void XStatHeap::set_at_initialize(const XPageAllocatorStats& stats) { - _at_initialize.min_capacity = stats.min_capacity(); - _at_initialize.max_capacity = stats.max_capacity(); -} - -void XStatHeap::set_at_mark_start(const XPageAllocatorStats& stats) { - _at_mark_start.soft_max_capacity = stats.soft_max_capacity(); - _at_mark_start.capacity = stats.capacity(); - _at_mark_start.free = free(stats.used()); - _at_mark_start.used = stats.used(); -} - -void XStatHeap::set_at_mark_end(const XPageAllocatorStats& stats) { - _at_mark_end.capacity = stats.capacity(); - _at_mark_end.free = free(stats.used()); - _at_mark_end.used = stats.used(); - _at_mark_end.allocated = allocated(stats.used(), 0 /* reclaimed */); -} - -void XStatHeap::set_at_select_relocation_set(const XRelocationSetSelectorStats& stats) { - const size_t live = stats.small().live() + stats.medium().live() + stats.large().live(); - _at_mark_end.live = live; - _at_mark_end.garbage = _at_mark_start.used - live; -} - -void XStatHeap::set_at_relocate_start(const XPageAllocatorStats& stats) { - _at_relocate_start.capacity = stats.capacity(); - _at_relocate_start.free = free(stats.used()); - _at_relocate_start.used = stats.used(); - _at_relocate_start.allocated = allocated(stats.used(), stats.reclaimed()); - _at_relocate_start.garbage = garbage(stats.reclaimed()); - _at_relocate_start.reclaimed = stats.reclaimed(); -} - -void XStatHeap::set_at_relocate_end(const XPageAllocatorStats& stats, size_t non_worker_relocated) { - const size_t reclaimed = stats.reclaimed() - MIN2(non_worker_relocated, stats.reclaimed()); - - _at_relocate_end.capacity = stats.capacity(); - _at_relocate_end.capacity_high = capacity_high(); - _at_relocate_end.capacity_low = capacity_low(); - _at_relocate_end.free = free(stats.used()); - _at_relocate_end.free_high = free(stats.used_low()); - _at_relocate_end.free_low = free(stats.used_high()); - _at_relocate_end.used = stats.used(); - _at_relocate_end.used_high = stats.used_high(); - _at_relocate_end.used_low = stats.used_low(); - _at_relocate_end.allocated = allocated(stats.used(), reclaimed); - _at_relocate_end.garbage = garbage(reclaimed); - _at_relocate_end.reclaimed = reclaimed; -} - -size_t XStatHeap::max_capacity() { - return _at_initialize.max_capacity; -} - -size_t XStatHeap::used_at_mark_start() { - return _at_mark_start.used; -} - -size_t XStatHeap::used_at_relocate_end() { - return _at_relocate_end.used; -} - -void XStatHeap::print() { - log_info(gc, heap)("Min Capacity: " - XSIZE_FMT, XSIZE_ARGS(_at_initialize.min_capacity)); - log_info(gc, heap)("Max Capacity: " - XSIZE_FMT, XSIZE_ARGS(_at_initialize.max_capacity)); - log_info(gc, heap)("Soft Max Capacity: " - XSIZE_FMT, XSIZE_ARGS(_at_mark_start.soft_max_capacity)); - - XStatTablePrinter table(10, 18); - log_info(gc, heap)("%s", table() - .fill() - .center("Mark Start") - .center("Mark End") - .center("Relocate Start") - .center("Relocate End") - .center("High") - .center("Low") - .end()); - log_info(gc, heap)("%s", table() - .right("Capacity:") - .left(XTABLE_ARGS(_at_mark_start.capacity)) - .left(XTABLE_ARGS(_at_mark_end.capacity)) - .left(XTABLE_ARGS(_at_relocate_start.capacity)) - .left(XTABLE_ARGS(_at_relocate_end.capacity)) - .left(XTABLE_ARGS(_at_relocate_end.capacity_high)) - .left(XTABLE_ARGS(_at_relocate_end.capacity_low)) - .end()); - log_info(gc, heap)("%s", table() - .right("Free:") - .left(XTABLE_ARGS(_at_mark_start.free)) - .left(XTABLE_ARGS(_at_mark_end.free)) - .left(XTABLE_ARGS(_at_relocate_start.free)) - .left(XTABLE_ARGS(_at_relocate_end.free)) - .left(XTABLE_ARGS(_at_relocate_end.free_high)) - .left(XTABLE_ARGS(_at_relocate_end.free_low)) - .end()); - log_info(gc, heap)("%s", table() - .right("Used:") - .left(XTABLE_ARGS(_at_mark_start.used)) - .left(XTABLE_ARGS(_at_mark_end.used)) - .left(XTABLE_ARGS(_at_relocate_start.used)) - .left(XTABLE_ARGS(_at_relocate_end.used)) - .left(XTABLE_ARGS(_at_relocate_end.used_high)) - .left(XTABLE_ARGS(_at_relocate_end.used_low)) - .end()); - log_info(gc, heap)("%s", table() - .right("Live:") - .left(XTABLE_ARGS_NA) - .left(XTABLE_ARGS(_at_mark_end.live)) - .left(XTABLE_ARGS(_at_mark_end.live /* Same as at mark end */)) - .left(XTABLE_ARGS(_at_mark_end.live /* Same as at mark end */)) - .left(XTABLE_ARGS_NA) - .left(XTABLE_ARGS_NA) - .end()); - log_info(gc, heap)("%s", table() - .right("Allocated:") - .left(XTABLE_ARGS_NA) - .left(XTABLE_ARGS(_at_mark_end.allocated)) - .left(XTABLE_ARGS(_at_relocate_start.allocated)) - .left(XTABLE_ARGS(_at_relocate_end.allocated)) - .left(XTABLE_ARGS_NA) - .left(XTABLE_ARGS_NA) - .end()); - log_info(gc, heap)("%s", table() - .right("Garbage:") - .left(XTABLE_ARGS_NA) - .left(XTABLE_ARGS(_at_mark_end.garbage)) - .left(XTABLE_ARGS(_at_relocate_start.garbage)) - .left(XTABLE_ARGS(_at_relocate_end.garbage)) - .left(XTABLE_ARGS_NA) - .left(XTABLE_ARGS_NA) - .end()); - log_info(gc, heap)("%s", table() - .right("Reclaimed:") - .left(XTABLE_ARGS_NA) - .left(XTABLE_ARGS_NA) - .left(XTABLE_ARGS(_at_relocate_start.reclaimed)) - .left(XTABLE_ARGS(_at_relocate_end.reclaimed)) - .left(XTABLE_ARGS_NA) - .left(XTABLE_ARGS_NA) - .end()); -} diff --git a/src/hotspot/share/gc/x/xStat.hpp b/src/hotspot/share/gc/x/xStat.hpp deleted file mode 100644 index 4983e5fcab6..00000000000 --- a/src/hotspot/share/gc/x/xStat.hpp +++ /dev/null @@ -1,578 +0,0 @@ -/* - * Copyright (c) 2015, 2021, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XSTAT_HPP -#define SHARE_GC_X_XSTAT_HPP - -#include "gc/shared/concurrentGCThread.hpp" -#include "gc/shared/gcCause.hpp" -#include "gc/shared/gcTimer.hpp" -#include "gc/x/xMetronome.hpp" -#include "logging/logHandle.hpp" -#include "memory/allocation.hpp" -#include "utilities/globalDefinitions.hpp" -#include "utilities/numberSeq.hpp" -#include "utilities/ticks.hpp" - -class XPage; -class XPageAllocatorStats; -class XRelocationSetSelectorGroupStats; -class XRelocationSetSelectorStats; -class XStatSampler; -class XStatSamplerHistory; -struct XStatCounterData; -struct XStatSamplerData; - -// -// Stat unit printers -// -typedef void (*XStatUnitPrinter)(LogTargetHandle log, const XStatSampler&, const XStatSamplerHistory&); - -void XStatUnitTime(LogTargetHandle log, const XStatSampler& sampler, const XStatSamplerHistory& history); -void XStatUnitBytes(LogTargetHandle log, const XStatSampler& sampler, const XStatSamplerHistory& history); -void XStatUnitThreads(LogTargetHandle log, const XStatSampler& sampler, const XStatSamplerHistory& history); -void XStatUnitBytesPerSecond(LogTargetHandle log, const XStatSampler& sampler, const XStatSamplerHistory& history); -void XStatUnitOpsPerSecond(LogTargetHandle log, const XStatSampler& sampler, const XStatSamplerHistory& history); - -// -// Stat value -// -class XStatValue { -private: - static uintptr_t _base; - static uint32_t _cpu_offset; - - const char* const _group; - const char* const _name; - const uint32_t _id; - const uint32_t _offset; - -protected: - XStatValue(const char* group, - const char* name, - uint32_t id, - uint32_t size); - - template T* get_cpu_local(uint32_t cpu) const; - -public: - static void initialize(); - - const char* group() const; - const char* name() const; - uint32_t id() const; -}; - -// -// Stat iterable value -// -template -class XStatIterableValue : public XStatValue { -private: - static uint32_t _count; - static T* _first; - - T* _next; - - T* insert() const; - -protected: - XStatIterableValue(const char* group, - const char* name, - uint32_t size); - -public: - static void sort(); - - static uint32_t count() { - return _count; - } - - static T* first() { - return _first; - } - - T* next() const { - return _next; - } -}; - -template uint32_t XStatIterableValue::_count = 0; -template T* XStatIterableValue::_first = nullptr; - -// -// Stat sampler -// -class XStatSampler : public XStatIterableValue { -private: - const XStatUnitPrinter _printer; - -public: - XStatSampler(const char* group, - const char* name, - XStatUnitPrinter printer); - - XStatSamplerData* get() const; - XStatSamplerData collect_and_reset() const; - - XStatUnitPrinter printer() const; -}; - -// -// Stat counter -// -class XStatCounter : public XStatIterableValue { -private: - const XStatSampler _sampler; - -public: - XStatCounter(const char* group, - const char* name, - XStatUnitPrinter printer); - - XStatCounterData* get() const; - void sample_and_reset() const; -}; - -// -// Stat unsampled counter -// -class XStatUnsampledCounter : public XStatIterableValue { -public: - XStatUnsampledCounter(const char* name); - - XStatCounterData* get() const; - XStatCounterData collect_and_reset() const; -}; - -// -// Stat MMU (Minimum Mutator Utilization) -// -class XStatMMUPause { -private: - double _start; - double _end; - -public: - XStatMMUPause(); - XStatMMUPause(const Ticks& start, const Ticks& end); - - double end() const; - double overlap(double start, double end) const; -}; - -class XStatMMU { -private: - static size_t _next; - static size_t _npauses; - static XStatMMUPause _pauses[200]; // Record the last 200 pauses - - static double _mmu_2ms; - static double _mmu_5ms; - static double _mmu_10ms; - static double _mmu_20ms; - static double _mmu_50ms; - static double _mmu_100ms; - - static const XStatMMUPause& pause(size_t index); - static double calculate_mmu(double time_slice); - -public: - static void register_pause(const Ticks& start, const Ticks& end); - - static void print(); -}; - -// -// Stat phases -// -class XStatPhase { -private: - static ConcurrentGCTimer _timer; - -protected: - const XStatSampler _sampler; - - XStatPhase(const char* group, const char* name); - - void log_start(LogTargetHandle log, bool thread = false) const; - void log_end(LogTargetHandle log, const Tickspan& duration, bool thread = false) const; - -public: - static ConcurrentGCTimer* timer(); - - const char* name() const; - - virtual void register_start(const Ticks& start) const = 0; - virtual void register_end(const Ticks& start, const Ticks& end) const = 0; -}; - -class XStatPhaseCycle : public XStatPhase { -public: - XStatPhaseCycle(const char* name); - - virtual void register_start(const Ticks& start) const; - virtual void register_end(const Ticks& start, const Ticks& end) const; -}; - -class XStatPhasePause : public XStatPhase { -private: - static Tickspan _max; // Max pause time - -public: - XStatPhasePause(const char* name); - - static const Tickspan& max(); - - virtual void register_start(const Ticks& start) const; - virtual void register_end(const Ticks& start, const Ticks& end) const; -}; - -class XStatPhaseConcurrent : public XStatPhase { -public: - XStatPhaseConcurrent(const char* name); - - virtual void register_start(const Ticks& start) const; - virtual void register_end(const Ticks& start, const Ticks& end) const; -}; - -class XStatSubPhase : public XStatPhase { -public: - XStatSubPhase(const char* name); - - virtual void register_start(const Ticks& start) const; - virtual void register_end(const Ticks& start, const Ticks& end) const; -}; - -class XStatCriticalPhase : public XStatPhase { -private: - const XStatCounter _counter; - const bool _verbose; - -public: - XStatCriticalPhase(const char* name, bool verbose = true); - - virtual void register_start(const Ticks& start) const; - virtual void register_end(const Ticks& start, const Ticks& end) const; -}; - -// -// Stat timer -// -class XStatTimerDisable : public StackObj { -private: - static THREAD_LOCAL uint32_t _active; - -public: - XStatTimerDisable() { - _active++; - } - - ~XStatTimerDisable() { - _active--; - } - - static bool is_active() { - return _active > 0; - } -}; - -class XStatTimer : public StackObj { -private: - const bool _enabled; - const XStatPhase& _phase; - const Ticks _start; - -public: - XStatTimer(const XStatPhase& phase) : - _enabled(!XStatTimerDisable::is_active()), - _phase(phase), - _start(Ticks::now()) { - if (_enabled) { - _phase.register_start(_start); - } - } - - ~XStatTimer() { - if (_enabled) { - const Ticks end = Ticks::now(); - _phase.register_end(_start, end); - } - } -}; - -// -// Stat sample/increment -// -void XStatSample(const XStatSampler& sampler, uint64_t value); -void XStatInc(const XStatCounter& counter, uint64_t increment = 1); -void XStatInc(const XStatUnsampledCounter& counter, uint64_t increment = 1); - -// -// Stat allocation rate -// -class XStatAllocRate : public AllStatic { -private: - static const XStatUnsampledCounter _counter; - static TruncatedSeq _samples; - static TruncatedSeq _rate; - -public: - static const uint64_t sample_hz = 10; - - static const XStatUnsampledCounter& counter(); - static uint64_t sample_and_reset(); - - static double predict(); - static double avg(); - static double sd(); -}; - -// -// Stat thread -// -class XStat : public ConcurrentGCThread { -private: - static const uint64_t sample_hz = 1; - - XMetronome _metronome; - - void sample_and_collect(XStatSamplerHistory* history) const; - bool should_print(LogTargetHandle log) const; - void print(LogTargetHandle log, const XStatSamplerHistory* history) const; - -protected: - virtual void run_service(); - virtual void stop_service(); - -public: - XStat(); -}; - -// -// Stat cycle -// -class XStatCycle : public AllStatic { -private: - static uint64_t _nwarmup_cycles; - static Ticks _start_of_last; - static Ticks _end_of_last; - static NumberSeq _serial_time; - static NumberSeq _parallelizable_time; - static uint _last_active_workers; - -public: - static void at_start(); - static void at_end(GCCause::Cause cause, uint active_workers); - - static bool is_warm(); - static uint64_t nwarmup_cycles(); - - static bool is_time_trustable(); - static const AbsSeq& serial_time(); - static const AbsSeq& parallelizable_time(); - - static uint last_active_workers(); - - static double time_since_last(); -}; - -// -// Stat workers -// -class XStatWorkers : public AllStatic { -private: - static Ticks _start_of_last; - static Tickspan _accumulated_duration; - -public: - static void at_start(); - static void at_end(); - - static double get_and_reset_duration(); -}; - -// -// Stat load -// -class XStatLoad : public AllStatic { -public: - static void print(); -}; - -// -// Stat mark -// -class XStatMark : public AllStatic { -private: - static size_t _nstripes; - static size_t _nproactiveflush; - static size_t _nterminateflush; - static size_t _ntrycomplete; - static size_t _ncontinue; - static size_t _mark_stack_usage; - -public: - static void set_at_mark_start(size_t nstripes); - static void set_at_mark_end(size_t nproactiveflush, - size_t nterminateflush, - size_t ntrycomplete, - size_t ncontinue); - static void set_at_mark_free(size_t mark_stack_usage); - - static void print(); -}; - -// -// Stat relocation -// -class XStatRelocation : public AllStatic { -private: - static XRelocationSetSelectorStats _selector_stats; - static size_t _forwarding_usage; - static size_t _small_in_place_count; - static size_t _medium_in_place_count; - - static void print(const char* name, - const XRelocationSetSelectorGroupStats& selector_group, - size_t in_place_count); - -public: - static void set_at_select_relocation_set(const XRelocationSetSelectorStats& selector_stats); - static void set_at_install_relocation_set(size_t forwarding_usage); - static void set_at_relocate_end(size_t small_in_place_count, size_t medium_in_place_count); - - static void print(); -}; - -// -// Stat nmethods -// -class XStatNMethods : public AllStatic { -public: - static void print(); -}; - -// -// Stat metaspace -// -class XStatMetaspace : public AllStatic { -public: - static void print(); -}; - -// -// Stat references -// -class XStatReferences : public AllStatic { -private: - static struct XCount { - size_t encountered; - size_t discovered; - size_t enqueued; - } _soft, _weak, _final, _phantom; - - static void set(XCount* count, size_t encountered, size_t discovered, size_t enqueued); - static void print(const char* name, const XCount& ref); - -public: - static void set_soft(size_t encountered, size_t discovered, size_t enqueued); - static void set_weak(size_t encountered, size_t discovered, size_t enqueued); - static void set_final(size_t encountered, size_t discovered, size_t enqueued); - static void set_phantom(size_t encountered, size_t discovered, size_t enqueued); - - static void print(); -}; - -// -// Stat heap -// -class XStatHeap : public AllStatic { -private: - static struct XAtInitialize { - size_t min_capacity; - size_t max_capacity; - } _at_initialize; - - static struct XAtMarkStart { - size_t soft_max_capacity; - size_t capacity; - size_t free; - size_t used; - } _at_mark_start; - - static struct XAtMarkEnd { - size_t capacity; - size_t free; - size_t used; - size_t live; - size_t allocated; - size_t garbage; - } _at_mark_end; - - static struct XAtRelocateStart { - size_t capacity; - size_t free; - size_t used; - size_t allocated; - size_t garbage; - size_t reclaimed; - } _at_relocate_start; - - static struct XAtRelocateEnd { - size_t capacity; - size_t capacity_high; - size_t capacity_low; - size_t free; - size_t free_high; - size_t free_low; - size_t used; - size_t used_high; - size_t used_low; - size_t allocated; - size_t garbage; - size_t reclaimed; - } _at_relocate_end; - - static size_t capacity_high(); - static size_t capacity_low(); - static size_t free(size_t used); - static size_t allocated(size_t used, size_t reclaimed); - static size_t garbage(size_t reclaimed); - -public: - static void set_at_initialize(const XPageAllocatorStats& stats); - static void set_at_mark_start(const XPageAllocatorStats& stats); - static void set_at_mark_end(const XPageAllocatorStats& stats); - static void set_at_select_relocation_set(const XRelocationSetSelectorStats& stats); - static void set_at_relocate_start(const XPageAllocatorStats& stats); - static void set_at_relocate_end(const XPageAllocatorStats& stats, size_t non_worker_relocated); - - static size_t max_capacity(); - static size_t used_at_mark_start(); - static size_t used_at_relocate_end(); - - static void print(); -}; - -#endif // SHARE_GC_X_XSTAT_HPP diff --git a/src/hotspot/share/gc/x/xTask.cpp b/src/hotspot/share/gc/x/xTask.cpp deleted file mode 100644 index 25f6d12f33d..00000000000 --- a/src/hotspot/share/gc/x/xTask.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2017, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/x/xTask.hpp" -#include "gc/x/xThread.hpp" - -XTask::Task::Task(XTask* task, const char* name) : - WorkerTask(name), - _task(task) {} - -void XTask::Task::work(uint worker_id) { - XThread::set_worker_id(worker_id); - _task->work(); - XThread::clear_worker_id(); -} - -XTask::XTask(const char* name) : - _worker_task(this, name) {} - -const char* XTask::name() const { - return _worker_task.name(); -} - -WorkerTask* XTask::worker_task() { - return &_worker_task; -} diff --git a/src/hotspot/share/gc/x/xTask.hpp b/src/hotspot/share/gc/x/xTask.hpp deleted file mode 100644 index 08adaed83e5..00000000000 --- a/src/hotspot/share/gc/x/xTask.hpp +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2017, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XTASK_HPP -#define SHARE_GC_X_XTASK_HPP - -#include "gc/shared/workerThread.hpp" -#include "memory/allocation.hpp" - -class XTask : public StackObj { -private: - class Task : public WorkerTask { - private: - XTask* const _task; - - public: - Task(XTask* task, const char* name); - - virtual void work(uint worker_id); - }; - - Task _worker_task; - -public: - XTask(const char* name); - - const char* name() const; - WorkerTask* worker_task(); - - virtual void work() = 0; -}; - -#endif // SHARE_GC_X_XTASK_HPP diff --git a/src/hotspot/share/gc/x/xThread.cpp b/src/hotspot/share/gc/x/xThread.cpp deleted file mode 100644 index fb9785690cf..00000000000 --- a/src/hotspot/share/gc/x/xThread.cpp +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) 2015, 2021, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/x/xThread.inline.hpp" -#include "runtime/javaThread.hpp" -#include "runtime/nonJavaThread.hpp" -#include "utilities/debug.hpp" - -THREAD_LOCAL bool XThread::_initialized; -THREAD_LOCAL uintptr_t XThread::_id; -THREAD_LOCAL bool XThread::_is_vm; -THREAD_LOCAL bool XThread::_is_java; -THREAD_LOCAL bool XThread::_is_worker; -THREAD_LOCAL uint XThread::_worker_id; - -void XThread::initialize() { - assert(!_initialized, "Already initialized"); - const Thread* const thread = Thread::current(); - _initialized = true; - _id = (uintptr_t)thread; - _is_vm = thread->is_VM_thread(); - _is_java = thread->is_Java_thread(); - _is_worker = false; - _worker_id = (uint)-1; -} - -const char* XThread::name() { - const Thread* const thread = Thread::current(); - if (thread->is_Named_thread()) { - const NamedThread* const named = (const NamedThread*)thread; - return named->name(); - } else if (thread->is_Java_thread()) { - return "Java"; - } - - return "Unknown"; -} - -void XThread::set_worker() { - ensure_initialized(); - _is_worker = true; -} - -bool XThread::has_worker_id() { - return _initialized && - _is_worker && - _worker_id != (uint)-1; -} - -void XThread::set_worker_id(uint worker_id) { - ensure_initialized(); - assert(!has_worker_id(), "Worker id already initialized"); - _worker_id = worker_id; -} - -void XThread::clear_worker_id() { - assert(has_worker_id(), "Worker id not initialized"); - _worker_id = (uint)-1; -} diff --git a/src/hotspot/share/gc/x/xThread.hpp b/src/hotspot/share/gc/x/xThread.hpp deleted file mode 100644 index 24df6ce1ca2..00000000000 --- a/src/hotspot/share/gc/x/xThread.hpp +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2015, 2022, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XTHREAD_HPP -#define SHARE_GC_X_XTHREAD_HPP - -#include "memory/allStatic.hpp" -#include "utilities/globalDefinitions.hpp" - -class XThread : public AllStatic { - friend class XTask; - friend class XWorkersInitializeTask; - friend class XRuntimeWorkersInitializeTask; - -private: - static THREAD_LOCAL bool _initialized; - static THREAD_LOCAL uintptr_t _id; - static THREAD_LOCAL bool _is_vm; - static THREAD_LOCAL bool _is_java; - static THREAD_LOCAL bool _is_worker; - static THREAD_LOCAL uint _worker_id; - - static void initialize(); - static void ensure_initialized(); - - static void set_worker(); - - static bool has_worker_id(); - static void set_worker_id(uint worker_id); - static void clear_worker_id(); - -public: - static const char* name(); - static uintptr_t id(); - static bool is_vm(); - static bool is_java(); - static bool is_worker(); - static uint worker_id(); -}; - -#endif // SHARE_GC_X_XTHREAD_HPP diff --git a/src/hotspot/share/gc/x/xThread.inline.hpp b/src/hotspot/share/gc/x/xThread.inline.hpp deleted file mode 100644 index eb6ff63e5f7..00000000000 --- a/src/hotspot/share/gc/x/xThread.inline.hpp +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright (c) 2015, 2020, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XTHREAD_INLINE_HPP -#define SHARE_GC_X_XTHREAD_INLINE_HPP - -#include "gc/x/xThread.hpp" - -#include "utilities/debug.hpp" - -inline void XThread::ensure_initialized() { - if (!_initialized) { - initialize(); - } -} - -inline uintptr_t XThread::id() { - ensure_initialized(); - return _id; -} - -inline bool XThread::is_vm() { - ensure_initialized(); - return _is_vm; -} - -inline bool XThread::is_java() { - ensure_initialized(); - return _is_java; -} - -inline bool XThread::is_worker() { - ensure_initialized(); - return _is_worker; -} - -inline uint XThread::worker_id() { - assert(has_worker_id(), "Worker id not initialized"); - return _worker_id; -} - -#endif // SHARE_GC_X_XTHREAD_INLINE_HPP diff --git a/src/hotspot/share/gc/x/xThreadLocalAllocBuffer.cpp b/src/hotspot/share/gc/x/xThreadLocalAllocBuffer.cpp deleted file mode 100644 index 7dc0a128b64..00000000000 --- a/src/hotspot/share/gc/x/xThreadLocalAllocBuffer.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (c) 2018, 2021, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/shared/tlab_globals.hpp" -#include "gc/x/xAddress.inline.hpp" -#include "gc/x/xStackWatermark.hpp" -#include "gc/x/xThreadLocalAllocBuffer.hpp" -#include "gc/x/xValue.inline.hpp" -#include "runtime/globals.hpp" -#include "runtime/javaThread.hpp" -#include "runtime/stackWatermarkSet.inline.hpp" - -XPerWorker* XThreadLocalAllocBuffer::_stats = nullptr; - -void XThreadLocalAllocBuffer::initialize() { - if (UseTLAB) { - assert(_stats == nullptr, "Already initialized"); - _stats = new XPerWorker(); - reset_statistics(); - } -} - -void XThreadLocalAllocBuffer::reset_statistics() { - if (UseTLAB) { - XPerWorkerIterator iter(_stats); - for (ThreadLocalAllocStats* stats; iter.next(&stats);) { - stats->reset(); - } - } -} - -void XThreadLocalAllocBuffer::publish_statistics() { - if (UseTLAB) { - ThreadLocalAllocStats total; - - XPerWorkerIterator iter(_stats); - for (ThreadLocalAllocStats* stats; iter.next(&stats);) { - total.update(*stats); - } - - total.publish(); - } -} - -static void fixup_address(HeapWord** p) { - *p = (HeapWord*)XAddress::good_or_null((uintptr_t)*p); -} - -void XThreadLocalAllocBuffer::retire(JavaThread* thread, ThreadLocalAllocStats* stats) { - if (UseTLAB) { - stats->reset(); - thread->tlab().addresses_do(fixup_address); - thread->tlab().retire(stats); - if (ResizeTLAB) { - thread->tlab().resize(); - } - } -} - -void XThreadLocalAllocBuffer::remap(JavaThread* thread) { - if (UseTLAB) { - thread->tlab().addresses_do(fixup_address); - } -} - -void XThreadLocalAllocBuffer::update_stats(JavaThread* thread) { - if (UseTLAB) { - XStackWatermark* const watermark = StackWatermarkSet::get(thread, StackWatermarkKind::gc); - _stats->addr()->update(watermark->stats()); - } -} diff --git a/src/hotspot/share/gc/x/xThreadLocalAllocBuffer.hpp b/src/hotspot/share/gc/x/xThreadLocalAllocBuffer.hpp deleted file mode 100644 index 521f4da1909..00000000000 --- a/src/hotspot/share/gc/x/xThreadLocalAllocBuffer.hpp +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2018, 2022, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XTHREADLOCALALLOCBUFFER_HPP -#define SHARE_GC_X_XTHREADLOCALALLOCBUFFER_HPP - -#include "gc/shared/threadLocalAllocBuffer.hpp" -#include "gc/x/xValue.hpp" -#include "memory/allStatic.hpp" - -class JavaThread; - -class XThreadLocalAllocBuffer : public AllStatic { -private: - static XPerWorker* _stats; - -public: - static void initialize(); - - static void reset_statistics(); - static void publish_statistics(); - - static void retire(JavaThread* thread, ThreadLocalAllocStats* stats); - static void remap(JavaThread* thread); - static void update_stats(JavaThread* thread); -}; - -#endif // SHARE_GC_X_XTHREADLOCALALLOCBUFFER_HPP diff --git a/src/hotspot/share/gc/x/xThreadLocalData.hpp b/src/hotspot/share/gc/x/xThreadLocalData.hpp deleted file mode 100644 index adc72f6ca76..00000000000 --- a/src/hotspot/share/gc/x/xThreadLocalData.hpp +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2018, 2020, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XTHREADLOCALDATA_HPP -#define SHARE_GC_X_XTHREADLOCALDATA_HPP - -#include "gc/x/xMarkStack.hpp" -#include "gc/x/xGlobals.hpp" -#include "runtime/javaThread.hpp" -#include "utilities/debug.hpp" -#include "utilities/sizes.hpp" - -class XThreadLocalData { -private: - uintptr_t _address_bad_mask; - XMarkThreadLocalStacks _stacks; - oop* _invisible_root; - - XThreadLocalData() : - _address_bad_mask(0), - _stacks(), - _invisible_root(nullptr) {} - - static XThreadLocalData* data(Thread* thread) { - return thread->gc_data(); - } - -public: - static void create(Thread* thread) { - new (data(thread)) XThreadLocalData(); - } - - static void destroy(Thread* thread) { - data(thread)->~XThreadLocalData(); - } - - static void set_address_bad_mask(Thread* thread, uintptr_t mask) { - data(thread)->_address_bad_mask = mask; - } - - static XMarkThreadLocalStacks* stacks(Thread* thread) { - return &data(thread)->_stacks; - } - - static void set_invisible_root(Thread* thread, oop* root) { - assert(data(thread)->_invisible_root == nullptr, "Already set"); - data(thread)->_invisible_root = root; - } - - static void clear_invisible_root(Thread* thread) { - assert(data(thread)->_invisible_root != nullptr, "Should be set"); - data(thread)->_invisible_root = nullptr; - } - - template - static void do_invisible_root(Thread* thread, T f) { - if (data(thread)->_invisible_root != nullptr) { - f(data(thread)->_invisible_root); - } - } - - static ByteSize address_bad_mask_offset() { - return Thread::gc_data_offset() + byte_offset_of(XThreadLocalData, _address_bad_mask); - } - - static ByteSize nmethod_disarmed_offset() { - return address_bad_mask_offset() + in_ByteSize(XAddressBadMaskHighOrderBitsOffset); - } -}; - -#endif // SHARE_GC_X_XTHREADLOCALDATA_HPP diff --git a/src/hotspot/share/gc/x/xTracer.cpp b/src/hotspot/share/gc/x/xTracer.cpp deleted file mode 100644 index 3a0bd2b00e3..00000000000 --- a/src/hotspot/share/gc/x/xTracer.cpp +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/shared/gcId.hpp" -#include "gc/x/xGlobals.hpp" -#include "gc/x/xStat.hpp" -#include "gc/x/xTracer.hpp" -#include "jfr/jfrEvents.hpp" -#include "runtime/safepointVerifiers.hpp" -#include "utilities/debug.hpp" -#include "utilities/macros.hpp" -#if INCLUDE_JFR -#include "jfr/metadata/jfrSerializer.hpp" -#endif - -#if INCLUDE_JFR - -class XPageTypeConstant : public JfrSerializer { -public: - virtual void serialize(JfrCheckpointWriter& writer) { - writer.write_count(3); - writer.write_key(XPageTypeSmall); - writer.write("Small"); - writer.write_key(XPageTypeMedium); - writer.write("Medium"); - writer.write_key(XPageTypeLarge); - writer.write("Large"); - } -}; - -class XStatisticsCounterTypeConstant : public JfrSerializer { -public: - virtual void serialize(JfrCheckpointWriter& writer) { - writer.write_count(XStatCounter::count()); - for (XStatCounter* counter = XStatCounter::first(); counter != nullptr; counter = counter->next()) { - writer.write_key(counter->id()); - writer.write(counter->name()); - } - } -}; - -class XStatisticsSamplerTypeConstant : public JfrSerializer { -public: - virtual void serialize(JfrCheckpointWriter& writer) { - writer.write_count(XStatSampler::count()); - for (XStatSampler* sampler = XStatSampler::first(); sampler != nullptr; sampler = sampler->next()) { - writer.write_key(sampler->id()); - writer.write(sampler->name()); - } - } -}; - -static void register_jfr_type_serializers() { - JfrSerializer::register_serializer(TYPE_ZPAGETYPETYPE, - true /* permit_cache */, - new XPageTypeConstant()); - JfrSerializer::register_serializer(TYPE_ZSTATISTICSCOUNTERTYPE, - true /* permit_cache */, - new XStatisticsCounterTypeConstant()); - JfrSerializer::register_serializer(TYPE_ZSTATISTICSSAMPLERTYPE, - true /* permit_cache */, - new XStatisticsSamplerTypeConstant()); -} - -#endif // INCLUDE_JFR - -XTracer* XTracer::_tracer = nullptr; - -XTracer::XTracer() : - GCTracer(Z) {} - -void XTracer::initialize() { - assert(_tracer == nullptr, "Already initialized"); - _tracer = new XTracer(); - JFR_ONLY(register_jfr_type_serializers();) -} - -void XTracer::send_stat_counter(const XStatCounter& counter, uint64_t increment, uint64_t value) { - NoSafepointVerifier nsv; - - EventZStatisticsCounter e; - if (e.should_commit()) { - e.set_id(counter.id()); - e.set_increment(increment); - e.set_value(value); - e.commit(); - } -} - -void XTracer::send_stat_sampler(const XStatSampler& sampler, uint64_t value) { - NoSafepointVerifier nsv; - - EventZStatisticsSampler e; - if (e.should_commit()) { - e.set_id(sampler.id()); - e.set_value(value); - e.commit(); - } -} - -void XTracer::send_thread_phase(const char* name, const Ticks& start, const Ticks& end) { - NoSafepointVerifier nsv; - - EventZThreadPhase e(UNTIMED); - if (e.should_commit()) { - e.set_gcId(GCId::current_or_undefined()); - e.set_name(name); - e.set_starttime(start); - e.set_endtime(end); - e.commit(); - } -} - -void XTracer::send_thread_debug(const char* name, const Ticks& start, const Ticks& end) { - NoSafepointVerifier nsv; - - EventZThreadDebug e(UNTIMED); - if (e.should_commit()) { - e.set_gcId(GCId::current_or_undefined()); - e.set_name(name); - e.set_starttime(start); - e.set_endtime(end); - e.commit(); - } -} diff --git a/src/hotspot/share/gc/x/xTracer.hpp b/src/hotspot/share/gc/x/xTracer.hpp deleted file mode 100644 index d9219d79c51..00000000000 --- a/src/hotspot/share/gc/x/xTracer.hpp +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2016, 2020, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XTRACER_HPP -#define SHARE_GC_X_XTRACER_HPP - -#include "gc/shared/gcTrace.hpp" - -class XStatCounter; -class XStatPhase; -class XStatSampler; - -class XTracer : public GCTracer, public CHeapObj { -private: - static XTracer* _tracer; - - XTracer(); - - void send_stat_counter(const XStatCounter& counter, uint64_t increment, uint64_t value); - void send_stat_sampler(const XStatSampler& sampler, uint64_t value); - void send_thread_phase(const char* name, const Ticks& start, const Ticks& end); - void send_thread_debug(const char* name, const Ticks& start, const Ticks& end); - -public: - static XTracer* tracer(); - static void initialize(); - - void report_stat_counter(const XStatCounter& counter, uint64_t increment, uint64_t value); - void report_stat_sampler(const XStatSampler& sampler, uint64_t value); - void report_thread_phase(const char* name, const Ticks& start, const Ticks& end); - void report_thread_debug(const char* name, const Ticks& start, const Ticks& end); -}; - -// For temporary latency measurements during development and debugging -class XTraceThreadDebug : public StackObj { -private: - const Ticks _start; - const char* const _name; - -public: - XTraceThreadDebug(const char* name); - ~XTraceThreadDebug(); -}; - -#endif // SHARE_GC_X_XTRACER_HPP diff --git a/src/hotspot/share/gc/x/xTracer.inline.hpp b/src/hotspot/share/gc/x/xTracer.inline.hpp deleted file mode 100644 index 22dd2e2b6fb..00000000000 --- a/src/hotspot/share/gc/x/xTracer.inline.hpp +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 2016, 2020, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XTRACER_INLINE_HPP -#define SHARE_GC_X_XTRACER_INLINE_HPP - -#include "gc/x/xTracer.hpp" - -#include "jfr/jfrEvents.hpp" - -inline XTracer* XTracer::tracer() { - return _tracer; -} - -inline void XTracer::report_stat_counter(const XStatCounter& counter, uint64_t increment, uint64_t value) { - if (EventZStatisticsCounter::is_enabled()) { - send_stat_counter(counter, increment, value); - } -} - -inline void XTracer::report_stat_sampler(const XStatSampler& sampler, uint64_t value) { - if (EventZStatisticsSampler::is_enabled()) { - send_stat_sampler(sampler, value); - } -} - -inline void XTracer::report_thread_phase(const char* name, const Ticks& start, const Ticks& end) { - if (EventZThreadPhase::is_enabled()) { - send_thread_phase(name, start, end); - } -} - -inline void XTracer::report_thread_debug(const char* name, const Ticks& start, const Ticks& end) { - if (EventZThreadDebug::is_enabled()) { - send_thread_debug(name, start, end); - } -} - -inline XTraceThreadDebug::XTraceThreadDebug(const char* name) : - _start(Ticks::now()), - _name(name) {} - -inline XTraceThreadDebug::~XTraceThreadDebug() { - XTracer::tracer()->report_thread_debug(_name, _start, Ticks::now()); -} - -#endif // SHARE_GC_X_XTRACER_INLINE_HPP diff --git a/src/hotspot/share/gc/x/xUncommitter.cpp b/src/hotspot/share/gc/x/xUncommitter.cpp deleted file mode 100644 index ffd57b8c2a8..00000000000 --- a/src/hotspot/share/gc/x/xUncommitter.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) 2019, 2021, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/shared/gc_globals.hpp" -#include "gc/x/xHeap.inline.hpp" -#include "gc/x/xLock.inline.hpp" -#include "gc/x/xStat.hpp" -#include "gc/x/xUncommitter.hpp" -#include "jfr/jfrEvents.hpp" -#include "logging/log.hpp" - -static const XStatCounter XCounterUncommit("Memory", "Uncommit", XStatUnitBytesPerSecond); - -XUncommitter::XUncommitter(XPageAllocator* page_allocator) : - _page_allocator(page_allocator), - _lock(), - _stop(false) { - set_name("XUncommitter"); - create_and_start(); -} - -bool XUncommitter::wait(uint64_t timeout) const { - XLocker locker(&_lock); - while (!ZUncommit && !_stop) { - _lock.wait(); - } - - if (!_stop && timeout > 0) { - log_debug(gc, heap)("Uncommit Timeout: " UINT64_FORMAT "s", timeout); - _lock.wait(timeout * MILLIUNITS); - } - - return !_stop; -} - -bool XUncommitter::should_continue() const { - XLocker locker(&_lock); - return !_stop; -} - -void XUncommitter::run_service() { - uint64_t timeout = 0; - - while (wait(timeout)) { - EventZUncommit event; - size_t uncommitted = 0; - - while (should_continue()) { - // Uncommit chunk - const size_t flushed = _page_allocator->uncommit(&timeout); - if (flushed == 0) { - // Done - break; - } - - uncommitted += flushed; - } - - if (uncommitted > 0) { - // Update statistics - XStatInc(XCounterUncommit, uncommitted); - log_info(gc, heap)("Uncommitted: " SIZE_FORMAT "M(%.0f%%)", - uncommitted / M, percent_of(uncommitted, XHeap::heap()->max_capacity())); - - // Send event - event.commit(uncommitted); - } - } -} - -void XUncommitter::stop_service() { - XLocker locker(&_lock); - _stop = true; - _lock.notify_all(); -} diff --git a/src/hotspot/share/gc/x/xUncommitter.hpp b/src/hotspot/share/gc/x/xUncommitter.hpp deleted file mode 100644 index 9f6212fa98d..00000000000 --- a/src/hotspot/share/gc/x/xUncommitter.hpp +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2019, 2020, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XUNCOMMITTER_HPP -#define SHARE_GC_X_XUNCOMMITTER_HPP - -#include "gc/shared/concurrentGCThread.hpp" -#include "gc/x/xLock.hpp" - -class XPageAllocation; - -class XUncommitter : public ConcurrentGCThread { -private: - XPageAllocator* const _page_allocator; - mutable XConditionLock _lock; - bool _stop; - - bool wait(uint64_t timeout) const; - bool should_continue() const; - -protected: - virtual void run_service(); - virtual void stop_service(); - -public: - XUncommitter(XPageAllocator* page_allocator); -}; - -#endif // SHARE_GC_X_XUNCOMMITTER_HPP diff --git a/src/hotspot/share/gc/x/xUnload.cpp b/src/hotspot/share/gc/x/xUnload.cpp deleted file mode 100644 index c501ace7d14..00000000000 --- a/src/hotspot/share/gc/x/xUnload.cpp +++ /dev/null @@ -1,172 +0,0 @@ -/* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "classfile/classLoaderDataGraph.hpp" -#include "classfile/systemDictionary.hpp" -#include "code/codeBehaviours.hpp" -#include "code/codeCache.hpp" -#include "code/dependencyContext.hpp" -#include "gc/shared/gcBehaviours.hpp" -#include "gc/shared/suspendibleThreadSet.hpp" -#include "gc/x/xBarrier.inline.hpp" -#include "gc/x/xLock.inline.hpp" -#include "gc/x/xNMethod.hpp" -#include "gc/x/xStat.hpp" -#include "gc/x/xUnload.hpp" -#include "memory/metaspaceUtils.hpp" -#include "oops/access.inline.hpp" - -static const XStatSubPhase XSubPhaseConcurrentClassesUnlink("Concurrent Classes Unlink"); -static const XStatSubPhase XSubPhaseConcurrentClassesPurge("Concurrent Classes Purge"); - -class XPhantomIsAliveObjectClosure : public BoolObjectClosure { -public: - virtual bool do_object_b(oop o) { - return XBarrier::is_alive_barrier_on_phantom_oop(o); - } -}; - -class XIsUnloadingOopClosure : public OopClosure { -private: - XPhantomIsAliveObjectClosure _is_alive; - bool _is_unloading; - -public: - XIsUnloadingOopClosure() : - _is_alive(), - _is_unloading(false) {} - - virtual void do_oop(oop* p) { - const oop o = RawAccess<>::oop_load(p); - if (o != nullptr && !_is_alive.do_object_b(o)) { - _is_unloading = true; - } - } - - virtual void do_oop(narrowOop* p) { - ShouldNotReachHere(); - } - - bool is_unloading() const { - return _is_unloading; - } -}; - -class XIsUnloadingBehaviour : public IsUnloadingBehaviour { -public: - virtual bool has_dead_oop(nmethod* nm) const { - XReentrantLock* const lock = XNMethod::lock_for_nmethod(nm); - XLocker locker(lock); - XIsUnloadingOopClosure cl; - XNMethod::nmethod_oops_do_inner(nm, &cl); - return cl.is_unloading(); - } -}; - -class XCompiledICProtectionBehaviour : public CompiledICProtectionBehaviour { -public: - virtual bool lock(nmethod* nm) { - XReentrantLock* const lock = XNMethod::ic_lock_for_nmethod(nm); - lock->lock(); - return true; - } - - virtual void unlock(nmethod* nm) { - XReentrantLock* const lock = XNMethod::ic_lock_for_nmethod(nm); - lock->unlock(); - } - - virtual bool is_safe(nmethod* nm) { - if (SafepointSynchronize::is_at_safepoint() || nm->is_unloading()) { - return true; - } - - XReentrantLock* const lock = XNMethod::ic_lock_for_nmethod(nm); - return lock->is_owned(); - } -}; - -XUnload::XUnload(XWorkers* workers) : - _workers(workers) { - - if (!ClassUnloading) { - return; - } - - static XIsUnloadingBehaviour is_unloading_behaviour; - IsUnloadingBehaviour::set_current(&is_unloading_behaviour); - - static XCompiledICProtectionBehaviour ic_protection_behaviour; - CompiledICProtectionBehaviour::set_current(&ic_protection_behaviour); -} - -void XUnload::prepare() { - if (!ClassUnloading) { - return; - } - - CodeCache::increment_unloading_cycle(); - DependencyContext::cleaning_start(); -} - -void XUnload::unlink() { - if (!ClassUnloading) { - return; - } - - XStatTimer timer(XSubPhaseConcurrentClassesUnlink); - SuspendibleThreadSetJoiner sts; - bool unloading_occurred; - - { - MutexLocker ml(ClassLoaderDataGraph_lock); - unloading_occurred = SystemDictionary::do_unloading(XStatPhase::timer()); - } - - Klass::clean_weak_klass_links(unloading_occurred); - XNMethod::unlink(_workers, unloading_occurred); - DependencyContext::cleaning_end(); -} - -void XUnload::purge() { - if (!ClassUnloading) { - return; - } - - XStatTimer timer(XSubPhaseConcurrentClassesPurge); - - { - SuspendibleThreadSetJoiner sts; - XNMethod::purge(); - } - - ClassLoaderDataGraph::purge(/*at_safepoint*/false); - CodeCache::purge_exception_caches(); -} - -void XUnload::finish() { - // Resize and verify metaspace - MetaspaceGC::compute_new_size(); - DEBUG_ONLY(MetaspaceUtils::verify();) -} diff --git a/src/hotspot/share/gc/x/xUnload.hpp b/src/hotspot/share/gc/x/xUnload.hpp deleted file mode 100644 index df6ba7ed2eb..00000000000 --- a/src/hotspot/share/gc/x/xUnload.hpp +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2018, 2019, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XUNLOAD_HPP -#define SHARE_GC_X_XUNLOAD_HPP - -class XWorkers; - -class XUnload { -private: - XWorkers* const _workers; - -public: - XUnload(XWorkers* workers); - - void prepare(); - void unlink(); - void purge(); - void finish(); -}; - -#endif // SHARE_GC_X_XUNLOAD_HPP diff --git a/src/hotspot/share/gc/x/xUnmapper.cpp b/src/hotspot/share/gc/x/xUnmapper.cpp deleted file mode 100644 index 17371cf1394..00000000000 --- a/src/hotspot/share/gc/x/xUnmapper.cpp +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright (c) 2020, 2021, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/shared/gc_globals.hpp" -#include "gc/shared/gcLogPrecious.hpp" -#include "gc/x/xList.inline.hpp" -#include "gc/x/xLock.inline.hpp" -#include "gc/x/xPage.inline.hpp" -#include "gc/x/xPageAllocator.hpp" -#include "gc/x/xUnmapper.hpp" -#include "jfr/jfrEvents.hpp" -#include "runtime/globals.hpp" - -XUnmapper::XUnmapper(XPageAllocator* page_allocator) : - _page_allocator(page_allocator), - _lock(), - _queue(), - _enqueued_bytes(0), - _warned_sync_unmapping(false), - _stop(false) { - set_name("XUnmapper"); - create_and_start(); -} - -XPage* XUnmapper::dequeue() { - XLocker locker(&_lock); - - for (;;) { - if (_stop) { - return nullptr; - } - - XPage* const page = _queue.remove_first(); - if (page != nullptr) { - _enqueued_bytes -= page->size(); - return page; - } - - _lock.wait(); - } -} - -bool XUnmapper::try_enqueue(XPage* page) { - if (ZVerifyViews) { - // Asynchronous unmap and destroy is not supported with ZVerifyViews - return false; - } - - // Enqueue for asynchronous unmap and destroy - XLocker locker(&_lock); - if (is_saturated()) { - // The unmapper thread is lagging behind and is unable to unmap memory fast enough - if (!_warned_sync_unmapping) { - _warned_sync_unmapping = true; - log_warning_p(gc)("WARNING: Encountered synchronous unmapping because asynchronous unmapping could not keep up"); - } - log_debug(gc, unmap)("Synchronous unmapping " SIZE_FORMAT "M page", page->size() / M); - return false; - } - - log_trace(gc, unmap)("Asynchronous unmapping " SIZE_FORMAT "M page (" SIZE_FORMAT "M / " SIZE_FORMAT "M enqueued)", - page->size() / M, _enqueued_bytes / M, queue_capacity() / M); - - _queue.insert_last(page); - _enqueued_bytes += page->size(); - _lock.notify_all(); - - return true; -} - -size_t XUnmapper::queue_capacity() const { - return align_up(_page_allocator->max_capacity() * ZAsyncUnmappingLimit / 100.0, XGranuleSize); -} - -bool XUnmapper::is_saturated() const { - return _enqueued_bytes >= queue_capacity(); -} - -void XUnmapper::do_unmap_and_destroy_page(XPage* page) const { - EventZUnmap event; - const size_t unmapped = page->size(); - - // Unmap and destroy - _page_allocator->unmap_page(page); - _page_allocator->destroy_page(page); - - // Send event - event.commit(unmapped); -} - -void XUnmapper::unmap_and_destroy_page(XPage* page) { - if (!try_enqueue(page)) { - // Synchronously unmap and destroy - do_unmap_and_destroy_page(page); - } -} - -void XUnmapper::run_service() { - for (;;) { - XPage* const page = dequeue(); - if (page == nullptr) { - // Stop - return; - } - - do_unmap_and_destroy_page(page); - } -} - -void XUnmapper::stop_service() { - XLocker locker(&_lock); - _stop = true; - _lock.notify_all(); -} diff --git a/src/hotspot/share/gc/x/xUnmapper.hpp b/src/hotspot/share/gc/x/xUnmapper.hpp deleted file mode 100644 index 811588f14d6..00000000000 --- a/src/hotspot/share/gc/x/xUnmapper.hpp +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2020, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XUNMAPPER_HPP -#define SHARE_GC_X_XUNMAPPER_HPP - -#include "gc/shared/concurrentGCThread.hpp" -#include "gc/x/xList.hpp" -#include "gc/x/xLock.hpp" - -class XPage; -class XPageAllocator; - -class XUnmapper : public ConcurrentGCThread { -private: - XPageAllocator* const _page_allocator; - XConditionLock _lock; - XList _queue; - size_t _enqueued_bytes; - bool _warned_sync_unmapping; - bool _stop; - - XPage* dequeue(); - bool try_enqueue(XPage* page); - size_t queue_capacity() const; - bool is_saturated() const; - void do_unmap_and_destroy_page(XPage* page) const; - -protected: - virtual void run_service(); - virtual void stop_service(); - -public: - XUnmapper(XPageAllocator* page_allocator); - - void unmap_and_destroy_page(XPage* page); -}; - -#endif // SHARE_GC_X_XUNMAPPER_HPP diff --git a/src/hotspot/share/gc/x/xUtils.hpp b/src/hotspot/share/gc/x/xUtils.hpp deleted file mode 100644 index 26f14c0e98f..00000000000 --- a/src/hotspot/share/gc/x/xUtils.hpp +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2015, 2022, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XUTILS_HPP -#define SHARE_GC_X_XUTILS_HPP - -#include "memory/allStatic.hpp" -#include "utilities/globalDefinitions.hpp" - -class XUtils : public AllStatic { -public: - // Allocation - static uintptr_t alloc_aligned(size_t alignment, size_t size); - - // Size conversion - static size_t bytes_to_words(size_t size_in_words); - static size_t words_to_bytes(size_t size_in_words); - - // Object - static size_t object_size(uintptr_t addr); - static void object_copy_disjoint(uintptr_t from, uintptr_t to, size_t size); - static void object_copy_conjoint(uintptr_t from, uintptr_t to, size_t size); -}; - -#endif // SHARE_GC_X_XUTILS_HPP diff --git a/src/hotspot/share/gc/x/xUtils.inline.hpp b/src/hotspot/share/gc/x/xUtils.inline.hpp deleted file mode 100644 index 09180959311..00000000000 --- a/src/hotspot/share/gc/x/xUtils.inline.hpp +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2015, 2020, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XUTILS_INLINE_HPP -#define SHARE_GC_X_XUTILS_INLINE_HPP - -#include "gc/x/xUtils.hpp" - -#include "gc/x/xOop.inline.hpp" -#include "oops/oop.inline.hpp" -#include "utilities/align.hpp" -#include "utilities/copy.hpp" -#include "utilities/debug.hpp" -#include "utilities/globalDefinitions.hpp" - -inline size_t XUtils::bytes_to_words(size_t size_in_bytes) { - assert(is_aligned(size_in_bytes, BytesPerWord), "Size not word aligned"); - return size_in_bytes >> LogBytesPerWord; -} - -inline size_t XUtils::words_to_bytes(size_t size_in_words) { - return size_in_words << LogBytesPerWord; -} - -inline size_t XUtils::object_size(uintptr_t addr) { - return words_to_bytes(XOop::from_address(addr)->size()); -} - -inline void XUtils::object_copy_disjoint(uintptr_t from, uintptr_t to, size_t size) { - Copy::aligned_disjoint_words((HeapWord*)from, (HeapWord*)to, bytes_to_words(size)); -} - -inline void XUtils::object_copy_conjoint(uintptr_t from, uintptr_t to, size_t size) { - if (from != to) { - Copy::aligned_conjoint_words((HeapWord*)from, (HeapWord*)to, bytes_to_words(size)); - } -} - -#endif // SHARE_GC_X_XUTILS_INLINE_HPP diff --git a/src/hotspot/share/gc/x/xValue.hpp b/src/hotspot/share/gc/x/xValue.hpp deleted file mode 100644 index 4b2838c8a2c..00000000000 --- a/src/hotspot/share/gc/x/xValue.hpp +++ /dev/null @@ -1,140 +0,0 @@ -/* - * Copyright (c) 2015, 2022, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XVALUE_HPP -#define SHARE_GC_X_XVALUE_HPP - -#include "memory/allStatic.hpp" -#include "utilities/globalDefinitions.hpp" - -// -// Storage -// - -template -class XValueStorage : public AllStatic { -private: - static uintptr_t _top; - static uintptr_t _end; - -public: - static const size_t offset = 4 * K; - - static uintptr_t alloc(size_t size); -}; - -class XContendedStorage : public XValueStorage { -public: - static size_t alignment(); - static uint32_t count(); - static uint32_t id(); -}; - -class XPerCPUStorage : public XValueStorage { -public: - static size_t alignment(); - static uint32_t count(); - static uint32_t id(); -}; - -class XPerNUMAStorage : public XValueStorage { -public: - static size_t alignment(); - static uint32_t count(); - static uint32_t id(); -}; - -class XPerWorkerStorage : public XValueStorage { -public: - static size_t alignment(); - static uint32_t count(); - static uint32_t id(); -}; - -// -// Value -// - -template -class XValue : public CHeapObj { -private: - const uintptr_t _addr; - - uintptr_t value_addr(uint32_t value_id) const; - -public: - XValue(); - XValue(const T& value); - - const T* addr(uint32_t value_id = S::id()) const; - T* addr(uint32_t value_id = S::id()); - - const T& get(uint32_t value_id = S::id()) const; - T& get(uint32_t value_id = S::id()); - - void set(const T& value, uint32_t value_id = S::id()); - void set_all(const T& value); -}; - -template using XContended = XValue; -template using XPerCPU = XValue; -template using XPerNUMA = XValue; -template using XPerWorker = XValue; - -// -// Iterator -// - -template -class XValueIterator { -private: - XValue* const _value; - uint32_t _value_id; - -public: - XValueIterator(XValue* value); - - bool next(T** value); -}; - -template using XPerCPUIterator = XValueIterator; -template using XPerNUMAIterator = XValueIterator; -template using XPerWorkerIterator = XValueIterator; - -template -class XValueConstIterator { -private: - const XValue* const _value; - uint32_t _value_id; - -public: - XValueConstIterator(const XValue* value); - - bool next(const T** value); -}; - -template using XPerCPUConstIterator = XValueConstIterator; -template using XPerNUMAConstIterator = XValueConstIterator; -template using XPerWorkerConstIterator = XValueConstIterator; - -#endif // SHARE_GC_X_XVALUE_HPP diff --git a/src/hotspot/share/gc/x/xValue.inline.hpp b/src/hotspot/share/gc/x/xValue.inline.hpp deleted file mode 100644 index 1b12eb7d555..00000000000 --- a/src/hotspot/share/gc/x/xValue.inline.hpp +++ /dev/null @@ -1,210 +0,0 @@ -/* - * Copyright (c) 2015, 2021, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XVALUE_INLINE_HPP -#define SHARE_GC_X_XVALUE_INLINE_HPP - -#include "gc/x/xValue.hpp" - -#include "gc/shared/gc_globals.hpp" -#include "gc/x/xCPU.inline.hpp" -#include "gc/x/xGlobals.hpp" -#include "gc/x/xNUMA.hpp" -#include "gc/x/xThread.inline.hpp" -#include "gc/x/xUtils.hpp" -#include "runtime/globals.hpp" -#include "utilities/align.hpp" - -// -// Storage -// - -template uintptr_t XValueStorage::_end = 0; -template uintptr_t XValueStorage::_top = 0; - -template -uintptr_t XValueStorage::alloc(size_t size) { - assert(size <= offset, "Allocation too large"); - - // Allocate entry in existing memory block - const uintptr_t addr = align_up(_top, S::alignment()); - _top = addr + size; - - if (_top < _end) { - // Success - return addr; - } - - // Allocate new block of memory - const size_t block_alignment = offset; - const size_t block_size = offset * S::count(); - _top = XUtils::alloc_aligned(block_alignment, block_size); - _end = _top + offset; - - // Retry allocation - return alloc(size); -} - -inline size_t XContendedStorage::alignment() { - return XCacheLineSize; -} - -inline uint32_t XContendedStorage::count() { - return 1; -} - -inline uint32_t XContendedStorage::id() { - return 0; -} - -inline size_t XPerCPUStorage::alignment() { - return sizeof(uintptr_t); -} - -inline uint32_t XPerCPUStorage::count() { - return XCPU::count(); -} - -inline uint32_t XPerCPUStorage::id() { - return XCPU::id(); -} - -inline size_t XPerNUMAStorage::alignment() { - return sizeof(uintptr_t); -} - -inline uint32_t XPerNUMAStorage::count() { - return XNUMA::count(); -} - -inline uint32_t XPerNUMAStorage::id() { - return XNUMA::id(); -} - -inline size_t XPerWorkerStorage::alignment() { - return sizeof(uintptr_t); -} - -inline uint32_t XPerWorkerStorage::count() { - return UseDynamicNumberOfGCThreads ? ConcGCThreads : MAX2(ConcGCThreads, ParallelGCThreads); -} - -inline uint32_t XPerWorkerStorage::id() { - return XThread::worker_id(); -} - -// -// Value -// - -template -inline uintptr_t XValue::value_addr(uint32_t value_id) const { - return _addr + (value_id * S::offset); -} - -template -inline XValue::XValue() : - _addr(S::alloc(sizeof(T))) { - // Initialize all instances - XValueIterator iter(this); - for (T* addr; iter.next(&addr);) { - ::new (addr) T; - } -} - -template -inline XValue::XValue(const T& value) : - _addr(S::alloc(sizeof(T))) { - // Initialize all instances - XValueIterator iter(this); - for (T* addr; iter.next(&addr);) { - ::new (addr) T(value); - } -} - -template -inline const T* XValue::addr(uint32_t value_id) const { - return reinterpret_cast(value_addr(value_id)); -} - -template -inline T* XValue::addr(uint32_t value_id) { - return reinterpret_cast(value_addr(value_id)); -} - -template -inline const T& XValue::get(uint32_t value_id) const { - return *addr(value_id); -} - -template -inline T& XValue::get(uint32_t value_id) { - return *addr(value_id); -} - -template -inline void XValue::set(const T& value, uint32_t value_id) { - get(value_id) = value; -} - -template -inline void XValue::set_all(const T& value) { - XValueIterator iter(this); - for (T* addr; iter.next(&addr);) { - *addr = value; - } -} - -// -// Iterator -// - -template -inline XValueIterator::XValueIterator(XValue* value) : - _value(value), - _value_id(0) {} - -template -inline bool XValueIterator::next(T** value) { - if (_value_id < S::count()) { - *value = _value->addr(_value_id++); - return true; - } - return false; -} - -template -inline XValueConstIterator::XValueConstIterator(const XValue* value) : - _value(value), - _value_id(0) {} - -template -inline bool XValueConstIterator::next(const T** value) { - if (_value_id < S::count()) { - *value = _value->addr(_value_id++); - return true; - } - return false; -} - -#endif // SHARE_GC_X_XVALUE_INLINE_HPP diff --git a/src/hotspot/share/gc/x/xVerify.cpp b/src/hotspot/share/gc/x/xVerify.cpp deleted file mode 100644 index ac6e8ee65d0..00000000000 --- a/src/hotspot/share/gc/x/xVerify.cpp +++ /dev/null @@ -1,405 +0,0 @@ -/* - * Copyright (c) 2019, 2022, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "classfile/classLoaderData.hpp" -#include "gc/shared/gc_globals.hpp" -#include "gc/x/xAddress.inline.hpp" -#include "gc/x/xHeap.inline.hpp" -#include "gc/x/xNMethod.hpp" -#include "gc/x/xOop.hpp" -#include "gc/x/xPageAllocator.hpp" -#include "gc/x/xResurrection.hpp" -#include "gc/x/xRootsIterator.hpp" -#include "gc/x/xStackWatermark.hpp" -#include "gc/x/xStat.hpp" -#include "gc/x/xVerify.hpp" -#include "memory/iterator.inline.hpp" -#include "memory/resourceArea.hpp" -#include "oops/oop.hpp" -#include "runtime/frame.inline.hpp" -#include "runtime/globals.hpp" -#include "runtime/handles.hpp" -#include "runtime/javaThread.hpp" -#include "runtime/safepoint.hpp" -#include "runtime/stackFrameStream.inline.hpp" -#include "runtime/stackWatermark.inline.hpp" -#include "runtime/stackWatermarkSet.inline.hpp" -#include "utilities/debug.hpp" -#include "utilities/globalDefinitions.hpp" -#include "utilities/preserveException.hpp" - -#define BAD_OOP_ARG(o, p) "Bad oop " PTR_FORMAT " found at " PTR_FORMAT, p2i(o), p2i(p) - -static void z_verify_oop(oop* p) { - const oop o = RawAccess<>::oop_load(p); - if (o != nullptr) { - const uintptr_t addr = XOop::to_address(o); - guarantee(XAddress::is_good(addr), BAD_OOP_ARG(o, p)); - guarantee(oopDesc::is_oop(XOop::from_address(addr)), BAD_OOP_ARG(o, p)); - } -} - -static void z_verify_possibly_weak_oop(oop* p) { - const oop o = RawAccess<>::oop_load(p); - if (o != nullptr) { - const uintptr_t addr = XOop::to_address(o); - guarantee(XAddress::is_good(addr) || XAddress::is_finalizable_good(addr), BAD_OOP_ARG(o, p)); - guarantee(oopDesc::is_oop(XOop::from_address(XAddress::good(addr))), BAD_OOP_ARG(o, p)); - } -} - -class XVerifyRootClosure : public OopClosure { -private: - const bool _verify_fixed; - -public: - XVerifyRootClosure(bool verify_fixed) : - _verify_fixed(verify_fixed) {} - - virtual void do_oop(oop* p) { - if (_verify_fixed) { - z_verify_oop(p); - } else { - // Don't know the state of the oop. - oop obj = *p; - obj = NativeAccess::oop_load(&obj); - z_verify_oop(&obj); - } - } - - virtual void do_oop(narrowOop*) { - ShouldNotReachHere(); - } - - bool verify_fixed() const { - return _verify_fixed; - } -}; - -class XVerifyStack : public OopClosure { -private: - XVerifyRootClosure* const _cl; - JavaThread* const _jt; - uint64_t _last_good; - bool _verifying_bad_frames; - -public: - XVerifyStack(XVerifyRootClosure* cl, JavaThread* jt) : - _cl(cl), - _jt(jt), - _last_good(0), - _verifying_bad_frames(false) { - XStackWatermark* const stack_watermark = StackWatermarkSet::get(jt, StackWatermarkKind::gc); - - if (_cl->verify_fixed()) { - assert(stack_watermark->processing_started(), "Should already have been fixed"); - assert(stack_watermark->processing_completed(), "Should already have been fixed"); - } else { - // We don't really know the state of the stack, verify watermark. - if (!stack_watermark->processing_started()) { - _verifying_bad_frames = true; - } else { - // Not time yet to verify bad frames - _last_good = stack_watermark->last_processed(); - } - } - } - - void do_oop(oop* p) { - if (_verifying_bad_frames) { - const oop obj = *p; - guarantee(!XAddress::is_good(XOop::to_address(obj)), BAD_OOP_ARG(obj, p)); - } - _cl->do_oop(p); - } - - void do_oop(narrowOop* p) { - ShouldNotReachHere(); - } - - void prepare_next_frame(frame& frame) { - if (_cl->verify_fixed()) { - // All frames need to be good - return; - } - - // The verification has two modes, depending on whether we have reached the - // last processed frame or not. Before it is reached, we expect everything to - // be good. After reaching it, we expect everything to be bad. - const uintptr_t sp = reinterpret_cast(frame.sp()); - - if (!_verifying_bad_frames && sp == _last_good) { - // Found the last good frame, now verify the bad ones - _verifying_bad_frames = true; - } - } - - void verify_frames() { - NMethodToOopClosure nm_cl(_cl, false /* fix_relocations */); - for (StackFrameStream frames(_jt, true /* update */, false /* process_frames */); - !frames.is_done(); - frames.next()) { - frame& frame = *frames.current(); - frame.oops_do(this, &nm_cl, frames.register_map(), DerivedPointerIterationMode::_ignore); - prepare_next_frame(frame); - } - } -}; - -class XVerifyOopClosure : public ClaimMetadataVisitingOopIterateClosure { -private: - const bool _verify_weaks; - -public: - XVerifyOopClosure(bool verify_weaks) : - ClaimMetadataVisitingOopIterateClosure(ClassLoaderData::_claim_other), - _verify_weaks(verify_weaks) {} - - virtual void do_oop(oop* p) { - if (_verify_weaks) { - z_verify_possibly_weak_oop(p); - } else { - // We should never encounter finalizable oops through strong - // paths. This assumes we have only visited strong roots. - z_verify_oop(p); - } - } - - virtual void do_oop(narrowOop* p) { - ShouldNotReachHere(); - } - - virtual ReferenceIterationMode reference_iteration_mode() { - return _verify_weaks ? DO_FIELDS : DO_FIELDS_EXCEPT_REFERENT; - } - - // Don't follow this metadata when verifying oops - virtual void do_method(Method* m) {} - virtual void do_nmethod(nmethod* nm) {} -}; - -typedef ClaimingCLDToOopClosure XVerifyCLDClosure; - -class XVerifyThreadClosure : public ThreadClosure { -private: - XVerifyRootClosure* const _cl; - -public: - XVerifyThreadClosure(XVerifyRootClosure* cl) : - _cl(cl) {} - - virtual void do_thread(Thread* thread) { - thread->oops_do_no_frames(_cl, nullptr); - - JavaThread* const jt = JavaThread::cast(thread); - if (!jt->has_last_Java_frame()) { - return; - } - - XVerifyStack verify_stack(_cl, jt); - verify_stack.verify_frames(); - } -}; - -class XVerifyNMethodClosure : public NMethodClosure { -private: - OopClosure* const _cl; - BarrierSetNMethod* const _bs_nm; - const bool _verify_fixed; - - bool trust_nmethod_state() const { - // The root iterator will visit non-processed - // nmethods class unloading is turned off. - return ClassUnloading || _verify_fixed; - } - -public: - XVerifyNMethodClosure(OopClosure* cl, bool verify_fixed) : - _cl(cl), - _bs_nm(BarrierSet::barrier_set()->barrier_set_nmethod()), - _verify_fixed(verify_fixed) {} - - virtual void do_nmethod(nmethod* nm) { - assert(!trust_nmethod_state() || !_bs_nm->is_armed(nm), "Should not encounter any armed nmethods"); - - XNMethod::nmethod_oops_do(nm, _cl); - } -}; - -void XVerify::roots_strong(bool verify_fixed) { - assert(SafepointSynchronize::is_at_safepoint(), "Must be at a safepoint"); - assert(!XResurrection::is_blocked(), "Invalid phase"); - - XVerifyRootClosure cl(verify_fixed); - XVerifyCLDClosure cld_cl(&cl); - XVerifyThreadClosure thread_cl(&cl); - XVerifyNMethodClosure nm_cl(&cl, verify_fixed); - - XRootsIterator iter(ClassLoaderData::_claim_none); - iter.apply(&cl, - &cld_cl, - &thread_cl, - &nm_cl); -} - -void XVerify::roots_weak() { - assert(SafepointSynchronize::is_at_safepoint(), "Must be at a safepoint"); - assert(!XResurrection::is_blocked(), "Invalid phase"); - - XVerifyRootClosure cl(true /* verify_fixed */); - XWeakRootsIterator iter; - iter.apply(&cl); -} - -void XVerify::objects(bool verify_weaks) { - assert(SafepointSynchronize::is_at_safepoint(), "Must be at a safepoint"); - assert(XGlobalPhase == XPhaseMarkCompleted, "Invalid phase"); - assert(!XResurrection::is_blocked(), "Invalid phase"); - - XVerifyOopClosure cl(verify_weaks); - ObjectToOopClosure object_cl(&cl); - XHeap::heap()->object_iterate(&object_cl, verify_weaks); -} - -void XVerify::before_zoperation() { - // Verify strong roots - XStatTimerDisable disable; - if (ZVerifyRoots) { - roots_strong(false /* verify_fixed */); - } -} - -void XVerify::after_mark() { - // Verify all strong roots and strong references - XStatTimerDisable disable; - if (ZVerifyRoots) { - roots_strong(true /* verify_fixed */); - } - if (ZVerifyObjects) { - objects(false /* verify_weaks */); - } -} - -void XVerify::after_weak_processing() { - // Verify all roots and all references - XStatTimerDisable disable; - if (ZVerifyRoots) { - roots_strong(true /* verify_fixed */); - roots_weak(); - } - if (ZVerifyObjects) { - objects(true /* verify_weaks */); - } -} - -template -class XPageDebugMapOrUnmapClosure : public XPageClosure { -private: - const XPageAllocator* const _allocator; - -public: - XPageDebugMapOrUnmapClosure(const XPageAllocator* allocator) : - _allocator(allocator) {} - - void do_page(const XPage* page) { - if (Map) { - _allocator->debug_map_page(page); - } else { - _allocator->debug_unmap_page(page); - } - } -}; - -XVerifyViewsFlip::XVerifyViewsFlip(const XPageAllocator* allocator) : - _allocator(allocator) { - if (ZVerifyViews) { - // Unmap all pages - XPageDebugMapOrUnmapClosure cl(_allocator); - XHeap::heap()->pages_do(&cl); - } -} - -XVerifyViewsFlip::~XVerifyViewsFlip() { - if (ZVerifyViews) { - // Map all pages - XPageDebugMapOrUnmapClosure cl(_allocator); - XHeap::heap()->pages_do(&cl); - } -} - -#ifdef ASSERT - -class XVerifyBadOopClosure : public OopClosure { -public: - virtual void do_oop(oop* p) { - const oop o = *p; - assert(!XAddress::is_good(XOop::to_address(o)), "Should not be good: " PTR_FORMAT, p2i(o)); - } - - virtual void do_oop(narrowOop* p) { - ShouldNotReachHere(); - } -}; - -// This class encapsulates various marks we need to deal with calling the -// frame iteration code from arbitrary points in the runtime. It is mostly -// due to problems that we might want to eventually clean up inside of the -// frame iteration code, such as creating random handles even though there -// is no safepoint to protect against, and fiddling around with exceptions. -class StackWatermarkProcessingMark { - ResetNoHandleMark _rnhm; - HandleMark _hm; - PreserveExceptionMark _pem; - ResourceMark _rm; - -public: - StackWatermarkProcessingMark(Thread* thread) : - _rnhm(), - _hm(thread), - _pem(thread), - _rm(thread) {} -}; - -void XVerify::verify_frame_bad(const frame& fr, RegisterMap& register_map) { - XVerifyBadOopClosure verify_cl; - fr.oops_do(&verify_cl, nullptr, ®ister_map, DerivedPointerIterationMode::_ignore); -} - -void XVerify::verify_thread_head_bad(JavaThread* jt) { - XVerifyBadOopClosure verify_cl; - jt->oops_do_no_frames(&verify_cl, nullptr); -} - -void XVerify::verify_thread_frames_bad(JavaThread* jt) { - if (jt->has_last_Java_frame()) { - XVerifyBadOopClosure verify_cl; - StackWatermarkProcessingMark swpm(Thread::current()); - // Traverse the execution stack - for (StackFrameStream fst(jt, true /* update */, false /* process_frames */); !fst.is_done(); fst.next()) { - fst.current()->oops_do(&verify_cl, nullptr /* code_cl */, fst.register_map(), DerivedPointerIterationMode::_ignore); - } - } -} - -#endif // ASSERT diff --git a/src/hotspot/share/gc/x/xVerify.hpp b/src/hotspot/share/gc/x/xVerify.hpp deleted file mode 100644 index bbe10f376fa..00000000000 --- a/src/hotspot/share/gc/x/xVerify.hpp +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2019, 2022, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XVERIFY_HPP -#define SHARE_GC_X_XVERIFY_HPP - -#include "memory/allStatic.hpp" - -class frame; -class XPageAllocator; - -class XVerify : public AllStatic { -private: - static void roots_strong(bool verify_fixed); - static void roots_weak(); - - static void objects(bool verify_weaks); - -public: - static void before_zoperation(); - static void after_mark(); - static void after_weak_processing(); - - static void verify_thread_head_bad(JavaThread* thread) NOT_DEBUG_RETURN; - static void verify_thread_frames_bad(JavaThread* thread) NOT_DEBUG_RETURN; - static void verify_frame_bad(const frame& fr, RegisterMap& register_map) NOT_DEBUG_RETURN; -}; - -class XVerifyViewsFlip { -private: - const XPageAllocator* const _allocator; - -public: - XVerifyViewsFlip(const XPageAllocator* allocator); - ~XVerifyViewsFlip(); -}; - -#endif // SHARE_GC_X_XVERIFY_HPP diff --git a/src/hotspot/share/gc/x/xVirtualMemory.cpp b/src/hotspot/share/gc/x/xVirtualMemory.cpp deleted file mode 100644 index 63cb789d8de..00000000000 --- a/src/hotspot/share/gc/x/xVirtualMemory.cpp +++ /dev/null @@ -1,208 +0,0 @@ -/* - * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/shared/gcLogPrecious.hpp" -#include "gc/x/xAddress.inline.hpp" -#include "gc/x/xAddressSpaceLimit.hpp" -#include "gc/x/xGlobals.hpp" -#include "gc/x/xVirtualMemory.inline.hpp" -#include "nmt/memTracker.hpp" -#include "utilities/align.hpp" -#include "utilities/debug.hpp" - -XVirtualMemoryManager::XVirtualMemoryManager(size_t max_capacity) : - _manager(), - _reserved(0), - _initialized(false) { - - // Check max supported heap size - if (max_capacity > XAddressOffsetMax) { - log_error_p(gc)("Java heap too large (max supported heap size is " SIZE_FORMAT "G)", - XAddressOffsetMax / G); - return; - } - - // Initialize platform specific parts before reserving address space - pd_initialize_before_reserve(); - - // Reserve address space - if (!reserve(max_capacity)) { - log_error_pd(gc)("Failed to reserve enough address space for Java heap"); - return; - } - - // Initialize platform specific parts after reserving address space - pd_initialize_after_reserve(); - - // Successfully initialized - _initialized = true; -} - -size_t XVirtualMemoryManager::reserve_discontiguous(uintptr_t start, size_t size, size_t min_range) { - if (size < min_range) { - // Too small - return 0; - } - - assert(is_aligned(size, XGranuleSize), "Misaligned"); - - if (reserve_contiguous(start, size)) { - return size; - } - - const size_t half = size / 2; - if (half < min_range) { - // Too small - return 0; - } - - // Divide and conquer - const size_t first_part = align_down(half, XGranuleSize); - const size_t second_part = size - first_part; - return reserve_discontiguous(start, first_part, min_range) + - reserve_discontiguous(start + first_part, second_part, min_range); -} - -size_t XVirtualMemoryManager::reserve_discontiguous(size_t size) { - // Don't try to reserve address ranges smaller than 1% of the requested size. - // This avoids an explosion of reservation attempts in case large parts of the - // address space is already occupied. - const size_t min_range = align_up(size / 100, XGranuleSize); - size_t start = 0; - size_t reserved = 0; - - // Reserve size somewhere between [0, XAddressOffsetMax) - while (reserved < size && start < XAddressOffsetMax) { - const size_t remaining = MIN2(size - reserved, XAddressOffsetMax - start); - reserved += reserve_discontiguous(start, remaining, min_range); - start += remaining; - } - - return reserved; -} - -bool XVirtualMemoryManager::reserve_contiguous(uintptr_t start, size_t size) { - assert(is_aligned(size, XGranuleSize), "Must be granule aligned"); - - // Reserve address views - const uintptr_t marked0 = XAddress::marked0(start); - const uintptr_t marked1 = XAddress::marked1(start); - const uintptr_t remapped = XAddress::remapped(start); - - // Reserve address space - if (!pd_reserve(marked0, size)) { - return false; - } - - if (!pd_reserve(marked1, size)) { - pd_unreserve(marked0, size); - return false; - } - - if (!pd_reserve(remapped, size)) { - pd_unreserve(marked0, size); - pd_unreserve(marked1, size); - return false; - } - - // Register address views with native memory tracker - nmt_reserve(marked0, size); - nmt_reserve(marked1, size); - nmt_reserve(remapped, size); - - // Make the address range free - _manager.free(start, size); - - return true; -} - -bool XVirtualMemoryManager::reserve_contiguous(size_t size) { - // Allow at most 8192 attempts spread evenly across [0, XAddressOffsetMax) - const size_t unused = XAddressOffsetMax - size; - const size_t increment = MAX2(align_up(unused / 8192, XGranuleSize), XGranuleSize); - - for (size_t start = 0; start + size <= XAddressOffsetMax; start += increment) { - if (reserve_contiguous(start, size)) { - // Success - return true; - } - } - - // Failed - return false; -} - -bool XVirtualMemoryManager::reserve(size_t max_capacity) { - const size_t limit = MIN2(XAddressOffsetMax, XAddressSpaceLimit::heap_view()); - const size_t size = MIN2(max_capacity * XVirtualToPhysicalRatio, limit); - - size_t reserved = size; - bool contiguous = true; - - // Prefer a contiguous address space - if (!reserve_contiguous(size)) { - // Fall back to a discontiguous address space - reserved = reserve_discontiguous(size); - contiguous = false; - } - - log_info_p(gc, init)("Address Space Type: %s/%s/%s", - (contiguous ? "Contiguous" : "Discontiguous"), - (limit == XAddressOffsetMax ? "Unrestricted" : "Restricted"), - (reserved == size ? "Complete" : "Degraded")); - log_info_p(gc, init)("Address Space Size: " SIZE_FORMAT "M x " SIZE_FORMAT " = " SIZE_FORMAT "M", - reserved / M, XHeapViews, (reserved * XHeapViews) / M); - - // Record reserved - _reserved = reserved; - - return reserved >= max_capacity; -} - -void XVirtualMemoryManager::nmt_reserve(uintptr_t start, size_t size) { - MemTracker::record_virtual_memory_reserve((void*)start, size, CALLER_PC); - MemTracker::record_virtual_memory_tag((void*)start, mtJavaHeap); -} - -bool XVirtualMemoryManager::is_initialized() const { - return _initialized; -} - -XVirtualMemory XVirtualMemoryManager::alloc(size_t size, bool force_low_address) { - uintptr_t start; - - // Small pages are allocated at low addresses, while medium/large pages - // are allocated at high addresses (unless forced to be at a low address). - if (force_low_address || size <= XPageSizeSmall) { - start = _manager.alloc_low_address(size); - } else { - start = _manager.alloc_high_address(size); - } - - return XVirtualMemory(start, size); -} - -void XVirtualMemoryManager::free(const XVirtualMemory& vmem) { - _manager.free(vmem.start(), vmem.size()); -} diff --git a/src/hotspot/share/gc/x/xVirtualMemory.hpp b/src/hotspot/share/gc/x/xVirtualMemory.hpp deleted file mode 100644 index c9e5c67ea57..00000000000 --- a/src/hotspot/share/gc/x/xVirtualMemory.hpp +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2015, 2020, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XVIRTUALMEMORY_HPP -#define SHARE_GC_X_XVIRTUALMEMORY_HPP - -#include "gc/x/xMemory.hpp" - -class VMStructs; - -class XVirtualMemory { - friend class ::VMStructs; - -private: - uintptr_t _start; - uintptr_t _end; - -public: - XVirtualMemory(); - XVirtualMemory(uintptr_t start, size_t size); - - bool is_null() const; - uintptr_t start() const; - uintptr_t end() const; - size_t size() const; - - XVirtualMemory split(size_t size); -}; - -class XVirtualMemoryManager { -private: - XMemoryManager _manager; - uintptr_t _reserved; - bool _initialized; - - // Platform specific implementation - void pd_initialize_before_reserve(); - void pd_initialize_after_reserve(); - bool pd_reserve(uintptr_t addr, size_t size); - void pd_unreserve(uintptr_t addr, size_t size); - - bool reserve_contiguous(uintptr_t start, size_t size); - bool reserve_contiguous(size_t size); - size_t reserve_discontiguous(uintptr_t start, size_t size, size_t min_range); - size_t reserve_discontiguous(size_t size); - bool reserve(size_t max_capacity); - - void nmt_reserve(uintptr_t start, size_t size); - -public: - XVirtualMemoryManager(size_t max_capacity); - - bool is_initialized() const; - - size_t reserved() const; - uintptr_t lowest_available_address() const; - - XVirtualMemory alloc(size_t size, bool force_low_address); - void free(const XVirtualMemory& vmem); -}; - -#endif // SHARE_GC_X_XVIRTUALMEMORY_HPP diff --git a/src/hotspot/share/gc/x/xVirtualMemory.inline.hpp b/src/hotspot/share/gc/x/xVirtualMemory.inline.hpp deleted file mode 100644 index 8c834b42c7f..00000000000 --- a/src/hotspot/share/gc/x/xVirtualMemory.inline.hpp +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2015, 2019, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XVIRTUALMEMORY_INLINE_HPP -#define SHARE_GC_X_XVIRTUALMEMORY_INLINE_HPP - -#include "gc/x/xVirtualMemory.hpp" - -#include "gc/x/xMemory.inline.hpp" - -inline XVirtualMemory::XVirtualMemory() : - _start(UINTPTR_MAX), - _end(UINTPTR_MAX) {} - -inline XVirtualMemory::XVirtualMemory(uintptr_t start, size_t size) : - _start(start), - _end(start + size) {} - -inline bool XVirtualMemory::is_null() const { - return _start == UINTPTR_MAX; -} - -inline uintptr_t XVirtualMemory::start() const { - return _start; -} - -inline uintptr_t XVirtualMemory::end() const { - return _end; -} - -inline size_t XVirtualMemory::size() const { - return _end - _start; -} - -inline XVirtualMemory XVirtualMemory::split(size_t size) { - _start += size; - return XVirtualMemory(_start - size, size); -} - -inline size_t XVirtualMemoryManager::reserved() const { - return _reserved; -} - -inline uintptr_t XVirtualMemoryManager::lowest_available_address() const { - return _manager.peek_low_address(); -} - -#endif // SHARE_GC_X_XVIRTUALMEMORY_INLINE_HPP diff --git a/src/hotspot/share/gc/x/xWeakRootsProcessor.cpp b/src/hotspot/share/gc/x/xWeakRootsProcessor.cpp deleted file mode 100644 index 0271fcd8c3d..00000000000 --- a/src/hotspot/share/gc/x/xWeakRootsProcessor.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2015, 2021, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/x/xBarrier.inline.hpp" -#include "gc/x/xRootsIterator.hpp" -#include "gc/x/xTask.hpp" -#include "gc/x/xWeakRootsProcessor.hpp" -#include "gc/x/xWorkers.hpp" - -class XPhantomCleanOopClosure : public OopClosure { -public: - virtual void do_oop(oop* p) { - // Read the oop once, to make sure the liveness check - // and the later clearing uses the same value. - const oop obj = Atomic::load(p); - if (XBarrier::is_alive_barrier_on_phantom_oop(obj)) { - XBarrier::keep_alive_barrier_on_phantom_oop_field(p); - } else { - // The destination could have been modified/reused, in which case - // we don't want to clear it. However, no one could write the same - // oop here again (the object would be strongly live and we would - // not consider clearing such oops), so therefore we don't have an - // ABA problem here. - Atomic::cmpxchg(p, obj, oop(nullptr)); - } - } - - virtual void do_oop(narrowOop* p) { - ShouldNotReachHere(); - } -}; - -XWeakRootsProcessor::XWeakRootsProcessor(XWorkers* workers) : - _workers(workers) {} - -class XProcessWeakRootsTask : public XTask { -private: - XWeakRootsIterator _weak_roots; - -public: - XProcessWeakRootsTask() : - XTask("XProcessWeakRootsTask"), - _weak_roots() {} - - ~XProcessWeakRootsTask() { - _weak_roots.report_num_dead(); - } - - virtual void work() { - XPhantomCleanOopClosure cl; - _weak_roots.apply(&cl); - } -}; - -void XWeakRootsProcessor::process_weak_roots() { - XProcessWeakRootsTask task; - _workers->run(&task); -} diff --git a/src/hotspot/share/gc/x/xWeakRootsProcessor.hpp b/src/hotspot/share/gc/x/xWeakRootsProcessor.hpp deleted file mode 100644 index c63b2702374..00000000000 --- a/src/hotspot/share/gc/x/xWeakRootsProcessor.hpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2017, 2020, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XWEAKROOTSPROCESSOR_HPP -#define SHARE_GC_X_XWEAKROOTSPROCESSOR_HPP - -class XWorkers; - -class XWeakRootsProcessor { -private: - XWorkers* const _workers; - -public: - XWeakRootsProcessor(XWorkers* workers); - - void process_weak_roots(); -}; - -#endif // SHARE_GC_X_XWEAKROOTSPROCESSOR_HPP diff --git a/src/hotspot/share/gc/x/xWorkers.cpp b/src/hotspot/share/gc/x/xWorkers.cpp deleted file mode 100644 index 642c63f0531..00000000000 --- a/src/hotspot/share/gc/x/xWorkers.cpp +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Copyright (c) 2015, 2021, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/shared/gc_globals.hpp" -#include "gc/shared/gcLogPrecious.hpp" -#include "gc/x/xLock.inline.hpp" -#include "gc/x/xStat.hpp" -#include "gc/x/xTask.hpp" -#include "gc/x/xThread.hpp" -#include "gc/x/xWorkers.hpp" -#include "runtime/java.hpp" - -class XWorkersInitializeTask : public WorkerTask { -private: - const uint _nworkers; - uint _started; - XConditionLock _lock; - -public: - XWorkersInitializeTask(uint nworkers) : - WorkerTask("XWorkersInitializeTask"), - _nworkers(nworkers), - _started(0), - _lock() {} - - virtual void work(uint worker_id) { - // Register as worker - XThread::set_worker(); - - // Wait for all threads to start - XLocker locker(&_lock); - if (++_started == _nworkers) { - // All threads started - _lock.notify_all(); - } else { - while (_started != _nworkers) { - _lock.wait(); - } - } - } -}; - -XWorkers::XWorkers() : - _workers("XWorker", - UseDynamicNumberOfGCThreads ? ConcGCThreads : MAX2(ConcGCThreads, ParallelGCThreads)) { - - if (UseDynamicNumberOfGCThreads) { - log_info_p(gc, init)("GC Workers: %u (dynamic)", _workers.max_workers()); - } else { - log_info_p(gc, init)("GC Workers: %u/%u (static)", ConcGCThreads, _workers.max_workers()); - } - - // Initialize worker threads - _workers.initialize_workers(); - _workers.set_active_workers(_workers.max_workers()); - if (_workers.active_workers() != _workers.max_workers()) { - vm_exit_during_initialization("Failed to create XWorkers"); - } - - // Execute task to register threads as workers - XWorkersInitializeTask task(_workers.max_workers()); - _workers.run_task(&task); -} - -uint XWorkers::active_workers() const { - return _workers.active_workers(); -} - -void XWorkers::set_active_workers(uint nworkers) { - log_info(gc, task)("Using %u workers", nworkers); - _workers.set_active_workers(nworkers); -} - -void XWorkers::run(XTask* task) { - log_debug(gc, task)("Executing Task: %s, Active Workers: %u", task->name(), active_workers()); - XStatWorkers::at_start(); - _workers.run_task(task->worker_task()); - XStatWorkers::at_end(); -} - -void XWorkers::run_all(XTask* task) { - // Save number of active workers - const uint prev_active_workers = _workers.active_workers(); - - // Execute task using all workers - _workers.set_active_workers(_workers.max_workers()); - log_debug(gc, task)("Executing Task: %s, Active Workers: %u", task->name(), active_workers()); - _workers.run_task(task->worker_task()); - - // Restore number of active workers - _workers.set_active_workers(prev_active_workers); -} - -void XWorkers::threads_do(ThreadClosure* tc) const { - _workers.threads_do(tc); -} diff --git a/src/hotspot/share/gc/x/xWorkers.hpp b/src/hotspot/share/gc/x/xWorkers.hpp deleted file mode 100644 index 33c49bb7fef..00000000000 --- a/src/hotspot/share/gc/x/xWorkers.hpp +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright (c) 2015, 2021, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_XWORKERS_HPP -#define SHARE_GC_X_XWORKERS_HPP - -#include "gc/shared/workerThread.hpp" - -class ThreadClosure; -class XTask; - -class XWorkers { -private: - WorkerThreads _workers; - -public: - XWorkers(); - - uint active_workers() const; - void set_active_workers(uint nworkers); - - void run(XTask* task); - void run_all(XTask* task); - - void threads_do(ThreadClosure* tc) const; -}; - -#endif // SHARE_GC_X_XWORKERS_HPP diff --git a/src/hotspot/share/gc/x/x_globals.hpp b/src/hotspot/share/gc/x/x_globals.hpp deleted file mode 100644 index ab47d7ba9c8..00000000000 --- a/src/hotspot/share/gc/x/x_globals.hpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_X_X_GLOBALS_HPP -#define SHARE_GC_X_X_GLOBALS_HPP - -#define GC_X_FLAGS(develop, \ - develop_pd, \ - product, \ - product_pd, \ - range, \ - constraint) \ - \ - product(bool, ZVerifyViews, false, DIAGNOSTIC, \ - "Verify heap view accesses") \ - \ -// end of GC_X_FLAGS - -#endif // SHARE_GC_X_X_GLOBALS_HPP diff --git a/src/hotspot/share/gc/z/shared/vmStructs_z_shared.hpp b/src/hotspot/share/gc/z/shared/vmStructs_z_shared.hpp deleted file mode 100644 index f0c03abbf7a..00000000000 --- a/src/hotspot/share/gc/z/shared/vmStructs_z_shared.hpp +++ /dev/null @@ -1,68 +0,0 @@ -/* - * 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_Z_SHARED_VMSTRUCTS_Z_SHARED_HPP -#define SHARE_GC_Z_SHARED_VMSTRUCTS_Z_SHARED_HPP - -#include "gc/x/vmStructs_x.hpp" -#include "gc/z/vmStructs_z.hpp" - -#define VM_STRUCTS_Z_SHARED(nonstatic_field, volatile_nonstatic_field, static_field) \ - VM_STRUCTS_X( \ - nonstatic_field, \ - volatile_nonstatic_field, \ - static_field) \ - \ - VM_STRUCTS_Z( \ - nonstatic_field, \ - volatile_nonstatic_field, \ - static_field) - -#define VM_INT_CONSTANTS_Z_SHARED(declare_constant, declare_constant_with_value) \ - VM_INT_CONSTANTS_X( \ - declare_constant, \ - declare_constant_with_value) \ - \ - VM_INT_CONSTANTS_Z( \ - declare_constant, \ - declare_constant_with_value) - -#define VM_LONG_CONSTANTS_Z_SHARED(declare_constant) \ - VM_LONG_CONSTANTS_X( \ - declare_constant) \ - \ - VM_LONG_CONSTANTS_Z( \ - declare_constant) - -#define VM_TYPES_Z_SHARED(declare_type, declare_toplevel_type, declare_integer_type) \ - VM_TYPES_X( \ - declare_type, \ - declare_toplevel_type, \ - declare_integer_type) \ - \ - VM_TYPES_Z( \ - declare_type, \ - declare_toplevel_type, \ - declare_integer_type) - -#endif // SHARE_GC_Z_SHARED_VMSTRUCTS_Z_SHARED_HPP diff --git a/src/hotspot/share/gc/z/shared/zSharedArguments.cpp b/src/hotspot/share/gc/z/shared/zSharedArguments.cpp deleted file mode 100644 index 4d7e9827f18..00000000000 --- a/src/hotspot/share/gc/z/shared/zSharedArguments.cpp +++ /dev/null @@ -1,87 +0,0 @@ -/* - * 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/shared/gcArguments.hpp" -#include "gc/x/xArguments.hpp" -#include "gc/z/shared/zSharedArguments.hpp" -#include "gc/z/zArguments.hpp" -#include "runtime/globals.hpp" -#include "runtime/globals_extension.hpp" -#include "runtime/java.hpp" - -void ZSharedArguments::initialize_alignments() { - if (ZGenerational) { - ZArguments::initialize_alignments(); - } else { - XArguments::initialize_alignments(); - } -} - -void ZSharedArguments::initialize_heap_flags_and_sizes() { - GCArguments::initialize_heap_flags_and_sizes(); - - if (ZGenerational) { - ZArguments::initialize_heap_flags_and_sizes(); - } else { - XArguments::initialize_heap_flags_and_sizes(); - } -} - -void ZSharedArguments::initialize() { - GCArguments::initialize(); - - if (ZGenerational) { - ZArguments::initialize(); - } else { - XArguments::initialize(); - } -} - -size_t ZSharedArguments::heap_virtual_to_physical_ratio() { - if (ZGenerational) { - return ZArguments::heap_virtual_to_physical_ratio(); - } else { - return XArguments::heap_virtual_to_physical_ratio(); - } -} - -size_t ZSharedArguments::conservative_max_heap_alignment() { - return 0; -} - -CollectedHeap* ZSharedArguments::create_heap() { - if (ZGenerational) { - return ZArguments::create_heap(); - } else { - return XArguments::create_heap(); - } -} - -bool ZSharedArguments::is_supported() const { - if (ZGenerational) { - return ZArguments::is_os_supported(); - } else { - return XArguments::is_os_supported(); - } -} diff --git a/src/hotspot/share/gc/z/shared/zSharedArguments.hpp b/src/hotspot/share/gc/z/shared/zSharedArguments.hpp deleted file mode 100644 index c53f28ee0f9..00000000000 --- a/src/hotspot/share/gc/z/shared/zSharedArguments.hpp +++ /dev/null @@ -1,46 +0,0 @@ -/* - * 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_Z_SHARED_ZSHAREDARGUMENTS_HPP -#define SHARE_GC_Z_SHARED_ZSHAREDARGUMENTS_HPP - -#include "gc/shared/gcArguments.hpp" - -class CollectedHeap; - -class ZSharedArguments : public GCArguments { -private: - virtual void initialize_alignments(); - virtual void initialize_heap_flags_and_sizes(); - - virtual void initialize(); - virtual size_t conservative_max_heap_alignment(); - virtual size_t heap_virtual_to_physical_ratio(); - virtual CollectedHeap* create_heap(); - - virtual bool is_supported() const; - - bool is_os_supported() const; -}; - -#endif // SHARE_GC_Z_SHARED_ZSHAREDARGUMENTS_HPP diff --git a/src/hotspot/share/gc/z/shared/z_shared_globals.hpp b/src/hotspot/share/gc/z/shared/z_shared_globals.hpp deleted file mode 100644 index 4421d3fb0c3..00000000000 --- a/src/hotspot/share/gc/z/shared/z_shared_globals.hpp +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#ifndef SHARE_GC_Z_SHARED_Z_SHARED_GLOBALS_HPP -#define SHARE_GC_Z_SHARED_Z_SHARED_GLOBALS_HPP - -#include "gc/x/x_globals.hpp" -#include "gc/z/z_globals.hpp" - -#define GC_Z_SHARED_FLAGS(develop, \ - develop_pd, \ - product, \ - product_pd, \ - range, \ - constraint) \ - \ - product(double, ZAllocationSpikeTolerance, 2.0, \ - "Allocation spike tolerance factor") \ - \ - /* Updated in arguments parsing to ZGenerational ? 5.0 : 25.0 */ \ - product(double, ZFragmentationLimit, 0 /* ignored */, \ - "Maximum allowed heap fragmentation") \ - range(0, 100) \ - \ - product(size_t, ZMarkStackSpaceLimit, 8*G, \ - "Maximum number of bytes allocated for mark stacks") \ - range(32*M, 1024*G) \ - \ - product(double, ZCollectionInterval, 0, \ - "Force GC at a fixed time interval (in seconds). " \ - "Backwards compatible alias for ZCollectionIntervalMajor") \ - \ - product(bool, ZProactive, true, \ - "Enable proactive GC cycles") \ - \ - product(bool, ZUncommit, true, \ - "Uncommit unused memory") \ - \ - product(uintx, ZUncommitDelay, 5 * 60, \ - "Uncommit memory if it has been unused for the specified " \ - "amount of time (in seconds)") \ - \ - product(double, ZAsyncUnmappingLimit, 100.0, DIAGNOSTIC, \ - "Specify the max amount (percentage of max heap size) of async " \ - "unmapping that can be in-flight before unmapping requests are " \ - "temporarily forced to be synchronous instead. " \ - "The default means after an amount of pages proportional to the " \ - "max capacity is enqueued, we resort to synchronous unmapping.") \ - \ - product(uint, ZStatisticsInterval, 10, DIAGNOSTIC, \ - "Time between statistics print outs (in seconds)") \ - range(1, (uint)-1) \ - \ - product(bool, ZStressRelocateInPlace, false, DIAGNOSTIC, \ - "Always relocate pages in-place") \ - \ - product(bool, ZVerifyRoots, trueInDebug, DIAGNOSTIC, \ - "Verify roots") \ - \ - product(bool, ZVerifyObjects, false, DIAGNOSTIC, \ - "Verify objects") \ - \ - product(bool, ZVerifyMarking, trueInDebug, DIAGNOSTIC, \ - "Verify marking stacks") \ - \ - product(bool, ZVerifyForwarding, false, DIAGNOSTIC, \ - "Verify forwarding tables") \ - \ - GC_X_FLAGS( \ - develop, \ - develop_pd, \ - product, \ - product_pd, \ - range, \ - constraint) \ - \ - GC_Z_FLAGS( \ - develop, \ - develop_pd, \ - product, \ - product_pd, \ - range, \ - constraint) - -// end of GC_Z_SHARED_FLAGS - -#endif // SHARE_GC_Z_SHARED_Z_SHARED_GLOBALS_HPP diff --git a/src/hotspot/share/gc/z/zArguments.cpp b/src/hotspot/share/gc/z/zArguments.cpp index f3ff568c64d..331ca9f7c94 100644 --- a/src/hotspot/share/gc/z/zArguments.cpp +++ b/src/hotspot/share/gc/z/zArguments.cpp @@ -38,6 +38,8 @@ void ZArguments::initialize_alignments() { } void ZArguments::initialize_heap_flags_and_sizes() { + GCArguments::initialize_heap_flags_and_sizes(); + if (!FLAG_IS_CMDLINE(MaxHeapSize) && !FLAG_IS_CMDLINE(MaxRAMPercentage) && !FLAG_IS_CMDLINE(SoftMaxHeapSize)) { @@ -117,6 +119,8 @@ void ZArguments::select_max_gc_threads() { } void ZArguments::initialize() { + GCArguments::initialize(); + // Check mark stack size const size_t mark_stack_space_limit = ZAddressSpaceLimit::mark_stack(); if (ZMarkStackSpaceLimit > mark_stack_space_limit) { @@ -220,6 +224,10 @@ void ZArguments::initialize() { #endif } +size_t ZArguments::conservative_max_heap_alignment() { + return 0; +} + size_t ZArguments::heap_virtual_to_physical_ratio() { return ZVirtualToPhysicalRatio; } @@ -228,6 +236,6 @@ CollectedHeap* ZArguments::create_heap() { return new ZCollectedHeap(); } -bool ZArguments::is_supported() { +bool ZArguments::is_supported() const { return is_os_supported(); } diff --git a/src/hotspot/share/gc/z/zArguments.hpp b/src/hotspot/share/gc/z/zArguments.hpp index 7d1c00d30d1..b51eb116dbf 100644 --- a/src/hotspot/share/gc/z/zArguments.hpp +++ b/src/hotspot/share/gc/z/zArguments.hpp @@ -28,20 +28,21 @@ class CollectedHeap; -class ZArguments : AllStatic { +class ZArguments : public GCArguments { private: static void select_max_gc_threads(); -public: - static void initialize_alignments(); - static void initialize_heap_flags_and_sizes(); - static void initialize(); - static size_t heap_virtual_to_physical_ratio(); - static CollectedHeap* create_heap(); - - static bool is_supported(); - static bool is_os_supported(); + +public: + virtual void initialize_alignments(); + virtual void initialize_heap_flags_and_sizes(); + virtual void initialize(); + virtual size_t conservative_max_heap_alignment(); + virtual size_t heap_virtual_to_physical_ratio(); + virtual CollectedHeap* create_heap(); + + virtual bool is_supported() const; }; #endif // SHARE_GC_Z_ZARGUMENTS_HPP diff --git a/src/hotspot/share/gc/z/z_globals.hpp b/src/hotspot/share/gc/z/z_globals.hpp index c3e4bde73e4..4e307632969 100644 --- a/src/hotspot/share/gc/z/z_globals.hpp +++ b/src/hotspot/share/gc/z/z_globals.hpp @@ -34,6 +34,31 @@ range, \ constraint) \ \ + product(double, ZAllocationSpikeTolerance, 2.0, \ + "Allocation spike tolerance factor") \ + \ + product(double, ZFragmentationLimit, 5.0, \ + "Maximum allowed heap fragmentation") \ + range(0, 100) \ + \ + product(size_t, ZMarkStackSpaceLimit, 8*G, \ + "Maximum number of bytes allocated for mark stacks") \ + range(32*M, 1024*G) \ + \ + product(double, ZCollectionInterval, 0, \ + "Force GC at a fixed time interval (in seconds). " \ + "Backwards compatible alias for ZCollectionIntervalMajor") \ + \ + product(bool, ZProactive, true, \ + "Enable proactive GC cycles") \ + \ + product(bool, ZUncommit, true, \ + "Uncommit unused memory") \ + \ + product(uintx, ZUncommitDelay, 5 * 60, \ + "Uncommit memory if it has been unused for the specified " \ + "amount of time (in seconds)") \ + \ product(double, ZYoungCompactionLimit, 25.0, \ "Maximum allowed garbage in young pages") \ range(0, 100) \ @@ -47,6 +72,32 @@ product(bool, ZCollectionIntervalOnly, false, \ "Only use timers for GC heuristics") \ \ + product(double, ZAsyncUnmappingLimit, 100.0, DIAGNOSTIC, \ + "Specify the max amount (percentage of max heap size) of async " \ + "unmapping that can be in-flight before unmapping requests are " \ + "temporarily forced to be synchronous instead. " \ + "The default means after an amount of pages proportional to the " \ + "max capacity is enqueued, we resort to synchronous unmapping.") \ + \ + product(uint, ZStatisticsInterval, 10, DIAGNOSTIC, \ + "Time between statistics print outs (in seconds)") \ + range(1, (uint)-1) \ + \ + product(bool, ZStressRelocateInPlace, false, DIAGNOSTIC, \ + "Always relocate pages in-place") \ + \ + product(bool, ZVerifyRoots, trueInDebug, DIAGNOSTIC, \ + "Verify roots") \ + \ + product(bool, ZVerifyObjects, false, DIAGNOSTIC, \ + "Verify objects") \ + \ + product(bool, ZVerifyMarking, trueInDebug, DIAGNOSTIC, \ + "Verify marking stacks") \ + \ + product(bool, ZVerifyForwarding, false, DIAGNOSTIC, \ + "Verify forwarding tables") \ + \ product(bool, ZBufferStoreBarriers, true, DIAGNOSTIC, \ "Buffer store barriers") \ \ @@ -64,13 +115,13 @@ product(bool, ZVerifyRemembered, trueInDebug, DIAGNOSTIC, \ "Verify remembered sets") \ \ - develop(bool, ZVerifyOops, false, \ - "Verify accessed oops") \ - \ product(int, ZTenuringThreshold, -1, DIAGNOSTIC, \ "Young generation tenuring threshold, -1 for dynamic computation")\ range(-1, static_cast(ZPageAgeMax)) \ \ + develop(bool, ZVerifyOops, false, \ + "Verify accessed oops") \ + \ develop(size_t, ZForceDiscontiguousHeapReservations, 0, \ "The gc will attempt to split the heap reservation into this " \ "many reservations, subject to available virtual address space " \ diff --git a/src/hotspot/share/include/jvm.h b/src/hotspot/share/include/jvm.h index edad228b4e3..6634306636b 100644 --- a/src/hotspot/share/include/jvm.h +++ b/src/hotspot/share/include/jvm.h @@ -1142,9 +1142,6 @@ JVM_VirtualThreadMount(JNIEnv* env, jobject vthread, jboolean hide); JNIEXPORT void JNICALL JVM_VirtualThreadUnmount(JNIEnv* env, jobject vthread, jboolean hide); -JNIEXPORT void JNICALL -JVM_VirtualThreadHideFrames(JNIEnv* env, jclass clazz, jboolean hide); - JNIEXPORT void JNICALL JVM_VirtualThreadDisableSuspend(JNIEnv* env, jclass clazz, jboolean enter); diff --git a/src/hotspot/share/jfr/instrumentation/jfrJvmtiAgent.cpp b/src/hotspot/share/jfr/instrumentation/jfrJvmtiAgent.cpp index 882d468a4a3..f8f975528cb 100644 --- a/src/hotspot/share/jfr/instrumentation/jfrJvmtiAgent.cpp +++ b/src/hotspot/share/jfr/instrumentation/jfrJvmtiAgent.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -133,7 +133,7 @@ static void log_and_throw(jvmtiError error, TRAPS) { static void check_exception_and_log(JNIEnv* env, TRAPS) { assert(env != nullptr, "invariant"); - if (env->ExceptionOccurred()) { + if (env->ExceptionCheck()) { // array index out of bound DEBUG_ONLY(JfrJavaSupport::check_java_thread_in_native(THREAD)); ThreadInVMfromNative tvmfn(THREAD); diff --git a/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp b/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp index 6bca2aa644e..dc3eecd5791 100644 --- a/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp +++ b/src/hotspot/share/jvmci/jvmciCodeInstaller.cpp @@ -343,6 +343,7 @@ narrowKlass CodeInstaller::record_narrow_metadata_reference(CodeSection* section int index = _oop_recorder->find_index(klass); section->relocate(dest, metadata_Relocation::spec(index)); JVMCI_event_3("narrowKlass[%d of %d] = %s", index, _oop_recorder->metadata_count(), klass->name()->as_C_string()); + guarantee(CompressedKlassPointers::is_encodable(klass), "klass cannot be compressed: %s", klass->external_name()); return CompressedKlassPointers::encode(klass); } #endif diff --git a/src/hotspot/share/jvmci/jvmciCompilerToVMInit.cpp b/src/hotspot/share/jvmci/jvmciCompilerToVMInit.cpp index 1612038008a..ab536a81e6e 100644 --- a/src/hotspot/share/jvmci/jvmciCompilerToVMInit.cpp +++ b/src/hotspot/share/jvmci/jvmciCompilerToVMInit.cpp @@ -36,8 +36,6 @@ #include "gc/shared/gc_globals.hpp" #include "gc/shared/tlab_globals.hpp" #if INCLUDE_ZGC -#include "gc/x/xBarrierSetRuntime.hpp" -#include "gc/x/xThreadLocalData.hpp" #include "gc/z/zBarrierSetRuntime.hpp" #include "gc/z/zThreadLocalData.hpp" #endif @@ -173,23 +171,9 @@ void CompilerToVM::Data::initialize(JVMCI_TRAPS) { #if INCLUDE_ZGC if (UseZGC) { - if (ZGenerational) { - ZPointerVectorLoadBadMask_address = (address) &ZPointerVectorLoadBadMask; - ZPointerVectorStoreBadMask_address = (address) &ZPointerVectorStoreBadMask; - ZPointerVectorStoreGoodMask_address = (address) &ZPointerVectorStoreGoodMask; - } else { - thread_address_bad_mask_offset = in_bytes(XThreadLocalData::address_bad_mask_offset()); - // Initialize the old names for compatibility. The proper XBarrierSetRuntime names are - // exported as addresses in vmStructs_jvmci.cpp as are the new ZBarrierSetRuntime names. - ZBarrierSetRuntime_load_barrier_on_oop_field_preloaded = XBarrierSetRuntime::load_barrier_on_oop_field_preloaded_addr(); - ZBarrierSetRuntime_load_barrier_on_weak_oop_field_preloaded = XBarrierSetRuntime::load_barrier_on_weak_oop_field_preloaded_addr(); - ZBarrierSetRuntime_load_barrier_on_phantom_oop_field_preloaded = XBarrierSetRuntime::load_barrier_on_phantom_oop_field_preloaded_addr(); - ZBarrierSetRuntime_weak_load_barrier_on_oop_field_preloaded = XBarrierSetRuntime::weak_load_barrier_on_oop_field_preloaded_addr(); - ZBarrierSetRuntime_weak_load_barrier_on_weak_oop_field_preloaded = XBarrierSetRuntime::weak_load_barrier_on_weak_oop_field_preloaded_addr(); - ZBarrierSetRuntime_weak_load_barrier_on_phantom_oop_field_preloaded = XBarrierSetRuntime::weak_load_barrier_on_phantom_oop_field_preloaded_addr(); - ZBarrierSetRuntime_load_barrier_on_oop_array = XBarrierSetRuntime::load_barrier_on_oop_array_addr(); - ZBarrierSetRuntime_clone = XBarrierSetRuntime::clone_addr(); - } + ZPointerVectorLoadBadMask_address = (address) &ZPointerVectorLoadBadMask; + ZPointerVectorStoreBadMask_address = (address) &ZPointerVectorStoreBadMask; + ZPointerVectorStoreGoodMask_address = (address) &ZPointerVectorStoreGoodMask; } #endif diff --git a/src/hotspot/share/jvmci/vmStructs_jvmci.cpp b/src/hotspot/share/jvmci/vmStructs_jvmci.cpp index 02e6eaf40f3..45ad1f577be 100644 --- a/src/hotspot/share/jvmci/vmStructs_jvmci.cpp +++ b/src/hotspot/share/jvmci/vmStructs_jvmci.cpp @@ -50,7 +50,6 @@ #include "gc/g1/g1ThreadLocalData.hpp" #endif #if INCLUDE_ZGC -#include "gc/x/xBarrierSetRuntime.hpp" #include "gc/z/zBarrierSetAssembler.hpp" #include "gc/z/zBarrierSetRuntime.hpp" #include "gc/z/zThreadLocalData.hpp" @@ -249,7 +248,6 @@ nonstatic_field(JavaThread, _cont_entry, ContinuationEntry*) \ nonstatic_field(JavaThread, _unlocked_inflated_monitor, ObjectMonitor*) \ JVMTI_ONLY(nonstatic_field(JavaThread, _is_in_VTMS_transition, bool)) \ - JVMTI_ONLY(nonstatic_field(JavaThread, _is_in_tmp_VTMS_transition, bool)) \ JVMTI_ONLY(nonstatic_field(JavaThread, _is_disable_suspend, bool)) \ \ nonstatic_field(ContinuationEntry, _pin_count, uint32_t) \ @@ -833,15 +831,6 @@ declare_function(os::javaTimeMillis) \ declare_function(os::javaTimeNanos) \ \ - ZGC_ONLY(DECLARE_FUNCTION_FROM_ADDR(declare_function_with_value, XBarrierSetRuntime::load_barrier_on_oop_field_preloaded)) \ - ZGC_ONLY(DECLARE_FUNCTION_FROM_ADDR(declare_function_with_value, XBarrierSetRuntime::load_barrier_on_weak_oop_field_preloaded)) \ - ZGC_ONLY(DECLARE_FUNCTION_FROM_ADDR(declare_function_with_value, XBarrierSetRuntime::load_barrier_on_phantom_oop_field_preloaded)) \ - ZGC_ONLY(DECLARE_FUNCTION_FROM_ADDR(declare_function_with_value, XBarrierSetRuntime::weak_load_barrier_on_oop_field_preloaded)) \ - ZGC_ONLY(DECLARE_FUNCTION_FROM_ADDR(declare_function_with_value, XBarrierSetRuntime::weak_load_barrier_on_weak_oop_field_preloaded)) \ - ZGC_ONLY(DECLARE_FUNCTION_FROM_ADDR(declare_function_with_value, XBarrierSetRuntime::weak_load_barrier_on_phantom_oop_field_preloaded)) \ - ZGC_ONLY(DECLARE_FUNCTION_FROM_ADDR(declare_function_with_value, XBarrierSetRuntime::load_barrier_on_oop_array)) \ - ZGC_ONLY(DECLARE_FUNCTION_FROM_ADDR(declare_function_with_value, XBarrierSetRuntime::clone)) \ - \ ZGC_ONLY(DECLARE_FUNCTION_FROM_ADDR(declare_function_with_value, ZBarrierSetRuntime::load_barrier_on_oop_field_preloaded)) \ ZGC_ONLY(DECLARE_FUNCTION_FROM_ADDR(declare_function_with_value, ZBarrierSetRuntime::load_barrier_on_weak_oop_field_preloaded)) \ ZGC_ONLY(DECLARE_FUNCTION_FROM_ADDR(declare_function_with_value, ZBarrierSetRuntime::load_barrier_on_phantom_oop_field_preloaded)) \ diff --git a/src/hotspot/share/libadt/vectset.cpp b/src/hotspot/share/libadt/vectset.cpp index b0d5d100400..e2eb08b1a34 100644 --- a/src/hotspot/share/libadt/vectset.cpp +++ b/src/hotspot/share/libadt/vectset.cpp @@ -49,9 +49,7 @@ void VectorSet::init(Arena* arena) { // Expand the existing set to a bigger size void VectorSet::grow(uint new_word_capacity) { _nesting.check(_set_arena); // Check if a potential reallocation in the arena is safe - if (new_word_capacity < _size) { - return; // No need to grow - } + assert(new_word_capacity >= _size, "Should have been checked before, use maybe_grow?"); assert(new_word_capacity < (1U << 30), ""); uint x = next_power_of_2(new_word_capacity); if (x > _data_size) { @@ -66,9 +64,7 @@ void VectorSet::grow(uint new_word_capacity) { void VectorSet::insert(uint elem) { uint32_t word = elem >> word_bits; uint32_t mask = 1U << (elem & bit_mask); - if (word >= _size) { - grow(word); - } + maybe_grow(word); _data[word] |= mask; } diff --git a/src/hotspot/share/libadt/vectset.hpp b/src/hotspot/share/libadt/vectset.hpp index eafa60db1fe..fee15566f24 100644 --- a/src/hotspot/share/libadt/vectset.hpp +++ b/src/hotspot/share/libadt/vectset.hpp @@ -49,8 +49,15 @@ class VectorSet : public AnyObj { ReallocMark _nesting; // Safety checks for arena reallocation void init(Arena* arena); + // Grow vector to required word capacity + void maybe_grow(uint new_word_capacity) { + if (new_word_capacity >= _size) { + grow(new_word_capacity); + } + } void grow(uint new_word_capacity); + public: VectorSet(); VectorSet(Arena* arena); @@ -78,7 +85,7 @@ class VectorSet : public AnyObj { // bool test_set(uint elem) { uint32_t word = elem >> word_bits; - grow(word); + maybe_grow(word); uint32_t mask = 1U << (elem & bit_mask); uint32_t data = _data[word]; _data[word] = data | mask; @@ -107,7 +114,7 @@ class VectorSet : public AnyObj { // Fast inlined set void set(uint elem) { uint32_t word = elem >> word_bits; - grow(word); + maybe_grow(word); uint32_t mask = 1U << (elem & bit_mask); _data[word] |= mask; } diff --git a/src/hotspot/share/memory/metaspace.hpp b/src/hotspot/share/memory/metaspace.hpp index fc405a389ee..7076a6a09bb 100644 --- a/src/hotspot/share/memory/metaspace.hpp +++ b/src/hotspot/share/memory/metaspace.hpp @@ -56,7 +56,6 @@ class Metaspace : public AllStatic { StandardMetaspaceType = ZeroMetaspaceType, BootMetaspaceType = StandardMetaspaceType + 1, ClassMirrorHolderMetaspaceType = BootMetaspaceType + 1, - ReflectionMetaspaceType = ClassMirrorHolderMetaspaceType + 1, MetaspaceTypeCount }; diff --git a/src/hotspot/share/memory/metaspace/metaspaceArenaGrowthPolicy.cpp b/src/hotspot/share/memory/metaspace/metaspaceArenaGrowthPolicy.cpp index 592624c25f0..0698c1509cf 100644 --- a/src/hotspot/share/memory/metaspace/metaspaceArenaGrowthPolicy.cpp +++ b/src/hotspot/share/memory/metaspace/metaspaceArenaGrowthPolicy.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2020 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -61,17 +61,6 @@ static const chunklevel_t g_sequ_anon_class[] = { // .. repeat last }; -static const chunklevel_t g_sequ_refl_non_class[] = { - chunklevel::CHUNK_LEVEL_2K, - chunklevel::CHUNK_LEVEL_1K - // .. repeat last -}; - -static const chunklevel_t g_sequ_refl_class[] = { - chunklevel::CHUNK_LEVEL_1K, - // .. repeat last -}; - // Boot class loader: give it large chunks: beyond commit granule size // (typically 64K) the costs for large chunks largely diminishes since // they are committed on the fly. @@ -95,15 +84,12 @@ const ArenaGrowthPolicy* ArenaGrowthPolicy::policy_for_space_type(Metaspace::Met DEFINE_CLASS_FOR_ARRAY(standard_class) DEFINE_CLASS_FOR_ARRAY(anon_non_class) DEFINE_CLASS_FOR_ARRAY(anon_class) - DEFINE_CLASS_FOR_ARRAY(refl_non_class) - DEFINE_CLASS_FOR_ARRAY(refl_class) DEFINE_CLASS_FOR_ARRAY(boot_non_class) DEFINE_CLASS_FOR_ARRAY(boot_class) if (is_class) { switch(space_type) { case Metaspace::StandardMetaspaceType: return &chunk_alloc_sequence_standard_class; - case Metaspace::ReflectionMetaspaceType: return &chunk_alloc_sequence_refl_class; case Metaspace::ClassMirrorHolderMetaspaceType: return &chunk_alloc_sequence_anon_class; case Metaspace::BootMetaspaceType: return &chunk_alloc_sequence_boot_class; default: ShouldNotReachHere(); @@ -111,7 +97,6 @@ const ArenaGrowthPolicy* ArenaGrowthPolicy::policy_for_space_type(Metaspace::Met } else { switch(space_type) { case Metaspace::StandardMetaspaceType: return &chunk_alloc_sequence_standard_non_class; - case Metaspace::ReflectionMetaspaceType: return &chunk_alloc_sequence_refl_non_class; case Metaspace::ClassMirrorHolderMetaspaceType: return &chunk_alloc_sequence_anon_non_class; case Metaspace::BootMetaspaceType: return &chunk_alloc_sequence_boot_non_class; default: ShouldNotReachHere(); diff --git a/src/hotspot/share/memory/metaspace/metaspaceReporter.cpp b/src/hotspot/share/memory/metaspace/metaspaceReporter.cpp index c154fd1db25..3cd9ba5ab87 100644 --- a/src/hotspot/share/memory/metaspace/metaspaceReporter.cpp +++ b/src/hotspot/share/memory/metaspace/metaspaceReporter.cpp @@ -49,7 +49,6 @@ static const char* describe_spacetype(Metaspace::MetaspaceType st) { case Metaspace::StandardMetaspaceType: s = "Standard"; break; case Metaspace::BootMetaspaceType: s = "Boot"; break; case Metaspace::ClassMirrorHolderMetaspaceType: s = "ClassMirrorHolder"; break; - case Metaspace::ReflectionMetaspaceType: s = "Reflection"; break; default: ShouldNotReachHere(); } return s; diff --git a/src/hotspot/share/nmt/memBaseline.cpp b/src/hotspot/share/nmt/memBaseline.cpp index 6f82b2de9f1..270601e9c05 100644 --- a/src/hotspot/share/nmt/memBaseline.cpp +++ b/src/hotspot/share/nmt/memBaseline.cpp @@ -141,7 +141,7 @@ void MemBaseline::baseline_summary() { MallocMemorySummary::snapshot(&_malloc_memory_snapshot); VirtualMemorySummary::snapshot(&_virtual_memory_snapshot); { - MemoryFileTracker::Instance::Locker lock; + NmtVirtualMemoryLocker ml; MemoryFileTracker::Instance::summary_snapshot(&_virtual_memory_snapshot); } diff --git a/src/hotspot/share/nmt/memReporter.cpp b/src/hotspot/share/nmt/memReporter.cpp index 6ce6206ebcc..15767da276c 100644 --- a/src/hotspot/share/nmt/memReporter.cpp +++ b/src/hotspot/share/nmt/memReporter.cpp @@ -465,7 +465,7 @@ void MemDetailReporter::report_virtual_memory_region(const ReservedMemoryRegion* void MemDetailReporter::report_memory_file_allocations() { stringStream st; { - MemoryFileTracker::Instance::Locker lock; + NmtVirtualMemoryLocker ml; MemoryFileTracker::Instance::print_all_reports_on(&st, scale()); } output()->print_raw(st.freeze()); diff --git a/src/hotspot/share/nmt/memTracker.hpp b/src/hotspot/share/nmt/memTracker.hpp index 6ba1db2e7ff..92640430e1c 100644 --- a/src/hotspot/share/nmt/memTracker.hpp +++ b/src/hotspot/share/nmt/memTracker.hpp @@ -31,7 +31,6 @@ #include "nmt/threadStackTracker.hpp" #include "nmt/virtualMemoryTracker.hpp" #include "runtime/mutexLocker.hpp" -#include "runtime/threadCritical.hpp" #include "utilities/debug.hpp" #include "utilities/nativeCallStack.hpp" @@ -125,7 +124,7 @@ class MemTracker : AllStatic { assert_post_init(); if (!enabled()) return; if (addr != nullptr) { - ThreadCritical tc; + NmtVirtualMemoryLocker ml; VirtualMemoryTracker::add_reserved_region((address)addr, size, stack, mem_tag); } } @@ -151,7 +150,7 @@ class MemTracker : AllStatic { assert_post_init(); if (!enabled()) return; if (addr != nullptr) { - ThreadCritical tc; + NmtVirtualMemoryLocker ml; VirtualMemoryTracker::add_reserved_region((address)addr, size, stack, mem_tag); VirtualMemoryTracker::add_committed_region((address)addr, size, stack); } @@ -162,7 +161,7 @@ class MemTracker : AllStatic { assert_post_init(); if (!enabled()) return; if (addr != nullptr) { - ThreadCritical tc; + NmtVirtualMemoryLocker ml; VirtualMemoryTracker::add_committed_region((address)addr, size, stack); } } @@ -170,7 +169,7 @@ class MemTracker : AllStatic { static inline MemoryFileTracker::MemoryFile* register_file(const char* descriptive_name) { assert_post_init(); if (!enabled()) return nullptr; - MemoryFileTracker::Instance::Locker lock; + NmtVirtualMemoryLocker ml; return MemoryFileTracker::Instance::make_file(descriptive_name); } @@ -178,7 +177,7 @@ class MemTracker : AllStatic { assert_post_init(); if (!enabled()) return; assert(file != nullptr, "must be"); - MemoryFileTracker::Instance::Locker lock; + NmtVirtualMemoryLocker ml; MemoryFileTracker::Instance::free_file(file); } @@ -187,7 +186,7 @@ class MemTracker : AllStatic { assert_post_init(); if (!enabled()) return; assert(file != nullptr, "must be"); - MemoryFileTracker::Instance::Locker lock; + NmtVirtualMemoryLocker ml; MemoryFileTracker::Instance::allocate_memory(file, offset, size, stack, mem_tag); } @@ -196,7 +195,7 @@ class MemTracker : AllStatic { assert_post_init(); if (!enabled()) return; assert(file != nullptr, "must be"); - MemoryFileTracker::Instance::Locker lock; + NmtVirtualMemoryLocker ml; MemoryFileTracker::Instance::free_memory(file, offset, size); } @@ -210,7 +209,7 @@ class MemTracker : AllStatic { assert_post_init(); if (!enabled()) return; if (addr != nullptr) { - ThreadCritical tc; + NmtVirtualMemoryLocker ml; VirtualMemoryTracker::split_reserved_region((address)addr, size, split, mem_tag, split_tag); } } @@ -219,7 +218,7 @@ class MemTracker : AllStatic { assert_post_init(); if (!enabled()) return; if (addr != nullptr) { - ThreadCritical tc; + NmtVirtualMemoryLocker ml; VirtualMemoryTracker::set_reserved_region_type((address)addr, mem_tag); } } diff --git a/src/hotspot/share/nmt/memoryFileTracker.cpp b/src/hotspot/share/nmt/memoryFileTracker.cpp index ede483ed337..ab4f8b6d1f3 100644 --- a/src/hotspot/share/nmt/memoryFileTracker.cpp +++ b/src/hotspot/share/nmt/memoryFileTracker.cpp @@ -29,13 +29,11 @@ #include "nmt/nmtCommon.hpp" #include "nmt/nmtNativeCallStackStorage.hpp" #include "nmt/vmatree.hpp" -#include "runtime/mutex.hpp" #include "utilities/growableArray.hpp" #include "utilities/nativeCallStack.hpp" #include "utilities/ostream.hpp" MemoryFileTracker* MemoryFileTracker::Instance::_tracker = nullptr; -PlatformMutex* MemoryFileTracker::Instance::_mutex = nullptr; MemoryFileTracker::MemoryFileTracker(bool is_detailed_mode) : _stack_storage(is_detailed_mode), _files() {} @@ -132,7 +130,6 @@ bool MemoryFileTracker::Instance::initialize(NMT_TrackingLevel tracking_level) { _tracker = static_cast(os::malloc(sizeof(MemoryFileTracker), mtNMT)); if (_tracker == nullptr) return false; new (_tracker) MemoryFileTracker(tracking_level == NMT_TrackingLevel::NMT_detail); - _mutex = new PlatformMutex(); return true; } @@ -193,11 +190,3 @@ void MemoryFileTracker::summary_snapshot(VirtualMemorySnapshot* snapshot) const void MemoryFileTracker::Instance::summary_snapshot(VirtualMemorySnapshot* snapshot) { _tracker->summary_snapshot(snapshot); } - -MemoryFileTracker::Instance::Locker::Locker() { - MemoryFileTracker::Instance::_mutex->lock(); -} - -MemoryFileTracker::Instance::Locker::~Locker() { - MemoryFileTracker::Instance::_mutex->unlock(); -} diff --git a/src/hotspot/share/nmt/memoryFileTracker.hpp b/src/hotspot/share/nmt/memoryFileTracker.hpp index 42902701a16..911f10baf98 100644 --- a/src/hotspot/share/nmt/memoryFileTracker.hpp +++ b/src/hotspot/share/nmt/memoryFileTracker.hpp @@ -30,7 +30,6 @@ #include "nmt/nmtNativeCallStackStorage.hpp" #include "nmt/virtualMemoryTracker.hpp" #include "nmt/vmatree.hpp" -#include "runtime/mutex.hpp" #include "runtime/os.inline.hpp" #include "utilities/growableArray.hpp" #include "utilities/nativeCallStack.hpp" @@ -81,14 +80,8 @@ class MemoryFileTracker { class Instance : public AllStatic { static MemoryFileTracker* _tracker; - static PlatformMutex* _mutex; public: - class Locker : public StackObj { - public: - Locker(); - ~Locker(); - }; static bool initialize(NMT_TrackingLevel tracking_level); diff --git a/src/hotspot/share/nmt/nmtCommon.hpp b/src/hotspot/share/nmt/nmtCommon.hpp index 3f72960f21f..4422d340634 100644 --- a/src/hotspot/share/nmt/nmtCommon.hpp +++ b/src/hotspot/share/nmt/nmtCommon.hpp @@ -29,6 +29,7 @@ #include "memory/allStatic.hpp" #include "nmt/memTag.hpp" +#include "runtime/mutexLocker.hpp" #include "utilities/align.hpp" #include "utilities/globalDefinitions.hpp" @@ -137,5 +138,13 @@ class NMTUtil : AllStatic { static S _strings[mt_number_of_tags]; }; +// Same as MutexLocker but can be used during VM init. +// Performs no action if given a null mutex or with detached threads. +class NmtVirtualMemoryLocker: public ConditionalMutexLocker { +public: + NmtVirtualMemoryLocker() : + ConditionalMutexLocker(NmtVirtualMemory_lock, Thread::current_or_null_safe() != nullptr, Mutex::_no_safepoint_check_flag) { + } +}; #endif // SHARE_NMT_NMTCOMMON_HPP diff --git a/src/hotspot/share/nmt/threadStackTracker.cpp b/src/hotspot/share/nmt/threadStackTracker.cpp index 6f112fa8fc5..42af67d6464 100644 --- a/src/hotspot/share/nmt/threadStackTracker.cpp +++ b/src/hotspot/share/nmt/threadStackTracker.cpp @@ -29,7 +29,6 @@ #include "nmt/threadStackTracker.hpp" #include "nmt/virtualMemoryTracker.hpp" #include "runtime/os.hpp" -#include "runtime/threadCritical.hpp" #include "utilities/align.hpp" #include "utilities/debug.hpp" #include "utilities/globalDefinitions.hpp" @@ -53,7 +52,7 @@ void ThreadStackTracker::new_thread_stack(void* base, size_t size, const NativeC assert(base != nullptr, "Should have been filtered"); align_thread_stack_boundaries_inward(base, size); - ThreadCritical tc; + NmtVirtualMemoryLocker ml; VirtualMemoryTracker::add_reserved_region((address)base, size, stack, mtThreadStack); _thread_count++; } @@ -63,7 +62,7 @@ void ThreadStackTracker::delete_thread_stack(void* base, size_t size) { assert(base != nullptr, "Should have been filtered"); align_thread_stack_boundaries_inward(base, size); - ThreadCritical tc; + NmtVirtualMemoryLocker ml; VirtualMemoryTracker::remove_released_region((address)base, size); _thread_count--; } diff --git a/src/hotspot/share/nmt/virtualMemoryTracker.cpp b/src/hotspot/share/nmt/virtualMemoryTracker.cpp index d298381f103..8b0f2f4d7a4 100644 --- a/src/hotspot/share/nmt/virtualMemoryTracker.cpp +++ b/src/hotspot/share/nmt/virtualMemoryTracker.cpp @@ -30,7 +30,6 @@ #include "nmt/threadStackTracker.hpp" #include "nmt/virtualMemoryTracker.hpp" #include "runtime/os.hpp" -#include "runtime/threadCritical.hpp" #include "utilities/ostream.hpp" VirtualMemorySnapshot VirtualMemorySummary::_snapshot; @@ -621,6 +620,7 @@ class SnapshotThreadStackWalker : public VirtualMemoryWalker { SnapshotThreadStackWalker() {} bool do_allocation_site(const ReservedMemoryRegion* rgn) { + assert_lock_strong(NmtVirtualMemory_lock); if (rgn->mem_tag() == mtThreadStack) { address stack_bottom = rgn->thread_stack_uncommitted_bottom(); address committed_start; @@ -661,7 +661,7 @@ void VirtualMemoryTracker::snapshot_thread_stacks() { bool VirtualMemoryTracker::walk_virtual_memory(VirtualMemoryWalker* walker) { assert(_reserved_regions != nullptr, "Sanity check"); - ThreadCritical tc; + NmtVirtualMemoryLocker ml; // Check that the _reserved_regions haven't been deleted. if (_reserved_regions != nullptr) { LinkedListNode* head = _reserved_regions->head(); diff --git a/src/hotspot/share/oops/constMethodFlags.hpp b/src/hotspot/share/oops/constMethodFlags.hpp index 236f25ea746..031ebe44a96 100644 --- a/src/hotspot/share/oops/constMethodFlags.hpp +++ b/src/hotspot/share/oops/constMethodFlags.hpp @@ -60,6 +60,7 @@ class ConstMethodFlags { flag(jvmti_mount_transition , 1 << 18) \ flag(deprecated , 1 << 19) \ flag(deprecated_for_removal , 1 << 20) \ + flag(jvmti_hide_events , 1 << 21) \ /* end of list */ #define CM_FLAGS_ENUM_NAME(name, value) _misc_##name = value, diff --git a/src/hotspot/share/oops/method.hpp b/src/hotspot/share/oops/method.hpp index 6ffaebcdfda..d42089d3a5c 100644 --- a/src/hotspot/share/oops/method.hpp +++ b/src/hotspot/share/oops/method.hpp @@ -746,6 +746,9 @@ class Method : public Metadata { bool changes_current_thread() const { return constMethod()->changes_current_thread(); } void set_changes_current_thread() { constMethod()->set_changes_current_thread(); } + bool jvmti_hide_events() const { return constMethod()->jvmti_hide_events(); } + void set_jvmti_hide_events() { constMethod()->set_jvmti_hide_events(); } + bool jvmti_mount_transition() const { return constMethod()->jvmti_mount_transition(); } void set_jvmti_mount_transition() { constMethod()->set_jvmti_mount_transition(); } diff --git a/src/hotspot/share/oops/oop.cpp b/src/hotspot/share/oops/oop.cpp index 38dee491a10..acb47d4c7cf 100644 --- a/src/hotspot/share/oops/oop.cpp +++ b/src/hotspot/share/oops/oop.cpp @@ -178,7 +178,7 @@ void* oopDesc::load_oop_raw(oop obj, int offset) { oop oopDesc::obj_field_acquire(int offset) const { return HeapAccess::oop_load_at(as_oop(), offset); } -void oopDesc::obj_field_put_raw(int offset, oop value) { assert(!(UseZGC && ZGenerational), "Generational ZGC must use store barriers"); +void oopDesc::obj_field_put_raw(int offset, oop value) { assert(!UseZGC, "ZGC must use store barriers"); RawAccess<>::oop_store_at(as_oop(), offset, value); } void oopDesc::release_obj_field_put(int offset, oop value) { HeapAccess::oop_store_at(as_oop(), offset, value); } void oopDesc::obj_field_put_volatile(int offset, oop value) { HeapAccess::oop_store_at(as_oop(), offset, value); } diff --git a/src/hotspot/share/oops/stackChunkOop.inline.hpp b/src/hotspot/share/oops/stackChunkOop.inline.hpp index a54b8159e7e..7b955d551d7 100644 --- a/src/hotspot/share/oops/stackChunkOop.inline.hpp +++ b/src/hotspot/share/oops/stackChunkOop.inline.hpp @@ -88,20 +88,7 @@ inline void stackChunkOopDesc::set_max_thawing_size(int value) { jdk_internal_vm_StackChunk::set_maxThawingSize(this, (jint)value); } -inline oop stackChunkOopDesc::cont() const { - if (UseZGC && !ZGenerational) { - assert(!UseCompressedOops, "Non-generational ZGC does not support compressed oops"); - // The state of the cont oop is used by XCollectedHeap::requires_barriers, - // to determine the age of the stackChunkOopDesc. For that to work, it is - // only the GC that is allowed to perform a load barrier on the oop. - // This function is used by non-GC code and therfore create a stack-local - // copy on the oop and perform the load barrier on that copy instead. - oop obj = jdk_internal_vm_StackChunk::cont_raw(as_oop()); - obj = (oop)NativeAccess<>::oop_load(&obj); - return obj; - } - return jdk_internal_vm_StackChunk::cont(as_oop()); -} +inline oop stackChunkOopDesc::cont() const { return jdk_internal_vm_StackChunk::cont(as_oop()); } inline void stackChunkOopDesc::set_cont(oop value) { jdk_internal_vm_StackChunk::set_cont(this, value); } template inline void stackChunkOopDesc::set_cont_raw(oop value) { jdk_internal_vm_StackChunk::set_cont_raw

    (this, value); } diff --git a/src/hotspot/share/opto/c2compiler.cpp b/src/hotspot/share/opto/c2compiler.cpp index fa0abf2deb1..138fd38bfa4 100644 --- a/src/hotspot/share/opto/c2compiler.cpp +++ b/src/hotspot/share/opto/c2compiler.cpp @@ -841,7 +841,6 @@ bool C2Compiler::is_intrinsic_supported(vmIntrinsics::ID id) { case vmIntrinsics::_notifyJvmtiVThreadEnd: case vmIntrinsics::_notifyJvmtiVThreadMount: case vmIntrinsics::_notifyJvmtiVThreadUnmount: - case vmIntrinsics::_notifyJvmtiVThreadHideFrames: case vmIntrinsics::_notifyJvmtiVThreadDisableSuspend: #endif break; diff --git a/src/hotspot/share/opto/classes.hpp b/src/hotspot/share/opto/classes.hpp index 7fd488f9d34..60ee3e01137 100644 --- a/src/hotspot/share/opto/classes.hpp +++ b/src/hotspot/share/opto/classes.hpp @@ -330,6 +330,8 @@ shmacro(ShenandoahLoadReferenceBarrier) macro(SCMemProj) macro(CopySignD) macro(CopySignF) +macro(SaturatingAddV) +macro(SaturatingSubV) macro(SignumD) macro(SignumF) macro(SignumVF) @@ -436,6 +438,8 @@ macro(XorV) macro(XorReductionV) macro(MinV) macro(MaxV) +macro(UMinV) +macro(UMaxV) macro(MinReductionV) macro(MaxReductionV) macro(CompressV) diff --git a/src/hotspot/share/opto/domgraph.cpp b/src/hotspot/share/opto/domgraph.cpp index 84f83ef131b..6bed1b1a2bd 100644 --- a/src/hotspot/share/opto/domgraph.cpp +++ b/src/hotspot/share/opto/domgraph.cpp @@ -410,10 +410,9 @@ void PhaseIdealLoop::Dominators() { // Setup mappings from my Graph to Tarjan's stuff and back // Note: Tarjan uses 1-based arrays NTarjan *ntarjan = NEW_RESOURCE_ARRAY(NTarjan,C->unique()+1); - // Initialize _control field for fast reference - int i; - for( i= C->unique()-1; i>=0; i-- ) - ntarjan[i]._control = nullptr; + // Initialize all fields at once for safety and extra performance. + // Among other things, this initializes _control field for fast reference. + memset(ntarjan, 0, (C->unique() + 1)*sizeof(NTarjan)); // Store the DFS order for the main loop const uint fill_value = max_juint; @@ -429,6 +428,7 @@ void PhaseIdealLoop::Dominators() { ntarjan[0]._size = ntarjan[0]._semi = 0; ntarjan[0]._label = &ntarjan[0]; + int i; for( i = dfsnum-1; i>1; i-- ) { // For all nodes in reverse DFS order NTarjan *w = &ntarjan[i]; // Get Node from DFS assert(w->_control != nullptr,"bad DFS walk"); diff --git a/src/hotspot/share/opto/idealGraphPrinter.cpp b/src/hotspot/share/opto/idealGraphPrinter.cpp index 4b813252ff9..40aec858205 100644 --- a/src/hotspot/share/opto/idealGraphPrinter.cpp +++ b/src/hotspot/share/opto/idealGraphPrinter.cpp @@ -509,6 +509,10 @@ void IdealGraphPrinter::visit_node(Node *n, bool edges, VectorSet* temp_set) { print_prop("idealOpcode", (const char *)NodeClassNames[node->as_Mach()->ideal_Opcode()]); } + if (node->is_CountedLoop()) { + print_loop_kind(node->as_CountedLoop()); + } + print_field(node); buffer[0] = 0; @@ -639,6 +643,20 @@ void IdealGraphPrinter::visit_node(Node *n, bool edges, VectorSet* temp_set) { } } +void IdealGraphPrinter::print_loop_kind(const CountedLoopNode* counted_loop) { + const char* loop_kind = nullptr; + if (counted_loop->is_pre_loop()) { + loop_kind = "pre"; + } else if (counted_loop->is_main_loop()) { + loop_kind = "main"; + } else if (counted_loop->is_post_loop()) { + loop_kind = "post"; + } + if (loop_kind != nullptr) { + print_prop("loop_kind", loop_kind); + } +} + void IdealGraphPrinter::print_bci_and_line_number(JVMState* caller) { if (caller != nullptr) { ResourceMark rm; diff --git a/src/hotspot/share/opto/idealGraphPrinter.hpp b/src/hotspot/share/opto/idealGraphPrinter.hpp index 65d7f4b5473..a06f2396f63 100644 --- a/src/hotspot/share/opto/idealGraphPrinter.hpp +++ b/src/hotspot/share/opto/idealGraphPrinter.hpp @@ -34,6 +34,7 @@ #ifndef PRODUCT class Compile; +class CountedLoopNode; class PhaseIFG; class PhaseChaitin; class Matcher; @@ -124,6 +125,8 @@ class IdealGraphPrinter : public CHeapObj { IdealGraphPrinter(); ~IdealGraphPrinter(); + void print_loop_kind(const CountedLoopNode* counted_loop); + public: IdealGraphPrinter(Compile* compile, const char* file_name = nullptr, bool append = false); static void clean_up(); diff --git a/src/hotspot/share/opto/library_call.cpp b/src/hotspot/share/opto/library_call.cpp index c7c9da18e54..523b1efd0c2 100644 --- a/src/hotspot/share/opto/library_call.cpp +++ b/src/hotspot/share/opto/library_call.cpp @@ -495,7 +495,6 @@ bool LibraryCallKit::try_to_inline(int predicate) { "notifyJvmtiMount", false, false); case vmIntrinsics::_notifyJvmtiVThreadUnmount: return inline_native_notify_jvmti_funcs(CAST_FROM_FN_PTR(address, OptoRuntime::notify_jvmti_vthread_unmount()), "notifyJvmtiUnmount", false, false); - case vmIntrinsics::_notifyJvmtiVThreadHideFrames: return inline_native_notify_jvmti_hide(); case vmIntrinsics::_notifyJvmtiVThreadDisableSuspend: return inline_native_notify_jvmti_sync(); #endif @@ -2975,29 +2974,6 @@ bool LibraryCallKit::inline_native_notify_jvmti_funcs(address funcAddr, const ch return true; } -// Always update the temporary VTMS transition bit. -bool LibraryCallKit::inline_native_notify_jvmti_hide() { - if (!DoJVMTIVirtualThreadTransitions) { - return true; - } - IdealKit ideal(this); - - { - // unconditionally update the temporary VTMS transition bit in current JavaThread - Node* thread = ideal.thread(); - Node* hide = _gvn.transform(argument(0)); // hide argument for temporary VTMS transition notification - Node* addr = basic_plus_adr(thread, in_bytes(JavaThread::is_in_tmp_VTMS_transition_offset())); - const TypePtr *addr_type = _gvn.type(addr)->isa_ptr(); - - sync_kit(ideal); - access_store_at(nullptr, addr, addr_type, hide, _gvn.type(hide), T_BOOLEAN, IN_NATIVE | MO_UNORDERED); - ideal.sync_kit(this); - } - final_sync(ideal); - - return true; -} - // Always update the is_disable_suspend bit. bool LibraryCallKit::inline_native_notify_jvmti_sync() { if (!DoJVMTIVirtualThreadTransitions) { @@ -7398,11 +7374,11 @@ bool LibraryCallKit::inline_counterMode_AESCrypt(vmIntrinsics::ID id) { //------------------------------get_key_start_from_aescrypt_object----------------------- Node * LibraryCallKit::get_key_start_from_aescrypt_object(Node *aescrypt_object) { -#if defined(PPC64) || defined(S390) +#if defined(PPC64) || defined(S390) || defined(RISCV64) // MixColumns for decryption can be reduced by preprocessing MixColumns with round keys. // Intel's extension is based on this optimization and AESCrypt generates round keys by preprocessing MixColumns. // However, ppc64 vncipher processes MixColumns and requires the same round keys with encryption. - // The ppc64 stubs of encryption and decryption use the same round keys (sessionK[0]). + // The ppc64 and riscv64 stubs of encryption and decryption use the same round keys (sessionK[0]). Node* objSessionK = load_field_from_object(aescrypt_object, "sessionK", "[[I"); assert (objSessionK != nullptr, "wrong version of com.sun.crypto.provider.AESCrypt"); if (objSessionK == nullptr) { diff --git a/src/hotspot/share/opto/loopTransform.cpp b/src/hotspot/share/opto/loopTransform.cpp index 322183ec3a0..f5a7ffcf92a 100644 --- a/src/hotspot/share/opto/loopTransform.cpp +++ b/src/hotspot/share/opto/loopTransform.cpp @@ -762,7 +762,7 @@ void PhaseIdealLoop::do_peeling(IdealLoopTree *loop, Node_List &old_new) { // Step 1: Clone the loop body. The clone becomes the peeled iteration. // The pre-loop illegally has 2 control users (old & new loops). - const uint idx_before_clone = Compile::current()->unique(); + const uint first_node_index_in_cloned_loop_body = Compile::current()->unique(); LoopNode* outer_loop_head = head->skip_strip_mined(); clone_loop(loop, old_new, dom_depth(outer_loop_head), ControlAroundStripMined); @@ -815,19 +815,8 @@ void PhaseIdealLoop::do_peeling(IdealLoopTree *loop, Node_List &old_new) { // Step 5: Assertion Predicates initialization if (counted_loop && UseLoopPredicate) { - CountedLoopNode *cl_head = head->as_CountedLoop(); - Node* init = cl_head->init_trip(); - Node* stride = cl_head->stride(); - IdealLoopTree* outer_loop = get_loop(outer_loop_head); - const Predicates predicates(new_head->in(LoopNode::EntryControl)); - initialize_assertion_predicates_for_peeled_loop(predicates.loop_predicate_block(), - outer_loop_head, dd_outer_loop_head, - init, stride, outer_loop, - idx_before_clone, old_new); - initialize_assertion_predicates_for_peeled_loop(predicates.profiled_loop_predicate_block(), - outer_loop_head, dd_outer_loop_head, - init, stride, outer_loop, - idx_before_clone, old_new); + initialize_assertion_predicates_for_peeled_loop(new_head->as_CountedLoop(), head->as_CountedLoop(), + first_node_index_in_cloned_loop_body, old_new); } // Now force out all loop-invariant dominating tests. The optimizer @@ -1434,7 +1423,6 @@ bool PhaseIdealLoop::assertion_predicate_has_loop_opaque_node(IfNode* iff) { assert(stride == 0 || init != 0, "init should be there every time stride is"); return init != 0; } -#endif // ASSERT void PhaseIdealLoop::count_opaque_loop_nodes(Node* n, uint& init, uint& stride) { init = 0; @@ -1460,6 +1448,7 @@ void PhaseIdealLoop::count_opaque_loop_nodes(Node* n, uint& init, uint& stride) } } } +#endif // ASSERT // Create an Initialized Assertion Predicate from the template_assertion_predicate IfTrueNode* PhaseIdealLoop::create_initialized_assertion_predicate(IfNode* template_assertion_predicate, Node* new_init, @@ -1978,55 +1967,32 @@ void PhaseIdealLoop::copy_assertion_predicates_to_post_loop(LoopNode* main_loop_ } } -void PhaseIdealLoop::initialize_assertion_predicates_for_peeled_loop(const PredicateBlock* predicate_block, - LoopNode* outer_loop_head, - const int dd_outer_loop_head, Node* init, - Node* stride, IdealLoopTree* outer_loop, - const uint idx_before_clone, - const Node_List &old_new) { - if (!predicate_block->has_parse_predicate()) { - return; - } - Node* input_proj = outer_loop_head->in(LoopNode::EntryControl); - const Node* parse_predicate_uncommon_trap = predicate_block->parse_predicate()->uncommon_trap(); - Node* next_regular_predicate_proj = predicate_block->skip_parse_predicate(); - while (next_regular_predicate_proj->is_IfProj()) { - IfNode* iff = next_regular_predicate_proj->in(0)->as_If(); - ProjNode* uncommon_proj = iff->proj_out(1 - next_regular_predicate_proj->as_Proj()->_con); - if (uncommon_proj->unique_ctrl_out() != parse_predicate_uncommon_trap) { - // Does not belong to this Predicate Block anymore. - break; - } - Node* bol = iff->in(1); - assert(!bol->is_OpaqueInitializedAssertionPredicate(), "should not find an Initialized Assertion Predicate"); - if (bol->is_OpaqueTemplateAssertionPredicate()) { - // Initialize from Template Assertion Predicate. - input_proj = create_initialized_assertion_predicate(iff, init, stride, input_proj); - - // Rewire any control inputs from the old Assertion Predicates above the peeled iteration down to the initialized - // Assertion Predicates above the peeled loop. - for (DUIterator i = next_regular_predicate_proj->outs(); next_regular_predicate_proj->has_out(i); i++) { - Node* dependent = next_regular_predicate_proj->out(i); - Node* new_node = old_new[dependent->_idx]; - - if (!dependent->is_CFG() && - dependent->_idx < idx_before_clone && // old node - new_node != nullptr && // cloned - new_node->_idx >= idx_before_clone) { // for peeling - // The old nodes from the peeled loop still point to the predicate above the peeled loop. - // We need to rewire the dependencies to the newly Initialized Assertion Predicates. - _igvn.replace_input_of(dependent, 0, input_proj); - --i; // correct for just deleted predicate->out(i) - } - } - } - next_regular_predicate_proj = iff->in(0); - } - - _igvn.replace_input_of(outer_loop_head, LoopNode::EntryControl, input_proj); - set_idom(outer_loop_head, input_proj, dd_outer_loop_head); +void PhaseIdealLoop::initialize_assertion_predicates_for_peeled_loop(CountedLoopNode* peeled_loop_head, + CountedLoopNode* remaining_loop_head, + const uint first_node_index_in_cloned_loop_body, + const Node_List& old_new) { + const NodeInOriginalLoopBody node_in_original_loop_body(first_node_index_in_cloned_loop_body, old_new); + create_assertion_predicates_at_loop(peeled_loop_head, remaining_loop_head, node_in_original_loop_body); } +void PhaseIdealLoop::create_assertion_predicates_at_loop(CountedLoopNode* source_loop_head, + CountedLoopNode* target_loop_head, + const NodeInLoopBody& _node_in_loop_body) { + Node* init = target_loop_head->init_trip(); + Node* stride = target_loop_head->stride(); + LoopNode* target_outer_loop_head = target_loop_head->skip_strip_mined(); + Node* target_loop_entry = target_outer_loop_head->in(LoopNode::EntryControl); + CreateAssertionPredicatesVisitor create_assertion_predicates_visitor(init, stride, target_loop_entry, this, + _node_in_loop_body); + Node* source_loop_entry = source_loop_head->skip_strip_mined()->in(LoopNode::EntryControl); + PredicateIterator predicate_iterator(source_loop_entry); + predicate_iterator.for_each(create_assertion_predicates_visitor); + if (create_assertion_predicates_visitor.has_created_predicates()) { + IfTrueNode* last_created_predicate_success_proj = create_assertion_predicates_visitor.last_created_success_proj(); + _igvn.replace_input_of(target_outer_loop_head, LoopNode::EntryControl, last_created_predicate_success_proj); + set_idom(target_outer_loop_head, last_created_predicate_success_proj, dom_depth(target_outer_loop_head)); + } +} //------------------------------do_unroll-------------------------------------- // Unroll the loop body one step - make each trip do 2 iterations. void PhaseIdealLoop::do_unroll(IdealLoopTree *loop, Node_List &old_new, bool adjust_min_trip) { diff --git a/src/hotspot/share/opto/loopnode.cpp b/src/hotspot/share/opto/loopnode.cpp index 518b93bbf50..e2db179676d 100644 --- a/src/hotspot/share/opto/loopnode.cpp +++ b/src/hotspot/share/opto/loopnode.cpp @@ -4488,7 +4488,9 @@ void PhaseIdealLoop::eliminate_useless_template_assertion_predicates(Unique_Node OpaqueTemplateAssertionPredicateNode* opaque_node = C->template_assertion_predicate_opaq_node(i - 1)->as_OpaqueTemplateAssertionPredicate(); if (!useful_predicates.member(opaque_node)) { // not in the useful list - _igvn.replace_node(opaque_node, _igvn.intcon(1)); + ConINode* one = _igvn.intcon(1); + set_ctrl(one, C->root()); + _igvn.replace_node(opaque_node, one); } } } diff --git a/src/hotspot/share/opto/loopnode.hpp b/src/hotspot/share/opto/loopnode.hpp index a2094045bfa..fc0f1b4d53c 100644 --- a/src/hotspot/share/opto/loopnode.hpp +++ b/src/hotspot/share/opto/loopnode.hpp @@ -952,18 +952,22 @@ class PhaseIdealLoop : public PhaseTransform { Node* zero_trip_guard_proj_post, const Node_List& old_new); Node* clone_template_assertion_predicate(IfNode* iff, Node* new_init, Node* predicate, Node* uncommon_proj, Node* control, IdealLoopTree* outer_loop, Node* new_control); + public: IfTrueNode* create_initialized_assertion_predicate(IfNode* template_assertion_predicate, Node* new_init, Node* new_stride, Node* control); - static void count_opaque_loop_nodes(Node* n, uint& init, uint& stride); + private: + DEBUG_ONLY(static void count_opaque_loop_nodes(Node* n, uint& init, uint& stride);) DEBUG_ONLY(static bool assertion_predicate_has_loop_opaque_node(IfNode* iff);) static void get_assertion_predicates(Node* predicate, Unique_Node_List& list, bool get_opaque = false); void update_main_loop_assertion_predicates(Node* ctrl, CountedLoopNode* loop_head, Node* init, int stride_con); void copy_assertion_predicates_to_post_loop(LoopNode* main_loop_head, CountedLoopNode* post_loop_head, Node* stride); - void initialize_assertion_predicates_for_peeled_loop(const PredicateBlock* predicate_block, LoopNode* outer_loop_head, - int dd_outer_loop_head, Node* init, Node* stride, - IdealLoopTree* outer_loop, uint idx_before_clone, + void initialize_assertion_predicates_for_peeled_loop(CountedLoopNode* peeled_loop_head, + CountedLoopNode* remaining_loop_head, + uint first_node_index_in_cloned_loop_body, const Node_List& old_new); + void create_assertion_predicates_at_loop(CountedLoopNode* source_loop_head, CountedLoopNode* target_loop_head, + const NodeInLoopBody& _node_in_loop_body); void insert_loop_limit_check_predicate(ParsePredicateSuccessProj* loop_limit_check_parse_proj, Node* cmp_limit, Node* bol); void log_loop_tree(); diff --git a/src/hotspot/share/opto/node.cpp b/src/hotspot/share/opto/node.cpp index 8dbf09f7d4f..3f82c472163 100644 --- a/src/hotspot/share/opto/node.cpp +++ b/src/hotspot/share/opto/node.cpp @@ -2770,9 +2770,7 @@ const RegMask &Node::in_RegMask(uint) const { void Node_Array::grow(uint i) { _nesting.check(_a); // Check if a potential reallocation in the arena is safe - if (i < _max) { - return; // No need to grow - } + assert(i >= _max, "Should have been checked before, use maybe_grow?"); assert(_max > 0, "invariant"); uint old = _max; _max = next_power_of_2(i); diff --git a/src/hotspot/share/opto/node.hpp b/src/hotspot/share/opto/node.hpp index 0afb3c9166b..db8b00c0bda 100644 --- a/src/hotspot/share/opto/node.hpp +++ b/src/hotspot/share/opto/node.hpp @@ -169,6 +169,7 @@ class RootNode; class SafePointNode; class SafePointScalarObjectNode; class SafePointScalarMergeNode; +class SaturatingVectorNode; class StartNode; class State; class StoreNode; @@ -741,6 +742,7 @@ class Node { DEFINE_CLASS_ID(CompressM, Vector, 6) DEFINE_CLASS_ID(Reduction, Vector, 7) DEFINE_CLASS_ID(NegV, Vector, 8) + DEFINE_CLASS_ID(SaturatingVector, Vector, 9) DEFINE_CLASS_ID(Con, Type, 8) DEFINE_CLASS_ID(ConI, Con, 0) DEFINE_CLASS_ID(SafePointScalarMerge, Type, 9) @@ -1010,6 +1012,7 @@ class Node { DEFINE_CLASS_QUERY(StoreVectorScatter) DEFINE_CLASS_QUERY(StoreVectorMasked) DEFINE_CLASS_QUERY(StoreVectorScatterMasked) + DEFINE_CLASS_QUERY(SaturatingVector) DEFINE_CLASS_QUERY(ShiftV) DEFINE_CLASS_QUERY(Unlock) @@ -1610,7 +1613,14 @@ class Node_Array : public AnyObj { Node** _nodes; ReallocMark _nesting; // Safety checks for arena reallocation - void grow( uint i ); // Grow array node to fit + // Grow array to required capacity + void maybe_grow(uint i) { + if (i >= _max) { + grow(i); + } + } + void grow(uint i); + public: Node_Array(Arena* a, uint max = OptoNodeListSize) : _a(a), _max(max) { _nodes = NEW_ARENA_ARRAY(a, Node*, max); @@ -1628,7 +1638,7 @@ class Node_Array : public AnyObj { Node* at(uint i) const { assert(i<_max,"oob"); return _nodes[i]; } Node** adr() { return _nodes; } // Extend the mapping: index i maps to Node *n. - void map( uint i, Node *n ) { grow(i); _nodes[i] = n; } + void map( uint i, Node *n ) { maybe_grow(i); _nodes[i] = n; } void insert( uint i, Node *n ); void remove( uint i ); // Remove, preserving order // Clear all entries in _nodes to null but keep storage diff --git a/src/hotspot/share/opto/output.cpp b/src/hotspot/share/opto/output.cpp index 2865cf67429..ea1175bce14 100644 --- a/src/hotspot/share/opto/output.cpp +++ b/src/hotspot/share/opto/output.cpp @@ -792,7 +792,14 @@ void PhaseOutput::FillLocArray( int idx, MachSafePointNode* sfpt, Node *local, for (uint i = 1; i < smerge->req(); i++) { Node* obj_node = smerge->in(i); - (void)FillLocArray(mv->possible_objects()->length(), sfpt, obj_node, mv->possible_objects(), objs); + int idx = mv->possible_objects()->length(); + (void)FillLocArray(idx, sfpt, obj_node, mv->possible_objects(), objs); + + // By default ObjectValues that are in 'possible_objects' are not root objects. + // They will be marked as root later if they are directly referenced in a JVMS. + assert(mv->possible_objects()->length() > idx, "Didn't add entry to possible_objects?!"); + assert(mv->possible_objects()->at(idx)->is_object(), "Entries in possible_objects should be ObjectValue."); + mv->possible_objects()->at(idx)->as_ObjectValue()->set_root(false); } } array->append(mv); @@ -1127,7 +1134,14 @@ void PhaseOutput::Process_OopMap_Node(MachNode *mach, int current_offset) { for (uint i = 1; i < smerge->req(); i++) { Node* obj_node = smerge->in(i); - FillLocArray(mv->possible_objects()->length(), sfn, obj_node, mv->possible_objects(), objs); + int idx = mv->possible_objects()->length(); + (void)FillLocArray(idx, sfn, obj_node, mv->possible_objects(), objs); + + // By default ObjectValues that are in 'possible_objects' are not root objects. + // They will be marked as root later if they are directly referenced in a JVMS. + assert(mv->possible_objects()->length() > idx, "Didn't add entry to possible_objects?!"); + assert(mv->possible_objects()->at(idx)->is_object(), "Entries in possible_objects should be ObjectValue."); + mv->possible_objects()->at(idx)->as_ObjectValue()->set_root(false); } } scval = mv; @@ -1158,11 +1172,17 @@ void PhaseOutput::Process_OopMap_Node(MachNode *mach, int current_offset) { for (int j = 0; j< merge->possible_objects()->length(); j++) { ObjectValue* ov = merge->possible_objects()->at(j)->as_ObjectValue(); - bool is_root = locarray->contains(ov) || - exparray->contains(ov) || - contains_as_owner(monarray, ov) || - contains_as_scalarized_obj(jvms, sfn, objs, ov); - ov->set_root(is_root); + if (ov->is_root()) { + // Already flagged as 'root' by something else. We shouldn't change it + // to non-root in a younger JVMS because it may need to be alive in + // a younger JVMS. + } else { + bool is_root = locarray->contains(ov) || + exparray->contains(ov) || + contains_as_owner(monarray, ov) || + contains_as_scalarized_obj(jvms, sfn, objs, ov); + ov->set_root(is_root); + } } } } diff --git a/src/hotspot/share/opto/predicates.cpp b/src/hotspot/share/opto/predicates.cpp index fd1aa1a9cd1..54a17376f18 100644 --- a/src/hotspot/share/opto/predicates.cpp +++ b/src/hotspot/share/opto/predicates.cpp @@ -138,6 +138,21 @@ bool RuntimePredicate::is_predicate(Node* node, Deoptimization::DeoptReason deop return RegularPredicateWithUCT::is_predicate(node, deopt_reason); } +// Rewire any non-CFG nodes dependent on this Template Assertion Predicate (i.e. with a control input to this +// Template Assertion Predicate) to the 'target_predicate' based on the 'data_in_loop_body' check. +void TemplateAssertionPredicate::rewire_loop_data_dependencies(IfTrueNode* target_predicate, + const NodeInLoopBody& data_in_loop_body, + PhaseIdealLoop* phase) const { + for (DUIterator i = _success_proj->outs(); _success_proj->has_out(i); i++) { + Node* output = _success_proj->out(i); + if (!output->is_CFG() && data_in_loop_body.check(output)) { + phase->igvn().replace_input_of(output, 0, target_predicate); + --i; // account for the just deleted output + } + } +} + + // Template Assertion Predicates always have the dedicated OpaqueTemplateAssertionPredicate to identify them. bool TemplateAssertionPredicate::is_predicate(Node* node) { if (!may_be_assertion_predicate_if(node)) { @@ -712,3 +727,25 @@ void Predicates::dump_for_loop(LoopNode* loop_node) { dump_at(loop_node->skip_strip_mined()->in(LoopNode::EntryControl)); } #endif // NOT PRODUCT + +// Keep track of whether we are in the correct Predicate Block where Template Assertion Predicates can be found. +// The PredicateIterator will always start at the loop entry and first visits the Loop Limit Check Predicate Block. +void CreateAssertionPredicatesVisitor::visit(const ParsePredicate& parse_predicate) { + Deoptimization::DeoptReason deopt_reason = parse_predicate.head()->deopt_reason(); + if (deopt_reason == Deoptimization::Reason_predicate || + deopt_reason == Deoptimization::Reason_profile_predicate) { + _has_hoisted_check_parse_predicates = true; + } +} + +void CreateAssertionPredicatesVisitor::visit(const TemplateAssertionPredicate& template_assertion_predicate) { + if (!_has_hoisted_check_parse_predicates) { + // Only process if we are in the correct Predicate Block. + return; + } + IfNode* template_head = template_assertion_predicate.head(); + IfTrueNode* initialized_predicate = _phase->create_initialized_assertion_predicate(template_head, _init, _stride, + _new_control); + template_assertion_predicate.rewire_loop_data_dependencies(initialized_predicate, _node_in_loop_body, _phase); + _new_control = initialized_predicate; +} diff --git a/src/hotspot/share/opto/predicates.hpp b/src/hotspot/share/opto/predicates.hpp index ced401a5f77..5eb0cfc9b35 100644 --- a/src/hotspot/share/opto/predicates.hpp +++ b/src/hotspot/share/opto/predicates.hpp @@ -248,6 +248,12 @@ class PredicateVisitor : StackObj { } }; +// Interface to check whether a node is in a loop body or not. +class NodeInLoopBody : public StackObj { + public: + virtual bool check(Node* node) const = 0; +}; + // Class to represent Assertion Predicates with a HaltNode instead of an UCT (i.e. either an Initialized Assertion // Predicate or a Template Assertion Predicate created after the initial one at Loop Predication). class AssertionPredicatesWithHalt : public StackObj { @@ -393,6 +399,8 @@ class TemplateAssertionPredicate : public Predicate { return _success_proj; } + void rewire_loop_data_dependencies(IfTrueNode* target_predicate, const NodeInLoopBody& data_in_loop_body, + PhaseIdealLoop* phase) const; static bool is_predicate(Node* node); }; @@ -910,4 +918,70 @@ class Predicates : public StackObj { #endif // NOT PRODUCT }; +// This class checks whether a node is in the original loop body and not the cloned one. +class NodeInOriginalLoopBody : public NodeInLoopBody { + const uint _first_node_index_in_cloned_loop_body; + const Node_List& _old_new; + + public: + NodeInOriginalLoopBody(const uint first_node_index_in_cloned_loop_body, const Node_List& old_new) + : _first_node_index_in_cloned_loop_body(first_node_index_in_cloned_loop_body), + _old_new(old_new) {} + NONCOPYABLE(NodeInOriginalLoopBody); + + // Check if 'node' is not a cloned node (i.e. "< _first_node_index_in_cloned_loop_body") and if we've created a + // clone from 'node' (i.e. _old_new entry is non-null). Then we know that 'node' belongs to the original loop body. + bool check(Node* node) const override { + if (node->_idx < _first_node_index_in_cloned_loop_body) { + Node* cloned_node = _old_new[node->_idx]; + return cloned_node != nullptr && cloned_node->_idx >= _first_node_index_in_cloned_loop_body; + } else { + return false; + } + } +}; + +// Visitor to create Initialized Assertion Predicates at a target loop from Template Assertion Predicates from a source +// loop. This visitor can be used in combination with a PredicateIterator. +class CreateAssertionPredicatesVisitor : public PredicateVisitor { + Node* const _init; + Node* const _stride; + Node* const _old_target_loop_entry; + Node* _new_control; + PhaseIdealLoop* const _phase; + bool _has_hoisted_check_parse_predicates; + const NodeInLoopBody& _node_in_loop_body; + + public: + CreateAssertionPredicatesVisitor(Node* init, Node* stride, Node* new_control, PhaseIdealLoop* phase, + const NodeInLoopBody& node_in_loop_body) + : _init(init), + _stride(stride), + _old_target_loop_entry(new_control), + _new_control(new_control), + _phase(phase), + _has_hoisted_check_parse_predicates(false), + _node_in_loop_body(node_in_loop_body) {} + NONCOPYABLE(CreateAssertionPredicatesVisitor); + + using PredicateVisitor::visit; + + void visit(const ParsePredicate& parse_predicate) override; + void visit(const TemplateAssertionPredicate& template_assertion_predicate) override; + + // Did we create any new Initialized Assertion Predicates? + bool has_created_predicates() const { + return _new_control != _old_target_loop_entry; + } + + // Return the last created node by this visitor or the originally provided 'new_control' to the visitor if there was + // no new node created (i.e. no Template Assertion Predicates found). + IfTrueNode* last_created_success_proj() const { + assert(has_created_predicates(), "should only be queried if new nodes have been created"); + assert(_new_control->unique_ctrl_out_or_null() == nullptr, "no control outputs, yet"); + assert(_new_control->is_IfTrue(), "Assertion Predicates only have IfTrue on success proj"); + return _new_control->as_IfTrue(); + } +}; + #endif // SHARE_OPTO_PREDICATES_HPP diff --git a/src/hotspot/share/opto/vectorIntrinsics.cpp b/src/hotspot/share/opto/vectorIntrinsics.cpp index 6b7483b131f..3d20b22a175 100644 --- a/src/hotspot/share/opto/vectorIntrinsics.cpp +++ b/src/hotspot/share/opto/vectorIntrinsics.cpp @@ -365,9 +365,12 @@ bool LibraryCallKit::inline_vector_nary_operation(int n) { } BasicType elem_bt = elem_type->basic_type(); + bool has_scalar_op = VectorSupport::has_scalar_op(opr->get_con()); + bool is_unsigned = VectorSupport::is_unsigned_op(opr->get_con()); + int num_elem = vlen->get_con(); int opc = VectorSupport::vop2ideal(opr->get_con(), elem_bt); - int sopc = VectorNode::opcode(opc, elem_bt); + int sopc = has_scalar_op ? VectorNode::opcode(opc, elem_bt) : opc; if ((opc != Op_CallLeafVector) && (sopc == 0)) { log_if_needed(" ** operation not supported: opc=%s bt=%s", NodeClassNames[opc], type2name(elem_bt)); return false; // operation not supported @@ -481,7 +484,7 @@ bool LibraryCallKit::inline_vector_nary_operation(int n) { switch (n) { case 1: case 2: { - operation = VectorNode::make(sopc, opd1, opd2, vt, is_vector_mask(vbox_klass), VectorNode::is_shift_opcode(opc)); + operation = VectorNode::make(sopc, opd1, opd2, vt, is_vector_mask(vbox_klass), VectorNode::is_shift_opcode(opc), is_unsigned); break; } case 3: { diff --git a/src/hotspot/share/opto/vectornode.cpp b/src/hotspot/share/opto/vectornode.cpp index fc1c951cfbd..cc2fff23acc 100644 --- a/src/hotspot/share/opto/vectornode.cpp +++ b/src/hotspot/share/opto/vectornode.cpp @@ -667,7 +667,7 @@ VectorNode* VectorNode::make_mask_node(int vopc, Node* n1, Node* n2, uint vlen, } // Make a vector node for binary operation -VectorNode* VectorNode::make(int vopc, Node* n1, Node* n2, const TypeVect* vt, bool is_mask, bool is_var_shift) { +VectorNode* VectorNode::make(int vopc, Node* n1, Node* n2, const TypeVect* vt, bool is_mask, bool is_var_shift, bool is_unsigned) { // This method should not be called for unimplemented vectors. guarantee(vopc > 0, "vopc must be > 0"); @@ -739,6 +739,9 @@ VectorNode* VectorNode::make(int vopc, Node* n1, Node* n2, const TypeVect* vt, b case Op_RShiftVI: return new RShiftVINode(n1, n2, vt, is_var_shift); case Op_RShiftVL: return new RShiftVLNode(n1, n2, vt, is_var_shift); + case Op_UMinV: return new UMinVNode(n1, n2, vt); + case Op_UMaxV: return new UMaxVNode(n1, n2, vt); + case Op_URShiftVB: return new URShiftVBNode(n1, n2, vt, is_var_shift); case Op_URShiftVS: return new URShiftVSNode(n1, n2, vt, is_var_shift); case Op_URShiftVI: return new URShiftVINode(n1, n2, vt, is_var_shift); @@ -759,6 +762,10 @@ VectorNode* VectorNode::make(int vopc, Node* n1, Node* n2, const TypeVect* vt, b case Op_ExpandBitsV: return new ExpandBitsVNode(n1, n2, vt); case Op_CountLeadingZerosV: return new CountLeadingZerosVNode(n1, vt); case Op_CountTrailingZerosV: return new CountTrailingZerosVNode(n1, vt); + + case Op_SaturatingAddV: return new SaturatingAddVNode(n1, n2, vt, is_unsigned); + case Op_SaturatingSubV: return new SaturatingSubVNode(n1, n2, vt, is_unsigned); + default: fatal("Missed vector creation for '%s'", NodeClassNames[vopc]); return nullptr; @@ -2079,10 +2086,8 @@ Node* VectorBlendNode::Identity(PhaseGVN* phase) { return this; } - #ifndef PRODUCT void VectorBoxAllocateNode::dump_spec(outputStream *st) const { CallStaticJavaNode::dump_spec(st); } - #endif // !PRODUCT diff --git a/src/hotspot/share/opto/vectornode.hpp b/src/hotspot/share/opto/vectornode.hpp index 256664983ff..25a381408ca 100644 --- a/src/hotspot/share/opto/vectornode.hpp +++ b/src/hotspot/share/opto/vectornode.hpp @@ -78,7 +78,7 @@ class VectorNode : public TypeNode { static VectorNode* scalar2vector(Node* s, uint vlen, BasicType bt, bool is_mask = false); static VectorNode* shift_count(int opc, Node* cnt, uint vlen, BasicType bt); static VectorNode* make(int opc, Node* n1, Node* n2, uint vlen, BasicType bt, bool is_var_shift = false); - static VectorNode* make(int vopc, Node* n1, Node* n2, const TypeVect* vt, bool is_mask = false, bool is_var_shift = false); + static VectorNode* make(int vopc, Node* n1, Node* n2, const TypeVect* vt, bool is_mask = false, bool is_var_shift = false, bool is_unsigned = false); static VectorNode* make(int opc, Node* n1, Node* n2, Node* n3, uint vlen, BasicType bt); static VectorNode* make(int vopc, Node* n1, Node* n2, Node* n3, const TypeVect* vt); static VectorNode* make_mask_node(int vopc, Node* n1, Node* n2, uint vlen, BasicType bt); @@ -144,6 +144,32 @@ class VectorNode : public TypeNode { }; //===========================Vector=ALU=Operations============================= +// Base IR node for saturating signed / unsigned operations. +// Saturating operation prevents wrapping result value in over/underflowing +// scenarios, instead returns delimiting MAX/MIN value of result type. +class SaturatingVectorNode : public VectorNode { + private: + const bool _is_unsigned; + + public: + SaturatingVectorNode(Node* in1, Node* in2, const TypeVect* vt, bool is_unsigned) : VectorNode(in1, in2, vt), _is_unsigned(is_unsigned) { + init_class_id(Class_SaturatingVector); + } + + // Needed for proper cloning. + virtual uint size_of() const { return sizeof(*this); } + +#ifndef PRODUCT + // Print node specific info + virtual void dump_spec(outputStream *st) const { + TypeNode::dump_spec(st); + st->print("%s", _is_unsigned ? "{unsigned_vector_node}" : "{signed_vector_node}"); + } +#endif + virtual uint hash() const { return Node::hash() + _is_unsigned; } + + bool is_unsigned() { return _is_unsigned; } +}; //------------------------------AddVBNode-------------------------------------- // Vector add byte @@ -355,6 +381,22 @@ class SubVLNode : public VectorNode { virtual int Opcode() const; }; +//------------------------------SaturatingAddVNode----------------------------- +// Vector saturating addition. +class SaturatingAddVNode : public SaturatingVectorNode { + public: + SaturatingAddVNode(Node* in1, Node* in2, const TypeVect* vt, bool is_unsigned) : SaturatingVectorNode(in1, in2, vt, is_unsigned) {} + virtual int Opcode() const; +}; + +//------------------------------SaturatingSubVNode----------------------------- +// Vector saturating subtraction. +class SaturatingSubVNode : public SaturatingVectorNode { + public: + SaturatingSubVNode(Node* in1, Node* in2, const TypeVect* vt, bool is_unsigned) : SaturatingVectorNode(in1, in2, vt, is_unsigned) {} + virtual int Opcode() const; +}; + //------------------------------SubVFNode-------------------------------------- // Vector subtract float class SubVFNode : public VectorNode { @@ -561,6 +603,14 @@ class MinVNode : public VectorNode { virtual int Opcode() const; }; +class UMinVNode : public VectorNode { + public: + UMinVNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1, in2 ,vt) { + assert(is_integral_type(vt->element_basic_type()), ""); + } + virtual int Opcode() const; +}; + //------------------------------MaxVNode-------------------------------------- // Vector Max class MaxVNode : public VectorNode { @@ -569,6 +619,14 @@ class MaxVNode : public VectorNode { virtual int Opcode() const; }; +class UMaxVNode : public VectorNode { + public: + UMaxVNode(Node* in1, Node* in2, const TypeVect* vt) : VectorNode(in1, in2, vt) { + assert(is_integral_type(vt->element_basic_type()), ""); + } + virtual int Opcode() const; +}; + //------------------------------AbsVINode-------------------------------------- // Vector Abs int class AbsVINode : public VectorNode { diff --git a/src/hotspot/share/prims/jvm.cpp b/src/hotspot/share/prims/jvm.cpp index 20dc842eded..f0f14a05031 100644 --- a/src/hotspot/share/prims/jvm.cpp +++ b/src/hotspot/share/prims/jvm.cpp @@ -3941,19 +3941,6 @@ JVM_ENTRY(void, JVM_VirtualThreadUnmount(JNIEnv* env, jobject vthread, jboolean #endif JVM_END -// Always update the temporary VTMS transition bit. -JVM_ENTRY(void, JVM_VirtualThreadHideFrames(JNIEnv* env, jclass clazz, jboolean hide)) -#if INCLUDE_JVMTI - if (!DoJVMTIVirtualThreadTransitions) { - assert(!JvmtiExport::can_support_virtual_threads(), "sanity check"); - return; - } - assert(!thread->is_in_VTMS_transition(), "sanity check"); - assert(thread->is_in_tmp_VTMS_transition() != (bool)hide, "sanity check"); - thread->toggle_is_in_tmp_VTMS_transition(); -#endif -JVM_END - // Notification from VirtualThread about disabling JVMTI Suspend in a sync critical section. // Needed to avoid deadlocks with JVMTI suspend mechanism. JVM_ENTRY(void, JVM_VirtualThreadDisableSuspend(JNIEnv* env, jclass clazz, jboolean enter)) diff --git a/src/hotspot/share/prims/jvmtiEnvBase.cpp b/src/hotspot/share/prims/jvmtiEnvBase.cpp index 20f48eee673..c28afbb1c51 100644 --- a/src/hotspot/share/prims/jvmtiEnvBase.cpp +++ b/src/hotspot/share/prims/jvmtiEnvBase.cpp @@ -584,7 +584,6 @@ JvmtiEnvBase::jvf_for_thread_and_depth(JavaThread* java_thread, jint depth) { javaVFrame *jvf = java_thread->last_java_vframe(®_map); jvf = JvmtiEnvBase::check_and_skip_hidden_frames(java_thread, jvf); - for (int d = 0; jvf != nullptr && d < depth; d++) { jvf = jvf->java_sender(); } @@ -652,22 +651,42 @@ JavaThread* JvmtiEnvBase::get_JavaThread_or_null(oop vthread) { return Continuation::is_continuation_mounted(java_thread, cont) ? java_thread : nullptr; } +// An unmounted vthread may have an empty stack. +// Otherwise, it always has the yield0() and yield() frames we need to hide. +// The methods yield0() and yield() are annotated with the @JvmtiHideEvents. +javaVFrame* +JvmtiEnvBase::skip_yield_frames_for_unmounted_vthread(javaVFrame* jvf) { + if (jvf == nullptr) { + return jvf; // empty stack is possible + } + assert(jvf->method()->jvmti_hide_events(), "sanity check"); + assert(jvf->method()->method_holder() == vmClasses::Continuation_klass(), "expected Continuation class"); + jvf = jvf->java_sender(); // skip yield0 frame + + assert(jvf != nullptr && jvf->method()->jvmti_hide_events(), "sanity check"); + assert(jvf->method()->method_holder() == vmClasses::Continuation_klass(), "expected Continuation class"); + jvf = jvf->java_sender(); // skip yield frame + return jvf; +} + +// A thread may have an empty stack. +// Otherwise, some top frames may heed to be hidden. +// Two cases are processed below: +// - top frame is annotated with @JvmtiMountTransition: just skip top frames with annotated methods +// - JavaThread is in VTMS transition: skip top frames until a frame annotated with @ChangesCurrentThread is found javaVFrame* JvmtiEnvBase::check_and_skip_hidden_frames(bool is_in_VTMS_transition, javaVFrame* jvf) { - // The second condition is needed to hide notification methods. - if (!is_in_VTMS_transition && (jvf == nullptr || !jvf->method()->jvmti_mount_transition())) { - return jvf; // No frames to skip. + if (jvf == nullptr) { + return jvf; // empty stack is possible } - // Find jvf with a method annotated with @JvmtiMountTransition. - for ( ; jvf != nullptr; jvf = jvf->java_sender()) { - if (jvf->method()->jvmti_mount_transition()) { // Cannot actually appear in an unmounted continuation; they're never frozen. - jvf = jvf->java_sender(); // Skip annotated method. - break; + if (jvf->method()->jvmti_mount_transition()) { + // Skip frames annotated with @JvmtiMountTransition. + for ( ; jvf != nullptr && jvf->method()->jvmti_mount_transition(); jvf = jvf->java_sender()) { } - if (jvf->method()->changes_current_thread()) { - break; + } else if (is_in_VTMS_transition) { + // Skip frames above the frame annotated with @ChangesCurrentThread. + for ( ; jvf != nullptr && !jvf->method()->changes_current_thread(); jvf = jvf->java_sender()) { } - // Skip frame above annotated method. } return jvf; } @@ -678,17 +697,6 @@ JvmtiEnvBase::check_and_skip_hidden_frames(JavaThread* jt, javaVFrame* jvf) { return jvf; } -javaVFrame* -JvmtiEnvBase::check_and_skip_hidden_frames(oop vthread, javaVFrame* jvf) { - JvmtiThreadState* state = java_lang_Thread::jvmti_thread_state(vthread); - if (state == nullptr) { - // nothing to skip - return jvf; - } - jvf = check_and_skip_hidden_frames(java_lang_Thread::is_in_VTMS_transition(vthread), jvf); - return jvf; -} - javaVFrame* JvmtiEnvBase::get_vthread_jvf(oop vthread) { assert(java_lang_VirtualThread::state(vthread) != java_lang_VirtualThread::NEW, "sanity check"); @@ -707,12 +715,13 @@ JvmtiEnvBase::get_vthread_jvf(oop vthread) { return nullptr; } vframeStream vfs(java_thread); + assert(!java_thread->is_in_VTMS_transition(), "invariant"); jvf = vfs.at_end() ? nullptr : vfs.asJavaVFrame(); - jvf = check_and_skip_hidden_frames(java_thread, jvf); + jvf = check_and_skip_hidden_frames(false, jvf); } else { vframeStream vfs(cont); jvf = vfs.at_end() ? nullptr : vfs.asJavaVFrame(); - jvf = check_and_skip_hidden_frames(vthread, jvf); + jvf = skip_yield_frames_for_unmounted_vthread(jvf); } return jvf; } @@ -725,11 +734,9 @@ JvmtiEnvBase::get_cthread_last_java_vframe(JavaThread* jt, RegisterMap* reg_map_ bool cthread_with_cont = JvmtiEnvBase::is_cthread_with_continuation(jt); javaVFrame *jvf = cthread_with_cont ? jt->carrier_last_java_vframe(reg_map_p) : jt->last_java_vframe(reg_map_p); - // Skip hidden frames only for carrier threads - // which are in non-temporary VTMS transition. - if (jt->is_in_VTMS_transition()) { - jvf = check_and_skip_hidden_frames(jt, jvf); - } + + // Skip hidden frames for carrier threads only. + jvf = check_and_skip_hidden_frames(jt, jvf); return jvf; } @@ -1332,7 +1339,9 @@ JvmtiEnvBase::set_frame_pop(JvmtiThreadState* state, javaVFrame* jvf, jint depth if (jvf == nullptr) { return JVMTI_ERROR_NO_MORE_FRAMES; } - if (jvf->method()->is_native() || (depth == 0 && state->top_frame_is_exiting())) { + if (jvf->method()->is_native() || + (depth == 0 && state->top_frame_is_exiting()) || + (state->is_virtual() && jvf->method()->jvmti_hide_events())) { return JVMTI_ERROR_OPAQUE_FRAME; } assert(jvf->frame_pointer() != nullptr, "frame pointer mustn't be null"); @@ -1989,7 +1998,6 @@ void JvmtiHandshake::execute(JvmtiUnitedHandshakeClosure* hs_cl, jthread target) { JavaThread* current = JavaThread::current(); HandleMark hm(current); - JvmtiVTMSTransitionDisabler disabler(target); ThreadsListHandle tlh(current); JavaThread* java_thread = nullptr; diff --git a/src/hotspot/share/prims/jvmtiEnvBase.hpp b/src/hotspot/share/prims/jvmtiEnvBase.hpp index c6891fdeb1f..e8769d423c5 100644 --- a/src/hotspot/share/prims/jvmtiEnvBase.hpp +++ b/src/hotspot/share/prims/jvmtiEnvBase.hpp @@ -366,9 +366,9 @@ class JvmtiEnvBase : public CHeapObj { static bool get_field_descriptor(Klass* k, jfieldID field, fieldDescriptor* fd); // check and skip frames hidden in mount/unmount transitions + static javaVFrame* skip_yield_frames_for_unmounted_vthread(javaVFrame* jvf); static javaVFrame* check_and_skip_hidden_frames(bool is_in_VTMS_transition, javaVFrame* jvf); static javaVFrame* check_and_skip_hidden_frames(JavaThread* jt, javaVFrame* jvf); - static javaVFrame* check_and_skip_hidden_frames(oop vthread, javaVFrame* jvf); // check if virtual thread is not terminated (alive) static bool is_vthread_alive(oop vt); diff --git a/src/hotspot/share/prims/jvmtiExport.cpp b/src/hotspot/share/prims/jvmtiExport.cpp index cec898a0de8..b2e9fb9a4ab 100644 --- a/src/hotspot/share/prims/jvmtiExport.cpp +++ b/src/hotspot/share/prims/jvmtiExport.cpp @@ -929,7 +929,7 @@ class JvmtiClassFileLoadHookPoster : public StackObj { _cached_class_file_ptr = cache_ptr; _has_been_modified = false; - assert(!_thread->is_in_any_VTMS_transition(), "CFLH events are not allowed in any VTMS transition"); + assert(!_thread->is_in_VTMS_transition(), "CFLH events are not allowed in VTMS transition"); _state = JvmtiExport::get_jvmti_thread_state(_thread); if (_state != nullptr) { @@ -1091,8 +1091,8 @@ bool JvmtiExport::post_class_file_load_hook(Symbol* h_name, return false; } - if (JavaThread::current()->is_in_any_VTMS_transition()) { - return false; // no events should be posted if thread is in any VTMS transition + if (JavaThread::current()->is_in_VTMS_transition()) { + return false; // no events should be posted if thread is in VTMS transition } JvmtiClassFileLoadHookPoster poster(h_name, class_loader, @@ -1228,8 +1228,8 @@ void JvmtiExport::post_raw_breakpoint(JavaThread *thread, Method* method, addres if (state == nullptr) { return; } - if (thread->is_in_any_VTMS_transition()) { - return; // no events should be posted if thread is in any VTMS transition + if (thread->is_in_VTMS_transition()) { + return; // no events should be posted if thread is in VTMS transition } EVT_TRIG_TRACE(JVMTI_EVENT_BREAKPOINT, ("[%s] Trg Breakpoint triggered", @@ -1368,8 +1368,8 @@ void JvmtiExport::post_class_load(JavaThread *thread, Klass* klass) { if (state == nullptr) { return; } - if (thread->is_in_any_VTMS_transition()) { - return; // no events should be posted if thread is in any VTMS transition + if (thread->is_in_VTMS_transition()) { + return; // no events should be posted if thread is in VTMS transition } EVT_TRIG_TRACE(JVMTI_EVENT_CLASS_LOAD, ("[%s] Trg Class Load triggered", @@ -1405,8 +1405,8 @@ void JvmtiExport::post_class_prepare(JavaThread *thread, Klass* klass) { if (state == nullptr) { return; } - if (thread->is_in_any_VTMS_transition()) { - return; // no events should be posted if thread is in any VTMS transition + if (thread->is_in_VTMS_transition()) { + return; // no events should be posted if thread is in VTMS transition } EVT_TRIG_TRACE(JVMTI_EVENT_CLASS_PREPARE, ("[%s] Trg Class Prepare triggered", @@ -1743,8 +1743,8 @@ void JvmtiExport::post_object_free(JvmtiEnv* env, GrowableArray* objects) assert(objects != nullptr, "Nothing to post"); JavaThread *javaThread = JavaThread::current(); - if (javaThread->is_in_any_VTMS_transition()) { - return; // no events should be posted if thread is in any VTMS transition + if (javaThread->is_in_VTMS_transition()) { + return; // no events should be posted if thread is in VTMS transition } if (!env->is_enabled(JVMTI_EVENT_OBJECT_FREE)) { return; // the event type has been already disabled @@ -1767,8 +1767,8 @@ void JvmtiExport::post_resource_exhausted(jint resource_exhausted_flags, const c JavaThread *thread = JavaThread::current(); - if (thread->is_in_any_VTMS_transition()) { - return; // no events should be posted if thread is in any VTMS transition + if (thread->is_in_VTMS_transition()) { + return; // no events should be posted if thread is in VTMS transition } log_error(jvmti)("Posting Resource Exhausted event: %s", @@ -1810,8 +1810,8 @@ void JvmtiExport::post_method_entry(JavaThread *thread, Method* method, frame cu // for any thread that actually wants method entry, interp_only_mode is set return; } - if (mh->jvmti_mount_transition() || thread->is_in_any_VTMS_transition()) { - return; // no events should be posted if thread is in any VTMS transition + if (mh->jvmti_mount_transition() || thread->is_in_VTMS_transition()) { + return; // no events should be posted if thread is in VTMS transition } EVT_TRIG_TRACE(JVMTI_EVENT_METHOD_ENTRY, ("[%s] Trg Method Entry triggered %s.%s", JvmtiTrace::safe_get_thread_name(thread), @@ -1902,8 +1902,8 @@ void JvmtiExport::post_method_exit_inner(JavaThread* thread, bool exception_exit, frame current_frame, jvalue& value) { - if (mh->jvmti_mount_transition() || thread->is_in_any_VTMS_transition()) { - return; // no events should be posted if thread is in any VTMS transition + if (mh->jvmti_mount_transition() || thread->is_in_VTMS_transition()) { + return; // no events should be posted if thread is in VTMS transition } EVT_TRIG_TRACE(JVMTI_EVENT_METHOD_EXIT, ("[%s] Trg Method Exit triggered %s.%s", @@ -1978,8 +1978,8 @@ void JvmtiExport::post_single_step(JavaThread *thread, Method* method, address l if (state == nullptr) { return; } - if (mh->jvmti_mount_transition() || thread->is_in_any_VTMS_transition()) { - return; // no events should be posted if thread is in any VTMS transition + if (mh->jvmti_mount_transition() || thread->is_in_VTMS_transition()) { + return; // no events should be posted if thread is in VTMS transition } JvmtiEnvThreadStateIterator it(state); @@ -2020,8 +2020,8 @@ void JvmtiExport::post_exception_throw(JavaThread *thread, Method* method, addre if (state == nullptr) { return; } - if (thread->is_in_any_VTMS_transition()) { - return; // no events should be posted if thread is in any VTMS transition + if (thread->is_in_VTMS_transition()) { + return; // no events should be posted if thread is in VTMS transition } EVT_TRIG_TRACE(JVMTI_EVENT_EXCEPTION, ("[%s] Trg Exception thrown triggered", @@ -2142,8 +2142,8 @@ void JvmtiExport::notice_unwind_due_to_exception(JavaThread *thread, Method* met assert(!state->is_exception_caught(), "exception must not be caught yet."); state->set_exception_caught(); - if (mh->jvmti_mount_transition() || thread->is_in_any_VTMS_transition()) { - return; // no events should be posted if thread is in any VTMS transition + if (mh->jvmti_mount_transition() || thread->is_in_VTMS_transition()) { + return; // no events should be posted if thread is in VTMS transition } JvmtiEnvThreadStateIterator it(state); for (JvmtiEnvThreadState* ets = it.first(); ets != nullptr; ets = it.next(ets)) { @@ -2188,8 +2188,8 @@ void JvmtiExport::post_field_access_by_jni(JavaThread *thread, oop obj, // function don't make the call unless there is a Java context. assert(thread->has_last_Java_frame(), "must be called with a Java context"); - if (thread->is_in_any_VTMS_transition()) { - return; // no events should be posted if thread is in any VTMS transition + if (thread->is_in_VTMS_transition()) { + return; // no events should be posted if thread is in VTMS transition } ResourceMark rm; @@ -2224,8 +2224,8 @@ void JvmtiExport::post_field_access(JavaThread *thread, Method* method, if (state == nullptr) { return; } - if (thread->is_in_any_VTMS_transition()) { - return; // no events should be posted if thread is in any VTMS transition + if (thread->is_in_VTMS_transition()) { + return; // no events should be posted if thread is in VTMS transition } EVT_TRIG_TRACE(JVMTI_EVENT_FIELD_ACCESS, ("[%s] Trg Field Access event triggered", @@ -2274,8 +2274,8 @@ void JvmtiExport::post_field_modification_by_jni(JavaThread *thread, oop obj, // function don't make the call unless there is a Java context. assert(thread->has_last_Java_frame(), "must be called with Java context"); - if (thread->is_in_any_VTMS_transition()) { - return; // no events should be posted if thread is in any VTMS transition + if (thread->is_in_VTMS_transition()) { + return; // no events should be posted if thread is in VTMS transition } ResourceMark rm; @@ -2305,8 +2305,8 @@ void JvmtiExport::post_raw_field_modification(JavaThread *thread, Method* method address location, Klass* field_klass, Handle object, jfieldID field, char sig_type, jvalue *value) { - if (thread->is_in_any_VTMS_transition()) { - return; // no events should be posted if thread is in any VTMS transition + if (thread->is_in_VTMS_transition()) { + return; // no events should be posted if thread is in VTMS transition } if (sig_type == JVM_SIGNATURE_INT || sig_type == JVM_SIGNATURE_BOOLEAN || @@ -2380,8 +2380,8 @@ void JvmtiExport::post_field_modification(JavaThread *thread, Method* method, if (state == nullptr) { return; } - if (thread->is_in_any_VTMS_transition()) { - return; // no events should be posted if thread is in any VTMS transition + if (thread->is_in_VTMS_transition()) { + return; // no events should be posted if thread is in VTMS transition } EVT_TRIG_TRACE(JVMTI_EVENT_FIELD_MODIFICATION, @@ -2419,8 +2419,8 @@ void JvmtiExport::post_native_method_bind(Method* method, address* function_ptr) HandleMark hm(thread); methodHandle mh(thread, method); - if (thread->is_in_any_VTMS_transition()) { - return; // no events should be posted if thread is in any VTMS transition + if (thread->is_in_VTMS_transition()) { + return; // no events should be posted if thread is in VTMS transition } EVT_TRIG_TRACE(JVMTI_EVENT_NATIVE_METHOD_BIND, ("[%s] Trg Native Method Bind event triggered", JvmtiTrace::safe_get_thread_name(thread))); @@ -2493,7 +2493,7 @@ void JvmtiExport::post_compiled_method_load(nmethod *nm) { } JavaThread* thread = JavaThread::current(); - assert(!thread->is_in_any_VTMS_transition(), "compiled method load events are not allowed in any VTMS transition"); + assert(!thread->is_in_VTMS_transition(), "compiled method load events are not allowed in VTMS transition"); EVT_TRIG_TRACE(JVMTI_EVENT_COMPILED_METHOD_LOAD, ("[%s] method compile load event triggered", @@ -2516,7 +2516,7 @@ void JvmtiExport::post_compiled_method_load(JvmtiEnv* env, nmethod *nm) { } JavaThread* thread = JavaThread::current(); - assert(!thread->is_in_any_VTMS_transition(), "compiled method load events are not allowed in any VTMS transition"); + assert(!thread->is_in_VTMS_transition(), "compiled method load events are not allowed in VTMS transition"); EVT_TRACE(JVMTI_EVENT_COMPILED_METHOD_LOAD, ("[%s] method compile load event sent %s.%s ", @@ -2541,7 +2541,7 @@ void JvmtiExport::post_dynamic_code_generated_internal(const char *name, const v JavaThread* thread = JavaThread::current(); - assert(!thread->is_in_any_VTMS_transition(), "dynamic code generated events are not allowed in any VTMS transition"); + assert(!thread->is_in_VTMS_transition(), "dynamic code generated events are not allowed in VTMS transition"); // In theory everyone coming thru here is in_vm but we need to be certain // because a callee will do a vm->native transition @@ -2589,7 +2589,7 @@ void JvmtiExport::post_dynamic_code_generated(JvmtiEnv* env, const char *name, { JavaThread* thread = JavaThread::current(); - assert(!thread->is_in_any_VTMS_transition(), "dynamic code generated events are not allowed in any VTMS transition"); + assert(!thread->is_in_VTMS_transition(), "dynamic code generated events are not allowed in VTMS transition"); EVT_TRIG_TRACE(JVMTI_EVENT_DYNAMIC_CODE_GENERATED, ("[%s] dynamic code generated event triggered (by GenerateEvents)", @@ -2744,8 +2744,8 @@ void JvmtiExport::post_monitor_contended_enter(JavaThread *thread, ObjectMonitor if (state == nullptr) { return; } - if (thread->is_in_any_VTMS_transition()) { - return; // no events should be posted if thread is in any VTMS transition + if (thread->is_in_VTMS_transition()) { + return; // no events should be posted if thread is in VTMS transition } EVT_TRIG_TRACE(JVMTI_EVENT_MONITOR_CONTENDED_ENTER, @@ -2777,8 +2777,8 @@ void JvmtiExport::post_monitor_contended_entered(JavaThread *thread, ObjectMonit if (state == nullptr) { return; } - if (thread->is_in_any_VTMS_transition()) { - return; // no events should be posted if thread is in any VTMS transition + if (thread->is_in_VTMS_transition()) { + return; // no events should be posted if thread is in VTMS transition } EVT_TRIG_TRACE(JVMTI_EVENT_MONITOR_CONTENDED_ENTERED, @@ -2811,8 +2811,8 @@ void JvmtiExport::post_monitor_wait(JavaThread *thread, oop object, if (state == nullptr) { return; } - if (thread->is_in_any_VTMS_transition()) { - return; // no events should be posted if thread is in any VTMS transition + if (thread->is_in_VTMS_transition()) { + return; // no events should be posted if thread is in VTMS transition } EVT_TRIG_TRACE(JVMTI_EVENT_MONITOR_WAIT, @@ -2845,8 +2845,8 @@ void JvmtiExport::post_monitor_waited(JavaThread *thread, ObjectMonitor *obj_mnt if (state == nullptr) { return; } - if (thread->is_in_any_VTMS_transition()) { - return; // no events should be posted if thread is in any VTMS transition + if (thread->is_in_VTMS_transition()) { + return; // no events should be posted if thread is in VTMS transition } EVT_TRIG_TRACE(JVMTI_EVENT_MONITOR_WAITED, @@ -2874,8 +2874,8 @@ void JvmtiExport::post_vm_object_alloc(JavaThread *thread, oop object) { if (object == nullptr) { return; } - if (thread->is_in_any_VTMS_transition()) { - return; // no events should be posted if thread is in any VTMS transition + if (thread->is_in_VTMS_transition()) { + return; // no events should be posted if thread is in VTMS transition } HandleMark hm(thread); Handle h(thread, object); @@ -2911,8 +2911,8 @@ void JvmtiExport::post_sampled_object_alloc(JavaThread *thread, oop object) { if (object == nullptr) { return; } - if (thread->is_in_any_VTMS_transition()) { - return; // no events should be posted if thread is in any VTMS transition + if (thread->is_in_VTMS_transition()) { + return; // no events should be posted if thread is in VTMS transition } EVT_TRIG_TRACE(JVMTI_EVENT_SAMPLED_OBJECT_ALLOC, diff --git a/src/hotspot/share/prims/jvmtiImpl.cpp b/src/hotspot/share/prims/jvmtiImpl.cpp index 7b9821fe28a..ac7143e02b8 100644 --- a/src/hotspot/share/prims/jvmtiImpl.cpp +++ b/src/hotspot/share/prims/jvmtiImpl.cpp @@ -833,11 +833,6 @@ VM_VirtualThreadGetOrSetLocal::VM_VirtualThreadGetOrSetLocal(JvmtiEnv* env, Hand } javaVFrame *VM_VirtualThreadGetOrSetLocal::get_java_vframe() { - Thread* cur_thread = Thread::current(); - oop cont = java_lang_VirtualThread::continuation(_vthread_h()); - assert(cont != nullptr, "vthread contintuation must not be null"); - - javaVFrame* jvf = nullptr; JavaThread* java_thread = JvmtiEnvBase::get_JavaThread_or_null(_vthread_h()); bool is_cont_mounted = (java_thread != nullptr); @@ -845,22 +840,8 @@ javaVFrame *VM_VirtualThreadGetOrSetLocal::get_java_vframe() { _result = JVMTI_ERROR_THREAD_NOT_SUSPENDED; return nullptr; } + javaVFrame* jvf = JvmtiEnvBase::get_vthread_jvf(_vthread_h()); - if (is_cont_mounted) { - vframeStream vfs(java_thread); - - if (!vfs.at_end()) { - jvf = vfs.asJavaVFrame(); - jvf = JvmtiEnvBase::check_and_skip_hidden_frames(java_thread, jvf); - } - } else { - vframeStream vfs(cont); - - if (!vfs.at_end()) { - jvf = vfs.asJavaVFrame(); - jvf = JvmtiEnvBase::check_and_skip_hidden_frames(_vthread_h(), jvf); - } - } int d = 0; while ((jvf != nullptr) && (d < _depth)) { jvf = jvf->java_sender(); diff --git a/src/hotspot/share/prims/jvmtiThreadState.cpp b/src/hotspot/share/prims/jvmtiThreadState.cpp index b8d5cb4cdb5..d175aa6c78d 100644 --- a/src/hotspot/share/prims/jvmtiThreadState.cpp +++ b/src/hotspot/share/prims/jvmtiThreadState.cpp @@ -253,7 +253,7 @@ JvmtiVTMSTransitionDisabler::print_info() { #endif // disable VTMS transitions for one virtual thread -// no-op if thread is non-null and not a virtual thread +// disable VTMS transitions for all threads if thread is nullptr or a platform thread JvmtiVTMSTransitionDisabler::JvmtiVTMSTransitionDisabler(jthread thread) : _is_SR(false), _thread(thread) { @@ -266,6 +266,17 @@ JvmtiVTMSTransitionDisabler::JvmtiVTMSTransitionDisabler(jthread thread) if (!sync_protocol_enabled_permanently()) { JvmtiVTMSTransitionDisabler::inc_sync_protocol_enabled_count(); } + oop thread_oop = JNIHandles::resolve_external_guard(thread); + + // Target can be virtual or platform thread. + // If target is a platform thread then we have to disable VTMS transitions for all threads. + // It is by several reasons: + // - carrier threads can mount virtual threads which may cause incorrect behavior + // - there is no mechanism to disable transitions for a specific carrier thread yet + if (!java_lang_VirtualThread::is_instance(thread_oop)) { + _thread = nullptr; // target is a platform thread, switch to disabling VTMS transitions for all threads + } + if (_thread != nullptr) { VTMS_transition_disable_for_one(); // disable VTMS transitions for one virtual thread } else { @@ -316,9 +327,8 @@ JvmtiVTMSTransitionDisabler::VTMS_transition_disable_for_one() { JavaThread* thread = JavaThread::current(); HandleMark hm(thread); Handle vth = Handle(thread, JNIHandles::resolve_external_guard(_thread)); - if (!java_lang_VirtualThread::is_instance(vth())) { - return; // no-op if _thread is not a virtual thread - } + assert(java_lang_VirtualThread::is_instance(vth()), "sanity check"); + MonitorLocker ml(JvmtiVTMSTransition_lock); while (_SR_mode) { // suspender or resumer is a JvmtiVTMSTransitionDisabler monopolist @@ -343,7 +353,6 @@ JvmtiVTMSTransitionDisabler::VTMS_transition_disable_for_all() { { MonitorLocker ml(JvmtiVTMSTransition_lock); - assert(!thread->is_in_tmp_VTMS_transition(), "sanity check"); assert(!thread->is_in_VTMS_transition(), "VTMS_transition sanity check"); while (_SR_mode) { // Suspender or resumer is a JvmtiVTMSTransitionDisabler monopolist. ml.wait(10); // Wait while there is an active suspender or resumer. @@ -468,7 +477,7 @@ JvmtiVTMSTransitionDisabler::start_VTMS_transition(jthread vthread, bool is_moun JvmtiVTSuspender::is_vthread_suspended(thread_id) ) { // Block while transitions are disabled or there are suspend requests. - if (ml.wait(10)) { + if (ml.wait(200)) { attempts--; } DEBUG_ONLY(if (attempts == 0) break;) @@ -525,7 +534,7 @@ JvmtiVTMSTransitionDisabler::finish_VTMS_transition(jthread vthread, bool is_mou (is_mount && JvmtiVTSuspender::is_vthread_suspended(thread_id)) ) { // Block while there are suspend requests. - if (ml.wait(10)) { + if (ml.wait(200)) { attempts--; } DEBUG_ONLY(if (attempts == 0) break;) @@ -557,7 +566,6 @@ JvmtiVTMSTransitionDisabler::VTMS_vthread_start(jobject vthread) { JavaThread* thread = JavaThread::current(); assert(!thread->is_in_VTMS_transition(), "sanity check"); - assert(!thread->is_in_tmp_VTMS_transition(), "sanity check"); // If interp_only_mode has been enabled then we must eagerly create JvmtiThreadState // objects for globally enabled virtual thread filtered events. Otherwise, @@ -583,7 +591,6 @@ JvmtiVTMSTransitionDisabler::VTMS_vthread_end(jobject vthread) { JavaThread* thread = JavaThread::current(); assert(!thread->is_in_VTMS_transition(), "sanity check"); - assert(!thread->is_in_tmp_VTMS_transition(), "sanity check"); // post VirtualThreadUnmount event before VirtualThreadEnd if (JvmtiExport::should_post_vthread_unmount()) { @@ -628,7 +635,6 @@ JvmtiVTMSTransitionDisabler::VTMS_vthread_unmount(jobject vthread, bool hide) { void JvmtiVTMSTransitionDisabler::VTMS_mount_begin(jobject vthread) { JavaThread* thread = JavaThread::current(); - assert(!thread->is_in_tmp_VTMS_transition(), "sanity check"); assert(!thread->is_in_VTMS_transition(), "sanity check"); start_VTMS_transition(vthread, /* is_mount */ true); } @@ -641,7 +647,6 @@ JvmtiVTMSTransitionDisabler::VTMS_mount_end(jobject vthread) { thread->rebind_to_jvmti_thread_state_of(vt); assert(thread->is_in_VTMS_transition(), "sanity check"); - assert(!thread->is_in_tmp_VTMS_transition(), "sanity check"); finish_VTMS_transition(vthread, /* is_mount */ true); } @@ -649,7 +654,6 @@ void JvmtiVTMSTransitionDisabler::VTMS_unmount_begin(jobject vthread, bool last_unmount) { JavaThread* thread = JavaThread::current(); - assert(!thread->is_in_tmp_VTMS_transition(), "sanity check"); assert(!thread->is_in_VTMS_transition(), "sanity check"); start_VTMS_transition(vthread, /* is_mount */ false); @@ -662,7 +666,6 @@ void JvmtiVTMSTransitionDisabler::VTMS_unmount_end(jobject vthread) { JavaThread* thread = JavaThread::current(); assert(thread->is_in_VTMS_transition(), "sanity check"); - assert(!thread->is_in_tmp_VTMS_transition(), "sanity check"); finish_VTMS_transition(vthread, /* is_mount */ false); } diff --git a/src/hotspot/share/prims/methodHandles.cpp b/src/hotspot/share/prims/methodHandles.cpp index 498da559cf5..1e44ea95731 100644 --- a/src/hotspot/share/prims/methodHandles.cpp +++ b/src/hotspot/share/prims/methodHandles.cpp @@ -1464,15 +1464,15 @@ JVM_ENTRY(void, JVM_RegisterMethodHandleMethods(JNIEnv *env, jclass MHN_class)) ThreadToNativeFromVM ttnfv(thread); int status = env->RegisterNatives(MHN_class, MHN_methods, sizeof(MHN_methods)/sizeof(JNINativeMethod)); - guarantee(status == JNI_OK && !env->ExceptionOccurred(), + guarantee(status == JNI_OK && !env->ExceptionCheck(), "register java.lang.invoke.MethodHandleNative natives"); status = env->RegisterNatives(MH_class, MH_methods, sizeof(MH_methods)/sizeof(JNINativeMethod)); - guarantee(status == JNI_OK && !env->ExceptionOccurred(), + guarantee(status == JNI_OK && !env->ExceptionCheck(), "register java.lang.invoke.MethodHandle natives"); status = env->RegisterNatives(VH_class, VH_methods, sizeof(VH_methods)/sizeof(JNINativeMethod)); - guarantee(status == JNI_OK && !env->ExceptionOccurred(), + guarantee(status == JNI_OK && !env->ExceptionCheck(), "register java.lang.invoke.VarHandle natives"); } diff --git a/src/hotspot/share/prims/nativeEntryPoint.cpp b/src/hotspot/share/prims/nativeEntryPoint.cpp index 2dbff08a7cb..81c6058c11b 100644 --- a/src/hotspot/share/prims/nativeEntryPoint.cpp +++ b/src/hotspot/share/prims/nativeEntryPoint.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -116,6 +116,6 @@ static JNINativeMethod NEP_methods[] = { JNI_ENTRY(void, JVM_RegisterNativeEntryPointMethods(JNIEnv *env, jclass NEP_class)) ThreadToNativeFromVM ttnfv(thread); int status = env->RegisterNatives(NEP_class, NEP_methods, sizeof(NEP_methods)/sizeof(JNINativeMethod)); - guarantee(status == JNI_OK && !env->ExceptionOccurred(), + guarantee(status == JNI_OK && !env->ExceptionCheck(), "register jdk.internal.foreign.abi.NativeEntryPoint natives"); JNI_END diff --git a/src/hotspot/share/prims/unsafe.cpp b/src/hotspot/share/prims/unsafe.cpp index 239ae480030..46f9bfc3ef9 100644 --- a/src/hotspot/share/prims/unsafe.cpp +++ b/src/hotspot/share/prims/unsafe.cpp @@ -669,7 +669,7 @@ static jclass Unsafe_DefineClass_impl(JNIEnv *env, jstring name, jbyteArray data } env->GetByteArrayRegion(data, offset, length, body); - if (env->ExceptionOccurred()) { + if (env->ExceptionCheck()) { goto free_body; } diff --git a/src/hotspot/share/prims/upcallLinker.cpp b/src/hotspot/share/prims/upcallLinker.cpp index 1abce57652a..7511e278c69 100644 --- a/src/hotspot/share/prims/upcallLinker.cpp +++ b/src/hotspot/share/prims/upcallLinker.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -187,6 +187,6 @@ static JNINativeMethod UL_methods[] = { JNI_ENTRY(void, JVM_RegisterUpcallLinkerMethods(JNIEnv *env, jclass UL_class)) ThreadToNativeFromVM ttnfv(thread); int status = env->RegisterNatives(UL_class, UL_methods, sizeof(UL_methods)/sizeof(JNINativeMethod)); - guarantee(status == JNI_OK && !env->ExceptionOccurred(), + guarantee(status == JNI_OK && !env->ExceptionCheck(), "register jdk.internal.foreign.abi.UpcallLinker natives"); JNI_END diff --git a/src/hotspot/share/prims/upcallStubs.cpp b/src/hotspot/share/prims/upcallStubs.cpp index 19737575fcd..3c70b671c9d 100644 --- a/src/hotspot/share/prims/upcallStubs.cpp +++ b/src/hotspot/share/prims/upcallStubs.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -50,7 +50,7 @@ static JNINativeMethod UH_methods[] = { */ JVM_LEAF(void, JVM_RegisterUpcallHandlerMethods(JNIEnv *env, jclass UH_class)) int status = env->RegisterNatives(UH_class, UH_methods, sizeof(UH_methods)/sizeof(JNINativeMethod)); - guarantee(status == JNI_OK && !env->ExceptionOccurred(), + guarantee(status == JNI_OK && !env->ExceptionCheck(), "register jdk.internal.foreign.abi.UpcallStubs natives"); JVM_END diff --git a/src/hotspot/share/prims/vectorSupport.cpp b/src/hotspot/share/prims/vectorSupport.cpp index 65bc6c48fee..9eb0b46131b 100644 --- a/src/hotspot/share/prims/vectorSupport.cpp +++ b/src/hotspot/share/prims/vectorSupport.cpp @@ -199,6 +199,36 @@ instanceOop VectorSupport::allocate_vector(InstanceKlass* ik, frame* fr, Registe } #ifdef COMPILER2 +bool VectorSupport::has_scalar_op(jint id) { + VectorOperation vop = (VectorOperation)id; + switch (vop) { + case VECTOR_OP_COMPRESS: + case VECTOR_OP_EXPAND: + case VECTOR_OP_SADD: + case VECTOR_OP_SUADD: + case VECTOR_OP_SSUB: + case VECTOR_OP_SUSUB: + case VECTOR_OP_UMIN: + case VECTOR_OP_UMAX: + return false; + default: + return true; + } +} + +bool VectorSupport::is_unsigned_op(jint id) { + VectorOperation vop = (VectorOperation)id; + switch (vop) { + case VECTOR_OP_SUADD: + case VECTOR_OP_SUSUB: + case VECTOR_OP_UMIN: + case VECTOR_OP_UMAX: + return true; + default: + return false; + } +} + int VectorSupport::vop2ideal(jint id, BasicType bt) { VectorOperation vop = (VectorOperation)id; switch (vop) { @@ -274,6 +304,26 @@ int VectorSupport::vop2ideal(jint id, BasicType bt) { } break; } + case VECTOR_OP_UMIN: { + switch (bt) { + case T_BYTE: + case T_SHORT: + case T_INT: + case T_LONG: return Op_UMinV; + default: fatal("MIN: %s", type2name(bt)); + } + break; + } + case VECTOR_OP_UMAX: { + switch (bt) { + case T_BYTE: + case T_SHORT: + case T_INT: + case T_LONG: return Op_UMaxV; + default: fatal("MAX: %s", type2name(bt)); + } + break; + } case VECTOR_OP_ABS: { switch (bt) { case T_BYTE: // fall-through @@ -533,6 +583,28 @@ int VectorSupport::vop2ideal(jint id, BasicType bt) { } break; } + case VECTOR_OP_SADD: + case VECTOR_OP_SUADD: { + switch(bt) { + case T_BYTE: // fall-through + case T_SHORT: // fall-through + case T_INT: // fall-through + case T_LONG: return Op_SaturatingAddV; + default: fatal("S[U]ADD: %s", type2name(bt)); + } + break; + } + case VECTOR_OP_SSUB: + case VECTOR_OP_SUSUB: { + switch(bt) { + case T_BYTE: // fall-through + case T_SHORT: // fall-through + case T_INT: // fall-through + case T_LONG: return Op_SaturatingSubV; + default: fatal("S[U}SUB: %s", type2name(bt)); + } + break; + } case VECTOR_OP_COMPRESS_BITS: { switch (bt) { case T_INT: diff --git a/src/hotspot/share/prims/vectorSupport.hpp b/src/hotspot/share/prims/vectorSupport.hpp index 6f8e52e9ec0..001484874e2 100644 --- a/src/hotspot/share/prims/vectorSupport.hpp +++ b/src/hotspot/share/prims/vectorSupport.hpp @@ -121,6 +121,13 @@ class VectorSupport : AllStatic { VECTOR_OP_EXPM1 = 117, VECTOR_OP_HYPOT = 118, + VECTOR_OP_SADD = 119, + VECTOR_OP_SSUB = 120, + VECTOR_OP_SUADD = 121, + VECTOR_OP_SUSUB = 122, + VECTOR_OP_UMIN = 123, + VECTOR_OP_UMAX = 124, + VECTOR_OP_MATH_START = VECTOR_OP_TAN, VECTOR_OP_MATH_END = VECTOR_OP_HYPOT, NUM_VECTOR_OP_MATH = VECTOR_OP_MATH_END - VECTOR_OP_MATH_START + 1 @@ -143,6 +150,8 @@ class VectorSupport : AllStatic { static const char* mathname[VectorSupport::NUM_VECTOR_OP_MATH]; static int vop2ideal(jint vop, BasicType bt); + static bool has_scalar_op(jint id); + static bool is_unsigned_op(jint id); static instanceOop allocate_vector(InstanceKlass* holder, frame* fr, RegisterMap* reg_map, ObjectValue* sv, TRAPS); diff --git a/src/hotspot/share/prims/whitebox.cpp b/src/hotspot/share/prims/whitebox.cpp index 24f6156224d..54c5279512e 100644 --- a/src/hotspot/share/prims/whitebox.cpp +++ b/src/hotspot/share/prims/whitebox.cpp @@ -424,11 +424,7 @@ WB_ENTRY(jboolean, WB_isObjectInOldGen(JNIEnv* env, jobject o, jobject obj)) #endif #if INCLUDE_ZGC if (UseZGC) { - if (ZGenerational) { - return ZHeap::heap()->is_old(to_zaddress(p)); - } else { - return Universe::heap()->is_in(p); - } + return ZHeap::heap()->is_old(to_zaddress(p)); } #endif #if INCLUDE_SHENANDOAHGC @@ -1751,7 +1747,7 @@ WB_ENTRY(jlong, WB_GetTotalUsedWordsInMetaspaceTestContext(JNIEnv* env, jobject WB_END WB_ENTRY(jlong, WB_CreateArenaInTestContext(JNIEnv* env, jobject wb, jlong context, jboolean is_micro)) - const Metaspace::MetaspaceType type = is_micro ? Metaspace::ReflectionMetaspaceType : Metaspace::StandardMetaspaceType; + const Metaspace::MetaspaceType type = is_micro ? Metaspace::ClassMirrorHolderMetaspaceType : Metaspace::StandardMetaspaceType; metaspace::MetaspaceTestContext* context0 = (metaspace::MetaspaceTestContext*) context; return (jlong)p2i(context0->create_arena(type)); WB_END @@ -2159,8 +2155,7 @@ WB_ENTRY(jboolean, WB_IsJVMCISupportedByGC(JNIEnv* env)) WB_END WB_ENTRY(jboolean, WB_CanWriteJavaHeapArchive(JNIEnv* env)) - return HeapShared::can_write() - && ArchiveHeapLoader::can_use(); // work-around JDK-8341371 + return HeapShared::can_write(); WB_END diff --git a/src/hotspot/share/runtime/arguments.cpp b/src/hotspot/share/runtime/arguments.cpp index fe9641063b3..bcb6b919023 100644 --- a/src/hotspot/share/runtime/arguments.cpp +++ b/src/hotspot/share/runtime/arguments.cpp @@ -85,6 +85,7 @@ char** Arguments::_jvm_flags_array = nullptr; int Arguments::_num_jvm_flags = 0; char** Arguments::_jvm_args_array = nullptr; int Arguments::_num_jvm_args = 0; +unsigned int Arguments::_addmods_count = 0; char* Arguments::_java_command = nullptr; SystemProperty* Arguments::_system_properties = nullptr; size_t Arguments::_conservative_max_heap_alignment = 0; @@ -336,6 +337,10 @@ bool Arguments::is_internal_module_property(const char* property) { return false; } +bool Arguments::is_add_modules_property(const char* key) { + return (strcmp(key, MODULE_PROPERTY_PREFIX ADDMODS) == 0); +} + // Return true if the key matches the --module-path property name ("jdk.module.path"). bool Arguments::is_module_path_property(const char* key) { return (strcmp(key, MODULE_PROPERTY_PREFIX PATH) == 0); @@ -505,7 +510,6 @@ static SpecialFlag const special_jvm_flags[] = { // --- Non-alias flags - sorted by obsolete_in then expired_in: { "AllowRedefinitionToAddDeleteMethods", JDK_Version::jdk(13), JDK_Version::undefined(), JDK_Version::undefined() }, { "FlightRecorder", JDK_Version::jdk(13), JDK_Version::undefined(), JDK_Version::undefined() }, - { "ZGenerational", JDK_Version::jdk(23), JDK_Version::undefined(), JDK_Version::undefined() }, { "DumpSharedSpaces", JDK_Version::jdk(18), JDK_Version::jdk(19), JDK_Version::undefined() }, { "DynamicDumpSharedSpaces", JDK_Version::jdk(18), JDK_Version::jdk(19), JDK_Version::undefined() }, { "RequireSharedSpaces", JDK_Version::jdk(18), JDK_Version::jdk(19), JDK_Version::undefined() }, @@ -521,7 +525,7 @@ static SpecialFlag const special_jvm_flags[] = { // -------------- Obsolete Flags - sorted by expired_in -------------- { "MetaspaceReclaimPolicy", JDK_Version::undefined(), JDK_Version::jdk(21), JDK_Version::undefined() }, - + { "ZGenerational", JDK_Version::jdk(23), JDK_Version::jdk(24), JDK_Version::undefined() }, { "UseNotificationThread", JDK_Version::jdk(23), JDK_Version::jdk(24), JDK_Version::jdk(25) }, { "PreserveAllAnnotations", JDK_Version::jdk(23), JDK_Version::jdk(24), JDK_Version::jdk(25) }, { "UseEmptySlotsInSupers", JDK_Version::jdk(23), JDK_Version::jdk(24), JDK_Version::jdk(25) }, @@ -1774,7 +1778,6 @@ bool Arguments::sun_java_launcher_is_altjvm() { unsigned int addreads_count = 0; unsigned int addexports_count = 0; unsigned int addopens_count = 0; -unsigned int addmods_count = 0; unsigned int patch_mod_count = 0; unsigned int enable_native_access_count = 0; @@ -1800,7 +1803,7 @@ bool Arguments::check_vm_args_consistency() { PropertyList_unique_add(&_system_properties, "jdk.internal.vm.ci.enabled", "true", AddProperty, UnwriteableProperty, InternalProperty); if (ClassLoader::is_module_observable("jdk.internal.vm.ci")) { - if (!create_numbered_module_property("jdk.module.addmods", "jdk.internal.vm.ci", addmods_count++)) { + if (!create_numbered_module_property("jdk.module.addmods", "jdk.internal.vm.ci", _addmods_count++)) { return false; } } @@ -1809,7 +1812,7 @@ bool Arguments::check_vm_args_consistency() { #if INCLUDE_JFR if (status && (FlightRecorderOptions || StartFlightRecording)) { - if (!create_numbered_module_property("jdk.module.addmods", "jdk.jfr", addmods_count++)) { + if (!create_numbered_module_property("jdk.module.addmods", "jdk.jfr", _addmods_count++)) { return false; } } @@ -2236,7 +2239,7 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_m return JNI_ENOMEM; } } else if (match_option(option, "--add-modules=", &tail)) { - if (!create_numbered_module_property("jdk.module.addmods", tail, addmods_count++)) { + if (!create_numbered_module_property("jdk.module.addmods", tail, _addmods_count++)) { return JNI_ENOMEM; } } else if (match_option(option, "--enable-native-access=", &tail)) { @@ -2323,7 +2326,7 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_m FREE_C_HEAP_ARRAY(char, options); // java agents need module java.instrument - if (!create_numbered_module_property("jdk.module.addmods", "java.instrument", addmods_count++)) { + if (!create_numbered_module_property("jdk.module.addmods", "java.instrument", _addmods_count++)) { return JNI_ENOMEM; } } @@ -2504,7 +2507,7 @@ jint Arguments::parse_each_vm_init_arg(const JavaVMInitArgs* args, bool* patch_m return JNI_EINVAL; } // management agent in module jdk.management.agent - if (!create_numbered_module_property("jdk.module.addmods", "jdk.management.agent", addmods_count++)) { + if (!create_numbered_module_property("jdk.module.addmods", "jdk.management.agent", _addmods_count++)) { return JNI_ENOMEM; } #else diff --git a/src/hotspot/share/runtime/arguments.hpp b/src/hotspot/share/runtime/arguments.hpp index e1bfc0438dc..ac842285fd8 100644 --- a/src/hotspot/share/runtime/arguments.hpp +++ b/src/hotspot/share/runtime/arguments.hpp @@ -196,6 +196,8 @@ class Arguments : AllStatic { static int _num_jvm_args; // string containing all java command (class/jarfile name and app args) static char* _java_command; + // number of unique modules specified in the --add-modules option + static unsigned int _addmods_count; // Property list static SystemProperty* _system_properties; @@ -461,6 +463,8 @@ class Arguments : AllStatic { static int PropertyList_readable_count(SystemProperty* pl); static bool is_internal_module_property(const char* option); + static bool is_add_modules_property(const char* key); + static unsigned int addmods_count() { return _addmods_count; } static bool is_module_path_property(const char* key); // Miscellaneous System property value getter and setters. diff --git a/src/hotspot/share/runtime/continuation.cpp b/src/hotspot/share/runtime/continuation.cpp index cd55b4a9cff..fb697dd4920 100644 --- a/src/hotspot/share/runtime/continuation.cpp +++ b/src/hotspot/share/runtime/continuation.cpp @@ -428,5 +428,5 @@ void CONT_RegisterNativeMethods(JNIEnv *env, jclass cls) { ThreadToNativeFromVM trans(thread); int status = env->RegisterNatives(cls, CONT_methods, sizeof(CONT_methods)/sizeof(JNINativeMethod)); guarantee(status == JNI_OK, "register jdk.internal.vm.Continuation natives"); - guarantee(!env->ExceptionOccurred(), "register jdk.internal.vm.Continuation natives"); + guarantee(!env->ExceptionCheck(), "register jdk.internal.vm.Continuation natives"); } diff --git a/src/hotspot/share/runtime/continuationFreezeThaw.cpp b/src/hotspot/share/runtime/continuationFreezeThaw.cpp index e36b252362b..ce2e2bdb9ff 100644 --- a/src/hotspot/share/runtime/continuationFreezeThaw.cpp +++ b/src/hotspot/share/runtime/continuationFreezeThaw.cpp @@ -1442,9 +1442,7 @@ stackChunkOop Freeze::allocate_chunk(size_t stack_size, int argsize_md) #if INCLUDE_ZGC if (UseZGC) { - if (ZGenerational) { - ZStackChunkGCData::initialize(chunk); - } + ZStackChunkGCData::initialize(chunk); assert(!chunk->requires_barriers(), "ZGC always allocates in the young generation"); _barriers = false; } else diff --git a/src/hotspot/share/runtime/javaThread.cpp b/src/hotspot/share/runtime/javaThread.cpp index 14528f6d908..285c2de17fa 100644 --- a/src/hotspot/share/runtime/javaThread.cpp +++ b/src/hotspot/share/runtime/javaThread.cpp @@ -446,7 +446,6 @@ JavaThread::JavaThread(MemTag mem_tag) : #if INCLUDE_JVMTI _carrier_thread_suspended(false), _is_in_VTMS_transition(false), - _is_in_tmp_VTMS_transition(false), _is_disable_suspend(false), _VTMS_transition_mark(false), #ifdef ASSERT diff --git a/src/hotspot/share/runtime/javaThread.hpp b/src/hotspot/share/runtime/javaThread.hpp index bda438612e3..249a1e4dc87 100644 --- a/src/hotspot/share/runtime/javaThread.hpp +++ b/src/hotspot/share/runtime/javaThread.hpp @@ -311,7 +311,6 @@ class JavaThread: public Thread { #if INCLUDE_JVMTI volatile bool _carrier_thread_suspended; // Carrier thread is externally suspended bool _is_in_VTMS_transition; // thread is in virtual thread mount state transition - bool _is_in_tmp_VTMS_transition; // thread is in temporary virtual thread mount state transition bool _is_disable_suspend; // JVMTI suspend is temporarily disabled; used on current thread only bool _VTMS_transition_mark; // used for sync between VTMS transitions and disablers #ifdef ASSERT @@ -675,11 +674,7 @@ class JavaThread: public Thread { } bool is_in_VTMS_transition() const { return _is_in_VTMS_transition; } - bool is_in_tmp_VTMS_transition() const { return _is_in_tmp_VTMS_transition; } - bool is_in_any_VTMS_transition() const { return _is_in_VTMS_transition || _is_in_tmp_VTMS_transition; } - void set_is_in_VTMS_transition(bool val); - void toggle_is_in_tmp_VTMS_transition() { _is_in_tmp_VTMS_transition = !_is_in_tmp_VTMS_transition; }; bool is_disable_suspend() const { return _is_disable_suspend; } void toggle_is_disable_suspend() { _is_disable_suspend = !_is_disable_suspend; }; @@ -851,7 +846,6 @@ class JavaThread: public Thread { #if INCLUDE_JVMTI static ByteSize is_in_VTMS_transition_offset() { return byte_offset_of(JavaThread, _is_in_VTMS_transition); } - static ByteSize is_in_tmp_VTMS_transition_offset() { return byte_offset_of(JavaThread, _is_in_tmp_VTMS_transition); } static ByteSize is_disable_suspend_offset() { return byte_offset_of(JavaThread, _is_disable_suspend); } #endif diff --git a/src/hotspot/share/runtime/mutexLocker.cpp b/src/hotspot/share/runtime/mutexLocker.cpp index a0a6e5626e4..76d0674e8c6 100644 --- a/src/hotspot/share/runtime/mutexLocker.cpp +++ b/src/hotspot/share/runtime/mutexLocker.cpp @@ -135,6 +135,7 @@ Mutex* SharedDecoder_lock = nullptr; Mutex* DCmdFactory_lock = nullptr; Mutex* NMTQuery_lock = nullptr; Mutex* NMTCompilationCostHistory_lock = nullptr; +Mutex* NmtVirtualMemory_lock = nullptr; #if INCLUDE_CDS #if INCLUDE_JVMTI @@ -293,10 +294,11 @@ void mutex_init() { MUTEX_DEFN(CodeHeapStateAnalytics_lock , PaddedMutex , safepoint); MUTEX_DEFN(ThreadsSMRDelete_lock , PaddedMonitor, service-2); // Holds ConcurrentHashTableResize_lock MUTEX_DEFN(ThreadIdTableCreate_lock , PaddedMutex , safepoint); - MUTEX_DEFN(SharedDecoder_lock , PaddedMutex , tty-1); + MUTEX_DEFN(SharedDecoder_lock , PaddedMutex , service-5); // Must be lower than NmtVirtualMemory_lock due to MemTracker::print_containing_region MUTEX_DEFN(DCmdFactory_lock , PaddedMutex , nosafepoint); MUTEX_DEFN(NMTQuery_lock , PaddedMutex , safepoint); MUTEX_DEFN(NMTCompilationCostHistory_lock , PaddedMutex , nosafepoint); + MUTEX_DEFN(NmtVirtualMemory_lock , PaddedMutex , service-4); #if INCLUDE_CDS #if INCLUDE_JVMTI MUTEX_DEFN(CDSClassFileStream_lock , PaddedMutex , safepoint); diff --git a/src/hotspot/share/runtime/mutexLocker.hpp b/src/hotspot/share/runtime/mutexLocker.hpp index 932ca5fce82..07bea6b614d 100644 --- a/src/hotspot/share/runtime/mutexLocker.hpp +++ b/src/hotspot/share/runtime/mutexLocker.hpp @@ -28,6 +28,7 @@ #include "memory/allocation.hpp" #include "runtime/flags/flagSetting.hpp" #include "runtime/mutex.hpp" +#include "runtime/thread.hpp" // Mutexes used in the VM. @@ -115,6 +116,7 @@ extern Mutex* SharedDecoder_lock; // serializes access to the dec extern Mutex* DCmdFactory_lock; // serialize access to DCmdFactory information extern Mutex* NMTQuery_lock; // serialize NMT Dcmd queries extern Mutex* NMTCompilationCostHistory_lock; // guards NMT compilation cost history +extern Mutex* NmtVirtualMemory_lock; // guards NMT virtual memory updates #if INCLUDE_CDS #if INCLUDE_JVMTI extern Mutex* CDSClassFileStream_lock; // FileMapInfo::open_stream_for_jvmti diff --git a/src/hotspot/share/runtime/objectMonitor.cpp b/src/hotspot/share/runtime/objectMonitor.cpp index 755d49d2c6c..3ea987801db 100644 --- a/src/hotspot/share/runtime/objectMonitor.cpp +++ b/src/hotspot/share/runtime/objectMonitor.cpp @@ -1133,6 +1133,14 @@ void ObjectMonitor::UnlinkAfterAcquire(JavaThread* current, ObjectWaiter* curren // or drain _cxq, we need to reacquire the lock before we can wake up // (unpark) a waiting thread. // +// Note that we read the EntryList and then the cxq after dropping the +// lock, so the values need not form a stable snapshot. In particular, +// after reading the (empty) EntryList, another thread could acquire +// and release the lock, moving any entries in the cxq to the +// EntryList, causing the current thread to see an empty cxq and +// conclude there are no waiters. But this is okay as the thread that +// moved the cxq is responsible for waking the successor. +// // The CAS() in enter provides for safety and exclusion, while the // MEMBAR in exit provides for progress and avoids stranding. // diff --git a/src/hotspot/share/runtime/os.cpp b/src/hotspot/share/runtime/os.cpp index 5dc5a1af8cc..2395510f27f 100644 --- a/src/hotspot/share/runtime/os.cpp +++ b/src/hotspot/share/runtime/os.cpp @@ -2166,7 +2166,7 @@ bool os::uncommit_memory(char* addr, size_t bytes, bool executable) { assert_nonempty_range(addr, bytes); bool res; if (MemTracker::enabled()) { - ThreadCritical tc; + NmtVirtualMemoryLocker ml; res = pd_uncommit_memory(addr, bytes, executable); if (res) { MemTracker::record_virtual_memory_uncommit((address)addr, bytes); @@ -2188,7 +2188,7 @@ bool os::release_memory(char* addr, size_t bytes) { assert_nonempty_range(addr, bytes); bool res; if (MemTracker::enabled()) { - ThreadCritical tc; + NmtVirtualMemoryLocker ml; res = pd_release_memory(addr, bytes); if (res) { MemTracker::record_virtual_memory_release((address)addr, bytes); @@ -2273,7 +2273,7 @@ char* os::map_memory(int fd, const char* file_name, size_t file_offset, bool os::unmap_memory(char *addr, size_t bytes) { bool result; if (MemTracker::enabled()) { - ThreadCritical tc; + NmtVirtualMemoryLocker ml; result = pd_unmap_memory(addr, bytes); if (result) { MemTracker::record_virtual_memory_release((address)addr, bytes); @@ -2312,7 +2312,7 @@ char* os::reserve_memory_special(size_t size, size_t alignment, size_t page_size bool os::release_memory_special(char* addr, size_t bytes) { bool res; if (MemTracker::enabled()) { - ThreadCritical tc; + NmtVirtualMemoryLocker ml; res = pd_release_memory_special(addr, bytes); if (res) { MemTracker::record_virtual_memory_release((address)addr, bytes); diff --git a/src/hotspot/share/services/attachListener.cpp b/src/hotspot/share/services/attachListener.cpp index 36931531a4e..90f5930cce0 100644 --- a/src/hotspot/share/services/attachListener.cpp +++ b/src/hotspot/share/services/attachListener.cpp @@ -50,6 +50,38 @@ volatile AttachListenerState AttachListener::_state = AL_NOT_INITIALIZED; +AttachAPIVersion AttachListener::_supported_version = ATTACH_API_V1; + +static bool get_bool_sys_prop(const char* name, bool default_value, TRAPS) { + ResourceMark rm(THREAD); + HandleMark hm(THREAD); + + // setup the arguments to getProperty + Handle key_str = java_lang_String::create_from_str(name, CHECK_(default_value)); + // return value + JavaValue result(T_OBJECT); + // public static String getProperty(String key, String def); + JavaCalls::call_static(&result, + vmClasses::System_klass(), + vmSymbols::getProperty_name(), + vmSymbols::string_string_signature(), + key_str, + CHECK_(default_value)); + oop value_oop = result.get_oop(); + if (value_oop != nullptr) { + // convert Java String to utf8 string + char* value = java_lang_String::as_utf8_string(value_oop); + if (strcasecmp(value, "true") == 0) { + return true; + } + if (strcasecmp(value, "false") == 0) { + return false; + } + } + return default_value; +} + + // Implementation of "properties" command. // // Invokes VMSupport.serializePropertiesToByteArray to serialize @@ -351,6 +383,12 @@ static jint print_flag(AttachOperation* op, outputStream* out) { return JNI_OK; } +// Implementation of "getversion" command +static jint get_version(AttachOperation* op, outputStream* out) { + out->print("%d", (int)AttachListener::get_supported_version()); + return JNI_OK; +} + // Table to map operation names to functions. // names must be of length <= AttachOperation::name_length_max @@ -365,6 +403,7 @@ static AttachOperationFunctionInfo funcs[] = { { "setflag", set_flag }, { "printflag", print_flag }, { "jcmd", jcmd }, + { "getversion", get_version }, { nullptr, nullptr } }; @@ -472,3 +511,175 @@ void AttachListener::detachall() { // call the platform dependent clean-up pd_detachall(); } + +void AttachListener::set_supported_version(AttachAPIVersion version) { +// _supported_version = version; + const char* prop_name = "jdk.attach.compat"; + if (!get_bool_sys_prop(prop_name, false, JavaThread::current())) { + _supported_version = version; + } +} + +AttachAPIVersion AttachListener::get_supported_version() { + return _supported_version; +} + + +int AttachOperation::RequestReader::read_uint() { + const int MAX_VALUE = INT_MAX / 20; + char ch; + int value = 0; + while (true) { + int n = read(&ch, 1); + if (n != 1) { + // IO errors (n < 0) are logged by read(). + if (n == 0) { // EOF + log_error(attach)("Failed to read int value: EOF"); + } + return -1; + } + if (ch == '\0') { + return value; + } + if (ch < '0' || ch > '9') { + log_error(attach)("Failed to read int value: unexpected symbol: %c", ch); + return -1; + } + // Ensure there is no integer overflow. + if (value >= MAX_VALUE) { + log_error(attach)("Failed to read int value: too big"); + return -1; + } + value = value * 10 + (ch - '0'); + } +} + +// Reads operation name and arguments. +// buffer_size: maximum data size; +// min_str_count: minimum number of strings in the request (name + arguments); +// min_read_size: minimum data size. +bool AttachOperation::read_request_data(AttachOperation::RequestReader* reader, + int buffer_size, int min_str_count, int min_read_size) { + char* buffer = (char*)os::malloc(buffer_size, mtServiceability); + int str_count = 0; + int off = 0; + int left = buffer_size; + + // Read until all (expected) strings or expected bytes have been read, the buffer is full, or EOF. + do { + int n = reader->read(buffer + off, left); + if (n < 0) { + os::free(buffer); + return false; + } + if (n == 0) { // EOF + break; + } + if (min_str_count > 0) { // need to count arguments + for (int i = 0; i < n; i++) { + if (buffer[off + i] == '\0') { + str_count++; + } + } + } + off += n; + left -= n; + } while (left > 0 && (off < min_read_size || str_count < min_str_count)); + + if (off < min_read_size || str_count < min_str_count) { // unexpected EOF + log_error(attach)("Failed to read request: incomplete request"); + os::free(buffer); + return false; + } + // Request must ends with '\0'. + if (buffer[off - 1] != '\0') { + log_error(attach)("Failed to read request: not terminated"); + os::free(buffer); + return false; + } + + // Parse request. + // Command name is the 1st string. + set_name(buffer); + log_debug(attach)("read request: cmd = %s", buffer); + + // Arguments. + char* end = buffer + off; + for (char* cur = strchr(buffer, '\0') + 1; cur < end; cur = strchr(cur, '\0') + 1) { + log_debug(attach)("read request: arg = %s", cur); + append_arg(cur); + } + + os::free(buffer); + + return true; +} + +bool AttachOperation::read_request(RequestReader* reader) { + uint ver = reader->read_uint(); + int buffer_size = 0; + // Read conditions: + int min_str_count = 0; // expected number of strings in the request + int min_read_size = 1; // expected size of the request data (by default 1 symbol for terminating '\0') + switch (ver) { + case ATTACH_API_V1: // 00000 + // Always contain a command (up to name_length_max chars) + // and arg_count_max(3) arguments (each up to arg_length_max chars). + buffer_size = (name_length_max + 1) + arg_count_max * (arg_length_max + 1); + min_str_count = 1 /*name*/ + arg_count_max; + break; + case ATTACH_API_V2: // 000000 + if (AttachListener::get_supported_version() < 2) { + log_error(attach)("Failed to read request: v2 is unsupported ot disabled"); + return false; + } + + // read size of the data + buffer_size = reader->read_uint(); + if (buffer_size < 0) { + return false; + } + log_debug(attach)("v2 request, data size = %d", buffer_size); + + // Sanity check: max request size is 256K. + if (buffer_size > 256 * 1024) { + log_error(attach)("Failed to read request: too big"); + return false; + } + // Must contain exact 'buffer_size' bytes. + min_read_size = buffer_size; + break; + default: + log_error(attach)("Failed to read request: unknown version (%d)", ver); + return false; + } + + return read_request_data(reader, buffer_size, min_str_count, min_read_size); +} + +bool AttachOperation::ReplyWriter::write_fully(const void* buffer, int size) { + const char* buf = (const char*)buffer; + do { + int n = write(buf, size); + if (n < 0) { + return false; + } + buf += n; + size -= n; + } while (size > 0); + return true; +} + +bool AttachOperation::write_reply(ReplyWriter* writer, jint result, bufferedStream* result_stream) { + char msg[32]; + os::snprintf_checked(msg, sizeof(msg), "%d\n", result); + if (!writer->write_fully(msg, (int)strlen(msg))) { + return false; + } + if (!writer->write_fully(result_stream->base(), (int)result_stream->size())) { + return false; + } + writer->flush(); + return true; +} + diff --git a/src/hotspot/share/services/attachListener.hpp b/src/hotspot/share/services/attachListener.hpp index c49f996cdb4..093fa410d12 100644 --- a/src/hotspot/share/services/attachListener.hpp +++ b/src/hotspot/share/services/attachListener.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,6 +32,7 @@ #include "utilities/debug.hpp" #include "utilities/exceptions.hpp" #include "utilities/globalDefinitions.hpp" +#include "utilities/growableArray.hpp" #include "utilities/macros.hpp" #include "utilities/ostream.hpp" @@ -59,6 +60,20 @@ enum AttachListenerState { AL_INITIALIZED }; +/* +Version 1 (since jdk6): attach operations always have 3 (AttachOperation::arg_count_max) + arguments, each up to 1024 (AttachOperation::arg_length_max) chars. +Version 2 (since jdk24): attach operations may have any number of arguments of any length; + for safety default implementation restricts attach operation request size by 256KB. + To detect if target VM supports version 2, client sends "getversion" command. + Old VM reports "Operation not recognized" error, newer VM reports version supported by the implementation. + If the target VM does not support version 2, client uses version 1 to enqueue operations. +*/ +enum AttachAPIVersion: int { + ATTACH_API_V1 = 1, + ATTACH_API_V2 = 2 +}; + class AttachListenerThread : public JavaThread { private: static void thread_entry(JavaThread* thread, TRAPS); @@ -93,7 +108,12 @@ class AttachListener: AllStatic { private: static volatile AttachListenerState _state; + static AttachAPIVersion _supported_version; + public: + static void set_supported_version(AttachAPIVersion version); + static AttachAPIVersion get_supported_version(); + static void set_state(AttachListenerState new_state) { Atomic::store(&_state, new_state); } @@ -136,8 +156,9 @@ class AttachListener: AllStatic { }; #if INCLUDE_SERVICES -class AttachOperation: public CHeapObj { - public: +class AttachOperation: public CHeapObj { +public: + // v1 constants enum { name_length_max = 16, // maximum length of name arg_length_max = 1024, // maximum length of argument @@ -148,51 +169,100 @@ class AttachOperation: public CHeapObj { // clients detach static char* detachall_operation_name() { return (char*)"detachall"; } - private: - char _name[name_length_max+1]; - char _arg[arg_count_max][arg_length_max+1]; +private: + char* _name; + GrowableArrayCHeap _args; - public: - const char* name() const { return _name; } + static char* copy_str(const char* value) { + return value == nullptr ? nullptr : os::strdup(value, mtServiceability); + } + +public: + const char* name() const { return _name; } // set the operation name void set_name(const char* name) { - assert(strlen(name) <= name_length_max, "exceeds maximum name length"); - size_t len = MIN2(strlen(name), (size_t)name_length_max); - memcpy(_name, name, len); - _name[len] = '\0'; + os::free(_name); + _name = copy_str(name); + } + + int arg_count() const { + return _args.length(); } // get an argument value const char* arg(int i) const { - assert(i>=0 && i= _args.length() || _args.at(i) == nullptr) { + static char empty_str[] = ""; + return empty_str; + } + return _args.at(i); + } + + // appends an argument + void append_arg(const char* arg) { + _args.append(copy_str(arg)); } // set an argument value - void set_arg(int i, char* arg) { - assert(i>=0 && i it = _args.begin(); it != _args.end(); ++it) { + os::free(*it); + } + } + // complete operation by sending result code and any result data to the client virtual void complete(jint result, bufferedStream* result_stream) = 0; + + // Helper classes/methods for platform-specific implementations. + class RequestReader { + public: + // Returns number of bytes read, + // 0 on EOF, negative value on error. + virtual int read(void* buffer, int size) = 0; + + // Reads unsigned value, returns -1 on error. + int read_uint(); + }; + + // Reads standard operation request (v1 or v2). + bool read_request(RequestReader* reader); + + class ReplyWriter { + public: + // Returns number of bytes written, negative value on error. + virtual int write(const void* buffer, int size) = 0; + + virtual void flush() {} + + bool write_fully(const void* buffer, int size); + }; + + // Writes standard operation reply (to be called from 'complete' method). + bool write_reply(ReplyWriter* writer, jint result, bufferedStream* result_stream); + +private: + bool read_request_data(AttachOperation::RequestReader* reader, int buffer_size, int min_str_count, int min_read_size); + }; + #endif // INCLUDE_SERVICES #endif // SHARE_SERVICES_ATTACHLISTENER_HPP diff --git a/src/hotspot/share/utilities/debug.cpp b/src/hotspot/share/utilities/debug.cpp index 119d1cf17fd..88730c1e6ec 100644 --- a/src/hotspot/share/utilities/debug.cpp +++ b/src/hotspot/share/utilities/debug.cpp @@ -725,10 +725,22 @@ void disarm_assert_poison() { static void store_context(const void* context) { memcpy(&g_stored_assertion_context, context, sizeof(ucontext_t)); -#if defined(LINUX) && defined(PPC64) +#if defined(LINUX) // on Linux ppc64, ucontext_t contains pointers into itself which have to be patched up // after copying the context (see comment in sys/ucontext.h): +#if defined(PPC64) *((void**) &g_stored_assertion_context.uc_mcontext.regs) = &(g_stored_assertion_context.uc_mcontext.gp_regs); +#elif defined(AMD64) + // In the copied version, fpregs should point to the copied contents. + // Sanity check: fpregs should point into the context. + if ((address)((const ucontext_t*)context)->uc_mcontext.fpregs > (address)context) { + size_t fpregs_offset = pointer_delta(((const ucontext_t*)context)->uc_mcontext.fpregs, context, 1); + if (fpregs_offset < sizeof(ucontext_t)) { + // Preserve the offset. + *((void**) &g_stored_assertion_context.uc_mcontext.fpregs) = (void*)((address)(void*)&g_stored_assertion_context + fpregs_offset); + } + } +#endif #endif } diff --git a/src/hotspot/share/utilities/vmError.cpp b/src/hotspot/share/utilities/vmError.cpp index 7bbb978b806..0df77689a04 100644 --- a/src/hotspot/share/utilities/vmError.cpp +++ b/src/hotspot/share/utilities/vmError.cpp @@ -717,6 +717,10 @@ void VMError::report(outputStream* st, bool _verbose) { address lastpc = nullptr; BEGIN + if (MemTracker::enabled() && NmtVirtualMemory_lock != nullptr && NmtVirtualMemory_lock->owned_by_self()) { + // Manually unlock to avoid reentrancy due to mallocs in detailed mode. + NmtVirtualMemory_lock->unlock(); + } STEP("printing fatal error message") st->print_cr("#"); @@ -1862,7 +1866,7 @@ void VMError::report_and_die(int id, const char* message, const char* detail_fmt if (DumpReplayDataOnError && _thread && _thread->is_Compiler_thread() && !skip_replay) { skip_replay = true; ciEnv* env = ciEnv::current(); - if (env != nullptr) { + if (env != nullptr && env->task() != nullptr) { const bool overwrite = false; // We do not overwrite an existing replay file. int fd = prepare_log_file(ReplayDataFile, "replay_pid%p.log", overwrite, buffer, sizeof(buffer)); if (fd != -1) { diff --git a/src/java.base/macosx/native/libjli/java_md_macosx.m b/src/java.base/macosx/native/libjli/java_md_macosx.m index 7aeb32be859..354efc69769 100644 --- a/src/java.base/macosx/native/libjli/java_md_macosx.m +++ b/src/java.base/macosx/native/libjli/java_md_macosx.m @@ -149,7 +149,7 @@ /* * Exports the JNI interface from libjli * - * This allows client code to link against the .jre/.jdk bundles, + * This allows client code to link against the JDK bundles, * and not worry about trying to pick a HotSpot to link against. * * Switching architectures is unsupported, since client code has @@ -162,10 +162,10 @@ static InvocationFunctions *GetExportedJNIFunctions() { if (sExportedJNIFunctions != NULL) return sExportedJNIFunctions; - char jrePath[PATH_MAX]; - jboolean gotJREPath = GetJREPath(jrePath, sizeof(jrePath), JNI_FALSE); - if (!gotJREPath) { - JLI_ReportErrorMessage("Failed to GetJREPath()"); + char jdkRoot[PATH_MAX]; + jboolean got = GetJDKInstallRoot(jdkRoot, sizeof(jdkRoot), JNI_FALSE); + if (!got) { + JLI_ReportErrorMessage("Failed to determine JDK installation root"); return NULL; } @@ -183,7 +183,7 @@ } char jvmPath[PATH_MAX]; - jboolean gotJVMPath = GetJVMPath(jrePath, preferredJVM, jvmPath, sizeof(jvmPath)); + jboolean gotJVMPath = GetJVMPath(jdkRoot, preferredJVM, jvmPath, sizeof(jvmPath)); if (!gotJVMPath) { JLI_ReportErrorMessage("Failed to GetJVMPath()"); return NULL; @@ -326,9 +326,9 @@ static void MacOSXStartup(int argc, char *argv[]) { void CreateExecutionEnvironment(int *pargc, char ***pargv, - char jrepath[], jint so_jrepath, + char jdkroot[], jint so_jdkroot, char jvmpath[], jint so_jvmpath, - char jvmcfg[], jint so_jvmcfg) { + char jvmcfg[], jint so_jvmcfg) { /* Compute/set the name of the executable */ SetExecname(*pargv); @@ -336,13 +336,13 @@ static void MacOSXStartup(int argc, char *argv[]) { int argc = *pargc; char **argv = *pargv; - /* Find out where the JRE is that we will be using. */ - if (!GetJREPath(jrepath, so_jrepath, JNI_FALSE) ) { - JLI_ReportErrorMessage(JRE_ERROR1); + /* Find out where the JDK is that we will be using. */ + if (!GetJDKInstallRoot(jdkroot, so_jdkroot, JNI_FALSE) ) { + JLI_ReportErrorMessage(LAUNCHER_ERROR1); exit(2); } JLI_Snprintf(jvmcfg, so_jvmcfg, "%s%slib%sjvm.cfg", - jrepath, FILESEP, FILESEP); + jdkroot, FILESEP, FILESEP); /* Find the specified JVM type */ if (ReadKnownVMs(jvmcfg, JNI_FALSE) < 1) { JLI_ReportErrorMessage(CFG_ERROR7); @@ -356,7 +356,7 @@ static void MacOSXStartup(int argc, char *argv[]) { exit(4); } - if (!GetJVMPath(jrepath, jvmtype, jvmpath, so_jvmpath)) { + if (!GetJVMPath(jdkroot, jvmtype, jvmpath, so_jvmpath)) { JLI_ReportErrorMessage(CFG_ERROR8, jvmtype, jvmpath); exit(4); } @@ -378,7 +378,7 @@ static void MacOSXStartup(int argc, char *argv[]) { * VM choosing is done by the launcher (java.c). */ static jboolean -GetJVMPath(const char *jrepath, const char *jvmtype, +GetJVMPath(const char *jdkroot, const char *jvmtype, char *jvmpath, jint jvmpathsize) { struct stat s; @@ -390,7 +390,7 @@ static void MacOSXStartup(int argc, char *argv[]) { * macosx client library is built thin, i386 only. * 64 bit client requests must load server library */ - JLI_Snprintf(jvmpath, jvmpathsize, "%s/lib/%s/" JVM_DLL, jrepath, jvmtype); + JLI_Snprintf(jvmpath, jvmpathsize, "%s/lib/%s/" JVM_DLL, jdkroot, jvmtype); } JLI_TraceLauncher("Does `%s' exist ... ", jvmpath); @@ -408,15 +408,15 @@ static void MacOSXStartup(int argc, char *argv[]) { } /* - * Find path to JRE based on .exe's location or registry settings. + * Find path to the JDK installation root */ static jboolean -GetJREPath(char *path, jint pathsize, jboolean speculative) +GetJDKInstallRoot(char *path, jint pathsize, jboolean speculative) { char libjava[MAXPATHLEN]; if (GetApplicationHome(path, pathsize)) { - /* Is JRE co-located with the application? */ + /* Is the JDK co-located with the application? */ if (JLI_IsStaticallyLinked()) { char jvm_cfg[MAXPATHLEN]; JLI_Snprintf(jvm_cfg, sizeof(jvm_cfg), "%s/lib/jvm.cfg", path); @@ -445,7 +445,7 @@ static void MacOSXStartup(int argc, char *argv[]) { /* try to find ourselves instead */ Dl_info selfInfo; - dladdr(&GetJREPath, &selfInfo); + dladdr(&GetJDKInstallRoot, &selfInfo); if (JLI_IsStaticallyLinked()) { char jvm_cfg[MAXPATHLEN]; @@ -488,8 +488,8 @@ static void MacOSXStartup(int argc, char *argv[]) { return JNI_TRUE; } - // If libjli.dylib is loaded from a macos bundle MacOS dir, find the JRE dir - // in ../Home. + // If libjli.dylib is loaded from a macos bundle MacOS dir, find the JDK + // install root at ../Home. const char altLastPathComponent[] = "/MacOS/libjli.dylib"; size_t sizeOfAltLastPathComponent = sizeof(altLastPathComponent) - 1; if (pathLen < sizeOfLastPathComponent) { @@ -505,7 +505,7 @@ static void MacOSXStartup(int argc, char *argv[]) { } if (!speculative) - JLI_ReportErrorMessage(JRE_ERROR8 JAVA_DLL); + JLI_ReportErrorMessage(LAUNCHER_ERROR2 JAVA_DLL); return JNI_FALSE; } @@ -642,27 +642,27 @@ static void MacOSXStartup(int argc, char *argv[]) { void* SplashProcAddress(const char* name) { if (!hSplashLib) { - char jrePath[PATH_MAX]; - if (!GetJREPath(jrePath, sizeof(jrePath), JNI_FALSE)) { - JLI_ReportErrorMessage(JRE_ERROR1); + char jdkRoot[PATH_MAX]; + if (!GetJDKInstallRoot(jdkRoot, sizeof(jdkRoot), JNI_FALSE)) { + JLI_ReportErrorMessage(LAUNCHER_ERROR1); return NULL; } char splashPath[PATH_MAX]; const int ret = JLI_Snprintf(splashPath, sizeof(splashPath), - "%s/lib/%s", jrePath, SPLASHSCREEN_SO); + "%s/lib/%s", jdkRoot, SPLASHSCREEN_SO); if (ret >= (int)sizeof(splashPath)) { - JLI_ReportErrorMessage(JRE_ERROR11); + JLI_ReportErrorMessage(LAUNCHER_ERROR3); return NULL; } if (ret < 0) { - JLI_ReportErrorMessage(JRE_ERROR13); + JLI_ReportErrorMessage(LAUNCHER_ERROR5); return NULL; } hSplashLib = dlopen(splashPath, RTLD_LAZY | RTLD_GLOBAL); // It's OK if dlopen() fails. The splash screen library binary file - // might have been stripped out from the JRE image to reduce its size + // might have been stripped out from the JDK image to reduce its size // (e.g. on embedded platforms). if (hSplashLib) { diff --git a/src/java.base/share/classes/com/sun/crypto/provider/AESKeyWrap.java b/src/java.base/share/classes/com/sun/crypto/provider/AESKeyWrap.java index 7fad0b84d07..7ba4420f973 100644 --- a/src/java.base/share/classes/com/sun/crypto/provider/AESKeyWrap.java +++ b/src/java.base/share/classes/com/sun/crypto/provider/AESKeyWrap.java @@ -37,6 +37,9 @@ * * "Recommendation for Block Cipher Modes of Operation: Methods for Key Wrapping" * and represents AES cipher in KW mode. + * + * @spec https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-38F.pdf + * Recommendation for Block Cipher Modes of Operation: Methods for Key Wrapping */ class AESKeyWrap extends FeedbackCipher { diff --git a/src/java.base/share/classes/com/sun/crypto/provider/AESKeyWrapPadded.java b/src/java.base/share/classes/com/sun/crypto/provider/AESKeyWrapPadded.java index 1e4e7236c8c..4f25849d850 100644 --- a/src/java.base/share/classes/com/sun/crypto/provider/AESKeyWrapPadded.java +++ b/src/java.base/share/classes/com/sun/crypto/provider/AESKeyWrapPadded.java @@ -39,6 +39,9 @@ * * "Recommendation for Block Cipher Modes of Operation: Methods for Key Wrapping" * and represents AES cipher in KWP mode. + * + * @spec https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-38F.pdf + * Recommendation for Block Cipher Modes of Operation: Methods for Key Wrapping */ class AESKeyWrapPadded extends FeedbackCipher { diff --git a/src/java.base/share/classes/com/sun/crypto/provider/KWUtil.java b/src/java.base/share/classes/com/sun/crypto/provider/KWUtil.java index e5dc8920326..5dda6379d03 100644 --- a/src/java.base/share/classes/com/sun/crypto/provider/KWUtil.java +++ b/src/java.base/share/classes/com/sun/crypto/provider/KWUtil.java @@ -31,6 +31,9 @@ * This class acts as the base class for AES KeyWrap algorithms as defined * in * "Recommendation for Block Cipher Modes of Operation: Methods for Key Wrapping" + * + * @spec https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-38F.pdf + * Recommendation for Block Cipher Modes of Operation: Methods for Key Wrapping */ class KWUtil { diff --git a/src/java.base/share/classes/com/sun/crypto/provider/KeyWrapCipher.java b/src/java.base/share/classes/com/sun/crypto/provider/KeyWrapCipher.java index fb69a27c62d..ba2825fa36c 100644 --- a/src/java.base/share/classes/com/sun/crypto/provider/KeyWrapCipher.java +++ b/src/java.base/share/classes/com/sun/crypto/provider/KeyWrapCipher.java @@ -36,6 +36,9 @@ * This class is the impl class for AES KeyWrap algorithms as defined in * * "Recommendation for Block Cipher Modes of Operation: Methods for Key Wrapping" + * + * @spec https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-38F.pdf + * Recommendation for Block Cipher Modes of Operation: Methods for Key Wrapping */ abstract class KeyWrapCipher extends CipherSpi { diff --git a/src/java.base/share/classes/java/io/FileInputStream.java b/src/java.base/share/classes/java/io/FileInputStream.java index 180b2e416a9..4210a0f56b6 100644 --- a/src/java.base/share/classes/java/io/FileInputStream.java +++ b/src/java.base/share/classes/java/io/FileInputStream.java @@ -29,6 +29,7 @@ import java.util.Arrays; import jdk.internal.util.ArraysSupport; import jdk.internal.event.FileReadEvent; +import jdk.internal.vm.annotation.Stable; import sun.nio.ch.FileChannelImpl; /** @@ -81,6 +82,10 @@ public class FileInputStream extends InputStream private volatile boolean closed; + // This field indicates whether the file is a regular file as some + // operations need the current position which requires seeking + private @Stable Boolean isRegularFile; + /** * Creates a {@code FileInputStream} to read from an existing file * named by the path name {@code name}. @@ -331,6 +336,9 @@ public int read(byte[] b, int off, int len) throws IOException { @Override public byte[] readAllBytes() throws IOException { + if (!isRegularFile()) + return super.readAllBytes(); + long length = length(); long position = position(); long size = length - position; @@ -382,6 +390,9 @@ public byte[] readNBytes(int len) throws IOException { if (len == 0) return new byte[0]; + if (!isRegularFile()) + return super.readNBytes(len); + long length = length(); long position = position(); long size = length - position; @@ -418,7 +429,7 @@ public byte[] readNBytes(int len) throws IOException { @Override public long transferTo(OutputStream out) throws IOException { long transferred = 0L; - if (out instanceof FileOutputStream fos) { + if (out instanceof FileOutputStream fos && isRegularFile()) { FileChannel fc = getChannel(); long pos = fc.position(); transferred = fc.transferTo(pos, Long.MAX_VALUE, fos.getChannel()); @@ -471,7 +482,10 @@ private long position() throws IOException { */ @Override public long skip(long n) throws IOException { - return skip0(n); + if (isRegularFile()) + return skip0(n); + + return super.skip(n); } private native long skip0(long n) throws IOException; @@ -603,6 +617,18 @@ public FileChannel getChannel() { return fc; } + /** + * Determine whether the file is a regular file. + */ + private boolean isRegularFile() { + Boolean isRegularFile = this.isRegularFile; + if (isRegularFile == null) { + this.isRegularFile = isRegularFile = isRegularFile0(fd); + } + return isRegularFile; + } + private native boolean isRegularFile0(FileDescriptor fd); + private static native void initIDs(); static { diff --git a/src/java.base/share/classes/java/lang/Boolean.java b/src/java.base/share/classes/java/lang/Boolean.java index 38b830fc0cf..31507f60e37 100644 --- a/src/java.base/share/classes/java/lang/Boolean.java +++ b/src/java.base/share/classes/java/lang/Boolean.java @@ -78,8 +78,7 @@ public final class Boolean implements java.io.Serializable, * * @since 1.1 */ - @SuppressWarnings("unchecked") - public static final Class TYPE = (Class) Class.getPrimitiveClass("boolean"); + public static final Class TYPE = Class.getPrimitiveClass("boolean"); /** * The value of the Boolean. diff --git a/src/java.base/share/classes/java/lang/Byte.java b/src/java.base/share/classes/java/lang/Byte.java index 35a537a0903..5835f65366f 100644 --- a/src/java.base/share/classes/java/lang/Byte.java +++ b/src/java.base/share/classes/java/lang/Byte.java @@ -79,8 +79,7 @@ public final class Byte extends Number implements Comparable, Constable { * The {@code Class} instance representing the primitive type * {@code byte}. */ - @SuppressWarnings("unchecked") - public static final Class TYPE = (Class) Class.getPrimitiveClass("byte"); + public static final Class TYPE = Class.getPrimitiveClass("byte"); /** * Returns a new {@code String} object representing the @@ -118,7 +117,7 @@ private ByteCache() {} // Load and use the archived cache if it exists CDS.initializeFromArchive(ByteCache.class); - if (archivedCache == null || archivedCache.length != size) { + if (archivedCache == null) { Byte[] c = new Byte[size]; byte value = (byte)-128; for(int i = 0; i < size; i++) { @@ -127,6 +126,7 @@ private ByteCache() {} archivedCache = c; } cache = archivedCache; + assert cache.length == size; } } diff --git a/src/java.base/share/classes/java/lang/Character.java b/src/java.base/share/classes/java/lang/Character.java index 5844805c858..8368adf5403 100644 --- a/src/java.base/share/classes/java/lang/Character.java +++ b/src/java.base/share/classes/java/lang/Character.java @@ -232,8 +232,7 @@ class Character implements java.io.Serializable, Comparable, Constabl * * @since 1.1 */ - @SuppressWarnings("unchecked") - public static final Class TYPE = (Class) Class.getPrimitiveClass("char"); + public static final Class TYPE = Class.getPrimitiveClass("char"); /* * Normative general types @@ -8985,7 +8984,7 @@ private CharacterCache(){} // Load and use the archived cache if it exists CDS.initializeFromArchive(CharacterCache.class); - if (archivedCache == null || archivedCache.length != size) { + if (archivedCache == null) { Character[] c = new Character[size]; for (int i = 0; i < size; i++) { c[i] = new Character((char) i); @@ -8993,6 +8992,7 @@ private CharacterCache(){} archivedCache = c; } cache = archivedCache; + assert cache.length == size; } } diff --git a/src/java.base/share/classes/java/lang/Class.java b/src/java.base/share/classes/java/lang/Class.java index ec2aa4b78ea..e39a1e1529c 100644 --- a/src/java.base/share/classes/java/lang/Class.java +++ b/src/java.base/share/classes/java/lang/Class.java @@ -3537,10 +3537,10 @@ ProtectionDomain protectionDomain() { private native ProtectionDomain getProtectionDomain0(); /* - * Return the Virtual Machine's Class object for the named - * primitive type. + * Returns the Class object for the named primitive type. Type parameter T + * avoids redundant casts for trusted code. */ - static native Class getPrimitiveClass(String name); + static native Class getPrimitiveClass(String name); /* * Check if client is allowed to access members. If access is denied, diff --git a/src/java.base/share/classes/java/lang/Double.java b/src/java.base/share/classes/java/lang/Double.java index 7216e20d6c3..ed23f7d39c9 100644 --- a/src/java.base/share/classes/java/lang/Double.java +++ b/src/java.base/share/classes/java/lang/Double.java @@ -459,8 +459,7 @@ public final class Double extends Number * * @since 1.1 */ - @SuppressWarnings("unchecked") - public static final Class TYPE = (Class) Class.getPrimitiveClass("double"); + public static final Class TYPE = Class.getPrimitiveClass("double"); /** * Returns a string representation of the {@code double} diff --git a/src/java.base/share/classes/java/lang/Float.java b/src/java.base/share/classes/java/lang/Float.java index af076e9417b..821a05fa00a 100644 --- a/src/java.base/share/classes/java/lang/Float.java +++ b/src/java.base/share/classes/java/lang/Float.java @@ -175,8 +175,7 @@ public final class Float extends Number * * @since 1.1 */ - @SuppressWarnings("unchecked") - public static final Class TYPE = (Class) Class.getPrimitiveClass("float"); + public static final Class TYPE = Class.getPrimitiveClass("float"); /** * Returns a string representation of the {@code float} diff --git a/src/java.base/share/classes/java/lang/Integer.java b/src/java.base/share/classes/java/lang/Integer.java index 5f64c1b8660..e666e977c61 100644 --- a/src/java.base/share/classes/java/lang/Integer.java +++ b/src/java.base/share/classes/java/lang/Integer.java @@ -95,8 +95,7 @@ public final class Integer extends Number * * @since 1.1 */ - @SuppressWarnings("unchecked") - public static final Class TYPE = (Class) Class.getPrimitiveClass("int"); + public static final Class TYPE = Class.getPrimitiveClass("int"); /** * All possible chars for representing a number as a String @@ -961,7 +960,17 @@ private static final class IntegerCache { if (archivedCache == null || size > archivedCache.length) { Integer[] c = new Integer[size]; int j = low; - for(int i = 0; i < c.length; i++) { + // If archive has Integer cache, we must use all instances from it. + // Otherwise, the identity checks between archived Integers and + // runtime-cached Integers would fail. + int archivedSize = (archivedCache == null) ? 0 : archivedCache.length; + for (int i = 0; i < archivedSize; i++) { + c[i] = archivedCache[i]; + assert j == archivedCache[i]; + j++; + } + // Fill the rest of the cache. + for (int i = archivedSize; i < size; i++) { c[i] = new Integer(j++); } archivedCache = c; diff --git a/src/java.base/share/classes/java/lang/Long.java b/src/java.base/share/classes/java/lang/Long.java index 5f4c2b15d03..8c083b3ec84 100644 --- a/src/java.base/share/classes/java/lang/Long.java +++ b/src/java.base/share/classes/java/lang/Long.java @@ -95,8 +95,7 @@ public final class Long extends Number * * @since 1.1 */ - @SuppressWarnings("unchecked") - public static final Class TYPE = (Class) Class.getPrimitiveClass("long"); + public static final Class TYPE = Class.getPrimitiveClass("long"); /** * Returns a string representation of the first argument in the @@ -963,7 +962,7 @@ private LongCache() {} // Load and use the archived cache if it exists CDS.initializeFromArchive(LongCache.class); - if (archivedCache == null || archivedCache.length != size) { + if (archivedCache == null) { Long[] c = new Long[size]; long value = -128; for(int i = 0; i < size; i++) { @@ -972,6 +971,7 @@ private LongCache() {} archivedCache = c; } cache = archivedCache; + assert cache.length == size; } } diff --git a/src/java.base/share/classes/java/lang/Short.java b/src/java.base/share/classes/java/lang/Short.java index 914d9cc67db..57e88442b27 100644 --- a/src/java.base/share/classes/java/lang/Short.java +++ b/src/java.base/share/classes/java/lang/Short.java @@ -79,8 +79,7 @@ public final class Short extends Number implements Comparable, Constable * The {@code Class} instance representing the primitive type * {@code short}. */ - @SuppressWarnings("unchecked") - public static final Class TYPE = (Class) Class.getPrimitiveClass("short"); + public static final Class TYPE = Class.getPrimitiveClass("short"); /** * Returns a new {@code String} object representing the @@ -245,7 +244,7 @@ private ShortCache() {} // Load and use the archived cache if it exists CDS.initializeFromArchive(ShortCache.class); - if (archivedCache == null || archivedCache.length != size) { + if (archivedCache == null) { Short[] c = new Short[size]; short value = -128; for(int i = 0; i < size; i++) { @@ -254,6 +253,7 @@ private ShortCache() {} archivedCache = c; } cache = archivedCache; + assert cache.length == size; } } diff --git a/src/java.base/share/classes/java/lang/ThreadLocal.java b/src/java.base/share/classes/java/lang/ThreadLocal.java index 4c2eb08c125..8a9aa7998fd 100644 --- a/src/java.base/share/classes/java/lang/ThreadLocal.java +++ b/src/java.base/share/classes/java/lang/ThreadLocal.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -232,8 +232,8 @@ private T setInitialValue(Thread t) { if (this instanceof TerminatingThreadLocal ttl) { TerminatingThreadLocal.register(ttl); } - if (TRACE_VTHREAD_LOCALS) { - dumpStackIfVirtualThread(); + if (TRACE_VTHREAD_LOCALS && t == Thread.currentThread() && t.isVirtual()) { + printStackTrace(); } return value; } @@ -249,8 +249,8 @@ private T setInitialValue(Thread t) { */ public void set(T value) { set(Thread.currentThread(), value); - if (TRACE_VTHREAD_LOCALS) { - dumpStackIfVirtualThread(); + if (TRACE_VTHREAD_LOCALS && Thread.currentThread().isVirtual()) { + printStackTrace(); } } @@ -799,7 +799,6 @@ private void expungeStaleEntries() { } } - /** * Reads the value of the jdk.traceVirtualThreadLocals property to determine if * a stack trace should be printed when a virtual thread sets a thread local. @@ -811,30 +810,28 @@ private static boolean traceVirtualThreadLocals() { } /** - * Print a stack trace if the current thread is a virtual thread. + * Print the stack trace of the current thread, skipping the printStackTrace frame. + * A thread local is used to detect reentrancy as the printing may itself use + * thread locals. */ - static void dumpStackIfVirtualThread() { - if (Thread.currentThread() instanceof VirtualThread vthread) { + private void printStackTrace() { + Thread t = Thread.currentThread(); + ThreadLocalMap map = getMap(t); + if (map.getEntry(DUMPING_STACK) == null) { + map.set(DUMPING_STACK, true); try { - var stack = StackWalkerHolder.STACK_WALKER.walk(s -> + var stack = StackWalker.getInstance().walk(s -> s.skip(1) // skip caller .collect(Collectors.toList())); - - // switch to carrier thread to avoid recursive use of thread-locals - vthread.executeOnCarrierThread(() -> { - System.out.println(vthread); - for (StackWalker.StackFrame frame : stack) { - System.out.format(" %s%n", frame.toStackTraceElement()); - } - return null; - }); - } catch (Exception e) { - throw new InternalError(e); + System.out.println(t); + for (StackWalker.StackFrame frame : stack) { + System.out.format(" %s%n", frame.toStackTraceElement()); + } + } finally { + map.remove(DUMPING_STACK); } } } - private static class StackWalkerHolder { - static final StackWalker STACK_WALKER = StackWalker.getInstance(); - } + private static final ThreadLocal DUMPING_STACK = new ThreadLocal<>(); } diff --git a/src/java.base/share/classes/java/lang/VirtualThread.java b/src/java.base/share/classes/java/lang/VirtualThread.java index 6eb20fa9e2e..f76a6eec914 100644 --- a/src/java.base/share/classes/java/lang/VirtualThread.java +++ b/src/java.base/share/classes/java/lang/VirtualThread.java @@ -28,7 +28,6 @@ import java.security.PrivilegedAction; import java.util.Locale; import java.util.Objects; -import java.util.concurrent.Callable; import java.util.concurrent.CountDownLatch; import java.util.concurrent.Executor; import java.util.concurrent.Executors; @@ -56,6 +55,7 @@ import jdk.internal.vm.annotation.ChangesCurrentThread; import jdk.internal.vm.annotation.Hidden; import jdk.internal.vm.annotation.IntrinsicCandidate; +import jdk.internal.vm.annotation.JvmtiHideEvents; import jdk.internal.vm.annotation.JvmtiMountTransition; import jdk.internal.vm.annotation.ReservedStackAccess; import sun.nio.ch.Interruptible; @@ -136,13 +136,18 @@ final class VirtualThread extends BaseVirtualThread { // parking permit private volatile boolean parkPermit; + // timeout for timed-park, in nanoseconds, only accessed on current/carrier thread + private long parkTimeout; + + // timer task for timed-park, only accessed on current/carrier thread + private Future timeoutTask; + // carrier thread when mounted, accessed by VM private volatile Thread carrierThread; // termination object when joining, created lazily if needed private volatile CountDownLatch termination; - /** * Returns the default scheduler. */ @@ -213,8 +218,14 @@ protected void onPinned(Continuation.Pinned reason) { private static Runnable wrap(VirtualThread vthread, Runnable task) { return new Runnable() { @Hidden + @JvmtiHideEvents public void run() { - vthread.run(task); + vthread.notifyJvmtiStart(); // notify JVMTI + try { + vthread.run(task); + } finally { + vthread.notifyJvmtiEnd(); // notify JVMTI + } } }; } @@ -239,8 +250,10 @@ private void runContinuation() { if (!compareAndSetState(initialState, RUNNING)) { return; } - // consume parking permit when continuing after parking + // consume permit when continuing after parking. If continuing after a + // timed-park then the timeout task is cancelled. if (initialState == UNPARKED) { + cancelTimeoutTask(); setParkPermit(false); } } else { @@ -261,6 +274,17 @@ private void runContinuation() { } } + /** + * Cancel timeout task when continuing after a timed-park. The + * timeout task may be executing, or may have already completed. + */ + private void cancelTimeoutTask() { + if (timeoutTask != null) { + timeoutTask.cancel(false); + timeoutTask = null; + } + } + /** * Submits the runContinuation task to the scheduler. For the default scheduler, * and calling it on a worker thread, the task will be pushed to the local queue, @@ -269,23 +293,21 @@ private void runContinuation() { * @param retryOnOOME true to retry indefinitely if OutOfMemoryError is thrown * @throws RejectedExecutionException */ - @ChangesCurrentThread private void submitRunContinuation(Executor scheduler, boolean retryOnOOME) { boolean done = false; while (!done) { try { - // The scheduler's execute method is invoked in the context of the - // carrier thread. For the default scheduler this ensures that the - // current thread is a ForkJoinWorkerThread so the task will be pushed - // to the local queue. For other schedulers, it avoids deadlock that - // would arise due to platform and virtual threads contending for a - // lock on the scheduler's submission queue. - if (currentThread() instanceof VirtualThread vthread) { - vthread.switchToCarrierThread(); + // Pin the continuation to prevent the virtual thread from unmounting + // when submitting a task. For the default scheduler this ensures that + // the carrier doesn't change when pushing a task. For other schedulers + // it avoids deadlock that could arise due to carriers and virtual + // threads contending for a lock. + if (currentThread().isVirtual()) { + Continuation.pin(); try { scheduler.execute(runContinuation); } finally { - switchToVirtualThread(vthread); + Continuation.unpin(); } } else { scheduler.execute(runContinuation); @@ -304,24 +326,6 @@ private void submitRunContinuation(Executor scheduler, boolean retryOnOOME) { } } - /** - * Submits the runContinuation task to given scheduler with a lazy submit. - * If OutOfMemoryError is thrown then the submit will be retried until it succeeds. - * @throws RejectedExecutionException - * @see ForkJoinPool#lazySubmit(ForkJoinTask) - */ - private void lazySubmitRunContinuation(ForkJoinPool pool) { - assert Thread.currentThread() instanceof CarrierThread; - try { - pool.lazySubmit(ForkJoinTask.adapt(runContinuation)); - } catch (RejectedExecutionException ree) { - submitFailed(ree); - throw ree; - } catch (OutOfMemoryError e) { - submitRunContinuation(pool, true); - } - } - /** * Submits the runContinuation task to the given scheduler as an external submit. * If OutOfMemoryError is thrown then the submit will be retried until it succeeds. @@ -351,6 +355,30 @@ private void submitRunContinuation() { submitRunContinuation(scheduler, true); } + /** + * Lazy submit the runContinuation task if invoked on a carrier thread and its local + * queue is empty. If not empty, or invoked by another thread, then this method works + * like submitRunContinuation and just submits the task to the scheduler. + * If OutOfMemoryError is thrown then the submit will be retried until it succeeds. + * @throws RejectedExecutionException + * @see ForkJoinPool#lazySubmit(ForkJoinTask) + */ + private void lazySubmitRunContinuation() { + if (currentThread() instanceof CarrierThread ct && ct.getQueuedTaskCount() == 0) { + ForkJoinPool pool = ct.getPool(); + try { + pool.lazySubmit(ForkJoinTask.adapt(runContinuation)); + } catch (RejectedExecutionException ree) { + submitFailed(ree); + throw ree; + } catch (OutOfMemoryError e) { + submitRunContinuation(); + } + } else { + submitRunContinuation(); + } + } + /** * Submits the runContinuation task to the scheduler. For the default scheduler, and * calling it a virtual thread that uses the default scheduler, the task will be @@ -389,9 +417,6 @@ private void submitFailed(RejectedExecutionException ree) { private void run(Runnable task) { assert Thread.currentThread() == this && state == RUNNING; - // notify JVMTI, may post VirtualThreadStart event - notifyJvmtiStart(); - // emit JFR event if enabled if (VirtualThreadStartEvent.isTurnedOn()) { var event = new VirtualThreadStartEvent(); @@ -405,20 +430,14 @@ private void run(Runnable task) { } catch (Throwable exc) { dispatchUncaughtException(exc); } finally { - try { - // pop any remaining scopes from the stack, this may block - StackableScope.popAll(); - - // emit JFR event if enabled - if (VirtualThreadEndEvent.isTurnedOn()) { - var event = new VirtualThreadEndEvent(); - event.javaThreadId = threadId(); - event.commit(); - } + // pop any remaining scopes from the stack, this may block + StackableScope.popAll(); - } finally { - // notify JVMTI, may post VirtualThreadEnd event - notifyJvmtiEnd(); + // emit JFR event if enabled + if (VirtualThreadEndEvent.isTurnedOn()) { + var event = new VirtualThreadEndEvent(); + event.javaThreadId = threadId(); + event.commit(); } } } @@ -476,45 +495,6 @@ private void unmount() { notifyJvmtiUnmount(/*hide*/false); } - /** - * Sets the current thread to the current carrier thread. - */ - @ChangesCurrentThread - @JvmtiMountTransition - private void switchToCarrierThread() { - notifyJvmtiHideFrames(true); - Thread carrier = this.carrierThread; - assert Thread.currentThread() == this - && carrier == Thread.currentCarrierThread(); - carrier.setCurrentThread(carrier); - } - - /** - * Sets the current thread to the given virtual thread. - */ - @ChangesCurrentThread - @JvmtiMountTransition - private static void switchToVirtualThread(VirtualThread vthread) { - Thread carrier = vthread.carrierThread; - assert carrier == Thread.currentCarrierThread(); - carrier.setCurrentThread(vthread); - notifyJvmtiHideFrames(false); - } - - /** - * Executes the given value returning task on the current carrier thread. - */ - @ChangesCurrentThread - V executeOnCarrierThread(Callable task) throws Exception { - assert Thread.currentThread() == this; - switchToCarrierThread(); - try { - return task.call(); - } finally { - switchToVirtualThread(this); - } - } - /** * Invokes Continuation.yield, notifying JVMTI (if enabled) to hide frames until * the continuation continues. @@ -530,9 +510,8 @@ private boolean yieldContinuation() { } /** - * Invoked after the continuation yields. If parking then it sets the state - * and also re-submits the task to continue if unparked while parking. - * If yielding due to Thread.yield then it just submits the task to continue. + * Invoked in the context of the carrier thread after the Continuation yields when + * parking or Thread.yield. */ private void afterYield() { assert carrierThread == null; @@ -546,17 +525,20 @@ private void afterYield() { // LockSupport.park/parkNanos if (s == PARKING || s == TIMED_PARKING) { - int newState = (s == PARKING) ? PARKED : TIMED_PARKED; - setState(newState); + int newState; + if (s == PARKING) { + setState(newState = PARKED); + } else { + // schedule unpark + assert parkTimeout > 0; + timeoutTask = schedule(this::unpark, parkTimeout, NANOSECONDS); + setState(newState = TIMED_PARKED); + } // may have been unparked while parking if (parkPermit && compareAndSetState(newState, UNPARKED)) { - // lazy submit to continue on the current carrier if possible - if (currentThread() instanceof CarrierThread ct && ct.getQueuedTaskCount() == 0) { - lazySubmitRunContinuation(ct.getPool()); - } else { - submitRunContinuation(); - } + // lazy submit if local queue is empty + lazySubmitRunContinuation(); } return; } @@ -674,7 +656,9 @@ void park() { boolean yielded = false; setState(PARKING); try { - yielded = yieldContinuation(); // may throw + yielded = yieldContinuation(); + } catch (OutOfMemoryError e) { + // park on carrier } finally { assert (Thread.currentThread() == this) && (yielded == (state() == RUNNING)); if (!yielded) { @@ -709,21 +693,23 @@ void parkNanos(long nanos) { if (nanos > 0) { long startTime = System.nanoTime(); + // park the thread, afterYield will schedule the thread to unpark boolean yielded = false; - Future unparker = scheduleUnpark(nanos); // may throw OOME + setParkTimeout(nanos); setState(TIMED_PARKING); try { - yielded = yieldContinuation(); // may throw + yielded = yieldContinuation(); + } catch (OutOfMemoryError e) { + // park on carrier } finally { assert (Thread.currentThread() == this) && (yielded == (state() == RUNNING)); if (!yielded) { assert state() == TIMED_PARKING; setState(RUNNING); } - cancel(unparker); } - // park on carrier thread for remaining time when pinned + // park on carrier thread for remaining time when pinned (or OOME) if (!yielded) { long remainingNanos = nanos - (System.nanoTime() - startTime); parkOnCarrierThread(true, remainingNanos); @@ -774,38 +760,6 @@ private void parkOnCarrierThread(boolean timed, long nanos) { } } - /** - * Schedule this virtual thread to be unparked after a given delay. - */ - @ChangesCurrentThread - private Future scheduleUnpark(long nanos) { - assert Thread.currentThread() == this; - // need to switch to current carrier thread to avoid nested parking - switchToCarrierThread(); - try { - return schedule(this::unpark, nanos, NANOSECONDS); - } finally { - switchToVirtualThread(this); - } - } - - /** - * Cancels a task if it has not completed. - */ - @ChangesCurrentThread - private void cancel(Future future) { - assert Thread.currentThread() == this; - if (!future.isDone()) { - // need to switch to current carrier thread to avoid nested parking - switchToCarrierThread(); - try { - future.cancel(false); - } finally { - switchToVirtualThread(this); - } - } - } - /** * Re-enables this virtual thread for scheduling. If this virtual thread is parked * then its task is scheduled to continue, otherwise its next call to {@code park} or @@ -1043,10 +997,10 @@ Thread.State threadState() { return Thread.State.RUNNABLE; case PARKED: case PINNED: - return State.WAITING; + return Thread.State.WAITING; case TIMED_PARKED: case TIMED_PINNED: - return State.TIMED_WAITING; + return Thread.State.TIMED_WAITING; case TERMINATED: return Thread.State.TERMINATED; default: @@ -1265,6 +1219,10 @@ private boolean getAndSetParkPermit(boolean newValue) { } } + private void setParkTimeout(long timeout) { + parkTimeout = timeout; + } + private void setCarrierThread(Thread carrier) { // U.putReferenceRelease(this, CARRIER_THREAD, carrier); this.carrierThread = carrier; @@ -1288,10 +1246,6 @@ private void setCarrierThread(Thread carrier) { @JvmtiMountTransition private native void notifyJvmtiUnmount(boolean hide); - @IntrinsicCandidate - @JvmtiMountTransition - private static native void notifyJvmtiHideFrames(boolean hide); - @IntrinsicCandidate private static native void notifyJvmtiDisableSuspend(boolean enter); diff --git a/src/java.base/share/classes/java/lang/Void.java b/src/java.base/share/classes/java/lang/Void.java index 3ea0e79e61c..9a3adafec33 100644 --- a/src/java.base/share/classes/java/lang/Void.java +++ b/src/java.base/share/classes/java/lang/Void.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,8 +39,7 @@ class Void { * The {@code Class} object representing the pseudo-type corresponding to * the keyword {@code void}. */ - @SuppressWarnings("unchecked") - public static final Class TYPE = (Class) Class.getPrimitiveClass("void"); + public static final Class TYPE = Class.getPrimitiveClass("void"); /* * The Void class cannot be instantiated. diff --git a/src/java.base/share/classes/java/lang/reflect/ParameterizedType.java b/src/java.base/share/classes/java/lang/reflect/ParameterizedType.java index 99016623a3e..c78af9ef2ec 100644 --- a/src/java.base/share/classes/java/lang/reflect/ParameterizedType.java +++ b/src/java.base/share/classes/java/lang/reflect/ParameterizedType.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -66,11 +66,15 @@ public interface ParameterizedType extends Type { Type[] getActualTypeArguments(); /** - * Returns the {@code Type} object representing the class or interface - * that declared this type. + * {@return the {@code Type} object representing the class or interface + * that declared this type} + * + * @apiNote + * All {@code ParameterizedType} objects from core reflection return a + * {@link Class}. The static {@code Type} return type allows other + * implementations to represent classes and interfaces not in the current + * runtime. * - * @return the {@code Type} object representing the class or interface - * that declared this type * @since 1.5 */ Type getRawType(); diff --git a/src/java.base/share/classes/java/security/DrbgParameters.java b/src/java.base/share/classes/java/security/DrbgParameters.java index ecf8d50aab1..d979aba9531 100644 --- a/src/java.base/share/classes/java/security/DrbgParameters.java +++ b/src/java.base/share/classes/java/security/DrbgParameters.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -227,6 +227,9 @@ * Calling {@link SecureRandom#generateSeed(int)} will directly read * from this system default entropy source. * + * @spec https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-90Ar1.pdf + * Recommendation for Random Number Generation Using Deterministic Random Bit Generators + * * @since 9 */ public class DrbgParameters { diff --git a/src/java.base/share/classes/java/security/Key.java b/src/java.base/share/classes/java/security/Key.java index 4ba26bf1034..28c0098c064 100644 --- a/src/java.base/share/classes/java/security/Key.java +++ b/src/java.base/share/classes/java/security/Key.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -86,6 +86,10 @@ * Security Appendix * of the Java Object Serialization Specification for more information. * + * @spec serialization/index.html Java Object Serialization Specification + * @spec https://www.rfc-editor.org/info/rfc5280 + * RFC 5280: Internet X.509 Public Key Infrastructure Certificate + * and Certificate Revocation List (CRL) Profile * @see PublicKey * @see PrivateKey * @see KeyPair @@ -124,6 +128,7 @@ public interface Key extends java.io.Serializable { * Java Security Standard Algorithm Names Specification * for information about standard key algorithm names. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @return the name of the algorithm associated with this key. */ String getAlgorithm(); diff --git a/src/java.base/share/classes/java/security/KeyRep.java b/src/java.base/share/classes/java/security/KeyRep.java index 0a82bf82ae0..2a887750036 100644 --- a/src/java.base/share/classes/java/security/KeyRep.java +++ b/src/java.base/share/classes/java/security/KeyRep.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,6 +44,7 @@ * Security Appendix * of the Java Object Serialization Specification for more information. * + * @spec serialization/index.html Java Object Serialization Specification * @see Key * @see KeyFactory * @see javax.crypto.spec.SecretKeySpec diff --git a/src/java.base/share/classes/java/security/SecureRandom.java b/src/java.base/share/classes/java/security/SecureRandom.java index fac7f6b9383..734f25e6615 100644 --- a/src/java.base/share/classes/java/security/SecureRandom.java +++ b/src/java.base/share/classes/java/security/SecureRandom.java @@ -140,6 +140,11 @@ *

  • {@link SecureRandomSpi#engineReseed(SecureRandomParameters)} * * + * @spec https://www.rfc-editor.org/info/rfc4086 + * RFC 4086: Randomness Requirements for Security + * @spec https://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.140-2.pdf + * Security Requirements for Cryptographic Modules + * * @see java.security.SecureRandomSpi * @see java.util.Random * diff --git a/src/java.base/share/classes/java/security/Security.java b/src/java.base/share/classes/java/security/Security.java index 6628b717eb0..322605ef5ed 100644 --- a/src/java.base/share/classes/java/security/Security.java +++ b/src/java.base/share/classes/java/security/Security.java @@ -423,6 +423,7 @@ private static String getProviderProperty(String key, Provider provider) { * * @return the value of the specified property. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @deprecated This method used to return the value of a proprietary * property in the master file of the "SUN" Cryptographic Service * Provider in order to determine how to parse algorithm-specific @@ -657,6 +658,7 @@ public static Provider getProvider(String name) { * if the filter is not in the required format * @throws NullPointerException if filter is {@code null} * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @see #getProviders(java.util.Map) * @since 1.3 */ @@ -734,6 +736,7 @@ public static Provider[] getProviders(String filter) { * if the filter is not in the required format * @throws NullPointerException if filter is {@code null} * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @see #getProviders(java.lang.String) * @since 1.3 */ diff --git a/src/java.base/share/classes/java/security/cert/CRL.java b/src/java.base/share/classes/java/security/cert/CRL.java index fec267de051..fee08c3c2ed 100644 --- a/src/java.base/share/classes/java/security/cert/CRL.java +++ b/src/java.base/share/classes/java/security/cert/CRL.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -56,6 +56,8 @@ public abstract class CRL { * "{@docRoot}/../specs/security/standard-names.html"> * Java Security Standard Algorithm Names document * for information about standard CRL types. + * + * @spec security/standard-names.html Java Security Standard Algorithm Names */ protected CRL(String type) { this.type = type; diff --git a/src/java.base/share/classes/java/security/cert/CRLReason.java b/src/java.base/share/classes/java/security/cert/CRLReason.java index 2bc83f3356b..c2b19136c43 100644 --- a/src/java.base/share/classes/java/security/cert/CRLReason.java +++ b/src/java.base/share/classes/java/security/cert/CRLReason.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,6 +31,9 @@ * RFC 5280: Internet X.509 Public Key Infrastructure Certificate and CRL * Profile. * + * @spec https://www.rfc-editor.org/info/rfc5280 + * RFC 5280: Internet X.509 Public Key Infrastructure Certificate + * and Certificate Revocation List (CRL) Profile * @author Sean Mullan * @since 1.7 * @see X509CRLEntry#getRevocationReason diff --git a/src/java.base/share/classes/java/security/cert/PKIXRevocationChecker.java b/src/java.base/share/classes/java/security/cert/PKIXRevocationChecker.java index d36fcafd3e0..387b5ed8185 100644 --- a/src/java.base/share/classes/java/security/cert/PKIXRevocationChecker.java +++ b/src/java.base/share/classes/java/security/cert/PKIXRevocationChecker.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -81,14 +81,13 @@ * necessary locking. Multiple threads each manipulating separate objects * need not synchronize. * + * @spec https://www.rfc-editor.org/info/rfc2560 + * RFC 2560: X.509 Internet Public Key Infrastructure Online Certificate + * Status Protocol - OCSP + * @spec https://www.rfc-editor.org/info/rfc5280 + * RFC 5280: Internet X.509 Public Key Infrastructure Certificate + * and Certificate Revocation List (CRL) Profile * @since 1.8 - * - * @see RFC 2560: X.509 - * Internet Public Key Infrastructure Online Certificate Status Protocol - - * OCSP - * @see RFC 5280: - * Internet X.509 Public Key Infrastructure Certificate and Certificate - * Revocation List (CRL) Profile */ public abstract class PKIXRevocationChecker extends PKIXCertPathChecker { private URI ocspResponder; diff --git a/src/java.base/share/classes/java/security/cert/TrustAnchor.java b/src/java.base/share/classes/java/security/cert/TrustAnchor.java index 2626bcf3c2d..33d1e5fb433 100644 --- a/src/java.base/share/classes/java/security/cert/TrustAnchor.java +++ b/src/java.base/share/classes/java/security/cert/TrustAnchor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -125,6 +125,10 @@ public class TrustAnchor { * decoded * @throws NullPointerException if the specified * {@code X509Certificate} is {@code null} + * + * @spec https://www.rfc-editor.org/info/rfc5280 + * RFC 5280: Internet X.509 Public Key Infrastructure Certificate + * and Certificate Revocation List (CRL) Profile */ public TrustAnchor(X509Certificate trustedCert, byte[] nameConstraints) { @@ -207,6 +211,10 @@ public TrustAnchor(X500Principal caPrincipal, PublicKey pubKey, * or incorrectly formatted or the name constraints cannot be decoded * @throws NullPointerException if the specified {@code caName} or * {@code pubKey} parameter is {@code null} + * + * @spec https://www.rfc-editor.org/info/rfc2253 + * RFC 2253: Lightweight Directory Access Protocol (v3): + * UTF-8 String Representation of Distinguished Names */ public TrustAnchor(String caName, PublicKey pubKey, byte[] nameConstraints) { diff --git a/src/java.base/share/classes/java/security/cert/X509CRL.java b/src/java.base/share/classes/java/security/cert/X509CRL.java index ddb622af1fe..111de1daf0e 100644 --- a/src/java.base/share/classes/java/security/cert/X509CRL.java +++ b/src/java.base/share/classes/java/security/cert/X509CRL.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -95,6 +95,9 @@ * } * } * + * @spec https://www.rfc-editor.org/info/rfc5280 + * RFC 5280: Internet X.509 Public Key Infrastructure Certificate + * and Certificate Revocation List (CRL) Profile * @author Hemma Prafullchandra * @since 1.2 * @@ -457,6 +460,11 @@ public X509CRLEntry getRevokedCertificate(X509Certificate certificate) { * relevant ASN.1 definitions. * * @return the signature algorithm OID string. + * + * @spec https://www.rfc-editor.org/info/rfc3279 + * RFC 3279: Algorithms and Identifiers for the Internet X.509 + * Public Key Infrastructure Certificate and Certificate + * Revocation List (CRL) Profile */ public abstract String getSigAlgOID(); diff --git a/src/java.base/share/classes/java/security/cert/X509CRLSelector.java b/src/java.base/share/classes/java/security/cert/X509CRLSelector.java index 337dcc6342d..5660749884a 100644 --- a/src/java.base/share/classes/java/security/cert/X509CRLSelector.java +++ b/src/java.base/share/classes/java/security/cert/X509CRLSelector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -65,6 +65,9 @@ * provide the necessary locking. Multiple threads each manipulating * separate objects need not synchronize. * + * @spec https://www.rfc-editor.org/info/rfc5280 + * RFC 5280: Internet X.509 Public Key Infrastructure Certificate + * and Certificate Revocation List (CRL) Profile * @see CRLSelector * @see X509CRL * @@ -193,6 +196,10 @@ public void setIssuers(Collection issuers) { * * @param names a {@code Collection} of names (or {@code null}) * @throws IOException if a parsing error occurs + * + * @spec https://www.rfc-editor.org/info/rfc2253 + * RFC 2253: Lightweight Directory Access Protocol (v3): + * UTF-8 String Representation of Distinguished Names * @see #getIssuerNames */ public void setIssuerNames(Collection names) throws IOException { @@ -238,6 +245,9 @@ public void addIssuer(X500Principal issuer) { * RFC 2253 form * @throws IOException if a parsing error occurs * + * @spec https://www.rfc-editor.org/info/rfc2253 + * RFC 2253: Lightweight Directory Access Protocol (v3): + * UTF-8 String Representation of Distinguished Names * @deprecated Use {@link #addIssuer(X500Principal)} or * {@link #addIssuerName(byte[])} instead. This method should not be * relied on as it can fail to match some CRLs because of a loss of @@ -493,6 +503,10 @@ public Collection getIssuers() { * protect against subsequent modifications. * * @return a {@code Collection} of names (or {@code null}) + * + * @spec https://www.rfc-editor.org/info/rfc2253 + * RFC 2253: Lightweight Directory Access Protocol (v3): + * UTF-8 String Representation of Distinguished Names * @see #setIssuerNames */ public Collection getIssuerNames() { diff --git a/src/java.base/share/classes/java/security/cert/X509CertSelector.java b/src/java.base/share/classes/java/security/cert/X509CertSelector.java index 42f036b8518..7860fd528d5 100644 --- a/src/java.base/share/classes/java/security/cert/X509CertSelector.java +++ b/src/java.base/share/classes/java/security/cert/X509CertSelector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -74,6 +74,9 @@ * provide the necessary locking. Multiple threads each manipulating * separate objects need not synchronize. * + * @spec https://www.rfc-editor.org/info/rfc5280 + * RFC 5280: Internet X.509 Public Key Infrastructure Certificate + * and Certificate Revocation List (CRL) Profile * @see CertSelector * @see X509Certificate * @@ -194,6 +197,9 @@ public void setIssuer(X500Principal issuer) { * (or {@code null}) * @throws IOException if a parsing error occurs (incorrect form for DN) * + * @spec https://www.rfc-editor.org/info/rfc2253 + * RFC 2253: Lightweight Directory Access Protocol (v3): + * UTF-8 String Representation of Distinguished Names * @deprecated Use {@link #setIssuer(X500Principal)} or * {@link #setIssuer(byte[])} instead. This method should not be relied on * as it can fail to match some certificates because of a loss of encoding @@ -286,6 +292,9 @@ public void setSubject(X500Principal subject) { * (or {@code null}) * @throws IOException if a parsing error occurs (incorrect form for DN) * + * @spec https://www.rfc-editor.org/info/rfc2253 + * RFC 2253: Lightweight Directory Access Protocol (v3): + * UTF-8 String Representation of Distinguished Names * @deprecated Use {@link #setSubject(X500Principal)} or * {@link #setSubject(byte[])} instead. This method should not be relied * on as it can fail to match some certificates because of a loss of @@ -728,6 +737,12 @@ public void setSubjectAlternativeNames(Collection> names) * RFC 5280, section 4.2.1.6) * @param name the name in string form (not {@code null}) * @throws IOException if a parsing error occurs + * + * @spec https://www.rfc-editor.org/info/rfc2253 + * RFC 2253: Lightweight Directory Access Protocol (v3): + * UTF-8 String Representation of Distinguished Names + * @spec https://www.rfc-editor.org/info/rfc822 + * RFC 822: STANDARD FOR THE FORMAT OF ARPA INTERNET TEXT MESSAGES */ public void addSubjectAlternativeName(int type, String name) throws IOException { @@ -1269,6 +1284,9 @@ public X500Principal getIssuer() { * @return the required issuer distinguished name in RFC 2253 format * (or {@code null}) * + * @spec https://www.rfc-editor.org/info/rfc2253 + * RFC 2253: Lightweight Directory Access Protocol (v3): + * UTF-8 String Representation of Distinguished Names * @deprecated Use {@link #getIssuer()} or {@link #getIssuerAsBytes()} * instead. This method should not be relied on as it can fail to match * some certificates because of a loss of encoding information in the @@ -1328,6 +1346,9 @@ public X500Principal getSubject() { * @return the required subject distinguished name in RFC 2253 format * (or {@code null}) * + * @spec https://www.rfc-editor.org/info/rfc2253 + * RFC 2253: Lightweight Directory Access Protocol (v3): + * UTF-8 String Representation of Distinguished Names * @deprecated Use {@link #getSubject()} or {@link #getSubjectAsBytes()} * instead. This method should not be relied on as it can fail to match * some certificates because of a loss of encoding information in the diff --git a/src/java.base/share/classes/java/security/cert/X509Certificate.java b/src/java.base/share/classes/java/security/cert/X509Certificate.java index 22f2423145d..79f37a82d47 100644 --- a/src/java.base/share/classes/java/security/cert/X509Certificate.java +++ b/src/java.base/share/classes/java/security/cert/X509Certificate.java @@ -95,6 +95,9 @@ * } * * + * @spec https://www.rfc-editor.org/info/rfc5280 + * RFC 5280: Internet X.509 Public Key Infrastructure Certificate + * and Certificate Revocation List (CRL) Profile * @author Hemma Prafullchandra * @since 1.2 * @@ -386,6 +389,11 @@ public abstract byte[] getTBSCertificate() * relevant ASN.1 definitions. * * @return the signature algorithm OID string. + * + * @spec https://www.rfc-editor.org/info/rfc3279 + * RFC 3279: Algorithms and Identifiers for the Internet X.509 + * Public Key Infrastructure Certificate and Certificate + * Revocation List (CRL) Profile */ public abstract String getSigAlgOID(); @@ -614,6 +622,12 @@ public List getExtendedKeyUsage() throws CertificateParsingException { * @return an immutable {@code Collection} of subject alternative * names (or {@code null}) * @throws CertificateParsingException if the extension cannot be decoded + * + * @spec https://www.rfc-editor.org/info/rfc2253 + * RFC 2253: Lightweight Directory Access Protocol (v3): + * UTF-8 String Representation of Distinguished Names + * @spec https://www.rfc-editor.org/info/rfc822 + * RFC 822: STANDARD FOR THE FORMAT OF ARPA INTERNET TEXT MESSAGES * @since 1.4 */ public Collection> getSubjectAlternativeNames() diff --git a/src/java.base/share/classes/java/security/cert/package-info.java b/src/java.base/share/classes/java/security/cert/package-info.java index 0a5f0b7b532..e0c5b76cfd8 100644 --- a/src/java.base/share/classes/java/security/cert/package-info.java +++ b/src/java.base/share/classes/java/security/cert/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -52,6 +52,13 @@ *
  • {@extLink security_guide_pki Java PKI Programmer's Guide} * * + * @spec security/standard-names.html Java Security Standard Algorithm Names + * @spec https://www.rfc-editor.org/info/rfc2560 + * RFC 2560: X.509 Internet Public Key Infrastructure Online Certificate + * Status Protocol - OCSP + * @spec https://www.rfc-editor.org/info/rfc5280 + * RFC 5280: Internet X.509 Public Key Infrastructure Certificate + * and Certificate Revocation List (CRL) Profile * @since 1.2 */ package java.security.cert; diff --git a/src/java.base/share/classes/java/security/interfaces/EdECKey.java b/src/java.base/share/classes/java/security/interfaces/EdECKey.java index bec29eeed8e..ae00dd0678d 100644 --- a/src/java.base/share/classes/java/security/interfaces/EdECKey.java +++ b/src/java.base/share/classes/java/security/interfaces/EdECKey.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,6 +35,8 @@ * This interface allows access to the algorithm parameters associated with * the key. * + * @spec https://www.rfc-editor.org/info/rfc8032 + * RFC 8032: Edwards-Curve Digital Signature Algorithm (EdDSA) * @since 15 */ public interface EdECKey { diff --git a/src/java.base/share/classes/java/security/interfaces/EdECPrivateKey.java b/src/java.base/share/classes/java/security/interfaces/EdECPrivateKey.java index 2a1b194a90a..df193891ce1 100644 --- a/src/java.base/share/classes/java/security/interfaces/EdECPrivateKey.java +++ b/src/java.base/share/classes/java/security/interfaces/EdECPrivateKey.java @@ -40,6 +40,8 @@ * string lengths that are a multiple of 8, and the key is represented using * a byte array. * + * @spec https://www.rfc-editor.org/info/rfc8032 + * RFC 8032: Edwards-Curve Digital Signature Algorithm (EdDSA) * @since 15 */ public interface EdECPrivateKey extends EdECKey, PrivateKey { diff --git a/src/java.base/share/classes/java/security/interfaces/EdECPublicKey.java b/src/java.base/share/classes/java/security/interfaces/EdECPublicKey.java index f5a0f3c3194..5f3462164ef 100644 --- a/src/java.base/share/classes/java/security/interfaces/EdECPublicKey.java +++ b/src/java.base/share/classes/java/security/interfaces/EdECPublicKey.java @@ -38,6 +38,8 @@ * An Edwards-Curve public key is a point on the curve, which is represented using an * EdECPoint. * + * @spec https://www.rfc-editor.org/info/rfc8032 + * RFC 8032: Edwards-Curve Digital Signature Algorithm (EdDSA) * @since 15 */ public interface EdECPublicKey extends EdECKey, PublicKey { diff --git a/src/java.base/share/classes/java/security/interfaces/RSAKey.java b/src/java.base/share/classes/java/security/interfaces/RSAKey.java index f28a76869db..1d023e58ebb 100644 --- a/src/java.base/share/classes/java/security/interfaces/RSAKey.java +++ b/src/java.base/share/classes/java/security/interfaces/RSAKey.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,6 +33,8 @@ * PKCS#1 v2.2 standard, * such as those for RSA, or RSASSA-PSS algorithms. * + * @spec https://www.rfc-editor.org/info/rfc8017 + * RFC 8017: PKCS #1: RSA Cryptography Specifications Version 2.2 * @author Jan Luehe * * @see RSAPublicKey diff --git a/src/java.base/share/classes/java/security/interfaces/RSAMultiPrimePrivateCrtKey.java b/src/java.base/share/classes/java/security/interfaces/RSAMultiPrimePrivateCrtKey.java index 079130e5fb5..a523d36ac70 100644 --- a/src/java.base/share/classes/java/security/interfaces/RSAMultiPrimePrivateCrtKey.java +++ b/src/java.base/share/classes/java/security/interfaces/RSAMultiPrimePrivateCrtKey.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,6 +33,8 @@ * PKCS#1 v2.2 standard, * using the Chinese Remainder Theorem (CRT) information values. * + * @spec https://www.rfc-editor.org/info/rfc8017 + * RFC 8017: PKCS #1: RSA Cryptography Specifications Version 2.2 * @author Valerie Peng * * diff --git a/src/java.base/share/classes/java/security/interfaces/RSAPrivateCrtKey.java b/src/java.base/share/classes/java/security/interfaces/RSAPrivateCrtKey.java index 1b2bed7f9c1..7a8bea29e7e 100644 --- a/src/java.base/share/classes/java/security/interfaces/RSAPrivateCrtKey.java +++ b/src/java.base/share/classes/java/security/interfaces/RSAPrivateCrtKey.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,6 +32,8 @@ * PKCS#1 v2.2 standard, * using the Chinese Remainder Theorem (CRT) information values. * + * @spec https://www.rfc-editor.org/info/rfc8017 + * RFC 8017: PKCS #1: RSA Cryptography Specifications Version 2.2 * @author Jan Luehe * @since 1.2 * diff --git a/src/java.base/share/classes/java/security/package-info.java b/src/java.base/share/classes/java/security/package-info.java index ecbf629cbd9..349a895922f 100644 --- a/src/java.base/share/classes/java/security/package-info.java +++ b/src/java.base/share/classes/java/security/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -79,6 +79,7 @@ * * * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @since 1.1 */ package java.security; diff --git a/src/java.base/share/classes/java/security/spec/DSAGenParameterSpec.java b/src/java.base/share/classes/java/security/spec/DSAGenParameterSpec.java index b51f1f54904..3292d6b2bf7 100644 --- a/src/java.base/share/classes/java/security/spec/DSAGenParameterSpec.java +++ b/src/java.base/share/classes/java/security/spec/DSAGenParameterSpec.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,6 +29,9 @@ * generating DSA parameters as specified in * FIPS 186-3 Digital Signature Standard (DSS). * + * @spec https://csrc.nist.gov/publications/fips/fips186-3/fips_186-3.pdf + * FIPS 186-3 Digital Signature Standard (DSS) + * * @see AlgorithmParameterSpec * * @since 1.8 diff --git a/src/java.base/share/classes/java/security/spec/EdDSAParameterSpec.java b/src/java.base/share/classes/java/security/spec/EdDSAParameterSpec.java index 673e9377b14..df81d4d94d3 100644 --- a/src/java.base/share/classes/java/security/spec/EdDSAParameterSpec.java +++ b/src/java.base/share/classes/java/security/spec/EdDSAParameterSpec.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,6 +41,8 @@ *
  • Otherwise, the mode is Ed25519 or Ed448
  • * * + * @spec https://www.rfc-editor.org/info/rfc8032 + * RFC 8032: Edwards-Curve Digital Signature Algorithm (EdDSA) * @since 15 */ diff --git a/src/java.base/share/classes/java/security/spec/EdECPoint.java b/src/java.base/share/classes/java/security/spec/EdECPoint.java index cb080f8557d..81fd9bc5543 100644 --- a/src/java.base/share/classes/java/security/spec/EdECPoint.java +++ b/src/java.base/share/classes/java/security/spec/EdECPoint.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,6 +42,8 @@ * {@code BigInteger}, and implementations that consume objects of this class * may reject integer values which are not in the range [0, p). * + * @spec https://www.rfc-editor.org/info/rfc8032 + * RFC 8032: Edwards-Curve Digital Signature Algorithm (EdDSA) * @since 15 */ diff --git a/src/java.base/share/classes/java/security/spec/EdECPrivateKeySpec.java b/src/java.base/share/classes/java/security/spec/EdECPrivateKeySpec.java index 370dfc92e59..74f453aac08 100644 --- a/src/java.base/share/classes/java/security/spec/EdECPrivateKeySpec.java +++ b/src/java.base/share/classes/java/security/spec/EdECPrivateKeySpec.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,6 +34,8 @@ * a byte array. This class only supports bit string lengths that are a * multiple of 8. * + * @spec https://www.rfc-editor.org/info/rfc8032 + * RFC 8032: Edwards-Curve Digital Signature Algorithm (EdDSA) * @since 15 */ public final class EdECPrivateKeySpec implements KeySpec { diff --git a/src/java.base/share/classes/java/security/spec/EdECPublicKeySpec.java b/src/java.base/share/classes/java/security/spec/EdECPublicKeySpec.java index fc52b3b7968..f884983acf6 100644 --- a/src/java.base/share/classes/java/security/spec/EdECPublicKeySpec.java +++ b/src/java.base/share/classes/java/security/spec/EdECPublicKeySpec.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,6 +33,8 @@ * algorithm parameters. The public key is a point on the curve, which is * represented using an {@code EdECPoint}. * + * @spec https://www.rfc-editor.org/info/rfc8032 + * RFC 8032: Edwards-Curve Digital Signature Algorithm (EdDSA) * @since 15 */ public final class EdECPublicKeySpec implements KeySpec { diff --git a/src/java.base/share/classes/java/security/spec/MGF1ParameterSpec.java b/src/java.base/share/classes/java/security/spec/MGF1ParameterSpec.java index 64e88015015..2a26adb7e4e 100644 --- a/src/java.base/share/classes/java/security/spec/MGF1ParameterSpec.java +++ b/src/java.base/share/classes/java/security/spec/MGF1ParameterSpec.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -55,6 +55,8 @@ * ... -- Allows for future expansion -- * } * + * @spec https://www.rfc-editor.org/info/rfc8017 + * RFC 8017: PKCS #1: RSA Cryptography Specifications Version 2.2 * @see PSSParameterSpec * @see javax.crypto.spec.OAEPParameterSpec * diff --git a/src/java.base/share/classes/java/security/spec/PSSParameterSpec.java b/src/java.base/share/classes/java/security/spec/PSSParameterSpec.java index 5c77089f1ca..a05ce1b4b7a 100644 --- a/src/java.base/share/classes/java/security/spec/PSSParameterSpec.java +++ b/src/java.base/share/classes/java/security/spec/PSSParameterSpec.java @@ -65,6 +65,8 @@ * } * * + * @spec https://www.rfc-editor.org/info/rfc8017 + * RFC 8017: PKCS #1: RSA Cryptography Specifications Version 2.2 * @see MGF1ParameterSpec * @see AlgorithmParameterSpec * @see java.security.Signature @@ -96,6 +98,8 @@ public class PSSParameterSpec implements AlgorithmParameterSpec { /** * The PSS parameter set with all default values. + * @spec https://www.rfc-editor.org/info/rfc8017 + * RFC 8017: PKCS #1: RSA Cryptography Specifications Version 2.2 * @deprecated This field uses the default values defined in the PKCS #1 * standard. Some of these defaults are no longer recommended due * to advances in cryptanalysis -- see the @@ -170,6 +174,8 @@ public PSSParameterSpec(String mdName, String mgfName, * @param saltLen the length of salt in bytes * @throws IllegalArgumentException if {@code saltLen} is * less than 0 + * @spec https://www.rfc-editor.org/info/rfc8017 + * RFC 8017: PKCS #1: RSA Cryptography Specifications Version 2.2 * @deprecated This constructor uses the default values defined in * the PKCS #1 standard except for the salt length. Some of these * defaults are no longer recommended due to advances in diff --git a/src/java.base/share/classes/java/security/spec/RSAMultiPrimePrivateCrtKeySpec.java b/src/java.base/share/classes/java/security/spec/RSAMultiPrimePrivateCrtKeySpec.java index cdb55b97418..a3a08739a9b 100644 --- a/src/java.base/share/classes/java/security/spec/RSAMultiPrimePrivateCrtKeySpec.java +++ b/src/java.base/share/classes/java/security/spec/RSAMultiPrimePrivateCrtKeySpec.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,6 +34,8 @@ * using the Chinese Remainder Theorem (CRT) information values * for efficiency. * + * @spec https://www.rfc-editor.org/info/rfc8017 + * RFC 8017: PKCS #1: RSA Cryptography Specifications Version 2.2 * @author Valerie Peng * * diff --git a/src/java.base/share/classes/java/security/spec/RSAOtherPrimeInfo.java b/src/java.base/share/classes/java/security/spec/RSAOtherPrimeInfo.java index b434075c683..140c44e309e 100644 --- a/src/java.base/share/classes/java/security/spec/RSAOtherPrimeInfo.java +++ b/src/java.base/share/classes/java/security/spec/RSAOtherPrimeInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,6 +42,8 @@ * * * + * @spec https://www.rfc-editor.org/info/rfc8017 + * RFC 8017: PKCS #1: RSA Cryptography Specifications Version 2.2 * @author Valerie Peng * * diff --git a/src/java.base/share/classes/java/security/spec/RSAPrivateCrtKeySpec.java b/src/java.base/share/classes/java/security/spec/RSAPrivateCrtKeySpec.java index c8bed964b0e..70639cf7867 100644 --- a/src/java.base/share/classes/java/security/spec/RSAPrivateCrtKeySpec.java +++ b/src/java.base/share/classes/java/security/spec/RSAPrivateCrtKeySpec.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,6 +32,8 @@ * PKCS#1 v2.2 standard, * using the Chinese Remainder Theorem (CRT) information values for efficiency. * + * @spec https://www.rfc-editor.org/info/rfc8017 + * RFC 8017: PKCS #1: RSA Cryptography Specifications Version 2.2 * @author Jan Luehe * @since 1.2 * diff --git a/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java b/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java index cb061813c8a..13ab965c530 100644 --- a/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java +++ b/src/java.base/share/classes/java/util/concurrent/ForkJoinPool.java @@ -51,6 +51,7 @@ import java.util.function.Predicate; import java.util.concurrent.CountDownLatch; import java.util.concurrent.locks.LockSupport; +import jdk.internal.access.JavaLangAccess; import jdk.internal.access.JavaUtilConcurrentFJPAccess; import jdk.internal.access.SharedSecrets; import jdk.internal.misc.Unsafe; @@ -2632,7 +2633,7 @@ else if ((runState & SHUTDOWN) != 0L) { private void poolSubmit(boolean signalIfEmpty, ForkJoinTask task) { Thread t; ForkJoinWorkerThread wt; WorkQueue q; boolean internal; - if (((t = Thread.currentThread()) instanceof ForkJoinWorkerThread) && + if (((t = JLA.currentCarrierThread()) instanceof ForkJoinWorkerThread) && (wt = (ForkJoinWorkerThread)t).pool == this) { internal = true; q = wt.workQueue; @@ -2643,6 +2644,7 @@ private void poolSubmit(boolean signalIfEmpty, ForkJoinTask task) { } q.push(task, signalIfEmpty ? this : null, internal); } + private static final JavaLangAccess JLA = SharedSecrets.getJavaLangAccess(); /** * Returns queue for an external submission, bypassing call to diff --git a/src/java.base/share/classes/java/util/jar/JarFile.java b/src/java.base/share/classes/java/util/jar/JarFile.java index 3dc3a49dc77..3a1f412e9c7 100644 --- a/src/java.base/share/classes/java/util/jar/JarFile.java +++ b/src/java.base/share/classes/java/util/jar/JarFile.java @@ -40,6 +40,7 @@ import java.lang.ref.SoftReference; import java.security.CodeSigner; import java.security.cert.Certificate; +import java.util.BitSet; import java.util.Enumeration; import java.util.List; import java.util.Objects; @@ -597,26 +598,16 @@ private String getBasename(String name) { } private JarEntry getVersionedEntry(String name, JarEntry defaultEntry) { - if (!name.startsWith(META_INF)) { - int[] versions = JUZFA.getMetaInfVersions(this); - if (BASE_VERSION_FEATURE < versionFeature && versions.length > 0) { - // search for versioned entry - for (int i = versions.length - 1; i >= 0; i--) { - int version = versions[i]; - // skip versions above versionFeature - if (version > versionFeature) { - continue; - } - // skip versions below base version - if (version < BASE_VERSION_FEATURE) { - break; - } - JarFileEntry vje = (JarFileEntry)super.getEntry( - META_INF_VERSIONS + version + "/" + name); - if (vje != null) { - return vje.withBasename(name); - } + if (BASE_VERSION_FEATURE < versionFeature && !name.startsWith(META_INF)) { + BitSet versions = JUZFA.getMetaInfVersions(this, name); + int version = versions.previousSetBit(versionFeature); + while (version >= BASE_VERSION_FEATURE) { + JarFileEntry vje = (JarFileEntry)super.getEntry( + META_INF_VERSIONS + version + "/" + name); + if (vje != null) { + return vje.withBasename(name); } + version = versions.previousSetBit(version - 1); } } return defaultEntry; diff --git a/src/java.base/share/classes/java/util/zip/ZipFile.java b/src/java.base/share/classes/java/util/zip/ZipFile.java index 21b9593c017..3883e245db3 100644 --- a/src/java.base/share/classes/java/util/zip/ZipFile.java +++ b/src/java.base/share/classes/java/util/zip/ZipFile.java @@ -37,23 +37,7 @@ import java.nio.file.InvalidPathException; import java.nio.file.attribute.BasicFileAttributes; import java.nio.file.Files; -import java.util.ArrayDeque; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.Deque; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Locale; -import java.util.Objects; -import java.util.NoSuchElementException; -import java.util.Set; -import java.util.Spliterator; -import java.util.Spliterators; -import java.util.TreeSet; -import java.util.WeakHashMap; +import java.util.*; import java.util.function.Consumer; import java.util.function.IntFunction; import java.util.jar.JarEntry; @@ -64,6 +48,7 @@ import jdk.internal.access.JavaUtilJarAccess; import jdk.internal.access.SharedSecrets; import jdk.internal.util.ArraysSupport; +import jdk.internal.util.DecimalDigits; import jdk.internal.util.OperatingSystem; import jdk.internal.perf.PerfCounter; import jdk.internal.ref.CleanerFactory; @@ -1090,19 +1075,23 @@ private String getManifestName(boolean onlyIfSignatureRelatedFiles) { } /** - * Returns the versions for which there exists a non-directory - * entry that begin with "META-INF/versions/" (case ignored). + * Returns a BitSet where the set bits represents versions found for + * the given entry name. For performance reasons, the name is looked + * up only by hashcode, meaning the result is an over-approximation. * This method is used in JarFile, via SharedSecrets, as an * optimization when looking up potentially versioned entries. - * Returns an empty array if no versioned entries exist. + * Returns an empty BitSet if no versioned entries exist for this + * name. */ - private int[] getMetaInfVersions() { + private BitSet getMetaInfVersions(String name) { synchronized (this) { ensureOpen(); - return res.zsrc.metaVersions; + return res.zsrc.metaVersions.getOrDefault(ZipCoder.hash(name), EMPTY_VERSIONS); } } + private static final BitSet EMPTY_VERSIONS = new BitSet(); + /** * Returns the value of the System property which indicates whether the * Extra ZIP64 validation should be disabled. @@ -1139,8 +1128,8 @@ public String getManifestName(JarFile jar, boolean onlyIfHasSignatureRelatedFile return ((ZipFile)jar).getManifestName(onlyIfHasSignatureRelatedFiles); } @Override - public int[] getMetaInfVersions(JarFile jar) { - return ((ZipFile)jar).getMetaInfVersions(); + public BitSet getMetaInfVersions(JarFile jar, String name) { + return ((ZipFile)jar).getMetaInfVersions(name); } @Override public Enumeration entries(ZipFile zip) { @@ -1175,7 +1164,8 @@ private static class Source { private static final JavaUtilJarAccess JUJA = SharedSecrets.javaUtilJarAccess(); // "META-INF/".length() private static final int META_INF_LEN = 9; - private static final int[] EMPTY_META_VERSIONS = new int[0]; + // "META-INF/versions//".length() + private static final int META_INF_VERSIONS_LEN = 19; // CEN size is limited to the maximum array size in the JDK private static final int MAX_CEN_SIZE = ArraysSupport.SOFT_MAX_ARRAY_LENGTH; @@ -1192,7 +1182,7 @@ private static class Source { private int manifestPos = -1; // position of the META-INF/MANIFEST.MF, if exists private int manifestNum = 0; // number of META-INF/MANIFEST.MF, case insensitive private int[] signatureMetaNames; // positions of signature related entries, if such exist - private int[] metaVersions; // list of unique versions found in META-INF/versions/ + private Map metaVersions; // Versions found in META-INF/versions/, by entry name hash private final boolean startsWithLoc; // true, if ZIP file starts with LOCSIG (usually true) // A Hashmap for all entries. @@ -1574,7 +1564,7 @@ private void close() throws IOException { manifestPos = -1; manifestNum = 0; signatureMetaNames = null; - metaVersions = EMPTY_META_VERSIONS; + metaVersions = null; } private static final int BUF_SIZE = 8192; @@ -1759,8 +1749,6 @@ private void initCEN(int knownTotal) throws IOException { // list for all meta entries ArrayList signatureNames = null; - // Set of all version numbers seen in META-INF/versions/ - Set metaVersionsSet = null; // Iterate through the entries in the central directory int idx = 0; // Index into the entries array @@ -1799,9 +1787,19 @@ private void initCEN(int knownTotal) throws IOException { // performance in multi-release jar files int version = getMetaVersion(entryPos + META_INF_LEN, nlen - META_INF_LEN); if (version > 0) { - if (metaVersionsSet == null) - metaVersionsSet = new TreeSet<>(); - metaVersionsSet.add(version); + try { + // Compute hash code of name from "META-INF/versions/{version)/{name} + int prefixLen = META_INF_VERSIONS_LEN + DecimalDigits.stringSize(version); + int hashCode = zipCoderForPos(pos).checkedHash(cen, + entryPos + prefixLen, + nlen - prefixLen); + // Register version for this hash code + if (metaVersions == null) + metaVersions = new HashMap<>(); + metaVersions.computeIfAbsent(hashCode, _ -> new BitSet()).set(version); + } catch (Exception e) { + zerror("invalid CEN header (bad entry name or comment)"); + } } } } @@ -1819,14 +1817,8 @@ private void initCEN(int knownTotal) throws IOException { signatureMetaNames[j] = signatureNames.get(j); } } - if (metaVersionsSet != null) { - metaVersions = new int[metaVersionsSet.size()]; - int c = 0; - for (Integer version : metaVersionsSet) { - metaVersions[c++] = version; - } - } else { - metaVersions = EMPTY_META_VERSIONS; + if (metaVersions == null) { + metaVersions = Map.of(); } if (pos != cen.length) { zerror("invalid CEN header (bad header size)"); diff --git a/src/java.base/share/classes/javax/crypto/Cipher.java b/src/java.base/share/classes/javax/crypto/Cipher.java index 89b0fe7b288..2cfdcf55823 100644 --- a/src/java.base/share/classes/javax/crypto/Cipher.java +++ b/src/java.base/share/classes/javax/crypto/Cipher.java @@ -164,6 +164,10 @@ * Consult the release documentation for your implementation to see if any * other transformations are supported. * + * @spec https://www.rfc-editor.org/info/rfc5116 + * RFC 5116: An Interface and Algorithms for Authenticated Encryption + * @spec https://www.rfc-editor.org/info/rfc7539 + * RFC 7539: ChaCha20 and Poly1305 for IETF Protocols * @author Jan Luehe * @see KeyGenerator * @see SecretKey diff --git a/src/java.base/share/classes/javax/crypto/EncryptedPrivateKeyInfo.java b/src/java.base/share/classes/javax/crypto/EncryptedPrivateKeyInfo.java index e08f9945450..698548d373f 100644 --- a/src/java.base/share/classes/javax/crypto/EncryptedPrivateKeyInfo.java +++ b/src/java.base/share/classes/javax/crypto/EncryptedPrivateKeyInfo.java @@ -137,6 +137,8 @@ public EncryptedPrivateKeyInfo(byte[] encoded) throws IOException { * is empty, i.e. 0-length. * @exception NoSuchAlgorithmException if the specified algName is * not supported. + * + * @spec security/standard-names.html Java Security Standard Algorithm Names */ public EncryptedPrivateKeyInfo(String algName, byte[] encryptedData) throws NoSuchAlgorithmException { @@ -226,6 +228,8 @@ public EncryptedPrivateKeyInfo(AlgorithmParameters algParams, * for information about standard Cipher algorithm names. * * @return the encryption algorithm name. + * + * @spec security/standard-names.html Java Security Standard Algorithm Names */ public String getAlgName() { return algid == null ? params.getAlgorithm() : algid.getName(); diff --git a/src/java.base/share/classes/javax/crypto/package-info.java b/src/java.base/share/classes/javax/crypto/package-info.java index 159823f0fa7..6ab28f9d545 100644 --- a/src/java.base/share/classes/javax/crypto/package-info.java +++ b/src/java.base/share/classes/javax/crypto/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -59,6 +59,7 @@ * How to Implement a Provider in the Java Cryptography Architecture} * * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @since 1.4 */ package javax.crypto; diff --git a/src/java.base/share/classes/javax/crypto/spec/ChaCha20ParameterSpec.java b/src/java.base/share/classes/javax/crypto/spec/ChaCha20ParameterSpec.java index 75c05269460..b1752ef940d 100644 --- a/src/java.base/share/classes/javax/crypto/spec/ChaCha20ParameterSpec.java +++ b/src/java.base/share/classes/javax/crypto/spec/ChaCha20ParameterSpec.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,6 +39,8 @@ *

    This class can be used to initialize a {@code Cipher} object that * implements the ChaCha20 algorithm. * + * @spec https://www.rfc-editor.org/info/rfc7539 + * RFC 7539: ChaCha20 and Poly1305 for IETF Protocols * @since 11 */ public final class ChaCha20ParameterSpec implements AlgorithmParameterSpec { diff --git a/src/java.base/share/classes/javax/crypto/spec/GCMParameterSpec.java b/src/java.base/share/classes/javax/crypto/spec/GCMParameterSpec.java index 879d729c2ca..bb5fe5cdd5c 100644 --- a/src/java.base/share/classes/javax/crypto/spec/GCMParameterSpec.java +++ b/src/java.base/share/classes/javax/crypto/spec/GCMParameterSpec.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -56,6 +56,12 @@ * applications. Other values can be specified for this class, but not * all CSP implementations will support them. * + * @spec https://www.rfc-editor.org/info/rfc5116 + * RFC 5116: An Interface and Algorithms for Authenticated Encryption + * @spec https://csrc.nist.gov/publications/nistpubs/800-38D/SP-800-38D.pdf + * Recommendation for Block Cipher Modes of Operation: Galois/Counter + * Mode (GCM) and GMAC + * * @see javax.crypto.Cipher * * @since 1.7 diff --git a/src/java.base/share/classes/javax/crypto/spec/OAEPParameterSpec.java b/src/java.base/share/classes/javax/crypto/spec/OAEPParameterSpec.java index efc8f370877..ba46399f044 100644 --- a/src/java.base/share/classes/javax/crypto/spec/OAEPParameterSpec.java +++ b/src/java.base/share/classes/javax/crypto/spec/OAEPParameterSpec.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -72,6 +72,8 @@ * EncodingParameters ::= OCTET STRING(SIZE(0..MAX)) * * + * @spec https://www.rfc-editor.org/info/rfc8017 + * RFC 8017: PKCS #1: RSA Cryptography Specifications Version 2.2 * @see java.security.spec.MGF1ParameterSpec * @see PSource * diff --git a/src/java.base/share/classes/javax/crypto/spec/PBEKeySpec.java b/src/java.base/share/classes/javax/crypto/spec/PBEKeySpec.java index b21b610e780..e47deab6fbe 100644 --- a/src/java.base/share/classes/javax/crypto/spec/PBEKeySpec.java +++ b/src/java.base/share/classes/javax/crypto/spec/PBEKeySpec.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -54,6 +54,8 @@ * this class requests the password as a char array, so it can be overwritten * when done. * + * @spec https://www.rfc-editor.org/info/rfc2898 + * RFC 2898: PKCS #5: Password-Based Cryptography Specification Version 2.0 * @author Jan Luehe * @author Valerie Peng * diff --git a/src/java.base/share/classes/javax/crypto/spec/PBEParameterSpec.java b/src/java.base/share/classes/javax/crypto/spec/PBEParameterSpec.java index 84d175dfd9f..a44822bafec 100644 --- a/src/java.base/share/classes/javax/crypto/spec/PBEParameterSpec.java +++ b/src/java.base/share/classes/javax/crypto/spec/PBEParameterSpec.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,6 +33,8 @@ * PKCS #5 * standard. * + * @spec https://www.rfc-editor.org/info/rfc2898 + * RFC 2898: PKCS #5: Password-Based Cryptography Specification Version 2.0 * @author Jan Luehe * * @since 1.4 diff --git a/src/java.base/share/classes/javax/crypto/spec/PSource.java b/src/java.base/share/classes/javax/crypto/spec/PSource.java index 1cd57c6f03b..19546a630de 100644 --- a/src/java.base/share/classes/javax/crypto/spec/PSource.java +++ b/src/java.base/share/classes/javax/crypto/spec/PSource.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,6 +42,9 @@ * } * EncodingParameters ::= OCTET STRING(SIZE(0..MAX)) * + * + * @spec https://www.rfc-editor.org/info/rfc8017 + * RFC 8017: PKCS #1: RSA Cryptography Specifications Version 2.2 * @author Valerie Peng * * @since 1.5 diff --git a/src/java.base/share/classes/javax/crypto/spec/RC2ParameterSpec.java b/src/java.base/share/classes/javax/crypto/spec/RC2ParameterSpec.java index 6c32ee119c5..3c2e5a57da6 100644 --- a/src/java.base/share/classes/javax/crypto/spec/RC2ParameterSpec.java +++ b/src/java.base/share/classes/javax/crypto/spec/RC2ParameterSpec.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,6 +39,8 @@ *

    This class can be used to initialize a {@code Cipher} object that * implements the RC2 algorithm. * + * @spec https://www.rfc-editor.org/info/rfc2268 + * RFC 2268: A Description of the RC2(r) Encryption Algorithm * @author Jan Luehe * * @since 1.4 diff --git a/src/java.base/share/classes/javax/crypto/spec/RC5ParameterSpec.java b/src/java.base/share/classes/javax/crypto/spec/RC5ParameterSpec.java index 67daf8bb19a..86d128afbf8 100644 --- a/src/java.base/share/classes/javax/crypto/spec/RC5ParameterSpec.java +++ b/src/java.base/share/classes/javax/crypto/spec/RC5ParameterSpec.java @@ -39,6 +39,8 @@ *

    This class can be used to initialize a {@code Cipher} object that * implements the RC5 algorithm. * + * @spec https://www.rfc-editor.org/info/rfc2040 + * RFC 2040: The RC5, RC5-CBC, RC5-CBC-Pad, and RC5-CTS Algorithms * @author Jan Luehe * * @since 1.4 diff --git a/src/java.base/share/classes/javax/crypto/spec/SecretKeySpec.java b/src/java.base/share/classes/javax/crypto/spec/SecretKeySpec.java index 2ad9a7748f2..d36510a21a8 100644 --- a/src/java.base/share/classes/javax/crypto/spec/SecretKeySpec.java +++ b/src/java.base/share/classes/javax/crypto/spec/SecretKeySpec.java @@ -98,6 +98,8 @@ public class SecretKeySpec implements KeySpec, SecretKey { * for information about standard algorithm names. * @exception IllegalArgumentException if algorithm * is null or key is null or empty. + * + * @spec security/standard-names.html Java Security Standard Algorithm Names */ public SecretKeySpec(byte[] key, String algorithm) { String errMsg = doSanityCheck(key, algorithm); @@ -144,6 +146,8 @@ public SecretKeySpec(byte[] key, String algorithm) { * @exception ArrayIndexOutOfBoundsException is thrown if * offset or len index bytes outside the * key. + * + * @spec security/standard-names.html Java Security Standard Algorithm Names */ public SecretKeySpec(byte[] key, int offset, int len, String algorithm) { if (key == null || algorithm == null) { diff --git a/src/java.base/share/classes/javax/net/ssl/ExtendedSSLSession.java b/src/java.base/share/classes/javax/net/ssl/ExtendedSSLSession.java index c1ddf221ab5..2b98f4845cf 100644 --- a/src/java.base/share/classes/javax/net/ssl/ExtendedSSLSession.java +++ b/src/java.base/share/classes/javax/net/ssl/ExtendedSSLSession.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -63,6 +63,7 @@ public ExtendedSSLSession() {} * order of preference. The return value is an empty array if * no signature algorithm is supported. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @see SSLParameters#getAlgorithmConstraints */ public abstract String[] getLocalSupportedSignatureAlgorithms(); @@ -86,6 +87,7 @@ public ExtendedSSLSession() {} * order of preference. The return value is an empty array if * the peer has not sent the supported signature algorithms. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @see X509KeyManager * @see X509ExtendedKeyManager */ diff --git a/src/java.base/share/classes/javax/net/ssl/SNIHostName.java b/src/java.base/share/classes/javax/net/ssl/SNIHostName.java index 5abb9df1200..039ee41aab0 100644 --- a/src/java.base/share/classes/javax/net/ssl/SNIHostName.java +++ b/src/java.base/share/classes/javax/net/ssl/SNIHostName.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -53,6 +53,11 @@ *

    * Note that {@code SNIHostName} objects are immutable. * + * @spec https://www.rfc-editor.org/info/rfc5890 + * RFC 5890: Internationalized Domain Names for Applications (IDNA): + * Definitions and Document Framework + * @spec https://www.rfc-editor.org/info/rfc6066 + * RFC 6066: Transport Layer Security (TLS) Extensions: Extension Definitions * @see SNIServerName * @see StandardConstants#SNI_HOST_NAME * @@ -92,6 +97,15 @@ public final class SNIHostName extends SNIServerName { * * @throws NullPointerException if {@code hostname} is {@code null} * @throws IllegalArgumentException if {@code hostname} is illegal + * + * @spec https://www.rfc-editor.org/info/rfc1122 + * RFC 1122: Requirements for Internet Hosts - Communication Layers + * @spec https://www.rfc-editor.org/info/rfc1123 + * RFC 1123: Requirements for Internet Hosts - Application and Support + * @spec https://www.rfc-editor.org/info/rfc3490 + * RFC 3490: Internationalizing Domain Names in Applications (IDNA) + * @spec https://www.rfc-editor.org/info/rfc6066 + * RFC 6066: Transport Layer Security (TLS) Extensions: Extension Definitions */ public SNIHostName(String hostname) { // IllegalArgumentException will be thrown if {@code hostname} is @@ -159,6 +173,17 @@ public SNIHostName(String hostname) { * * @throws NullPointerException if {@code encoded} is {@code null} * @throws IllegalArgumentException if {@code encoded} is illegal + * + * @spec https://www.rfc-editor.org/info/rfc1122 + * RFC 1122: Requirements for Internet Hosts - Communication Layers + * @spec https://www.rfc-editor.org/info/rfc1123 + * RFC 1123: Requirements for Internet Hosts - Application and Support + * @spec https://www.rfc-editor.org/info/rfc3490 + * RFC 3490: Internationalizing Domain Names in Applications (IDNA) + * @spec https://www.rfc-editor.org/info/rfc4366 + * RFC 4366: Transport Layer Security (TLS) Extensions + * @spec https://www.rfc-editor.org/info/rfc6066 + * RFC 6066: Transport Layer Security (TLS) Extensions: Extension Definitions */ public SNIHostName(byte[] encoded) { // NullPointerException will be thrown if {@code encoded} is null @@ -198,6 +223,11 @@ public SNIHostName(byte[] encoded) { * * @return the {@link StandardCharsets#US_ASCII}-compliant hostname * of this {@code SNIHostName} object + * + * @spec https://www.rfc-editor.org/info/rfc5890 + * RFC 5890: Internationalized Domain Names for Applications (IDNA): Definitions and Document Framework + * @spec https://www.rfc-editor.org/info/rfc6066 + * RFC 6066: Transport Layer Security (TLS) Extensions: Extension Definitions */ public String getAsciiName() { return hostname; @@ -215,6 +245,9 @@ public String getAsciiName() { * the other server name object to compare with. * @return true if, and only if, the {@code other} is considered * equal to this instance + * + * @spec https://www.rfc-editor.org/info/rfc6066 + * RFC 6066: Transport Layer Security (TLS) Extensions: Extension Definitions */ @Override public boolean equals(Object other) { diff --git a/src/java.base/share/classes/javax/net/ssl/SNIServerName.java b/src/java.base/share/classes/javax/net/ssl/SNIServerName.java index 142bb33de8e..85eab316664 100644 --- a/src/java.base/share/classes/javax/net/ssl/SNIServerName.java +++ b/src/java.base/share/classes/javax/net/ssl/SNIServerName.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,6 +41,8 @@ * {@code SNIServerName} objects are immutable. Subclasses should not provide * methods that can change the state of an instance once it has been created. * + * @spec https://www.rfc-editor.org/info/rfc6066 + * RFC 6066: Transport Layer Security (TLS) Extensions: Extension Definitions * @see SSLParameters#getServerNames() * @see SSLParameters#setServerNames(List) * diff --git a/src/java.base/share/classes/javax/net/ssl/SSLEngine.java b/src/java.base/share/classes/javax/net/ssl/SSLEngine.java index 9a74c69f9f5..27f3c31e0e9 100644 --- a/src/java.base/share/classes/javax/net/ssl/SSLEngine.java +++ b/src/java.base/share/classes/javax/net/ssl/SSLEngine.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -413,6 +413,8 @@ * because there is no way to guarantee the eventual packet ordering. * * + * @spec https://www.rfc-editor.org/info/rfc2246 + * RFC 2246: The TLS Protocol Version 1.0 * @see SSLContext * @see SSLSocket * @see SSLServerSocket @@ -859,6 +861,8 @@ public abstract SSLEngineResult unwrap(ByteBuffer src, * if this engine has not received the proper SSL/TLS/DTLS close * notification message from the peer. * + * @spec https://www.rfc-editor.org/info/rfc2246 + * RFC 2246: The TLS Protocol Version 1.0 * @see #isInboundDone() * @see #isOutboundDone() */ @@ -1351,6 +1355,8 @@ public void setSSLParameters(SSLParameters params) { * Application-Layer Protocol Negotiation (ALPN), can negotiate * application-level values between peers. * + * @spec https://www.rfc-editor.org/info/rfc7301 + * RFC 7301: Transport Layer Security (TLS) Application-Layer Protocol Negotiation Extension * @implSpec * The implementation in this class throws * {@code UnsupportedOperationException} and performs no other action. diff --git a/src/java.base/share/classes/javax/net/ssl/SSLParameters.java b/src/java.base/share/classes/javax/net/ssl/SSLParameters.java index eabf0a13f67..e1f43994064 100644 --- a/src/java.base/share/classes/javax/net/ssl/SSLParameters.java +++ b/src/java.base/share/classes/javax/net/ssl/SSLParameters.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -300,6 +300,7 @@ public String getEndpointIdentificationAlgorithm() { * Java Security Standard Algorithm Names document * for information about standard algorithm names. * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @see X509ExtendedTrustManager * * @since 1.7 @@ -674,6 +675,9 @@ public String[] getApplicationProtocols() { * @throws IllegalArgumentException if protocols is null, or if * any element in a non-empty array is null or an * empty (zero-length) string + * + * @spec https://www.rfc-editor.org/info/rfc7301 + * RFC 7301: Transport Layer Security (TLS) Application-Layer Protocol Negotiation Extension * @see #getApplicationProtocols * @since 9 */ diff --git a/src/java.base/share/classes/javax/net/ssl/SSLSocket.java b/src/java.base/share/classes/javax/net/ssl/SSLSocket.java index d0c3c9ac2dd..25d572a5616 100644 --- a/src/java.base/share/classes/javax/net/ssl/SSLSocket.java +++ b/src/java.base/share/classes/javax/net/ssl/SSLSocket.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -770,6 +770,9 @@ public void setSSLParameters(SSLParameters params) { * if a value was successfully negotiated. * @throws UnsupportedOperationException if the underlying provider * does not implement the operation. + * + * @spec https://www.rfc-editor.org/info/rfc7301 + * RFC 7301: Transport Layer Security (TLS) Application-Layer Protocol Negotiation Extension * @since 9 */ public String getApplicationProtocol() { diff --git a/src/java.base/share/classes/javax/net/ssl/SSLSocketFactory.java b/src/java.base/share/classes/javax/net/ssl/SSLSocketFactory.java index bd7c3d0157a..cb5e3318052 100644 --- a/src/java.base/share/classes/javax/net/ssl/SSLSocketFactory.java +++ b/src/java.base/share/classes/javax/net/ssl/SSLSocketFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -198,6 +198,8 @@ public abstract Socket createSocket(Socket s, String host, * does not implement the operation * @throws NullPointerException if {@code s} is {@code null} * + * @spec https://www.rfc-editor.org/info/rfc6066 + * RFC 6066: Transport Layer Security (TLS) Extensions: Extension Definitions * @since 1.8 */ public Socket createSocket(Socket s, InputStream consumed, diff --git a/src/java.base/share/classes/javax/net/ssl/StandardConstants.java b/src/java.base/share/classes/javax/net/ssl/StandardConstants.java index 8e1df977b97..ca560390cb1 100644 --- a/src/java.base/share/classes/javax/net/ssl/StandardConstants.java +++ b/src/java.base/share/classes/javax/net/ssl/StandardConstants.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -49,6 +49,8 @@ private StandardConstants() { *

    * The value of this constant is {@value}. * + * @spec https://www.rfc-editor.org/info/rfc6066 + * RFC 6066: Transport Layer Security (TLS) Extensions: Extension Definitions * @see SNIServerName * @see SNIHostName */ diff --git a/src/java.base/share/classes/javax/net/ssl/package-info.java b/src/java.base/share/classes/javax/net/ssl/package-info.java index f41b3b7f19a..cdf3b2246f6 100644 --- a/src/java.base/share/classes/javax/net/ssl/package-info.java +++ b/src/java.base/share/classes/javax/net/ssl/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,6 +36,7 @@ * * * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @since 1.4 */ package javax.net.ssl; diff --git a/src/java.base/share/classes/javax/security/auth/login/package-info.java b/src/java.base/share/classes/javax/security/auth/login/package-info.java index 70d25f1acaa..658f219f20b 100644 --- a/src/java.base/share/classes/javax/security/auth/login/package-info.java +++ b/src/java.base/share/classes/javax/security/auth/login/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,6 +33,7 @@ * * * + * @spec security/standard-names.html Java Security Standard Algorithm Names * @since 1.4 */ package javax.security.auth.login; diff --git a/src/java.base/share/classes/javax/security/auth/x500/X500Principal.java b/src/java.base/share/classes/javax/security/auth/x500/X500Principal.java index efc5b7891b8..93e34ad65ef 100644 --- a/src/java.base/share/classes/javax/security/auth/x500/X500Principal.java +++ b/src/java.base/share/classes/javax/security/auth/x500/X500Principal.java @@ -60,6 +60,14 @@ * {@code X509Certificate} return X500Principals representing the * issuer and subject fields of the certificate. * + * @spec https://www.rfc-editor.org/info/rfc1779 + * RFC 1779: A String Representation of Distinguished Names + * @spec https://www.rfc-editor.org/info/rfc2253 + * RFC 2253: Lightweight Directory Access Protocol (v3): + * UTF-8 String Representation of Distinguished Names + * @spec https://www.rfc-editor.org/info/rfc5280 + * RFC 5280: Internet X.509 Public Key Infrastructure Certificate + * and Certificate Revocation List (CRL) Profile * @see java.security.cert.X509Certificate * @since 1.4 */ @@ -141,6 +149,10 @@ public X500Principal asX500Principal(X500Name name) { * is {@code null} * @exception IllegalArgumentException if the {@code name} * is improperly specified + * + * @spec https://www.rfc-editor.org/info/rfc4512 + * RFC 4512: Lightweight Directory Access Protocol (LDAP): + * Directory Information Models */ public X500Principal(String name) { this(name, Collections.emptyMap()); @@ -181,6 +193,10 @@ public X500Principal(String name) { * @exception IllegalArgumentException if the {@code name} is * improperly specified or a keyword in the {@code name} maps to an * OID that is not in the correct form + * + * @spec https://www.rfc-editor.org/info/rfc4512 + * RFC 4512: Lightweight Directory Access Protocol (LDAP): + * Directory Information Models * @since 1.6 */ public X500Principal(String name, Map keywordMap) { diff --git a/src/java.base/share/classes/javax/security/auth/x500/package-info.java b/src/java.base/share/classes/javax/security/auth/x500/package-info.java index 45859a79bed..b2afa89d251 100644 --- a/src/java.base/share/classes/javax/security/auth/x500/package-info.java +++ b/src/java.base/share/classes/javax/security/auth/x500/package-info.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,6 +44,17 @@ * Directory Information Models * * + * @spec https://www.rfc-editor.org/info/rfc1779 + * RFC 1779: A String Representation of Distinguished Names + * @spec https://www.rfc-editor.org/info/rfc2253 + * RFC 2253: Lightweight Directory Access Protocol (v3): + * UTF-8 String Representation of Distinguished Names + * @spec https://www.rfc-editor.org/info/rfc4512 + * RFC 4512: Lightweight Directory Access Protocol (LDAP): + * Directory Information Models + * @spec https://www.rfc-editor.org/info/rfc5280 + * RFC 5280: Internet X.509 Public Key Infrastructure Certificate + * and Certificate Revocation List (CRL) Profile * @since 1.4 */ package javax.security.auth.x500; diff --git a/src/java.base/share/classes/jdk/internal/access/JavaUtilZipFileAccess.java b/src/java.base/share/classes/jdk/internal/access/JavaUtilZipFileAccess.java index 2c9d904005d..9ff0f2e8b92 100644 --- a/src/java.base/share/classes/jdk/internal/access/JavaUtilZipFileAccess.java +++ b/src/java.base/share/classes/jdk/internal/access/JavaUtilZipFileAccess.java @@ -25,6 +25,7 @@ package jdk.internal.access; +import java.util.BitSet; import java.util.Enumeration; import java.util.List; import java.util.jar.JarEntry; @@ -38,7 +39,7 @@ public interface JavaUtilZipFileAccess { public List getManifestAndSignatureRelatedFiles(JarFile zip); public String getManifestName(JarFile zip, boolean onlyIfSignatureRelatedFiles); public int getManifestNum(JarFile zip); - public int[] getMetaInfVersions(JarFile zip); + public BitSet getMetaInfVersions(JarFile zip, String name); public Enumeration entries(ZipFile zip); public Stream stream(ZipFile zip); public Stream entryNameStream(ZipFile zip); diff --git a/src/java.base/share/classes/jdk/internal/classfile/impl/AbstractInstruction.java b/src/java.base/share/classes/jdk/internal/classfile/impl/AbstractInstruction.java index 8795894530b..2197ac81e37 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/impl/AbstractInstruction.java +++ b/src/java.base/share/classes/jdk/internal/classfile/impl/AbstractInstruction.java @@ -673,7 +673,8 @@ public void writeTo(DirectCodeBuilder writer) { if (writer.canWriteDirect(code.constantPool())) super.writeTo(writer); else - writer.writeLoadConstant(op, constantEntry()); + // We have writer.canWriteDirect(constantEntry().constantPool()) == false + writer.writeAdaptLoadConstant(op, constantEntry()); } @Override @@ -1346,7 +1347,12 @@ public ConstantDesc constantValue() { @Override public void writeTo(DirectCodeBuilder writer) { - writer.writeLoadConstant(op, constant); + var constant = this.constant; + if (writer.canWriteDirect(constant.constantPool())) + // Allows writing ldc_w small index constants upon user request + writer.writeDirectLoadConstant(op, constant); + else + writer.writeAdaptLoadConstant(op, constant); } @Override diff --git a/src/java.base/share/classes/jdk/internal/classfile/impl/DirectCodeBuilder.java b/src/java.base/share/classes/jdk/internal/classfile/impl/DirectCodeBuilder.java index 6536faa8bea..7d554a35974 100644 --- a/src/java.base/share/classes/jdk/internal/classfile/impl/DirectCodeBuilder.java +++ b/src/java.base/share/classes/jdk/internal/classfile/impl/DirectCodeBuilder.java @@ -670,16 +670,22 @@ public void writeArgumentConstant(Opcode opcode, int value) { } } - public void writeLoadConstant(Opcode opcode, LoadableConstantEntry value) { - // Make sure Long and Double have LDC2_W and - // rewrite to _W if index is >= 256 - int index = AbstractPoolEntry.maybeClone(constantPool, value).index(); - if (value instanceof LongEntry || value instanceof DoubleEntry) { - opcode = Opcode.LDC2_W; - } else if (index >= 256) - opcode = Opcode.LDC_W; + // value may not be writable to this constant pool + public void writeAdaptLoadConstant(Opcode opcode, LoadableConstantEntry value) { + var pe = AbstractPoolEntry.maybeClone(constantPool, value); + int index = pe.index(); + if (pe != value && opcode != Opcode.LDC2_W) { + // rewrite ldc/ldc_w if external entry; ldc2_w never needs rewrites + opcode = index <= 0xFF ? Opcode.LDC : Opcode.LDC_W; + } - assert !opcode.isWide(); + writeDirectLoadConstant(opcode, pe); + } + + // the loadable entry is writable to this constant pool + public void writeDirectLoadConstant(Opcode opcode, LoadableConstantEntry pe) { + assert !opcode.isWide() && canWriteDirect(pe.constantPool()); + int index = pe.index(); if (opcode.sizeIfFixed() == 3) { bytecodesBufWriter.writeU1U2(opcode.bytecode(), index); } else { @@ -1654,7 +1660,8 @@ public CodeBuilder lconst_1() { @Override public CodeBuilder ldc(LoadableConstantEntry entry) { - writeLoadConstant(BytecodeHelpers.ldcOpcode(entry), entry); + var direct = AbstractPoolEntry.maybeClone(constantPool, entry); + writeDirectLoadConstant(BytecodeHelpers.ldcOpcode(direct), direct); return this; } diff --git a/src/java.base/share/classes/jdk/internal/foreign/abi/BindingSpecializer.java b/src/java.base/share/classes/jdk/internal/foreign/abi/BindingSpecializer.java index f1e1d1728d8..41d7e3339d5 100644 --- a/src/java.base/share/classes/jdk/internal/foreign/abi/BindingSpecializer.java +++ b/src/java.base/share/classes/jdk/internal/foreign/abi/BindingSpecializer.java @@ -24,6 +24,7 @@ */ package jdk.internal.foreign.abi; +import java.lang.classfile.Annotation; import java.lang.classfile.ClassFile; import java.lang.classfile.CodeBuilder; import java.lang.classfile.Label; @@ -46,10 +47,13 @@ import jdk.internal.foreign.abi.Binding.ShiftRight; import jdk.internal.foreign.abi.Binding.VMLoad; import jdk.internal.foreign.abi.Binding.VMStore; +import jdk.internal.vm.annotation.ForceInline; import sun.security.action.GetBooleanAction; +import sun.security.action.GetIntegerAction; import sun.security.action.GetPropertyAction; import java.io.IOException; +import java.lang.classfile.attribute.RuntimeVisibleAnnotationsAttribute; import java.lang.constant.ClassDesc; import java.lang.constant.ConstantDesc; import java.lang.constant.DynamicConstantDesc; @@ -77,6 +81,8 @@ public class BindingSpecializer { = GetPropertyAction.privilegedGetProperty("jdk.internal.foreign.abi.Specializer.DUMP_CLASSES_DIR"); private static final boolean PERFORM_VERIFICATION = GetBooleanAction.privilegedGetProperty("jdk.internal.foreign.abi.Specializer.PERFORM_VERIFICATION"); + private static final int SCOPE_DEDUP_DEPTH + = GetIntegerAction.privilegedGetProperty("jdk.internal.foreign.abi.Specializer.SCOPE_DEDUP_DEPTH", 2); // Bunch of helper constants private static final int CLASSFILE_VERSION = ClassFileFormatVersion.latest().major(); @@ -99,6 +105,7 @@ public class BindingSpecializer { private static final ClassDesc CD_ValueLayout_OfFloat = referenceClassDesc(ValueLayout.OfFloat.class); private static final ClassDesc CD_ValueLayout_OfDouble = referenceClassDesc(ValueLayout.OfDouble.class); private static final ClassDesc CD_AddressLayout = referenceClassDesc(AddressLayout.class); + private static final ClassDesc CD_ForceInline = referenceClassDesc(ForceInline.class); private static final MethodTypeDesc MTD_NEW_BOUNDED_ARENA = MethodTypeDesc.of(CD_Arena, CD_long); private static final MethodTypeDesc MTD_NEW_EMPTY_ARENA = MethodTypeDesc.of(CD_Arena); @@ -196,8 +203,9 @@ private static byte[] specializeHelper(MethodType leafType, MethodType callerMet clb.withFlags(ACC_PUBLIC + ACC_FINAL + ACC_SUPER) .withSuperclass(CD_Object) .withVersion(CLASSFILE_VERSION, 0) - .withMethodBody(METHOD_NAME, methodTypeDesc(callerMethodType), ACC_PUBLIC | ACC_STATIC, - cb -> new BindingSpecializer(cb, callerMethodType, callingSequence, abi, leafType).specialize()); + .withMethod(METHOD_NAME, methodTypeDesc(callerMethodType), ACC_PUBLIC | ACC_STATIC, + mb -> mb.with(RuntimeVisibleAnnotationsAttribute.of(Annotation.of(CD_ForceInline))) + .withCode(cb -> new BindingSpecializer(cb, callerMethodType, callingSequence, abi, leafType).specialize())); }); if (DUMP_CLASSES_DIR != null) { @@ -502,11 +510,19 @@ private void emitAcquireScope() { // start with 1 scope to maybe acquire on the stack assert curScopeLocalIdx != -1; - boolean hasOtherScopes = curScopeLocalIdx != 0; - for (int i = 0; i < curScopeLocalIdx; i++) { + boolean hasLookup = false; + + // Here we check if the current scope has not been already acquired. + // To do that, we generate many comparisons (one per cached scope). + // Note that we always skip comparisons against the very first cached scope + // (as that is the function address, which typically belongs to another scope). + // We also stop the comparisons at SCOPE_DEDUP_DEPTH, to keep a lid on the size + // of the generated code. + for (int i = 1; i < curScopeLocalIdx && i <= SCOPE_DEDUP_DEPTH; i++) { cb.dup() // dup for comparison .aload(scopeSlots[i]) .if_acmpeq(skipAcquire); + hasLookup = true; } // 1 scope to acquire on the stack @@ -516,10 +532,10 @@ private void emitAcquireScope() { cb.invokevirtual(CD_MemorySessionImpl, "acquire0", MTD_ACQUIRE0) // call acquire on the other .astore(nextScopeLocal); // store off one to release later - if (hasOtherScopes) { // avoid ASM generating a bunch of nops for the dead code + if (hasLookup) { // avoid ASM generating a bunch of nops for the dead code cb.goto_(end) - .labelBinding(skipAcquire) - .pop(); // drop scope + .labelBinding(skipAcquire) + .pop(); // drop scope } cb.labelBinding(end); diff --git a/src/java.base/share/classes/jdk/internal/module/ArchivedModuleGraph.java b/src/java.base/share/classes/jdk/internal/module/ArchivedModuleGraph.java index 8b91ab67d2b..ca5ffb2ff68 100644 --- a/src/java.base/share/classes/jdk/internal/module/ArchivedModuleGraph.java +++ b/src/java.base/share/classes/jdk/internal/module/ArchivedModuleGraph.java @@ -25,6 +25,7 @@ package jdk.internal.module; import java.util.Objects; +import java.util.Set; import java.util.function.Function; import java.lang.module.Configuration; import java.lang.module.ModuleFinder; @@ -43,19 +44,22 @@ class ArchivedModuleGraph { private final Configuration configuration; private final Function classLoaderFunction; private final String mainModule; + private final Set addModules; private ArchivedModuleGraph(boolean hasSplitPackages, boolean hasIncubatorModules, ModuleFinder finder, Configuration configuration, Function classLoaderFunction, - String mainModule) { + String mainModule, + Set addModules) { this.hasSplitPackages = hasSplitPackages; this.hasIncubatorModules = hasIncubatorModules; this.finder = finder; this.configuration = configuration; this.classLoaderFunction = classLoaderFunction; this.mainModule = mainModule; + this.addModules = addModules; } ModuleFinder finder() { @@ -78,12 +82,24 @@ boolean hasIncubatorModules() { return hasIncubatorModules; } + static boolean sameAddModules(Set addModules) { + if (archivedModuleGraph.addModules == null || addModules == null) { + return false; + } + + if (archivedModuleGraph.addModules.size() != addModules.size()) { + return false; + } + + return archivedModuleGraph.addModules.containsAll(addModules); + } + /** * Returns the ArchivedModuleGraph for the given initial module. */ - static ArchivedModuleGraph get(String mainModule) { + static ArchivedModuleGraph get(String mainModule, Set addModules) { ArchivedModuleGraph graph = archivedModuleGraph; - if ((graph != null) && Objects.equals(graph.mainModule, mainModule)) { + if ((graph != null) && Objects.equals(graph.mainModule, mainModule) && sameAddModules(addModules)) { return graph; } else { return null; @@ -98,13 +114,15 @@ static void archive(boolean hasSplitPackages, ModuleFinder finder, Configuration configuration, Function classLoaderFunction, - String mainModule) { + String mainModule, + Set addModules) { archivedModuleGraph = new ArchivedModuleGraph(hasSplitPackages, hasIncubatorModules, finder, configuration, classLoaderFunction, - mainModule); + mainModule, + addModules); } static { diff --git a/src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java b/src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java index 656104e2455..f5904915e26 100644 --- a/src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java +++ b/src/java.base/share/classes/jdk/internal/module/ModuleBootstrap.java @@ -141,7 +141,6 @@ public static ModuleFinder limitedFinder() { private static boolean canUseArchivedBootLayer() { return getProperty("jdk.module.upgrade.path") == null && getProperty("jdk.module.patch.0") == null && // --patch-module - getProperty("jdk.module.addmods.0") == null && // --add-modules getProperty("jdk.module.limitmods") == null && // --limit-modules getProperty("jdk.module.addreads.0") == null && // --add-reads getProperty("jdk.module.addexports.0") == null && // --add-exports @@ -212,10 +211,9 @@ private static ModuleLayer boot2() { // If the java heap was archived at CDS dump time, and the environment // at dump time matches the current environment, then use the archived // system modules and finder. - ArchivedModuleGraph archivedModuleGraph = ArchivedModuleGraph.get(mainModule); + ArchivedModuleGraph archivedModuleGraph = ArchivedModuleGraph.get(mainModule, addModules); if (archivedModuleGraph != null && !haveModulePath - && addModules.isEmpty() && limitModules.isEmpty() && !isPatched) { systemModuleFinder = archivedModuleGraph.finder(); @@ -466,7 +464,6 @@ private static ModuleLayer boot2() { if (CDS.isDumpingStaticArchive() && !haveUpgradeModulePath - && addModules.isEmpty() && allJrtOrModularJar(cf)) { assert !isPatched; @@ -478,7 +475,8 @@ && allJrtOrModularJar(cf)) { systemModuleFinder, cf, clf, - mainModule); + mainModule, + addModules); if (!hasSplitPackages && !hasIncubatorModules) { ArchivedBootLayer.archive(bootLayer); } diff --git a/src/java.base/share/classes/jdk/internal/module/ModuleLoaderMap.java b/src/java.base/share/classes/jdk/internal/module/ModuleLoaderMap.java index a8b5eda709e..e48624bc524 100644 --- a/src/java.base/share/classes/jdk/internal/module/ModuleLoaderMap.java +++ b/src/java.base/share/classes/jdk/internal/module/ModuleLoaderMap.java @@ -51,32 +51,31 @@ private static final class Mapper implements Function { private static final ClassLoader APP_CLASSLOADER = ClassLoaders.appClassLoader(); - private static final Integer PLATFORM_LOADER_INDEX = 1; - private static final Integer APP_LOADER_INDEX = 2; + private static final String PLATFORM_LOADER_NAME = "PLATFORM"; + private static final String APP_LOADER_NAME = "APP"; /** - * Map from module to a class loader index. The index is resolved to the + * Map from module name to class loader name. The name is resolved to the * actual class loader in {@code apply}. */ - private final Map map; + private final Map map; /** * Creates a Mapper to map module names in the given Configuration to * built-in classloaders. * * As a proxy for the actual classloader, we store an easily archiveable - * index value in the internal map. The index is stored as a boxed value - * so that we can cheaply do identity comparisons during bootstrap. + * loader name in the internal map. */ Mapper(Configuration cf) { - var map = new HashMap(); + var map = new HashMap(); for (ResolvedModule resolvedModule : cf.modules()) { String mn = resolvedModule.name(); if (!Modules.bootModules.contains(mn)) { if (Modules.platformModules.contains(mn)) { - map.put(mn, PLATFORM_LOADER_INDEX); + map.put(mn, PLATFORM_LOADER_NAME); } else { - map.put(mn, APP_LOADER_INDEX); + map.put(mn, APP_LOADER_NAME); } } } @@ -85,12 +84,12 @@ private static final class Mapper implements Function { @Override public ClassLoader apply(String name) { - Integer loader = map.get(name); - if (loader == APP_LOADER_INDEX) { + String loader = map.get(name); + if (APP_LOADER_NAME.equals(loader)) { return APP_CLASSLOADER; - } else if (loader == PLATFORM_LOADER_INDEX) { + } else if (PLATFORM_LOADER_NAME.equals(loader)) { return PLATFORM_CLASSLOADER; - } else { // BOOT_LOADER_INDEX + } else { return null; } } diff --git a/src/java.base/share/classes/jdk/internal/vm/Continuation.java b/src/java.base/share/classes/jdk/internal/vm/Continuation.java index 99d0c62aaec..b863def8e6a 100644 --- a/src/java.base/share/classes/jdk/internal/vm/Continuation.java +++ b/src/java.base/share/classes/jdk/internal/vm/Continuation.java @@ -36,6 +36,7 @@ import jdk.internal.access.JavaLangAccess; import jdk.internal.access.SharedSecrets; import jdk.internal.vm.annotation.Hidden; +import jdk.internal.vm.annotation.JvmtiHideEvents; /** * A one-shot delimited continuation. @@ -305,6 +306,7 @@ private void finish() { @Hidden @DontInline @IntrinsicCandidate + @JvmtiHideEvents private static void enter(Continuation c, boolean isContinue) { // This method runs in the "entry frame". // A yield jumps to this method's caller as if returning from this method. @@ -316,6 +318,7 @@ private static void enter(Continuation c, boolean isContinue) { } @Hidden + @JvmtiHideEvents private void enter0() { target.run(); } @@ -340,6 +343,7 @@ private boolean isEmpty() { * @throws IllegalStateException if not currently in the given {@code scope}, */ @Hidden + @JvmtiHideEvents public static boolean yield(ContinuationScope scope) { Continuation cont = JLA.getContinuation(currentCarrierThread()); Continuation c; @@ -352,6 +356,7 @@ public static boolean yield(ContinuationScope scope) { } @Hidden + @JvmtiHideEvents private boolean yield0(ContinuationScope scope, Continuation child) { preempted = false; diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/x/XHash.java b/src/java.base/share/classes/jdk/internal/vm/annotation/JvmtiHideEvents.java similarity index 58% rename from src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/x/XHash.java rename to src/java.base/share/classes/jdk/internal/vm/annotation/JvmtiHideEvents.java index 79b1f5c2e70..06572e64546 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/x/XHash.java +++ b/src/java.base/share/classes/jdk/internal/vm/annotation/JvmtiHideEvents.java @@ -1,10 +1,12 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or @@ -19,23 +21,20 @@ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. - * */ -package sun.jvm.hotspot.gc.x; +package jdk.internal.vm.annotation; -class XHash { - private static long uint32(long value) { - return value & 0xFFFFFFFFL; - } +import java.lang.annotation.*; - static long uint32_to_uint32(long key) { - key = uint32(~key + (key << 15)); - key = uint32(key ^ (key >>> 12)); - key = uint32(key + (key << 2)); - key = uint32(key ^ (key >>> 4)); - key = uint32(key * 2057); - key = uint32(key ^ (key >>> 16)); - return key; - } +/** + * A method may be annotated with JvmtiHideEvents to hint that JVMTI events + * should not be generated in context of the annotated method. + * + * @implNote + * This annotation is only used for some VirtualThread and Continuation methods. + */ +@Target({ElementType.METHOD}) +@Retention(RetentionPolicy.RUNTIME) +public @interface JvmtiHideEvents { } diff --git a/src/java.base/share/classes/jdk/internal/vm/annotation/JvmtiMountTransition.java b/src/java.base/share/classes/jdk/internal/vm/annotation/JvmtiMountTransition.java index df0545e46b1..ff9f5d8bbbf 100644 --- a/src/java.base/share/classes/jdk/internal/vm/annotation/JvmtiMountTransition.java +++ b/src/java.base/share/classes/jdk/internal/vm/annotation/JvmtiMountTransition.java @@ -28,8 +28,11 @@ import java.lang.annotation.*; /** - * A method is annotated as "jvmti mount transition" if it starts - * or ends virtual thread mount state transition (VTMS transition). + * A method may be annotated with JvmtiMountTransition to hint + * it is desirable to omit it from JVMTI stack traces. + * Normally, a method is annotated with @JvmtiMountTransition if it starts + * or ends Virtual Thread Mount State (VTMS) transition, so the thread + * identity is undefined or different at method entry and exit. * * @implNote * This annotation is only used for VirtualThread methods. diff --git a/src/java.base/share/classes/jdk/internal/vm/vector/VectorSupport.java b/src/java.base/share/classes/jdk/internal/vm/vector/VectorSupport.java index 63cab418d46..afd6cc62ce5 100644 --- a/src/java.base/share/classes/jdk/internal/vm/vector/VectorSupport.java +++ b/src/java.base/share/classes/jdk/internal/vm/vector/VectorSupport.java @@ -114,6 +114,13 @@ public class VectorSupport { public static final int VECTOR_OP_EXPM1 = 117; public static final int VECTOR_OP_HYPOT = 118; + public static final int VECTOR_OP_SADD = 119; + public static final int VECTOR_OP_SSUB = 120; + public static final int VECTOR_OP_SUADD = 121; + public static final int VECTOR_OP_SUSUB = 122; + public static final int VECTOR_OP_UMIN = 123; + public static final int VECTOR_OP_UMAX = 124; + // See src/hotspot/share/opto/subnode.hpp // struct BoolTest, and enclosed enum mask public static final int BT_eq = 0; // 0000 diff --git a/src/java.base/share/classes/sun/security/provider/SHA3.java b/src/java.base/share/classes/sun/security/provider/SHA3.java index 75430c63916..5f974bc6ea6 100644 --- a/src/java.base/share/classes/sun/security/provider/SHA3.java +++ b/src/java.base/share/classes/sun/security/provider/SHA3.java @@ -32,6 +32,7 @@ import java.util.Arrays; import java.util.Objects; +import jdk.internal.util.Preconditions; import jdk.internal.vm.annotation.IntrinsicCandidate; import static java.lang.Math.min; @@ -99,6 +100,7 @@ private SHA3(String name, int digestLength, byte suffix, int c) { private void implCompressCheck(byte[] b, int ofs) { Objects.requireNonNull(b); + Preconditions.checkIndex(ofs + blockSize - 1, b.length, Preconditions.AIOOBE_FORMATTER); } /** diff --git a/src/java.base/share/classes/sun/security/x509/X509CRLImpl.java b/src/java.base/share/classes/sun/security/x509/X509CRLImpl.java index 9f72a6c5540..c5421114f7d 100644 --- a/src/java.base/share/classes/sun/security/x509/X509CRLImpl.java +++ b/src/java.base/share/classes/sun/security/x509/X509CRLImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -280,14 +280,20 @@ public X500Principal getIssuerX500Principal() { * prevCertIssuer if it does not exist */ private X500Principal getCertIssuer(X509CRLEntryImpl entry, - X500Principal prevCertIssuer) { + X500Principal prevCertIssuer) throws CRLException { CertificateIssuerExtension ciExt = entry.getCertificateIssuerExtension(); if (ciExt != null) { GeneralNames names = ciExt.getNames(); - X500Name issuerDN = (X500Name) names.get(0).getName(); - return issuerDN.asX500Principal(); + Iterator itr = names.iterator(); + while (itr.hasNext()) { + if (itr.next().getName() instanceof X500Name issuerDN) { + return issuerDN.asX500Principal(); + } + } + throw new CRLException("Parsing error: CertificateIssuer " + + "field does not contain an X.500 DN"); } else { return prevCertIssuer; } diff --git a/src/java.base/share/native/libjava/FileInputStream.c b/src/java.base/share/native/libjava/FileInputStream.c index e22499828f5..7db2ec4c208 100644 --- a/src/java.base/share/native/libjava/FileInputStream.c +++ b/src/java.base/share/native/libjava/FileInputStream.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -141,3 +141,9 @@ Java_java_io_FileInputStream_available0(JNIEnv *env, jobject this) { JNU_ThrowIOExceptionWithLastError(env, NULL); return 0; } + +JNIEXPORT jboolean JNICALL +Java_java_io_FileInputStream_isRegularFile0(JNIEnv *env, jobject this, jobject fdo) { + FD fd = getFD(env, this, fis_fd); + return IO_IsRegularFile(env, fd); +} diff --git a/src/java.base/share/native/libjava/VirtualThread.c b/src/java.base/share/native/libjava/VirtualThread.c index 94dbe0b7e37..f9d1d4996fc 100644 --- a/src/java.base/share/native/libjava/VirtualThread.c +++ b/src/java.base/share/native/libjava/VirtualThread.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,7 +36,6 @@ static JNINativeMethod methods[] = { { "notifyJvmtiEnd", "()V", (void *)&JVM_VirtualThreadEnd }, { "notifyJvmtiMount", "(Z)V", (void *)&JVM_VirtualThreadMount }, { "notifyJvmtiUnmount", "(Z)V", (void *)&JVM_VirtualThreadUnmount }, - { "notifyJvmtiHideFrames", "(Z)V", (void *)&JVM_VirtualThreadHideFrames }, { "notifyJvmtiDisableSuspend", "(Z)V", (void *)&JVM_VirtualThreadDisableSuspend }, }; diff --git a/src/java.base/share/native/libjli/emessages.h b/src/java.base/share/native/libjli/emessages.h index 342b116bfc7..6fb7cf4ce90 100644 --- a/src/java.base/share/native/libjli/emessages.h +++ b/src/java.base/share/native/libjli/emessages.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -62,60 +62,33 @@ #define JVM_ERROR1 "Error: Could not create the Java Virtual Machine.\n" GEN_ERROR #define JVM_ERROR2 "Error: Could not detach main thread.\n" JNI_ERROR -#define JAR_ERROR1 "Error: Failed to load Main-Class manifest attribute from\n%s\n%s" #define JAR_ERROR2 "Error: Unable to access jarfile %s" #define JAR_ERROR3 "Error: Invalid or corrupt jarfile %s" -#define CLS_ERROR1 "Error: Could not find the main class %s.\n" JNI_ERROR -#define CLS_ERROR2 "Error: Failed to load Main Class: %s\n%s" -#define CLS_ERROR3 "Error: No main method found in specified class.\n" GEN_ERROR -#define CLS_ERROR4 "Error: Main method not public\n" GEN_ERROR -#define CLS_ERROR5 "Error: main-class: attribute exceeds system limits of %d bytes\n" GEN_ERROR - #define CFG_WARN1 "Warning: %s VM not supported; %s VM will be used" #define CFG_WARN2 "Warning: No leading - on line %d of `%s'" #define CFG_WARN3 "Warning: Missing VM type on line %d of `%s'" -#define CFG_WARN4 "Warning: Missing server class VM on line %d of `%s'" #define CFG_WARN5 "Warning: Unknown VM type on line %d of `%s'" #define CFG_ERROR1 "Error: Corrupt jvm.cfg file; cycle in alias list." #define CFG_ERROR2 "Error: Unable to resolve VM alias %s" #define CFG_ERROR3 "Error: %s VM not supported" -#define CFG_ERROR4 "Error: Unable to locate JRE meeting specification \"%s\"" #define CFG_ERROR5 "Error: Could not determine application home." #define CFG_ERROR6 "Error: could not open `%s'" #define CFG_ERROR7 "Error: no known VMs. (check for corrupt jvm.cfg file)" -#define CFG_ERROR8 "Error: missing `%s' JVM at `%s'.\nPlease install or use the JRE or JDK that contains these missing components." +#define CFG_ERROR8 "Error: missing `%s' JVM at `%s'.\nPlease install a JDK that contains these missing components." #define CFG_ERROR9 "Error: could not determine JVM type." #define CFG_ERROR10 "Error: Argument file size should not be larger than %lu." -#define JRE_ERROR1 "Error: Could not find Java SE Runtime Environment." -#define JRE_ERROR2 "Error: This Java instance does not support a %d-bit JVM.\nPlease install the desired version." -#define JRE_ERROR3 "Error: Improper value at line %d." -#define JRE_ERROR4 "Error: trying to exec %s.\nCheck if file exists and permissions are set correctly." -#define JRE_ERROR5 "Error: Failed to start a %d-bit JVM process from a %d-bit JVM." -#define JRE_ERROR6 "Error: Verify all necessary Java SE components have been installed." -#define JRE_ERROR7 "Error: Either 64-bit processes are not supported by this platform\nor the 64-bit components have not been installed." -#define JRE_ERROR8 "Error: could not find " -#define JRE_ERROR9 "Error: Unable to resolve %s" -#define JRE_ERROR10 "Error: Unable to resolve current executable" -#define JRE_ERROR11 "Error: Path length exceeds maximum length (PATH_MAX)" -#define JRE_ERROR12 "Error: Exec of %s failed" -#define JRE_ERROR13 "Error: String processing operation failed" +#define LAUNCHER_ERROR1 "Error: Could not find Java SE Runtime Environment." +#define LAUNCHER_ERROR2 "Error: could not find " +#define LAUNCHER_ERROR3 "Error: Path length exceeds maximum length (PATH_MAX)" +#define LAUNCHER_ERROR4 "Error: trying to exec %s.\nCheck if file exists and permissions are set correctly." +#define LAUNCHER_ERROR5 "Error: String processing operation failed" #define DLL_ERROR1 "Error: dl failure on line %d" #define DLL_ERROR2 "Error: failed %s, because %s" #define DLL_ERROR3 "Error: could not find executable %s" #define DLL_ERROR4 "Error: Failed to load %s" -#define REG_ERROR1 "Error: opening registry key '%s'" -#define REG_ERROR2 "Error: Failed reading value of registry key:\n\t%s\\CurrentVersion" -#define REG_ERROR3 "Error: Registry key '%s'\\CurrentVersion'\nhas value '%s', but '%s' is required." -#define REG_ERROR4 "Failed reading value of registry key:\n\t%s\\%s\\JavaHome" - -#define SYS_ERROR1 "Error: CreateProcess(%s, ...) failed:" -#define SYS_ERROR2 "Error: WaitForSingleObject() failed." - - - #endif /* _EMESSAGES_H */ diff --git a/src/java.base/share/native/libjli/java.c b/src/java.base/share/native/libjli/java.c index 355ac4b9e28..0bb1daed28a 100644 --- a/src/java.base/share/native/libjli/java.c +++ b/src/java.base/share/native/libjli/java.c @@ -236,7 +236,7 @@ JLI_Launch(int argc, char ** argv, /* main argc, argv */ InvocationFunctions ifn; jlong start = 0, end = 0; char jvmpath[MAXPATHLEN]; - char jrepath[MAXPATHLEN]; + char jdkroot[MAXPATHLEN]; char jvmcfg[MAXPATHLEN]; _fVersion = fullversion; @@ -265,9 +265,9 @@ JLI_Launch(int argc, char ** argv, /* main argc, argv */ } CreateExecutionEnvironment(&argc, &argv, - jrepath, sizeof(jrepath), + jdkroot, sizeof(jdkroot), jvmpath, sizeof(jvmpath), - jvmcfg, sizeof(jvmcfg)); + jvmcfg, sizeof(jvmcfg)); ifn.CreateJavaVM = 0; ifn.GetDefaultJavaVMInitArgs = 0; @@ -2023,7 +2023,7 @@ PrintUsage(JNIEnv* env, jboolean doXUsage) * JVM on the command line. * * The intent of the jvm.cfg file is to allow several JVM libraries to - * be installed in different subdirectories of a single JRE installation, + * be installed in different subdirectories of a single JDK installation, * for space-savings and convenience in testing. * The intent is explicitly not to provide a full aliasing or predicate * mechanism. diff --git a/src/java.base/share/native/libjli/java.h b/src/java.base/share/native/libjli/java.h index 19493fedaae..f39e923cab8 100644 --- a/src/java.base/share/native/libjli/java.h +++ b/src/java.base/share/native/libjli/java.h @@ -111,15 +111,15 @@ GetApplicationHomeFromDll(char *buf, jint bufsize); * Different platforms will implement this, here * pargc is a pointer to the original argc, * pargv is a pointer to the original argv, - * jrepath is an accessible path to the jre as determined by the call - * so_jrepath is the length of the buffer jrepath + * jdkroot is an accessible path to the JDK installation root as determined by the call + * so_jdkroot is the length of the buffer jdkroot * jvmpath is an accessible path to the jvm as determined by the call * so_jvmpath is the length of the buffer jvmpath */ void CreateExecutionEnvironment(int *argc, char ***argv, - char *jrepath, jint so_jrepath, + char *jdkroot, jint so_jdkroot, char *jvmpath, jint so_jvmpath, - char *jvmcfg, jint so_jvmcfg); + char *jvmcfg, jint so_jvmcfg); /* Reports an error message to stderr or a window as appropriate. */ JNIEXPORT void JNICALL diff --git a/src/java.base/unix/classes/sun/nio/fs/UnixNativeDispatcher.java b/src/java.base/unix/classes/sun/nio/fs/UnixNativeDispatcher.java index a069a9a04ba..ab8975c6d12 100644 --- a/src/java.base/unix/classes/sun/nio/fs/UnixNativeDispatcher.java +++ b/src/java.base/unix/classes/sun/nio/fs/UnixNativeDispatcher.java @@ -569,7 +569,7 @@ static boolean openatSupported() { } /** - * Supports futimes or futimesat + * Supports futimes */ static boolean futimesSupported() { return (capabilities & SUPPORTS_FUTIMES) != 0; diff --git a/src/java.base/unix/native/libjava/io_util_md.c b/src/java.base/unix/native/libjava/io_util_md.c index 9895ac3b73f..2e81cbd05c2 100644 --- a/src/java.base/unix/native/libjava/io_util_md.c +++ b/src/java.base/unix/native/libjava/io_util_md.c @@ -264,3 +264,13 @@ handleGetLength(FD fd) #endif return sb.st_size; } + +jboolean +handleIsRegularFile(JNIEnv* env, FD fd) +{ + struct stat fbuf; + if (fstat(fd, &fbuf) == -1) + JNU_ThrowIOExceptionWithLastError(env, "fstat failed"); + + return S_ISREG(fbuf.st_mode) ? JNI_TRUE : JNI_FALSE; +} diff --git a/src/java.base/unix/native/libjava/io_util_md.h b/src/java.base/unix/native/libjava/io_util_md.h index 84e97b4ace5..5a8cb8655ef 100644 --- a/src/java.base/unix/native/libjava/io_util_md.h +++ b/src/java.base/unix/native/libjava/io_util_md.h @@ -41,6 +41,7 @@ jint handleAvailable(FD fd, jlong *pbytes); jint handleSetLength(FD fd, jlong length); jlong handleGetLength(FD fd); FD handleOpen(const char *path, int oflag, int mode); +jboolean handleIsRegularFile(JNIEnv* env, FD fd); /* * Functions to get fd from the java.io.FileDescriptor field @@ -66,6 +67,7 @@ FD getFD(JNIEnv *env, jobject cur, jfieldID fid); #define IO_Available handleAvailable #define IO_SetLength handleSetLength #define IO_GetLength handleGetLength +#define IO_IsRegularFile handleIsRegularFile /* * On Solaris, the handle field is unused diff --git a/src/java.base/unix/native/libjli/java_md.c b/src/java.base/unix/native/libjli/java_md.c index 7f2f5638a6b..c2d2ac93f36 100644 --- a/src/java.base/unix/native/libjli/java_md.c +++ b/src/java.base/unix/native/libjli/java_md.c @@ -253,8 +253,8 @@ RequiresSetenv(const char *jvmpath) { /* * Prevent recursions. Since LD_LIBRARY_PATH is the one which will be set by - * previous versions of the JRE, thus it is the only path that matters here. - * So we check to see if the desired JRE is set. + * previous versions of the JDK, thus it is the only path that matters here. + * So we check to see if the desired JDK is set. */ JLI_StrNCpy(jpath, jvmpath, PATH_MAX); p = JLI_StrRChr(jpath, '/'); @@ -273,7 +273,7 @@ RequiresSetenv(const char *jvmpath) { void CreateExecutionEnvironment(int *pargc, char ***pargv, - char jrepath[], jint so_jrepath, + char jdkroot[], jint so_jdkroot, char jvmpath[], jint so_jvmpath, char jvmcfg[], jint so_jvmcfg) { @@ -294,13 +294,13 @@ CreateExecutionEnvironment(int *pargc, char ***pargv, SetExecname(*pargv); /* Check to see if the jvmpath exists */ - /* Find out where the JRE is that we will be using. */ - if (!GetJREPath(jrepath, so_jrepath, JNI_FALSE)) { - JLI_ReportErrorMessage(JRE_ERROR1); + /* Find out where the JDK is that we will be using. */ + if (!GetJDKInstallRoot(jdkroot, so_jdkroot, JNI_FALSE)) { + JLI_ReportErrorMessage(LAUNCHER_ERROR1); exit(2); } JLI_Snprintf(jvmcfg, so_jvmcfg, "%s%slib%sjvm.cfg", - jrepath, FILESEP, FILESEP); + jdkroot, FILESEP, FILESEP); /* Find the specified JVM type */ if (ReadKnownVMs(jvmcfg, JNI_FALSE) < 1) { JLI_ReportErrorMessage(CFG_ERROR7); @@ -314,7 +314,7 @@ CreateExecutionEnvironment(int *pargc, char ***pargv, exit(4); } - if (!GetJVMPath(jrepath, jvmtype, jvmpath, so_jvmpath)) { + if (!GetJVMPath(jdkroot, jvmtype, jvmpath, so_jvmpath)) { JLI_ReportErrorMessage(CFG_ERROR8, jvmtype, jvmpath); exit(4); } @@ -339,8 +339,8 @@ CreateExecutionEnvironment(int *pargc, char ***pargv, * We will set the LD_LIBRARY_PATH as follows: * * o $JVMPATH (directory portion only) - * o $JRE/lib - * o $JRE/../lib + * o $JDK/lib + * o $JDK/../lib * * followed by the user's previous effective LD_LIBRARY_PATH, if * any. @@ -352,7 +352,7 @@ CreateExecutionEnvironment(int *pargc, char ***pargv, { /* New scope to declare local variable */ char *new_jvmpath = JLI_StringDup(jvmpath); new_runpath_size = ((runpath != NULL) ? JLI_StrLen(runpath) : 0) + - 2 * JLI_StrLen(jrepath) + + 2 * JLI_StrLen(jdkroot) + JLI_StrLen(new_jvmpath) + 52; new_runpath = JLI_MemAlloc(new_runpath_size); newpath = new_runpath + JLI_StrLen(LD_LIBRARY_PATH "="); @@ -372,8 +372,8 @@ CreateExecutionEnvironment(int *pargc, char ***pargv, "%s/lib:" "%s/../lib", new_jvmpath, - jrepath, - jrepath + jdkroot, + jdkroot ); JLI_MemFree(new_jvmpath); @@ -402,7 +402,7 @@ CreateExecutionEnvironment(int *pargc, char ***pargv, if (runpath != 0) { /* ensure storage for runpath + colon + NULL */ if ((JLI_StrLen(runpath) + 1 + 1) > new_runpath_size) { - JLI_ReportErrorMessageSys(JRE_ERROR11); + JLI_ReportErrorMessageSys(LAUNCHER_ERROR3); exit(1); } JLI_StrCat(new_runpath, ":"); @@ -437,14 +437,14 @@ CreateExecutionEnvironment(int *pargc, char ***pargv, #else /* !SETENV_REQUIRED */ execv(newexec, argv); #endif /* SETENV_REQUIRED */ - JLI_ReportErrorMessageSys(JRE_ERROR4, newexec); + JLI_ReportErrorMessageSys(LAUNCHER_ERROR4, newexec); } exit(1); } static jboolean -GetJVMPath(const char *jrepath, const char *jvmtype, +GetJVMPath(const char *jdkroot, const char *jvmtype, char *jvmpath, jint jvmpathsize) { struct stat s; @@ -452,7 +452,7 @@ GetJVMPath(const char *jrepath, const char *jvmtype, if (JLI_StrChr(jvmtype, '/')) { JLI_Snprintf(jvmpath, jvmpathsize, "%s/" JVM_DLL, jvmtype); } else { - JLI_Snprintf(jvmpath, jvmpathsize, "%s/lib/%s/" JVM_DLL, jrepath, jvmtype); + JLI_Snprintf(jvmpath, jvmpathsize, "%s/lib/%s/" JVM_DLL, jdkroot, jvmtype); } JLI_TraceLauncher("Does `%s' exist ... ", jvmpath); @@ -467,31 +467,31 @@ GetJVMPath(const char *jrepath, const char *jvmtype, } /* - * Find path to JRE based on .exe's location or registry settings. + * Find path to the JDK installation root */ static jboolean -GetJREPath(char *path, jint pathsize, jboolean speculative) +GetJDKInstallRoot(char *path, jint pathsize, jboolean speculative) { char libjava[MAXPATHLEN]; struct stat s; - JLI_TraceLauncher("Attempt to get JRE path from launcher executable path\n"); + JLI_TraceLauncher("Attempt to get JDK installation root from launcher executable path\n"); if (GetApplicationHome(path, pathsize)) { - /* Is JRE co-located with the application? */ + /* Is JDK co-located with the application? */ JLI_Snprintf(libjava, sizeof(libjava), "%s/lib/" JAVA_DLL, path); if (access(libjava, F_OK) == 0) { - JLI_TraceLauncher("JRE path is %s\n", path); + JLI_TraceLauncher("JDK installation root path is %s\n", path); return JNI_TRUE; } } - JLI_TraceLauncher("Attempt to get JRE path from shared lib of the image\n"); + JLI_TraceLauncher("Attempt to get JDK installation root path from shared lib of the image\n"); if (GetApplicationHomeFromDll(path, pathsize)) { JLI_Snprintf(libjava, sizeof(libjava), "%s/lib/" JAVA_DLL, path); if (stat(libjava, &s) == 0) { - JLI_TraceLauncher("JRE path is %s\n", path); + JLI_TraceLauncher("JDK installation root path is %s\n", path); return JNI_TRUE; } } @@ -501,14 +501,14 @@ GetJREPath(char *path, jint pathsize, jboolean speculative) if (GetApplicationHomeFromLibpath(path, pathsize)) { JLI_Snprintf(libjava, sizeof(libjava), "%s/lib/" JAVA_DLL, path); if (stat(libjava, &s) == 0) { - JLI_TraceLauncher("JRE path is %s\n", path); + JLI_TraceLauncher("JDK installation root path is %s\n", path); return JNI_TRUE; } } #endif if (!speculative) - JLI_ReportErrorMessage(JRE_ERROR8 JAVA_DLL); + JLI_ReportErrorMessage(LAUNCHER_ERROR2 JAVA_DLL); return JNI_FALSE; } @@ -597,22 +597,22 @@ static void* hSplashLib = NULL; void* SplashProcAddress(const char* name) { if (!hSplashLib) { int ret; - char jrePath[MAXPATHLEN]; + char jdkRoot[MAXPATHLEN]; char splashPath[MAXPATHLEN]; - if (!GetJREPath(jrePath, sizeof(jrePath), JNI_FALSE)) { - JLI_ReportErrorMessage(JRE_ERROR1); + if (!GetJDKInstallRoot(jdkRoot, sizeof(jdkRoot), JNI_FALSE)) { + JLI_ReportErrorMessage(LAUNCHER_ERROR1); return NULL; } ret = JLI_Snprintf(splashPath, sizeof(splashPath), "%s/lib/%s", - jrePath, SPLASHSCREEN_SO); + jdkRoot, SPLASHSCREEN_SO); if (ret >= (int) sizeof(splashPath)) { - JLI_ReportErrorMessage(JRE_ERROR11); + JLI_ReportErrorMessage(LAUNCHER_ERROR3); return NULL; } if (ret < 0) { - JLI_ReportErrorMessage(JRE_ERROR13); + JLI_ReportErrorMessage(LAUNCHER_ERROR5); return NULL; } hSplashLib = dlopen(splashPath, RTLD_LAZY | RTLD_GLOBAL); diff --git a/src/java.base/unix/native/libjli/java_md.h b/src/java.base/unix/native/libjli/java_md.h index acc75ab091d..ef0740b18f0 100644 --- a/src/java.base/unix/native/libjli/java_md.h +++ b/src/java.base/unix/native/libjli/java_md.h @@ -55,9 +55,9 @@ int UnsetEnv(char *name); char *FindExecName(char *program); const char *SetExecname(char **argv); const char *GetExecName(); -static jboolean GetJVMPath(const char *jrepath, const char *jvmtype, +static jboolean GetJVMPath(const char *jdkroot, const char *jvmtype, char *jvmpath, jint jvmpathsize); -static jboolean GetJREPath(char *path, jint pathsize, jboolean speculative); +static jboolean GetJDKInstallRoot(char *path, jint pathsize, jboolean speculative); #if defined(_AIX) jboolean GetApplicationHomeFromLibpath(char *buf, jint bufsize); diff --git a/src/java.base/unix/native/libjli/java_md_common.c b/src/java.base/unix/native/libjli/java_md_common.c index 453d605f710..f67a50304d0 100644 --- a/src/java.base/unix/native/libjli/java_md_common.c +++ b/src/java.base/unix/native/libjli/java_md_common.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -76,7 +76,7 @@ TruncatePath(char *buf, jboolean pathisdll) } /* - * Retrieves the path to the JRE home by locating the executable file + * Retrieves the path to the JDK home by locating the executable file * of the current process and then truncating the path to the executable */ jboolean @@ -93,7 +93,7 @@ GetApplicationHome(char *buf, jint bufsize) } /* - * Retrieves the path to the JRE home by locating the + * Retrieves the path to the JDK home by locating the * shared library and then truncating the path to it. */ jboolean @@ -124,7 +124,7 @@ LibjavaExists(const char *path) } /* - * Retrieves the path to the JRE home by locating libjava.so in + * Retrieves the path to the JDK home by locating libjava.so in * LIBPATH and then truncating the path to it. */ jboolean @@ -262,7 +262,7 @@ JLI_ReportExceptionDescription(JNIEnv * env) { /* * Since using the file system as a registry is a bit risky, perform * additional sanity checks on the identified directory to validate - * it as a valid jre/sdk. + * it as a valid JDK. * * Return 0 if the tests fail; otherwise return non-zero (true). * diff --git a/src/java.base/unix/native/libnio/fs/UnixNativeDispatcher.c b/src/java.base/unix/native/libnio/fs/UnixNativeDispatcher.c index 61e9215471a..9a68a12c219 100644 --- a/src/java.base/unix/native/libnio/fs/UnixNativeDispatcher.c +++ b/src/java.base/unix/native/libnio/fs/UnixNativeDispatcher.c @@ -204,7 +204,7 @@ typedef int openat_func(int, const char *, int, ...); typedef int fstatat_func(int, const char *, struct stat *, int); typedef int unlinkat_func(int, const char*, int); typedef int renameat_func(int, const char*, int, const char*); -typedef int futimesat_func(int, const char *, const struct timeval *); +typedef int futimes_func(int, const struct timeval *); typedef int futimens_func(int, const struct timespec *); typedef int lutimes_func(const char *, const struct timeval *); typedef DIR* fdopendir_func(int); @@ -217,7 +217,7 @@ static openat_func* my_openat_func = NULL; static fstatat_func* my_fstatat_func = NULL; static unlinkat_func* my_unlinkat_func = NULL; static renameat_func* my_renameat_func = NULL; -static futimesat_func* my_futimesat_func = NULL; +static futimes_func* my_futimes_func = NULL; static futimens_func* my_futimens_func = NULL; static lutimes_func* my_lutimes_func = NULL; static fdopendir_func* my_fdopendir_func = NULL; @@ -363,8 +363,8 @@ Java_sun_nio_fs_UnixNativeDispatcher_init(JNIEnv* env, jclass this) /* system calls that might not be available at run time */ #if defined(_ALLBSD_SOURCE) - my_openat_func = (openat_func*)dlsym(RTLD_DEFAULT, "openat"); - my_fstatat_func = (fstatat_func*)dlsym(RTLD_DEFAULT, "fstatat"); + my_openat_func = (openat_func*) openat; + my_fstatat_func = (fstatat_func*) fstatat; #else // Make sure we link to the 64-bit version of the functions my_openat_func = (openat_func*) dlsym(RTLD_DEFAULT, "openat64"); @@ -373,22 +373,22 @@ Java_sun_nio_fs_UnixNativeDispatcher_init(JNIEnv* env, jclass this) my_unlinkat_func = (unlinkat_func*) dlsym(RTLD_DEFAULT, "unlinkat"); my_renameat_func = (renameat_func*) dlsym(RTLD_DEFAULT, "renameat"); #if defined(__linux__) && defined(__arm__) - my_futimesat_func = (futimesat_func*) lookup_time_t_function("futimesat", - "__futimesat64"); + my_futimes_func = (futimes_func*) lookup_time_t_function("futimes", + "__futimes64"); my_lutimes_func = (lutimes_func*) lookup_time_t_function("lutimes", "__lutimes64"); my_futimens_func = (futimens_func*) lookup_time_t_function("futimens", "__futimens64"); #else -#ifndef _ALLBSD_SOURCE - my_futimesat_func = (futimesat_func*) dlsym(RTLD_DEFAULT, "futimesat"); + my_futimes_func = (futimes_func*) dlsym(RTLD_DEFAULT, "futimes"); my_lutimes_func = (lutimes_func*) dlsym(RTLD_DEFAULT, "lutimes"); -#endif my_futimens_func = (futimens_func*) dlsym(RTLD_DEFAULT, "futimens"); #endif #if defined(_AIX) // Make sure we link to the 64-bit version of the function my_fdopendir_func = (fdopendir_func*) dlsym(RTLD_DEFAULT, "fdopendir64"); +#elif defined(_ALLBSD_SOURCE) + my_fdopendir_func = (fdopendir_func*) fdopendir; #else my_fdopendir_func = (fdopendir_func*) dlsym(RTLD_DEFAULT, "fdopendir"); #endif @@ -399,13 +399,13 @@ Java_sun_nio_fs_UnixNativeDispatcher_init(JNIEnv* env, jclass this) my_fstatat_func = (fstatat_func*)&fstatat_wrapper; #endif - /* supports futimes or futimesat, futimens, and/or lutimes */ + /* supports futimes, futimens, and/or lutimes */ #ifdef _ALLBSD_SOURCE capabilities |= sun_nio_fs_UnixNativeDispatcher_SUPPORTS_FUTIMES; capabilities |= sun_nio_fs_UnixNativeDispatcher_SUPPORTS_LUTIMES; #else - if (my_futimesat_func != NULL) + if (my_futimes_func != NULL) capabilities |= sun_nio_fs_UnixNativeDispatcher_SUPPORTS_FUTIMES; if (my_lutimes_func != NULL) capabilities |= sun_nio_fs_UnixNativeDispatcher_SUPPORTS_LUTIMES; @@ -417,7 +417,7 @@ Java_sun_nio_fs_UnixNativeDispatcher_init(JNIEnv* env, jclass this) if (my_openat_func != NULL && my_fstatat_func != NULL && my_unlinkat_func != NULL && my_renameat_func != NULL && - my_futimesat_func != NULL && my_fdopendir_func != NULL) + my_futimes_func != NULL && my_fdopendir_func != NULL) { capabilities |= sun_nio_fs_UnixNativeDispatcher_SUPPORTS_OPENAT; } @@ -914,11 +914,11 @@ Java_sun_nio_fs_UnixNativeDispatcher_futimes0(JNIEnv* env, jclass this, jint fil #ifdef _ALLBSD_SOURCE RESTARTABLE(futimes(filedes, ×[0]), err); #else - if (my_futimesat_func == NULL) { - JNU_ThrowInternalError(env, "my_futimesat_func is NULL"); + if (my_futimes_func == NULL) { + JNU_ThrowInternalError(env, "my_futimes_func is NULL"); return; } - RESTARTABLE((*my_futimesat_func)(filedes, NULL, ×[0]), err); + RESTARTABLE((*my_futimes_func)(filedes, ×[0]), err); #endif if (err == -1) { throwUnixException(env, errno); diff --git a/src/java.base/windows/native/libjava/io_util_md.c b/src/java.base/windows/native/libjava/io_util_md.c index a5f1ced36c5..6a8bd434280 100644 --- a/src/java.base/windows/native/libjava/io_util_md.c +++ b/src/java.base/windows/native/libjava/io_util_md.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -595,3 +595,9 @@ handleGetLength(FD fd) { return -1; } } + +jboolean +handleIsRegularFile(JNIEnv* env, FD fd) +{ + return JNI_TRUE; +} diff --git a/src/java.base/windows/native/libjava/io_util_md.h b/src/java.base/windows/native/libjava/io_util_md.h index d9f239a25c5..82615cc8222 100644 --- a/src/java.base/windows/native/libjava/io_util_md.h +++ b/src/java.base/windows/native/libjava/io_util_md.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -51,6 +51,7 @@ jint handleAppend(FD fd, const void *buf, jint len); void fileDescriptorClose(JNIEnv *env, jobject this); JNIEXPORT jlong JNICALL handleLseek(FD fd, jlong offset, jint whence); +jboolean handleIsRegularFile(JNIEnv* env, FD fd); /* * Returns an opaque handle to file named by "path". If an error occurs, @@ -82,6 +83,7 @@ FD getFD(JNIEnv *env, jobject cur, jfieldID fid); #define IO_Available handleAvailable #define IO_SetLength handleSetLength #define IO_GetLength handleGetLength +#define IO_IsRegularFile handleIsRegularFile /* * Setting the handle field in Java_java_io_FileDescriptor_set for diff --git a/src/java.base/windows/native/libjli/java_md.c b/src/java.base/windows/native/libjli/java_md.c index 6ff155bcb9b..a1012bcc4f9 100644 --- a/src/java.base/windows/native/libjli/java_md.c +++ b/src/java.base/windows/native/libjli/java_md.c @@ -45,9 +45,9 @@ /* * Prototypes. */ -static jboolean GetJVMPath(const char *jrepath, const char *jvmtype, +static jboolean GetJVMPath(const char *jdkroot, const char *jvmtype, char *jvmpath, jint jvmpathsize); -static jboolean GetJREPath(char *path, jint pathsize); +static jboolean GetJDKInstallRoot(char *path, jint pathsize); /* We supports warmup for UI stack that is performed in parallel * to VM initialization. @@ -152,7 +152,7 @@ IsJavaw() */ void CreateExecutionEnvironment(int *pargc, char ***pargv, - char *jrepath, jint so_jrepath, + char *jdkroot, jint so_jdkroot, char *jvmpath, jint so_jvmpath, char *jvmcfg, jint so_jvmcfg) { @@ -160,14 +160,14 @@ CreateExecutionEnvironment(int *pargc, char ***pargv, int i = 0; char** argv = *pargv; - /* Find out where the JRE is that we will be using. */ - if (!GetJREPath(jrepath, so_jrepath)) { - JLI_ReportErrorMessage(JRE_ERROR1); + /* Find out where the JDK is that we will be using. */ + if (!GetJDKInstallRoot(jdkroot, so_jdkroot)) { + JLI_ReportErrorMessage(LAUNCHER_ERROR1); exit(2); } JLI_Snprintf(jvmcfg, so_jvmcfg, "%s%slib%sjvm.cfg", - jrepath, FILESEP, FILESEP); + jdkroot, FILESEP, FILESEP); /* Find the specified JVM type */ if (ReadKnownVMs(jvmcfg, JNI_FALSE) < 1) { @@ -182,7 +182,7 @@ CreateExecutionEnvironment(int *pargc, char ***pargv, } jvmpath[0] = '\0'; - if (!GetJVMPath(jrepath, jvmtype, jvmpath, so_jvmpath)) { + if (!GetJVMPath(jdkroot, jvmtype, jvmpath, so_jvmpath)) { JLI_ReportErrorMessage(CFG_ERROR8, jvmtype, jvmpath); exit(4); } @@ -223,18 +223,18 @@ LoadMSVCRT() if (!loaded) { /* - * The Microsoft C Runtime Library needs to be loaded first. A copy is - * assumed to be present in the "JRE path" directory. If it is not found - * there (or "JRE path" fails to resolve), skip the explicit load and let - * nature take its course, which is likely to be a failure to execute. - * The makefiles will provide the correct lib contained in quotes in the - * macro MSVCR_DLL_NAME. + * The Microsoft C Runtime Library needs to be loaded first. A copy is + * assumed to be present in the "bin" directory of the JDK installation root. + * If it is not found there (or the JDK installation root fails to resolve), + * skip the explicit load and let nature take its course, which is likely to + * be a failure to execute. The makefiles will provide the correct lib contained + * in quotes in the macro MSVCR_DLL_NAME. */ #ifdef MSVCR_DLL_NAME - if (GetJREPath(crtpath, MAXPATHLEN)) { + if (GetJDKInstallRoot(crtpath, MAXPATHLEN)) { if (JLI_StrLen(crtpath) + JLI_StrLen("\\bin\\") + JLI_StrLen(MSVCR_DLL_NAME) >= MAXPATHLEN) { - JLI_ReportErrorMessage(JRE_ERROR11); + JLI_ReportErrorMessage(LAUNCHER_ERROR3); return JNI_FALSE; } (void)JLI_StrCat(crtpath, "\\bin\\" MSVCR_DLL_NAME); /* Add crt dll */ @@ -248,10 +248,10 @@ LoadMSVCRT() } #endif /* MSVCR_DLL_NAME */ #ifdef VCRUNTIME_1_DLL_NAME - if (GetJREPath(crtpath, MAXPATHLEN)) { + if (GetJDKInstallRoot(crtpath, MAXPATHLEN)) { if (JLI_StrLen(crtpath) + JLI_StrLen("\\bin\\") + JLI_StrLen(VCRUNTIME_1_DLL_NAME) >= MAXPATHLEN) { - JLI_ReportErrorMessage(JRE_ERROR11); + JLI_ReportErrorMessage(LAUNCHER_ERROR3); return JNI_FALSE; } (void)JLI_StrCat(crtpath, "\\bin\\" VCRUNTIME_1_DLL_NAME); /* Add crt dll */ @@ -265,10 +265,10 @@ LoadMSVCRT() } #endif /* VCRUNTIME_1_DLL_NAME */ #ifdef MSVCP_DLL_NAME - if (GetJREPath(crtpath, MAXPATHLEN)) { + if (GetJDKInstallRoot(crtpath, MAXPATHLEN)) { if (JLI_StrLen(crtpath) + JLI_StrLen("\\bin\\") + JLI_StrLen(MSVCP_DLL_NAME) >= MAXPATHLEN) { - JLI_ReportErrorMessage(JRE_ERROR11); + JLI_ReportErrorMessage(LAUNCHER_ERROR3); return JNI_FALSE; } (void)JLI_StrCat(crtpath, "\\bin\\" MSVCP_DLL_NAME); /* Add prt dll */ @@ -288,47 +288,47 @@ LoadMSVCRT() /* - * Find path to JRE based on .exe's location or registry settings. + * Find path to JDK installation root based on .exe's location */ jboolean -GetJREPath(char *path, jint pathsize) +GetJDKInstallRoot(char *path, jint pathsize) { char javadll[MAXPATHLEN]; struct stat s; - JLI_TraceLauncher("Attempt to get JRE path from launcher executable path\n"); + JLI_TraceLauncher("Attempt to get JDK installation root path from launcher executable path\n"); if (GetApplicationHome(path, pathsize)) { - /* Is JRE co-located with the application? */ + /* Is the JDK co-located with the application? */ JLI_Snprintf(javadll, sizeof(javadll), "%s\\bin\\" JAVA_DLL, path); if (stat(javadll, &s) == 0) { - JLI_TraceLauncher("JRE path is %s\n", path); + JLI_TraceLauncher("JDK installation root path is %s\n", path); return JNI_TRUE; } } - JLI_TraceLauncher("Attempt to get JRE path from shared lib of the image\n"); + JLI_TraceLauncher("Attempt to get JDK installation root path from shared lib of the image\n"); - /* Try getting path to JRE from path to JLI.DLL */ + /* Try getting path to JDK from path to JLI.DLL */ if (GetApplicationHomeFromDll(path, pathsize)) { JLI_Snprintf(javadll, sizeof(javadll), "%s\\bin\\" JAVA_DLL, path); if (stat(javadll, &s) == 0) { - JLI_TraceLauncher("JRE path is %s\n", path); + JLI_TraceLauncher("JDK installation root path is %s\n", path); return JNI_TRUE; } } - JLI_ReportErrorMessage(JRE_ERROR8 JAVA_DLL); + JLI_ReportErrorMessage(LAUNCHER_ERROR2 JAVA_DLL); return JNI_FALSE; } /* - * Given a JRE location and a JVM type, construct what the name the + * Given a JDK installation location and a JVM type, construct what the name the * JVM shared library will be. Return true, if such a library * exists, false otherwise. */ static jboolean -GetJVMPath(const char *jrepath, const char *jvmtype, +GetJVMPath(const char *jdkroot, const char *jvmtype, char *jvmpath, jint jvmpathsize) { struct stat s; @@ -336,7 +336,7 @@ GetJVMPath(const char *jrepath, const char *jvmtype, JLI_Snprintf(jvmpath, jvmpathsize, "%s\\" JVM_DLL, jvmtype); } else { JLI_Snprintf(jvmpath, jvmpathsize, "%s\\bin\\%s\\" JVM_DLL, - jrepath, jvmtype); + jdkroot, jvmtype); } if (stat(jvmpath, &s) == 0) { return JNI_TRUE; @@ -356,10 +356,11 @@ LoadJavaVM(const char *jvmpath, InvocationFunctions *ifn) JLI_TraceLauncher("JVM path is %s\n", jvmpath); /* - * The Microsoft C Runtime Library needs to be loaded first. A copy is - * assumed to be present in the "JRE path" directory. If it is not found - * there (or "JRE path" fails to resolve), skip the explicit load and let - * nature take its course, which is likely to be a failure to execute. + * The Microsoft C Runtime Library needs to be loaded first. A copy is + * assumed to be present within the JDK. If it is not found there + * (or the JDK installation root fails to resolve), skip the explicit + * load and let nature take its course, which is likely to be a failure + * to execute. * */ LoadMSVCRT(); @@ -403,7 +404,7 @@ TruncatePath(char *buf) } /* - * Retrieves the path to the JRE home by locating the executable file + * Retrieves the path to the JDK home by locating the executable file * of the current process and then truncating the path to the executable */ jboolean @@ -414,7 +415,7 @@ GetApplicationHome(char *buf, jint bufsize) } /* - * Retrieves the path to the JRE home by locating JLI.DLL and + * Retrieves the path to the JDK home by locating JLI.DLL and * then truncating the path to JLI.DLL */ jboolean @@ -424,7 +425,7 @@ GetApplicationHomeFromDll(char *buf, jint bufsize) DWORD flags = GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT; - if (GetModuleHandleEx(flags, (LPCSTR)&GetJREPath, &module) != 0) { + if (GetModuleHandleEx(flags, (LPCSTR)&GetJDKInstallRoot, &module) != 0) { if (GetModuleFileName(module, buf, bufsize) != 0) { return TruncatePath(buf); } @@ -659,7 +660,7 @@ static HMODULE hSplashLib = NULL; void* SplashProcAddress(const char* name) { char libraryPath[MAXPATHLEN]; /* some extra space for JLI_StrCat'ing SPLASHSCREEN_SO */ - if (!GetJREPath(libraryPath, MAXPATHLEN)) { + if (!GetJDKInstallRoot(libraryPath, MAXPATHLEN)) { return NULL; } if (JLI_StrLen(libraryPath)+JLI_StrLen(SPLASHSCREEN_SO) >= MAXPATHLEN) { @@ -830,7 +831,7 @@ int AWTPreload(const char *funcName) if (hPreloadAwt == NULL) { /* awt.dll is not loaded yet */ char libraryPath[MAXPATHLEN]; - size_t jrePathLen = 0; + size_t jdkRootPathLen = 0; HMODULE hJava = NULL; HMODULE hVerify = NULL; @@ -839,18 +840,18 @@ int AWTPreload(const char *funcName) * jvm.dll is already loaded, so we need only java.dll; * java.dll depends on MSVCRT lib & verify.dll. */ - if (!GetJREPath(libraryPath, MAXPATHLEN)) { + if (!GetJDKInstallRoot(libraryPath, MAXPATHLEN)) { break; } /* save path length */ - jrePathLen = JLI_StrLen(libraryPath); + jdkRootPathLen = JLI_StrLen(libraryPath); - if (jrePathLen + JLI_StrLen("\\bin\\verify.dll") >= MAXPATHLEN) { - /* jre path is too long, the library path will not fit there; + if (jdkRootPathLen + JLI_StrLen("\\bin\\verify.dll") >= MAXPATHLEN) { + /* path is too long, the library path will not fit there; * report and abort preloading */ - JLI_ReportErrorMessage(JRE_ERROR11); + JLI_ReportErrorMessage(LAUNCHER_ERROR3); break; } @@ -864,8 +865,8 @@ int AWTPreload(const char *funcName) break; } - /* restore jrePath */ - libraryPath[jrePathLen] = 0; + /* restore libraryPath */ + libraryPath[jdkRootPathLen] = 0; /* load java.dll */ JLI_StrCat(libraryPath, "\\bin\\" JAVA_DLL); hJava = LoadLibrary(libraryPath); @@ -873,8 +874,8 @@ int AWTPreload(const char *funcName) break; } - /* restore jrePath */ - libraryPath[jrePathLen] = 0; + /* restore libraryPath */ + libraryPath[jdkRootPathLen] = 0; /* load awt.dll */ JLI_StrCat(libraryPath, "\\bin\\awt.dll"); hPreloadAwt = LoadLibrary(libraryPath); diff --git a/src/java.compiler/share/classes/javax/lang/model/util/Elements.java b/src/java.compiler/share/classes/javax/lang/model/util/Elements.java index 5159ac26e3b..7f0b493572e 100644 --- a/src/java.compiler/share/classes/javax/lang/model/util/Elements.java +++ b/src/java.compiler/share/classes/javax/lang/model/util/Elements.java @@ -81,8 +81,8 @@ public interface Elements { * @implSpec The default implementation of this method returns * {@code null}. * - * @param name fully qualified package name, or an empty string for an unnamed package * @param module module relative to which the lookup should happen + * @param name fully qualified package name, or an empty string for an unnamed package * @return the specified package, or {@code null} if it cannot be found * @see #getAllPackageElements * @since 9 @@ -167,8 +167,8 @@ default Set getAllPackageElements(CharSequence name) { * @implSpec The default implementation of this method returns * {@code null}. * - * @param name the canonical name * @param module module relative to which the lookup should happen + * @param name the canonical name * @return the named type element, or {@code null} if it cannot be found * @see #getAllTypeElements * @since 9 diff --git a/src/java.desktop/share/classes/javax/swing/JColorChooser.java b/src/java.desktop/share/classes/javax/swing/JColorChooser.java index 945c6f60697..62c4fe8b083 100644 --- a/src/java.desktop/share/classes/javax/swing/JColorChooser.java +++ b/src/java.desktop/share/classes/javax/swing/JColorChooser.java @@ -175,7 +175,9 @@ public static Color showDialog(Component component, * @return the selected color or null if the user opted out * @throws HeadlessException if GraphicsEnvironment.isHeadless() * returns true. + * * @see java.awt.GraphicsEnvironment#isHeadless + * @since 9 */ @SuppressWarnings("deprecation") public static Color showDialog(Component component, String title, diff --git a/src/java.desktop/share/classes/javax/swing/colorchooser/AbstractColorChooserPanel.java b/src/java.desktop/share/classes/javax/swing/colorchooser/AbstractColorChooserPanel.java index 9a428492512..5664051cf6b 100644 --- a/src/java.desktop/share/classes/javax/swing/colorchooser/AbstractColorChooserPanel.java +++ b/src/java.desktop/share/classes/javax/swing/colorchooser/AbstractColorChooserPanel.java @@ -229,6 +229,7 @@ void setSelectedColor(Color color) { * * @param b true if the transparency of a color can be selected * @see #isColorTransparencySelectionEnabled() + * @since 9 */ @BeanProperty(description = "Sets the transparency of a color selection on or off.") @@ -241,6 +242,7 @@ public void setColorTransparencySelectionEnabled(boolean b){ * * @return true if the transparency of a color can be selected * @see #setColorTransparencySelectionEnabled(boolean) + * @since 9 */ public boolean isColorTransparencySelectionEnabled(){ return true; diff --git a/src/java.management/share/classes/javax/management/AttributeList.java b/src/java.management/share/classes/javax/management/AttributeList.java index 74c9b860f91..932c4974244 100644 --- a/src/java.management/share/classes/javax/management/AttributeList.java +++ b/src/java.management/share/classes/javax/management/AttributeList.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -182,9 +182,9 @@ public void add(Attribute object) { * size())} a RuntimeOperationsException should be raised, wrapping the * java.lang.IndexOutOfBoundsException thrown. * - * @param object The Attribute object to be inserted. * @param index The position in the list where the new {@code Attribute} * object is to be inserted. + * @param object The Attribute object to be inserted. */ public void add(int index, Attribute object) { try { @@ -202,8 +202,8 @@ public void add(int index, Attribute object) { * out of range {@literal (index < 0 || index > size())} a RuntimeOperationsException * should be raised, wrapping the java.lang.IndexOutOfBoundsException thrown. * - * @param object The value to which the attribute element should be set. * @param index The position specified. + * @param object The value to which the attribute element should be set. */ public void set(int index, Attribute object) { try { @@ -238,9 +238,9 @@ public boolean addAll(AttributeList list) { * RuntimeOperationsException should be raised, wrapping the * java.lang.IndexOutOfBoundsException thrown. * - * @param list Elements to be inserted into the list. * @param index Position at which to insert the first element from the * AttributeList specified. + * @param list Elements to be inserted into the list. * * @return true if this list changed as a result of the call. * diff --git a/src/java.management/share/classes/javax/management/DefaultLoaderRepository.java b/src/java.management/share/classes/javax/management/DefaultLoaderRepository.java index 461ab1ec3c4..6e846287027 100644 --- a/src/java.management/share/classes/javax/management/DefaultLoaderRepository.java +++ b/src/java.management/share/classes/javax/management/DefaultLoaderRepository.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -80,8 +80,8 @@ public static Class loadClass(String className) * is not found the method will throw a ClassNotFoundException * exception. * - * @param className The name of the class to be loaded. * @param loader The class loader to be excluded. + * @param className The name of the class to be loaded. * * @return the loaded class. * diff --git a/src/java.management/share/classes/javax/management/MBeanConstructorInfo.java b/src/java.management/share/classes/javax/management/MBeanConstructorInfo.java index f327920d7d9..5803b306bab 100644 --- a/src/java.management/share/classes/javax/management/MBeanConstructorInfo.java +++ b/src/java.management/share/classes/javax/management/MBeanConstructorInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -75,10 +75,10 @@ public MBeanConstructorInfo(String description, Constructor constructor) { * Constructs an {@code MBeanConstructorInfo} object. * * @param name The name of the constructor. + * @param description A human readable description of the constructor. * @param signature {@code MBeanParameterInfo} objects * describing the parameters(arguments) of the constructor. This * may be null with the same effect as a zero-length array. - * @param description A human readable description of the constructor. */ public MBeanConstructorInfo(String name, String description, @@ -90,10 +90,10 @@ public MBeanConstructorInfo(String name, * Constructs an {@code MBeanConstructorInfo} object. * * @param name The name of the constructor. + * @param description A human readable description of the constructor. * @param signature {@code MBeanParameterInfo} objects * describing the parameters(arguments) of the constructor. This * may be null with the same effect as a zero-length array. - * @param description A human readable description of the constructor. * @param descriptor The descriptor for the constructor. This may be null * which is equivalent to an empty descriptor. * diff --git a/src/java.management/share/classes/javax/management/MBeanOperationInfo.java b/src/java.management/share/classes/javax/management/MBeanOperationInfo.java index 5069737edef..a0c6b76a79d 100644 --- a/src/java.management/share/classes/javax/management/MBeanOperationInfo.java +++ b/src/java.management/share/classes/javax/management/MBeanOperationInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -97,9 +97,9 @@ public class MBeanOperationInfo extends MBeanFeatureInfo implements Cloneable { * fields contributed by any annotations on the {@code Method} * object that contain the {@link DescriptorKey} meta-annotation. * + * @param description A human readable description of the operation. * @param method The {@code java.lang.reflect.Method} object * describing the MBean operation. - * @param description A human readable description of the operation. */ public MBeanOperationInfo(String description, Method method) { this(method.getName(), diff --git a/src/java.management/share/classes/javax/management/MBeanServer.java b/src/java.management/share/classes/javax/management/MBeanServer.java index 8bf68ef35bf..488c9615515 100644 --- a/src/java.management/share/classes/javax/management/MBeanServer.java +++ b/src/java.management/share/classes/javax/management/MBeanServer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -622,11 +622,11 @@ public Object instantiate(String className, Object params[], * newly created object is not registered in the MBean server.

    * * @param className The class name of the object to be instantiated. + * @param loaderName The object name of the class loader to be used. * @param params An array containing the parameters of the * constructor to be invoked. * @param signature An array containing the signature of the * constructor to be invoked. - * @param loaderName The object name of the class loader to be used. * * @return The newly instantiated object. * @@ -711,10 +711,10 @@ default public ObjectInputStream deserialize(String className, byte[] data) * * @param className The name of the class whose class loader should be * used for the de-serialization. - * @param data The byte array to be de-sererialized. * @param loaderName The name of the class loader to be used for * loading the specified class. If null, the MBean Server's class * loader will be used. + * @param data The byte array to be de-sererialized. * * @implSpec This method throws {@link UnsupportedOperationException} by default. * diff --git a/src/java.management/share/classes/javax/management/MBeanServerConnection.java b/src/java.management/share/classes/javax/management/MBeanServerConnection.java index 87764b81c91..22b68f19123 100644 --- a/src/java.management/share/classes/javax/management/MBeanServerConnection.java +++ b/src/java.management/share/classes/javax/management/MBeanServerConnection.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -278,11 +278,11 @@ public ObjectInstance createMBean(String className, ObjectName name, * * @param className The class name of the MBean to be instantiated. * @param name The object name of the MBean. May be null. + * @param loaderName The object name of the class loader to be used. * @param params An array containing the parameters of the * constructor to be invoked. * @param signature An array containing the signature of the * constructor to be invoked. - * @param loaderName The object name of the class loader to be used. * * @return An ObjectInstance, containing the * ObjectName and the Java class name of the newly diff --git a/src/java.management/share/classes/javax/management/loading/ClassLoaderRepository.java b/src/java.management/share/classes/javax/management/loading/ClassLoaderRepository.java index 3512f51238c..ecd46e8a66d 100644 --- a/src/java.management/share/classes/javax/management/loading/ClassLoaderRepository.java +++ b/src/java.management/share/classes/javax/management/loading/ClassLoaderRepository.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -100,10 +100,10 @@ public Class loadClass(String className) * the same time. The {@link #loadClassBefore} method is * recommended to avoid the risk of deadlock.

    * - * @param className The name of the class to be loaded. * @param exclude The class loader to be excluded. May be null, * in which case this method is equivalent to {@link #loadClass * loadClass(className)}. + * @param className The name of the class to be loaded. * * @return the loaded class. * @@ -133,10 +133,10 @@ public Class loadClassWithout(ClassLoader exclude, * search as soon as stop is reached, a potential * deadlock with concurrent class loading is avoided.

    * - * @param className The name of the class to be loaded. * @param stop The class loader at which to stop. May be null, in * which case this method is equivalent to {@link #loadClass(String) * loadClass(className)}. + * @param className The name of the class to be loaded. * * @return the loaded class. * diff --git a/src/java.management/share/classes/javax/management/loading/DefaultLoaderRepository.java b/src/java.management/share/classes/javax/management/loading/DefaultLoaderRepository.java index 014ed0fccf6..6277c6d1317 100644 --- a/src/java.management/share/classes/javax/management/loading/DefaultLoaderRepository.java +++ b/src/java.management/share/classes/javax/management/loading/DefaultLoaderRepository.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -88,8 +88,8 @@ public static Class loadClass(String className) * is not found the method will throw a ClassNotFoundException * exception. * - * @param className The name of the class to be loaded. * @param loader The class loader to be excluded. + * @param className The name of the class to be loaded. * * @return the loaded class. * diff --git a/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanOperationInfo.java b/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanOperationInfo.java index 1d22b41b1e8..4120bc2cd2d 100644 --- a/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanOperationInfo.java +++ b/src/java.management/share/classes/javax/management/modelmbean/ModelMBeanOperationInfo.java @@ -136,9 +136,9 @@ public class ModelMBeanOperationInfo extends MBeanOperationInfo * on the {@code Method} object that contain the {@link * DescriptorKey} meta-annotation. * + * @param description A human readable description of the operation. * @param operationMethod The java.lang.reflect.Method object * describing the MBean operation. - * @param description A human readable description of the operation. */ public ModelMBeanOperationInfo(String description, @@ -160,10 +160,10 @@ public ModelMBeanOperationInfo(String description, * contributed by any annotations on the {@code Method} object * that contain the {@link DescriptorKey} meta-annotation. * - * @param operationMethod The java.lang.reflect.Method object - * describing the MBean operation. * @param description A human readable description of the * operation. + * @param operationMethod The java.lang.reflect.Method object + * describing the MBean operation. * @param descriptor An instance of Descriptor containing the * appropriate metadata for this instance of the * ModelMBeanOperationInfo. If it is null a default diff --git a/src/java.naming/share/classes/javax/naming/CompositeName.java b/src/java.naming/share/classes/javax/naming/CompositeName.java index d731c20facc..021a2f59044 100644 --- a/src/java.naming/share/classes/javax/naming/CompositeName.java +++ b/src/java.naming/share/classes/javax/naming/CompositeName.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -485,9 +485,9 @@ public Name addAll(Name suffix) * new component are shifted up (away from index 0) * to accommodate the new components. * - * @param n The non-null components to add. * @param posn The index in this name at which to add the new * components. Must be in the range [0,size()]. + * @param n The non-null components to add. * @return The updated CompositeName, not a new one. Cannot be null. * @throws InvalidNameException If n is not a composite name. * @throws ArrayIndexOutOfBoundsException @@ -525,9 +525,9 @@ public Name add(String comp) throws InvalidNameException { * component are shifted up by one (away from index 0) to accommodate * the new component. * - * @param comp The non-null component to add. * @param posn The index at which to add the new component. * Must be in the range [0,size()]. + * @param comp The non-null component to add. * @return The updated CompositeName, not a new one. Cannot be null. * @throws ArrayIndexOutOfBoundsException * If posn is outside the specified range. diff --git a/src/java.naming/share/classes/javax/naming/CompoundName.java b/src/java.naming/share/classes/javax/naming/CompoundName.java index ec570acbb34..e66d9d1b434 100644 --- a/src/java.naming/share/classes/javax/naming/CompoundName.java +++ b/src/java.naming/share/classes/javax/naming/CompoundName.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -472,9 +472,9 @@ public Name addAll(Name suffix) throws InvalidNameException { * Implementation note: Currently the syntax properties of suffix * is not used or checked. They might be in the future. * - * @param n The non-null components to add. * @param posn The index in this name at which to add the new * components. Must be in the range [0,size()]. + * @param n The non-null components to add. * @return The updated CompoundName, not a new one. Cannot be null. * @throws ArrayIndexOutOfBoundsException * If posn is outside the specified range. @@ -512,9 +512,9 @@ public Name add(String comp) throws InvalidNameException{ * component are shifted up by one (away from index 0) * to accommodate the new component. * - * @param comp The non-null component to add. * @param posn The index at which to add the new component. * Must be in the range [0,size()]. + * @param comp The non-null component to add. * @throws ArrayIndexOutOfBoundsException * If posn is outside the specified range. * @return The updated CompoundName, not a new one. Cannot be null. diff --git a/src/java.naming/share/classes/javax/naming/Name.java b/src/java.naming/share/classes/javax/naming/Name.java index 163b9507176..24865fb64e4 100644 --- a/src/java.naming/share/classes/javax/naming/Name.java +++ b/src/java.naming/share/classes/javax/naming/Name.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -215,11 +215,11 @@ public interface Name * component are shifted up (away from 0) to accommodate the new * components. * - * @param n - * the components to add * @param posn * the index in this name at which to add the new * components. Must be in the range [0,size()]. + * @param n + * the components to add * @return the updated name (not a new one) * * @throws ArrayIndexOutOfBoundsException @@ -248,11 +248,11 @@ public interface Name * are shifted up by one (away from index 0) to accommodate the new * component. * - * @param comp - * the component to add * @param posn * the index at which to add the new component. * Must be in the range [0,size()]. + * @param comp + * the component to add * @return the updated name (not a new one) * * @throws ArrayIndexOutOfBoundsException diff --git a/src/java.naming/share/classes/javax/naming/Reference.java b/src/java.naming/share/classes/javax/naming/Reference.java index 789ddb95195..3d096f4b84f 100644 --- a/src/java.naming/share/classes/javax/naming/Reference.java +++ b/src/java.naming/share/classes/javax/naming/Reference.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -164,10 +164,10 @@ public Reference(String className, String factory, String factoryLocation) { * * @param className The non-null class name of the object to * which this reference refers. + * @param addr The non-null address of the object. * @param factory The possibly null class name of the object's factory. * @param factoryLocation The possibly null location from which * to load the factory (e.g. URL) - * @param addr The non-null address of the object. * @see javax.naming.spi.ObjectFactory * @see javax.naming.spi.NamingManager#getObjectInstance */ diff --git a/src/java.naming/share/classes/javax/naming/directory/SearchControls.java b/src/java.naming/share/classes/javax/naming/directory/SearchControls.java index 6d7cc4bb6cd..8d1f04e06ff 100644 --- a/src/java.naming/share/classes/javax/naming/directory/SearchControls.java +++ b/src/java.naming/share/classes/javax/naming/directory/SearchControls.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2000, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -163,16 +163,16 @@ public SearchControls() { * Constructs a search constraints using arguments. * @param scope The search scope. One of: * OBJECT_SCOPE, ONELEVEL_SCOPE, SUBTREE_SCOPE. - * @param timelim The number of milliseconds to wait before returning. - * If 0, wait indefinitely. - * @param deref If true, dereference links during search. * @param countlim The maximum number of entries to return. If 0, return * all entries that satisfy filter. - * @param retobj If true, return the object bound to the name of the - * entry; if false, do not return object. + * @param timelim The number of milliseconds to wait before returning. + * If 0, wait indefinitely. * @param attrs The identifiers of the attributes to return along with * the entry. If null, return all attributes. If empty * return no attributes. + * @param retobj If true, return the object bound to the name of the + * entry; if false, do not return object. + * @param deref If true, dereference links during search. */ public SearchControls(int scope, long countlim, diff --git a/src/java.naming/share/classes/javax/naming/ldap/LdapName.java b/src/java.naming/share/classes/javax/naming/ldap/LdapName.java index 773f3b534b4..bca85cbc11c 100644 --- a/src/java.naming/share/classes/javax/naming/ldap/LdapName.java +++ b/src/java.naming/share/classes/javax/naming/ldap/LdapName.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -436,9 +436,9 @@ public Name addAll(List suffixRdns) { * index (if any) of the first new component are shifted up * (away from index 0) to accommodate the new components. * - * @param suffix The non-null components to add. * @param posn The index at which to add the new component. * Must be in the range [0,size()]. + * @param suffix The non-null components to add. * * @return The updated name (not a new instance). * @@ -471,9 +471,9 @@ public Name addAll(int posn, Name suffix) * index (if any) of the first new RDN are shifted up (away from index 0) to * accommodate the new RDNs. * - * @param suffixRdns The non-null suffix {@code Rdn}s to add. * @param posn The index at which to add the suffix RDNs. * Must be in the range [0,size()]. + * @param suffixRdns The non-null suffix {@code Rdn}s to add. * * @return The updated name (not a new instance). * @throws IndexOutOfBoundsException @@ -524,9 +524,9 @@ public Name add(Rdn comp) { * component are shifted up by one (away from index 0) to accommodate * the new component. * - * @param comp The non-null component to add. * @param posn The index at which to add the new component. * Must be in the range [0,size()]. + * @param comp The non-null component to add. * @return The updated LdapName, not a new instance. * Cannot be null. * @exception IndexOutOfBoundsException @@ -548,9 +548,9 @@ public Name add(int posn, String comp) throws InvalidNameException { * RDN are shifted up by one (away from index 0) to accommodate * the new RDN. * - * @param comp The non-null RDN to add. * @param posn The index at which to add the new RDN. * Must be in the range [0,size()]. + * @param comp The non-null RDN to add. * @return The updated LdapName, not a new instance. * Cannot be null. * @exception IndexOutOfBoundsException diff --git a/src/java.naming/share/classes/javax/naming/ldap/LdapReferralException.java b/src/java.naming/share/classes/javax/naming/ldap/LdapReferralException.java index 95a1ca7df0e..70009333f10 100644 --- a/src/java.naming/share/classes/javax/naming/ldap/LdapReferralException.java +++ b/src/java.naming/share/classes/javax/naming/ldap/LdapReferralException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -143,11 +143,11 @@ protected LdapReferralException() { * Service provider implementors should read the "Service Provider" section * in the {@code LdapContext} class description for implementation details. * - * @param reqCtls The possibly null request controls to use for the new context. - * If null or the empty array means use no request controls. * @param env The possibly null environment properties to use when * for the new context. If null, the context is initialized with no environment * properties. + * @param reqCtls The possibly null request controls to use for the new context. + * If null or the empty array means use no request controls. * @return The non-null context at which to continue the method. * @throws NamingException If a naming exception was encountered. * Call either {@code retryReferral()} or {@code skipReferral()} diff --git a/src/java.prefs/unix/classes/java/util/prefs/FileSystemPreferences.java b/src/java.prefs/unix/classes/java/util/prefs/FileSystemPreferences.java index 5f0531c0ff7..756eedade72 100644 --- a/src/java.prefs/unix/classes/java/util/prefs/FileSystemPreferences.java +++ b/src/java.prefs/unix/classes/java/util/prefs/FileSystemPreferences.java @@ -450,7 +450,7 @@ private void replayChanges() { changeLog.get(i).replay(); } - private static Timer syncTimer = new Timer(true); // Daemon Thread + private static final Timer syncTimer = new Timer(true); // Daemon Thread static { addShutdownHook(); @@ -540,7 +540,7 @@ public Void run() { } }); if (newNode) { - // These 2 things guarantee node will get wrtten at next flush/sync + // These 2 things guarantee node will get written at next flush/sync prefsCache = new TreeMap<>(); nodeCreate = new NodeCreate(); changeLog.add(nodeCreate); @@ -1008,12 +1008,12 @@ private void checkLockFile0ErrorCode (int errorCode) * Initial time between lock attempts, in ms. The time is doubled * after each failing attempt (except the first). */ - private static int INIT_SLEEP_TIME = 50; + private static final int INIT_SLEEP_TIME = 50; /** * Maximum number of lock attempts. */ - private static int MAX_ATTEMPTS = 5; + private static final int MAX_ATTEMPTS = 5; /** * Release the appropriate file lock (user or system). diff --git a/src/java.scripting/share/classes/javax/script/Invocable.java b/src/java.scripting/share/classes/javax/script/Invocable.java index 1fda248a521..87a9624fecd 100644 --- a/src/java.scripting/share/classes/javax/script/Invocable.java +++ b/src/java.scripting/share/classes/javax/script/Invocable.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,13 +38,13 @@ public interface Invocable { * Calls a method on a script object compiled during a previous script execution, * which is retained in the state of the ScriptEngine. * - * @param name The name of the procedure to be called. - * * @param thiz If the procedure is a member of a class * defined in the script and thiz is an instance of that class * returned by a previous execution or invocation, the named method is * called through that instance. * + * @param name The name of the procedure to be called. + * * @param args Arguments to pass to the procedure. The rules for converting * the arguments to scripting variables are implementation-specific. * diff --git a/src/java.smartcardio/unix/legal/pcsclite.md b/src/java.smartcardio/unix/legal/pcsclite.md index 99a9936a477..66cdf62ee15 100644 --- a/src/java.smartcardio/unix/legal/pcsclite.md +++ b/src/java.smartcardio/unix/legal/pcsclite.md @@ -1,4 +1,4 @@ -## PC/SC Lite v1.9.9 +## PC/SC Lite v2.3.0 ### PC/SC Lite Notice ``` @@ -9,19 +9,19 @@ Only 3 header files are included in this distribution: winscard.h, wintypes.h, p Copyright for winscard.h: * Copyright (C) 1999-2003 * David Corcoran - * Copyright (C) 2002-2009 + * Copyright (C) 2002-2018 * Ludovic Rousseau Copyright for wintypes.h: * Copyright (C) 1999 * David Corcoran - * Copyright (C) 2002-2011 + * Copyright (C) 2002-2018 * Ludovic Rousseau Copyright for pcsclite.h: * Copyright (C) 1999-2004 * David Corcoran - * Copyright (C) 2002-2011 + * Copyright (C) 2002-2024 * Ludovic Rousseau * Copyright (C) 2005 * Martin Paljak diff --git a/src/java.smartcardio/unix/native/libj2pcsc/MUSCLE/pcsclite.h b/src/java.smartcardio/unix/native/libj2pcsc/MUSCLE/pcsclite.h index e722b13a730..f589868a7ba 100644 --- a/src/java.smartcardio/unix/native/libj2pcsc/MUSCLE/pcsclite.h +++ b/src/java.smartcardio/unix/native/libj2pcsc/MUSCLE/pcsclite.h @@ -3,7 +3,7 @@ * * Copyright (C) 1999-2004 * David Corcoran - * Copyright (C) 2002-2011 + * Copyright (C) 2002-2024 * Ludovic Rousseau * Copyright (C) 2005 * Martin Paljak @@ -192,7 +192,8 @@ extern const SCARD_IO_REQUEST g_rgSCardT0Pci, g_rgSCardT1Pci, g_rgSCardRawPci; /** @ingroup ErrorCodes */ #define SCARD_E_INVALID_CHV ((LONG)0x8010002A) /**< The supplied PIN is incorrect. */ /** @ingroup ErrorCodes */ -#define SCARD_E_UNKNOWN_RES_MNG ((LONG)0x8010002B) /**< An unrecognized error code was returned from a layered component. */ +#define SCARD_E_UNKNOWN_RES_MSG ((LONG)0x8010002B) /**< An unrecognized error code was returned from a layered component. */ +#define SCARD_E_UNKNOWN_RES_MNG SCARD_E_UNKNOWN_RES_MSG /** @ingroup ErrorCodes */ #define SCARD_E_NO_SUCH_CERTIFICATE ((LONG)0x8010002C) /**< The requested certificate does not exist. */ /** @ingroup ErrorCodes */ @@ -279,7 +280,7 @@ extern const SCARD_IO_REQUEST g_rgSCardT0Pci, g_rgSCardT1Pci, g_rgSCardRawPci; #define INFINITE 0xFFFFFFFF /**< Infinite timeout */ #endif -#define PCSCLITE_VERSION_NUMBER "1.9.9" /**< Current version */ +#define PCSCLITE_VERSION_NUMBER "2.3.0" /**< Current version */ /** Maximum readers context (a slot is count as a reader) */ #define PCSCLITE_MAX_READERS_CONTEXTS 16 diff --git a/src/java.smartcardio/unix/native/libj2pcsc/MUSCLE/winscard.h b/src/java.smartcardio/unix/native/libj2pcsc/MUSCLE/winscard.h index d2c5a5758b5..f9a4265de85 100644 --- a/src/java.smartcardio/unix/native/libj2pcsc/MUSCLE/winscard.h +++ b/src/java.smartcardio/unix/native/libj2pcsc/MUSCLE/winscard.h @@ -3,7 +3,7 @@ * * Copyright (C) 1999-2003 * David Corcoran - * Copyright (C) 2002-2009 + * Copyright (C) 2002-2018 * Ludovic Rousseau * Redistribution and use in source and binary forms, with or without diff --git a/src/java.smartcardio/unix/native/libj2pcsc/MUSCLE/wintypes.h b/src/java.smartcardio/unix/native/libj2pcsc/MUSCLE/wintypes.h index 3770de20909..5e8973a0993 100644 --- a/src/java.smartcardio/unix/native/libj2pcsc/MUSCLE/wintypes.h +++ b/src/java.smartcardio/unix/native/libj2pcsc/MUSCLE/wintypes.h @@ -3,7 +3,7 @@ * * Copyright (C) 1999 * David Corcoran - * Copyright (C) 2002-2011 + * Copyright (C) 2002-2018 * Ludovic Rousseau * Redistribution and use in source and binary forms, with or without diff --git a/src/java.sql.rowset/share/classes/javax/sql/rowset/CachedRowSet.java b/src/java.sql.rowset/share/classes/javax/sql/rowset/CachedRowSet.java index c10cefef290..e9efa2c7118 100644 --- a/src/java.sql.rowset/share/classes/javax/sql/rowset/CachedRowSet.java +++ b/src/java.sql.rowset/share/classes/javax/sql/rowset/CachedRowSet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -1561,10 +1561,10 @@ public interface CachedRowSet extends RowSet, Joinable { * method is more a matter of convenience when compared to using the version * of execute that takes a ResultSet object. * - * @param startRow the position in the ResultSet from where to start - * populating the records in this CachedRowSet * @param rs the ResultSet object containing the data * to be read into this CachedRowSet object + * @param startRow the position in the ResultSet from where to start + * populating the records in this CachedRowSet * @throws SQLException if a null ResultSet object is supplied * or this CachedRowSet object cannot * retrieve the associated ResultSetMetaData object diff --git a/src/java.xml/share/classes/javax/xml/stream/XMLEventFactory.java b/src/java.xml/share/classes/javax/xml/stream/XMLEventFactory.java index 6ca9768915c..d47f4d0e122 100644 --- a/src/java.xml/share/classes/javax/xml/stream/XMLEventFactory.java +++ b/src/java.xml/share/classes/javax/xml/stream/XMLEventFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -258,9 +258,9 @@ public abstract StartElement createStartElement(QName name, * an empty NamespaceContext. Querying this event for its namespaces or * attributes will result in an empty iterator being returned. * + * @param prefix the prefix of the QName of the new StartElement * @param namespaceUri the uri of the QName of the new StartElement * @param localName the local name of the QName of the new StartElement - * @param prefix the prefix of the QName of the new StartElement * @return an instance of the requested StartElement */ public abstract StartElement createStartElement(String prefix, @@ -272,9 +272,9 @@ public abstract StartElement createStartElement(String prefix, * Attributes can be added to this StartElement by passing an iterator * that walks over a set of Attribute interfaces. * + * @param prefix the prefix of the QName of the new StartElement * @param namespaceUri the uri of the QName of the new StartElement * @param localName the local name of the QName of the new StartElement - * @param prefix the prefix of the QName of the new StartElement * @param attributes an unordered set of objects that implement * Attribute to add to the new StartElement * @param namespaces an unordered set of objects that implement @@ -293,9 +293,9 @@ public abstract StartElement createStartElement(String prefix, * Attributes can be added to this StartElement by passing an iterator * that walks over a set of Attribute interfaces. * + * @param prefix the prefix of the QName of the new StartElement * @param namespaceUri the uri of the QName of the new StartElement * @param localName the local name of the QName of the new StartElement - * @param prefix the prefix of the QName of the new StartElement * @param attributes an unordered set of objects that implement * Attribute to add to the new StartElement, may be null * @param namespaces an unordered set of objects that implement @@ -323,9 +323,9 @@ public abstract EndElement createEndElement(QName name, /** * Create a new EndElement + * @param prefix the prefix of the QName of the new StartElement * @param namespaceUri the uri of the QName of the new StartElement * @param localName the local name of the QName of the new StartElement - * @param prefix the prefix of the QName of the new StartElement * @return an instance of the requested EndElement */ public abstract EndElement createEndElement(String prefix, @@ -333,9 +333,9 @@ public abstract EndElement createEndElement(String prefix, String localName); /** * Create a new EndElement + * @param prefix the prefix of the QName of the new StartElement * @param namespaceUri the uri of the QName of the new StartElement * @param localName the local name of the QName of the new StartElement - * @param prefix the prefix of the QName of the new StartElement * @param namespaces an unordered set of objects that implement * Namespace that have gone out of scope, may be null * @return an instance of the requested EndElement diff --git a/src/java.xml/share/classes/javax/xml/stream/XMLStreamException.java b/src/java.xml/share/classes/javax/xml/stream/XMLStreamException.java index 47ef2e437c9..a6bac73e528 100644 --- a/src/java.xml/share/classes/javax/xml/stream/XMLStreamException.java +++ b/src/java.xml/share/classes/javax/xml/stream/XMLStreamException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -77,8 +77,8 @@ public XMLStreamException(Throwable th) { /** * Construct an exception with the associated message and exception * - * @param th a nested exception * @param msg the message to report + * @param th a nested exception */ public XMLStreamException(String msg, Throwable th) { super(msg, th); @@ -88,9 +88,9 @@ public XMLStreamException(String msg, Throwable th) { /** * Construct an exception with the associated message, exception and location. * - * @param th a nested exception * @param msg the message to report * @param location the location of the error + * @param th a nested exception */ public XMLStreamException(String msg, Location location, Throwable th) { super("ParseError at [row,col]:["+location.getLineNumber()+","+ diff --git a/src/java.xml/share/classes/javax/xml/stream/XMLStreamWriter.java b/src/java.xml/share/classes/javax/xml/stream/XMLStreamWriter.java index 7cd383245a8..9f0f49776e5 100644 --- a/src/java.xml/share/classes/javax/xml/stream/XMLStreamWriter.java +++ b/src/java.xml/share/classes/javax/xml/stream/XMLStreamWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -209,8 +209,8 @@ public void writeStartElement(String namespaceURI, String localName) /** * Writes a start tag to the output - * @param localName local name of the tag, may not be null * @param prefix the prefix of the tag, may not be null + * @param localName local name of the tag, may not be null * @param namespaceURI the uri to bind the prefix to, may not be null * @throws XMLStreamException if an error occurs */ diff --git a/src/java.xml/share/classes/javax/xml/transform/TransformerConfigurationException.java b/src/java.xml/share/classes/javax/xml/transform/TransformerConfigurationException.java index a90e29121a8..9c0b9a4be5b 100644 --- a/src/java.xml/share/classes/javax/xml/transform/TransformerConfigurationException.java +++ b/src/java.xml/share/classes/javax/xml/transform/TransformerConfigurationException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -67,9 +67,9 @@ public TransformerConfigurationException(Throwable e) { * Create a new TransformerConfigurationException with the * given Exception base cause and detail message. * + * @param msg The detail message. * @param e The exception to be encapsulated in a * TransformerConfigurationException - * @param msg The detail message. */ public TransformerConfigurationException(String msg, Throwable e) { super(msg, e); diff --git a/src/java.xml/share/classes/javax/xml/validation/SchemaFactoryConfigurationError.java b/src/java.xml/share/classes/javax/xml/validation/SchemaFactoryConfigurationError.java index 47c4dda1ee6..b61060b7404 100644 --- a/src/java.xml/share/classes/javax/xml/validation/SchemaFactoryConfigurationError.java +++ b/src/java.xml/share/classes/javax/xml/validation/SchemaFactoryConfigurationError.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -69,9 +69,9 @@ public SchemaFactoryConfigurationError(Throwable cause) { * Create a new SchemaFactoryConfigurationError with the * given Throwable base cause and detail message. * + * @param message The detail message. * @param cause The exception or error to be encapsulated in a * SchemaFactoryConfigurationError. - * @param message The detail message. */ public SchemaFactoryConfigurationError(String message, Throwable cause) { super(message, cause); diff --git a/src/jdk.attach/share/classes/sun/tools/attach/HotSpotVirtualMachine.java b/src/jdk.attach/share/classes/sun/tools/attach/HotSpotVirtualMachine.java index 93656cdf513..10d23f33535 100644 --- a/src/jdk.attach/share/classes/sun/tools/attach/HotSpotVirtualMachine.java +++ b/src/jdk.attach/share/classes/sun/tools/attach/HotSpotVirtualMachine.java @@ -42,6 +42,8 @@ import java.util.Properties; import java.util.stream.Collectors; +import java.nio.charset.StandardCharsets; + /* * The HotSpot implementation of com.sun.tools.attach.VirtualMachine. */ @@ -102,7 +104,7 @@ private void loadAgentLibrary(String agentLibrary, boolean isAbsolute, String op agentLibrary, isAbsolute ? "true" : "false", options); - String result = readErrorMessage(in); + String result = readMessage(in); if (result.isEmpty()) { throw new AgentLoadException("Target VM did not respond"); } else if (result.startsWith(msgPrefix)) { @@ -327,6 +329,45 @@ public InputStream executeCommand(String cmd, Object ... args) throws IOExceptio } } + // Attach API version support + protected static final int VERSION_1 = 1; + protected static final int VERSION_2 = 2; + + /* + * Detects Attach API version supported by target VM. + */ + protected int detectVersion() throws IOException { + try { + InputStream reply = execute("getversion"); + String message = readMessage(reply); + reply.close(); + try { + int supportedVersion = Integer.parseUnsignedInt(message); + // we expect only VERSION_2 + if (supportedVersion == VERSION_2) { + return VERSION_2; + } + } catch (NumberFormatException nfe) { + // bad reply - fallback to VERSION_1 + } + } catch (AttachOperationFailedException | AgentLoadException ex) { + // the command is not supported, the VM supports VERSION_1 only + } + return VERSION_1; + } + + /* + * For testing purposes Attach API v2 may be disabled. + */ + protected boolean isAPIv2Enabled() { + // if "jdk.attach.compat" property is set, only v1 is enabled. + try { + String value = System.getProperty("jdk.attach.compat"); + return !("true".equalsIgnoreCase(value)); + } catch (SecurityException se) { + } + return true; + } /* * Utility method to read an 'int' from the input stream. Ideally @@ -367,7 +408,7 @@ int readInt(InputStream in) throws IOException { /* * Utility method to read data into a String. */ - String readErrorMessage(InputStream in) throws IOException { + String readMessage(InputStream in) throws IOException { String s; StringBuilder message = new StringBuilder(); BufferedReader br = new BufferedReader(new InputStreamReader(in)); @@ -400,7 +441,7 @@ void processCompletionStatus(IOException ioe, String cmd, InputStream sis) throw } if (completionStatus != 0) { // read from the stream and use that as the error message - String message = readErrorMessage(sis); + String message = readMessage(sis); sis.close(); // In the event of a protocol mismatch then the target VM @@ -417,6 +458,51 @@ void processCompletionStatus(IOException ioe, String cmd, InputStream sis) throw } } + /* + * Helper writer interface to send commands to the target VM. + */ + public static interface AttachOutputStream { + abstract void write(byte[] buffer, int offset, int length) throws IOException; + } + + private int dataSize(Object obj) { + return (obj == null ? 0 : obj.toString().getBytes(StandardCharsets.UTF_8).length) + 1; + } + + /* + * Writes object (usually String or Integer) to the attach writer. + */ + private void writeString(AttachOutputStream writer, Object obj) throws IOException { + if (obj != null) { + String s = obj.toString(); + if (s.length() > 0) { + byte[] b = s.getBytes(StandardCharsets.UTF_8); + writer.write(b, 0, b.length); + } + } + byte b[] = new byte[1]; + b[0] = 0; + writer.write(b, 0, 1); + } + + protected void writeCommand(AttachOutputStream writer, int ver, String cmd, Object ... args) throws IOException { + writeString(writer, ver); + if (ver == VERSION_2) { + // for v2 write size of the data + int size = dataSize(cmd); + for (Object arg: args) { + size += dataSize(arg); + } + writeString(writer, size); + } + writeString(writer, cmd); + // v1 commands always write 3 arguments + int argNumber = ver == VERSION_1 ? 3 : args.length; + for (int i = 0; i < argNumber; i++) { + writeString(writer, i < args.length ? args[i] : null); + } + } + /* * InputStream for the socket connection to get target VM */ diff --git a/src/jdk.attach/windows/classes/sun/tools/attach/VirtualMachineImpl.java b/src/jdk.attach/windows/classes/sun/tools/attach/VirtualMachineImpl.java index 9c30f5618d6..23c15ad06e1 100644 --- a/src/jdk.attach/windows/classes/sun/tools/attach/VirtualMachineImpl.java +++ b/src/jdk.attach/windows/classes/sun/tools/attach/VirtualMachineImpl.java @@ -26,6 +26,7 @@ import com.sun.tools.attach.AgentLoadException; import com.sun.tools.attach.AttachNotSupportedException; +import com.sun.tools.attach.AttachOperationFailedException; import com.sun.tools.attach.spi.AttachProvider; import java.io.IOException; @@ -42,6 +43,7 @@ public class VirtualMachineImpl extends HotSpotVirtualMachine { private static byte[] stub; private volatile long hProcess; // handle to the process + private int ver = VERSION_1; // updated in ctor depending on detectVersion result VirtualMachineImpl(AttachProvider provider, String id) throws AttachNotSupportedException, IOException @@ -51,11 +53,15 @@ public class VirtualMachineImpl extends HotSpotVirtualMachine { int pid = Integer.parseInt(id); hProcess = openProcess(pid); - // The target VM might be a pre-6.0 VM so we enqueue a "null" command - // which minimally tests that the enqueue function exists in the target - // VM. try { - enqueue(hProcess, stub, null, null); + if (isAPIv2Enabled()) { + ver = detectVersion(); + } else { + // The target VM might be a pre-6.0 VM so we enqueue a "null" command + // which minimally tests that the enqueue function exists in the target + // VM. + enqueue(hProcess, stub, VERSION_1, null, null); + } } catch (IOException x) { throw new AttachNotSupportedException(x.getMessage()); } @@ -73,7 +79,6 @@ public void detach() throws IOException { InputStream execute(String cmd, Object ... args) throws AgentLoadException, IOException { - assert args.length <= 3; // includes null checkNulls(args); // create a pipe using a random name @@ -83,12 +88,12 @@ InputStream execute(String cmd, Object ... args) String pipename = pipeprefix + r; long hPipe; try { - hPipe = createPipe(pipename); + hPipe = createPipe(ver, pipename); } catch (IOException ce) { // Retry with another random pipe name. r = rnd.nextInt(); pipename = pipeprefix + r; - hPipe = createPipe(pipename); + hPipe = createPipe(ver, pipename); } // check if we are detached - in theory it's possible that detach is invoked @@ -99,18 +104,34 @@ InputStream execute(String cmd, Object ... args) } try { - // enqueue the command to the process - enqueue(hProcess, stub, cmd, pipename, args); + // enqueue the command to the process. + if (ver == VERSION_1) { + enqueue(hProcess, stub, ver, cmd, pipename, args); + } else { + // for v2 operations request contains only pipe name. + enqueue(hProcess, stub, ver, null, pipename); + } - // wait for command to complete - process will connect with the - // completion status + // wait for the target VM to connect to the pipe. connectPipe(hPipe); + IOException ioe = null; + + if (ver == VERSION_2) { + PipeOutputStream writer = new PipeOutputStream(hPipe); + + try { + writeCommand(writer, ver, cmd, args); + } catch (IOException x) { + ioe = x; + } + } + // create an input stream for the pipe SocketInputStreamImpl in = new SocketInputStreamImpl(hPipe); // Process the command completion status - processCompletionStatus(null, cmd, in); + processCompletionStatus(ioe, cmd, in); // return the input stream return in; @@ -121,6 +142,17 @@ InputStream execute(String cmd, Object ... args) } } + private static class PipeOutputStream implements AttachOutputStream { + private long hPipe; + public PipeOutputStream(long hPipe) { + this.hPipe = hPipe; + } + @Override + public void write(byte[] buffer, int offset, int length) throws IOException { + VirtualMachineImpl.writePipe(hPipe, buffer, offset, length); + } + } + // An InputStream based on a pipe to the target VM private static class SocketInputStreamImpl extends SocketInputStream { public SocketInputStreamImpl(long fd) { @@ -149,7 +181,7 @@ protected void close(long fd) throws IOException { static native void closeProcess(long hProcess) throws IOException; - static native long createPipe(String name) throws IOException; + static native long createPipe(int ver, String name) throws IOException; static native void closePipe(long hPipe) throws IOException; @@ -157,7 +189,9 @@ protected void close(long fd) throws IOException { static native int readPipe(long hPipe, byte buf[], int off, int buflen) throws IOException; - static native void enqueue(long hProcess, byte[] stub, + static native void writePipe(long hPipe, byte buf[], int off, int buflen) throws IOException; + + static native void enqueue(long hProcess, byte[] stub, int ver, String cmd, String pipename, Object ... args) throws IOException; static { diff --git a/src/jdk.attach/windows/native/libattach/VirtualMachineImpl.c b/src/jdk.attach/windows/native/libattach/VirtualMachineImpl.c index 74d0e7bf7d5..7a436ef85c2 100644 --- a/src/jdk.attach/windows/native/libattach/VirtualMachineImpl.c +++ b/src/jdk.attach/windows/native/libattach/VirtualMachineImpl.c @@ -46,9 +46,11 @@ static IsWow64ProcessFunc _IsWow64Process; typedef BOOL (WINAPI *EnumProcessModulesFunc) (HANDLE, HMODULE *, DWORD, LPDWORD ); typedef DWORD (WINAPI *GetModuleFileNameExFunc) ( HANDLE, HMODULE, LPTSTR, DWORD ); -/* exported function in target VM */ +/* exported functions in target VM */ typedef jint (WINAPI* EnqueueOperationFunc) (const char* cmd, const char* arg1, const char* arg2, const char* arg3, const char* pipename); +typedef jint (WINAPI* EnqueueOperationFunc_v2) + (const char* pipename); /* OpenProcess with SE_DEBUG_NAME privilege */ static HANDLE @@ -70,11 +72,13 @@ static jboolean jstring_to_cstring(JNIEnv* env, jstring jstr, char* cstr, size_t #define MAX_PIPE_NAME_LENGTH 256 typedef struct { + jint version; GetModuleHandleFunc _GetModuleHandle; GetProcAddressFunc _GetProcAddress; char jvmLib[MAX_LIBNAME_LENGTH]; /* "jvm.dll" */ char func1[MAX_FUNC_LENGTH]; char func2[MAX_FUNC_LENGTH]; + char func_v2[MAX_FUNC_LENGTH]; char cmd[MAX_CMD_LENGTH + 1]; /* "load", "dump", ... */ char arg[MAX_ARGS][MAX_ARG_LENGTH + 1]; /* arguments to command */ char pipename[MAX_PIPE_NAME_LENGTH + 1]; @@ -102,27 +106,36 @@ DEF_STATIC_JNI_OnLoad DWORD WINAPI jvm_attach_thread_func(DataBlock *pData) { HINSTANCE h; - EnqueueOperationFunc addr; h = pData->_GetModuleHandle(pData->jvmLib); if (h == NULL) { return ERR_OPEN_JVM_FAIL; } - addr = (EnqueueOperationFunc)(pData->_GetProcAddress(h, pData->func1)); - if (addr == NULL) { - addr = (EnqueueOperationFunc)(pData->_GetProcAddress(h, pData->func2)); - } - if (addr == NULL) { + if (pData->version == 1) { + EnqueueOperationFunc addr = (EnqueueOperationFunc)(pData->_GetProcAddress(h, pData->func1)); + if (addr == NULL) { + addr = (EnqueueOperationFunc)(pData->_GetProcAddress(h, pData->func2)); + } + if (addr == NULL) { + return ERR_GET_ENQUEUE_FUNC_FAIL; + } + /* "null" command - does nothing in the target VM */ + if (pData->cmd[0] == '\0') { + return 0; + } else { + return (*addr)(pData->cmd, pData->arg[0], pData->arg[1], pData->arg[2], pData->pipename); + } + } else if (pData->version == 2) { + EnqueueOperationFunc_v2 addr = (EnqueueOperationFunc_v2)(pData->_GetProcAddress(h, pData->func_v2)); + if (addr == NULL) { + return ERR_GET_ENQUEUE_FUNC_FAIL; + } + return (*addr)(pData->pipename); + } else { return ERR_GET_ENQUEUE_FUNC_FAIL; } - /* "null" command - does nothing in the target VM */ - if (pData->cmd[0] == '\0') { - return 0; - } else { - return (*addr)(pData->cmd, pData->arg[0], pData->arg[1], pData->arg[2], pData->pipename); - } } /* This function marks the end of jvm_attach_thread_func. */ @@ -261,7 +274,7 @@ JNIEXPORT void JNICALL Java_sun_tools_attach_VirtualMachineImpl_closeProcess * Signature: (Ljava/lang/String;)J */ JNIEXPORT jlong JNICALL Java_sun_tools_attach_VirtualMachineImpl_createPipe - (JNIEnv *env, jclass cls, jstring pipename) + (JNIEnv *env, jclass cls, jint ver, jstring pipename) { HANDLE hPipe; char name[MAX_PIPE_NAME_LENGTH]; @@ -289,7 +302,8 @@ JNIEXPORT jlong JNICALL Java_sun_tools_attach_VirtualMachineImpl_createPipe hPipe = CreateNamedPipe( name, // pipe name - PIPE_ACCESS_INBOUND, // read access + ver == 1 ? PIPE_ACCESS_INBOUND // read access + : PIPE_ACCESS_DUPLEX, // read-write access PIPE_TYPE_BYTE | // byte mode PIPE_READMODE_BYTE | PIPE_WAIT, // blocking mode @@ -377,14 +391,46 @@ JNIEXPORT jint JNICALL Java_sun_tools_attach_VirtualMachineImpl_readPipe return (jint)nread; } +/* + * Class: sun_tools_attach_VirtualMachineImpl + * Method: writePipe + * Signature: (J[BII)V + */ +JNIEXPORT void JNICALL Java_sun_tools_attach_VirtualMachineImpl_writePipe + (JNIEnv *env, jclass cls, jlong hPipe, jbyteArray buffer, jint offset, jint length) +{ + jsize remaining = length; + do { + jbyte buf[128]; + jsize len = sizeof(buf); + DWORD written; + + if (len > remaining) { + len = remaining; + } + (*env)->GetByteArrayRegion(env, buffer, offset, len, buf); + + BOOL fSuccess = WriteFile((HANDLE)hPipe, buf, len, &written, NULL); + + if (!fSuccess) { + JNU_ThrowIOExceptionWithLastError(env, "WriteFile"); + return; + } + + offset += written; + remaining -= written; + + } while (remaining > 0); +} + /* * Class: sun_tools_attach_VirtualMachineImpl * Method: enqueue * Signature: (JZLjava/lang/String;[Ljava/lang/Object;)V */ JNIEXPORT void JNICALL Java_sun_tools_attach_VirtualMachineImpl_enqueue - (JNIEnv *env, jclass cls, jlong handle, jbyteArray stub, jstring cmd, - jstring pipename, jobjectArray args) + (JNIEnv *env, jclass cls, jlong handle, jbyteArray stub, jint ver, + jstring cmd, jstring pipename, jobjectArray args) { DataBlock data; DataBlock* pData; @@ -399,12 +445,15 @@ JNIEXPORT void JNICALL Java_sun_tools_attach_VirtualMachineImpl_enqueue * Setup data to copy to target process */ memset(&data, 0, sizeof(data)); + data.version = ver; + data._GetModuleHandle = _GetModuleHandle; data._GetProcAddress = _GetProcAddress; strcpy(data.jvmLib, "jvm"); strcpy(data.func1, "JVM_EnqueueOperation"); strcpy(data.func2, "_JVM_EnqueueOperation@20"); + strcpy(data.func_v2, "JVM_EnqueueOperation_v2"); /* * Command and arguments diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java index 83df2468a85..b06cb855bea 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Source.java @@ -262,6 +262,7 @@ public enum Feature { PRIMITIVE_PATTERNS(JDK23, Fragments.FeaturePrimitivePatterns, DiagKind.PLURAL), FLEXIBLE_CONSTRUCTORS(JDK22, Fragments.FeatureFlexibleConstructors, DiagKind.NORMAL), MODULE_IMPORTS(JDK23, Fragments.FeatureModuleImports, DiagKind.PLURAL), + PRIVATE_MEMBERS_IN_PERMITS_CLAUSE(JDK19), PATTERN_DECLARATIONS(JDK24, Fragments.FeaturePatternDeclarations, DiagKind.PLURAL), ; diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Type.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Type.java index e43da1b8503..ae5a10e79a8 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Type.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Type.java @@ -507,7 +507,7 @@ protected void appendAnnotationsString(StringBuilder sb, if (prefix) { sb.append(" "); } - sb.append(getAnnotationMirrors()); + sb.append(getAnnotationMirrors().toString(" ")); sb.append(" "); } } diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/AttrContext.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/AttrContext.java index b8afce009a5..f121849457c 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/AttrContext.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/AttrContext.java @@ -92,6 +92,10 @@ public class AttrContext { */ boolean allowProtectedAccess = false; + /** Are we attributing a permits clause? + */ + boolean isPermitsClause = false; + /** Are arguments to current function applications boxed into an array for varargs? */ Resolve.MethodResolutionPhase pendingResolutionPhase = null; @@ -149,6 +153,7 @@ AttrContext dup(WriteableScope scope) { info.preferredTreeForDiagnostics = preferredTreeForDiagnostics; info.visitingServiceImplementation = visitingServiceImplementation; info.allowProtectedAccess = allowProtectedAccess; + info.isPermitsClause = isPermitsClause; return info; } 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 55293535ff8..b6d7e166902 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 @@ -111,6 +111,7 @@ public class Resolve { private final boolean compactMethodDiags; private final boolean allowLocalVariableTypeInference; private final boolean allowYieldStatement; + private final boolean allowPrivateMembersInPermitsClause; final EnumSet verboseResolutionMode; final boolean dumpMethodReferenceSearchResults; final boolean dumpStacktraceOnError; @@ -147,6 +148,7 @@ protected Resolve(Context context) { Target target = Target.instance(context); allowLocalVariableTypeInference = Feature.LOCAL_VARIABLE_TYPE_INFERENCE.allowedInSource(source); allowYieldStatement = Feature.SWITCH_EXPRESSION.allowedInSource(source); + allowPrivateMembersInPermitsClause = Feature.PRIVATE_MEMBERS_IN_PERMITS_CLAUSE.allowedInSource(source); polymorphicSignatureScope = WriteableScope.create(syms.noSymbol); allowModules = Feature.MODULES.allowedInSource(source); allowRecords = Feature.RECORDS.allowedInSource(source); @@ -425,7 +427,9 @@ public boolean isAccessible(Env env, Type site, Symbol sym, boolean (env.enclClass.sym == sym.owner // fast special case || env.enclClass.sym.outermostClass() == - sym.owner.outermostClass()) + sym.owner.outermostClass() + || + privateMemberInPermitsClauseIfAllowed(env, sym)) && sym.isInheritedIn(site.tsym, types); case 0: @@ -458,6 +462,13 @@ public boolean isAccessible(Env env, Type site, Symbol sym, boolean return isAccessible(env, site, checkInner) && notOverriddenIn(site, sym); } } + + private boolean privateMemberInPermitsClauseIfAllowed(Env env, Symbol sym) { + return allowPrivateMembersInPermitsClause && + env.info.isPermitsClause && + ((JCClassDecl) env.tree).sym.outermostClass() == sym.owner.outermostClass(); + } + //where /* `sym' is accessible only if not overridden by * another symbol which is a member of `site' diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TypeEnter.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TypeEnter.java index 5be8d755d41..b518d7edb4b 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TypeEnter.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/TypeEnter.java @@ -979,11 +979,17 @@ private void fillPermits(JCClassDecl tree, Env baseEnv) { if (sym.isPermittedExplicit) { ListBuffer permittedSubtypeSymbols = new ListBuffer<>(); List permittedTrees = tree.permitting; - for (JCExpression permitted : permittedTrees) { - Type pt = attr.attribBase(permitted, baseEnv, false, false, false); - permittedSubtypeSymbols.append(pt.tsym); + var isPermitsClause = baseEnv.info.isPermitsClause; + try { + baseEnv.info.isPermitsClause = true; + for (JCExpression permitted : permittedTrees) { + Type pt = attr.attribBase(permitted, baseEnv, false, false, false); + permittedSubtypeSymbols.append(pt.tsym); + } + sym.setPermittedSubclasses(permittedSubtypeSymbols.toList()); + } finally { + baseEnv.info.isPermitsClause = isPermitsClause; } - sym.setPermittedSubclasses(permittedSubtypeSymbols.toList()); } } } diff --git a/src/jdk.dynalink/share/classes/jdk/dynalink/linker/GuardedInvocation.java b/src/jdk.dynalink/share/classes/jdk/dynalink/linker/GuardedInvocation.java index 174e63bff26..ff59ddf8268 100644 --- a/src/jdk.dynalink/share/classes/jdk/dynalink/linker/GuardedInvocation.java +++ b/src/jdk.dynalink/share/classes/jdk/dynalink/linker/GuardedInvocation.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -431,10 +431,10 @@ public MethodHandle compose(final MethodHandle fallback) { * Composes the invocation, guard, switch points, and the exception into a * composite method handle that knows how to fall back when the guard fails * or the invocation is invalidated. - * @param switchpointFallback the fallback method handle in case a switch - * point is invalidated. * @param guardFallback the fallback method handle in case guard returns * false. + * @param switchpointFallback the fallback method handle in case a switch + * point is invalidated. * @param catchFallback the fallback method in case the exception handler * triggers. * @return a composite method handle. diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/HSDB.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/HSDB.java index 870621421c8..d8c4d1a781e 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/HSDB.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/HSDB.java @@ -39,7 +39,6 @@ import sun.jvm.hotspot.gc.shared.*; import sun.jvm.hotspot.gc.shenandoah.*; import sun.jvm.hotspot.gc.g1.*; -import sun.jvm.hotspot.gc.x.*; import sun.jvm.hotspot.gc.z.*; import sun.jvm.hotspot.interpreter.*; import sun.jvm.hotspot.oops.*; @@ -1124,10 +1123,6 @@ public void addAnnotation(Address addr, OopHandle handle) { ShenandoahHeap heap = (ShenandoahHeap) collHeap; anno = "ShenandoahHeap "; bad = false; - } else if (collHeap instanceof XCollectedHeap) { - XCollectedHeap heap = (XCollectedHeap) collHeap; - anno = "ZHeap "; - bad = false; } else if (collHeap instanceof ZCollectedHeap) { ZCollectedHeap heap = (ZCollectedHeap) collHeap; anno = "ZHeap "; diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/x/XAddress.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/x/XAddress.java deleted file mode 100644 index fbd15110890..00000000000 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/x/XAddress.java +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2018, 2021, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package sun.jvm.hotspot.gc.x; - -import sun.jvm.hotspot.debugger.Address; -import sun.jvm.hotspot.runtime.VM; - -class XAddress { - static long as_long(Address value) { - if (value == null) { - return 0; - } - return value.asLongValue(); - }; - - static boolean is_null(Address value) { - return value == null; - } - - static boolean is_weak_bad(Address value) { - return (as_long(value) & XGlobals.XAddressWeakBadMask()) != 0L; - } - - static boolean is_weak_good(Address value) { - return !is_weak_bad(value) && !is_null(value); - } - - static boolean is_weak_good_or_null(Address value) { - return !is_weak_bad(value); - } - - static long offset(Address address) { - return as_long(address) & XGlobals.XAddressOffsetMask(); - } - - static Address good(Address value) { - return VM.getVM().getDebugger().newAddress(offset(value) | XGlobals.XAddressGoodMask()); - } - - static Address good_or_null(Address value) { - return is_null(value) ? value : good(value); - } - - private static boolean isPowerOf2(long value) { - return (value != 0L) && ((value & (value - 1)) == 0L); - } - - static boolean isIn(Address addr) { - long value = as_long(addr); - if (!isPowerOf2(value & ~XGlobals.XAddressOffsetMask())) { - return false; - } - return (value & (XGlobals.XAddressMetadataMask() & ~XGlobals.XAddressMetadataFinalizable())) != 0L; - } -} diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/x/XAttachedArrayForForwarding.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/x/XAttachedArrayForForwarding.java deleted file mode 100644 index 0c8bb38a776..00000000000 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/x/XAttachedArrayForForwarding.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2021, NTT DATA. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package sun.jvm.hotspot.gc.x; - -import sun.jvm.hotspot.debugger.Address; -import sun.jvm.hotspot.runtime.VM; -import sun.jvm.hotspot.runtime.VMObject; -import sun.jvm.hotspot.runtime.VMObjectFactory; -import sun.jvm.hotspot.types.CIntegerField; -import sun.jvm.hotspot.types.Type; -import sun.jvm.hotspot.types.TypeDataBase; - -public class XAttachedArrayForForwarding extends VMObject { - private static CIntegerField lengthField; - - static { - VM.registerVMInitializedObserver((o, d) -> initialize(VM.getVM().getTypeDataBase())); - } - - private static synchronized void initialize(TypeDataBase db) { - Type type = db.lookupType("XAttachedArrayForForwarding"); - - lengthField = type.getCIntegerField("_length"); - } - - public XAttachedArrayForForwarding(Address addr) { - super(addr); - } - - public long length() { - return lengthField.getValue(addr); - } - - // ObjectT: XForwarding - // ArrayT: XForwardingEntry - // - // template - // inline size_t XAttachedArray::object_size() - private long objectSize() { - return XUtils.alignUp(XForwarding.getSize(), XForwardingEntry.getSize()); - } - - // ArrayT* operator()(const ObjectT* obj) const - public XForwardingEntry get(XForwarding obj) { - Address o = obj.getAddress().addOffsetTo(objectSize()); - return VMObjectFactory.newObject(XForwardingEntry.class, o); - } -} diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/x/XBarrier.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/x/XBarrier.java deleted file mode 100644 index 54f9323a4e6..00000000000 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/x/XBarrier.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2018, 2021, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package sun.jvm.hotspot.gc.x; - -import sun.jvm.hotspot.debugger.Address; -import sun.jvm.hotspot.runtime.VM; - -class XBarrier { - private static boolean is_weak_good_or_null_fast_path(Address addr) { - return XAddress.is_weak_good_or_null(addr); - } - - private static Address weak_load_barrier_on_oop_slow_path(Address addr) { - return XAddress.is_weak_good(addr) ? XAddress.good(addr) : relocate_or_remap(addr); - } - - private static boolean during_relocate() { - return XGlobals.XGlobalPhase() == XGlobals.XPhaseRelocate; - } - - private static Address relocate(Address addr) { - return zheap().relocate_object(addr); - } - - private static XHeap zheap() { - XCollectedHeap zCollectedHeap = (XCollectedHeap)VM.getVM().getUniverse().heap(); - return zCollectedHeap.heap(); - } - - private static Address remap(Address addr) { - return zheap().remapObject(addr); - } - - private static Address relocate_or_remap(Address addr) { - return during_relocate() ? relocate(addr) : remap(addr); - } - - static Address weak_barrier(Address o) { - // Fast path - if (is_weak_good_or_null_fast_path(o)) { - // Return the good address instead of the weak good address - // to ensure that the currently active heap view is used. - return XAddress.good_or_null(o); - } - - // Slow path - return weak_load_barrier_on_oop_slow_path(o); - } -} diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/x/XCollectedHeap.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/x/XCollectedHeap.java deleted file mode 100644 index 5455a841fab..00000000000 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/x/XCollectedHeap.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright (c) 2017, 2022, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package sun.jvm.hotspot.gc.x; - -import java.io.PrintStream; -import java.util.Iterator; - -import sun.jvm.hotspot.debugger.Address; -import sun.jvm.hotspot.debugger.OopHandle; -import sun.jvm.hotspot.gc.shared.CollectedHeap; -import sun.jvm.hotspot.gc.shared.CollectedHeapName; -import sun.jvm.hotspot.gc.shared.LiveRegionsClosure; -import sun.jvm.hotspot.runtime.VM; -import sun.jvm.hotspot.runtime.VMObjectFactory; -import sun.jvm.hotspot.types.Type; -import sun.jvm.hotspot.types.TypeDataBase; -import sun.jvm.hotspot.utilities.BitMapInterface; - -// Mirror class for XCollectedHeap. - -public class XCollectedHeap extends CollectedHeap { - private static long zHeapFieldOffset; - - static { - VM.registerVMInitializedObserver((o, d) -> initialize(VM.getVM().getTypeDataBase())); - } - - private static synchronized void initialize(TypeDataBase db) { - Type type = db.lookupType("XCollectedHeap"); - - zHeapFieldOffset = type.getAddressField("_heap").getOffset(); - } - - public XHeap heap() { - Address heapAddr = addr.addOffsetTo(zHeapFieldOffset); - return VMObjectFactory.newObject(XHeap.class, heapAddr); - } - - @Override - public CollectedHeapName kind() { - return CollectedHeapName.Z; - } - - @Override - public void printOn(PrintStream tty) { - heap().printOn(tty); - } - - public XCollectedHeap(Address addr) { - super(addr); - } - - @Override - public long capacity() { - return heap().capacity(); - } - - @Override - public long used() { - return heap().used(); - } - - @Override - public boolean isInReserved(Address a) { - return heap().isIn(a); - } - - private OopHandle oop_load_barrier(Address oopAddress) { - oopAddress = XBarrier.weak_barrier(oopAddress); - if (oopAddress == null) { - return null; - } - - return oopAddress.addOffsetToAsOopHandle(0); - } - - @Override - public OopHandle oop_load_at(OopHandle handle, long offset) { - assert(!VM.getVM().isCompressedOopsEnabled()); - - Address oopAddress = handle.getAddressAt(offset); - - return oop_load_barrier(oopAddress); - } - - // addr can be either in heap or in native - @Override - public OopHandle oop_load_in_native(Address addr) { - Address oopAddress = addr.getAddressAt(0); - return oop_load_barrier(oopAddress); - } - - public String oopAddressDescription(OopHandle handle) { - Address origOop = XOop.to_address(handle); - Address loadBarrieredOop = XBarrier.weak_barrier(origOop); - if (!origOop.equals(loadBarrieredOop)) { - return origOop + " (" + loadBarrieredOop.toString() + ")"; - } else { - return handle.toString(); - } - } - - @Override - public void liveRegionsIterate(LiveRegionsClosure closure) { - Iterator iter = heap().pageTable().activePagesIterator(); - while (iter.hasNext()) { - XPage page = iter.next(); - closure.doLiveRegions(page); - } - } - - @Override - public BitMapInterface createBitMap(long size) { - // Ignores the size - return new XExternalBitMap(this); - } -} diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/x/XExternalBitMap.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/x/XExternalBitMap.java deleted file mode 100644 index 5a2f033e6a1..00000000000 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/x/XExternalBitMap.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright (c) 2019, 2021, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package sun.jvm.hotspot.gc.x; - -import java.util.HashMap; - -import sun.jvm.hotspot.runtime.VM; -import sun.jvm.hotspot.utilities.BitMap; -import sun.jvm.hotspot.utilities.BitMapInterface; - -/** Discontiguous bitmap for ZGC. */ -public class XExternalBitMap implements BitMapInterface { - private XPageTable pageTable; - private final long oopSize; - - private HashMap pageToBitMap = new HashMap(); - - public XExternalBitMap(XCollectedHeap collectedHeap) { - pageTable = collectedHeap.heap().pageTable(); - oopSize = VM.getVM().getOopSize(); - } - - private XPage getPage(long zOffset) { - if (zOffset > XGlobals.XAddressOffsetMask()) { - throw new RuntimeException("Not a Z offset: " + zOffset); - } - - XPage page = pageTable.get(XUtils.longToAddress(zOffset)); - if (page == null) { - throw new RuntimeException("Address not in pageTable: " + zOffset); - } - return page; - } - - private BitMap getOrAddBitMap(XPage page) { - BitMap bitMap = pageToBitMap.get(page); - if (bitMap == null) { - long size = page.size(); - - long maxNumObjects = size >>> page.object_alignment_shift(); - if (maxNumObjects > Integer.MAX_VALUE) { - throw new RuntimeException("int overflow"); - } - int intMaxNumObjects = (int)maxNumObjects; - - bitMap = new BitMap(intMaxNumObjects); - pageToBitMap.put(page, bitMap); - } - - return bitMap; - } - - private int pageLocalBitMapIndex(XPage page, long zOffset) { - long pageLocalZOffset = zOffset - page.start(); - return (int)(pageLocalZOffset >>> page.object_alignment_shift()); - } - - private long convertToZOffset(long offset) { - long addr = oopSize * offset; - return addr & XGlobals.XAddressOffsetMask(); - } - - @Override - public boolean at(long offset) { - long zOffset = convertToZOffset(offset); - XPage page = getPage(zOffset); - BitMap bitMap = getOrAddBitMap(page); - int index = pageLocalBitMapIndex(page, zOffset); - - return bitMap.at(index); - } - - @Override - public void atPut(long offset, boolean value) { - long zOffset = convertToZOffset(offset); - XPage page = getPage(zOffset); - BitMap bitMap = getOrAddBitMap(page); - int index = pageLocalBitMapIndex(page, zOffset); - - bitMap.atPut(index, value); - } - - @Override - public void clear() { - for (BitMap bitMap : pageToBitMap.values()) { - bitMap.clear(); - } - } -} diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/x/XForwarding.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/x/XForwarding.java deleted file mode 100644 index 727014a8479..00000000000 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/x/XForwarding.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2021, NTT DATA. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package sun.jvm.hotspot.gc.x; - -import java.util.Iterator; - -import sun.jvm.hotspot.debugger.Address; -import sun.jvm.hotspot.runtime.VM; -import sun.jvm.hotspot.runtime.VMObject; -import sun.jvm.hotspot.runtime.VMObjectFactory; -import sun.jvm.hotspot.types.CIntegerField; -import sun.jvm.hotspot.types.Type; -import sun.jvm.hotspot.types.TypeDataBase; - -public class XForwarding extends VMObject { - private static Type type; - private static long virtualFieldOffset; - private static long entriesFieldOffset; - private static CIntegerField objectAlignmentShiftField; - private static CIntegerField refCountField; - - static { - VM.registerVMInitializedObserver((o, d) -> initialize(VM.getVM().getTypeDataBase())); - } - - private static synchronized void initialize(TypeDataBase db) { - type = db.lookupType("XForwarding"); - - virtualFieldOffset = type.getField("_virtual").getOffset(); - entriesFieldOffset = type.getField("_entries").getOffset(); - objectAlignmentShiftField = type.getCIntegerField("_object_alignment_shift"); - refCountField = type.getCIntegerField("_ref_count"); - } - - public XForwarding(Address addr) { - super(addr); - } - - public static long getSize() { - return type.getSize(); - } - - private XVirtualMemory virtual() { - return VMObjectFactory.newObject(XVirtualMemory.class, addr.addOffsetTo(virtualFieldOffset)); - } - - private XAttachedArrayForForwarding entries() { - return VMObjectFactory.newObject(XAttachedArrayForForwarding.class, addr.addOffsetTo(entriesFieldOffset)); - } - - public long start() { - return virtual().start(); - } - - public int objectAlignmentShift() { - return (int)objectAlignmentShiftField.getValue(addr); - } - - public boolean retainPage() { - return refCountField.getValue(addr) > 0; - } - - private XForwardingEntry at(long cursor) { - long offset = XForwardingEntry.getSize() * cursor; - Address entryAddress = entries().get(this).getAddress().addOffsetTo(offset); - return VMObjectFactory.newObject(XForwardingEntry.class, entryAddress); - } - - private class XForwardEntryIterator implements Iterator { - - private long cursor; - - private XForwardingEntry nextEntry; - - public XForwardEntryIterator(long fromIndex) { - long mask = entries().length() - 1; - long hash = XHash.uint32_to_uint32(fromIndex); - cursor = hash & mask; - nextEntry = at(cursor); - } - - @Override - public boolean hasNext() { - return nextEntry.populated(); - } - - @Override - public XForwardingEntry next() { - XForwardingEntry entry = nextEntry; - - long mask = entries().length() - 1; - cursor = (cursor + 1) & mask; - nextEntry = at(cursor); - - return entry; - } - - public XForwardingEntry peak() { - return nextEntry; - } - } - - public XForwardingEntry find(long fromIndex) { - XForwardEntryIterator itr = new XForwardEntryIterator(fromIndex); - while (itr.hasNext()) { - XForwardingEntry entry = itr.next(); - if (entry.fromIndex() == fromIndex) { - return entry; - } - } - return itr.peak(); - } -} diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/x/XForwardingEntry.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/x/XForwardingEntry.java deleted file mode 100644 index aa4b55775ec..00000000000 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/x/XForwardingEntry.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2021, NTT DATA. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package sun.jvm.hotspot.gc.x; - -import sun.jvm.hotspot.debugger.Address; -import sun.jvm.hotspot.runtime.VM; -import sun.jvm.hotspot.runtime.VMObject; -import sun.jvm.hotspot.runtime.VMObjectFactory; -import sun.jvm.hotspot.types.CIntegerField; -import sun.jvm.hotspot.types.Type; -import sun.jvm.hotspot.types.TypeDataBase; - -public class XForwardingEntry extends VMObject { - private static Type type; - private static CIntegerField entryField; - - static { - VM.registerVMInitializedObserver((o, d) -> initialize(VM.getVM().getTypeDataBase())); - } - - private static synchronized void initialize(TypeDataBase db) { - type = db.lookupType("XForwardingEntry"); - - entryField = type.getCIntegerField("_entry"); - } - - public static long getSize() { - return type.getSize(); - } - - public XForwardingEntry(Address addr) { - super(addr); - } - - public long entry() { - return entryField.getValue(addr); - } - - // typedef XBitField field_populated - private boolean fieldPopulatedDecode(long value) { - long FieldMask = (1L << 1) - 1; - int FieldShift = 1; - int ValueShift = 0; - return (((value >>> FieldShift) & FieldMask) << ValueShift) != 0L; - } - - // typedef XBitField field_to_offset; - private long fieldToOffsetDecode(long value) { - long FieldMask = (1L << 45) - 1; - int FieldShift = 1; - int ValueShift = 0; - return ((value >>> FieldShift) & FieldMask) << ValueShift; - } - - // typedef XBitField field_from_index; - private long fieldFromIndexDecode(long value) { - long FieldMask = (1L << 18) - 1; - int FieldShift = 46; - int ValueShift = 0; - return ((value >>> FieldShift) & FieldMask) << ValueShift; - } - - public boolean populated() { - return fieldPopulatedDecode(entry()); - } - - public long toOffset() { - return fieldToOffsetDecode(entry()); - } - - public long fromIndex() { - return fieldFromIndexDecode(entry()); - } -} diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/x/XForwardingTable.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/x/XForwardingTable.java deleted file mode 100644 index 259f48a37b6..00000000000 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/x/XForwardingTable.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2018, 2021, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package sun.jvm.hotspot.gc.x; - -import sun.jvm.hotspot.debugger.Address; -import sun.jvm.hotspot.runtime.VM; -import sun.jvm.hotspot.runtime.VMObject; -import sun.jvm.hotspot.runtime.VMObjectFactory; -import sun.jvm.hotspot.types.AddressField; -import sun.jvm.hotspot.types.CIntegerField; -import sun.jvm.hotspot.types.Type; -import sun.jvm.hotspot.types.TypeDataBase; - -public class XForwardingTable extends VMObject { - private static long mapFieldOffset; - - static { - VM.registerVMInitializedObserver((o, d) -> initialize(VM.getVM().getTypeDataBase())); - } - - private static synchronized void initialize(TypeDataBase db) { - Type type = db.lookupType("XForwardingTable"); - - mapFieldOffset = type.getAddressField("_map").getOffset(); - } - - public XForwardingTable(Address addr) { - super(addr); - } - - private XGranuleMapForForwarding map() { - return VMObjectFactory.newObject(XGranuleMapForForwarding.class, addr.addOffsetTo(mapFieldOffset)); - } - - public XForwarding get(Address o) { - return VMObjectFactory.newObject(XForwarding.class, map().get(XAddress.offset(o))); - } -} diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/x/XForwardingTableCursor.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/x/XForwardingTableCursor.java deleted file mode 100644 index 40103cd1e43..00000000000 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/x/XForwardingTableCursor.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright (c) 2018, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package sun.jvm.hotspot.gc.x; - -class XForwardingTableCursor { - long _value; -} diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/x/XForwardingTableEntry.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/x/XForwardingTableEntry.java deleted file mode 100644 index 7c629f7c5cf..00000000000 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/x/XForwardingTableEntry.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2018, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package sun.jvm.hotspot.gc.x; - -import sun.jvm.hotspot.debugger.Address; - -class XForwardingTableEntry { - private Address entry; - - XForwardingTableEntry(Address addr) { - entry = addr; - } - - private static long empty() { - return ~0L; - } - - boolean is_empty() { - return entry.asLongValue() == empty(); - } - - Address to_offset() { - return entry.andWithMask((1L << 42) - 1); - } - - long from_index() { - return entry.asLongValue() >>> 42; - } - - public String toString() { - return entry + " - from_index: " + from_index() + " to_offset: " + to_offset(); - } -} diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/x/XGlobals.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/x/XGlobals.java deleted file mode 100644 index 1cfc6dd7663..00000000000 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/x/XGlobals.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * Copyright (c) 2018, 2021, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package sun.jvm.hotspot.gc.x; - -import sun.jvm.hotspot.runtime.VM; -import sun.jvm.hotspot.types.Field; -import sun.jvm.hotspot.types.Type; -import sun.jvm.hotspot.types.TypeDataBase; - -public class XGlobals { - private static Field instanceField; - - // Global phase state - public static int XPhaseRelocate; - - public static byte XPageTypeSmall; - public static byte XPageTypeMedium; - public static byte XPageTypeLarge; - - // Granule size shift - public static long XGranuleSizeShift; - - // Page size shifts - public static long XPageSizeSmallShift; - public static long XPageSizeMediumShift; - - // Object alignment shifts - public static int XObjectAlignmentMediumShift; - public static int XObjectAlignmentLargeShift; - - // Pointer part of address - public static long XAddressOffsetShift; - - // Pointer part of address - public static long XAddressOffsetBits; - public static long XAddressOffsetMax; - - static { - VM.registerVMInitializedObserver((o, d) -> initialize(VM.getVM().getTypeDataBase())); - } - - private static synchronized void initialize(TypeDataBase db) { - Type type = db.lookupType("XGlobalsForVMStructs"); - - instanceField = type.getField("_instance_p"); - - XPhaseRelocate = db.lookupIntConstant("XPhaseRelocate").intValue(); - - XPageTypeSmall = db.lookupIntConstant("XPageTypeSmall").byteValue(); - XPageTypeMedium = db.lookupIntConstant("XPageTypeMedium").byteValue(); - XPageTypeLarge = db.lookupIntConstant("XPageTypeLarge").byteValue(); - - XGranuleSizeShift = db.lookupLongConstant("XGranuleSizeShift").longValue(); - - XPageSizeSmallShift = db.lookupLongConstant("XPageSizeSmallShift").longValue(); - XPageSizeMediumShift = db.lookupLongConstant("XPageSizeMediumShift").longValue(); - - XObjectAlignmentMediumShift = db.lookupIntConstant("XObjectAlignmentMediumShift").intValue(); - XObjectAlignmentLargeShift = db.lookupIntConstant("XObjectAlignmentLargeShift").intValue(); - - XAddressOffsetShift = db.lookupLongConstant("XAddressOffsetShift").longValue(); - - XAddressOffsetBits = db.lookupLongConstant("XAddressOffsetBits").longValue(); - XAddressOffsetMax = db.lookupLongConstant("XAddressOffsetMax").longValue(); - } - - private static XGlobalsForVMStructs instance() { - return new XGlobalsForVMStructs(instanceField.getAddress()); - } - - public static int XGlobalPhase() { - return instance().XGlobalPhase(); - } - - public static int XGlobalSeqNum() { - return instance().XGlobalSeqNum(); - } - - public static long XAddressOffsetMask() { - return instance().XAddressOffsetMask(); - } - - public static long XAddressMetadataMask() { - return instance().XAddressMetadataMask(); - } - - public static long XAddressMetadataFinalizable() { - return instance().XAddressMetadataFinalizable(); - } - - public static long XAddressGoodMask() { - return instance().XAddressGoodMask(); - } - - public static long XAddressBadMask() { - return instance().XAddressBadMask(); - } - - public static long XAddressWeakBadMask() { - return instance().XAddressWeakBadMask(); - } - - public static int XObjectAlignmentSmallShift() { - return instance().XObjectAlignmentSmallShift(); - } - - public static int XObjectAlignmentSmall() { - return instance().XObjectAlignmentSmall(); - } -} diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/x/XGlobalsForVMStructs.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/x/XGlobalsForVMStructs.java deleted file mode 100644 index d4930dcd5dc..00000000000 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/x/XGlobalsForVMStructs.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (c) 2018, 2021, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package sun.jvm.hotspot.gc.x; - -import sun.jvm.hotspot.debugger.Address; -import sun.jvm.hotspot.runtime.VM; -import sun.jvm.hotspot.runtime.VMObject; -import sun.jvm.hotspot.types.AddressField; -import sun.jvm.hotspot.types.Type; -import sun.jvm.hotspot.types.TypeDataBase; - -class XGlobalsForVMStructs extends VMObject { - private static AddressField XGlobalPhaseField; - private static AddressField XGlobalSeqNumField; - private static AddressField XAddressOffsetMaskField; - private static AddressField XAddressMetadataMaskField; - private static AddressField XAddressMetadataFinalizableField; - private static AddressField XAddressGoodMaskField; - private static AddressField XAddressBadMaskField; - private static AddressField XAddressWeakBadMaskField; - private static AddressField XObjectAlignmentSmallShiftField; - private static AddressField XObjectAlignmentSmallField; - - static { - VM.registerVMInitializedObserver((o, d) -> initialize(VM.getVM().getTypeDataBase())); - } - - private static synchronized void initialize(TypeDataBase db) { - Type type = db.lookupType("XGlobalsForVMStructs"); - - XGlobalPhaseField = type.getAddressField("_XGlobalPhase"); - XGlobalSeqNumField = type.getAddressField("_XGlobalSeqNum"); - XAddressOffsetMaskField = type.getAddressField("_XAddressOffsetMask"); - XAddressMetadataMaskField = type.getAddressField("_XAddressMetadataMask"); - XAddressMetadataFinalizableField = type.getAddressField("_XAddressMetadataFinalizable"); - XAddressGoodMaskField = type.getAddressField("_XAddressGoodMask"); - XAddressBadMaskField = type.getAddressField("_XAddressBadMask"); - XAddressWeakBadMaskField = type.getAddressField("_XAddressWeakBadMask"); - XObjectAlignmentSmallShiftField = type.getAddressField("_XObjectAlignmentSmallShift"); - XObjectAlignmentSmallField = type.getAddressField("_XObjectAlignmentSmall"); - } - - XGlobalsForVMStructs(Address addr) { - super(addr); - } - - int XGlobalPhase() { - return XGlobalPhaseField.getValue(addr).getJIntAt(0); - } - - int XGlobalSeqNum() { - return XGlobalSeqNumField.getValue(addr).getJIntAt(0); - } - - long XAddressOffsetMask() { - return XAddressOffsetMaskField.getValue(addr).getJLongAt(0); - } - - long XAddressMetadataMask() { - return XAddressMetadataMaskField.getValue(addr).getJLongAt(0); - } - - long XAddressMetadataFinalizable() { - return XAddressMetadataFinalizableField.getValue(addr).getJLongAt(0); - } - - long XAddressGoodMask() { - return XAddressGoodMaskField.getValue(addr).getJLongAt(0); - } - - long XAddressBadMask() { - return XAddressBadMaskField.getValue(addr).getJLongAt(0); - } - - long XAddressWeakBadMask() { - return XAddressWeakBadMaskField.getValue(addr).getJLongAt(0); - } - - int XObjectAlignmentSmallShift() { - return XObjectAlignmentSmallShiftField.getValue(addr).getJIntAt(0); - } - - int XObjectAlignmentSmall() { - return XObjectAlignmentSmallField.getValue(addr).getJIntAt(0); - } -} diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/x/XGranuleMapForForwarding.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/x/XGranuleMapForForwarding.java deleted file mode 100644 index 347f1405729..00000000000 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/x/XGranuleMapForForwarding.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2021, NTT DATA. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package sun.jvm.hotspot.gc.x; - -import sun.jvm.hotspot.debugger.Address; -import sun.jvm.hotspot.runtime.VM; -import sun.jvm.hotspot.runtime.VMObject; -import sun.jvm.hotspot.types.AddressField; -import sun.jvm.hotspot.types.Type; -import sun.jvm.hotspot.types.TypeDataBase; - -public class XGranuleMapForForwarding extends VMObject { - private static AddressField mapField; - - static { - VM.registerVMInitializedObserver((o, d) -> initialize(VM.getVM().getTypeDataBase())); - } - - private static synchronized void initialize(TypeDataBase db) { - Type type = db.lookupType("XGranuleMapForForwarding"); - - mapField = type.getAddressField("_map"); - } - - public XGranuleMapForForwarding(Address addr) { - super(addr); - } - - private Address map() { - return mapField.getValue(addr); - } - - public long size() { - return XGlobals.XAddressOffsetMax >> XGlobals.XGranuleSizeShift; - } - - private long index_for_offset(long offset) { - long index = offset >>> XGlobals.XGranuleSizeShift; - - return index; - } - - Address at(long index) { - return map().getAddressAt(index * VM.getVM().getAddressSize()); - } - - Address get(long offset) { - long index = index_for_offset(offset); - return at(index); - } - - public class Iterator { - private long next = 0; - - boolean hasNext() { - return next < size(); - } - - Address next() { - if (next >= size()) { - throw new RuntimeException("OOIBE"); - } - - return at(next++); - } - } -} diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/x/XGranuleMapForPageTable.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/x/XGranuleMapForPageTable.java deleted file mode 100644 index 468a3e2457d..00000000000 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/x/XGranuleMapForPageTable.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) 2018, 2021, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package sun.jvm.hotspot.gc.x; - -import sun.jvm.hotspot.debugger.Address; -import sun.jvm.hotspot.runtime.VM; -import sun.jvm.hotspot.runtime.VMObject; -import sun.jvm.hotspot.types.AddressField; -import sun.jvm.hotspot.types.Type; -import sun.jvm.hotspot.types.TypeDataBase; - -public class XGranuleMapForPageTable extends VMObject { - private static AddressField mapField; - - static { - VM.registerVMInitializedObserver((o, d) -> initialize(VM.getVM().getTypeDataBase())); - } - - private static synchronized void initialize(TypeDataBase db) { - Type type = db.lookupType("XGranuleMapForPageTable"); - - mapField = type.getAddressField("_map"); - } - - public XGranuleMapForPageTable(Address addr) { - super(addr); - } - - private Address map() { - return mapField.getValue(addr); - } - - public long size() { - return XGlobals.XAddressOffsetMax >> XGlobals.XGranuleSizeShift; - } - - private long index_for_addr(Address addr) { - long index = XAddress.offset(addr) >> XGlobals.XGranuleSizeShift; - - return index; - } - - Address at(long index) { - return map().getAddressAt(index * VM.getVM().getBytesPerLong()); - } - - Address get(Address addr) { - long index = index_for_addr(addr); - return at(index); - } - - public class Iterator { - private long next = 0; - - boolean hasNext() { - return next < size(); - } - - Address next() { - if (next >= size()) { - throw new RuntimeException("OOIBE"); - } - - return at(next++); - } - } -} diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/x/XHeap.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/x/XHeap.java deleted file mode 100644 index c309ce21944..00000000000 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/x/XHeap.java +++ /dev/null @@ -1,127 +0,0 @@ -/* - * Copyright (c) 2017, 2022, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package sun.jvm.hotspot.gc.x; - -import java.io.PrintStream; - -import sun.jvm.hotspot.debugger.Address; -import sun.jvm.hotspot.runtime.VM; -import sun.jvm.hotspot.runtime.VMObject; -import sun.jvm.hotspot.runtime.VMObjectFactory; -import sun.jvm.hotspot.types.Type; -import sun.jvm.hotspot.types.TypeDataBase; - -// Mirror class for XHeap - -public class XHeap extends VMObject { - - private static long pageAllocatorFieldOffset; - private static long pageTableFieldOffset; - private static long forwardingTableFieldOffset; - private static long relocateFieldOffset; - - static { - VM.registerVMInitializedObserver((o, d) -> initialize(VM.getVM().getTypeDataBase())); - } - - private static synchronized void initialize(TypeDataBase db) { - Type type = db.lookupType("XHeap"); - - pageAllocatorFieldOffset = type.getAddressField("_page_allocator").getOffset(); - pageTableFieldOffset = type.getAddressField("_page_table").getOffset(); - forwardingTableFieldOffset = type.getAddressField("_forwarding_table").getOffset(); - relocateFieldOffset = type.getAddressField("_relocate").getOffset(); - } - - public XHeap(Address addr) { - super(addr); - } - - private XPageAllocator pageAllocator() { - Address pageAllocatorAddr = addr.addOffsetTo(pageAllocatorFieldOffset); - return VMObjectFactory.newObject(XPageAllocator.class, pageAllocatorAddr); - } - - XPageTable pageTable() { - return VMObjectFactory.newObject(XPageTable.class, addr.addOffsetTo(pageTableFieldOffset)); - } - - XForwardingTable forwardingTable() { - return VMObjectFactory.newObject(XForwardingTable.class, addr.addOffsetTo(forwardingTableFieldOffset)); - } - - XRelocate relocate() { - return VMObjectFactory.newObject(XRelocate.class, addr.addOffsetTo(relocateFieldOffset)); - } - - public long maxCapacity() { - return pageAllocator().maxCapacity(); - } - - public long capacity() { - return pageAllocator().capacity(); - } - - public long used() { - return pageAllocator().used(); - } - - boolean is_relocating(Address o) { - return pageTable().is_relocating(o); - } - - Address relocate_object(Address addr) { - XForwarding forwarding = forwardingTable().get(addr); - if (forwarding == null) { - return XAddress.good(addr); - } - return relocate().relocateObject(forwarding, XAddress.good(addr)); - } - - public boolean isIn(Address addr) { - if (XAddress.isIn(addr)) { - XPage page = pageTable().get(addr); - if (page != null) { - return page.isIn(addr); - } - } - return false; - } - - public Address remapObject(Address o) { - XForwarding forwarding = forwardingTable().get(addr); - if (forwarding == null) { - return XAddress.good(o); - } - return relocate().forwardObject(forwarding, XAddress.good(o)); - } - - public void printOn(PrintStream tty) { - tty.print(" ZHeap "); - tty.print("used " + (used() / 1024 / 1024) + "M, "); - tty.print("capacity " + (capacity() / 1024 / 1024) + "M, "); - tty.println("max capacity " + (maxCapacity() / 1024 / 1024) + "M"); - } -} diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/x/XOop.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/x/XOop.java deleted file mode 100644 index bbe296f658b..00000000000 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/x/XOop.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright (c) 2018, 2021, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package sun.jvm.hotspot.gc.x; - -import sun.jvm.hotspot.debugger.Address; -import sun.jvm.hotspot.debugger.OopHandle; - -class XOop { - static Address to_address(OopHandle oop) { - return oop; - } -} diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/x/XPage.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/x/XPage.java deleted file mode 100644 index a6315f10130..00000000000 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/x/XPage.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright (c) 2018, 2021, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package sun.jvm.hotspot.gc.x; - -import java.util.ArrayList; -import java.util.List; - -import sun.jvm.hotspot.debugger.Address; -import sun.jvm.hotspot.debugger.OopHandle; -import sun.jvm.hotspot.gc.shared.LiveRegionsProvider; -import sun.jvm.hotspot.memory.MemRegion; -import sun.jvm.hotspot.oops.Oop; -import sun.jvm.hotspot.oops.UnknownOopException; -import sun.jvm.hotspot.runtime.VM; -import sun.jvm.hotspot.runtime.VMObject; -import sun.jvm.hotspot.runtime.VMObjectFactory; -import sun.jvm.hotspot.types.AddressField; -import sun.jvm.hotspot.types.CIntegerField; -import sun.jvm.hotspot.types.Type; -import sun.jvm.hotspot.types.TypeDataBase; - -public class XPage extends VMObject implements LiveRegionsProvider { - private static CIntegerField typeField; - private static CIntegerField seqnumField; - private static long virtualFieldOffset; - private static AddressField topField; - - static { - VM.registerVMInitializedObserver((o, d) -> initialize(VM.getVM().getTypeDataBase())); - } - - private static synchronized void initialize(TypeDataBase db) { - Type type = db.lookupType("XPage"); - - typeField = type.getCIntegerField("_type"); - seqnumField = type.getCIntegerField("_seqnum"); - virtualFieldOffset = type.getField("_virtual").getOffset(); - topField = type.getAddressField("_top"); - } - - public XPage(Address addr) { - super(addr); - } - - private byte type() { - return typeField.getJByte(addr); - } - - private int seqnum() { - return seqnumField.getJInt(addr); - } - - private XVirtualMemory virtual() { - return VMObjectFactory.newObject(XVirtualMemory.class, addr.addOffsetTo(virtualFieldOffset)); - } - - private Address top() { - return topField.getValue(addr); - } - - private boolean is_relocatable() { - return seqnum() < XGlobals.XGlobalSeqNum(); - } - - long start() { - return virtual().start(); - } - - long size() { - return virtual().end() - virtual().start(); - } - - long object_alignment_shift() { - if (type() == XGlobals.XPageTypeSmall) { - return XGlobals.XObjectAlignmentSmallShift(); - } else if (type() == XGlobals.XPageTypeMedium) { - return XGlobals.XObjectAlignmentMediumShift; - } else { - assert(type() == XGlobals.XPageTypeLarge); - return XGlobals.XObjectAlignmentLargeShift; - } - } - - long objectAlignmentSize() { - return 1 << object_alignment_shift(); - } - - public boolean isIn(Address addr) { - long offset = XAddress.offset(addr); - // FIXME: it does not consider the sign. - return (offset >= start()) && (offset < top().asLongValue()); - } - - private long getObjectSize(Address good) { - OopHandle handle = good.addOffsetToAsOopHandle(0); - Oop obj = null; - - try { - obj = VM.getVM().getObjectHeap().newOop(handle); - } catch (UnknownOopException exp) { - throw new RuntimeException(" UnknownOopException " + exp); - } - - return VM.getVM().alignUp(obj.getObjectSize(), objectAlignmentSize()); - } - - public List getLiveRegions() { - Address start = XAddress.good(XUtils.longToAddress(start())); - - // Can't convert top() to a "good" address because it might - // be at the top of the "offset" range, and therefore also - // looks like one of the color bits. Instead use the "good" - // address and add the size. - long size = top().asLongValue() - start(); - Address end = start.addOffsetTo(size); - - return List.of(new MemRegion(start, end)); - } -} diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/x/XPageAllocator.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/x/XPageAllocator.java deleted file mode 100644 index 1af19ea875f..00000000000 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/x/XPageAllocator.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2017, 2021, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package sun.jvm.hotspot.gc.x; - -import sun.jvm.hotspot.debugger.Address; -import sun.jvm.hotspot.runtime.VM; -import sun.jvm.hotspot.runtime.VMObject; -import sun.jvm.hotspot.types.CIntegerField; -import sun.jvm.hotspot.types.Type; -import sun.jvm.hotspot.types.TypeDataBase; - -// Mirror class for XPageAllocator - -public class XPageAllocator extends VMObject { - - private static CIntegerField maxCapacityField; - private static CIntegerField capacityField; - private static CIntegerField usedField; - - static { - VM.registerVMInitializedObserver((o, d) -> initialize(VM.getVM().getTypeDataBase())); - } - - private static synchronized void initialize(TypeDataBase db) { - Type type = db.lookupType("XPageAllocator"); - - maxCapacityField = type.getCIntegerField("_max_capacity"); - capacityField = type.getCIntegerField("_capacity"); - usedField = type.getCIntegerField("_used"); - } - - public long maxCapacity() { - return maxCapacityField.getValue(addr); - } - - public long capacity() { - return capacityField.getValue(addr); - } - - public long used() { - return usedField.getValue(addr); - } - - public XPageAllocator(Address addr) { - super(addr); - } -} diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/x/XPageTable.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/x/XPageTable.java deleted file mode 100644 index c2aba43b912..00000000000 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/x/XPageTable.java +++ /dev/null @@ -1,176 +0,0 @@ -/* - * Copyright (c) 2018, 2022, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package sun.jvm.hotspot.gc.x; - -import java.util.Iterator; - -import sun.jvm.hotspot.debugger.Address; -import sun.jvm.hotspot.runtime.VM; -import sun.jvm.hotspot.runtime.VMObject; -import sun.jvm.hotspot.runtime.VMObjectFactory; -import sun.jvm.hotspot.types.Type; -import sun.jvm.hotspot.types.TypeDataBase; - -public class XPageTable extends VMObject { - private static long mapFieldOffset; - - static { - VM.registerVMInitializedObserver((o, d) -> initialize(VM.getVM().getTypeDataBase())); - } - - private static synchronized void initialize(TypeDataBase db) { - Type type = db.lookupType("XPageTable"); - - mapFieldOffset = type.getAddressField("_map").getOffset(); - } - - public XPageTable(Address addr) { - super(addr); - } - - private XGranuleMapForPageTable map() { - return VMObjectFactory.newObject(XGranuleMapForPageTable.class, addr.addOffsetTo(mapFieldOffset)); - } - - private XPageTableEntry getEntry(Address o) { - return new XPageTableEntry(map().get(o)); - } - - XPage get(Address o) { - return VMObjectFactory.newObject(XPage.class, map().get(VM.getVM().getDebugger().newAddress(XAddress.offset(o)))); - } - - boolean is_relocating(Address o) { - return getEntry(o).relocating(); - } - - private class XPagesIterator implements Iterator { - private XGranuleMapForPageTable.Iterator mapIter; - private XPage next; - - XPagesIterator() { - mapIter = map().new Iterator(); - positionToNext(); - } - - private XPage positionToNext() { - XPage current = next; - - // Find next - XPage found = null; - while (mapIter.hasNext()) { - XPageTableEntry entry = new XPageTableEntry(mapIter.next()); - if (!entry.isEmpty()) { - XPage page = entry.page(); - // Medium pages have repeated entries for all covered slots, - // therefore we need to compare against the current page. - if (page != null && !page.equals(current)) { - found = page; - break; - } - } - } - - next = found; - - return current; - } - - @Override - public boolean hasNext() { - return next != null; - } - - @Override - public XPage next() { - return positionToNext(); - } - - @Override - public void remove() { - /* not supported */ - } - } - - abstract class XPageFilter { - public abstract boolean accept(XPage page); - } - - class XPagesFilteredIterator implements Iterator { - private XPage next; - private XPagesIterator iter = new XPagesIterator(); - private XPageFilter filter; - - XPagesFilteredIterator(XPageFilter filter) { - this.filter = filter; - positionToNext(); - } - - public XPage positionToNext() { - XPage current = next; - - // Find next - XPage found = null; - while (iter.hasNext()) { - XPage page = iter.next(); - if (filter.accept(page)) { - found = page; - break; - } - } - - next = found; - - return current; - } - - @Override - public boolean hasNext() { - return next != null; - } - - @Override - public XPage next() { - return positionToNext(); - } - - @Override - public void remove() { - /* not supported */ - } - } - - public Iterator iterator() { - return new XPagesIterator(); - } - - public Iterator activePagesIterator() { - return new XPagesFilteredIterator(new XPageFilter() { - public boolean accept(XPage page) { - return page != null; - } - }); - } -} diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/x/XPageTableEntry.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/x/XPageTableEntry.java deleted file mode 100644 index 42a29878ecc..00000000000 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/x/XPageTableEntry.java +++ /dev/null @@ -1,52 +0,0 @@ -/* - * Copyright (c) 2018, 2022, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package sun.jvm.hotspot.gc.x; - -import sun.jvm.hotspot.debugger.Address; -import sun.jvm.hotspot.runtime.VMObjectFactory; - -class XPageTableEntry { - Address entry; - - XPageTableEntry(Address address) { - entry = address; - } - - XPage page() { - return VMObjectFactory.newObject(XPage.class, zPageBits()); - } - - private Address zPageBits() { - return entry.andWithMask(~1L); - } - - boolean relocating() { - return (entry.asLongValue() & 1) == 1; - } - - boolean isEmpty() { - return entry == null || zPageBits() == null; - } -} diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/x/XRelocate.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/x/XRelocate.java deleted file mode 100644 index a4b0dc1c992..00000000000 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/x/XRelocate.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. - * Copyright (c) 2021, NTT DATA. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package sun.jvm.hotspot.gc.x; - -import sun.jvm.hotspot.debugger.Address; -import sun.jvm.hotspot.runtime.VM; -import sun.jvm.hotspot.runtime.VMObject; -import sun.jvm.hotspot.types.AddressField; -import sun.jvm.hotspot.types.Type; -import sun.jvm.hotspot.types.TypeDataBase; - -public class XRelocate extends VMObject { - - static { - VM.registerVMInitializedObserver((o, d) -> initialize(VM.getVM().getTypeDataBase())); - } - - private static synchronized void initialize(TypeDataBase db) { - Type type = db.lookupType("XRelocate"); - } - - public XRelocate(Address addr) { - super(addr); - } - - private long forwardingIndex(XForwarding forwarding, Address from) { - long fromOffset = XAddress.offset(from); - return (fromOffset - forwarding.start()) >>> forwarding.objectAlignmentShift(); - } - - private Address forwardingFind(XForwarding forwarding, Address from) { - long fromIndex = forwardingIndex(forwarding, from); - XForwardingEntry entry = forwarding.find(fromIndex); - return entry.populated() ? XAddress.good(VM.getVM().getDebugger().newAddress(entry.toOffset())) : null; - } - - public Address forwardObject(XForwarding forwarding, Address from) { - return forwardingFind(forwarding, from); - } - - public Address relocateObject(XForwarding forwarding, Address o) { - Address toAddr = forwardingFind(forwarding, o); - if (toAddr != null) { - // Already relocated. - return toAddr; - } else { - // Return original address because it is not yet relocated. - return o; - } - } -} diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/x/XVirtualMemory.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/x/XVirtualMemory.java deleted file mode 100644 index de225ccdcbd..00000000000 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/x/XVirtualMemory.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2018, 2021, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -package sun.jvm.hotspot.gc.x; - -import sun.jvm.hotspot.debugger.Address; -import sun.jvm.hotspot.runtime.VM; -import sun.jvm.hotspot.runtime.VMObject; -import sun.jvm.hotspot.types.CIntegerField; -import sun.jvm.hotspot.types.Type; -import sun.jvm.hotspot.types.TypeDataBase; - -public class XVirtualMemory extends VMObject { - private static CIntegerField startField; - private static CIntegerField endField; - - static { - VM.registerVMInitializedObserver((o, d) -> initialize(VM.getVM().getTypeDataBase())); - } - - private static synchronized void initialize(TypeDataBase db) { - Type type = db.lookupType("XVirtualMemory"); - - startField = type.getCIntegerField("_start"); - endField = type.getCIntegerField("_end"); - } - - public XVirtualMemory(Address addr) { - super(addr); - } - - long start() { - return startField.getJLong(addr); - } - - long end() { - return endField.getJLong(addr); - } -} diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/memory/Universe.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/memory/Universe.java index c4ab8e32c0b..01fd0f7430a 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/memory/Universe.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/memory/Universe.java @@ -36,7 +36,6 @@ import sun.jvm.hotspot.gc.serial.SerialHeap; import sun.jvm.hotspot.gc.shared.CollectedHeap; import sun.jvm.hotspot.gc.shenandoah.ShenandoahHeap; -import sun.jvm.hotspot.gc.x.XCollectedHeap; import sun.jvm.hotspot.gc.z.ZCollectedHeap; import sun.jvm.hotspot.oops.Oop; import sun.jvm.hotspot.runtime.BasicType; @@ -87,7 +86,6 @@ private static synchronized void initialize(TypeDataBase db) { addHeapTypeIfInDB(db, ParallelScavengeHeap.class); addHeapTypeIfInDB(db, G1CollectedHeap.class); addHeapTypeIfInDB(db, EpsilonHeap.class); - addHeapTypeIfInDB(db, XCollectedHeap.class); addHeapTypeIfInDB(db, ZCollectedHeap.class); addHeapTypeIfInDB(db, ShenandoahHeap.class); diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ObjectHeap.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ObjectHeap.java index 2c1ad426b6a..be6c8522fc5 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ObjectHeap.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/oops/ObjectHeap.java @@ -37,7 +37,6 @@ import sun.jvm.hotspot.gc.g1.*; import sun.jvm.hotspot.gc.shenandoah.*; import sun.jvm.hotspot.gc.parallel.*; -import sun.jvm.hotspot.gc.x.*; import sun.jvm.hotspot.memory.*; import sun.jvm.hotspot.runtime.*; import sun.jvm.hotspot.types.*; diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/ThreadLocalAllocBuffer.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/ThreadLocalAllocBuffer.java index cb5e2add580..1dc67330d3d 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/ThreadLocalAllocBuffer.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/ThreadLocalAllocBuffer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -75,11 +75,11 @@ private long alignmentReserve() { } private long endReserve() { - long minFillerArraySize = Array.baseOffsetInBytes(BasicType.T_INT); + long labAlignmentReserve = VM.getVM().getLabAlignmentReserve(); long reserveForAllocationPrefetch = VM.getVM().getReserveForAllocationPrefetch(); long heapWordSize = VM.getVM().getHeapWordSize(); - return Math.max(minFillerArraySize, reserveForAllocationPrefetch * heapWordSize); + return Math.max(labAlignmentReserve, reserveForAllocationPrefetch) * heapWordSize; } /** Support for iteration over heap -- not sure how this will diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/VM.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/VM.java index 232f3e864a3..da900884045 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/VM.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/runtime/VM.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -127,6 +127,7 @@ public class VM { private ReversePtrs revPtrs; private VMRegImpl vmregImpl; private int reserveForAllocationPrefetch; + private int labAlignmentReserve; // System.getProperties from debuggee VM private Properties sysProps; @@ -138,12 +139,12 @@ public class VM { private Flag[] commandLineFlags; private Map flagsMap; - private static Type intType; - private static Type uintType; - private static Type intxType; - private static Type uintxType; - private static Type sizetType; - private static Type uint64tType; + private static CIntegerType intType; + private static CIntegerType uintType; + private static CIntegerType intxType; + private static CIntegerType uintxType; + private static CIntegerType sizetType; + private static CIntegerType uint64tType; private static CIntegerType boolType; private Boolean sharingEnabled; private Boolean compressedOopsEnabled; @@ -432,17 +433,29 @@ private VM(TypeDataBase db, JVMDebugger debugger, boolean isBigEndian) { vmRelease = CStringUtilities.getString(releaseAddr); Address vmInternalInfoAddr = vmVersion.getAddressField("_s_internal_vm_info_string").getValue(); vmInternalInfo = CStringUtilities.getString(vmInternalInfoAddr); - - Type threadLocalAllocBuffer = db.lookupType("ThreadLocalAllocBuffer"); - CIntegerType intType = (CIntegerType) db.lookupType("int"); - CIntegerField reserveForAllocationPrefetchField = threadLocalAllocBuffer.getCIntegerField("_reserve_for_allocation_prefetch"); - reserveForAllocationPrefetch = (int)reserveForAllocationPrefetchField.getCInteger(intType); } catch (Exception exp) { throw new RuntimeException("can't determine target's VM version : " + exp.getMessage()); } checkVMVersion(vmRelease); + // Initialize common primitive types + intType = (CIntegerType) db.lookupType("int"); + uintType = (CIntegerType) db.lookupType("uint"); + intxType = (CIntegerType) db.lookupType("intx"); + uintxType = (CIntegerType) db.lookupType("uintx"); + sizetType = (CIntegerType) db.lookupType("size_t"); + uint64tType = (CIntegerType) db.lookupType("uint64_t"); + boolType = (CIntegerType) db.lookupType("bool"); + + Type threadLocalAllocBuffer = db.lookupType("ThreadLocalAllocBuffer"); + CIntegerField reserveForAllocationPrefetchField = threadLocalAllocBuffer.getCIntegerField("_reserve_for_allocation_prefetch"); + reserveForAllocationPrefetch = (int)reserveForAllocationPrefetchField.getCInteger(intType); + + Type collectedHeap = db.lookupType("CollectedHeap"); + CIntegerField labAlignmentReserveField = collectedHeap.getCIntegerField("_lab_alignment_reserve"); + labAlignmentReserve = (int)labAlignmentReserveField.getCInteger(sizetType); + invocationEntryBCI = db.lookupIntConstant("InvocationEntryBci").intValue(); // We infer the presence of JVMTI from the presence of the InstanceKlass::_breakpoints field. @@ -493,14 +506,6 @@ private VM(TypeDataBase db, JVMDebugger debugger, boolean isBigEndian) { Flags_WAS_SET_ON_COMMAND_LINE = db.lookupIntConstant("JVMFlag::WAS_SET_ON_COMMAND_LINE").intValue(); oopSize = db.lookupIntConstant("oopSize").intValue(); - intType = db.lookupType("int"); - uintType = db.lookupType("uint"); - intxType = db.lookupType("intx"); - uintxType = db.lookupType("uintx"); - sizetType = db.lookupType("size_t"); - uint64tType = db.lookupType("uint64_t"); - boolType = (CIntegerType) db.lookupType("bool"); - minObjAlignmentInBytes = getObjectAlignmentInBytes(); if ((minObjAlignmentInBytes & (minObjAlignmentInBytes - 1)) != 0) { throw new RuntimeException("Object alignment " + minObjAlignmentInBytes + " is not power of two"); @@ -929,6 +934,10 @@ public int getReserveForAllocationPrefetch() { return reserveForAllocationPrefetch; } + public int getLabAlignmentReserve() { + return labAlignmentReserve; + } + public boolean isSharingEnabled() { if (sharingEnabled == null) { Address address = VM.getVM().getDebugger().lookup(null, "UseSharedSpaces"); diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/HeapSummary.java b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/HeapSummary.java index 86a1216bbd3..58a9c1b4519 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/HeapSummary.java +++ b/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/tools/HeapSummary.java @@ -32,7 +32,6 @@ import sun.jvm.hotspot.gc.serial.*; import sun.jvm.hotspot.gc.shenandoah.*; import sun.jvm.hotspot.gc.shared.*; -import sun.jvm.hotspot.gc.x.*; import sun.jvm.hotspot.gc.z.*; import sun.jvm.hotspot.debugger.JVMDebugger; import sun.jvm.hotspot.memory.*; @@ -145,9 +144,6 @@ public void run() { } else if (heap instanceof EpsilonHeap) { EpsilonHeap eh = (EpsilonHeap) heap; printSpace(eh.space()); - } else if (heap instanceof XCollectedHeap) { - XCollectedHeap zheap = (XCollectedHeap) heap; - zheap.printOn(System.out); } else if (heap instanceof ZCollectedHeap) { ZCollectedHeap zheap = (ZCollectedHeap) heap; zheap.printOn(System.out); diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteVector.java index 11c0fda80a4..f36215ffe12 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ByteVector.java @@ -884,6 +884,18 @@ private static BinaryOperation> binaryOperations(in v0.bOp(v1, vm, (i, a, n) -> rotateLeft(a, (int)n)); case VECTOR_OP_RROTATE: return (v0, v1, vm) -> v0.bOp(v1, vm, (i, a, n) -> rotateRight(a, (int)n)); + case VECTOR_OP_UMAX: return (v0, v1, vm) -> + v0.bOp(v1, vm, (i, a, b) -> (byte)VectorMath.maxUnsigned(a, b)); + case VECTOR_OP_UMIN: return (v0, v1, vm) -> + v0.bOp(v1, vm, (i, a, b) -> (byte)VectorMath.minUnsigned(a, b)); + case VECTOR_OP_SADD: return (v0, v1, vm) -> + v0.bOp(v1, vm, (i, a, b) -> (byte)(VectorMath.addSaturating(a, b))); + case VECTOR_OP_SSUB: return (v0, v1, vm) -> + v0.bOp(v1, vm, (i, a, b) -> (byte)(VectorMath.subSaturating(a, b))); + case VECTOR_OP_SUADD: return (v0, v1, vm) -> + v0.bOp(v1, vm, (i, a, b) -> (byte)(VectorMath.addSaturatingUnsigned(a, b))); + case VECTOR_OP_SUSUB: return (v0, v1, vm) -> + v0.bOp(v1, vm, (i, a, b) -> (byte)(VectorMath.subSaturatingUnsigned(a, b))); default: return null; } } diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntVector.java index b61e2fc991e..6cb81767cdd 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/IntVector.java @@ -884,6 +884,18 @@ private static BinaryOperation> binaryOperations( v0.bOp(v1, vm, (i, a, n) -> rotateLeft(a, (int)n)); case VECTOR_OP_RROTATE: return (v0, v1, vm) -> v0.bOp(v1, vm, (i, a, n) -> rotateRight(a, (int)n)); + case VECTOR_OP_UMAX: return (v0, v1, vm) -> + v0.bOp(v1, vm, (i, a, b) -> (int)VectorMath.maxUnsigned(a, b)); + case VECTOR_OP_UMIN: return (v0, v1, vm) -> + v0.bOp(v1, vm, (i, a, b) -> (int)VectorMath.minUnsigned(a, b)); + case VECTOR_OP_SADD: return (v0, v1, vm) -> + v0.bOp(v1, vm, (i, a, b) -> (int)(VectorMath.addSaturating(a, b))); + case VECTOR_OP_SSUB: return (v0, v1, vm) -> + v0.bOp(v1, vm, (i, a, b) -> (int)(VectorMath.subSaturating(a, b))); + case VECTOR_OP_SUADD: return (v0, v1, vm) -> + v0.bOp(v1, vm, (i, a, b) -> (int)(VectorMath.addSaturatingUnsigned(a, b))); + case VECTOR_OP_SUSUB: return (v0, v1, vm) -> + v0.bOp(v1, vm, (i, a, b) -> (int)(VectorMath.subSaturatingUnsigned(a, b))); case VECTOR_OP_COMPRESS_BITS: return (v0, v1, vm) -> v0.bOp(v1, vm, (i, a, n) -> Integer.compress(a, n)); case VECTOR_OP_EXPAND_BITS: return (v0, v1, vm) -> diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongVector.java index 68166bd9852..a740c9d49cf 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/LongVector.java @@ -842,6 +842,18 @@ private static BinaryOperation> binaryOperations(in v0.bOp(v1, vm, (i, a, n) -> rotateLeft(a, (int)n)); case VECTOR_OP_RROTATE: return (v0, v1, vm) -> v0.bOp(v1, vm, (i, a, n) -> rotateRight(a, (int)n)); + case VECTOR_OP_UMAX: return (v0, v1, vm) -> + v0.bOp(v1, vm, (i, a, b) -> (long)VectorMath.maxUnsigned(a, b)); + case VECTOR_OP_UMIN: return (v0, v1, vm) -> + v0.bOp(v1, vm, (i, a, b) -> (long)VectorMath.minUnsigned(a, b)); + case VECTOR_OP_SADD: return (v0, v1, vm) -> + v0.bOp(v1, vm, (i, a, b) -> (long)(VectorMath.addSaturating(a, b))); + case VECTOR_OP_SSUB: return (v0, v1, vm) -> + v0.bOp(v1, vm, (i, a, b) -> (long)(VectorMath.subSaturating(a, b))); + case VECTOR_OP_SUADD: return (v0, v1, vm) -> + v0.bOp(v1, vm, (i, a, b) -> (long)(VectorMath.addSaturatingUnsigned(a, b))); + case VECTOR_OP_SUSUB: return (v0, v1, vm) -> + v0.bOp(v1, vm, (i, a, b) -> (long)(VectorMath.subSaturatingUnsigned(a, b))); case VECTOR_OP_COMPRESS_BITS: return (v0, v1, vm) -> v0.bOp(v1, vm, (i, a, n) -> Long.compress(a, n)); case VECTOR_OP_EXPAND_BITS: return (v0, v1, vm) -> diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortVector.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortVector.java index 2f1ea210b90..0e3ff9aaa87 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortVector.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/ShortVector.java @@ -884,6 +884,18 @@ private static BinaryOperation> binaryOperations( v0.bOp(v1, vm, (i, a, n) -> rotateLeft(a, (int)n)); case VECTOR_OP_RROTATE: return (v0, v1, vm) -> v0.bOp(v1, vm, (i, a, n) -> rotateRight(a, (int)n)); + case VECTOR_OP_UMAX: return (v0, v1, vm) -> + v0.bOp(v1, vm, (i, a, b) -> (short)VectorMath.maxUnsigned(a, b)); + case VECTOR_OP_UMIN: return (v0, v1, vm) -> + v0.bOp(v1, vm, (i, a, b) -> (short)VectorMath.minUnsigned(a, b)); + case VECTOR_OP_SADD: return (v0, v1, vm) -> + v0.bOp(v1, vm, (i, a, b) -> (short)(VectorMath.addSaturating(a, b))); + case VECTOR_OP_SSUB: return (v0, v1, vm) -> + v0.bOp(v1, vm, (i, a, b) -> (short)(VectorMath.subSaturating(a, b))); + case VECTOR_OP_SUADD: return (v0, v1, vm) -> + v0.bOp(v1, vm, (i, a, b) -> (short)(VectorMath.addSaturatingUnsigned(a, b))); + case VECTOR_OP_SUSUB: return (v0, v1, vm) -> + v0.bOp(v1, vm, (i, a, b) -> (short)(VectorMath.subSaturatingUnsigned(a, b))); default: return null; } } diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorMath.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorMath.java new file mode 100644 index 00000000000..0d590d2d49a --- /dev/null +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorMath.java @@ -0,0 +1,586 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.incubator.vector; + +/** + * The class {@code VectorMath} contains methods for performing + * scalar numeric operations in support of vector numeric operations. + * @since 24 + */ +public final class VectorMath { + + private VectorMath() { + } + + /** + * Returns the smaller of two {@code long} values numerically treating + * the values as unsigned. That is, the result is the operand closer + * to the value of the expression {@code 0L}. If the operands have the + * same value, the result is that same value. + * + * @param a the first operand. + * @param b the second operand. + * @return the smaller of {@code a} and {@code b}. + * @see VectorOperators#UMIN + */ + public static long minUnsigned(long a, long b) { + return Long.compareUnsigned(a, b) < 0 ? a : b; + } + + /** + * Returns the greater of two {@code long} values numerically treating + * the values as unsigned. That is, the result is the operand closer + * to the value of the expression {@code 0xFFFFFFFF_FFFFFFFFL} numerically + * treating it as unsigned. If the operands have the same value, + * the result is that same value. + * + * @param a the first operand. + * @param b the second operand. + * @return the larger of {@code a} and {@code b}. + * @see VectorOperators#UMAX + */ + public static long maxUnsigned(long a, long b) { + return Long.compareUnsigned(a, b) > 0 ? a : b; + } + + /** + * Adds two {@code long} values using saturation + * arithemetic. The lower and upper (inclusive) bounds are + * {@code Long.MIN_VALUE} and {@code Long.MAX_VALUE}, respectively. + *

    + * If the result of the addition would otherwise overflow from + * a positive value to a negative value then the result is clamped + * to the upper bound {@code Long.MAX_VALUE}. + * If the result of the addition would otherwise underflow from + * a negative value to a positive value then the result is clamped + * to lower bound {@code Long.MIN_VALUE}. + * + * @param a the first operand. + * @param b the second operand. + * @return the saturating addition of the operands. + * @see VectorOperators#SADD + */ + public static long addSaturating(long a, long b) { + long res = a + b; + // HD 2-12 Overflow iff both arguments have the opposite sign of the result + if (((a ^ res) & (b ^ res)) < 0) { + return res < 0 ? Long.MAX_VALUE : Long.MIN_VALUE; + } else { + return res; + } + } + + /** + * Subtracts two {@code long} values using saturation + * arithemetic. The lower and upper (inclusive) bounds are + * {@code Long.MIN_VALUE} and {@code Long.MAX_VALUE}, respectively. + *

    + * If the result of the subtraction would otherwise overflow from + * a positive value to a negative value then the result is clamped + * to the upper bound {@code Long.MAX_VALUE}. + * If the result of the subtraction would otherwise underflow from + * a negative value to a positive value then the result is clamped + * to lower bound {@code Long.MIN_VALUE}. + * + * @param a the first operand. + * @param b the second operand. + * @return the saturating difference of the operands. + * @see VectorOperators#SSUB + */ + public static long subSaturating(long a, long b) { + long res = a - b; + // HD 2-12 Overflow iff the arguments have different signs and + // the sign of the result is different from the sign of a + if (((a ^ b) & (a ^ res)) < 0) { + return a < 0 ? Long.MIN_VALUE : Long.MAX_VALUE; + } else { + return res; + } + } + + /** + * Adds two {@code long} values using saturation + * arithemetic and numerically treating the values + * as unsigned. The lower and upper (inclusive) bounds + * are {@code 0L} and {@code 0xFFFFFFFF_FFFFFFFFL}, respectively, + * numerically treating them as unsigned. + *

    + * If the result of the unsigned addition would otherwise overflow + * from the greater of the two operands to a lesser value then the + * result is clamped to the upper bound {@code 0xFFFFFFFF_FFFFFFFFL}. + * + * @param a the first operand. + * @param b the second operand. + * @return the saturating addition of the operands. + * @see VectorOperators#SUADD + */ + public static long addSaturatingUnsigned(long a, long b) { + long res = a + b; + boolean overflow = Long.compareUnsigned(res, (a | b)) < 0; + if (overflow) { + return -1L; + } else { + return res; + } + } + + /** + * Subtracts two {@code long} values using saturation + * arithemetic and numerically treating the values + * as unsigned. The lower and upper (inclusive) bounds + * are {@code 0L} and {@code 0xFFFFFFFF_FFFFFFFFL}, respectively, + * numerically treating them as unsigned. + *

    + * If the result of the unsigned subtraction would otherwise underflow + * from the lesser of the two operands to a greater value then the + * result is clamped to the lower bound {@code 0L}. + * + * @param a the first operand. + * @param b the second operand. + * @return the saturating difference of the operands. + * @see VectorOperators#SUSUB + */ + public static long subSaturatingUnsigned(long a, long b) { + if (Long.compareUnsigned(b, a) < 0) { + return a - b; + } else { + return 0; + } + } + + + /** + * Returns the smaller of two {@code int} values numerically treating + * the values as unsigned. That is, the result is the operand closer + * to the value of the expression {@code 0}. If the operands have the + * same value, the result is that same value. + * + * @param a the first operand. + * @param b the second operand. + * @return the smaller of {@code a} and {@code b}. + * @see VectorOperators#UMIN + */ + public static int minUnsigned(int a, int b) { + return Integer.compareUnsigned(a, b) < 0 ? a : b; + } + + /** + * Returns the greater of two {@code int} values numerically treating + * the values as unsigned. That is, the result is the operand closer + * to the value of the expression {@code 0xFFFFFFFF} numerically + * treating it as unsigned. If the operands have the same value, + * the result is that same value. + * + * @param a the first operand. + * @param b the second operand. + * @return the larger of {@code a} and {@code b}. + * @see VectorOperators#UMAX + */ + public static int maxUnsigned(int a, int b) { + return Integer.compareUnsigned(a, b) > 0 ? a : b; + } + + /** + * Adds two {@code int} values using saturation + * arithemetic. The lower and upper (inclusive) bounds are + * {@code Integer.MIN_VALUE} and {@code Integer.MAX_VALUE}, respectively. + *

    + * If the result of the addition would otherwise overflow from + * a positive value to a negative value then the result is clamped + * to the upper bound {@code Integer.MAX_VALUE}. + * If the result of the addition would otherwise underflow from + * a negative value to a positive value then the result is clamped + * to lower bound {@code Integer.MIN_VALUE}. + * + * @param a the first operand. + * @param b the second operand. + * @return the saturating addition of the operands. + * @see VectorOperators#SADD + */ + public static int addSaturating(int a, int b) { + long res = (long)a + (long)b; + if (res > Integer.MAX_VALUE) { + return Integer.MAX_VALUE; + } else if (res < Integer.MIN_VALUE) { + return Integer.MIN_VALUE; + } else { + return (int)res; + } + } + + /** + * Subtracts two {@code int} values using saturation + * arithemetic. The lower and upper (inclusive) bounds are + * {@code Integer.MIN_VALUE} and {@code Integer.MAX_VALUE}, respectively. + *

    + * If the result of the subtraction would otherwise overflow from + * a positive value to a negative value then the result is clamped + * to the upper bound {@code Integer.MAX_VALUE}. + * If the result of the subtraction would otherwise underflow from + * a negative value to a positive value then the result is clamped + * to lower bound {@code Integer.MIN_VALUE}. + * + * @param a the first operand. + * @param b the second operand. + * @return the saturating difference of the operands. + * @see VectorOperators#SSUB + */ + public static int subSaturating(int a, int b) { + long res = (long)a - (long)b; + if (res > Integer.MAX_VALUE) { + return Integer.MAX_VALUE; + } else if (res < Integer.MIN_VALUE) { + return Integer.MIN_VALUE; + } else { + return (int)res; + } + } + + /** + * Adds two {@code int} values using saturation + * arithemetic and numerically treating the values + * as unsigned. The lower and upper (inclusive) bounds + * are {@code 0} and {@code 0xFFFFFFFF}, respectively, + * numerically treating them as unsigned. + *

    + * If the result of the unsigned addition would otherwise overflow + * from the greater of the two operands to a lesser value then the + * result is clamped to the upper bound {@code 0xFFFFFFFF}. + * + * @param a the first operand. + * @param b the second operand. + * @return the saturating addition of the operands. + * @see VectorOperators#SUADD + */ + public static int addSaturatingUnsigned(int a, int b) { + int res = a + b; + boolean overflow = Integer.compareUnsigned(res, (a | b)) < 0; + if (overflow) { + return -1; + } else { + return res; + } + } + + /** + * Subtracts two {@code int} values using saturation + * arithemetic and numerically treating the values + * as unsigned. The lower and upper (inclusive) bounds + * are {@code 0} and {@code -0xFFFFFFFF}, respectively, + * numerically treating them as unsigned. + *

    + * If the result of the unsigned subtraction would otherwise underflow + * from the lesser of the two operands to a greater value then the + * result is clamped to the lower bound {@code 0}. + * + * @param a the first operand. + * @param b the second operand. + * @return the saturating difference of the operands. + * @see VectorOperators#SUSUB + */ + public static int subSaturatingUnsigned(int a, int b) { + if (Integer.compareUnsigned(b, a) < 0) { + return a - b; + } else { + return 0; + } + } + + + /** + * Returns the smaller of two {@code short} values numerically treating + * the values as unsigned. That is, the result is the operand closer + * to the value of the expression {@code 0}. If the operands have the + * same value, the result is that same value. + * + * @param a the first operand. + * @param b the second operand. + * @return the smaller of {@code a} and {@code b}. + * @see VectorOperators#UMIN + */ + public static short minUnsigned(short a, short b) { + return Short.compareUnsigned(a, b) < 0 ? a : b; + } + + /** + * Returns the greater of two {@code short} values numerically treating + * the values as unsigned. That is, the result is the operand closer + * to the value of the expression {@code 0xFFFF} numerically + * treating it as unsigned. If the operands have the same value, + * the result is that same value. + * + * @param a the first operand. + * @param b the second operand. + * @return the larger of {@code a} and {@code b}. + * @see VectorOperators#UMAX + */ + public static short maxUnsigned(short a, short b) { + return Short.compareUnsigned(a, b) > 0 ? a : b; + } + + /** + * Adds two {@code short} values using saturation + * arithemetic. The lower and upper (inclusive) bounds are + * {@code Short.MIN_VALUE} and {@code Short.MAX_VALUE}, respectively. + *

    + * If the result of the addition would otherwise overflow from + * a positive value to a negative value then the result is clamped + * to the upper bound {@code Short.MAX_VALUE}. + * If the result of the addition would otherwise underflow from + * a negative value to a positive value then the result is clamped + * to lower bound {@code Short.MIN_VALUE}. + * + * @param a the first operand. + * @param b the second operand. + * @return the saturating addition of the operands. + * @see VectorOperators#SADD + */ + public static short addSaturating(short a, short b) { + int res = a + b; + if (res > Short.MAX_VALUE) { + return Short.MAX_VALUE; + } else if (res < Short.MIN_VALUE) { + return Short.MIN_VALUE; + } else { + return (short)res; + } + } + + /** + * Subtracts two {@code short} values using saturation + * arithemetic. The lower and upper (inclusive) bounds are + * {@code Short.MIN_VALUE} and {@code Short.MAX_VALUE}, respectively. + *

    + * If the result of the subtraction would otherwise overflow from + * a positive value to a negative value then the result is clamped + * to the upper bound {@code Short.MAX_VALUE}. + * If the result of the subtraction would otherwise underflow from + * a negative value to a positive value then the result is clamped + * to lower bound {@code Short.MIN_VALUE}. + * + * @param a the first operand. + * @param b the second operand. + * @return the saturating difference of the operands. + * @see VectorOperators#SSUB + */ + public static short subSaturating(short a, short b) { + int res = a - b; + if (res > Short.MAX_VALUE) { + return Short.MAX_VALUE; + } else if (res < Short.MIN_VALUE) { + return Short.MIN_VALUE; + } else { + return (short)res; + } + } + + /** + * Adds two {@code short} values using saturation + * arithemetic and numerically treating the values + * as unsigned. The lower and upper (inclusive) bounds + * are {@code 0} and {@code 0xFFFF}, respectively, + * numerically treating them as unsigned. + *

    + * If the result of the unsigned addition would otherwise overflow + * from the greater of the two operands to a lesser value then the + * result is clamped to the upper bound {@code 0xFFFF}. + * + * @param a the first operand. + * @param b the second operand. + * @return the saturating addition of the operands. + * @see VectorOperators#SUADD + */ + public static short addSaturatingUnsigned(short a, short b) { + short res = (short)(a + b); + boolean overflow = Short.compareUnsigned(res, (short)(a | b)) < 0; + if (overflow) { + return (short)(-1); + } else { + return res; + } + } + + /** + * Subtracts two {@code short} values using saturation + * arithemetic and numerically treating the values + * as unsigned. The lower and upper (inclusive) bounds + * are {@code 0} and {@code 0xFFFF}, respectively, + * numerically treating them as unsigned. + *

    + * If the result of the unsigned subtraction would otherwise underflow + * from the lesser of the two operands to a greater value then the + * result is clamped to the lower bound {@code 0}. + * + * @param a the first operand. + * @param b the second operand. + * @return the saturating difference of the operands. + * @see VectorOperators#SUSUB + */ + public static short subSaturatingUnsigned(short a, short b) { + if (Short.compareUnsigned(b, a) < 0) { + return (short)(a - b); + } else { + return 0; + } + } + + + /** + * Returns the smaller of two {@code byte} values numerically treating + * the values as unsigned. That is, the result is the operand closer + * to the value of the expression {@code 0}. If the operands have the + * same value, the result is that same value. + * + * @param a the first operand. + * @param b the second operand. + * @return the smaller of {@code a} and {@code b}. + * @see VectorOperators#UMIN + */ + public static byte minUnsigned(byte a, byte b) { + return Byte.compareUnsigned(a, b) < 0 ? a : b; + } + + /** + * Returns the greater of two {@code byte} values numerically treating + * the values as unsigned. That is, the result is the operand closer + * to the value of the expression {@code 0xFF} numerically + * treating it as unsigned. If the operands have the same value, + * the result is that same value. + * + * @param a the first operand. + * @param b the second operand. + * @return the larger of {@code a} and {@code b}. + * @see VectorOperators#UMAX + */ + public static byte maxUnsigned(byte a, byte b) { + return Byte.compareUnsigned(a, b) > 0 ? a : b; + } + + /** + * Adds two {@code byte} values using saturation + * arithemetic. The lower and upper (inclusive) bounds are + * {@code Byte.MIN_VALUE} and {@code Byte.MAX_VALUE}, respectively. + *

    + * If the result of the addition would otherwise overflow from + * a positive value to a negative value then the result is clamped + * to the upper bound {@code Byte.MAX_VALUE}. + * If the result of the addition would otherwise underflow from + * a negative value to a positive value then the result is clamped + * to lower bound {@code Byte.MIN_VALUE}. + * + * @param a the first operand. + * @param b the second operand. + * @return the saturating addition of the operands. + * @see VectorOperators#SADD + */ + public static byte addSaturating(byte a, byte b) { + int res = a + b; + if (res > Byte.MAX_VALUE) { + return Byte.MAX_VALUE; + } else if (res < Byte.MIN_VALUE) { + return Byte.MIN_VALUE; + } else { + return (byte)res; + } + } + + /** + * Subtracts two {@code byte} values using saturation + * arithemetic. The lower and upper (inclusive) bounds are + * {@code Byte.MIN_VALUE} and {@code Byte.MAX_VALUE}, respectively. + *

    + * If the result of the subtraction would otherwise overflow from + * a positive value to a negative value then the result is clamped + * to the upper bound {@code Byte.MAX_VALUE}. + * If the result of the subtraction would otherwise underflow from + * a negative value to a positive value then the result is clamped + * to lower bound {@code Byte.MIN_VALUE}. + * + * @param a the first operand. + * @param b the second operand. + * @return the saturating difference of the operands. + * @see VectorOperators#SSUB + */ + public static byte subSaturating(byte a, byte b) { + int res = a - b; + if (res > Byte.MAX_VALUE) { + return Byte.MAX_VALUE; + } else if (res < Byte.MIN_VALUE) { + return Byte.MIN_VALUE; + } else { + return (byte)res; + } + } + + /** + * Adds two {@code byte} values using saturation + * arithemetic and numerically treating the values + * as unsigned. The lower and upper (inclusive) bounds + * are {@code 0} and {@code 0xFF}, respectively, + * numerically treating them as unsigned. + *

    + * If the result of the unsigned addition would otherwise overflow + * from the greater of the two operands to a lesser value then the + * result is clamped to the upper bound {@code 0xFF}. + * + * @param a the first operand. + * @param b the second operand. + * @return the saturating addition of the operands. + * @see VectorOperators#SUADD + */ + public static byte addSaturatingUnsigned(byte a, byte b) { + byte res = (byte)(a + b); + boolean overflow = Byte.compareUnsigned(res, (byte)(a | b)) < 0; + if (overflow) { + return (byte)(-1); + } else { + return res; + } + } + + /** + * Subtracts two {@code byte} values using saturation + * arithemetic and numerically treating the values + * as unsigned. The lower and upper (inclusive) bounds + * are {@code 0} and {@code 0xFF}, respectively, + * numerically treating them as unsigned. + *

    + * If the result of the unsigned subtraction would otherwise underflow + * from the lesser of the two operands to a greater value then the + * result is clamped to the lower bound {@code 0}. + * + * @param a the first operand. + * @param b the second operand. + * @return the saturating difference of the operands. + * @see VectorOperators#SUSUB + */ + public static byte subSaturatingUnsigned(byte a, byte b) { + if (Byte.compareUnsigned(b, a) < 0) { + return (byte)(a - b); + } else { + return 0; + } + } +} diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorOperators.java b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorOperators.java index 38c4b1c94fe..fa70d65c742 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorOperators.java +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/VectorOperators.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -567,6 +567,32 @@ static boolean opKind(Operator op, int bit) { /** Produce {@code a^b}. Integral only. */ public static final /*bitwise*/ Associative XOR = assoc("XOR", "^", VectorSupport.VECTOR_OP_XOR, VO_NOFP+VO_ASSOC); + /** Produce saturating {@code a+b}. Integral only. + * @see VectorMath#addSaturating(int, int) + */ + public static final Binary SADD = binary("SADD", "+", VectorSupport.VECTOR_OP_SADD, VO_NOFP); + /** Produce saturating unsigned {@code a+b}. Integral only. + * @see VectorMath#addSaturatingUnsigned(int, int) + */ + public static final Binary SUADD = binary("SUADD", "+", VectorSupport.VECTOR_OP_SUADD, VO_NOFP); + /** Produce saturating {@code a-b}. Integral only. + * @see VectorMath#subSaturating(int, int) + */ + public static final Binary SSUB = binary("SSUB", "-", VectorSupport.VECTOR_OP_SSUB, VO_NOFP); + /** Produce saturating unsigned {@code a-b}. Integral only. + * @see VectorMath#subSaturatingUnsigned(int, int) + */ + public static final Binary SUSUB = binary("SUSUB", "-", VectorSupport.VECTOR_OP_SUSUB, VO_NOFP); + /** Produce unsigned {@code min(a,b)}. Integral only. + * @see VectorMath#minUnsigned(int, int) (int, int) + */ + public static final Associative UMIN = assoc("UMIN", "umin", VectorSupport.VECTOR_OP_UMIN, VO_NOFP+VO_ASSOC); + /** Produce unsigned {@code max(a,b)}. Integral only. + * @see VectorMath#maxUnsigned(int, int) (int, int) + */ + public static final Associative UMAX = assoc("UMAX", "umax", VectorSupport.VECTOR_OP_UMAX, VO_NOFP+VO_ASSOC); + + /** Produce {@code a<<(n&(ESIZE*8-1))}. Integral only. */ public static final /*bitwise*/ Binary LSHL = binary("LSHL", "<<", VectorSupport.VECTOR_OP_LSHIFT, VO_SHIFT); /** Produce {@code a>>(n&(ESIZE*8-1))}. Integral only. */ @@ -636,22 +662,22 @@ static boolean opKind(Operator op, int bit) { * @see java.lang.Integer#compareUnsigned * @see java.lang.Long#compareUnsigned */ - public static final Comparison UNSIGNED_LT = compare("UNSIGNED_LT", "<", VectorSupport.BT_ult, VO_NOFP); + public static final Comparison ULT = compare("ULT", "<", VectorSupport.BT_ult, VO_NOFP); /** Unsigned compare {@code a<=b}. Integral only. * @see java.lang.Integer#compareUnsigned * @see java.lang.Long#compareUnsigned */ - public static final Comparison UNSIGNED_LE = compare("UNSIGNED_LE", "<=", VectorSupport.BT_ule, VO_NOFP); + public static final Comparison ULE = compare("ULE", "<=", VectorSupport.BT_ule, VO_NOFP); /** Unsigned compare {@code a>b}. Integral only. * @see java.lang.Integer#compareUnsigned * @see java.lang.Long#compareUnsigned */ - public static final Comparison UNSIGNED_GT = compare("UNSIGNED_GT", ">", VectorSupport.BT_ugt, VO_NOFP); + public static final Comparison UGT = compare("UGT", ">", VectorSupport.BT_ugt, VO_NOFP); /** Unsigned compare {@code a>=b}. Integral only. * @see java.lang.Integer#compareUnsigned * @see java.lang.Long#compareUnsigned */ - public static final Comparison UNSIGNED_GE = compare("UNSIGNED_GE", ">=", VectorSupport.BT_uge, VO_NOFP); + public static final Comparison UGE = compare("UGE", ">=", VectorSupport.BT_uge, VO_NOFP); // Conversion operators diff --git a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-Vector.java.template b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-Vector.java.template index b9a48005ccf..b5f3a4b7d87 100644 --- a/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-Vector.java.template +++ b/src/jdk.incubator.vector/share/classes/jdk/incubator/vector/X-Vector.java.template @@ -980,6 +980,18 @@ public abstract class $abstractvectortype$ extends AbstractVector<$Boxtype$> { v0.bOp(v1, vm, (i, a, n) -> rotateLeft(a, (int)n)); case VECTOR_OP_RROTATE: return (v0, v1, vm) -> v0.bOp(v1, vm, (i, a, n) -> rotateRight(a, (int)n)); + case VECTOR_OP_UMAX: return (v0, v1, vm) -> + v0.bOp(v1, vm, (i, a, b) -> ($type$)VectorMath.maxUnsigned(a, b)); + case VECTOR_OP_UMIN: return (v0, v1, vm) -> + v0.bOp(v1, vm, (i, a, b) -> ($type$)VectorMath.minUnsigned(a, b)); + case VECTOR_OP_SADD: return (v0, v1, vm) -> + v0.bOp(v1, vm, (i, a, b) -> ($type$)(VectorMath.addSaturating(a, b))); + case VECTOR_OP_SSUB: return (v0, v1, vm) -> + v0.bOp(v1, vm, (i, a, b) -> ($type$)(VectorMath.subSaturating(a, b))); + case VECTOR_OP_SUADD: return (v0, v1, vm) -> + v0.bOp(v1, vm, (i, a, b) -> ($type$)(VectorMath.addSaturatingUnsigned(a, b))); + case VECTOR_OP_SUSUB: return (v0, v1, vm) -> + v0.bOp(v1, vm, (i, a, b) -> ($type$)(VectorMath.subSaturatingUnsigned(a, b))); #if[intOrLong] case VECTOR_OP_COMPRESS_BITS: return (v0, v1, vm) -> v0.bOp(v1, vm, (i, a, n) -> $Boxtype$.compress(a, n)); diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/DirectHotSpotObjectConstantImpl.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/DirectHotSpotObjectConstantImpl.java index cc553a39f89..8385aaa6560 100644 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/DirectHotSpotObjectConstantImpl.java +++ b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/DirectHotSpotObjectConstantImpl.java @@ -51,13 +51,17 @@ private DirectHotSpotObjectConstantImpl(Object object, boolean compressed) { @Override public JavaConstant compress() { - assert !compressed; + if (compressed) { + throw new IllegalArgumentException("already compressed: " + this); + } return new DirectHotSpotObjectConstantImpl(object, true); } @Override public JavaConstant uncompress() { - assert compressed; + if (!compressed) { + throw new IllegalArgumentException("not compressed: " + this); + } return new DirectHotSpotObjectConstantImpl(object, false); } diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotCompressedNullConstant.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotCompressedNullConstant.java index 7c6d94bba99..0becdf29976 100644 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotCompressedNullConstant.java +++ b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotCompressedNullConstant.java @@ -51,9 +51,14 @@ public boolean isCompressed() { return true; } + @Override + public boolean isCompressible() { + return false; + } + @Override public Constant compress() { - throw new IllegalArgumentException(); + throw new IllegalArgumentException("not compressible"); } @Override diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotConstant.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotConstant.java index ee4cb7bb397..e0ae6b4c881 100644 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotConstant.java +++ b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotConstant.java @@ -25,13 +25,34 @@ import jdk.vm.ci.meta.Constant; /** - * Marker interface for hotspot specific constants. + * A value in a space managed by Hotspot (e.g. heap or metaspace). + * Some of these values can be referenced with a compressed pointer + * instead of a full word-sized pointer. */ public interface HotSpotConstant extends Constant { + /** + * Determines if this constant is compressed. + */ boolean isCompressed(); + /** + * Determines if this constant is compressible. + */ + boolean isCompressible(); + + /** + * Gets a compressed version of this uncompressed constant. + * + * @throws IllegalArgumentException if this constant is not compressible + */ Constant compress(); + /** + * Gets an uncompressed version of this compressed constant. + * + * @throws IllegalArgumentException if this is an uncompressed constant + * or this constant is not compressible + */ Constant uncompress(); } diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotMetaspaceConstantImpl.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotMetaspaceConstantImpl.java index b819eaf7484..358441d0b22 100644 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotMetaspaceConstantImpl.java +++ b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotMetaspaceConstantImpl.java @@ -43,6 +43,9 @@ static MetaspaceObject getMetaspaceObject(Constant constant) { private HotSpotMetaspaceConstantImpl(MetaspaceObject metaspaceObject, boolean compressed) { this.metaspaceObject = metaspaceObject; this.compressed = compressed; + if (compressed && !canBeStoredInCompressibleMetaSpace()) { + throw new IllegalArgumentException("constant cannot be compressed: " + metaspaceObject); + } } @Override @@ -83,9 +86,28 @@ public boolean isCompressed() { return compressed; } + @Override + public boolean isCompressible() { + if (compressed) { + return false; + } + return canBeStoredInCompressibleMetaSpace(); + } + + private boolean canBeStoredInCompressibleMetaSpace() { + if (metaspaceObject instanceof HotSpotResolvedJavaType t && !t.isArray()) { + // As of JDK-8338526, interface and abstract types are not stored + // in compressible metaspace. + return !t.isInterface() && !t.isAbstract(); + } + return true; + } + @Override public Constant compress() { - assert !isCompressed(); + if (compressed) { + throw new IllegalArgumentException("already compressed: " + this); + } HotSpotMetaspaceConstantImpl res = HotSpotMetaspaceConstantImpl.forMetaspaceObject(metaspaceObject, true); assert res.isCompressed(); return res; @@ -93,7 +115,9 @@ public Constant compress() { @Override public Constant uncompress() { - assert isCompressed(); + if (!compressed) { + throw new IllegalArgumentException("not compressed: " + this); + } HotSpotMetaspaceConstantImpl res = HotSpotMetaspaceConstantImpl.forMetaspaceObject(metaspaceObject, false); assert !res.isCompressed(); return res; diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotObjectConstantImpl.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotObjectConstantImpl.java index 443673a8783..e4a77daf0d4 100644 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotObjectConstantImpl.java +++ b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotObjectConstantImpl.java @@ -52,6 +52,11 @@ public boolean isCompressed() { return compressed; } + @Override + public boolean isCompressible() { + return !compressed; + } + @Override public abstract JavaConstant compress(); diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/IndirectHotSpotObjectConstantImpl.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/IndirectHotSpotObjectConstantImpl.java index 33c6fde3b18..fe268e90476 100644 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/IndirectHotSpotObjectConstantImpl.java +++ b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/IndirectHotSpotObjectConstantImpl.java @@ -164,13 +164,17 @@ static void clearHandle(long handle) { @Override public JavaConstant compress() { - assert !compressed; + if (compressed) { + throw new IllegalArgumentException("already compressed: " + this); + } return new IndirectHotSpotObjectConstantImpl(this, true); } @Override public JavaConstant uncompress() { - assert compressed; + if (!compressed) { + throw new IllegalArgumentException("not compressed: " + this); + } return new IndirectHotSpotObjectConstantImpl(this, false); } diff --git a/src/jdk.jartool/share/man/jar.1 b/src/jdk.jartool/share/man/jar.1 index 865925cd075..a88653753ee 100644 --- a/src/jdk.jartool/share/man/jar.1 +++ b/src/jdk.jartool/share/man/jar.1 @@ -118,6 +118,9 @@ Updates an existing JAR file. .TP \f[V]-x\f[R] or \f[V]--extract\f[R] Extracts the named (or all) files from the archive. +If a file with the same name appears more than once in the archive, each +copy will be extracted, with later copies overwriting (replacing) +earlier copies unless -k is specified. .TP \f[V]-d\f[R] or \f[V]--describe-module\f[R] Prints the module descriptor or automatic module name. @@ -212,6 +215,14 @@ time-zone format, to use for the timestamp of the entries, e.g. .TP \f[V]--dir\f[R] \f[I]DIR\f[R] Directory into which the JAR file will be extracted. +.TP +\f[V]-k\f[R] or \f[V]--keep-old-files\f[R] +Do not overwrite existing files. +If a Jar file entry with the same name exists in the target directory, +the existing file will not be overwritten. +As a result, if a file appears more than once in an archive, later +copies will not overwrite earlier copies. +Also note that some file system can be case insensitive. .SH OTHER OPTIONS .PP The following options are recognized by the \f[V]jar\f[R] command and diff --git a/src/jdk.jcmd/share/man/jcmd.1 b/src/jdk.jcmd/share/man/jcmd.1 index a639dab16e1..495b629089d 100644 --- a/src/jdk.jcmd/share/man/jcmd.1 +++ b/src/jdk.jcmd/share/man/jcmd.1 @@ -65,13 +65,6 @@ selected JVM. The list of available commands for \f[V]jcmd\f[R] is obtained by running the \f[V]help\f[R] command (\f[V]jcmd\f[R] \f[I]pid\f[R] \f[V]help\f[R]) where \f[I]pid\f[R] is the process ID for the running Java process. -If the \f[I]pid\f[R] is \f[V]0\f[R], commands will be sent to all Java -processes. -The main class argument will be used to match, either partially or -fully, the class used to start Java. -If no options are given, it lists the running Java process identifiers -with the main class and command-line arguments that were used to launch -the process (the same as using \f[V]-l\f[R]). .TP \f[V]Perfcounter.print\f[R] Prints the performance counters exposed by the specified Java process. @@ -102,9 +95,10 @@ to the JVM. It must be used on the same machine on which the JVM is running, and have the same effective user and group identifiers that were used to launch the JVM. -Each diagnostic command has its own set of arguments. -To display the description, syntax, and a list of available arguments -for a diagnostic command, use the name of the command as the argument. +Each diagnostic command has its own set of options and arguments. +To display the description, syntax, and a list of available options and +arguments for a diagnostic command, use the name of the command as the +argument. For example: .RS .PP @@ -143,6 +137,11 @@ that are not in separate docker processes along with the main class and command-line arguments that were used to launch the process (the same as using \f[V]-l\f[R]). .PP +\f[V]jcmd\f[R] \f[I]commands\f[R] may take options and arguments. +\f[I]Options\f[R] are specified using either \f[I]key\f[R] or +\f[I]key\f[R]\f[V]=\f[R]\f[I]value\f[R] syntax. +\f[I]Arguments\f[R] are given as just a value, never name=value. +.PP The following commands are available: .TP \f[V]help\f[R] [\f[I]options\f[R]] [\f[I]arguments\f[R]] @@ -254,13 +253,9 @@ Impact: Low .PP \f[I]arguments\f[R]: .IP \[bu] 2 -\f[I]filename\f[R]: (Optional) The name of the map file (STRING, -/tmp/perf-.map) -.PP -If \f[V]filename\f[R] is not specified, a default file name is chosen -using the pid of the target JVM process. -For example, if the pid is \f[V]12345\f[R], then the default -\f[V]filename\f[R] will be \f[V]/tmp/perf-12345.map\f[R]. +\f[I]filename\f[R]: (Optional) The name of the map file. +If %p is specified in the filename, it is expanded to the JVM\[aq]s PID. +(FILE, \[dq]/tmp/perf-%p.map\[dq]) .RE .TP \f[V]Compiler.queue\f[R] @@ -302,7 +297,7 @@ Provides information about the Java finalization queue. Impact: Medium .RE .TP -\f[V]GC.heap_dump\f[R] [\f[I]options\f[R]] [\f[I]arguments\f[R]] +\f[V]GC.heap_dump\f[R] [\f[I]options\f[R]] \f[I]filename\f[R] Generates a HPROF format dump of the Java heap. .RS .PP @@ -335,7 +330,9 @@ fewer. .PP \f[I]arguments\f[R]: .IP \[bu] 2 -\f[I]filename\f[R]: The name of the dump file (STRING, no default value) +\f[I]filename\f[R]: The name of the dump file. +If %p is specified in the filename, it is expanded to the JVM\[aq]s PID. +(FILE, no default value) .RE .TP \f[V]GC.heap_info\f[R] @@ -511,7 +508,7 @@ The filename may also be a directory in which case, the filename is generated from the PID and the current date in the specified directory. If %p and/or %t is specified in the filename, it expands to the JVM\[aq]s PID and the current timestamp, respectively. -(STRING, no default value) +(FILE, no default value) .IP \[bu] 2 \f[V]maxage\f[R]: (Optional) Length of time for dumping the flight recording data to a file. @@ -581,7 +578,7 @@ The filename may also be a directory in which case, the filename is generated from the PID and the current date in the specified directory. If %p and/or %t is specified in the filename, it expands to the JVM\[aq]s PID and the current timestamp, respectively. -(STRING, no default value) +(FILE, no default value) .IP \[bu] 2 \f[V]maxage\f[R]: (Optional) Maximum time to keep the recorded data on disk. @@ -675,7 +672,7 @@ is written when the recording is stopped. If %p and/or %t is specified in the filename, it expands to the JVM\[aq]s PID and the current timestamp, respectively. If no path is provided, the data from the recording is discarded. -(STRING, no default value) +(FILE, no default value) .IP \[bu] 2 \f[V]name\f[R]: (Optional) Name of the recording (STRING, no default value) @@ -877,8 +874,9 @@ The following \f[I]options\f[R] must be specified using either .IP \[bu] 2 \f[V]-H\f[R]: (Optional) Human readable format (BOOLEAN, false) .IP \[bu] 2 -\f[V]-F\f[R]: (Optional) File path (STRING, -\[dq]vm_memory_map_.txt\[dq]) +\f[V]-F\f[R]: (Optional) File path. +If %p is specified in the filename, it is expanded to the JVM\[aq]s PID. +(FILE, \[dq]vm_memory_map_%p.txt\[dq]) .RE .TP \f[V]System.map\f[R] [\f[I]options\f[R]] (Linux only) @@ -934,8 +932,9 @@ false) .PP \f[I]arguments\f[R]: .IP \[bu] 2 -\f[I]filepath\f[R]: The file path to the output file (STRING, no default -value) +\f[I]filepath\f[R]: The file path to the output file. +If %p is specified in the filename, it is expanded to the JVM\[aq]s PID. +(FILE, no default value) .RE .TP \f[V]Thread.print\f[R] [\f[I]options\f[R]] @@ -970,16 +969,9 @@ Impact: Medium --- pause time depends on number of loaded classes \f[I]subcmd\f[R]: must be either \f[V]static_dump\f[R] or \f[V]dynamic_dump\f[R] (STRING, no default value) .IP \[bu] 2 -\f[I]filename\f[R]: (Optional) Name of the shared archive to be dumped -(STRING, java_pid_.jsa) -.PP -If \f[V]filename\f[R] is not specified, a default file name is chosen -using the pid of the target JVM process. -For example, java_pid1234_static.jsa, java_pid5678_dynamic.jsa, etc. -.PP -If \f[V]filename\f[R] is not specified as an absolute path, the archive -file is created in a directory relative to the current directory of the -target JVM process. +\f[I]filename\f[R]: (Optional) Name of the shared archive to be dumped. +If %p is specified in the filename, it is expanded to the JVM\[aq]s PID. +(FILE, \[dq]java_pid%p_.jsa\[dq]) .PP If \f[V]dynamic_dump\f[R] is specified, the target JVM must be started with the JVM option \f[V]-XX:+RecordDynamicDumpInfo\f[R]. diff --git a/src/jdk.jdeps/share/classes/com/sun/tools/javap/ClassWriter.java b/src/jdk.jdeps/share/classes/com/sun/tools/javap/ClassWriter.java index 77fbce8839e..92a0c06c1c3 100644 --- a/src/jdk.jdeps/share/classes/com/sun/tools/javap/ClassWriter.java +++ b/src/jdk.jdeps/share/classes/com/sun/tools/javap/ClassWriter.java @@ -576,9 +576,7 @@ protected void writeMethod(MethodModel m) { attrWriter.write(m.attributes()); } else if (code != null) { if (options.showDisassembled) { - println("Code:"); - codeWriter.writeInstrs(code); - codeWriter.writeExceptionTable(code); + codeWriter.writeMinimal(code); } if (options.showLineAndLocalVariableTables) { diff --git a/src/jdk.jdeps/share/classes/com/sun/tools/javap/CodeWriter.java b/src/jdk.jdeps/share/classes/com/sun/tools/javap/CodeWriter.java index 8f6b9b1d2ed..cb401c9f197 100644 --- a/src/jdk.jdeps/share/classes/com/sun/tools/javap/CodeWriter.java +++ b/src/jdk.jdeps/share/classes/com/sun/tools/javap/CodeWriter.java @@ -70,13 +70,11 @@ protected CodeWriter(Context context) { } void write(CodeAttribute attr) { - println("Code:"); - indent(+1); - writeVerboseHeader(attr); - writeInstrs(attr); - writeExceptionTable(attr); - attrWriter.write(attr.attributes(), attr); - indent(-1); + writeInternal(attr, false); + } + + void writeMinimal(CodeAttribute attr) { + writeInternal(attr, true); } public void writeVerboseHeader(CodeAttribute attr) { @@ -259,6 +257,20 @@ private List getDetailWriters(CodeAttribute attr) { return detailWriters; } + private void writeInternal(CodeAttribute attr, boolean minimal) { + println("Code:"); + indent(+1); + if (!minimal) { + writeVerboseHeader(attr); + } + writeInstrs(attr); + writeExceptionTable(attr); + if (!minimal) { + attrWriter.write(attr.attributes(), attr); + } + indent(-1); + } + private AttributeWriter attrWriter; private ClassWriter classWriter; private ConstantWriter constantWriter; diff --git a/src/jdk.jdi/share/classes/com/sun/jdi/ArrayReference.java b/src/jdk.jdi/share/classes/com/sun/jdi/ArrayReference.java index 11b5bdbcf70..7f445f7c05a 100644 --- a/src/jdk.jdi/share/classes/com/sun/jdi/ArrayReference.java +++ b/src/jdk.jdi/share/classes/com/sun/jdi/ArrayReference.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -108,8 +108,8 @@ public interface ArrayReference extends ObjectReference { * See JLS section 5.2 for more information on assignment * compatibility. * - * @param value the new value * @param index the index of the component to set + * @param value the new value * @throws java.lang.IndexOutOfBoundsException if * index is outside the range of this array, * that is, if either of the following are true: diff --git a/src/jdk.jdi/share/classes/com/sun/jdi/request/EventRequestManager.java b/src/jdk.jdi/share/classes/com/sun/jdi/request/EventRequestManager.java index 2ffa7008ee4..3bd363af56e 100644 --- a/src/jdk.jdi/share/classes/com/sun/jdi/request/EventRequestManager.java +++ b/src/jdk.jdi/share/classes/com/sun/jdi/request/EventRequestManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -261,8 +261,8 @@ ExceptionRequest createExceptionRequest(ReferenceType refType, * } * * @param thread the thread in which to step - * @param depth the step depth * @param size the step size + * @param depth the step depth * @return the created {@link StepRequest} * @throws DuplicateRequestException if there is already a pending * step request for the specified thread. diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/Type.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/Type.java index 0306541b4f7..7ede3de9d15 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/Type.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/Type.java @@ -38,6 +38,7 @@ import jdk.jfr.Event; import jdk.jfr.SettingControl; import jdk.jfr.ValueDescriptor; +import jdk.jfr.internal.util.Utils; /** * Internal data structure that describes a type, @@ -185,14 +186,9 @@ public ValueDescriptor getField(String name) { Type type = PrivateAccess.getInstance().getType(subField); return type.getField(post); } - } else { - for (ValueDescriptor v : getFields()) { - if (name.equals(v.getName())) { - return v; - } - } + return null; } - return null; + return Utils.findField(getFields(), name); } public List getFields() { diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/query/FieldBuilder.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/query/FieldBuilder.java index d91fa62b368..c6916bc52ef 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/query/FieldBuilder.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/query/FieldBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -49,6 +49,9 @@ import jdk.jfr.consumer.RecordedEvent; import jdk.jfr.consumer.RecordedFrame; import jdk.jfr.consumer.RecordedStackTrace; +import jdk.jfr.internal.PrivateAccess; +import jdk.jfr.internal.Type; +import jdk.jfr.internal.util.Utils; /** * This is a helper class to QueryResolver. It handles the creation of fields @@ -60,9 +63,9 @@ final class FieldBuilder { private static final Set KNOWN_TYPES = createKnownTypes(); private final List eventTypes; - private final ValueDescriptor descriptor; private final Field field; private final String fieldName; + private ValueDescriptor descriptor; public FieldBuilder(List eventTypes, FilteredType type, String fieldName) { this.eventTypes = eventTypes; @@ -77,12 +80,15 @@ public List build() { return List.of(field); } + configureAliases(); if (descriptor != null) { field.fixedWidth = !descriptor.getTypeName().equals("java.lang.String"); field.dataType = descriptor.getTypeName(); field.label = makeLabel(descriptor, hasDuration()); field.alignLeft = true; - field.valueGetter = valueGetter(field.name); + if (field.valueGetter == null) { + field.valueGetter = valueGetter(field.name); + } configureNumericTypes(); configureTime(); @@ -113,22 +119,6 @@ private boolean hasDuration() { } private boolean configureSyntheticFields() { - if (fieldName.equals("stackTrace.topApplicationFrame")) { - configureTopApplicationFrameField(); - return true; - } - if (fieldName.equals("stackTrace.notInit")) { - configureNotInitFrameField(); - return true; - } - if (fieldName.equals("stackTrace.topFrame.class")) { - configureTopFrameClassField(); - return true; - } - if (fieldName.equals("stackTrace.topFrame")) { - configureTopFrameField(); - return true; - } if (fieldName.equals("id") && field.type.getName().equals("jdk.ActiveSetting")) { configureEventTypeIdField(); return true; @@ -144,6 +134,73 @@ private boolean configureSyntheticFields() { return false; } + private void configureAliases() { + configureFrame("topFrame", FieldBuilder::topFrame); + configureFrame("topApplicationFrame", FieldBuilder::topApplicationFrame); + configureFrame("topNotInitFrame", FieldBuilder::topNotInitFrame); + } + + private void configureFrame(String frameName, Function getter) { + String name = "stackTrace." + frameName; + if (!fieldName.startsWith(name)) { + return; + } + ValueDescriptor stackTrace = Utils.findField(field.type.getFields(), "stackTrace"); + if (stackTrace == null) { + return; + } + ValueDescriptor frames = Utils.findField(stackTrace.getFields(), "frames"); + if (frames == null) { + return; + } + int length = name.length(); + if (fieldName.length() == length) { + descriptor = frames; // Use array descriptor for now + field.valueGetter = getter; + return; + } + String subName = fieldName.substring(length + 1); + Type type = PrivateAccess.getInstance().getType(frames); + ValueDescriptor subField = type.getField(subName); + if (subField != null) { + descriptor = subField; + field.valueGetter = e -> { + if (getter.apply(e) instanceof RecordedFrame frame) { + return frame.getValue(subName); + } + return null; + }; + } + } + + private static RecordedFrame topFrame(RecordedEvent event) { + return findJavaFrame(event, x -> true); + } + + private static RecordedFrame topApplicationFrame(RecordedEvent event) { + return findJavaFrame(event, frame -> { + RecordedClass cl = frame.getMethod().getType(); + RecordedClassLoader classLoader = cl.getClassLoader(); + return classLoader != null && !"bootstrap".equals(classLoader.getName()); + }); + } + + private static Object topNotInitFrame(RecordedEvent event) { + return findJavaFrame(event, frame -> !frame.getMethod().getName().equals("")); + } + + private static RecordedFrame findJavaFrame(RecordedEvent event, Predicate condition) { + RecordedStackTrace st = event.getStackTrace(); + if (st != null) { + for (RecordedFrame frame : st.getFrames()) { + if (frame.isJavaFrame() && condition.test(frame)) { + return frame; + } + } + } + return null; + } + private void configureEventTypeIdField() { Map eventTypes = createEventTypeLookup(); field.alignLeft = true; @@ -166,65 +223,6 @@ private Map createEventTypeLookup() { return map; } - private void configureTopFrameField() { - field.alignLeft = true; - field.label = "Method"; - field.dataType = "jdk.types.Method"; - field.valueGetter = e -> { - RecordedStackTrace t = e.getStackTrace(); - return t != null ? t.getFrames().getFirst() : null; - }; - field.lexicalSort = true; - } - - private void configureTopFrameClassField() { - field.alignLeft = true; - field.label = "Class"; - field.dataType = "java.lang.Class"; - field.valueGetter = e -> { - RecordedStackTrace t = e.getStackTrace(); - if (t == null) { - return null; - } - return t.getFrames().getFirst().getMethod().getType(); - }; - field.lexicalSort = true; - } - - private void configureCustomFrame(Predicate condition) { - field.alignLeft = true; - field.dataType = "jdk.types.Frame"; - field.label = "Method"; - field.lexicalSort = true; - field.valueGetter = e -> { - RecordedStackTrace t = e.getStackTrace(); - if (t != null) { - for (RecordedFrame f : t.getFrames()) { - if (f.isJavaFrame()) { - if (condition.test(f)) { - return f; - } - } - } - } - return null; - }; - } - - private void configureNotInitFrameField() { - configureCustomFrame(frame -> { - return !frame.getMethod().getName().equals(""); - }); - } - - private void configureTopApplicationFrameField() { - configureCustomFrame(frame -> { - RecordedClass cl = frame.getMethod().getType(); - RecordedClassLoader classLoader = cl.getClassLoader(); - return classLoader != null && !"bootstrap".equals(classLoader.getName()); - }); - } - private void configureEventType(Function retriever) { field.alignLeft = true; field.dataType = String.class.getName(); @@ -234,6 +232,9 @@ private void configureEventType(Function retriever) { } private static String makeLabel(ValueDescriptor v, boolean hasDuration) { + if (v.getTypeName().equals("jdk.types.StackFrame")) { + return "Method"; + } String label = v.getLabel(); if (label == null) { return v.getName(); diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/query/TableSorter.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/query/TableSorter.java index 88695162809..6a7f2e94be1 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/query/TableSorter.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/query/TableSorter.java @@ -24,6 +24,7 @@ */ package jdk.jfr.internal.query; +import java.math.BigDecimal; import java.util.Comparator; import java.util.function.Predicate; @@ -63,17 +64,80 @@ int sortOrderToFactor(SortOrder order) { @Override public int compare(Row rowA, Row rowB) { if (lexical) { - return compareObjects(rowA.getText(index), rowB.getText(index)); + return factor * compareObjects(rowA.getText(index), rowB.getText(index)); } else { - return compareObjects(rowA.getValue(index), rowB.getValue(index)); + return factor * compareObjects(rowA.getValue(index), rowB.getValue(index)); } } - private int compareObjects(Object a, Object b) { - if (a instanceof Comparable c1 && b instanceof Comparable c2) { - return factor * c1.compareTo(c2); + private static int compareObjects(Object a, Object b) { + if (a == b) { + return 0; } - return factor; + if (a == null) { + return -1; + } + if (b == null) { + return 1; + } + if (a instanceof String s1 && b instanceof String s2) { + return s1.compareTo(s2); + } + + if (a instanceof Number n1 && b instanceof Number n2) { + if (isIntegralType(n1)) { + if (isIntegralType(n2)) { + return Long.compare(n1.longValue(), n2.longValue()); + } + if (isFractionalType(n2)) { + return compare(n1.longValue(), n2.doubleValue()); + } + } + if (isFractionalType(n1)) { + if (isFractionalType(n2)) { + return Double.compare(n1.doubleValue(), n2.doubleValue()); + } + if (isIntegralType(n2)) { + return - compare(n2.longValue(), n1.doubleValue()); + } + } + } + if (a instanceof Number) { + return 1; + } + if (b instanceof Number) { + return -1; + } + // Comparison with the same class + if (a.getClass() == b.getClass() && a instanceof Comparable c1) { + return c1.compareTo((Comparable)b); + } + if (a instanceof Comparable) { + return 1; + } + if (b instanceof Comparable) { + return -1; + } + // Use something that is stable if it's not null, comparable or numeric + return Integer.compare(System.identityHashCode(a), System.identityHashCode(b)); + } + + private static int compare(long integral, double fractional) { + return BigDecimal.valueOf(integral).compareTo(BigDecimal.valueOf(fractional)); + } + + private static boolean isIntegralType(Number value) { + if (value instanceof Long || value instanceof Integer) { + return true; + } + if (value instanceof Short || value instanceof Byte) { + return true; + } + return false; + } + + private static boolean isFractionalType(Number number) { + return number instanceof Float || number instanceof Double; } } diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/query/view.ini b/src/jdk.jfr/share/classes/jdk/jfr/internal/query/view.ini index 8db19fdc239..b21b99e2dad 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/query/view.ini +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/query/view.ini @@ -186,7 +186,7 @@ table = "COLUMN 'Monitor Address', 'Class', 'Threads', 'Max Duration' label = "Deprecated Methods for Removal" table = "COLUMN 'Deprecated Method', 'Called from Class' FORMAT truncate-beginning, cell-height:10000;truncate-beginning - SELECT method AS m, SET(stackTrace.topFrame.class) + SELECT method AS m, SET(stackTrace.topFrame.method.type) FROM DeprecatedInvocation WHERE forRemoval = 'true' GROUP BY m @@ -266,7 +266,7 @@ table = "COLUMN 'Message', 'Count' [application.exception-by-site] label ="Exceptions by Site" table = "COLUMN 'Method', 'Count' - SELECT stackTrace.notInit AS S, COUNT(startTime) AS C + SELECT stackTrace.topNotInitFrame AS S, COUNT(startTime) AS C FROM JavaErrorThrow, JavaExceptionThrow GROUP BY S ORDER BY C DESC" [application.file-reads-by-path] diff --git a/src/jdk.jfr/share/classes/jdk/jfr/internal/util/Utils.java b/src/jdk.jfr/share/classes/jdk/jfr/internal/util/Utils.java index b5ae906c71c..c15e87709c5 100644 --- a/src/jdk.jfr/share/classes/jdk/jfr/internal/util/Utils.java +++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/util/Utils.java @@ -48,6 +48,7 @@ import jdk.jfr.Event; import jdk.jfr.EventType; import jdk.jfr.RecordingState; +import jdk.jfr.ValueDescriptor; import jdk.jfr.internal.LogLevel; import jdk.jfr.internal.LogTag; import jdk.jfr.internal.Logger; @@ -438,4 +439,13 @@ public static long multiplyOverflow(long a, long b, long defaultValue) { return defaultValue; } } + + public static ValueDescriptor findField(List fields, String name) { + for (ValueDescriptor v : fields) { + if (v.getName().equals(name)) { + return v; + } + } + return null; + } } diff --git a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/AbstractAppImageBuilder.java b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/AbstractAppImageBuilder.java index 4e46d9a59cc..b507cc955bd 100644 --- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/AbstractAppImageBuilder.java +++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/AbstractAppImageBuilder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,14 +27,20 @@ import java.io.IOException; import java.io.InputStream; +import java.nio.file.Files; import java.nio.file.Path; +import java.util.ArrayList; import java.util.Map; import java.util.List; +import java.util.Objects; +import java.util.stream.Stream; import static jdk.jpackage.internal.OverridableResource.createResource; import static jdk.jpackage.internal.StandardBundlerParam.APP_NAME; import static jdk.jpackage.internal.StandardBundlerParam.ICON; import static jdk.jpackage.internal.StandardBundlerParam.SOURCE_DIR; import static jdk.jpackage.internal.StandardBundlerParam.APP_CONTENT; +import static jdk.jpackage.internal.StandardBundlerParam.OUTPUT_DIR; +import static jdk.jpackage.internal.StandardBundlerParam.TEMP_ROOT; import jdk.jpackage.internal.resources.ResourceLocator; /* @@ -73,8 +79,21 @@ protected void copyApplication(Map params) throws IOException { Path inputPath = SOURCE_DIR.fetchFrom(params); if (inputPath != null) { - IOUtils.copyRecursive(SOURCE_DIR.fetchFrom(params), - appLayout.appDirectory()); + inputPath = inputPath.toAbsolutePath(); + + List excludes = new ArrayList<>(); + + for (var path : List.of(TEMP_ROOT.fetchFrom(params), OUTPUT_DIR.fetchFrom(params), root)) { + if (Files.isDirectory(path)) { + path = path.toAbsolutePath(); + if (path.startsWith(inputPath) && !Files.isSameFile(path, inputPath)) { + excludes.add(path); + } + } + } + + IOUtils.copyRecursive(inputPath, + appLayout.appDirectory().toAbsolutePath(), excludes); } AppImageFile.save(root, params); 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 16cd89d9d52..52579f50296 100644 --- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/Arguments.java +++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/Arguments.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -89,9 +89,6 @@ public class Arguments { private List allOptions = null; - private String input = null; - private Path output = null; - private boolean hasMainJar = false; private boolean hasMainClass = false; private boolean hasMainModule = false; @@ -135,9 +132,6 @@ public Arguments(String[] args) { allOptions = new ArrayList<>(); addLaunchers = new ArrayList<>(); - - output = Paths.get("").toAbsolutePath(); - deployParams.setOutput(output); } // CLIOptions is public for DeployParamsTest @@ -147,13 +141,12 @@ public enum CLIOptions { }), INPUT ("input", "i", OptionCategories.PROPERTY, () -> { - context().input = popArg(); - setOptionValue("input", context().input); + setOptionValue("input", popArg()); }), OUTPUT ("dest", "d", OptionCategories.PROPERTY, () -> { - context().output = Path.of(popArg()); - context().deployParams.setOutput(context().output); + var path = Path.of(popArg()); + setOptionValue("dest", path); }), DESCRIPTION ("description", OptionCategories.PROPERTY), @@ -711,7 +704,8 @@ private void generateBundle(Map params) Map localParams = new HashMap<>(params); try { bundler.validate(localParams); - Path result = bundler.execute(localParams, deployParams.outdir); + Path result = bundler.execute(localParams, + StandardBundlerParam.OUTPUT_DIR.fetchFrom(params)); if (result == null) { throw new PackagerException("MSG_BundlerFailed", bundler.getID(), bundler.getName()); diff --git a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/DeployParams.java b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/DeployParams.java index 3a96703e1b5..18645f17a6d 100644 --- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/DeployParams.java +++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/DeployParams.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -49,15 +49,9 @@ public class DeployParams { String targetFormat = null; // means default type for this platform - Path outdir = null; - // raw arguments to the bundler Map bundlerArguments = new LinkedHashMap<>(); - public void setOutput(Path output) { - outdir = output; - } - static class Template { Path in; Path out; diff --git a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/IOUtils.java b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/IOUtils.java index f4b0483bf98..573109a004b 100644 --- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/IOUtils.java +++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/IOUtils.java @@ -121,29 +121,52 @@ public static void copyRecursive(Path src, Path dest, CopyOption... options) } public static void copyRecursive(Path src, Path dest, - final List excludes, CopyOption... options) + final List excludes, CopyOption... options) throws IOException { + + List copyActions = new ArrayList<>(); + Files.walkFileTree(src, new SimpleFileVisitor() { @Override public FileVisitResult preVisitDirectory(final Path dir, - final BasicFileAttributes attrs) throws IOException { - if (excludes.contains(dir.toFile().getName())) { + final BasicFileAttributes attrs) { + if (isPathMatch(dir, excludes)) { return FileVisitResult.SKIP_SUBTREE; } else { - Files.createDirectories(dest.resolve(src.relativize(dir))); + copyActions.add(new CopyAction(null, dest.resolve(src. + relativize(dir)))); return FileVisitResult.CONTINUE; } } @Override public FileVisitResult visitFile(final Path file, - final BasicFileAttributes attrs) throws IOException { - if (!excludes.contains(file.toFile().getName())) { - Files.copy(file, dest.resolve(src.relativize(file)), options); + final BasicFileAttributes attrs) { + if (!isPathMatch(file, excludes)) { + copyActions.add(new CopyAction(file, dest.resolve(src. + relativize(file)))); } return FileVisitResult.CONTINUE; } }); + + for (var copyAction : copyActions) { + copyAction.apply(options); + } + } + + private static record CopyAction(Path src, Path dest) { + void apply(CopyOption... options) throws IOException { + if (src == null) { + Files.createDirectories(dest); + } else { + Files.copy(src, dest, options); + } + } + } + + private static boolean isPathMatch(Path what, List paths) { + return paths.stream().anyMatch(what::endsWith); } public static void copyFile(Path sourceFile, Path destFile) diff --git a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/StandardBundlerParam.java b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/StandardBundlerParam.java index a50293aedb5..718f186c954 100644 --- a/src/jdk.jpackage/share/classes/jdk/jpackage/internal/StandardBundlerParam.java +++ b/src/jdk.jpackage/share/classes/jdk/jpackage/internal/StandardBundlerParam.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -43,7 +43,6 @@ import java.util.Set; import java.util.function.BiFunction; import java.util.function.Function; -import java.util.stream.Collectors; import java.util.stream.Stream; /** @@ -100,6 +99,14 @@ class StandardBundlerParam extends BundlerParamInfo { (s, p) -> Path.of(s) ); + static final StandardBundlerParam OUTPUT_DIR = + new StandardBundlerParam<>( + Arguments.CLIOptions.OUTPUT.getId(), + Path.class, + p -> Path.of("").toAbsolutePath(), + (s, p) -> Path.of(s) + ); + // note that each bundler is likely to replace this one with // their own converter static final StandardBundlerParam MAIN_JAR = @@ -596,7 +603,7 @@ static void copyPredefinedRuntimeImage(Map params, } // copy whole runtime, need to skip jmods and src.zip - final List excludes = Arrays.asList("jmods", "src.zip"); + final List excludes = Arrays.asList(Path.of("jmods"), Path.of("src.zip")); IOUtils.copyRecursive(topImage, appLayout.runtimeHomeDirectory(), excludes, LinkOption.NOFOLLOW_LINKS); diff --git a/src/jdk.sctp/share/classes/com/sun/nio/sctp/SctpMultiChannel.java b/src/jdk.sctp/share/classes/com/sun/nio/sctp/SctpMultiChannel.java index b9069173938..290838755cd 100644 --- a/src/jdk.sctp/share/classes/com/sun/nio/sctp/SctpMultiChannel.java +++ b/src/jdk.sctp/share/classes/com/sun/nio/sctp/SctpMultiChannel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -481,14 +481,14 @@ public abstract T getOption(SctpSocketOption name, * @param name * The socket option * - * @param association - * The association whose option should be set, or {@code null} - * if this option should be set at the channel's socket level. - * * @param value * The value of the socket option. A value of {@code null} may be * a valid value for some socket options. * + * @param association + * The association whose option should be set, or {@code null} + * if this option should be set at the channel's socket level. + * * @return This channel * * @throws UnsupportedOperationException diff --git a/src/utils/IdealGraphVisualizer/Filter/src/main/resources/com/sun/hotspot/igv/filter/helper.js b/src/utils/IdealGraphVisualizer/Filter/src/main/resources/com/sun/hotspot/igv/filter/helper.js index 78c71c0fdb0..3426e74ba41 100644 --- a/src/utils/IdealGraphVisualizer/Filter/src/main/resources/com/sun/hotspot/igv/filter/helper.js +++ b/src/utils/IdealGraphVisualizer/Filter/src/main/resources/com/sun/hotspot/igv/filter/helper.js @@ -57,6 +57,11 @@ function hasAnyNode(selector) { return new AnySelector(selector); } +// Select the nodes for which the given property is defined. +function hasProperty(property) { + return new MatcherSelector(new Properties.InvertPropertyMatcher(new Properties.RegexpPropertyMatcher(property, ""))); +} + // Select the nodes whose given property matches a given regular expression. function matches(property, regexp) { return new MatcherSelector(new Properties.RegexpPropertyMatcher(property, regexp)); diff --git a/src/utils/IdealGraphVisualizer/ServerCompiler/src/main/resources/com/sun/hotspot/igv/servercompiler/filters/customNodeInfo.filter b/src/utils/IdealGraphVisualizer/ServerCompiler/src/main/resources/com/sun/hotspot/igv/servercompiler/filters/customNodeInfo.filter index 3f7956dc1ee..bcdd86ba7d3 100644 --- a/src/utils/IdealGraphVisualizer/ServerCompiler/src/main/resources/com/sun/hotspot/igv/servercompiler/filters/customNodeInfo.filter +++ b/src/utils/IdealGraphVisualizer/ServerCompiler/src/main/resources/com/sun/hotspot/igv/servercompiler/filters/customNodeInfo.filter @@ -30,3 +30,7 @@ editProperty(matches("name", "CallLeaf|CallLeafNoFP"), ["dump_spec"], "extra_lab function(dump_spec) {return callLeafInfo(dump_spec[0], 1);}); editProperty(matches("name", "CallLeafDirect|CallLeafDirectVector|CallLeafNoFPDirect"), ["dump_spec"], "extra_label", function(dump_spec) {return callLeafInfo(dump_spec[0], 0);}); + +// Show pre/main/post at CountedLoopNodes. +editProperty(hasProperty("loop_kind"), ["loop_kind"], "extra_label", + function(loop_kind) { return loop_kind[0]; }); diff --git a/test/hotspot/gtest/gc/x/test_xAddress.cpp b/test/hotspot/gtest/gc/x/test_xAddress.cpp deleted file mode 100644 index 3f769dc7eea..00000000000 --- a/test/hotspot/gtest/gc/x/test_xAddress.cpp +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/x/xAddress.inline.hpp" -#include "gc/x/xGlobals.hpp" -#include "unittest.hpp" - -class XAddressTest : public ::testing::Test { -protected: - static void is_good_bit(uintptr_t bit_mask) { - // Setup - XAddress::initialize(); - XAddress::set_good_mask(bit_mask); - - // Test that a pointer with only the given bit is considered good. - EXPECT_EQ(XAddress::is_good(XAddressMetadataMarked0), (bit_mask == XAddressMetadataMarked0)); - EXPECT_EQ(XAddress::is_good(XAddressMetadataMarked1), (bit_mask == XAddressMetadataMarked1)); - EXPECT_EQ(XAddress::is_good(XAddressMetadataRemapped), (bit_mask == XAddressMetadataRemapped)); - - // Test that a pointer with the given bit and some extra bits is considered good. - EXPECT_EQ(XAddress::is_good(XAddressMetadataMarked0 | 0x8),(bit_mask == XAddressMetadataMarked0)); - EXPECT_EQ(XAddress::is_good(XAddressMetadataMarked1 | 0x8), (bit_mask == XAddressMetadataMarked1)); - EXPECT_EQ(XAddress::is_good(XAddressMetadataRemapped | 0x8), (bit_mask == XAddressMetadataRemapped)); - - // Test that null is not considered good. - EXPECT_FALSE(XAddress::is_good(0)); - } - - static void is_good_or_null_bit(uintptr_t bit_mask) { - // Setup - XAddress::initialize(); - XAddress::set_good_mask(bit_mask); - - // Test that a pointer with only the given bit is considered good. - EXPECT_EQ(XAddress::is_good_or_null(XAddressMetadataMarked0), (bit_mask == XAddressMetadataMarked0)); - EXPECT_EQ(XAddress::is_good_or_null(XAddressMetadataMarked1), (bit_mask == XAddressMetadataMarked1)); - EXPECT_EQ(XAddress::is_good_or_null(XAddressMetadataRemapped), (bit_mask == XAddressMetadataRemapped)); - - // Test that a pointer with the given bit and some extra bits is considered good. - EXPECT_EQ(XAddress::is_good_or_null(XAddressMetadataMarked0 | 0x8), (bit_mask == XAddressMetadataMarked0)); - EXPECT_EQ(XAddress::is_good_or_null(XAddressMetadataMarked1 | 0x8), (bit_mask == XAddressMetadataMarked1)); - EXPECT_EQ(XAddress::is_good_or_null(XAddressMetadataRemapped | 0x8), (bit_mask == XAddressMetadataRemapped)); - - // Test that null is considered good_or_null. - EXPECT_TRUE(XAddress::is_good_or_null(0)); - } - - static void finalizable() { - // Setup - XAddress::initialize(); - XAddress::flip_to_marked(); - - // Test that a normal good pointer is good and weak good, but not finalizable - const uintptr_t addr1 = XAddress::good(1); - EXPECT_FALSE(XAddress::is_finalizable(addr1)); - EXPECT_TRUE(XAddress::is_marked(addr1)); - EXPECT_FALSE(XAddress::is_remapped(addr1)); - EXPECT_TRUE(XAddress::is_weak_good(addr1)); - EXPECT_TRUE(XAddress::is_weak_good_or_null(addr1)); - EXPECT_TRUE(XAddress::is_good(addr1)); - EXPECT_TRUE(XAddress::is_good_or_null(addr1)); - - // Test that a finalizable good pointer is finalizable and weak good, but not good - const uintptr_t addr2 = XAddress::finalizable_good(1); - EXPECT_TRUE(XAddress::is_finalizable(addr2)); - EXPECT_TRUE(XAddress::is_marked(addr2)); - EXPECT_FALSE(XAddress::is_remapped(addr2)); - EXPECT_TRUE(XAddress::is_weak_good(addr2)); - EXPECT_TRUE(XAddress::is_weak_good_or_null(addr2)); - EXPECT_FALSE(XAddress::is_good(addr2)); - EXPECT_FALSE(XAddress::is_good_or_null(addr2)); - - // Flip to remapped and test that it's no longer weak good - XAddress::flip_to_remapped(); - EXPECT_TRUE(XAddress::is_finalizable(addr2)); - EXPECT_TRUE(XAddress::is_marked(addr2)); - EXPECT_FALSE(XAddress::is_remapped(addr2)); - EXPECT_FALSE(XAddress::is_weak_good(addr2)); - EXPECT_FALSE(XAddress::is_weak_good_or_null(addr2)); - EXPECT_FALSE(XAddress::is_good(addr2)); - EXPECT_FALSE(XAddress::is_good_or_null(addr2)); - } -}; - -TEST_F(XAddressTest, is_good) { - is_good_bit(XAddressMetadataMarked0); - is_good_bit(XAddressMetadataMarked1); - is_good_bit(XAddressMetadataRemapped); -} - -TEST_F(XAddressTest, is_good_or_null) { - is_good_or_null_bit(XAddressMetadataMarked0); - is_good_or_null_bit(XAddressMetadataMarked1); - is_good_or_null_bit(XAddressMetadataRemapped); -} - -TEST_F(XAddressTest, is_weak_good_or_null) { -#define check_is_weak_good_or_null(value) \ - EXPECT_EQ(XAddress::is_weak_good_or_null(value), \ - (XAddress::is_good_or_null(value) || XAddress::is_remapped(value))) \ - << "is_good_or_null: " << XAddress::is_good_or_null(value) \ - << " is_remaped: " << XAddress::is_remapped(value) \ - << " is_good_or_null_or_remapped: " << XAddress::is_weak_good_or_null(value) - - check_is_weak_good_or_null((uintptr_t)nullptr); - check_is_weak_good_or_null(XAddressMetadataMarked0); - check_is_weak_good_or_null(XAddressMetadataMarked1); - check_is_weak_good_or_null(XAddressMetadataRemapped); - check_is_weak_good_or_null((uintptr_t)0x123); -} - -TEST_F(XAddressTest, finalizable) { - finalizable(); -} diff --git a/test/hotspot/gtest/gc/x/test_xArray.cpp b/test/hotspot/gtest/gc/x/test_xArray.cpp deleted file mode 100644 index 36c0b73ad6f..00000000000 --- a/test/hotspot/gtest/gc/x/test_xArray.cpp +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2017, 2022, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/x/xArray.inline.hpp" -#include "unittest.hpp" - -TEST(XArray, sanity) { - XArray a; - - // Add elements - for (int i = 0; i < 10; i++) { - a.append(i); - } - - XArray b; - - b.swap(&a); - - // Check size - ASSERT_EQ(a.length(), 0); - ASSERT_EQ(a.capacity(), 0); - ASSERT_EQ(a.is_empty(), true); - - ASSERT_EQ(b.length(), 10); - ASSERT_GE(b.capacity(), 10); - ASSERT_EQ(b.is_empty(), false); - - // Clear elements - a.clear(); - - // Check that b is unaffected - ASSERT_EQ(b.length(), 10); - ASSERT_GE(b.capacity(), 10); - ASSERT_EQ(b.is_empty(), false); - - a.append(1); - - // Check that b is unaffected - ASSERT_EQ(b.length(), 10); - ASSERT_GE(b.capacity(), 10); - ASSERT_EQ(b.is_empty(), false); -} - -TEST(XArray, iterator) { - XArray a; - - // Add elements - for (int i = 0; i < 10; i++) { - a.append(i); - } - - // Iterate - int count = 0; - XArrayIterator iter(&a); - for (int value; iter.next(&value);) { - ASSERT_EQ(a.at(count), count); - count++; - } - - // Check count - ASSERT_EQ(count, 10); -} diff --git a/test/hotspot/gtest/gc/x/test_xBitField.cpp b/test/hotspot/gtest/gc/x/test_xBitField.cpp deleted file mode 100644 index 248322b2a07..00000000000 --- a/test/hotspot/gtest/gc/x/test_xBitField.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2017, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/x/xBitField.hpp" -#include "unittest.hpp" - -TEST(XBitFieldTest, test) { - typedef XBitField field_bool; - typedef XBitField field_uint8; - typedef XBitField field_uint16; - typedef XBitField field_uint32; - typedef XBitField field_uint64; - typedef XBitField field_pointer; - - uint64_t entry; - - { - const bool value = false; - entry = field_bool::encode(value); - EXPECT_EQ(field_bool::decode(entry), value) << "Should be equal"; - } - - { - const bool value = true; - entry = field_bool::encode(value); - EXPECT_EQ(field_bool::decode(entry), value) << "Should be equal"; - } - - { - const uint8_t value = ~(uint8_t)0; - entry = field_uint8::encode(value); - EXPECT_EQ(field_uint8::decode(entry), value) << "Should be equal"; - } - - { - const uint16_t value = ~(uint16_t)0; - entry = field_uint16::encode(value); - EXPECT_EQ(field_uint16::decode(entry), value) << "Should be equal"; - } - - { - const uint32_t value = ~(uint32_t)0; - entry = field_uint32::encode(value); - EXPECT_EQ(field_uint32::decode(entry), value) << "Should be equal"; - } - - { - const uint64_t value = ~(uint64_t)0 >> 1; - entry = field_uint64::encode(value); - EXPECT_EQ(field_uint64::decode(entry), value) << "Should be equal"; - } - - { - void* const value = (void*)(~(uintptr_t)0 << 3); - entry = field_pointer::encode(value); - EXPECT_EQ(field_pointer::decode(entry), value) << "Should be equal"; - } -} diff --git a/test/hotspot/gtest/gc/x/test_xBitMap.cpp b/test/hotspot/gtest/gc/x/test_xBitMap.cpp deleted file mode 100644 index 2d3cb09c7ed..00000000000 --- a/test/hotspot/gtest/gc/x/test_xBitMap.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright (c) 2016, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/x/xBitMap.inline.hpp" -#include "unittest.hpp" - -class XBitMapTest : public ::testing::Test { -protected: - static void test_set_pair_unset(size_t size, bool finalizable) { - XBitMap bitmap(size); - - for (BitMap::idx_t i = 0; i < size - 1; i++) { - if ((i + 1) % BitsPerWord == 0) { - // Can't set pairs of bits in different words. - continue; - } - - // XBitMaps are not cleared when constructed. - bitmap.clear(); - - bool inc_live = false; - - bool ret = bitmap.par_set_bit_pair(i, finalizable, inc_live); - EXPECT_TRUE(ret) << "Failed to set bit"; - EXPECT_TRUE(inc_live) << "Should have set inc_live"; - - // First bit should always be set - EXPECT_TRUE(bitmap.at(i)) << "Should be set"; - - // Second bit should only be set when marking strong - EXPECT_NE(bitmap.at(i + 1), finalizable); - } - } - - static void test_set_pair_set(size_t size, bool finalizable) { - XBitMap bitmap(size); - - for (BitMap::idx_t i = 0; i < size - 1; i++) { - if ((i + 1) % BitsPerWord == 0) { - // Can't set pairs of bits in different words. - continue; - } - - // Fill the bitmap with ones. - bitmap.set_range(0, size); - - bool inc_live = false; - - bool ret = bitmap.par_set_bit_pair(i, finalizable, inc_live); - EXPECT_FALSE(ret) << "Should not succeed setting bit"; - EXPECT_FALSE(inc_live) << "Should not have set inc_live"; - - // Both bits were pre-set. - EXPECT_TRUE(bitmap.at(i)) << "Should be set"; - EXPECT_TRUE(bitmap.at(i + 1)) << "Should be set"; - } - } - - static void test_set_pair_set(bool finalizable) { - test_set_pair_set(2, finalizable); - test_set_pair_set(62, finalizable); - test_set_pair_set(64, finalizable); - test_set_pair_set(66, finalizable); - test_set_pair_set(126, finalizable); - test_set_pair_set(128, finalizable); - } - - static void test_set_pair_unset(bool finalizable) { - test_set_pair_unset(2, finalizable); - test_set_pair_unset(62, finalizable); - test_set_pair_unset(64, finalizable); - test_set_pair_unset(66, finalizable); - test_set_pair_unset(126, finalizable); - test_set_pair_unset(128, finalizable); - } - -}; - -TEST_F(XBitMapTest, test_set_pair_set) { - test_set_pair_set(false); - test_set_pair_set(true); -} - -TEST_F(XBitMapTest, test_set_pair_unset) { - test_set_pair_unset(false); - test_set_pair_unset(true); -} diff --git a/test/hotspot/gtest/gc/x/test_xForwarding.cpp b/test/hotspot/gtest/gc/x/test_xForwarding.cpp deleted file mode 100644 index de850304ebb..00000000000 --- a/test/hotspot/gtest/gc/x/test_xForwarding.cpp +++ /dev/null @@ -1,205 +0,0 @@ -/* - * Copyright (c) 2016, 2020, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/x/xAddress.inline.hpp" -#include "gc/x/xForwarding.inline.hpp" -#include "gc/x/xForwardingAllocator.inline.hpp" -#include "gc/x/xGlobals.hpp" -#include "gc/x/xPage.inline.hpp" -#include "unittest.hpp" - -using namespace testing; - -#define CAPTURE_DELIM "\n" -#define CAPTURE1(expression) #expression << " evaluates to " << expression -#define CAPTURE2(e0, e1) CAPTURE1(e0) << CAPTURE_DELIM << CAPTURE1(e1) - -#define CAPTURE(expression) CAPTURE1(expression) - -class XForwardingTest : public Test { -public: - // Helper functions - - class SequenceToFromIndex : AllStatic { - public: - static uintptr_t even(size_t sequence_number) { - return sequence_number * 2; - } - static uintptr_t odd(size_t sequence_number) { - return even(sequence_number) + 1; - } - static uintptr_t one_to_one(size_t sequence_number) { - return sequence_number; - } - }; - - // Test functions - - static void setup(XForwarding* forwarding) { - EXPECT_PRED1(is_power_of_2, forwarding->_entries.length()) << CAPTURE(forwarding->_entries.length()); - } - - static void find_empty(XForwarding* forwarding) { - size_t size = forwarding->_entries.length(); - size_t entries_to_check = size * 2; - - for (size_t i = 0; i < entries_to_check; i++) { - uintptr_t from_index = SequenceToFromIndex::one_to_one(i); - - XForwardingCursor cursor; - XForwardingEntry entry = forwarding->find(from_index, &cursor); - EXPECT_FALSE(entry.populated()) << CAPTURE2(from_index, size); - } - } - - static void find_full(XForwarding* forwarding) { - size_t size = forwarding->_entries.length(); - size_t entries_to_populate = size; - - // Populate - for (size_t i = 0; i < entries_to_populate; i++) { - uintptr_t from_index = SequenceToFromIndex::one_to_one(i); - - XForwardingCursor cursor; - XForwardingEntry entry = forwarding->find(from_index, &cursor); - ASSERT_FALSE(entry.populated()) << CAPTURE2(from_index, size); - - forwarding->insert(from_index, from_index, &cursor); - } - - // Verify - for (size_t i = 0; i < entries_to_populate; i++) { - uintptr_t from_index = SequenceToFromIndex::one_to_one(i); - - XForwardingCursor cursor; - XForwardingEntry entry = forwarding->find(from_index, &cursor); - ASSERT_TRUE(entry.populated()) << CAPTURE2(from_index, size); - - ASSERT_EQ(entry.from_index(), from_index) << CAPTURE(size); - ASSERT_EQ(entry.to_offset(), from_index) << CAPTURE(size); - } - } - - static void find_every_other(XForwarding* forwarding) { - size_t size = forwarding->_entries.length(); - size_t entries_to_populate = size / 2; - - // Populate even from indices - for (size_t i = 0; i < entries_to_populate; i++) { - uintptr_t from_index = SequenceToFromIndex::even(i); - - XForwardingCursor cursor; - XForwardingEntry entry = forwarding->find(from_index, &cursor); - ASSERT_FALSE(entry.populated()) << CAPTURE2(from_index, size); - - forwarding->insert(from_index, from_index, &cursor); - } - - // Verify populated even indices - for (size_t i = 0; i < entries_to_populate; i++) { - uintptr_t from_index = SequenceToFromIndex::even(i); - - XForwardingCursor cursor; - XForwardingEntry entry = forwarding->find(from_index, &cursor); - ASSERT_TRUE(entry.populated()) << CAPTURE2(from_index, size); - - ASSERT_EQ(entry.from_index(), from_index) << CAPTURE(size); - ASSERT_EQ(entry.to_offset(), from_index) << CAPTURE(size); - } - - // Verify empty odd indices - // - // This check could be done on a larger range of sequence numbers, - // but currently entries_to_populate is used. - for (size_t i = 0; i < entries_to_populate; i++) { - uintptr_t from_index = SequenceToFromIndex::odd(i); - - XForwardingCursor cursor; - XForwardingEntry entry = forwarding->find(from_index, &cursor); - - ASSERT_FALSE(entry.populated()) << CAPTURE2(from_index, size); - } - } - - static void test(void (*function)(XForwarding*), uint32_t size) { - // Create page - const XVirtualMemory vmem(0, XPageSizeSmall); - const XPhysicalMemory pmem(XPhysicalMemorySegment(0, XPageSizeSmall, true)); - XPage page(XPageTypeSmall, vmem, pmem); - - page.reset(); - - const size_t object_size = 16; - const uintptr_t object = page.alloc_object(object_size); - - XGlobalSeqNum++; - - bool dummy = false; - page.mark_object(XAddress::marked(object), dummy, dummy); - - const uint32_t live_objects = size; - const size_t live_bytes = live_objects * object_size; - page.inc_live(live_objects, live_bytes); - - // Setup allocator - XForwardingAllocator allocator; - const uint32_t nentries = XForwarding::nentries(&page); - allocator.reset((sizeof(XForwarding)) + (nentries * sizeof(XForwardingEntry))); - - // Setup forwarding - XForwarding* const forwarding = XForwarding::alloc(&allocator, &page); - - // Actual test function - (*function)(forwarding); - } - - // Run the given function with a few different input values. - static void test(void (*function)(XForwarding*)) { - test(function, 1); - test(function, 2); - test(function, 3); - test(function, 4); - test(function, 7); - test(function, 8); - test(function, 1023); - test(function, 1024); - test(function, 1025); - } -}; - -TEST_F(XForwardingTest, setup) { - test(&XForwardingTest::setup); -} - -TEST_F(XForwardingTest, find_empty) { - test(&XForwardingTest::find_empty); -} - -TEST_F(XForwardingTest, find_full) { - test(&XForwardingTest::find_full); -} - -TEST_F(XForwardingTest, find_every_other) { - test(&XForwardingTest::find_every_other); -} diff --git a/test/hotspot/gtest/gc/x/test_xList.cpp b/test/hotspot/gtest/gc/x/test_xList.cpp deleted file mode 100644 index f4766ce99e2..00000000000 --- a/test/hotspot/gtest/gc/x/test_xList.cpp +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Copyright (c) 2015, 2020, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/x/xList.inline.hpp" -#include "unittest.hpp" - -#ifndef PRODUCT - -class XTestEntry { - friend class XList; - -private: - const int _id; - XListNode _node; - -public: - XTestEntry(int id) : - _id(id), - _node() {} - - int id() const { - return _id; - } -}; - -class XListTest : public ::testing::Test { -protected: - static void assert_sorted(XList* list) { - // Iterate forward - { - int count = list->first()->id(); - XListIterator iter(list); - for (XTestEntry* entry; iter.next(&entry);) { - ASSERT_EQ(entry->id(), count); - count++; - } - } - - // Iterate backward - { - int count = list->last()->id(); - XListReverseIterator iter(list); - for (XTestEntry* entry; iter.next(&entry);) { - EXPECT_EQ(entry->id(), count); - count--; - } - } - } -}; - -TEST_F(XListTest, test_insert) { - XList list; - XTestEntry e0(0); - XTestEntry e1(1); - XTestEntry e2(2); - XTestEntry e3(3); - XTestEntry e4(4); - XTestEntry e5(5); - - list.insert_first(&e2); - list.insert_before(&e2, &e1); - list.insert_after(&e2, &e3); - list.insert_last(&e4); - list.insert_first(&e0); - list.insert_last(&e5); - - EXPECT_EQ(list.size(), 6u); - assert_sorted(&list); - - for (int i = 0; i < 6; i++) { - XTestEntry* e = list.remove_first(); - EXPECT_EQ(e->id(), i); - } - - EXPECT_EQ(list.size(), 0u); -} - -TEST_F(XListTest, test_remove) { - // Remove first - { - XList list; - XTestEntry e0(0); - XTestEntry e1(1); - XTestEntry e2(2); - XTestEntry e3(3); - XTestEntry e4(4); - XTestEntry e5(5); - - list.insert_last(&e0); - list.insert_last(&e1); - list.insert_last(&e2); - list.insert_last(&e3); - list.insert_last(&e4); - list.insert_last(&e5); - - EXPECT_EQ(list.size(), 6u); - - for (int i = 0; i < 6; i++) { - XTestEntry* e = list.remove_first(); - EXPECT_EQ(e->id(), i); - } - - EXPECT_EQ(list.size(), 0u); - } - - // Remove last - { - XList list; - XTestEntry e0(0); - XTestEntry e1(1); - XTestEntry e2(2); - XTestEntry e3(3); - XTestEntry e4(4); - XTestEntry e5(5); - - list.insert_last(&e0); - list.insert_last(&e1); - list.insert_last(&e2); - list.insert_last(&e3); - list.insert_last(&e4); - list.insert_last(&e5); - - EXPECT_EQ(list.size(), 6u); - - for (int i = 5; i >= 0; i--) { - XTestEntry* e = list.remove_last(); - EXPECT_EQ(e->id(), i); - } - - EXPECT_EQ(list.size(), 0u); - } -} - -#endif // PRODUCT diff --git a/test/hotspot/gtest/gc/x/test_xLiveMap.cpp b/test/hotspot/gtest/gc/x/test_xLiveMap.cpp deleted file mode 100644 index d57790e9dab..00000000000 --- a/test/hotspot/gtest/gc/x/test_xLiveMap.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (c) 2017, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/x/xLiveMap.inline.hpp" -#include "unittest.hpp" - -class XLiveMapTest : public ::testing::Test { -protected: - static void strongly_live_for_large_xpage() { - // Large XPages only have room for one object. - XLiveMap livemap(1); - - bool inc_live; - uintptr_t object = 0u; - - // Mark the object strong. - livemap.set(object, false /* finalizable */, inc_live); - - // Check that both bits are in the same segment. - ASSERT_EQ(livemap.index_to_segment(0), livemap.index_to_segment(1)); - - // Check that the object was marked. - ASSERT_TRUE(livemap.get(0)); - - // Check that the object was strongly marked. - ASSERT_TRUE(livemap.get(1)); - - ASSERT_TRUE(inc_live); - } -}; - -TEST_F(XLiveMapTest, strongly_live_for_large_xpage) { - strongly_live_for_large_xpage(); -} diff --git a/test/hotspot/gtest/gc/x/test_xPhysicalMemory.cpp b/test/hotspot/gtest/gc/x/test_xPhysicalMemory.cpp deleted file mode 100644 index f22032632e9..00000000000 --- a/test/hotspot/gtest/gc/x/test_xPhysicalMemory.cpp +++ /dev/null @@ -1,174 +0,0 @@ -/* - * Copyright (c) 2016, 2020, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/x/xPhysicalMemory.inline.hpp" -#include "unittest.hpp" - -TEST(XPhysicalMemoryTest, copy) { - const XPhysicalMemorySegment seg0(0, 100, true); - const XPhysicalMemorySegment seg1(200, 100, true); - - XPhysicalMemory pmem0; - pmem0.add_segment(seg0); - EXPECT_EQ(pmem0.nsegments(), 1); - EXPECT_EQ(pmem0.segment(0).size(), 100u); - - XPhysicalMemory pmem1; - pmem1.add_segment(seg0); - pmem1.add_segment(seg1); - EXPECT_EQ(pmem1.nsegments(), 2); - EXPECT_EQ(pmem1.segment(0).size(), 100u); - EXPECT_EQ(pmem1.segment(1).size(), 100u); - - XPhysicalMemory pmem2(pmem0); - EXPECT_EQ(pmem2.nsegments(), 1); - EXPECT_EQ(pmem2.segment(0).size(), 100u); - - pmem2 = pmem1; - EXPECT_EQ(pmem2.nsegments(), 2); - EXPECT_EQ(pmem2.segment(0).size(), 100u); - EXPECT_EQ(pmem2.segment(1).size(), 100u); -} - -TEST(XPhysicalMemoryTest, add) { - const XPhysicalMemorySegment seg0(0, 1, true); - const XPhysicalMemorySegment seg1(1, 1, true); - const XPhysicalMemorySegment seg2(2, 1, true); - const XPhysicalMemorySegment seg3(3, 1, true); - const XPhysicalMemorySegment seg4(4, 1, true); - const XPhysicalMemorySegment seg5(5, 1, true); - const XPhysicalMemorySegment seg6(6, 1, true); - - XPhysicalMemory pmem0; - EXPECT_EQ(pmem0.nsegments(), 0); - EXPECT_EQ(pmem0.is_null(), true); - - XPhysicalMemory pmem1; - pmem1.add_segment(seg0); - pmem1.add_segment(seg1); - pmem1.add_segment(seg2); - pmem1.add_segment(seg3); - pmem1.add_segment(seg4); - pmem1.add_segment(seg5); - pmem1.add_segment(seg6); - EXPECT_EQ(pmem1.nsegments(), 1); - EXPECT_EQ(pmem1.segment(0).size(), 7u); - EXPECT_EQ(pmem1.is_null(), false); - - XPhysicalMemory pmem2; - pmem2.add_segment(seg0); - pmem2.add_segment(seg1); - pmem2.add_segment(seg2); - pmem2.add_segment(seg4); - pmem2.add_segment(seg5); - pmem2.add_segment(seg6); - EXPECT_EQ(pmem2.nsegments(), 2); - EXPECT_EQ(pmem2.segment(0).size(), 3u); - EXPECT_EQ(pmem2.segment(1).size(), 3u); - EXPECT_EQ(pmem2.is_null(), false); - - XPhysicalMemory pmem3; - pmem3.add_segment(seg0); - pmem3.add_segment(seg2); - pmem3.add_segment(seg3); - pmem3.add_segment(seg4); - pmem3.add_segment(seg6); - EXPECT_EQ(pmem3.nsegments(), 3); - EXPECT_EQ(pmem3.segment(0).size(), 1u); - EXPECT_EQ(pmem3.segment(1).size(), 3u); - EXPECT_EQ(pmem3.segment(2).size(), 1u); - EXPECT_EQ(pmem3.is_null(), false); - - XPhysicalMemory pmem4; - pmem4.add_segment(seg0); - pmem4.add_segment(seg2); - pmem4.add_segment(seg4); - pmem4.add_segment(seg6); - EXPECT_EQ(pmem4.nsegments(), 4); - EXPECT_EQ(pmem4.segment(0).size(), 1u); - EXPECT_EQ(pmem4.segment(1).size(), 1u); - EXPECT_EQ(pmem4.segment(2).size(), 1u); - EXPECT_EQ(pmem4.segment(3).size(), 1u); - EXPECT_EQ(pmem4.is_null(), false); -} - -TEST(XPhysicalMemoryTest, remove) { - XPhysicalMemory pmem; - - pmem.add_segment(XPhysicalMemorySegment(10, 10, true)); - pmem.add_segment(XPhysicalMemorySegment(30, 10, true)); - pmem.add_segment(XPhysicalMemorySegment(50, 10, true)); - EXPECT_EQ(pmem.nsegments(), 3); - EXPECT_EQ(pmem.size(), 30u); - EXPECT_FALSE(pmem.is_null()); - - pmem.remove_segments(); - EXPECT_EQ(pmem.nsegments(), 0); - EXPECT_EQ(pmem.size(), 0u); - EXPECT_TRUE(pmem.is_null()); -} - -TEST(XPhysicalMemoryTest, split) { - XPhysicalMemory pmem; - - pmem.add_segment(XPhysicalMemorySegment(0, 10, true)); - pmem.add_segment(XPhysicalMemorySegment(10, 10, true)); - pmem.add_segment(XPhysicalMemorySegment(30, 10, true)); - EXPECT_EQ(pmem.nsegments(), 2); - EXPECT_EQ(pmem.size(), 30u); - - XPhysicalMemory pmem0 = pmem.split(1); - EXPECT_EQ(pmem0.nsegments(), 1); - EXPECT_EQ(pmem0.size(), 1u); - EXPECT_EQ(pmem.nsegments(), 2); - EXPECT_EQ(pmem.size(), 29u); - - XPhysicalMemory pmem1 = pmem.split(25); - EXPECT_EQ(pmem1.nsegments(), 2); - EXPECT_EQ(pmem1.size(), 25u); - EXPECT_EQ(pmem.nsegments(), 1); - EXPECT_EQ(pmem.size(), 4u); - - XPhysicalMemory pmem2 = pmem.split(4); - EXPECT_EQ(pmem2.nsegments(), 1); - EXPECT_EQ(pmem2.size(), 4u); - EXPECT_EQ(pmem.nsegments(), 0); - EXPECT_EQ(pmem.size(), 0u); -} - -TEST(XPhysicalMemoryTest, split_committed) { - XPhysicalMemory pmem0; - pmem0.add_segment(XPhysicalMemorySegment(0, 10, true)); - pmem0.add_segment(XPhysicalMemorySegment(10, 10, false)); - pmem0.add_segment(XPhysicalMemorySegment(20, 10, true)); - pmem0.add_segment(XPhysicalMemorySegment(30, 10, false)); - EXPECT_EQ(pmem0.nsegments(), 4); - EXPECT_EQ(pmem0.size(), 40u); - - XPhysicalMemory pmem1 = pmem0.split_committed(); - EXPECT_EQ(pmem0.nsegments(), 2); - EXPECT_EQ(pmem0.size(), 20u); - EXPECT_EQ(pmem1.nsegments(), 2); - EXPECT_EQ(pmem1.size(), 20u); -} diff --git a/test/hotspot/gtest/gc/x/test_xVirtualMemory.cpp b/test/hotspot/gtest/gc/x/test_xVirtualMemory.cpp deleted file mode 100644 index 6698ccfa045..00000000000 --- a/test/hotspot/gtest/gc/x/test_xVirtualMemory.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2016, 2019, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -#include "precompiled.hpp" -#include "gc/x/xVirtualMemory.inline.hpp" -#include "unittest.hpp" - -TEST(XVirtualMemory, split) { - XVirtualMemory vmem(0, 10); - - XVirtualMemory vmem0 = vmem.split(0); - EXPECT_EQ(vmem0.size(), 0u); - EXPECT_EQ(vmem.size(), 10u); - - XVirtualMemory vmem1 = vmem.split(5); - EXPECT_EQ(vmem1.size(), 5u); - EXPECT_EQ(vmem.size(), 5u); - - XVirtualMemory vmem2 = vmem.split(5); - EXPECT_EQ(vmem2.size(), 5u); - EXPECT_EQ(vmem.size(), 0u); - - XVirtualMemory vmem3 = vmem.split(0); - EXPECT_EQ(vmem3.size(), 0u); -} diff --git a/test/hotspot/gtest/metaspace/test_arenagrowthpolicy.cpp b/test/hotspot/gtest/metaspace/test_arenagrowthpolicy.cpp index a37af058e09..80e6c1d77da 100644 --- a/test/hotspot/gtest/metaspace/test_arenagrowthpolicy.cpp +++ b/test/hotspot/gtest/metaspace/test_arenagrowthpolicy.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2020 SAP SE. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * @@ -61,8 +61,6 @@ TEST_VM(metaspace, arena_growth_policy_##spacetype##_##is_class) { \ test_arena_growth_policy(Metaspace::spacetype, is_class); \ } -DEFINE_GROWTH_POLICY_TEST(ReflectionMetaspaceType, true) -DEFINE_GROWTH_POLICY_TEST(ReflectionMetaspaceType, false) DEFINE_GROWTH_POLICY_TEST(ClassMirrorHolderMetaspaceType, true) DEFINE_GROWTH_POLICY_TEST(ClassMirrorHolderMetaspaceType, false) DEFINE_GROWTH_POLICY_TEST(StandardMetaspaceType, true) diff --git a/test/hotspot/gtest/metaspace/test_metaspacearena.cpp b/test/hotspot/gtest/metaspace/test_metaspacearena.cpp index aee53ea32aa..2e5a6d40ce7 100644 --- a/test/hotspot/gtest/metaspace/test_metaspacearena.cpp +++ b/test/hotspot/gtest/metaspace/test_metaspacearena.cpp @@ -218,7 +218,8 @@ class MetaspaceArenaTestHelper { static void test_basics(size_t commit_limit, bool is_micro) { MetaspaceGtestContext context(commit_limit); - MetaspaceArenaTestHelper helper(context, is_micro ? Metaspace::ReflectionMetaspaceType : Metaspace::StandardMetaspaceType, false); + const Metaspace::MetaspaceType type = is_micro ? Metaspace::ClassMirrorHolderMetaspaceType : Metaspace::StandardMetaspaceType; + MetaspaceArenaTestHelper helper(context, type, false); helper.allocate_from_arena_with_tests(1); helper.allocate_from_arena_with_tests(128); @@ -278,11 +279,11 @@ TEST_VM(metaspace, MetaspaceArena_test_enlarge_in_place_standard_nc) { } TEST_VM(metaspace, MetaspaceArena_test_enlarge_in_place_micro_c) { - test_chunk_enlargment_simple(Metaspace::ReflectionMetaspaceType, true); + test_chunk_enlargment_simple(Metaspace::ClassMirrorHolderMetaspaceType, true); } TEST_VM(metaspace, MetaspaceArena_test_enlarge_in_place_micro_nc) { - test_chunk_enlargment_simple(Metaspace::ReflectionMetaspaceType, false); + test_chunk_enlargment_simple(Metaspace::ClassMirrorHolderMetaspaceType, false); } // Test chunk enlargement: @@ -434,8 +435,8 @@ static void test_recover_from_commit_limit_hit() { // The first MetaspaceArena mimicks a micro loader. This will fill the free // chunk list with very small chunks. We allocate from them in an interleaved // way to cause fragmentation. - MetaspaceArenaTestHelper helper1(context, Metaspace::ReflectionMetaspaceType, false); - MetaspaceArenaTestHelper helper2(context, Metaspace::ReflectionMetaspaceType, false); + MetaspaceArenaTestHelper helper1(context, Metaspace::ClassMirrorHolderMetaspaceType, false); + MetaspaceArenaTestHelper helper2(context, Metaspace::ClassMirrorHolderMetaspaceType, false); // This MetaspaceArena should hit the limit. We use BootMetaspaceType here since // it gets a large initial chunk which is committed @@ -495,7 +496,9 @@ static void test_controlled_growth(Metaspace::MetaspaceType type, bool is_class, MetaspaceGtestContext context; MetaspaceArenaTestHelper smhelper(context, type, is_class, "Grower"); - MetaspaceArenaTestHelper smhelper_harrasser(context, Metaspace::ReflectionMetaspaceType, true, "Harasser"); + const Metaspace::MetaspaceType other_type = + (type == Metaspace::StandardMetaspaceType) ? Metaspace::ClassMirrorHolderMetaspaceType : Metaspace::StandardMetaspaceType; + MetaspaceArenaTestHelper smhelper_harrasser(context, other_type, true, "Harasser"); size_t used = 0, committed = 0, capacity = 0; const size_t alloc_words = 16; @@ -617,16 +620,6 @@ static void test_controlled_growth(Metaspace::MetaspaceType type, bool is_class, } // these numbers have to be in sync with arena policy numbers (see memory/metaspace/arenaGrowthPolicy.cpp) -TEST_VM(metaspace, MetaspaceArena_growth_refl_c_inplace) { - test_controlled_growth(Metaspace::ReflectionMetaspaceType, true, - word_size_for_level(CHUNK_LEVEL_1K), true); -} - -TEST_VM(metaspace, MetaspaceArena_growth_refl_c_not_inplace) { - test_controlled_growth(Metaspace::ReflectionMetaspaceType, true, - word_size_for_level(CHUNK_LEVEL_1K), false); -} - TEST_VM(metaspace, MetaspaceArena_growth_anon_c_inplace) { test_controlled_growth(Metaspace::ClassMirrorHolderMetaspaceType, true, word_size_for_level(CHUNK_LEVEL_1K), true); @@ -660,16 +653,6 @@ TEST_VM(metaspace, MetaspaceArena_growth_boot_c_not_inplace) { } */ -TEST_VM(metaspace, MetaspaceArena_growth_refl_nc_inplace) { - test_controlled_growth(Metaspace::ReflectionMetaspaceType, false, - word_size_for_level(CHUNK_LEVEL_2K), true); -} - -TEST_VM(metaspace, MetaspaceArena_growth_refl_nc_not_inplace) { - test_controlled_growth(Metaspace::ReflectionMetaspaceType, false, - word_size_for_level(CHUNK_LEVEL_2K), false); -} - TEST_VM(metaspace, MetaspaceArena_growth_anon_nc_inplace) { test_controlled_growth(Metaspace::ClassMirrorHolderMetaspaceType, false, word_size_for_level(CHUNK_LEVEL_1K), true); diff --git a/test/hotspot/gtest/metaspace/test_metaspacearena_stress.cpp b/test/hotspot/gtest/metaspace/test_metaspacearena_stress.cpp index e94f733e45b..bb536dfd0e2 100644 --- a/test/hotspot/gtest/metaspace/test_metaspacearena_stress.cpp +++ b/test/hotspot/gtest/metaspace/test_metaspacearena_stress.cpp @@ -227,7 +227,7 @@ class MetaspaceArenaTest { void create_random_test_bed_at(int slotindex) { SizeRange allocation_range(1, 100); // randomize too? const ArenaGrowthPolicy* growth_policy = ArenaGrowthPolicy::policy_for_space_type( - (fifty_fifty() ? Metaspace::StandardMetaspaceType : Metaspace::ReflectionMetaspaceType), + (fifty_fifty() ? Metaspace::StandardMetaspaceType : Metaspace::ClassMirrorHolderMetaspaceType), fifty_fifty()); create_new_test_bed_at(slotindex, growth_policy, allocation_range); } diff --git a/test/hotspot/jtreg/ProblemList-generational-zgc.txt b/test/hotspot/jtreg/ProblemList-generational-zgc.txt deleted file mode 100644 index 801328ec4ae..00000000000 --- a/test/hotspot/jtreg/ProblemList-generational-zgc.txt +++ /dev/null @@ -1,118 +0,0 @@ -# -# Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -############################################################################# -# -# List of quarantined tests for testing with Generational ZGC. -# -############################################################################# - -# Quiet all SA tests - -resourcehogs/serviceability/sa/TestHeapDumpForLargeArray.java 8307393 generic-all -serviceability/sa/CDSJMapClstats.java 8307393 generic-all -serviceability/sa/ClhsdbAttach.java 8307393 generic-all -serviceability/sa/ClhsdbAttachDifferentJVMs.java 8307393 generic-all -serviceability/sa/ClhsdbCDSCore.java 8307393 generic-all -serviceability/sa/ClhsdbCDSJstackPrintAll.java 8307393 generic-all -serviceability/sa/ClhsdbClasses.java 8307393 generic-all -serviceability/sa/ClhsdbDumpclass.java 8307393 generic-all -serviceability/sa/ClhsdbDumpheap.java 8307393 generic-all -serviceability/sa/ClhsdbField.java 8307393 generic-all -serviceability/sa/ClhsdbFindPC.java#apa 8307393 generic-all -serviceability/sa/ClhsdbFindPC.java#no-xcomp-core 8307393 generic-all -serviceability/sa/ClhsdbFindPC.java#no-xcomp-process 8307393 generic-all -serviceability/sa/ClhsdbFindPC.java#xcomp-core 8307393 generic-all -serviceability/sa/ClhsdbFindPC.java#xcomp-process 8307393 generic-all -serviceability/sa/ClhsdbFlags.java 8307393 generic-all -serviceability/sa/ClhsdbHistory.java 8307393 generic-all -serviceability/sa/ClhsdbInspect.java 8307393 generic-all -serviceability/sa/ClhsdbJdis.java 8307393 generic-all -serviceability/sa/ClhsdbJhisto.java 8307393 generic-all -serviceability/sa/ClhsdbJstack.java#id0 8307393 generic-all -serviceability/sa/ClhsdbJstack.java#id1 8307393 generic-all -serviceability/sa/ClhsdbJstackWithConcurrentLock.java 8307393 generic-all -serviceability/sa/ClhsdbJstackXcompStress.java 8307393 generic-all -serviceability/sa/ClhsdbLauncher.java 8307393 generic-all -serviceability/sa/ClhsdbLongConstant.java 8307393 generic-all -serviceability/sa/ClhsdbPmap.java 8307393 generic-all -serviceability/sa/ClhsdbPmap.java#core 8307393 generic-all -serviceability/sa/ClhsdbPmap.java#process 8307393 generic-all -serviceability/sa/ClhsdbPrintAll.java 8307393 generic-all -serviceability/sa/ClhsdbPrintAs.java 8307393 generic-all -serviceability/sa/ClhsdbPrintStatics.java 8307393 generic-all -serviceability/sa/ClhsdbPstack.java#core 8307393 generic-all -serviceability/sa/ClhsdbPstack.java#process 8307393 generic-all -serviceability/sa/ClhsdbScanOops.java 8307393 generic-all -serviceability/sa/ClhsdbSource.java 8307393 generic-all -serviceability/sa/ClhsdbSymbol.java 8307393 generic-all -serviceability/sa/ClhsdbThread.java 8307393 generic-all -serviceability/sa/ClhsdbThreadContext.java 8307393 generic-all -serviceability/sa/ClhsdbVmStructsDump.java 8307393 generic-all -serviceability/sa/ClhsdbWhere.java 8307393 generic-all -serviceability/sa/DeadlockDetectionTest.java 8307393 generic-all -serviceability/sa/JhsdbThreadInfoTest.java 8307393 generic-all -serviceability/sa/LingeredAppSysProps.java 8307393 generic-all -serviceability/sa/LingeredAppWithDefaultMethods.java 8307393 generic-all -serviceability/sa/LingeredAppWithEnum.java 8307393 generic-all -serviceability/sa/LingeredAppWithInterface.java 8307393 generic-all -serviceability/sa/LingeredAppWithInvokeDynamic.java 8307393 generic-all -serviceability/sa/LingeredAppWithLock.java 8307393 generic-all -serviceability/sa/LingeredAppWithNativeMethod.java 8307393 generic-all -serviceability/sa/LingeredAppWithRecComputation.java 8307393 generic-all -serviceability/sa/TestClassDump.java 8307393 generic-all -serviceability/sa/TestClhsdbJstackLock.java 8307393 generic-all -serviceability/sa/TestCpoolForInvokeDynamic.java 8307393 generic-all -serviceability/sa/TestDefaultMethods.java 8307393 generic-all -serviceability/sa/TestG1HeapRegion.java 8307393 generic-all -serviceability/sa/TestHeapDumpForInvokeDynamic.java 8307393 generic-all -serviceability/sa/TestInstanceKlassSize.java 8307393 generic-all -serviceability/sa/TestInstanceKlassSizeForInterface.java 8307393 generic-all -serviceability/sa/TestIntConstant.java 8307393 generic-all -serviceability/sa/TestJhsdbJstackLineNumbers.java 8307393 generic-all -serviceability/sa/TestJhsdbJstackLock.java 8307393 generic-all -serviceability/sa/TestJhsdbJstackMixed.java 8307393 generic-all -serviceability/sa/TestJhsdbJstackUpcall.java 8307393 generic-all -serviceability/sa/TestJmapCore.java 8307393 generic-all -serviceability/sa/TestJmapCoreMetaspace.java 8307393 generic-all -serviceability/sa/TestObjectAlignment.java 8307393 generic-all -serviceability/sa/TestObjectMonitorIterate.java 8307393 generic-all -serviceability/sa/TestPrintMdo.java 8307393 generic-all -serviceability/sa/TestRevPtrsForInvokeDynamic.java 8307393 generic-all -serviceability/sa/TestSysProps.java 8307393 generic-all -serviceability/sa/TestType.java 8307393 generic-all -serviceability/sa/TestUniverse.java 8307393 generic-all -serviceability/sa/UniqueVtableTest.java 8307393 generic-all -serviceability/sa/jmap-hprof/JMapHProfLargeHeapProc.java 8307393 generic-all -serviceability/sa/jmap-hprof/JMapHProfLargeHeapTest.java 8307393 generic-all -serviceability/sa/sadebugd/ClhsdbAttachToDebugServer.java 8307393 generic-all -serviceability/sa/sadebugd/ClhsdbTestConnectArgument.java 8307393 generic-all -serviceability/sa/ClhsdbTestAllocationMerge.java 8307393 generic-all -serviceability/sa/sadebugd/DebugdConnectTest.java 8307393 generic-all -serviceability/sa/sadebugd/DebugdUtils.java 8307393 generic-all -serviceability/sa/sadebugd/DisableRegistryTest.java 8307393 generic-all -serviceability/sa/sadebugd/PmapOnDebugdTest.java 8307393 generic-all -serviceability/sa/sadebugd/RunCommandOnServerTest.java 8307393 generic-all -serviceability/sa/sadebugd/SADebugDTest.java 8307393 generic-all - -vmTestbase/gc/gctests/MemoryEaterMT/MemoryEaterMT.java 8289582 windows-x64 diff --git a/test/hotspot/jtreg/ProblemList-zgc.txt b/test/hotspot/jtreg/ProblemList-zgc.txt index 1afe56c99f8..7b2978ba491 100644 --- a/test/hotspot/jtreg/ProblemList-zgc.txt +++ b/test/hotspot/jtreg/ProblemList-zgc.txt @@ -27,22 +27,92 @@ # ############################################################################# -resourcehogs/serviceability/sa/TestHeapDumpForLargeArray.java 8276539 generic-all -serviceability/sa/CDSJMapClstats.java 8276539 generic-all -serviceability/sa/ClhsdbJhisto.java 8276539 generic-all -serviceability/sa/ClhsdbJstackWithConcurrentLock.java 8276539 generic-all -serviceability/sa/jmap-hprof/JMapHProfLargeHeapTest.java 8276539 generic-all +# Quiet all SA tests -serviceability/sa/ClhsdbFindPC.java#xcomp-core 8284045 generic-all -serviceability/sa/TestJmapCore.java 8268283,8270202 generic-all -serviceability/sa/TestJmapCoreMetaspace.java 8268636 generic-all - -serviceability/sa/TestJhsdbJstackMixed.java 8248912 generic-all -serviceability/sa/ClhsdbPstack.java#process 8248912 generic-all -serviceability/sa/ClhsdbPstack.java#core 8248912 generic-all - -serviceability/sa/TestSysProps.java 8302055 generic-all - -serviceability/sa/TestHeapDumpForInvokeDynamic.java 8315646 generic-all +resourcehogs/serviceability/sa/TestHeapDumpForLargeArray.java 8307393 generic-all +serviceability/sa/CDSJMapClstats.java 8307393 generic-all +serviceability/sa/ClhsdbAttach.java 8307393 generic-all +serviceability/sa/ClhsdbAttachDifferentJVMs.java 8307393 generic-all +serviceability/sa/ClhsdbCDSCore.java 8307393 generic-all +serviceability/sa/ClhsdbCDSJstackPrintAll.java 8307393 generic-all +serviceability/sa/ClhsdbClasses.java 8307393 generic-all +serviceability/sa/ClhsdbDumpclass.java 8307393 generic-all +serviceability/sa/ClhsdbDumpheap.java 8307393 generic-all +serviceability/sa/ClhsdbField.java 8307393 generic-all +serviceability/sa/ClhsdbFindPC.java#apa 8307393 generic-all +serviceability/sa/ClhsdbFindPC.java#no-xcomp-core 8307393 generic-all +serviceability/sa/ClhsdbFindPC.java#no-xcomp-process 8307393 generic-all +serviceability/sa/ClhsdbFindPC.java#xcomp-core 8307393 generic-all +serviceability/sa/ClhsdbFindPC.java#xcomp-process 8307393 generic-all +serviceability/sa/ClhsdbFlags.java 8307393 generic-all +serviceability/sa/ClhsdbHistory.java 8307393 generic-all +serviceability/sa/ClhsdbInspect.java 8307393 generic-all +serviceability/sa/ClhsdbJdis.java 8307393 generic-all +serviceability/sa/ClhsdbJhisto.java 8307393 generic-all +serviceability/sa/ClhsdbJstack.java#id0 8307393 generic-all +serviceability/sa/ClhsdbJstack.java#id1 8307393 generic-all +serviceability/sa/ClhsdbJstackWithConcurrentLock.java 8307393 generic-all +serviceability/sa/ClhsdbJstackXcompStress.java 8307393 generic-all +serviceability/sa/ClhsdbLauncher.java 8307393 generic-all +serviceability/sa/ClhsdbLongConstant.java 8307393 generic-all +serviceability/sa/ClhsdbPmap.java 8307393 generic-all +serviceability/sa/ClhsdbPmap.java#core 8307393 generic-all +serviceability/sa/ClhsdbPmap.java#process 8307393 generic-all +serviceability/sa/ClhsdbPrintAll.java 8307393 generic-all +serviceability/sa/ClhsdbPrintAs.java 8307393 generic-all +serviceability/sa/ClhsdbPrintStatics.java 8307393 generic-all +serviceability/sa/ClhsdbPstack.java#core 8307393 generic-all +serviceability/sa/ClhsdbPstack.java#process 8307393 generic-all +serviceability/sa/ClhsdbScanOops.java 8307393 generic-all +serviceability/sa/ClhsdbSource.java 8307393 generic-all +serviceability/sa/ClhsdbSymbol.java 8307393 generic-all +serviceability/sa/ClhsdbThread.java 8307393 generic-all +serviceability/sa/ClhsdbThreadContext.java 8307393 generic-all +serviceability/sa/ClhsdbVmStructsDump.java 8307393 generic-all +serviceability/sa/ClhsdbWhere.java 8307393 generic-all +serviceability/sa/DeadlockDetectionTest.java 8307393 generic-all +serviceability/sa/JhsdbThreadInfoTest.java 8307393 generic-all +serviceability/sa/LingeredAppSysProps.java 8307393 generic-all +serviceability/sa/LingeredAppWithDefaultMethods.java 8307393 generic-all +serviceability/sa/LingeredAppWithEnum.java 8307393 generic-all +serviceability/sa/LingeredAppWithInterface.java 8307393 generic-all +serviceability/sa/LingeredAppWithInvokeDynamic.java 8307393 generic-all +serviceability/sa/LingeredAppWithLock.java 8307393 generic-all +serviceability/sa/LingeredAppWithNativeMethod.java 8307393 generic-all +serviceability/sa/LingeredAppWithRecComputation.java 8307393 generic-all +serviceability/sa/TestClassDump.java 8307393 generic-all +serviceability/sa/TestClhsdbJstackLock.java 8307393 generic-all +serviceability/sa/TestCpoolForInvokeDynamic.java 8307393 generic-all +serviceability/sa/TestDefaultMethods.java 8307393 generic-all +serviceability/sa/TestG1HeapRegion.java 8307393 generic-all +serviceability/sa/TestHeapDumpForInvokeDynamic.java 8307393 generic-all +serviceability/sa/TestInstanceKlassSize.java 8307393 generic-all +serviceability/sa/TestInstanceKlassSizeForInterface.java 8307393 generic-all +serviceability/sa/TestIntConstant.java 8307393 generic-all +serviceability/sa/TestJhsdbJstackLineNumbers.java 8307393 generic-all +serviceability/sa/TestJhsdbJstackLock.java 8307393 generic-all +serviceability/sa/TestJhsdbJstackMixed.java 8307393 generic-all +serviceability/sa/TestJhsdbJstackUpcall.java 8307393 generic-all +serviceability/sa/TestJmapCore.java 8307393 generic-all +serviceability/sa/TestJmapCoreMetaspace.java 8307393 generic-all +serviceability/sa/TestObjectAlignment.java 8307393 generic-all +serviceability/sa/TestObjectMonitorIterate.java 8307393 generic-all +serviceability/sa/TestPrintMdo.java 8307393 generic-all +serviceability/sa/TestRevPtrsForInvokeDynamic.java 8307393 generic-all +serviceability/sa/TestSysProps.java 8307393 generic-all +serviceability/sa/TestType.java 8307393 generic-all +serviceability/sa/TestUniverse.java 8307393 generic-all +serviceability/sa/UniqueVtableTest.java 8307393 generic-all +serviceability/sa/jmap-hprof/JMapHProfLargeHeapProc.java 8307393 generic-all +serviceability/sa/jmap-hprof/JMapHProfLargeHeapTest.java 8307393 generic-all +serviceability/sa/sadebugd/ClhsdbAttachToDebugServer.java 8307393 generic-all +serviceability/sa/sadebugd/ClhsdbTestConnectArgument.java 8307393 generic-all +serviceability/sa/ClhsdbTestAllocationMerge.java 8307393 generic-all +serviceability/sa/sadebugd/DebugdConnectTest.java 8307393 generic-all +serviceability/sa/sadebugd/DebugdUtils.java 8307393 generic-all +serviceability/sa/sadebugd/DisableRegistryTest.java 8307393 generic-all +serviceability/sa/sadebugd/PmapOnDebugdTest.java 8307393 generic-all +serviceability/sa/sadebugd/RunCommandOnServerTest.java 8307393 generic-all +serviceability/sa/sadebugd/SADebugDTest.java 8307393 generic-all vmTestbase/gc/gctests/MemoryEaterMT/MemoryEaterMT.java 8289582 windows-x64 diff --git a/test/hotspot/jtreg/ProblemList.txt b/test/hotspot/jtreg/ProblemList.txt index 3ff450dc3ad..ce9e97e1715 100644 --- a/test/hotspot/jtreg/ProblemList.txt +++ b/test/hotspot/jtreg/ProblemList.txt @@ -59,8 +59,7 @@ compiler/codecache/CheckLargePages.java 8332654 linux-x64 compiler/vectorapi/reshape/TestVectorReinterpret.java 8320897 aix-ppc64,linux-ppc64le compiler/vectorapi/VectorLogicalOpIdentityTest.java 8302459 linux-x64,windows-x64 -compiler/vectorapi/VectorRebracket128Test.java#ZSinglegen 8330538 generic-all -compiler/vectorapi/VectorRebracket128Test.java#ZGenerational 8330538 generic-all +compiler/vectorapi/VectorRebracket128Test.java#Z 8330538 generic-all compiler/jvmci/TestUncaughtErrorInCompileMethod.java 8309073 generic-all compiler/jvmci/jdk.vm.ci.code.test/src/jdk/vm/ci/code/test/DataPatchTest.java 8331704 linux-riscv64 @@ -94,8 +93,7 @@ gc/TestAlwaysPreTouchBehavior.java#ParallelCollector 8334513 generic-all gc/TestAlwaysPreTouchBehavior.java#SerialCollector 8334513 generic-all gc/TestAlwaysPreTouchBehavior.java#Shenandoah 8334513 generic-all gc/TestAlwaysPreTouchBehavior.java#G1 8334513 generic-all -gc/TestAlwaysPreTouchBehavior.java#ZGenerational 8334513 generic-all -gc/TestAlwaysPreTouchBehavior.java#ZSinglegen 8334513 generic-all +gc/TestAlwaysPreTouchBehavior.java#Z 8334513 generic-all gc/TestAlwaysPreTouchBehavior.java#Epsilon 8334513 generic-all gc/stress/gclocker/TestExcessGCLockerCollections.java 8229120 generic-all @@ -105,6 +103,7 @@ gc/stress/gclocker/TestExcessGCLockerCollections.java 8229120 generic-all runtime/jni/terminatedThread/TestTerminatedThread.java 8317789 aix-ppc64 runtime/handshake/HandshakeSuspendExitTest.java 8294313 generic-all +runtime/Monitor/SyncOnValueBasedClassTest.java 8340995 linux-s390x runtime/os/TestTracePageSizes.java#no-options 8267460 linux-aarch64 runtime/os/TestTracePageSizes.java#explicit-large-page-size 8267460 linux-aarch64 runtime/os/TestTracePageSizes.java#compiler-options 8267460 linux-aarch64 diff --git a/test/hotspot/jtreg/TEST.ROOT b/test/hotspot/jtreg/TEST.ROOT index 962fc36838c..21c5aebaa71 100644 --- a/test/hotspot/jtreg/TEST.ROOT +++ b/test/hotspot/jtreg/TEST.ROOT @@ -61,8 +61,6 @@ requires.properties= \ vm.gc.Shenandoah \ vm.gc.Epsilon \ vm.gc.Z \ - vm.gc.ZGenerational \ - vm.gc.ZSinglegen \ vm.jvmci \ vm.jvmci.enabled \ vm.emulatedClient \ diff --git a/test/hotspot/jtreg/compiler/arguments/TestManyParameters.java b/test/hotspot/jtreg/compiler/arguments/TestManyParameters.java new file mode 100644 index 00000000000..4828a0feabc --- /dev/null +++ b/test/hotspot/jtreg/compiler/arguments/TestManyParameters.java @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @requires os.simpleArch == "x64" + * @bug 8342156 + * @summary Check that C2's restriction on number of method arguments is not too + * restrictive on x64. + * + * @run main/othervm -Xcomp + * -XX:CompileCommand=compileonly,compiler.arguments.TestManyParameters::test + * -XX:+UnlockDiagnosticVMOptions + * -XX:+AbortVMOnCompilationFailure + * compiler.arguments.TestManyParameters + */ + +package compiler.arguments; + +public class TestManyParameters { + + public static void main(String[] args) { + test(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54); + } + + static void test(int i1, int i2, int i3, int i4, int i5, int i6, int i7, int i8, int i9, int i10, int i11, int i12, int i13, int i14, int i15, int i16, int i17, int i18, int i19, int i20, int i21, int i22, int i23, int i24, int i25, int i26, int i27, int i28, int i29, int i30, int i31, int i32, int i33, int i34, int i35, int i36, int i37, int i38, int i39, int i40, int i41, int i42, int i43, int i44, int i45, int i46, int i47, int i48, int i49, int i50, int i51, int i52, int i53, int i54) {} +} diff --git a/test/hotspot/jtreg/compiler/c2/irTests/TestVectorizationMismatchedAccess.java b/test/hotspot/jtreg/compiler/c2/irTests/TestVectorizationMismatchedAccess.java index 2fdbb0816ad..2d17753ba94 100644 --- a/test/hotspot/jtreg/compiler/c2/irTests/TestVectorizationMismatchedAccess.java +++ b/test/hotspot/jtreg/compiler/c2/irTests/TestVectorizationMismatchedAccess.java @@ -50,9 +50,6 @@ public class TestVectorizationMismatchedAccess { private final static WhiteBox wb = WhiteBox.getWhiteBox(); public static void main(String[] args) { - if (ByteOrder.nativeOrder() != ByteOrder.LITTLE_ENDIAN) { - throw new RuntimeException("fix test that was written for a little endian platform"); - } TestFramework.runWithFlags("--add-modules", "java.base", "--add-exports", "java.base/jdk.internal.misc=ALL-UNNAMED"); } @@ -77,6 +74,14 @@ public static void main(String[] args) { } } + // Method to adjust the value for the native byte order + static private long handleByteOrder(long value) { + if (ByteOrder.nativeOrder() != ByteOrder.LITTLE_ENDIAN) { + value = Long.reverseBytes(value); + } + return value; + } + static private void runAndVerify(Runnable test, int offset) { System.arraycopy(verifyLongArray, 0, longArray, 0, longArray.length); Arrays.fill(byteArray, (byte)0); @@ -154,7 +159,7 @@ static private void runAndVerify3(Runnable test, int offset) { // might get fixed with JDK-8325155. public static void testByteLong1a(byte[] dest, long[] src) { for (int i = 0; i < src.length; i++) { - UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * i, src[i]); + UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * i, handleByteOrder(src[i])); } } @@ -165,7 +170,7 @@ public static void testByteLong1a(byte[] dest, long[] src) { // 32-bit: address has ConvL2I for cast of long to address, not supported. public static void testByteLong1b(byte[] dest, long[] src) { for (int i = 0; i < src.length; i++) { - UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8L * i, src[i]); + UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8L * i, handleByteOrder(src[i])); } } @@ -175,7 +180,7 @@ public static void testByteLong1b(byte[] dest, long[] src) { public static void testByteLong1c(byte[] dest, long[] src) { long base = 64; // make sure it is big enough and 8 byte aligned (required for 32-bit) for (int i = 0; i < src.length - 8; i++) { - UNSAFE.putLongUnaligned(dest, base + 8 * i, src[i]); + UNSAFE.putLongUnaligned(dest, base + 8 * i, handleByteOrder(src[i])); } } @@ -187,7 +192,7 @@ public static void testByteLong1c(byte[] dest, long[] src) { public static void testByteLong1d(byte[] dest, long[] src) { long base = 64; // make sure it is big enough and 8 byte aligned (required for 32-bit) for (int i = 0; i < src.length - 8; i++) { - UNSAFE.putLongUnaligned(dest, base + 8L * i, src[i]); + UNSAFE.putLongUnaligned(dest, base + 8L * i, handleByteOrder(src[i])); } } @@ -207,7 +212,7 @@ public static void testByteLong1_runner() { // might get fixed with JDK-8325155. public static void testByteLong2a(byte[] dest, long[] src) { for (int i = 1; i < src.length; i++) { - UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * (i - 1), src[i]); + UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * (i - 1), handleByteOrder(src[i])); } } @@ -218,7 +223,7 @@ public static void testByteLong2a(byte[] dest, long[] src) { // 32-bit: address has ConvL2I for cast of long to address, not supported. public static void testByteLong2b(byte[] dest, long[] src) { for (int i = 1; i < src.length; i++) { - UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8L * (i - 1), src[i]); + UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8L * (i - 1), handleByteOrder(src[i])); } } @@ -236,7 +241,7 @@ public static void testByteLong2_runner() { // might get fixed with JDK-8325155. public static void testByteLong3a(byte[] dest, long[] src) { for (int i = 0; i < src.length - 1; i++) { - UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * (i + 1), src[i]); + UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * (i + 1), handleByteOrder(src[i])); } } @@ -247,7 +252,7 @@ public static void testByteLong3a(byte[] dest, long[] src) { // 32-bit: address has ConvL2I for cast of long to address, not supported. public static void testByteLong3b(byte[] dest, long[] src) { for (int i = 0; i < src.length - 1; i++) { - UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8L * (i + 1), src[i]); + UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8L * (i + 1), handleByteOrder(src[i])); } } @@ -267,7 +272,7 @@ public static void testByteLong3_runner() { // AlignVector cannot guarantee that invar is aligned. public static void testByteLong4a(byte[] dest, long[] src, int start, int stop) { for (int i = start; i < stop; i++) { - UNSAFE.putLongUnaligned(dest, 8 * i + baseOffset, src[i]); + UNSAFE.putLongUnaligned(dest, 8 * i + baseOffset, handleByteOrder(src[i])); } } @@ -280,7 +285,7 @@ public static void testByteLong4a(byte[] dest, long[] src, int start, int stop) // AlignVector cannot guarantee that invar is aligned. public static void testByteLong4b(byte[] dest, long[] src, int start, int stop) { for (int i = start; i < stop; i++) { - UNSAFE.putLongUnaligned(dest, 8L * i + baseOffset, src[i]); + UNSAFE.putLongUnaligned(dest, 8L * i + baseOffset, handleByteOrder(src[i])); } } @@ -299,7 +304,7 @@ public static void testByteLong4_runner() { // might get fixed with JDK-8325155. public static void testByteLong5a(byte[] dest, long[] src, int start, int stop) { for (int i = start; i < stop; i++) { - UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * (i + baseOffset), src[i]); + UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8 * (i + baseOffset), handleByteOrder(src[i])); } } @@ -310,7 +315,7 @@ public static void testByteLong5a(byte[] dest, long[] src, int start, int stop) // 32-bit: address has ConvL2I for cast of long to address, not supported. public static void testByteLong5b(byte[] dest, long[] src, int start, int stop) { for (int i = start; i < stop; i++) { - UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8L * (i + baseOffset), src[i]); + UNSAFE.putLongUnaligned(dest, UNSAFE.ARRAY_BYTE_BASE_OFFSET + 8L * (i + baseOffset), handleByteOrder(src[i])); } } @@ -454,7 +459,7 @@ public static void testByteByte5_runner() { // See: JDK-8331576 public static void testOffHeapLong1a(long dest, long[] src) { for (int i = 0; i < src.length; i++) { - UNSAFE.putLongUnaligned(null, dest + 8 * i, src[i]); + UNSAFE.putLongUnaligned(null, dest + 8 * i, handleByteOrder(src[i])); } } @@ -465,7 +470,7 @@ public static void testOffHeapLong1a(long dest, long[] src) { // See: JDK-8331576 public static void testOffHeapLong1b(long dest, long[] src) { for (int i = 0; i < src.length; i++) { - UNSAFE.putLongUnaligned(null, dest + 8L * i, src[i]); + UNSAFE.putLongUnaligned(null, dest + 8L * i, handleByteOrder(src[i])); } } @@ -482,7 +487,7 @@ public static void testOffHeapLong1_runner() { // See: JDK-8331576 public static void testOffHeapLong2a(long dest, long[] src) { for (int i = 1; i < src.length; i++) { - UNSAFE.putLongUnaligned(null, dest + 8 * (i - 1), src[i]); + UNSAFE.putLongUnaligned(null, dest + 8 * (i - 1), handleByteOrder(src[i])); } } @@ -493,7 +498,7 @@ public static void testOffHeapLong2a(long dest, long[] src) { // See: JDK-8331576 public static void testOffHeapLong2b(long dest, long[] src) { for (int i = 1; i < src.length; i++) { - UNSAFE.putLongUnaligned(null, dest + 8L * (i - 1), src[i]); + UNSAFE.putLongUnaligned(null, dest + 8L * (i - 1), handleByteOrder(src[i])); } } @@ -510,7 +515,7 @@ public static void testOffHeapLong2_runner() { // See: JDK-8331576 public static void testOffHeapLong3a(long dest, long[] src) { for (int i = 0; i < src.length - 1; i++) { - UNSAFE.putLongUnaligned(null, dest + 8 * (i + 1), src[i]); + UNSAFE.putLongUnaligned(null, dest + 8 * (i + 1), handleByteOrder(src[i])); } } @@ -521,7 +526,7 @@ public static void testOffHeapLong3a(long dest, long[] src) { // See: JDK-8331576 public static void testOffHeapLong3b(long dest, long[] src) { for (int i = 0; i < src.length - 1; i++) { - UNSAFE.putLongUnaligned(null, dest + 8L * (i + 1), src[i]); + UNSAFE.putLongUnaligned(null, dest + 8L * (i + 1), handleByteOrder(src[i])); } } @@ -540,7 +545,7 @@ public static void testOffHeapLong3_runner() { // AlignVector cannot guarantee that invar is aligned. public static void testOffHeapLong4a(long dest, long[] src, int start, int stop) { for (int i = start; i < stop; i++) { - UNSAFE.putLongUnaligned(null, dest + 8 * i + baseOffset, src[i]); + UNSAFE.putLongUnaligned(null, dest + 8 * i + baseOffset, handleByteOrder(src[i])); } } @@ -553,7 +558,7 @@ public static void testOffHeapLong4a(long dest, long[] src, int start, int stop) // AlignVector cannot guarantee that invar is aligned. public static void testOffHeapLong4b(long dest, long[] src, int start, int stop) { for (int i = start; i < stop; i++) { - UNSAFE.putLongUnaligned(null, dest + 8L * i + baseOffset, src[i]); + UNSAFE.putLongUnaligned(null, dest + 8L * i + baseOffset, handleByteOrder(src[i])); } } diff --git a/test/hotspot/jtreg/compiler/escapeAnalysis/TestReduceAllocationAndJVMStates.java b/test/hotspot/jtreg/compiler/escapeAnalysis/TestReduceAllocationAndJVMStates.java new file mode 100644 index 00000000000..3b0513003ae --- /dev/null +++ b/test/hotspot/jtreg/compiler/escapeAnalysis/TestReduceAllocationAndJVMStates.java @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8335977 + * @summary Check that Reduce Allocation Merges doesn't crash when there + * is an uncommon_trap with a chain of JVMS and, the reduced phi + * input(s) are local(s) in an old JVMS but not in a younger JVMS. + * I.e., check that we don't lose track of "_is_root" when traversing + * a JVMS chain. + * @run main/othervm -Xbatch + * -XX:CompileOnly=compiler.escapeAnalysis.TestReduceAllocationAndJVMStates::test* + * compiler.escapeAnalysis.TestReduceAllocationAndJVMStates + * @run main compiler.escapeAnalysis.TestReduceAllocationAndJVMStates + */ +package compiler.escapeAnalysis; + +public class TestReduceAllocationAndJVMStates { + static boolean bFld; + static int iFld; + + public static void main(String[] args) { + bFld = false; + + for (int i = 0; i < 10000; i++) { + test(i % 2 == 0); + } + bFld = true; + + // This will trigger a deoptimization which + // will make the issue manifest to the user + test(true); + } + + static int test(boolean flag) { + Super a = new A(); + Super b = new B(); + Super s = (flag ? a : b); + + // This needs to be inlined by C2 + check(); + + return a.i + b.i + s.i; + } + + // This shouldn't be manually inlined + static void check() { + if (bFld) { + iFld = 34; + } + } +} + +class Super { + int i; +} +class A extends Super {} +class B extends Super {} diff --git a/test/hotspot/jtreg/compiler/gcbarriers/TestArrayCopyWithLargeObjectAlignment.java b/test/hotspot/jtreg/compiler/gcbarriers/TestArrayCopyWithLargeObjectAlignment.java index dd2d485fb76..494c571450d 100644 --- a/test/hotspot/jtreg/compiler/gcbarriers/TestArrayCopyWithLargeObjectAlignment.java +++ b/test/hotspot/jtreg/compiler/gcbarriers/TestArrayCopyWithLargeObjectAlignment.java @@ -30,11 +30,11 @@ * @summary Test that, when using a larger object alignment, ZGC arraycopy * barriers are only applied to actual OOPs, and not to object * alignment padding words. - * @requires vm.gc.ZGenerational + * @requires vm.gc.Z * @run main/othervm -Xbatch -XX:-TieredCompilation * -XX:CompileOnly=compiler.gcbarriers.TestArrayCopyWithLargeObjectAlignment::* * -XX:ObjectAlignmentInBytes=16 - * -XX:+UseZGC -XX:+ZGenerational + * -XX:+UseZGC * compiler.gcbarriers.TestArrayCopyWithLargeObjectAlignment */ diff --git a/test/hotspot/jtreg/compiler/gcbarriers/TestZGCBarrierElision.java b/test/hotspot/jtreg/compiler/gcbarriers/TestZGCBarrierElision.java index af047dd5457..6f39ba7a8a1 100644 --- a/test/hotspot/jtreg/compiler/gcbarriers/TestZGCBarrierElision.java +++ b/test/hotspot/jtreg/compiler/gcbarriers/TestZGCBarrierElision.java @@ -34,7 +34,7 @@ * necessary barriers. The tests use volatile memory accesses and * blackholes to prevent C2 from simply optimizing them away. * @library /test/lib / - * @requires vm.gc.ZGenerational + * @requires vm.gc.Z * @run driver compiler.gcbarriers.TestZGCBarrierElision test-correctness */ @@ -43,7 +43,7 @@ * @summary Test that the ZGC barrier elision optimization elides unnecessary * barriers following simple allocation and domination rules. * @library /test/lib / - * @requires vm.gc.ZGenerational & (vm.simpleArch == "x64" | vm.simpleArch == "aarch64") + * @requires vm.gc.Z & (vm.simpleArch == "x64" | vm.simpleArch == "aarch64") * @run driver compiler.gcbarriers.TestZGCBarrierElision test-effectiveness */ @@ -99,7 +99,7 @@ public static void main(String[] args) { } String commonName = Common.class.getName(); TestFramework test = new TestFramework(testClass); - test.addFlags("-XX:+UseZGC", "-XX:+ZGenerational", "-XX:+UnlockExperimentalVMOptions", + test.addFlags("-XX:+UseZGC", "-XX:+UnlockExperimentalVMOptions", "-XX:CompileCommand=blackhole," + commonName + "::blackhole", "-XX:CompileCommand=dontinline," + commonName + "::nonInlinedMethod", "-XX:LoopMaxUnroll=0"); diff --git a/test/hotspot/jtreg/compiler/gcbarriers/TestZGCUnrolling.java b/test/hotspot/jtreg/compiler/gcbarriers/TestZGCUnrolling.java index 618b03e4cfb..0c30531285e 100644 --- a/test/hotspot/jtreg/compiler/gcbarriers/TestZGCUnrolling.java +++ b/test/hotspot/jtreg/compiler/gcbarriers/TestZGCUnrolling.java @@ -34,7 +34,7 @@ * The tests use volatile memory accesses to prevent C2 from simply * optimizing them away. * @library /test/lib / - * @requires vm.gc.ZGenerational + * @requires vm.gc.Z * @run driver compiler.gcbarriers.TestZGCUnrolling */ @@ -55,8 +55,7 @@ static class Outer { } public static void main(String[] args) { - TestFramework.runWithFlags("-XX:+UseZGC", "-XX:+ZGenerational", - "-XX:LoopUnrollLimit=24"); + TestFramework.runWithFlags("-XX:+UseZGC", "-XX:LoopUnrollLimit=24"); } @Test diff --git a/test/hotspot/jtreg/compiler/gcbarriers/UnsafeIntrinsicsTest.java b/test/hotspot/jtreg/compiler/gcbarriers/UnsafeIntrinsicsTest.java index 6a511fd60d9..65901f5e656 100644 --- a/test/hotspot/jtreg/compiler/gcbarriers/UnsafeIntrinsicsTest.java +++ b/test/hotspot/jtreg/compiler/gcbarriers/UnsafeIntrinsicsTest.java @@ -22,14 +22,14 @@ */ /* - * @test id=ZSinglegenDebug + * @test id=ZDebug * @key randomness * @bug 8059022 8271855 * @modules java.base/jdk.internal.misc:+open * @summary Validate barriers after Unsafe getReference, CAS and swap (GetAndSet) - * @requires vm.gc.ZSinglegen & vm.debug + * @requires vm.gc.Z & vm.debug * @library /test/lib - * @run main/othervm -XX:+UseZGC -XX:-ZGenerational + * @run main/othervm -XX:+UseZGC * -XX:+UnlockDiagnosticVMOptions * -XX:+ZVerifyOops -XX:ZCollectionInterval=1 * -XX:-CreateCoredumpOnCrash @@ -38,46 +38,14 @@ */ /* - * @test id=ZSinglegen + * @test id=Z * @key randomness * @bug 8059022 8271855 * @modules java.base/jdk.internal.misc:+open * @summary Validate barriers after Unsafe getReference, CAS and swap (GetAndSet) - * @requires vm.gc.ZSinglegen & !vm.debug + * @requires vm.gc.Z & !vm.debug * @library /test/lib - * @run main/othervm -XX:+UseZGC -XX:-ZGenerational - * -XX:+UnlockDiagnosticVMOptions - * -XX:ZCollectionInterval=1 - * -XX:-CreateCoredumpOnCrash - * -XX:CompileCommand=dontinline,*::mergeImpl* - * compiler.gcbarriers.UnsafeIntrinsicsTest - */ - -/* - * @test id=ZGenerationalDebug - * @key randomness - * @bug 8059022 8271855 - * @modules java.base/jdk.internal.misc:+open - * @summary Validate barriers after Unsafe getReference, CAS and swap (GetAndSet) - * @requires vm.gc.ZGenerational & vm.debug - * @library /test/lib - * @run main/othervm -XX:+UseZGC -XX:+ZGenerational - * -XX:+UnlockDiagnosticVMOptions - * -XX:+ZVerifyOops -XX:ZCollectionInterval=1 - * -XX:-CreateCoredumpOnCrash - * -XX:CompileCommand=dontinline,*::mergeImpl* - * compiler.gcbarriers.UnsafeIntrinsicsTest - */ - -/* - * @test id=ZGenerational - * @key randomness - * @bug 8059022 8271855 - * @modules java.base/jdk.internal.misc:+open - * @summary Validate barriers after Unsafe getReference, CAS and swap (GetAndSet) - * @requires vm.gc.ZGenerational & !vm.debug - * @library /test/lib - * @run main/othervm -XX:+UseZGC -XX:+ZGenerational + * @run main/othervm -XX:+UseZGC * -XX:+UnlockDiagnosticVMOptions * -XX:ZCollectionInterval=1 * -XX:-CreateCoredumpOnCrash diff --git a/test/hotspot/jtreg/compiler/loopopts/TestRangeCheckPredicatesControl.java b/test/hotspot/jtreg/compiler/loopopts/TestRangeCheckPredicatesControl.java index a46de67de05..1f64ed28d8a 100644 --- a/test/hotspot/jtreg/compiler/loopopts/TestRangeCheckPredicatesControl.java +++ b/test/hotspot/jtreg/compiler/loopopts/TestRangeCheckPredicatesControl.java @@ -22,25 +22,14 @@ */ /* - * @test id=ZSinglegen + * @test id=Z * @key stress randomness - * @requires vm.gc.ZSinglegen + * @requires vm.gc.Z * @bug 8237859 * @summary A LoadP node has a wrong control input (too early) which results in an out-of-bounds read of an object array with ZGC. * - * @run main/othervm -XX:+UseZGC -XX:-ZGenerational compiler.loopopts.TestRangeCheckPredicatesControl - * @run main/othervm -XX:+UseZGC -XX:-ZGenerational -XX:+UnlockDiagnosticVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+StressGCM compiler.loopopts.TestRangeCheckPredicatesControl - */ - -/* - * @test id=ZGenerational - * @key stress randomness - * @requires vm.gc.ZGenerational - * @bug 8237859 - * @summary A LoadP node has a wrong control input (too early) which results in an out-of-bounds read of an object array with ZGC. - * - * @run main/othervm -XX:+UseZGC -XX:+ZGenerational compiler.loopopts.TestRangeCheckPredicatesControl - * @run main/othervm -XX:+UseZGC -XX:+ZGenerational -XX:+UnlockDiagnosticVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+StressGCM compiler.loopopts.TestRangeCheckPredicatesControl + * @run main/othervm -XX:+UseZGC compiler.loopopts.TestRangeCheckPredicatesControl + * @run main/othervm -XX:+UseZGC -XX:+UnlockDiagnosticVMOptions -XX:+IgnoreUnrecognizedVMOptions -XX:+StressGCM compiler.loopopts.TestRangeCheckPredicatesControl */ package compiler.loopopts; diff --git a/test/hotspot/jtreg/compiler/loopstripmining/TestNoWarningLoopStripMiningIterSet.java b/test/hotspot/jtreg/compiler/loopstripmining/TestNoWarningLoopStripMiningIterSet.java index c356e4495c2..c7fedf8982e 100644 --- a/test/hotspot/jtreg/compiler/loopstripmining/TestNoWarningLoopStripMiningIterSet.java +++ b/test/hotspot/jtreg/compiler/loopstripmining/TestNoWarningLoopStripMiningIterSet.java @@ -44,25 +44,14 @@ */ /* - * @test id=ZSinglegen + * @test id=Z * @bug 8241486 * @summary G1/Z give warning when using LoopStripMiningIter and turn off LoopStripMiningIter (0) * @requires vm.flagless * @requires vm.flavor == "server" & !vm.graal.enabled - * @requires vm.gc.ZSinglegen + * @requires vm.gc.Z * @library /test/lib - * @run driver TestNoWarningLoopStripMiningIterSet Z -XX:-ZGenerational - */ - -/* - * @test id=ZGenerational - * @bug 8241486 - * @summary G1/Z give warning when using LoopStripMiningIter and turn off LoopStripMiningIter (0) - * @requires vm.flagless - * @requires vm.flavor == "server" & !vm.graal.enabled - * @requires vm.gc.ZGenerational - * @library /test/lib - * @run driver TestNoWarningLoopStripMiningIterSet Z -XX:+ZGenerational + * @run driver TestNoWarningLoopStripMiningIterSet Z */ /* @@ -106,18 +95,9 @@ public static void testWith(Consumer check, String msg, boolean public static void main(String[] args) throws Exception { String gc = "-XX:+Use" + args[0] + "GC"; - if (args.length > 1) { - String extraVMArg = args[1]; - testWith(output -> output.shouldNotContain(CLSOffLSMGreaterZero), "should have CLS and LSM enabled", true, 100, "-XX:LoopStripMiningIter=100", gc, extraVMArg); - testWith(output -> output.shouldContain(CLSOffLSMGreaterZero), "should have CLS and LSM disabled", false, 0, "-XX:-UseCountedLoopSafepoints", "-XX:LoopStripMiningIter=100", gc, extraVMArg); - testWith(output -> output.shouldContain(CLSOnLSMEqualZero), "should have CLS and LSM enabled", true, 1, "-XX:LoopStripMiningIter=0", gc, extraVMArg); - testWith(output -> output.shouldNotContain(CLSOnLSMEqualZero), "should have CLS and LSM disabled", false, 0, "-XX:-UseCountedLoopSafepoints", "-XX:LoopStripMiningIter=0", gc, extraVMArg); - } else { - testWith(output -> output.shouldNotContain(CLSOffLSMGreaterZero), "should have CLS and LSM enabled", true, 100, "-XX:LoopStripMiningIter=100", gc); - testWith(output -> output.shouldContain(CLSOffLSMGreaterZero), "should have CLS and LSM disabled", false, 0, "-XX:-UseCountedLoopSafepoints", "-XX:LoopStripMiningIter=100", gc); - testWith(output -> output.shouldContain(CLSOnLSMEqualZero), "should have CLS and LSM enabled", true, 1, "-XX:LoopStripMiningIter=0", gc); - testWith(output -> output.shouldNotContain(CLSOnLSMEqualZero), "should have CLS and LSM disabled", false, 0, "-XX:-UseCountedLoopSafepoints", "-XX:LoopStripMiningIter=0", gc); - - } + testWith(output -> output.shouldNotContain(CLSOffLSMGreaterZero), "should have CLS and LSM enabled", true, 100, "-XX:LoopStripMiningIter=100", gc); + testWith(output -> output.shouldContain(CLSOffLSMGreaterZero), "should have CLS and LSM disabled", false, 0, "-XX:-UseCountedLoopSafepoints", "-XX:LoopStripMiningIter=100", gc); + testWith(output -> output.shouldContain(CLSOnLSMEqualZero), "should have CLS and LSM enabled", true, 1, "-XX:LoopStripMiningIter=0", gc); + testWith(output -> output.shouldNotContain(CLSOnLSMEqualZero), "should have CLS and LSM disabled", false, 0, "-XX:-UseCountedLoopSafepoints", "-XX:LoopStripMiningIter=0", gc); } } diff --git a/test/hotspot/jtreg/compiler/predicates/TestAssertionPredicateDoesntConstantFold.java b/test/hotspot/jtreg/compiler/predicates/assertion/TestAssertionPredicateDoesntConstantFold.java similarity index 100% rename from test/hotspot/jtreg/compiler/predicates/TestAssertionPredicateDoesntConstantFold.java rename to test/hotspot/jtreg/compiler/predicates/assertion/TestAssertionPredicateDoesntConstantFold.java diff --git a/test/hotspot/jtreg/gc/z/TestDefault.java b/test/hotspot/jtreg/compiler/predicates/assertion/TestMissingSetCtrlForTrueConstant.java similarity index 51% rename from test/hotspot/jtreg/gc/z/TestDefault.java rename to test/hotspot/jtreg/compiler/predicates/assertion/TestMissingSetCtrlForTrueConstant.java index 1f1b7d49408..565069ac75c 100644 --- a/test/hotspot/jtreg/gc/z/TestDefault.java +++ b/test/hotspot/jtreg/compiler/predicates/assertion/TestMissingSetCtrlForTrueConstant.java @@ -19,33 +19,40 @@ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. + * */ -package gc.z; - /* - * @test TestDefault - * @requires vm.gc.ZGenerational - * @summary Test that ZGC Generational Mode is Default - * @library /test/lib - * @run driver gc.z.TestDefault + * @test + * @bug 8343137 + * @requires vm.debug == true & vm.compiler2.enabled + * @summary Test that set_ctrl() is properly set for true constant when folding useless Template Assertion Predicate. + * @run main/othervm -Xcomp -XX:+VerifyLoopOptimizations + * -XX:CompileCommand=compileonly,compiler.predicates.assertion.TestMissingSetCtrlForTrueConstant::test + * compiler.predicates.assertion.TestMissingSetCtrlForTrueConstant */ -import java.util.LinkedList; -import jdk.test.lib.process.ProcessTools; +package compiler.predicates.assertion; -public class TestDefault { - static class Test { - public static void main(String[] args) throws Exception {} +public class TestMissingSetCtrlForTrueConstant { + static long iFld; + static int[] iArrFld = new int[100]; + static double[] dArrFld = new double[100]; + + public static void main(String[] strArr) { + test(); } - public static void main(String[] args) throws Exception { - ProcessTools.executeLimitedTestJava("-XX:+UseZGC", - "-Xlog:gc+init", - Test.class.getName()) - .shouldNotContain("Option ZGenerational was deprecated") - .shouldNotContain("Using deprecated non-generational mode") - .shouldContain("GC Workers for Old Generation") - .shouldContain("GC Workers for Young Generation") - .shouldHaveExitValue(0); + + static void test() { + long l = 34; + for (int i = 78; i > 8; --i) { + switch (i) { + case 24: + l += iFld - 34; + case 25: + iFld = iArrFld[i] += i; + } + dArrFld[i + 1] += i; + } } } diff --git a/test/hotspot/jtreg/compiler/predicates/TestTemplateAssertionPredicateNotRemoved.java b/test/hotspot/jtreg/compiler/predicates/assertion/TestTemplateAssertionPredicateNotRemoved.java similarity index 88% rename from test/hotspot/jtreg/compiler/predicates/TestTemplateAssertionPredicateNotRemoved.java rename to test/hotspot/jtreg/compiler/predicates/assertion/TestTemplateAssertionPredicateNotRemoved.java index 557d9d461bf..6d8588213b5 100644 --- a/test/hotspot/jtreg/compiler/predicates/TestTemplateAssertionPredicateNotRemoved.java +++ b/test/hotspot/jtreg/compiler/predicates/assertion/TestTemplateAssertionPredicateNotRemoved.java @@ -29,14 +29,14 @@ * completely with JDK-8288981 and 8314116 just mitigates the problem. * @requires vm.compiler2.enabled * @run main/othervm -Xbatch -XX:-TieredCompilation - * -XX:CompileCommand=compileonly,compiler.predicates.TestTemplateAssertionPredicateNotRemoved::* - * compiler.predicates.TestTemplateAssertionPredicateNotRemoved + * -XX:CompileCommand=compileonly,compiler.predicates.assertion.TestTemplateAssertionPredicateNotRemoved::* + * compiler.predicates.assertion.TestTemplateAssertionPredicateNotRemoved * @run main/othervm -Xbatch -XX:-TieredCompilation -XX:LoopMaxUnroll=0 - * -XX:CompileCommand=compileonly,compiler.predicates.TestTemplateAssertionPredicateNotRemoved::* - * compiler.predicates.TestTemplateAssertionPredicateNotRemoved + * -XX:CompileCommand=compileonly,compiler.predicates.assertion.TestTemplateAssertionPredicateNotRemoved::* + * compiler.predicates.assertion.TestTemplateAssertionPredicateNotRemoved */ -package compiler.predicates; +package compiler.predicates.assertion; public class TestTemplateAssertionPredicateNotRemoved { static int[] iArrFld = new int[10]; diff --git a/test/hotspot/jtreg/compiler/predicates/TestTemplateAssertionPredicateWithTwoUCTs.java b/test/hotspot/jtreg/compiler/predicates/assertion/TestTemplateAssertionPredicateWithTwoUCTs.java similarity index 90% rename from test/hotspot/jtreg/compiler/predicates/TestTemplateAssertionPredicateWithTwoUCTs.java rename to test/hotspot/jtreg/compiler/predicates/assertion/TestTemplateAssertionPredicateWithTwoUCTs.java index aadaf75869f..7d21f6b5f2d 100644 --- a/test/hotspot/jtreg/compiler/predicates/TestTemplateAssertionPredicateWithTwoUCTs.java +++ b/test/hotspot/jtreg/compiler/predicates/assertion/TestTemplateAssertionPredicateWithTwoUCTs.java @@ -27,11 +27,11 @@ * @bug 8342287 * @summary Test that a fail path projection of a Template Assertion Predicate is not treated as success path projection. * @run main/othervm -XX:-TieredCompilation -Xbatch - * -XX:CompileCommand=compileonly,compiler.predicates.TestTemplateAssertionPredicateWithTwoUCTs::test - * compiler.predicates.TestTemplateAssertionPredicateWithTwoUCTs + * -XX:CompileCommand=compileonly,compiler.predicates.assertion.TestTemplateAssertionPredicateWithTwoUCTs::test + * compiler.predicates.assertion.TestTemplateAssertionPredicateWithTwoUCTs */ -package compiler.predicates; +package compiler.predicates.assertion; public class TestTemplateAssertionPredicateWithTwoUCTs { static int iFld; diff --git a/test/hotspot/jtreg/compiler/testlibrary/sha/predicate/IntrinsicPredicates.java b/test/hotspot/jtreg/compiler/testlibrary/sha/predicate/IntrinsicPredicates.java index 27fe9989247..0c53c36af1d 100644 --- a/test/hotspot/jtreg/compiler/testlibrary/sha/predicate/IntrinsicPredicates.java +++ b/test/hotspot/jtreg/compiler/testlibrary/sha/predicate/IntrinsicPredicates.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -104,8 +104,10 @@ public class IntrinsicPredicates { new CPUSpecificPredicate("x86_64", new String[] { "avx2", "bmi2" }, null)))))))))); public static final BooleanSupplier SHA3_INSTRUCTION_AVAILABLE - // sha3 is only implemented on aarch64 for now - = new CPUSpecificPredicate("aarch64.*", new String[] {"sha3" }, null); + // sha3 is only implemented on aarch64 and avx512 for now + = new OrPredicate(new CPUSpecificPredicate("aarch64.*", new String[] {"sha3" }, null), + new OrPredicate(new CPUSpecificPredicate("amd64.*", new String[] {"avx512f", "avx512bw"}, null), + new CPUSpecificPredicate("x86_64", new String[] {"avx512f", "avx512bw"}, null))); public static final BooleanSupplier ANY_SHA_INSTRUCTION_AVAILABLE = new OrPredicate(IntrinsicPredicates.SHA1_INSTRUCTION_AVAILABLE, diff --git a/test/hotspot/jtreg/compiler/uncommontrap/TestDeoptOOM.java b/test/hotspot/jtreg/compiler/uncommontrap/TestDeoptOOM.java index 6f1f4138435..a0a2aacde3f 100644 --- a/test/hotspot/jtreg/compiler/uncommontrap/TestDeoptOOM.java +++ b/test/hotspot/jtreg/compiler/uncommontrap/TestDeoptOOM.java @@ -34,28 +34,15 @@ */ /* - * @test id=ZSinglegen + * @test id=Z * @bug 8273456 * @summary Test that ttyLock is ranked above StackWatermark_lock - * @requires !vm.graal.enabled & vm.gc.ZSinglegen + * @requires !vm.graal.enabled & vm.gc.Z * @run main/othervm -XX:-BackgroundCompilation -Xmx128M -XX:+IgnoreUnrecognizedVMOptions -XX:+VerifyStack * -XX:CompileCommand=exclude,compiler.uncommontrap.TestDeoptOOM::main * -XX:CompileCommand=exclude,compiler.uncommontrap.TestDeoptOOM::m9_1 * -XX:+UnlockDiagnosticVMOptions - * -XX:+UseZGC -XX:-ZGenerational -XX:+LogCompilation -XX:+PrintDeoptimizationDetails -XX:+TraceDeoptimization -XX:+Verbose - * compiler.uncommontrap.TestDeoptOOM - */ - -/* - * @test id=ZGenerational - * @bug 8273456 - * @summary Test that ttyLock is ranked above StackWatermark_lock - * @requires !vm.graal.enabled & vm.gc.ZGenerational - * @run main/othervm -XX:-BackgroundCompilation -Xmx128M -XX:+IgnoreUnrecognizedVMOptions -XX:+VerifyStack - * -XX:CompileCommand=exclude,compiler.uncommontrap.TestDeoptOOM::main - * -XX:CompileCommand=exclude,compiler.uncommontrap.TestDeoptOOM::m9_1 - * -XX:+UnlockDiagnosticVMOptions - * -XX:+UseZGC -XX:+ZGenerational -XX:+LogCompilation -XX:+PrintDeoptimizationDetails -XX:+TraceDeoptimization -XX:+Verbose + * -XX:+UseZGC -XX:+LogCompilation -XX:+PrintDeoptimizationDetails -XX:+TraceDeoptimization -XX:+Verbose * compiler.uncommontrap.TestDeoptOOM */ diff --git a/test/hotspot/jtreg/compiler/vectorapi/VectorCompareWithImmTest.java b/test/hotspot/jtreg/compiler/vectorapi/VectorCompareWithImmTest.java index b7c192778bd..833ef2b614c 100644 --- a/test/hotspot/jtreg/compiler/vectorapi/VectorCompareWithImmTest.java +++ b/test/hotspot/jtreg/compiler/vectorapi/VectorCompareWithImmTest.java @@ -143,7 +143,7 @@ public static void testByteGTInRange_runner() { @IR(counts = { IRNode.VMASK_CMPU_IMM_I_SVE, ">= 1" }) public static void testByteUnsignedGTInRange() { ByteVector av = ByteVector.fromArray(B_SPECIES, ba, 0); - av.compare(VectorOperators.UNSIGNED_GT, 64).intoArray(br, 0); + av.compare(VectorOperators.UGT, 64).intoArray(br, 0); } @Run(test = "testByteUnsignedGTInRange") @@ -163,7 +163,7 @@ public static void testByteGTOutOfRange() { @IR(failOn = { IRNode.VMASK_CMPU_IMM_I_SVE }) public static void testByteUnsignedGTOutOfRange() { ByteVector av = ByteVector.fromArray(B_SPECIES, ba, 0); - av.compare(VectorOperators.UNSIGNED_GT, -91).intoArray(br, 0); + av.compare(VectorOperators.UGT, -91).intoArray(br, 0); } @Test @@ -183,7 +183,7 @@ public static void testShortGEInRange_runner() { @IR(counts = { IRNode.VMASK_CMPU_IMM_I_SVE, ">= 1" }) public static void testShortUnsignedGEInRange() { ShortVector av = ShortVector.fromArray(S_SPECIES, sa, 0); - av.compare(VectorOperators.UNSIGNED_GE, 56).intoArray(sr, 0); + av.compare(VectorOperators.UGE, 56).intoArray(sr, 0); } @Run(test = "testShortUnsignedGEInRange") @@ -203,7 +203,7 @@ public static void testShortGEOutOfRange() { @IR(failOn = { IRNode.VMASK_CMPU_IMM_I_SVE }) public static void testShortUnsignedGEOutOfRange() { ShortVector av = ShortVector.fromArray(S_SPECIES, sa, 0); - av.compare(VectorOperators.UNSIGNED_GE, -85).intoArray(sr, 0); + av.compare(VectorOperators.UGE, -85).intoArray(sr, 0); } @Test @@ -223,7 +223,7 @@ public static void testIntLTInRange_runner() { @IR(counts = { IRNode.VMASK_CMPU_IMM_I_SVE, ">= 1" }) public static void testIntUnsignedLTInRange() { IntVector av = IntVector.fromArray(I_SPECIES, ia, 0); - av.compare(VectorOperators.UNSIGNED_LT, 101).intoArray(ir, 0); + av.compare(VectorOperators.ULT, 101).intoArray(ir, 0); } @Run(test = "testIntUnsignedLTInRange") @@ -243,7 +243,7 @@ public static void testIntLTOutOfRange() { @IR(failOn = { IRNode.VMASK_CMPU_IMM_I_SVE }) public static void testIntUnsignedLTOutOfRange() { IntVector av = IntVector.fromArray(I_SPECIES, ia, 0); - av.compare(VectorOperators.UNSIGNED_LT, -110).intoArray(ir, 0); + av.compare(VectorOperators.ULT, -110).intoArray(ir, 0); } @Test @@ -263,7 +263,7 @@ public static void testLongLEInRange_runner() { @IR(counts = { IRNode.VMASK_CMPU_IMM_L_SVE, ">= 1" }) public static void testLongUnsignedLEInRange() { LongVector av = LongVector.fromArray(L_SPECIES, la, 0); - av.compare(VectorOperators.UNSIGNED_LE, 95).intoArray(lr, 0); + av.compare(VectorOperators.ULE, 95).intoArray(lr, 0); } @Run(test = "testLongUnsignedLEInRange") @@ -283,7 +283,7 @@ public static void testLongLEOutOfRange() { @IR(failOn = { IRNode.VMASK_CMPU_IMM_L_SVE }) public static void testLongUnsignedLEOutOfRange() { LongVector av = LongVector.fromArray(L_SPECIES, la, 0); - av.compare(VectorOperators.UNSIGNED_LE, -99).intoArray(lr, 0); + av.compare(VectorOperators.ULE, -99).intoArray(lr, 0); } @Test diff --git a/test/hotspot/jtreg/compiler/vectorapi/VectorCompareWithZeroTest.java b/test/hotspot/jtreg/compiler/vectorapi/VectorCompareWithZeroTest.java index 21ad4a524d2..26e159fb768 100644 --- a/test/hotspot/jtreg/compiler/vectorapi/VectorCompareWithZeroTest.java +++ b/test/hotspot/jtreg/compiler/vectorapi/VectorCompareWithZeroTest.java @@ -240,14 +240,14 @@ public static void testDoubleVectorLessThanZero_runner() { @IR(failOn = { IRNode.VMASK_CMP_ZERO_I_NEON }) public static void testIntVectorUnsignedCondition() { IntVector av = IntVector.fromArray(I_SPECIES, ia, 0); - av.compare(VectorOperators.UNSIGNED_GT, 0).intoArray(ir, 0); + av.compare(VectorOperators.UGT, 0).intoArray(ir, 0); } @Test @IR(failOn = { IRNode.VMASK_CMP_ZERO_L_NEON }) public static void testLongVectorUnsignedCondition() { LongVector av = LongVector.fromArray(L_SPECIES, la, 0); - av.compare(VectorOperators.UNSIGNED_GE, 0).intoArray(lr, 0); + av.compare(VectorOperators.UGE, 0).intoArray(lr, 0); } public static void main(String[] args) { @@ -257,4 +257,4 @@ public static void main(String[] args) { .addFlags("-XX:UseSVE=0") .start(); } -} \ No newline at end of file +} diff --git a/test/hotspot/jtreg/compiler/vectorapi/VectorRebracket128Test.java b/test/hotspot/jtreg/compiler/vectorapi/VectorRebracket128Test.java index 239f5256405..4f7f03590dd 100644 --- a/test/hotspot/jtreg/compiler/vectorapi/VectorRebracket128Test.java +++ b/test/hotspot/jtreg/compiler/vectorapi/VectorRebracket128Test.java @@ -35,23 +35,13 @@ import jdk.internal.vm.annotation.ForceInline; /* - * @test id=ZSinglegen + * @test id=Z * @bug 8260473 - * @requires vm.gc.ZSinglegen + * @requires vm.gc.Z * @modules jdk.incubator.vector * @modules java.base/jdk.internal.vm.annotation * @run testng/othervm -XX:CompileCommand=compileonly,jdk/incubator/vector/ByteVector.fromMemorySegment - * -XX:-TieredCompilation -XX:CICompilerCount=1 -XX:+UseZGC -XX:-ZGenerational -Xbatch -Xmx256m VectorRebracket128Test - */ - -/* - * @test id=ZGenerational - * @bug 8260473 - * @requires vm.gc.ZGenerational - * @modules jdk.incubator.vector - * @modules java.base/jdk.internal.vm.annotation - * @run testng/othervm -XX:CompileCommand=compileonly,jdk/incubator/vector/ByteVector.fromMemorySegment - * -XX:-TieredCompilation -XX:CICompilerCount=1 -XX:+UseZGC -XX:+ZGenerational -Xbatch -Xmx256m VectorRebracket128Test + * -XX:-TieredCompilation -XX:CICompilerCount=1 -XX:+UseZGC -Xbatch -Xmx256m VectorRebracket128Test */ @Test diff --git a/test/hotspot/jtreg/compiler/vectorization/TestFloat16VectorConvChain.java b/test/hotspot/jtreg/compiler/vectorization/TestFloat16VectorConvChain.java index 384cc411d3e..a2ff267f937 100644 --- a/test/hotspot/jtreg/compiler/vectorization/TestFloat16VectorConvChain.java +++ b/test/hotspot/jtreg/compiler/vectorization/TestFloat16VectorConvChain.java @@ -25,7 +25,7 @@ * @test * @summary Test Float16 vector conversion chain. * @requires (vm.cpu.features ~= ".*avx512vl.*" | vm.cpu.features ~= ".*f16c.*") | os.arch == "aarch64" -* | (os.arch == "riscv64" & vm.cpu.features ~= ".*zfh.*") +* | (os.arch == "riscv64" & vm.cpu.features ~= ".*zvfh.*") * @library /test/lib / * @run driver compiler.vectorization.TestFloat16VectorConvChain */ @@ -40,7 +40,7 @@ public class TestFloat16VectorConvChain { @Test - @IR(applyIfCPUFeatureOr = {"f16c", "true", "avx512vl", "true"}, counts = {IRNode.VECTOR_CAST_HF2F, IRNode.VECTOR_SIZE_ANY, ">= 1", IRNode.VECTOR_CAST_F2HF, IRNode.VECTOR_SIZE_ANY, " >= 1"}) + @IR(applyIfCPUFeatureOr = {"f16c", "true", "avx512vl", "true", "zvfh", "true"}, counts = {IRNode.VECTOR_CAST_HF2F, IRNode.VECTOR_SIZE_ANY, ">= 1", IRNode.VECTOR_CAST_F2HF, IRNode.VECTOR_SIZE_ANY, " >= 1"}) public static void test(short [] res, short [] src1, short [] src2) { for (int i = 0; i < res.length; i++) { res[i] = (short)Float.float16ToFloat(Float.floatToFloat16(Float.float16ToFloat(src1[i]) + Float.float16ToFloat(src2[i]))); diff --git a/test/hotspot/jtreg/gc/TestAlwaysPreTouchBehavior.java b/test/hotspot/jtreg/gc/TestAlwaysPreTouchBehavior.java index c282c2876ea..9f6c915d1c0 100644 --- a/test/hotspot/jtreg/gc/TestAlwaysPreTouchBehavior.java +++ b/test/hotspot/jtreg/gc/TestAlwaysPreTouchBehavior.java @@ -73,27 +73,15 @@ */ /** - * @test id=ZGenerational + * @test id=Z * @summary tests AlwaysPreTouch - * @requires vm.gc.ZGenerational + * @requires vm.gc.Z * @requires os.maxMemory > 2G * @requires os.family != "aix" * @library /test/lib * @build jdk.test.whitebox.WhiteBox * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:+UseZGC -XX:+ZGenerational -Xmx512m -Xms512m -XX:+AlwaysPreTouch gc.TestAlwaysPreTouchBehavior - */ - -/** - * @test id=ZSinglegen - * @summary tests AlwaysPreTouch - * @requires vm.gc.ZSinglegen - * @requires os.maxMemory > 2G - * @requires os.family != "aix" - * @library /test/lib - * @build jdk.test.whitebox.WhiteBox - * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:+UseZGC -XX:-ZGenerational -Xmx512m -Xms512m -XX:+AlwaysPreTouch gc.TestAlwaysPreTouchBehavior + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:+UseZGC -Xmx512m -Xms512m -XX:+AlwaysPreTouch gc.TestAlwaysPreTouchBehavior */ /** diff --git a/test/hotspot/jtreg/gc/TestReferenceClearDuringReferenceProcessing.java b/test/hotspot/jtreg/gc/TestReferenceClearDuringReferenceProcessing.java index f66387b4cd7..3be7ba241e7 100644 --- a/test/hotspot/jtreg/gc/TestReferenceClearDuringReferenceProcessing.java +++ b/test/hotspot/jtreg/gc/TestReferenceClearDuringReferenceProcessing.java @@ -36,27 +36,15 @@ * gc.TestReferenceClearDuringReferenceProcessing */ -/* @test id=ZSinglegen +/* @test id=Z * @bug 8256517 - * @requires vm.gc.ZSinglegen + * @requires vm.gc.Z * @library /test/lib * @build jdk.test.whitebox.WhiteBox * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox * @run main/othervm * -Xbootclasspath/a:. - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:+UseZGC -XX:-ZGenerational - * gc.TestReferenceClearDuringReferenceProcessing - */ - -/* @test id=ZGenerational - * @bug 8256517 - * @requires vm.gc.ZGenerational - * @library /test/lib - * @build jdk.test.whitebox.WhiteBox - * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox - * @run main/othervm - * -Xbootclasspath/a:. - * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:+UseZGC -XX:+ZGenerational + * -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:+UseZGC * gc.TestReferenceClearDuringReferenceProcessing */ diff --git a/test/hotspot/jtreg/gc/TestSystemGC.java b/test/hotspot/jtreg/gc/TestSystemGC.java index c81b98a562f..6d37dc3d44b 100644 --- a/test/hotspot/jtreg/gc/TestSystemGC.java +++ b/test/hotspot/jtreg/gc/TestSystemGC.java @@ -58,21 +58,12 @@ */ /* - * @test id=ZSinglegen - * @requires vm.gc.ZSinglegen + * @test id=Z + * @requires vm.gc.Z * @comment ZGC will not start when LargePages cannot be allocated, therefore * we do not run such configuration. * @summary Runs System.gc() with different flags. - * @run main/othervm -XX:+UseZGC -XX:-ZGenerational gc.TestSystemGC - */ - -/* - * @test id=ZGenerational - * @requires vm.gc.ZGenerational - * @comment ZGC will not start when LargePages cannot be allocated, therefore - * we do not run such configuration. - * @summary Runs System.gc() with different flags. - * @run main/othervm -XX:+UseZGC -XX:+ZGenerational gc.TestSystemGC + * @run main/othervm -XX:+UseZGC gc.TestSystemGC */ public class TestSystemGC { diff --git a/test/hotspot/jtreg/gc/TestVerifySubSet.java b/test/hotspot/jtreg/gc/TestVerifySubSet.java index 08cddc74a00..3dc28549b56 100644 --- a/test/hotspot/jtreg/gc/TestVerifySubSet.java +++ b/test/hotspot/jtreg/gc/TestVerifySubSet.java @@ -26,9 +26,9 @@ /* @test TestVerifySubSet.java * @bug 8072725 * @summary Test VerifySubSet option - * @comment Generational ZGC can't use the generic Universe::verify - * because there's no guarantee that we will ever have - * a stable snapshot where all roots can be verified. + * @comment ZGC can't use the generic Universe::verify because + * there's no guarantee that we will ever have a stable + * snapshot where all roots can be verified. * @requires vm.gc != "Z" * @library /test/lib * @modules java.base/jdk.internal.misc diff --git a/test/hotspot/jtreg/gc/cslocker/TestCSLocker.java b/test/hotspot/jtreg/gc/cslocker/TestCSLocker.java index 2a6e3a1bfd0..bd5b6e28aa8 100644 --- a/test/hotspot/jtreg/gc/cslocker/TestCSLocker.java +++ b/test/hotspot/jtreg/gc/cslocker/TestCSLocker.java @@ -33,11 +33,11 @@ * @summary completely in JNI CS, while other is trying to allocate memory * @summary provoking GC. OOM means FAIL, deadlock means PASS. * - * @comment This test assumes that no allocation happens during the sleep loop, \ - * which is something that we can't guarantee. With Generational ZGC we \ - * see test timeouts because the main thread allocates and waits for the \ - * GC, which waits for the CSLocker, which waits for the main thread. \ - * @requires !vm.opt.final.ZGenerational + * @comment This test assumes that no allocation happens during the sleep loop, + * which is something that we can't guarantee. With ZGC we see test + * timeouts because the main thread allocates and waits for the GC, + * which waits for the CSLocker, which waits for the main thread. + * @requires vm.gc != "Z" * * @run main/native/othervm -Xmx256m gc.cslocker.TestCSLocker */ diff --git a/test/hotspot/jtreg/gc/stress/gcbasher/TestGCBasherWithZ.java b/test/hotspot/jtreg/gc/stress/gcbasher/TestGCBasherWithZ.java index dd54556697d..fb58d5784d4 100644 --- a/test/hotspot/jtreg/gc/stress/gcbasher/TestGCBasherWithZ.java +++ b/test/hotspot/jtreg/gc/stress/gcbasher/TestGCBasherWithZ.java @@ -27,47 +27,27 @@ import java.io.IOException; /* - * @test TestGCBasherWithZGenerational + * @test TestGCBasherWithZ * @key stress * @library / - * @requires vm.gc.ZGenerational + * @requires vm.gc.Z * @requires vm.flavor == "server" & !vm.emulatedClient * @summary Stress ZGC - * @run main/othervm/timeout=200 -Xlog:gc*=info -Xmx384m -server -XX:+UseZGC -XX:+ZGenerational gc.stress.gcbasher.TestGCBasherWithZ 120000 - */ -/* - * @test TestGCBasherWithZSinglegen - * @key stress - * @library / - * @requires vm.gc.ZSinglegen - * @requires vm.flavor == "server" & !vm.emulatedClient - * @summary Stress ZGC - * @run main/othervm/timeout=200 -Xlog:gc*=info -Xmx384m -server -XX:+UseZGC -XX:-ZGenerational gc.stress.gcbasher.TestGCBasherWithZ 120000 + * @run main/othervm/timeout=200 -Xlog:gc*=info -Xmx384m -server -XX:+UseZGC gc.stress.gcbasher.TestGCBasherWithZ 120000 */ /* - * @test TestGCBasherDeoptWithZGenerational + * @test TestGCBasherDeoptWithZ * @key stress * @library / - * @requires vm.gc.ZGenerational + * @requires vm.gc.Z * @requires vm.flavor == "server" & !vm.emulatedClient & vm.opt.ClassUnloading != false * @summary Stress ZGC with nmethod barrier forced deoptimization enabled. - * @run main/othervm/timeout=200 -Xlog:gc*=info,nmethod+barrier=trace -Xmx384m -server -XX:+UseZGC -XX:+ZGenerational + * @run main/othervm/timeout=200 -Xlog:gc*=info,nmethod+barrier=trace -Xmx384m -server -XX:+UseZGC * -XX:+UnlockDiagnosticVMOptions -XX:+DeoptimizeNMethodBarriersALot -XX:-Inline * gc.stress.gcbasher.TestGCBasherWithZ 120000 */ -/* - * @test TestGCBasherDeoptWithZSinglegen - * @key stress - * @library / - * @requires vm.gc.ZSinglegen - * @requires vm.flavor == "server" & !vm.emulatedClient & vm.opt.ClassUnloading != false - * @summary Stress ZGC with nmethod barrier forced deoptimization enabled. - * @run main/othervm/timeout=200 -Xlog:gc*=info,nmethod+barrier=trace -Xmx384m -server -XX:+UseZGC -XX:-ZGenerational - * -XX:+UnlockDiagnosticVMOptions -XX:+DeoptimizeNMethodBarriersALot -XX:-Inline - * gc.stress.gcbasher.TestGCBasherWithZ 120000 - */ public class TestGCBasherWithZ { public static void main(String[] args) throws IOException { TestGCBasher.main(args); diff --git a/test/hotspot/jtreg/gc/stress/gcold/TestGCOldWithZ.java b/test/hotspot/jtreg/gc/stress/gcold/TestGCOldWithZ.java index 0f77a6c286a..0741cf1fba3 100644 --- a/test/hotspot/jtreg/gc/stress/gcold/TestGCOldWithZ.java +++ b/test/hotspot/jtreg/gc/stress/gcold/TestGCOldWithZ.java @@ -25,24 +25,15 @@ package gc.stress.gcold; /* - * @test TestGCOldWithZGenerational + * @test TestGCOldWithZ * @key randomness * @library / /test/lib - * @requires vm.gc.ZGenerational + * @requires vm.gc.Z * @summary Stress the Z - * @run main/othervm -Xmx384M -XX:+UseZGC -XX:+ZGenerational gc.stress.gcold.TestGCOldWithZ 50 1 20 10 10000 - * @run main/othervm -Xmx256m -XX:+UseZGC -XX:+ZGenerational gc.stress.gcold.TestGCOldWithZ 50 5 20 1 5000 + * @run main/othervm -Xmx384M -XX:+UseZGC gc.stress.gcold.TestGCOldWithZ 50 1 20 10 10000 + * @run main/othervm -Xmx256m -XX:+UseZGC gc.stress.gcold.TestGCOldWithZ 50 5 20 1 5000 */ -/* - * @test TestGCOldWithZSinglegen - * @key randomness - * @library / /test/lib - * @requires vm.gc.ZSinglegen - * @summary Stress the Z - * @run main/othervm -Xmx384M -XX:+UseZGC -XX:-ZGenerational gc.stress.gcold.TestGCOldWithZ 50 1 20 10 10000 - * @run main/othervm -Xmx256m -XX:+UseZGC -XX:-ZGenerational gc.stress.gcold.TestGCOldWithZ 50 5 20 1 5000 - */ public class TestGCOldWithZ { public static void main(String[] args) { TestGCOld.main(args); diff --git a/test/hotspot/jtreg/gc/stringdedup/TestStringDeduplicationAgeThreshold.java b/test/hotspot/jtreg/gc/stringdedup/TestStringDeduplicationAgeThreshold.java index e70d63cf397..090a49aa80b 100644 --- a/test/hotspot/jtreg/gc/stringdedup/TestStringDeduplicationAgeThreshold.java +++ b/test/hotspot/jtreg/gc/stringdedup/TestStringDeduplicationAgeThreshold.java @@ -76,29 +76,16 @@ */ /* - * @test id=ZSinglegen + * @test id=Z * @summary Test string deduplication age threshold * @bug 8029075 - * @requires vm.gc.ZSinglegen + * @requires vm.gc.Z * @library /test/lib * @library / * @modules java.base/jdk.internal.misc:open * @modules java.base/java.lang:open * java.management - * @run driver gc.stringdedup.TestStringDeduplicationAgeThreshold Z -XX:-ZGenerational - */ - -/* - * @test id=ZGenerational - * @summary Test string deduplication age threshold - * @bug 8029075 - * @requires vm.gc.ZGenerational - * @library /test/lib - * @library / - * @modules java.base/jdk.internal.misc:open - * @modules java.base/java.lang:open - * java.management - * @run driver gc.stringdedup.TestStringDeduplicationAgeThreshold Z -XX:+ZGenerational + * @run driver gc.stringdedup.TestStringDeduplicationAgeThreshold Z */ public class TestStringDeduplicationAgeThreshold { diff --git a/test/hotspot/jtreg/gc/stringdedup/TestStringDeduplicationFullGC.java b/test/hotspot/jtreg/gc/stringdedup/TestStringDeduplicationFullGC.java index 03793f03b1b..7105be7d478 100644 --- a/test/hotspot/jtreg/gc/stringdedup/TestStringDeduplicationFullGC.java +++ b/test/hotspot/jtreg/gc/stringdedup/TestStringDeduplicationFullGC.java @@ -76,29 +76,16 @@ */ /* - * @test id=ZSinglegen + * @test id=Z * @summary Test string deduplication during full GC * @bug 8029075 - * @requires vm.gc.ZSinglegen + * @requires vm.gc.Z * @library /test/lib * @library / * @modules java.base/jdk.internal.misc:open * @modules java.base/java.lang:open * java.management - * @run driver gc.stringdedup.TestStringDeduplicationFullGC Z -XX:-ZGenerational - */ - -/* - * @test id=ZGenerational - * @summary Test string deduplication during full GC - * @bug 8029075 - * @requires vm.gc.ZGenerational - * @library /test/lib - * @library / - * @modules java.base/jdk.internal.misc:open - * @modules java.base/java.lang:open - * java.management - * @run driver gc.stringdedup.TestStringDeduplicationFullGC Z -XX:+ZGenerational + * @run driver gc.stringdedup.TestStringDeduplicationFullGC Z */ public class TestStringDeduplicationFullGC { diff --git a/test/hotspot/jtreg/gc/stringdedup/TestStringDeduplicationInterned.java b/test/hotspot/jtreg/gc/stringdedup/TestStringDeduplicationInterned.java index 0981be49aec..124bf9d5cf9 100644 --- a/test/hotspot/jtreg/gc/stringdedup/TestStringDeduplicationInterned.java +++ b/test/hotspot/jtreg/gc/stringdedup/TestStringDeduplicationInterned.java @@ -76,29 +76,16 @@ */ /* - * @test id=ZSinglegen + * @test id=Z * @summary Test string deduplication of interned strings * @bug 8029075 - * @requires vm.gc.ZSinglegen + * @requires vm.gc.Z * @library /test/lib * @library / * @modules java.base/jdk.internal.misc:open * @modules java.base/java.lang:open * java.management - * @run driver gc.stringdedup.TestStringDeduplicationInterned Z -XX:-ZGenerational - */ - -/* - * @test id=ZGenerational - * @summary Test string deduplication of interned strings - * @bug 8029075 - * @requires vm.gc.ZGenerational - * @library /test/lib - * @library / - * @modules java.base/jdk.internal.misc:open - * @modules java.base/java.lang:open - * java.management - * @run driver gc.stringdedup.TestStringDeduplicationInterned Z -XX:+ZGenerational + * @run driver gc.stringdedup.TestStringDeduplicationInterned Z */ public class TestStringDeduplicationInterned { diff --git a/test/hotspot/jtreg/gc/stringdedup/TestStringDeduplicationPrintOptions.java b/test/hotspot/jtreg/gc/stringdedup/TestStringDeduplicationPrintOptions.java index 265cb1b9dd3..0659bc5aea3 100644 --- a/test/hotspot/jtreg/gc/stringdedup/TestStringDeduplicationPrintOptions.java +++ b/test/hotspot/jtreg/gc/stringdedup/TestStringDeduplicationPrintOptions.java @@ -76,29 +76,16 @@ */ /* - * @test id=ZSinglegen + * @test id=Z * @summary Test string deduplication print options * @bug 8029075 - * @requires vm.gc.ZSinglegen + * @requires vm.gc.Z * @library /test/lib * @library / * @modules java.base/jdk.internal.misc:open * @modules java.base/java.lang:open * java.management - * @run driver gc.stringdedup.TestStringDeduplicationPrintOptions Z -XX:-ZGenerational - */ - -/* - * @test id=ZGenerational - * @summary Test string deduplication print options - * @bug 8029075 - * @requires vm.gc.ZGenerational - * @library /test/lib - * @library / - * @modules java.base/jdk.internal.misc:open - * @modules java.base/java.lang:open - * java.management - * @run driver gc.stringdedup.TestStringDeduplicationPrintOptions Z -XX:+ZGenerational + * @run driver gc.stringdedup.TestStringDeduplicationPrintOptions Z */ public class TestStringDeduplicationPrintOptions { diff --git a/test/hotspot/jtreg/gc/stringdedup/TestStringDeduplicationTableResize.java b/test/hotspot/jtreg/gc/stringdedup/TestStringDeduplicationTableResize.java index 2c16e9c4c4a..d82244ef07a 100644 --- a/test/hotspot/jtreg/gc/stringdedup/TestStringDeduplicationTableResize.java +++ b/test/hotspot/jtreg/gc/stringdedup/TestStringDeduplicationTableResize.java @@ -76,29 +76,16 @@ */ /* - * @test id=ZSinglegen + * @test id=Z * @summary Test string deduplication table resize * @bug 8029075 - * @requires vm.gc.ZSinglegen + * @requires vm.gc.Z * @library /test/lib * @library / * @modules java.base/jdk.internal.misc:open * @modules java.base/java.lang:open * java.management - * @run driver gc.stringdedup.TestStringDeduplicationTableResize Z -XX:-ZGenerational - */ - -/* - * @test id=ZGenerational - * @summary Test string deduplication table resize - * @bug 8029075 - * @requires vm.gc.ZGenerational - * @library /test/lib - * @library / - * @modules java.base/jdk.internal.misc:open - * @modules java.base/java.lang:open - * java.management - * @run driver gc.stringdedup.TestStringDeduplicationTableResize Z -XX:+ZGenerational + * @run driver gc.stringdedup.TestStringDeduplicationTableResize Z */ public class TestStringDeduplicationTableResize { diff --git a/test/hotspot/jtreg/gc/stringdedup/TestStringDeduplicationTools.java b/test/hotspot/jtreg/gc/stringdedup/TestStringDeduplicationTools.java index 2a6652eb06e..3dbedd61d12 100644 --- a/test/hotspot/jtreg/gc/stringdedup/TestStringDeduplicationTools.java +++ b/test/hotspot/jtreg/gc/stringdedup/TestStringDeduplicationTools.java @@ -57,7 +57,6 @@ class TestStringDeduplicationTools { private static byte[] dummy; private static String selectedGC = null; - private static String selectedGCMode = null; static { try { @@ -74,9 +73,6 @@ class TestStringDeduplicationTools { public static void selectGC(String[] args) { selectedGC = args[0]; - if (args.length > 1) { - selectedGCMode = args[1]; - } } private static Object getValue(String string) { @@ -137,16 +133,10 @@ public void handleNotification(Notification n, Object o) { gcCount++; } } else if (info.getGcName().startsWith("ZGC")) { - // Generational ZGC only triggers string deduplications from major collections + // ZGC only triggers string deduplications from major collections if (info.getGcName().startsWith("ZGC Major") && "end of GC cycle".equals(info.getGcAction())) { gcCount++; } - - // Single-gen ZGC - if (!info.getGcName().startsWith("ZGC Major") && !info.getGcName().startsWith("ZGC Minor") && - "end of GC cycle".equals(info.getGcAction())) { - gcCount++; - } } else if (info.getGcName().startsWith("G1")) { if ("end of minor GC".equals(info.getGcAction())) { gcCount++; @@ -325,9 +315,6 @@ private static OutputAnalyzer runTest(String... extraArgs) throws Exception { ArrayList args = new ArrayList(); args.add("-XX:+Use" + selectedGC + "GC"); - if (selectedGCMode != null) { - args.add(selectedGCMode); - } args.addAll(Arrays.asList(defaultArgs)); args.addAll(Arrays.asList(extraArgs)); diff --git a/test/hotspot/jtreg/gc/stringdedup/TestStringDeduplicationYoungGC.java b/test/hotspot/jtreg/gc/stringdedup/TestStringDeduplicationYoungGC.java index d8787cc70ba..053dc0a2862 100644 --- a/test/hotspot/jtreg/gc/stringdedup/TestStringDeduplicationYoungGC.java +++ b/test/hotspot/jtreg/gc/stringdedup/TestStringDeduplicationYoungGC.java @@ -76,29 +76,16 @@ */ /* - * @test id=ZSinglegen + * @test id=Z * @summary Test string deduplication during young GC * @bug 8029075 - * @requires vm.gc.ZSinglegen + * @requires vm.gc.Z * @library /test/lib * @library / * @modules java.base/jdk.internal.misc:open * @modules java.base/java.lang:open * java.management - * @run driver gc.stringdedup.TestStringDeduplicationYoungGC Z -XX:-ZGenerational - */ - -/* - * @test id=ZGenerational - * @summary Test string deduplication during young GC - * @bug 8029075 - * @requires vm.gc.ZGenerational - * @library /test/lib - * @library / - * @modules java.base/jdk.internal.misc:open - * @modules java.base/java.lang:open - * java.management - * @run driver gc.stringdedup.TestStringDeduplicationYoungGC Z -XX:+ZGenerational + * @run driver gc.stringdedup.TestStringDeduplicationYoungGC Z */ public class TestStringDeduplicationYoungGC { diff --git a/test/hotspot/jtreg/gc/x/TestAllocateHeapAt.java b/test/hotspot/jtreg/gc/x/TestAllocateHeapAt.java deleted file mode 100644 index 6a9768de7e6..00000000000 --- a/test/hotspot/jtreg/gc/x/TestAllocateHeapAt.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package gc.x; - -/* - * @test TestAllocateHeapAt - * @requires vm.gc.ZSinglegen & os.family == "linux" - * @requires !vm.opt.final.UseLargePages - * @summary Test ZGC with -XX:AllocateHeapAt - * @library /test/lib - * @run main/othervm gc.x.TestAllocateHeapAt . true - * @run main/othervm gc.x.TestAllocateHeapAt non-existing-directory false - */ - -import jdk.test.lib.process.ProcessTools; - -public class TestAllocateHeapAt { - public static void main(String[] args) throws Exception { - final String directory = args[0]; - final boolean exists = Boolean.parseBoolean(args[1]); - final String heapBackingFile = "Heap Backing File: " + directory; - final String failedToCreateFile = "Failed to create file " + directory; - - ProcessTools.executeTestJava( - "-XX:+UseZGC", - "-XX:-ZGenerational", - "-Xlog:gc*", - "-Xms32M", - "-Xmx32M", - "-XX:AllocateHeapAt=" + directory, - "-version") - .shouldContain(exists ? heapBackingFile : failedToCreateFile) - .shouldNotContain(exists ? failedToCreateFile : heapBackingFile) - .shouldHaveExitValue(exists ? 0 : 1); - } -} diff --git a/test/hotspot/jtreg/gc/x/TestAlwaysPreTouch.java b/test/hotspot/jtreg/gc/x/TestAlwaysPreTouch.java deleted file mode 100644 index b6ba6bf7a05..00000000000 --- a/test/hotspot/jtreg/gc/x/TestAlwaysPreTouch.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2019, 2020, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package gc.x; - -/* - * @test TestAlwaysPreTouch - * @requires vm.gc.ZSinglegen - * @summary Test ZGC parallel pre-touch - * @run main/othervm -XX:+UseZGC -XX:-ZGenerational -Xlog:gc* -XX:-AlwaysPreTouch -Xms128M -Xmx128M gc.x.TestAlwaysPreTouch - * @run main/othervm -XX:+UseZGC -XX:-ZGenerational -Xlog:gc* -XX:+AlwaysPreTouch -XX:ParallelGCThreads=1 -Xms2M -Xmx128M gc.x.TestAlwaysPreTouch - * @run main/othervm -XX:+UseZGC -XX:-ZGenerational -Xlog:gc* -XX:+AlwaysPreTouch -XX:ParallelGCThreads=8 -Xms2M -Xmx128M gc.x.TestAlwaysPreTouch - * @run main/othervm -XX:+UseZGC -XX:-ZGenerational -Xlog:gc* -XX:+AlwaysPreTouch -XX:ParallelGCThreads=1 -Xms128M -Xmx128M gc.x.TestAlwaysPreTouch - * @run main/othervm -XX:+UseZGC -XX:-ZGenerational -Xlog:gc* -XX:+AlwaysPreTouch -XX:ParallelGCThreads=8 -Xms128M -Xmx128M gc.x.TestAlwaysPreTouch - */ - -public class TestAlwaysPreTouch { - public static void main(String[] args) throws Exception { - System.out.println("Success"); - } -} diff --git a/test/hotspot/jtreg/gc/x/TestGarbageCollectorMXBean.java b/test/hotspot/jtreg/gc/x/TestGarbageCollectorMXBean.java deleted file mode 100644 index 193b93ee2d0..00000000000 --- a/test/hotspot/jtreg/gc/x/TestGarbageCollectorMXBean.java +++ /dev/null @@ -1,221 +0,0 @@ -/* - * Copyright (c) 2020, 2022, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package gc.x; - -/** - * @test TestGarbageCollectorMXBean - * @requires vm.gc.ZSinglegen - * @summary Test ZGC garbage collector MXBean - * @modules java.management - * @requires vm.compMode != "Xcomp" - * @run main/othervm -XX:+UseZGC -XX:-ZGenerational -Xms256M -Xmx512M -Xlog:gc gc.x.TestGarbageCollectorMXBean 256 512 - * @run main/othervm -XX:+UseZGC -XX:-ZGenerational -Xms512M -Xmx512M -Xlog:gc gc.x.TestGarbageCollectorMXBean 512 512 - */ - -import java.lang.management.ManagementFactory; -import java.util.concurrent.atomic.AtomicInteger; -import java.util.concurrent.atomic.AtomicLong; -import javax.management.Notification; -import javax.management.NotificationEmitter; -import javax.management.NotificationListener; -import javax.management.openmbean.CompositeData; - -import com.sun.management.GarbageCollectionNotificationInfo; - -public class TestGarbageCollectorMXBean { - private static final long startTime = System.nanoTime(); - - private static void log(String msg) { - final String elapsedSeconds = String.format("%.3fs", (System.nanoTime() - startTime) / 1_000_000_000.0); - System.out.println("[" + elapsedSeconds + "] (" + Thread.currentThread().getName() + ") " + msg); - } - - public static void main(String[] args) throws Exception { - final long M = 1024 * 1024; - final long initialCapacity = Long.parseLong(args[0]) * M; - final long maxCapacity = Long.parseLong(args[1]) * M; - final AtomicInteger cycles = new AtomicInteger(); - final AtomicInteger pauses = new AtomicInteger(); - final AtomicInteger errors = new AtomicInteger(); - - final NotificationListener listener = (Notification notification, Object ignored) -> { - final var type = notification.getType(); - if (!type.equals(GarbageCollectionNotificationInfo.GARBAGE_COLLECTION_NOTIFICATION)) { - // Ignore - return; - } - - final var data = (CompositeData)notification.getUserData(); - final var info = GarbageCollectionNotificationInfo.from(data); - final var name = info.getGcName(); - final var id = info.getGcInfo().getId(); - final var action = info.getGcAction(); - final var cause = info.getGcCause(); - final var startTime = info.getGcInfo().getStartTime(); - final var endTime = info.getGcInfo().getEndTime(); - final var duration = info.getGcInfo().getDuration(); - final var memoryUsageBeforeGC = info.getGcInfo().getMemoryUsageBeforeGc().get("ZHeap"); - final var memoryUsageAfterGC = info.getGcInfo().getMemoryUsageAfterGc().get("ZHeap"); - - log(name + " (" + type + ")"); - log(" Id: " + id); - log(" Action: " + action); - log(" Cause: " + cause); - log(" StartTime: " + startTime); - log(" EndTime: " + endTime); - log(" Duration: " + duration); - log(" MemoryUsageBeforeGC: " + memoryUsageBeforeGC); - log(" MemoryUsageAfterGC: " + memoryUsageAfterGC); - log(""); - - if (name.equals("ZGC Cycles")) { - cycles.incrementAndGet(); - - if (!action.equals("end of GC cycle")) { - log("ERROR: Action"); - errors.incrementAndGet(); - } - - if (memoryUsageBeforeGC.getInit() != initialCapacity) { - log("ERROR: MemoryUsageBeforeGC.init"); - errors.incrementAndGet(); - } - - if (memoryUsageBeforeGC.getUsed() > initialCapacity) { - log("ERROR: MemoryUsageBeforeGC.used"); - errors.incrementAndGet(); - } - - if (memoryUsageBeforeGC.getCommitted() != initialCapacity) { - log("ERROR: MemoryUsageBeforeGC.committed"); - errors.incrementAndGet(); - } - - if (memoryUsageBeforeGC.getMax() != maxCapacity) { - log("ERROR: MemoryUsageBeforeGC.max"); - errors.incrementAndGet(); - } - } else if (name.equals("ZGC Pauses")) { - pauses.incrementAndGet(); - - if (!action.equals("end of GC pause")) { - log("ERROR: Action"); - errors.incrementAndGet(); - } - - if (memoryUsageBeforeGC.getInit() != 0) { - log("ERROR: MemoryUsageBeforeGC.init"); - errors.incrementAndGet(); - } - - if (memoryUsageBeforeGC.getUsed() != 0) { - log("ERROR: MemoryUsageBeforeGC.used"); - errors.incrementAndGet(); - } - - if (memoryUsageBeforeGC.getCommitted() != 0) { - log("ERROR: MemoryUsageBeforeGC.committed"); - errors.incrementAndGet(); - } - - if (memoryUsageBeforeGC.getMax() != 0) { - log("ERROR: MemoryUsageBeforeGC.max"); - errors.incrementAndGet(); - } - } else { - log("ERROR: Name"); - errors.incrementAndGet(); - } - - if (!cause.equals("System.gc()")) { - log("ERROR: Cause"); - errors.incrementAndGet(); - } - - if (startTime > endTime) { - log("ERROR: StartTime"); - errors.incrementAndGet(); - } - - if (endTime - startTime != duration) { - log("ERROR: Duration"); - errors.incrementAndGet(); - } - }; - - // Collect garbage created at startup - System.gc(); - - // Register GC event listener - for (final var collector : ManagementFactory.getGarbageCollectorMXBeans()) { - final NotificationEmitter emitter = (NotificationEmitter)collector; - emitter.addNotificationListener(listener, null, null); - } - - final int minCycles = 5; - final int minPauses = minCycles * 3; - - // Run GCs - for (int i = 0; i < minCycles; i++) { - log("Starting GC " + i); - System.gc(); - } - - // Wait at most 90 seconds - for (int i = 0; i < 90; i++) { - log("Waiting..."); - Thread.sleep(1000); - - if (cycles.get() >= minCycles) { - log("All events received!"); - break; - } - } - - final int actualCycles = cycles.get(); - final int actualPauses = pauses.get(); - final int actualErrors = errors.get(); - - log(" minCycles: " + minCycles); - log(" minPauses: " + minPauses); - log("actualCycles: " + actualCycles); - log("actualPauses: " + actualPauses); - log("actualErrors: " + actualErrors); - - // Verify number of cycle events - if (actualCycles < minCycles) { - throw new Exception("Unexpected cycles"); - } - - // Verify number of pause events - if (actualPauses < minPauses) { - throw new Exception("Unexpected pauses"); - } - - // Verify number of errors - if (actualErrors != 0) { - throw new Exception("Unexpected errors"); - } - } -} diff --git a/test/hotspot/jtreg/gc/x/TestHighUsage.java b/test/hotspot/jtreg/gc/x/TestHighUsage.java deleted file mode 100644 index 32b0af19e4b..00000000000 --- a/test/hotspot/jtreg/gc/x/TestHighUsage.java +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (c) 2019, 2020, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package gc.x; - -/* - * @test TestHighUsage - * @requires vm.gc.ZSinglegen - * @summary Test ZGC "High Usage" rule - * @library /test/lib - * @run main/othervm gc.x.TestHighUsage - */ - -import java.util.LinkedList; -import jdk.test.lib.process.ProcessTools; - -public class TestHighUsage { - static class Test { - private static final int K = 1024; - private static final int M = K * K; - private static final long maxCapacity = Runtime.getRuntime().maxMemory(); - private static final long slowAllocationThreshold = 16 * M; - private static final long highUsageThreshold = maxCapacity / 20; // 5% - private static volatile LinkedList keepAlive; - private static volatile Object dummy; - - public static void main(String[] args) throws Exception { - System.out.println("Max capacity: " + (maxCapacity / M) + "M"); - System.out.println("High usage threshold: " + (highUsageThreshold / M) + "M"); - System.out.println("Allocating live-set"); - - // Allocate live-set - keepAlive = new LinkedList<>(); - while (Runtime.getRuntime().freeMemory() > slowAllocationThreshold) { - while (Runtime.getRuntime().freeMemory() > slowAllocationThreshold) { - keepAlive.add(new byte[128 * K]); - } - - // Compact live-set and let allocation rate settle down - System.gc(); - Thread.sleep(2000); - } - - System.out.println("Allocating garbage slowly"); - - // Allocate garbage slowly, so that the sampled allocation rate on average - // becomes zero MB/s for the last 1 second windows. Once we reach the high - // usage threshold we idle to allow for a "High Usage" GC cycle to happen. - // We need to allocate slowly to avoid an "Allocation Rate" GC cycle. - for (int i = 0; i < 300; i++) { - if (Runtime.getRuntime().freeMemory() > highUsageThreshold) { - // Allocate - dummy = new byte[128 * K]; - System.out.println("Free: " + (Runtime.getRuntime().freeMemory() / M) + "M (Allocating)"); - } else { - // Idle - System.out.println("Free: " + (Runtime.getRuntime().freeMemory() / M) + "M (Idling)"); - } - - Thread.sleep(250); - } - - System.out.println("Done"); - } - } - - public static void main(String[] args) throws Exception { - ProcessTools.executeTestJava("-XX:+UseZGC", - "-XX:-ZGenerational", - "-XX:-ZProactive", - "-Xms128M", - "-Xmx128M", - "-XX:ParallelGCThreads=1", - "-XX:ConcGCThreads=1", - "-Xlog:gc,gc+start", - Test.class.getName()) - .shouldNotContain("Allocation Stall") - .shouldContain("High Usage") - .shouldHaveExitValue(0); - } -} diff --git a/test/hotspot/jtreg/gc/x/TestMemoryMXBean.java b/test/hotspot/jtreg/gc/x/TestMemoryMXBean.java deleted file mode 100644 index fad1febe158..00000000000 --- a/test/hotspot/jtreg/gc/x/TestMemoryMXBean.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 2020, 2022, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package gc.x; - -/** - * @test TestMemoryMXBean - * @requires vm.gc.ZSinglegen - * @summary Test ZGC heap memory MXBean - * @modules java.management - * @run main/othervm -XX:+UseZGC -XX:-ZGenerational -Xms128M -Xmx256M -Xlog:gc* gc.x.TestMemoryMXBean 128 256 - * @run main/othervm -XX:+UseZGC -XX:-ZGenerational -Xms256M -Xmx256M -Xlog:gc* gc.x.TestMemoryMXBean 256 256 - */ - -import java.lang.management.ManagementFactory; - -public class TestMemoryMXBean { - public static void main(String[] args) throws Exception { - final long M = 1024 * 1024; - final long expectedInitialCapacity = Long.parseLong(args[0]) * M; - final long expectedMaxCapacity = Long.parseLong(args[1]) * M; - final var memoryUsage = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage(); - final long initialCapacity = memoryUsage.getInit(); - final long capacity = memoryUsage.getCommitted(); - final long maxCapacity = memoryUsage.getMax(); - - System.out.println("expectedInitialCapacity: " + expectedInitialCapacity); - System.out.println(" expectedMaxCapacity: " + expectedMaxCapacity); - System.out.println(" initialCapacity: " + initialCapacity); - System.out.println(" capacity: " + capacity); - System.out.println(" maxCapacity: " + maxCapacity); - - if (initialCapacity != expectedInitialCapacity) { - throw new Exception("Unexpected initial capacity"); - } - - if (maxCapacity != expectedMaxCapacity) { - throw new Exception("Unexpected max capacity"); - } - - if (capacity < initialCapacity || capacity > maxCapacity) { - throw new Exception("Unexpected capacity"); - } - } -} diff --git a/test/hotspot/jtreg/gc/x/TestMemoryManagerMXBean.java b/test/hotspot/jtreg/gc/x/TestMemoryManagerMXBean.java deleted file mode 100644 index 70ce6c23b2e..00000000000 --- a/test/hotspot/jtreg/gc/x/TestMemoryManagerMXBean.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright (c) 2020, 2022, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package gc.x; - -/** - * @test TestMemoryManagerMXBean - * @requires vm.gc.ZSinglegen - * @summary Test ZGC memory manager MXBean - * @modules java.management - * @run main/othervm -XX:+UseZGC -XX:-ZGenerational -Xmx128M gc.x.TestMemoryManagerMXBean - */ - -import java.lang.management.ManagementFactory; - -public class TestMemoryManagerMXBean { - private static void checkName(String name) throws Exception { - if (name == null || name.length() == 0) { - throw new Exception("Invalid name"); - } - } - - public static void main(String[] args) throws Exception { - int zgcCyclesMemoryManagers = 0; - int zgcPausesMemoryManagers = 0; - int zgcCyclesMemoryPools = 0; - int zgcPausesMemoryPools = 0; - - for (final var memoryManager : ManagementFactory.getMemoryManagerMXBeans()) { - final var memoryManagerName = memoryManager.getName(); - checkName(memoryManagerName); - - System.out.println("MemoryManager: " + memoryManagerName); - - if (memoryManagerName.equals("ZGC Cycles")) { - zgcCyclesMemoryManagers++; - } else if (memoryManagerName.equals("ZGC Pauses")) { - zgcPausesMemoryManagers++; - } - - for (final var memoryPoolName : memoryManager.getMemoryPoolNames()) { - checkName(memoryPoolName); - - System.out.println(" MemoryPool: " + memoryPoolName); - - if (memoryPoolName.equals("ZHeap")) { - if (memoryManagerName.equals("ZGC Cycles")) { - zgcCyclesMemoryPools++; - } else if (memoryManagerName.equals("ZGC Pauses")) { - zgcPausesMemoryPools++; - } - } - } - } - - if (zgcCyclesMemoryManagers != 1) { - throw new Exception("Unexpected number of cycle MemoryManagers"); - } - - if (zgcPausesMemoryManagers != 1) { - throw new Exception("Unexpected number of pause MemoryManagers"); - } - - if (zgcCyclesMemoryPools != 1) { - throw new Exception("Unexpected number of cycle MemoryPools"); - } - - if (zgcPausesMemoryPools != 1) { - throw new Exception("Unexpected number of pause MemoryPools"); - } - } -} diff --git a/test/hotspot/jtreg/gc/x/TestNoUncommit.java b/test/hotspot/jtreg/gc/x/TestNoUncommit.java deleted file mode 100644 index be5aa950509..00000000000 --- a/test/hotspot/jtreg/gc/x/TestNoUncommit.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 2020, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package gc.x; - -/* - * @test TestNoUncommit - * @requires vm.gc.ZSinglegen & !vm.graal.enabled - * @summary Test ZGC uncommit unused memory disabled - * @run main/othervm -XX:+UseZGC -XX:-ZGenerational -Xlog:gc*,gc+heap=debug,gc+stats=off -Xms512M -Xmx512M -XX:ZUncommitDelay=1 gc.x.TestNoUncommit - * @run main/othervm -XX:+UseZGC -XX:-ZGenerational -Xlog:gc*,gc+heap=debug,gc+stats=off -Xms128M -Xmx512M -XX:ZUncommitDelay=1 -XX:-ZUncommit gc.x.TestNoUncommit - */ - -public class TestNoUncommit { - private static final int allocSize = 200 * 1024 * 1024; // 200M - private static volatile Object keepAlive = null; - - private static long capacity() { - return Runtime.getRuntime().totalMemory(); - } - - public static void main(String[] args) throws Exception { - System.out.println("Allocating"); - keepAlive = new byte[allocSize]; - final var afterAlloc = capacity(); - - System.out.println("Reclaiming"); - keepAlive = null; - System.gc(); - - // Wait longer than the uncommit delay (which is 1 second) - Thread.sleep(5 * 1000); - - final var afterDelay = capacity(); - - // Verify - if (afterAlloc > afterDelay) { - throw new Exception("Should not uncommit"); - } - - System.out.println("Success"); - } -} diff --git a/test/hotspot/jtreg/gc/x/TestPageCacheFlush.java b/test/hotspot/jtreg/gc/x/TestPageCacheFlush.java deleted file mode 100644 index a48b6f77e17..00000000000 --- a/test/hotspot/jtreg/gc/x/TestPageCacheFlush.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2020, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package gc.x; - -/* - * @test TestPageCacheFlush - * @requires vm.gc.ZSinglegen - * @summary Test ZGC page cache flushing - * @library /test/lib - * @run driver gc.x.TestPageCacheFlush - */ - -import java.util.LinkedList; -import jdk.test.lib.process.ProcessTools; - -public class TestPageCacheFlush { - static class Test { - private static final int K = 1024; - private static final int M = K * K; - private static volatile LinkedList keepAlive; - - public static void fillPageCache(int size) { - System.out.println("Begin allocate (" + size + ")"); - - keepAlive = new LinkedList<>(); - - try { - for (;;) { - keepAlive.add(new byte[size]); - } - } catch (OutOfMemoryError e) { - keepAlive = null; - System.gc(); - } - - System.out.println("End allocate (" + size + ")"); - } - - public static void main(String[] args) throws Exception { - // Allocate small objects to fill the page cache with small pages - fillPageCache(10 * K); - - // Allocate large objects to provoke page cache flushing to rebuild - // cached small pages into large pages - fillPageCache(10 * M); - } - } - - public static void main(String[] args) throws Exception { - ProcessTools.executeTestJava( - "-XX:+UseZGC", - "-XX:-ZGenerational", - "-Xms128M", - "-Xmx128M", - "-Xlog:gc,gc+init,gc+heap=debug", - Test.class.getName()) - .outputTo(System.out) - .errorTo(System.out) - .shouldContain("Page Cache Flushed:") - .shouldHaveExitValue(0); - } -} diff --git a/test/hotspot/jtreg/gc/x/TestRelocateInPlace.java b/test/hotspot/jtreg/gc/x/TestRelocateInPlace.java deleted file mode 100644 index dba08b23a5d..00000000000 --- a/test/hotspot/jtreg/gc/x/TestRelocateInPlace.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2020, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package gc.x; - -/* - * @test TestRelocateInPlace - * @requires vm.gc.ZSinglegen - * @summary Test ZGC in-place relocateion - * @run main/othervm -XX:+UseZGC -XX:-ZGenerational -Xlog:gc*,gc+stats=off -Xmx256M -XX:+UnlockDiagnosticVMOptions -XX:+ZStressRelocateInPlace gc.x.TestRelocateInPlace - */ - -import java.util.ArrayList; - -public class TestRelocateInPlace { - private static final int allocSize = 100 * 1024 * 1024; // 100M - private static final int smallObjectSize = 4 * 1024; // 4K - private static final int mediumObjectSize = 2 * 1024 * 1024; // 2M - - private static volatile ArrayList keepAlive; - - private static void allocate(int objectSize) { - keepAlive = new ArrayList<>(); - for (int i = 0; i < allocSize; i+= objectSize) { - keepAlive.add(new byte[objectSize]); - } - } - - private static void fragment() { - // Release every other reference to cause lots of fragmentation - for (int i = 0; i < keepAlive.size(); i += 2) { - keepAlive.set(i, null); - } - } - - private static void test(int objectSize) throws Exception { - System.out.println("Allocating"); - allocate(objectSize); - - System.out.println("Fragmenting"); - fragment(); - - System.out.println("Reclaiming"); - System.gc(); - } - - public static void main(String[] args) throws Exception { - for (int i = 0; i < 10; i++) { - System.out.println("Iteration " + i); - test(smallObjectSize); - test(mediumObjectSize); - } - } -} diff --git a/test/hotspot/jtreg/gc/x/TestSmallHeap.java b/test/hotspot/jtreg/gc/x/TestSmallHeap.java deleted file mode 100644 index a7e8042f924..00000000000 --- a/test/hotspot/jtreg/gc/x/TestSmallHeap.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2019, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package gc.x; - -/* - * @test TestSmallHeap - * @requires vm.gc.ZSinglegen - * @summary Test ZGC with small heaps - * @library / /test/lib - * @run driver gc.x.TestSmallHeap 8M 16M 32M 64M 128M 256M 512M 1024M - */ - -import jdk.test.lib.process.ProcessTools; -import static gc.testlibrary.Allocation.blackHole; - -public class TestSmallHeap { - public static class Test { - public static void main(String[] args) throws Exception { - final long maxCapacity = Runtime.getRuntime().maxMemory(); - System.out.println("Max Capacity " + maxCapacity + " bytes"); - - // Allocate byte arrays of increasing length, so that - // all allocation paths (small/medium/large) are tested. - for (int length = 16; length <= maxCapacity / 16; length *= 2) { - System.out.println("Allocating " + length + " bytes"); - blackHole(new byte[length]); - } - - System.out.println("Success"); - } - } - - public static void main(String[] args) throws Exception { - for (var maxCapacity: args) { - ProcessTools.executeTestJava( - "-XX:+UseZGC", - "-XX:-ZGenerational", - "-Xlog:gc,gc+init,gc+reloc,gc+heap", - "-Xmx" + maxCapacity, - Test.class.getName()) - .outputTo(System.out) - .errorTo(System.out) - .shouldContain("Success") - .shouldHaveExitValue(0); - } - } -} diff --git a/test/hotspot/jtreg/gc/x/TestUncommit.java b/test/hotspot/jtreg/gc/x/TestUncommit.java deleted file mode 100644 index febd6b99588..00000000000 --- a/test/hotspot/jtreg/gc/x/TestUncommit.java +++ /dev/null @@ -1,136 +0,0 @@ -/* - * Copyright (c) 2019, 2020, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package gc.x; - -/* - * @test TestUncommit - * @requires vm.gc.ZSinglegen - * @summary Test ZGC uncommit unused memory - * @library /test/lib - * @run main/othervm -XX:+UseZGC -XX:-ZGenerational -Xlog:gc*,gc+heap=debug,gc+stats=off -Xms128M -Xmx512M -XX:ZUncommitDelay=10 gc.x.TestUncommit - */ - -import java.util.ArrayList; -import jdk.test.lib.Utils; - -public class TestUncommit { - private static final int delay = 10 * 1000; // milliseconds - private static final int allocSize = 200 * 1024 * 1024; // 200M - private static final int smallObjectSize = 4 * 1024; // 4K - private static final int mediumObjectSize = 2 * 1024 * 1024; // 2M - private static final int largeObjectSize = allocSize; - - private static volatile ArrayList keepAlive; - - private static final long startTime = System.nanoTime(); - - private static void log(String msg) { - final String elapsedSeconds = String.format("%.3fs", (System.nanoTime() - startTime) / 1_000_000_000.0); - System.out.println("[" + elapsedSeconds + "] (" + Thread.currentThread().getName() + ") " + msg); - } - - private static long capacity() { - return Runtime.getRuntime().totalMemory(); - } - - private static void allocate(int objectSize) { - keepAlive = new ArrayList<>(); - for (int i = 0; i < allocSize; i+= objectSize) { - keepAlive.add(new byte[objectSize]); - } - } - - private static void reclaim() { - keepAlive = null; - System.gc(); - } - - private static void test(int objectSize) throws Exception { - final var beforeAlloc = capacity(); - final var timeBeforeAlloc = System.nanoTime(); - - // Allocate memory - log("Allocating"); - allocate(objectSize); - - final var afterAlloc = capacity(); - - // Reclaim memory - log("Reclaiming"); - reclaim(); - - log("Waiting for uncommit to start"); - while (capacity() >= afterAlloc) { - Thread.sleep(1000); - } - - log("Uncommit started"); - final var timeUncommitStart = System.nanoTime(); - final var actualDelay = (timeUncommitStart - timeBeforeAlloc) / 1_000_000; - - log("Waiting for uncommit to complete"); - while (capacity() > beforeAlloc) { - Thread.sleep(1000); - } - - log("Uncommit completed"); - final var afterUncommit = capacity(); - - log(" Uncommit Delay: " + delay); - log(" Object Size: " + objectSize); - log(" Alloc Size: " + allocSize); - log(" Before Alloc: " + beforeAlloc); - log(" After Alloc: " + afterAlloc); - log(" After Uncommit: " + afterUncommit); - log(" Actual Uncommit Delay: " + actualDelay); - - // Verify - if (actualDelay < delay) { - throw new Exception("Uncommitted too fast"); - } - - if (actualDelay > delay * 2 * Utils.TIMEOUT_FACTOR) { - throw new Exception("Uncommitted too slow"); - } - - if (afterUncommit < beforeAlloc) { - throw new Exception("Uncommitted too much"); - } - - if (afterUncommit > beforeAlloc) { - throw new Exception("Uncommitted too little"); - } - - log("Success"); - } - - public static void main(String[] args) throws Exception { - for (int i = 0; i < 2; i++) { - log("Iteration " + i); - test(smallObjectSize); - test(mediumObjectSize); - test(largeObjectSize); - } - } -} diff --git a/test/hotspot/jtreg/gc/z/TestAllocateHeapAt.java b/test/hotspot/jtreg/gc/z/TestAllocateHeapAt.java index 2fb040840b4..dbcca704fab 100644 --- a/test/hotspot/jtreg/gc/z/TestAllocateHeapAt.java +++ b/test/hotspot/jtreg/gc/z/TestAllocateHeapAt.java @@ -25,7 +25,7 @@ /* * @test TestAllocateHeapAt - * @requires vm.gc.ZGenerational & os.family == "linux" + * @requires vm.gc.Z & os.family == "linux" * @requires !vm.opt.final.UseLargePages * @summary Test ZGC with -XX:AllocateHeapAt * @library /test/lib @@ -44,7 +44,6 @@ public static void main(String[] args) throws Exception { ProcessTools.executeTestJava( "-XX:+UseZGC", - "-XX:+ZGenerational", "-Xlog:gc*", "-Xms32M", "-Xmx32M", diff --git a/test/hotspot/jtreg/gc/z/TestAllocateHeapAtWithHugeTLBFS.java b/test/hotspot/jtreg/gc/z/TestAllocateHeapAtWithHugeTLBFS.java index ac647bbd013..4134ce838d4 100644 --- a/test/hotspot/jtreg/gc/z/TestAllocateHeapAtWithHugeTLBFS.java +++ b/test/hotspot/jtreg/gc/z/TestAllocateHeapAtWithHugeTLBFS.java @@ -25,7 +25,7 @@ /* * @test TestAllocateHeapAtWithHugeTLBFS - * @requires vm.gc.ZGenerational & os.family == "linux" + * @requires vm.gc.Z & os.family == "linux" * @summary Test ZGC with -XX:AllocateHeapAt and -XX:+UseLargePages * @library /test/lib * @run driver gc.z.TestAllocateHeapAtWithHugeTLBFS true @@ -77,7 +77,6 @@ public static void main(String[] args) throws Exception { ProcessTools.executeTestJava( "-XX:+UseZGC", - "-XX:+ZGenerational", "-Xlog:gc*", "-Xms32M", "-Xmx32M", diff --git a/test/hotspot/jtreg/gc/z/TestAlwaysPreTouch.java b/test/hotspot/jtreg/gc/z/TestAlwaysPreTouch.java index 8020c82c4fd..db0471431d1 100644 --- a/test/hotspot/jtreg/gc/z/TestAlwaysPreTouch.java +++ b/test/hotspot/jtreg/gc/z/TestAlwaysPreTouch.java @@ -25,13 +25,13 @@ /* * @test TestAlwaysPreTouch - * @requires vm.gc.ZGenerational + * @requires vm.gc.Z * @summary Test ZGC parallel pre-touch - * @run main/othervm -XX:+UseZGC -XX:+ZGenerational -Xlog:gc* -XX:-AlwaysPreTouch -Xms128M -Xmx128M gc.z.TestAlwaysPreTouch - * @run main/othervm -XX:+UseZGC -XX:+ZGenerational -Xlog:gc* -XX:+AlwaysPreTouch -XX:ParallelGCThreads=1 -Xms2M -Xmx128M gc.z.TestAlwaysPreTouch - * @run main/othervm -XX:+UseZGC -XX:+ZGenerational -Xlog:gc* -XX:+AlwaysPreTouch -XX:ParallelGCThreads=8 -Xms2M -Xmx128M gc.z.TestAlwaysPreTouch - * @run main/othervm -XX:+UseZGC -XX:+ZGenerational -Xlog:gc* -XX:+AlwaysPreTouch -XX:ParallelGCThreads=1 -Xms128M -Xmx128M gc.z.TestAlwaysPreTouch - * @run main/othervm -XX:+UseZGC -XX:+ZGenerational -Xlog:gc* -XX:+AlwaysPreTouch -XX:ParallelGCThreads=8 -Xms128M -Xmx128M gc.z.TestAlwaysPreTouch + * @run main/othervm -XX:+UseZGC -Xlog:gc* -XX:-AlwaysPreTouch -Xms128M -Xmx128M gc.z.TestAlwaysPreTouch + * @run main/othervm -XX:+UseZGC -Xlog:gc* -XX:+AlwaysPreTouch -XX:ParallelGCThreads=1 -Xms2M -Xmx128M gc.z.TestAlwaysPreTouch + * @run main/othervm -XX:+UseZGC -Xlog:gc* -XX:+AlwaysPreTouch -XX:ParallelGCThreads=8 -Xms2M -Xmx128M gc.z.TestAlwaysPreTouch + * @run main/othervm -XX:+UseZGC -Xlog:gc* -XX:+AlwaysPreTouch -XX:ParallelGCThreads=1 -Xms128M -Xmx128M gc.z.TestAlwaysPreTouch + * @run main/othervm -XX:+UseZGC -Xlog:gc* -XX:+AlwaysPreTouch -XX:ParallelGCThreads=8 -Xms128M -Xmx128M gc.z.TestAlwaysPreTouch */ public class TestAlwaysPreTouch { diff --git a/test/hotspot/jtreg/gc/z/TestGarbageCollectorMXBean.java b/test/hotspot/jtreg/gc/z/TestGarbageCollectorMXBean.java index b3ecc28ff65..d3cf46d51e8 100644 --- a/test/hotspot/jtreg/gc/z/TestGarbageCollectorMXBean.java +++ b/test/hotspot/jtreg/gc/z/TestGarbageCollectorMXBean.java @@ -25,12 +25,12 @@ /** * @test TestGarbageCollectorMXBean - * @requires vm.gc.ZGenerational + * @requires vm.gc.Z * @summary Test ZGC garbage collector MXBean * @modules java.management * @requires vm.compMode != "Xcomp" - * @run main/othervm -XX:+UseZGC -XX:+ZGenerational -Xms256M -Xmx512M -Xlog:gc gc.z.TestGarbageCollectorMXBean 256 512 - * @run main/othervm -XX:+UseZGC -XX:+ZGenerational -Xms512M -Xmx512M -Xlog:gc gc.z.TestGarbageCollectorMXBean 512 512 + * @run main/othervm -XX:+UseZGC -Xms256M -Xmx512M -Xlog:gc gc.z.TestGarbageCollectorMXBean 256 512 + * @run main/othervm -XX:+UseZGC -Xms512M -Xmx512M -Xlog:gc gc.z.TestGarbageCollectorMXBean 512 512 */ import java.lang.management.ManagementFactory; diff --git a/test/hotspot/jtreg/gc/z/TestMemoryMXBean.java b/test/hotspot/jtreg/gc/z/TestMemoryMXBean.java index 6f4505a64bf..ec1daaa00fb 100644 --- a/test/hotspot/jtreg/gc/z/TestMemoryMXBean.java +++ b/test/hotspot/jtreg/gc/z/TestMemoryMXBean.java @@ -25,11 +25,11 @@ /** * @test TestMemoryMXBean - * @requires vm.gc.ZGenerational + * @requires vm.gc.Z * @summary Test ZGC heap memory MXBean * @modules java.management - * @run main/othervm -XX:+UseZGC -XX:+ZGenerational -Xms128M -Xmx256M -Xlog:gc* gc.z.TestMemoryMXBean 128 256 - * @run main/othervm -XX:+UseZGC -XX:+ZGenerational -Xms256M -Xmx256M -Xlog:gc* gc.z.TestMemoryMXBean 256 256 + * @run main/othervm -XX:+UseZGC -Xms128M -Xmx256M -Xlog:gc* gc.z.TestMemoryMXBean 128 256 + * @run main/othervm -XX:+UseZGC -Xms256M -Xmx256M -Xlog:gc* gc.z.TestMemoryMXBean 256 256 */ import java.lang.management.ManagementFactory; diff --git a/test/hotspot/jtreg/gc/z/TestMemoryManagerMXBean.java b/test/hotspot/jtreg/gc/z/TestMemoryManagerMXBean.java index 5a0c481a42f..6540d67e855 100644 --- a/test/hotspot/jtreg/gc/z/TestMemoryManagerMXBean.java +++ b/test/hotspot/jtreg/gc/z/TestMemoryManagerMXBean.java @@ -25,10 +25,10 @@ /** * @test TestMemoryManagerMXBean - * @requires vm.gc.ZGenerational + * @requires vm.gc.Z * @summary Test ZGC memory manager MXBean * @modules java.management - * @run main/othervm -XX:+UseZGC -XX:+ZGenerational -Xmx128M gc.z.TestMemoryManagerMXBean + * @run main/othervm -XX:+UseZGC -Xmx128M gc.z.TestMemoryManagerMXBean */ import java.lang.management.ManagementFactory; diff --git a/test/hotspot/jtreg/gc/z/TestNoUncommit.java b/test/hotspot/jtreg/gc/z/TestNoUncommit.java index 6115681552e..cd5833f308f 100644 --- a/test/hotspot/jtreg/gc/z/TestNoUncommit.java +++ b/test/hotspot/jtreg/gc/z/TestNoUncommit.java @@ -25,10 +25,10 @@ /* * @test TestNoUncommit - * @requires vm.gc.ZGenerational & !vm.graal.enabled + * @requires vm.gc.Z & !vm.graal.enabled * @summary Test ZGC uncommit unused memory disabled - * @run main/othervm -XX:+UseZGC -XX:+ZGenerational -Xlog:gc*,gc+heap=debug,gc+stats=off -Xms512M -Xmx512M -XX:ZUncommitDelay=1 gc.z.TestNoUncommit - * @run main/othervm -XX:+UseZGC -XX:+ZGenerational -Xlog:gc*,gc+heap=debug,gc+stats=off -Xms128M -Xmx512M -XX:ZUncommitDelay=1 -XX:-ZUncommit gc.z.TestNoUncommit + * @run main/othervm -XX:+UseZGC -Xlog:gc*,gc+heap=debug,gc+stats=off -Xms512M -Xmx512M -XX:ZUncommitDelay=1 gc.z.TestNoUncommit + * @run main/othervm -XX:+UseZGC -Xlog:gc*,gc+heap=debug,gc+stats=off -Xms128M -Xmx512M -XX:ZUncommitDelay=1 -XX:-ZUncommit gc.z.TestNoUncommit */ public class TestNoUncommit { diff --git a/test/hotspot/jtreg/gc/z/TestPageCacheFlush.java b/test/hotspot/jtreg/gc/z/TestPageCacheFlush.java index 3b666ddc2c8..847c7b2d117 100644 --- a/test/hotspot/jtreg/gc/z/TestPageCacheFlush.java +++ b/test/hotspot/jtreg/gc/z/TestPageCacheFlush.java @@ -25,7 +25,7 @@ /* * @test TestPageCacheFlush - * @requires vm.gc.ZGenerational + * @requires vm.gc.Z * @summary Test ZGC page cache flushing * @library /test/lib * @run driver gc.z.TestPageCacheFlush @@ -70,7 +70,6 @@ public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception { ProcessTools.executeTestJava( "-XX:+UseZGC", - "-XX:+ZGenerational", "-Xms128M", "-Xmx128M", "-Xlog:gc,gc+init,gc+heap=debug", diff --git a/test/hotspot/jtreg/gc/z/TestRegistersPushPopAtZGCLoadBarrierStub.java b/test/hotspot/jtreg/gc/z/TestRegistersPushPopAtZGCLoadBarrierStub.java index 71aa634c761..9730fdaafd8 100644 --- a/test/hotspot/jtreg/gc/z/TestRegistersPushPopAtZGCLoadBarrierStub.java +++ b/test/hotspot/jtreg/gc/z/TestRegistersPushPopAtZGCLoadBarrierStub.java @@ -31,7 +31,7 @@ * @library /test/lib / * @modules jdk.incubator.vector * - * @requires vm.gc.ZGenerational & vm.debug + * @requires vm.gc.Z & vm.debug * @requires os.arch=="aarch64" * * @run driver gc.z.TestRegistersPushPopAtZGCLoadBarrierStub @@ -316,7 +316,6 @@ static String launchJavaTestProcess(String test_name) throws Exception { command.add("-XX:-UseOnStackReplacement"); command.add("-XX:-TieredCompilation"); command.add("-XX:+UseZGC"); - command.add("-XX:+ZGenerational"); command.add("--add-modules=jdk.incubator.vector"); command.add("-XX:CompileCommand=print," + Launcher.class.getName() + "::" + test_name); command.add(Launcher.class.getName()); diff --git a/test/hotspot/jtreg/gc/z/TestRelocateInPlace.java b/test/hotspot/jtreg/gc/z/TestRelocateInPlace.java index 5115fe3c965..723a6504c6a 100644 --- a/test/hotspot/jtreg/gc/z/TestRelocateInPlace.java +++ b/test/hotspot/jtreg/gc/z/TestRelocateInPlace.java @@ -25,9 +25,9 @@ /* * @test TestRelocateInPlace - * @requires vm.gc.ZGenerational + * @requires vm.gc.Z * @summary Test ZGC in-place relocateion - * @run main/othervm -XX:+UseZGC -XX:+ZGenerational -Xlog:gc*,gc+stats=off -Xmx256M -XX:+UnlockDiagnosticVMOptions -XX:+ZStressRelocateInPlace gc.z.TestRelocateInPlace + * @run main/othervm -XX:+UseZGC -Xlog:gc*,gc+stats=off -Xmx256M -XX:+UnlockDiagnosticVMOptions -XX:+ZStressRelocateInPlace gc.z.TestRelocateInPlace */ import java.util.ArrayList; diff --git a/test/hotspot/jtreg/gc/z/TestSmallHeap.java b/test/hotspot/jtreg/gc/z/TestSmallHeap.java index 67d9d33d281..9ac65d05108 100644 --- a/test/hotspot/jtreg/gc/z/TestSmallHeap.java +++ b/test/hotspot/jtreg/gc/z/TestSmallHeap.java @@ -25,7 +25,7 @@ /* * @test TestSmallHeap - * @requires vm.gc.ZGenerational + * @requires vm.gc.Z * @summary Test ZGC with small heaps * @library / /test/lib * @run driver gc.z.TestSmallHeap 16M 32M 64M 128M 256M 512M 1024M @@ -55,7 +55,6 @@ public static void main(String[] args) throws Exception { for (var maxCapacity: args) { ProcessTools.executeTestJava( "-XX:+UseZGC", - "-XX:+ZGenerational", "-Xlog:gc,gc+init,gc+reloc,gc+heap", "-Xmx" + maxCapacity, Test.class.getName()) diff --git a/test/hotspot/jtreg/gc/z/TestUncommit.java b/test/hotspot/jtreg/gc/z/TestUncommit.java index fea0721cce3..e02773e868f 100644 --- a/test/hotspot/jtreg/gc/z/TestUncommit.java +++ b/test/hotspot/jtreg/gc/z/TestUncommit.java @@ -25,10 +25,10 @@ /* * @test TestUncommit - * @requires vm.gc.ZGenerational + * @requires vm.gc.Z * @summary Test ZGC uncommit unused memory * @library /test/lib - * @run main/othervm -XX:+UseZGC -XX:+ZGenerational -Xlog:gc*,gc+heap=debug,gc+stats=off -Xms128M -Xmx512M -XX:ZUncommitDelay=10 gc.z.TestUncommit + * @run main/othervm -XX:+UseZGC -Xlog:gc*,gc+heap=debug,gc+stats=off -Xms128M -Xmx512M -XX:ZUncommitDelay=10 gc.z.TestUncommit */ import java.util.ArrayList; diff --git a/test/hotspot/jtreg/gc/z/TestZForceDiscontiguousHeapReservations.java b/test/hotspot/jtreg/gc/z/TestZForceDiscontiguousHeapReservations.java index f1a14f0cf90..fa2485073dd 100644 --- a/test/hotspot/jtreg/gc/z/TestZForceDiscontiguousHeapReservations.java +++ b/test/hotspot/jtreg/gc/z/TestZForceDiscontiguousHeapReservations.java @@ -25,7 +25,7 @@ /** * @test TestZForceDiscontiguousHeapReservations - * @requires vm.gc.ZGenerational & vm.debug + * @requires vm.gc.Z & vm.debug * @summary Test the ZForceDiscontiguousHeapReservations development flag * @library /test/lib * @run driver gc.z.TestZForceDiscontiguousHeapReservations @@ -47,7 +47,6 @@ private static void testValue(int n) throws Exception { final int XmsInM = Math.min(16 * XmxInM / (n + 1), XmxInM); OutputAnalyzer oa = ProcessTools.executeTestJava( "-XX:+UseZGC", - "-XX:+ZGenerational", "-Xms" + XmsInM + "M", "-Xmx" + XmxInM + "M", "-Xlog:gc,gc+init", diff --git a/test/hotspot/jtreg/gc/z/TestZNMT.java b/test/hotspot/jtreg/gc/z/TestZNMT.java index 889cc77b0e4..b536f3eab8e 100644 --- a/test/hotspot/jtreg/gc/z/TestZNMT.java +++ b/test/hotspot/jtreg/gc/z/TestZNMT.java @@ -26,8 +26,8 @@ /** * @test TestZNMT * @bug 8310743 - * @requires vm.gc.ZGenerational & vm.debug - * @summary Test NMT and ZGenerational heap reservation / commits interactions. + * @requires vm.gc.Z & vm.debug + * @summary Test NMT and ZGC heap reservation / commits interactions. * @library / /test/lib * @run driver gc.z.TestZNMT */ @@ -70,7 +70,6 @@ private static void testValue(int zForceDiscontiguousHeapReservations) throws Ex final int XmsInM = Math.min(16 * XmxInM / (zForceDiscontiguousHeapReservations + 1), XmxInM); OutputAnalyzer oa = ProcessTools.executeTestJava( "-XX:+UseZGC", - "-XX:+ZGenerational", "-Xms" + XmsInM + "M", "-Xmx" + XmxInM + "M", "-Xlog:gc,gc+init", diff --git a/test/hotspot/jtreg/runtime/CommandLine/VMDeprecatedOptions.java b/test/hotspot/jtreg/runtime/CommandLine/VMDeprecatedOptions.java index 96bc22dfb1d..0ecfbe2c8db 100644 --- a/test/hotspot/jtreg/runtime/CommandLine/VMDeprecatedOptions.java +++ b/test/hotspot/jtreg/runtime/CommandLine/VMDeprecatedOptions.java @@ -57,7 +57,6 @@ public class VMDeprecatedOptions { Arrays.asList(new String[][] { // deprecated non-alias flags: {"AllowRedefinitionToAddDeleteMethods", "true"}, - {"ZGenerational", "false"}, {"LockingMode", "1"}, // deprecated alias flags (see also aliased_jvm_flags): diff --git a/test/hotspot/jtreg/runtime/cds/appcds/TestEpsilonGCWithCDS.java b/test/hotspot/jtreg/runtime/cds/appcds/TestEpsilonGCWithCDS.java index fe7c5a4ae31..132f63ba850 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/TestEpsilonGCWithCDS.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/TestEpsilonGCWithCDS.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,16 +37,41 @@ * @run driver TestEpsilonGCWithCDS */ +// Below is exactly the same as above, except: +// - requires vm.bits == "64" +// - extra argument "false" + +/* + * @test Loading CDS archived heap objects into EpsilonGC + * @bug 8234679 8341371 + * @requires vm.cds + * @requires vm.gc.Epsilon + * @requires vm.gc.G1 + * @requires vm.bits == "64" + * + * @comment don't run this test if any -XX::+Use???GC options are specified, since they will + * interfere with the test. + * @requires vm.gc == null + * + * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds + * @compile test-classes/Hello.java + * @run driver TestEpsilonGCWithCDS false + */ import jdk.test.lib.Platform; import jdk.test.lib.process.OutputAnalyzer; public class TestEpsilonGCWithCDS { public final static String HELLO = "Hello World"; static String helloJar; + static boolean useCompressedOops = true; public static void main(String... args) throws Exception { helloJar = JarBuilder.build("hello", "Hello"); + if (args.length > 0 && args[0].equals("false")) { + useCompressedOops = false; + } + // Check if we can use EpsilonGC during dump time, or run time, or both. test(false, true); test(true, false); @@ -70,6 +95,8 @@ static void test(boolean dumpWithEpsilon, boolean execWithEpsilon, boolean useSm String execGC = execWithEpsilon ? Epsilon : G1; String small1 = useSmallRegions ? "-Xmx256m" : "-showversion"; String small2 = useSmallRegions ? "-XX:ObjectAlignmentInBytes=64" : "-showversion"; + String errMsg = "Cannot use CDS heap data. Selected GC not compatible -XX:-UseCompressedOops"; + String coops = useCompressedOops ? "-XX:+UseCompressedOops" : "-XX:-UseCompressedOops"; OutputAnalyzer out; System.out.println("0. Dump with " + dumpGC); @@ -79,6 +106,7 @@ static void test(boolean dumpWithEpsilon, boolean execWithEpsilon, boolean useSm dumpGC, small1, small2, + coops, "-Xlog:cds"); out.shouldContain("Dumping shared data to file:"); out.shouldHaveExitValue(0); @@ -89,9 +117,11 @@ static void test(boolean dumpWithEpsilon, boolean execWithEpsilon, boolean useSm execGC, small1, small2, + coops, "-Xlog:cds", "Hello"); out.shouldContain(HELLO); + out.shouldNotContain(errMsg); out.shouldHaveExitValue(0); } } diff --git a/test/hotspot/jtreg/runtime/cds/appcds/TestParallelGCWithCDS.java b/test/hotspot/jtreg/runtime/cds/appcds/TestParallelGCWithCDS.java index 691c87fef36..705df07f841 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/TestParallelGCWithCDS.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/TestParallelGCWithCDS.java @@ -37,16 +37,41 @@ * @run driver TestParallelGCWithCDS */ +// Below is exactly the same as above, except: +// - requires vm.bits == "64" +// - extra argument "false" + + /* + * @test Loading CDS archived heap objects into ParallelGC + * @bug 8274788 8341371 + * @requires vm.cds + * @requires vm.gc.Parallel + * @requires vm.gc.G1 + * @requires vm.bits == "64" + * + * @comment don't run this test if any -XX::+Use???GC options are specified, since they will + * interfere with the test. + * @requires vm.gc == null + * + * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds + * @compile test-classes/Hello.java + * @run driver TestParallelGCWithCDS false + */ import jdk.test.lib.Platform; import jdk.test.lib.process.OutputAnalyzer; public class TestParallelGCWithCDS { public final static String HELLO = "Hello World"; static String helloJar; + static boolean useCompressedOops = true; public static void main(String... args) throws Exception { helloJar = JarBuilder.build("hello", "Hello"); + if (args.length > 0 && args[0].equals("false")) { + useCompressedOops = false; + } + // Check if we can use ParallelGC during dump time, or run time, or both. test(false, true); test(true, false); @@ -69,6 +94,8 @@ static void test(boolean dumpWithParallel, boolean execWithParallel, boolean use String execGC = execWithParallel ? Parallel : G1; String small1 = useSmallRegions ? "-Xmx256m" : "-showversion"; String small2 = useSmallRegions ? "-XX:ObjectAlignmentInBytes=64" : "-showversion"; + String errMsg = "Cannot use CDS heap data. Selected GC not compatible -XX:-UseCompressedOops"; + String coops = useCompressedOops ? "-XX:+UseCompressedOops" : "-XX:-UseCompressedOops"; OutputAnalyzer out; System.out.println("0. Dump with " + dumpGC); @@ -77,6 +104,7 @@ static void test(boolean dumpWithParallel, boolean execWithParallel, boolean use dumpGC, small1, small2, + coops, "-Xlog:cds"); out.shouldContain("Dumping shared data to file:"); out.shouldHaveExitValue(0); @@ -86,9 +114,11 @@ static void test(boolean dumpWithParallel, boolean execWithParallel, boolean use execGC, small1, small2, + coops, "-Xlog:cds", "Hello"); out.shouldContain(HELLO); + out.shouldNotContain(errMsg); out.shouldHaveExitValue(0); int n = 2; @@ -109,10 +139,12 @@ static void test(boolean dumpWithParallel, boolean execWithParallel, boolean use small1, small2, xmx, + coops, "-Xlog:cds", "Hello"); if (out.getExitValue() == 0) { out.shouldContain(HELLO); + out.shouldNotContain(errMsg); } else { String pattern = "((Too small maximum heap)" + "|(GC triggered before VM initialization completed)" + diff --git a/test/hotspot/jtreg/runtime/cds/appcds/TestSerialGCWithCDS.java b/test/hotspot/jtreg/runtime/cds/appcds/TestSerialGCWithCDS.java index 8c8cb4d932a..b191b5f395b 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/TestSerialGCWithCDS.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/TestSerialGCWithCDS.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -98,6 +98,7 @@ static void test(boolean dumpWithSerial, boolean execWithSerial, boolean useSmal String execGC = execWithSerial ? Serial : G1; String small1 = useSmallRegions ? "-Xmx256m" : DUMMY; String small2 = useSmallRegions ? "-XX:ObjectAlignmentInBytes=64" : DUMMY; + String errMsg = "Cannot use CDS heap data. Selected GC not compatible -XX:-UseCompressedOops"; String coops; if (Platform.is64bit()) { coops = useCompressedOops ? "-XX:+UseCompressedOops" : "-XX:-UseCompressedOops"; @@ -125,7 +126,7 @@ static void test(boolean dumpWithSerial, boolean execWithSerial, boolean useSmal coops, "-Xlog:cds", "Hello"); - checkExecOutput(dumpWithSerial, execWithSerial, out); + out.shouldNotContain(errMsg); System.out.println("2. Exec with " + execGC + " and test ArchiveRelocationMode"); out = TestCommon.exec(helloJar, @@ -136,7 +137,7 @@ static void test(boolean dumpWithSerial, boolean execWithSerial, boolean useSmal "-Xlog:cds,cds+heap", "-XX:ArchiveRelocationMode=1", // always relocate shared metadata "Hello"); - checkExecOutput(dumpWithSerial, execWithSerial, out); + out.shouldNotContain(errMsg); int n = 2; if (dumpWithSerial == false && execWithSerial == true) { @@ -160,7 +161,7 @@ static void test(boolean dumpWithSerial, boolean execWithSerial, boolean useSmal "-Xlog:cds", "Hello"); if (out.getExitValue() == 0) { - checkExecOutput(dumpWithSerial, execWithSerial, out); + out.shouldNotContain(errMsg); } else { String output = out.getStdout() + out.getStderr(); String exp1 = "Too small maximum heap"; @@ -173,19 +174,4 @@ static void test(boolean dumpWithSerial, boolean execWithSerial, boolean useSmal } } } - - static void checkExecOutput(boolean dumpWithSerial, boolean execWithSerial, OutputAnalyzer out) { - String errMsg = "Cannot use CDS heap data. UseG1GC is required for -XX:-UseCompressedOops"; - if (Platform.is64bit() && - !Platform.isWindows() && // archive heap not supported on Windows. - !dumpWithSerial && // Dumped with G1, so we have an archived heap - execWithSerial && // Running with serial - !useCompressedOops) { // ArchiveHeapLoader::can_load() always returns false when COOP is disabled - out.shouldContain(errMsg); - } - if (!execWithSerial) { - // We should never see this message with G1 - out.shouldNotContain(errMsg); - } - } } diff --git a/test/hotspot/jtreg/runtime/cds/appcds/TestShenandoahWithCDS.java b/test/hotspot/jtreg/runtime/cds/appcds/TestShenandoahWithCDS.java index 83442c1e159..d8bbfee504b 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/TestShenandoahWithCDS.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/TestShenandoahWithCDS.java @@ -35,16 +35,38 @@ * @run driver TestShenandoahWithCDS */ +// Below is exactly the same as above, except: +// - requires vm.bits == "64" +// - extra argument "false" + +/* + * @test + * @bug 8293650 8341371 + * @requires vm.cds + * @requires vm.bits == 64 + * @requires vm.gc.Shenandoah + * @requires vm.gc.G1 + * @requires vm.gc == null + * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds + * @compile test-classes/Hello.java + * @run driver TestShenandoahWithCDS false + */ + import jdk.test.lib.Platform; import jdk.test.lib.process.OutputAnalyzer; public class TestShenandoahWithCDS { public final static String HELLO = "Hello World"; static String helloJar; + static boolean useCompressedOops = true; public static void main(String... args) throws Exception { helloJar = JarBuilder.build("hello", "Hello"); + if (args.length > 0 && args[0].equals("false")) { + useCompressedOops = false; + } + // Run with the variety of region sizes, and combinations // of G1/Shenandoah at dump/exec times. "-1" means to use G1. final int[] regionSizes = { -1, 256, 512, 1024, 2048 }; @@ -62,6 +84,8 @@ static void test(int dumpRegionSize, int execRegionSize) throws Exception { String optExecGC = (execRegionSize != -1) ? "-XX:+UseShenandoahGC" : "-XX:+UseG1GC"; String optDumpRegionSize = (dumpRegionSize != -1) ? "-XX:ShenandoahRegionSize=" + dumpRegionSize + "K" : exp; String optExecRegionSize = (execRegionSize != -1) ? "-XX:ShenandoahRegionSize=" + execRegionSize + "K" : exp; + String errMsg = "Cannot use CDS heap data. Selected GC not compatible -XX:-UseCompressedOops"; + String coops = useCompressedOops ? "-XX:+UseCompressedOops" : "-XX:-UseCompressedOops"; OutputAnalyzer out; System.out.println("0. Dump with " + optDumpGC + " and " + optDumpRegionSize); @@ -71,6 +95,7 @@ static void test(int dumpRegionSize, int execRegionSize) throws Exception { "-Xmx1g", optDumpGC, optDumpRegionSize, + coops, "-Xlog:cds"); out.shouldContain("Dumping shared data to file:"); out.shouldHaveExitValue(0); @@ -81,9 +106,11 @@ static void test(int dumpRegionSize, int execRegionSize) throws Exception { "-Xmx1g", optExecGC, optExecRegionSize, + coops, "-Xlog:cds", "Hello"); out.shouldContain(HELLO); + out.shouldNotContain(errMsg); out.shouldHaveExitValue(0); } } diff --git a/test/hotspot/jtreg/runtime/cds/appcds/TestZGCWithCDS.java b/test/hotspot/jtreg/runtime/cds/appcds/TestZGCWithCDS.java index ea51b198f59..89fc346ffbb 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/TestZGCWithCDS.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/TestZGCWithCDS.java @@ -22,29 +22,16 @@ */ /* - * @test id=ZSinglegen + * @test * @bug 8232069 * @requires vm.cds * @requires vm.bits == 64 - * @requires vm.gc.ZSinglegen + * @requires vm.gc.Z * @requires vm.gc.Serial * @requires vm.gc == null * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds * @compile test-classes/Hello.java - * @run driver TestZGCWithCDS -XX:-ZGenerational - */ - -/* - * @test id=ZGenerational - * @bug 8232069 - * @requires vm.cds - * @requires vm.bits == 64 - * @requires vm.gc.ZGenerational - * @requires vm.gc.Serial - * @requires vm.gc == null - * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds - * @compile test-classes/Hello.java - * @run driver TestZGCWithCDS -XX:+ZGenerational + * @run driver TestZGCWithCDS */ import jdk.test.lib.Platform; @@ -55,14 +42,12 @@ public class TestZGCWithCDS { public final static String UNABLE_TO_USE_ARCHIVE = "Unable to use shared archive."; public final static String ERR_MSG = "The saved state of UseCompressedOops and UseCompressedClassPointers is different from runtime, CDS will be disabled."; public static void main(String... args) throws Exception { - String zGenerational = args[0]; String helloJar = JarBuilder.build("hello", "Hello"); System.out.println("0. Dump with ZGC"); OutputAnalyzer out = TestCommon .dump(helloJar, new String[] {"Hello"}, "-XX:+UseZGC", - zGenerational, "-Xlog:cds"); out.shouldContain("Dumping shared data to file:"); out.shouldHaveExitValue(0); @@ -71,7 +56,6 @@ public static void main(String... args) throws Exception { out = TestCommon .exec(helloJar, "-XX:+UseZGC", - zGenerational, "-Xlog:cds", "Hello"); out.shouldContain(HELLO); @@ -151,7 +135,6 @@ public static void main(String... args) throws Exception { out = TestCommon .exec(helloJar, "-XX:+UseZGC", - zGenerational, "-Xlog:cds", "Hello"); out.shouldContain(HELLO); diff --git a/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/ArchivedIntegerCacheTest.java b/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/ArchivedIntegerCacheTest.java index 43d8568fac5..8bf3f9fcd27 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/ArchivedIntegerCacheTest.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/ArchivedIntegerCacheTest.java @@ -27,8 +27,9 @@ * @summary Test primitive box caches integrity in various scenarios (IntegerCache etc) * @requires vm.cds.write.archived.java.heap * @library /test/jdk/lib/testlibrary /test/lib /test/hotspot/jtreg/runtime/cds/appcds - * @compile CheckIntegerCacheApp.java + * @compile --add-exports java.base/jdk.internal.misc=ALL-UNNAMED CheckIntegerCacheApp.java ArchivedIntegerHolder.java * @run driver jdk.test.lib.helpers.ClassFileInstaller -jar boxCache.jar CheckIntegerCacheApp + * @run driver jdk.test.lib.helpers.ClassFileInstaller -jar boxCache-boot.jar ArchivedIntegerHolder * @run driver ArchivedIntegerCacheTest */ @@ -41,6 +42,19 @@ public class ArchivedIntegerCacheTest { + public static String[] mixArgs(String... args) { + String bootJar = ClassFileInstaller.getJarPath("boxCache-boot.jar"); + + String[] newArgs = new String[args.length + 5]; + newArgs[0] = "--add-exports"; + newArgs[1] = "java.base/jdk.internal.misc=ALL-UNNAMED"; + newArgs[2] = "-Xbootclasspath/a:" + bootJar; + newArgs[3] = "-XX:+IgnoreUnrecognizedVMOptions"; + newArgs[4] = "-XX:ArchiveHeapTestClass=ArchivedIntegerHolder"; + System.arraycopy(args, 0, newArgs, 5, args.length); + return newArgs; + } + public static void main(String[] args) throws Exception { String appJar = ClassFileInstaller.getJarPath("boxCache.jar"); @@ -51,15 +65,15 @@ public static void main(String[] args) throws Exception { // Dump default archive // OutputAnalyzer output = TestCommon.dump(appJar, - TestCommon.list("CheckIntegerCacheApp")); + TestCommon.list("CheckIntegerCacheApp"), + mixArgs()); TestCommon.checkDump(output); // Test case 1) // - Default options System.out.println("----------------------- Test case 1 ----------------------"); output = TestCommon.exec(appJar, - "CheckIntegerCacheApp", - "127"); + mixArgs("CheckIntegerCacheApp", "127")); TestCommon.checkExec(output); // Test case 2) @@ -67,9 +81,8 @@ public static void main(String[] args) throws Exception { // - Larger -XX:AutoBoxCacheMax System.out.println("----------------------- Test case 2 ----------------------"); output = TestCommon.exec(appJar, - "-XX:AutoBoxCacheMax=20000", - "CheckIntegerCacheApp", - "20000"); + mixArgs("-XX:AutoBoxCacheMax=20000", + "CheckIntegerCacheApp", "20000")); TestCommon.checkExec(output); // @@ -77,7 +90,7 @@ public static void main(String[] args) throws Exception { // output = TestCommon.dump(appJar, TestCommon.list("CheckIntegerCacheApp"), - "-XX:AutoBoxCacheMax=20000"); + mixArgs("-XX:AutoBoxCacheMax=20000")); TestCommon.checkDump(output); // Test case 3) @@ -85,10 +98,8 @@ public static void main(String[] args) throws Exception { // - Default options System.out.println("----------------------- Test case 3 ----------------------"); output = TestCommon.exec(appJar, - "--module-path", - moduleDir.toString(), - "CheckIntegerCacheApp", - "127"); + mixArgs("--module-path", moduleDir.toString(), + "CheckIntegerCacheApp", "127")); TestCommon.checkExec(output); @@ -97,11 +108,9 @@ public static void main(String[] args) throws Exception { // - Matching options System.out.println("----------------------- Test case 4 ----------------------"); output = TestCommon.exec(appJar, - "--module-path", - moduleDir.toString(), - "-XX:AutoBoxCacheMax=20000", - "CheckIntegerCacheApp", - "20000"); + mixArgs("--module-path", moduleDir.toString(), + "-XX:AutoBoxCacheMax=20000", + "CheckIntegerCacheApp", "20000")); TestCommon.checkExec(output); // Test case 5) @@ -109,23 +118,21 @@ public static void main(String[] args) throws Exception { // - Larger requested cache System.out.println("----------------------- Test case 5 ----------------------"); output = TestCommon.exec(appJar, - "--module-path", - moduleDir.toString(), - "-XX:AutoBoxCacheMax=30000", - "CheckIntegerCacheApp", - "30000"); + mixArgs("--module-path", moduleDir.toString(), + "-XX:AutoBoxCacheMax=30000", + "CheckIntegerCacheApp", "30000")); TestCommon.checkExec(output); // Test case 6) // - Cache is too large to archive output = TestCommon.dump(appJar, TestCommon.list("CheckIntegerCacheApp"), - "-XX:AutoBoxCacheMax=2000000", - "-Xmx1g", - "-XX:NewSize=1g", - "-Xlog:cds+heap=info", - "-Xlog:gc+region+cds", - "-Xlog:gc+region=trace"); + mixArgs("-XX:AutoBoxCacheMax=2000000", + "-Xmx1g", + "-XX:NewSize=1g", + "-Xlog:cds+heap=info", + "-Xlog:gc+region+cds", + "-Xlog:gc+region=trace")); TestCommon.checkDump(output, "Cannot archive the sub-graph referenced from [Ljava.lang.Integer; object"); } diff --git a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/x/XUtils.java b/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/ArchivedIntegerHolder.java similarity index 67% rename from src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/x/XUtils.java rename to test/hotspot/jtreg/runtime/cds/appcds/cacheObject/ArchivedIntegerHolder.java index a5c9ffde371..c8ab0db7d34 100644 --- a/src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/gc/x/XUtils.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/ArchivedIntegerHolder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright Amazon.com Inc. 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 @@ -22,19 +22,17 @@ * */ -package sun.jvm.hotspot.gc.x; +import jdk.internal.misc.CDS; -import sun.jvm.hotspot.debugger.Address; -import sun.jvm.hotspot.runtime.VM; - -class XUtils { - static Address longToAddress(long value) { - return VM.getVM().getDebugger().newAddress(value); - } - - static long alignUp(long size, long alignment) { - long mask = alignment - 1; - long adjusted = size + mask; - return adjusted & ~mask; +public class ArchivedIntegerHolder { + public static Object[] archivedObjects; + static { + CDS.initializeFromArchive(ArchivedIntegerHolder.class); + if (archivedObjects == null) { + archivedObjects = new Object[256]; + for (int i = -128; i <= 127; i++) { + archivedObjects[i + 128] = Integer.valueOf(i); + } + } } } diff --git a/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/CheckIntegerCacheApp.java b/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/CheckIntegerCacheApp.java index a1d1655b32f..7f66b2339a2 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/CheckIntegerCacheApp.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/cacheObject/CheckIntegerCacheApp.java @@ -62,6 +62,14 @@ public static void main(String[] args) throws Exception { } } + // Check that archived integer cache agrees with runtime integer cache. + for (int i = -128; i <= 127; i++) { + if (ArchivedIntegerHolder.archivedObjects[i + 128] != Integer.valueOf(i)) { + throw new RuntimeException( + "FAILED. Archived and runtime caches disagree for " + i); + } + } + int high = Integer.parseInt(args[0]); if (Integer.valueOf(high) != Integer.valueOf(high)) { throw new RuntimeException( diff --git a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/LambdaProxyCallerIsHidden.java b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/LambdaProxyCallerIsHidden.java index 583f6cf55e2..0c8cad0b3a6 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/LambdaProxyCallerIsHidden.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/LambdaProxyCallerIsHidden.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,8 @@ * jdk/test/lib/compiler/InMemoryJavaCompiler * jdk/test/lib/compiler/InMemoryJavaCompiler$FileManagerWrapper$1 * jdk/test/lib/compiler/InMemoryJavaCompiler$FileManagerWrapper - * jdk/test/lib/compiler/InMemoryJavaCompiler$MemoryJavaFileObject + * jdk/test/lib/compiler/InMemoryJavaCompiler$SourceFile + * jdk/test/lib/compiler/InMemoryJavaCompiler$ClassFile * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. LambdaProxyCallerIsHidden */ diff --git a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/RedefineCallerClassTest.java b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/RedefineCallerClassTest.java index 3d681347969..90d403bc380 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/RedefineCallerClassTest.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/RedefineCallerClassTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -52,7 +52,8 @@ public class RedefineCallerClassTest extends DynamicArchiveTestBase { "jdk/test/lib/compiler/InMemoryJavaCompiler", "jdk/test/lib/compiler/InMemoryJavaCompiler$FileManagerWrapper", "jdk/test/lib/compiler/InMemoryJavaCompiler$FileManagerWrapper$1", - "jdk/test/lib/compiler/InMemoryJavaCompiler$MemoryJavaFileObject" + "jdk/test/lib/compiler/InMemoryJavaCompiler$SourceFile", + "jdk/test/lib/compiler/InMemoryJavaCompiler$ClassFile" }; public static void main(String[] args) throws Exception { diff --git a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/RegularHiddenClass.java b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/RegularHiddenClass.java index 3ceec349f5d..957e4cb6479 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/RegularHiddenClass.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive/RegularHiddenClass.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,7 +35,8 @@ * jdk/test/lib/compiler/InMemoryJavaCompiler * jdk/test/lib/compiler/InMemoryJavaCompiler$FileManagerWrapper$1 * jdk/test/lib/compiler/InMemoryJavaCompiler$FileManagerWrapper - * jdk/test/lib/compiler/InMemoryJavaCompiler$MemoryJavaFileObject + * jdk/test/lib/compiler/InMemoryJavaCompiler$SourceFile + * jdk/test/lib/compiler/InMemoryJavaCompiler$ClassFile * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. RegularHiddenClass */ diff --git a/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/addmods/AddmodsOption.java b/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/addmods/AddmodsOption.java new file mode 100644 index 00000000000..5bab21dea13 --- /dev/null +++ b/test/hotspot/jtreg/runtime/cds/appcds/jigsaw/addmods/AddmodsOption.java @@ -0,0 +1,231 @@ +/* + * Copyright (c) 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8319343 + * @summary Test handling of the --add-modules option. + * @requires vm.cds.write.archived.java.heap + * @requires vm.flagless + * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds + * @run driver AddmodsOption + */ + +import jdk.test.lib.process.OutputAnalyzer; + +public class AddmodsOption { + public static void main(String[] args) throws Exception { + final String moduleOption = "jdk.httpserver/sun.net.httpserver.simpleserver.Main"; + final String incubatorModule = "jdk.incubator.vector"; + final String jconsoleModule = "jdk.jconsole"; + final String multiModules = ",,jdk.jconsole,jdk.compiler,,"; + final String allSystem = "ALL-SYSTEM"; + final String allModulePath = "ALL-MODULE-PATH"; + final String loggingOption = "-Xlog:cds=debug,cds+module=debug,cds+heap=info,module=trace"; + final String versionPattern = "java.[0-9][0-9][-].*"; + final String subgraphCannotBeUsed = "subgraph jdk.internal.module.ArchivedBootLayer cannot be used because full module graph is disabled"; + final String warningIncubator = "WARNING: Using incubator modules: jdk.incubator.vector"; + String archiveName = TestCommon.getNewArchiveName("addmods-option"); + TestCommon.setCurrentArchiveName(archiveName); + + // dump a base archive with --add-modules jdk.jconsole -m jdk.httpserver + OutputAnalyzer oa = TestCommon.dumpBaseArchive( + archiveName, + loggingOption, + "--add-modules", jconsoleModule, + "-m", moduleOption, + "-version"); + oa.shouldHaveExitValue(0); + + // same modules specified during runtime + oa = TestCommon.execCommon( + loggingOption, + "--add-modules", jconsoleModule, + "-m", moduleOption, + "-version"); + oa.shouldHaveExitValue(0) + // version of the jdk.httpserver module, e.g. java 22-ea + .shouldMatch(versionPattern) + .shouldMatch("cds,module.*Restored from archive: entry.0x.*name jdk.jconsole") + .shouldMatch("cds,module.*Restored from archive: entry.0x.*name jdk.httpserver"); + + // different --add-modules specified during runtime + oa = TestCommon.execCommon( + loggingOption, + "--add-modules", incubatorModule, + "-m", moduleOption, + "-version"); + oa.shouldHaveExitValue(0) + .shouldContain("Mismatched --add-modules module name(s).") + .shouldContain("dump time: jdk.jconsole runtime: jdk.incubator.vector") + .shouldContain(subgraphCannotBeUsed); + + // no module specified during runtime + oa = TestCommon.execCommon( + loggingOption, + "-version"); + oa.shouldHaveExitValue(0) + .shouldContain("Module jdk.httpserver specified during dump time but not during runtime") + .shouldContain(subgraphCannotBeUsed); + + // dump an archive without the --add-modules option + archiveName = TestCommon.getNewArchiveName("no-addmods-option"); + TestCommon.setCurrentArchiveName(archiveName); + oa = TestCommon.dumpBaseArchive( + archiveName, + loggingOption, + "-m", moduleOption, + "-version"); + oa.shouldHaveExitValue(0); + + // run with --add-modules option + oa = TestCommon.execCommon( + loggingOption, + "--add-modules", jconsoleModule, + "-m", moduleOption, + "-version"); + oa.shouldHaveExitValue(0) + .shouldContain("--add-modules module name(s) specified during runtime but not found in archive: jdk.jconsole") + // version of the jdk.httpserver module, e.g. java 22-ea + .shouldMatch(versionPattern) + .shouldContain(subgraphCannotBeUsed); + + // dump an archive with an incubator module, -add-modules jdk.incubator.vector + archiveName = TestCommon.getNewArchiveName("incubator-module"); + TestCommon.setCurrentArchiveName(archiveName); + oa = TestCommon.dumpBaseArchive( + archiveName, + loggingOption, + "--add-modules", incubatorModule, + "-m", moduleOption, + "-version"); + oa.shouldHaveExitValue(0) + // module graph won't be archived with an incubator module + .shouldContain("archivedBootLayer not available, disabling full module graph"); + + // run with the same incubator module + oa = TestCommon.execCommon( + loggingOption, + "--add-modules", incubatorModule, + "-m", moduleOption, + "-version"); + oa.shouldContain("full module graph: disabled") + // module is not restored from archive + .shouldContain("define_module(): creation of module: jdk.incubator.vector") + .shouldContain("WARNING: Using incubator modules: jdk.incubator.vector") + .shouldContain("subgraph jdk.internal.module.ArchivedBootLayer is not recorde") + .shouldHaveExitValue(0); + + // dump an archive with JVMCI option which indirectly adds the + // jdk.internal.vm.ci module using the --add-modules option + archiveName = TestCommon.getNewArchiveName("jvmci-module"); + TestCommon.setCurrentArchiveName(archiveName); + oa = TestCommon.dumpBaseArchive( + archiveName, + loggingOption, + "-XX:+UnlockExperimentalVMOptions", + "-XX:+EagerJVMCI", "-XX:+UseJVMCICompiler", + "-version"); + oa.shouldHaveExitValue(0); + + // run with the JVMCI option + oa = TestCommon.execCommon( + loggingOption, + "-XX:+UnlockExperimentalVMOptions", + "-XX:+EagerJVMCI", "-XX:+UseJVMCICompiler", + "-version"); + try { + oa.shouldHaveExitValue(0) + .shouldMatch("cds,module.*Restored from archive: entry.0x.*name jdk.internal.vm.ci"); + } catch (RuntimeException re) { + // JVMCI compile may not be available + oa.shouldHaveExitValue(1) + .shouldContain("Cannot use JVMCI compiler: No JVMCI compiler found"); + } + + // dump an archive with multiple modules in -add-modules + archiveName = TestCommon.getNewArchiveName("muti-modules"); + TestCommon.setCurrentArchiveName(archiveName); + oa = TestCommon.dumpBaseArchive( + archiveName, + loggingOption, + "--add-modules", multiModules, + "-m", moduleOption, + "-version"); + oa.shouldHaveExitValue(0); + + // run with the same multiple modules with a duplicate module in --add-modules + oa = TestCommon.execCommon( + loggingOption, + "--add-modules", multiModules, + "--add-modules", jconsoleModule, + "-m", moduleOption, + "-version"); + oa.shouldHaveExitValue(0) + .shouldMatch("cds,module.*Restored from archive: entry.0x.*name jdk.compiler") + .shouldMatch("cds,module.*Restored from archive: entry.0x.*name jdk.jconsole"); + + // dump an archive with ALL-SYSTEM in -add-modules + archiveName = TestCommon.getNewArchiveName("muti-modules"); + TestCommon.setCurrentArchiveName(archiveName); + oa = TestCommon.dumpBaseArchive( + archiveName, + loggingOption, + "--add-modules", allSystem, + "-m", moduleOption, + "-version"); + oa.shouldHaveExitValue(0) + .shouldContain(warningIncubator); + + // run with the same ALL-SYSTEM in --add-modules + oa = TestCommon.execCommon( + loggingOption, + "--add-modules", allSystem, + "-m", moduleOption, + "-version"); + oa.shouldHaveExitValue(0) + // the jdk.incubator.vector was specified indirectly via ALL-SYSTEM + .shouldContain(warningIncubator) + .shouldContain("full module graph cannot be loaded: archive was created without full module graph"); + + // dump an archive with ALL-MODULE-PATH in -add-modules + archiveName = TestCommon.getNewArchiveName("muti-modules"); + TestCommon.setCurrentArchiveName(archiveName); + oa = TestCommon.dumpBaseArchive( + archiveName, + loggingOption, + "--add-modules", allModulePath, + "-m", moduleOption, + "-version"); + oa.shouldHaveExitValue(0); + + // run with the same ALL-MODULE-PATH in --add-modules + oa = TestCommon.execCommon( + loggingOption, + "--add-modules", allModulePath, + "-m", moduleOption, + "-version"); + oa.shouldHaveExitValue(0) + .shouldMatch("cds,module.*Restored from archive: entry.0x.*name jdk.httpserver"); + } +} diff --git a/test/hotspot/jtreg/runtime/cds/appcds/loaderConstraints/DynamicLoaderConstraintsTest.java b/test/hotspot/jtreg/runtime/cds/appcds/loaderConstraints/DynamicLoaderConstraintsTest.java index 6de08da4673..004cc7bb5db 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/loaderConstraints/DynamicLoaderConstraintsTest.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/loaderConstraints/DynamicLoaderConstraintsTest.java @@ -53,9 +53,9 @@ */ /** - * @test id=custom-cl-zgc-singlegen + * @test id=custom-cl-zgc * @requires vm.cds.custom.loaders - * @requires vm.gc.ZSinglegen + * @requires vm.gc.Z * @summary Test dumptime_table entries are removed with zgc eager class unloading * @bug 8274935 * @library /test/lib @@ -69,23 +69,6 @@ * @run main/othervm/timeout=180 -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. DynamicLoaderConstraintsTest custom-zgc */ -/** - * @test id=custom-cl-zgc-generational - * @requires vm.cds.custom.loaders - * @requires vm.gc.ZGenerational - * @summary Test dumptime_table entries are removed with zgc eager class unloading - * @bug 8274935 - * @library /test/lib - * /test/hotspot/jtreg/runtime/cds/appcds - * /test/hotspot/jtreg/runtime/cds/appcds/test-classes - * /test/hotspot/jtreg/runtime/cds/appcds/dynamicArchive - * @modules java.base/jdk.internal.misc - * jdk.httpserver - * @build jdk.test.whitebox.WhiteBox - * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox - * @run main/othervm/timeout=180 -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. DynamicLoaderConstraintsTest custom-zgc-generational - */ - import com.sun.net.httpserver.HttpExchange; import com.sun.net.httpserver.HttpHandler; import jdk.test.lib.Asserts; @@ -118,12 +101,10 @@ public class DynamicLoaderConstraintsTest extends DynamicArchiveTestBase { */ static boolean useCustomLoader; static boolean useZGC; - static boolean useZGenerational; public static void main(String[] args) throws Exception { useCustomLoader = (args.length != 0); - useZGenerational = (args.length != 0 && args[0].equals("custom-zgc-generational")); - useZGC = useZGenerational || (args.length != 0 && args[0].equals("custom-zgc")); + useZGC = (args.length != 0 && args[0].equals("custom-zgc")); runTest(DynamicLoaderConstraintsTest::doTest); } @@ -150,7 +131,7 @@ static void doTest(boolean errorInDump) throws Exception { for (int i = 1; i <= 3; i++) { System.out.println("========================================"); System.out.println("errorInDump: " + errorInDump + ", useCustomLoader: " + useCustomLoader + - ", useZGC: " + useZGC + ", ZGenerational: " + useZGenerational + ", case: " + i); + ", useZGC: " + useZGC + ", case: " + i); System.out.println("========================================"); String topArchiveName = getNewArchiveName(); String testCase = Integer.toString(i); @@ -164,10 +145,9 @@ static void doTest(boolean errorInDump) throws Exception { if (useCustomLoader) { if (useZGC) { - String zGenerational = "-XX:" + (useZGenerational ? "+" : "-") + "ZGenerational"; // Add options to force eager class unloading. cmdLine = TestCommon.concat(cmdLine, "-cp", loaderJar, - "-XX:+UseZGC", zGenerational, "-XX:ZCollectionInterval=0.01", + "-XX:+UseZGC", "-XX:ZCollectionInterval=0.01", loaderMainClass, appJar); setBaseArchiveOptions("-XX:+UseZGC", "-Xlog:cds"); } else { diff --git a/test/hotspot/jtreg/runtime/cds/appcds/redefineClass/RedefineBasicTest.java b/test/hotspot/jtreg/runtime/cds/appcds/redefineClass/RedefineBasicTest.java index 81d6e20321e..acbd0c948be 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/redefineClass/RedefineBasicTest.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/redefineClass/RedefineBasicTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -47,7 +47,8 @@ public class RedefineBasicTest { "jdk/test/lib/compiler/InMemoryJavaCompiler", "jdk/test/lib/compiler/InMemoryJavaCompiler$FileManagerWrapper", "jdk/test/lib/compiler/InMemoryJavaCompiler$FileManagerWrapper$1", - "jdk/test/lib/compiler/InMemoryJavaCompiler$MemoryJavaFileObject" + "jdk/test/lib/compiler/InMemoryJavaCompiler$SourceFile", + "jdk/test/lib/compiler/InMemoryJavaCompiler$ClassFile" }; public static void main(String[] args) throws Exception { diff --git a/test/hotspot/jtreg/runtime/cds/appcds/redefineClass/RedefineRunningMethods_Shared.java b/test/hotspot/jtreg/runtime/cds/appcds/redefineClass/RedefineRunningMethods_Shared.java index d8459359604..039aaef11cd 100644 --- a/test/hotspot/jtreg/runtime/cds/appcds/redefineClass/RedefineRunningMethods_Shared.java +++ b/test/hotspot/jtreg/runtime/cds/appcds/redefineClass/RedefineRunningMethods_Shared.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -48,7 +48,8 @@ public class RedefineRunningMethods_Shared { "jdk/test/lib/compiler/InMemoryJavaCompiler", "jdk/test/lib/compiler/InMemoryJavaCompiler$FileManagerWrapper", "jdk/test/lib/compiler/InMemoryJavaCompiler$FileManagerWrapper$1", - "jdk/test/lib/compiler/InMemoryJavaCompiler$MemoryJavaFileObject" + "jdk/test/lib/compiler/InMemoryJavaCompiler$SourceFile", + "jdk/test/lib/compiler/InMemoryJavaCompiler$ClassFile" }; public static void main(String[] args) throws Exception { diff --git a/test/hotspot/jtreg/serviceability/attach/AttachAPIv2/CompatTest.java b/test/hotspot/jtreg/serviceability/attach/AttachAPIv2/CompatTest.java new file mode 100644 index 00000000000..444b87bb6ea --- /dev/null +++ b/test/hotspot/jtreg/serviceability/attach/AttachAPIv2/CompatTest.java @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @summary Basic compatibility test for Attach API v2 + * @bug 8219896 + * @library /test/lib + * @modules jdk.attach/sun.tools.attach + * + * @run main/othervm -Xlog:attach=trace CompatTest + * @run main/othervm -Xlog:attach=trace -Djdk.attach.compat=true CompatTest + */ + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.io.IOException; + +import com.sun.tools.attach.VirtualMachine; +import sun.tools.attach.HotSpotVirtualMachine; + +import jdk.test.lib.apps.LingeredApp; + +public class CompatTest { + + public static void main(String[] args) throws Exception { + // if the test (client part) in the "compat" mode + boolean clientCompat = "true".equals(System.getProperty("jdk.attach.compat")); + System.out.println("Client is in compat mode: " + clientCompat); + LingeredApp app = null; + try { + app = LingeredApp.startApp("-Xlog:attach=trace"); + test(app, clientCompat); + } finally { + LingeredApp.stopApp(app); + } + + try { + app = LingeredApp.startApp("-Xlog:attach=trace", "-Djdk.attach.compat=true"); + // target VM in "compat" mode, always expect failure + test(app, true); + } finally { + LingeredApp.stopApp(app); + } + + } + + // The test uses HotSpotVirtualMachine.setFlag method with long flag value. + // For attach API v1 an exception is expected to be thrown (argument cannot be longer than 1024 characters). + private static String flagName = "HeapDumpPath"; + // long for v1 + private static String flagValue = "X" + "A".repeat(1024) + "X"; + + private static void test(LingeredApp app, boolean expectFailure) throws Exception { + System.out.println("======== Start ========"); + + HotSpotVirtualMachine vm = (HotSpotVirtualMachine)VirtualMachine.attach(String.valueOf(app.getPid())); + + BufferedReader replyReader = null; + try { + replyReader = new BufferedReader(new InputStreamReader( + vm.setFlag(flagName, flagValue))); + + if (expectFailure) { + throw new RuntimeException("No expected exception is thrown"); + } + + String line; + while ((line = replyReader.readLine()) != null) { + System.out.println("setFlag reply: " + line); + } + replyReader.close(); + + } catch (IOException ex) { + System.out.println("OK: setFlag thrown expected exception:"); + ex.printStackTrace(System.out); + } finally { + vm.detach(); + } + + System.out.println("======== End ========"); + System.out.println(); + } +} diff --git a/test/hotspot/jtreg/serviceability/dcmd/gc/HeapDumpCompressedTest.java b/test/hotspot/jtreg/serviceability/dcmd/gc/HeapDumpCompressedTest.java index 1e6d99a5048..3a960cc8c7d 100644 --- a/test/hotspot/jtreg/serviceability/dcmd/gc/HeapDumpCompressedTest.java +++ b/test/hotspot/jtreg/serviceability/dcmd/gc/HeapDumpCompressedTest.java @@ -71,27 +71,15 @@ */ /* - * @test id=ZSinglegen - * @requires vm.gc.ZSinglegen + * @test id=Z + * @requires vm.gc.Z * @summary Test of diagnostic command GC.heap_dump with gzipped output (Z GC) * @library /test/lib * @modules java.base/jdk.internal.misc * java.compiler * java.management * jdk.internal.jvmstat/sun.jvmstat.monitor - * @run main/othervm -XX:+UseZGC -XX:-ZGenerational HeapDumpCompressedTest - */ - -/* - * @test id=ZGenerational - * @requires vm.gc.ZGenerational - * @summary Test of diagnostic command GC.heap_dump with gzipped output (Z GC) - * @library /test/lib - * @modules java.base/jdk.internal.misc - * java.compiler - * java.management - * jdk.internal.jvmstat/sun.jvmstat.monitor - * @run main/othervm -XX:+UseZGC -XX:+ZGenerational HeapDumpCompressedTest + * @run main/othervm -XX:+UseZGC HeapDumpCompressedTest */ /* diff --git a/test/hotspot/jtreg/serviceability/jvmti/thread/GetFrameCount/framecnt01/framecnt01.java b/test/hotspot/jtreg/serviceability/jvmti/thread/GetFrameCount/framecnt01/framecnt01.java index 8a7177ec25d..221363f5621 100644 --- a/test/hotspot/jtreg/serviceability/jvmti/thread/GetFrameCount/framecnt01/framecnt01.java +++ b/test/hotspot/jtreg/serviceability/jvmti/thread/GetFrameCount/framecnt01/framecnt01.java @@ -79,7 +79,7 @@ public static void main(String args[]) throws Exception { } // this is too fragile, implementation can change at any time. - checkFrames(vThread1, false, 13); + checkFrames(vThread1, false, 11); LockSupport.unpark(vThread1); vThread1.join(); diff --git a/test/hotspot/jtreg/gc/x/TestDeprecated.java b/test/hotspot/jtreg/serviceability/jvmti/vthread/CheckHiddenFrames/CheckHiddenFrames.java similarity index 58% rename from test/hotspot/jtreg/gc/x/TestDeprecated.java rename to test/hotspot/jtreg/serviceability/jvmti/vthread/CheckHiddenFrames/CheckHiddenFrames.java index 39b0318d52b..1b6d409e30b 100644 --- a/test/hotspot/jtreg/gc/x/TestDeprecated.java +++ b/test/hotspot/jtreg/serviceability/jvmti/vthread/CheckHiddenFrames/CheckHiddenFrames.java @@ -21,30 +21,36 @@ * questions. */ -package gc.x; - /* - * @test TestDeprecated - * @requires vm.gc.ZSinglegen - * @summary Test ZGenerational Deprecated - * @library /test/lib - * @run driver gc.x.TestDeprecated + * @test + * @bug 8341273 + * @summary Verifies JVMTI properly hides frames which are in VTMS transition + * @run main/othervm/native -agentlib:CheckHiddenFrames CheckHiddenFrames */ -import java.util.LinkedList; -import jdk.test.lib.process.ProcessTools; +public class CheckHiddenFrames { + static native boolean checkHidden(Thread t); -public class TestDeprecated { - static class Test { - public static void main(String[] args) throws Exception {} + static void sleep(long millis) { + try { + Thread.sleep(millis); + } catch (InterruptedException e) { + } } + public static void main(String[] args) throws Exception { - ProcessTools.executeLimitedTestJava("-XX:+UseZGC", - "-XX:-ZGenerational", - "-Xlog:gc+init", - Test.class.getName()) - .shouldContain("Option ZGenerational was deprecated") - .shouldContain("Using deprecated non-generational mode") - .shouldHaveExitValue(0); + Thread thread = Thread.startVirtualThread(CheckHiddenFrames::test); + System.out.println("Started virtual thread: " + thread); + + if (!checkHidden(thread)) { + thread.interrupt(); + throw new RuntimeException("CheckHiddenFrames failed!"); + } + thread.interrupt(); + thread.join(); + } + + static void test() { + sleep(1000000); } } diff --git a/test/hotspot/jtreg/serviceability/jvmti/vthread/CheckHiddenFrames/libCheckHiddenFrames.cpp b/test/hotspot/jtreg/serviceability/jvmti/vthread/CheckHiddenFrames/libCheckHiddenFrames.cpp new file mode 100644 index 00000000000..50f930b5731 --- /dev/null +++ b/test/hotspot/jtreg/serviceability/jvmti/vthread/CheckHiddenFrames/libCheckHiddenFrames.cpp @@ -0,0 +1,123 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +#include +#include "jvmti.h" +#include "jvmti_common.hpp" + +extern "C" { + +const int MAX_COUNT = 50; +static jvmtiEnv *jvmti = nullptr; + +static char* +get_frame_method_name(jvmtiEnv *jvmti, JNIEnv* jni, jthread thread, jint depth) { + jmethodID method = nullptr; + jlocation location = 0; + + jvmtiError err = jvmti->GetFrameLocation(thread, 0, &method, &location); + check_jvmti_status(jni, err, "get_method_name_at_depth: error in JVMTI GetFrameLocation"); + + return get_method_name(jvmti, jni, method); +} + +static bool +method_must_be_hidden(char* mname) { + return strcmp(mname, "yield") == 0 || + strcmp(mname, "yield0") == 0; +} + +static jboolean +check_top_frames_location(jvmtiEnv *jvmti, JNIEnv* jni, jthread thread) { + jboolean status = JNI_TRUE; + + for (int depth = 0; depth < 2; depth++) { + char* mname = get_frame_method_name(jvmti, jni, thread, depth); + + if (method_must_be_hidden(mname)) { + LOG("Failed: GetFrameLocation returned info for frame expected to be hidden: frame[%d]=%s\n", depth, mname); + status = JNI_FALSE; + } + deallocate(jvmti, jni, mname); + } + return status; +} + +static jboolean +check_top_frames_in_stack_trace(jvmtiEnv *jvmti, JNIEnv* jni, jthread thread) { + jboolean status = JNI_TRUE; + jvmtiFrameInfo frameInfo[MAX_COUNT]; + jint count1 = 0; + jint count2 = 0; + + jvmtiError err = jvmti->GetStackTrace(thread, 0, MAX_COUNT, frameInfo, &count1); + check_jvmti_status(jni, err, "check_top_frames_in_stack_trace: error in JVMTI GetStackTrace"); + + for (int depth = 0; depth < 2; depth++) { + char* mname = get_method_name(jvmti, jni, frameInfo[depth].method); + + if (method_must_be_hidden(mname)) { + LOG("Failed: GetStackTrace returned info for frame expected to be hidden: frame[%d]=%s\n", depth, mname); + status = JNI_FALSE; + } + deallocate(jvmti, jni, mname); + } + + err = jvmti->GetFrameCount(thread, &count2); + check_jvmti_status(jni, err, "check_top_frames_in_stack_trace: error in JVMTI GetFrameCount"); + + if (count1 != count2) { + LOG("Failed: frame counts returned by GetStackTrace and GetFrameCount do not match: %d!=%d\n", count1, count2); + status = JNI_FALSE; + } + return status; +} + +JNIEXPORT jboolean JNICALL +Java_CheckHiddenFrames_checkHidden(JNIEnv *jni, jclass clazz, jthread thread) { + jboolean status = JNI_TRUE; + + wait_for_state(jvmti, jni, thread, JVMTI_THREAD_STATE_WAITING_WITH_TIMEOUT); + print_stack_trace(jvmti, jni, thread); + + + if (!check_top_frames_location(jvmti, jni, thread)) { + status = JNI_FALSE; + } + if (!check_top_frames_in_stack_trace(jvmti, jni, thread)) { + status = JNI_FALSE; + } + return status; +} + +extern JNIEXPORT jint JNICALL +Agent_OnLoad(JavaVM *jvm, char *options, void *reserved) { + LOG("Agent_OnLoad started\n"); + if (jvm->GetEnv((void **)(&jvmti), JVMTI_VERSION) != JNI_OK) { + return JNI_ERR; + } + LOG("Agent_OnLoad finished\n"); + return JNI_OK; +} + +} // extern "C" diff --git a/test/hotspot/jtreg/testlibrary_tests/ir_framework/examples/GCBarrierIRExample.java b/test/hotspot/jtreg/testlibrary_tests/ir_framework/examples/GCBarrierIRExample.java index e0287fc39fe..11db83a1b31 100644 --- a/test/hotspot/jtreg/testlibrary_tests/ir_framework/examples/GCBarrierIRExample.java +++ b/test/hotspot/jtreg/testlibrary_tests/ir_framework/examples/GCBarrierIRExample.java @@ -33,7 +33,7 @@ * @summary Example test that illustrates the use of the IR test framework for * verification of late-expanded GC barriers. * @library /test/lib / - * @requires vm.gc.ZGenerational + * @requires vm.gc.Z * @run driver ir_framework.examples.GCBarrierIRExample */ @@ -61,7 +61,7 @@ public static void main(String[] args) { // emission, such as ZGC. Because the collector selection flags are not // whitelisted (see IR framework's README.md file), the user (as opposed // to jtreg) needs to set these flags here. - TestFramework.runWithFlags("-XX:+UseZGC", "-XX:+ZGenerational"); + TestFramework.runWithFlags("-XX:+UseZGC"); } @Test diff --git a/test/hotspot/jtreg/vmTestbase/gc/g1/unloading/bytecode/BytecodeGeneratorFactory.java b/test/hotspot/jtreg/vmTestbase/gc/g1/unloading/bytecode/BytecodeGeneratorFactory.java index cad856f553e..73f74794394 100644 --- a/test/hotspot/jtreg/vmTestbase/gc/g1/unloading/bytecode/BytecodeGeneratorFactory.java +++ b/test/hotspot/jtreg/vmTestbase/gc/g1/unloading/bytecode/BytecodeGeneratorFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,7 @@ import java.util.Map; import java.util.Random; -import vm.share.InMemoryJavaCompiler; +import jdk.test.lib.compiler.InMemoryJavaCompiler; /** * BytecodeFactory that employs in memory compilation. @@ -44,12 +44,10 @@ public BytecodeGeneratorFactory(long seed) { @Override public Bytecode createBytecode(String className) { - Map sources = new HashMap(); - sources.put(className, sourceGenerator.generateSource(className, + byte[] bytecode = InMemoryJavaCompiler.compile(className, sourceGenerator.generateSource(className, "public static void main() { System.out.println(\"From main method in in-mem-compiled code " + random.nextGaussian() + " + str_bytesToReplace0 str_bytesToReplace1\"); }\n " + "public static int methodForCompilation(Object object) { int i = object.hashCode(); i = i * 2000 / 1994 + 153; return i; }\n")); - byte[] bytecode = InMemoryJavaCompiler.compile(sources).values().iterator().next(); return new Bytecode(className, bytecode); } diff --git a/test/hotspot/jtreg/vmTestbase/metaspace/staticReferences/StaticReferences.java b/test/hotspot/jtreg/vmTestbase/metaspace/staticReferences/StaticReferences.java index ce0dd65c7ee..7ea901abe06 100644 --- a/test/hotspot/jtreg/vmTestbase/metaspace/staticReferences/StaticReferences.java +++ b/test/hotspot/jtreg/vmTestbase/metaspace/staticReferences/StaticReferences.java @@ -60,7 +60,7 @@ import nsk.share.test.Stresser; import nsk.share.test.TestBase; import nsk.share.test.Tests; -import vm.share.InMemoryJavaCompiler; +import jdk.test.lib.compiler.InMemoryJavaCompiler; /** * Test checks that static fields will be initialized in new loaded class. Test performs in loop the following routine: @@ -210,9 +210,7 @@ private void checkStaticFields(Class clazz) { } private byte[] generateAndCompile(int[] fieldQuantities) { - Map sources = new HashMap(); - sources.put("A", generateSource(fieldQuantities)); - return InMemoryJavaCompiler.compile(sources).values().iterator().next(); + return InMemoryJavaCompiler.compile("A", generateSource(fieldQuantities)); } private StringBuffer generateSource(int[] fieldQuantities) { diff --git a/test/hotspot/jtreg/vmTestbase/metaspace/stressDictionary/StressDictionary.java b/test/hotspot/jtreg/vmTestbase/metaspace/stressDictionary/StressDictionary.java index b4c44a9a059..0db2d24fa8f 100644 --- a/test/hotspot/jtreg/vmTestbase/metaspace/stressDictionary/StressDictionary.java +++ b/test/hotspot/jtreg/vmTestbase/metaspace/stressDictionary/StressDictionary.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -43,7 +43,7 @@ import nsk.share.gc.GCTestBase; import nsk.share.test.*; -import vm.share.InMemoryJavaCompiler; +import jdk.test.lib.compiler.InMemoryJavaCompiler; /** * There is a data structure named "dictionary" in class BlockFreelist. It stores @@ -178,10 +178,8 @@ public void run() { } private byte[] generateAndCompile() { - Map sources = new HashMap(); String className = "MyClass" + classesCounter.incrementAndGet(); - sources.put(className, generateSource(className)); - return InMemoryJavaCompiler.compile(sources).values().iterator().next(); + return InMemoryJavaCompiler.compile(className, generateSource(className)); } private CharSequence generateSource(String className) { diff --git a/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/common/generateHierarchy/GenerateHierarchyHelper.java b/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/common/generateHierarchy/GenerateHierarchyHelper.java index daccf644393..be6f1ebe85f 100644 --- a/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/common/generateHierarchy/GenerateHierarchyHelper.java +++ b/test/hotspot/jtreg/vmTestbase/metaspace/stressHierarchy/common/generateHierarchy/GenerateHierarchyHelper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ import java.util.*; -import vm.share.InMemoryJavaCompiler; +import jdk.test.lib.compiler.InMemoryJavaCompiler; import jdk.test.lib.Utils; public class GenerateHierarchyHelper { diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/StressRedefine.java b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/StressRedefine.java index 1192de03f88..d581cd5693b 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/StressRedefine.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/RedefineClasses/StressRedefine.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,7 +21,6 @@ * questions. */ -//package nsk.jvmti.RedefineClasses.StressRedefine; package nsk.jvmti.RedefineClasses; @@ -41,7 +40,7 @@ import nsk.share.test.Stresser; import nsk.share.test.Tests; -import vm.share.InMemoryJavaCompiler; +import jdk.test.lib.compiler.InMemoryJavaCompiler; /** * There is a data structure named "dictionary" in class BlockFreelist. It stores @@ -203,9 +202,7 @@ private static ThreadFactory virtualThreadFactory() { } private static byte[] generateAndCompile() { - Map sources = new HashMap(); - sources.put(GenerateSourceHelper.CLASS_NAME, GenerateSourceHelper.generateSource()); - return InMemoryJavaCompiler.compile(sources).values().iterator().next(); + return InMemoryJavaCompiler.compile(GenerateSourceHelper.CLASS_NAME, GenerateSourceHelper.generateSource()); } // Auxiliary classloader. Used only once at the beginning. diff --git a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP05/sp05t003/TestDescription.java b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP05/sp05t003/TestDescription.java index ecb2cfc59e5..1c8ca451c8e 100644 --- a/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP05/sp05t003/TestDescription.java +++ b/test/hotspot/jtreg/vmTestbase/nsk/jvmti/scenarios/sampling/SP05/sp05t003/TestDescription.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -50,7 +50,7 @@ * @library /vmTestbase * /test/lib * @run main/othervm/native - * -agentlib:sp05t003=-waittime=5 + * -agentlib:sp05t003=-waittime=5,-verbose * nsk.jvmti.scenarios.sampling.SP05.sp05t003 */ diff --git a/test/hotspot/jtreg/vmTestbase/vm/share/InMemoryJavaCompiler.java b/test/hotspot/jtreg/vmTestbase/vm/share/InMemoryJavaCompiler.java deleted file mode 100644 index 6f5f1c0cbcd..00000000000 --- a/test/hotspot/jtreg/vmTestbase/vm/share/InMemoryJavaCompiler.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright (c) 2013, 2018, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package vm.share; - -import javax.tools.FileObject; -import javax.tools.ForwardingJavaFileManager; -import javax.tools.JavaCompiler; -import javax.tools.JavaFileManager; -import javax.tools.JavaFileObject; -import javax.tools.SimpleJavaFileObject; -import javax.tools.ToolProvider; -import java.io.ByteArrayOutputStream; -import java.io.StringWriter; -import java.io.Writer; -import java.net.URI; -import java.util.Collection; -import java.util.HashMap; -import java.util.LinkedList; -import java.util.Map; -import java.util.Map.Entry; - - -public class InMemoryJavaCompiler { - - public static Map compile(Map inputMap) { - Collection sourceFiles = new LinkedList(); - for (Entry entry : inputMap.entrySet()) { - sourceFiles.add(new SourceFile(entry.getKey(), entry.getValue())); - } - - JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); - FileManager fileManager = new FileManager(compiler.getStandardFileManager(null, null, null)); - - Writer writer = new StringWriter(); - Boolean exitCode = compiler.getTask(writer, fileManager, null, null, null, sourceFiles).call(); - if (!exitCode) { - System.out.println("*********** javac output begin ***********"); - System.out.println(writer.toString()); - System.out.println("*********** javac output end ***********"); - if (writer.toString().contains("java.lang.OutOfMemoryError")) { - System.out.println("Got OOME while performing in memory compilation. It happens on weak hosts and there is nothing we can do. "); - throw new OutOfMemoryError("Got OOME while performing in memory compilation."); - } - throw new RuntimeException("Test bug: in memory compilation failed."); - } - return fileManager.getByteCode(); - } - - // Wraper for class file - static class ClassFile extends SimpleJavaFileObject { - - private final ByteArrayOutputStream baos = new ByteArrayOutputStream(); - - protected ClassFile(String name) { - super(URI.create("memo:///" + name.replace('.', '/') + Kind.CLASS.extension), Kind.CLASS); - } - - @Override - public ByteArrayOutputStream openOutputStream() { return this.baos; } - - byte[] toByteArray() { return baos.toByteArray(); } - } - - // File manager which spawns ClassFile instances by demand - static class FileManager extends ForwardingJavaFileManager { - - private Map classesMap = new HashMap(); - - protected FileManager(JavaFileManager fileManager) { - super(fileManager); - } - - @Override - public ClassFile getJavaFileForOutput(Location location, String name, JavaFileObject.Kind kind, FileObject source) { - ClassFile classFile = new ClassFile(name); - classesMap.put(name, classFile); - return classFile; - } - - public Map getByteCode() { - Map result = new HashMap(); - for (Entry entry : classesMap.entrySet()) { - result.put(entry.getKey(), entry.getValue().toByteArray()); - } - return result; - } - } - - // Wrapper for source file - static class SourceFile extends SimpleJavaFileObject { - - private CharSequence sourceCode; - - public SourceFile(String name, CharSequence sourceCode) { - super(URI.create("memo:///" + name.replace('.', '/') + Kind.SOURCE.extension), Kind.SOURCE); - this.sourceCode = sourceCode; - } - - @Override - public CharSequence getCharContent(boolean ignore) { - return this.sourceCode; - } - } - -} diff --git a/test/jdk/ProblemList-generational-zgc.txt b/test/jdk/ProblemList-generational-zgc.txt deleted file mode 100644 index 9fa9874d20c..00000000000 --- a/test/jdk/ProblemList-generational-zgc.txt +++ /dev/null @@ -1,40 +0,0 @@ -# -# Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -############################################################################# -# -# List of quarantined tests for testing with Generational ZGC. -# -############################################################################# - -# Quiet all SA tests - -sun/tools/jhsdb/HeapDumpTest.java 8307393 generic-all -sun/tools/jhsdb/BasicLauncherTest.java 8307393 generic-all -sun/tools/jhsdb/JStackStressTest.java 8307393 generic-all -sun/tools/jhsdb/JShellHeapDumpTest.java 8307393 generic-all -sun/tools/jhsdb/SAGetoptTest.java 8307393 generic-all -sun/tools/jhsdb/heapconfig/JMapHeapConfigTest.java 8307393 generic-all -sun/tools/jhsdb/HeapDumpTestWithActiveProcess.java 8307393 generic-all - -com/sun/jdi/ThreadMemoryLeakTest.java 8307402 generic-all diff --git a/test/jdk/ProblemList-zgc.txt b/test/jdk/ProblemList-zgc.txt index 9fae070e25d..e81ac813747 100644 --- a/test/jdk/ProblemList-zgc.txt +++ b/test/jdk/ProblemList-zgc.txt @@ -27,5 +27,14 @@ # ############################################################################# -sun/tools/jhsdb/JShellHeapDumpTest.java 8276539 generic-all -sun/tools/jhsdb/HeapDumpTestWithActiveProcess.java 8276539 generic-all +# Quiet all SA tests + +sun/tools/jhsdb/HeapDumpTest.java 8307393 generic-all +sun/tools/jhsdb/BasicLauncherTest.java 8307393 generic-all +sun/tools/jhsdb/JStackStressTest.java 8307393 generic-all +sun/tools/jhsdb/JShellHeapDumpTest.java 8307393 generic-all +sun/tools/jhsdb/SAGetoptTest.java 8307393 generic-all +sun/tools/jhsdb/heapconfig/JMapHeapConfigTest.java 8307393 generic-all +sun/tools/jhsdb/HeapDumpTestWithActiveProcess.java 8307393 generic-all + +com/sun/jdi/ThreadMemoryLeakTest.java 8307402 generic-all diff --git a/test/jdk/ProblemList.txt b/test/jdk/ProblemList.txt index e015ad18320..b37787b5f7e 100644 --- a/test/jdk/ProblemList.txt +++ b/test/jdk/ProblemList.txt @@ -531,6 +531,7 @@ java/lang/instrument/RetransformBigClass.sh 8065756 generic- # jdk_io java/io/pathNames/GeneralWin32.java 8180264 windows-all +java/io/IO/IO.java 8337935 linux-ppc64le ############################################################################ @@ -723,9 +724,6 @@ javax/swing/JMenuItem/ActionListenerCalledTwice/ActionListenerCalledTwiceTest.ja # core_tools -tools/jar/ExtractFilesTest.java 8342930 generic-all -tools/jar/MultipleManifestTest.java 8342930 generic-all - ############################################################################ diff --git a/test/jdk/TEST.ROOT b/test/jdk/TEST.ROOT index c8db6b89a71..6276932afbd 100644 --- a/test/jdk/TEST.ROOT +++ b/test/jdk/TEST.ROOT @@ -84,8 +84,6 @@ requires.properties= \ vm.gc.Shenandoah \ vm.gc.Epsilon \ vm.gc.Z \ - vm.gc.ZGenerational \ - vm.gc.ZSinglegen \ vm.graal.enabled \ vm.compiler1.enabled \ vm.compiler2.enabled \ diff --git a/test/jdk/com/sun/crypto/provider/CICO/CICODESFuncTest.java b/test/jdk/com/sun/crypto/provider/CICO/CICODESFuncTest.java index 3164294ecca..440914826bc 100644 --- a/test/jdk/com/sun/crypto/provider/CICO/CICODESFuncTest.java +++ b/test/jdk/com/sun/crypto/provider/CICO/CICODESFuncTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -66,7 +66,8 @@ public class CICODESFuncTest { private static final int IV_LENGTH = 8; public static void main(String[] args) throws Exception { - Provider provider = Security.getProvider("SunJCE"); + Provider provider = Security.getProvider( + System.getProperty("test.provider.name", "SunJCE")); if (provider == null) { throw new RuntimeException("SunJCE provider does not exist."); } diff --git a/test/jdk/com/sun/crypto/provider/CICO/CICOSkipTest.java b/test/jdk/com/sun/crypto/provider/CICO/CICOSkipTest.java index 0641845d7f9..6ccf4c1eedf 100644 --- a/test/jdk/com/sun/crypto/provider/CICO/CICOSkipTest.java +++ b/test/jdk/com/sun/crypto/provider/CICO/CICOSkipTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -204,9 +204,10 @@ private void initCiphers(String algo, SecretKey key, AlgorithmParameterSpec aps) throws NoSuchAlgorithmException, NoSuchPaddingException, InvalidKeyException, InvalidAlgorithmParameterException { - Provider provider = Security.getProvider("SunJCE"); + String providerName = System.getProperty("test.provider.name", "SunJCE"); + Provider provider = Security.getProvider(providerName); if (provider == null) { - throw new RuntimeException("SunJCE provider does not exist."); + throw new RuntimeException(providerName + " provider does not exist."); } Cipher ci1 = Cipher.getInstance(algo, provider); ci1.init(Cipher.ENCRYPT_MODE, key, aps); diff --git a/test/jdk/com/sun/crypto/provider/CICO/PBEFunc/AESPBEWrapper.java b/test/jdk/com/sun/crypto/provider/CICO/PBEFunc/AESPBEWrapper.java index e6e5c2faa01..3dd15d50058 100644 --- a/test/jdk/com/sun/crypto/provider/CICO/PBEFunc/AESPBEWrapper.java +++ b/test/jdk/com/sun/crypto/provider/CICO/PBEFunc/AESPBEWrapper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -69,9 +69,10 @@ public AESPBEWrapper(PBEAlgorithm algo, String passwd) */ @Override protected Cipher initCipher(int mode) throws GeneralSecurityException { - Provider provider = Security.getProvider("SunJCE"); + String providerName = System.getProperty("test.provider.name", "SunJCE"); + Provider provider = Security.getProvider(providerName); if (provider == null) { - throw new RuntimeException("SunJCE provider does not exist."); + throw new RuntimeException(providerName + ": provider does not exist."); } // get Cipher instance Cipher ci = Cipher.getInstance(transformation, provider); diff --git a/test/jdk/com/sun/crypto/provider/CICO/PBEFunc/DefaultPBEWrapper.java b/test/jdk/com/sun/crypto/provider/CICO/PBEFunc/DefaultPBEWrapper.java index f68fd85146b..cde094e1f90 100644 --- a/test/jdk/com/sun/crypto/provider/CICO/PBEFunc/DefaultPBEWrapper.java +++ b/test/jdk/com/sun/crypto/provider/CICO/PBEFunc/DefaultPBEWrapper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -58,9 +58,10 @@ public DefaultPBEWrapper(PBEAlgorithm algo, String passwd) { */ @Override protected Cipher initCipher(int mode) throws GeneralSecurityException { - Provider provider = Security.getProvider("SunJCE"); + String providerName = System.getProperty("test.provider.name", "SunJCE"); + Provider provider = Security.getProvider(providerName); if (provider == null) { - throw new RuntimeException("SunJCE provider does not exist."); + throw new RuntimeException(providerName + ": provider does not exist."); } SecretKey key = SecretKeyFactory.getInstance(baseAlgo) .generateSecret(new PBEKeySpec(password.toCharArray())); diff --git a/test/jdk/com/sun/crypto/provider/CICO/PBEFunc/PBKDF2Wrapper.java b/test/jdk/com/sun/crypto/provider/CICO/PBEFunc/PBKDF2Wrapper.java index fb2d0ac901f..ac7580990f0 100644 --- a/test/jdk/com/sun/crypto/provider/CICO/PBEFunc/PBKDF2Wrapper.java +++ b/test/jdk/com/sun/crypto/provider/CICO/PBEFunc/PBKDF2Wrapper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -89,9 +89,10 @@ public PBKDF2Wrapper(PBEAlgorithm algo, String passwd) */ @Override protected Cipher initCipher(int mode) throws GeneralSecurityException { - Provider provider = Security.getProvider("SunJCE"); + String providerName = System.getProperty("test.provider.name", "SunJCE"); + Provider provider = Security.getProvider(providerName); if (provider == null) { - throw new RuntimeException("SunJCE provider does not exist."); + throw new RuntimeException(providerName + ": provider does not exist."); } // Generate secret key PBEKeySpec pbeKeySpec = new PBEKeySpec(password.toCharArray(), diff --git a/test/jdk/com/sun/crypto/provider/Cipher/AEAD/Encrypt.java b/test/jdk/com/sun/crypto/provider/Cipher/AEAD/Encrypt.java index 58267c2ffba..78b69c2ea95 100644 --- a/test/jdk/com/sun/crypto/provider/Cipher/AEAD/Encrypt.java +++ b/test/jdk/com/sun/crypto/provider/Cipher/AEAD/Encrypt.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -122,7 +122,8 @@ public Encrypt(Provider provider, String algorithm, String mode, } public static void main(String[] args) throws Exception { - Provider p = Security.getProvider("SunJCE"); + Provider p = Security.getProvider( + System.getProperty("test.provider.name", "SunJCE")); for (String alg : ALGORITHMS) { for (int keyStrength : KEY_STRENGTHS) { if (keyStrength > Cipher.getMaxAllowedKeyLength(alg)) { diff --git a/test/jdk/com/sun/crypto/provider/Cipher/AEAD/GCMLargeDataKAT.java b/test/jdk/com/sun/crypto/provider/Cipher/AEAD/GCMLargeDataKAT.java index 11efb2d0611..885b5998aa4 100644 --- a/test/jdk/com/sun/crypto/provider/Cipher/AEAD/GCMLargeDataKAT.java +++ b/test/jdk/com/sun/crypto/provider/Cipher/AEAD/GCMLargeDataKAT.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -102,7 +102,8 @@ public class GCMLargeDataKAT { byte[] encrypt(int inLen) { try { - cipher = Cipher.getInstance("AES/GCM/NoPadding", "SunJCE"); + cipher = Cipher.getInstance("AES/GCM/NoPadding", + System.getProperty("test.provider.name", "SunJCE")); cipher.init(Cipher.ENCRYPT_MODE, key, spec); return cipher.doFinal(plaintext, 0, inLen); } catch (Exception e) { @@ -125,7 +126,8 @@ boolean decrypt(byte[] data) { return false; } try { - cipher = Cipher.getInstance("AES/GCM/NoPadding", "SunJCE"); + cipher = Cipher.getInstance("AES/GCM/NoPadding", + System.getProperty("test.provider.name", "SunJCE")); cipher.init(Cipher.DECRYPT_MODE, key, spec); result = cipher.doFinal(data); } catch (Exception e) { diff --git a/test/jdk/com/sun/crypto/provider/Cipher/AEAD/GCMParameterSpecTest.java b/test/jdk/com/sun/crypto/provider/Cipher/AEAD/GCMParameterSpecTest.java index 7250c4d7f0f..f65a8eed2b9 100644 --- a/test/jdk/com/sun/crypto/provider/Cipher/AEAD/GCMParameterSpecTest.java +++ b/test/jdk/com/sun/crypto/provider/Cipher/AEAD/GCMParameterSpecTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -87,7 +87,8 @@ public GCMParameterSpecTest(int keyLength, int tagLength, int IVlength, AAD = Helper.generateBytes(AADLength); // init a secret key - KeyGenerator kg = KeyGenerator.getInstance("AES", "SunJCE"); + KeyGenerator kg = KeyGenerator.getInstance("AES", + System.getProperty("test.provider.name", "SunJCE")); kg.init(keyLength); key = kg.generateKey(); } @@ -211,7 +212,8 @@ private byte[] recoverCipherText(byte[] cipherText, GCMParameterSpec spec) private Cipher createCipher(int mode, GCMParameterSpec spec) throws Exception { - Cipher cipher = Cipher.getInstance(TRANSFORMATION, "SunJCE"); + Cipher cipher = Cipher.getInstance(TRANSFORMATION, + System.getProperty("test.provider.name", "SunJCE")); cipher.init(mode, key, spec); return cipher; } diff --git a/test/jdk/com/sun/crypto/provider/Cipher/AEAD/KeyWrapper.java b/test/jdk/com/sun/crypto/provider/Cipher/AEAD/KeyWrapper.java index 21f1deec45b..c1a0ae2dfd0 100644 --- a/test/jdk/com/sun/crypto/provider/Cipher/AEAD/KeyWrapper.java +++ b/test/jdk/com/sun/crypto/provider/Cipher/AEAD/KeyWrapper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,7 @@ public class KeyWrapper { static final String AES = "AES"; static final String TRANSFORMATION = "AES/GCM/NoPadding"; - static final String PROVIDER = "SunJCE"; + static final String PROVIDER = System.getProperty("test.provider.name", "SunJCE"); static final int KEY_LENGTH = 128; public static void main(String argv[]) throws Exception { diff --git a/test/jdk/com/sun/crypto/provider/Cipher/AEAD/ReadWriteSkip.java b/test/jdk/com/sun/crypto/provider/Cipher/AEAD/ReadWriteSkip.java index f6bd3805ae4..fd7df41c91a 100644 --- a/test/jdk/com/sun/crypto/provider/Cipher/AEAD/ReadWriteSkip.java +++ b/test/jdk/com/sun/crypto/provider/Cipher/AEAD/ReadWriteSkip.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -50,7 +50,7 @@ static enum BufferType { static final int BLOCK = 50; static final int SAVE = 45; static final int DISCARD = BLOCK - SAVE; - static final String PROVIDER = "SunJCE"; + static final String PROVIDER = System.getProperty("test.provider.name", "SunJCE"); static final String AES = "AES"; static final String GCM = "GCM"; static final String PADDING = "NoPadding"; diff --git a/test/jdk/com/sun/crypto/provider/Cipher/AEAD/SameBuffer.java b/test/jdk/com/sun/crypto/provider/Cipher/AEAD/SameBuffer.java index 756fd624223..3e3fa3d77b1 100644 --- a/test/jdk/com/sun/crypto/provider/Cipher/AEAD/SameBuffer.java +++ b/test/jdk/com/sun/crypto/provider/Cipher/AEAD/SameBuffer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,7 +41,7 @@ */ public class SameBuffer { - private static final String PROVIDER = "SunJCE"; + private static final String PROVIDER = System.getProperty("test.provider.name", "SunJCE"); private static final String AES = "AES"; private static final String GCM = "GCM"; private static final String PADDING = "NoPadding"; diff --git a/test/jdk/com/sun/crypto/provider/Cipher/AEAD/SealedObjectTest.java b/test/jdk/com/sun/crypto/provider/Cipher/AEAD/SealedObjectTest.java index 6f5e8200e10..accf38f98b5 100644 --- a/test/jdk/com/sun/crypto/provider/Cipher/AEAD/SealedObjectTest.java +++ b/test/jdk/com/sun/crypto/provider/Cipher/AEAD/SealedObjectTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,7 @@ public class SealedObjectTest { private static final String AES = "AES"; private static final String TRANSFORMATION = "AES/GCM/NoPadding"; - private static final String PROVIDER = "SunJCE"; + private static final String PROVIDER = System.getProperty("test.provider.name", "SunJCE"); private static final int KEY_LENGTH = 128; public static void main(String[] args) throws Exception { diff --git a/test/jdk/com/sun/crypto/provider/Cipher/AEAD/WrongAAD.java b/test/jdk/com/sun/crypto/provider/Cipher/AEAD/WrongAAD.java index 157a8bb329d..6a35b3f2ce8 100644 --- a/test/jdk/com/sun/crypto/provider/Cipher/AEAD/WrongAAD.java +++ b/test/jdk/com/sun/crypto/provider/Cipher/AEAD/WrongAAD.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,7 +44,7 @@ */ public class WrongAAD { - private static final String PROVIDER = "SunJCE"; + private static final String PROVIDER = System.getProperty("test.provider.name", "SunJCE"); private static final String TRANSFORMATION = "AES/GCM/NoPadding"; private static final int TEXT_SIZE = 800; private static final int KEY_SIZE = 128; diff --git a/test/jdk/com/sun/crypto/provider/Cipher/AES/CICO.java b/test/jdk/com/sun/crypto/provider/Cipher/AES/CICO.java index 1bb9f0d061f..5d6da523f2a 100644 --- a/test/jdk/com/sun/crypto/provider/Cipher/AES/CICO.java +++ b/test/jdk/com/sun/crypto/provider/Cipher/AES/CICO.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -52,7 +52,7 @@ public class CICO { "cFB24", "cFB32", "Cfb40", "CFB72", "OfB", "OfB20", "OfB48", "OfB56", "OFB64", "OFB112", "CFB112", "pCbC" }; private static final String[] PADDING = { "noPadding", "pkcs5padding" }; - private static final String PROVIDER = "SunJCE"; + private static final String PROVIDER = System.getProperty("test.provider.name", "SunJCE"); private static final int NREADS = 3; private static final int KEY_LENGTH = 128; diff --git a/test/jdk/com/sun/crypto/provider/Cipher/AES/CTR.java b/test/jdk/com/sun/crypto/provider/Cipher/AES/CTR.java index d569965bca1..e610e98a27b 100644 --- a/test/jdk/com/sun/crypto/provider/Cipher/AES/CTR.java +++ b/test/jdk/com/sun/crypto/provider/Cipher/AES/CTR.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -50,7 +50,8 @@ public class CTR { private static final String ALGORITHM = "AES"; - private static final String PROVIDER = "SunJCE"; + private static final String PROVIDER = + System.getProperty("test.provider.name", "SunJCE"); private static final String[] MODES = {"CTR","CFB24","OFB32","GCM"}; diff --git a/test/jdk/com/sun/crypto/provider/Cipher/AES/Padding.java b/test/jdk/com/sun/crypto/provider/Cipher/AES/Padding.java index 9598e1743c2..a494d230381 100644 --- a/test/jdk/com/sun/crypto/provider/Cipher/AES/Padding.java +++ b/test/jdk/com/sun/crypto/provider/Cipher/AES/Padding.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -47,7 +47,8 @@ public class Padding { private static final String ALGORITHM = "AES"; - private static final String PROVIDER = "SunJCE"; + private static final String PROVIDER = + System.getProperty("test.provider.name", "SunJCE"); private static final String[] MODES_PKCS5PAD = { "ECb", "CbC", "PCBC", "OFB", "OFB150", "cFB", "CFB7", "cFB8", "cFB16", "cFB24", "cFB32", diff --git a/test/jdk/com/sun/crypto/provider/Cipher/AES/Test4511676.java b/test/jdk/com/sun/crypto/provider/Cipher/AES/Test4511676.java index ef538f63f90..e8b8c3edf30 100644 --- a/test/jdk/com/sun/crypto/provider/Cipher/AES/Test4511676.java +++ b/test/jdk/com/sun/crypto/provider/Cipher/AES/Test4511676.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,10 +41,12 @@ public class Test4511676 { public boolean execute() throws Exception { - Cipher ci = Cipher.getInstance(ALGO, "SunJCE"); + Cipher ci = Cipher.getInstance(ALGO, + System.getProperty("test.provider.name", "SunJCE")); // TEST FIX 4511676 - KeyGenerator kg = KeyGenerator.getInstance(ALGO, "SunJCE"); + KeyGenerator kg = KeyGenerator.getInstance(ALGO, + System.getProperty("test.provider.name", "SunJCE")); kg.init(KEYSIZE*8); SecretKey key = kg.generateKey(); try { diff --git a/test/jdk/com/sun/crypto/provider/Cipher/AES/Test4512524.java b/test/jdk/com/sun/crypto/provider/Cipher/AES/Test4512524.java index b743d6bcefd..c1428fdc033 100644 --- a/test/jdk/com/sun/crypto/provider/Cipher/AES/Test4512524.java +++ b/test/jdk/com/sun/crypto/provider/Cipher/AES/Test4512524.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -45,10 +45,12 @@ public class Test4512524 { public void execute(String mode) throws Exception { String transformation = ALGO+"/"+mode+"/"+PADDING; - Cipher ci = Cipher.getInstance(transformation, "SunJCE"); + Cipher ci = Cipher.getInstance(transformation, + System.getProperty("test.provider.name", "SunJCE")); // TEST FIX 4512524 - KeyGenerator kg = KeyGenerator.getInstance(ALGO, "SunJCE"); + KeyGenerator kg = KeyGenerator.getInstance(ALGO, + System.getProperty("test.provider.name", "SunJCE")); kg.init(KEYSIZE*8); SecretKey key = kg.generateKey(); diff --git a/test/jdk/com/sun/crypto/provider/Cipher/AES/Test4512704.java b/test/jdk/com/sun/crypto/provider/Cipher/AES/Test4512704.java index bf004314392..a33727075d7 100644 --- a/test/jdk/com/sun/crypto/provider/Cipher/AES/Test4512704.java +++ b/test/jdk/com/sun/crypto/provider/Cipher/AES/Test4512704.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -45,9 +45,11 @@ public void execute(String mode) throws Exception { AlgorithmParameterSpec aps = null; String transformation = ALGO + "/" + mode + "/"+PADDING; - Cipher ci = Cipher.getInstance(transformation, "SunJCE"); + Cipher ci = Cipher.getInstance(transformation, + System.getProperty("test.provider.name", "SunJCE")); - KeyGenerator kg = KeyGenerator.getInstance(ALGO, "SunJCE"); + KeyGenerator kg = KeyGenerator.getInstance(ALGO, + System.getProperty("test.provider.name", "SunJCE")); kg.init(KEYSIZE*8); SecretKey key = kg.generateKey(); // TEST FIX 4512704 diff --git a/test/jdk/com/sun/crypto/provider/Cipher/AES/Test4513830.java b/test/jdk/com/sun/crypto/provider/Cipher/AES/Test4513830.java index 856c55a6fbe..80d58dc19c5 100644 --- a/test/jdk/com/sun/crypto/provider/Cipher/AES/Test4513830.java +++ b/test/jdk/com/sun/crypto/provider/Cipher/AES/Test4513830.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -52,10 +52,12 @@ public boolean execute() throws Exception { byte[] plainText=new byte[125]; rdm.nextBytes(plainText); - Cipher ci = Cipher.getInstance(ALGO+"/"+MODE+"/"+PADDING, "SunJCE"); + Cipher ci = Cipher.getInstance(ALGO+"/"+MODE+"/"+PADDING, + System.getProperty("test.provider.name", "SunJCE")); // TEST FIX 4513830 - KeyGenerator kg = KeyGenerator.getInstance(ALGO, "SunJCE"); + KeyGenerator kg = KeyGenerator.getInstance(ALGO, + System.getProperty("test.provider.name", "SunJCE")); kg.init(KEYSIZE*8); SecretKey key = kg.generateKey(); diff --git a/test/jdk/com/sun/crypto/provider/Cipher/AES/Test4517355.java b/test/jdk/com/sun/crypto/provider/Cipher/AES/Test4517355.java index ccab72bf69a..1eed3831f53 100644 --- a/test/jdk/com/sun/crypto/provider/Cipher/AES/Test4517355.java +++ b/test/jdk/com/sun/crypto/provider/Cipher/AES/Test4517355.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -48,8 +48,10 @@ public class Test4517355 { public void execute(String mode, String padding) throws Exception { String transformation = ALGO + "/" + mode + "/" + padding; - Cipher ci = Cipher.getInstance(transformation, "SunJCE"); - KeyGenerator kg = KeyGenerator.getInstance(ALGO, "SunJCE"); + Cipher ci = Cipher.getInstance(transformation, + System.getProperty("test.provider.name", "SunJCE")); + KeyGenerator kg = KeyGenerator.getInstance(ALGO, + System.getProperty("test.provider.name", "SunJCE")); kg.init(KEYSIZE*8); SecretKey key = kg.generateKey(); diff --git a/test/jdk/com/sun/crypto/provider/Cipher/AES/Test4626070.java b/test/jdk/com/sun/crypto/provider/Cipher/AES/Test4626070.java index 86409d3e4cd..e49ef86b384 100644 --- a/test/jdk/com/sun/crypto/provider/Cipher/AES/Test4626070.java +++ b/test/jdk/com/sun/crypto/provider/Cipher/AES/Test4626070.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,8 +38,10 @@ public class Test4626070 { public void execute(String mode, String padding) throws Exception { String transformation = ALGO + "/" + mode + "/" + padding; - Cipher ci = Cipher.getInstance(transformation, "SunJCE"); - KeyGenerator kg = KeyGenerator.getInstance(ALGO, "SunJCE"); + Cipher ci = Cipher.getInstance(transformation, + System.getProperty("test.provider.name", "SunJCE")); + KeyGenerator kg = KeyGenerator.getInstance(ALGO, + System.getProperty("test.provider.name", "SunJCE")); kg.init(KEYSIZE*8); SecretKey key = kg.generateKey(); diff --git a/test/jdk/com/sun/crypto/provider/Cipher/AES/TestAESCipher.java b/test/jdk/com/sun/crypto/provider/Cipher/AES/TestAESCipher.java index dd0d97101c1..9e2342c7be6 100644 --- a/test/jdk/com/sun/crypto/provider/Cipher/AES/TestAESCipher.java +++ b/test/jdk/com/sun/crypto/provider/Cipher/AES/TestAESCipher.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -48,7 +48,7 @@ public class TestAESCipher { private static final String ALGORITHM = "AES"; - private static final String PROVIDER = "SunJCE"; + private static final String PROVIDER = System.getProperty("test.provider.name", "SunJCE"); private static final String[] MODES = { "ECb", "CbC", "CTR", "PCBC", "OFB", "OFB150", "cFB", "CFB7", "cFB8", "cFB16", "cFB24", "cFB32", "Cfb40", "cfB48", "cfB56", "cfB64", "cfB72", "cfB80", "cfB88", diff --git a/test/jdk/com/sun/crypto/provider/Cipher/AES/TestAESCiphers/Dynamic.java b/test/jdk/com/sun/crypto/provider/Cipher/AES/TestAESCiphers/Dynamic.java index 91d7426b7f1..65b34507835 100644 --- a/test/jdk/com/sun/crypto/provider/Cipher/AES/TestAESCiphers/Dynamic.java +++ b/test/jdk/com/sun/crypto/provider/Cipher/AES/TestAESCiphers/Dynamic.java @@ -46,7 +46,7 @@ public class Dynamic { static final String[] PADDING = { "NoPadding", "PKCS5Padding", "ISO10126Padding" }; - static final String SUNJCE = "SunJCE"; + static final String PROVIDER = System.getProperty("test.provider.name", "SunJCE"); Cipher ci = null; byte[] iv = null; @@ -128,8 +128,8 @@ protected boolean runTest(String algo, String mo, String pad) new Random().nextBytes(plainText); String transformation = algo + "/" + mo + "/" + pad; - ci = Cipher.getInstance(transformation, SUNJCE); - KeyGenerator kg = KeyGenerator.getInstance(algo, SUNJCE); + ci = Cipher.getInstance(transformation, PROVIDER); + KeyGenerator kg = KeyGenerator.getInstance(algo, PROVIDER); if (keyStrength > Cipher.getMaxAllowedKeyLength(transformation)) { // skip if this key length is larger than what's // configured in the jce jurisdiction policy files diff --git a/test/jdk/com/sun/crypto/provider/Cipher/AES/TestAESCiphers/TestAESWithProviderChange.java b/test/jdk/com/sun/crypto/provider/Cipher/AES/TestAESCiphers/TestAESWithProviderChange.java index d29a0aa0904..bb9538c70a1 100644 --- a/test/jdk/com/sun/crypto/provider/Cipher/AES/TestAESCiphers/TestAESWithProviderChange.java +++ b/test/jdk/com/sun/crypto/provider/Cipher/AES/TestAESCiphers/TestAESWithProviderChange.java @@ -33,7 +33,7 @@ public class TestAESWithProviderChange extends Dynamic { public static void main(String argv[]) throws Exception { - Security.removeProvider(SUNJCE); + Security.removeProvider(PROVIDER); Security.addProvider(new com.sun.crypto.provider.SunJCE()); new TestAESWithProviderChange().run(argv); } diff --git a/test/jdk/com/sun/crypto/provider/Cipher/AES/TestAESCiphers/TestAESWithRemoveAddProvider.java b/test/jdk/com/sun/crypto/provider/Cipher/AES/TestAESCiphers/TestAESWithRemoveAddProvider.java index 81761a7ea4b..677f9aa913a 100644 --- a/test/jdk/com/sun/crypto/provider/Cipher/AES/TestAESCiphers/TestAESWithRemoveAddProvider.java +++ b/test/jdk/com/sun/crypto/provider/Cipher/AES/TestAESCiphers/TestAESWithRemoveAddProvider.java @@ -34,8 +34,8 @@ public class TestAESWithRemoveAddProvider extends Dynamic { public static void main(String argv[]) throws Exception { - Provider pJCE = Security.getProvider(SUNJCE); - Security.removeProvider(SUNJCE); + Provider pJCE = Security.getProvider(PROVIDER); + Security.removeProvider(PROVIDER); Security.addProvider(pJCE); new TestAESWithRemoveAddProvider().run(argv); } diff --git a/test/jdk/com/sun/crypto/provider/Cipher/AES/TestAESCiphers/testAES.policy b/test/jdk/com/sun/crypto/provider/Cipher/AES/TestAESCiphers/testAES.policy index 175e9cb86e5..5c6a06beb02 100644 --- a/test/jdk/com/sun/crypto/provider/Cipher/AES/TestAESCiphers/testAES.policy +++ b/test/jdk/com/sun/crypto/provider/Cipher/AES/TestAESCiphers/testAES.policy @@ -1,6 +1,7 @@ grant codeBase "file:${test.classes}/*" { - permission java.security.SecurityPermission "removeProvider.SunJCE"; - permission java.security.SecurityPermission "insertProvider.SunJCE"; + permission java.security.SecurityPermission "removeProvider.*"; + permission java.security.SecurityPermission "insertProvider.*"; permission java.lang.RuntimePermission "accessClassInPackage.com.sun.crypto.provider"; + permission java.util.PropertyPermission "test.provider.name", "read"; }; diff --git a/test/jdk/com/sun/crypto/provider/Cipher/AES/TestCICOWithGCM.java b/test/jdk/com/sun/crypto/provider/Cipher/AES/TestCICOWithGCM.java index c6c7a66c5e4..87d08b2c4a7 100644 --- a/test/jdk/com/sun/crypto/provider/Cipher/AES/TestCICOWithGCM.java +++ b/test/jdk/com/sun/crypto/provider/Cipher/AES/TestCICOWithGCM.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -43,7 +43,8 @@ public class TestCICOWithGCM { public static void main(String[] args) throws Exception { //init Secret Key - KeyGenerator kg = KeyGenerator.getInstance("AES", "SunJCE"); + KeyGenerator kg = KeyGenerator.getInstance("AES", + System.getProperty("test.provider.name", "SunJCE")); kg.init(128); SecretKey key = kg.generateKey(); @@ -53,9 +54,11 @@ public static void main(String[] args) throws Exception { rdm.nextBytes(plainText); //init ciphers - Cipher encCipher = Cipher.getInstance("AES/GCM/NoPadding", "SunJCE"); + Cipher encCipher = Cipher.getInstance("AES/GCM/NoPadding", + System.getProperty("test.provider.name", "SunJCE")); encCipher.init(Cipher.ENCRYPT_MODE, key); - Cipher decCipher = Cipher.getInstance("AES/GCM/NoPadding", "SunJCE"); + Cipher decCipher = Cipher.getInstance("AES/GCM/NoPadding", + System.getProperty("test.provider.name", "SunJCE")); decCipher.init(Cipher.DECRYPT_MODE, key, encCipher.getParameters()); //init cipher streams diff --git a/test/jdk/com/sun/crypto/provider/Cipher/AES/TestCICOWithGCMAndAAD.java b/test/jdk/com/sun/crypto/provider/Cipher/AES/TestCICOWithGCMAndAAD.java index 80732762297..960dd66567a 100644 --- a/test/jdk/com/sun/crypto/provider/Cipher/AES/TestCICOWithGCMAndAAD.java +++ b/test/jdk/com/sun/crypto/provider/Cipher/AES/TestCICOWithGCMAndAAD.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,8 @@ public class TestCICOWithGCMAndAAD { public static void main(String[] args) throws Exception { //init Secret Key - KeyGenerator kg = KeyGenerator.getInstance("AES", "SunJCE"); + KeyGenerator kg = KeyGenerator.getInstance("AES", + System.getProperty("test.provider.name", "SunJCE")); kg.init(128); SecretKey key = kg.generateKey(); @@ -53,10 +54,12 @@ public static void main(String[] args) throws Exception { byte[] aad2 = aad.clone(); aad2[50]++; - Cipher encCipher = Cipher.getInstance("AES/GCM/NoPadding", "SunJCE"); + Cipher encCipher = Cipher.getInstance("AES/GCM/NoPadding", + System.getProperty("test.provider.name", "SunJCE")); encCipher.init(Cipher.ENCRYPT_MODE, key); encCipher.updateAAD(aad); - Cipher decCipher = Cipher.getInstance("AES/GCM/NoPadding", "SunJCE"); + Cipher decCipher = Cipher.getInstance("AES/GCM/NoPadding", + System.getProperty("test.provider.name", "SunJCE")); decCipher.init(Cipher.DECRYPT_MODE, key, encCipher.getParameters()); decCipher.updateAAD(aad); diff --git a/test/jdk/com/sun/crypto/provider/Cipher/AES/TestCopySafe.java b/test/jdk/com/sun/crypto/provider/Cipher/AES/TestCopySafe.java index 697da6750ad..70a9dd5998f 100644 --- a/test/jdk/com/sun/crypto/provider/Cipher/AES/TestCopySafe.java +++ b/test/jdk/com/sun/crypto/provider/Cipher/AES/TestCopySafe.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -57,7 +57,8 @@ public class TestCopySafe { public static void main(String[] argv) throws Exception { - Provider p = Security.getProvider("SunJCE"); + Provider p = Security.getProvider( + System.getProperty("test.provider.name", "SunJCE")); AlgorithmParameterSpec params = null; boolean result = true; diff --git a/test/jdk/com/sun/crypto/provider/Cipher/AES/TestGCMKeyAndIvCheck.java b/test/jdk/com/sun/crypto/provider/Cipher/AES/TestGCMKeyAndIvCheck.java index 0777508b36f..d94753e941e 100644 --- a/test/jdk/com/sun/crypto/provider/Cipher/AES/TestGCMKeyAndIvCheck.java +++ b/test/jdk/com/sun/crypto/provider/Cipher/AES/TestGCMKeyAndIvCheck.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -68,7 +68,8 @@ private static void checkISE(Cipher c) throws Exception { } public void test() throws Exception { - Cipher c = Cipher.getInstance("AES/GCM/NoPadding", "SunJCE"); + Cipher c = Cipher.getInstance("AES/GCM/NoPadding", + System.getProperty("test.provider.name", "SunJCE")); SecretKey key = new SecretKeySpec(new byte[16], "AES"); // First try parameter-less init. diff --git a/test/jdk/com/sun/crypto/provider/Cipher/AES/TestISO10126Padding.java b/test/jdk/com/sun/crypto/provider/Cipher/AES/TestISO10126Padding.java index 9b91e612c35..26b160eaae1 100644 --- a/test/jdk/com/sun/crypto/provider/Cipher/AES/TestISO10126Padding.java +++ b/test/jdk/com/sun/crypto/provider/Cipher/AES/TestISO10126Padding.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -45,7 +45,8 @@ public class TestISO10126Padding { private TestISO10126Padding() throws Exception { // setup - KeyGenerator kg = KeyGenerator.getInstance(ALGO, "SunJCE"); + KeyGenerator kg = KeyGenerator.getInstance(ALGO, + System.getProperty("test.provider.name", "SunJCE")); kg.init(KEYSIZE*8); key = kg.generateKey(); } @@ -59,7 +60,8 @@ private void runTest(int dataLength) throws Exception { // TEST#1 -- // generate the cipher text using manually-supplied // XML Encryption padding - Cipher ci = Cipher.getInstance(TRANS + "/NoPadding", "SunJCE"); + Cipher ci = Cipher.getInstance(TRANS + "/NoPadding", + System.getProperty("test.provider.name", "SunJCE")); ci.init(Cipher.ENCRYPT_MODE, key); byte[] paddedData = new byte[ci.getBlockSize()]; System.arraycopy(data, 0, paddedData, 0, data.length); @@ -68,7 +70,8 @@ private void runTest(int dataLength) throws Exception { byte[] cipherText = ci.doFinal(paddedData); // decrypt using ISO10126Padding - ci = Cipher.getInstance(TRANS + "/ISO10126Padding", "SunJCE"); + ci = Cipher.getInstance(TRANS + "/ISO10126Padding", + System.getProperty("test.provider.name", "SunJCE")); ci.init(Cipher.DECRYPT_MODE, key); byte[] recovered = ci.doFinal(cipherText); if (!Arrays.equals(data, recovered)) { @@ -76,7 +79,8 @@ private void runTest(int dataLength) throws Exception { } // TEST#2 -- // generate the cipher text using ISO10126Padding - ci = Cipher.getInstance(TRANS + "/ISO10126Padding", "SunJCE"); + ci = Cipher.getInstance(TRANS + "/ISO10126Padding", + System.getProperty("test.provider.name", "SunJCE")); ci.init(Cipher.ENCRYPT_MODE, key); cipherText = ci.doFinal(data); diff --git a/test/jdk/com/sun/crypto/provider/Cipher/AES/TestKATForECB_IV.java b/test/jdk/com/sun/crypto/provider/Cipher/AES/TestKATForECB_IV.java index a9576e7f3eb..71f07d61b13 100644 --- a/test/jdk/com/sun/crypto/provider/Cipher/AES/TestKATForECB_IV.java +++ b/test/jdk/com/sun/crypto/provider/Cipher/AES/TestKATForECB_IV.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -83,7 +83,8 @@ private static byte[] constructByteArray(String s) { public boolean execute() throws Exception { String transformation = ALGO+"/"+MODE+"/"+PADDING; - Cipher c = Cipher.getInstance(transformation, "SunJCE"); + Cipher c = Cipher.getInstance(transformation, + System.getProperty("test.provider.name", "SunJCE")); for (int i=0; i diff --git a/test/jdk/com/sun/crypto/provider/Cipher/AES/TestKATForECB_VK.java b/test/jdk/com/sun/crypto/provider/Cipher/AES/TestKATForECB_VK.java index 098232b8c4c..623f5f5d281 100644 --- a/test/jdk/com/sun/crypto/provider/Cipher/AES/TestKATForECB_VK.java +++ b/test/jdk/com/sun/crypto/provider/Cipher/AES/TestKATForECB_VK.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -707,7 +707,8 @@ private static byte[] constructByteArray(String s) { public boolean execute() throws Exception { String transformation = ALGO+"/"+MODE+"/"+PADDING; - Cipher c = Cipher.getInstance(transformation, "SunJCE"); + Cipher c = Cipher.getInstance(transformation, + System.getProperty("test.provider.name", "SunJCE")); for (int i=0; i diff --git a/test/jdk/com/sun/crypto/provider/Cipher/AES/TestKATForECB_VT.java b/test/jdk/com/sun/crypto/provider/Cipher/AES/TestKATForECB_VT.java index b8f83bd7b05..6265ca10281 100644 --- a/test/jdk/com/sun/crypto/provider/Cipher/AES/TestKATForECB_VT.java +++ b/test/jdk/com/sun/crypto/provider/Cipher/AES/TestKATForECB_VT.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -513,7 +513,8 @@ private static byte[] constructByteArray(String s) { public boolean execute() throws Exception { String transformation = ALGO+"/"+MODE+"/"+PADDING; - Cipher c = Cipher.getInstance(transformation, "SunJCE"); + Cipher c = Cipher.getInstance(transformation, + System.getProperty("test.provider.name", "SunJCE")); for (int i=0; i diff --git a/test/jdk/com/sun/crypto/provider/Cipher/AES/TestKATForGCM.java b/test/jdk/com/sun/crypto/provider/Cipher/AES/TestKATForGCM.java index bdcf465f854..70db7b166e8 100644 --- a/test/jdk/com/sun/crypto/provider/Cipher/AES/TestKATForGCM.java +++ b/test/jdk/com/sun/crypto/provider/Cipher/AES/TestKATForGCM.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -278,7 +278,8 @@ public String toString() { }; void executeArray(TestVector tv) throws Exception { - Cipher c = Cipher.getInstance("AES/GCM/NoPadding", "SunJCE"); + Cipher c = Cipher.getInstance("AES/GCM/NoPadding", + System.getProperty("test.provider.name", "SunJCE")); try { System.out.println("Test #" + tv.id + ": byte[]."); @@ -320,7 +321,8 @@ void executeArray(TestVector tv) throws Exception { } void executeByteBuffer(TestVector tv, boolean direct, int offset) throws Exception { - Cipher c = Cipher.getInstance("AES/GCM/NoPadding", "SunJCE"); + Cipher c = Cipher.getInstance("AES/GCM/NoPadding", + System.getProperty("test.provider.name", "SunJCE")); ByteBuffer src; ByteBuffer ctdst; diff --git a/test/jdk/com/sun/crypto/provider/Cipher/AES/TestNoPaddingModes.java b/test/jdk/com/sun/crypto/provider/Cipher/AES/TestNoPaddingModes.java index 9747f3bced2..a32f787a72a 100644 --- a/test/jdk/com/sun/crypto/provider/Cipher/AES/TestNoPaddingModes.java +++ b/test/jdk/com/sun/crypto/provider/Cipher/AES/TestNoPaddingModes.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,7 +42,8 @@ public class TestNoPaddingModes { }; public static void main(String[] args) throws Exception { - Provider p = Security.getProvider("SunJCE"); + Provider p = Security.getProvider( + System.getProperty("test.provider.name", "SunJCE")); String transformation; for (String mode : MODES) { for (String padding : PADDINGS) { @@ -50,7 +51,8 @@ public static void main(String[] args) throws Exception { System.out.println("Test using " + transformation); try { - Cipher c = Cipher.getInstance(transformation, "SunJCE"); + Cipher c = Cipher.getInstance(transformation, + System.getProperty("test.provider.name", "SunJCE")); throw new RuntimeException("=> Fail, no exception thrown"); } catch (NoSuchAlgorithmException | NoSuchPaddingException ex) { System.out.println("=> Expected ex: " + ex); diff --git a/test/jdk/com/sun/crypto/provider/Cipher/AES/TestNonexpanding.java b/test/jdk/com/sun/crypto/provider/Cipher/AES/TestNonexpanding.java index 3ed865f5a98..140f24d51d1 100644 --- a/test/jdk/com/sun/crypto/provider/Cipher/AES/TestNonexpanding.java +++ b/test/jdk/com/sun/crypto/provider/Cipher/AES/TestNonexpanding.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -45,7 +45,8 @@ public class TestNonexpanding { private static final String ALGORITHM = "AES"; - private static final String PROVIDER = "SunJCE"; + private static final String PROVIDER = + System.getProperty("test.provider.name", "SunJCE"); private static final String[] MODES = { "ECb", "CbC", "OFB", "OFB150", "cFB", "CFB7", "cFB8", "cFB16", "cFB24", "cFB32", "Cfb40", "cfB48", "cfB56", "cfB64", "cfB72", "cfB80", "cfB88", "cfB96", "cfb104", diff --git a/test/jdk/com/sun/crypto/provider/Cipher/AES/TestSameBuffer.java b/test/jdk/com/sun/crypto/provider/Cipher/AES/TestSameBuffer.java index e158bc54652..cc8c050396e 100644 --- a/test/jdk/com/sun/crypto/provider/Cipher/AES/TestSameBuffer.java +++ b/test/jdk/com/sun/crypto/provider/Cipher/AES/TestSameBuffer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -47,7 +47,8 @@ public class TestSameBuffer { private static final String ALGORITHM = "AES"; - private static final String PROVIDER = "SunJCE"; + private static final String PROVIDER = + System.getProperty("test.provider.name", "SunJCE"); private static final String[] MODES = { "ECb", "CbC", "OFB", "CFB150", "cFB", "CFB7", " cFB8", "cFB16", "cFB24", "cFB32", "Cfb40", "cfB48", " cfB56", "cfB64", "cfB72", "cfB80", "cfB88", "cfB96", diff --git a/test/jdk/com/sun/crypto/provider/Cipher/AES/TestShortBuffer.java b/test/jdk/com/sun/crypto/provider/Cipher/AES/TestShortBuffer.java index 52d6c43bdb1..fe1f76c0a04 100644 --- a/test/jdk/com/sun/crypto/provider/Cipher/AES/TestShortBuffer.java +++ b/test/jdk/com/sun/crypto/provider/Cipher/AES/TestShortBuffer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -71,7 +71,7 @@ private static void runTest() throws Exception { for (int i = 0; i < MODES.length; i++) { System.out.println("===== TESTING MODE " + MODES[i] + " ====="); Cipher ci = Cipher.getInstance(ALGO+"/"+MODES[i]+"/PKCS5Padding", - "SunJCE"); + System.getProperty("test.provider.name", "SunJCE")); TestShortBuffer test = null; int stored = 0; AlgorithmParameters params = null; diff --git a/test/jdk/com/sun/crypto/provider/Cipher/CTR/CounterMode.java b/test/jdk/com/sun/crypto/provider/Cipher/CTR/CounterMode.java index 6d985312b6b..1073985c18c 100644 --- a/test/jdk/com/sun/crypto/provider/Cipher/CTR/CounterMode.java +++ b/test/jdk/com/sun/crypto/provider/Cipher/CTR/CounterMode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -162,7 +162,8 @@ public static void main(String[] args) throws Exception { continue; } System.out.println("Running test " + i + " (" + alg + ")"); - Cipher cipher = Cipher.getInstance(alg + "/CTR/NoPadding", "SunJCE"); + Cipher cipher = Cipher.getInstance(alg + "/CTR/NoPadding", + System.getProperty("test.provider.name", "SunJCE")); SecretKeySpec key = new SecretKeySpec(KEYS[i], alg); IvParameterSpec iv = new IvParameterSpec(IVS[i]); byte[] plainText = PLAIN[i]; diff --git a/test/jdk/com/sun/crypto/provider/Cipher/CTS/CTSMode.java b/test/jdk/com/sun/crypto/provider/Cipher/CTS/CTSMode.java index 6dba280899f..6d34fd3d50b 100644 --- a/test/jdk/com/sun/crypto/provider/Cipher/CTS/CTSMode.java +++ b/test/jdk/com/sun/crypto/provider/Cipher/CTS/CTSMode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -156,7 +156,7 @@ private static void test1() throws Exception { } System.out.println("Running test1_" + i + " (" + algo + ")"); Cipher cipher = Cipher.getInstance(algo+ "/CTS/NoPadding", - "SunJCE"); + System.getProperty("test.provider.name", "SunJCE")); byte[] plainText = PLAIN1[i]; byte[] cipherText = CIPHER1[i]; cipher.init(Cipher.ENCRYPT_MODE, KEY1, IV1); @@ -194,7 +194,8 @@ private static void test2() throws Exception { continue; } Cipher cipher = - Cipher.getInstance(algo+"/CTS/NoPadding", "SunJCE"); + Cipher.getInstance(algo+"/CTS/NoPadding", + System.getProperty("test.provider.name", "SunJCE")); int blockSize = cipher.getBlockSize(); SecretKeySpec key = new SecretKeySpec(new byte[keySize], algo); // Make sure encryption works for inputs with valid length @@ -226,7 +227,8 @@ private static void test2() throws Exception { IvParameterSpec iv2 = new IvParameterSpec(IV2_SRC, 0, blockSize); cipher.init(Cipher.ENCRYPT_MODE, key, iv2); Cipher cipher2 = - Cipher.getInstance(algo+"/CBC/NoPadding", "SunJCE"); + Cipher.getInstance(algo+"/CBC/NoPadding", + System.getProperty("test.provider.name", "SunJCE")); cipher2.init(Cipher.ENCRYPT_MODE, key, iv2); byte[] eout = cipher.doFinal(IV2_SRC, 0, blockSize); @@ -294,7 +296,8 @@ private static void test3() throws Exception { continue; } Cipher cipher = - Cipher.getInstance(algo+ "/CTS/NoPadding", "SunJCE"); + Cipher.getInstance(algo+ "/CTS/NoPadding", + System.getProperty("test.provider.name", "SunJCE")); byte[] plainText = PLAIN1[i]; byte[] cipherText = CIPHER1[i]; byte[] enc = new byte[plainText.length]; diff --git a/test/jdk/com/sun/crypto/provider/Cipher/DES/KeyWrapping.java b/test/jdk/com/sun/crypto/provider/Cipher/DES/KeyWrapping.java index c1447eb3e51..a71390b504e 100644 --- a/test/jdk/com/sun/crypto/provider/Cipher/DES/KeyWrapping.java +++ b/test/jdk/com/sun/crypto/provider/Cipher/DES/KeyWrapping.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,16 +24,19 @@ /* * @test * @bug 0000000 + * @library /test/lib * @summary KeyWrapping * @author Jan Luehe */ import javax.crypto.*; import java.security.*; +import jdk.test.lib.security.SecurityUtils; public class KeyWrapping { public static void main(String[] args) throws Exception { - Cipher c1 = Cipher.getInstance("DES", "SunJCE"); + Cipher c1 = Cipher.getInstance("DES", + System.getProperty("test.provider.name", "SunJCE")); Cipher c2 = Cipher.getInstance("DES"); KeyGenerator keyGen = KeyGenerator.getInstance("DES"); @@ -70,8 +73,9 @@ public static void main(String[] args) throws Exception { if (!msg.equals(new String(clearText))) throw new Exception("The unwrapped session key is corrupted."); - KeyPairGenerator kpairGen = KeyPairGenerator.getInstance("DSA"); - kpairGen.initialize(1024); + String kpgAlgorithm = "DSA"; + KeyPairGenerator kpairGen = KeyPairGenerator.getInstance(kpgAlgorithm); + kpairGen.initialize(SecurityUtils.getTestKeySize(kpgAlgorithm)); KeyPair kpair = kpairGen.genKeyPair(); diff --git a/test/jdk/com/sun/crypto/provider/Cipher/DES/Sealtest.java b/test/jdk/com/sun/crypto/provider/Cipher/DES/Sealtest.java index abc536f14e2..d4b2173358c 100644 --- a/test/jdk/com/sun/crypto/provider/Cipher/DES/Sealtest.java +++ b/test/jdk/com/sun/crypto/provider/Cipher/DES/Sealtest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,20 +24,23 @@ /* * @test * @bug 0000000 7055362 + * @library /test/lib * @summary Sealtest * @author Jan Luehe */ import java.io.*; import java.security.*; import javax.crypto.*; +import jdk.test.lib.security.SecurityUtils; public class Sealtest { public static void main(String[] args) throws Exception { // create DSA keypair - KeyPairGenerator kpgen = KeyPairGenerator.getInstance("DSA"); - kpgen.initialize(512); + String kpgAlgorithm = "DSA"; + KeyPairGenerator kpgen = KeyPairGenerator.getInstance(kpgAlgorithm); + kpgen.initialize(SecurityUtils.getTestKeySize(kpgAlgorithm)); KeyPair kp = kpgen.generateKeyPair(); // create DES key diff --git a/test/jdk/com/sun/crypto/provider/Cipher/KeyWrap/NISTWrapKAT.java b/test/jdk/com/sun/crypto/provider/Cipher/KeyWrap/NISTWrapKAT.java index 3da7c7072f0..a79f48196d1 100644 --- a/test/jdk/com/sun/crypto/provider/Cipher/KeyWrap/NISTWrapKAT.java +++ b/test/jdk/com/sun/crypto/provider/Cipher/KeyWrap/NISTWrapKAT.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -259,9 +259,12 @@ public void testKeyWrap(String algo, String key, int keyLen, System.out.println("=> skip, exceeds max allowed size " + allowed); return; } - Cipher c1 = Cipher.getInstance(algo, "SunJCE"); - Cipher c2 = Cipher.getInstance(algo, "SunJCE"); - Cipher c3 = Cipher.getInstance(algo, "SunJCE"); + Cipher c1 = Cipher.getInstance(algo, + System.getProperty("test.provider.name", "SunJCE")); + Cipher c2 = Cipher.getInstance(algo, + System.getProperty("test.provider.name", "SunJCE")); + Cipher c3 = Cipher.getInstance(algo, + System.getProperty("test.provider.name", "SunJCE")); byte[] keyVal = toBytes(key, keyLen << 1); byte[] dataVal = toBytes(data, dataLen << 1); @@ -318,9 +321,12 @@ public void testEnc(String algo, String key, int keyLen, String data, int dataLe System.out.println("=> skip, exceeds max allowed size " + allowed); return; } - Cipher c1 = Cipher.getInstance(algo, "SunJCE"); - Cipher c2 = Cipher.getInstance(algo, "SunJCE"); - Cipher c3 = Cipher.getInstance(algo, "SunJCE"); + Cipher c1 = Cipher.getInstance(algo, + System.getProperty("test.provider.name", "SunJCE")); + Cipher c2 = Cipher.getInstance(algo, + System.getProperty("test.provider.name", "SunJCE")); + Cipher c3 = Cipher.getInstance(algo, + System.getProperty("test.provider.name", "SunJCE")); byte[] keyVal = toBytes(key, keyLen << 1); byte[] dataVal = toBytes(data, dataLen << 1); diff --git a/test/jdk/com/sun/crypto/provider/Cipher/KeyWrap/TestCipherKeyWrapperTest.java b/test/jdk/com/sun/crypto/provider/Cipher/KeyWrap/TestCipherKeyWrapperTest.java index 6a3708bff9e..82794de2582 100644 --- a/test/jdk/com/sun/crypto/provider/Cipher/KeyWrap/TestCipherKeyWrapperTest.java +++ b/test/jdk/com/sun/crypto/provider/Cipher/KeyWrap/TestCipherKeyWrapperTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -50,15 +50,18 @@ import javax.crypto.SecretKeyFactory; import javax.crypto.spec.PBEKeySpec; import javax.crypto.spec.PBEParameterSpec; +import jdk.test.lib.security.SecurityUtils; /* * @test * @bug 8048599 8248268 8288050 + * @library /test/lib * @summary Tests for key wrap and unwrap operations */ public class TestCipherKeyWrapperTest { - private static final String SUN_JCE = "SunJCE"; + private static final String PROVIDER_NAME = + System.getProperty("test.provider.name", "SunJCE"); // Blowfish Variable key length: 32 bits to 448 bits private static final int BLOWFISH_MIN_KEYSIZE = 32; private static final int BLOWFISH_MAX_KEYSIZE = 448; @@ -157,9 +160,9 @@ public static void main(String[] args) throws Exception { // PBE and public wrapper test. String[] publicPrivateAlgos = new String[] { "DiffieHellman", "DSA", "RSA" }; - Provider provider = Security.getProvider(SUN_JCE); + Provider provider = Security.getProvider(PROVIDER_NAME); if (provider == null) { - throw new RuntimeException("SUN_JCE provider not exist"); + throw new RuntimeException(PROVIDER_NAME + " provider not exist"); } test.wrapperPBEKeyTest(provider); @@ -269,7 +272,7 @@ private void wrapperPublicPriviteKeyTest(Provider p, String[] algorithms) System.out.println("Generate key pair (algorithm: " + algo + ", provider: " + p.getName() + ")"); KeyPairGenerator kpg = KeyPairGenerator.getInstance(algo); - kpg.initialize(512); + kpg.initialize(SecurityUtils.getTestKeySize(algo)); KeyPair kp = kpg.genKeyPair(); // key generated String algoWrap = "DES"; diff --git a/test/jdk/com/sun/crypto/provider/Cipher/KeyWrap/TestGeneral.java b/test/jdk/com/sun/crypto/provider/Cipher/KeyWrap/TestGeneral.java index bdc36b9a35e..66bc6d7f7fa 100644 --- a/test/jdk/com/sun/crypto/provider/Cipher/KeyWrap/TestGeneral.java +++ b/test/jdk/com/sun/crypto/provider/Cipher/KeyWrap/TestGeneral.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -220,7 +220,8 @@ public static void main(String[] argv) throws Exception { SecretKey aes256 = new SecretKeySpec(DATA_32, "AES"); SecretKey any256 = new SecretKeySpec(DATA_32, "ANY"); PrivateKey priv = KeyPairGenerator.getInstance - ("RSA", "SunRsaSign").generateKeyPair().getPrivate(); + ("RSA", System.getProperty("test.provider.name", "SunRsaSign")) + .generateKeyPair().getPrivate(); String[] algos = { "AES/KW/PKCS5Padding", "AES/KW/NoPadding", "AES/KWP/NoPadding" @@ -228,7 +229,8 @@ public static void main(String[] argv) throws Exception { for (String a : algos) { System.out.println("Testing " + a); - Cipher c = Cipher.getInstance(a, "SunJCE"); + Cipher c = Cipher.getInstance(a, + System.getProperty("test.provider.name", "SunJCE")); int blkSize = c.getBlockSize(); diff --git a/test/jdk/com/sun/crypto/provider/Cipher/KeyWrap/TestKeySizeCheck.java b/test/jdk/com/sun/crypto/provider/Cipher/KeyWrap/TestKeySizeCheck.java index 4732836d6d9..ea8ac397ebb 100644 --- a/test/jdk/com/sun/crypto/provider/Cipher/KeyWrap/TestKeySizeCheck.java +++ b/test/jdk/com/sun/crypto/provider/Cipher/KeyWrap/TestKeySizeCheck.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -61,7 +61,8 @@ public static void test(String algo, int[] invalidKeySizes) throws Exception { System.out.println("Testing " + algo); - Cipher c = Cipher.getInstance(algo, "SunJCE"); + Cipher c = Cipher.getInstance(algo, + System.getProperty("test.provider.name", "SunJCE")); int[] modes = { Cipher.ENCRYPT_MODE, Cipher.WRAP_MODE }; for (int ks : invalidKeySizes) { diff --git a/test/jdk/com/sun/crypto/provider/Cipher/KeyWrap/XMLEncKAT.java b/test/jdk/com/sun/crypto/provider/Cipher/KeyWrap/XMLEncKAT.java index 90cfacf36fd..e9d9038ada9 100644 --- a/test/jdk/com/sun/crypto/provider/Cipher/KeyWrap/XMLEncKAT.java +++ b/test/jdk/com/sun/crypto/provider/Cipher/KeyWrap/XMLEncKAT.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -111,7 +111,8 @@ public static void testKeyWrap(String cAlg, byte[] cKeyVal, String cKeyAlg, String[] base64Wrapped) throws Exception { System.out.println("Testing " + cAlg + " Cipher with " + 8*cKeyVal.length + "-bit key"); - Cipher c = Cipher.getInstance(cAlg, "SunJCE"); + Cipher c = Cipher.getInstance(cAlg, + System.getProperty("test.provider.name", "SunJCE")); SecretKey cKey = new SecretKeySpec(cKeyVal, cKeyAlg); c.init(Cipher.UNWRAP_MODE, cKey); Key[] key = new SecretKey[base64Wrapped.length]; diff --git a/test/jdk/com/sun/crypto/provider/Cipher/PBE/DecryptWithoutParameters.java b/test/jdk/com/sun/crypto/provider/Cipher/PBE/DecryptWithoutParameters.java index 35cb5184441..f8af47d6e6d 100644 --- a/test/jdk/com/sun/crypto/provider/Cipher/PBE/DecryptWithoutParameters.java +++ b/test/jdk/com/sun/crypto/provider/Cipher/PBE/DecryptWithoutParameters.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -113,7 +113,8 @@ public static void main(String argv[]) throws Exception { boolean status = true; for (String algo : PBES1ALGOS) { - Cipher cipher = Cipher.getInstance(algo, "SunJCE"); + Cipher cipher = Cipher.getInstance(algo, + System.getProperty("test.provider.name", "SunJCE")); SecretKey key = new SecretKeySpec(new byte[5], algo); status = status && test(cipher, key, null); } @@ -122,7 +123,8 @@ public static void main(String argv[]) throws Exception { int iterCount = 123456; PBEParameterSpec spec = new PBEParameterSpec(salt, iterCount); for (String algo : PBES2ALGOS) { - Cipher cipher = Cipher.getInstance(algo, "SunJCE"); + Cipher cipher = Cipher.getInstance(algo, + System.getProperty("test.provider.name", "SunJCE")); SecretKey key = new SecretKeySpec(new byte[5], algo); PBEKey key2 = new MyPBEKey(algo, new PBEKeySpec("phrase".toCharArray(), salt, iterCount)); diff --git a/test/jdk/com/sun/crypto/provider/Cipher/PBE/NegativeLength.java b/test/jdk/com/sun/crypto/provider/Cipher/PBE/NegativeLength.java index 9c4cc3663c1..736e0a9fe64 100644 --- a/test/jdk/com/sun/crypto/provider/Cipher/PBE/NegativeLength.java +++ b/test/jdk/com/sun/crypto/provider/Cipher/PBE/NegativeLength.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,7 +38,9 @@ public class NegativeLength { public static void main(String[] args) throws Exception { SecretKeyFactory skf = SecretKeyFactory.getInstance( - "PBKDF2WithHmacSHA1", "SunJCE"); + "PBKDF2WithHmacSHA1", + System.getProperty("test.provider.name", "SunJCE")); + // Create a valid PBEKeySpec PBEKeySpec pbeks = new PBEKeySpec( diff --git a/test/jdk/com/sun/crypto/provider/Cipher/PBE/PBEInvalidParamsTest.java b/test/jdk/com/sun/crypto/provider/Cipher/PBE/PBEInvalidParamsTest.java index bb327b24743..cc15ac6dbc7 100644 --- a/test/jdk/com/sun/crypto/provider/Cipher/PBE/PBEInvalidParamsTest.java +++ b/test/jdk/com/sun/crypto/provider/Cipher/PBE/PBEInvalidParamsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -67,7 +67,8 @@ public static void main(String[] args) throws Exception { System.out.println("=>testing " + algo); SecretKeyFactory skf = SecretKeyFactory.getInstance(algo); SecretKey key = skf.generateSecret(ks); - Cipher c = Cipher.getInstance(algo, "SunJCE"); + Cipher c = Cipher.getInstance(algo, + System.getProperty("test.provider.name", "SunJCE")); try { c.init(Cipher.ENCRYPT_MODE, key, INVALID_PARAMS); throw new Exception("Test Failed: expected IAPE is " + diff --git a/test/jdk/com/sun/crypto/provider/Cipher/PBE/PBEKeyCleanupTest.java b/test/jdk/com/sun/crypto/provider/Cipher/PBE/PBEKeyCleanupTest.java index 03da1d9c9a9..77cf745fb3b 100644 --- a/test/jdk/com/sun/crypto/provider/Cipher/PBE/PBEKeyCleanupTest.java +++ b/test/jdk/com/sun/crypto/provider/Cipher/PBE/PBEKeyCleanupTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,6 +23,7 @@ /* * @test + * @library /test/lib * @modules java.base/com.sun.crypto.provider:+open * @run main/othervm PBEKeyCleanupTest * @summary Verify that key storage is cleared @@ -38,6 +39,7 @@ import javax.crypto.SecretKey; import javax.crypto.SecretKeyFactory; import javax.crypto.spec.PBEKeySpec; +import jdk.test.lib.security.SecurityUtils; /** * Test that the array holding the key bytes is cleared when it is @@ -45,7 +47,8 @@ */ public class PBEKeyCleanupTest { - private final static String SunJCEProvider = "SunJCE"; + private final static String PROVIDER_NAME = + System.getProperty("test.provider.name", "SunJCE"); private static final String PASS_PHRASE = "some hidden string"; private static final int ITERATION_COUNT = 1000; @@ -60,19 +63,19 @@ private static void testPBESecret(String algorithm) throws Exception { char[] password = new char[] {'f', 'o', 'o'}; PBEKeySpec pbeKeySpec = new PBEKeySpec(password); SecretKeyFactory keyFac = - SecretKeyFactory.getInstance(algorithm, SunJCEProvider); + SecretKeyFactory.getInstance(algorithm, PROVIDER_NAME); testCleanupSecret(algorithm, keyFac.generateSecret(pbeKeySpec)); } private static void testPBKSecret(String algorithm) throws Exception { - byte[] salt = new byte[8]; + byte[] salt = new byte[SecurityUtils.getTestSaltSize()]; new Random().nextBytes(salt); char[] password = new char[] {'f', 'o', 'o'}; PBEKeySpec pbeKeySpec = new PBEKeySpec(PASS_PHRASE.toCharArray(), salt, ITERATION_COUNT, KEY_SIZE); SecretKeyFactory keyFac = - SecretKeyFactory.getInstance(algorithm, SunJCEProvider); + SecretKeyFactory.getInstance(algorithm, PROVIDER_NAME); testCleanupSecret(algorithm, keyFac.generateSecret(pbeKeySpec)); } diff --git a/test/jdk/com/sun/crypto/provider/Cipher/PBE/PBEKeysAlgorithmNames.java b/test/jdk/com/sun/crypto/provider/Cipher/PBE/PBEKeysAlgorithmNames.java index 9e2debc40f1..2a5a83e45b9 100644 --- a/test/jdk/com/sun/crypto/provider/Cipher/PBE/PBEKeysAlgorithmNames.java +++ b/test/jdk/com/sun/crypto/provider/Cipher/PBE/PBEKeysAlgorithmNames.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -59,7 +59,8 @@ public static void main(String[] argv) throws Exception { for (String s : algs) { System.out.println("Testing " + s); - SecretKeyFactory skf = SecretKeyFactory.getInstance(s, "SunJCE"); + SecretKeyFactory skf = SecretKeyFactory.getInstance(s, + System.getProperty("test.provider.name", "SunJCE")); System.out.println(" Checking skf.getAlgorithm()"); if (!skf.getAlgorithm().equalsIgnoreCase(s)) { diff --git a/test/jdk/com/sun/crypto/provider/Cipher/PBE/PBEParametersTest.java b/test/jdk/com/sun/crypto/provider/Cipher/PBE/PBEParametersTest.java index 757a7663d27..f380ad58111 100644 --- a/test/jdk/com/sun/crypto/provider/Cipher/PBE/PBEParametersTest.java +++ b/test/jdk/com/sun/crypto/provider/Cipher/PBE/PBEParametersTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -61,7 +61,8 @@ public static void main(String[] args) throws Exception { String algo = PBE_ALGOS[i]; SecretKeyFactory skf = SecretKeyFactory.getInstance(algo); SecretKey key = skf.generateSecret(ks); - Cipher c = Cipher.getInstance(algo, "SunJCE"); + Cipher c = Cipher.getInstance(algo, + System.getProperty("test.provider.name", "SunJCE")); c.init(Cipher.ENCRYPT_MODE, key); c.doFinal(new byte[10]); // force the generation of parameters AlgorithmParameters params = c.getParameters(); diff --git a/test/jdk/com/sun/crypto/provider/Cipher/PBE/PBESameBuffer/PBESameBuffer.java b/test/jdk/com/sun/crypto/provider/Cipher/PBE/PBESameBuffer/PBESameBuffer.java index 4fe20f8cbac..cba73f325c6 100644 --- a/test/jdk/com/sun/crypto/provider/Cipher/PBE/PBESameBuffer/PBESameBuffer.java +++ b/test/jdk/com/sun/crypto/provider/Cipher/PBE/PBESameBuffer/PBESameBuffer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -81,7 +81,7 @@ public static void main(String[] args) { public boolean test(String[] args, PrintStream out) { boolean result = true; - Provider p = Security.getProvider("SunJCE"); + Provider p = Security.getProvider(System.getProperty("test.provider.name", "SunJCE")); for (int loop : OFFSETS) { OUTPUT_OFFSET = loop; diff --git a/test/jdk/com/sun/crypto/provider/Cipher/PBE/PBESealedObject.java b/test/jdk/com/sun/crypto/provider/Cipher/PBE/PBESealedObject.java index f7b80ea8ecc..fdf06edda1b 100644 --- a/test/jdk/com/sun/crypto/provider/Cipher/PBE/PBESealedObject.java +++ b/test/jdk/com/sun/crypto/provider/Cipher/PBE/PBESealedObject.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -80,9 +80,12 @@ public class PBESealedObject { "PBEWithHmacSHA512/256AndAES_256", }; + private static final String PROVIDER_NAME = + System.getProperty("test.provider.name", "SunJCE"); + public static void main(String[] args) { PBESealedObject test = new PBESealedObject(); - Provider sunjce = Security.getProvider("SunJCE"); + Provider sunjce = Security.getProvider(PROVIDER_NAME); if (!test.runAll(sunjce, System.out)) { throw new RuntimeException("One or more tests have failed...."); @@ -163,7 +166,7 @@ public boolean runTest(Provider p, String algo, PrintStream out) return false; } - unsealedKey = (SecretKey) so.getObject(key, "SunJCE"); + unsealedKey = (SecretKey) so.getObject(key, PROVIDER_NAME); return Arrays.equals(unsealedKey.getEncoded(), key.getEncoded()); } catch (InvalidKeyException ex) { if (keyAlgo.endsWith("TRIPLEDES") || keyAlgo.endsWith("AES_256")) { diff --git a/test/jdk/com/sun/crypto/provider/Cipher/PBE/PKCS12Cipher.java b/test/jdk/com/sun/crypto/provider/Cipher/PBE/PKCS12Cipher.java index 9f80b0ae152..d19da00b638 100644 --- a/test/jdk/com/sun/crypto/provider/Cipher/PBE/PKCS12Cipher.java +++ b/test/jdk/com/sun/crypto/provider/Cipher/PBE/PKCS12Cipher.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -84,7 +84,8 @@ public static void main(String[] argv) throws Exception { new SecureRandom().nextBytes(input); char[] PASSWD = { 'p','a','s','s','w','o','r','d' }; long start = System.currentTimeMillis(); - Provider p = Security.getProvider("SunJCE"); + Provider p = Security.getProvider( + System.getProperty("test.provider.name", "SunJCE")); System.out.println("Testing provider " + p.getName() + "..."); runTest("PBEWithSHA1AndDESede", input, PASSWD, p); runTest("PBEWithSHA1AndRC2_40", input, PASSWD, p); diff --git a/test/jdk/com/sun/crypto/provider/Cipher/PBE/PKCS12CipherKAT.java b/test/jdk/com/sun/crypto/provider/Cipher/PBE/PKCS12CipherKAT.java index 7943e8d228f..a5911a91ebf 100644 --- a/test/jdk/com/sun/crypto/provider/Cipher/PBE/PKCS12CipherKAT.java +++ b/test/jdk/com/sun/crypto/provider/Cipher/PBE/PKCS12CipherKAT.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -179,7 +179,8 @@ private static Test t(String alg, String plaintext, char[] password, static void runTests(Test[] tests) throws Exception { long start = System.currentTimeMillis(); - Provider p = Security.getProvider("SunJCE"); + Provider p = Security.getProvider( + System.getProperty("test.provider.name", "SunJCE")); System.out.println("Testing provider " + p.getName() + "..."); Cipher.getInstance("PBEWithSHA1AndRC2_40", p); Cipher.getInstance("PBEWithSHA1AndDESede", p); diff --git a/test/jdk/com/sun/crypto/provider/Cipher/PBE/TestCipherKeyWrapperPBEKey.java b/test/jdk/com/sun/crypto/provider/Cipher/PBE/TestCipherKeyWrapperPBEKey.java index 2f1419a9303..f9e6ca78df0 100644 --- a/test/jdk/com/sun/crypto/provider/Cipher/PBE/TestCipherKeyWrapperPBEKey.java +++ b/test/jdk/com/sun/crypto/provider/Cipher/PBE/TestCipherKeyWrapperPBEKey.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -83,7 +83,8 @@ public class TestCipherKeyWrapperPBEKey { public static void main(String[] args) { TestCipherKeyWrapperPBEKey test = new TestCipherKeyWrapperPBEKey(); - Provider sunjce = Security.getProvider("SunJCE"); + Provider sunjce = Security.getProvider( + System.getProperty("test.provider.name", "SunJCE")); if (!test.runAll(sunjce, System.out)) { throw new RuntimeException("One or more tests have failed...."); diff --git a/test/jdk/com/sun/crypto/provider/Cipher/PBE/TestCipherPBECons.java b/test/jdk/com/sun/crypto/provider/Cipher/PBE/TestCipherPBECons.java index e3167068029..788f27bcb47 100644 --- a/test/jdk/com/sun/crypto/provider/Cipher/PBE/TestCipherPBECons.java +++ b/test/jdk/com/sun/crypto/provider/Cipher/PBE/TestCipherPBECons.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -47,7 +47,8 @@ public class TestCipherPBECons { public static void main(String[] args) { TestCipherPBECons test = new TestCipherPBECons(); - Provider sunjce = Security.getProvider("SunJCE"); + Provider sunjce = Security.getProvider( + System.getProperty("test.provider.name", "SunJCE")); if (!test.runAll(sunjce, System.out)) { throw new RuntimeException("One or more tests have failed...."); diff --git a/test/jdk/com/sun/crypto/provider/Cipher/RSA/TestOAEP.java b/test/jdk/com/sun/crypto/provider/Cipher/RSA/TestOAEP.java index 28d22e22f75..0775336ca26 100644 --- a/test/jdk/com/sun/crypto/provider/Cipher/RSA/TestOAEP.java +++ b/test/jdk/com/sun/crypto/provider/Cipher/RSA/TestOAEP.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -47,9 +47,10 @@ public class TestOAEP { public static void main(String[] args) throws Exception { long start = System.currentTimeMillis(); - cp = Security.getProvider("SunJCE"); + cp = Security.getProvider(System.getProperty("test.provider.name", "SunJCE")); System.out.println("Testing provider " + cp.getName() + "..."); - Provider kfp = Security.getProvider("SunRsaSign"); + Provider kfp = Security.getProvider( + System.getProperty("test.provider.name", "SunRsaSign")); KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA", kfp); kpg.initialize(768); KeyPair kp = kpg.generateKeyPair(); diff --git a/test/jdk/com/sun/crypto/provider/Cipher/RSA/TestOAEPPadding.java b/test/jdk/com/sun/crypto/provider/Cipher/RSA/TestOAEPPadding.java index fe1ca35fcc4..2a82f2214d4 100644 --- a/test/jdk/com/sun/crypto/provider/Cipher/RSA/TestOAEPPadding.java +++ b/test/jdk/com/sun/crypto/provider/Cipher/RSA/TestOAEPPadding.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,6 +24,7 @@ /* * @test * @bug 8020081 8022669 + * @library /test/lib * @summary encryption/decryption test for using OAEPPadding with * OAEPParameterSpec specified and not specified during a Cipher.init(). * @author Anthony Scarpino @@ -43,7 +44,7 @@ import javax.crypto.spec.OAEPParameterSpec; import javax.crypto.IllegalBlockSizeException; import javax.crypto.spec.PSource; - +import jdk.test.lib.security.SecurityUtils; public class TestOAEPPadding { private static RSAPrivateKey privateKey; @@ -52,11 +53,14 @@ public class TestOAEPPadding { static boolean failed = false; public static void main(String args[]) throws Exception { - cp = Security.getProvider("SunJCE"); + cp = Security.getProvider( + System.getProperty("test.provider.name", "SunJCE")); System.out.println("Testing provider " + cp.getName() + "..."); - Provider kfp = Security.getProvider("SunRsaSign"); - KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA", kfp); - kpg.initialize(2048); + Provider kfp = Security.getProvider( + System.getProperty("test.providername", "SunRsaSign")); + String kpgAlgorithm = "RSA"; + KeyPairGenerator kpg = KeyPairGenerator.getInstance(kpgAlgorithm, kfp); + kpg.initialize(SecurityUtils.getTestKeySize(kpgAlgorithm)); KeyPair kp = kpg.generateKeyPair(); privateKey = (RSAPrivateKey)kp.getPrivate(); publicKey = (RSAPublicKey)kp.getPublic(); diff --git a/test/jdk/com/sun/crypto/provider/Cipher/RSA/TestOAEPParameterSpec.java b/test/jdk/com/sun/crypto/provider/Cipher/RSA/TestOAEPParameterSpec.java index 9f17da2a711..8578930dbc1 100644 --- a/test/jdk/com/sun/crypto/provider/Cipher/RSA/TestOAEPParameterSpec.java +++ b/test/jdk/com/sun/crypto/provider/Cipher/RSA/TestOAEPParameterSpec.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,7 +44,8 @@ private static boolean runTest(String mdName, MGF1ParameterSpec mgfSpec, byte[] p) throws Exception { OAEPParameterSpec spec = new OAEPParameterSpec(mdName, "MGF1", mgfSpec, new PSource.PSpecified(p)); - cp = Security.getProvider("SunJCE"); + cp = Security.getProvider( + System.getProperty("test.provider.name", "SunJCE")); System.out.println("Testing provider " + cp.getName() + "..."); AlgorithmParameters ap = AlgorithmParameters.getInstance("OAEP", cp); diff --git a/test/jdk/com/sun/crypto/provider/Cipher/RSA/TestOAEPWithParams.java b/test/jdk/com/sun/crypto/provider/Cipher/RSA/TestOAEPWithParams.java index 308171d766e..6cf66178da7 100644 --- a/test/jdk/com/sun/crypto/provider/Cipher/RSA/TestOAEPWithParams.java +++ b/test/jdk/com/sun/crypto/provider/Cipher/RSA/TestOAEPWithParams.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,6 +24,7 @@ /* * @test * @bug 4923484 8146293 + * @library /test/lib * @summary encryption/decryption test for using OAEPParameterSpec. * @author Valerie Peng */ @@ -35,6 +36,7 @@ import javax.crypto.*; import javax.crypto.spec.PSource; import javax.crypto.spec.OAEPParameterSpec; +import jdk.test.lib.security.SecurityUtils; public class TestOAEPWithParams { @@ -54,11 +56,14 @@ public class TestOAEPWithParams { }; public static void main(String[] args) throws Exception { long start = System.currentTimeMillis(); - cp = Security.getProvider("SunJCE"); + cp = Security.getProvider( + System.getProperty("test.provider.name", "SunJCE")); System.out.println("Testing provider " + cp.getName() + "..."); - Provider kfp = Security.getProvider("SunRsaSign"); - KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA", kfp); - kpg.initialize(768); + Provider kfp = Security.getProvider( + System.getProperty("test.provider.name", "SunRsaSign")); + String kpgAlgorithm = "RSA"; + KeyPairGenerator kpg = KeyPairGenerator.getInstance(kpgAlgorithm, kfp); + kpg.initialize(SecurityUtils.getTestKeySize(kpgAlgorithm)); KeyPair kp = kpg.generateKeyPair(); privateKey = kp.getPrivate(); publicKey = kp.getPublic(); diff --git a/test/jdk/com/sun/crypto/provider/Cipher/RSA/TestOAEP_KAT.java b/test/jdk/com/sun/crypto/provider/Cipher/RSA/TestOAEP_KAT.java index 6d43ce1a715..3cbbfc3ba3f 100644 --- a/test/jdk/com/sun/crypto/provider/Cipher/RSA/TestOAEP_KAT.java +++ b/test/jdk/com/sun/crypto/provider/Cipher/RSA/TestOAEP_KAT.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -57,8 +57,10 @@ public class TestOAEP_KAT { public static void main(String[] args) throws Exception { long start = System.currentTimeMillis(); - Provider provider = Security.getProvider("SunJCE"); - Provider kfProvider = Security.getProvider("SunRsaSign"); + Provider provider = Security.getProvider( + System.getProperty("test.provider.name", "SunJCE")); + Provider kfProvider = Security.getProvider( + System.getProperty("test.provider.name", "SunRsaSign")); System.out.println("Testing provider " + provider.getName() + "..."); Cipher c = Cipher.getInstance("RSA/ECB/OAEPwithSHA1andMGF1Padding", provider); KeyFactory kf = KeyFactory.getInstance("RSA", kfProvider); diff --git a/test/jdk/com/sun/crypto/provider/Cipher/RSA/TestRSA.java b/test/jdk/com/sun/crypto/provider/Cipher/RSA/TestRSA.java index 1e4c6ed10b1..610890a5247 100644 --- a/test/jdk/com/sun/crypto/provider/Cipher/RSA/TestRSA.java +++ b/test/jdk/com/sun/crypto/provider/Cipher/RSA/TestRSA.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -101,20 +101,28 @@ private static int nextNibble(StringReader r) throws IOException { } private final static BigInteger N = new BigInteger - ("116231208661367609700141079576488663663527180869991078124978203037949869" - +"312762870627991319537001781149083155962615105864954367253799351549459177" - +"839995715202060014346744789001273681801687605044315560723525700773069112" - +"214443196787519930666193675297582113726306864236010438506452172563580739" - +"994193451997175316921"); + ("188266606413163647033284152746165049309898453322378171182320013745371408" + +"184225151227340555539225381200565037956400694325061098310480360339435446" + +"755336872372614880713694669514510970895097323213784523223711244354375506" + +"545371740274561954822416119304686041493350049135717091225288845575963270" + +"990119098295690603875646206002898855577388327774594330896529948536446408" + +"529165060686851725546480612209956477350581924733034990053737541249952501" + +"521769091148873248215142518797910690254486909784694829645856181407041627" + +"170373444275842961547787746324163594572697634605250977434548015081503826" + +"85269006571608614747965903308253511034583"); private final static BigInteger E = BigInteger.valueOf(65537); private final static BigInteger D = new BigInteger - ("528278531576995741358027120152717979850387435582102361125581844437708890" - +"736418759997555187916546691958396015481089485084669078137376029510618510" - +"203389286674134146181629472813419906337170366867244770096128371742241254" - +"843638089774095747779777512895029847721754360216404183209801002443859648" - +"26168432372077852785"); + ("559658959270449023652159986632594861346314765962941829914811303419116045" + +"486272857832294696380057096672262714220410818939360476461317579410769250" + +"330981320689411092912185059149606517928125605236733543203155054153225543" + +"370812803235323701309554652228655108862291812277980776744407549833834128" + +"186640306349843950814414209051640048163781518404082259622597528271617305" + +"214590875955949331568915021275293633454662841999317653268823194135508673" + +"577887397954709453731172900970199673444683653554380810128925964066225098" + +"009484055412274405773246950554037029408478181447349886871279557912030178" + +"079306593910311097342934485929224862873"); private final static Random RANDOM = new Random(); @@ -154,21 +162,22 @@ public static void testKat(String alg, int mode, Key key, String in, String out, } private final static String in2 = "0f:7d:6c:20:75:99:a5:bc:c1:53:b0:4e:8d:ef:98:fb:cf:2d:e5:1d:d4:bf:71:56:12:b7:a3:c3:e4:53:1b:07:d3:bb:94:a7:a7:28:75:1e:83:46:c9:80:4e:3f:ac:b2:47:06:9f:1b:68:38:73:b8:69:9e:6b:8b:8b:23:60:31:ae:ea:36:24:6f:85:af:de:a5:2a:88:7d:6a:9f:8a:9f:61:f6:59:3f:a8:ce:91:75:49:e9:34:b8:9f:b6:21:8c"; - private final static String out2 = "7d:84:d1:3a:dc:ac:46:09:3a:0c:e5:4b:85:5d:fa:bb:52:f1:0f:de:d9:87:ef:b3:f7:c8:e3:9a:29:be:e9:b5:51:57:fd:07:5b:3c:1c:1c:56:aa:0c:a6:3f:79:40:16:ee:2c:2c:2e:fe:b8:3e:fd:45:90:1c:e7:87:1d:0a:0a:c5:de:9d:2b:a9:dd:77:d2:89:ba:98:fe:78:5b:a3:91:b4:ac:b5:ae:ce:45:21:f7:74:97:3e:a9:58:59:bc:14:13:02:3f:09:7b:97:90:b3:bd:53:cb:15:c0:6e:36:ea:d4:a3:3e:fc:94:85:a9:66:7f:57:b4:2a:ae:70:2e:fb"; + private final static String out2 = "4d:17:15:23:d9:f6:97:4d:4b:5b:9b:37:bd:a7:c5:33:b9:40:1f:c4:63:fa:7c:2a:fb:19:0b:d8:c4:3a:bd:e7:46:6b:1b:09:20:93:39:7c:e5:5f:7b:83:a7:a6:f6:f5:42:20:e7:7f:d3:14:9a:14:25:f9:31:9e:3c:c9:04:20:be:31:ac:77:45:37:4d:76:1b:10:3a:aa:42:c7:df:4c:61:a4:35:4d:28:41:c2:f9:b7:ce:00:94:42:06:c7:35:06:ca:f2:9e:96:c3:89:54:10:82:d8:de:f3:6c:23:8c:47:41:5a:13:fa:33:e0:a5:7f:ec:43:5d:b0:ea:c9:43:17:72:73:ce:11:48:fb:19:ee:13:6a:92:13:06:5c:55:dc:9e:86:b9:fb:44:62:44:9e:a9:e8:bd:6a:c0:c1:64:4b:fd:a9:5d:ef:59:1e:16:fe:64:c1:07:31:9e:9f:4d:4e:28:34:ea:39:e0:65:68:d4:8b:02:0b:8b:ed:bb:a6:a6:4a:29:b9:b5:08:f3:7a:a8:fd:03:3e:0d:d0:9e:25:47:2c:45:f2:40:39:58:e8:95:64:04:2b:50:1e:a5:ff:00:a4:cf:a9:13:4b:17:3a:e8:d1:2c:c1:4a:ab:1c:07:b4:b5:f6:c9:3f:38:48:89:55:59:00:c1:25:c9:d7:68"; private final static String in1 = "17:a3:a7:b1:86:29:06:c5:81:33:cd:2f:da:32:7c:0e:26:a8:18:aa:37:9b:dd:4a:b0:b0:a7:1c:14:82:6c:d9:c9:14:9f:55:19:91:02:0d:d9:d7:95:c2:2b:a6:fa:ba:a3:51:00:83:6b:ec:97:27:40:a3:8f:ba:b1:09:15:11:44:33:c6:3c:47:95:50:71:50:5a:f4:aa:00:4e:b9:48:6a:b1:34:e9:d0:c8:b8:92:bf:95:f3:3d:91:66:93:2b"; - private final static String out1 = "28:b7:b4:73:f2:16:11:c0:67:70:96:ee:dc:3e:23:87:9f:30:a7:e5:f0:db:aa:67:33:27:0e:75:79:af:29:f5:88:3d:93:22:14:d2:59:b4:eb:ce:95:7f:24:74:df:f2:aa:4d:e6:65:5a:63:6d:64:30:ef:31:f1:a6:df:17:42:b6:d1:ed:22:1f:b0:96:69:9d:f8:ce:ff:3a:47:96:51:ba:d9:8d:57:39:40:dc:fc:d3:03:92:39:f4:dd:4b:1b:07:8b:33:60:27:2d:5f:c6:cf:17:92:c6:12:69:a3:54:2e:b8:0f:ca:d9:46:0f:da:95:34:d0:84:35:9c:f6:44"; + private final static String out1 = "18:6d:d2:89:43:cb:ec:5c:ff:3d:fd:d5:23:2d:aa:fc:db:a7:63:5f:c7:2d:6f:81:c2:9f:aa:47:ed:fc:79:39:8a:6d:8f:c3:d0:f9:64:c3:e1:5f:1a:b3:20:03:1e:8a:3a:c5:58:ef:78:6b:fc:50:98:0a:11:d3:30:d9:68:44:9b:93:a6:b3:92:8f:09:0c:7a:d0:64:ac:e2:c7:b5:6a:37:35:00:3b:4e:d7:64:fb:54:c2:54:90:b9:71:6a:48:c4:6c:1e:e4:e6:4c:3f:fc:34:69:16:b9:53:8c:9f:30:4e:2e:7e:9c:fb:5f:26:18:c0:6e:69:32:18:30:40:59:8c:d1:c2:7a:41:75:06:9d:1c:0f:14:74:a9:f0:47:3a:97:0d:c4:c6:3f:24:ee:ed:c5:f8:2c:b6:ae:1d:e5:64:33:cd:e1:e0:21:d6:10:c0:8b:59:06:59:81:73:28:b4:f4:ef:fa:e8:67:a8:65:a5:e4:3c:c3:7e:99:f8:55:7a:e9:0d:41:3a:bf:c1:8c:41:f3:71:32:b6:c0:05:8b:91:8a:90:35:60:95:52:78:8e:a7:e5:a9:a1:bf:a3:de:55:c6:02:03:d5:98:01:59:fb:91:da:37:9e:3f:39:85:e1:3f:79:23:6c:0e:68:25:4c:13:3a:52:a2:f8:d9:4c:ce"; - private final static String rin1 = "09:01:06:53:a7:96:09:63:ef:e1:3f:e9:8d:95:22:d1:0e:1b:87:c1:a2:41:b2:09:97:a3:5e:e0:a4:1d:59:91:21:e4:ca:87:bf:77:4a:7e:a2:22:ff:59:1e:bd:a4:80:aa:93:4a:41:56:95:5b:f4:57:df:fc:52:2f:46:9b:45:d7:03:ae:22:8e:67:9e:6c:b9:95:4f:bd:8e:e8:67:90:5b:fe:de:2f:11:22:2e:9d:30:93:6d:c0:48:00:cb:08:b9:c4:36:e9:03:7c:08:2d:68:42:cb:71:d0:7d:47:22:c1:58:c5:b8:2f:28:3e:98:78:11:6d:71:5b:3b:36:3c"; - private final static String rout1 = "4a:21:64:20:56:5f:27:0c:90:1d:f3:1b:64:8e:16:d3:af:79:ca:c6:65:56:19:77:8f:25:35:70:be:f3:15:b3:e3:d8:8f:04:ec:c3:60:59:d0:9a:66:be:1c:ad:f7:09:46:a9:09:46:12:5f:28:b6:28:b1:53:fb:fe:07:73:b8:8b:f8:83:64:8e:2d:45:ca:1a:fd:85:4a:2c:fa:fc:e6:58:f7:e4:83:68:8c:38:49:2b:f3:5c:c1:2d:24:6a:cd:22:6d:cb:f4:f1:8c:9e:1a:94:a7:4b:6f:d1:b4:b4:ab:56:8b:a3:a9:89:88:c3:5d:a8:47:2a:67:50:32:71:19"; + private final static String rin1 = "09:01:06:53:a7:96:09:63:ef:e1:3f:e9:8d:95:22:d1:0e:1b:87:c1:a2:41:b2:09:97:a3:5e:e0:a4:1d:59:91:21:e4:ca:87:bf:77:4a:7e:a2:22:ff:59:1e:bd:a4:80:aa:93:4a:41:56:95:5b:f4:57:df:fc:52:2f:46:9b:45:d7:03:ae:22:8e:67:9e:6c:b9:95:4f:bd:8e:e8:67:90:5b:fe:de:2f:11:22:2e:9d:30:93:6d:c0:48:00:cb:08:b9:c4:36:e9:03:7c:08:2d:68:42:cb:71:d0:7d:47:22:c1:58:c5:b8:2f:28:3e:98:78:11:6d:71:5b:3b:36:3c:09:01:06:53:a7:96:09:63:ef:e1:3f:e9:8d:95:22:d1:0e:1b:87:c1:a2:41:b2:09:97:a3:5e:e0:a4:1d:59:91:21:e4:ca:87:bf:77:4a:7e:a2:22:ff:59:1e:bd:a4:80:aa:93:4a:41:56:95:5b:f4:57:df:fc:52:2f:46:9b:45:d7:03:ae:22:8e:67:9e:6c:b9:95:4f:bd:8e:e8:67:90:5b:fe:de:2f:11:22:2e:9d:30:93:6d:c0:48:00:cb:08:b9:c4:36:e9:03:7c:08:2d:68:42:cb:71:d0:7d:47:22:c1:58:c5:b8:2f:28:3e:98:78:11:6d:71:5b:3b:36:3c"; + private final static String rout1 = "19:dd:a2:f9:57:d4:6b:60:85:ec:2d:5d:f9:64:f8:a0:c0:33:36:a2:8c:59:0f:74:9b:62:a8:ad:42:ed:be:34:0e:dc:13:db:d5:b9:aa:64:38:35:18:d7:6c:1d:da:5b:ff:f2:98:f5:fc:67:36:fb:9f:84:df:84:a3:af:ce:02:e5:05:ca:a7:e4:29:c0:5c:55:6a:8d:dc:8f:f7:6e:d4:ee:2e:6c:5b:ea:f8:bf:4c:7d:5f:af:6a:c3:77:02:80:33:be:13:4c:98:cf:dc:aa:e8:7d:73:69:6e:30:2c:35:c5:90:83:45:0d:64:04:af:b6:94:c3:a8:e2:d4:08:98:1d:b1:73:e3:fc:10:1f:71:0f:d0:13:f3:58:80:c4:a3:a9:02:52:cf:aa:41:b6:9b:69:33:9d:2a:d6:f6:02:07:ec:ce:19:01:f1:2f:90:27:fe:00:a5:d7:8d:01:97:36:fd:88:34:2f:f3:ab:38:ed:9d:69:91:af:b2:0d:ca:92:ca:9e:e7:24:37:d6:e3:c7:02:30:69:5b:ea:b4:b2:68:5f:4e:8c:cc:fd:bb:2e:96:2f:a3:c6:f7:71:93:24:5c:ca:8f:bc:f9:d8:bd:d3:b9:d1:16:ba:5a:ac:62:41:b4:d8:56:45:74:55:c2:a5:ef:23:f5:e3:27:ce:99:97:e9"; - private final static String rin2 = "1b:49:a6:7a:83:1c:b6:28:47:16:2f:be:6a:d3:28:a6:83:07:4f:50:be:5c:99:26:2a:15:b8:21:a8:cc:8a:45:93:07:ff:32:67:3c:a4:92:d2:cd:43:eb:f5:2e:09:79:c8:32:3a:9d:00:4c:f5:6e:65:b2:ca:9c:c2:d5:35:8e:fe:6c:ba:1a:7b:65:c1:4f:e9:6c:cb:5d:9f:13:5d:5f:be:32:cd:91:ed:8b:d7:d7:e9:d6:5c:cc:11:7b:d9:ff:7a:93:de:e4:81:92:56:0c:52:47:75:56:a8:e0:9a:55:16:0c:43:df:ae:be:a1:6a:9d:5a:be:fc:51:ea:52:0c"; - private final static String rout2 = "65:28:b9:48:8d:68:3f:5e:9a:85:e7:09:78:4c:0c:0e:60:6c:89:43:3c:d3:72:b9:2f:5a:eb:4f:15:77:93:9d:47:05:a6:52:48:72:ee:ce:e8:5a:6d:28:b0:06:5a:a1:93:58:a1:61:3f:9b:42:0d:c1:ec:32:0a:7a:1e:38:45:47:87:52:16:62:c9:44:c6:04:4d:82:64:01:f4:b1:26:dc:7f:61:82:52:7a:f6:6b:ab:22:98:87:93:63:4c:3f:92:c7:5b:cc:e5:2b:15:db:f7:d3:c7:b5:38:6f:15:3b:1e:88:3d:31:0c:b4:f9:6d:66:41:b7:1b:a0:4a:b8:16"; + private final static String rin2 = "1b:49:a6:7a:83:1c:b6:28:47:16:2f:be:6a:d3:28:a6:83:07:4f:50:be:5c:99:26:2a:15:b8:21:a8:cc:8a:45:93:07:ff:32:67:3c:a4:92:d2:cd:43:eb:f5:2e:09:79:c8:32:3a:9d:00:4c:f5:6e:65:b2:ca:9c:c2:d5:35:8e:fe:6c:ba:1a:7b:65:c1:4f:e9:6c:cb:5d:9f:13:5d:5f:be:32:cd:91:ed:8b:d7:d7:e9:d6:5c:cc:11:7b:d9:ff:7a:93:de:e4:81:92:56:0c:52:47:75:56:a8:e0:9a:55:16:0c:43:df:ae:be:a1:6a:9d:5a:be:fc:51:ea:52:0c:1b:49:a6:7a:83:1c:b6:28:47:16:2f:be:6a:d3:28:a6:83:07:4f:50:be:5c:99:26:2a:15:b8:21:a8:cc:8a:45:93:07:ff:32:67:3c:a4:92:d2:cd:43:eb:f5:2e:09:79:c8:32:3a:9d:00:4c:f5:6e:65:b2:ca:9c:c2:d5:35:8e:fe:6c:ba:1a:7b:65:c1:4f:e9:6c:cb:5d:9f:13:5d:5f:be:32:cd:91:ed:8b:d7:d7:e9:d6:5c:cc:11:7b:d9:ff:7a:93:de:e4:81:92:56:0c:52:47:75:56:a8:e0:9a:55:16:0c:43:df:ae:be:a1:6a:9d:5a:be:fc:51:ea:52:0c"; + private final static String rout2 = "7a:11:19:cf:76:97:4b:29:48:66:69:e7:f0:db:18:53:d4:50:71:a4:9d:90:47:9f:e6:8a:f3:ba:2e:96:fd:c8:4b:02:7e:06:a9:2b:47:0d:68:3c:6a:f9:21:62:77:0d:4e:e1:1b:82:97:66:13:01:c2:3b:b2:d3:f8:9e:cc:c9:2a:1a:76:05:3f:d4:f7:fb:9d:9b:bf:a8:2d:fd:81:e5:f4:bb:ca:3b:5f:93:ea:ef:88:1c:c1:18:52:38:be:50:42:29:08:d9:65:43:5f:01:7d:50:22:7a:2f:f1:29:14:95:30:c1:b8:fd:eb:da:c1:4e:8a:ef:97:84:f9:cf:34:ab:89:a6:3c:4a:ff:a4:98:a8:7c:c6:2c:c3:e3:10:a9:8b:67:32:47:35:37:15:03:3b:d0:f3:23:fc:bb:42:64:a2:ba:63:3e:94:6e:7a:e6:94:05:79:29:28:d5:99:5b:f9:67:fd:ea:d3:5f:b5:7b:f4:10:9b:0a:1c:20:6b:0c:59:56:76:45:07:56:cb:d0:ab:08:fc:19:8e:f1:27:03:22:f1:e9:23:d3:01:b1:4d:cf:96:f7:a6:44:59:de:2a:52:fd:bb:14:ae:39:c4:e4:0f:4e:10:f7:c6:61:79:0a:a6:4c:ed:ee:d7:40:fe:ef:f3:85:ae:3e:f3:bb:6e:de"; public static void main(String[] args) throws Exception { long start = System.currentTimeMillis(); - p = Security.getProvider("SunJCE"); + p = Security.getProvider( + System.getProperty("test.provider.name", "SunJCE")); System.out.println("Testing provider " + p.getName() + "..."); KeyFactory kf; @@ -189,8 +198,8 @@ public static void main(String[] args) throws Exception { // blocktype 1 testEncDec("RSA/ECB/PKCS1Padding", 96, privateKey, publicKey); - testEncDec("RSA/ECB/NoPadding", 128, publicKey, privateKey); - testEncDec("RSA/ECB/NoPadding", 128, privateKey, publicKey); + testEncDec("RSA/ECB/NoPadding", 256, publicKey, privateKey); + testEncDec("RSA/ECB/NoPadding", 256, privateKey, publicKey); // expected failure, blocktype 2 random padding bytes are different testKat("RSA/ECB/PKCS1Padding", Cipher.ENCRYPT_MODE, publicKey, in2, out2, false); diff --git a/test/jdk/com/sun/crypto/provider/Cipher/TestCipher.java b/test/jdk/com/sun/crypto/provider/Cipher/TestCipher.java index b5e50c842a0..dd3568f2e19 100644 --- a/test/jdk/com/sun/crypto/provider/Cipher/TestCipher.java +++ b/test/jdk/com/sun/crypto/provider/Cipher/TestCipher.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,7 +44,7 @@ */ public abstract class TestCipher { - private final String SUNJCE = "SunJCE"; + private final String PROVIDER_NAME = System.getProperty("test.provider.name", "SunJCE"); private final String ALGORITHM; private final String[] MODES; private final String[] PADDINGS; @@ -138,8 +138,8 @@ private void runTest(String mo, String pad, int keySize) out.println("Testing: " + TRANSFORMATION); // Initialization - Cipher ci = Cipher.getInstance(TRANSFORMATION, SUNJCE); - KeyGenerator kg = KeyGenerator.getInstance(ALGORITHM, SUNJCE); + Cipher ci = Cipher.getInstance(TRANSFORMATION, PROVIDER_NAME); + KeyGenerator kg = KeyGenerator.getInstance(ALGORITHM, PROVIDER_NAME); if (keySize != 0) { kg.init(keySize); } diff --git a/test/jdk/com/sun/crypto/provider/Cipher/TextLength/SameBufferOverwrite.java b/test/jdk/com/sun/crypto/provider/Cipher/TextLength/SameBufferOverwrite.java index d110c05a339..22da35e7e6b 100644 --- a/test/jdk/com/sun/crypto/provider/Cipher/TextLength/SameBufferOverwrite.java +++ b/test/jdk/com/sun/crypto/provider/Cipher/TextLength/SameBufferOverwrite.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,9 +44,11 @@ public class SameBufferOverwrite { SameBufferOverwrite(String algo, String transformation) throws Exception { - KeyGenerator kg = KeyGenerator.getInstance(algo, "SunJCE"); + KeyGenerator kg = KeyGenerator.getInstance(algo, + System.getProperty("test.provider.name", "SunJCE")); skey = kg.generateKey(); - c = Cipher.getInstance(transformation, "SunJCE"); + c = Cipher.getInstance(transformation, + System.getProperty("test.provider.name", "SunJCE")); } /* diff --git a/test/jdk/com/sun/crypto/provider/Cipher/UTIL/StrongOrUnlimited.java b/test/jdk/com/sun/crypto/provider/Cipher/UTIL/StrongOrUnlimited.java index 70908a23746..5c806df25bd 100644 --- a/test/jdk/com/sun/crypto/provider/Cipher/UTIL/StrongOrUnlimited.java +++ b/test/jdk/com/sun/crypto/provider/Cipher/UTIL/StrongOrUnlimited.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,7 +38,8 @@ public static void main(String[] args) throws Exception { // decide if the installed jurisdiction policy file is the // unlimited version boolean isUnlimited = true; - Cipher c = Cipher.getInstance("AES", "SunJCE"); + Cipher c = Cipher.getInstance("AES", + System.getProperty("test.provider.name", "SunJCE")); try { c.init(Cipher.ENCRYPT_MODE, diff --git a/test/jdk/com/sun/crypto/provider/Cipher/UTIL/SunJCEGetInstance.java b/test/jdk/com/sun/crypto/provider/Cipher/UTIL/SunJCEGetInstance.java index d9bf59b63f0..6ba7f9a0d69 100644 --- a/test/jdk/com/sun/crypto/provider/Cipher/UTIL/SunJCEGetInstance.java +++ b/test/jdk/com/sun/crypto/provider/Cipher/UTIL/SunJCEGetInstance.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,9 +40,10 @@ public static void main(String[] args) throws Exception { Cipher jce; try{ + String providerName = System.getProperty("test.provider.name", "SunJCE"); // Remove SunJCE from Provider list - Provider prov = Security.getProvider("SunJCE"); - Security.removeProvider("SunJCE"); + Provider prov = Security.getProvider(providerName); + Security.removeProvider(providerName); // Create our own instance of SunJCE provider. Purposefully not // using SunJCE.getInstance() so we can have our own instance // for the test. diff --git a/test/jdk/com/sun/crypto/provider/KeyAgreement/DHGenSharedSecret.java b/test/jdk/com/sun/crypto/provider/KeyAgreement/DHGenSharedSecret.java index 34e87030636..9fe96d967dc 100644 --- a/test/jdk/com/sun/crypto/provider/KeyAgreement/DHGenSharedSecret.java +++ b/test/jdk/com/sun/crypto/provider/KeyAgreement/DHGenSharedSecret.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,6 +24,7 @@ /* * @test * @bug 0000000 + * @library /test/lib * @summary DHGenSharedSecret * @author Jan Luehe */ @@ -33,40 +34,11 @@ import javax.crypto.*; import javax.crypto.spec.*; import java.math.BigInteger; +import jdk.test.lib.security.DiffieHellmanGroup; +import jdk.test.lib.security.SecurityUtils; public class DHGenSharedSecret { - static byte[] DHPrime = { -(byte)0x00, (byte)0x8D, (byte)0x8A, (byte)0x6C, (byte)0x7F, (byte)0xCC, -(byte)0xA5, (byte)0xBF, (byte)0x9C, (byte)0xE1, (byte)0xFA, (byte)0x3C, -(byte)0xCA, (byte)0x98, (byte)0xB7, (byte)0x99, (byte)0xD1, (byte)0xE5, -(byte)0x2C, (byte)0xC0, (byte)0x26, (byte)0x97, (byte)0x12, (byte)0x80, -(byte)0x12, (byte)0xEF, (byte)0x0B, (byte)0xDE, (byte)0x71, (byte)0x76, -(byte)0xAA, (byte)0x2D, (byte)0x86, (byte)0x41, (byte)0x0E, (byte)0x6A, -(byte)0xC2, (byte)0x12, (byte)0xAA, (byte)0xAA, (byte)0xE4, (byte)0x84, -(byte)0x80, (byte)0x13, (byte)0x95, (byte)0x06, (byte)0xC4, (byte)0x83, -(byte)0xB9, (byte)0xD3, (byte)0x72, (byte)0xC5, (byte)0xC8, (byte)0x85, -(byte)0x96, (byte)0x59, (byte)0x08, (byte)0xFA, (byte)0x9E, (byte)0x3C, -(byte)0xDC, (byte)0x92, (byte)0x28, (byte)0xC3, (byte)0x1D, (byte)0x6F, -(byte)0x44, (byte)0x36, (byte)0x70, (byte)0x40, (byte)0x80, (byte)0xF1, -(byte)0x35 - }; - - static byte[] DHBase = { -(byte)0x72, (byte)0x21, (byte)0xB3, (byte)0xA8, (byte)0x83, (byte)0xDD, -(byte)0x76, (byte)0xF5, (byte)0x0D, (byte)0x9B, (byte)0x81, (byte)0x11, -(byte)0x15, (byte)0x03, (byte)0x6D, (byte)0x4D, (byte)0x46, (byte)0x65, -(byte)0x30, (byte)0xB0, (byte)0xFA, (byte)0xFE, (byte)0xBE, (byte)0xA8, -(byte)0xD9, (byte)0x83, (byte)0x33, (byte)0x54, (byte)0xC7, (byte)0xF6, -(byte)0x81, (byte)0xAC, (byte)0xCC, (byte)0xA3, (byte)0xAE, (byte)0xAA, -(byte)0xC8, (byte)0x11, (byte)0x38, (byte)0xD4, (byte)0x4F, (byte)0xC4, -(byte)0x89, (byte)0xD3, (byte)0x72, (byte)0xEE, (byte)0x22, (byte)0x5A, -(byte)0x68, (byte)0xF7, (byte)0xAC, (byte)0x24, (byte)0x01, (byte)0x9B, -(byte)0xE9, (byte)0x08, (byte)0xFE, (byte)0x58, (byte)0x0A, (byte)0xCF, -(byte)0xB9, (byte)0x52, (byte)0xB4, (byte)0x02, (byte)0x73, (byte)0xA4, -(byte)0xA6, (byte)0xB9, (byte)0x0C, (byte)0x8D, (byte)0xA7, (byte)0xFB, - }; - public static void main(String[] args) throws Exception { DHGenSharedSecret test = new DHGenSharedSecret(); test.run(); @@ -75,8 +47,9 @@ public static void main(String[] args) throws Exception { public void run() throws Exception { long start, end; - BigInteger p = new BigInteger(1, DHPrime); - BigInteger g = new BigInteger(1, DHBase); + DiffieHellmanGroup dhGroup = SecurityUtils.getTestDHGroup(); + BigInteger p = dhGroup.getPrime(); + BigInteger g = new BigInteger(1, dhGroup.getBase().toByteArray()); int l = 512; DHParameterSpec spec = diff --git a/test/jdk/com/sun/crypto/provider/KeyAgreement/DHKeyAgreement2.java b/test/jdk/com/sun/crypto/provider/KeyAgreement/DHKeyAgreement2.java index c7a0c4aeb33..e3439b0140e 100644 --- a/test/jdk/com/sun/crypto/provider/KeyAgreement/DHKeyAgreement2.java +++ b/test/jdk/com/sun/crypto/provider/KeyAgreement/DHKeyAgreement2.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,6 +24,7 @@ /* * @test * @bug 7146728 + * @library /test/lib * @summary DHKeyAgreement2 * @author Jan Luehe * @run main/othervm -Djdk.crypto.KeyAgreement.legacyKDF=true DHKeyAgreement2 @@ -38,13 +39,14 @@ import javax.crypto.*; import javax.crypto.spec.*; import javax.crypto.interfaces.*; +import jdk.test.lib.security.DiffieHellmanGroup; +import jdk.test.lib.security.SecurityUtils; /** * This test utility executes the Diffie-Hellman key agreement protocol * between 2 parties: Alice and Bob. * - * By default, preconfigured parameters (1024 bit prime modulus and base - * generator used by SKIP) are used. + * By default, preconfigured parameters are used. * If this program is called with the "-gen" option, a new set of parameters * are created. */ @@ -59,7 +61,7 @@ public class DHKeyAgreement2 { private DHKeyAgreement2() {} public static void main(String argv[]) throws Exception { - String mode = "USE_SKIP_DH_PARAMS"; + String mode = "USE_PRECONFIGURED_DH_PARAMS"; DHKeyAgreement2 keyAgree = new DHKeyAgreement2(); @@ -80,22 +82,25 @@ public static void main(String argv[]) throws Exception { private void run(String mode) throws Exception { - DHParameterSpec dhSkipParamSpec; + DHParameterSpec dhParameterSpec; + String algorithm = "DH"; + int primeSize = SecurityUtils.getTestKeySize(algorithm); if (mode.equals("GENERATE_DH_PARAMS")) { // Some central authority creates new DH parameters System.err.println("Creating Diffie-Hellman parameters ..."); AlgorithmParameterGenerator paramGen = AlgorithmParameterGenerator.getInstance("DH", SUNJCE); - paramGen.init(512); + paramGen.init(primeSize); AlgorithmParameters params = paramGen.generateParameters(); - dhSkipParamSpec = (DHParameterSpec)params.getParameterSpec + dhParameterSpec = (DHParameterSpec)params.getParameterSpec (DHParameterSpec.class); } else { - // use some pre-generated, default DH parameters - System.err.println("Using SKIP Diffie-Hellman parameters"); - dhSkipParamSpec = new DHParameterSpec(skip1024Modulus, - skip1024Base); + // use some pre-generated, test default DH parameters + DiffieHellmanGroup dhGroup = SecurityUtils.getTestDHGroup(primeSize); + System.err.println("Using " + dhGroup.name() + " Diffie-Hellman parameters"); + dhParameterSpec = new DHParameterSpec(dhGroup.getPrime(), + dhGroup.getBase()); } /* @@ -104,7 +109,7 @@ private void run(String mode) throws Exception { */ System.err.println("ALICE: Generate DH keypair ..."); KeyPairGenerator aliceKpairGen = KeyPairGenerator.getInstance("DH", SUNJCE); - aliceKpairGen.initialize(dhSkipParamSpec); + aliceKpairGen.initialize(dhParameterSpec); KeyPair aliceKpair = aliceKpairGen.generateKeyPair(); System.out.println("Alice DH public key:\n" + aliceKpair.getPublic().toString()); @@ -274,47 +279,4 @@ private void usage() { System.err.print("DHKeyAgreement usage: "); System.err.println("[-gen]"); } - - // The 1024 bit Diffie-Hellman modulus values used by SKIP - private static final byte skip1024ModulusBytes[] = { - (byte)0xF4, (byte)0x88, (byte)0xFD, (byte)0x58, - (byte)0x4E, (byte)0x49, (byte)0xDB, (byte)0xCD, - (byte)0x20, (byte)0xB4, (byte)0x9D, (byte)0xE4, - (byte)0x91, (byte)0x07, (byte)0x36, (byte)0x6B, - (byte)0x33, (byte)0x6C, (byte)0x38, (byte)0x0D, - (byte)0x45, (byte)0x1D, (byte)0x0F, (byte)0x7C, - (byte)0x88, (byte)0xB3, (byte)0x1C, (byte)0x7C, - (byte)0x5B, (byte)0x2D, (byte)0x8E, (byte)0xF6, - (byte)0xF3, (byte)0xC9, (byte)0x23, (byte)0xC0, - (byte)0x43, (byte)0xF0, (byte)0xA5, (byte)0x5B, - (byte)0x18, (byte)0x8D, (byte)0x8E, (byte)0xBB, - (byte)0x55, (byte)0x8C, (byte)0xB8, (byte)0x5D, - (byte)0x38, (byte)0xD3, (byte)0x34, (byte)0xFD, - (byte)0x7C, (byte)0x17, (byte)0x57, (byte)0x43, - (byte)0xA3, (byte)0x1D, (byte)0x18, (byte)0x6C, - (byte)0xDE, (byte)0x33, (byte)0x21, (byte)0x2C, - (byte)0xB5, (byte)0x2A, (byte)0xFF, (byte)0x3C, - (byte)0xE1, (byte)0xB1, (byte)0x29, (byte)0x40, - (byte)0x18, (byte)0x11, (byte)0x8D, (byte)0x7C, - (byte)0x84, (byte)0xA7, (byte)0x0A, (byte)0x72, - (byte)0xD6, (byte)0x86, (byte)0xC4, (byte)0x03, - (byte)0x19, (byte)0xC8, (byte)0x07, (byte)0x29, - (byte)0x7A, (byte)0xCA, (byte)0x95, (byte)0x0C, - (byte)0xD9, (byte)0x96, (byte)0x9F, (byte)0xAB, - (byte)0xD0, (byte)0x0A, (byte)0x50, (byte)0x9B, - (byte)0x02, (byte)0x46, (byte)0xD3, (byte)0x08, - (byte)0x3D, (byte)0x66, (byte)0xA4, (byte)0x5D, - (byte)0x41, (byte)0x9F, (byte)0x9C, (byte)0x7C, - (byte)0xBD, (byte)0x89, (byte)0x4B, (byte)0x22, - (byte)0x19, (byte)0x26, (byte)0xBA, (byte)0xAB, - (byte)0xA2, (byte)0x5E, (byte)0xC3, (byte)0x55, - (byte)0xE9, (byte)0x2F, (byte)0x78, (byte)0xC7 - }; - - // The SKIP 1024 bit modulus - private static final BigInteger skip1024Modulus - = new BigInteger(1, skip1024ModulusBytes); - - // The base used with the SKIP 1024 bit modulus - private static final BigInteger skip1024Base = BigInteger.valueOf(2); } diff --git a/test/jdk/com/sun/crypto/provider/KeyAgreement/DHKeyAgreement3.java b/test/jdk/com/sun/crypto/provider/KeyAgreement/DHKeyAgreement3.java index 6cdcf1dad2e..d4f70ea2563 100644 --- a/test/jdk/com/sun/crypto/provider/KeyAgreement/DHKeyAgreement3.java +++ b/test/jdk/com/sun/crypto/provider/KeyAgreement/DHKeyAgreement3.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,6 +24,7 @@ /* * @test * @bug 0000000 + * @library /test/lib * @summary DHKeyAgreement3 * @author Jan Luehe */ @@ -37,13 +38,14 @@ import javax.crypto.*; import javax.crypto.spec.*; import javax.crypto.interfaces.*; +import jdk.test.lib.security.DiffieHellmanGroup; +import jdk.test.lib.security.SecurityUtils; /** * This test utility executes the Diffie-Hellman key agreement protocol * between 3 parties: Alice, Bob, and Carol. * - * We use the same 1024 bit prime modulus and base generator that are used by - * SKIP. + * By default, preconfigured parameters are used. */ public class DHKeyAgreement3 { @@ -61,27 +63,27 @@ public static void main(String argv[]) throws Exception { private void run() throws Exception { - DHParameterSpec dhSkipParamSpec; - - System.err.println("Using SKIP Diffie-Hellman parameters"); - dhSkipParamSpec = new DHParameterSpec(skip1024Modulus, skip1024Base); + DiffieHellmanGroup dhGroup = SecurityUtils.getTestDHGroup(); + DHParameterSpec dhParamSpec; + System.err.println("Using " + dhGroup.name() + " Diffie-Hellman parameters"); + dhParamSpec = new DHParameterSpec(dhGroup.getPrime(), dhGroup.getBase()); // Alice creates her own DH key pair System.err.println("ALICE: Generate DH keypair ..."); KeyPairGenerator aliceKpairGen = KeyPairGenerator.getInstance("DH", "SunJCE"); - aliceKpairGen.initialize(dhSkipParamSpec); + aliceKpairGen.initialize(dhParamSpec); KeyPair aliceKpair = aliceKpairGen.generateKeyPair(); // Bob creates his own DH key pair System.err.println("BOB: Generate DH keypair ..."); KeyPairGenerator bobKpairGen = KeyPairGenerator.getInstance("DH", "SunJCE"); - bobKpairGen.initialize(dhSkipParamSpec); + bobKpairGen.initialize(dhParamSpec); KeyPair bobKpair = bobKpairGen.generateKeyPair(); // Carol creates her own DH key pair System.err.println("CAROL: Generate DH keypair ..."); KeyPairGenerator carolKpairGen = KeyPairGenerator.getInstance("DH", "SunJCE"); - carolKpairGen.initialize(dhSkipParamSpec); + carolKpairGen.initialize(dhParamSpec); KeyPair carolKpair = carolKpairGen.generateKeyPair(); @@ -178,47 +180,4 @@ private void usage() { System.err.print("DHKeyAgreement usage: "); System.err.println("[-gen]"); } - - // The 1024 bit Diffie-Hellman modulus values used by SKIP - private static final byte skip1024ModulusBytes[] = { - (byte)0xF4, (byte)0x88, (byte)0xFD, (byte)0x58, - (byte)0x4E, (byte)0x49, (byte)0xDB, (byte)0xCD, - (byte)0x20, (byte)0xB4, (byte)0x9D, (byte)0xE4, - (byte)0x91, (byte)0x07, (byte)0x36, (byte)0x6B, - (byte)0x33, (byte)0x6C, (byte)0x38, (byte)0x0D, - (byte)0x45, (byte)0x1D, (byte)0x0F, (byte)0x7C, - (byte)0x88, (byte)0xB3, (byte)0x1C, (byte)0x7C, - (byte)0x5B, (byte)0x2D, (byte)0x8E, (byte)0xF6, - (byte)0xF3, (byte)0xC9, (byte)0x23, (byte)0xC0, - (byte)0x43, (byte)0xF0, (byte)0xA5, (byte)0x5B, - (byte)0x18, (byte)0x8D, (byte)0x8E, (byte)0xBB, - (byte)0x55, (byte)0x8C, (byte)0xB8, (byte)0x5D, - (byte)0x38, (byte)0xD3, (byte)0x34, (byte)0xFD, - (byte)0x7C, (byte)0x17, (byte)0x57, (byte)0x43, - (byte)0xA3, (byte)0x1D, (byte)0x18, (byte)0x6C, - (byte)0xDE, (byte)0x33, (byte)0x21, (byte)0x2C, - (byte)0xB5, (byte)0x2A, (byte)0xFF, (byte)0x3C, - (byte)0xE1, (byte)0xB1, (byte)0x29, (byte)0x40, - (byte)0x18, (byte)0x11, (byte)0x8D, (byte)0x7C, - (byte)0x84, (byte)0xA7, (byte)0x0A, (byte)0x72, - (byte)0xD6, (byte)0x86, (byte)0xC4, (byte)0x03, - (byte)0x19, (byte)0xC8, (byte)0x07, (byte)0x29, - (byte)0x7A, (byte)0xCA, (byte)0x95, (byte)0x0C, - (byte)0xD9, (byte)0x96, (byte)0x9F, (byte)0xAB, - (byte)0xD0, (byte)0x0A, (byte)0x50, (byte)0x9B, - (byte)0x02, (byte)0x46, (byte)0xD3, (byte)0x08, - (byte)0x3D, (byte)0x66, (byte)0xA4, (byte)0x5D, - (byte)0x41, (byte)0x9F, (byte)0x9C, (byte)0x7C, - (byte)0xBD, (byte)0x89, (byte)0x4B, (byte)0x22, - (byte)0x19, (byte)0x26, (byte)0xBA, (byte)0xAB, - (byte)0xA2, (byte)0x5E, (byte)0xC3, (byte)0x55, - (byte)0xE9, (byte)0x2F, (byte)0x78, (byte)0xC7 - }; - - // The SKIP 1024 bit modulus - private static final BigInteger skip1024Modulus - = new BigInteger(1, skip1024ModulusBytes); - - // The base used with the SKIP 1024 bit modulus - private static final BigInteger skip1024Base = BigInteger.valueOf(2); } diff --git a/test/jdk/com/sun/crypto/provider/KeyAgreement/DHKeyAgreementPadding.java b/test/jdk/com/sun/crypto/provider/KeyAgreement/DHKeyAgreementPadding.java index dc963bf6267..c863da6b4b4 100644 --- a/test/jdk/com/sun/crypto/provider/KeyAgreement/DHKeyAgreementPadding.java +++ b/test/jdk/com/sun/crypto/provider/KeyAgreement/DHKeyAgreementPadding.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,21 +34,22 @@ import java.security.KeyPairGenerator; import java.util.Arrays; import java.util.HexFormat; +import jdk.test.lib.security.SecurityUtils; public class DHKeyAgreementPadding { public static void main(String[] args) throws Exception { - - byte[] aliceSecret = new byte[80]; - byte[] bobSecret = new byte[80]; - - KeyAgreement alice = KeyAgreement.getInstance("DiffieHellman"); - KeyAgreement bob = KeyAgreement.getInstance("DiffieHellman"); + String kpgAlgorithm = "DiffieHellman"; + KeyAgreement alice = KeyAgreement.getInstance(kpgAlgorithm); + KeyAgreement bob = KeyAgreement.getInstance(kpgAlgorithm); + int keySizeBits = SecurityUtils.getTestKeySize(kpgAlgorithm); + byte[] aliceSecret = new byte[keySizeBits / 8]; + byte[] bobSecret = new byte[keySizeBits / 8]; // The probability of an error is 0.2% or 1/500. Try more times. for (int i = 0; i < 5000; i++) { - KeyPairGenerator keyPairGen = KeyPairGenerator.getInstance("DiffieHellman"); - keyPairGen.initialize(512); + KeyPairGenerator keyPairGen = KeyPairGenerator.getInstance(kpgAlgorithm); + keyPairGen.initialize(keySizeBits); KeyPair aliceKeyPair = keyPairGen.generateKeyPair(); KeyPair bobKeyPair = keyPairGen.generateKeyPair(); diff --git a/test/jdk/com/sun/crypto/provider/KeyAgreement/DHKeyFactory.java b/test/jdk/com/sun/crypto/provider/KeyAgreement/DHKeyFactory.java index e12f3871ec2..356cfc4b20a 100644 --- a/test/jdk/com/sun/crypto/provider/KeyAgreement/DHKeyFactory.java +++ b/test/jdk/com/sun/crypto/provider/KeyAgreement/DHKeyFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,6 +24,7 @@ /* * @test * @bug 0000000 + * @library /test/lib * @summary DHKeyFactory * @author Jan Luehe */ @@ -36,6 +37,8 @@ import javax.crypto.*; import javax.crypto.spec.*; import javax.crypto.interfaces.*; +import jdk.test.lib.security.DiffieHellmanGroup; +import jdk.test.lib.security.SecurityUtils; /** * This test creates a DH keypair, retrieves the encodings of the DH public and @@ -55,15 +58,13 @@ public static void main(String argv[]) throws Exception { private void run() throws Exception { - DHParameterSpec dhSkipParamSpec; + DiffieHellmanGroup dhGroup = SecurityUtils.getTestDHGroup(); + DHParameterSpec dhParamSpec = new DHParameterSpec(dhGroup.getPrime(), dhGroup.getBase()); + System.out.println("Using " + dhGroup.name() + " Diffie-Hellman parameters"); - // use some pre-generated, default DH parameters - System.err.println("Using SKIP Diffie-Hellman parameters"); - dhSkipParamSpec = new DHParameterSpec(skip1024Modulus, - skip1024Base); - - KeyPairGenerator kpgen = KeyPairGenerator.getInstance("DH", "SunJCE"); - kpgen.initialize(dhSkipParamSpec); + KeyPairGenerator kpgen = KeyPairGenerator.getInstance("DH", + System.getProperty("test.provider.name", "SunJCE")); + kpgen.initialize(dhParamSpec); KeyPair kp = kpgen.generateKeyPair(); // get the public key encoding @@ -72,7 +73,8 @@ private void run() throws Exception { // get the private key encoding byte[] privKeyEnc = kp.getPrivate().getEncoded(); - KeyFactory kfac = KeyFactory.getInstance("DH", "SunJCE"); + KeyFactory kfac = KeyFactory.getInstance("DH", + System.getProperty("test.provider.name", "SunJCE")); X509EncodedKeySpec x509KeySpec = new X509EncodedKeySpec(pubKeyEnc); PublicKey pubKey = kfac.generatePublic(x509KeySpec); @@ -80,47 +82,4 @@ private void run() throws Exception { PKCS8EncodedKeySpec pkcsKeySpec = new PKCS8EncodedKeySpec(privKeyEnc); PrivateKey privKey = kfac.generatePrivate(pkcsKeySpec); } - - // The 1024 bit Diffie-Hellman modulus values used by SKIP - private static final byte skip1024ModulusBytes[] = { - (byte)0xF4, (byte)0x88, (byte)0xFD, (byte)0x58, - (byte)0x4E, (byte)0x49, (byte)0xDB, (byte)0xCD, - (byte)0x20, (byte)0xB4, (byte)0x9D, (byte)0xE4, - (byte)0x91, (byte)0x07, (byte)0x36, (byte)0x6B, - (byte)0x33, (byte)0x6C, (byte)0x38, (byte)0x0D, - (byte)0x45, (byte)0x1D, (byte)0x0F, (byte)0x7C, - (byte)0x88, (byte)0xB3, (byte)0x1C, (byte)0x7C, - (byte)0x5B, (byte)0x2D, (byte)0x8E, (byte)0xF6, - (byte)0xF3, (byte)0xC9, (byte)0x23, (byte)0xC0, - (byte)0x43, (byte)0xF0, (byte)0xA5, (byte)0x5B, - (byte)0x18, (byte)0x8D, (byte)0x8E, (byte)0xBB, - (byte)0x55, (byte)0x8C, (byte)0xB8, (byte)0x5D, - (byte)0x38, (byte)0xD3, (byte)0x34, (byte)0xFD, - (byte)0x7C, (byte)0x17, (byte)0x57, (byte)0x43, - (byte)0xA3, (byte)0x1D, (byte)0x18, (byte)0x6C, - (byte)0xDE, (byte)0x33, (byte)0x21, (byte)0x2C, - (byte)0xB5, (byte)0x2A, (byte)0xFF, (byte)0x3C, - (byte)0xE1, (byte)0xB1, (byte)0x29, (byte)0x40, - (byte)0x18, (byte)0x11, (byte)0x8D, (byte)0x7C, - (byte)0x84, (byte)0xA7, (byte)0x0A, (byte)0x72, - (byte)0xD6, (byte)0x86, (byte)0xC4, (byte)0x03, - (byte)0x19, (byte)0xC8, (byte)0x07, (byte)0x29, - (byte)0x7A, (byte)0xCA, (byte)0x95, (byte)0x0C, - (byte)0xD9, (byte)0x96, (byte)0x9F, (byte)0xAB, - (byte)0xD0, (byte)0x0A, (byte)0x50, (byte)0x9B, - (byte)0x02, (byte)0x46, (byte)0xD3, (byte)0x08, - (byte)0x3D, (byte)0x66, (byte)0xA4, (byte)0x5D, - (byte)0x41, (byte)0x9F, (byte)0x9C, (byte)0x7C, - (byte)0xBD, (byte)0x89, (byte)0x4B, (byte)0x22, - (byte)0x19, (byte)0x26, (byte)0xBA, (byte)0xAB, - (byte)0xA2, (byte)0x5E, (byte)0xC3, (byte)0x55, - (byte)0xE9, (byte)0x2F, (byte)0x78, (byte)0xC7 - }; - - // The SKIP 1024 bit modulus - private static final BigInteger skip1024Modulus - = new BigInteger(1, skip1024ModulusBytes); - - // The base used with the SKIP 1024 bit modulus - private static final BigInteger skip1024Base = BigInteger.valueOf(2); } diff --git a/test/jdk/com/sun/crypto/provider/KeyAgreement/DHKeyGenSpeed.java b/test/jdk/com/sun/crypto/provider/KeyAgreement/DHKeyGenSpeed.java index b24f0a66fb9..723ce11760b 100644 --- a/test/jdk/com/sun/crypto/provider/KeyAgreement/DHKeyGenSpeed.java +++ b/test/jdk/com/sun/crypto/provider/KeyAgreement/DHKeyGenSpeed.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,6 +24,7 @@ /* * @test * @bug 0000000 + * @library /test/lib * @summary DHKeyGenSpeed * @author Jan Luehe */ @@ -33,42 +34,11 @@ import javax.crypto.*; import javax.crypto.spec.*; import java.math.*; +import jdk.test.lib.security.DiffieHellmanGroup; +import jdk.test.lib.security.SecurityUtils; public class DHKeyGenSpeed { - static byte[] DHPrime = { -(byte)0x00, (byte)0x91, (byte)0x18, (byte)0x26, (byte)0x9A, (byte)0x26, -(byte)0x43, (byte)0xA6, (byte)0x1E, (byte)0x11, (byte)0x02, (byte)0xA0, -(byte)0x88, (byte)0xFE, (byte)0x12, (byte)0xEA, (byte)0x63, (byte)0x20, -(byte)0x6D, (byte)0x4F, (byte)0x40, (byte)0x3C, (byte)0x4F, (byte)0x13, -(byte)0x10, (byte)0x97, (byte)0xEC, (byte)0x3A, (byte)0x38, (byte)0x87, -(byte)0x9B, (byte)0x08, (byte)0x66, (byte)0x0C, (byte)0x82, (byte)0xD0, -(byte)0x57, (byte)0xE0, (byte)0x37, (byte)0x16, (byte)0x8E, (byte)0xB4, -(byte)0xEA, (byte)0xB7, (byte)0xE6, (byte)0xAF, (byte)0x4C, (byte)0xE0, -(byte)0x40, (byte)0x07, (byte)0xF4, (byte)0x81, (byte)0xDD, (byte)0x36, -(byte)0x33, (byte)0xAD, (byte)0x92, (byte)0xC6, (byte)0x0F, (byte)0xB5, -(byte)0xE4, (byte)0x0F, (byte)0x0E, (byte)0xEA, (byte)0x91, (byte)0x35, -(byte)0xFB, (byte)0x55, (byte)0x7A, (byte)0x39, (byte)0xD1, (byte)0xF0, -(byte)0x6B, (byte)0x9A, (byte)0xB9, (byte)0xFA, (byte)0x19, (byte)0xBE, -(byte)0x1B, (byte)0xFD, (byte)0x77 - }; - static byte[] DHBase = { -(byte)0x29, (byte)0xF2, (byte)0x29, (byte)0xC8, (byte)0x42, (byte)0x25, -(byte)0x29, (byte)0xC3, (byte)0xF2, (byte)0xAA, (byte)0xF2, (byte)0x6A, -(byte)0x3C, (byte)0xD2, (byte)0xD2, (byte)0xDE, (byte)0xD3, (byte)0x6B, -(byte)0x85, (byte)0xA5, (byte)0xE1, (byte)0x43, (byte)0x90, (byte)0xA2, -(byte)0xB6, (byte)0xA5, (byte)0x0C, (byte)0xBA, (byte)0xB9, (byte)0x4C, -(byte)0x25, (byte)0xE0, (byte)0xC8, (byte)0xEA, (byte)0xA1, (byte)0x7B, -(byte)0xB9, (byte)0xF8, (byte)0xFF, (byte)0x15, (byte)0x66, (byte)0x5B, -(byte)0xB0, (byte)0x00, (byte)0x18, (byte)0xE2, (byte)0xF4, (byte)0xF1, -(byte)0xB4, (byte)0x7A, (byte)0xC2, (byte)0xCF, (byte)0x9C, (byte)0x61, -(byte)0x36, (byte)0xED, (byte)0x14, (byte)0x72, (byte)0xD7, (byte)0xD4, -(byte)0x94, (byte)0x20, (byte)0x5E, (byte)0x1E, (byte)0xE4, (byte)0xB1, -(byte)0x60, (byte)0xC8, (byte)0x10, (byte)0x85, (byte)0xBD, (byte)0x74, -(byte)0x34, (byte)0x8C, (byte)0x3C, (byte)0x2A, (byte)0xBD, (byte)0x3C, -(byte)0xFF, (byte)0x14 - }; - public static void main(String[] args) throws Exception { DHKeyGenSpeed test = new DHKeyGenSpeed(); test.run(); @@ -78,8 +48,9 @@ public static void main(String[] args) throws Exception { public void run() throws Exception { long start, end; - BigInteger p = new BigInteger(1, DHPrime); - BigInteger g = new BigInteger(1, DHBase); + DiffieHellmanGroup dhGroup = SecurityUtils.getTestDHGroup(); + BigInteger p = dhGroup.getPrime(); + BigInteger g = new BigInteger(1, dhGroup.getBase().toByteArray()); int l = 576; DHParameterSpec spec = @@ -87,14 +58,15 @@ public void run() throws Exception { // generate keyPairs using parameters KeyPairGenerator keyGen = - KeyPairGenerator.getInstance("DH", "SunJCE"); + KeyPairGenerator.getInstance("DH", + System.getProperty("test.provider.name", "SunJCE")); start = System.currentTimeMillis(); keyGen.initialize(spec); KeyPair keys = keyGen.generateKeyPair(); end = System.currentTimeMillis(); System.out.println("PrimeBits\tExponentBits"); - System.out.println(DHPrime.length*8 + "\t\t" + l); + System.out.println(dhGroup.getPrime().bitLength() + "\t\t" + l); System.out.println("keyGen(millisecond): " + (end - start)); System.out.println("Test Passed!"); } diff --git a/test/jdk/com/sun/crypto/provider/KeyAgreement/SameDHKeyStressTest.java b/test/jdk/com/sun/crypto/provider/KeyAgreement/SameDHKeyStressTest.java index 910104b98c5..9b7eec95d6d 100644 --- a/test/jdk/com/sun/crypto/provider/KeyAgreement/SameDHKeyStressTest.java +++ b/test/jdk/com/sun/crypto/provider/KeyAgreement/SameDHKeyStressTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -78,7 +78,8 @@ public static boolean runTest(String algo, int numParties, String secretAlgo) { Key[] keyArchives = new Key[numParties]; try { // generate AlogirhtmParameterSpec - AlgorithmParameterGenerator apg = AlgorithmParameterGenerator.getInstance("DH","SunJCE"); + AlgorithmParameterGenerator apg = AlgorithmParameterGenerator.getInstance("DH", + System.getProperty("test.provider.name", "SunJCE")); AlgorithmParameterSpec aps = new DHGenParameterSpec(512, 64); apg.init(aps); DHParameterSpec spec = apg.generateParameters(). @@ -139,8 +140,10 @@ class KAParticipant { public KAParticipant(String pName, String algo) throws NoSuchAlgorithmException, NoSuchProviderException { name = pName; algorithm = algo; - keyGen = KeyPairGenerator.getInstance(algo,"SunJCE"); - ka = KeyAgreement.getInstance(algo,"SunJCE"); + keyGen = KeyPairGenerator.getInstance(algo, + System.getProperty("test.provider.name", "SunJCE")); + ka = KeyAgreement.getInstance(algo, + System.getProperty("test.provider.name", "SunJCE")); } public void initialize(AlgorithmParameterSpec spec) throws InvalidAlgorithmParameterException, InvalidKeyException { diff --git a/test/jdk/com/sun/crypto/provider/KeyAgreement/SupportedDHKeys.java b/test/jdk/com/sun/crypto/provider/KeyAgreement/SupportedDHKeys.java index 1faaa6783b4..71f383079e0 100644 --- a/test/jdk/com/sun/crypto/provider/KeyAgreement/SupportedDHKeys.java +++ b/test/jdk/com/sun/crypto/provider/KeyAgreement/SupportedDHKeys.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -55,7 +55,8 @@ private enum SupportedKeySize { public static void main(String[] args) throws Exception { for (SupportedKeySize keySize : SupportedKeySize.values()) { System.out.println("Checking " + keySize.primeSize + " ..."); - KeyPairGenerator kpg = KeyPairGenerator.getInstance("DH", "SunJCE"); + KeyPairGenerator kpg = KeyPairGenerator.getInstance("DH", + System.getProperty("test.provider.name", "SunJCE")); kpg.initialize(keySize.primeSize); KeyPair kp = kpg.generateKeyPair(); checkKeyPair(kp, keySize.primeSize); diff --git a/test/jdk/com/sun/crypto/provider/KeyAgreement/SupportedDHParamGens.java b/test/jdk/com/sun/crypto/provider/KeyAgreement/SupportedDHParamGens.java index 27f010dd141..96a5754cfa6 100644 --- a/test/jdk/com/sun/crypto/provider/KeyAgreement/SupportedDHParamGens.java +++ b/test/jdk/com/sun/crypto/provider/KeyAgreement/SupportedDHParamGens.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -49,12 +49,14 @@ public static void main(String[] args) throws Exception { System.out.println("Checking " + primeSize + " ..."); AlgorithmParameterGenerator apg = - AlgorithmParameterGenerator.getInstance("DH", "SunJCE"); + AlgorithmParameterGenerator.getInstance("DH", + System.getProperty("test.provider.name", "SunJCE")); apg.init(primeSize); AlgorithmParameters ap = apg.generateParameters(); DHParameterSpec spec = ap.getParameterSpec(DHParameterSpec.class); - KeyPairGenerator kpg = KeyPairGenerator.getInstance("DH", "SunJCE"); + KeyPairGenerator kpg = KeyPairGenerator.getInstance("DH", + System.getProperty("test.provider.name", "SunJCE")); kpg.initialize(spec); KeyPair kp = kpg.generateKeyPair(); checkKeyPair(kp, primeSize); diff --git a/test/jdk/com/sun/crypto/provider/KeyAgreement/TestExponentSize.java b/test/jdk/com/sun/crypto/provider/KeyAgreement/TestExponentSize.java index 2367c361d57..ade1d1fb6e9 100644 --- a/test/jdk/com/sun/crypto/provider/KeyAgreement/TestExponentSize.java +++ b/test/jdk/com/sun/crypto/provider/KeyAgreement/TestExponentSize.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -81,7 +81,8 @@ BigInteger getBigIntValue() { public static void main(String[] args) throws Exception { KeyPair kp; - KeyPairGenerator kpg = KeyPairGenerator.getInstance("DH", "SunJCE"); + KeyPairGenerator kpg = KeyPairGenerator.getInstance("DH", + System.getProperty("test.provider.name", "SunJCE")); // Sun's default uses a default psize of 3072 and // lsize of (pSize / 2) but at least 384 bits diff --git a/test/jdk/com/sun/crypto/provider/KeyAgreement/UnsupportedDHKeys.java b/test/jdk/com/sun/crypto/provider/KeyAgreement/UnsupportedDHKeys.java index d2ef5fab807..dff10c3d21a 100644 --- a/test/jdk/com/sun/crypto/provider/KeyAgreement/UnsupportedDHKeys.java +++ b/test/jdk/com/sun/crypto/provider/KeyAgreement/UnsupportedDHKeys.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -61,7 +61,8 @@ public static void main(String[] args) throws Exception { try { System.out.println("Checking " + keySize.primeSize + " ..."); KeyPairGenerator kpg = - KeyPairGenerator.getInstance("DH", "SunJCE"); + KeyPairGenerator.getInstance("DH", + System.getProperty("test.provider.name", "SunJCE")); kpg.initialize(keySize.primeSize); throw new Exception("Should not support " + keySize.primeSize); diff --git a/test/jdk/com/sun/crypto/provider/KeyFactory/PBKDF2HmacSHA1FactoryTest.java b/test/jdk/com/sun/crypto/provider/KeyFactory/PBKDF2HmacSHA1FactoryTest.java index 1f2fa128db8..e5c8bb63aa7 100644 --- a/test/jdk/com/sun/crypto/provider/KeyFactory/PBKDF2HmacSHA1FactoryTest.java +++ b/test/jdk/com/sun/crypto/provider/KeyFactory/PBKDF2HmacSHA1FactoryTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -69,7 +69,8 @@ public class PBKDF2HmacSHA1FactoryTest { }; private static void test() throws Exception { - SecretKeyFactory skf = SecretKeyFactory.getInstance(ALGO, "SunJCE"); + SecretKeyFactory skf = SecretKeyFactory.getInstance(ALGO, + System.getProperty("test.provider.name", "SunJCE")); for (int i = 0; i < TEST_VECTORS.length; i++) { System.out.println("=>Testing vector#" + (i+1)); diff --git a/test/jdk/com/sun/crypto/provider/KeyFactory/TestProviderLeak.java b/test/jdk/com/sun/crypto/provider/KeyFactory/TestProviderLeak.java index 650e743baa9..b2122d5691b 100644 --- a/test/jdk/com/sun/crypto/provider/KeyFactory/TestProviderLeak.java +++ b/test/jdk/com/sun/crypto/provider/KeyFactory/TestProviderLeak.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,6 +24,7 @@ /* * @test * @bug 6578538 8027624 + * @library /test/lib * @summary com.sun.crypto.provider.SunJCE instance leak using KRB5 and * LoginContext * @author Brad Wetmore @@ -45,6 +46,7 @@ import java.util.*; import java.util.concurrent.*; +import jdk.test.lib.security.SecurityUtils; public class TestProviderLeak { private static final int MB = 1024 * 1024; @@ -106,9 +108,10 @@ private static void dumpMemoryStats(String s) throws Exception { public static void main(String [] args) throws Exception { // Prepare the test final SecretKeyFactory skf = - SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1", "SunJCE"); + SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1", + System.getProperty("test.provider.name", "SunJCE")); final PBEKeySpec pbeKS = new PBEKeySpec( - "passPhrase".toCharArray(), new byte [] { 0 }, 5, 512); + "passPhrase".toCharArray(), new byte [SecurityUtils.getTestSaltSize()], 1000, 512); ExecutorService executor = Executors.newSingleThreadExecutor(); Callable task = new Callable() { diff --git a/test/jdk/com/sun/crypto/provider/KeyGenerator/Test4628062.java b/test/jdk/com/sun/crypto/provider/KeyGenerator/Test4628062.java index 04ca4944aff..f8502ce2bf1 100644 --- a/test/jdk/com/sun/crypto/provider/KeyGenerator/Test4628062.java +++ b/test/jdk/com/sun/crypto/provider/KeyGenerator/Test4628062.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,7 +44,8 @@ public class Test4628062 { private static final int[] HMACSHA512_256_SIZES = { 32 }; public boolean execute(String algo, int[] keySizes) throws Exception { - KeyGenerator kg = KeyGenerator.getInstance(algo, "SunJCE"); + KeyGenerator kg = KeyGenerator.getInstance(algo, + System.getProperty("test.provider.name", "SunJCE")); // TEST FIX 4628062 Key keyWithDefaultSize = kg.generateKey(); diff --git a/test/jdk/com/sun/crypto/provider/KeyGenerator/Test6227536.java b/test/jdk/com/sun/crypto/provider/KeyGenerator/Test6227536.java index 43de6ead59a..db8f78af835 100644 --- a/test/jdk/com/sun/crypto/provider/KeyGenerator/Test6227536.java +++ b/test/jdk/com/sun/crypto/provider/KeyGenerator/Test6227536.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,7 +38,8 @@ public class Test6227536 { String[] keyGensToTest = new String[]{"HmacSHA1", "HmacMD5"}; public boolean execute(String algo) throws Exception { - KeyGenerator kg = KeyGenerator.getInstance(algo, "SunJCE"); + KeyGenerator kg = KeyGenerator.getInstance(algo, + System.getProperty("test.provider.name", "SunJCE")); Utils.runAndCheckException(() -> kg.init(0), IllegalArgumentException.class); diff --git a/test/jdk/com/sun/crypto/provider/KeyGenerator/TestExplicitKeyLength.java b/test/jdk/com/sun/crypto/provider/KeyGenerator/TestExplicitKeyLength.java index fd53497a4b4..6a0c2419fcc 100644 --- a/test/jdk/com/sun/crypto/provider/KeyGenerator/TestExplicitKeyLength.java +++ b/test/jdk/com/sun/crypto/provider/KeyGenerator/TestExplicitKeyLength.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,7 +41,8 @@ public class TestExplicitKeyLength { { 64, 80 }; // in bits public static void runTest(String algo, int keysize) throws Exception { - KeyGenerator kg = KeyGenerator.getInstance(algo, "SunJCE"); + KeyGenerator kg = KeyGenerator.getInstance(algo, + System.getProperty("test.provider.name", "SunJCE")); kg.init(keysize); Key generatedKey = kg.generateKey(); int actualSizeInBits = generatedKey.getEncoded().length*8; diff --git a/test/jdk/com/sun/crypto/provider/Mac/DigestCloneabilityTest.java b/test/jdk/com/sun/crypto/provider/Mac/DigestCloneabilityTest.java index 2c54237fac5..5fac9ffc72d 100644 --- a/test/jdk/com/sun/crypto/provider/Mac/DigestCloneabilityTest.java +++ b/test/jdk/com/sun/crypto/provider/Mac/DigestCloneabilityTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,7 +40,8 @@ public static void main(String[] args) throws Exception { // make SampleProvider the most preferred, so its digest impl is picked int status = Security.insertProviderAt(p, 1); try { - Mac mac = Mac.getInstance(ALGO, "SunJCE"); + Mac mac = Mac.getInstance(ALGO, + System.getProperty("test.provider.name", "SunJCE")); // do a complete mac generation and check if the supplied // digest is used mac.init(new SecretKeySpec(new byte[512>>3], ALGO)); @@ -72,7 +73,8 @@ public static class CloneableDigest extends MessageDigestSpi public CloneableDigest() throws NoSuchAlgorithmException { try { - md = MessageDigest.getInstance("SHA-512", "SUN"); + md = MessageDigest.getInstance("SHA-512", + System.getProperty("test.provider.name", "SUN")); } catch (NoSuchProviderException nspe) { // should never happen } diff --git a/test/jdk/com/sun/crypto/provider/Mac/EmptyByteBufferTest.java b/test/jdk/com/sun/crypto/provider/Mac/EmptyByteBufferTest.java index 9b1dd1cb373..dafc6023a79 100644 --- a/test/jdk/com/sun/crypto/provider/Mac/EmptyByteBufferTest.java +++ b/test/jdk/com/sun/crypto/provider/Mac/EmptyByteBufferTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -51,7 +51,8 @@ public void doTest(String alg) throws NoSuchAlgorithmException, SecretKey key = Utils.getSecretKeySpec(); // instantiate Mac object and init it with a SecretKey - Mac mac = Mac.getInstance(alg, "SunJCE"); + Mac mac = Mac.getInstance(alg, + System.getProperty("test.provider.name", "SunJCE")); mac.init(key); // prepare buffer diff --git a/test/jdk/com/sun/crypto/provider/Mac/HmacPBESHA1.java b/test/jdk/com/sun/crypto/provider/Mac/HmacPBESHA1.java index 8f72f5b6aae..1222736f6f9 100644 --- a/test/jdk/com/sun/crypto/provider/Mac/HmacPBESHA1.java +++ b/test/jdk/com/sun/crypto/provider/Mac/HmacPBESHA1.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -49,7 +49,8 @@ public class HmacPBESHA1 { }; private static final int[] MAC_LENGTHS = { 20, 20, 28, 32, 48, 64, 28, 32 }; private static final String KEY_ALGO = "PBE"; - private static final String PROVIDER = "SunJCE"; + private static final String PROVIDER = + System.getProperty("test.provider.name", "SunJCE"); private static SecretKey key = null; diff --git a/test/jdk/com/sun/crypto/provider/Mac/HmacSaltLengths.java b/test/jdk/com/sun/crypto/provider/Mac/HmacSaltLengths.java index a7a5a8e0ee9..aa2ef2ae7de 100644 --- a/test/jdk/com/sun/crypto/provider/Mac/HmacSaltLengths.java +++ b/test/jdk/com/sun/crypto/provider/Mac/HmacSaltLengths.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -91,7 +91,8 @@ public static void main(String[] argv) throws Exception { new SecureRandom().nextBytes(input); char[] PASSWD = { 'p','a','s','s','w','o','r','d' }; long start = System.currentTimeMillis(); - Provider p = Security.getProvider("SunJCE"); + Provider p = Security.getProvider( + System.getProperty("test.provider.name", "SunJCE")); System.out.println("Testing provider " + p.getName() + "..."); for (String algo : ALGOS) { runTest(algo, input, PASSWD, p); diff --git a/test/jdk/com/sun/crypto/provider/Mac/LargeByteBufferTest.java b/test/jdk/com/sun/crypto/provider/Mac/LargeByteBufferTest.java index f294b67743b..4b2f8d8abc7 100644 --- a/test/jdk/com/sun/crypto/provider/Mac/LargeByteBufferTest.java +++ b/test/jdk/com/sun/crypto/provider/Mac/LargeByteBufferTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -53,7 +53,8 @@ public void doTest(String alg) throws NoSuchAlgorithmException, SecretKey key = Utils.getSecretKeySpec(); // instantiate Mac object and init it with a SecretKey - Mac mac = Mac.getInstance(alg, "SunJCE"); + Mac mac = Mac.getInstance(alg, + System.getProperty("test.provider.name", "SunJCE")); mac.init(key); // prepare buffer diff --git a/test/jdk/com/sun/crypto/provider/Mac/MacClone.java b/test/jdk/com/sun/crypto/provider/Mac/MacClone.java index 46e797a189a..e66b71ec1a3 100644 --- a/test/jdk/com/sun/crypto/provider/Mac/MacClone.java +++ b/test/jdk/com/sun/crypto/provider/Mac/MacClone.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -64,7 +64,8 @@ private static void doTest(String algo, SecretKey skey, // // Clone an uninitialized Mac object // - Mac mac = Mac.getInstance(algo, "SunJCE"); + Mac mac = Mac.getInstance(algo, + System.getProperty("test.provider.name", "SunJCE")); Mac macClone = (Mac)mac.clone(); System.out.println(macClone.getProvider().toString()); System.out.println(macClone.getAlgorithm()); @@ -81,7 +82,8 @@ private static void doTest(String algo, SecretKey skey, // // Clone an initialized Mac object // - mac = Mac.getInstance(algo, "SunJCE"); + mac = Mac.getInstance(algo, + System.getProperty("test.provider.name", "SunJCE")); mac.init(skey, params); macClone = (Mac)mac.clone(); System.out.println(macClone.getProvider().toString()); diff --git a/test/jdk/com/sun/crypto/provider/Mac/MacKAT.java b/test/jdk/com/sun/crypto/provider/Mac/MacKAT.java index b75359e2ddf..9721668ea91 100644 --- a/test/jdk/com/sun/crypto/provider/Mac/MacKAT.java +++ b/test/jdk/com/sun/crypto/provider/Mac/MacKAT.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -333,7 +333,8 @@ private static Test t(String alg, byte[] input, String macvalue, byte[] key) { static void runTests(Test[] tests) throws Exception { long start = System.currentTimeMillis(); - Provider p = Security.getProvider("SunJCE"); + Provider p = Security.getProvider( + System.getProperty("test.provider.name", "SunJCE")); System.out.println("Testing provider " + p.getName() + "..."); for (int i = 0; i < tests.length; i++) { Test test = tests[i]; diff --git a/test/jdk/com/sun/crypto/provider/Mac/MacSameTest.java b/test/jdk/com/sun/crypto/provider/Mac/MacSameTest.java index 598ea6a910c..e8b8351c974 100644 --- a/test/jdk/com/sun/crypto/provider/Mac/MacSameTest.java +++ b/test/jdk/com/sun/crypto/provider/Mac/MacSameTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -63,7 +63,8 @@ public void doTest(String algo) throws NoSuchAlgorithmException, NoSuchProviderException, InvalidKeyException { Mac mac; try { - mac = Mac.getInstance(algo, "SunJCE"); + mac = Mac.getInstance(algo, + System.getProperty("test.provider.name", "SunJCE")); } catch (NoSuchAlgorithmException nsae) { // depending on Solaris configuration, // it can support HMAC or not with Mac diff --git a/test/jdk/com/sun/crypto/provider/Mac/NullByteBufferTest.java b/test/jdk/com/sun/crypto/provider/Mac/NullByteBufferTest.java index d71d4f96317..a4f3e441cb3 100644 --- a/test/jdk/com/sun/crypto/provider/Mac/NullByteBufferTest.java +++ b/test/jdk/com/sun/crypto/provider/Mac/NullByteBufferTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -51,7 +51,8 @@ public void doTest(String alg) throws NoSuchAlgorithmException, SecretKey key = Utils.getSecretKeySpec(); // instantiate Mac object and init it with a SecretKey - Mac mac = Mac.getInstance(alg, "SunJCE"); + Mac mac = Mac.getInstance(alg, + System.getProperty("test.provider.name", "SunJCE")); mac.init(key); try { diff --git a/test/jdk/com/sun/crypto/provider/NSASuiteB/TestAESOids.java b/test/jdk/com/sun/crypto/provider/NSASuiteB/TestAESOids.java index 062c34ceda3..445ccf8c739 100644 --- a/test/jdk/com/sun/crypto/provider/NSASuiteB/TestAESOids.java +++ b/test/jdk/com/sun/crypto/provider/NSASuiteB/TestAESOids.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -51,7 +51,8 @@ */ public class TestAESOids { - private static final String PROVIDER_NAME = "SunJCE"; + private static final String PROVIDER_NAME = + System.getProperty("test.provider.name", "SunJCE"); private static final byte[] INPUT = "1234567890123456".getBytes(); private static final List DATA = Arrays.asList( diff --git a/test/jdk/com/sun/crypto/provider/NSASuiteB/TestAESWrapOids.java b/test/jdk/com/sun/crypto/provider/NSASuiteB/TestAESWrapOids.java index a75694be832..9b99ece8bda 100644 --- a/test/jdk/com/sun/crypto/provider/NSASuiteB/TestAESWrapOids.java +++ b/test/jdk/com/sun/crypto/provider/NSASuiteB/TestAESWrapOids.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -46,7 +46,8 @@ */ public class TestAESWrapOids { - private static final String PROVIDER_NAME = "SunJCE"; + private static final String PROVIDER_NAME = + System.getProperty("test.provider.name", "SunJCE"); private static final List DATA = Arrays.asList( new DataTuple("2.16.840.1.101.3.4.1.5", "AESWrap_128"), diff --git a/test/jdk/com/sun/crypto/provider/NSASuiteB/TestHmacSHAOids.java b/test/jdk/com/sun/crypto/provider/NSASuiteB/TestHmacSHAOids.java index 3ac097fe0ea..30989b94050 100644 --- a/test/jdk/com/sun/crypto/provider/NSASuiteB/TestHmacSHAOids.java +++ b/test/jdk/com/sun/crypto/provider/NSASuiteB/TestHmacSHAOids.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,7 +41,8 @@ */ public class TestHmacSHAOids { - private static final String PROVIDER_NAME = "SunJCE"; + private static final String PROVIDER_NAME = + System.getProperty("test.provider.name", "SunJCE"); private static final byte[] INPUT = "1234567890".getBytes(); private static final List DATA = Arrays.asList( diff --git a/test/jdk/com/sun/crypto/provider/TLS/TestKeyMaterial.java b/test/jdk/com/sun/crypto/provider/TLS/TestKeyMaterial.java index 983e8acb4c3..b23390f0e50 100644 --- a/test/jdk/com/sun/crypto/provider/TLS/TestKeyMaterial.java +++ b/test/jdk/com/sun/crypto/provider/TLS/TestKeyMaterial.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -47,7 +47,8 @@ public class TestKeyMaterial extends Utils { private static int PREFIX_LENGTH = "km-master: ".length(); public static void main(String[] args) throws Exception { - Provider provider = Security.getProvider("SunJCE"); + Provider provider = Security.getProvider( + System.getProperty("test.provider.name", "SunJCE")); InputStream in = new FileInputStream(new File(BASE, "keymatdata.txt")); BufferedReader reader = new BufferedReader(new InputStreamReader(in)); diff --git a/test/jdk/com/sun/crypto/provider/TLS/TestLeadingZeroes.java b/test/jdk/com/sun/crypto/provider/TLS/TestLeadingZeroes.java index bf47477b135..9dc22c77fd0 100644 --- a/test/jdk/com/sun/crypto/provider/TLS/TestLeadingZeroes.java +++ b/test/jdk/com/sun/crypto/provider/TLS/TestLeadingZeroes.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -47,7 +47,8 @@ public class TestLeadingZeroes { - private static final String SUNJCE = "SunJCE"; + private static final String PROVIDER_NAME = + System.getProperty("test.provider.name", "SunJCE"); // Hex formatter to upper case with ":" delimiter private static final HexFormat HEX_FORMATTER = HexFormat.ofDelimiter(":").withUpperCase(); @@ -73,14 +74,14 @@ private void run() throws Exception { kfac.generatePrivate(new PKCS8EncodedKeySpec(bobPrivKeyEnc)); // generate normal shared secret - KeyAgreement aliceKeyAgree = KeyAgreement.getInstance("DH", SUNJCE); + KeyAgreement aliceKeyAgree = KeyAgreement.getInstance("DH", PROVIDER_NAME); aliceKeyAgree.init(alicePrivKey); aliceKeyAgree.doPhase(bobPubKey, true); byte[] sharedSecret = aliceKeyAgree.generateSecret(); System.out.println("shared secret:\n" + HEX_FORMATTER.formatHex(sharedSecret)); // verify that leading zero is present - if (sharedSecret.length != 128) { + if (sharedSecret.length != 256) { throw new Exception("Unexpected shared secret length"); } if (sharedSecret[0] != 0) { @@ -96,7 +97,7 @@ private void run() throws Exception { "tls premaster secret:\n" + HEX_FORMATTER.formatHex(tlsPremasterSecret)); // check that leading zero has been stripped - if (tlsPremasterSecret.length != 127) { + if (tlsPremasterSecret.length != 255) { throw new Exception("Unexpected TLS premaster secret length"); } if (tlsPremasterSecret[0] == 0) { @@ -111,279 +112,455 @@ private void run() throws Exception { } private static final byte alicePubKeyEnc[] = { - (byte)0x30, (byte)0x82, (byte)0x01, (byte)0x24, - (byte)0x30, (byte)0x81, (byte)0x99, (byte)0x06, - (byte)0x09, (byte)0x2A, (byte)0x86, (byte)0x48, - (byte)0x86, (byte)0xF7, (byte)0x0D, (byte)0x01, - (byte)0x03, (byte)0x01, (byte)0x30, (byte)0x81, - (byte)0x8B, (byte)0x02, (byte)0x81, (byte)0x81, - (byte)0x00, (byte)0xF4, (byte)0x88, (byte)0xFD, - (byte)0x58, (byte)0x4E, (byte)0x49, (byte)0xDB, - (byte)0xCD, (byte)0x20, (byte)0xB4, (byte)0x9D, - (byte)0xE4, (byte)0x91, (byte)0x07, (byte)0x36, - (byte)0x6B, (byte)0x33, (byte)0x6C, (byte)0x38, - (byte)0x0D, (byte)0x45, (byte)0x1D, (byte)0x0F, - (byte)0x7C, (byte)0x88, (byte)0xB3, (byte)0x1C, - (byte)0x7C, (byte)0x5B, (byte)0x2D, (byte)0x8E, - (byte)0xF6, (byte)0xF3, (byte)0xC9, (byte)0x23, - (byte)0xC0, (byte)0x43, (byte)0xF0, (byte)0xA5, - (byte)0x5B, (byte)0x18, (byte)0x8D, (byte)0x8E, - (byte)0xBB, (byte)0x55, (byte)0x8C, (byte)0xB8, - (byte)0x5D, (byte)0x38, (byte)0xD3, (byte)0x34, - (byte)0xFD, (byte)0x7C, (byte)0x17, (byte)0x57, - (byte)0x43, (byte)0xA3, (byte)0x1D, (byte)0x18, - (byte)0x6C, (byte)0xDE, (byte)0x33, (byte)0x21, - (byte)0x2C, (byte)0xB5, (byte)0x2A, (byte)0xFF, - (byte)0x3C, (byte)0xE1, (byte)0xB1, (byte)0x29, - (byte)0x40, (byte)0x18, (byte)0x11, (byte)0x8D, - (byte)0x7C, (byte)0x84, (byte)0xA7, (byte)0x0A, - (byte)0x72, (byte)0xD6, (byte)0x86, (byte)0xC4, - (byte)0x03, (byte)0x19, (byte)0xC8, (byte)0x07, - (byte)0x29, (byte)0x7A, (byte)0xCA, (byte)0x95, - (byte)0x0C, (byte)0xD9, (byte)0x96, (byte)0x9F, - (byte)0xAB, (byte)0xD0, (byte)0x0A, (byte)0x50, - (byte)0x9B, (byte)0x02, (byte)0x46, (byte)0xD3, - (byte)0x08, (byte)0x3D, (byte)0x66, (byte)0xA4, - (byte)0x5D, (byte)0x41, (byte)0x9F, (byte)0x9C, - (byte)0x7C, (byte)0xBD, (byte)0x89, (byte)0x4B, - (byte)0x22, (byte)0x19, (byte)0x26, (byte)0xBA, - (byte)0xAB, (byte)0xA2, (byte)0x5E, (byte)0xC3, - (byte)0x55, (byte)0xE9, (byte)0x2F, (byte)0x78, - (byte)0xC7, (byte)0x02, (byte)0x01, (byte)0x02, - (byte)0x02, (byte)0x02, (byte)0x02, (byte)0x00, - (byte)0x03, (byte)0x81, (byte)0x85, (byte)0x00, - (byte)0x02, (byte)0x81, (byte)0x81, (byte)0x00, - (byte)0xEE, (byte)0xD6, (byte)0xB1, (byte)0xA3, - (byte)0xB4, (byte)0x78, (byte)0x2B, (byte)0x35, - (byte)0xEF, (byte)0xCD, (byte)0x17, (byte)0x86, - (byte)0x63, (byte)0x2B, (byte)0x97, (byte)0x0E, - (byte)0x7A, (byte)0xD1, (byte)0xFF, (byte)0x7A, - (byte)0xEB, (byte)0x57, (byte)0x61, (byte)0xA1, - (byte)0xF7, (byte)0x90, (byte)0x11, (byte)0xA7, - (byte)0x79, (byte)0x28, (byte)0x69, (byte)0xBA, - (byte)0xA7, (byte)0xB2, (byte)0x37, (byte)0x17, - (byte)0xAE, (byte)0x3C, (byte)0x92, (byte)0x89, - (byte)0x88, (byte)0xE5, (byte)0x7E, (byte)0x8E, - (byte)0xF0, (byte)0x24, (byte)0xD0, (byte)0xE1, - (byte)0xC4, (byte)0xB0, (byte)0x26, (byte)0x5A, - (byte)0x1E, (byte)0xBD, (byte)0xA0, (byte)0xCF, - (byte)0x3E, (byte)0x97, (byte)0x2A, (byte)0x13, - (byte)0x92, (byte)0x3B, (byte)0x39, (byte)0xD0, - (byte)0x1D, (byte)0xA3, (byte)0x6B, (byte)0x3E, - (byte)0xC2, (byte)0xBB, (byte)0x14, (byte)0xB6, - (byte)0xE2, (byte)0x4C, (byte)0x0E, (byte)0x5B, - (byte)0x4B, (byte)0xA4, (byte)0x9D, (byte)0xA6, - (byte)0x21, (byte)0xB0, (byte)0xF9, (byte)0xDE, - (byte)0x55, (byte)0xAE, (byte)0x5C, (byte)0x29, - (byte)0x0E, (byte)0xC1, (byte)0xFC, (byte)0xBA, - (byte)0x51, (byte)0xD3, (byte)0xB6, (byte)0x6D, - (byte)0x75, (byte)0x72, (byte)0xDF, (byte)0x43, - (byte)0xAB, (byte)0x94, (byte)0x21, (byte)0x6E, - (byte)0x0C, (byte)0xD1, (byte)0x93, (byte)0x54, - (byte)0x56, (byte)0x7D, (byte)0x4B, (byte)0x90, - (byte)0xF1, (byte)0x94, (byte)0x45, (byte)0xD4, - (byte)0x2A, (byte)0x71, (byte)0xA1, (byte)0xB8, - (byte)0xDD, (byte)0xAA, (byte)0x05, (byte)0xF0, - (byte)0x27, (byte)0x37, (byte)0xBD, (byte)0x44 + (byte)0x30, (byte)0x82, (byte)0x02, (byte)0x25, + (byte)0x30, (byte)0x82, (byte)0x01, (byte)0x17, + (byte)0x06, (byte)0x09, (byte)0x2a, (byte)0x86, + (byte)0x48, (byte)0x86, (byte)0xf7, (byte)0x0d, + (byte)0x01, (byte)0x03, (byte)0x01, (byte)0x30, + (byte)0x82, (byte)0x01, (byte)0x08, (byte)0x02, + (byte)0x82, (byte)0x01, (byte)0x01, (byte)0x00, + (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, + (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, + (byte)0xad, (byte)0xf8, (byte)0x54, (byte)0x58, + (byte)0xa2, (byte)0xbb, (byte)0x4a, (byte)0x9a, + (byte)0xaf, (byte)0xdc, (byte)0x56, (byte)0x20, + (byte)0x27, (byte)0x3d, (byte)0x3c, (byte)0xf1, + (byte)0xd8, (byte)0xb9, (byte)0xc5, (byte)0x83, + (byte)0xce, (byte)0x2d, (byte)0x36, (byte)0x95, + (byte)0xa9, (byte)0xe1, (byte)0x36, (byte)0x41, + (byte)0x14, (byte)0x64, (byte)0x33, (byte)0xfb, + (byte)0xcc, (byte)0x93, (byte)0x9d, (byte)0xce, + (byte)0x24, (byte)0x9b, (byte)0x3e, (byte)0xf9, + (byte)0x7d, (byte)0x2f, (byte)0xe3, (byte)0x63, + (byte)0x63, (byte)0x0c, (byte)0x75, (byte)0xd8, + (byte)0xf6, (byte)0x81, (byte)0xb2, (byte)0x02, + (byte)0xae, (byte)0xc4, (byte)0x61, (byte)0x7a, + (byte)0xd3, (byte)0xdf, (byte)0x1e, (byte)0xd5, + (byte)0xd5, (byte)0xfd, (byte)0x65, (byte)0x61, + (byte)0x24, (byte)0x33, (byte)0xf5, (byte)0x1f, + (byte)0x5f, (byte)0x06, (byte)0x6e, (byte)0xd0, + (byte)0x85, (byte)0x63, (byte)0x65, (byte)0x55, + (byte)0x3d, (byte)0xed, (byte)0x1a, (byte)0xf3, + (byte)0xb5, (byte)0x57, (byte)0x13, (byte)0x5e, + (byte)0x7f, (byte)0x57, (byte)0xc9, (byte)0x35, + (byte)0x98, (byte)0x4f, (byte)0x0c, (byte)0x70, + (byte)0xe0, (byte)0xe6, (byte)0x8b, (byte)0x77, + (byte)0xe2, (byte)0xa6, (byte)0x89, (byte)0xda, + (byte)0xf3, (byte)0xef, (byte)0xe8, (byte)0x72, + (byte)0x1d, (byte)0xf1, (byte)0x58, (byte)0xa1, + (byte)0x36, (byte)0xad, (byte)0xe7, (byte)0x35, + (byte)0x30, (byte)0xac, (byte)0xca, (byte)0x4f, + (byte)0x48, (byte)0x3a, (byte)0x79, (byte)0x7a, + (byte)0xbc, (byte)0x0a, (byte)0xb1, (byte)0x82, + (byte)0xb3, (byte)0x24, (byte)0xfb, (byte)0x61, + (byte)0xd1, (byte)0x08, (byte)0xa9, (byte)0x4b, + (byte)0xb2, (byte)0xc8, (byte)0xe3, (byte)0xfb, + (byte)0xb9, (byte)0x6a, (byte)0xda, (byte)0xb7, + (byte)0x60, (byte)0xd7, (byte)0xf4, (byte)0x68, + (byte)0x1d, (byte)0x4f, (byte)0x42, (byte)0xa3, + (byte)0xde, (byte)0x39, (byte)0x4d, (byte)0xf4, + (byte)0xae, (byte)0x56, (byte)0xed, (byte)0xe7, + (byte)0x63, (byte)0x72, (byte)0xbb, (byte)0x19, + (byte)0x0b, (byte)0x07, (byte)0xa7, (byte)0xc8, + (byte)0xee, (byte)0x0a, (byte)0x6d, (byte)0x70, + (byte)0x9e, (byte)0x02, (byte)0xfc, (byte)0xe1, + (byte)0xcd, (byte)0xf7, (byte)0xe2, (byte)0xec, + (byte)0xc0, (byte)0x34, (byte)0x04, (byte)0xcd, + (byte)0x28, (byte)0x34, (byte)0x2f, (byte)0x61, + (byte)0x91, (byte)0x72, (byte)0xfe, (byte)0x9c, + (byte)0xe9, (byte)0x85, (byte)0x83, (byte)0xff, + (byte)0x8e, (byte)0x4f, (byte)0x12, (byte)0x32, + (byte)0xee, (byte)0xf2, (byte)0x81, (byte)0x83, + (byte)0xc3, (byte)0xfe, (byte)0x3b, (byte)0x1b, + (byte)0x4c, (byte)0x6f, (byte)0xad, (byte)0x73, + (byte)0x3b, (byte)0xb5, (byte)0xfc, (byte)0xbc, + (byte)0x2e, (byte)0xc2, (byte)0x20, (byte)0x05, + (byte)0xc5, (byte)0x8e, (byte)0xf1, (byte)0x83, + (byte)0x7d, (byte)0x16, (byte)0x83, (byte)0xb2, + (byte)0xc6, (byte)0xf3, (byte)0x4a, (byte)0x26, + (byte)0xc1, (byte)0xb2, (byte)0xef, (byte)0xfa, + (byte)0x88, (byte)0x6b, (byte)0x42, (byte)0x38, + (byte)0x61, (byte)0x28, (byte)0x5c, (byte)0x97, + (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, + (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, + (byte)0x02, (byte)0x01, (byte)0x02, (byte)0x03, + (byte)0x82, (byte)0x01, (byte)0x06, (byte)0x00, + (byte)0x02, (byte)0x82, (byte)0x01, (byte)0x01, + (byte)0x00, (byte)0xb0, (byte)0x6e, (byte)0x76, + (byte)0x73, (byte)0x32, (byte)0xd4, (byte)0xcf, + (byte)0xb8, (byte)0x16, (byte)0x46, (byte)0x76, + (byte)0x8b, (byte)0x2b, (byte)0x2b, (byte)0xda, + (byte)0x6e, (byte)0x25, (byte)0x52, (byte)0x87, + (byte)0x9e, (byte)0x0c, (byte)0x97, (byte)0xc7, + (byte)0x16, (byte)0x42, (byte)0xb6, (byte)0x30, + (byte)0xc6, (byte)0x30, (byte)0xce, (byte)0xc5, + (byte)0xf4, (byte)0x8e, (byte)0x28, (byte)0xe0, + (byte)0x8d, (byte)0x5b, (byte)0x44, (byte)0x59, + (byte)0xae, (byte)0x5e, (byte)0xb6, (byte)0x5f, + (byte)0x48, (byte)0x8e, (byte)0x13, (byte)0x91, + (byte)0x00, (byte)0x72, (byte)0x9b, (byte)0x1b, + (byte)0xd8, (byte)0x69, (byte)0xe4, (byte)0xdf, + (byte)0x10, (byte)0x50, (byte)0x53, (byte)0x0f, + (byte)0x3d, (byte)0xba, (byte)0x82, (byte)0x02, + (byte)0x1c, (byte)0x78, (byte)0xf3, (byte)0xf3, + (byte)0x9a, (byte)0x01, (byte)0x3d, (byte)0xb6, + (byte)0x65, (byte)0xc2, (byte)0x6f, (byte)0x70, + (byte)0xec, (byte)0x67, (byte)0x14, (byte)0x56, + (byte)0xa0, (byte)0x98, (byte)0xef, (byte)0xc8, + (byte)0x63, (byte)0xbe, (byte)0x14, (byte)0x78, + (byte)0x1d, (byte)0xff, (byte)0xf8, (byte)0xf9, + (byte)0xd9, (byte)0x53, (byte)0xb2, (byte)0xc4, + (byte)0x40, (byte)0x3e, (byte)0x90, (byte)0x5c, + (byte)0x10, (byte)0xf8, (byte)0xa4, (byte)0xd3, + (byte)0xa2, (byte)0x39, (byte)0xc6, (byte)0xeb, + (byte)0xcd, (byte)0x3d, (byte)0xd1, (byte)0x27, + (byte)0x51, (byte)0xc8, (byte)0x4f, (byte)0x9b, + (byte)0x86, (byte)0xce, (byte)0xcf, (byte)0x80, + (byte)0x96, (byte)0x3d, (byte)0xb9, (byte)0x25, + (byte)0x05, (byte)0x54, (byte)0x15, (byte)0x8d, + (byte)0x02, (byte)0xd2, (byte)0x6f, (byte)0xed, + (byte)0xaf, (byte)0x49, (byte)0x0d, (byte)0x3e, + (byte)0xda, (byte)0xe6, (byte)0x3d, (byte)0x1a, + (byte)0x91, (byte)0x8f, (byte)0xca, (byte)0x6d, + (byte)0x88, (byte)0xff, (byte)0x0f, (byte)0x75, + (byte)0xf5, (byte)0x4e, (byte)0x08, (byte)0x42, + (byte)0xf0, (byte)0xa3, (byte)0x4a, (byte)0x95, + (byte)0xca, (byte)0x18, (byte)0xc1, (byte)0x3d, + (byte)0x9a, (byte)0x12, (byte)0x3e, (byte)0x09, + (byte)0x29, (byte)0x82, (byte)0x8e, (byte)0xe5, + (byte)0x3a, (byte)0x4c, (byte)0xcc, (byte)0x8f, + (byte)0x94, (byte)0x14, (byte)0xe3, (byte)0xc7, + (byte)0x63, (byte)0x8a, (byte)0x23, (byte)0x11, + (byte)0x03, (byte)0x77, (byte)0x7d, (byte)0xe8, + (byte)0x03, (byte)0x15, (byte)0x37, (byte)0xa9, + (byte)0xe5, (byte)0xd7, (byte)0x38, (byte)0x8f, + (byte)0xa8, (byte)0x49, (byte)0x5d, (byte)0xe4, + (byte)0x0d, (byte)0xed, (byte)0xb9, (byte)0x92, + (byte)0xc4, (byte)0xd7, (byte)0x72, (byte)0xf2, + (byte)0x29, (byte)0x26, (byte)0x99, (byte)0x11, + (byte)0xac, (byte)0xa8, (byte)0x45, (byte)0xb1, + (byte)0x6b, (byte)0x5a, (byte)0x01, (byte)0xc4, + (byte)0xe0, (byte)0x08, (byte)0xbf, (byte)0xa1, + (byte)0x49, (byte)0x2a, (byte)0x9c, (byte)0x8c, + (byte)0x89, (byte)0x31, (byte)0x07, (byte)0x36, + (byte)0x7d, (byte)0xec, (byte)0xa3, (byte)0x9a, + (byte)0x1e, (byte)0xd6, (byte)0xc6, (byte)0x01, + (byte)0x0e, (byte)0xc8, (byte)0x85, (byte)0x55, + (byte)0x42, (byte)0xa4, (byte)0x87, (byte)0x58, + (byte)0xfa, (byte)0xec, (byte)0x71, (byte)0x2e, + (byte)0x4c, (byte)0x46, (byte)0xd2, (byte)0x19, + (byte)0x23, (byte)0x0a, (byte)0x59, (byte)0x1a, + (byte)0x56 }; private static final byte alicePrivKeyEnc[] = { - (byte)0x30, (byte)0x81, (byte)0xE3, (byte)0x02, - (byte)0x01, (byte)0x00, (byte)0x30, (byte)0x81, - (byte)0x99, (byte)0x06, (byte)0x09, (byte)0x2A, - (byte)0x86, (byte)0x48, (byte)0x86, (byte)0xF7, - (byte)0x0D, (byte)0x01, (byte)0x03, (byte)0x01, - (byte)0x30, (byte)0x81, (byte)0x8B, (byte)0x02, - (byte)0x81, (byte)0x81, (byte)0x00, (byte)0xF4, - (byte)0x88, (byte)0xFD, (byte)0x58, (byte)0x4E, - (byte)0x49, (byte)0xDB, (byte)0xCD, (byte)0x20, - (byte)0xB4, (byte)0x9D, (byte)0xE4, (byte)0x91, - (byte)0x07, (byte)0x36, (byte)0x6B, (byte)0x33, - (byte)0x6C, (byte)0x38, (byte)0x0D, (byte)0x45, - (byte)0x1D, (byte)0x0F, (byte)0x7C, (byte)0x88, - (byte)0xB3, (byte)0x1C, (byte)0x7C, (byte)0x5B, - (byte)0x2D, (byte)0x8E, (byte)0xF6, (byte)0xF3, - (byte)0xC9, (byte)0x23, (byte)0xC0, (byte)0x43, - (byte)0xF0, (byte)0xA5, (byte)0x5B, (byte)0x18, - (byte)0x8D, (byte)0x8E, (byte)0xBB, (byte)0x55, - (byte)0x8C, (byte)0xB8, (byte)0x5D, (byte)0x38, - (byte)0xD3, (byte)0x34, (byte)0xFD, (byte)0x7C, - (byte)0x17, (byte)0x57, (byte)0x43, (byte)0xA3, - (byte)0x1D, (byte)0x18, (byte)0x6C, (byte)0xDE, - (byte)0x33, (byte)0x21, (byte)0x2C, (byte)0xB5, - (byte)0x2A, (byte)0xFF, (byte)0x3C, (byte)0xE1, - (byte)0xB1, (byte)0x29, (byte)0x40, (byte)0x18, - (byte)0x11, (byte)0x8D, (byte)0x7C, (byte)0x84, - (byte)0xA7, (byte)0x0A, (byte)0x72, (byte)0xD6, - (byte)0x86, (byte)0xC4, (byte)0x03, (byte)0x19, - (byte)0xC8, (byte)0x07, (byte)0x29, (byte)0x7A, - (byte)0xCA, (byte)0x95, (byte)0x0C, (byte)0xD9, - (byte)0x96, (byte)0x9F, (byte)0xAB, (byte)0xD0, - (byte)0x0A, (byte)0x50, (byte)0x9B, (byte)0x02, - (byte)0x46, (byte)0xD3, (byte)0x08, (byte)0x3D, - (byte)0x66, (byte)0xA4, (byte)0x5D, (byte)0x41, - (byte)0x9F, (byte)0x9C, (byte)0x7C, (byte)0xBD, - (byte)0x89, (byte)0x4B, (byte)0x22, (byte)0x19, - (byte)0x26, (byte)0xBA, (byte)0xAB, (byte)0xA2, - (byte)0x5E, (byte)0xC3, (byte)0x55, (byte)0xE9, - (byte)0x2F, (byte)0x78, (byte)0xC7, (byte)0x02, - (byte)0x01, (byte)0x02, (byte)0x02, (byte)0x02, - (byte)0x02, (byte)0x00, (byte)0x04, (byte)0x42, - (byte)0x02, (byte)0x40, (byte)0x36, (byte)0x4D, - (byte)0xD0, (byte)0x58, (byte)0x64, (byte)0x91, - (byte)0x78, (byte)0xA2, (byte)0x4B, (byte)0x79, - (byte)0x46, (byte)0xFE, (byte)0xC9, (byte)0xD9, - (byte)0xCA, (byte)0x5C, (byte)0xF9, (byte)0xFD, - (byte)0x6C, (byte)0x5D, (byte)0x76, (byte)0x3A, - (byte)0x41, (byte)0x6D, (byte)0x44, (byte)0x62, - (byte)0x75, (byte)0x93, (byte)0x81, (byte)0x93, - (byte)0x00, (byte)0x4C, (byte)0xB1, (byte)0xD8, - (byte)0x7D, (byte)0x9D, (byte)0xF3, (byte)0x16, - (byte)0x2C, (byte)0x6C, (byte)0x9F, (byte)0x7A, - (byte)0x84, (byte)0xA3, (byte)0x7A, (byte)0xC1, - (byte)0x4F, (byte)0x60, (byte)0xE3, (byte)0xB5, - (byte)0x86, (byte)0x28, (byte)0x08, (byte)0x4D, - (byte)0x94, (byte)0xB6, (byte)0x04, (byte)0x0D, - (byte)0xAC, (byte)0xBD, (byte)0x1F, (byte)0x42, - (byte)0x8F, (byte)0x1B + (byte)0x30, (byte)0x82, (byte)0x01, (byte)0x3f, + (byte)0x02, (byte)0x01, (byte)0x00, (byte)0x30, + (byte)0x82, (byte)0x01, (byte)0x17, (byte)0x06, + (byte)0x09, (byte)0x2a, (byte)0x86, (byte)0x48, + (byte)0x86, (byte)0xf7, (byte)0x0d, (byte)0x01, + (byte)0x03, (byte)0x01, (byte)0x30, (byte)0x82, + (byte)0x01, (byte)0x08, (byte)0x02, (byte)0x82, + (byte)0x01, (byte)0x01, (byte)0x00, (byte)0xff, + (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, + (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xad, + (byte)0xf8, (byte)0x54, (byte)0x58, (byte)0xa2, + (byte)0xbb, (byte)0x4a, (byte)0x9a, (byte)0xaf, + (byte)0xdc, (byte)0x56, (byte)0x20, (byte)0x27, + (byte)0x3d, (byte)0x3c, (byte)0xf1, (byte)0xd8, + (byte)0xb9, (byte)0xc5, (byte)0x83, (byte)0xce, + (byte)0x2d, (byte)0x36, (byte)0x95, (byte)0xa9, + (byte)0xe1, (byte)0x36, (byte)0x41, (byte)0x14, + (byte)0x64, (byte)0x33, (byte)0xfb, (byte)0xcc, + (byte)0x93, (byte)0x9d, (byte)0xce, (byte)0x24, + (byte)0x9b, (byte)0x3e, (byte)0xf9, (byte)0x7d, + (byte)0x2f, (byte)0xe3, (byte)0x63, (byte)0x63, + (byte)0x0c, (byte)0x75, (byte)0xd8, (byte)0xf6, + (byte)0x81, (byte)0xb2, (byte)0x02, (byte)0xae, + (byte)0xc4, (byte)0x61, (byte)0x7a, (byte)0xd3, + (byte)0xdf, (byte)0x1e, (byte)0xd5, (byte)0xd5, + (byte)0xfd, (byte)0x65, (byte)0x61, (byte)0x24, + (byte)0x33, (byte)0xf5, (byte)0x1f, (byte)0x5f, + (byte)0x06, (byte)0x6e, (byte)0xd0, (byte)0x85, + (byte)0x63, (byte)0x65, (byte)0x55, (byte)0x3d, + (byte)0xed, (byte)0x1a, (byte)0xf3, (byte)0xb5, + (byte)0x57, (byte)0x13, (byte)0x5e, (byte)0x7f, + (byte)0x57, (byte)0xc9, (byte)0x35, (byte)0x98, + (byte)0x4f, (byte)0x0c, (byte)0x70, (byte)0xe0, + (byte)0xe6, (byte)0x8b, (byte)0x77, (byte)0xe2, + (byte)0xa6, (byte)0x89, (byte)0xda, (byte)0xf3, + (byte)0xef, (byte)0xe8, (byte)0x72, (byte)0x1d, + (byte)0xf1, (byte)0x58, (byte)0xa1, (byte)0x36, + (byte)0xad, (byte)0xe7, (byte)0x35, (byte)0x30, + (byte)0xac, (byte)0xca, (byte)0x4f, (byte)0x48, + (byte)0x3a, (byte)0x79, (byte)0x7a, (byte)0xbc, + (byte)0x0a, (byte)0xb1, (byte)0x82, (byte)0xb3, + (byte)0x24, (byte)0xfb, (byte)0x61, (byte)0xd1, + (byte)0x08, (byte)0xa9, (byte)0x4b, (byte)0xb2, + (byte)0xc8, (byte)0xe3, (byte)0xfb, (byte)0xb9, + (byte)0x6a, (byte)0xda, (byte)0xb7, (byte)0x60, + (byte)0xd7, (byte)0xf4, (byte)0x68, (byte)0x1d, + (byte)0x4f, (byte)0x42, (byte)0xa3, (byte)0xde, + (byte)0x39, (byte)0x4d, (byte)0xf4, (byte)0xae, + (byte)0x56, (byte)0xed, (byte)0xe7, (byte)0x63, + (byte)0x72, (byte)0xbb, (byte)0x19, (byte)0x0b, + (byte)0x07, (byte)0xa7, (byte)0xc8, (byte)0xee, + (byte)0x0a, (byte)0x6d, (byte)0x70, (byte)0x9e, + (byte)0x02, (byte)0xfc, (byte)0xe1, (byte)0xcd, + (byte)0xf7, (byte)0xe2, (byte)0xec, (byte)0xc0, + (byte)0x34, (byte)0x04, (byte)0xcd, (byte)0x28, + (byte)0x34, (byte)0x2f, (byte)0x61, (byte)0x91, + (byte)0x72, (byte)0xfe, (byte)0x9c, (byte)0xe9, + (byte)0x85, (byte)0x83, (byte)0xff, (byte)0x8e, + (byte)0x4f, (byte)0x12, (byte)0x32, (byte)0xee, + (byte)0xf2, (byte)0x81, (byte)0x83, (byte)0xc3, + (byte)0xfe, (byte)0x3b, (byte)0x1b, (byte)0x4c, + (byte)0x6f, (byte)0xad, (byte)0x73, (byte)0x3b, + (byte)0xb5, (byte)0xfc, (byte)0xbc, (byte)0x2e, + (byte)0xc2, (byte)0x20, (byte)0x05, (byte)0xc5, + (byte)0x8e, (byte)0xf1, (byte)0x83, (byte)0x7d, + (byte)0x16, (byte)0x83, (byte)0xb2, (byte)0xc6, + (byte)0xf3, (byte)0x4a, (byte)0x26, (byte)0xc1, + (byte)0xb2, (byte)0xef, (byte)0xfa, (byte)0x88, + (byte)0x6b, (byte)0x42, (byte)0x38, (byte)0x61, + (byte)0x28, (byte)0x5c, (byte)0x97, (byte)0xff, + (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, + (byte)0xff, (byte)0xff, (byte)0xff, (byte)0x02, + (byte)0x01, (byte)0x02, (byte)0x04, (byte)0x1f, + (byte)0x02, (byte)0x1d, (byte)0x00, (byte)0xc7, + (byte)0x06, (byte)0xe9, (byte)0x24, (byte)0xf8, + (byte)0xb1, (byte)0xdf, (byte)0x98, (byte)0x61, + (byte)0x34, (byte)0x7f, (byte)0xcf, (byte)0xf1, + (byte)0xcc, (byte)0xcd, (byte)0xc8, (byte)0xcc, + (byte)0xd9, (byte)0x6a, (byte)0xb8, (byte)0x7d, + (byte)0x72, (byte)0x4c, (byte)0x58, (byte)0x5a, + (byte)0x97, (byte)0x39, (byte)0x69 }; private static final byte bobPubKeyEnc[] = { - (byte)0x30, (byte)0x82, (byte)0x01, (byte)0x23, - (byte)0x30, (byte)0x81, (byte)0x99, (byte)0x06, - (byte)0x09, (byte)0x2A, (byte)0x86, (byte)0x48, - (byte)0x86, (byte)0xF7, (byte)0x0D, (byte)0x01, - (byte)0x03, (byte)0x01, (byte)0x30, (byte)0x81, - (byte)0x8B, (byte)0x02, (byte)0x81, (byte)0x81, - (byte)0x00, (byte)0xF4, (byte)0x88, (byte)0xFD, - (byte)0x58, (byte)0x4E, (byte)0x49, (byte)0xDB, - (byte)0xCD, (byte)0x20, (byte)0xB4, (byte)0x9D, - (byte)0xE4, (byte)0x91, (byte)0x07, (byte)0x36, - (byte)0x6B, (byte)0x33, (byte)0x6C, (byte)0x38, - (byte)0x0D, (byte)0x45, (byte)0x1D, (byte)0x0F, - (byte)0x7C, (byte)0x88, (byte)0xB3, (byte)0x1C, - (byte)0x7C, (byte)0x5B, (byte)0x2D, (byte)0x8E, - (byte)0xF6, (byte)0xF3, (byte)0xC9, (byte)0x23, - (byte)0xC0, (byte)0x43, (byte)0xF0, (byte)0xA5, - (byte)0x5B, (byte)0x18, (byte)0x8D, (byte)0x8E, - (byte)0xBB, (byte)0x55, (byte)0x8C, (byte)0xB8, - (byte)0x5D, (byte)0x38, (byte)0xD3, (byte)0x34, - (byte)0xFD, (byte)0x7C, (byte)0x17, (byte)0x57, - (byte)0x43, (byte)0xA3, (byte)0x1D, (byte)0x18, - (byte)0x6C, (byte)0xDE, (byte)0x33, (byte)0x21, - (byte)0x2C, (byte)0xB5, (byte)0x2A, (byte)0xFF, - (byte)0x3C, (byte)0xE1, (byte)0xB1, (byte)0x29, - (byte)0x40, (byte)0x18, (byte)0x11, (byte)0x8D, - (byte)0x7C, (byte)0x84, (byte)0xA7, (byte)0x0A, - (byte)0x72, (byte)0xD6, (byte)0x86, (byte)0xC4, - (byte)0x03, (byte)0x19, (byte)0xC8, (byte)0x07, - (byte)0x29, (byte)0x7A, (byte)0xCA, (byte)0x95, - (byte)0x0C, (byte)0xD9, (byte)0x96, (byte)0x9F, - (byte)0xAB, (byte)0xD0, (byte)0x0A, (byte)0x50, - (byte)0x9B, (byte)0x02, (byte)0x46, (byte)0xD3, - (byte)0x08, (byte)0x3D, (byte)0x66, (byte)0xA4, - (byte)0x5D, (byte)0x41, (byte)0x9F, (byte)0x9C, - (byte)0x7C, (byte)0xBD, (byte)0x89, (byte)0x4B, - (byte)0x22, (byte)0x19, (byte)0x26, (byte)0xBA, - (byte)0xAB, (byte)0xA2, (byte)0x5E, (byte)0xC3, - (byte)0x55, (byte)0xE9, (byte)0x2F, (byte)0x78, - (byte)0xC7, (byte)0x02, (byte)0x01, (byte)0x02, - (byte)0x02, (byte)0x02, (byte)0x02, (byte)0x00, - (byte)0x03, (byte)0x81, (byte)0x84, (byte)0x00, - (byte)0x02, (byte)0x81, (byte)0x80, (byte)0x2C, - (byte)0x40, (byte)0xFA, (byte)0xF6, (byte)0xA6, - (byte)0xF8, (byte)0xAC, (byte)0xC2, (byte)0x4F, - (byte)0xCD, (byte)0xC7, (byte)0x37, (byte)0x93, - (byte)0xE5, (byte)0xE4, (byte)0x5E, (byte)0x18, - (byte)0x14, (byte)0xE6, (byte)0x50, (byte)0xDA, - (byte)0x55, (byte)0x38, (byte)0x5D, (byte)0x24, - (byte)0xF5, (byte)0x42, (byte)0x68, (byte)0x5F, - (byte)0xF5, (byte)0x15, (byte)0xC8, (byte)0x9B, - (byte)0x5D, (byte)0x06, (byte)0x3D, (byte)0xE1, - (byte)0x52, (byte)0x2F, (byte)0x98, (byte)0xFF, - (byte)0x37, (byte)0xBB, (byte)0x75, (byte)0x48, - (byte)0x48, (byte)0xE9, (byte)0x65, (byte)0x84, - (byte)0x37, (byte)0xBB, (byte)0xB3, (byte)0xE9, - (byte)0x36, (byte)0x01, (byte)0xB4, (byte)0x6A, - (byte)0x1C, (byte)0xB2, (byte)0x11, (byte)0x82, - (byte)0xCE, (byte)0x3D, (byte)0x65, (byte)0xE5, - (byte)0x3C, (byte)0x89, (byte)0xE9, (byte)0x52, - (byte)0x19, (byte)0xBD, (byte)0x58, (byte)0xF6, - (byte)0xA2, (byte)0x03, (byte)0xA8, (byte)0xB2, - (byte)0xA5, (byte)0xDB, (byte)0xEB, (byte)0xF5, - (byte)0x94, (byte)0xF9, (byte)0x46, (byte)0xBE, - (byte)0x45, (byte)0x4C, (byte)0x65, (byte)0xD2, - (byte)0xD1, (byte)0xCF, (byte)0xFF, (byte)0xFF, - (byte)0xFA, (byte)0x38, (byte)0xF1, (byte)0x72, - (byte)0xAB, (byte)0xB9, (byte)0x14, (byte)0x4E, - (byte)0xF5, (byte)0xF0, (byte)0x7A, (byte)0x8E, - (byte)0x45, (byte)0xFD, (byte)0x5B, (byte)0xF9, - (byte)0xA2, (byte)0x97, (byte)0x1B, (byte)0xAE, - (byte)0x2C, (byte)0x7B, (byte)0x6B, (byte)0x7C, - (byte)0x98, (byte)0xFE, (byte)0x58, (byte)0xDD, - (byte)0xBE, (byte)0xF6, (byte)0x1C, (byte)0x8E, - (byte)0xD0, (byte)0xA1, (byte)0x72 + (byte)0x30, (byte)0x82, (byte)0x02, (byte)0x25, + (byte)0x30, (byte)0x82, (byte)0x01, (byte)0x17, + (byte)0x06, (byte)0x09, (byte)0x2a, (byte)0x86, + (byte)0x48, (byte)0x86, (byte)0xf7, (byte)0x0d, + (byte)0x01, (byte)0x03, (byte)0x01, (byte)0x30, + (byte)0x82, (byte)0x01, (byte)0x08, (byte)0x02, + (byte)0x82, (byte)0x01, (byte)0x01, (byte)0x00, + (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, + (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, + (byte)0xad, (byte)0xf8, (byte)0x54, (byte)0x58, + (byte)0xa2, (byte)0xbb, (byte)0x4a, (byte)0x9a, + (byte)0xaf, (byte)0xdc, (byte)0x56, (byte)0x20, + (byte)0x27, (byte)0x3d, (byte)0x3c, (byte)0xf1, + (byte)0xd8, (byte)0xb9, (byte)0xc5, (byte)0x83, + (byte)0xce, (byte)0x2d, (byte)0x36, (byte)0x95, + (byte)0xa9, (byte)0xe1, (byte)0x36, (byte)0x41, + (byte)0x14, (byte)0x64, (byte)0x33, (byte)0xfb, + (byte)0xcc, (byte)0x93, (byte)0x9d, (byte)0xce, + (byte)0x24, (byte)0x9b, (byte)0x3e, (byte)0xf9, + (byte)0x7d, (byte)0x2f, (byte)0xe3, (byte)0x63, + (byte)0x63, (byte)0x0c, (byte)0x75, (byte)0xd8, + (byte)0xf6, (byte)0x81, (byte)0xb2, (byte)0x02, + (byte)0xae, (byte)0xc4, (byte)0x61, (byte)0x7a, + (byte)0xd3, (byte)0xdf, (byte)0x1e, (byte)0xd5, + (byte)0xd5, (byte)0xfd, (byte)0x65, (byte)0x61, + (byte)0x24, (byte)0x33, (byte)0xf5, (byte)0x1f, + (byte)0x5f, (byte)0x06, (byte)0x6e, (byte)0xd0, + (byte)0x85, (byte)0x63, (byte)0x65, (byte)0x55, + (byte)0x3d, (byte)0xed, (byte)0x1a, (byte)0xf3, + (byte)0xb5, (byte)0x57, (byte)0x13, (byte)0x5e, + (byte)0x7f, (byte)0x57, (byte)0xc9, (byte)0x35, + (byte)0x98, (byte)0x4f, (byte)0x0c, (byte)0x70, + (byte)0xe0, (byte)0xe6, (byte)0x8b, (byte)0x77, + (byte)0xe2, (byte)0xa6, (byte)0x89, (byte)0xda, + (byte)0xf3, (byte)0xef, (byte)0xe8, (byte)0x72, + (byte)0x1d, (byte)0xf1, (byte)0x58, (byte)0xa1, + (byte)0x36, (byte)0xad, (byte)0xe7, (byte)0x35, + (byte)0x30, (byte)0xac, (byte)0xca, (byte)0x4f, + (byte)0x48, (byte)0x3a, (byte)0x79, (byte)0x7a, + (byte)0xbc, (byte)0x0a, (byte)0xb1, (byte)0x82, + (byte)0xb3, (byte)0x24, (byte)0xfb, (byte)0x61, + (byte)0xd1, (byte)0x08, (byte)0xa9, (byte)0x4b, + (byte)0xb2, (byte)0xc8, (byte)0xe3, (byte)0xfb, + (byte)0xb9, (byte)0x6a, (byte)0xda, (byte)0xb7, + (byte)0x60, (byte)0xd7, (byte)0xf4, (byte)0x68, + (byte)0x1d, (byte)0x4f, (byte)0x42, (byte)0xa3, + (byte)0xde, (byte)0x39, (byte)0x4d, (byte)0xf4, + (byte)0xae, (byte)0x56, (byte)0xed, (byte)0xe7, + (byte)0x63, (byte)0x72, (byte)0xbb, (byte)0x19, + (byte)0x0b, (byte)0x07, (byte)0xa7, (byte)0xc8, + (byte)0xee, (byte)0x0a, (byte)0x6d, (byte)0x70, + (byte)0x9e, (byte)0x02, (byte)0xfc, (byte)0xe1, + (byte)0xcd, (byte)0xf7, (byte)0xe2, (byte)0xec, + (byte)0xc0, (byte)0x34, (byte)0x04, (byte)0xcd, + (byte)0x28, (byte)0x34, (byte)0x2f, (byte)0x61, + (byte)0x91, (byte)0x72, (byte)0xfe, (byte)0x9c, + (byte)0xe9, (byte)0x85, (byte)0x83, (byte)0xff, + (byte)0x8e, (byte)0x4f, (byte)0x12, (byte)0x32, + (byte)0xee, (byte)0xf2, (byte)0x81, (byte)0x83, + (byte)0xc3, (byte)0xfe, (byte)0x3b, (byte)0x1b, + (byte)0x4c, (byte)0x6f, (byte)0xad, (byte)0x73, + (byte)0x3b, (byte)0xb5, (byte)0xfc, (byte)0xbc, + (byte)0x2e, (byte)0xc2, (byte)0x20, (byte)0x05, + (byte)0xc5, (byte)0x8e, (byte)0xf1, (byte)0x83, + (byte)0x7d, (byte)0x16, (byte)0x83, (byte)0xb2, + (byte)0xc6, (byte)0xf3, (byte)0x4a, (byte)0x26, + (byte)0xc1, (byte)0xb2, (byte)0xef, (byte)0xfa, + (byte)0x88, (byte)0x6b, (byte)0x42, (byte)0x38, + (byte)0x61, (byte)0x28, (byte)0x5c, (byte)0x97, + (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, + (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, + (byte)0x02, (byte)0x01, (byte)0x02, (byte)0x03, + (byte)0x82, (byte)0x01, (byte)0x06, (byte)0x00, + (byte)0x02, (byte)0x82, (byte)0x01, (byte)0x01, + (byte)0x00, (byte)0x8d, (byte)0xb4, (byte)0x1c, + (byte)0xfc, (byte)0xc0, (byte)0x5f, (byte)0x38, + (byte)0x4c, (byte)0x7f, (byte)0x31, (byte)0xaa, + (byte)0x03, (byte)0x06, (byte)0xf0, (byte)0xec, + (byte)0xfd, (byte)0x45, (byte)0x8d, (byte)0x69, + (byte)0x8a, (byte)0xb6, (byte)0x60, (byte)0x2f, + (byte)0xa2, (byte)0xb4, (byte)0xda, (byte)0xc0, + (byte)0x2e, (byte)0xe1, (byte)0x31, (byte)0x12, + (byte)0x5a, (byte)0x49, (byte)0xef, (byte)0xf7, + (byte)0x17, (byte)0x77, (byte)0x26, (byte)0xa8, + (byte)0x91, (byte)0x0b, (byte)0xbc, (byte)0x84, + (byte)0x5c, (byte)0x20, (byte)0x84, (byte)0xd3, + (byte)0x38, (byte)0xc9, (byte)0xa1, (byte)0x5b, + (byte)0xad, (byte)0x84, (byte)0x83, (byte)0xb9, + (byte)0xe1, (byte)0x59, (byte)0x87, (byte)0xd9, + (byte)0x9b, (byte)0x36, (byte)0x6b, (byte)0x3c, + (byte)0xb6, (byte)0x3c, (byte)0x3a, (byte)0x0c, + (byte)0xf4, (byte)0x0b, (byte)0xad, (byte)0x23, + (byte)0x8d, (byte)0x5f, (byte)0x80, (byte)0x16, + (byte)0xa3, (byte)0x96, (byte)0xbd, (byte)0x28, + (byte)0x2f, (byte)0x9f, (byte)0xd1, (byte)0x7e, + (byte)0x13, (byte)0x86, (byte)0x6a, (byte)0x22, + (byte)0x26, (byte)0xdb, (byte)0x3b, (byte)0x42, + (byte)0xf0, (byte)0x21, (byte)0x7a, (byte)0x6c, + (byte)0xe3, (byte)0xb0, (byte)0x8d, (byte)0x9c, + (byte)0x3b, (byte)0xfb, (byte)0x17, (byte)0x27, + (byte)0xde, (byte)0xe4, (byte)0x82, (byte)0x2e, + (byte)0x6d, (byte)0x08, (byte)0xeb, (byte)0x2b, + (byte)0xb9, (byte)0xb0, (byte)0x94, (byte)0x0e, + (byte)0x56, (byte)0xc1, (byte)0xf2, (byte)0x54, + (byte)0xd8, (byte)0x94, (byte)0x21, (byte)0xc2, + (byte)0x2d, (byte)0x4d, (byte)0x28, (byte)0xf2, + (byte)0xc3, (byte)0x96, (byte)0x5b, (byte)0x24, + (byte)0xb6, (byte)0xee, (byte)0xa4, (byte)0xbf, + (byte)0x20, (byte)0x19, (byte)0x29, (byte)0x1a, + (byte)0x55, (byte)0x46, (byte)0x7a, (byte)0x2a, + (byte)0x14, (byte)0x12, (byte)0x4d, (byte)0xf4, + (byte)0xee, (byte)0xf5, (byte)0x6f, (byte)0x4f, + (byte)0xf7, (byte)0x99, (byte)0x1c, (byte)0xa3, + (byte)0x72, (byte)0x33, (byte)0x7d, (byte)0xfe, + (byte)0xae, (byte)0x0b, (byte)0xda, (byte)0x2c, + (byte)0xc7, (byte)0xf3, (byte)0xba, (byte)0xb7, + (byte)0x83, (byte)0x58, (byte)0x4c, (byte)0x93, + (byte)0x5d, (byte)0x90, (byte)0x65, (byte)0xc9, + (byte)0xb8, (byte)0x6d, (byte)0x2d, (byte)0xda, + (byte)0x10, (byte)0x55, (byte)0xe6, (byte)0x27, + (byte)0xb9, (byte)0x4b, (byte)0x75, (byte)0x30, + (byte)0xfa, (byte)0xe4, (byte)0xa3, (byte)0xff, + (byte)0xae, (byte)0xf9, (byte)0xfb, (byte)0xe4, + (byte)0x62, (byte)0x89, (byte)0x7c, (byte)0x7d, + (byte)0x20, (byte)0x50, (byte)0xf9, (byte)0xd1, + (byte)0xe2, (byte)0x0e, (byte)0x56, (byte)0xf6, + (byte)0x3c, (byte)0x8b, (byte)0x24, (byte)0x8a, + (byte)0x6d, (byte)0x92, (byte)0x3f, (byte)0x85, + (byte)0x7b, (byte)0x3b, (byte)0x49, (byte)0x21, + (byte)0x9d, (byte)0x26, (byte)0x1b, (byte)0x58, + (byte)0x08, (byte)0x9e, (byte)0x5f, (byte)0xea, + (byte)0x23, (byte)0x20, (byte)0xc2, (byte)0x3d, + (byte)0x87, (byte)0xbe, (byte)0x1a, (byte)0x17, + (byte)0x34, (byte)0xd8, (byte)0x10, (byte)0x0f, + (byte)0x81, (byte)0xb6, (byte)0xc7, (byte)0xa5, + (byte)0xe9, (byte)0x8b, (byte)0x21, (byte)0xab, + (byte)0x09, (byte)0x88, (byte)0x5e, (byte)0xbd, + (byte)0xa2, (byte)0x8a, (byte)0xc4, (byte)0xa8, + (byte)0x83 }; private static final byte bobPrivKeyEnc[] = { - (byte)0x30, (byte)0x81, (byte)0xE4, (byte)0x02, - (byte)0x01, (byte)0x00, (byte)0x30, (byte)0x81, - (byte)0x99, (byte)0x06, (byte)0x09, (byte)0x2A, - (byte)0x86, (byte)0x48, (byte)0x86, (byte)0xF7, - (byte)0x0D, (byte)0x01, (byte)0x03, (byte)0x01, - (byte)0x30, (byte)0x81, (byte)0x8B, (byte)0x02, - (byte)0x81, (byte)0x81, (byte)0x00, (byte)0xF4, - (byte)0x88, (byte)0xFD, (byte)0x58, (byte)0x4E, - (byte)0x49, (byte)0xDB, (byte)0xCD, (byte)0x20, - (byte)0xB4, (byte)0x9D, (byte)0xE4, (byte)0x91, - (byte)0x07, (byte)0x36, (byte)0x6B, (byte)0x33, - (byte)0x6C, (byte)0x38, (byte)0x0D, (byte)0x45, - (byte)0x1D, (byte)0x0F, (byte)0x7C, (byte)0x88, - (byte)0xB3, (byte)0x1C, (byte)0x7C, (byte)0x5B, - (byte)0x2D, (byte)0x8E, (byte)0xF6, (byte)0xF3, - (byte)0xC9, (byte)0x23, (byte)0xC0, (byte)0x43, - (byte)0xF0, (byte)0xA5, (byte)0x5B, (byte)0x18, - (byte)0x8D, (byte)0x8E, (byte)0xBB, (byte)0x55, - (byte)0x8C, (byte)0xB8, (byte)0x5D, (byte)0x38, - (byte)0xD3, (byte)0x34, (byte)0xFD, (byte)0x7C, - (byte)0x17, (byte)0x57, (byte)0x43, (byte)0xA3, - (byte)0x1D, (byte)0x18, (byte)0x6C, (byte)0xDE, - (byte)0x33, (byte)0x21, (byte)0x2C, (byte)0xB5, - (byte)0x2A, (byte)0xFF, (byte)0x3C, (byte)0xE1, - (byte)0xB1, (byte)0x29, (byte)0x40, (byte)0x18, - (byte)0x11, (byte)0x8D, (byte)0x7C, (byte)0x84, - (byte)0xA7, (byte)0x0A, (byte)0x72, (byte)0xD6, - (byte)0x86, (byte)0xC4, (byte)0x03, (byte)0x19, - (byte)0xC8, (byte)0x07, (byte)0x29, (byte)0x7A, - (byte)0xCA, (byte)0x95, (byte)0x0C, (byte)0xD9, - (byte)0x96, (byte)0x9F, (byte)0xAB, (byte)0xD0, - (byte)0x0A, (byte)0x50, (byte)0x9B, (byte)0x02, - (byte)0x46, (byte)0xD3, (byte)0x08, (byte)0x3D, - (byte)0x66, (byte)0xA4, (byte)0x5D, (byte)0x41, - (byte)0x9F, (byte)0x9C, (byte)0x7C, (byte)0xBD, - (byte)0x89, (byte)0x4B, (byte)0x22, (byte)0x19, - (byte)0x26, (byte)0xBA, (byte)0xAB, (byte)0xA2, - (byte)0x5E, (byte)0xC3, (byte)0x55, (byte)0xE9, - (byte)0x2F, (byte)0x78, (byte)0xC7, (byte)0x02, - (byte)0x01, (byte)0x02, (byte)0x02, (byte)0x02, - (byte)0x02, (byte)0x00, (byte)0x04, (byte)0x43, - (byte)0x02, (byte)0x41, (byte)0x00, (byte)0xE0, - (byte)0x31, (byte)0xE7, (byte)0x77, (byte)0xB8, - (byte)0xD0, (byte)0x7E, (byte)0x0A, (byte)0x9B, - (byte)0x94, (byte)0xD5, (byte)0x3D, (byte)0x33, - (byte)0x62, (byte)0x32, (byte)0x51, (byte)0xCE, - (byte)0x74, (byte)0x5C, (byte)0xA5, (byte)0x72, - (byte)0xD9, (byte)0x36, (byte)0xF3, (byte)0x8A, - (byte)0x3F, (byte)0x8B, (byte)0xC6, (byte)0xFE, - (byte)0xEF, (byte)0x94, (byte)0x8B, (byte)0x50, - (byte)0x41, (byte)0x9B, (byte)0x14, (byte)0xC8, - (byte)0xE9, (byte)0x1F, (byte)0x24, (byte)0x1F, - (byte)0x65, (byte)0x8E, (byte)0xD3, (byte)0x85, - (byte)0xD0, (byte)0x68, (byte)0x6C, (byte)0xF1, - (byte)0x79, (byte)0x45, (byte)0xD0, (byte)0x06, - (byte)0xA4, (byte)0xB8, (byte)0xE0, (byte)0x64, - (byte)0xF5, (byte)0x38, (byte)0x72, (byte)0x97, - (byte)0x00, (byte)0x23, (byte)0x5F + (byte)0x30, (byte)0x82, (byte)0x01, (byte)0x3f, + (byte)0x02, (byte)0x01, (byte)0x00, (byte)0x30, + (byte)0x82, (byte)0x01, (byte)0x17, (byte)0x06, + (byte)0x09, (byte)0x2a, (byte)0x86, (byte)0x48, + (byte)0x86, (byte)0xf7, (byte)0x0d, (byte)0x01, + (byte)0x03, (byte)0x01, (byte)0x30, (byte)0x82, + (byte)0x01, (byte)0x08, (byte)0x02, (byte)0x82, + (byte)0x01, (byte)0x01, (byte)0x00, (byte)0xff, + (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, + (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xad, + (byte)0xf8, (byte)0x54, (byte)0x58, (byte)0xa2, + (byte)0xbb, (byte)0x4a, (byte)0x9a, (byte)0xaf, + (byte)0xdc, (byte)0x56, (byte)0x20, (byte)0x27, + (byte)0x3d, (byte)0x3c, (byte)0xf1, (byte)0xd8, + (byte)0xb9, (byte)0xc5, (byte)0x83, (byte)0xce, + (byte)0x2d, (byte)0x36, (byte)0x95, (byte)0xa9, + (byte)0xe1, (byte)0x36, (byte)0x41, (byte)0x14, + (byte)0x64, (byte)0x33, (byte)0xfb, (byte)0xcc, + (byte)0x93, (byte)0x9d, (byte)0xce, (byte)0x24, + (byte)0x9b, (byte)0x3e, (byte)0xf9, (byte)0x7d, + (byte)0x2f, (byte)0xe3, (byte)0x63, (byte)0x63, + (byte)0x0c, (byte)0x75, (byte)0xd8, (byte)0xf6, + (byte)0x81, (byte)0xb2, (byte)0x02, (byte)0xae, + (byte)0xc4, (byte)0x61, (byte)0x7a, (byte)0xd3, + (byte)0xdf, (byte)0x1e, (byte)0xd5, (byte)0xd5, + (byte)0xfd, (byte)0x65, (byte)0x61, (byte)0x24, + (byte)0x33, (byte)0xf5, (byte)0x1f, (byte)0x5f, + (byte)0x06, (byte)0x6e, (byte)0xd0, (byte)0x85, + (byte)0x63, (byte)0x65, (byte)0x55, (byte)0x3d, + (byte)0xed, (byte)0x1a, (byte)0xf3, (byte)0xb5, + (byte)0x57, (byte)0x13, (byte)0x5e, (byte)0x7f, + (byte)0x57, (byte)0xc9, (byte)0x35, (byte)0x98, + (byte)0x4f, (byte)0x0c, (byte)0x70, (byte)0xe0, + (byte)0xe6, (byte)0x8b, (byte)0x77, (byte)0xe2, + (byte)0xa6, (byte)0x89, (byte)0xda, (byte)0xf3, + (byte)0xef, (byte)0xe8, (byte)0x72, (byte)0x1d, + (byte)0xf1, (byte)0x58, (byte)0xa1, (byte)0x36, + (byte)0xad, (byte)0xe7, (byte)0x35, (byte)0x30, + (byte)0xac, (byte)0xca, (byte)0x4f, (byte)0x48, + (byte)0x3a, (byte)0x79, (byte)0x7a, (byte)0xbc, + (byte)0x0a, (byte)0xb1, (byte)0x82, (byte)0xb3, + (byte)0x24, (byte)0xfb, (byte)0x61, (byte)0xd1, + (byte)0x08, (byte)0xa9, (byte)0x4b, (byte)0xb2, + (byte)0xc8, (byte)0xe3, (byte)0xfb, (byte)0xb9, + (byte)0x6a, (byte)0xda, (byte)0xb7, (byte)0x60, + (byte)0xd7, (byte)0xf4, (byte)0x68, (byte)0x1d, + (byte)0x4f, (byte)0x42, (byte)0xa3, (byte)0xde, + (byte)0x39, (byte)0x4d, (byte)0xf4, (byte)0xae, + (byte)0x56, (byte)0xed, (byte)0xe7, (byte)0x63, + (byte)0x72, (byte)0xbb, (byte)0x19, (byte)0x0b, + (byte)0x07, (byte)0xa7, (byte)0xc8, (byte)0xee, + (byte)0x0a, (byte)0x6d, (byte)0x70, (byte)0x9e, + (byte)0x02, (byte)0xfc, (byte)0xe1, (byte)0xcd, + (byte)0xf7, (byte)0xe2, (byte)0xec, (byte)0xc0, + (byte)0x34, (byte)0x04, (byte)0xcd, (byte)0x28, + (byte)0x34, (byte)0x2f, (byte)0x61, (byte)0x91, + (byte)0x72, (byte)0xfe, (byte)0x9c, (byte)0xe9, + (byte)0x85, (byte)0x83, (byte)0xff, (byte)0x8e, + (byte)0x4f, (byte)0x12, (byte)0x32, (byte)0xee, + (byte)0xf2, (byte)0x81, (byte)0x83, (byte)0xc3, + (byte)0xfe, (byte)0x3b, (byte)0x1b, (byte)0x4c, + (byte)0x6f, (byte)0xad, (byte)0x73, (byte)0x3b, + (byte)0xb5, (byte)0xfc, (byte)0xbc, (byte)0x2e, + (byte)0xc2, (byte)0x20, (byte)0x05, (byte)0xc5, + (byte)0x8e, (byte)0xf1, (byte)0x83, (byte)0x7d, + (byte)0x16, (byte)0x83, (byte)0xb2, (byte)0xc6, + (byte)0xf3, (byte)0x4a, (byte)0x26, (byte)0xc1, + (byte)0xb2, (byte)0xef, (byte)0xfa, (byte)0x88, + (byte)0x6b, (byte)0x42, (byte)0x38, (byte)0x61, + (byte)0x28, (byte)0x5c, (byte)0x97, (byte)0xff, + (byte)0xff, (byte)0xff, (byte)0xff, (byte)0xff, + (byte)0xff, (byte)0xff, (byte)0xff, (byte)0x02, + (byte)0x01, (byte)0x02, (byte)0x04, (byte)0x1f, + (byte)0x02, (byte)0x1d, (byte)0x01, (byte)0x62, + (byte)0x8e, (byte)0xfc, (byte)0xf3, (byte)0x25, + (byte)0xf3, (byte)0x2a, (byte)0xf4, (byte)0x49, + (byte)0x20, (byte)0x83, (byte)0x61, (byte)0x7f, + (byte)0x97, (byte)0x8f, (byte)0x48, (byte)0xac, + (byte)0xf9, (byte)0xc3, (byte)0xad, (byte)0x3c, + (byte)0x56, (byte)0x95, (byte)0x1c, (byte)0x85, + (byte)0xd3, (byte)0x85, (byte)0xd6 }; } diff --git a/test/jdk/com/sun/crypto/provider/TLS/TestMasterSecret.java b/test/jdk/com/sun/crypto/provider/TLS/TestMasterSecret.java index 10f6ddc4019..f34bdff2ef7 100644 --- a/test/jdk/com/sun/crypto/provider/TLS/TestMasterSecret.java +++ b/test/jdk/com/sun/crypto/provider/TLS/TestMasterSecret.java @@ -49,7 +49,8 @@ public class TestMasterSecret extends Utils { private static int PREFIX_LENGTH = "m-premaster: ".length(); public static void main(String[] args) throws Exception { - Provider provider = Security.getProvider("SunJCE"); + Provider provider = Security.getProvider( + System.getProperty("test.provider.name", "SunJCE")); InputStream in = new FileInputStream(new File(BASE, "masterdata.txt")); BufferedReader reader = new BufferedReader(new InputStreamReader(in)); diff --git a/test/jdk/com/sun/crypto/provider/TLS/TestPRF.java b/test/jdk/com/sun/crypto/provider/TLS/TestPRF.java index 577927ea883..d35232431bf 100644 --- a/test/jdk/com/sun/crypto/provider/TLS/TestPRF.java +++ b/test/jdk/com/sun/crypto/provider/TLS/TestPRF.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -47,7 +47,8 @@ public class TestPRF extends Utils { private static int PREFIX_LENGTH = "prf-output: ".length(); public static void main(String[] args) throws Exception { - Provider provider = Security.getProvider("SunJCE"); + Provider provider = Security.getProvider( + System.getProperty("test.provider.name", "SunJCE")); InputStream in = new FileInputStream(new File(BASE, "prfdata.txt")); BufferedReader reader = new BufferedReader(new InputStreamReader(in)); diff --git a/test/jdk/com/sun/crypto/provider/TLS/TestPRF12.java b/test/jdk/com/sun/crypto/provider/TLS/TestPRF12.java index dffda070e47..692fc630f9b 100644 --- a/test/jdk/com/sun/crypto/provider/TLS/TestPRF12.java +++ b/test/jdk/com/sun/crypto/provider/TLS/TestPRF12.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -50,7 +50,8 @@ public class TestPRF12 extends Utils { private static int PREFIX_LENGTH = "prf-output: ".length(); public static void main(String[] args) throws Exception { - Provider provider = Security.getProvider("SunJCE"); + Provider provider = Security.getProvider( + System.getProperty("test.provider.name", "SunJCE")); InputStream in = new FileInputStream(new File(BASE, "prf12data.txt")); BufferedReader reader = new BufferedReader(new InputStreamReader(in)); diff --git a/test/jdk/com/sun/crypto/provider/TLS/TestPremaster.java b/test/jdk/com/sun/crypto/provider/TLS/TestPremaster.java index b95b0855dd0..096af76cfe4 100644 --- a/test/jdk/com/sun/crypto/provider/TLS/TestPremaster.java +++ b/test/jdk/com/sun/crypto/provider/TLS/TestPremaster.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,7 +41,8 @@ public class TestPremaster { public static void main(String[] args) throws Exception { - Provider provider = Security.getProvider("SunJCE"); + Provider provider = Security.getProvider( + System.getProperty("test.provider.name", "SunJCE")); KeyGenerator kg; diff --git a/test/jdk/com/sun/jdi/ClassesByName2Test.java b/test/jdk/com/sun/jdi/ClassesByName2Test.java index acc186e7225..b8f517d0448 100644 --- a/test/jdk/com/sun/jdi/ClassesByName2Test.java +++ b/test/jdk/com/sun/jdi/ClassesByName2Test.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -58,7 +58,8 @@ public static void main(String[] args){ Thread one = DebuggeeWrapper.newThread (() -> { try { java.security.KeyPairGenerator keyGen = - java.security.KeyPairGenerator.getInstance("DSA", "SUN"); + java.security.KeyPairGenerator.getInstance("DSA", + System.getProperty("test.provider.name", "SUN")); } catch (Exception e) { e.printStackTrace(); } diff --git a/test/jdk/com/sun/org/apache/xml/internal/security/SignatureKeyInfo.java b/test/jdk/com/sun/org/apache/xml/internal/security/SignatureKeyInfo.java index d1de2030c24..793232654b6 100644 --- a/test/jdk/com/sun/org/apache/xml/internal/security/SignatureKeyInfo.java +++ b/test/jdk/com/sun/org/apache/xml/internal/security/SignatureKeyInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -62,6 +62,7 @@ import java.io.File; import java.math.BigInteger; import java.security.*; +import jdk.test.lib.security.SecurityUtils; import static jdk.test.lib.Asserts.assertEquals; @@ -160,7 +161,7 @@ private static void addKeyInfoData(KeyInfo keyInfo, String algorithm) throws Exc private static KeyPair getKeyPair(String algorithm) throws NoSuchAlgorithmException { KeyPairGenerator keyGen = KeyPairGenerator.getInstance(algorithm); - keyGen.initialize(2048); + keyGen.initialize(SecurityUtils.getTestKeySize(algorithm)); return keyGen.genKeyPair(); } diff --git a/test/jdk/java/awt/Graphics2D/LargeWindowPaintTest.java b/test/jdk/java/awt/Graphics2D/LargeWindowPaintTest.java index 991c22938b8..2c61a29aacb 100644 --- a/test/jdk/java/awt/Graphics2D/LargeWindowPaintTest.java +++ b/test/jdk/java/awt/Graphics2D/LargeWindowPaintTest.java @@ -33,25 +33,14 @@ */ /* - * @test id=ZSinglegen + * @test id=Z * @bug 8240654 * @summary Test painting a large window works * @key headful * @requires (os.family == "windows") - * @requires vm.gc.ZSinglegen - * @run main/othervm -XX:+UseZGC -XX:-ZGenerational -Dsun.java2d.uiScale=1 LargeWindowPaintTest - * @run main/othervm -XX:+UseZGC -XX:-ZGenerational -Dsun.java2d.uiScale=1 -Dsun.java2d.d3d=false LargeWindowPaintTest - */ - -/* - * @test id=ZGenerational - * @bug 8240654 - * @summary Test painting a large window works - * @key headful - * @requires (os.family == "windows") - * @requires vm.gc.ZGenerational - * @run main/othervm -XX:+UseZGC -XX:+ZGenerational -Dsun.java2d.uiScale=1 LargeWindowPaintTest - * @run main/othervm -XX:+UseZGC -XX:+ZGenerational -Dsun.java2d.uiScale=1 -Dsun.java2d.d3d=false LargeWindowPaintTest + * @requires vm.gc.Z + * @run main/othervm -XX:+UseZGC -Dsun.java2d.uiScale=1 LargeWindowPaintTest + * @run main/othervm -XX:+UseZGC -Dsun.java2d.uiScale=1 -Dsun.java2d.d3d=false LargeWindowPaintTest */ import java.awt.Color; diff --git a/test/jdk/java/awt/print/PrinterJob/AlphaPrintTest.java b/test/jdk/java/awt/print/PrinterJob/AlphaPrintTest.java index 5214ab11ec5..9a1ff616ee9 100644 --- a/test/jdk/java/awt/print/PrinterJob/AlphaPrintTest.java +++ b/test/jdk/java/awt/print/PrinterJob/AlphaPrintTest.java @@ -22,23 +22,13 @@ */ /* - * @test id=ZSinglegen + * @test id=Z * @bug 8240654 * @summary Test printing alpha colors - banded printing works with ZGC. * @key headful printer * @requires (os.family == "windows") - * @requires vm.gc.ZSinglegen - * @run main/manual/othervm -XX:+UseZGC -XX:-ZGenerational -Dsun.java2d.d3d=false AlphaPrintTest - */ - -/* - * @test id=ZGenerational - * @bug 8240654 - * @summary Test printing alpha colors - banded printing works with ZGC. - * @key headful printer - * @requires (os.family == "windows") - * @requires vm.gc.ZGenerational - * @run main/manual/othervm -XX:+UseZGC -XX:+ZGenerational -Dsun.java2d.d3d=false AlphaPrintTest + * @requires vm.gc.Z + * @run main/manual/othervm -XX:+UseZGC -Dsun.java2d.d3d=false AlphaPrintTest */ import java.awt.Color; diff --git a/test/jdk/java/foreign/stackwalk/TestAsyncStackWalk.java b/test/jdk/java/foreign/stackwalk/TestAsyncStackWalk.java index c21225575f9..1c234a9c3c6 100644 --- a/test/jdk/java/foreign/stackwalk/TestAsyncStackWalk.java +++ b/test/jdk/java/foreign/stackwalk/TestAsyncStackWalk.java @@ -39,8 +39,8 @@ */ /* - * @test id=ZSinglegen - * @requires vm.gc.ZSinglegen + * @test id=Z + * @requires vm.gc.Z * @library /test/lib * @library ../ * @build jdk.test.whitebox.WhiteBox @@ -52,25 +52,7 @@ * -XX:+WhiteBoxAPI * --enable-native-access=ALL-UNNAMED * -Xbatch - * -XX:+UseZGC -XX:-ZGenerational - * TestAsyncStackWalk - */ - -/* - * @test id=ZGenerational - * @requires vm.gc.ZGenerational - * @library /test/lib - * @library ../ - * @build jdk.test.whitebox.WhiteBox - * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox - * - * @run main/othervm - * -Xbootclasspath/a:. - * -XX:+UnlockDiagnosticVMOptions - * -XX:+WhiteBoxAPI - * --enable-native-access=ALL-UNNAMED - * -Xbatch - * -XX:+UseZGC -XX:+ZGenerational + * -XX:+UseZGC * TestAsyncStackWalk */ diff --git a/test/jdk/java/foreign/stackwalk/TestStackWalk.java b/test/jdk/java/foreign/stackwalk/TestStackWalk.java index 5218792658f..193a71affdd 100644 --- a/test/jdk/java/foreign/stackwalk/TestStackWalk.java +++ b/test/jdk/java/foreign/stackwalk/TestStackWalk.java @@ -39,8 +39,8 @@ */ /* - * @test id=ZSinglegen - * @requires vm.gc.ZSinglegen + * @test id=Z + * @requires vm.gc.Z * @library /test/lib * @library ../ * @build jdk.test.whitebox.WhiteBox @@ -52,25 +52,7 @@ * -XX:+WhiteBoxAPI * --enable-native-access=ALL-UNNAMED * -Xbatch - * -XX:+UseZGC -XX:-ZGenerational - * TestStackWalk - */ - -/* - * @test id=ZGenerational - * @requires vm.gc.ZGenerational - * @library /test/lib - * @library ../ - * @build jdk.test.whitebox.WhiteBox - * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox - * - * @run main/othervm - * -Xbootclasspath/a:. - * -XX:+UnlockDiagnosticVMOptions - * -XX:+WhiteBoxAPI - * --enable-native-access=ALL-UNNAMED - * -Xbatch - * -XX:+UseZGC -XX:+ZGenerational + * -XX:+UseZGC * TestStackWalk */ diff --git a/test/jdk/java/io/FileInputStream/PseudoDevice.java b/test/jdk/java/io/FileInputStream/PseudoDevice.java new file mode 100644 index 00000000000..9f581c3ff81 --- /dev/null +++ b/test/jdk/java/io/FileInputStream/PseudoDevice.java @@ -0,0 +1,210 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* @test + * @bug 8341666 + * @summary Test of FileInputStream reading from stdin and a named pipe + * @requires os.family != "windows" + * @library .. /test/lib + * @build jdk.test.lib.Platform + * @run junit/othervm --enable-native-access=ALL-UNNAMED PseudoDevice + */ + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.InputStream; +import java.io.IOException; +import java.lang.foreign.Arena; +import java.lang.foreign.FunctionDescriptor; +import java.lang.foreign.Linker; +import java.lang.foreign.MemorySegment; +import java.lang.foreign.SymbolLookup; +import java.lang.foreign.ValueLayout; +import java.lang.invoke.MethodHandle; +import jdk.test.lib.Platform; + +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.BeforeAll; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.condition.DisabledOnOs; +import org.junit.jupiter.api.condition.OS; +import static org.junit.jupiter.api.Assertions.*; + +public class PseudoDevice { + + private static final String PIPE = "pipe"; + private static final File PIPE_FILE = new File(PIPE); + private static final String SENTENCE = + "Rien n'est permis mais tout est possible"; + + private static class mkfifo { + public static final FunctionDescriptor DESC = FunctionDescriptor.of( + ValueLayout.JAVA_INT, + ValueLayout.ADDRESS, + ValueLayout.JAVA_SHORT + ); + + public static final MemorySegment ADDR; + static { + Linker linker = Linker.nativeLinker(); + SymbolLookup stdlib = linker.defaultLookup(); + ADDR = stdlib.find("mkfifo").orElseThrow(); + } + + public static final MethodHandle HANDLE = + Linker.nativeLinker().downcallHandle(ADDR, DESC); + } + + public static int mkfifo(MemorySegment x0, short x1) { + var mh$ = mkfifo.HANDLE; + try { + return (int)mh$.invokeExact(x0, x1); + } catch (Throwable ex$) { + throw new AssertionError("should not reach here", ex$); + } + } + + private static Thread createWriteThread() { + Thread t = new Thread( + new Runnable() { + public void run() { + try (FileOutputStream fos = new FileOutputStream(PIPE);) { + fos.write(SENTENCE.getBytes()); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + } + ); + t.start(); + return t; + } + + @BeforeAll + static void before() throws InterruptedException, IOException { + if (Platform.isWindows()) + return; + + PIPE_FILE.delete(); + try (var newArena = Arena.ofConfined()) { + var addr = newArena.allocateFrom(PIPE); + short mode = 0666; + assertEquals(0, mkfifo(addr, mode)); + } + if (!PIPE_FILE.exists()) + throw new RuntimeException("Failed to create " + PIPE); + } + + @AfterAll + static void after() throws IOException { + if (Platform.isWindows()) + return; + + PIPE_FILE.delete(); + } + + /** + * Tests that new FileInputStream(File).available() does not throw + */ + @Test + @DisabledOnOs(OS.WINDOWS) + void availableStdin() throws IOException { + File stdin = new File("/dev", "stdin"); + if (stdin.exists()) { + try (InputStream s = new FileInputStream(stdin);) { + s.available(); + } + } + } + + /** + * Tests that new FileInputStream(File).skip(0) does not throw + */ + @Test + @DisabledOnOs(OS.WINDOWS) + void skipStdin() throws IOException { + File stdin = new File("/dev", "stdin"); + if (stdin.exists()) { + try (InputStream s = new FileInputStream(stdin);) { + s.skip(0); + } + } + } + + /** + * Tests new FileInputStream(File).readAllBytes(). + */ + @Test + @DisabledOnOs(OS.WINDOWS) + void readAllBytes() throws InterruptedException, IOException { + Thread t = createWriteThread(); + try (InputStream in = new FileInputStream(PIPE)) { + String s = new String(in.readAllBytes()); + System.out.println(s); + assertEquals(SENTENCE, s); + } finally { + t.join(); + } + } + + /** + * Tests new FileInputStream(File).readNBytes(byte[],int,int). + */ + @Test + @DisabledOnOs(OS.WINDOWS) + void readNBytesNoOverride() throws InterruptedException, IOException { + Thread t = createWriteThread(); + try (InputStream in = new FileInputStream(PIPE)) { + final int offset = 11; + final int length = 17; + assert length <= SENTENCE.length(); + byte[] b = new byte[offset + length]; + int n = in.readNBytes(b, offset, length); + String s = new String(b, offset, length); + System.out.println(s); + assertEquals(SENTENCE.substring(0, length), s); + } finally { + t.join(); + } + } + + /** + * Tests new FileInputStream(File).readNBytes(int). + */ + @Test + @DisabledOnOs(OS.WINDOWS) + void readNBytesOverride() throws InterruptedException, IOException { + Thread t = createWriteThread(); + try (InputStream in = new FileInputStream(PIPE)) { + final int length = 17; + assert length <= SENTENCE.length(); + byte[] b = in.readNBytes(length); + String s = new String(b); + System.out.println(s); + assertEquals(SENTENCE.substring(0, length), s); + } finally { + t.join(); + } + } +} diff --git a/test/jdk/java/io/ObjectStreamClass/ObjectStreamClassCaching.java b/test/jdk/java/io/ObjectStreamClass/ObjectStreamClassCaching.java index 115481243f7..4004cbcf859 100644 --- a/test/jdk/java/io/ObjectStreamClass/ObjectStreamClassCaching.java +++ b/test/jdk/java/io/ObjectStreamClass/ObjectStreamClassCaching.java @@ -49,12 +49,12 @@ */ /* - * @test id=ZGenerational - * @requires vm.gc.ZGenerational + * @test id=Z + * @requires vm.gc.Z * @bug 8277072 8327180 * @library /test/lib/ * @summary ObjectStreamClass caches keep ClassLoaders alive (ZGC) - * @run testng/othervm -Xmx64m -XX:+UseZGC -XX:+ZGenerational ObjectStreamClassCaching + * @run testng/othervm -Xmx64m -XX:+UseZGC ObjectStreamClassCaching */ /* diff --git a/test/jdk/java/lang/ProcessBuilder/CloseRace.java b/test/jdk/java/lang/ProcessBuilder/CloseRace.java index e7eab128d60..b0ca352b8ac 100644 --- a/test/jdk/java/lang/ProcessBuilder/CloseRace.java +++ b/test/jdk/java/lang/ProcessBuilder/CloseRace.java @@ -22,24 +22,24 @@ */ /** - * @test + * @test id=Default * @bug 8024521 8315721 * @summary Closing ProcessPipeInputStream at the time the process exits is racy * and leads to data corruption. Run this test manually (as * an ordinary java program) with -Xmx8M to repro bug 8024521. - * @requires !vm.opt.final.ZGenerational + * @requires vm.gc != "Z" * @comment Don't allow -Xcomp, it disturbs the timing * @requires (vm.compMode != "Xcomp") * @run main/othervm -Xmx8M -Dtest.duration=2 CloseRace */ /** - * @test + * @test id=Z * @comment Turn up heap size to lower amount of GCs - * @requires vm.gc.Z & vm.opt.final.ZGenerational + * @requires vm.gc.Z * @comment Don't allow -Xcomp, it disturbs the timing * @requires (vm.compMode != "Xcomp") - * @run main/othervm -XX:+UseZGC -XX:+ZGenerational -Xmx32M -Dtest.duration=2 CloseRace + * @run main/othervm -XX:+UseZGC -Xmx32M -Dtest.duration=2 CloseRace */ import java.io.*; diff --git a/test/jdk/java/lang/Thread/virtual/ParkWithFixedThreadPool.java b/test/jdk/java/lang/Thread/virtual/ParkWithFixedThreadPool.java index 28a32fc504a..70b73884d92 100644 --- a/test/jdk/java/lang/Thread/virtual/ParkWithFixedThreadPool.java +++ b/test/jdk/java/lang/Thread/virtual/ParkWithFixedThreadPool.java @@ -30,14 +30,16 @@ * @run main ParkWithFixedThreadPool */ -import java.util.concurrent.*; -import java.util.concurrent.atomic.*; +import java.util.concurrent.Executor; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.ThreadFactory; import java.util.concurrent.locks.LockSupport; import jdk.test.lib.thread.VThreadScheduler; public class ParkWithFixedThreadPool { public static void main(String[] args) throws Exception { - try (ExecutorService scheduler = Executors.newFixedThreadPool(8)) { + try (var scheduler = new Scheduler(8)) { int vthreadCount = 300; Thread[] vthreads = new Thread[vthreadCount]; Runnable target = new Runnable() { @@ -74,4 +76,27 @@ public void run() { } } } + + static class Scheduler implements Executor, AutoCloseable { + private final ExecutorService pool; + + Scheduler(int poolSize) { + pool = Executors.newFixedThreadPool(poolSize); + } + + @Override + public void execute(Runnable task) { + try { + pool.execute(task); + } finally { + // ExecutorService::execute may consume parking permit + LockSupport.unpark(Thread.currentThread()); + } + } + + @Override + public void close() { + pool.close(); + } + } } diff --git a/test/jdk/java/lang/Thread/virtual/stress/Skynet.java b/test/jdk/java/lang/Thread/virtual/stress/Skynet.java index 5b63fe84b1d..562a8dbd5e1 100644 --- a/test/jdk/java/lang/Thread/virtual/stress/Skynet.java +++ b/test/jdk/java/lang/Thread/virtual/stress/Skynet.java @@ -28,22 +28,12 @@ * @requires !vm.debug | vm.gc != "Z" * @run main/othervm/timeout=300 -Xmx1500m Skynet */ - -/* - * @test id=ZSinglegen - * @requires vm.debug == true & vm.continuations - * @requires vm.gc.ZSinglegen - * @run main/othervm/timeout=300 -XX:+UnlockDiagnosticVMOptions - * -XX:+UseZGC -XX:-ZGenerational - * -XX:+ZVerifyOops -XX:ZCollectionInterval=0.01 -Xmx1500m Skynet - */ - /* - * @test id=ZGenerational + * @test id=Z * @requires vm.debug == true & vm.continuations - * @requires vm.gc.ZGenerational + * @requires vm.gc.Z * @run main/othervm/timeout=300 -XX:+UnlockDiagnosticVMOptions - * -XX:+UseZGC -XX:+ZGenerational + * -XX:+UseZGC * -XX:+ZVerifyOops -XX:ZCollectionInterval=0.01 -Xmx1500m Skynet */ diff --git a/test/jdk/java/lang/management/MemoryMXBean/MemoryTest.java b/test/jdk/java/lang/management/MemoryMXBean/MemoryTest.java index 68a6671e77a..f8abba43983 100644 --- a/test/jdk/java/lang/management/MemoryMXBean/MemoryTest.java +++ b/test/jdk/java/lang/management/MemoryMXBean/MemoryTest.java @@ -34,27 +34,15 @@ */ /* - * @test id=ZSinglegen + * @test id=Z * @bug 4530538 * @summary Basic unit test of MemoryMXBean.getMemoryPools() and * MemoryMXBean.getMemoryManager(). - * @requires vm.gc.ZSinglegen + * @requires vm.gc.Z * @author Mandy Chung * * @modules jdk.management - * @run main/othervm -XX:+UseZGC -XX:-ZGenerational MemoryTest 2 1 - */ - -/* - * @test id=ZGenerational - * @bug 4530538 - * @summary Basic unit test of MemoryMXBean.getMemoryPools() and - * MemoryMXBean.getMemoryManager(). - * @requires vm.gc.ZGenerational - * @author Mandy Chung - * - * @modules jdk.management - * @run main/othervm -XX:+UseZGC -XX:+ZGenerational MemoryTest 4 2 + * @run main/othervm -XX:+UseZGC MemoryTest 4 2 */ /* diff --git a/test/jdk/java/nio/channels/Selector/WakeupNow.java b/test/jdk/java/nio/channels/Selector/WakeupNow.java index 23dc0c30907..a8d1222ba13 100644 --- a/test/jdk/java/nio/channels/Selector/WakeupNow.java +++ b/test/jdk/java/nio/channels/Selector/WakeupNow.java @@ -26,7 +26,9 @@ * @summary Ensure that the wakeup state is cleared by selectNow() */ -import java.nio.channels.*; +import java.nio.channels.Pipe; +import java.nio.channels.SelectionKey; +import java.nio.channels.Selector; public class WakeupNow { @@ -47,14 +49,15 @@ private static void test1() throws Exception { // ensure wakeup is consumed by selectNow Thread.sleep(2000); sel.selectNow(); - long startTime = System.currentTimeMillis(); + long startTime = System.nanoTime(); int n = sel.select(2000); - long endTime = System.currentTimeMillis(); + long endTime = System.nanoTime(); p.source().close(); p.sink().close(); sel.close(); - if (endTime - startTime < 1000) - throw new RuntimeException("test failed"); + long delta = endTime - startTime; + if (delta < 1_000_000_000) + throw new RuntimeException("test failed with delta " + delta); } // Test if selectNow clears wakeup with only the wakeup fd @@ -62,18 +65,17 @@ private static void test1() throws Exception { // This fails before the fix on Solaris private static void test2() throws Exception { Selector sel = Selector.open(); - Pipe p = Pipe.open(); - p.source().configureBlocking(false); sel.wakeup(); // ensure wakeup is consumed by selectNow Thread.sleep(2000); sel.selectNow(); - long startTime = System.currentTimeMillis(); + long startTime = System.nanoTime(); int n = sel.select(2000); - long endTime = System.currentTimeMillis(); + long endTime = System.nanoTime(); sel.close(); - if (endTime - startTime < 1000) - throw new RuntimeException("test failed"); + long delta = endTime - startTime; + if (delta < 1_000_000_000) + throw new RuntimeException("test failed with delta " + delta); } } diff --git a/test/jdk/java/nio/file/DirectoryStream/SecureDS.java b/test/jdk/java/nio/file/DirectoryStream/SecureDS.java index d4f197eb09b..e058d782c52 100644 --- a/test/jdk/java/nio/file/DirectoryStream/SecureDS.java +++ b/test/jdk/java/nio/file/DirectoryStream/SecureDS.java @@ -22,8 +22,9 @@ */ /* @test - * @bug 4313887 6838333 + * @bug 4313887 6838333 8343020 * @summary Unit test for java.nio.file.SecureDirectoryStream + * @requires (os.family == "linux" | os.family == "mac") * @library .. */ @@ -45,11 +46,7 @@ public static void main(String[] args) throws IOException { DirectoryStream stream = newDirectoryStream(dir); stream.close(); if (!(stream instanceof SecureDirectoryStream)) { - if (System.getProperty("os.name").equals("Linux")) - throw new AssertionError( - "SecureDirectoryStream not supported."); - System.out.println("SecureDirectoryStream not supported."); - return; + throw new AssertionError("SecureDirectoryStream not supported."); } supportsSymbolicLinks = TestUtil.supportsSymbolicLinks(dir); diff --git a/test/jdk/java/security/KeyAgreement/KeyAgreementTest.java b/test/jdk/java/security/KeyAgreement/KeyAgreementTest.java index 1e16c157fed..1e5eb968030 100644 --- a/test/jdk/java/security/KeyAgreement/KeyAgreementTest.java +++ b/test/jdk/java/security/KeyAgreement/KeyAgreementTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -51,7 +51,7 @@ public static void main(String[] args) throws Exception { String kaAlgo = args[0]; String kpgAlgo = args[1]; - String provider = args[2]; + String provider = System.getProperty("test.provider.name", args[2]); System.out.println("Testing " + kaAlgo); AlgoSpec aSpec = AlgoSpec.valueOf(AlgoSpec.class, kaAlgo); List specs = aSpec.getAlgorithmParameterSpecs(); diff --git a/test/jdk/java/security/KeyAgreement/KeySizeTest.java b/test/jdk/java/security/KeyAgreement/KeySizeTest.java index 5dfb2dc7315..6ac36a5ee86 100644 --- a/test/jdk/java/security/KeyAgreement/KeySizeTest.java +++ b/test/jdk/java/security/KeyAgreement/KeySizeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -64,7 +64,7 @@ public class KeySizeTest { public static void main(String[] args) throws Exception { String kaAlgo = args[0]; - String provider = args[1]; + String provider = System.getProperty("test.provider.name", args[1]); String kpgAlgo = args[2]; int keySize = Integer.parseInt(args[3]); testKeyAgreement(provider, kaAlgo, kpgAlgo, keySize); diff --git a/test/jdk/java/security/KeyAgreement/KeySpecTest.java b/test/jdk/java/security/KeyAgreement/KeySpecTest.java index 1e8742dd796..f5974738a12 100644 --- a/test/jdk/java/security/KeyAgreement/KeySpecTest.java +++ b/test/jdk/java/security/KeyAgreement/KeySpecTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,6 +24,7 @@ /* * @test * @bug 8184359 + * @library /test/lib * @summary Standard tests on KeySpec, KeyFactory, KeyPairs and Keys. * Arguments order * @run main KeySpecTest DiffieHellman SunJCE DiffieHellman @@ -55,13 +56,14 @@ import javax.crypto.KeyAgreement; import javax.crypto.spec.DHPrivateKeySpec; import javax.crypto.spec.DHPublicKeySpec; +import jdk.test.lib.security.SecurityUtils; public class KeySpecTest { public static void main(String[] args) throws Exception { String kaAlgo = args[0]; - String provider = args[1]; + String provider = System.getProperty("test.provider.name", args[1]); String kpgAlgo = args[2]; KeyPair kp = genKeyPair(provider, kpgAlgo, (args.length > 3) ? args[3] : kpgAlgo); @@ -78,7 +80,7 @@ private static KeyPair genKeyPair(String provider, String kpgAlgo, KeyPairGenerator kpg = KeyPairGenerator.getInstance(kpgAlgo, provider); switch (kpgInit) { case "DiffieHellman": - kpg.initialize(512); + kpg.initialize(SecurityUtils.getTestKeySize(kpgInit)); break; case "EC": kpg.initialize(256); diff --git a/test/jdk/java/security/KeyAgreement/MultiThreadTest.java b/test/jdk/java/security/KeyAgreement/MultiThreadTest.java index f53572a10b5..743e874a7de 100644 --- a/test/jdk/java/security/KeyAgreement/MultiThreadTest.java +++ b/test/jdk/java/security/KeyAgreement/MultiThreadTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,6 +24,7 @@ /* * @test * @bug 8184359 + * @library /test/lib * @summary KeyPairGenerator Test with multiple threads. * Arguments order * @run main MultiThreadTest DiffieHellman SunJCE DiffieHellman @@ -39,6 +40,7 @@ import java.util.concurrent.Executors; import java.util.concurrent.ThreadFactory; import javax.crypto.KeyAgreement; +import jdk.test.lib.security.SecurityUtils; /** * This test targets KeyPairGenerator API related issue in a multi threaded @@ -52,7 +54,7 @@ public class MultiThreadTest { public static void main(String[] args) throws Exception { String kaAlgo = args[0]; - String provider = args[1]; + String provider = System.getProperty("test.provider.name", args[1]); String kpgAlgo = args[2]; KeyPairGenerator kpg = genKeyGenerator(provider, kpgAlgo, (args.length > 3) ? args[3] : kpgAlgo); @@ -68,7 +70,7 @@ private static KeyPairGenerator genKeyGenerator(String provider, KeyPairGenerator kpg = KeyPairGenerator.getInstance(kpgAlgo, provider); switch (kpgInit) { case "DiffieHellman": - kpg.initialize(512); + kpg.initialize(SecurityUtils.getTestKeySize(kpgInit)); break; case "EC": kpg.initialize(256); diff --git a/test/jdk/java/security/KeyAgreement/NegativeTest.java b/test/jdk/java/security/KeyAgreement/NegativeTest.java index 864bf09aeeb..3ccb614ffc3 100644 --- a/test/jdk/java/security/KeyAgreement/NegativeTest.java +++ b/test/jdk/java/security/KeyAgreement/NegativeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,7 +35,7 @@ * Arguments order * * @library /test/lib - * @run main NegativeTest DiffieHellman SunJCE DiffieHellman 1024 + * @run main NegativeTest DiffieHellman SunJCE DiffieHellman 2048 * @run main NegativeTest ECDH SunEC EC 256 * @run main NegativeTest XDH SunEC XDH 255 X25519 * @run main NegativeTest XDH SunEC XDH 448 X448 @@ -59,13 +59,14 @@ import java.util.Arrays; import java.util.HexFormat; import javax.crypto.KeyAgreement; +import jdk.test.lib.security.SecurityUtils; public class NegativeTest { public static void main(String[] args) throws Exception { String kaAlgo = args[0]; - String provider = args[1]; + String provider = System.getProperty("test.provider.name", args[1]); String kpgAlgo = args[2]; int keySize = Integer.parseInt(args[3]); String kpgInit = (args.length > 4) ? args[4] : args[2]; @@ -93,7 +94,7 @@ private static KeyPair genKeyPair(String provider, String kpgAlgo, Security.getProvider(provider)); switch (kpgInit) { case "DiffieHellman": - kpg.initialize(512); + kpg.initialize(SecurityUtils.getTestKeySize(kpgInit)); break; case "EC": kpg.initialize(256); diff --git a/test/jdk/java/security/KeyFactory/Failover.java b/test/jdk/java/security/KeyFactory/Failover.java index 6242758a9cf..7107ef1ad02 100644 --- a/test/jdk/java/security/KeyFactory/Failover.java +++ b/test/jdk/java/security/KeyFactory/Failover.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,7 +24,7 @@ /** * @test * @bug 4894125 7054918 8130181 - * @library ../testlibrary + * @library ../testlibrary /test/lib * @summary test that failover for KeyFactory works * @author Andreas Sterbenz */ @@ -34,6 +34,7 @@ import java.security.*; import java.security.interfaces.*; import java.security.spec.*; +import jdk.test.lib.security.SecurityUtils; public class Failover { @@ -72,8 +73,9 @@ public static void main0(String[] args) throws Exception { // somewhat more real tests using DSA System.out.println("DSA tests..."); - KeyPairGenerator kpg = KeyPairGenerator.getInstance("DSA"); - kpg.initialize(512); + String kpgAlgorithm = "DSA"; + KeyPairGenerator kpg = KeyPairGenerator.getInstance(kpgAlgorithm); + kpg.initialize(SecurityUtils.getTestKeySize(kpgAlgorithm)); KeyPair kp = kpg.generateKeyPair(); kf = KeyFactory.getInstance("DSA"); diff --git a/test/jdk/java/security/KeyFactory/GenerateRSAPrivateCrtKey.java b/test/jdk/java/security/KeyFactory/GenerateRSAPrivateCrtKey.java index de37778b844..1c7cdba2598 100644 --- a/test/jdk/java/security/KeyFactory/GenerateRSAPrivateCrtKey.java +++ b/test/jdk/java/security/KeyFactory/GenerateRSAPrivateCrtKey.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -51,7 +51,8 @@ public static void main(String[] args) throws Exception { new BigInteger(1, coeff)); // Create an RSA private key from the CRT specification - KeyFactory kf = KeyFactory.getInstance("RSA", "SunRsaSign"); + KeyFactory kf = KeyFactory.getInstance("RSA", + System.getProperty("test.provider.name", "SunRsaSign")); RSAPrivateCrtKey rsaPriKey = (RSAPrivateCrtKey) kf.generatePrivate(rsaCrtSpec); diff --git a/test/jdk/java/security/KeyFactory/KeyFactoryGetKeySpecForInvalidSpec.java b/test/jdk/java/security/KeyFactory/KeyFactoryGetKeySpecForInvalidSpec.java index e72d5c8decc..71b05b0c225 100644 --- a/test/jdk/java/security/KeyFactory/KeyFactoryGetKeySpecForInvalidSpec.java +++ b/test/jdk/java/security/KeyFactory/KeyFactoryGetKeySpecForInvalidSpec.java @@ -69,7 +69,8 @@ public BigInteger getModulus() { } public static void main(String[] args) throws Exception { - KeyPairGenerator kg = KeyPairGenerator.getInstance("RSA", "SunRsaSign"); + KeyPairGenerator kg = KeyPairGenerator.getInstance("RSA", + System.getProperty("test.provider.name", "SunRsaSign")); kg.initialize(2048); KeyPair pair = kg.generateKeyPair(); diff --git a/test/jdk/java/security/KeyPairGenerator/GenerateKeypair.java b/test/jdk/java/security/KeyPairGenerator/GenerateKeypair.java index 2c68e5954fa..b2c87b1c38a 100644 --- a/test/jdk/java/security/KeyPairGenerator/GenerateKeypair.java +++ b/test/jdk/java/security/KeyPairGenerator/GenerateKeypair.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,18 +24,21 @@ /* * @test * @bug 4221800 + * @library /test/lib * @summary Test restored generateKeyPair method */ import java.security.KeyPairGenerator; import java.security.KeyPair; +import jdk.test.lib.security.SecurityUtils; public class GenerateKeypair { public static void main(String[] args) throws Exception { - KeyPairGenerator kpg = KeyPairGenerator.getInstance("DSA"); - kpg.initialize(512); + String kpgAlgorithm = "DSA"; + KeyPairGenerator kpg = KeyPairGenerator.getInstance(kpgAlgorithm); + kpg.initialize(SecurityUtils.getTestKeySize(kpgAlgorithm)); // test generateKeyPair KeyPair kpair = kpg.generateKeyPair(); diff --git a/test/jdk/java/security/KeyPairGenerator/GenerateRSAKeyPair.java b/test/jdk/java/security/KeyPairGenerator/GenerateRSAKeyPair.java index eafd06ee3ec..1b9ace546dc 100644 --- a/test/jdk/java/security/KeyPairGenerator/GenerateRSAKeyPair.java +++ b/test/jdk/java/security/KeyPairGenerator/GenerateRSAKeyPair.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,6 +24,7 @@ /* * @test * @bug 4297026 + * @library /test/lib * @summary Make sure that RSA Keypair generation using * java.security.spec.RSAKeyGenParameterSpec passes */ @@ -31,14 +32,18 @@ import java.security.KeyPairGenerator; import java.security.KeyPair; import java.security.spec.RSAKeyGenParameterSpec; +import jdk.test.lib.security.SecurityUtils; public class GenerateRSAKeyPair { public static void main(String[] args) throws Exception { + String kpgAlgorithm = "RSA"; RSAKeyGenParameterSpec rsaSpec = - new RSAKeyGenParameterSpec (1024, RSAKeyGenParameterSpec.F4); - KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA", "SunRsaSign"); + new RSAKeyGenParameterSpec (SecurityUtils.getTestKeySize(kpgAlgorithm), + RSAKeyGenParameterSpec.F4); + KeyPairGenerator kpg = KeyPairGenerator.getInstance(kpgAlgorithm, + System.getProperty("test.provider.name", "SunRsaSign")); kpg.initialize(rsaSpec); // test generateKeyPair diff --git a/test/jdk/java/security/KeyRep/Serial.java b/test/jdk/java/security/KeyRep/Serial.java index 413aa10661a..88c91a091e7 100644 --- a/test/jdk/java/security/KeyRep/Serial.java +++ b/test/jdk/java/security/KeyRep/Serial.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,6 +24,7 @@ /* * @test * @bug 4532506 4999599 + * @library /test/lib * @summary Serializing KeyPair on one VM (Sun), * and Deserializing on another (IBM) fails * @run main/othervm/java.security.policy=Serial.policy Serial @@ -34,19 +35,22 @@ import java.security.*; import javax.crypto.*; import javax.crypto.spec.*; +import jdk.test.lib.security.DiffieHellmanGroup; +import jdk.test.lib.security.SecurityUtils; public class Serial { // providers - private static final String SUN = "SUN"; - private static final String RSA = "SunRsaSign"; - private static final String JCE = "SunJCE"; + private static final String SUN = System.getProperty("test.provider.name", "SUN"); + private static final String RSA = System.getProperty("test.provider.name", "SunRsaSign"); + private static final String JCE = System.getProperty("test.provider.name", "SunJCE"); public static void main(String[] args) throws Exception { // generate DSA key pair - KeyPairGenerator kpg = KeyPairGenerator.getInstance("DSA", SUN); - kpg.initialize(512); + String kpgAlgorithmDsa = "DSA"; + KeyPairGenerator kpg = KeyPairGenerator.getInstance(kpgAlgorithmDsa, SUN); + kpg.initialize(SecurityUtils.getTestKeySize(kpgAlgorithmDsa)); KeyPair dsaKp = kpg.genKeyPair(); // serialize DSA key pair @@ -67,8 +71,9 @@ public static void main(String[] args) throws Exception { } // generate RSA key pair - kpg = KeyPairGenerator.getInstance("RSA", RSA); - kpg.initialize(512); + String kpgAlgorithmRsa = "RSA"; + kpg = KeyPairGenerator.getInstance(kpgAlgorithmRsa, RSA); + kpg.initialize(SecurityUtils.getTestKeySize(kpgAlgorithmRsa)); KeyPair rsaKp = kpg.genKeyPair(); // serialize RSA key pair @@ -89,8 +94,9 @@ public static void main(String[] args) throws Exception { } // generate DH key pair + DiffieHellmanGroup dhGroup = SecurityUtils.getTestDHGroup(); kpg = KeyPairGenerator.getInstance("DiffieHellman", JCE); - kpg.initialize(new DHParameterSpec(skip1024Modulus, skip1024Base)); + kpg.initialize(new DHParameterSpec(dhGroup.getPrime(), dhGroup.getBase())); KeyPair dhKp = kpg.genKeyPair(); // serialize DH key pair @@ -197,47 +203,4 @@ private static void checkKey(String algorithm, int size) throws Exception { throw new SecurityException(algorithm + " test failed"); } } - - // The 1024 bit Diffie-Hellman modulus values used by SKIP - private static final byte skip1024ModulusBytes[] = { - (byte)0xF4, (byte)0x88, (byte)0xFD, (byte)0x58, - (byte)0x4E, (byte)0x49, (byte)0xDB, (byte)0xCD, - (byte)0x20, (byte)0xB4, (byte)0x9D, (byte)0xE4, - (byte)0x91, (byte)0x07, (byte)0x36, (byte)0x6B, - (byte)0x33, (byte)0x6C, (byte)0x38, (byte)0x0D, - (byte)0x45, (byte)0x1D, (byte)0x0F, (byte)0x7C, - (byte)0x88, (byte)0xB3, (byte)0x1C, (byte)0x7C, - (byte)0x5B, (byte)0x2D, (byte)0x8E, (byte)0xF6, - (byte)0xF3, (byte)0xC9, (byte)0x23, (byte)0xC0, - (byte)0x43, (byte)0xF0, (byte)0xA5, (byte)0x5B, - (byte)0x18, (byte)0x8D, (byte)0x8E, (byte)0xBB, - (byte)0x55, (byte)0x8C, (byte)0xB8, (byte)0x5D, - (byte)0x38, (byte)0xD3, (byte)0x34, (byte)0xFD, - (byte)0x7C, (byte)0x17, (byte)0x57, (byte)0x43, - (byte)0xA3, (byte)0x1D, (byte)0x18, (byte)0x6C, - (byte)0xDE, (byte)0x33, (byte)0x21, (byte)0x2C, - (byte)0xB5, (byte)0x2A, (byte)0xFF, (byte)0x3C, - (byte)0xE1, (byte)0xB1, (byte)0x29, (byte)0x40, - (byte)0x18, (byte)0x11, (byte)0x8D, (byte)0x7C, - (byte)0x84, (byte)0xA7, (byte)0x0A, (byte)0x72, - (byte)0xD6, (byte)0x86, (byte)0xC4, (byte)0x03, - (byte)0x19, (byte)0xC8, (byte)0x07, (byte)0x29, - (byte)0x7A, (byte)0xCA, (byte)0x95, (byte)0x0C, - (byte)0xD9, (byte)0x96, (byte)0x9F, (byte)0xAB, - (byte)0xD0, (byte)0x0A, (byte)0x50, (byte)0x9B, - (byte)0x02, (byte)0x46, (byte)0xD3, (byte)0x08, - (byte)0x3D, (byte)0x66, (byte)0xA4, (byte)0x5D, - (byte)0x41, (byte)0x9F, (byte)0x9C, (byte)0x7C, - (byte)0xBD, (byte)0x89, (byte)0x4B, (byte)0x22, - (byte)0x19, (byte)0x26, (byte)0xBA, (byte)0xAB, - (byte)0xA2, (byte)0x5E, (byte)0xC3, (byte)0x55, - (byte)0xE9, (byte)0x2F, (byte)0x78, (byte)0xC7 - }; - - // The SKIP 1024 bit modulus - private static final BigInteger skip1024Modulus - = new BigInteger(1, skip1024ModulusBytes); - - // The base used with the SKIP 1024 bit modulus - private static final BigInteger skip1024Base = BigInteger.valueOf(2); } diff --git a/test/jdk/java/security/KeyRep/Serial.policy b/test/jdk/java/security/KeyRep/Serial.policy index 0c2c1d0868d..3c529c87a13 100644 --- a/test/jdk/java/security/KeyRep/Serial.policy +++ b/test/jdk/java/security/KeyRep/Serial.policy @@ -1,3 +1,4 @@ grant { + permission java.util.PropertyPermission "test.provider.name", "read"; // XXX note package access is *not* granted to the 'sun' package }; diff --git a/test/jdk/java/security/MessageDigest/ByteBuffers.java b/test/jdk/java/security/MessageDigest/ByteBuffers.java index dd3467d0e67..f21a51e1c10 100644 --- a/test/jdk/java/security/MessageDigest/ByteBuffers.java +++ b/test/jdk/java/security/MessageDigest/ByteBuffers.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,7 @@ public class ByteBuffers { public static void main(String[] args) throws Exception { - Provider p = Security.getProvider("SUN"); + Provider p = Security.getProvider(System.getProperty("test.provider.name", "SUN")); Random random = new Random(); int n = 10 * 1024; byte[] t = new byte[n]; diff --git a/test/jdk/java/security/MessageDigest/TestCloneable.java b/test/jdk/java/security/MessageDigest/TestCloneable.java index 3a4feb82ff6..48236dbd447 100644 --- a/test/jdk/java/security/MessageDigest/TestCloneable.java +++ b/test/jdk/java/security/MessageDigest/TestCloneable.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -43,14 +43,16 @@ public class TestCloneable { private static final Class CNSE = CloneNotSupportedException.class; + private static String providerName = System.getProperty("test.provider.name", "SUN"); + @DataProvider public Object[][] testData() { return new Object[][] { - { "MD2", "SUN" }, { "MD5", "SUN" }, { "SHA-1", "SUN" }, - { "SHA-224", "SUN" }, { "SHA-256", "SUN" }, - { "SHA-384", "SUN" }, { "SHA-512", "SUN" }, - { "SHA3-224", "SUN" }, { "SHA3-256", "SUN" }, - { "SHA3-384", "SUN" }, { "SHA3-512", "SUN" } + { "MD2", providerName }, { "MD5", providerName }, { "SHA-1", providerName }, + { "SHA-224", providerName }, { "SHA-256", providerName }, + { "SHA-384", providerName }, { "SHA-512", providerName }, + { "SHA3-224", providerName }, { "SHA3-256", providerName }, + { "SHA3-384", providerName }, { "SHA3-512", providerName } }; } diff --git a/test/jdk/java/security/Provider/SupportsParameter.java b/test/jdk/java/security/Provider/SupportsParameter.java index bc3cb031791..039fb3d0797 100644 --- a/test/jdk/java/security/Provider/SupportsParameter.java +++ b/test/jdk/java/security/Provider/SupportsParameter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,6 +24,7 @@ /** * @test * @bug 4911081 8130181 + * @library /test/lib * @summary verify that Provider.Service.supportsParameter() works * @author Andreas Sterbenz */ @@ -33,12 +34,14 @@ import javax.crypto.*; import javax.crypto.spec.SecretKeySpec; +import jdk.test.lib.security.SecurityUtils; public class SupportsParameter { public static void main(String[] args) throws Exception { - KeyPairGenerator kpg = KeyPairGenerator.getInstance("DSA"); - kpg.initialize(512); + String kpgAlgorithm = "DSA"; + KeyPairGenerator kpg = KeyPairGenerator.getInstance(kpgAlgorithm); + kpg.initialize(SecurityUtils.getTestKeySize(kpgAlgorithm)); KeyPair kp = kpg.generateKeyPair(); PublicKey dsaPublicKey = kp.getPublic(); PrivateKey dsaPrivateKey = kp.getPrivate(); diff --git a/test/jdk/java/security/SecureRandom/DefaultAlgo.java b/test/jdk/java/security/SecureRandom/DefaultAlgo.java index 06027f7162e..8f9e776f246 100644 --- a/test/jdk/java/security/SecureRandom/DefaultAlgo.java +++ b/test/jdk/java/security/SecureRandom/DefaultAlgo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -87,8 +87,9 @@ private static void checkDefault(Provider p, String ... algos) { p.remove("SecureRandom." + s); out.println("removed " + s); } - validate(new SecureRandom(), "SUN", - SunEntries.DEF_SECURE_RANDOM_ALGO); + validate(new SecureRandom(), System.getProperty("test.provider.name", "SUN"), + System.getProperty("test.default.secure.random.algorithm.name", + SunEntries.DEF_SECURE_RANDOM_ALGO)); } else { validate(new SecureRandom(), pName, algos[0]); } diff --git a/test/jdk/java/security/SecureRandom/DefaultProvider.java b/test/jdk/java/security/SecureRandom/DefaultProvider.java index c80700b78c9..b9a393bd346 100644 --- a/test/jdk/java/security/SecureRandom/DefaultProvider.java +++ b/test/jdk/java/security/SecureRandom/DefaultProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,7 +42,7 @@ public static void main(String[] args) throws NoSuchAlgorithmException { out.println("TEST: Default provider with constructor"); SecureRandom secureRandom = new SecureRandom(); String provider = secureRandom.getProvider().getName(); - if (!provider.equals("SUN")) { + if (!provider.equals(System.getProperty("test.provider.name", "SUN"))) { throw new RuntimeException("Unexpected provider name: " + provider); } @@ -51,7 +51,7 @@ public static void main(String[] args) throws NoSuchAlgorithmException { /* Test default provider with getInstance(String algorithm) */ out.println("TEST: SHA1PRNG supported on all platforms by SUN provider"); String algorithm = "SHA1PRNG"; - provider = "SUN"; + provider = System.getProperty("test.provider.name", "SUN"); SecureRandom instance = SecureRandom.getInstance(algorithm); assertInstance(instance, algorithm, provider); @@ -61,7 +61,7 @@ public static void main(String[] args) throws NoSuchAlgorithmException { out.println("TEST: NativePRNG supported on all platforms" + "(except Windows), by SUN provider"); algorithm = "NativePRNG"; - provider = "SUN"; + provider = System.getProperty("test.provider.name", "SUN"); } else { out.println( "TEST: Windows-PRNG supported on windows by SunMSCAPI provider"); diff --git a/test/jdk/java/security/SecureRandom/GetInstanceTest.java b/test/jdk/java/security/SecureRandom/GetInstanceTest.java index c1fdf133305..e95557a7bcb 100644 --- a/test/jdk/java/security/SecureRandom/GetInstanceTest.java +++ b/test/jdk/java/security/SecureRandom/GetInstanceTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -75,7 +75,8 @@ public static void main(String[] args) throws Exception { + "'securerandom.strongAlgorithms'."); } try { - Security.setProperty(STRONG_ALG_SEC_PROP, "DRBG:SUN"); + Security.setProperty(STRONG_ALG_SEC_PROP, "DRBG:" + + System.getProperty("test.provider.name", SUN_PROVIDER)); sr = matchExc(() -> SecureRandom.getInstanceStrong(), PASS, NoSuchAlgorithmException.class, "PASS - Undefined security Property " @@ -123,7 +124,8 @@ private static void verifyInstance(String mech) throws Exception { // Test for getInstance(algorithm, provider) method. checkAttributes( matchExc(() -> SecureRandom.getInstance(srAlgo, - Security.getProvider(SUN_PROVIDER)), + Security.getProvider( + System.getProperty("test.provider.name", SUN_PROVIDER))), !(nsa(mech)), NoSuchAlgorithmException.class, String.format("PASS - It is expected to fail for" @@ -132,7 +134,8 @@ private static void verifyInstance(String mech) throws Exception { mech); // Test for getInstance(algorithm, providerName) method. checkAttributes( - matchExc(() -> SecureRandom.getInstance(srAlgo, SUN_PROVIDER), + matchExc(() -> SecureRandom.getInstance(srAlgo, + System.getProperty("test.provider.name", SUN_PROVIDER)), !(nsa(mech)), NoSuchAlgorithmException.class, String.format("PASS - It is expected to fail for " + "getInstance(algorithm, providerName) when " @@ -175,7 +178,8 @@ private static void verifyInstance(String mech) throws Exception { // Test for getInstance(algorithm, params, provider) method. checkAttributes( matchExc(() -> SecureRandom.getInstance(srAlgo, param, - Security.getProvider(SUN_PROVIDER)), + Security.getProvider(System.getProperty( + "test.provider.name", SUN_PROVIDER))), (isDRBG(mech)) && (isValidDRBGParam(param)), getExcType(mech, param), String.format("PASS - It is expected to fail " @@ -186,7 +190,7 @@ private static void verifyInstance(String mech) throws Exception { // Test for getInstance(algorithm, params, providerName) method. checkAttributes( matchExc(() -> SecureRandom.getInstance(srAlgo, param, - SUN_PROVIDER), + System.getProperty("test.provider.name", SUN_PROVIDER)), (isDRBG(mech)) && (isValidDRBGParam(param)), getExcType(mech, param), String.format("PASS - It is expected to fail " @@ -306,7 +310,8 @@ private static void checkAttributes(SecureRandom sr, String mech) { return; } Asserts.assertEquals(sr.getAlgorithm(), (isDRBG(mech) ? "DRBG" : mech)); - Asserts.assertEquals(sr.getProvider().getName(), SUN_PROVIDER); + String expectedProviderName = System.getProperty("test.provider.name", SUN_PROVIDER); + Asserts.assertEquals(sr.getProvider().getName(), expectedProviderName); } } diff --git a/test/jdk/java/security/Security/CaseInsensitiveAlgNames.java b/test/jdk/java/security/Security/CaseInsensitiveAlgNames.java index 2267c461e55..f29d368d6d1 100644 --- a/test/jdk/java/security/Security/CaseInsensitiveAlgNames.java +++ b/test/jdk/java/security/Security/CaseInsensitiveAlgNames.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,10 +41,14 @@ public static void main(String[] args) md = MessageDigest.getInstance("shA1"); // MessageDigest with provider - md = MessageDigest.getInstance("SHA", "SUN"); - md = MessageDigest.getInstance("sha", "SUN"); - md = MessageDigest.getInstance("Sha-1", "SUN"); - md = MessageDigest.getInstance("shA1", "SUN"); + md = MessageDigest.getInstance("SHA", + System.getProperty("test.provider.name", "SUN")); + md = MessageDigest.getInstance("sha", + System.getProperty("test.provider.name", "SUN")); + md = MessageDigest.getInstance("Sha-1", + System.getProperty("test.provider.name", "SUN")); + md = MessageDigest.getInstance("shA1", + System.getProperty("test.provider.name", "SUN")); // KeyPairGenerator without provider KeyPairGenerator kGen = KeyPairGenerator.getInstance("DSA"); @@ -54,11 +58,15 @@ public static void main(String[] args) kGen = KeyPairGenerator.getInstance("1.2.840.10040.4.1"); // KeyPairGenerator with provider - kGen = KeyPairGenerator.getInstance("DSA", "SUN"); - kGen = KeyPairGenerator.getInstance("dsa", "SUN"); - kGen = KeyPairGenerator.getInstance("dSA", "SUN"); + kGen = KeyPairGenerator.getInstance("DSA", + System.getProperty("test.provider.name", "SUN")); + kGen = KeyPairGenerator.getInstance("dsa", + System.getProperty("test.provider.name", "SUN")); + kGen = KeyPairGenerator.getInstance("dSA", + System.getProperty("test.provider.name", "SUN")); kGen = KeyPairGenerator.getInstance("OId.1.2.840.10040.4.1", - "SUN"); - kGen = KeyPairGenerator.getInstance("1.2.840.10040.4.1", "SUN"); + System.getProperty("test.provider.name", "SUN")); + kGen = KeyPairGenerator.getInstance("1.2.840.10040.4.1", + System.getProperty("test.provider.name", "SUN")); } } diff --git a/test/jdk/java/security/Signature/ByteBuffers.java b/test/jdk/java/security/Signature/ByteBuffers.java index 937c9842c3b..d9866204244 100644 --- a/test/jdk/java/security/Signature/ByteBuffers.java +++ b/test/jdk/java/security/Signature/ByteBuffers.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,8 @@ public class ByteBuffers { public static void main(String[] args) throws Exception { - Provider p = Security.getProvider("SUN"); + Provider p = Security.getProvider( + System.getProperty("test.provider.name", "SUN")); Random random = new Random(); int n = 10 * 1024; byte[] t = new byte[n]; diff --git a/test/jdk/java/security/Signature/NONEwithRSA.java b/test/jdk/java/security/Signature/NONEwithRSA.java index 6d18c7ac96f..c7b08528e7e 100644 --- a/test/jdk/java/security/Signature/NONEwithRSA.java +++ b/test/jdk/java/security/Signature/NONEwithRSA.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,6 +24,7 @@ /** * @test * @bug 4955844 + * @library /test/lib * @summary ensure that the NONEwithRSA adapter works correctly * @author Andreas Sterbenz * @key randomness @@ -34,17 +35,19 @@ import java.security.*; import javax.crypto.*; +import jdk.test.lib.security.SecurityUtils; public class NONEwithRSA { public static void main(String[] args) throws Exception { -// showProvider(Security.getProvider("SUN")); +// showProvider(Security.getProvider(System.getProperty("test.provider.name", "SUN"))); Random random = new Random(); byte[] b = new byte[16]; random.nextBytes(b); - KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA"); - kpg.initialize(512); + String kpgAlgorithm = "RSA"; + KeyPairGenerator kpg = KeyPairGenerator.getInstance(kpgAlgorithm); + kpg.initialize(SecurityUtils.getTestKeySize(kpgAlgorithm)); KeyPair kp = kpg.generateKeyPair(); Signature sig = Signature.getInstance("NONEwithRSA"); @@ -66,9 +69,11 @@ public static void main(String[] args) throws Exception { throw new Exception("decryption failed"); } - sig = Signature.getInstance("NONEwithRSA", "SunJCE"); + sig = Signature.getInstance("NONEwithRSA", + System.getProperty("test.provider.name", "SunJCE")); sig.initSign(kp.getPrivate()); - sig = Signature.getInstance("NONEwithRSA", Security.getProvider("SunJCE")); + sig = Signature.getInstance("NONEwithRSA", Security.getProvider( + System.getProperty("test.provider.name", "SunJCE"))); sig.initSign(kp.getPrivate()); try { diff --git a/test/jdk/java/security/Signature/ResetAfterException.java b/test/jdk/java/security/Signature/ResetAfterException.java index 62d5c190bec..39c766ac63d 100644 --- a/test/jdk/java/security/Signature/ResetAfterException.java +++ b/test/jdk/java/security/Signature/ResetAfterException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,10 +24,12 @@ /** * @test * @bug 8149802 + * @library /test/lib * @summary Ensure that Signature objects are reset after verification errored out. */ import java.util.Arrays; import java.security.*; +import jdk.test.lib.security.SecurityUtils; public class ResetAfterException { @@ -51,18 +53,19 @@ public static void main(String[] args) throws Exception { boolean res = true; System.out.println("Testing Provider: " + p.getName()); KeyPairGenerator keyGen = null; + String kpgAlgorithm = "RSA"; try { // It's possible that some provider, e.g. SunMSCAPI, // doesn't work well with keys from other providers // so we use the same provider to generate key first - keyGen = KeyPairGenerator.getInstance("RSA", p); + keyGen = KeyPairGenerator.getInstance(kpgAlgorithm, p); } catch (NoSuchAlgorithmException nsae) { - keyGen = KeyPairGenerator.getInstance("RSA"); + keyGen = KeyPairGenerator.getInstance(kpgAlgorithm); } if (keyGen == null) { throw new RuntimeException("Error: No support for RSA KeyPairGenerator"); } - keyGen.initialize(1024); + keyGen.initialize(SecurityUtils.getTestKeySize(kpgAlgorithm)); KeyPair keyPair = keyGen.generateKeyPair(); sig.initSign(keyPair.getPrivate()); diff --git a/test/jdk/java/security/Signature/SignatureGetInstance.java b/test/jdk/java/security/Signature/SignatureGetInstance.java index c246773f83a..e36d253dbc8 100644 --- a/test/jdk/java/security/Signature/SignatureGetInstance.java +++ b/test/jdk/java/security/Signature/SignatureGetInstance.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -50,7 +50,8 @@ public static void main(String[] args) throws Exception { MyPubKey testPub = new MyPubKey(); testDblInit(testPriv, testPub, true, "TestProvider"); - testDblInit(kp.getPrivate(), kp.getPublic(), true, "SunRsaSign"); + testDblInit(kp.getPrivate(), kp.getPublic(), true, + System.getProperty("test.provider.name", "SunRsaSign")); testDblInit(testPriv, kp.getPublic(), false, null); testDblInit(kp.getPrivate(), testPub, false, null); @@ -59,7 +60,7 @@ public static void main(String[] args) throws Exception { testSetAndInit(null, kp.getPrivate(), true); testSetAndInit(null, kp.getPublic(), true); - String provName = "SunRsaSign"; + String provName = System.getProperty("test.provider.name", "SunRsaSign"); testSetAndInit(provName, testPriv, false); testSetAndInit(provName, testPub, false); testSetAndInit(provName, kp.getPrivate(), true); diff --git a/test/jdk/java/security/Signature/TestCloneable.java b/test/jdk/java/security/Signature/TestCloneable.java index 33e2383cfa4..97f69a8725b 100644 --- a/test/jdk/java/security/Signature/TestCloneable.java +++ b/test/jdk/java/security/Signature/TestCloneable.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,21 +42,25 @@ public class TestCloneable { @DataProvider public Object[][] testData() { + String dsaProviderName = System.getProperty("test.provider.name", "SUN"); + String ecProviderName = System.getProperty("test.provider.name", "SunEC"); + String rsaProviderName = System.getProperty("test.provider.name", "SunRsaSign"); + return new Object[][] { - { "SHA1withDSA", "SUN" }, { "NONEwithDSA", "SUN" }, - { "SHA224withDSA", "SUN" }, { "SHA256withDSA", "SUN" }, - { "EdDSA", "SunEC" }, { "Ed25519", "SunEC" }, { "Ed448", "SunEC" }, - { "SHA1withECDSA", "SunEC" }, { "SHA224withECDSA", "SunEC" }, - { "SHA256withECDSA", "SunEC" }, { "SHA384withECDSA", "SunEC" }, - { "SHA512withECDSA", "SunEC" }, { "NONEwithECDSA", "SunEC" }, - { "MD2withRSA", "SunRsaSign" }, { "MD5withRSA", "SunRsaSign" }, - { "SHA1withRSA", "SunRsaSign" }, { "SHA224withRSA", "SunRsaSign" }, - { "SHA256withRSA", "SunRsaSign" }, - { "SHA384withRSA", "SunRsaSign" }, - { "SHA512withRSA", "SunRsaSign" }, - { "SHA512/224withRSA", "SunRsaSign" }, - { "SHA512/256withRSA", "SunRsaSign" }, - { "RSASSA-PSS", "SunRsaSign" }, + { "SHA1withDSA", dsaProviderName }, { "NONEwithDSA", dsaProviderName }, + { "SHA224withDSA", dsaProviderName }, { "SHA256withDSA", dsaProviderName }, + { "EdDSA", ecProviderName }, { "Ed25519", ecProviderName }, { "Ed448", ecProviderName }, + { "SHA1withECDSA", ecProviderName }, { "SHA224withECDSA", ecProviderName }, + { "SHA256withECDSA", ecProviderName }, { "SHA384withECDSA", ecProviderName }, + { "SHA512withECDSA", ecProviderName }, { "NONEwithECDSA", ecProviderName }, + { "MD2withRSA", rsaProviderName }, { "MD5withRSA", rsaProviderName }, + { "SHA1withRSA", rsaProviderName }, { "SHA224withRSA", rsaProviderName }, + { "SHA256withRSA", rsaProviderName }, + { "SHA384withRSA", rsaProviderName }, + { "SHA512withRSA", rsaProviderName }, + { "SHA512/224withRSA", rsaProviderName }, + { "SHA512/256withRSA", rsaProviderName }, + { "RSASSA-PSS", rsaProviderName }, { "NONEwithRSA", "SunMSCAPI" }, { "SHA1withRSA", "SunMSCAPI" }, { "SHA256withRSA", "SunMSCAPI" }, { "SHA384withRSA", "SunMSCAPI" }, { "SHA512withRSA", "SunMSCAPI" }, diff --git a/test/jdk/java/security/Signature/TestInitSignWithMyOwnRandom.java b/test/jdk/java/security/Signature/TestInitSignWithMyOwnRandom.java index 0d2d7fd35a4..a59ea9a9355 100644 --- a/test/jdk/java/security/Signature/TestInitSignWithMyOwnRandom.java +++ b/test/jdk/java/security/Signature/TestInitSignWithMyOwnRandom.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,7 +34,8 @@ public class TestInitSignWithMyOwnRandom { public static void main(String[] argv) throws Exception { // any signature implementation will do as long as // it needs a random source - Provider p = Security.getProvider("SUN"); + Provider p = Security.getProvider( + System.getProperty("test.provider.name", "SUN")); KeyPairGenerator kpg = KeyPairGenerator.getInstance("DSA", p); kpg.initialize(512); KeyPair kp = kpg.generateKeyPair(); diff --git a/test/jdk/java/security/Signature/VerifyRangeCheckOverflow.java b/test/jdk/java/security/Signature/VerifyRangeCheckOverflow.java index b68d8ca9be7..5cf939d05db 100644 --- a/test/jdk/java/security/Signature/VerifyRangeCheckOverflow.java +++ b/test/jdk/java/security/Signature/VerifyRangeCheckOverflow.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,6 +27,7 @@ /* @test * @bug 7172149 + * @library /test/lib * @summary AIOOBE from Signature.verify after integer overflow * @author Jonathan Lu */ @@ -35,12 +36,14 @@ import java.security.KeyPairGenerator; import java.security.PublicKey; import java.security.Signature; +import jdk.test.lib.security.SecurityUtils; public class VerifyRangeCheckOverflow { public static void main(String[] args) throws Exception { - KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("DSA"); - keyPairGenerator.initialize(1024); + String kpgAlgorithm = "DSA"; + KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance(kpgAlgorithm); + keyPairGenerator.initialize(SecurityUtils.getTestKeySize(kpgAlgorithm)); KeyPair keys = keyPairGenerator.generateKeyPair(); PublicKey publicKey = keys.getPublic(); byte[] sigBytes = new byte[100]; diff --git a/test/jdk/java/security/SignedObject/Chain.java b/test/jdk/java/security/SignedObject/Chain.java index b4a5ea794e6..0fb5cf3c53f 100644 --- a/test/jdk/java/security/SignedObject/Chain.java +++ b/test/jdk/java/security/SignedObject/Chain.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -55,7 +55,10 @@ static enum Provider { Sun("SUN"), SunEC("SunEC"), SunJSSE("SunJSSE"), - SunMSCAPI("SunMSCAPI"); + SunMSCAPI("SunMSCAPI"), + TestProvider_or_SunRsaSign(System.getProperty("test.provider.name", "SunRsaSign")), + TestProvider_or_Sun(System.getProperty("test.provider.name", "SUN")), + TestProvider_or_SunEC(System.getProperty("test.provider.name", "SunEC")); final String name; @@ -166,9 +169,9 @@ public String toString() { new Test(SigAlg.SHA3_256withRSA, KeyAlg.RSA, Provider.Default), new Test(SigAlg.SHA3_384withRSA, KeyAlg.RSA, Provider.Default), new Test(SigAlg.SHA3_512withRSA, KeyAlg.RSA, Provider.Default), - new Test(SigAlg.SHA1withDSA, KeyAlg.DSA, Provider.Sun, 1024), - new Test(SigAlg.SHA224withDSA, KeyAlg.DSA, Provider.Sun, 2048), - new Test(SigAlg.SHA256withDSA, KeyAlg.DSA, Provider.Sun, 2048), + new Test(SigAlg.SHA1withDSA, KeyAlg.DSA, Provider.TestProvider_or_Sun, 1024), + new Test(SigAlg.SHA224withDSA, KeyAlg.DSA, Provider.TestProvider_or_Sun, 2048), + new Test(SigAlg.SHA256withDSA, KeyAlg.DSA, Provider.TestProvider_or_Sun, 2048), }; private static final String str = "to-be-signed"; @@ -190,7 +193,7 @@ private static boolean runTestPSS(int keysize) { Iterator mdAlgs = SigTestUtil.getDigestAlgorithms (SignatureType.RSASSA_PSS, keysize).iterator(); while (mdAlgs.hasNext()) { - result &= runTest(new Test(pss, KeyAlg.RSA, Provider.SunRsaSign, + result &= runTest(new Test(pss, KeyAlg.RSA, Provider.TestProvider_or_SunRsaSign, keysize, SigTestUtil.generateDefaultParameter (SignatureType.RSASSA_PSS, mdAlgs.next()))); } diff --git a/test/jdk/java/security/SignedObject/Copy.java b/test/jdk/java/security/SignedObject/Copy.java index b6edfc031fc..16267ee534d 100644 --- a/test/jdk/java/security/SignedObject/Copy.java +++ b/test/jdk/java/security/SignedObject/Copy.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -49,7 +49,7 @@ public static void main(String args[]) throws Exception { signature); System.out.println("Signature algorithm: " + so.getAlgorithm()); - signature = Signature.getInstance(DSA, "SUN"); + signature = Signature.getInstance(DSA, System.getProperty("test.provider.name", "SUN")); if (!so.verify(kp.getPublic(), signature)) { throw new RuntimeException("Verification failed"); } diff --git a/test/jdk/java/security/cert/X509Certificate/GetSigAlgParams.java b/test/jdk/java/security/cert/X509Certificate/GetSigAlgParams.java index 6d7a8345617..4867058c4c2 100644 --- a/test/jdk/java/security/cert/X509Certificate/GetSigAlgParams.java +++ b/test/jdk/java/security/cert/X509Certificate/GetSigAlgParams.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,12 +24,14 @@ /* * @test * @bug 8259428 + * @library /test/lib * @summary Verify X509Certificate.getSigAlgParams() returns new array each * time it is called * @modules java.base/sun.security.tools.keytool java.base/sun.security.x509 */ import java.security.cert.X509Certificate; +import jdk.test.lib.security.SecurityUtils; import sun.security.tools.keytool.CertAndKeyGen; import sun.security.x509.X500Name; @@ -38,7 +40,7 @@ public class GetSigAlgParams { public static void main(String[] args) throws Exception { CertAndKeyGen cakg = new CertAndKeyGen("RSASSA-PSS", "RSASSA-PSS"); - cakg.generate(1024); + cakg.generate(SecurityUtils.getTestKeySize("RSA")); X509Certificate c = cakg.getSelfCertificate(new X500Name("CN=Me"), 100); if (c.getSigAlgParams() == c.getSigAlgParams()) { throw new Exception("Encoded params are the same byte array"); diff --git a/test/jdk/java/security/misc/GetInstanceNullsEmpties.java b/test/jdk/java/security/misc/GetInstanceNullsEmpties.java index 75089208fa8..9fb1d43e6ed 100644 --- a/test/jdk/java/security/misc/GetInstanceNullsEmpties.java +++ b/test/jdk/java/security/misc/GetInstanceNullsEmpties.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,7 +44,8 @@ */ public class GetInstanceNullsEmpties { - private static final Provider SUN = Security.getProvider("SUN"); + private static final String providerName = System.getProperty("test.provider.name", "SUN"); + private static final Provider provider = Security.getProvider(providerName); /* * See if there are more than "expected" number of getInstance() methods, @@ -168,14 +169,14 @@ private static void testAlgorithmParameterGenerator() throws Exception { run(m, NoSuchAlgorithmException.class, ""); m = getInstance(clazz, STRING, STRING); - run(m, NullPointerException.class, null, "SUN"); - run(m, NoSuchAlgorithmException.class, "", "SUN"); + run(m, NullPointerException.class, null, providerName); + run(m, NoSuchAlgorithmException.class, "", providerName); run(m, IllegalArgumentException.class, "FOO", null); run(m, IllegalArgumentException.class, "FOO", ""); m = getInstance(clazz, STRING, PROVIDER); - run(m, NullPointerException.class, null, SUN); - run(m, NoSuchAlgorithmException.class, "", SUN); + run(m, NullPointerException.class, null, provider); + run(m, NoSuchAlgorithmException.class, "", provider); run(m, IllegalArgumentException.class, "FOO", null); } @@ -190,14 +191,14 @@ private static void testAlgorithmParameters() throws Exception { run(m, NoSuchAlgorithmException.class, ""); m = getInstance(clazz, STRING, STRING); - run(m, NullPointerException.class, null, "SUN"); - run(m, NoSuchAlgorithmException.class, "", "SUN"); + run(m, NullPointerException.class, null, providerName); + run(m, NoSuchAlgorithmException.class, "", providerName); run(m, IllegalArgumentException.class, "FOO", null); run(m, IllegalArgumentException.class, "FOO", ""); m = getInstance(clazz, STRING, PROVIDER); - run(m, NullPointerException.class, null, SUN); - run(m, NoSuchAlgorithmException.class, "", SUN); + run(m, NullPointerException.class, null, provider); + run(m, NoSuchAlgorithmException.class, "", provider); run(m, IllegalArgumentException.class, "FOO", null); } @@ -212,14 +213,14 @@ private static void testCertPathBuilder() throws Exception { run(m, NoSuchAlgorithmException.class, ""); m = getInstance(clazz, STRING, STRING); - run(m, NullPointerException.class, null, "SUN"); - run(m, NoSuchAlgorithmException.class, "", "SUN"); + run(m, NullPointerException.class, null, providerName); + run(m, NoSuchAlgorithmException.class, "", providerName); run(m, IllegalArgumentException.class, "FOO", null); run(m, IllegalArgumentException.class, "FOO", ""); m = getInstance(clazz, STRING, PROVIDER); - run(m, NullPointerException.class, null, SUN); - run(m, NoSuchAlgorithmException.class, "", SUN); + run(m, NullPointerException.class, null, provider); + run(m, NoSuchAlgorithmException.class, "", provider); run(m, IllegalArgumentException.class, "FOO", null); } @@ -234,14 +235,14 @@ private static void testCertPathValidator() throws Exception { run(m, NoSuchAlgorithmException.class, ""); m = getInstance(clazz, STRING, STRING); - run(m, NullPointerException.class, null, "SUN"); - run(m, NoSuchAlgorithmException.class, "", "SUN"); + run(m, NullPointerException.class, null, providerName); + run(m, NoSuchAlgorithmException.class, "", providerName); run(m, IllegalArgumentException.class, "FOO", null); run(m, IllegalArgumentException.class, "FOO", ""); m = getInstance(clazz, STRING, PROVIDER); - run(m, NullPointerException.class, null, SUN); - run(m, NoSuchAlgorithmException.class, "", SUN); + run(m, NullPointerException.class, null, provider); + run(m, NoSuchAlgorithmException.class, "", provider); run(m, IllegalArgumentException.class, "FOO", null); } @@ -257,14 +258,14 @@ private static void testCertStore() throws Exception { run(m, NoSuchAlgorithmException.class, "", csp); m = getInstance(clazz, STRING, CertStoreParameters.class, STRING); - run(m, NullPointerException.class, null, csp, "SUN"); - run(m, NoSuchAlgorithmException.class, "", csp, "SUN"); + run(m, NullPointerException.class, null, csp, providerName); + run(m, NoSuchAlgorithmException.class, "", csp, providerName); run(m, IllegalArgumentException.class, "FOO", csp, null); run(m, IllegalArgumentException.class, "FOO", csp, ""); m = getInstance(clazz, STRING, CertStoreParameters.class, PROVIDER); - run(m, NullPointerException.class, null, csp, SUN); - run(m, NoSuchAlgorithmException.class, "", csp, SUN); + run(m, NullPointerException.class, null, csp, provider); + run(m, NoSuchAlgorithmException.class, "", csp, provider); run(m, IllegalArgumentException.class, "FOO", csp, null); } @@ -279,14 +280,14 @@ private static void testCertificateFactory() throws Exception { run(m, CertificateException.class, ""); m = getInstance(clazz, STRING, STRING); - run(m, NullPointerException.class, null, "SUN"); - run(m, CertificateException.class, "", "SUN"); + run(m, NullPointerException.class, null, providerName); + run(m, CertificateException.class, "", providerName); run(m, IllegalArgumentException.class, "FOO", null); run(m, IllegalArgumentException.class, "FOO", ""); m = getInstance(clazz, STRING, PROVIDER); - run(m, NullPointerException.class, null, SUN); - run(m, CertificateException.class, "", SUN); + run(m, NullPointerException.class, null, provider); + run(m, CertificateException.class, "", provider); run(m, IllegalArgumentException.class, "FOO", null); } @@ -305,14 +306,14 @@ private static void testCipher() throws Exception { run(m, NoSuchAlgorithmException.class, ""); m = getInstance(clazz, STRING, STRING); - run(m, NoSuchAlgorithmException.class, null, "SUN"); - run(m, NoSuchAlgorithmException.class, "", "SUN"); + run(m, NoSuchAlgorithmException.class, null, providerName); + run(m, NoSuchAlgorithmException.class, "", providerName); run(m, IllegalArgumentException.class, "FOO", null); run(m, IllegalArgumentException.class, "FOO", ""); m = getInstance(clazz, STRING, PROVIDER); - run(m, NoSuchAlgorithmException.class, null, SUN); - run(m, NoSuchAlgorithmException.class, "", SUN); + run(m, NoSuchAlgorithmException.class, null, provider); + run(m, NoSuchAlgorithmException.class, "", provider); run(m, IllegalArgumentException.class, "FOO", null); } @@ -329,15 +330,15 @@ private static void testConfiguration() throws Exception { run(m, NoSuchAlgorithmException.class, "", cp); m = getInstance(clazz, STRING, Configuration.Parameters.class, STRING); - run(m, NullPointerException.class, null, cp, "SUN"); - run(m, NoSuchAlgorithmException.class, "", cp, "SUN"); + run(m, NullPointerException.class, null, cp, providerName); + run(m, NoSuchAlgorithmException.class, "", cp, providerName); run(m, IllegalArgumentException.class, "FOO", cp, null); run(m, IllegalArgumentException.class, "FOO", cp, ""); m = getInstance(clazz, STRING, Configuration.Parameters.class, PROVIDER); - run(m, NullPointerException.class, null, cp, SUN); - run(m, NoSuchAlgorithmException.class, "", cp, SUN); + run(m, NullPointerException.class, null, cp, provider); + run(m, NoSuchAlgorithmException.class, "", cp, provider); run(m, IllegalArgumentException.class, "FOO", cp, null); } @@ -352,14 +353,14 @@ private static void testExemptionMechanism() throws Exception { run(m, NoSuchAlgorithmException.class, ""); m = getInstance(clazz, STRING, STRING); - run(m, NullPointerException.class, null, "SUN"); - run(m, NoSuchAlgorithmException.class, "", "SUN"); + run(m, NullPointerException.class, null, providerName); + run(m, NoSuchAlgorithmException.class, "", providerName); run(m, IllegalArgumentException.class, "FOO", null); run(m, IllegalArgumentException.class, "FOO", ""); m = getInstance(clazz, STRING, PROVIDER); - run(m, NullPointerException.class, null, SUN); - run(m, NoSuchAlgorithmException.class, "", SUN); + run(m, NullPointerException.class, null, provider); + run(m, NoSuchAlgorithmException.class, "", provider); run(m, IllegalArgumentException.class, "FOO", null); } @@ -374,14 +375,14 @@ private static void testKeyAgreement() throws Exception { run(m, NoSuchAlgorithmException.class, ""); m = getInstance(clazz, STRING, STRING); - run(m, NullPointerException.class, null, "SUN"); - run(m, NoSuchAlgorithmException.class, "", "SUN"); + run(m, NullPointerException.class, null, providerName); + run(m, NoSuchAlgorithmException.class, "", providerName); run(m, IllegalArgumentException.class, "FOO", null); run(m, IllegalArgumentException.class, "FOO", ""); m = getInstance(clazz, STRING, PROVIDER); - run(m, NullPointerException.class, null, SUN); - run(m, NoSuchAlgorithmException.class, "", SUN); + run(m, NullPointerException.class, null, provider); + run(m, NoSuchAlgorithmException.class, "", provider); run(m, IllegalArgumentException.class, "FOO", null); } @@ -396,14 +397,14 @@ private static void testKeyFactory() throws Exception { run(m, NoSuchAlgorithmException.class, ""); m = getInstance(clazz, STRING, STRING); - run(m, NullPointerException.class, null, "SUN"); - run(m, NoSuchAlgorithmException.class, "", "SUN"); + run(m, NullPointerException.class, null, providerName); + run(m, NoSuchAlgorithmException.class, "", providerName); run(m, IllegalArgumentException.class, "FOO", null); run(m, IllegalArgumentException.class, "FOO", ""); m = getInstance(clazz, STRING, PROVIDER); - run(m, NullPointerException.class, null, SUN); - run(m, NoSuchAlgorithmException.class, "", SUN); + run(m, NullPointerException.class, null, provider); + run(m, NoSuchAlgorithmException.class, "", provider); run(m, IllegalArgumentException.class, "FOO", null); } @@ -418,14 +419,14 @@ private static void testKeyGenerator() throws Exception { run(m, NoSuchAlgorithmException.class, ""); m = getInstance(clazz, STRING, STRING); - run(m, NullPointerException.class, null, "SUN"); - run(m, NoSuchAlgorithmException.class, "", "SUN"); + run(m, NullPointerException.class, null, providerName); + run(m, NoSuchAlgorithmException.class, "", providerName); run(m, IllegalArgumentException.class, "FOO", null); run(m, IllegalArgumentException.class, "FOO", ""); m = getInstance(clazz, STRING, PROVIDER); - run(m, NullPointerException.class, null, SUN); - run(m, NoSuchAlgorithmException.class, "", SUN); + run(m, NullPointerException.class, null, provider); + run(m, NoSuchAlgorithmException.class, "", provider); run(m, IllegalArgumentException.class, "FOO", null); } @@ -440,14 +441,14 @@ private static void testKeyManagerFactory() throws Exception { run(m, NoSuchAlgorithmException.class, ""); m = getInstance(clazz, STRING, STRING); - run(m, NullPointerException.class, null, "SUN"); - run(m, NoSuchAlgorithmException.class, "", "SUN"); + run(m, NullPointerException.class, null, providerName); + run(m, NoSuchAlgorithmException.class, "", providerName); run(m, IllegalArgumentException.class, "FOO", null); run(m, IllegalArgumentException.class, "FOO", ""); m = getInstance(clazz, STRING, PROVIDER); - run(m, NullPointerException.class, null, SUN); - run(m, NoSuchAlgorithmException.class, "", SUN); + run(m, NullPointerException.class, null, provider); + run(m, NoSuchAlgorithmException.class, "", provider); run(m, IllegalArgumentException.class, "FOO", null); } @@ -462,14 +463,14 @@ private static void testKeyPairGenerator() throws Exception { run(m, NoSuchAlgorithmException.class, ""); m = getInstance(clazz, STRING, STRING); - run(m, NullPointerException.class, null, "SUN"); - run(m, NoSuchAlgorithmException.class, "", "SUN"); + run(m, NullPointerException.class, null, providerName); + run(m, NoSuchAlgorithmException.class, "", providerName); run(m, IllegalArgumentException.class, "FOO", null); run(m, IllegalArgumentException.class, "FOO", ""); m = getInstance(clazz, STRING, PROVIDER); - run(m, NullPointerException.class, null, SUN); - run(m, NoSuchAlgorithmException.class, "", SUN); + run(m, NullPointerException.class, null, provider); + run(m, NoSuchAlgorithmException.class, "", provider); run(m, IllegalArgumentException.class, "FOO", null); } @@ -488,14 +489,14 @@ private static void testKeyStore() throws Exception { run(m, KeyStoreException.class, ""); m = getInstance(clazz, STRING, STRING); - run(m, NullPointerException.class, null, "SUN"); - run(m, KeyStoreException.class, "", "SUN"); + run(m, NullPointerException.class, null, providerName); + run(m, KeyStoreException.class, "", providerName); run(m, IllegalArgumentException.class, "FOO", null); run(m, IllegalArgumentException.class, "FOO", ""); m = getInstance(clazz, STRING, PROVIDER); - run(m, NullPointerException.class, null, SUN); - run(m, KeyStoreException.class, "", SUN); + run(m, NullPointerException.class, null, provider); + run(m, KeyStoreException.class, "", provider); run(m, IllegalArgumentException.class, "FOO", null); } @@ -510,14 +511,14 @@ private static void testMac() throws Exception { run(m, NoSuchAlgorithmException.class, ""); m = getInstance(clazz, STRING, STRING); - run(m, NullPointerException.class, null, "SUN"); - run(m, NoSuchAlgorithmException.class, "", "SUN"); + run(m, NullPointerException.class, null, providerName); + run(m, NoSuchAlgorithmException.class, "", providerName); run(m, IllegalArgumentException.class, "FOO", null); run(m, IllegalArgumentException.class, "FOO", ""); m = getInstance(clazz, STRING, PROVIDER); - run(m, NullPointerException.class, null, SUN); - run(m, NoSuchAlgorithmException.class, "", SUN); + run(m, NullPointerException.class, null, provider); + run(m, NoSuchAlgorithmException.class, "", provider); run(m, IllegalArgumentException.class, "FOO", null); } @@ -532,14 +533,14 @@ private static void testMessageDigest() throws Exception { run(m, NoSuchAlgorithmException.class, ""); m = getInstance(clazz, STRING, STRING); - run(m, NullPointerException.class, null, "SUN"); - run(m, NoSuchAlgorithmException.class, "", "SUN"); + run(m, NullPointerException.class, null, providerName); + run(m, NoSuchAlgorithmException.class, "", providerName); run(m, IllegalArgumentException.class, "FOO", null); run(m, IllegalArgumentException.class, "FOO", ""); m = getInstance(clazz, STRING, PROVIDER); - run(m, NullPointerException.class, null, SUN); - run(m, NoSuchAlgorithmException.class, "", SUN); + run(m, NullPointerException.class, null, provider); + run(m, NoSuchAlgorithmException.class, "", provider); run(m, IllegalArgumentException.class, "FOO", null); } @@ -556,14 +557,14 @@ private static void testPolicy() throws Exception { run(m, NoSuchAlgorithmException.class, "", pp); m = getInstance(clazz, STRING, Policy.Parameters.class, STRING); - run(m, NullPointerException.class, null, pp, "SUN"); - run(m, NoSuchAlgorithmException.class, "", pp, "SUN"); + run(m, NullPointerException.class, null, pp, providerName); + run(m, NoSuchAlgorithmException.class, "", pp, providerName); run(m, IllegalArgumentException.class, "FOO", pp, null); run(m, IllegalArgumentException.class, "FOO", pp, ""); m = getInstance(clazz, STRING, Policy.Parameters.class, PROVIDER); - run(m, NullPointerException.class, null, pp, SUN); - run(m, NoSuchAlgorithmException.class, "", pp, SUN); + run(m, NullPointerException.class, null, pp, provider); + run(m, NoSuchAlgorithmException.class, "", pp, provider); run(m, IllegalArgumentException.class, "FOO", pp, null); } @@ -578,14 +579,14 @@ private static void testSSLContext() throws Exception { run(m, NoSuchAlgorithmException.class, ""); m = getInstance(clazz, STRING, STRING); - run(m, NullPointerException.class, null, "SUN"); - run(m, NoSuchAlgorithmException.class, "", "SUN"); + run(m, NullPointerException.class, null, providerName); + run(m, NoSuchAlgorithmException.class, "", providerName); run(m, IllegalArgumentException.class, "FOO", null); run(m, IllegalArgumentException.class, "FOO", ""); m = getInstance(clazz, STRING, PROVIDER); - run(m, NullPointerException.class, null, SUN); - run(m, NoSuchAlgorithmException.class, "", SUN); + run(m, NullPointerException.class, null, provider); + run(m, NoSuchAlgorithmException.class, "", provider); run(m, IllegalArgumentException.class, "FOO", null); } @@ -600,14 +601,14 @@ private static void testSecretKeyFactory() throws Exception { run(m, NoSuchAlgorithmException.class, ""); m = getInstance(clazz, STRING, STRING); - run(m, NullPointerException.class, null, "SUN"); - run(m, NoSuchAlgorithmException.class, "", "SUN"); + run(m, NullPointerException.class, null, providerName); + run(m, NoSuchAlgorithmException.class, "", providerName); run(m, IllegalArgumentException.class, "FOO", null); run(m, IllegalArgumentException.class, "FOO", ""); m = getInstance(clazz, STRING, PROVIDER); - run(m, NullPointerException.class, null, SUN); - run(m, NoSuchAlgorithmException.class, "", SUN); + run(m, NullPointerException.class, null, provider); + run(m, NoSuchAlgorithmException.class, "", provider); run(m, IllegalArgumentException.class, "FOO", null); } @@ -624,14 +625,14 @@ private static void testSecureRandom() throws Exception { run(m, NoSuchAlgorithmException.class, ""); m = getInstance(clazz, STRING, STRING); - run(m, NullPointerException.class, null, "SUN"); - run(m, NoSuchAlgorithmException.class, "", "SUN"); + run(m, NullPointerException.class, null, providerName); + run(m, NoSuchAlgorithmException.class, "", providerName); run(m, IllegalArgumentException.class, "FOO", null); run(m, IllegalArgumentException.class, "FOO", ""); m = getInstance(clazz, STRING, PROVIDER); - run(m, NullPointerException.class, null, SUN); - run(m, NoSuchAlgorithmException.class, "", SUN); + run(m, NullPointerException.class, null, provider); + run(m, NoSuchAlgorithmException.class, "", provider); run(m, IllegalArgumentException.class, "FOO", null); m = getInstance(clazz, STRING, SecureRandomParameters.class); @@ -639,14 +640,14 @@ private static void testSecureRandom() throws Exception { run(m, NoSuchAlgorithmException.class, "", srp); m = getInstance(clazz, STRING, SecureRandomParameters.class, STRING); - run(m, NullPointerException.class, null, srp, "SUN"); - run(m, NoSuchAlgorithmException.class, "", srp, "SUN"); + run(m, NullPointerException.class, null, srp, providerName); + run(m, NoSuchAlgorithmException.class, "", srp, providerName); run(m, IllegalArgumentException.class, "FOO", srp, null); run(m, IllegalArgumentException.class, "FOO", srp, ""); m = getInstance(clazz, STRING, SecureRandomParameters.class, PROVIDER); - run(m, NullPointerException.class, null, srp, SUN); - run(m, NoSuchAlgorithmException.class, "", srp, SUN); + run(m, NullPointerException.class, null, srp, provider); + run(m, NoSuchAlgorithmException.class, "", srp, provider); run(m, IllegalArgumentException.class, "FOO", srp, null); } @@ -661,14 +662,14 @@ private static void testSignature() throws Exception { run(m, NoSuchAlgorithmException.class, ""); m = getInstance(clazz, STRING, STRING); - run(m, NullPointerException.class, null, "SUN"); - run(m, NoSuchAlgorithmException.class, "", "SUN"); + run(m, NullPointerException.class, null, providerName); + run(m, NoSuchAlgorithmException.class, "", providerName); run(m, IllegalArgumentException.class, "FOO", null); run(m, IllegalArgumentException.class, "FOO", ""); m = getInstance(clazz, STRING, PROVIDER); - run(m, NullPointerException.class, null, SUN); - run(m, NoSuchAlgorithmException.class, "", SUN); + run(m, NullPointerException.class, null, provider); + run(m, NoSuchAlgorithmException.class, "", provider); run(m, IllegalArgumentException.class, "FOO", null); } @@ -683,14 +684,14 @@ private static void testTrustManagerFactory() throws Exception { run(m, NoSuchAlgorithmException.class, ""); m = getInstance(clazz, STRING, STRING); - run(m, NullPointerException.class, null, "SUN"); - run(m, NoSuchAlgorithmException.class, "", "SUN"); + run(m, NullPointerException.class, null, providerName); + run(m, NoSuchAlgorithmException.class, "", providerName); run(m, IllegalArgumentException.class, "FOO", null); run(m, IllegalArgumentException.class, "FOO", ""); m = getInstance(clazz, STRING, PROVIDER); - run(m, NullPointerException.class, null, SUN); - run(m, NoSuchAlgorithmException.class, "", SUN); + run(m, NullPointerException.class, null, provider); + run(m, NoSuchAlgorithmException.class, "", provider); run(m, IllegalArgumentException.class, "FOO", null); } } diff --git a/test/jdk/javax/crypto/Cipher/ByteBuffers.java b/test/jdk/javax/crypto/Cipher/ByteBuffers.java index 233e62fb83a..141f1c10781 100644 --- a/test/jdk/javax/crypto/Cipher/ByteBuffers.java +++ b/test/jdk/javax/crypto/Cipher/ByteBuffers.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,7 +40,8 @@ public class ByteBuffers { public static void main(String[] args) throws Exception { - Provider p = Security.getProvider("SunJCE"); + Provider p = Security.getProvider( + System.getProperty("test.provider.name", "SunJCE")); Random random = new Random(); int n = 10 * 1024; byte[] t = new byte[n]; diff --git a/test/jdk/javax/crypto/Cipher/CipherInputStreamExceptions.java b/test/jdk/javax/crypto/Cipher/CipherInputStreamExceptions.java index 15cacec707f..8ffbb6f6a26 100644 --- a/test/jdk/javax/crypto/Cipher/CipherInputStreamExceptions.java +++ b/test/jdk/javax/crypto/Cipher/CipherInputStreamExceptions.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -357,10 +357,12 @@ static byte[] encryptedText(String mode, int length) throws Exception{ static byte[] encryptedText(String mode, byte[] pt) throws Exception{ Cipher c; if (mode.compareTo("GCM") == 0) { - c = Cipher.getInstance("AES/GCM/NoPadding", "SunJCE"); + c = Cipher.getInstance("AES/GCM/NoPadding", + System.getProperty("test.provider.name", "SunJCE")); c.init(Cipher.ENCRYPT_MODE, key, gcmspec); } else if (mode.compareTo("CBC") == 0) { - c = Cipher.getInstance("AES/CBC/PKCS5Padding", "SunJCE"); + c = Cipher.getInstance("AES/CBC/PKCS5Padding", + System.getProperty("test.provider.name", "SunJCE")); c.init(Cipher.ENCRYPT_MODE, key, iv); } else { return null; @@ -380,10 +382,12 @@ static CipherInputStream getStream(String mode, byte[] ct, int length) Cipher c; if (mode.compareTo("GCM") == 0) { - c = Cipher.getInstance("AES/GCM/NoPadding", "SunJCE"); + c = Cipher.getInstance("AES/GCM/NoPadding", + System.getProperty("test.provider.name", "SunJCE")); c.init(Cipher.DECRYPT_MODE, key, gcmspec); } else if (mode.compareTo("CBC") == 0) { - c = Cipher.getInstance("AES/CBC/PKCS5Padding", "SunJCE"); + c = Cipher.getInstance("AES/CBC/PKCS5Padding", + System.getProperty("test.provider.name", "SunJCE")); c.init(Cipher.DECRYPT_MODE, key, iv); } else { return null; diff --git a/test/jdk/javax/crypto/Cipher/GetMaxAllowed.java b/test/jdk/javax/crypto/Cipher/GetMaxAllowed.java index 7ef6f439aac..ee0b9c487a6 100644 --- a/test/jdk/javax/crypto/Cipher/GetMaxAllowed.java +++ b/test/jdk/javax/crypto/Cipher/GetMaxAllowed.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -96,7 +96,8 @@ public static void main(String[] args) throws Exception { // decide if the installed jurisdiction policy file is the // unlimited version boolean isUnlimited = true; - Cipher c = Cipher.getInstance("AES", "SunJCE"); + Cipher c = Cipher.getInstance("AES", + System.getProperty("test.provider.name", "SunJCE")); try { c.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(new byte[24], "AES")); } catch (InvalidKeyException ike) { diff --git a/test/jdk/javax/crypto/Cipher/TestCipherMode.java b/test/jdk/javax/crypto/Cipher/TestCipherMode.java index 19e854bca34..83ea6340871 100644 --- a/test/jdk/javax/crypto/Cipher/TestCipherMode.java +++ b/test/jdk/javax/crypto/Cipher/TestCipherMode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -103,7 +103,9 @@ private static Key getKey(String t, CipherMode m) public static void main(String[] argv) throws Exception { - TestCipherMode test = new TestCipherMode("SunJCE", TRANSFORMATIONS); + TestCipherMode test = new TestCipherMode( + System.getProperty("test.provider.name", "SunJCE"), + TRANSFORMATIONS); System.out.println("All Tests Passed"); } diff --git a/test/jdk/javax/crypto/Cipher/TestGetInstance.java b/test/jdk/javax/crypto/Cipher/TestGetInstance.java index 01d60f63a84..07ad131c736 100644 --- a/test/jdk/javax/crypto/Cipher/TestGetInstance.java +++ b/test/jdk/javax/crypto/Cipher/TestGetInstance.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,16 +42,19 @@ private static void same(Provider p1, Provider p2) throws Exception { } public static void main(String[] args) throws Exception { - Provider p = Security.getProvider("SunJCE"); + Provider p = Security.getProvider( + System.getProperty("test.provider.name", "SunJCE")); Cipher c; c = Cipher.getInstance("PBEWithMD5AndTripleDES"); same(p, c.getProvider()); - c = Cipher.getInstance("des", "SunJCE"); + c = Cipher.getInstance("des", + System.getProperty("test.provider.name", "SunJCE")); same(p, c.getProvider()); - c = Cipher.getInstance("des/cbc/pkcs5padding", "SunJCE"); + c = Cipher.getInstance("des/cbc/pkcs5padding", + System.getProperty("test.provider.name", "SunJCE")); same(p, c.getProvider()); c = Cipher.getInstance("des", p); @@ -66,7 +69,8 @@ public static void main(String[] args) throws Exception { System.out.println(e); } try { - c = Cipher.getInstance("DES/XYZ/PKCS5Padding", "SunJCE"); + c = Cipher.getInstance("DES/XYZ/PKCS5Padding", + System.getProperty("test.provider.name", "SunJCE")); throw new AssertionError(); } catch (NoSuchAlgorithmException e) { System.out.println(e); @@ -85,7 +89,8 @@ public static void main(String[] args) throws Exception { System.out.println(e); } try { - c = Cipher.getInstance("DES/CBC/XYZPadding", "SunJCE"); + c = Cipher.getInstance("DES/CBC/XYZPadding", + System.getProperty("test.provider.name", "SunJCE")); throw new AssertionError(); } catch (NoSuchPaddingException e) { System.out.println(e); @@ -104,7 +109,8 @@ public static void main(String[] args) throws Exception { System.out.println(e); } try { - c = Cipher.getInstance("foo", "SunJCE"); + c = Cipher.getInstance("foo", + System.getProperty("test.provider.name", "SunJCE")); throw new AssertionError(); } catch (NoSuchAlgorithmException e) { System.out.println(e); @@ -117,13 +123,15 @@ public static void main(String[] args) throws Exception { } try { - c = Cipher.getInstance("foo", "SUN"); + c = Cipher.getInstance("foo", + System.getProperty("test.provider.name", "SUN")); throw new AssertionError(); } catch (NoSuchAlgorithmException e) { System.out.println(e); } try { - c = Cipher.getInstance("foo", Security.getProvider("SUN")); + c = Cipher.getInstance("foo", Security.getProvider( + System.getProperty("test.provider.name", "SUN"))); throw new AssertionError(); } catch (NoSuchAlgorithmException e) { System.out.println(e); diff --git a/test/jdk/javax/crypto/CipherSpi/DirectBBRemaining.java b/test/jdk/javax/crypto/CipherSpi/DirectBBRemaining.java index 9e03c908660..5a383ded6dc 100644 --- a/test/jdk/javax/crypto/CipherSpi/DirectBBRemaining.java +++ b/test/jdk/javax/crypto/CipherSpi/DirectBBRemaining.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -57,7 +57,8 @@ public static void main(String args[]) throws Exception { random.nextBytes(keyBytes); SecretKey key = new SecretKeySpec(keyBytes, "DES"); - Cipher cipher = Cipher.getInstance("DES/CBC/PKCS5Padding", "SunJCE"); + Cipher cipher = Cipher.getInstance("DES/CBC/PKCS5Padding", + System.getProperty("test.provider.name", "SunJCE")); cipher.init(Cipher.ENCRYPT_MODE, key); /* diff --git a/test/jdk/javax/crypto/CryptoPermission/AllPermCheck.java b/test/jdk/javax/crypto/CryptoPermission/AllPermCheck.java index d7a1ad40e39..ea0ae4ab925 100644 --- a/test/jdk/javax/crypto/CryptoPermission/AllPermCheck.java +++ b/test/jdk/javax/crypto/CryptoPermission/AllPermCheck.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -84,7 +84,7 @@ public static void runTest(Cipher c, Key key) throws Exception { } public static void main(String[] args) throws Exception { - Provider p = Security.getProvider("SunJCE"); + Provider p = Security.getProvider(System.getProperty("test.provider.name", "SunJCE")); System.out.println("Testing provider " + p.getName() + "..."); if (Cipher.getMaxAllowedKeyLength("DES") == Integer.MAX_VALUE) { // skip this test for unlimited jurisdiction policy files diff --git a/test/jdk/javax/crypto/CryptoPermission/LowercasePermCheck.java b/test/jdk/javax/crypto/CryptoPermission/LowercasePermCheck.java index c358cb10844..a8eca5f6830 100644 --- a/test/jdk/javax/crypto/CryptoPermission/LowercasePermCheck.java +++ b/test/jdk/javax/crypto/CryptoPermission/LowercasePermCheck.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -46,7 +46,7 @@ public class LowercasePermCheck { }; public static void main(String[] args) throws Exception { - Provider p = Security.getProvider("SunJCE"); + Provider p = Security.getProvider(System.getProperty("test.provider.name", "SunJCE")); System.out.println("Testing provider " + p.getName() + "..."); if (Cipher.getMaxAllowedKeyLength("DES") == Integer.MAX_VALUE) { // skip this test for unlimited jurisdiction policy files diff --git a/test/jdk/javax/crypto/CryptoPermission/RSANoLimit.java b/test/jdk/javax/crypto/CryptoPermission/RSANoLimit.java index 4f54ff8ce3e..54ba18b98e1 100644 --- a/test/jdk/javax/crypto/CryptoPermission/RSANoLimit.java +++ b/test/jdk/javax/crypto/CryptoPermission/RSANoLimit.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -135,7 +135,7 @@ public class RSANoLimit { }; public static void main(String[] args) throws Exception { boolean result = true; - Provider p = Security.getProvider("SunJCE"); + Provider p = Security.getProvider(System.getProperty("test.provider.name", "SunJCE")); System.out.println("Testing provider " + p.getName() + "..."); // Test#1: make sure Cipher.getMaxAllowedKeyLength returns the // correct value diff --git a/test/jdk/javax/crypto/EncryptedPrivateKeyInfo/GetAlgName.java b/test/jdk/javax/crypto/EncryptedPrivateKeyInfo/GetAlgName.java index 33b624e4a28..3b89257323b 100644 --- a/test/jdk/javax/crypto/EncryptedPrivateKeyInfo/GetAlgName.java +++ b/test/jdk/javax/crypto/EncryptedPrivateKeyInfo/GetAlgName.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -47,9 +47,11 @@ public static void main(String[] argv) throws Exception { String algo = ALGOS[i]; // generate AlgorithmParameters object SecretKeyFactory skf = - SecretKeyFactory.getInstance(algo, "SunJCE"); + SecretKeyFactory.getInstance(algo, + System.getProperty("test.provider.name", "SunJCE")); SecretKey key = skf.generateSecret(ks); - Cipher c = Cipher.getInstance(algo, "SunJCE"); + Cipher c = Cipher.getInstance(algo, + System.getProperty("test.provider.name", "SunJCE")); c.init(Cipher.ENCRYPT_MODE, key); c.doFinal(BYTES); // force the parameter generation if not already diff --git a/test/jdk/javax/crypto/EncryptedPrivateKeyInfo/GetKeySpec.java b/test/jdk/javax/crypto/EncryptedPrivateKeyInfo/GetKeySpec.java index 314742cbf8d..6be4ef9bbdf 100644 --- a/test/jdk/javax/crypto/EncryptedPrivateKeyInfo/GetKeySpec.java +++ b/test/jdk/javax/crypto/EncryptedPrivateKeyInfo/GetKeySpec.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -46,7 +46,7 @@ public class GetKeySpec { PBEParameterSpec goodParamSpec = new PBEParameterSpec(new byte[8], 1024); GOOD_PARAMS = AlgorithmParameters.getInstance - (cipherAlg, "SunJCE"); + (cipherAlg, System.getProperty("test.provider.name", "SunJCE")); GOOD_PARAMS.init(goodParamSpec); } catch (Exception ex) { // should never happen @@ -102,7 +102,7 @@ public static void main(String[] argv) throws Exception { byte[] encryptedData = parse(encryptedPKCS8); boolean result = true; - Provider p = Security.getProvider("SunJCE"); + Provider p = Security.getProvider(System.getProperty("test.provider.name", "SunJCE")); // generate encrypted data and EncryptedPrivateKeyInfo object EncryptedPrivateKeyInfo epki = diff --git a/test/jdk/javax/crypto/EncryptedPrivateKeyInfo/GetKeySpecException.java b/test/jdk/javax/crypto/EncryptedPrivateKeyInfo/GetKeySpecException.java index e3ecb33d91c..7be1023aafe 100644 --- a/test/jdk/javax/crypto/EncryptedPrivateKeyInfo/GetKeySpecException.java +++ b/test/jdk/javax/crypto/EncryptedPrivateKeyInfo/GetKeySpecException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -50,7 +50,7 @@ public class GetKeySpecException { static { try { - sunjce = Security.getProvider("SunJCE"); + sunjce = Security.getProvider(System.getProperty("test.provider.name", "SunJCE")); PBEParameterSpec badParamSpec = new PBEParameterSpec(new byte[10], 10); BAD_PARAMS = AlgorithmParameters.getInstance(cipherAlg, sunjce); @@ -61,7 +61,7 @@ public class GetKeySpecException { GOOD_PARAMS.init(goodParamSpec); PBEKeySpec keySpec = new PBEKeySpec(passwd); SecretKeyFactory skf = - SecretKeyFactory.getInstance(cipherAlg, "SunJCE"); + SecretKeyFactory.getInstance(cipherAlg, System.getProperty("test.provider.name", "SunJCE")); cipherKey = skf.generateSecret(keySpec); } catch (Exception ex) { // should never happen @@ -164,7 +164,7 @@ public static void main0(String[] args) throws Exception { // TEST#3: getKeySpec(Key, String) System.out.println("Testing getKeySpec(Key, String)..."); try { - pkcs8Spec = epki.getKeySpec(null, "SunJCE"); + pkcs8Spec = epki.getKeySpec(null, System.getProperty("test.provider.name", "SunJCE")); throwException("Should throw NPE for null Key!"); } catch (NullPointerException npe) { System.out.println("Expected NPE thrown"); @@ -176,13 +176,13 @@ public static void main0(String[] args) throws Exception { System.out.println("Expected NPE thrown"); } try { - pkcs8Spec = epki.getKeySpec(INVALID_KEY, "SunJCE"); + pkcs8Spec = epki.getKeySpec(INVALID_KEY, System.getProperty("test.provider.name", "SunJCE")); throwException("Should throw IKE for invalid Key!"); } catch (InvalidKeyException ikse) { System.out.println("Expected IKE thrown"); } try { - pkcs8Spec = epkiBad.getKeySpec(cipherKey, "SunJCE"); + pkcs8Spec = epkiBad.getKeySpec(cipherKey, System.getProperty("test.provider.name", "SunJCE")); throwException("Should throw IKE for corrupted epki!"); } catch (InvalidKeyException ike) { System.out.println("Expected IKE thrown"); @@ -195,8 +195,9 @@ public static void main0(String[] args) throws Exception { System.out.println("Expected NSAE thrown"); } try { - Security.removeProvider("SunJCE"); - pkcs8Spec = epki.getKeySpec(cipherKey, "SunJCE"); + Security.removeProvider(System.getProperty("test.provider.name", "SunJCE")); + pkcs8Spec = epki.getKeySpec(cipherKey, + System.getProperty("test.provider.name", "SunJCE")); throwException("Should throw NSPE for unconfigured provider!"); } catch (NoSuchProviderException nspe) { System.out.println("Expected NSPE thrown"); diff --git a/test/jdk/javax/crypto/EncryptedPrivateKeyInfo/GetKeySpecException2.java b/test/jdk/javax/crypto/EncryptedPrivateKeyInfo/GetKeySpecException2.java index a3f983d0ea4..ef2d6acdef7 100644 --- a/test/jdk/javax/crypto/EncryptedPrivateKeyInfo/GetKeySpecException2.java +++ b/test/jdk/javax/crypto/EncryptedPrivateKeyInfo/GetKeySpecException2.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -54,7 +54,8 @@ public static void main(String[] argv) throws Exception { // TEST#1: getKeySpec(Cipher) with Cipher in an illegal state, // i.e. WRAP_MODE, UNWRAP_MODE. System.out.println("Testing getKeySpec(Cipher) with WRAP_MODE..."); - Cipher c = Cipher.getInstance(cipherAlg, "SunJCE"); + Cipher c = Cipher.getInstance(cipherAlg, + System.getProperty("test.provider.name", "SunJCE")); MyPBEKey key = new MyPBEKey(passwd); c.init(Cipher.WRAP_MODE, key); try { diff --git a/test/jdk/javax/crypto/EncryptedPrivateKeyInfo/GetKeySpecInvalidEncoding.java b/test/jdk/javax/crypto/EncryptedPrivateKeyInfo/GetKeySpecInvalidEncoding.java index fcc51332488..a6aa3c86222 100644 --- a/test/jdk/javax/crypto/EncryptedPrivateKeyInfo/GetKeySpecInvalidEncoding.java +++ b/test/jdk/javax/crypto/EncryptedPrivateKeyInfo/GetKeySpecInvalidEncoding.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -48,7 +48,7 @@ public class GetKeySpecInvalidEncoding { PBEParameterSpec goodParamSpec = new PBEParameterSpec(new byte[8], 6); GOOD_PARAMS = AlgorithmParameters.getInstance - (cipherAlg, "SunJCE"); + (cipherAlg, System.getProperty("test.provider.name", "SunJCE")); GOOD_PARAMS.init(goodParamSpec); } catch (Exception ex) { // should never happen @@ -101,7 +101,7 @@ public static void main(String[] argv) throws Exception { } byte[] encryptedData = parse(encryptedPKCS8); - Provider p = Security.getProvider("SunJCE"); + Provider p = Security.getProvider(System.getProperty("test.provider.name", "SunJCE")); // generate encrypted data and EncryptedPrivateKeyInfo object EncryptedPrivateKeyInfo epki = diff --git a/test/jdk/javax/crypto/KeyGenerator/TestGetInstance.java b/test/jdk/javax/crypto/KeyGenerator/TestGetInstance.java index 53c766874ed..3863fc98154 100644 --- a/test/jdk/javax/crypto/KeyGenerator/TestGetInstance.java +++ b/test/jdk/javax/crypto/KeyGenerator/TestGetInstance.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -43,13 +43,14 @@ private static void same(Object o1, Object o2) throws Exception { public static void main(String[] args) throws Exception { long start = System.currentTimeMillis(); - Provider p = Security.getProvider("SunJCE"); + Provider p = Security.getProvider(System.getProperty("test.provider.name", "SunJCE")); KeyGenerator kg; kg = KeyGenerator.getInstance("des"); System.out.println("Default: " + kg.getProvider().getName()); - kg = KeyGenerator.getInstance("des", "SunJCE"); + kg = KeyGenerator.getInstance("des", + System.getProperty("test.provider.name", "SunJCE")); same(p, kg.getProvider()); kg = KeyGenerator.getInstance("des", p); same(p, kg.getProvider()); @@ -61,7 +62,8 @@ public static void main(String[] args) throws Exception { System.out.println(e); } try { - kg = KeyGenerator.getInstance("foo", "SunJCE"); + kg = KeyGenerator.getInstance("foo", + System.getProperty("test.provider.name", "SunJCE")); throw new AssertionError(); } catch (NoSuchAlgorithmException e) { System.out.println(e); @@ -74,13 +76,15 @@ public static void main(String[] args) throws Exception { } try { - kg = KeyGenerator.getInstance("foo", "SUN"); + kg = KeyGenerator.getInstance("foo", + System.getProperty("test.provider.name", "SUN")); throw new AssertionError(); } catch (NoSuchAlgorithmException e) { System.out.println(e); } try { - kg = KeyGenerator.getInstance("foo", Security.getProvider("SUN")); + kg = KeyGenerator.getInstance("foo", + Security.getProvider(System.getProperty("test.provider.name", "SUN"))); throw new AssertionError(); } catch (NoSuchAlgorithmException e) { System.out.println(e); diff --git a/test/jdk/javax/crypto/KeyGenerator/TestKGParity.java b/test/jdk/javax/crypto/KeyGenerator/TestKGParity.java index efaefb06199..65e9b062de7 100644 --- a/test/jdk/javax/crypto/KeyGenerator/TestKGParity.java +++ b/test/jdk/javax/crypto/KeyGenerator/TestKGParity.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -54,8 +54,10 @@ private void run() throws Exception { Provider[] providers = Security.getProviders(); for (Provider p : providers) { String prvName = p.getName(); - if (prvName.startsWith("SunJCE") - || prvName.startsWith("SunPKCS11-")) { + if ((System.getProperty("test.provider.name") != null && + prvName.equals(System.getProperty("test.provider.name"))) || + (System.getProperty("test.provider.name") == null && + (prvName.startsWith("SunJCE") || prvName.startsWith("SunPKCS11-")))) { for (String algorithm : ALGORITHM_ARR) { if (!runTest(p, algorithm)) { throw new RuntimeException( diff --git a/test/jdk/javax/crypto/Mac/ByteBuffers.java b/test/jdk/javax/crypto/Mac/ByteBuffers.java index a00e5a43cd6..39efee91798 100644 --- a/test/jdk/javax/crypto/Mac/ByteBuffers.java +++ b/test/jdk/javax/crypto/Mac/ByteBuffers.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,7 +40,7 @@ public class ByteBuffers { public static void main(String[] args) throws Exception { - Provider p = Security.getProvider("SunJCE"); + Provider p = Security.getProvider(System.getProperty("test.provider.name", "SunJCE")); Random random = new Random(); int n = 10 * 1024; byte[] t = new byte[n]; diff --git a/test/jdk/javax/crypto/Mac/TestGetInstance.java b/test/jdk/javax/crypto/Mac/TestGetInstance.java index 30d055423db..0361bc0b8d0 100644 --- a/test/jdk/javax/crypto/Mac/TestGetInstance.java +++ b/test/jdk/javax/crypto/Mac/TestGetInstance.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -43,13 +43,13 @@ private static void same(Object o1, Object o2) throws Exception { public static void main(String[] args) throws Exception { long start = System.currentTimeMillis(); - Provider p = Security.getProvider("SunJCE"); + Provider p = Security.getProvider(System.getProperty("test.provider.name", "SunJCE")); Mac mac; mac = Mac.getInstance("hmacmd5"); System.out.println("Default: " + mac.getProvider().getName()); - mac = Mac.getInstance("hmacmd5", "SunJCE"); + mac = Mac.getInstance("hmacmd5", System.getProperty("test.provider.name", "SunJCE")); same(p, mac.getProvider()); mac = Mac.getInstance("hmacmd5", p); same(p, mac.getProvider()); @@ -61,7 +61,7 @@ public static void main(String[] args) throws Exception { System.out.println(e); } try { - mac = Mac.getInstance("foo", "SunJCE"); + mac = Mac.getInstance("foo", System.getProperty("test.provider.name", "SunJCE")); throw new AssertionError(); } catch (NoSuchAlgorithmException e) { System.out.println(e); @@ -74,13 +74,14 @@ public static void main(String[] args) throws Exception { } try { - mac = Mac.getInstance("foo", "SUN"); + mac = Mac.getInstance("foo", System.getProperty("test.provider.name", "SUN")); throw new AssertionError(); } catch (NoSuchAlgorithmException e) { System.out.println(e); } try { - mac = Mac.getInstance("foo", Security.getProvider("SUN")); + mac = Mac.getInstance("foo", Security.getProvider( + System.getProperty("test.provider.name", "SUN"))); throw new AssertionError(); } catch (NoSuchAlgorithmException e) { System.out.println(e); diff --git a/test/jdk/javax/crypto/SecretKeyFactory/SecKFTranslateTest.java b/test/jdk/javax/crypto/SecretKeyFactory/SecKFTranslateTest.java index f1b5c825798..398cf12a97e 100644 --- a/test/jdk/javax/crypto/SecretKeyFactory/SecKFTranslateTest.java +++ b/test/jdk/javax/crypto/SecretKeyFactory/SecKFTranslateTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -50,7 +50,8 @@ */ public class SecKFTranslateTest { - private static final String SUN_JCE = "SunJCE"; + private static final String PROVIDER_NAME = + System.getProperty("test.provider.name", "SunJCE"); public static void main(String[] args) throws Exception { @@ -77,10 +78,10 @@ private void runTest(Algorithm algo) throws NoSuchAlgorithmException, Random random = new Random(); // Initialization SecretKeyFactory skf = SecretKeyFactory.getInstance(algo.toString(), - SUN_JCE); + PROVIDER_NAME); random.nextBytes(plainText); - Cipher ci = Cipher.getInstance(algo.toString(), SUN_JCE); + Cipher ci = Cipher.getInstance(algo.toString(), PROVIDER_NAME); // Encryption ci.init(Cipher.ENCRYPT_MODE, key1, aps[0]); byte[] cipherText = new byte[ci.getOutputSize(plainText.length)]; diff --git a/test/jdk/javax/crypto/SecretKeyFactory/SecKeyFacSunJCEPrf.java b/test/jdk/javax/crypto/SecretKeyFactory/SecKeyFacSunJCEPrf.java index c5080ba33c5..8501f888e0f 100644 --- a/test/jdk/javax/crypto/SecretKeyFactory/SecKeyFacSunJCEPrf.java +++ b/test/jdk/javax/crypto/SecretKeyFactory/SecKeyFacSunJCEPrf.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,11 +42,11 @@ public class SecKeyFacSunJCEPrf { // One of the PBKDF2 HMAC-SHA1 test vectors from RFC 6070 - private static final byte[] SALT = "salt".getBytes(); + private static final byte[] SALT = "16-byte salt val".getBytes(); private static final char[] PASS = "password".toCharArray(); private static final int ITER = 4096; private static final byte[] EXP_OUT = - HexFormat.of().parseHex("4B007901B765489ABEAD49D926F721D065A429C1"); + HexFormat.of().parseHex("D2CACD3F1D44AF293C704F0B1005338D903C688C"); public static void main(String[] args) throws Exception { // Instantiate the Evil Provider and insert it in the @@ -56,7 +56,8 @@ public static void main(String[] args) throws Exception { Security.insertProviderAt(evilProv, 1); SecretKeyFactory pbkdf2 = - SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1", "SunJCE"); + SecretKeyFactory.getInstance("PBKDF2WithHmacSHA1", + System.getProperty("test.provider.name", "SunJCE")); PBEKeySpec pbks = new PBEKeySpec(PASS, SALT, ITER, 160); SecretKey secKey1 = pbkdf2.generateSecret(pbks); diff --git a/test/jdk/javax/crypto/SecretKeyFactory/evilprov/com/evilprovider/EvilHmacSHA1.java b/test/jdk/javax/crypto/SecretKeyFactory/evilprov/com/evilprovider/EvilHmacSHA1.java index 2617928ff16..06310056274 100644 --- a/test/jdk/javax/crypto/SecretKeyFactory/evilprov/com/evilprovider/EvilHmacSHA1.java +++ b/test/jdk/javax/crypto/SecretKeyFactory/evilprov/com/evilprovider/EvilHmacSHA1.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,8 @@ public final class EvilHmacSHA1 extends MacSpi { private final Mac internalMac; public EvilHmacSHA1() throws GeneralSecurityException { - internalMac = Mac.getInstance("HmacSHA1", "SunJCE"); + internalMac = Mac.getInstance("HmacSHA1", + System.getProperty("test.provider.name", "SunJCE")); } @Override diff --git a/test/jdk/javax/imageio/plugins/wbmp/WBMPStreamTruncateTest.java b/test/jdk/javax/imageio/plugins/wbmp/WBMPStreamTruncateTest.java index 36b8d4a72e0..0d38869634e 100644 --- a/test/jdk/javax/imageio/plugins/wbmp/WBMPStreamTruncateTest.java +++ b/test/jdk/javax/imageio/plugins/wbmp/WBMPStreamTruncateTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -46,9 +46,6 @@ public class WBMPStreamTruncateTest static final int height = 100; public static void main(String[] args) throws IOException { - String sep = System.getProperty("file.separator"); - String dir = System.getProperty("test.src", "."); - String filePath = dir+sep; BufferedImage srcImage = new BufferedImage(width, height, BufferedImage.TYPE_BYTE_BINARY); Graphics2D g = (Graphics2D) srcImage.getGraphics(); @@ -57,7 +54,7 @@ public static void main(String[] args) throws IOException g.dispose(); // create WBMP image File imageFile = File. - createTempFile("test", ".wbmp", new File(filePath)); + createTempFile("test", ".wbmp", new File("./")); imageFile.deleteOnExit(); ImageIO.write(srcImage, "wbmp", imageFile); BufferedImage testImg = diff --git a/test/jdk/javax/security/auth/Destroyable/KeyDestructionTest.java b/test/jdk/javax/security/auth/Destroyable/KeyDestructionTest.java index 71570807e4a..6a664cebf7e 100644 --- a/test/jdk/javax/security/auth/Destroyable/KeyDestructionTest.java +++ b/test/jdk/javax/security/auth/Destroyable/KeyDestructionTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,6 +24,7 @@ /* * @test * @bug 6263419 + * @library /test/lib * @summary No way to clean the memory for a java.security.Key */ @@ -32,10 +33,12 @@ import javax.crypto.*; import javax.security.auth.Destroyable; import javax.security.auth.DestroyFailedException; +import jdk.test.lib.security.SecurityUtils; public class KeyDestructionTest { public static void main(String[] args) throws Exception { - KeyPair keypair = generateKeyPair("RSA", 1024); + String kpgAlgorithm = "RSA"; + KeyPair keypair = generateKeyPair(kpgAlgorithm, SecurityUtils.getTestKeySize(kpgAlgorithm)); // Check keys that support and have implemented key destruction testKeyDestruction(new MyDestroyableSecretKey()); diff --git a/test/jdk/javax/security/auth/login/Configuration/GetInstance.java b/test/jdk/javax/security/auth/login/Configuration/GetInstance.java index 4be056bd26c..41820c90743 100644 --- a/test/jdk/javax/security/auth/login/Configuration/GetInstance.java +++ b/test/jdk/javax/security/auth/login/Configuration/GetInstance.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -84,12 +84,14 @@ private int testDefault(int testnum) throws Exception { private int testStringProvider(int testnum) throws Exception { // get an instance of JavaLoginConfig from SUN - Configuration c = Configuration.getInstance(JAVA_CONFIG, null, "SUN"); + Configuration c = Configuration.getInstance(JAVA_CONFIG, null, + System.getProperty("test.provider.name", "SUN")); doTest(c, testnum++); // get an instance of JavaLoginConfig from SunRsaSign try { - c = Configuration.getInstance(JAVA_CONFIG, null, "SunRsaSign"); + c = Configuration.getInstance(JAVA_CONFIG, null, + System.getProperty("test.provider.name", "SunRsaSign")); throw new SecurityException("test " + testnum++ + " failed"); } catch (NoSuchAlgorithmException nsae) { // good @@ -112,14 +114,16 @@ private int testProvider(int testnum) throws Exception { // get an instance of JavaLoginConfig from SUN Configuration c = Configuration.getInstance(JAVA_CONFIG, null, - Security.getProvider("SUN")); + Security.getProvider( + System.getProperty("test.provider.name", "SUN"))); doTest(c, testnum++); // get an instance of JavaLoginConfig from SunRsaSign try { c = Configuration.getInstance(JAVA_CONFIG, null, - Security.getProvider("SunRsaSign")); + Security.getProvider( + System.getProperty("test.provider.name","SunRsaSign"))); throw new SecurityException("test " + testnum++ + " failed"); } catch (NoSuchAlgorithmException nsae) { // good @@ -186,7 +190,7 @@ private int testException(int testnum) throws Exception { try { Configuration c = Configuration.getInstance(JAVA_CONFIG, new BadParam(), - "SUN"); + System.getProperty("test.provider.name","SUN")); throw new SecurityException("test " + testnum++ + " failed"); } catch (IllegalArgumentException iae) { // good @@ -196,7 +200,7 @@ private int testException(int testnum) throws Exception { try { Configuration c = Configuration.getInstance(JAVA_CONFIG, new BadParam(), - Security.getProvider("SUN")); + Security.getProvider(System.getProperty("test.provider.name","SUN"))); throw new SecurityException("test " + testnum++ + " failed"); } catch (IllegalArgumentException iae) { // good @@ -285,7 +289,7 @@ private void doTest(Configuration c, int testnum) throws Exception { testnum = doCommon(c, testnum); // test getProvider - if ("SUN".equals(c.getProvider().getName())) { + if (System.getProperty("test.provider.name","SUN").equals(c.getProvider().getName())) { System.out.println("test " + testnum + " (getProvider) passed"); } else { throw new SecurityException("test " + testnum + @@ -325,7 +329,7 @@ private void doTestURI(Configuration c, } // test getProvider - if ("SUN".equals(c.getProvider().getName())) { + if (System.getProperty("test.provider.name","SUN").equals(c.getProvider().getName())) { System.out.println("test " + testnum + " (getProvider) passed"); } else { throw new SecurityException("test " + testnum + diff --git a/test/jdk/javax/security/auth/login/Configuration/GetInstanceSecurity.grantedPolicy b/test/jdk/javax/security/auth/login/Configuration/GetInstanceSecurity.grantedPolicy index bcb47b245a7..f92b9fa63ad 100644 --- a/test/jdk/javax/security/auth/login/Configuration/GetInstanceSecurity.grantedPolicy +++ b/test/jdk/javax/security/auth/login/Configuration/GetInstanceSecurity.grantedPolicy @@ -1,4 +1,5 @@ grant { + permission java.util.PropertyPermission "test.provider.name", "read"; permission java.util.PropertyPermission "test.src", "read"; permission java.io.FilePermission "${test.src}${/}*", "read"; diff --git a/test/jdk/javax/security/auth/login/Configuration/GetInstanceSecurity.java b/test/jdk/javax/security/auth/login/Configuration/GetInstanceSecurity.java index fc2bec08221..68417a34bd9 100644 --- a/test/jdk/javax/security/auth/login/Configuration/GetInstanceSecurity.java +++ b/test/jdk/javax/security/auth/login/Configuration/GetInstanceSecurity.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -51,7 +51,7 @@ public static void main(String[] args) throws Exception { try { Configuration c = Configuration.getInstance - (JAVA_CONFIG, null, "SUN"); + (JAVA_CONFIG, null, System.getProperty("test.provider.name","SUN")); throw new RuntimeException("did not catch security exception"); } catch (SecurityException se) { // good @@ -59,7 +59,8 @@ public static void main(String[] args) throws Exception { try { Configuration c = Configuration.getInstance - (JAVA_CONFIG, null, Security.getProvider("SUN")); + (JAVA_CONFIG, null, Security.getProvider( + System.getProperty("test.provider.name","SUN"))); throw new RuntimeException("did not catch security exception"); } catch (SecurityException se) { // good @@ -71,7 +72,8 @@ public static void main(String[] args) throws Exception { "GetInstanceSecurity.grantedPolicy"); URI uri = file.toURI(); URIParameter param = new URIParameter(uri); - Policy p = Policy.getInstance("JavaPolicy", param, "SUN"); + Policy p = Policy.getInstance("JavaPolicy", param, + System.getProperty("test.provider.name","SUN")); Policy.setPolicy(p); // retry operations @@ -88,7 +90,7 @@ public static void main(String[] args) throws Exception { try { Configuration c = Configuration.getInstance - (JAVA_CONFIG, uriParam, "SUN"); + (JAVA_CONFIG, uriParam, System.getProperty("test.provider.name","SUN")); // good } catch (SecurityException se) { throw new RuntimeException("unexpected SecurityException"); @@ -96,7 +98,8 @@ public static void main(String[] args) throws Exception { try { Configuration c = Configuration.getInstance - (JAVA_CONFIG, uriParam, Security.getProvider("SUN")); + (JAVA_CONFIG, uriParam, Security.getProvider( + System.getProperty("test.provider.name","SUN"))); // good } catch (SecurityException se) { throw new RuntimeException("unexpected SecurityException"); diff --git a/test/jdk/javax/security/auth/login/Configuration/GetInstanceSecurity.policy b/test/jdk/javax/security/auth/login/Configuration/GetInstanceSecurity.policy index 4c0f7acfc88..162168a3ffd 100644 --- a/test/jdk/javax/security/auth/login/Configuration/GetInstanceSecurity.policy +++ b/test/jdk/javax/security/auth/login/Configuration/GetInstanceSecurity.policy @@ -1,6 +1,6 @@ grant { - + permission java.util.PropertyPermission "test.provider.name", "read"; permission java.util.PropertyPermission "test.src", "read"; permission java.lang.RuntimePermission "accessClassInPackage.sun.net.www"; permission java.io.FilePermission diff --git a/test/jdk/javax/swing/JFileChooser/FileSystemView/WindowsDefaultIconSizeTest.java b/test/jdk/javax/swing/JFileChooser/FileSystemView/WindowsDefaultIconSizeTest.java index 081277ca2d4..dcdc7ca7b96 100644 --- a/test/jdk/javax/swing/JFileChooser/FileSystemView/WindowsDefaultIconSizeTest.java +++ b/test/jdk/javax/swing/JFileChooser/FileSystemView/WindowsDefaultIconSizeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,18 +44,16 @@ public static void main(String[] args) { } public void test() { - String sep = System.getProperty("file.separator"); - String dir = System.getProperty("test.src", "."); String filename = "test.not"; - File testFile = new File(dir + sep + filename); + File testFile = new File(filename); try { if (!testFile.exists()) { testFile.createNewFile(); testFile.deleteOnExit(); } FileSystemView fsv = FileSystemView.getFileSystemView(); - Icon icon = fsv.getSystemIcon(new File(dir + sep + filename)); + Icon icon = fsv.getSystemIcon(new File(filename)); if (icon instanceof ImageIcon) { Image image = ((ImageIcon) icon).getImage(); if (image instanceof MultiResolutionImage) { diff --git a/test/jdk/jdk/classfile/LDCTest.java b/test/jdk/jdk/classfile/LDCTest.java index 207d53e8820..63a08b50436 100644 --- a/test/jdk/jdk/classfile/LDCTest.java +++ b/test/jdk/jdk/classfile/LDCTest.java @@ -23,88 +23,145 @@ /* * @test + * @bug 8342458 + * @library /test/lib * @summary Testing ClassFile LDC instructions. * @run junit LDCTest */ -import java.lang.constant.ClassDesc; -import static java.lang.classfile.ClassFile.ACC_PUBLIC; -import static java.lang.classfile.ClassFile.ACC_STATIC; -import static java.lang.constant.ConstantDescs.*; -import java.lang.constant.MethodTypeDesc; - -import java.lang.classfile.*; +import java.lang.classfile.Attributes; +import java.lang.classfile.ClassFile; +import java.lang.classfile.Instruction; +import java.lang.classfile.MethodModel; +import java.lang.classfile.attribute.CodeAttribute; import java.lang.classfile.constantpool.ConstantPoolBuilder; +import java.lang.classfile.constantpool.LongEntry; import java.lang.classfile.constantpool.StringEntry; +import java.lang.classfile.instruction.ConstantInstruction; +import java.lang.constant.ClassDesc; +import java.lang.constant.DirectMethodHandleDesc; +import java.lang.constant.DynamicConstantDesc; +import java.lang.constant.MethodHandleDesc; +import java.lang.constant.MethodTypeDesc; import java.lang.reflect.AccessFlag; -import static org.junit.jupiter.api.Assertions.*; +import java.util.List; + +import jdk.test.lib.ByteCodeLoader; import org.junit.jupiter.api.Test; -import static helpers.TestConstants.MTD_VOID; + +import static java.lang.classfile.ClassFile.*; import static java.lang.classfile.Opcode.*; -import java.lang.classfile.instruction.ConstantInstruction; +import static java.lang.constant.ConstantDescs.*; +import static org.junit.jupiter.api.Assertions.*; class LDCTest { @Test - void testLDCisConvertedToLDCW() throws Exception { - var cc = ClassFile.of(); - byte[] bytes = cc.build(ClassDesc.of("MyClass"), cb -> { - cb.withFlags(AccessFlag.PUBLIC); - cb.withVersion(52, 0); - cb.withMethod("", MethodTypeDesc.of(CD_void), 0, mb -> mb - .withCode(codeb -> codeb.aload(0) - .invokespecial(CD_Object, "", MTD_VOID, false) - .return_() - ) - ) + void loadConstantGeneralTest() throws Exception { + var otherCp = ConstantPoolBuilder.of(); + var narrowString131 = otherCp.stringEntry("string131"); + assertTrue(narrowString131.index() <= 0xFF); + for (int i = 0; i < 0xFF; i++) { + var unused = otherCp.intEntry(i); + } + var wideString0 = otherCp.stringEntry("string0"); + assertTrue(wideString0.index() > 0xFF); - .withMethod("main", MethodTypeDesc.of(CD_void, CD_String.arrayType()), - ACC_PUBLIC | ACC_STATIC, - mb -> mb.withCode(c0 -> { - ConstantPoolBuilder cpb = cb.constantPool(); - for (int i = 0; i <= 256/2 + 2; i++) { // two entries per String - StringEntry s = cpb.stringEntry("string" + i); - } - c0.ldc("string0") - .ldc("string131") - .ldc("string50") - .loadConstant(-0.0f) - .loadConstant(-0.0d) - //non-LDC test cases - .loadConstant(0.0f) - .loadConstant(0.0d) - .return_(); - })); - }); + var cc = ClassFile.of(); + var cd = ClassDesc.of("MyClass"); + MethodTypeDesc bsmType = MethodTypeDesc.of(CD_double, CD_MethodHandles_Lookup, CD_String, CD_Class); + byte[] bytes = cc.build(cd, cb -> cb + .withFlags(AccessFlag.PUBLIC) + .withVersion(JAVA_11_VERSION, 0) // condy support required + .withMethodBody("bsm", bsmType, ACC_STATIC, cob -> cob + .dconst_1() + .dreturn()) + .withMethodBody("main", MethodTypeDesc.of(CD_void, CD_String.arrayType()), + ACC_PUBLIC | ACC_STATIC, c0 -> { + ConstantPoolBuilder cpb = cb.constantPool(); + LongEntry l42 = cpb.longEntry(42); + assertTrue(l42.index() <= 0xFF); + for (int i = 0; i <= 256 / 2 + 2; i++) { // two entries per String + StringEntry s = cpb.stringEntry("string" + i); + } + var wideCondy = cpb.constantDynamicEntry(DynamicConstantDesc.of(MethodHandleDesc.ofMethod( + DirectMethodHandleDesc.Kind.STATIC, cd, "bsm", bsmType))); + assertTrue(wideCondy.index() > 0xFF); + var s0 = cpb.stringEntry("string0"); + assertTrue(s0.index() <= 0xFF); + // use line number to match case numbers; pop ensures verification passes + c0.ldc("string0").pop() // regular ldc + .ldc(wideString0).pop() // adaption - narrowed + .with(ConstantInstruction.ofLoad(LDC, wideString0)).pop() // adaption + .with(ConstantInstruction.ofLoad(LDC_W, wideString0)).pop() // adaption - narrowed + .with(ConstantInstruction.ofLoad(LDC_W, s0)).pop() // explicit ldc_w - local + .ldc("string131").pop() // ldc_w + .ldc(narrowString131).pop() // adaption - widened + .with(ConstantInstruction.ofLoad(LDC, narrowString131)).pop() // adaption - widened + .with(ConstantInstruction.ofLoad(LDC_W, narrowString131)).pop() // adaption + .ldc("string50").pop() + .ldc(l42).pop2() // long cases + .loadConstant(l42.longValue()).pop2() + .loadConstant(Long.valueOf(l42.longValue())).pop2() + .loadConstant(-0.0f).pop() // floating cases + .loadConstant(-0.0d).pop2() + .loadConstant(0.0f).pop() // intrinsic cases + .loadConstant(0.0d).pop2() + .ldc(wideCondy).pop2() // no wrong "widening" of condy + .return_(); + })); - var model = cc.parse(bytes); - var code = model.elementStream() - .filter(e -> e instanceof MethodModel) - .map(e -> (MethodModel) e) - .filter(e -> e.methodName().stringValue().equals("main")) - .flatMap(MethodModel::elementStream) - .filter(e -> e instanceof CodeModel) - .map(e -> (CodeModel) e) + var cm = cc.parse(bytes); + var code = cm.elementStream() + .mapMulti((ce, sink) -> { + if (ce instanceof MethodModel mm && mm.methodName().equalsString("main")) { + sink.accept(mm.findAttribute(Attributes.code()).orElseThrow()); + } + }) .findFirst() .orElseThrow(); - var opcodes = code.elementList().stream() - .filter(e -> e instanceof Instruction) - .map(e -> (Instruction)e) - .toList(); + var instructions = code.elementList().stream() + .mapMulti((ce, sink) -> { + if (ce instanceof ConstantInstruction i) { + sink.accept(i); + } + }) + .toList(); - assertEquals(opcodes.size(), 8); - assertEquals(opcodes.get(0).opcode(), LDC); - assertEquals(opcodes.get(1).opcode(), LDC_W); - assertEquals(opcodes.get(2).opcode(), LDC); + assertIterableEquals(List.of( + LDC, // string0 + LDC, + LDC, + LDC, + LDC_W, + LDC_W, // string131 + LDC_W, + LDC_W, + LDC_W, + LDC, // string50 + LDC2_W, // long cases + LDC2_W, + LDC2_W, + LDC_W, // floating cases + LDC2_W, + FCONST_0, // intrinsic cases + DCONST_0, + LDC2_W // wide condy + ), instructions.stream().map(Instruction::opcode).toList()); + + int longCaseStart = 10; + for (int longCaseIndex = longCaseStart; longCaseIndex < longCaseStart + 3; longCaseIndex++) { + var message = "Case " + longCaseIndex; + assertEquals(42, (long) instructions.get(longCaseIndex).constantValue(), message); + } + + int floatingCaseStart = longCaseStart + 3; assertEquals( - Float.floatToRawIntBits((float)((ConstantInstruction)opcodes.get(3)).constantValue()), + Float.floatToRawIntBits((float) instructions.get(floatingCaseStart).constantValue()), Float.floatToRawIntBits(-0.0f)); assertEquals( - Double.doubleToRawLongBits((double)((ConstantInstruction)opcodes.get(4)).constantValue()), + Double.doubleToRawLongBits((double) instructions.get(floatingCaseStart + 1).constantValue()), Double.doubleToRawLongBits(-0.0d)); - assertEquals(opcodes.get(5).opcode(), FCONST_0); - assertEquals(opcodes.get(6).opcode(), DCONST_0); - assertEquals(opcodes.get(7).opcode(), RETURN); - } - // TODO test for explicit LDC_W? -} \ No newline at end of file + assertDoesNotThrow(() -> ByteCodeLoader.load("MyClass", bytes), "Invalid LDC bytecode generated"); + } +} diff --git a/test/jdk/jdk/dynalink/TypeConverterFactoryMemoryLeakTest.java b/test/jdk/jdk/dynalink/TypeConverterFactoryMemoryLeakTest.java index 7e907781e9d..4735bb4a08f 100644 --- a/test/jdk/jdk/dynalink/TypeConverterFactoryMemoryLeakTest.java +++ b/test/jdk/jdk/dynalink/TypeConverterFactoryMemoryLeakTest.java @@ -46,19 +46,11 @@ */ /* - * @test id=with_ZGC_Singlegen - * @requires vm.gc.ZSinglegen + * @test id=with_ZGC + * @requires vm.gc.Z * @bug 8198540 * @summary Test TypeConverterFactory is not leaking method handles (Z GC) - * @run main/othervm -XX:+UseZGC -XX:-ZGenerational TypeConverterFactoryMemoryLeakTest - */ - -/* - * @test id=with_ZGC_Generational - * @requires vm.gc.ZGenerational - * @bug 8198540 - * @summary Test TypeConverterFactory is not leaking method handles (Z GC) - * @run main/othervm -XX:+UseZGC -XX:+ZGenerational TypeConverterFactoryMemoryLeakTest + * @run main/othervm -XX:+UseZGC TypeConverterFactoryMemoryLeakTest */ /* diff --git a/test/jdk/jdk/dynalink/TypeConverterFactoryRetentionTests.java b/test/jdk/jdk/dynalink/TypeConverterFactoryRetentionTests.java index bdfd33eff48..8ad972d4502 100644 --- a/test/jdk/jdk/dynalink/TypeConverterFactoryRetentionTests.java +++ b/test/jdk/jdk/dynalink/TypeConverterFactoryRetentionTests.java @@ -46,19 +46,11 @@ */ /* - * @test id=with_ZGC_Singlegen - * @requires vm.gc.ZSinglegen + * @test id=with_ZGC + * @requires vm.gc.Z * @bug 8198540 * @summary Test TypeConverterFactory is not leaking class loaders (Z GC) - * @run main/othervm -XX:+UseZGC -XX:-ZGenerational TypeConverterFactoryRetentionTests - */ - -/* - * @test id=with_ZGC_Generational - * @requires vm.gc.ZGenerational - * @bug 8198540 - * @summary Test TypeConverterFactory is not leaking class loaders (Z GC) - * @run main/othervm -XX:+UseZGC -XX:+ZGenerational TypeConverterFactoryRetentionTests + * @run main/othervm -XX:+UseZGC TypeConverterFactoryRetentionTests */ /* diff --git a/test/jdk/jdk/incubator/vector/Byte128VectorTests.java b/test/jdk/jdk/incubator/vector/Byte128VectorTests.java index eda803b3f35..36a140c474a 100644 --- a/test/jdk/jdk/incubator/vector/Byte128VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Byte128VectorTests.java @@ -38,6 +38,7 @@ import jdk.incubator.vector.VectorMask; import jdk.incubator.vector.VectorOperators; import jdk.incubator.vector.Vector; +import jdk.incubator.vector.VectorMath; import jdk.incubator.vector.ByteVector; @@ -962,6 +963,33 @@ static byte bits(byte e) { }) ); + static final List> BYTE_SATURATING_GENERATORS = List.of( + withToString("byte[Byte.MIN_VALUE]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (byte)(Byte.MIN_VALUE)); + }), + withToString("byte[Byte.MAX_VALUE]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (byte)(Byte.MAX_VALUE)); + }), + withToString("byte[Byte.MAX_VALUE - 100]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (byte)(Byte.MAX_VALUE - 100)); + }), + withToString("byte[Byte.MIN_VALUE + 100]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (byte)(Byte.MIN_VALUE + 100)); + }), + withToString("byte[-i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (byte)(-i * 5)); + }), + withToString("byte[i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (byte)(i * 5)); + }) + ); + // Create combinations of pairs // @@@ Might be sensitive to order e.g. div by 0 static final List>> BYTE_GENERATOR_PAIRS = @@ -969,6 +997,11 @@ static byte bits(byte e) { flatMap(fa -> BYTE_GENERATORS.stream().skip(1).map(fb -> List.of(fa, fb))). collect(Collectors.toList()); + static final List>> BYTE_SATURATING_GENERATOR_PAIRS = + Stream.of(BYTE_GENERATORS.get(0)). + flatMap(fa -> BYTE_SATURATING_GENERATORS.stream().skip(1).map(fb -> List.of(fa, fb))). + collect(Collectors.toList()); + @DataProvider public Object[][] boolUnaryOpProvider() { return BOOL_ARRAY_GENERATORS.stream(). @@ -999,12 +1032,27 @@ public Object[][] byteBinaryOpProvider() { toArray(Object[][]::new); } + @DataProvider + public Object[][] byteSaturatingBinaryOpProvider() { + return BYTE_SATURATING_GENERATOR_PAIRS.stream().map(List::toArray). + toArray(Object[][]::new); + } + @DataProvider public Object[][] byteIndexedOpProvider() { return BYTE_GENERATOR_PAIRS.stream().map(List::toArray). toArray(Object[][]::new); } + @DataProvider + public Object[][] byteSaturatingBinaryOpMaskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> BYTE_SATURATING_GENERATOR_PAIRS.stream().map(lfa -> { + return Stream.concat(lfa.stream(), Stream.of(fm)).toArray(); + })). + toArray(Object[][]::new); + } + @DataProvider public Object[][] byteBinaryOpMaskProvider() { return BOOLEAN_MASK_GENERATORS.stream(). @@ -2939,6 +2987,252 @@ static void maxByte128VectorTests(IntFunction fa, IntFunction fb assertArraysEquals(r, a, b, Byte128VectorTests::max); } + static byte UMIN(byte a, byte b) { + return (byte)(VectorMath.minUnsigned(a, b)); + } + + @Test(dataProvider = "byteBinaryOpProvider") + static void UMINByte128VectorTests(IntFunction fa, IntFunction fb) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Byte128VectorTests::UMIN); + } + + @Test(dataProvider = "byteBinaryOpMaskProvider") + static void UMINByte128VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Byte128VectorTests::UMIN); + } + + static byte UMAX(byte a, byte b) { + return (byte)(VectorMath.maxUnsigned(a, b)); + } + + @Test(dataProvider = "byteBinaryOpProvider") + static void UMAXByte128VectorTests(IntFunction fa, IntFunction fb) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Byte128VectorTests::UMAX); + } + + @Test(dataProvider = "byteBinaryOpMaskProvider") + static void UMAXByte128VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Byte128VectorTests::UMAX); + } + + static byte SADD(byte a, byte b) { + return (byte)(VectorMath.addSaturating(a, b)); + } + + @Test(dataProvider = "byteSaturatingBinaryOpProvider") + static void SADDByte128VectorTests(IntFunction fa, IntFunction fb) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Byte128VectorTests::SADD); + } + + @Test(dataProvider = "byteSaturatingBinaryOpMaskProvider") + static void SADDByte128VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Byte128VectorTests::SADD); + } + + static byte SSUB(byte a, byte b) { + return (byte)(VectorMath.subSaturating(a, b)); + } + + @Test(dataProvider = "byteSaturatingBinaryOpProvider") + static void SSUBByte128VectorTests(IntFunction fa, IntFunction fb) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Byte128VectorTests::SSUB); + } + + @Test(dataProvider = "byteSaturatingBinaryOpMaskProvider") + static void SSUBByte128VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Byte128VectorTests::SSUB); + } + + static byte SUADD(byte a, byte b) { + return (byte)(VectorMath.addSaturatingUnsigned(a, b)); + } + + @Test(dataProvider = "byteSaturatingBinaryOpProvider") + static void SUADDByte128VectorTests(IntFunction fa, IntFunction fb) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Byte128VectorTests::SUADD); + } + + @Test(dataProvider = "byteSaturatingBinaryOpMaskProvider") + static void SUADDByte128VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Byte128VectorTests::SUADD); + } + + static byte SUSUB(byte a, byte b) { + return (byte)(VectorMath.subSaturatingUnsigned(a, b)); + } + + @Test(dataProvider = "byteSaturatingBinaryOpProvider") + static void SUSUBByte128VectorTests(IntFunction fa, IntFunction fb) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Byte128VectorTests::SUSUB); + } + + @Test(dataProvider = "byteSaturatingBinaryOpMaskProvider") + static void SUSUBByte128VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Byte128VectorTests::SUSUB); + } + @Test(dataProvider = "byteBinaryOpProvider") static void MINByte128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); @@ -4147,7 +4441,7 @@ static void GEByte128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) { + static void ULTByte128VectorTests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -4155,7 +4449,7 @@ static void UNSIGNED_LTByte128VectorTests(IntFunction fa, IntFunction mv = av.compare(VectorOperators.UNSIGNED_LT, bv); + VectorMask mv = av.compare(VectorOperators.ULT, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4166,7 +4460,7 @@ static void UNSIGNED_LTByte128VectorTests(IntFunction fa, IntFunction fa, IntFunction fb, + static void ULTByte128VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -4178,7 +4472,7 @@ static void UNSIGNED_LTByte128VectorTestsMasked(IntFunction fa, IntFunct for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ByteVector bv = ByteVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_LT, bv, vmask); + VectorMask mv = av.compare(VectorOperators.ULT, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4189,7 +4483,7 @@ static void UNSIGNED_LTByte128VectorTestsMasked(IntFunction fa, IntFunct } @Test(dataProvider = "byteCompareOpProvider") - static void UNSIGNED_GTByte128VectorTests(IntFunction fa, IntFunction fb) { + static void UGTByte128VectorTests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -4197,7 +4491,7 @@ static void UNSIGNED_GTByte128VectorTests(IntFunction fa, IntFunction mv = av.compare(VectorOperators.UNSIGNED_GT, bv); + VectorMask mv = av.compare(VectorOperators.UGT, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4208,7 +4502,7 @@ static void UNSIGNED_GTByte128VectorTests(IntFunction fa, IntFunction fa, IntFunction fb, + static void UGTByte128VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -4220,7 +4514,7 @@ static void UNSIGNED_GTByte128VectorTestsMasked(IntFunction fa, IntFunct for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ByteVector bv = ByteVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_GT, bv, vmask); + VectorMask mv = av.compare(VectorOperators.UGT, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4231,7 +4525,7 @@ static void UNSIGNED_GTByte128VectorTestsMasked(IntFunction fa, IntFunct } @Test(dataProvider = "byteCompareOpProvider") - static void UNSIGNED_LEByte128VectorTests(IntFunction fa, IntFunction fb) { + static void ULEByte128VectorTests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -4239,7 +4533,7 @@ static void UNSIGNED_LEByte128VectorTests(IntFunction fa, IntFunction mv = av.compare(VectorOperators.UNSIGNED_LE, bv); + VectorMask mv = av.compare(VectorOperators.ULE, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4250,7 +4544,7 @@ static void UNSIGNED_LEByte128VectorTests(IntFunction fa, IntFunction fa, IntFunction fb, + static void ULEByte128VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -4262,7 +4556,7 @@ static void UNSIGNED_LEByte128VectorTestsMasked(IntFunction fa, IntFunct for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ByteVector bv = ByteVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_LE, bv, vmask); + VectorMask mv = av.compare(VectorOperators.ULE, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4273,7 +4567,7 @@ static void UNSIGNED_LEByte128VectorTestsMasked(IntFunction fa, IntFunct } @Test(dataProvider = "byteCompareOpProvider") - static void UNSIGNED_GEByte128VectorTests(IntFunction fa, IntFunction fb) { + static void UGEByte128VectorTests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -4281,7 +4575,7 @@ static void UNSIGNED_GEByte128VectorTests(IntFunction fa, IntFunction mv = av.compare(VectorOperators.UNSIGNED_GE, bv); + VectorMask mv = av.compare(VectorOperators.UGE, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4292,7 +4586,7 @@ static void UNSIGNED_GEByte128VectorTests(IntFunction fa, IntFunction fa, IntFunction fb, + static void UGEByte128VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -4304,7 +4598,7 @@ static void UNSIGNED_GEByte128VectorTestsMasked(IntFunction fa, IntFunct for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ByteVector bv = ByteVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_GE, bv, vmask); + VectorMask mv = av.compare(VectorOperators.UGE, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { diff --git a/test/jdk/jdk/incubator/vector/Byte256VectorTests.java b/test/jdk/jdk/incubator/vector/Byte256VectorTests.java index 06cc13c0b12..0ad567b5ee4 100644 --- a/test/jdk/jdk/incubator/vector/Byte256VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Byte256VectorTests.java @@ -38,6 +38,7 @@ import jdk.incubator.vector.VectorMask; import jdk.incubator.vector.VectorOperators; import jdk.incubator.vector.Vector; +import jdk.incubator.vector.VectorMath; import jdk.incubator.vector.ByteVector; @@ -962,6 +963,33 @@ static byte bits(byte e) { }) ); + static final List> BYTE_SATURATING_GENERATORS = List.of( + withToString("byte[Byte.MIN_VALUE]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (byte)(Byte.MIN_VALUE)); + }), + withToString("byte[Byte.MAX_VALUE]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (byte)(Byte.MAX_VALUE)); + }), + withToString("byte[Byte.MAX_VALUE - 100]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (byte)(Byte.MAX_VALUE - 100)); + }), + withToString("byte[Byte.MIN_VALUE + 100]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (byte)(Byte.MIN_VALUE + 100)); + }), + withToString("byte[-i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (byte)(-i * 5)); + }), + withToString("byte[i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (byte)(i * 5)); + }) + ); + // Create combinations of pairs // @@@ Might be sensitive to order e.g. div by 0 static final List>> BYTE_GENERATOR_PAIRS = @@ -969,6 +997,11 @@ static byte bits(byte e) { flatMap(fa -> BYTE_GENERATORS.stream().skip(1).map(fb -> List.of(fa, fb))). collect(Collectors.toList()); + static final List>> BYTE_SATURATING_GENERATOR_PAIRS = + Stream.of(BYTE_GENERATORS.get(0)). + flatMap(fa -> BYTE_SATURATING_GENERATORS.stream().skip(1).map(fb -> List.of(fa, fb))). + collect(Collectors.toList()); + @DataProvider public Object[][] boolUnaryOpProvider() { return BOOL_ARRAY_GENERATORS.stream(). @@ -999,12 +1032,27 @@ public Object[][] byteBinaryOpProvider() { toArray(Object[][]::new); } + @DataProvider + public Object[][] byteSaturatingBinaryOpProvider() { + return BYTE_SATURATING_GENERATOR_PAIRS.stream().map(List::toArray). + toArray(Object[][]::new); + } + @DataProvider public Object[][] byteIndexedOpProvider() { return BYTE_GENERATOR_PAIRS.stream().map(List::toArray). toArray(Object[][]::new); } + @DataProvider + public Object[][] byteSaturatingBinaryOpMaskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> BYTE_SATURATING_GENERATOR_PAIRS.stream().map(lfa -> { + return Stream.concat(lfa.stream(), Stream.of(fm)).toArray(); + })). + toArray(Object[][]::new); + } + @DataProvider public Object[][] byteBinaryOpMaskProvider() { return BOOLEAN_MASK_GENERATORS.stream(). @@ -2939,6 +2987,252 @@ static void maxByte256VectorTests(IntFunction fa, IntFunction fb assertArraysEquals(r, a, b, Byte256VectorTests::max); } + static byte UMIN(byte a, byte b) { + return (byte)(VectorMath.minUnsigned(a, b)); + } + + @Test(dataProvider = "byteBinaryOpProvider") + static void UMINByte256VectorTests(IntFunction fa, IntFunction fb) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Byte256VectorTests::UMIN); + } + + @Test(dataProvider = "byteBinaryOpMaskProvider") + static void UMINByte256VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Byte256VectorTests::UMIN); + } + + static byte UMAX(byte a, byte b) { + return (byte)(VectorMath.maxUnsigned(a, b)); + } + + @Test(dataProvider = "byteBinaryOpProvider") + static void UMAXByte256VectorTests(IntFunction fa, IntFunction fb) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Byte256VectorTests::UMAX); + } + + @Test(dataProvider = "byteBinaryOpMaskProvider") + static void UMAXByte256VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Byte256VectorTests::UMAX); + } + + static byte SADD(byte a, byte b) { + return (byte)(VectorMath.addSaturating(a, b)); + } + + @Test(dataProvider = "byteSaturatingBinaryOpProvider") + static void SADDByte256VectorTests(IntFunction fa, IntFunction fb) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Byte256VectorTests::SADD); + } + + @Test(dataProvider = "byteSaturatingBinaryOpMaskProvider") + static void SADDByte256VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Byte256VectorTests::SADD); + } + + static byte SSUB(byte a, byte b) { + return (byte)(VectorMath.subSaturating(a, b)); + } + + @Test(dataProvider = "byteSaturatingBinaryOpProvider") + static void SSUBByte256VectorTests(IntFunction fa, IntFunction fb) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Byte256VectorTests::SSUB); + } + + @Test(dataProvider = "byteSaturatingBinaryOpMaskProvider") + static void SSUBByte256VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Byte256VectorTests::SSUB); + } + + static byte SUADD(byte a, byte b) { + return (byte)(VectorMath.addSaturatingUnsigned(a, b)); + } + + @Test(dataProvider = "byteSaturatingBinaryOpProvider") + static void SUADDByte256VectorTests(IntFunction fa, IntFunction fb) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Byte256VectorTests::SUADD); + } + + @Test(dataProvider = "byteSaturatingBinaryOpMaskProvider") + static void SUADDByte256VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Byte256VectorTests::SUADD); + } + + static byte SUSUB(byte a, byte b) { + return (byte)(VectorMath.subSaturatingUnsigned(a, b)); + } + + @Test(dataProvider = "byteSaturatingBinaryOpProvider") + static void SUSUBByte256VectorTests(IntFunction fa, IntFunction fb) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Byte256VectorTests::SUSUB); + } + + @Test(dataProvider = "byteSaturatingBinaryOpMaskProvider") + static void SUSUBByte256VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Byte256VectorTests::SUSUB); + } + @Test(dataProvider = "byteBinaryOpProvider") static void MINByte256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); @@ -4147,7 +4441,7 @@ static void GEByte256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) { + static void ULTByte256VectorTests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -4155,7 +4449,7 @@ static void UNSIGNED_LTByte256VectorTests(IntFunction fa, IntFunction mv = av.compare(VectorOperators.UNSIGNED_LT, bv); + VectorMask mv = av.compare(VectorOperators.ULT, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4166,7 +4460,7 @@ static void UNSIGNED_LTByte256VectorTests(IntFunction fa, IntFunction fa, IntFunction fb, + static void ULTByte256VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -4178,7 +4472,7 @@ static void UNSIGNED_LTByte256VectorTestsMasked(IntFunction fa, IntFunct for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ByteVector bv = ByteVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_LT, bv, vmask); + VectorMask mv = av.compare(VectorOperators.ULT, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4189,7 +4483,7 @@ static void UNSIGNED_LTByte256VectorTestsMasked(IntFunction fa, IntFunct } @Test(dataProvider = "byteCompareOpProvider") - static void UNSIGNED_GTByte256VectorTests(IntFunction fa, IntFunction fb) { + static void UGTByte256VectorTests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -4197,7 +4491,7 @@ static void UNSIGNED_GTByte256VectorTests(IntFunction fa, IntFunction mv = av.compare(VectorOperators.UNSIGNED_GT, bv); + VectorMask mv = av.compare(VectorOperators.UGT, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4208,7 +4502,7 @@ static void UNSIGNED_GTByte256VectorTests(IntFunction fa, IntFunction fa, IntFunction fb, + static void UGTByte256VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -4220,7 +4514,7 @@ static void UNSIGNED_GTByte256VectorTestsMasked(IntFunction fa, IntFunct for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ByteVector bv = ByteVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_GT, bv, vmask); + VectorMask mv = av.compare(VectorOperators.UGT, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4231,7 +4525,7 @@ static void UNSIGNED_GTByte256VectorTestsMasked(IntFunction fa, IntFunct } @Test(dataProvider = "byteCompareOpProvider") - static void UNSIGNED_LEByte256VectorTests(IntFunction fa, IntFunction fb) { + static void ULEByte256VectorTests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -4239,7 +4533,7 @@ static void UNSIGNED_LEByte256VectorTests(IntFunction fa, IntFunction mv = av.compare(VectorOperators.UNSIGNED_LE, bv); + VectorMask mv = av.compare(VectorOperators.ULE, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4250,7 +4544,7 @@ static void UNSIGNED_LEByte256VectorTests(IntFunction fa, IntFunction fa, IntFunction fb, + static void ULEByte256VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -4262,7 +4556,7 @@ static void UNSIGNED_LEByte256VectorTestsMasked(IntFunction fa, IntFunct for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ByteVector bv = ByteVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_LE, bv, vmask); + VectorMask mv = av.compare(VectorOperators.ULE, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4273,7 +4567,7 @@ static void UNSIGNED_LEByte256VectorTestsMasked(IntFunction fa, IntFunct } @Test(dataProvider = "byteCompareOpProvider") - static void UNSIGNED_GEByte256VectorTests(IntFunction fa, IntFunction fb) { + static void UGEByte256VectorTests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -4281,7 +4575,7 @@ static void UNSIGNED_GEByte256VectorTests(IntFunction fa, IntFunction mv = av.compare(VectorOperators.UNSIGNED_GE, bv); + VectorMask mv = av.compare(VectorOperators.UGE, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4292,7 +4586,7 @@ static void UNSIGNED_GEByte256VectorTests(IntFunction fa, IntFunction fa, IntFunction fb, + static void UGEByte256VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -4304,7 +4598,7 @@ static void UNSIGNED_GEByte256VectorTestsMasked(IntFunction fa, IntFunct for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ByteVector bv = ByteVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_GE, bv, vmask); + VectorMask mv = av.compare(VectorOperators.UGE, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { diff --git a/test/jdk/jdk/incubator/vector/Byte512VectorTests.java b/test/jdk/jdk/incubator/vector/Byte512VectorTests.java index a75aa42ef20..0edc66dfccc 100644 --- a/test/jdk/jdk/incubator/vector/Byte512VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Byte512VectorTests.java @@ -38,6 +38,7 @@ import jdk.incubator.vector.VectorMask; import jdk.incubator.vector.VectorOperators; import jdk.incubator.vector.Vector; +import jdk.incubator.vector.VectorMath; import jdk.incubator.vector.ByteVector; @@ -962,6 +963,33 @@ static byte bits(byte e) { }) ); + static final List> BYTE_SATURATING_GENERATORS = List.of( + withToString("byte[Byte.MIN_VALUE]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (byte)(Byte.MIN_VALUE)); + }), + withToString("byte[Byte.MAX_VALUE]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (byte)(Byte.MAX_VALUE)); + }), + withToString("byte[Byte.MAX_VALUE - 100]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (byte)(Byte.MAX_VALUE - 100)); + }), + withToString("byte[Byte.MIN_VALUE + 100]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (byte)(Byte.MIN_VALUE + 100)); + }), + withToString("byte[-i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (byte)(-i * 5)); + }), + withToString("byte[i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (byte)(i * 5)); + }) + ); + // Create combinations of pairs // @@@ Might be sensitive to order e.g. div by 0 static final List>> BYTE_GENERATOR_PAIRS = @@ -969,6 +997,11 @@ static byte bits(byte e) { flatMap(fa -> BYTE_GENERATORS.stream().skip(1).map(fb -> List.of(fa, fb))). collect(Collectors.toList()); + static final List>> BYTE_SATURATING_GENERATOR_PAIRS = + Stream.of(BYTE_GENERATORS.get(0)). + flatMap(fa -> BYTE_SATURATING_GENERATORS.stream().skip(1).map(fb -> List.of(fa, fb))). + collect(Collectors.toList()); + @DataProvider public Object[][] boolUnaryOpProvider() { return BOOL_ARRAY_GENERATORS.stream(). @@ -999,12 +1032,27 @@ public Object[][] byteBinaryOpProvider() { toArray(Object[][]::new); } + @DataProvider + public Object[][] byteSaturatingBinaryOpProvider() { + return BYTE_SATURATING_GENERATOR_PAIRS.stream().map(List::toArray). + toArray(Object[][]::new); + } + @DataProvider public Object[][] byteIndexedOpProvider() { return BYTE_GENERATOR_PAIRS.stream().map(List::toArray). toArray(Object[][]::new); } + @DataProvider + public Object[][] byteSaturatingBinaryOpMaskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> BYTE_SATURATING_GENERATOR_PAIRS.stream().map(lfa -> { + return Stream.concat(lfa.stream(), Stream.of(fm)).toArray(); + })). + toArray(Object[][]::new); + } + @DataProvider public Object[][] byteBinaryOpMaskProvider() { return BOOLEAN_MASK_GENERATORS.stream(). @@ -2939,6 +2987,252 @@ static void maxByte512VectorTests(IntFunction fa, IntFunction fb assertArraysEquals(r, a, b, Byte512VectorTests::max); } + static byte UMIN(byte a, byte b) { + return (byte)(VectorMath.minUnsigned(a, b)); + } + + @Test(dataProvider = "byteBinaryOpProvider") + static void UMINByte512VectorTests(IntFunction fa, IntFunction fb) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Byte512VectorTests::UMIN); + } + + @Test(dataProvider = "byteBinaryOpMaskProvider") + static void UMINByte512VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Byte512VectorTests::UMIN); + } + + static byte UMAX(byte a, byte b) { + return (byte)(VectorMath.maxUnsigned(a, b)); + } + + @Test(dataProvider = "byteBinaryOpProvider") + static void UMAXByte512VectorTests(IntFunction fa, IntFunction fb) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Byte512VectorTests::UMAX); + } + + @Test(dataProvider = "byteBinaryOpMaskProvider") + static void UMAXByte512VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Byte512VectorTests::UMAX); + } + + static byte SADD(byte a, byte b) { + return (byte)(VectorMath.addSaturating(a, b)); + } + + @Test(dataProvider = "byteSaturatingBinaryOpProvider") + static void SADDByte512VectorTests(IntFunction fa, IntFunction fb) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Byte512VectorTests::SADD); + } + + @Test(dataProvider = "byteSaturatingBinaryOpMaskProvider") + static void SADDByte512VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Byte512VectorTests::SADD); + } + + static byte SSUB(byte a, byte b) { + return (byte)(VectorMath.subSaturating(a, b)); + } + + @Test(dataProvider = "byteSaturatingBinaryOpProvider") + static void SSUBByte512VectorTests(IntFunction fa, IntFunction fb) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Byte512VectorTests::SSUB); + } + + @Test(dataProvider = "byteSaturatingBinaryOpMaskProvider") + static void SSUBByte512VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Byte512VectorTests::SSUB); + } + + static byte SUADD(byte a, byte b) { + return (byte)(VectorMath.addSaturatingUnsigned(a, b)); + } + + @Test(dataProvider = "byteSaturatingBinaryOpProvider") + static void SUADDByte512VectorTests(IntFunction fa, IntFunction fb) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Byte512VectorTests::SUADD); + } + + @Test(dataProvider = "byteSaturatingBinaryOpMaskProvider") + static void SUADDByte512VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Byte512VectorTests::SUADD); + } + + static byte SUSUB(byte a, byte b) { + return (byte)(VectorMath.subSaturatingUnsigned(a, b)); + } + + @Test(dataProvider = "byteSaturatingBinaryOpProvider") + static void SUSUBByte512VectorTests(IntFunction fa, IntFunction fb) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Byte512VectorTests::SUSUB); + } + + @Test(dataProvider = "byteSaturatingBinaryOpMaskProvider") + static void SUSUBByte512VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Byte512VectorTests::SUSUB); + } + @Test(dataProvider = "byteBinaryOpProvider") static void MINByte512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); @@ -4147,7 +4441,7 @@ static void GEByte512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) { + static void ULTByte512VectorTests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -4155,7 +4449,7 @@ static void UNSIGNED_LTByte512VectorTests(IntFunction fa, IntFunction mv = av.compare(VectorOperators.UNSIGNED_LT, bv); + VectorMask mv = av.compare(VectorOperators.ULT, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4166,7 +4460,7 @@ static void UNSIGNED_LTByte512VectorTests(IntFunction fa, IntFunction fa, IntFunction fb, + static void ULTByte512VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -4178,7 +4472,7 @@ static void UNSIGNED_LTByte512VectorTestsMasked(IntFunction fa, IntFunct for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ByteVector bv = ByteVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_LT, bv, vmask); + VectorMask mv = av.compare(VectorOperators.ULT, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4189,7 +4483,7 @@ static void UNSIGNED_LTByte512VectorTestsMasked(IntFunction fa, IntFunct } @Test(dataProvider = "byteCompareOpProvider") - static void UNSIGNED_GTByte512VectorTests(IntFunction fa, IntFunction fb) { + static void UGTByte512VectorTests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -4197,7 +4491,7 @@ static void UNSIGNED_GTByte512VectorTests(IntFunction fa, IntFunction mv = av.compare(VectorOperators.UNSIGNED_GT, bv); + VectorMask mv = av.compare(VectorOperators.UGT, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4208,7 +4502,7 @@ static void UNSIGNED_GTByte512VectorTests(IntFunction fa, IntFunction fa, IntFunction fb, + static void UGTByte512VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -4220,7 +4514,7 @@ static void UNSIGNED_GTByte512VectorTestsMasked(IntFunction fa, IntFunct for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ByteVector bv = ByteVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_GT, bv, vmask); + VectorMask mv = av.compare(VectorOperators.UGT, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4231,7 +4525,7 @@ static void UNSIGNED_GTByte512VectorTestsMasked(IntFunction fa, IntFunct } @Test(dataProvider = "byteCompareOpProvider") - static void UNSIGNED_LEByte512VectorTests(IntFunction fa, IntFunction fb) { + static void ULEByte512VectorTests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -4239,7 +4533,7 @@ static void UNSIGNED_LEByte512VectorTests(IntFunction fa, IntFunction mv = av.compare(VectorOperators.UNSIGNED_LE, bv); + VectorMask mv = av.compare(VectorOperators.ULE, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4250,7 +4544,7 @@ static void UNSIGNED_LEByte512VectorTests(IntFunction fa, IntFunction fa, IntFunction fb, + static void ULEByte512VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -4262,7 +4556,7 @@ static void UNSIGNED_LEByte512VectorTestsMasked(IntFunction fa, IntFunct for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ByteVector bv = ByteVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_LE, bv, vmask); + VectorMask mv = av.compare(VectorOperators.ULE, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4273,7 +4567,7 @@ static void UNSIGNED_LEByte512VectorTestsMasked(IntFunction fa, IntFunct } @Test(dataProvider = "byteCompareOpProvider") - static void UNSIGNED_GEByte512VectorTests(IntFunction fa, IntFunction fb) { + static void UGEByte512VectorTests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -4281,7 +4575,7 @@ static void UNSIGNED_GEByte512VectorTests(IntFunction fa, IntFunction mv = av.compare(VectorOperators.UNSIGNED_GE, bv); + VectorMask mv = av.compare(VectorOperators.UGE, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4292,7 +4586,7 @@ static void UNSIGNED_GEByte512VectorTests(IntFunction fa, IntFunction fa, IntFunction fb, + static void UGEByte512VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -4304,7 +4598,7 @@ static void UNSIGNED_GEByte512VectorTestsMasked(IntFunction fa, IntFunct for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ByteVector bv = ByteVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_GE, bv, vmask); + VectorMask mv = av.compare(VectorOperators.UGE, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { diff --git a/test/jdk/jdk/incubator/vector/Byte64VectorTests.java b/test/jdk/jdk/incubator/vector/Byte64VectorTests.java index b621c28a779..98c8382c526 100644 --- a/test/jdk/jdk/incubator/vector/Byte64VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Byte64VectorTests.java @@ -38,6 +38,7 @@ import jdk.incubator.vector.VectorMask; import jdk.incubator.vector.VectorOperators; import jdk.incubator.vector.Vector; +import jdk.incubator.vector.VectorMath; import jdk.incubator.vector.ByteVector; @@ -962,6 +963,33 @@ static byte bits(byte e) { }) ); + static final List> BYTE_SATURATING_GENERATORS = List.of( + withToString("byte[Byte.MIN_VALUE]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (byte)(Byte.MIN_VALUE)); + }), + withToString("byte[Byte.MAX_VALUE]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (byte)(Byte.MAX_VALUE)); + }), + withToString("byte[Byte.MAX_VALUE - 100]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (byte)(Byte.MAX_VALUE - 100)); + }), + withToString("byte[Byte.MIN_VALUE + 100]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (byte)(Byte.MIN_VALUE + 100)); + }), + withToString("byte[-i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (byte)(-i * 5)); + }), + withToString("byte[i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (byte)(i * 5)); + }) + ); + // Create combinations of pairs // @@@ Might be sensitive to order e.g. div by 0 static final List>> BYTE_GENERATOR_PAIRS = @@ -969,6 +997,11 @@ static byte bits(byte e) { flatMap(fa -> BYTE_GENERATORS.stream().skip(1).map(fb -> List.of(fa, fb))). collect(Collectors.toList()); + static final List>> BYTE_SATURATING_GENERATOR_PAIRS = + Stream.of(BYTE_GENERATORS.get(0)). + flatMap(fa -> BYTE_SATURATING_GENERATORS.stream().skip(1).map(fb -> List.of(fa, fb))). + collect(Collectors.toList()); + @DataProvider public Object[][] boolUnaryOpProvider() { return BOOL_ARRAY_GENERATORS.stream(). @@ -999,12 +1032,27 @@ public Object[][] byteBinaryOpProvider() { toArray(Object[][]::new); } + @DataProvider + public Object[][] byteSaturatingBinaryOpProvider() { + return BYTE_SATURATING_GENERATOR_PAIRS.stream().map(List::toArray). + toArray(Object[][]::new); + } + @DataProvider public Object[][] byteIndexedOpProvider() { return BYTE_GENERATOR_PAIRS.stream().map(List::toArray). toArray(Object[][]::new); } + @DataProvider + public Object[][] byteSaturatingBinaryOpMaskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> BYTE_SATURATING_GENERATOR_PAIRS.stream().map(lfa -> { + return Stream.concat(lfa.stream(), Stream.of(fm)).toArray(); + })). + toArray(Object[][]::new); + } + @DataProvider public Object[][] byteBinaryOpMaskProvider() { return BOOLEAN_MASK_GENERATORS.stream(). @@ -2939,6 +2987,252 @@ static void maxByte64VectorTests(IntFunction fa, IntFunction fb) assertArraysEquals(r, a, b, Byte64VectorTests::max); } + static byte UMIN(byte a, byte b) { + return (byte)(VectorMath.minUnsigned(a, b)); + } + + @Test(dataProvider = "byteBinaryOpProvider") + static void UMINByte64VectorTests(IntFunction fa, IntFunction fb) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Byte64VectorTests::UMIN); + } + + @Test(dataProvider = "byteBinaryOpMaskProvider") + static void UMINByte64VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Byte64VectorTests::UMIN); + } + + static byte UMAX(byte a, byte b) { + return (byte)(VectorMath.maxUnsigned(a, b)); + } + + @Test(dataProvider = "byteBinaryOpProvider") + static void UMAXByte64VectorTests(IntFunction fa, IntFunction fb) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Byte64VectorTests::UMAX); + } + + @Test(dataProvider = "byteBinaryOpMaskProvider") + static void UMAXByte64VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Byte64VectorTests::UMAX); + } + + static byte SADD(byte a, byte b) { + return (byte)(VectorMath.addSaturating(a, b)); + } + + @Test(dataProvider = "byteSaturatingBinaryOpProvider") + static void SADDByte64VectorTests(IntFunction fa, IntFunction fb) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Byte64VectorTests::SADD); + } + + @Test(dataProvider = "byteSaturatingBinaryOpMaskProvider") + static void SADDByte64VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Byte64VectorTests::SADD); + } + + static byte SSUB(byte a, byte b) { + return (byte)(VectorMath.subSaturating(a, b)); + } + + @Test(dataProvider = "byteSaturatingBinaryOpProvider") + static void SSUBByte64VectorTests(IntFunction fa, IntFunction fb) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Byte64VectorTests::SSUB); + } + + @Test(dataProvider = "byteSaturatingBinaryOpMaskProvider") + static void SSUBByte64VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Byte64VectorTests::SSUB); + } + + static byte SUADD(byte a, byte b) { + return (byte)(VectorMath.addSaturatingUnsigned(a, b)); + } + + @Test(dataProvider = "byteSaturatingBinaryOpProvider") + static void SUADDByte64VectorTests(IntFunction fa, IntFunction fb) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Byte64VectorTests::SUADD); + } + + @Test(dataProvider = "byteSaturatingBinaryOpMaskProvider") + static void SUADDByte64VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Byte64VectorTests::SUADD); + } + + static byte SUSUB(byte a, byte b) { + return (byte)(VectorMath.subSaturatingUnsigned(a, b)); + } + + @Test(dataProvider = "byteSaturatingBinaryOpProvider") + static void SUSUBByte64VectorTests(IntFunction fa, IntFunction fb) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Byte64VectorTests::SUSUB); + } + + @Test(dataProvider = "byteSaturatingBinaryOpMaskProvider") + static void SUSUBByte64VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Byte64VectorTests::SUSUB); + } + @Test(dataProvider = "byteBinaryOpProvider") static void MINByte64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); @@ -4147,7 +4441,7 @@ static void GEByte64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) { + static void ULTByte64VectorTests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -4155,7 +4449,7 @@ static void UNSIGNED_LTByte64VectorTests(IntFunction fa, IntFunction mv = av.compare(VectorOperators.UNSIGNED_LT, bv); + VectorMask mv = av.compare(VectorOperators.ULT, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4166,7 +4460,7 @@ static void UNSIGNED_LTByte64VectorTests(IntFunction fa, IntFunction fa, IntFunction fb, + static void ULTByte64VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -4178,7 +4472,7 @@ static void UNSIGNED_LTByte64VectorTestsMasked(IntFunction fa, IntFuncti for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ByteVector bv = ByteVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_LT, bv, vmask); + VectorMask mv = av.compare(VectorOperators.ULT, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4189,7 +4483,7 @@ static void UNSIGNED_LTByte64VectorTestsMasked(IntFunction fa, IntFuncti } @Test(dataProvider = "byteCompareOpProvider") - static void UNSIGNED_GTByte64VectorTests(IntFunction fa, IntFunction fb) { + static void UGTByte64VectorTests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -4197,7 +4491,7 @@ static void UNSIGNED_GTByte64VectorTests(IntFunction fa, IntFunction mv = av.compare(VectorOperators.UNSIGNED_GT, bv); + VectorMask mv = av.compare(VectorOperators.UGT, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4208,7 +4502,7 @@ static void UNSIGNED_GTByte64VectorTests(IntFunction fa, IntFunction fa, IntFunction fb, + static void UGTByte64VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -4220,7 +4514,7 @@ static void UNSIGNED_GTByte64VectorTestsMasked(IntFunction fa, IntFuncti for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ByteVector bv = ByteVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_GT, bv, vmask); + VectorMask mv = av.compare(VectorOperators.UGT, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4231,7 +4525,7 @@ static void UNSIGNED_GTByte64VectorTestsMasked(IntFunction fa, IntFuncti } @Test(dataProvider = "byteCompareOpProvider") - static void UNSIGNED_LEByte64VectorTests(IntFunction fa, IntFunction fb) { + static void ULEByte64VectorTests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -4239,7 +4533,7 @@ static void UNSIGNED_LEByte64VectorTests(IntFunction fa, IntFunction mv = av.compare(VectorOperators.UNSIGNED_LE, bv); + VectorMask mv = av.compare(VectorOperators.ULE, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4250,7 +4544,7 @@ static void UNSIGNED_LEByte64VectorTests(IntFunction fa, IntFunction fa, IntFunction fb, + static void ULEByte64VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -4262,7 +4556,7 @@ static void UNSIGNED_LEByte64VectorTestsMasked(IntFunction fa, IntFuncti for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ByteVector bv = ByteVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_LE, bv, vmask); + VectorMask mv = av.compare(VectorOperators.ULE, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4273,7 +4567,7 @@ static void UNSIGNED_LEByte64VectorTestsMasked(IntFunction fa, IntFuncti } @Test(dataProvider = "byteCompareOpProvider") - static void UNSIGNED_GEByte64VectorTests(IntFunction fa, IntFunction fb) { + static void UGEByte64VectorTests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -4281,7 +4575,7 @@ static void UNSIGNED_GEByte64VectorTests(IntFunction fa, IntFunction mv = av.compare(VectorOperators.UNSIGNED_GE, bv); + VectorMask mv = av.compare(VectorOperators.UGE, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4292,7 +4586,7 @@ static void UNSIGNED_GEByte64VectorTests(IntFunction fa, IntFunction fa, IntFunction fb, + static void UGEByte64VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -4304,7 +4598,7 @@ static void UNSIGNED_GEByte64VectorTestsMasked(IntFunction fa, IntFuncti for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ByteVector bv = ByteVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_GE, bv, vmask); + VectorMask mv = av.compare(VectorOperators.UGE, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { diff --git a/test/jdk/jdk/incubator/vector/ByteMaxVectorTests.java b/test/jdk/jdk/incubator/vector/ByteMaxVectorTests.java index bbd354c958a..2d9d49f32ad 100644 --- a/test/jdk/jdk/incubator/vector/ByteMaxVectorTests.java +++ b/test/jdk/jdk/incubator/vector/ByteMaxVectorTests.java @@ -38,6 +38,7 @@ import jdk.incubator.vector.VectorMask; import jdk.incubator.vector.VectorOperators; import jdk.incubator.vector.Vector; +import jdk.incubator.vector.VectorMath; import jdk.incubator.vector.ByteVector; @@ -967,6 +968,33 @@ static byte bits(byte e) { }) ); + static final List> BYTE_SATURATING_GENERATORS = List.of( + withToString("byte[Byte.MIN_VALUE]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (byte)(Byte.MIN_VALUE)); + }), + withToString("byte[Byte.MAX_VALUE]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (byte)(Byte.MAX_VALUE)); + }), + withToString("byte[Byte.MAX_VALUE - 100]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (byte)(Byte.MAX_VALUE - 100)); + }), + withToString("byte[Byte.MIN_VALUE + 100]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (byte)(Byte.MIN_VALUE + 100)); + }), + withToString("byte[-i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (byte)(-i * 5)); + }), + withToString("byte[i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (byte)(i * 5)); + }) + ); + // Create combinations of pairs // @@@ Might be sensitive to order e.g. div by 0 static final List>> BYTE_GENERATOR_PAIRS = @@ -974,6 +1002,11 @@ static byte bits(byte e) { flatMap(fa -> BYTE_GENERATORS.stream().skip(1).map(fb -> List.of(fa, fb))). collect(Collectors.toList()); + static final List>> BYTE_SATURATING_GENERATOR_PAIRS = + Stream.of(BYTE_GENERATORS.get(0)). + flatMap(fa -> BYTE_SATURATING_GENERATORS.stream().skip(1).map(fb -> List.of(fa, fb))). + collect(Collectors.toList()); + @DataProvider public Object[][] boolUnaryOpProvider() { return BOOL_ARRAY_GENERATORS.stream(). @@ -1004,12 +1037,27 @@ public Object[][] byteBinaryOpProvider() { toArray(Object[][]::new); } + @DataProvider + public Object[][] byteSaturatingBinaryOpProvider() { + return BYTE_SATURATING_GENERATOR_PAIRS.stream().map(List::toArray). + toArray(Object[][]::new); + } + @DataProvider public Object[][] byteIndexedOpProvider() { return BYTE_GENERATOR_PAIRS.stream().map(List::toArray). toArray(Object[][]::new); } + @DataProvider + public Object[][] byteSaturatingBinaryOpMaskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> BYTE_SATURATING_GENERATOR_PAIRS.stream().map(lfa -> { + return Stream.concat(lfa.stream(), Stream.of(fm)).toArray(); + })). + toArray(Object[][]::new); + } + @DataProvider public Object[][] byteBinaryOpMaskProvider() { return BOOLEAN_MASK_GENERATORS.stream(). @@ -2944,6 +2992,252 @@ static void maxByteMaxVectorTests(IntFunction fa, IntFunction fb assertArraysEquals(r, a, b, ByteMaxVectorTests::max); } + static byte UMIN(byte a, byte b) { + return (byte)(VectorMath.minUnsigned(a, b)); + } + + @Test(dataProvider = "byteBinaryOpProvider") + static void UMINByteMaxVectorTests(IntFunction fa, IntFunction fb) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, ByteMaxVectorTests::UMIN); + } + + @Test(dataProvider = "byteBinaryOpMaskProvider") + static void UMINByteMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::UMIN); + } + + static byte UMAX(byte a, byte b) { + return (byte)(VectorMath.maxUnsigned(a, b)); + } + + @Test(dataProvider = "byteBinaryOpProvider") + static void UMAXByteMaxVectorTests(IntFunction fa, IntFunction fb) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, ByteMaxVectorTests::UMAX); + } + + @Test(dataProvider = "byteBinaryOpMaskProvider") + static void UMAXByteMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::UMAX); + } + + static byte SADD(byte a, byte b) { + return (byte)(VectorMath.addSaturating(a, b)); + } + + @Test(dataProvider = "byteSaturatingBinaryOpProvider") + static void SADDByteMaxVectorTests(IntFunction fa, IntFunction fb) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, ByteMaxVectorTests::SADD); + } + + @Test(dataProvider = "byteSaturatingBinaryOpMaskProvider") + static void SADDByteMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::SADD); + } + + static byte SSUB(byte a, byte b) { + return (byte)(VectorMath.subSaturating(a, b)); + } + + @Test(dataProvider = "byteSaturatingBinaryOpProvider") + static void SSUBByteMaxVectorTests(IntFunction fa, IntFunction fb) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, ByteMaxVectorTests::SSUB); + } + + @Test(dataProvider = "byteSaturatingBinaryOpMaskProvider") + static void SSUBByteMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::SSUB); + } + + static byte SUADD(byte a, byte b) { + return (byte)(VectorMath.addSaturatingUnsigned(a, b)); + } + + @Test(dataProvider = "byteSaturatingBinaryOpProvider") + static void SUADDByteMaxVectorTests(IntFunction fa, IntFunction fb) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, ByteMaxVectorTests::SUADD); + } + + @Test(dataProvider = "byteSaturatingBinaryOpMaskProvider") + static void SUADDByteMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::SUADD); + } + + static byte SUSUB(byte a, byte b) { + return (byte)(VectorMath.subSaturatingUnsigned(a, b)); + } + + @Test(dataProvider = "byteSaturatingBinaryOpProvider") + static void SUSUBByteMaxVectorTests(IntFunction fa, IntFunction fb) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, ByteMaxVectorTests::SUSUB); + } + + @Test(dataProvider = "byteSaturatingBinaryOpMaskProvider") + static void SUSUBByteMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + byte[] a = fa.apply(SPECIES.length()); + byte[] b = fb.apply(SPECIES.length()); + byte[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ByteVector av = ByteVector.fromArray(SPECIES, a, i); + ByteVector bv = ByteVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, ByteMaxVectorTests::SUSUB); + } + @Test(dataProvider = "byteBinaryOpProvider") static void MINByteMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); @@ -4152,7 +4446,7 @@ static void GEByteMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) { + static void ULTByteMaxVectorTests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -4160,7 +4454,7 @@ static void UNSIGNED_LTByteMaxVectorTests(IntFunction fa, IntFunction mv = av.compare(VectorOperators.UNSIGNED_LT, bv); + VectorMask mv = av.compare(VectorOperators.ULT, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4171,7 +4465,7 @@ static void UNSIGNED_LTByteMaxVectorTests(IntFunction fa, IntFunction fa, IntFunction fb, + static void ULTByteMaxVectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -4183,7 +4477,7 @@ static void UNSIGNED_LTByteMaxVectorTestsMasked(IntFunction fa, IntFunct for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ByteVector bv = ByteVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_LT, bv, vmask); + VectorMask mv = av.compare(VectorOperators.ULT, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4194,7 +4488,7 @@ static void UNSIGNED_LTByteMaxVectorTestsMasked(IntFunction fa, IntFunct } @Test(dataProvider = "byteCompareOpProvider") - static void UNSIGNED_GTByteMaxVectorTests(IntFunction fa, IntFunction fb) { + static void UGTByteMaxVectorTests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -4202,7 +4496,7 @@ static void UNSIGNED_GTByteMaxVectorTests(IntFunction fa, IntFunction mv = av.compare(VectorOperators.UNSIGNED_GT, bv); + VectorMask mv = av.compare(VectorOperators.UGT, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4213,7 +4507,7 @@ static void UNSIGNED_GTByteMaxVectorTests(IntFunction fa, IntFunction fa, IntFunction fb, + static void UGTByteMaxVectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -4225,7 +4519,7 @@ static void UNSIGNED_GTByteMaxVectorTestsMasked(IntFunction fa, IntFunct for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ByteVector bv = ByteVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_GT, bv, vmask); + VectorMask mv = av.compare(VectorOperators.UGT, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4236,7 +4530,7 @@ static void UNSIGNED_GTByteMaxVectorTestsMasked(IntFunction fa, IntFunct } @Test(dataProvider = "byteCompareOpProvider") - static void UNSIGNED_LEByteMaxVectorTests(IntFunction fa, IntFunction fb) { + static void ULEByteMaxVectorTests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -4244,7 +4538,7 @@ static void UNSIGNED_LEByteMaxVectorTests(IntFunction fa, IntFunction mv = av.compare(VectorOperators.UNSIGNED_LE, bv); + VectorMask mv = av.compare(VectorOperators.ULE, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4255,7 +4549,7 @@ static void UNSIGNED_LEByteMaxVectorTests(IntFunction fa, IntFunction fa, IntFunction fb, + static void ULEByteMaxVectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -4267,7 +4561,7 @@ static void UNSIGNED_LEByteMaxVectorTestsMasked(IntFunction fa, IntFunct for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ByteVector bv = ByteVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_LE, bv, vmask); + VectorMask mv = av.compare(VectorOperators.ULE, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4278,7 +4572,7 @@ static void UNSIGNED_LEByteMaxVectorTestsMasked(IntFunction fa, IntFunct } @Test(dataProvider = "byteCompareOpProvider") - static void UNSIGNED_GEByteMaxVectorTests(IntFunction fa, IntFunction fb) { + static void UGEByteMaxVectorTests(IntFunction fa, IntFunction fb) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -4286,7 +4580,7 @@ static void UNSIGNED_GEByteMaxVectorTests(IntFunction fa, IntFunction mv = av.compare(VectorOperators.UNSIGNED_GE, bv); + VectorMask mv = av.compare(VectorOperators.UGE, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4297,7 +4591,7 @@ static void UNSIGNED_GEByteMaxVectorTests(IntFunction fa, IntFunction fa, IntFunction fb, + static void UGEByteMaxVectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { byte[] a = fa.apply(SPECIES.length()); byte[] b = fb.apply(SPECIES.length()); @@ -4309,7 +4603,7 @@ static void UNSIGNED_GEByteMaxVectorTestsMasked(IntFunction fa, IntFunct for (int i = 0; i < a.length; i += SPECIES.length()) { ByteVector av = ByteVector.fromArray(SPECIES, a, i); ByteVector bv = ByteVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_GE, bv, vmask); + VectorMask mv = av.compare(VectorOperators.UGE, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { diff --git a/test/jdk/jdk/incubator/vector/Int128VectorTests.java b/test/jdk/jdk/incubator/vector/Int128VectorTests.java index 528d26a952b..028e757e853 100644 --- a/test/jdk/jdk/incubator/vector/Int128VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Int128VectorTests.java @@ -38,6 +38,7 @@ import jdk.incubator.vector.VectorMask; import jdk.incubator.vector.VectorOperators; import jdk.incubator.vector.Vector; +import jdk.incubator.vector.VectorMath; import jdk.incubator.vector.IntVector; @@ -952,6 +953,33 @@ static int bits(int e) { }) ); + static final List> INT_SATURATING_GENERATORS = List.of( + withToString("int[Integer.MIN_VALUE]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (int)(Integer.MIN_VALUE)); + }), + withToString("int[Integer.MAX_VALUE]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (int)(Integer.MAX_VALUE)); + }), + withToString("int[Integer.MAX_VALUE - 100]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (int)(Integer.MAX_VALUE - 100)); + }), + withToString("int[Integer.MIN_VALUE + 100]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (int)(Integer.MIN_VALUE + 100)); + }), + withToString("int[-i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (int)(-i * 5)); + }), + withToString("int[i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (int)(i * 5)); + }) + ); + // Create combinations of pairs // @@@ Might be sensitive to order e.g. div by 0 static final List>> INT_GENERATOR_PAIRS = @@ -959,6 +987,11 @@ static int bits(int e) { flatMap(fa -> INT_GENERATORS.stream().skip(1).map(fb -> List.of(fa, fb))). collect(Collectors.toList()); + static final List>> INT_SATURATING_GENERATOR_PAIRS = + Stream.of(INT_GENERATORS.get(0)). + flatMap(fa -> INT_SATURATING_GENERATORS.stream().skip(1).map(fb -> List.of(fa, fb))). + collect(Collectors.toList()); + @DataProvider public Object[][] boolUnaryOpProvider() { return BOOL_ARRAY_GENERATORS.stream(). @@ -989,12 +1022,27 @@ public Object[][] intBinaryOpProvider() { toArray(Object[][]::new); } + @DataProvider + public Object[][] intSaturatingBinaryOpProvider() { + return INT_SATURATING_GENERATOR_PAIRS.stream().map(List::toArray). + toArray(Object[][]::new); + } + @DataProvider public Object[][] intIndexedOpProvider() { return INT_GENERATOR_PAIRS.stream().map(List::toArray). toArray(Object[][]::new); } + @DataProvider + public Object[][] intSaturatingBinaryOpMaskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> INT_SATURATING_GENERATOR_PAIRS.stream().map(lfa -> { + return Stream.concat(lfa.stream(), Stream.of(fm)).toArray(); + })). + toArray(Object[][]::new); + } + @DataProvider public Object[][] intBinaryOpMaskProvider() { return BOOLEAN_MASK_GENERATORS.stream(). @@ -2983,6 +3031,252 @@ static void maxInt128VectorTests(IntFunction fa, IntFunction fb) { assertArraysEquals(r, a, b, Int128VectorTests::max); } + static int UMIN(int a, int b) { + return (int)(VectorMath.minUnsigned(a, b)); + } + + @Test(dataProvider = "intBinaryOpProvider") + static void UMINInt128VectorTests(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Int128VectorTests::UMIN); + } + + @Test(dataProvider = "intBinaryOpMaskProvider") + static void UMINInt128VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Int128VectorTests::UMIN); + } + + static int UMAX(int a, int b) { + return (int)(VectorMath.maxUnsigned(a, b)); + } + + @Test(dataProvider = "intBinaryOpProvider") + static void UMAXInt128VectorTests(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Int128VectorTests::UMAX); + } + + @Test(dataProvider = "intBinaryOpMaskProvider") + static void UMAXInt128VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Int128VectorTests::UMAX); + } + + static int SADD(int a, int b) { + return (int)(VectorMath.addSaturating(a, b)); + } + + @Test(dataProvider = "intSaturatingBinaryOpProvider") + static void SADDInt128VectorTests(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Int128VectorTests::SADD); + } + + @Test(dataProvider = "intSaturatingBinaryOpMaskProvider") + static void SADDInt128VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Int128VectorTests::SADD); + } + + static int SSUB(int a, int b) { + return (int)(VectorMath.subSaturating(a, b)); + } + + @Test(dataProvider = "intSaturatingBinaryOpProvider") + static void SSUBInt128VectorTests(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Int128VectorTests::SSUB); + } + + @Test(dataProvider = "intSaturatingBinaryOpMaskProvider") + static void SSUBInt128VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Int128VectorTests::SSUB); + } + + static int SUADD(int a, int b) { + return (int)(VectorMath.addSaturatingUnsigned(a, b)); + } + + @Test(dataProvider = "intSaturatingBinaryOpProvider") + static void SUADDInt128VectorTests(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Int128VectorTests::SUADD); + } + + @Test(dataProvider = "intSaturatingBinaryOpMaskProvider") + static void SUADDInt128VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Int128VectorTests::SUADD); + } + + static int SUSUB(int a, int b) { + return (int)(VectorMath.subSaturatingUnsigned(a, b)); + } + + @Test(dataProvider = "intSaturatingBinaryOpProvider") + static void SUSUBInt128VectorTests(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Int128VectorTests::SUSUB); + } + + @Test(dataProvider = "intSaturatingBinaryOpMaskProvider") + static void SUSUBInt128VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Int128VectorTests::SUSUB); + } + @Test(dataProvider = "intBinaryOpProvider") static void MINInt128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); @@ -4191,7 +4485,7 @@ static void GEInt128VectorTestsMasked(IntFunction fa, IntFunction } @Test(dataProvider = "intCompareOpProvider") - static void UNSIGNED_LTInt128VectorTests(IntFunction fa, IntFunction fb) { + static void ULTInt128VectorTests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -4199,7 +4493,7 @@ static void UNSIGNED_LTInt128VectorTests(IntFunction fa, IntFunction mv = av.compare(VectorOperators.UNSIGNED_LT, bv); + VectorMask mv = av.compare(VectorOperators.ULT, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4210,7 +4504,7 @@ static void UNSIGNED_LTInt128VectorTests(IntFunction fa, IntFunction fa, IntFunction fb, + static void ULTInt128VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -4222,7 +4516,7 @@ static void UNSIGNED_LTInt128VectorTestsMasked(IntFunction fa, IntFunctio for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); IntVector bv = IntVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_LT, bv, vmask); + VectorMask mv = av.compare(VectorOperators.ULT, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4233,7 +4527,7 @@ static void UNSIGNED_LTInt128VectorTestsMasked(IntFunction fa, IntFunctio } @Test(dataProvider = "intCompareOpProvider") - static void UNSIGNED_GTInt128VectorTests(IntFunction fa, IntFunction fb) { + static void UGTInt128VectorTests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -4241,7 +4535,7 @@ static void UNSIGNED_GTInt128VectorTests(IntFunction fa, IntFunction mv = av.compare(VectorOperators.UNSIGNED_GT, bv); + VectorMask mv = av.compare(VectorOperators.UGT, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4252,7 +4546,7 @@ static void UNSIGNED_GTInt128VectorTests(IntFunction fa, IntFunction fa, IntFunction fb, + static void UGTInt128VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -4264,7 +4558,7 @@ static void UNSIGNED_GTInt128VectorTestsMasked(IntFunction fa, IntFunctio for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); IntVector bv = IntVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_GT, bv, vmask); + VectorMask mv = av.compare(VectorOperators.UGT, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4275,7 +4569,7 @@ static void UNSIGNED_GTInt128VectorTestsMasked(IntFunction fa, IntFunctio } @Test(dataProvider = "intCompareOpProvider") - static void UNSIGNED_LEInt128VectorTests(IntFunction fa, IntFunction fb) { + static void ULEInt128VectorTests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -4283,7 +4577,7 @@ static void UNSIGNED_LEInt128VectorTests(IntFunction fa, IntFunction mv = av.compare(VectorOperators.UNSIGNED_LE, bv); + VectorMask mv = av.compare(VectorOperators.ULE, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4294,7 +4588,7 @@ static void UNSIGNED_LEInt128VectorTests(IntFunction fa, IntFunction fa, IntFunction fb, + static void ULEInt128VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -4306,7 +4600,7 @@ static void UNSIGNED_LEInt128VectorTestsMasked(IntFunction fa, IntFunctio for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); IntVector bv = IntVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_LE, bv, vmask); + VectorMask mv = av.compare(VectorOperators.ULE, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4317,7 +4611,7 @@ static void UNSIGNED_LEInt128VectorTestsMasked(IntFunction fa, IntFunctio } @Test(dataProvider = "intCompareOpProvider") - static void UNSIGNED_GEInt128VectorTests(IntFunction fa, IntFunction fb) { + static void UGEInt128VectorTests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -4325,7 +4619,7 @@ static void UNSIGNED_GEInt128VectorTests(IntFunction fa, IntFunction mv = av.compare(VectorOperators.UNSIGNED_GE, bv); + VectorMask mv = av.compare(VectorOperators.UGE, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4336,7 +4630,7 @@ static void UNSIGNED_GEInt128VectorTests(IntFunction fa, IntFunction fa, IntFunction fb, + static void UGEInt128VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -4348,7 +4642,7 @@ static void UNSIGNED_GEInt128VectorTestsMasked(IntFunction fa, IntFunctio for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); IntVector bv = IntVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_GE, bv, vmask); + VectorMask mv = av.compare(VectorOperators.UGE, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { diff --git a/test/jdk/jdk/incubator/vector/Int256VectorTests.java b/test/jdk/jdk/incubator/vector/Int256VectorTests.java index 09561e0f3c4..6dab8a39873 100644 --- a/test/jdk/jdk/incubator/vector/Int256VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Int256VectorTests.java @@ -38,6 +38,7 @@ import jdk.incubator.vector.VectorMask; import jdk.incubator.vector.VectorOperators; import jdk.incubator.vector.Vector; +import jdk.incubator.vector.VectorMath; import jdk.incubator.vector.IntVector; @@ -952,6 +953,33 @@ static int bits(int e) { }) ); + static final List> INT_SATURATING_GENERATORS = List.of( + withToString("int[Integer.MIN_VALUE]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (int)(Integer.MIN_VALUE)); + }), + withToString("int[Integer.MAX_VALUE]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (int)(Integer.MAX_VALUE)); + }), + withToString("int[Integer.MAX_VALUE - 100]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (int)(Integer.MAX_VALUE - 100)); + }), + withToString("int[Integer.MIN_VALUE + 100]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (int)(Integer.MIN_VALUE + 100)); + }), + withToString("int[-i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (int)(-i * 5)); + }), + withToString("int[i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (int)(i * 5)); + }) + ); + // Create combinations of pairs // @@@ Might be sensitive to order e.g. div by 0 static final List>> INT_GENERATOR_PAIRS = @@ -959,6 +987,11 @@ static int bits(int e) { flatMap(fa -> INT_GENERATORS.stream().skip(1).map(fb -> List.of(fa, fb))). collect(Collectors.toList()); + static final List>> INT_SATURATING_GENERATOR_PAIRS = + Stream.of(INT_GENERATORS.get(0)). + flatMap(fa -> INT_SATURATING_GENERATORS.stream().skip(1).map(fb -> List.of(fa, fb))). + collect(Collectors.toList()); + @DataProvider public Object[][] boolUnaryOpProvider() { return BOOL_ARRAY_GENERATORS.stream(). @@ -989,12 +1022,27 @@ public Object[][] intBinaryOpProvider() { toArray(Object[][]::new); } + @DataProvider + public Object[][] intSaturatingBinaryOpProvider() { + return INT_SATURATING_GENERATOR_PAIRS.stream().map(List::toArray). + toArray(Object[][]::new); + } + @DataProvider public Object[][] intIndexedOpProvider() { return INT_GENERATOR_PAIRS.stream().map(List::toArray). toArray(Object[][]::new); } + @DataProvider + public Object[][] intSaturatingBinaryOpMaskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> INT_SATURATING_GENERATOR_PAIRS.stream().map(lfa -> { + return Stream.concat(lfa.stream(), Stream.of(fm)).toArray(); + })). + toArray(Object[][]::new); + } + @DataProvider public Object[][] intBinaryOpMaskProvider() { return BOOLEAN_MASK_GENERATORS.stream(). @@ -2983,6 +3031,252 @@ static void maxInt256VectorTests(IntFunction fa, IntFunction fb) { assertArraysEquals(r, a, b, Int256VectorTests::max); } + static int UMIN(int a, int b) { + return (int)(VectorMath.minUnsigned(a, b)); + } + + @Test(dataProvider = "intBinaryOpProvider") + static void UMINInt256VectorTests(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Int256VectorTests::UMIN); + } + + @Test(dataProvider = "intBinaryOpMaskProvider") + static void UMINInt256VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Int256VectorTests::UMIN); + } + + static int UMAX(int a, int b) { + return (int)(VectorMath.maxUnsigned(a, b)); + } + + @Test(dataProvider = "intBinaryOpProvider") + static void UMAXInt256VectorTests(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Int256VectorTests::UMAX); + } + + @Test(dataProvider = "intBinaryOpMaskProvider") + static void UMAXInt256VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Int256VectorTests::UMAX); + } + + static int SADD(int a, int b) { + return (int)(VectorMath.addSaturating(a, b)); + } + + @Test(dataProvider = "intSaturatingBinaryOpProvider") + static void SADDInt256VectorTests(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Int256VectorTests::SADD); + } + + @Test(dataProvider = "intSaturatingBinaryOpMaskProvider") + static void SADDInt256VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Int256VectorTests::SADD); + } + + static int SSUB(int a, int b) { + return (int)(VectorMath.subSaturating(a, b)); + } + + @Test(dataProvider = "intSaturatingBinaryOpProvider") + static void SSUBInt256VectorTests(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Int256VectorTests::SSUB); + } + + @Test(dataProvider = "intSaturatingBinaryOpMaskProvider") + static void SSUBInt256VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Int256VectorTests::SSUB); + } + + static int SUADD(int a, int b) { + return (int)(VectorMath.addSaturatingUnsigned(a, b)); + } + + @Test(dataProvider = "intSaturatingBinaryOpProvider") + static void SUADDInt256VectorTests(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Int256VectorTests::SUADD); + } + + @Test(dataProvider = "intSaturatingBinaryOpMaskProvider") + static void SUADDInt256VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Int256VectorTests::SUADD); + } + + static int SUSUB(int a, int b) { + return (int)(VectorMath.subSaturatingUnsigned(a, b)); + } + + @Test(dataProvider = "intSaturatingBinaryOpProvider") + static void SUSUBInt256VectorTests(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Int256VectorTests::SUSUB); + } + + @Test(dataProvider = "intSaturatingBinaryOpMaskProvider") + static void SUSUBInt256VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Int256VectorTests::SUSUB); + } + @Test(dataProvider = "intBinaryOpProvider") static void MINInt256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); @@ -4191,7 +4485,7 @@ static void GEInt256VectorTestsMasked(IntFunction fa, IntFunction } @Test(dataProvider = "intCompareOpProvider") - static void UNSIGNED_LTInt256VectorTests(IntFunction fa, IntFunction fb) { + static void ULTInt256VectorTests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -4199,7 +4493,7 @@ static void UNSIGNED_LTInt256VectorTests(IntFunction fa, IntFunction mv = av.compare(VectorOperators.UNSIGNED_LT, bv); + VectorMask mv = av.compare(VectorOperators.ULT, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4210,7 +4504,7 @@ static void UNSIGNED_LTInt256VectorTests(IntFunction fa, IntFunction fa, IntFunction fb, + static void ULTInt256VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -4222,7 +4516,7 @@ static void UNSIGNED_LTInt256VectorTestsMasked(IntFunction fa, IntFunctio for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); IntVector bv = IntVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_LT, bv, vmask); + VectorMask mv = av.compare(VectorOperators.ULT, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4233,7 +4527,7 @@ static void UNSIGNED_LTInt256VectorTestsMasked(IntFunction fa, IntFunctio } @Test(dataProvider = "intCompareOpProvider") - static void UNSIGNED_GTInt256VectorTests(IntFunction fa, IntFunction fb) { + static void UGTInt256VectorTests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -4241,7 +4535,7 @@ static void UNSIGNED_GTInt256VectorTests(IntFunction fa, IntFunction mv = av.compare(VectorOperators.UNSIGNED_GT, bv); + VectorMask mv = av.compare(VectorOperators.UGT, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4252,7 +4546,7 @@ static void UNSIGNED_GTInt256VectorTests(IntFunction fa, IntFunction fa, IntFunction fb, + static void UGTInt256VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -4264,7 +4558,7 @@ static void UNSIGNED_GTInt256VectorTestsMasked(IntFunction fa, IntFunctio for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); IntVector bv = IntVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_GT, bv, vmask); + VectorMask mv = av.compare(VectorOperators.UGT, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4275,7 +4569,7 @@ static void UNSIGNED_GTInt256VectorTestsMasked(IntFunction fa, IntFunctio } @Test(dataProvider = "intCompareOpProvider") - static void UNSIGNED_LEInt256VectorTests(IntFunction fa, IntFunction fb) { + static void ULEInt256VectorTests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -4283,7 +4577,7 @@ static void UNSIGNED_LEInt256VectorTests(IntFunction fa, IntFunction mv = av.compare(VectorOperators.UNSIGNED_LE, bv); + VectorMask mv = av.compare(VectorOperators.ULE, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4294,7 +4588,7 @@ static void UNSIGNED_LEInt256VectorTests(IntFunction fa, IntFunction fa, IntFunction fb, + static void ULEInt256VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -4306,7 +4600,7 @@ static void UNSIGNED_LEInt256VectorTestsMasked(IntFunction fa, IntFunctio for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); IntVector bv = IntVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_LE, bv, vmask); + VectorMask mv = av.compare(VectorOperators.ULE, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4317,7 +4611,7 @@ static void UNSIGNED_LEInt256VectorTestsMasked(IntFunction fa, IntFunctio } @Test(dataProvider = "intCompareOpProvider") - static void UNSIGNED_GEInt256VectorTests(IntFunction fa, IntFunction fb) { + static void UGEInt256VectorTests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -4325,7 +4619,7 @@ static void UNSIGNED_GEInt256VectorTests(IntFunction fa, IntFunction mv = av.compare(VectorOperators.UNSIGNED_GE, bv); + VectorMask mv = av.compare(VectorOperators.UGE, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4336,7 +4630,7 @@ static void UNSIGNED_GEInt256VectorTests(IntFunction fa, IntFunction fa, IntFunction fb, + static void UGEInt256VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -4348,7 +4642,7 @@ static void UNSIGNED_GEInt256VectorTestsMasked(IntFunction fa, IntFunctio for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); IntVector bv = IntVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_GE, bv, vmask); + VectorMask mv = av.compare(VectorOperators.UGE, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { diff --git a/test/jdk/jdk/incubator/vector/Int512VectorTests.java b/test/jdk/jdk/incubator/vector/Int512VectorTests.java index e6d1aa68f56..0c86655ff22 100644 --- a/test/jdk/jdk/incubator/vector/Int512VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Int512VectorTests.java @@ -38,6 +38,7 @@ import jdk.incubator.vector.VectorMask; import jdk.incubator.vector.VectorOperators; import jdk.incubator.vector.Vector; +import jdk.incubator.vector.VectorMath; import jdk.incubator.vector.IntVector; @@ -952,6 +953,33 @@ static int bits(int e) { }) ); + static final List> INT_SATURATING_GENERATORS = List.of( + withToString("int[Integer.MIN_VALUE]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (int)(Integer.MIN_VALUE)); + }), + withToString("int[Integer.MAX_VALUE]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (int)(Integer.MAX_VALUE)); + }), + withToString("int[Integer.MAX_VALUE - 100]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (int)(Integer.MAX_VALUE - 100)); + }), + withToString("int[Integer.MIN_VALUE + 100]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (int)(Integer.MIN_VALUE + 100)); + }), + withToString("int[-i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (int)(-i * 5)); + }), + withToString("int[i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (int)(i * 5)); + }) + ); + // Create combinations of pairs // @@@ Might be sensitive to order e.g. div by 0 static final List>> INT_GENERATOR_PAIRS = @@ -959,6 +987,11 @@ static int bits(int e) { flatMap(fa -> INT_GENERATORS.stream().skip(1).map(fb -> List.of(fa, fb))). collect(Collectors.toList()); + static final List>> INT_SATURATING_GENERATOR_PAIRS = + Stream.of(INT_GENERATORS.get(0)). + flatMap(fa -> INT_SATURATING_GENERATORS.stream().skip(1).map(fb -> List.of(fa, fb))). + collect(Collectors.toList()); + @DataProvider public Object[][] boolUnaryOpProvider() { return BOOL_ARRAY_GENERATORS.stream(). @@ -989,12 +1022,27 @@ public Object[][] intBinaryOpProvider() { toArray(Object[][]::new); } + @DataProvider + public Object[][] intSaturatingBinaryOpProvider() { + return INT_SATURATING_GENERATOR_PAIRS.stream().map(List::toArray). + toArray(Object[][]::new); + } + @DataProvider public Object[][] intIndexedOpProvider() { return INT_GENERATOR_PAIRS.stream().map(List::toArray). toArray(Object[][]::new); } + @DataProvider + public Object[][] intSaturatingBinaryOpMaskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> INT_SATURATING_GENERATOR_PAIRS.stream().map(lfa -> { + return Stream.concat(lfa.stream(), Stream.of(fm)).toArray(); + })). + toArray(Object[][]::new); + } + @DataProvider public Object[][] intBinaryOpMaskProvider() { return BOOLEAN_MASK_GENERATORS.stream(). @@ -2983,6 +3031,252 @@ static void maxInt512VectorTests(IntFunction fa, IntFunction fb) { assertArraysEquals(r, a, b, Int512VectorTests::max); } + static int UMIN(int a, int b) { + return (int)(VectorMath.minUnsigned(a, b)); + } + + @Test(dataProvider = "intBinaryOpProvider") + static void UMINInt512VectorTests(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Int512VectorTests::UMIN); + } + + @Test(dataProvider = "intBinaryOpMaskProvider") + static void UMINInt512VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Int512VectorTests::UMIN); + } + + static int UMAX(int a, int b) { + return (int)(VectorMath.maxUnsigned(a, b)); + } + + @Test(dataProvider = "intBinaryOpProvider") + static void UMAXInt512VectorTests(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Int512VectorTests::UMAX); + } + + @Test(dataProvider = "intBinaryOpMaskProvider") + static void UMAXInt512VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Int512VectorTests::UMAX); + } + + static int SADD(int a, int b) { + return (int)(VectorMath.addSaturating(a, b)); + } + + @Test(dataProvider = "intSaturatingBinaryOpProvider") + static void SADDInt512VectorTests(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Int512VectorTests::SADD); + } + + @Test(dataProvider = "intSaturatingBinaryOpMaskProvider") + static void SADDInt512VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Int512VectorTests::SADD); + } + + static int SSUB(int a, int b) { + return (int)(VectorMath.subSaturating(a, b)); + } + + @Test(dataProvider = "intSaturatingBinaryOpProvider") + static void SSUBInt512VectorTests(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Int512VectorTests::SSUB); + } + + @Test(dataProvider = "intSaturatingBinaryOpMaskProvider") + static void SSUBInt512VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Int512VectorTests::SSUB); + } + + static int SUADD(int a, int b) { + return (int)(VectorMath.addSaturatingUnsigned(a, b)); + } + + @Test(dataProvider = "intSaturatingBinaryOpProvider") + static void SUADDInt512VectorTests(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Int512VectorTests::SUADD); + } + + @Test(dataProvider = "intSaturatingBinaryOpMaskProvider") + static void SUADDInt512VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Int512VectorTests::SUADD); + } + + static int SUSUB(int a, int b) { + return (int)(VectorMath.subSaturatingUnsigned(a, b)); + } + + @Test(dataProvider = "intSaturatingBinaryOpProvider") + static void SUSUBInt512VectorTests(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Int512VectorTests::SUSUB); + } + + @Test(dataProvider = "intSaturatingBinaryOpMaskProvider") + static void SUSUBInt512VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Int512VectorTests::SUSUB); + } + @Test(dataProvider = "intBinaryOpProvider") static void MINInt512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); @@ -4191,7 +4485,7 @@ static void GEInt512VectorTestsMasked(IntFunction fa, IntFunction } @Test(dataProvider = "intCompareOpProvider") - static void UNSIGNED_LTInt512VectorTests(IntFunction fa, IntFunction fb) { + static void ULTInt512VectorTests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -4199,7 +4493,7 @@ static void UNSIGNED_LTInt512VectorTests(IntFunction fa, IntFunction mv = av.compare(VectorOperators.UNSIGNED_LT, bv); + VectorMask mv = av.compare(VectorOperators.ULT, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4210,7 +4504,7 @@ static void UNSIGNED_LTInt512VectorTests(IntFunction fa, IntFunction fa, IntFunction fb, + static void ULTInt512VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -4222,7 +4516,7 @@ static void UNSIGNED_LTInt512VectorTestsMasked(IntFunction fa, IntFunctio for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); IntVector bv = IntVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_LT, bv, vmask); + VectorMask mv = av.compare(VectorOperators.ULT, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4233,7 +4527,7 @@ static void UNSIGNED_LTInt512VectorTestsMasked(IntFunction fa, IntFunctio } @Test(dataProvider = "intCompareOpProvider") - static void UNSIGNED_GTInt512VectorTests(IntFunction fa, IntFunction fb) { + static void UGTInt512VectorTests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -4241,7 +4535,7 @@ static void UNSIGNED_GTInt512VectorTests(IntFunction fa, IntFunction mv = av.compare(VectorOperators.UNSIGNED_GT, bv); + VectorMask mv = av.compare(VectorOperators.UGT, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4252,7 +4546,7 @@ static void UNSIGNED_GTInt512VectorTests(IntFunction fa, IntFunction fa, IntFunction fb, + static void UGTInt512VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -4264,7 +4558,7 @@ static void UNSIGNED_GTInt512VectorTestsMasked(IntFunction fa, IntFunctio for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); IntVector bv = IntVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_GT, bv, vmask); + VectorMask mv = av.compare(VectorOperators.UGT, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4275,7 +4569,7 @@ static void UNSIGNED_GTInt512VectorTestsMasked(IntFunction fa, IntFunctio } @Test(dataProvider = "intCompareOpProvider") - static void UNSIGNED_LEInt512VectorTests(IntFunction fa, IntFunction fb) { + static void ULEInt512VectorTests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -4283,7 +4577,7 @@ static void UNSIGNED_LEInt512VectorTests(IntFunction fa, IntFunction mv = av.compare(VectorOperators.UNSIGNED_LE, bv); + VectorMask mv = av.compare(VectorOperators.ULE, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4294,7 +4588,7 @@ static void UNSIGNED_LEInt512VectorTests(IntFunction fa, IntFunction fa, IntFunction fb, + static void ULEInt512VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -4306,7 +4600,7 @@ static void UNSIGNED_LEInt512VectorTestsMasked(IntFunction fa, IntFunctio for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); IntVector bv = IntVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_LE, bv, vmask); + VectorMask mv = av.compare(VectorOperators.ULE, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4317,7 +4611,7 @@ static void UNSIGNED_LEInt512VectorTestsMasked(IntFunction fa, IntFunctio } @Test(dataProvider = "intCompareOpProvider") - static void UNSIGNED_GEInt512VectorTests(IntFunction fa, IntFunction fb) { + static void UGEInt512VectorTests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -4325,7 +4619,7 @@ static void UNSIGNED_GEInt512VectorTests(IntFunction fa, IntFunction mv = av.compare(VectorOperators.UNSIGNED_GE, bv); + VectorMask mv = av.compare(VectorOperators.UGE, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4336,7 +4630,7 @@ static void UNSIGNED_GEInt512VectorTests(IntFunction fa, IntFunction fa, IntFunction fb, + static void UGEInt512VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -4348,7 +4642,7 @@ static void UNSIGNED_GEInt512VectorTestsMasked(IntFunction fa, IntFunctio for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); IntVector bv = IntVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_GE, bv, vmask); + VectorMask mv = av.compare(VectorOperators.UGE, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { diff --git a/test/jdk/jdk/incubator/vector/Int64VectorTests.java b/test/jdk/jdk/incubator/vector/Int64VectorTests.java index 4435d31cd04..b2cb3698f62 100644 --- a/test/jdk/jdk/incubator/vector/Int64VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Int64VectorTests.java @@ -38,6 +38,7 @@ import jdk.incubator.vector.VectorMask; import jdk.incubator.vector.VectorOperators; import jdk.incubator.vector.Vector; +import jdk.incubator.vector.VectorMath; import jdk.incubator.vector.IntVector; @@ -952,6 +953,33 @@ static int bits(int e) { }) ); + static final List> INT_SATURATING_GENERATORS = List.of( + withToString("int[Integer.MIN_VALUE]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (int)(Integer.MIN_VALUE)); + }), + withToString("int[Integer.MAX_VALUE]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (int)(Integer.MAX_VALUE)); + }), + withToString("int[Integer.MAX_VALUE - 100]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (int)(Integer.MAX_VALUE - 100)); + }), + withToString("int[Integer.MIN_VALUE + 100]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (int)(Integer.MIN_VALUE + 100)); + }), + withToString("int[-i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (int)(-i * 5)); + }), + withToString("int[i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (int)(i * 5)); + }) + ); + // Create combinations of pairs // @@@ Might be sensitive to order e.g. div by 0 static final List>> INT_GENERATOR_PAIRS = @@ -959,6 +987,11 @@ static int bits(int e) { flatMap(fa -> INT_GENERATORS.stream().skip(1).map(fb -> List.of(fa, fb))). collect(Collectors.toList()); + static final List>> INT_SATURATING_GENERATOR_PAIRS = + Stream.of(INT_GENERATORS.get(0)). + flatMap(fa -> INT_SATURATING_GENERATORS.stream().skip(1).map(fb -> List.of(fa, fb))). + collect(Collectors.toList()); + @DataProvider public Object[][] boolUnaryOpProvider() { return BOOL_ARRAY_GENERATORS.stream(). @@ -989,12 +1022,27 @@ public Object[][] intBinaryOpProvider() { toArray(Object[][]::new); } + @DataProvider + public Object[][] intSaturatingBinaryOpProvider() { + return INT_SATURATING_GENERATOR_PAIRS.stream().map(List::toArray). + toArray(Object[][]::new); + } + @DataProvider public Object[][] intIndexedOpProvider() { return INT_GENERATOR_PAIRS.stream().map(List::toArray). toArray(Object[][]::new); } + @DataProvider + public Object[][] intSaturatingBinaryOpMaskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> INT_SATURATING_GENERATOR_PAIRS.stream().map(lfa -> { + return Stream.concat(lfa.stream(), Stream.of(fm)).toArray(); + })). + toArray(Object[][]::new); + } + @DataProvider public Object[][] intBinaryOpMaskProvider() { return BOOLEAN_MASK_GENERATORS.stream(). @@ -2983,6 +3031,252 @@ static void maxInt64VectorTests(IntFunction fa, IntFunction fb) { assertArraysEquals(r, a, b, Int64VectorTests::max); } + static int UMIN(int a, int b) { + return (int)(VectorMath.minUnsigned(a, b)); + } + + @Test(dataProvider = "intBinaryOpProvider") + static void UMINInt64VectorTests(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Int64VectorTests::UMIN); + } + + @Test(dataProvider = "intBinaryOpMaskProvider") + static void UMINInt64VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Int64VectorTests::UMIN); + } + + static int UMAX(int a, int b) { + return (int)(VectorMath.maxUnsigned(a, b)); + } + + @Test(dataProvider = "intBinaryOpProvider") + static void UMAXInt64VectorTests(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Int64VectorTests::UMAX); + } + + @Test(dataProvider = "intBinaryOpMaskProvider") + static void UMAXInt64VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Int64VectorTests::UMAX); + } + + static int SADD(int a, int b) { + return (int)(VectorMath.addSaturating(a, b)); + } + + @Test(dataProvider = "intSaturatingBinaryOpProvider") + static void SADDInt64VectorTests(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Int64VectorTests::SADD); + } + + @Test(dataProvider = "intSaturatingBinaryOpMaskProvider") + static void SADDInt64VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Int64VectorTests::SADD); + } + + static int SSUB(int a, int b) { + return (int)(VectorMath.subSaturating(a, b)); + } + + @Test(dataProvider = "intSaturatingBinaryOpProvider") + static void SSUBInt64VectorTests(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Int64VectorTests::SSUB); + } + + @Test(dataProvider = "intSaturatingBinaryOpMaskProvider") + static void SSUBInt64VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Int64VectorTests::SSUB); + } + + static int SUADD(int a, int b) { + return (int)(VectorMath.addSaturatingUnsigned(a, b)); + } + + @Test(dataProvider = "intSaturatingBinaryOpProvider") + static void SUADDInt64VectorTests(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Int64VectorTests::SUADD); + } + + @Test(dataProvider = "intSaturatingBinaryOpMaskProvider") + static void SUADDInt64VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Int64VectorTests::SUADD); + } + + static int SUSUB(int a, int b) { + return (int)(VectorMath.subSaturatingUnsigned(a, b)); + } + + @Test(dataProvider = "intSaturatingBinaryOpProvider") + static void SUSUBInt64VectorTests(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Int64VectorTests::SUSUB); + } + + @Test(dataProvider = "intSaturatingBinaryOpMaskProvider") + static void SUSUBInt64VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Int64VectorTests::SUSUB); + } + @Test(dataProvider = "intBinaryOpProvider") static void MINInt64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); @@ -4191,7 +4485,7 @@ static void GEInt64VectorTestsMasked(IntFunction fa, IntFunction f } @Test(dataProvider = "intCompareOpProvider") - static void UNSIGNED_LTInt64VectorTests(IntFunction fa, IntFunction fb) { + static void ULTInt64VectorTests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -4199,7 +4493,7 @@ static void UNSIGNED_LTInt64VectorTests(IntFunction fa, IntFunction mv = av.compare(VectorOperators.UNSIGNED_LT, bv); + VectorMask mv = av.compare(VectorOperators.ULT, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4210,7 +4504,7 @@ static void UNSIGNED_LTInt64VectorTests(IntFunction fa, IntFunction fa, IntFunction fb, + static void ULTInt64VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -4222,7 +4516,7 @@ static void UNSIGNED_LTInt64VectorTestsMasked(IntFunction fa, IntFunction for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); IntVector bv = IntVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_LT, bv, vmask); + VectorMask mv = av.compare(VectorOperators.ULT, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4233,7 +4527,7 @@ static void UNSIGNED_LTInt64VectorTestsMasked(IntFunction fa, IntFunction } @Test(dataProvider = "intCompareOpProvider") - static void UNSIGNED_GTInt64VectorTests(IntFunction fa, IntFunction fb) { + static void UGTInt64VectorTests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -4241,7 +4535,7 @@ static void UNSIGNED_GTInt64VectorTests(IntFunction fa, IntFunction mv = av.compare(VectorOperators.UNSIGNED_GT, bv); + VectorMask mv = av.compare(VectorOperators.UGT, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4252,7 +4546,7 @@ static void UNSIGNED_GTInt64VectorTests(IntFunction fa, IntFunction fa, IntFunction fb, + static void UGTInt64VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -4264,7 +4558,7 @@ static void UNSIGNED_GTInt64VectorTestsMasked(IntFunction fa, IntFunction for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); IntVector bv = IntVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_GT, bv, vmask); + VectorMask mv = av.compare(VectorOperators.UGT, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4275,7 +4569,7 @@ static void UNSIGNED_GTInt64VectorTestsMasked(IntFunction fa, IntFunction } @Test(dataProvider = "intCompareOpProvider") - static void UNSIGNED_LEInt64VectorTests(IntFunction fa, IntFunction fb) { + static void ULEInt64VectorTests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -4283,7 +4577,7 @@ static void UNSIGNED_LEInt64VectorTests(IntFunction fa, IntFunction mv = av.compare(VectorOperators.UNSIGNED_LE, bv); + VectorMask mv = av.compare(VectorOperators.ULE, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4294,7 +4588,7 @@ static void UNSIGNED_LEInt64VectorTests(IntFunction fa, IntFunction fa, IntFunction fb, + static void ULEInt64VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -4306,7 +4600,7 @@ static void UNSIGNED_LEInt64VectorTestsMasked(IntFunction fa, IntFunction for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); IntVector bv = IntVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_LE, bv, vmask); + VectorMask mv = av.compare(VectorOperators.ULE, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4317,7 +4611,7 @@ static void UNSIGNED_LEInt64VectorTestsMasked(IntFunction fa, IntFunction } @Test(dataProvider = "intCompareOpProvider") - static void UNSIGNED_GEInt64VectorTests(IntFunction fa, IntFunction fb) { + static void UGEInt64VectorTests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -4325,7 +4619,7 @@ static void UNSIGNED_GEInt64VectorTests(IntFunction fa, IntFunction mv = av.compare(VectorOperators.UNSIGNED_GE, bv); + VectorMask mv = av.compare(VectorOperators.UGE, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4336,7 +4630,7 @@ static void UNSIGNED_GEInt64VectorTests(IntFunction fa, IntFunction fa, IntFunction fb, + static void UGEInt64VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -4348,7 +4642,7 @@ static void UNSIGNED_GEInt64VectorTestsMasked(IntFunction fa, IntFunction for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); IntVector bv = IntVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_GE, bv, vmask); + VectorMask mv = av.compare(VectorOperators.UGE, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { diff --git a/test/jdk/jdk/incubator/vector/IntMaxVectorTests.java b/test/jdk/jdk/incubator/vector/IntMaxVectorTests.java index 94dce66d951..fc0f6c1c139 100644 --- a/test/jdk/jdk/incubator/vector/IntMaxVectorTests.java +++ b/test/jdk/jdk/incubator/vector/IntMaxVectorTests.java @@ -38,6 +38,7 @@ import jdk.incubator.vector.VectorMask; import jdk.incubator.vector.VectorOperators; import jdk.incubator.vector.Vector; +import jdk.incubator.vector.VectorMath; import jdk.incubator.vector.IntVector; @@ -957,6 +958,33 @@ static int bits(int e) { }) ); + static final List> INT_SATURATING_GENERATORS = List.of( + withToString("int[Integer.MIN_VALUE]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (int)(Integer.MIN_VALUE)); + }), + withToString("int[Integer.MAX_VALUE]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (int)(Integer.MAX_VALUE)); + }), + withToString("int[Integer.MAX_VALUE - 100]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (int)(Integer.MAX_VALUE - 100)); + }), + withToString("int[Integer.MIN_VALUE + 100]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (int)(Integer.MIN_VALUE + 100)); + }), + withToString("int[-i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (int)(-i * 5)); + }), + withToString("int[i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (int)(i * 5)); + }) + ); + // Create combinations of pairs // @@@ Might be sensitive to order e.g. div by 0 static final List>> INT_GENERATOR_PAIRS = @@ -964,6 +992,11 @@ static int bits(int e) { flatMap(fa -> INT_GENERATORS.stream().skip(1).map(fb -> List.of(fa, fb))). collect(Collectors.toList()); + static final List>> INT_SATURATING_GENERATOR_PAIRS = + Stream.of(INT_GENERATORS.get(0)). + flatMap(fa -> INT_SATURATING_GENERATORS.stream().skip(1).map(fb -> List.of(fa, fb))). + collect(Collectors.toList()); + @DataProvider public Object[][] boolUnaryOpProvider() { return BOOL_ARRAY_GENERATORS.stream(). @@ -994,12 +1027,27 @@ public Object[][] intBinaryOpProvider() { toArray(Object[][]::new); } + @DataProvider + public Object[][] intSaturatingBinaryOpProvider() { + return INT_SATURATING_GENERATOR_PAIRS.stream().map(List::toArray). + toArray(Object[][]::new); + } + @DataProvider public Object[][] intIndexedOpProvider() { return INT_GENERATOR_PAIRS.stream().map(List::toArray). toArray(Object[][]::new); } + @DataProvider + public Object[][] intSaturatingBinaryOpMaskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> INT_SATURATING_GENERATOR_PAIRS.stream().map(lfa -> { + return Stream.concat(lfa.stream(), Stream.of(fm)).toArray(); + })). + toArray(Object[][]::new); + } + @DataProvider public Object[][] intBinaryOpMaskProvider() { return BOOLEAN_MASK_GENERATORS.stream(). @@ -2988,6 +3036,252 @@ static void maxIntMaxVectorTests(IntFunction fa, IntFunction fb) { assertArraysEquals(r, a, b, IntMaxVectorTests::max); } + static int UMIN(int a, int b) { + return (int)(VectorMath.minUnsigned(a, b)); + } + + @Test(dataProvider = "intBinaryOpProvider") + static void UMINIntMaxVectorTests(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, IntMaxVectorTests::UMIN); + } + + @Test(dataProvider = "intBinaryOpMaskProvider") + static void UMINIntMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, IntMaxVectorTests::UMIN); + } + + static int UMAX(int a, int b) { + return (int)(VectorMath.maxUnsigned(a, b)); + } + + @Test(dataProvider = "intBinaryOpProvider") + static void UMAXIntMaxVectorTests(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, IntMaxVectorTests::UMAX); + } + + @Test(dataProvider = "intBinaryOpMaskProvider") + static void UMAXIntMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, IntMaxVectorTests::UMAX); + } + + static int SADD(int a, int b) { + return (int)(VectorMath.addSaturating(a, b)); + } + + @Test(dataProvider = "intSaturatingBinaryOpProvider") + static void SADDIntMaxVectorTests(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, IntMaxVectorTests::SADD); + } + + @Test(dataProvider = "intSaturatingBinaryOpMaskProvider") + static void SADDIntMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, IntMaxVectorTests::SADD); + } + + static int SSUB(int a, int b) { + return (int)(VectorMath.subSaturating(a, b)); + } + + @Test(dataProvider = "intSaturatingBinaryOpProvider") + static void SSUBIntMaxVectorTests(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, IntMaxVectorTests::SSUB); + } + + @Test(dataProvider = "intSaturatingBinaryOpMaskProvider") + static void SSUBIntMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, IntMaxVectorTests::SSUB); + } + + static int SUADD(int a, int b) { + return (int)(VectorMath.addSaturatingUnsigned(a, b)); + } + + @Test(dataProvider = "intSaturatingBinaryOpProvider") + static void SUADDIntMaxVectorTests(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, IntMaxVectorTests::SUADD); + } + + @Test(dataProvider = "intSaturatingBinaryOpMaskProvider") + static void SUADDIntMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, IntMaxVectorTests::SUADD); + } + + static int SUSUB(int a, int b) { + return (int)(VectorMath.subSaturatingUnsigned(a, b)); + } + + @Test(dataProvider = "intSaturatingBinaryOpProvider") + static void SUSUBIntMaxVectorTests(IntFunction fa, IntFunction fb) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, IntMaxVectorTests::SUSUB); + } + + @Test(dataProvider = "intSaturatingBinaryOpMaskProvider") + static void SUSUBIntMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + int[] a = fa.apply(SPECIES.length()); + int[] b = fb.apply(SPECIES.length()); + int[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + IntVector av = IntVector.fromArray(SPECIES, a, i); + IntVector bv = IntVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, IntMaxVectorTests::SUSUB); + } + @Test(dataProvider = "intBinaryOpProvider") static void MINIntMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); @@ -4196,7 +4490,7 @@ static void GEIntMaxVectorTestsMasked(IntFunction fa, IntFunction } @Test(dataProvider = "intCompareOpProvider") - static void UNSIGNED_LTIntMaxVectorTests(IntFunction fa, IntFunction fb) { + static void ULTIntMaxVectorTests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -4204,7 +4498,7 @@ static void UNSIGNED_LTIntMaxVectorTests(IntFunction fa, IntFunction mv = av.compare(VectorOperators.UNSIGNED_LT, bv); + VectorMask mv = av.compare(VectorOperators.ULT, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4215,7 +4509,7 @@ static void UNSIGNED_LTIntMaxVectorTests(IntFunction fa, IntFunction fa, IntFunction fb, + static void ULTIntMaxVectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -4227,7 +4521,7 @@ static void UNSIGNED_LTIntMaxVectorTestsMasked(IntFunction fa, IntFunctio for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); IntVector bv = IntVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_LT, bv, vmask); + VectorMask mv = av.compare(VectorOperators.ULT, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4238,7 +4532,7 @@ static void UNSIGNED_LTIntMaxVectorTestsMasked(IntFunction fa, IntFunctio } @Test(dataProvider = "intCompareOpProvider") - static void UNSIGNED_GTIntMaxVectorTests(IntFunction fa, IntFunction fb) { + static void UGTIntMaxVectorTests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -4246,7 +4540,7 @@ static void UNSIGNED_GTIntMaxVectorTests(IntFunction fa, IntFunction mv = av.compare(VectorOperators.UNSIGNED_GT, bv); + VectorMask mv = av.compare(VectorOperators.UGT, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4257,7 +4551,7 @@ static void UNSIGNED_GTIntMaxVectorTests(IntFunction fa, IntFunction fa, IntFunction fb, + static void UGTIntMaxVectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -4269,7 +4563,7 @@ static void UNSIGNED_GTIntMaxVectorTestsMasked(IntFunction fa, IntFunctio for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); IntVector bv = IntVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_GT, bv, vmask); + VectorMask mv = av.compare(VectorOperators.UGT, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4280,7 +4574,7 @@ static void UNSIGNED_GTIntMaxVectorTestsMasked(IntFunction fa, IntFunctio } @Test(dataProvider = "intCompareOpProvider") - static void UNSIGNED_LEIntMaxVectorTests(IntFunction fa, IntFunction fb) { + static void ULEIntMaxVectorTests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -4288,7 +4582,7 @@ static void UNSIGNED_LEIntMaxVectorTests(IntFunction fa, IntFunction mv = av.compare(VectorOperators.UNSIGNED_LE, bv); + VectorMask mv = av.compare(VectorOperators.ULE, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4299,7 +4593,7 @@ static void UNSIGNED_LEIntMaxVectorTests(IntFunction fa, IntFunction fa, IntFunction fb, + static void ULEIntMaxVectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -4311,7 +4605,7 @@ static void UNSIGNED_LEIntMaxVectorTestsMasked(IntFunction fa, IntFunctio for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); IntVector bv = IntVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_LE, bv, vmask); + VectorMask mv = av.compare(VectorOperators.ULE, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4322,7 +4616,7 @@ static void UNSIGNED_LEIntMaxVectorTestsMasked(IntFunction fa, IntFunctio } @Test(dataProvider = "intCompareOpProvider") - static void UNSIGNED_GEIntMaxVectorTests(IntFunction fa, IntFunction fb) { + static void UGEIntMaxVectorTests(IntFunction fa, IntFunction fb) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -4330,7 +4624,7 @@ static void UNSIGNED_GEIntMaxVectorTests(IntFunction fa, IntFunction mv = av.compare(VectorOperators.UNSIGNED_GE, bv); + VectorMask mv = av.compare(VectorOperators.UGE, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4341,7 +4635,7 @@ static void UNSIGNED_GEIntMaxVectorTests(IntFunction fa, IntFunction fa, IntFunction fb, + static void UGEIntMaxVectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { int[] a = fa.apply(SPECIES.length()); int[] b = fb.apply(SPECIES.length()); @@ -4353,7 +4647,7 @@ static void UNSIGNED_GEIntMaxVectorTestsMasked(IntFunction fa, IntFunctio for (int i = 0; i < a.length; i += SPECIES.length()) { IntVector av = IntVector.fromArray(SPECIES, a, i); IntVector bv = IntVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_GE, bv, vmask); + VectorMask mv = av.compare(VectorOperators.UGE, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { diff --git a/test/jdk/jdk/incubator/vector/Long128VectorTests.java b/test/jdk/jdk/incubator/vector/Long128VectorTests.java index 7e6bf6b7b81..3694128877a 100644 --- a/test/jdk/jdk/incubator/vector/Long128VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Long128VectorTests.java @@ -38,6 +38,7 @@ import jdk.incubator.vector.VectorMask; import jdk.incubator.vector.VectorOperators; import jdk.incubator.vector.Vector; +import jdk.incubator.vector.VectorMath; import jdk.incubator.vector.LongVector; @@ -942,6 +943,33 @@ static long bits(long e) { }) ); + static final List> LONG_SATURATING_GENERATORS = List.of( + withToString("long[Long.MIN_VALUE]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (long)(Long.MIN_VALUE)); + }), + withToString("long[Long.MAX_VALUE]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (long)(Long.MAX_VALUE)); + }), + withToString("long[Long.MAX_VALUE - 100]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (long)(Long.MAX_VALUE - 100)); + }), + withToString("long[Long.MIN_VALUE + 100]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (long)(Long.MIN_VALUE + 100)); + }), + withToString("long[-i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (long)(-i * 5)); + }), + withToString("long[i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (long)(i * 5)); + }) + ); + // Create combinations of pairs // @@@ Might be sensitive to order e.g. div by 0 static final List>> LONG_GENERATOR_PAIRS = @@ -949,6 +977,11 @@ static long bits(long e) { flatMap(fa -> LONG_GENERATORS.stream().skip(1).map(fb -> List.of(fa, fb))). collect(Collectors.toList()); + static final List>> LONG_SATURATING_GENERATOR_PAIRS = + Stream.of(LONG_GENERATORS.get(0)). + flatMap(fa -> LONG_SATURATING_GENERATORS.stream().skip(1).map(fb -> List.of(fa, fb))). + collect(Collectors.toList()); + @DataProvider public Object[][] boolUnaryOpProvider() { return BOOL_ARRAY_GENERATORS.stream(). @@ -979,12 +1012,27 @@ public Object[][] longBinaryOpProvider() { toArray(Object[][]::new); } + @DataProvider + public Object[][] longSaturatingBinaryOpProvider() { + return LONG_SATURATING_GENERATOR_PAIRS.stream().map(List::toArray). + toArray(Object[][]::new); + } + @DataProvider public Object[][] longIndexedOpProvider() { return LONG_GENERATOR_PAIRS.stream().map(List::toArray). toArray(Object[][]::new); } + @DataProvider + public Object[][] longSaturatingBinaryOpMaskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> LONG_SATURATING_GENERATOR_PAIRS.stream().map(lfa -> { + return Stream.concat(lfa.stream(), Stream.of(fm)).toArray(); + })). + toArray(Object[][]::new); + } + @DataProvider public Object[][] longBinaryOpMaskProvider() { return BOOLEAN_MASK_GENERATORS.stream(). @@ -3005,6 +3053,252 @@ static void maxLong128VectorTests(IntFunction fa, IntFunction fb assertArraysEquals(r, a, b, Long128VectorTests::max); } + static long UMIN(long a, long b) { + return (long)(VectorMath.minUnsigned(a, b)); + } + + @Test(dataProvider = "longBinaryOpProvider") + static void UMINLong128VectorTests(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Long128VectorTests::UMIN); + } + + @Test(dataProvider = "longBinaryOpMaskProvider") + static void UMINLong128VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Long128VectorTests::UMIN); + } + + static long UMAX(long a, long b) { + return (long)(VectorMath.maxUnsigned(a, b)); + } + + @Test(dataProvider = "longBinaryOpProvider") + static void UMAXLong128VectorTests(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Long128VectorTests::UMAX); + } + + @Test(dataProvider = "longBinaryOpMaskProvider") + static void UMAXLong128VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Long128VectorTests::UMAX); + } + + static long SADD(long a, long b) { + return (long)(VectorMath.addSaturating(a, b)); + } + + @Test(dataProvider = "longSaturatingBinaryOpProvider") + static void SADDLong128VectorTests(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Long128VectorTests::SADD); + } + + @Test(dataProvider = "longSaturatingBinaryOpMaskProvider") + static void SADDLong128VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Long128VectorTests::SADD); + } + + static long SSUB(long a, long b) { + return (long)(VectorMath.subSaturating(a, b)); + } + + @Test(dataProvider = "longSaturatingBinaryOpProvider") + static void SSUBLong128VectorTests(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Long128VectorTests::SSUB); + } + + @Test(dataProvider = "longSaturatingBinaryOpMaskProvider") + static void SSUBLong128VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Long128VectorTests::SSUB); + } + + static long SUADD(long a, long b) { + return (long)(VectorMath.addSaturatingUnsigned(a, b)); + } + + @Test(dataProvider = "longSaturatingBinaryOpProvider") + static void SUADDLong128VectorTests(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Long128VectorTests::SUADD); + } + + @Test(dataProvider = "longSaturatingBinaryOpMaskProvider") + static void SUADDLong128VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Long128VectorTests::SUADD); + } + + static long SUSUB(long a, long b) { + return (long)(VectorMath.subSaturatingUnsigned(a, b)); + } + + @Test(dataProvider = "longSaturatingBinaryOpProvider") + static void SUSUBLong128VectorTests(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Long128VectorTests::SUSUB); + } + + @Test(dataProvider = "longSaturatingBinaryOpMaskProvider") + static void SUSUBLong128VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Long128VectorTests::SUSUB); + } + @Test(dataProvider = "longBinaryOpProvider") static void MINLong128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); @@ -4213,7 +4507,7 @@ static void GELong128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) { + static void ULTLong128VectorTests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -4221,7 +4515,7 @@ static void UNSIGNED_LTLong128VectorTests(IntFunction fa, IntFunction mv = av.compare(VectorOperators.UNSIGNED_LT, bv); + VectorMask mv = av.compare(VectorOperators.ULT, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4232,7 +4526,7 @@ static void UNSIGNED_LTLong128VectorTests(IntFunction fa, IntFunction fa, IntFunction fb, + static void ULTLong128VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -4244,7 +4538,7 @@ static void UNSIGNED_LTLong128VectorTestsMasked(IntFunction fa, IntFunct for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); LongVector bv = LongVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_LT, bv, vmask); + VectorMask mv = av.compare(VectorOperators.ULT, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4255,7 +4549,7 @@ static void UNSIGNED_LTLong128VectorTestsMasked(IntFunction fa, IntFunct } @Test(dataProvider = "longCompareOpProvider") - static void UNSIGNED_GTLong128VectorTests(IntFunction fa, IntFunction fb) { + static void UGTLong128VectorTests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -4263,7 +4557,7 @@ static void UNSIGNED_GTLong128VectorTests(IntFunction fa, IntFunction mv = av.compare(VectorOperators.UNSIGNED_GT, bv); + VectorMask mv = av.compare(VectorOperators.UGT, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4274,7 +4568,7 @@ static void UNSIGNED_GTLong128VectorTests(IntFunction fa, IntFunction fa, IntFunction fb, + static void UGTLong128VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -4286,7 +4580,7 @@ static void UNSIGNED_GTLong128VectorTestsMasked(IntFunction fa, IntFunct for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); LongVector bv = LongVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_GT, bv, vmask); + VectorMask mv = av.compare(VectorOperators.UGT, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4297,7 +4591,7 @@ static void UNSIGNED_GTLong128VectorTestsMasked(IntFunction fa, IntFunct } @Test(dataProvider = "longCompareOpProvider") - static void UNSIGNED_LELong128VectorTests(IntFunction fa, IntFunction fb) { + static void ULELong128VectorTests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -4305,7 +4599,7 @@ static void UNSIGNED_LELong128VectorTests(IntFunction fa, IntFunction mv = av.compare(VectorOperators.UNSIGNED_LE, bv); + VectorMask mv = av.compare(VectorOperators.ULE, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4316,7 +4610,7 @@ static void UNSIGNED_LELong128VectorTests(IntFunction fa, IntFunction fa, IntFunction fb, + static void ULELong128VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -4328,7 +4622,7 @@ static void UNSIGNED_LELong128VectorTestsMasked(IntFunction fa, IntFunct for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); LongVector bv = LongVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_LE, bv, vmask); + VectorMask mv = av.compare(VectorOperators.ULE, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4339,7 +4633,7 @@ static void UNSIGNED_LELong128VectorTestsMasked(IntFunction fa, IntFunct } @Test(dataProvider = "longCompareOpProvider") - static void UNSIGNED_GELong128VectorTests(IntFunction fa, IntFunction fb) { + static void UGELong128VectorTests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -4347,7 +4641,7 @@ static void UNSIGNED_GELong128VectorTests(IntFunction fa, IntFunction mv = av.compare(VectorOperators.UNSIGNED_GE, bv); + VectorMask mv = av.compare(VectorOperators.UGE, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4358,7 +4652,7 @@ static void UNSIGNED_GELong128VectorTests(IntFunction fa, IntFunction fa, IntFunction fb, + static void UGELong128VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -4370,7 +4664,7 @@ static void UNSIGNED_GELong128VectorTestsMasked(IntFunction fa, IntFunct for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); LongVector bv = LongVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_GE, bv, vmask); + VectorMask mv = av.compare(VectorOperators.UGE, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { diff --git a/test/jdk/jdk/incubator/vector/Long256VectorTests.java b/test/jdk/jdk/incubator/vector/Long256VectorTests.java index 299b7007ba5..1fc441680fd 100644 --- a/test/jdk/jdk/incubator/vector/Long256VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Long256VectorTests.java @@ -38,6 +38,7 @@ import jdk.incubator.vector.VectorMask; import jdk.incubator.vector.VectorOperators; import jdk.incubator.vector.Vector; +import jdk.incubator.vector.VectorMath; import jdk.incubator.vector.LongVector; @@ -942,6 +943,33 @@ static long bits(long e) { }) ); + static final List> LONG_SATURATING_GENERATORS = List.of( + withToString("long[Long.MIN_VALUE]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (long)(Long.MIN_VALUE)); + }), + withToString("long[Long.MAX_VALUE]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (long)(Long.MAX_VALUE)); + }), + withToString("long[Long.MAX_VALUE - 100]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (long)(Long.MAX_VALUE - 100)); + }), + withToString("long[Long.MIN_VALUE + 100]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (long)(Long.MIN_VALUE + 100)); + }), + withToString("long[-i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (long)(-i * 5)); + }), + withToString("long[i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (long)(i * 5)); + }) + ); + // Create combinations of pairs // @@@ Might be sensitive to order e.g. div by 0 static final List>> LONG_GENERATOR_PAIRS = @@ -949,6 +977,11 @@ static long bits(long e) { flatMap(fa -> LONG_GENERATORS.stream().skip(1).map(fb -> List.of(fa, fb))). collect(Collectors.toList()); + static final List>> LONG_SATURATING_GENERATOR_PAIRS = + Stream.of(LONG_GENERATORS.get(0)). + flatMap(fa -> LONG_SATURATING_GENERATORS.stream().skip(1).map(fb -> List.of(fa, fb))). + collect(Collectors.toList()); + @DataProvider public Object[][] boolUnaryOpProvider() { return BOOL_ARRAY_GENERATORS.stream(). @@ -979,12 +1012,27 @@ public Object[][] longBinaryOpProvider() { toArray(Object[][]::new); } + @DataProvider + public Object[][] longSaturatingBinaryOpProvider() { + return LONG_SATURATING_GENERATOR_PAIRS.stream().map(List::toArray). + toArray(Object[][]::new); + } + @DataProvider public Object[][] longIndexedOpProvider() { return LONG_GENERATOR_PAIRS.stream().map(List::toArray). toArray(Object[][]::new); } + @DataProvider + public Object[][] longSaturatingBinaryOpMaskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> LONG_SATURATING_GENERATOR_PAIRS.stream().map(lfa -> { + return Stream.concat(lfa.stream(), Stream.of(fm)).toArray(); + })). + toArray(Object[][]::new); + } + @DataProvider public Object[][] longBinaryOpMaskProvider() { return BOOLEAN_MASK_GENERATORS.stream(). @@ -3005,6 +3053,252 @@ static void maxLong256VectorTests(IntFunction fa, IntFunction fb assertArraysEquals(r, a, b, Long256VectorTests::max); } + static long UMIN(long a, long b) { + return (long)(VectorMath.minUnsigned(a, b)); + } + + @Test(dataProvider = "longBinaryOpProvider") + static void UMINLong256VectorTests(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Long256VectorTests::UMIN); + } + + @Test(dataProvider = "longBinaryOpMaskProvider") + static void UMINLong256VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Long256VectorTests::UMIN); + } + + static long UMAX(long a, long b) { + return (long)(VectorMath.maxUnsigned(a, b)); + } + + @Test(dataProvider = "longBinaryOpProvider") + static void UMAXLong256VectorTests(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Long256VectorTests::UMAX); + } + + @Test(dataProvider = "longBinaryOpMaskProvider") + static void UMAXLong256VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Long256VectorTests::UMAX); + } + + static long SADD(long a, long b) { + return (long)(VectorMath.addSaturating(a, b)); + } + + @Test(dataProvider = "longSaturatingBinaryOpProvider") + static void SADDLong256VectorTests(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Long256VectorTests::SADD); + } + + @Test(dataProvider = "longSaturatingBinaryOpMaskProvider") + static void SADDLong256VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Long256VectorTests::SADD); + } + + static long SSUB(long a, long b) { + return (long)(VectorMath.subSaturating(a, b)); + } + + @Test(dataProvider = "longSaturatingBinaryOpProvider") + static void SSUBLong256VectorTests(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Long256VectorTests::SSUB); + } + + @Test(dataProvider = "longSaturatingBinaryOpMaskProvider") + static void SSUBLong256VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Long256VectorTests::SSUB); + } + + static long SUADD(long a, long b) { + return (long)(VectorMath.addSaturatingUnsigned(a, b)); + } + + @Test(dataProvider = "longSaturatingBinaryOpProvider") + static void SUADDLong256VectorTests(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Long256VectorTests::SUADD); + } + + @Test(dataProvider = "longSaturatingBinaryOpMaskProvider") + static void SUADDLong256VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Long256VectorTests::SUADD); + } + + static long SUSUB(long a, long b) { + return (long)(VectorMath.subSaturatingUnsigned(a, b)); + } + + @Test(dataProvider = "longSaturatingBinaryOpProvider") + static void SUSUBLong256VectorTests(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Long256VectorTests::SUSUB); + } + + @Test(dataProvider = "longSaturatingBinaryOpMaskProvider") + static void SUSUBLong256VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Long256VectorTests::SUSUB); + } + @Test(dataProvider = "longBinaryOpProvider") static void MINLong256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); @@ -4213,7 +4507,7 @@ static void GELong256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) { + static void ULTLong256VectorTests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -4221,7 +4515,7 @@ static void UNSIGNED_LTLong256VectorTests(IntFunction fa, IntFunction mv = av.compare(VectorOperators.UNSIGNED_LT, bv); + VectorMask mv = av.compare(VectorOperators.ULT, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4232,7 +4526,7 @@ static void UNSIGNED_LTLong256VectorTests(IntFunction fa, IntFunction fa, IntFunction fb, + static void ULTLong256VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -4244,7 +4538,7 @@ static void UNSIGNED_LTLong256VectorTestsMasked(IntFunction fa, IntFunct for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); LongVector bv = LongVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_LT, bv, vmask); + VectorMask mv = av.compare(VectorOperators.ULT, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4255,7 +4549,7 @@ static void UNSIGNED_LTLong256VectorTestsMasked(IntFunction fa, IntFunct } @Test(dataProvider = "longCompareOpProvider") - static void UNSIGNED_GTLong256VectorTests(IntFunction fa, IntFunction fb) { + static void UGTLong256VectorTests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -4263,7 +4557,7 @@ static void UNSIGNED_GTLong256VectorTests(IntFunction fa, IntFunction mv = av.compare(VectorOperators.UNSIGNED_GT, bv); + VectorMask mv = av.compare(VectorOperators.UGT, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4274,7 +4568,7 @@ static void UNSIGNED_GTLong256VectorTests(IntFunction fa, IntFunction fa, IntFunction fb, + static void UGTLong256VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -4286,7 +4580,7 @@ static void UNSIGNED_GTLong256VectorTestsMasked(IntFunction fa, IntFunct for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); LongVector bv = LongVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_GT, bv, vmask); + VectorMask mv = av.compare(VectorOperators.UGT, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4297,7 +4591,7 @@ static void UNSIGNED_GTLong256VectorTestsMasked(IntFunction fa, IntFunct } @Test(dataProvider = "longCompareOpProvider") - static void UNSIGNED_LELong256VectorTests(IntFunction fa, IntFunction fb) { + static void ULELong256VectorTests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -4305,7 +4599,7 @@ static void UNSIGNED_LELong256VectorTests(IntFunction fa, IntFunction mv = av.compare(VectorOperators.UNSIGNED_LE, bv); + VectorMask mv = av.compare(VectorOperators.ULE, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4316,7 +4610,7 @@ static void UNSIGNED_LELong256VectorTests(IntFunction fa, IntFunction fa, IntFunction fb, + static void ULELong256VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -4328,7 +4622,7 @@ static void UNSIGNED_LELong256VectorTestsMasked(IntFunction fa, IntFunct for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); LongVector bv = LongVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_LE, bv, vmask); + VectorMask mv = av.compare(VectorOperators.ULE, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4339,7 +4633,7 @@ static void UNSIGNED_LELong256VectorTestsMasked(IntFunction fa, IntFunct } @Test(dataProvider = "longCompareOpProvider") - static void UNSIGNED_GELong256VectorTests(IntFunction fa, IntFunction fb) { + static void UGELong256VectorTests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -4347,7 +4641,7 @@ static void UNSIGNED_GELong256VectorTests(IntFunction fa, IntFunction mv = av.compare(VectorOperators.UNSIGNED_GE, bv); + VectorMask mv = av.compare(VectorOperators.UGE, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4358,7 +4652,7 @@ static void UNSIGNED_GELong256VectorTests(IntFunction fa, IntFunction fa, IntFunction fb, + static void UGELong256VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -4370,7 +4664,7 @@ static void UNSIGNED_GELong256VectorTestsMasked(IntFunction fa, IntFunct for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); LongVector bv = LongVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_GE, bv, vmask); + VectorMask mv = av.compare(VectorOperators.UGE, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { diff --git a/test/jdk/jdk/incubator/vector/Long512VectorTests.java b/test/jdk/jdk/incubator/vector/Long512VectorTests.java index e6eafa02ed0..81d538a55c4 100644 --- a/test/jdk/jdk/incubator/vector/Long512VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Long512VectorTests.java @@ -38,6 +38,7 @@ import jdk.incubator.vector.VectorMask; import jdk.incubator.vector.VectorOperators; import jdk.incubator.vector.Vector; +import jdk.incubator.vector.VectorMath; import jdk.incubator.vector.LongVector; @@ -942,6 +943,33 @@ static long bits(long e) { }) ); + static final List> LONG_SATURATING_GENERATORS = List.of( + withToString("long[Long.MIN_VALUE]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (long)(Long.MIN_VALUE)); + }), + withToString("long[Long.MAX_VALUE]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (long)(Long.MAX_VALUE)); + }), + withToString("long[Long.MAX_VALUE - 100]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (long)(Long.MAX_VALUE - 100)); + }), + withToString("long[Long.MIN_VALUE + 100]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (long)(Long.MIN_VALUE + 100)); + }), + withToString("long[-i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (long)(-i * 5)); + }), + withToString("long[i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (long)(i * 5)); + }) + ); + // Create combinations of pairs // @@@ Might be sensitive to order e.g. div by 0 static final List>> LONG_GENERATOR_PAIRS = @@ -949,6 +977,11 @@ static long bits(long e) { flatMap(fa -> LONG_GENERATORS.stream().skip(1).map(fb -> List.of(fa, fb))). collect(Collectors.toList()); + static final List>> LONG_SATURATING_GENERATOR_PAIRS = + Stream.of(LONG_GENERATORS.get(0)). + flatMap(fa -> LONG_SATURATING_GENERATORS.stream().skip(1).map(fb -> List.of(fa, fb))). + collect(Collectors.toList()); + @DataProvider public Object[][] boolUnaryOpProvider() { return BOOL_ARRAY_GENERATORS.stream(). @@ -979,12 +1012,27 @@ public Object[][] longBinaryOpProvider() { toArray(Object[][]::new); } + @DataProvider + public Object[][] longSaturatingBinaryOpProvider() { + return LONG_SATURATING_GENERATOR_PAIRS.stream().map(List::toArray). + toArray(Object[][]::new); + } + @DataProvider public Object[][] longIndexedOpProvider() { return LONG_GENERATOR_PAIRS.stream().map(List::toArray). toArray(Object[][]::new); } + @DataProvider + public Object[][] longSaturatingBinaryOpMaskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> LONG_SATURATING_GENERATOR_PAIRS.stream().map(lfa -> { + return Stream.concat(lfa.stream(), Stream.of(fm)).toArray(); + })). + toArray(Object[][]::new); + } + @DataProvider public Object[][] longBinaryOpMaskProvider() { return BOOLEAN_MASK_GENERATORS.stream(). @@ -3005,6 +3053,252 @@ static void maxLong512VectorTests(IntFunction fa, IntFunction fb assertArraysEquals(r, a, b, Long512VectorTests::max); } + static long UMIN(long a, long b) { + return (long)(VectorMath.minUnsigned(a, b)); + } + + @Test(dataProvider = "longBinaryOpProvider") + static void UMINLong512VectorTests(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Long512VectorTests::UMIN); + } + + @Test(dataProvider = "longBinaryOpMaskProvider") + static void UMINLong512VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Long512VectorTests::UMIN); + } + + static long UMAX(long a, long b) { + return (long)(VectorMath.maxUnsigned(a, b)); + } + + @Test(dataProvider = "longBinaryOpProvider") + static void UMAXLong512VectorTests(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Long512VectorTests::UMAX); + } + + @Test(dataProvider = "longBinaryOpMaskProvider") + static void UMAXLong512VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Long512VectorTests::UMAX); + } + + static long SADD(long a, long b) { + return (long)(VectorMath.addSaturating(a, b)); + } + + @Test(dataProvider = "longSaturatingBinaryOpProvider") + static void SADDLong512VectorTests(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Long512VectorTests::SADD); + } + + @Test(dataProvider = "longSaturatingBinaryOpMaskProvider") + static void SADDLong512VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Long512VectorTests::SADD); + } + + static long SSUB(long a, long b) { + return (long)(VectorMath.subSaturating(a, b)); + } + + @Test(dataProvider = "longSaturatingBinaryOpProvider") + static void SSUBLong512VectorTests(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Long512VectorTests::SSUB); + } + + @Test(dataProvider = "longSaturatingBinaryOpMaskProvider") + static void SSUBLong512VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Long512VectorTests::SSUB); + } + + static long SUADD(long a, long b) { + return (long)(VectorMath.addSaturatingUnsigned(a, b)); + } + + @Test(dataProvider = "longSaturatingBinaryOpProvider") + static void SUADDLong512VectorTests(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Long512VectorTests::SUADD); + } + + @Test(dataProvider = "longSaturatingBinaryOpMaskProvider") + static void SUADDLong512VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Long512VectorTests::SUADD); + } + + static long SUSUB(long a, long b) { + return (long)(VectorMath.subSaturatingUnsigned(a, b)); + } + + @Test(dataProvider = "longSaturatingBinaryOpProvider") + static void SUSUBLong512VectorTests(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Long512VectorTests::SUSUB); + } + + @Test(dataProvider = "longSaturatingBinaryOpMaskProvider") + static void SUSUBLong512VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Long512VectorTests::SUSUB); + } + @Test(dataProvider = "longBinaryOpProvider") static void MINLong512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); @@ -4213,7 +4507,7 @@ static void GELong512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) { + static void ULTLong512VectorTests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -4221,7 +4515,7 @@ static void UNSIGNED_LTLong512VectorTests(IntFunction fa, IntFunction mv = av.compare(VectorOperators.UNSIGNED_LT, bv); + VectorMask mv = av.compare(VectorOperators.ULT, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4232,7 +4526,7 @@ static void UNSIGNED_LTLong512VectorTests(IntFunction fa, IntFunction fa, IntFunction fb, + static void ULTLong512VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -4244,7 +4538,7 @@ static void UNSIGNED_LTLong512VectorTestsMasked(IntFunction fa, IntFunct for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); LongVector bv = LongVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_LT, bv, vmask); + VectorMask mv = av.compare(VectorOperators.ULT, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4255,7 +4549,7 @@ static void UNSIGNED_LTLong512VectorTestsMasked(IntFunction fa, IntFunct } @Test(dataProvider = "longCompareOpProvider") - static void UNSIGNED_GTLong512VectorTests(IntFunction fa, IntFunction fb) { + static void UGTLong512VectorTests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -4263,7 +4557,7 @@ static void UNSIGNED_GTLong512VectorTests(IntFunction fa, IntFunction mv = av.compare(VectorOperators.UNSIGNED_GT, bv); + VectorMask mv = av.compare(VectorOperators.UGT, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4274,7 +4568,7 @@ static void UNSIGNED_GTLong512VectorTests(IntFunction fa, IntFunction fa, IntFunction fb, + static void UGTLong512VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -4286,7 +4580,7 @@ static void UNSIGNED_GTLong512VectorTestsMasked(IntFunction fa, IntFunct for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); LongVector bv = LongVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_GT, bv, vmask); + VectorMask mv = av.compare(VectorOperators.UGT, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4297,7 +4591,7 @@ static void UNSIGNED_GTLong512VectorTestsMasked(IntFunction fa, IntFunct } @Test(dataProvider = "longCompareOpProvider") - static void UNSIGNED_LELong512VectorTests(IntFunction fa, IntFunction fb) { + static void ULELong512VectorTests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -4305,7 +4599,7 @@ static void UNSIGNED_LELong512VectorTests(IntFunction fa, IntFunction mv = av.compare(VectorOperators.UNSIGNED_LE, bv); + VectorMask mv = av.compare(VectorOperators.ULE, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4316,7 +4610,7 @@ static void UNSIGNED_LELong512VectorTests(IntFunction fa, IntFunction fa, IntFunction fb, + static void ULELong512VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -4328,7 +4622,7 @@ static void UNSIGNED_LELong512VectorTestsMasked(IntFunction fa, IntFunct for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); LongVector bv = LongVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_LE, bv, vmask); + VectorMask mv = av.compare(VectorOperators.ULE, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4339,7 +4633,7 @@ static void UNSIGNED_LELong512VectorTestsMasked(IntFunction fa, IntFunct } @Test(dataProvider = "longCompareOpProvider") - static void UNSIGNED_GELong512VectorTests(IntFunction fa, IntFunction fb) { + static void UGELong512VectorTests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -4347,7 +4641,7 @@ static void UNSIGNED_GELong512VectorTests(IntFunction fa, IntFunction mv = av.compare(VectorOperators.UNSIGNED_GE, bv); + VectorMask mv = av.compare(VectorOperators.UGE, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4358,7 +4652,7 @@ static void UNSIGNED_GELong512VectorTests(IntFunction fa, IntFunction fa, IntFunction fb, + static void UGELong512VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -4370,7 +4664,7 @@ static void UNSIGNED_GELong512VectorTestsMasked(IntFunction fa, IntFunct for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); LongVector bv = LongVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_GE, bv, vmask); + VectorMask mv = av.compare(VectorOperators.UGE, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { diff --git a/test/jdk/jdk/incubator/vector/Long64VectorTests.java b/test/jdk/jdk/incubator/vector/Long64VectorTests.java index 035db048eb8..1d85fc510d9 100644 --- a/test/jdk/jdk/incubator/vector/Long64VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Long64VectorTests.java @@ -38,6 +38,7 @@ import jdk.incubator.vector.VectorMask; import jdk.incubator.vector.VectorOperators; import jdk.incubator.vector.Vector; +import jdk.incubator.vector.VectorMath; import jdk.incubator.vector.LongVector; @@ -942,6 +943,33 @@ static long bits(long e) { }) ); + static final List> LONG_SATURATING_GENERATORS = List.of( + withToString("long[Long.MIN_VALUE]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (long)(Long.MIN_VALUE)); + }), + withToString("long[Long.MAX_VALUE]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (long)(Long.MAX_VALUE)); + }), + withToString("long[Long.MAX_VALUE - 100]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (long)(Long.MAX_VALUE - 100)); + }), + withToString("long[Long.MIN_VALUE + 100]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (long)(Long.MIN_VALUE + 100)); + }), + withToString("long[-i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (long)(-i * 5)); + }), + withToString("long[i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (long)(i * 5)); + }) + ); + // Create combinations of pairs // @@@ Might be sensitive to order e.g. div by 0 static final List>> LONG_GENERATOR_PAIRS = @@ -949,6 +977,11 @@ static long bits(long e) { flatMap(fa -> LONG_GENERATORS.stream().skip(1).map(fb -> List.of(fa, fb))). collect(Collectors.toList()); + static final List>> LONG_SATURATING_GENERATOR_PAIRS = + Stream.of(LONG_GENERATORS.get(0)). + flatMap(fa -> LONG_SATURATING_GENERATORS.stream().skip(1).map(fb -> List.of(fa, fb))). + collect(Collectors.toList()); + @DataProvider public Object[][] boolUnaryOpProvider() { return BOOL_ARRAY_GENERATORS.stream(). @@ -979,12 +1012,27 @@ public Object[][] longBinaryOpProvider() { toArray(Object[][]::new); } + @DataProvider + public Object[][] longSaturatingBinaryOpProvider() { + return LONG_SATURATING_GENERATOR_PAIRS.stream().map(List::toArray). + toArray(Object[][]::new); + } + @DataProvider public Object[][] longIndexedOpProvider() { return LONG_GENERATOR_PAIRS.stream().map(List::toArray). toArray(Object[][]::new); } + @DataProvider + public Object[][] longSaturatingBinaryOpMaskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> LONG_SATURATING_GENERATOR_PAIRS.stream().map(lfa -> { + return Stream.concat(lfa.stream(), Stream.of(fm)).toArray(); + })). + toArray(Object[][]::new); + } + @DataProvider public Object[][] longBinaryOpMaskProvider() { return BOOLEAN_MASK_GENERATORS.stream(). @@ -3005,6 +3053,252 @@ static void maxLong64VectorTests(IntFunction fa, IntFunction fb) assertArraysEquals(r, a, b, Long64VectorTests::max); } + static long UMIN(long a, long b) { + return (long)(VectorMath.minUnsigned(a, b)); + } + + @Test(dataProvider = "longBinaryOpProvider") + static void UMINLong64VectorTests(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Long64VectorTests::UMIN); + } + + @Test(dataProvider = "longBinaryOpMaskProvider") + static void UMINLong64VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Long64VectorTests::UMIN); + } + + static long UMAX(long a, long b) { + return (long)(VectorMath.maxUnsigned(a, b)); + } + + @Test(dataProvider = "longBinaryOpProvider") + static void UMAXLong64VectorTests(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Long64VectorTests::UMAX); + } + + @Test(dataProvider = "longBinaryOpMaskProvider") + static void UMAXLong64VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Long64VectorTests::UMAX); + } + + static long SADD(long a, long b) { + return (long)(VectorMath.addSaturating(a, b)); + } + + @Test(dataProvider = "longSaturatingBinaryOpProvider") + static void SADDLong64VectorTests(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Long64VectorTests::SADD); + } + + @Test(dataProvider = "longSaturatingBinaryOpMaskProvider") + static void SADDLong64VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Long64VectorTests::SADD); + } + + static long SSUB(long a, long b) { + return (long)(VectorMath.subSaturating(a, b)); + } + + @Test(dataProvider = "longSaturatingBinaryOpProvider") + static void SSUBLong64VectorTests(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Long64VectorTests::SSUB); + } + + @Test(dataProvider = "longSaturatingBinaryOpMaskProvider") + static void SSUBLong64VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Long64VectorTests::SSUB); + } + + static long SUADD(long a, long b) { + return (long)(VectorMath.addSaturatingUnsigned(a, b)); + } + + @Test(dataProvider = "longSaturatingBinaryOpProvider") + static void SUADDLong64VectorTests(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Long64VectorTests::SUADD); + } + + @Test(dataProvider = "longSaturatingBinaryOpMaskProvider") + static void SUADDLong64VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Long64VectorTests::SUADD); + } + + static long SUSUB(long a, long b) { + return (long)(VectorMath.subSaturatingUnsigned(a, b)); + } + + @Test(dataProvider = "longSaturatingBinaryOpProvider") + static void SUSUBLong64VectorTests(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Long64VectorTests::SUSUB); + } + + @Test(dataProvider = "longSaturatingBinaryOpMaskProvider") + static void SUSUBLong64VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Long64VectorTests::SUSUB); + } + @Test(dataProvider = "longBinaryOpProvider") static void MINLong64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); @@ -4213,7 +4507,7 @@ static void GELong64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) { + static void ULTLong64VectorTests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -4221,7 +4515,7 @@ static void UNSIGNED_LTLong64VectorTests(IntFunction fa, IntFunction mv = av.compare(VectorOperators.UNSIGNED_LT, bv); + VectorMask mv = av.compare(VectorOperators.ULT, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4232,7 +4526,7 @@ static void UNSIGNED_LTLong64VectorTests(IntFunction fa, IntFunction fa, IntFunction fb, + static void ULTLong64VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -4244,7 +4538,7 @@ static void UNSIGNED_LTLong64VectorTestsMasked(IntFunction fa, IntFuncti for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); LongVector bv = LongVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_LT, bv, vmask); + VectorMask mv = av.compare(VectorOperators.ULT, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4255,7 +4549,7 @@ static void UNSIGNED_LTLong64VectorTestsMasked(IntFunction fa, IntFuncti } @Test(dataProvider = "longCompareOpProvider") - static void UNSIGNED_GTLong64VectorTests(IntFunction fa, IntFunction fb) { + static void UGTLong64VectorTests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -4263,7 +4557,7 @@ static void UNSIGNED_GTLong64VectorTests(IntFunction fa, IntFunction mv = av.compare(VectorOperators.UNSIGNED_GT, bv); + VectorMask mv = av.compare(VectorOperators.UGT, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4274,7 +4568,7 @@ static void UNSIGNED_GTLong64VectorTests(IntFunction fa, IntFunction fa, IntFunction fb, + static void UGTLong64VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -4286,7 +4580,7 @@ static void UNSIGNED_GTLong64VectorTestsMasked(IntFunction fa, IntFuncti for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); LongVector bv = LongVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_GT, bv, vmask); + VectorMask mv = av.compare(VectorOperators.UGT, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4297,7 +4591,7 @@ static void UNSIGNED_GTLong64VectorTestsMasked(IntFunction fa, IntFuncti } @Test(dataProvider = "longCompareOpProvider") - static void UNSIGNED_LELong64VectorTests(IntFunction fa, IntFunction fb) { + static void ULELong64VectorTests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -4305,7 +4599,7 @@ static void UNSIGNED_LELong64VectorTests(IntFunction fa, IntFunction mv = av.compare(VectorOperators.UNSIGNED_LE, bv); + VectorMask mv = av.compare(VectorOperators.ULE, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4316,7 +4610,7 @@ static void UNSIGNED_LELong64VectorTests(IntFunction fa, IntFunction fa, IntFunction fb, + static void ULELong64VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -4328,7 +4622,7 @@ static void UNSIGNED_LELong64VectorTestsMasked(IntFunction fa, IntFuncti for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); LongVector bv = LongVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_LE, bv, vmask); + VectorMask mv = av.compare(VectorOperators.ULE, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4339,7 +4633,7 @@ static void UNSIGNED_LELong64VectorTestsMasked(IntFunction fa, IntFuncti } @Test(dataProvider = "longCompareOpProvider") - static void UNSIGNED_GELong64VectorTests(IntFunction fa, IntFunction fb) { + static void UGELong64VectorTests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -4347,7 +4641,7 @@ static void UNSIGNED_GELong64VectorTests(IntFunction fa, IntFunction mv = av.compare(VectorOperators.UNSIGNED_GE, bv); + VectorMask mv = av.compare(VectorOperators.UGE, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4358,7 +4652,7 @@ static void UNSIGNED_GELong64VectorTests(IntFunction fa, IntFunction fa, IntFunction fb, + static void UGELong64VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -4370,7 +4664,7 @@ static void UNSIGNED_GELong64VectorTestsMasked(IntFunction fa, IntFuncti for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); LongVector bv = LongVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_GE, bv, vmask); + VectorMask mv = av.compare(VectorOperators.UGE, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { diff --git a/test/jdk/jdk/incubator/vector/LongMaxVectorTests.java b/test/jdk/jdk/incubator/vector/LongMaxVectorTests.java index 68ea78db4f0..bae5b968d79 100644 --- a/test/jdk/jdk/incubator/vector/LongMaxVectorTests.java +++ b/test/jdk/jdk/incubator/vector/LongMaxVectorTests.java @@ -38,6 +38,7 @@ import jdk.incubator.vector.VectorMask; import jdk.incubator.vector.VectorOperators; import jdk.incubator.vector.Vector; +import jdk.incubator.vector.VectorMath; import jdk.incubator.vector.LongVector; @@ -947,6 +948,33 @@ static long bits(long e) { }) ); + static final List> LONG_SATURATING_GENERATORS = List.of( + withToString("long[Long.MIN_VALUE]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (long)(Long.MIN_VALUE)); + }), + withToString("long[Long.MAX_VALUE]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (long)(Long.MAX_VALUE)); + }), + withToString("long[Long.MAX_VALUE - 100]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (long)(Long.MAX_VALUE - 100)); + }), + withToString("long[Long.MIN_VALUE + 100]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (long)(Long.MIN_VALUE + 100)); + }), + withToString("long[-i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (long)(-i * 5)); + }), + withToString("long[i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (long)(i * 5)); + }) + ); + // Create combinations of pairs // @@@ Might be sensitive to order e.g. div by 0 static final List>> LONG_GENERATOR_PAIRS = @@ -954,6 +982,11 @@ static long bits(long e) { flatMap(fa -> LONG_GENERATORS.stream().skip(1).map(fb -> List.of(fa, fb))). collect(Collectors.toList()); + static final List>> LONG_SATURATING_GENERATOR_PAIRS = + Stream.of(LONG_GENERATORS.get(0)). + flatMap(fa -> LONG_SATURATING_GENERATORS.stream().skip(1).map(fb -> List.of(fa, fb))). + collect(Collectors.toList()); + @DataProvider public Object[][] boolUnaryOpProvider() { return BOOL_ARRAY_GENERATORS.stream(). @@ -984,12 +1017,27 @@ public Object[][] longBinaryOpProvider() { toArray(Object[][]::new); } + @DataProvider + public Object[][] longSaturatingBinaryOpProvider() { + return LONG_SATURATING_GENERATOR_PAIRS.stream().map(List::toArray). + toArray(Object[][]::new); + } + @DataProvider public Object[][] longIndexedOpProvider() { return LONG_GENERATOR_PAIRS.stream().map(List::toArray). toArray(Object[][]::new); } + @DataProvider + public Object[][] longSaturatingBinaryOpMaskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> LONG_SATURATING_GENERATOR_PAIRS.stream().map(lfa -> { + return Stream.concat(lfa.stream(), Stream.of(fm)).toArray(); + })). + toArray(Object[][]::new); + } + @DataProvider public Object[][] longBinaryOpMaskProvider() { return BOOLEAN_MASK_GENERATORS.stream(). @@ -3010,6 +3058,252 @@ static void maxLongMaxVectorTests(IntFunction fa, IntFunction fb assertArraysEquals(r, a, b, LongMaxVectorTests::max); } + static long UMIN(long a, long b) { + return (long)(VectorMath.minUnsigned(a, b)); + } + + @Test(dataProvider = "longBinaryOpProvider") + static void UMINLongMaxVectorTests(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, LongMaxVectorTests::UMIN); + } + + @Test(dataProvider = "longBinaryOpMaskProvider") + static void UMINLongMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, LongMaxVectorTests::UMIN); + } + + static long UMAX(long a, long b) { + return (long)(VectorMath.maxUnsigned(a, b)); + } + + @Test(dataProvider = "longBinaryOpProvider") + static void UMAXLongMaxVectorTests(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, LongMaxVectorTests::UMAX); + } + + @Test(dataProvider = "longBinaryOpMaskProvider") + static void UMAXLongMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, LongMaxVectorTests::UMAX); + } + + static long SADD(long a, long b) { + return (long)(VectorMath.addSaturating(a, b)); + } + + @Test(dataProvider = "longSaturatingBinaryOpProvider") + static void SADDLongMaxVectorTests(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, LongMaxVectorTests::SADD); + } + + @Test(dataProvider = "longSaturatingBinaryOpMaskProvider") + static void SADDLongMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, LongMaxVectorTests::SADD); + } + + static long SSUB(long a, long b) { + return (long)(VectorMath.subSaturating(a, b)); + } + + @Test(dataProvider = "longSaturatingBinaryOpProvider") + static void SSUBLongMaxVectorTests(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, LongMaxVectorTests::SSUB); + } + + @Test(dataProvider = "longSaturatingBinaryOpMaskProvider") + static void SSUBLongMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, LongMaxVectorTests::SSUB); + } + + static long SUADD(long a, long b) { + return (long)(VectorMath.addSaturatingUnsigned(a, b)); + } + + @Test(dataProvider = "longSaturatingBinaryOpProvider") + static void SUADDLongMaxVectorTests(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, LongMaxVectorTests::SUADD); + } + + @Test(dataProvider = "longSaturatingBinaryOpMaskProvider") + static void SUADDLongMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, LongMaxVectorTests::SUADD); + } + + static long SUSUB(long a, long b) { + return (long)(VectorMath.subSaturatingUnsigned(a, b)); + } + + @Test(dataProvider = "longSaturatingBinaryOpProvider") + static void SUSUBLongMaxVectorTests(IntFunction fa, IntFunction fb) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, LongMaxVectorTests::SUSUB); + } + + @Test(dataProvider = "longSaturatingBinaryOpMaskProvider") + static void SUSUBLongMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + long[] a = fa.apply(SPECIES.length()); + long[] b = fb.apply(SPECIES.length()); + long[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + LongVector av = LongVector.fromArray(SPECIES, a, i); + LongVector bv = LongVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, LongMaxVectorTests::SUSUB); + } + @Test(dataProvider = "longBinaryOpProvider") static void MINLongMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); @@ -4218,7 +4512,7 @@ static void GELongMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) { + static void ULTLongMaxVectorTests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -4226,7 +4520,7 @@ static void UNSIGNED_LTLongMaxVectorTests(IntFunction fa, IntFunction mv = av.compare(VectorOperators.UNSIGNED_LT, bv); + VectorMask mv = av.compare(VectorOperators.ULT, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4237,7 +4531,7 @@ static void UNSIGNED_LTLongMaxVectorTests(IntFunction fa, IntFunction fa, IntFunction fb, + static void ULTLongMaxVectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -4249,7 +4543,7 @@ static void UNSIGNED_LTLongMaxVectorTestsMasked(IntFunction fa, IntFunct for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); LongVector bv = LongVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_LT, bv, vmask); + VectorMask mv = av.compare(VectorOperators.ULT, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4260,7 +4554,7 @@ static void UNSIGNED_LTLongMaxVectorTestsMasked(IntFunction fa, IntFunct } @Test(dataProvider = "longCompareOpProvider") - static void UNSIGNED_GTLongMaxVectorTests(IntFunction fa, IntFunction fb) { + static void UGTLongMaxVectorTests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -4268,7 +4562,7 @@ static void UNSIGNED_GTLongMaxVectorTests(IntFunction fa, IntFunction mv = av.compare(VectorOperators.UNSIGNED_GT, bv); + VectorMask mv = av.compare(VectorOperators.UGT, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4279,7 +4573,7 @@ static void UNSIGNED_GTLongMaxVectorTests(IntFunction fa, IntFunction fa, IntFunction fb, + static void UGTLongMaxVectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -4291,7 +4585,7 @@ static void UNSIGNED_GTLongMaxVectorTestsMasked(IntFunction fa, IntFunct for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); LongVector bv = LongVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_GT, bv, vmask); + VectorMask mv = av.compare(VectorOperators.UGT, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4302,7 +4596,7 @@ static void UNSIGNED_GTLongMaxVectorTestsMasked(IntFunction fa, IntFunct } @Test(dataProvider = "longCompareOpProvider") - static void UNSIGNED_LELongMaxVectorTests(IntFunction fa, IntFunction fb) { + static void ULELongMaxVectorTests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -4310,7 +4604,7 @@ static void UNSIGNED_LELongMaxVectorTests(IntFunction fa, IntFunction mv = av.compare(VectorOperators.UNSIGNED_LE, bv); + VectorMask mv = av.compare(VectorOperators.ULE, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4321,7 +4615,7 @@ static void UNSIGNED_LELongMaxVectorTests(IntFunction fa, IntFunction fa, IntFunction fb, + static void ULELongMaxVectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -4333,7 +4627,7 @@ static void UNSIGNED_LELongMaxVectorTestsMasked(IntFunction fa, IntFunct for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); LongVector bv = LongVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_LE, bv, vmask); + VectorMask mv = av.compare(VectorOperators.ULE, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4344,7 +4638,7 @@ static void UNSIGNED_LELongMaxVectorTestsMasked(IntFunction fa, IntFunct } @Test(dataProvider = "longCompareOpProvider") - static void UNSIGNED_GELongMaxVectorTests(IntFunction fa, IntFunction fb) { + static void UGELongMaxVectorTests(IntFunction fa, IntFunction fb) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -4352,7 +4646,7 @@ static void UNSIGNED_GELongMaxVectorTests(IntFunction fa, IntFunction mv = av.compare(VectorOperators.UNSIGNED_GE, bv); + VectorMask mv = av.compare(VectorOperators.UGE, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4363,7 +4657,7 @@ static void UNSIGNED_GELongMaxVectorTests(IntFunction fa, IntFunction fa, IntFunction fb, + static void UGELongMaxVectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { long[] a = fa.apply(SPECIES.length()); long[] b = fb.apply(SPECIES.length()); @@ -4375,7 +4669,7 @@ static void UNSIGNED_GELongMaxVectorTestsMasked(IntFunction fa, IntFunct for (int i = 0; i < a.length; i += SPECIES.length()) { LongVector av = LongVector.fromArray(SPECIES, a, i); LongVector bv = LongVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_GE, bv, vmask); + VectorMask mv = av.compare(VectorOperators.UGE, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { diff --git a/test/jdk/jdk/incubator/vector/Short128VectorTests.java b/test/jdk/jdk/incubator/vector/Short128VectorTests.java index 2103be0994c..2d6a1fd0a5f 100644 --- a/test/jdk/jdk/incubator/vector/Short128VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Short128VectorTests.java @@ -38,6 +38,7 @@ import jdk.incubator.vector.VectorMask; import jdk.incubator.vector.VectorOperators; import jdk.incubator.vector.Vector; +import jdk.incubator.vector.VectorMath; import jdk.incubator.vector.ShortVector; @@ -952,6 +953,33 @@ static short bits(short e) { }) ); + static final List> SHORT_SATURATING_GENERATORS = List.of( + withToString("short[Short.MIN_VALUE]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (short)(Short.MIN_VALUE)); + }), + withToString("short[Short.MAX_VALUE]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (short)(Short.MAX_VALUE)); + }), + withToString("short[Short.MAX_VALUE - 100]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (short)(Short.MAX_VALUE - 100)); + }), + withToString("short[Short.MIN_VALUE + 100]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (short)(Short.MIN_VALUE + 100)); + }), + withToString("short[-i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (short)(-i * 5)); + }), + withToString("short[i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (short)(i * 5)); + }) + ); + // Create combinations of pairs // @@@ Might be sensitive to order e.g. div by 0 static final List>> SHORT_GENERATOR_PAIRS = @@ -959,6 +987,11 @@ static short bits(short e) { flatMap(fa -> SHORT_GENERATORS.stream().skip(1).map(fb -> List.of(fa, fb))). collect(Collectors.toList()); + static final List>> SHORT_SATURATING_GENERATOR_PAIRS = + Stream.of(SHORT_GENERATORS.get(0)). + flatMap(fa -> SHORT_SATURATING_GENERATORS.stream().skip(1).map(fb -> List.of(fa, fb))). + collect(Collectors.toList()); + @DataProvider public Object[][] boolUnaryOpProvider() { return BOOL_ARRAY_GENERATORS.stream(). @@ -989,12 +1022,27 @@ public Object[][] shortBinaryOpProvider() { toArray(Object[][]::new); } + @DataProvider + public Object[][] shortSaturatingBinaryOpProvider() { + return SHORT_SATURATING_GENERATOR_PAIRS.stream().map(List::toArray). + toArray(Object[][]::new); + } + @DataProvider public Object[][] shortIndexedOpProvider() { return SHORT_GENERATOR_PAIRS.stream().map(List::toArray). toArray(Object[][]::new); } + @DataProvider + public Object[][] shortSaturatingBinaryOpMaskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> SHORT_SATURATING_GENERATOR_PAIRS.stream().map(lfa -> { + return Stream.concat(lfa.stream(), Stream.of(fm)).toArray(); + })). + toArray(Object[][]::new); + } + @DataProvider public Object[][] shortBinaryOpMaskProvider() { return BOOLEAN_MASK_GENERATORS.stream(). @@ -2930,6 +2978,252 @@ static void maxShort128VectorTests(IntFunction fa, IntFunction assertArraysEquals(r, a, b, Short128VectorTests::max); } + static short UMIN(short a, short b) { + return (short)(VectorMath.minUnsigned(a, b)); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void UMINShort128VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Short128VectorTests::UMIN); + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void UMINShort128VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Short128VectorTests::UMIN); + } + + static short UMAX(short a, short b) { + return (short)(VectorMath.maxUnsigned(a, b)); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void UMAXShort128VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Short128VectorTests::UMAX); + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void UMAXShort128VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Short128VectorTests::UMAX); + } + + static short SADD(short a, short b) { + return (short)(VectorMath.addSaturating(a, b)); + } + + @Test(dataProvider = "shortSaturatingBinaryOpProvider") + static void SADDShort128VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Short128VectorTests::SADD); + } + + @Test(dataProvider = "shortSaturatingBinaryOpMaskProvider") + static void SADDShort128VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Short128VectorTests::SADD); + } + + static short SSUB(short a, short b) { + return (short)(VectorMath.subSaturating(a, b)); + } + + @Test(dataProvider = "shortSaturatingBinaryOpProvider") + static void SSUBShort128VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Short128VectorTests::SSUB); + } + + @Test(dataProvider = "shortSaturatingBinaryOpMaskProvider") + static void SSUBShort128VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Short128VectorTests::SSUB); + } + + static short SUADD(short a, short b) { + return (short)(VectorMath.addSaturatingUnsigned(a, b)); + } + + @Test(dataProvider = "shortSaturatingBinaryOpProvider") + static void SUADDShort128VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Short128VectorTests::SUADD); + } + + @Test(dataProvider = "shortSaturatingBinaryOpMaskProvider") + static void SUADDShort128VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Short128VectorTests::SUADD); + } + + static short SUSUB(short a, short b) { + return (short)(VectorMath.subSaturatingUnsigned(a, b)); + } + + @Test(dataProvider = "shortSaturatingBinaryOpProvider") + static void SUSUBShort128VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Short128VectorTests::SUSUB); + } + + @Test(dataProvider = "shortSaturatingBinaryOpMaskProvider") + static void SUSUBShort128VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Short128VectorTests::SUSUB); + } + @Test(dataProvider = "shortBinaryOpProvider") static void MINShort128VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); @@ -4138,7 +4432,7 @@ static void GEShort128VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) { + static void ULTShort128VectorTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -4146,7 +4440,7 @@ static void UNSIGNED_LTShort128VectorTests(IntFunction fa, IntFunction< for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ShortVector bv = ShortVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_LT, bv); + VectorMask mv = av.compare(VectorOperators.ULT, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4157,7 +4451,7 @@ static void UNSIGNED_LTShort128VectorTests(IntFunction fa, IntFunction< } @Test(dataProvider = "shortCompareOpMaskProvider") - static void UNSIGNED_LTShort128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ULTShort128VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -4169,7 +4463,7 @@ static void UNSIGNED_LTShort128VectorTestsMasked(IntFunction fa, IntFun for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ShortVector bv = ShortVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_LT, bv, vmask); + VectorMask mv = av.compare(VectorOperators.ULT, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4180,7 +4474,7 @@ static void UNSIGNED_LTShort128VectorTestsMasked(IntFunction fa, IntFun } @Test(dataProvider = "shortCompareOpProvider") - static void UNSIGNED_GTShort128VectorTests(IntFunction fa, IntFunction fb) { + static void UGTShort128VectorTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -4188,7 +4482,7 @@ static void UNSIGNED_GTShort128VectorTests(IntFunction fa, IntFunction< for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ShortVector bv = ShortVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_GT, bv); + VectorMask mv = av.compare(VectorOperators.UGT, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4199,7 +4493,7 @@ static void UNSIGNED_GTShort128VectorTests(IntFunction fa, IntFunction< } @Test(dataProvider = "shortCompareOpMaskProvider") - static void UNSIGNED_GTShort128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void UGTShort128VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -4211,7 +4505,7 @@ static void UNSIGNED_GTShort128VectorTestsMasked(IntFunction fa, IntFun for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ShortVector bv = ShortVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_GT, bv, vmask); + VectorMask mv = av.compare(VectorOperators.UGT, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4222,7 +4516,7 @@ static void UNSIGNED_GTShort128VectorTestsMasked(IntFunction fa, IntFun } @Test(dataProvider = "shortCompareOpProvider") - static void UNSIGNED_LEShort128VectorTests(IntFunction fa, IntFunction fb) { + static void ULEShort128VectorTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -4230,7 +4524,7 @@ static void UNSIGNED_LEShort128VectorTests(IntFunction fa, IntFunction< for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ShortVector bv = ShortVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_LE, bv); + VectorMask mv = av.compare(VectorOperators.ULE, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4241,7 +4535,7 @@ static void UNSIGNED_LEShort128VectorTests(IntFunction fa, IntFunction< } @Test(dataProvider = "shortCompareOpMaskProvider") - static void UNSIGNED_LEShort128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ULEShort128VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -4253,7 +4547,7 @@ static void UNSIGNED_LEShort128VectorTestsMasked(IntFunction fa, IntFun for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ShortVector bv = ShortVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_LE, bv, vmask); + VectorMask mv = av.compare(VectorOperators.ULE, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4264,7 +4558,7 @@ static void UNSIGNED_LEShort128VectorTestsMasked(IntFunction fa, IntFun } @Test(dataProvider = "shortCompareOpProvider") - static void UNSIGNED_GEShort128VectorTests(IntFunction fa, IntFunction fb) { + static void UGEShort128VectorTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -4272,7 +4566,7 @@ static void UNSIGNED_GEShort128VectorTests(IntFunction fa, IntFunction< for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ShortVector bv = ShortVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_GE, bv); + VectorMask mv = av.compare(VectorOperators.UGE, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4283,7 +4577,7 @@ static void UNSIGNED_GEShort128VectorTests(IntFunction fa, IntFunction< } @Test(dataProvider = "shortCompareOpMaskProvider") - static void UNSIGNED_GEShort128VectorTestsMasked(IntFunction fa, IntFunction fb, + static void UGEShort128VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -4295,7 +4589,7 @@ static void UNSIGNED_GEShort128VectorTestsMasked(IntFunction fa, IntFun for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ShortVector bv = ShortVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_GE, bv, vmask); + VectorMask mv = av.compare(VectorOperators.UGE, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { diff --git a/test/jdk/jdk/incubator/vector/Short256VectorTests.java b/test/jdk/jdk/incubator/vector/Short256VectorTests.java index feed6bbe5f3..fa8ec1f31b6 100644 --- a/test/jdk/jdk/incubator/vector/Short256VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Short256VectorTests.java @@ -38,6 +38,7 @@ import jdk.incubator.vector.VectorMask; import jdk.incubator.vector.VectorOperators; import jdk.incubator.vector.Vector; +import jdk.incubator.vector.VectorMath; import jdk.incubator.vector.ShortVector; @@ -952,6 +953,33 @@ static short bits(short e) { }) ); + static final List> SHORT_SATURATING_GENERATORS = List.of( + withToString("short[Short.MIN_VALUE]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (short)(Short.MIN_VALUE)); + }), + withToString("short[Short.MAX_VALUE]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (short)(Short.MAX_VALUE)); + }), + withToString("short[Short.MAX_VALUE - 100]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (short)(Short.MAX_VALUE - 100)); + }), + withToString("short[Short.MIN_VALUE + 100]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (short)(Short.MIN_VALUE + 100)); + }), + withToString("short[-i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (short)(-i * 5)); + }), + withToString("short[i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (short)(i * 5)); + }) + ); + // Create combinations of pairs // @@@ Might be sensitive to order e.g. div by 0 static final List>> SHORT_GENERATOR_PAIRS = @@ -959,6 +987,11 @@ static short bits(short e) { flatMap(fa -> SHORT_GENERATORS.stream().skip(1).map(fb -> List.of(fa, fb))). collect(Collectors.toList()); + static final List>> SHORT_SATURATING_GENERATOR_PAIRS = + Stream.of(SHORT_GENERATORS.get(0)). + flatMap(fa -> SHORT_SATURATING_GENERATORS.stream().skip(1).map(fb -> List.of(fa, fb))). + collect(Collectors.toList()); + @DataProvider public Object[][] boolUnaryOpProvider() { return BOOL_ARRAY_GENERATORS.stream(). @@ -989,12 +1022,27 @@ public Object[][] shortBinaryOpProvider() { toArray(Object[][]::new); } + @DataProvider + public Object[][] shortSaturatingBinaryOpProvider() { + return SHORT_SATURATING_GENERATOR_PAIRS.stream().map(List::toArray). + toArray(Object[][]::new); + } + @DataProvider public Object[][] shortIndexedOpProvider() { return SHORT_GENERATOR_PAIRS.stream().map(List::toArray). toArray(Object[][]::new); } + @DataProvider + public Object[][] shortSaturatingBinaryOpMaskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> SHORT_SATURATING_GENERATOR_PAIRS.stream().map(lfa -> { + return Stream.concat(lfa.stream(), Stream.of(fm)).toArray(); + })). + toArray(Object[][]::new); + } + @DataProvider public Object[][] shortBinaryOpMaskProvider() { return BOOLEAN_MASK_GENERATORS.stream(). @@ -2930,6 +2978,252 @@ static void maxShort256VectorTests(IntFunction fa, IntFunction assertArraysEquals(r, a, b, Short256VectorTests::max); } + static short UMIN(short a, short b) { + return (short)(VectorMath.minUnsigned(a, b)); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void UMINShort256VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Short256VectorTests::UMIN); + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void UMINShort256VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Short256VectorTests::UMIN); + } + + static short UMAX(short a, short b) { + return (short)(VectorMath.maxUnsigned(a, b)); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void UMAXShort256VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Short256VectorTests::UMAX); + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void UMAXShort256VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Short256VectorTests::UMAX); + } + + static short SADD(short a, short b) { + return (short)(VectorMath.addSaturating(a, b)); + } + + @Test(dataProvider = "shortSaturatingBinaryOpProvider") + static void SADDShort256VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Short256VectorTests::SADD); + } + + @Test(dataProvider = "shortSaturatingBinaryOpMaskProvider") + static void SADDShort256VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Short256VectorTests::SADD); + } + + static short SSUB(short a, short b) { + return (short)(VectorMath.subSaturating(a, b)); + } + + @Test(dataProvider = "shortSaturatingBinaryOpProvider") + static void SSUBShort256VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Short256VectorTests::SSUB); + } + + @Test(dataProvider = "shortSaturatingBinaryOpMaskProvider") + static void SSUBShort256VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Short256VectorTests::SSUB); + } + + static short SUADD(short a, short b) { + return (short)(VectorMath.addSaturatingUnsigned(a, b)); + } + + @Test(dataProvider = "shortSaturatingBinaryOpProvider") + static void SUADDShort256VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Short256VectorTests::SUADD); + } + + @Test(dataProvider = "shortSaturatingBinaryOpMaskProvider") + static void SUADDShort256VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Short256VectorTests::SUADD); + } + + static short SUSUB(short a, short b) { + return (short)(VectorMath.subSaturatingUnsigned(a, b)); + } + + @Test(dataProvider = "shortSaturatingBinaryOpProvider") + static void SUSUBShort256VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Short256VectorTests::SUSUB); + } + + @Test(dataProvider = "shortSaturatingBinaryOpMaskProvider") + static void SUSUBShort256VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Short256VectorTests::SUSUB); + } + @Test(dataProvider = "shortBinaryOpProvider") static void MINShort256VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); @@ -4138,7 +4432,7 @@ static void GEShort256VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) { + static void ULTShort256VectorTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -4146,7 +4440,7 @@ static void UNSIGNED_LTShort256VectorTests(IntFunction fa, IntFunction< for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ShortVector bv = ShortVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_LT, bv); + VectorMask mv = av.compare(VectorOperators.ULT, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4157,7 +4451,7 @@ static void UNSIGNED_LTShort256VectorTests(IntFunction fa, IntFunction< } @Test(dataProvider = "shortCompareOpMaskProvider") - static void UNSIGNED_LTShort256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ULTShort256VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -4169,7 +4463,7 @@ static void UNSIGNED_LTShort256VectorTestsMasked(IntFunction fa, IntFun for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ShortVector bv = ShortVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_LT, bv, vmask); + VectorMask mv = av.compare(VectorOperators.ULT, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4180,7 +4474,7 @@ static void UNSIGNED_LTShort256VectorTestsMasked(IntFunction fa, IntFun } @Test(dataProvider = "shortCompareOpProvider") - static void UNSIGNED_GTShort256VectorTests(IntFunction fa, IntFunction fb) { + static void UGTShort256VectorTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -4188,7 +4482,7 @@ static void UNSIGNED_GTShort256VectorTests(IntFunction fa, IntFunction< for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ShortVector bv = ShortVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_GT, bv); + VectorMask mv = av.compare(VectorOperators.UGT, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4199,7 +4493,7 @@ static void UNSIGNED_GTShort256VectorTests(IntFunction fa, IntFunction< } @Test(dataProvider = "shortCompareOpMaskProvider") - static void UNSIGNED_GTShort256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void UGTShort256VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -4211,7 +4505,7 @@ static void UNSIGNED_GTShort256VectorTestsMasked(IntFunction fa, IntFun for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ShortVector bv = ShortVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_GT, bv, vmask); + VectorMask mv = av.compare(VectorOperators.UGT, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4222,7 +4516,7 @@ static void UNSIGNED_GTShort256VectorTestsMasked(IntFunction fa, IntFun } @Test(dataProvider = "shortCompareOpProvider") - static void UNSIGNED_LEShort256VectorTests(IntFunction fa, IntFunction fb) { + static void ULEShort256VectorTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -4230,7 +4524,7 @@ static void UNSIGNED_LEShort256VectorTests(IntFunction fa, IntFunction< for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ShortVector bv = ShortVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_LE, bv); + VectorMask mv = av.compare(VectorOperators.ULE, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4241,7 +4535,7 @@ static void UNSIGNED_LEShort256VectorTests(IntFunction fa, IntFunction< } @Test(dataProvider = "shortCompareOpMaskProvider") - static void UNSIGNED_LEShort256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ULEShort256VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -4253,7 +4547,7 @@ static void UNSIGNED_LEShort256VectorTestsMasked(IntFunction fa, IntFun for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ShortVector bv = ShortVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_LE, bv, vmask); + VectorMask mv = av.compare(VectorOperators.ULE, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4264,7 +4558,7 @@ static void UNSIGNED_LEShort256VectorTestsMasked(IntFunction fa, IntFun } @Test(dataProvider = "shortCompareOpProvider") - static void UNSIGNED_GEShort256VectorTests(IntFunction fa, IntFunction fb) { + static void UGEShort256VectorTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -4272,7 +4566,7 @@ static void UNSIGNED_GEShort256VectorTests(IntFunction fa, IntFunction< for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ShortVector bv = ShortVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_GE, bv); + VectorMask mv = av.compare(VectorOperators.UGE, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4283,7 +4577,7 @@ static void UNSIGNED_GEShort256VectorTests(IntFunction fa, IntFunction< } @Test(dataProvider = "shortCompareOpMaskProvider") - static void UNSIGNED_GEShort256VectorTestsMasked(IntFunction fa, IntFunction fb, + static void UGEShort256VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -4295,7 +4589,7 @@ static void UNSIGNED_GEShort256VectorTestsMasked(IntFunction fa, IntFun for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ShortVector bv = ShortVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_GE, bv, vmask); + VectorMask mv = av.compare(VectorOperators.UGE, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { diff --git a/test/jdk/jdk/incubator/vector/Short512VectorTests.java b/test/jdk/jdk/incubator/vector/Short512VectorTests.java index a1a1ac6bc37..ba6a7dadebd 100644 --- a/test/jdk/jdk/incubator/vector/Short512VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Short512VectorTests.java @@ -38,6 +38,7 @@ import jdk.incubator.vector.VectorMask; import jdk.incubator.vector.VectorOperators; import jdk.incubator.vector.Vector; +import jdk.incubator.vector.VectorMath; import jdk.incubator.vector.ShortVector; @@ -952,6 +953,33 @@ static short bits(short e) { }) ); + static final List> SHORT_SATURATING_GENERATORS = List.of( + withToString("short[Short.MIN_VALUE]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (short)(Short.MIN_VALUE)); + }), + withToString("short[Short.MAX_VALUE]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (short)(Short.MAX_VALUE)); + }), + withToString("short[Short.MAX_VALUE - 100]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (short)(Short.MAX_VALUE - 100)); + }), + withToString("short[Short.MIN_VALUE + 100]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (short)(Short.MIN_VALUE + 100)); + }), + withToString("short[-i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (short)(-i * 5)); + }), + withToString("short[i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (short)(i * 5)); + }) + ); + // Create combinations of pairs // @@@ Might be sensitive to order e.g. div by 0 static final List>> SHORT_GENERATOR_PAIRS = @@ -959,6 +987,11 @@ static short bits(short e) { flatMap(fa -> SHORT_GENERATORS.stream().skip(1).map(fb -> List.of(fa, fb))). collect(Collectors.toList()); + static final List>> SHORT_SATURATING_GENERATOR_PAIRS = + Stream.of(SHORT_GENERATORS.get(0)). + flatMap(fa -> SHORT_SATURATING_GENERATORS.stream().skip(1).map(fb -> List.of(fa, fb))). + collect(Collectors.toList()); + @DataProvider public Object[][] boolUnaryOpProvider() { return BOOL_ARRAY_GENERATORS.stream(). @@ -989,12 +1022,27 @@ public Object[][] shortBinaryOpProvider() { toArray(Object[][]::new); } + @DataProvider + public Object[][] shortSaturatingBinaryOpProvider() { + return SHORT_SATURATING_GENERATOR_PAIRS.stream().map(List::toArray). + toArray(Object[][]::new); + } + @DataProvider public Object[][] shortIndexedOpProvider() { return SHORT_GENERATOR_PAIRS.stream().map(List::toArray). toArray(Object[][]::new); } + @DataProvider + public Object[][] shortSaturatingBinaryOpMaskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> SHORT_SATURATING_GENERATOR_PAIRS.stream().map(lfa -> { + return Stream.concat(lfa.stream(), Stream.of(fm)).toArray(); + })). + toArray(Object[][]::new); + } + @DataProvider public Object[][] shortBinaryOpMaskProvider() { return BOOLEAN_MASK_GENERATORS.stream(). @@ -2930,6 +2978,252 @@ static void maxShort512VectorTests(IntFunction fa, IntFunction assertArraysEquals(r, a, b, Short512VectorTests::max); } + static short UMIN(short a, short b) { + return (short)(VectorMath.minUnsigned(a, b)); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void UMINShort512VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Short512VectorTests::UMIN); + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void UMINShort512VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Short512VectorTests::UMIN); + } + + static short UMAX(short a, short b) { + return (short)(VectorMath.maxUnsigned(a, b)); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void UMAXShort512VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Short512VectorTests::UMAX); + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void UMAXShort512VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Short512VectorTests::UMAX); + } + + static short SADD(short a, short b) { + return (short)(VectorMath.addSaturating(a, b)); + } + + @Test(dataProvider = "shortSaturatingBinaryOpProvider") + static void SADDShort512VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Short512VectorTests::SADD); + } + + @Test(dataProvider = "shortSaturatingBinaryOpMaskProvider") + static void SADDShort512VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Short512VectorTests::SADD); + } + + static short SSUB(short a, short b) { + return (short)(VectorMath.subSaturating(a, b)); + } + + @Test(dataProvider = "shortSaturatingBinaryOpProvider") + static void SSUBShort512VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Short512VectorTests::SSUB); + } + + @Test(dataProvider = "shortSaturatingBinaryOpMaskProvider") + static void SSUBShort512VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Short512VectorTests::SSUB); + } + + static short SUADD(short a, short b) { + return (short)(VectorMath.addSaturatingUnsigned(a, b)); + } + + @Test(dataProvider = "shortSaturatingBinaryOpProvider") + static void SUADDShort512VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Short512VectorTests::SUADD); + } + + @Test(dataProvider = "shortSaturatingBinaryOpMaskProvider") + static void SUADDShort512VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Short512VectorTests::SUADD); + } + + static short SUSUB(short a, short b) { + return (short)(VectorMath.subSaturatingUnsigned(a, b)); + } + + @Test(dataProvider = "shortSaturatingBinaryOpProvider") + static void SUSUBShort512VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Short512VectorTests::SUSUB); + } + + @Test(dataProvider = "shortSaturatingBinaryOpMaskProvider") + static void SUSUBShort512VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Short512VectorTests::SUSUB); + } + @Test(dataProvider = "shortBinaryOpProvider") static void MINShort512VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); @@ -4138,7 +4432,7 @@ static void GEShort512VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) { + static void ULTShort512VectorTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -4146,7 +4440,7 @@ static void UNSIGNED_LTShort512VectorTests(IntFunction fa, IntFunction< for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ShortVector bv = ShortVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_LT, bv); + VectorMask mv = av.compare(VectorOperators.ULT, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4157,7 +4451,7 @@ static void UNSIGNED_LTShort512VectorTests(IntFunction fa, IntFunction< } @Test(dataProvider = "shortCompareOpMaskProvider") - static void UNSIGNED_LTShort512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ULTShort512VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -4169,7 +4463,7 @@ static void UNSIGNED_LTShort512VectorTestsMasked(IntFunction fa, IntFun for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ShortVector bv = ShortVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_LT, bv, vmask); + VectorMask mv = av.compare(VectorOperators.ULT, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4180,7 +4474,7 @@ static void UNSIGNED_LTShort512VectorTestsMasked(IntFunction fa, IntFun } @Test(dataProvider = "shortCompareOpProvider") - static void UNSIGNED_GTShort512VectorTests(IntFunction fa, IntFunction fb) { + static void UGTShort512VectorTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -4188,7 +4482,7 @@ static void UNSIGNED_GTShort512VectorTests(IntFunction fa, IntFunction< for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ShortVector bv = ShortVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_GT, bv); + VectorMask mv = av.compare(VectorOperators.UGT, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4199,7 +4493,7 @@ static void UNSIGNED_GTShort512VectorTests(IntFunction fa, IntFunction< } @Test(dataProvider = "shortCompareOpMaskProvider") - static void UNSIGNED_GTShort512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void UGTShort512VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -4211,7 +4505,7 @@ static void UNSIGNED_GTShort512VectorTestsMasked(IntFunction fa, IntFun for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ShortVector bv = ShortVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_GT, bv, vmask); + VectorMask mv = av.compare(VectorOperators.UGT, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4222,7 +4516,7 @@ static void UNSIGNED_GTShort512VectorTestsMasked(IntFunction fa, IntFun } @Test(dataProvider = "shortCompareOpProvider") - static void UNSIGNED_LEShort512VectorTests(IntFunction fa, IntFunction fb) { + static void ULEShort512VectorTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -4230,7 +4524,7 @@ static void UNSIGNED_LEShort512VectorTests(IntFunction fa, IntFunction< for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ShortVector bv = ShortVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_LE, bv); + VectorMask mv = av.compare(VectorOperators.ULE, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4241,7 +4535,7 @@ static void UNSIGNED_LEShort512VectorTests(IntFunction fa, IntFunction< } @Test(dataProvider = "shortCompareOpMaskProvider") - static void UNSIGNED_LEShort512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void ULEShort512VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -4253,7 +4547,7 @@ static void UNSIGNED_LEShort512VectorTestsMasked(IntFunction fa, IntFun for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ShortVector bv = ShortVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_LE, bv, vmask); + VectorMask mv = av.compare(VectorOperators.ULE, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4264,7 +4558,7 @@ static void UNSIGNED_LEShort512VectorTestsMasked(IntFunction fa, IntFun } @Test(dataProvider = "shortCompareOpProvider") - static void UNSIGNED_GEShort512VectorTests(IntFunction fa, IntFunction fb) { + static void UGEShort512VectorTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -4272,7 +4566,7 @@ static void UNSIGNED_GEShort512VectorTests(IntFunction fa, IntFunction< for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ShortVector bv = ShortVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_GE, bv); + VectorMask mv = av.compare(VectorOperators.UGE, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4283,7 +4577,7 @@ static void UNSIGNED_GEShort512VectorTests(IntFunction fa, IntFunction< } @Test(dataProvider = "shortCompareOpMaskProvider") - static void UNSIGNED_GEShort512VectorTestsMasked(IntFunction fa, IntFunction fb, + static void UGEShort512VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -4295,7 +4589,7 @@ static void UNSIGNED_GEShort512VectorTestsMasked(IntFunction fa, IntFun for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ShortVector bv = ShortVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_GE, bv, vmask); + VectorMask mv = av.compare(VectorOperators.UGE, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { diff --git a/test/jdk/jdk/incubator/vector/Short64VectorTests.java b/test/jdk/jdk/incubator/vector/Short64VectorTests.java index cc14cccd119..939da11d53a 100644 --- a/test/jdk/jdk/incubator/vector/Short64VectorTests.java +++ b/test/jdk/jdk/incubator/vector/Short64VectorTests.java @@ -38,6 +38,7 @@ import jdk.incubator.vector.VectorMask; import jdk.incubator.vector.VectorOperators; import jdk.incubator.vector.Vector; +import jdk.incubator.vector.VectorMath; import jdk.incubator.vector.ShortVector; @@ -952,6 +953,33 @@ static short bits(short e) { }) ); + static final List> SHORT_SATURATING_GENERATORS = List.of( + withToString("short[Short.MIN_VALUE]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (short)(Short.MIN_VALUE)); + }), + withToString("short[Short.MAX_VALUE]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (short)(Short.MAX_VALUE)); + }), + withToString("short[Short.MAX_VALUE - 100]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (short)(Short.MAX_VALUE - 100)); + }), + withToString("short[Short.MIN_VALUE + 100]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (short)(Short.MIN_VALUE + 100)); + }), + withToString("short[-i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (short)(-i * 5)); + }), + withToString("short[i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (short)(i * 5)); + }) + ); + // Create combinations of pairs // @@@ Might be sensitive to order e.g. div by 0 static final List>> SHORT_GENERATOR_PAIRS = @@ -959,6 +987,11 @@ static short bits(short e) { flatMap(fa -> SHORT_GENERATORS.stream().skip(1).map(fb -> List.of(fa, fb))). collect(Collectors.toList()); + static final List>> SHORT_SATURATING_GENERATOR_PAIRS = + Stream.of(SHORT_GENERATORS.get(0)). + flatMap(fa -> SHORT_SATURATING_GENERATORS.stream().skip(1).map(fb -> List.of(fa, fb))). + collect(Collectors.toList()); + @DataProvider public Object[][] boolUnaryOpProvider() { return BOOL_ARRAY_GENERATORS.stream(). @@ -989,12 +1022,27 @@ public Object[][] shortBinaryOpProvider() { toArray(Object[][]::new); } + @DataProvider + public Object[][] shortSaturatingBinaryOpProvider() { + return SHORT_SATURATING_GENERATOR_PAIRS.stream().map(List::toArray). + toArray(Object[][]::new); + } + @DataProvider public Object[][] shortIndexedOpProvider() { return SHORT_GENERATOR_PAIRS.stream().map(List::toArray). toArray(Object[][]::new); } + @DataProvider + public Object[][] shortSaturatingBinaryOpMaskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> SHORT_SATURATING_GENERATOR_PAIRS.stream().map(lfa -> { + return Stream.concat(lfa.stream(), Stream.of(fm)).toArray(); + })). + toArray(Object[][]::new); + } + @DataProvider public Object[][] shortBinaryOpMaskProvider() { return BOOLEAN_MASK_GENERATORS.stream(). @@ -2930,6 +2978,252 @@ static void maxShort64VectorTests(IntFunction fa, IntFunction assertArraysEquals(r, a, b, Short64VectorTests::max); } + static short UMIN(short a, short b) { + return (short)(VectorMath.minUnsigned(a, b)); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void UMINShort64VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Short64VectorTests::UMIN); + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void UMINShort64VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Short64VectorTests::UMIN); + } + + static short UMAX(short a, short b) { + return (short)(VectorMath.maxUnsigned(a, b)); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void UMAXShort64VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Short64VectorTests::UMAX); + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void UMAXShort64VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Short64VectorTests::UMAX); + } + + static short SADD(short a, short b) { + return (short)(VectorMath.addSaturating(a, b)); + } + + @Test(dataProvider = "shortSaturatingBinaryOpProvider") + static void SADDShort64VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Short64VectorTests::SADD); + } + + @Test(dataProvider = "shortSaturatingBinaryOpMaskProvider") + static void SADDShort64VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Short64VectorTests::SADD); + } + + static short SSUB(short a, short b) { + return (short)(VectorMath.subSaturating(a, b)); + } + + @Test(dataProvider = "shortSaturatingBinaryOpProvider") + static void SSUBShort64VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Short64VectorTests::SSUB); + } + + @Test(dataProvider = "shortSaturatingBinaryOpMaskProvider") + static void SSUBShort64VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Short64VectorTests::SSUB); + } + + static short SUADD(short a, short b) { + return (short)(VectorMath.addSaturatingUnsigned(a, b)); + } + + @Test(dataProvider = "shortSaturatingBinaryOpProvider") + static void SUADDShort64VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Short64VectorTests::SUADD); + } + + @Test(dataProvider = "shortSaturatingBinaryOpMaskProvider") + static void SUADDShort64VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Short64VectorTests::SUADD); + } + + static short SUSUB(short a, short b) { + return (short)(VectorMath.subSaturatingUnsigned(a, b)); + } + + @Test(dataProvider = "shortSaturatingBinaryOpProvider") + static void SUSUBShort64VectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, Short64VectorTests::SUSUB); + } + + @Test(dataProvider = "shortSaturatingBinaryOpMaskProvider") + static void SUSUBShort64VectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, Short64VectorTests::SUSUB); + } + @Test(dataProvider = "shortBinaryOpProvider") static void MINShort64VectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); @@ -4138,7 +4432,7 @@ static void GEShort64VectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) { + static void ULTShort64VectorTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -4146,7 +4440,7 @@ static void UNSIGNED_LTShort64VectorTests(IntFunction fa, IntFunction mv = av.compare(VectorOperators.UNSIGNED_LT, bv); + VectorMask mv = av.compare(VectorOperators.ULT, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4157,7 +4451,7 @@ static void UNSIGNED_LTShort64VectorTests(IntFunction fa, IntFunction fa, IntFunction fb, + static void ULTShort64VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -4169,7 +4463,7 @@ static void UNSIGNED_LTShort64VectorTestsMasked(IntFunction fa, IntFunc for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ShortVector bv = ShortVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_LT, bv, vmask); + VectorMask mv = av.compare(VectorOperators.ULT, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4180,7 +4474,7 @@ static void UNSIGNED_LTShort64VectorTestsMasked(IntFunction fa, IntFunc } @Test(dataProvider = "shortCompareOpProvider") - static void UNSIGNED_GTShort64VectorTests(IntFunction fa, IntFunction fb) { + static void UGTShort64VectorTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -4188,7 +4482,7 @@ static void UNSIGNED_GTShort64VectorTests(IntFunction fa, IntFunction mv = av.compare(VectorOperators.UNSIGNED_GT, bv); + VectorMask mv = av.compare(VectorOperators.UGT, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4199,7 +4493,7 @@ static void UNSIGNED_GTShort64VectorTests(IntFunction fa, IntFunction fa, IntFunction fb, + static void UGTShort64VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -4211,7 +4505,7 @@ static void UNSIGNED_GTShort64VectorTestsMasked(IntFunction fa, IntFunc for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ShortVector bv = ShortVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_GT, bv, vmask); + VectorMask mv = av.compare(VectorOperators.UGT, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4222,7 +4516,7 @@ static void UNSIGNED_GTShort64VectorTestsMasked(IntFunction fa, IntFunc } @Test(dataProvider = "shortCompareOpProvider") - static void UNSIGNED_LEShort64VectorTests(IntFunction fa, IntFunction fb) { + static void ULEShort64VectorTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -4230,7 +4524,7 @@ static void UNSIGNED_LEShort64VectorTests(IntFunction fa, IntFunction mv = av.compare(VectorOperators.UNSIGNED_LE, bv); + VectorMask mv = av.compare(VectorOperators.ULE, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4241,7 +4535,7 @@ static void UNSIGNED_LEShort64VectorTests(IntFunction fa, IntFunction fa, IntFunction fb, + static void ULEShort64VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -4253,7 +4547,7 @@ static void UNSIGNED_LEShort64VectorTestsMasked(IntFunction fa, IntFunc for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ShortVector bv = ShortVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_LE, bv, vmask); + VectorMask mv = av.compare(VectorOperators.ULE, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4264,7 +4558,7 @@ static void UNSIGNED_LEShort64VectorTestsMasked(IntFunction fa, IntFunc } @Test(dataProvider = "shortCompareOpProvider") - static void UNSIGNED_GEShort64VectorTests(IntFunction fa, IntFunction fb) { + static void UGEShort64VectorTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -4272,7 +4566,7 @@ static void UNSIGNED_GEShort64VectorTests(IntFunction fa, IntFunction mv = av.compare(VectorOperators.UNSIGNED_GE, bv); + VectorMask mv = av.compare(VectorOperators.UGE, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4283,7 +4577,7 @@ static void UNSIGNED_GEShort64VectorTests(IntFunction fa, IntFunction fa, IntFunction fb, + static void UGEShort64VectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -4295,7 +4589,7 @@ static void UNSIGNED_GEShort64VectorTestsMasked(IntFunction fa, IntFunc for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ShortVector bv = ShortVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_GE, bv, vmask); + VectorMask mv = av.compare(VectorOperators.UGE, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { diff --git a/test/jdk/jdk/incubator/vector/ShortMaxVectorTests.java b/test/jdk/jdk/incubator/vector/ShortMaxVectorTests.java index a557494f74c..ade78e1f3f5 100644 --- a/test/jdk/jdk/incubator/vector/ShortMaxVectorTests.java +++ b/test/jdk/jdk/incubator/vector/ShortMaxVectorTests.java @@ -38,6 +38,7 @@ import jdk.incubator.vector.VectorMask; import jdk.incubator.vector.VectorOperators; import jdk.incubator.vector.Vector; +import jdk.incubator.vector.VectorMath; import jdk.incubator.vector.ShortVector; @@ -957,6 +958,33 @@ static short bits(short e) { }) ); + static final List> SHORT_SATURATING_GENERATORS = List.of( + withToString("short[Short.MIN_VALUE]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (short)(Short.MIN_VALUE)); + }), + withToString("short[Short.MAX_VALUE]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (short)(Short.MAX_VALUE)); + }), + withToString("short[Short.MAX_VALUE - 100]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (short)(Short.MAX_VALUE - 100)); + }), + withToString("short[Short.MIN_VALUE + 100]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (short)(Short.MIN_VALUE + 100)); + }), + withToString("short[-i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (short)(-i * 5)); + }), + withToString("short[i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> (short)(i * 5)); + }) + ); + // Create combinations of pairs // @@@ Might be sensitive to order e.g. div by 0 static final List>> SHORT_GENERATOR_PAIRS = @@ -964,6 +992,11 @@ static short bits(short e) { flatMap(fa -> SHORT_GENERATORS.stream().skip(1).map(fb -> List.of(fa, fb))). collect(Collectors.toList()); + static final List>> SHORT_SATURATING_GENERATOR_PAIRS = + Stream.of(SHORT_GENERATORS.get(0)). + flatMap(fa -> SHORT_SATURATING_GENERATORS.stream().skip(1).map(fb -> List.of(fa, fb))). + collect(Collectors.toList()); + @DataProvider public Object[][] boolUnaryOpProvider() { return BOOL_ARRAY_GENERATORS.stream(). @@ -994,12 +1027,27 @@ public Object[][] shortBinaryOpProvider() { toArray(Object[][]::new); } + @DataProvider + public Object[][] shortSaturatingBinaryOpProvider() { + return SHORT_SATURATING_GENERATOR_PAIRS.stream().map(List::toArray). + toArray(Object[][]::new); + } + @DataProvider public Object[][] shortIndexedOpProvider() { return SHORT_GENERATOR_PAIRS.stream().map(List::toArray). toArray(Object[][]::new); } + @DataProvider + public Object[][] shortSaturatingBinaryOpMaskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> SHORT_SATURATING_GENERATOR_PAIRS.stream().map(lfa -> { + return Stream.concat(lfa.stream(), Stream.of(fm)).toArray(); + })). + toArray(Object[][]::new); + } + @DataProvider public Object[][] shortBinaryOpMaskProvider() { return BOOLEAN_MASK_GENERATORS.stream(). @@ -2935,6 +2983,252 @@ static void maxShortMaxVectorTests(IntFunction fa, IntFunction assertArraysEquals(r, a, b, ShortMaxVectorTests::max); } + static short UMIN(short a, short b) { + return (short)(VectorMath.minUnsigned(a, b)); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void UMINShortMaxVectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, ShortMaxVectorTests::UMIN); + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void UMINShortMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMIN, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::UMIN); + } + + static short UMAX(short a, short b) { + return (short)(VectorMath.maxUnsigned(a, b)); + } + + @Test(dataProvider = "shortBinaryOpProvider") + static void UMAXShortMaxVectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, ShortMaxVectorTests::UMAX); + } + + @Test(dataProvider = "shortBinaryOpMaskProvider") + static void UMAXShortMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.UMAX, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::UMAX); + } + + static short SADD(short a, short b) { + return (short)(VectorMath.addSaturating(a, b)); + } + + @Test(dataProvider = "shortSaturatingBinaryOpProvider") + static void SADDShortMaxVectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, ShortMaxVectorTests::SADD); + } + + @Test(dataProvider = "shortSaturatingBinaryOpMaskProvider") + static void SADDShortMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SADD, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::SADD); + } + + static short SSUB(short a, short b) { + return (short)(VectorMath.subSaturating(a, b)); + } + + @Test(dataProvider = "shortSaturatingBinaryOpProvider") + static void SSUBShortMaxVectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, ShortMaxVectorTests::SSUB); + } + + @Test(dataProvider = "shortSaturatingBinaryOpMaskProvider") + static void SSUBShortMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SSUB, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::SSUB); + } + + static short SUADD(short a, short b) { + return (short)(VectorMath.addSaturatingUnsigned(a, b)); + } + + @Test(dataProvider = "shortSaturatingBinaryOpProvider") + static void SUADDShortMaxVectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, ShortMaxVectorTests::SUADD); + } + + @Test(dataProvider = "shortSaturatingBinaryOpMaskProvider") + static void SUADDShortMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUADD, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::SUADD); + } + + static short SUSUB(short a, short b) { + return (short)(VectorMath.subSaturatingUnsigned(a, b)); + } + + @Test(dataProvider = "shortSaturatingBinaryOpProvider") + static void SUSUBShortMaxVectorTests(IntFunction fa, IntFunction fb) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, ShortMaxVectorTests::SUSUB); + } + + @Test(dataProvider = "shortSaturatingBinaryOpMaskProvider") + static void SUSUBShortMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + IntFunction fm) { + short[] a = fa.apply(SPECIES.length()); + short[] b = fb.apply(SPECIES.length()); + short[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + ShortVector av = ShortVector.fromArray(SPECIES, a, i); + ShortVector bv = ShortVector.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.SUSUB, bv, vmask).intoArray(r, i); + } + } + + assertArraysEquals(r, a, b, mask, ShortMaxVectorTests::SUSUB); + } + @Test(dataProvider = "shortBinaryOpProvider") static void MINShortMaxVectorTestsBroadcastSmokeTest(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); @@ -4143,7 +4437,7 @@ static void GEShortMaxVectorTestsMasked(IntFunction fa, IntFunction fa, IntFunction fb) { + static void ULTShortMaxVectorTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -4151,7 +4445,7 @@ static void UNSIGNED_LTShortMaxVectorTests(IntFunction fa, IntFunction< for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ShortVector bv = ShortVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_LT, bv); + VectorMask mv = av.compare(VectorOperators.ULT, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4162,7 +4456,7 @@ static void UNSIGNED_LTShortMaxVectorTests(IntFunction fa, IntFunction< } @Test(dataProvider = "shortCompareOpMaskProvider") - static void UNSIGNED_LTShortMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void ULTShortMaxVectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -4174,7 +4468,7 @@ static void UNSIGNED_LTShortMaxVectorTestsMasked(IntFunction fa, IntFun for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ShortVector bv = ShortVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_LT, bv, vmask); + VectorMask mv = av.compare(VectorOperators.ULT, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4185,7 +4479,7 @@ static void UNSIGNED_LTShortMaxVectorTestsMasked(IntFunction fa, IntFun } @Test(dataProvider = "shortCompareOpProvider") - static void UNSIGNED_GTShortMaxVectorTests(IntFunction fa, IntFunction fb) { + static void UGTShortMaxVectorTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -4193,7 +4487,7 @@ static void UNSIGNED_GTShortMaxVectorTests(IntFunction fa, IntFunction< for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ShortVector bv = ShortVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_GT, bv); + VectorMask mv = av.compare(VectorOperators.UGT, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4204,7 +4498,7 @@ static void UNSIGNED_GTShortMaxVectorTests(IntFunction fa, IntFunction< } @Test(dataProvider = "shortCompareOpMaskProvider") - static void UNSIGNED_GTShortMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void UGTShortMaxVectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -4216,7 +4510,7 @@ static void UNSIGNED_GTShortMaxVectorTestsMasked(IntFunction fa, IntFun for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ShortVector bv = ShortVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_GT, bv, vmask); + VectorMask mv = av.compare(VectorOperators.UGT, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4227,7 +4521,7 @@ static void UNSIGNED_GTShortMaxVectorTestsMasked(IntFunction fa, IntFun } @Test(dataProvider = "shortCompareOpProvider") - static void UNSIGNED_LEShortMaxVectorTests(IntFunction fa, IntFunction fb) { + static void ULEShortMaxVectorTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -4235,7 +4529,7 @@ static void UNSIGNED_LEShortMaxVectorTests(IntFunction fa, IntFunction< for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ShortVector bv = ShortVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_LE, bv); + VectorMask mv = av.compare(VectorOperators.ULE, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4246,7 +4540,7 @@ static void UNSIGNED_LEShortMaxVectorTests(IntFunction fa, IntFunction< } @Test(dataProvider = "shortCompareOpMaskProvider") - static void UNSIGNED_LEShortMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void ULEShortMaxVectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -4258,7 +4552,7 @@ static void UNSIGNED_LEShortMaxVectorTestsMasked(IntFunction fa, IntFun for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ShortVector bv = ShortVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_LE, bv, vmask); + VectorMask mv = av.compare(VectorOperators.ULE, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4269,7 +4563,7 @@ static void UNSIGNED_LEShortMaxVectorTestsMasked(IntFunction fa, IntFun } @Test(dataProvider = "shortCompareOpProvider") - static void UNSIGNED_GEShortMaxVectorTests(IntFunction fa, IntFunction fb) { + static void UGEShortMaxVectorTests(IntFunction fa, IntFunction fb) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -4277,7 +4571,7 @@ static void UNSIGNED_GEShortMaxVectorTests(IntFunction fa, IntFunction< for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ShortVector bv = ShortVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_GE, bv); + VectorMask mv = av.compare(VectorOperators.UGE, bv); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { @@ -4288,7 +4582,7 @@ static void UNSIGNED_GEShortMaxVectorTests(IntFunction fa, IntFunction< } @Test(dataProvider = "shortCompareOpMaskProvider") - static void UNSIGNED_GEShortMaxVectorTestsMasked(IntFunction fa, IntFunction fb, + static void UGEShortMaxVectorTestsMasked(IntFunction fa, IntFunction fb, IntFunction fm) { short[] a = fa.apply(SPECIES.length()); short[] b = fb.apply(SPECIES.length()); @@ -4300,7 +4594,7 @@ static void UNSIGNED_GEShortMaxVectorTestsMasked(IntFunction fa, IntFun for (int i = 0; i < a.length; i += SPECIES.length()) { ShortVector av = ShortVector.fromArray(SPECIES, a, i); ShortVector bv = ShortVector.fromArray(SPECIES, b, i); - VectorMask mv = av.compare(VectorOperators.UNSIGNED_GE, bv, vmask); + VectorMask mv = av.compare(VectorOperators.UGE, bv, vmask); // Check results as part of computation. for (int j = 0; j < SPECIES.length(); j++) { diff --git a/test/jdk/jdk/incubator/vector/VectorMathTest.java b/test/jdk/jdk/incubator/vector/VectorMathTest.java new file mode 100644 index 00000000000..366b9acde59 --- /dev/null +++ b/test/jdk/jdk/incubator/vector/VectorMathTest.java @@ -0,0 +1,245 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8338021 + * @summary Test unsigned and saturating scalar operators for use with Vector API + * @modules jdk.incubator.vector + * @run testng VectorMathTest + */ + +import jdk.incubator.vector.VectorMath; +import org.testng.Assert; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +import java.lang.reflect.Array; +import java.util.function.BinaryOperator; + +public class VectorMathTest { + // @formatter:off + public static final byte ZERO_B = (byte)0; + public static final short ZERO_S = (short)0; + public static final int ZERO_I = 0; + public static final long ZERO_L = 0L; + + public static final byte TEN_B = (byte)10; + public static final int TEN_S = (short)10; + public static final short TEN_I = 10; + public static final long TEN_L = 10L; + + public static final byte FIFTY_B = (byte)50; + public static final int FIFTY_S = (short)50; + public static final short FIFTY_I = 50; + public static final long FIFTY_L = 50L; + + public static final byte SIXTY_B = (byte)60; + public static final int SIXTY_S = (short)60; + public static final short SIXTY_I = 60; + public static final long SIXTY_L = 60L; + + public static final byte UMAX_B = (byte)-1; + public static final short UMAX_S = (short)-1; + public static final int UMAX_I = -1; + public static final long UMAX_L = -1L; + + public static byte[] INPUT_SB = {Byte.MIN_VALUE, (byte)(Byte.MIN_VALUE + TEN_B), ZERO_B, (byte)(Byte.MAX_VALUE - TEN_B), Byte.MAX_VALUE}; + public static short[] INPUT_SS = {Short.MIN_VALUE, (short)(Short.MIN_VALUE + TEN_S), ZERO_S, (short)(Short.MAX_VALUE - TEN_S), Short.MAX_VALUE}; + public static int[] INPUT_SI = {Integer.MIN_VALUE, (Integer.MIN_VALUE + TEN_I), ZERO_I, Integer.MAX_VALUE - TEN_I, Integer.MAX_VALUE}; + public static long[] INPUT_SL = {Long.MIN_VALUE, Long.MIN_VALUE + TEN_L, ZERO_L, Long.MAX_VALUE - TEN_L, Long.MAX_VALUE}; + + public static int[] INPUT_SADD_I = {-FIFTY_I, -FIFTY_I, -FIFTY_I, FIFTY_I, FIFTY_I}; + public static byte[] EXPECTED_SADD_B = {Byte.MIN_VALUE, Byte.MIN_VALUE, -FIFTY_B, Byte.MAX_VALUE, Byte.MAX_VALUE}; + public static short[] EXPECTED_SADD_S = {Short.MIN_VALUE, Short.MIN_VALUE, -FIFTY_S, Short.MAX_VALUE, Short.MAX_VALUE}; + public static int[] EXPECTED_SADD_I = {Integer.MIN_VALUE, Integer.MIN_VALUE, -FIFTY_I, Integer.MAX_VALUE, Integer.MAX_VALUE}; + public static long[] EXPECTED_SADD_L = {Long.MIN_VALUE, Long.MIN_VALUE, -FIFTY_L, Long.MAX_VALUE, Long.MAX_VALUE}; + + public static int[] INPUT_SSUB_I = {FIFTY_I, FIFTY_I, FIFTY_I, -FIFTY_I, -FIFTY_I}; + public static byte[] EXPECTED_SSUB_B = {Byte.MIN_VALUE, Byte.MIN_VALUE, -FIFTY_B, Byte.MAX_VALUE, Byte.MAX_VALUE}; + public static short[] EXPECTED_SSUB_S = {Short.MIN_VALUE, Short.MIN_VALUE, -FIFTY_S, Short.MAX_VALUE, Short.MAX_VALUE}; + public static int[] EXPECTED_SSUB_I = {Integer.MIN_VALUE, Integer.MIN_VALUE, -FIFTY_I, Integer.MAX_VALUE, Integer.MAX_VALUE}; + public static long[] EXPECTED_SSUB_L = {Long.MIN_VALUE, Long.MIN_VALUE, -FIFTY_L, Long.MAX_VALUE, Long.MAX_VALUE}; + + public static byte[] INPUT_UB = {ZERO_B, (byte)(ZERO_B + TEN_B), (byte)(UMAX_B - TEN_B), UMAX_B}; + public static short[] INPUT_US = {ZERO_S, (short)(ZERO_S + TEN_S), (short)(UMAX_S - TEN_S), UMAX_S}; + public static int[] INPUT_UI = {ZERO_I, ZERO_I + TEN_I, UMAX_I - TEN_I, UMAX_I}; + public static long[] INPUT_UL = {ZERO_L, ZERO_L + TEN_L, UMAX_L - TEN_L, UMAX_L}; + + public static int[] INPUT_SUADD_I = {FIFTY_I, FIFTY_I, FIFTY_I, FIFTY_I}; + public static byte[] EXPECTED_SUADD_B = {FIFTY_B, SIXTY_B, UMAX_B, UMAX_B}; + public static short[] EXPECTED_SUADD_S = {FIFTY_S, SIXTY_S, UMAX_S, UMAX_S}; + public static int[] EXPECTED_SUADD_I = {FIFTY_I, SIXTY_I, UMAX_I, UMAX_I}; + public static long[] EXPECTED_SUADD_L = {FIFTY_L, SIXTY_L, UMAX_L, UMAX_L}; + + public static int[] INPUT_SUSUB_I = {FIFTY_I, FIFTY_I, FIFTY_I, FIFTY_I}; + public static byte[] EXPECTED_SUSUB_B = {ZERO_B, ZERO_B, UMAX_B - SIXTY_B, UMAX_B - FIFTY_B}; + public static short[] EXPECTED_SUSUB_S = {ZERO_S, ZERO_S, UMAX_S - SIXTY_S, UMAX_S - FIFTY_S}; + public static int[] EXPECTED_SUSUB_I = {ZERO_I, ZERO_I, UMAX_I - SIXTY_I, UMAX_I - FIFTY_I}; + public static long[] EXPECTED_SUSUB_L = {ZERO_L, ZERO_L, UMAX_L - SIXTY_L, UMAX_L - FIFTY_L}; + + public static byte[] EXPECTED_UMIN_B = {ZERO_B, TEN_B, ZERO_B, Byte.MAX_VALUE - TEN_B}; + public static short[] EXPECTED_UMIN_S = {ZERO_S, TEN_S, ZERO_S, Short.MAX_VALUE - TEN_S}; + public static int[] EXPECTED_UMIN_I = {ZERO_I, TEN_I, ZERO_I, Integer.MAX_VALUE - TEN_I}; + public static long[] EXPECTED_UMIN_L = {ZERO_L, TEN_L, ZERO_L, Long.MAX_VALUE - TEN_L}; + + public static byte[] EXPECTED_UMAX_B = {Byte.MIN_VALUE, (byte)(Byte.MIN_VALUE + TEN_B), (byte)(UMAX_B - TEN_B), UMAX_B}; + public static short[] EXPECTED_UMAX_S = {Short.MIN_VALUE, (short)(Short.MIN_VALUE + TEN_S), (short)(UMAX_S - TEN_S), UMAX_S}; + public static int[] EXPECTED_UMAX_I = {Integer.MIN_VALUE, Integer.MIN_VALUE + TEN_I, (UMAX_I - TEN_I), UMAX_I}; + public static long[] EXPECTED_UMAX_L = {Long.MIN_VALUE, Long.MIN_VALUE + TEN_L, (UMAX_L - TEN_L), UMAX_L}; + // @formatter:on + + static Object conv(Object a, Class ct) { + Object na = Array.newInstance(ct, Array.getLength(a)); + for (int i = 0; i < Array.getLength(a); i++) { + Number number = (Number) Array.get(a, i); + if (ct == byte.class) { + number = number.byteValue(); + } else if (ct == short.class) { + number = number.shortValue(); + } else if (ct == int.class) { + number = number.intValue(); + } else if (ct == long.class) { + number = number.longValue(); + } else { + assert false : "should not reach here"; + } + Array.set(na, i, number); + } + return na; + } + + static BinaryOperator named(String name, BinaryOperator op) { + return new BinaryOperator() { + @Override + public T apply(T a, T b) { + return op.apply(a, b); + } + + public String toString() { + return name; + } + }; + } + + static final BinaryOperator OP_UMIN = named("minUnsigned", + (a, b) -> switch (a) { + case Byte _ -> VectorMath.minUnsigned((byte) a, (byte) b); + case Short _ -> VectorMath.minUnsigned((short) a, (short) b); + case Integer _ -> VectorMath.minUnsigned((int) a, (int) b); + case Long _ -> VectorMath.minUnsigned((long) a, (long) b); + default -> throw new UnsupportedOperationException("should not reach here"); + }); + + static final BinaryOperator OP_UMAX = named("maxUnsigned", + (a, b) -> switch (a) { + case Byte _ -> VectorMath.maxUnsigned((byte) a, (byte) b); + case Short _ -> VectorMath.maxUnsigned((short) a, (short) b); + case Integer _ -> VectorMath.maxUnsigned((int) a, (int) b); + case Long _ -> VectorMath.maxUnsigned((long) a, (long) b); + default -> throw new UnsupportedOperationException("should not reach here"); + }); + + static final BinaryOperator OP_SADD = named("addSaturating", + (a, b) -> switch (a) { + case Byte _ -> VectorMath.addSaturating((byte) a, (byte) b); + case Short _ -> VectorMath.addSaturating((short) a, (short) b); + case Integer _ -> VectorMath.addSaturating((int) a, (int) b); + case Long _ -> VectorMath.addSaturating((long) a, (long) b); + default -> throw new UnsupportedOperationException("should not reach here"); + }); + + static final BinaryOperator OP_SSUB = named("subSaturating", + (a, b) -> switch (a) { + case Byte _ -> VectorMath.subSaturating((byte) a, (byte) b); + case Short _ -> VectorMath.subSaturating((short) a, (short) b); + case Integer _ -> VectorMath.subSaturating((int) a, (int) b); + case Long _ -> VectorMath.subSaturating((long) a, (long) b); + default -> throw new UnsupportedOperationException("should not reach here"); + }); + + static final BinaryOperator OP_SUADD = named("addSaturatingUnsigned", + (a, b) -> switch (a) { + case Byte _ -> VectorMath.addSaturatingUnsigned((byte) a, (byte) b); + case Short _ -> VectorMath.addSaturatingUnsigned((short) a, (short) b); + case Integer _ -> VectorMath.addSaturatingUnsigned((int) a, (int) b); + case Long _ -> VectorMath.addSaturatingUnsigned((long) a, (long) b); + default -> throw new UnsupportedOperationException("should not reach here"); + }); + + static final BinaryOperator OP_SUSUB = named("subSaturatingUnsigned", + (a, b) -> switch (a) { + case Byte _ -> VectorMath.subSaturatingUnsigned((byte) a, (byte) b); + case Short _ -> VectorMath.subSaturatingUnsigned((short) a, (short) b); + case Integer _ -> VectorMath.subSaturatingUnsigned((int) a, (int) b); + case Long _ -> VectorMath.subSaturatingUnsigned((long) a, (long) b); + default -> throw new UnsupportedOperationException("should not reach here"); + }); + + @DataProvider + public static Object[][] opProvider() { + return new Object[][] { + {OP_UMIN, byte.class, INPUT_UB, INPUT_SB, EXPECTED_UMIN_B, }, + {OP_UMIN, short.class, INPUT_US, INPUT_SS, EXPECTED_UMIN_S, }, + {OP_UMIN, int.class, INPUT_UI, INPUT_SI, EXPECTED_UMIN_I, }, + {OP_UMIN, long.class, INPUT_UL, INPUT_SL, EXPECTED_UMIN_L, }, + + {OP_UMAX, byte.class, INPUT_UB, INPUT_SB, EXPECTED_UMAX_B, }, + {OP_UMAX, short.class, INPUT_US, INPUT_SS, EXPECTED_UMAX_S, }, + {OP_UMAX, int.class, INPUT_UI, INPUT_SI, EXPECTED_UMAX_I, }, + {OP_UMAX, long.class, INPUT_UL, INPUT_SL, EXPECTED_UMAX_L, }, + + {OP_SADD, byte.class, INPUT_SB, conv(INPUT_SADD_I, byte.class), EXPECTED_SADD_B, }, + {OP_SADD, short.class, INPUT_SS, conv(INPUT_SADD_I, short.class), EXPECTED_SADD_S, }, + {OP_SADD, int.class, INPUT_SI, INPUT_SADD_I, EXPECTED_SADD_I, }, + {OP_SADD, long.class, INPUT_SL, conv(INPUT_SADD_I, long.class), EXPECTED_SADD_L, }, + + {OP_SSUB, byte.class, INPUT_SB, conv(INPUT_SSUB_I, byte.class), EXPECTED_SSUB_B, }, + {OP_SSUB, short.class, INPUT_SS, conv(INPUT_SSUB_I, short.class), EXPECTED_SSUB_S, }, + {OP_SSUB, int.class, INPUT_SI, INPUT_SSUB_I, EXPECTED_SSUB_I, }, + {OP_SSUB, long.class, INPUT_SL, conv(INPUT_SSUB_I, long.class), EXPECTED_SSUB_L, }, + + {OP_SUADD, byte.class, INPUT_UB, conv(INPUT_SUADD_I, byte.class), EXPECTED_SUADD_B, }, + {OP_SUADD, short.class, INPUT_US, conv(INPUT_SUADD_I, short.class), EXPECTED_SUADD_S, }, + {OP_SUADD, int.class, INPUT_UI, INPUT_SUADD_I, EXPECTED_SUADD_I, }, + {OP_SUADD, long.class, INPUT_UL, conv(INPUT_SUADD_I, long.class), EXPECTED_SUADD_L, }, + + {OP_SUSUB, byte.class, INPUT_UB, conv(INPUT_SUSUB_I, byte.class), EXPECTED_SUSUB_B, }, + {OP_SUSUB, short.class, INPUT_US, conv(INPUT_SUSUB_I, short.class), EXPECTED_SUSUB_S, }, + {OP_SUSUB, int.class, INPUT_UI, INPUT_SUSUB_I, EXPECTED_SUSUB_I, }, + {OP_SUSUB, long.class, INPUT_UL, conv(INPUT_SUSUB_I, long.class), EXPECTED_SUSUB_L, }, + }; + } + + @Test(dataProvider = "opProvider") + public void test(BinaryOperator op, Class type, Object a, Object b, Object expected) { + assert Array.getLength(a) <= Array.getLength(b) && Array.getLength(a) <= Array.getLength(expected); + + Object actual = Array.newInstance(type, Array.getLength(a)); + for (int i = 0; i < Array.getLength(a); i++) { + Object e = op.apply(Array.get(a, i), Array.get(b, i)); + Array.set(actual, i, e); + } + Assert.assertEquals(actual, expected); + } +} diff --git a/test/jdk/jdk/incubator/vector/VectorMaxConversionTests.java b/test/jdk/jdk/incubator/vector/VectorMaxConversionTests.java index 28c5348100a..a8f89f9d705 100644 --- a/test/jdk/jdk/incubator/vector/VectorMaxConversionTests.java +++ b/test/jdk/jdk/incubator/vector/VectorMaxConversionTests.java @@ -41,26 +41,14 @@ */ /* - * @test id=ZSinglegen + * @test id=Z * @bug 8281544 * @summary Test that ZGC and vectorapi with KNL work together. - * @requires vm.gc.ZSinglegen + * @requires vm.gc.Z * @modules jdk.incubator.vector * @modules java.base/jdk.internal.vm.annotation * @run testng/othervm -XX:-TieredCompilation --add-opens jdk.incubator.vector/jdk.incubator.vector=ALL-UNNAMED - * -XX:+UnlockDiagnosticVMOptions -XX:+UseKNLSetting -XX:+UseZGC -XX:-ZGenerational -XX:+IgnoreUnrecognizedVMOptions - * VectorMaxConversionTests - */ - -/* - * @test id=ZGenerational - * @bug 8281544 - * @summary Test that ZGC and vectorapi with KNL work together. - * @requires vm.gc.ZGenerational - * @modules jdk.incubator.vector - * @modules java.base/jdk.internal.vm.annotation - * @run testng/othervm -XX:-TieredCompilation --add-opens jdk.incubator.vector/jdk.incubator.vector=ALL-UNNAMED - * -XX:+UnlockDiagnosticVMOptions -XX:+UseKNLSetting -XX:+UseZGC -XX:+ZGenerational -XX:+IgnoreUnrecognizedVMOptions + * -XX:+UnlockDiagnosticVMOptions -XX:+UseKNLSetting -XX:+UseZGC -XX:+IgnoreUnrecognizedVMOptions * VectorMaxConversionTests */ diff --git a/test/jdk/jdk/incubator/vector/gen-template.sh b/test/jdk/jdk/incubator/vector/gen-template.sh index 375287bef2d..232de04ba7c 100644 --- a/test/jdk/jdk/incubator/vector/gen-template.sh +++ b/test/jdk/jdk/incubator/vector/gen-template.sh @@ -42,6 +42,8 @@ ternary_double_broadcast_masked="Ternary-Double-Broadcast-Masked-op" ternary_scalar="Ternary-Scalar-op" binary="Binary-op" binary_masked="Binary-Masked-op" +saturating_binary="SaturatingBinary-op" +saturating_binary_masked="SaturatingBinary-Masked-op" binary_broadcast="Binary-Broadcast-op" binary_broadcast_masked="Binary-Broadcast-Masked-op" binary_broadcast_long="Binary-Broadcast-Long-op" @@ -310,6 +312,12 @@ function gen_binary_op { gen_op_tmpl $binary_masked "$@" } +function gen_saturating_binary_op { + echo "Generating binary op $1 ($2)..." + gen_op_tmpl $saturating_binary "$@" + gen_op_tmpl $saturating_binary_masked "$@" +} + function gen_binary_op_no_masked { echo "Generating binary op $1 ($2)..." # gen_op_tmpl $binary_scalar "$@" @@ -459,6 +467,12 @@ gen_shift_cst_op "ROL" "ROL_scalar(a, CONST_SHIFT)" "BITWISE" # Masked reductions. gen_binary_op_no_masked "MIN+min" "Math.min(a, b)" gen_binary_op_no_masked "MAX+max" "Math.max(a, b)" +gen_binary_op "UMIN" "VectorMath.minUnsigned(a, b)" "BITWISE" +gen_binary_op "UMAX" "VectorMath.maxUnsigned(a, b)" "BITWISE" +gen_saturating_binary_op "SADD" "VectorMath.addSaturating(a, b)" "BITWISE" +gen_saturating_binary_op "SSUB" "VectorMath.subSaturating(a, b)" "BITWISE" +gen_saturating_binary_op "SUADD" "VectorMath.addSaturatingUnsigned(a, b)" "BITWISE" +gen_saturating_binary_op "SUSUB" "VectorMath.subSaturatingUnsigned(a, b)" "BITWISE" gen_binary_bcst_op_no_masked "MIN+min" "Math.min(a, b)" gen_binary_bcst_op_no_masked "MAX+max" "Math.max(a, b)" @@ -494,10 +508,10 @@ gen_compare_op "NE" "neq" gen_compare_op "LE" "le" gen_compare_op "GE" "ge" -gen_compare_op "UNSIGNED_LT" "ult" "BITWISE" -gen_compare_op "UNSIGNED_GT" "ugt" "BITWISE" -gen_compare_op "UNSIGNED_LE" "ule" "BITWISE" -gen_compare_op "UNSIGNED_GE" "uge" "BITWISE" +gen_compare_op "ULT" "ult" "BITWISE" +gen_compare_op "UGT" "ugt" "BITWISE" +gen_compare_op "ULE" "ule" "BITWISE" +gen_compare_op "UGE" "uge" "BITWISE" gen_compare_bcst_op "LT" "<" diff --git a/test/jdk/jdk/incubator/vector/templates/Kernel-SaturatingBinary-Masked-op.template b/test/jdk/jdk/incubator/vector/templates/Kernel-SaturatingBinary-Masked-op.template new file mode 100644 index 00000000000..495b27b967c --- /dev/null +++ b/test/jdk/jdk/incubator/vector/templates/Kernel-SaturatingBinary-Masked-op.template @@ -0,0 +1,13 @@ + $type$[] a = fa.apply(SPECIES.length()); + $type$[] b = fb.apply(SPECIES.length()); + $type$[] r = fr.apply(SPECIES.length()); + boolean[] mask = fm.apply(SPECIES.length()); + VectorMask<$Wideboxtype$> vmask = VectorMask.fromArray(SPECIES, mask, 0); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + $abstractvectortype$ av = $abstractvectortype$.fromArray(SPECIES, a, i); + $abstractvectortype$ bv = $abstractvectortype$.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.[[TEST]], bv, vmask).intoArray(r, i); + } + } diff --git a/test/jdk/jdk/incubator/vector/templates/Kernel-SaturatingBinary-op.template b/test/jdk/jdk/incubator/vector/templates/Kernel-SaturatingBinary-op.template new file mode 100644 index 00000000000..0870991268f --- /dev/null +++ b/test/jdk/jdk/incubator/vector/templates/Kernel-SaturatingBinary-op.template @@ -0,0 +1,11 @@ + $type$[] a = fa.apply(SPECIES.length()); + $type$[] b = fb.apply(SPECIES.length()); + $type$[] r = fr.apply(SPECIES.length()); + + for (int ic = 0; ic < INVOC_COUNT; ic++) { + for (int i = 0; i < a.length; i += SPECIES.length()) { + $abstractvectortype$ av = $abstractvectortype$.fromArray(SPECIES, a, i); + $abstractvectortype$ bv = $abstractvectortype$.fromArray(SPECIES, b, i); + av.lanewise(VectorOperators.[[TEST]], bv).intoArray(r, i); + } + } diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-SaturatingBinary-Masked-op.template b/test/jdk/jdk/incubator/vector/templates/Unit-SaturatingBinary-Masked-op.template new file mode 100644 index 00000000000..5597d706b05 --- /dev/null +++ b/test/jdk/jdk/incubator/vector/templates/Unit-SaturatingBinary-Masked-op.template @@ -0,0 +1,7 @@ + + @Test(dataProvider = "$type$SaturatingBinaryOpMaskProvider") + static void [[TEST]]$vectorteststype$Masked(IntFunction<$type$[]> fa, IntFunction<$type$[]> fb, + IntFunction fm) { +[[KERNEL]] + assertArraysEquals(r, a, b, mask, $vectorteststype$::[[TEST]]); + } diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-SaturatingBinary-op.template b/test/jdk/jdk/incubator/vector/templates/Unit-SaturatingBinary-op.template new file mode 100644 index 00000000000..69c53fa6913 --- /dev/null +++ b/test/jdk/jdk/incubator/vector/templates/Unit-SaturatingBinary-op.template @@ -0,0 +1,10 @@ + + static $type$ [[TEST]]($type$ a, $type$ b) { + return ($type$)([[TEST_OP]]); + } + + @Test(dataProvider = "$type$SaturatingBinaryOpProvider") + static void [[TEST]]$vectorteststype$(IntFunction<$type$[]> fa, IntFunction<$type$[]> fb) { +[[KERNEL]] + assertArraysEquals(r, a, b, $vectorteststype$::[[TEST]]); + } diff --git a/test/jdk/jdk/incubator/vector/templates/Unit-header.template b/test/jdk/jdk/incubator/vector/templates/Unit-header.template index 2f33ede458a..991f82cc7cf 100644 --- a/test/jdk/jdk/incubator/vector/templates/Unit-header.template +++ b/test/jdk/jdk/incubator/vector/templates/Unit-header.template @@ -38,6 +38,9 @@ import jdk.incubator.vector.VectorShuffle; import jdk.incubator.vector.VectorMask; import jdk.incubator.vector.VectorOperators; import jdk.incubator.vector.Vector; +#if[!FP] +import jdk.incubator.vector.VectorMath; +#end[!FP] #if[Byte] import jdk.incubator.vector.ByteVector; @@ -1221,6 +1224,35 @@ relativeError)); }) ); +#if[!FP] + static final List> $TYPE$_SATURATING_GENERATORS = List.of( + withToString("$type$[$Boxtype$.MIN_VALUE]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> ($type$)($Boxtype$.MIN_VALUE)); + }), + withToString("$type$[$Boxtype$.MAX_VALUE]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> ($type$)($Boxtype$.MAX_VALUE)); + }), + withToString("$type$[$Boxtype$.MAX_VALUE - 100]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> ($type$)($Boxtype$.MAX_VALUE - 100)); + }), + withToString("$type$[$Boxtype$.MIN_VALUE + 100]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> ($type$)($Boxtype$.MIN_VALUE + 100)); + }), + withToString("$type$[-i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> ($type$)(-i * 5)); + }), + withToString("$type$[i * 5]", (int s) -> { + return fill(s * BUFFER_REPS, + i -> ($type$)(i * 5)); + }) + ); + +#end[!FP] // Create combinations of pairs // @@@ Might be sensitive to order e.g. div by 0 static final List>> $TYPE$_GENERATOR_PAIRS = @@ -1228,6 +1260,13 @@ relativeError)); flatMap(fa -> $TYPE$_GENERATORS.stream().skip(1).map(fb -> List.of(fa, fb))). collect(Collectors.toList()); +#if[!FP] + static final List>> $TYPE$_SATURATING_GENERATOR_PAIRS = + Stream.of($TYPE$_GENERATORS.get(0)). + flatMap(fa -> $TYPE$_SATURATING_GENERATORS.stream().skip(1).map(fb -> List.of(fa, fb))). + collect(Collectors.toList()); + +#end[!FP] @DataProvider public Object[][] boolUnaryOpProvider() { return BOOL_ARRAY_GENERATORS.stream(). @@ -1258,12 +1297,31 @@ relativeError)); toArray(Object[][]::new); } +#if[!FP] + @DataProvider + public Object[][] $type$SaturatingBinaryOpProvider() { + return $TYPE$_SATURATING_GENERATOR_PAIRS.stream().map(List::toArray). + toArray(Object[][]::new); + } + +#end[!FP] @DataProvider public Object[][] $type$IndexedOpProvider() { return $TYPE$_GENERATOR_PAIRS.stream().map(List::toArray). toArray(Object[][]::new); } +#if[!FP] + @DataProvider + public Object[][] $type$SaturatingBinaryOpMaskProvider() { + return BOOLEAN_MASK_GENERATORS.stream(). + flatMap(fm -> $TYPE$_SATURATING_GENERATOR_PAIRS.stream().map(lfa -> { + return Stream.concat(lfa.stream(), Stream.of(fm)).toArray(); + })). + toArray(Object[][]::new); + } + +#end[!FP] @DataProvider public Object[][] $type$BinaryOpMaskProvider() { return BOOLEAN_MASK_GENERATORS.stream(). diff --git a/test/jdk/jdk/jfr/event/gc/collection/TestGarbageCollectionEventWithZMajor.java b/test/jdk/jdk/jfr/event/gc/collection/TestGarbageCollectionEventWithZMajor.java index 81e18439b57..3766d9d0d32 100644 --- a/test/jdk/jdk/jfr/event/gc/collection/TestGarbageCollectionEventWithZMajor.java +++ b/test/jdk/jdk/jfr/event/gc/collection/TestGarbageCollectionEventWithZMajor.java @@ -35,10 +35,10 @@ /** * @test - * @requires vm.hasJFR & vm.gc.ZGenerational + * @requires vm.hasJFR & vm.gc.Z * @key jfr * @library /test/lib /test/jdk - * @run main/othervm -Xmx50m -XX:+UseZGC -XX:+ZGenerational -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -Xlog:gc* jdk.jfr.event.gc.collection.TestGarbageCollectionEventWithZMajor + * @run main/othervm -Xmx50m -XX:+UseZGC -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -Xlog:gc* jdk.jfr.event.gc.collection.TestGarbageCollectionEventWithZMajor */ public class TestGarbageCollectionEventWithZMajor { diff --git a/test/jdk/jdk/jfr/event/gc/collection/TestGarbageCollectionEventWithZMinor.java b/test/jdk/jdk/jfr/event/gc/collection/TestGarbageCollectionEventWithZMinor.java index e7e94cf9ff0..c8d681594dd 100644 --- a/test/jdk/jdk/jfr/event/gc/collection/TestGarbageCollectionEventWithZMinor.java +++ b/test/jdk/jdk/jfr/event/gc/collection/TestGarbageCollectionEventWithZMinor.java @@ -40,12 +40,12 @@ /** * @test * @key jfr - * @requires vm.hasJFR & vm.gc.ZGenerational + * @requires vm.hasJFR & vm.gc.Z * @key jfr * @library /test/lib /test/jdk * @build jdk.test.whitebox.WhiteBox * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox - * @run main/othervm -Xbootclasspath/a:. -XX:+UseZGC -XX:+ZGenerational -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -Xlog:gc* jdk.jfr.event.gc.collection.TestGarbageCollectionEventWithZMinor + * @run main/othervm -Xbootclasspath/a:. -XX:+UseZGC -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -Xlog:gc* jdk.jfr.event.gc.collection.TestGarbageCollectionEventWithZMinor */ public class TestGarbageCollectionEventWithZMinor { diff --git a/test/jdk/jdk/jfr/event/gc/collection/TestZOldGarbageCollectionEvent.java b/test/jdk/jdk/jfr/event/gc/collection/TestZOldGarbageCollectionEvent.java index 0f807f4f6e4..50177ffd16b 100644 --- a/test/jdk/jdk/jfr/event/gc/collection/TestZOldGarbageCollectionEvent.java +++ b/test/jdk/jdk/jfr/event/gc/collection/TestZOldGarbageCollectionEvent.java @@ -35,10 +35,10 @@ /** * @test - * @requires vm.hasJFR & vm.gc.ZGenerational + * @requires vm.hasJFR & vm.gc.Z * @key jfr * @library /test/lib /test/jdk - * @run main/othervm -Xmx50m -XX:+UseZGC -XX:+ZGenerational -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -Xlog:gc* jdk.jfr.event.gc.collection.TestZOldGarbageCollectionEvent + * @run main/othervm -Xmx50m -XX:+UseZGC -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -Xlog:gc* jdk.jfr.event.gc.collection.TestZOldGarbageCollectionEvent */ public class TestZOldGarbageCollectionEvent { diff --git a/test/jdk/jdk/jfr/event/gc/collection/TestZYoungGarbageCollectionEvent.java b/test/jdk/jdk/jfr/event/gc/collection/TestZYoungGarbageCollectionEvent.java index c16bdaa5d64..f8e4e8b344b 100644 --- a/test/jdk/jdk/jfr/event/gc/collection/TestZYoungGarbageCollectionEvent.java +++ b/test/jdk/jdk/jfr/event/gc/collection/TestZYoungGarbageCollectionEvent.java @@ -35,10 +35,10 @@ /** * @test - * @requires vm.hasJFR & vm.gc.ZGenerational + * @requires vm.hasJFR & vm.gc.Z * @key jfr * @library /test/lib /test/jdk - * @run main/othervm -Xmx50m -XX:+UseZGC -XX:+ZGenerational -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -Xlog:gc* jdk.jfr.event.gc.collection.TestZYoungGarbageCollectionEvent + * @run main/othervm -Xmx50m -XX:+UseZGC -XX:+UnlockExperimentalVMOptions -XX:-UseFastUnorderedTimeStamps -Xlog:gc* jdk.jfr.event.gc.collection.TestZYoungGarbageCollectionEvent */ public class TestZYoungGarbageCollectionEvent { diff --git a/test/jdk/jdk/jfr/event/gc/detailed/TestGCPhaseConcurrent.java b/test/jdk/jdk/jfr/event/gc/detailed/TestGCPhaseConcurrent.java index fb048ee6bd7..48e188346f8 100644 --- a/test/jdk/jdk/jfr/event/gc/detailed/TestGCPhaseConcurrent.java +++ b/test/jdk/jdk/jfr/event/gc/detailed/TestGCPhaseConcurrent.java @@ -31,19 +31,11 @@ import jdk.test.lib.jfr.Events; /** - * @test id=ZGenerational + * @test id=Z * @key jfr * @library /test/lib /test/jdk /test/hotspot/jtreg - * @requires vm.hasJFR & vm.gc.ZGenerational - * @run main/othervm -XX:+UseZGC -XX:+ZGenerational -Xmx32M jdk.jfr.event.gc.detailed.TestGCPhaseConcurrent Z - */ - -/** - * @test id=ZSinglegen - * @key jfr - * @library /test/lib /test/jdk /test/hotspot/jtreg - * @requires vm.hasJFR & vm.gc.ZSinglegen - * @run main/othervm -XX:+UseZGC -XX:-ZGenerational -Xmx32M jdk.jfr.event.gc.detailed.TestGCPhaseConcurrent X + * @requires vm.hasJFR & vm.gc.Z + * @run main/othervm -XX:+UseZGC -Xmx32M jdk.jfr.event.gc.detailed.TestGCPhaseConcurrent Z */ /** diff --git a/test/jdk/jdk/jfr/event/gc/detailed/TestZAllocationStallEvent.java b/test/jdk/jdk/jfr/event/gc/detailed/TestZAllocationStallEvent.java index 8977a574a62..1b4ce259784 100644 --- a/test/jdk/jdk/jfr/event/gc/detailed/TestZAllocationStallEvent.java +++ b/test/jdk/jdk/jfr/event/gc/detailed/TestZAllocationStallEvent.java @@ -32,19 +32,11 @@ import jdk.test.lib.jfr.Events; /** - * @test id=ZSinglegen - * @requires vm.hasJFR & vm.gc.ZSinglegen + * @test + * @requires vm.hasJFR & vm.gc.Z * @key jfr * @library /test/lib /test/jdk /test/hotspot/jtreg - * @run main/othervm -XX:+UseZGC -XX:-ZGenerational -Xmx32M -Xlog:gc*:gc.log::filecount=0 jdk.jfr.event.gc.detailed.TestZAllocationStallEvent - */ - -/** - * @test id=ZGenerational - * @requires vm.hasJFR & vm.gc.ZGenerational - * @key jfr - * @library /test/lib /test/jdk /test/hotspot/jtreg - * @run main/othervm -XX:+UseZGC -XX:+ZGenerational -Xmx32M -Xlog:gc*:gc.log::filecount=0 jdk.jfr.event.gc.detailed.TestZAllocationStallEvent + * @run main/othervm -XX:+UseZGC -Xmx32M -Xlog:gc*:gc.log::filecount=0 jdk.jfr.event.gc.detailed.TestZAllocationStallEvent */ public class TestZAllocationStallEvent { diff --git a/test/jdk/jdk/jfr/event/gc/detailed/TestZPageAllocationEvent.java b/test/jdk/jdk/jfr/event/gc/detailed/TestZPageAllocationEvent.java index 182f7b3d509..d672a2654b8 100644 --- a/test/jdk/jdk/jfr/event/gc/detailed/TestZPageAllocationEvent.java +++ b/test/jdk/jdk/jfr/event/gc/detailed/TestZPageAllocationEvent.java @@ -32,19 +32,11 @@ import jdk.test.lib.jfr.Events; /** - * @test id=ZSinglegen - * @requires vm.hasJFR & vm.gc.ZSinglegen + * @test + * @requires vm.hasJFR & vm.gc.Z * @key jfr * @library /test/lib /test/jdk /test/hotspot/jtreg - * @run main/othervm -XX:+UseZGC -XX:-ZGenerational -Xmx32M jdk.jfr.event.gc.detailed.TestZPageAllocationEvent - */ - -/** - * @test id=ZGenerational - * @requires vm.hasJFR & vm.gc.ZGenerational - * @key jfr - * @library /test/lib /test/jdk /test/hotspot/jtreg - * @run main/othervm -XX:+UseZGC -XX:+ZGenerational -Xmx32M jdk.jfr.event.gc.detailed.TestZPageAllocationEvent + * @run main/othervm -XX:+UseZGC -Xmx32M jdk.jfr.event.gc.detailed.TestZPageAllocationEvent */ public class TestZPageAllocationEvent { diff --git a/test/jdk/jdk/jfr/event/gc/detailed/TestZRelocationSetEvent.java b/test/jdk/jdk/jfr/event/gc/detailed/TestZRelocationSetEvent.java index 8f07abeaaef..f14eec97548 100644 --- a/test/jdk/jdk/jfr/event/gc/detailed/TestZRelocationSetEvent.java +++ b/test/jdk/jdk/jfr/event/gc/detailed/TestZRelocationSetEvent.java @@ -32,19 +32,11 @@ import jdk.test.lib.jfr.Events; /** - * @test id=ZSinglegen - * @requires vm.hasJFR & vm.gc.ZSinglegen + * @test + * @requires vm.hasJFR & vm.gc.Z * @key jfr * @library /test/lib /test/jdk /test/hotspot/jtreg - * @run main/othervm -XX:+UseZGC -XX:-ZGenerational -Xmx32M jdk.jfr.event.gc.detailed.TestZRelocationSetEvent - */ - -/** - * @test id=ZGenerational - * @requires vm.hasJFR & vm.gc.ZGenerational - * @key jfr - * @library /test/lib /test/jdk /test/hotspot/jtreg - * @run main/othervm -XX:+UseZGC -XX:+ZGenerational -Xmx32M jdk.jfr.event.gc.detailed.TestZRelocationSetEvent + * @run main/othervm -XX:+UseZGC -Xmx32M jdk.jfr.event.gc.detailed.TestZRelocationSetEvent */ public class TestZRelocationSetEvent { diff --git a/test/jdk/jdk/jfr/event/gc/detailed/TestZRelocationSetGroupEvent.java b/test/jdk/jdk/jfr/event/gc/detailed/TestZRelocationSetGroupEvent.java index b997d173ffb..f00655cf942 100644 --- a/test/jdk/jdk/jfr/event/gc/detailed/TestZRelocationSetGroupEvent.java +++ b/test/jdk/jdk/jfr/event/gc/detailed/TestZRelocationSetGroupEvent.java @@ -32,19 +32,11 @@ import jdk.test.lib.jfr.Events; /** - * @test id=ZSinglegen - * @requires vm.hasJFR & vm.gc.ZSinglegen + * @test + * @requires vm.hasJFR & vm.gc.Z * @key jfr * @library /test/lib /test/jdk /test/hotspot/jtreg - * @run main/othervm -XX:+UseZGC -XX:-ZGenerational -Xmx32M jdk.jfr.event.gc.detailed.TestZRelocationSetGroupEvent - */ - -/** - * @test id=ZGenerational - * @requires vm.hasJFR & vm.gc.ZGenerational - * @key jfr - * @library /test/lib /test/jdk /test/hotspot/jtreg - * @run main/othervm -XX:+UseZGC -XX:+ZGenerational -Xmx32M jdk.jfr.event.gc.detailed.TestZRelocationSetGroupEvent + * @run main/othervm -XX:+UseZGC -Xmx32M jdk.jfr.event.gc.detailed.TestZRelocationSetGroupEvent */ public class TestZRelocationSetGroupEvent { diff --git a/test/jdk/jdk/jfr/event/gc/detailed/TestZUncommitEvent.java b/test/jdk/jdk/jfr/event/gc/detailed/TestZUncommitEvent.java index 06fd9b5a1b8..e7a37e2de55 100644 --- a/test/jdk/jdk/jfr/event/gc/detailed/TestZUncommitEvent.java +++ b/test/jdk/jdk/jfr/event/gc/detailed/TestZUncommitEvent.java @@ -34,19 +34,11 @@ import jdk.test.lib.jfr.Events; /** - * @test id=ZSinglegen - * @requires vm.hasJFR & vm.gc.ZSinglegen + * @test id=Z + * @requires vm.hasJFR & vm.gc.Z * @key jfr * @library /test/lib /test/jdk /test/hotspot/jtreg - * @run main/othervm -XX:+UseZGC -XX:-ZGenerational -Xms32M -Xmx128M -Xlog:gc,gc+heap -XX:+ZUncommit -XX:ZUncommitDelay=1 jdk.jfr.event.gc.detailed.TestZUncommitEvent - */ - -/** - * @test id=ZGenerational - * @requires vm.hasJFR & vm.gc.ZGenerational - * @key jfr - * @library /test/lib /test/jdk /test/hotspot/jtreg - * @run main/othervm -XX:+UseZGC -XX:+ZGenerational -Xms32M -Xmx128M -Xlog:gc,gc+heap -XX:+ZUncommit -XX:ZUncommitDelay=1 jdk.jfr.event.gc.detailed.TestZUncommitEvent + * @run main/othervm -XX:+UseZGC -Xms32M -Xmx128M -Xlog:gc,gc+heap -XX:+ZUncommit -XX:ZUncommitDelay=1 jdk.jfr.event.gc.detailed.TestZUncommitEvent */ public class TestZUncommitEvent { diff --git a/test/jdk/jdk/jfr/event/gc/detailed/TestZUnmapEvent.java b/test/jdk/jdk/jfr/event/gc/detailed/TestZUnmapEvent.java index 94460f8f278..a19e89771c0 100644 --- a/test/jdk/jdk/jfr/event/gc/detailed/TestZUnmapEvent.java +++ b/test/jdk/jdk/jfr/event/gc/detailed/TestZUnmapEvent.java @@ -32,19 +32,11 @@ import jdk.test.lib.jfr.Events; /** - * @test id=ZSinglegen - * @requires vm.hasJFR & vm.gc.ZSinglegen + * @test id=Z + * @requires vm.hasJFR & vm.gc.Z * @key jfr * @library /test/lib /test/jdk /test/hotspot/jtreg - * @run main/othervm -XX:+UseZGC -XX:-ZGenerational -Xmx32M jdk.jfr.event.gc.detailed.TestZUnmapEvent - */ - -/** - * @test id=ZGenerational - * @requires vm.hasJFR & vm.gc.ZGenerational - * @key jfr - * @library /test/lib /test/jdk /test/hotspot/jtreg - * @run main/othervm -XX:+UseZGC -XX:+ZGenerational -Xmx32M jdk.jfr.event.gc.detailed.TestZUnmapEvent + * @run main/othervm -XX:+UseZGC -Xmx32M jdk.jfr.event.gc.detailed.TestZUnmapEvent */ public class TestZUnmapEvent { diff --git a/test/jdk/jdk/jfr/event/oldobject/TestZ.java b/test/jdk/jdk/jfr/event/oldobject/TestZ.java index 224a1237324..99605846382 100644 --- a/test/jdk/jdk/jfr/event/oldobject/TestZ.java +++ b/test/jdk/jdk/jfr/event/oldobject/TestZ.java @@ -33,23 +33,13 @@ import jdk.test.lib.jfr.Events; /** - * @test id=ZSinglegen - * @requires vm.hasJFR & vm.gc.ZSinglegen + * @test + * @requires vm.hasJFR & vm.gc.Z * @key jfr * @summary Test leak profiler with ZGC * @library /test/lib /test/jdk * @modules jdk.jfr/jdk.jfr.internal.test - * @run main/othervm -XX:TLABSize=2k -XX:+UseZGC -XX:-ZGenerational jdk.jfr.event.oldobject.TestZ - */ - -/** - * @test id=ZGenerational - * @requires vm.hasJFR & vm.gc.ZGenerational - * @key jfr - * @summary Test leak profiler with ZGC - * @library /test/lib /test/jdk - * @modules jdk.jfr/jdk.jfr.internal.test - * @run main/othervm -XX:TLABSize=2k -XX:+UseZGC -XX:+ZGenerational jdk.jfr.event.oldobject.TestZ + * @run main/othervm -XX:TLABSize=2k -XX:+UseZGC jdk.jfr.event.oldobject.TestZ */ public class TestZ { diff --git a/test/jdk/jdk/security/jarsigner/Spec.java b/test/jdk/jdk/security/jarsigner/Spec.java index 0e189babb8b..5ca3b11cd96 100644 --- a/test/jdk/jdk/security/jarsigner/Spec.java +++ b/test/jdk/jdk/security/jarsigner/Spec.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,6 +36,7 @@ import jdk.security.jarsigner.JarSigner; import jdk.test.lib.util.JarUtils; +import jdk.test.lib.security.SecurityUtils; import sun.security.provider.certpath.X509CertPath; import java.io.File; @@ -175,14 +176,16 @@ public static void main(String[] args) throws Exception { .equals("SHA-384")); // Calculating large DSA and RSA keys are too slow. - KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA"); - kpg.initialize(1024); + String kpgRSA = "RSA"; + String kpgDSA = "DSA"; + KeyPairGenerator kpg = KeyPairGenerator.getInstance(kpgRSA); + kpg.initialize(SecurityUtils.getTestKeySize(kpgRSA)); assertTrue(JarSigner.Builder .getDefaultSignatureAlgorithm(kpg.generateKeyPair().getPrivate()) .equals("SHA384withRSA")); - kpg = KeyPairGenerator.getInstance("DSA"); - kpg.initialize(1024); + kpg = KeyPairGenerator.getInstance(kpgDSA); + kpg.initialize(SecurityUtils.getTestKeySize(kpgDSA)); assertTrue(JarSigner.Builder .getDefaultSignatureAlgorithm(kpg.generateKeyPair().getPrivate()) .equals("SHA256withDSA")); diff --git a/test/jdk/sun/security/ec/ECDSAPrimitive.java b/test/jdk/sun/security/ec/ECDSAPrimitive.java index ba9ed0dec80..71e2e30044b 100644 --- a/test/jdk/sun/security/ec/ECDSAPrimitive.java +++ b/test/jdk/sun/security/ec/ECDSAPrimitive.java @@ -93,7 +93,8 @@ public static void main(String[] args) throws Exception { digestAlg = null; } else { AlgorithmParameters params = - AlgorithmParameters.getInstance("EC", "SunEC"); + AlgorithmParameters.getInstance("EC", + System.getProperty("test.provider.name", "SunEC")); params.init(new ECGenParameterSpec(curveName)); ecParams = params.getParameterSpec( ECParameterSpec.class); diff --git a/test/jdk/sun/security/ec/ECDSAPrvGreaterThanOrder.java b/test/jdk/sun/security/ec/ECDSAPrvGreaterThanOrder.java index 40f52d534a7..f5a02971dbf 100644 --- a/test/jdk/sun/security/ec/ECDSAPrvGreaterThanOrder.java +++ b/test/jdk/sun/security/ec/ECDSAPrvGreaterThanOrder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -52,7 +52,7 @@ public static void main(String[] args) throws Exception { KeyAgreement ka = null; try { sig = Signature.getInstance("SHA256withECDSA", - "SunEC"); + System.getProperty("test.provider.name", "SunEC")); sig.initSign(ecPrivKey); throw new RuntimeException("Expected exception for " + "ECDSA/" + sig.getAlgorithm() + "/" + curveName + @@ -66,7 +66,8 @@ public static void main(String[] args) throws Exception { // Next, try starting a ECDH operation try { - ka = KeyAgreement.getInstance("ECDH", "SunEC"); + ka = KeyAgreement.getInstance("ECDH", + System.getProperty("test.provider.name", "SunEC")); ka.init(ecPrivKey); throw new RuntimeException("Expected exception for ECDH/" + curveName + " not thrown."); @@ -83,7 +84,7 @@ private static ECPrivateKey makePrivateKey(String curveName) { System.out.println("Creating private key for curve " + curveName); AlgorithmParameters params = AlgorithmParameters.getInstance( - "EC", "SunEC"); + "EC", System.getProperty("test.provider.name", "SunEC")); params.init(new ECGenParameterSpec(curveName)); ECParameterSpec ecParameters = params.getParameterSpec( ECParameterSpec.class); @@ -96,7 +97,8 @@ private static ECPrivateKey makePrivateKey(String curveName) { System.out.println("Modified d Value is: " + dVal); // Create the private key - KeyFactory kf = KeyFactory.getInstance("EC", "SunEC"); + KeyFactory kf = KeyFactory.getInstance("EC", + System.getProperty("test.provider.name", "SunEC")); return (ECPrivateKey)kf.generatePrivate( new ECPrivateKeySpec(dVal, ecParameters)); } catch (GeneralSecurityException gse) { diff --git a/test/jdk/sun/security/ec/InvalidCurve.java b/test/jdk/sun/security/ec/InvalidCurve.java index 4c696970b84..76d3b6b79e6 100644 --- a/test/jdk/sun/security/ec/InvalidCurve.java +++ b/test/jdk/sun/security/ec/InvalidCurve.java @@ -38,7 +38,8 @@ public static void main(String[] args) { KeyPairGenerator keyGen; try { - keyGen = KeyPairGenerator.getInstance("EC", "SunEC"); + keyGen = KeyPairGenerator.getInstance("EC", + System.getProperty("test.provider.name", "SunEC")); ECGenParameterSpec brainpoolSpec = new ECGenParameterSpec("brainpoolP160r1"); keyGen.initialize(brainpoolSpec); diff --git a/test/jdk/sun/security/ec/NSASuiteB/TestSHAwithECDSASignatureOids.java b/test/jdk/sun/security/ec/NSASuiteB/TestSHAwithECDSASignatureOids.java index cca4e77befb..ba209d7e429 100644 --- a/test/jdk/sun/security/ec/NSASuiteB/TestSHAwithECDSASignatureOids.java +++ b/test/jdk/sun/security/ec/NSASuiteB/TestSHAwithECDSASignatureOids.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -45,7 +45,7 @@ public class TestSHAwithECDSASignatureOids { public static void main(String[] args) throws Exception { TestSignatureOidHelper helper = new TestSignatureOidHelper("EC", - "SunEC", 256, DATA); + System.getProperty("test.provider.name", "SunEC"), 256, DATA); helper.execute(); } } diff --git a/test/jdk/sun/security/ec/OidInstance.java b/test/jdk/sun/security/ec/OidInstance.java index 972c8e1026a..590ddce305e 100644 --- a/test/jdk/sun/security/ec/OidInstance.java +++ b/test/jdk/sun/security/ec/OidInstance.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,8 +38,8 @@ public class OidInstance { public static void main(String[] args) throws Exception { String oid = KnownOIDs.EC.value(); - KeyFactory.getInstance(oid, "SunEC"); - KeyPairGenerator.getInstance(oid, "SunEC"); - AlgorithmParameters.getInstance(oid, "SunEC"); + KeyFactory.getInstance(oid, System.getProperty("test.provider.name", "SunEC")); + KeyPairGenerator.getInstance(oid, System.getProperty("test.provider.name", "SunEC")); + AlgorithmParameters.getInstance(oid, System.getProperty("test.provider.name", "SunEC")); } } diff --git a/test/jdk/sun/security/ec/SignatureDigestTruncate.java b/test/jdk/sun/security/ec/SignatureDigestTruncate.java index 47f0123a491..99048f85137 100644 --- a/test/jdk/sun/security/ec/SignatureDigestTruncate.java +++ b/test/jdk/sun/security/ec/SignatureDigestTruncate.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -96,17 +96,20 @@ private static void runTest(String alg, String curveName, byte[] expectedSig = hex.parseHex(sigStr); AlgorithmParameters params = - AlgorithmParameters.getInstance("EC", "SunEC"); + AlgorithmParameters.getInstance("EC", + System.getProperty("test.provider.name", "SunEC")); params.init(new ECGenParameterSpec(curveName)); ECParameterSpec ecParams = params.getParameterSpec(ECParameterSpec.class); - KeyFactory kf = KeyFactory.getInstance("EC", "SunEC"); + KeyFactory kf = KeyFactory.getInstance("EC", + System.getProperty("test.provider.name", "SunEC")); BigInteger s = new BigInteger(1, privateKey); ECPrivateKeySpec privKeySpec = new ECPrivateKeySpec(s, ecParams); PrivateKey privKey = kf.generatePrivate(privKeySpec); - Signature sig = Signature.getInstance(alg, "SunEC"); + Signature sig = Signature.getInstance(alg, + System.getProperty("test.provider.name", "SunEC")); sig.initSign(privKey, new FixedRandom(k)); sig.update(msg); byte[] computedSig = sig.sign(); diff --git a/test/jdk/sun/security/ec/SignatureKAT.java b/test/jdk/sun/security/ec/SignatureKAT.java index 542d90d6ca5..802c74f3b69 100644 --- a/test/jdk/sun/security/ec/SignatureKAT.java +++ b/test/jdk/sun/security/ec/SignatureKAT.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -132,16 +132,19 @@ private static void runTest(TestData td) throws Exception { System.out.println("Testing " + td.sigName + " with " + td.cd.name); AlgorithmParameters params = - AlgorithmParameters.getInstance("EC", "SunEC"); + AlgorithmParameters.getInstance("EC", + System.getProperty("test.provider.name", "SunEC")); params.init(new ECGenParameterSpec(td.cd.name)); ECParameterSpec ecParams = params.getParameterSpec(ECParameterSpec.class); - KeyFactory kf = KeyFactory.getInstance("EC", "SunEC"); + KeyFactory kf = KeyFactory.getInstance("EC", + System.getProperty("test.provider.name", "SunEC")); PrivateKey privKey = kf.generatePrivate (new ECPrivateKeySpec(td.cd.priv, ecParams)); - Signature sig = Signature.getInstance(td.sigName, "SunEC"); + Signature sig = Signature.getInstance(td.sigName, + System.getProperty("test.provider.name", "SunEC")); sig.initSign(privKey); sig.update(td.cd.msgBytes); // NOTE: there is no way to set the nonce value into current SunEC diff --git a/test/jdk/sun/security/ec/SignedObjectChain.java b/test/jdk/sun/security/ec/SignedObjectChain.java index cfeff8c1ad5..e245a6caa2d 100644 --- a/test/jdk/sun/security/ec/SignedObjectChain.java +++ b/test/jdk/sun/security/ec/SignedObjectChain.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,7 +35,7 @@ public class SignedObjectChain { private static class Test extends Chain.Test { public Test(Chain.SigAlg sigAlg) { - super(sigAlg, Chain.KeyAlg.EC, Chain.Provider.SunEC); + super(sigAlg, Chain.KeyAlg.EC, Chain.Provider.TestProvider_or_SunEC); } } diff --git a/test/jdk/sun/security/ec/TestEC.java b/test/jdk/sun/security/ec/TestEC.java index de4f47ca5ed..dacb67ce892 100644 --- a/test/jdk/sun/security/ec/TestEC.java +++ b/test/jdk/sun/security/ec/TestEC.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -85,7 +85,7 @@ public static void main(String[] args) throws Exception { } public static void main0(String[] args) throws Exception { - Provider p = Security.getProvider("SunEC"); + Provider p = Security.getProvider(System.getProperty("test.provider.name", "SunEC")); if (p == null) { throw new NoSuchProviderException("Can't get SunEC provider"); diff --git a/test/jdk/sun/security/ec/ed/EdCRLSign.java b/test/jdk/sun/security/ec/ed/EdCRLSign.java index 4ed512b8f20..10a801f4f5f 100644 --- a/test/jdk/sun/security/ec/ed/EdCRLSign.java +++ b/test/jdk/sun/security/ec/ed/EdCRLSign.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,7 +44,7 @@ public class EdCRLSign { private static final String OID25519 = "OID.1.3.101.112"; private static final String OIDN448 = "1.3.101.113"; private static final String OID448 = "OID.1.3.101.113"; - private static final String PROVIDER = "SunEC"; + private static final String PROVIDER = System.getProperty("test.provider.name", "SunEC"); private static final SecureRandom S_RND = new SecureRandom(new byte[]{0x1}); public static void main(String[] args) throws Exception { diff --git a/test/jdk/sun/security/ec/ed/EdDSAKeyCompatibility.java b/test/jdk/sun/security/ec/ed/EdDSAKeyCompatibility.java index 4240ec53477..f3796073b71 100644 --- a/test/jdk/sun/security/ec/ed/EdDSAKeyCompatibility.java +++ b/test/jdk/sun/security/ec/ed/EdDSAKeyCompatibility.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -54,7 +54,7 @@ public class EdDSAKeyCompatibility { private static final String EDDSA = "EdDSA"; private static final String ED25519 = "Ed25519"; private static final String ED448 = "Ed448"; - private static final String PROVIDER = "SunEC"; + private static final String PROVIDER = System.getProperty("test.provider.name", "SunEC"); public static void main(String[] args) throws Exception { diff --git a/test/jdk/sun/security/ec/ed/EdDSAKeySize.java b/test/jdk/sun/security/ec/ed/EdDSAKeySize.java index d5a6bec6f5a..8cb207c8fe2 100644 --- a/test/jdk/sun/security/ec/ed/EdDSAKeySize.java +++ b/test/jdk/sun/security/ec/ed/EdDSAKeySize.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -60,7 +60,7 @@ public class EdDSAKeySize { private static final String OID25519 = "OID.1.3.101.112"; private static final String OIDN448 = "1.3.101.113"; private static final String OID448 = "OID.1.3.101.113"; - private static final String PROVIDER = "SunEC"; + private static final String PROVIDER = System.getProperty("test.provider.name", "SunEC"); private static final SecureRandom RND = new SecureRandom(new byte[]{0x1}); public static void main(String[] args) throws Exception { diff --git a/test/jdk/sun/security/ec/ed/EdDSANegativeTest.java b/test/jdk/sun/security/ec/ed/EdDSANegativeTest.java index c03249e8553..ba45be67575 100644 --- a/test/jdk/sun/security/ec/ed/EdDSANegativeTest.java +++ b/test/jdk/sun/security/ec/ed/EdDSANegativeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -48,7 +48,7 @@ public class EdDSANegativeTest { private static final String EDDSA = "EdDSA"; private static final String ED25519 = "Ed25519"; private static final String ED448 = "Ed448"; - private static final String PROVIDER = "SunEC"; + private static final String PROVIDER = System.getProperty("test.provider.name", "SunEC"); private static final String OTHER = "other"; private static final byte[] MSG = "TEST".getBytes(); diff --git a/test/jdk/sun/security/ec/ed/EdDSAParamSpec.java b/test/jdk/sun/security/ec/ed/EdDSAParamSpec.java index 046134f220d..b13f51a74a7 100644 --- a/test/jdk/sun/security/ec/ed/EdDSAParamSpec.java +++ b/test/jdk/sun/security/ec/ed/EdDSAParamSpec.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -43,7 +43,7 @@ public class EdDSAParamSpec { private static final String EDDSA = "EdDSA"; private static final String ED25519 = "Ed25519"; private static final String ED448 = "Ed448"; - private static final String PROVIDER = "SunEC"; + private static final String PROVIDER = System.getProperty("test.provider.name", "SunEC"); private static final byte[] MSG = "TEST".getBytes(); private static final SecureRandom RND = new SecureRandom(new byte[]{0x1}); diff --git a/test/jdk/sun/security/ec/ed/EdDSAReuseTest.java b/test/jdk/sun/security/ec/ed/EdDSAReuseTest.java index bebabb8539f..9e40b572513 100644 --- a/test/jdk/sun/security/ec/ed/EdDSAReuseTest.java +++ b/test/jdk/sun/security/ec/ed/EdDSAReuseTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,7 +42,7 @@ public class EdDSAReuseTest { private static final String EDDSA = "EdDSA"; private static final String ED25519 = "Ed25519"; private static final String ED448 = "Ed448"; - private static final String PROVIDER = "SunEC"; + private static final String PROVIDER = System.getProperty("test.provider.name", "SunEC"); private static final String MSG = "TEST"; private static final int REUSE = 20; private static final int ONCE = 1; diff --git a/test/jdk/sun/security/ec/ed/EdDSATest.java b/test/jdk/sun/security/ec/ed/EdDSATest.java index 5ba06b8970a..c154bca4252 100644 --- a/test/jdk/sun/security/ec/ed/EdDSATest.java +++ b/test/jdk/sun/security/ec/ed/EdDSATest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -68,7 +68,7 @@ public class EdDSATest { private static final String OID25519 = "OID.1.3.101.112"; private static final String OIDN448 = "1.3.101.113"; private static final String OID448 = "OID.1.3.101.113"; - private static final String PROVIDER = "SunEC"; + private static final String PROVIDER = System.getProperty("test.provider.name", "SunEC"); private static final byte[] MSG = "TEST".getBytes(); private static final SecureRandom S_RND = new SecureRandom(new byte[]{0x1}); diff --git a/test/jdk/sun/security/ec/ed/TestEdDSA.java b/test/jdk/sun/security/ec/ed/TestEdDSA.java index 511d92ab997..1990638496f 100644 --- a/test/jdk/sun/security/ec/ed/TestEdDSA.java +++ b/test/jdk/sun/security/ec/ed/TestEdDSA.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -462,10 +462,14 @@ private static void runBasicTest(String name, Object param) * when the algorithm ID for a specific curve is specified. */ private static void runCurveMixTest() throws Exception { - runCurveMixTest("SunEC", "Ed25519", 448); - runCurveMixTest("SunEC", "Ed25519", "Ed448"); - runCurveMixTest("SunEC", "Ed448", 255); - runCurveMixTest("SunEC", "Ed448", "Ed25519"); + runCurveMixTest(System.getProperty("test.provider.name", "SunEC"), + "Ed25519", 448); + runCurveMixTest(System.getProperty("test.provider.name", "SunEC"), + "Ed25519", "Ed448"); + runCurveMixTest(System.getProperty("test.provider.name", "SunEC"), + "Ed448", 255); + runCurveMixTest(System.getProperty("test.provider.name", "SunEC"), + "Ed448", "Ed25519"); } private static void runCurveMixTest(String providerName, String name, diff --git a/test/jdk/sun/security/jca/PreferredProviderNegativeTest.java b/test/jdk/sun/security/jca/PreferredProviderNegativeTest.java index 58bcbe91153..cd74b5164d3 100644 --- a/test/jdk/sun/security/jca/PreferredProviderNegativeTest.java +++ b/test/jdk/sun/security/jca/PreferredProviderNegativeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -107,7 +107,7 @@ public static void main(String[] args) String expected; String value = args[1]; - expected = "SunJCE"; + expected = System.getProperty("test.provider.name", "SunJCE"); if (args.length >= 2) { switch (args[0]) { diff --git a/test/jdk/sun/security/mscapi/InteropWithSunRsaSign.java b/test/jdk/sun/security/mscapi/InteropWithSunRsaSign.java index cc01caca17c..1494c175c7a 100644 --- a/test/jdk/sun/security/mscapi/InteropWithSunRsaSign.java +++ b/test/jdk/sun/security/mscapi/InteropWithSunRsaSign.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -103,11 +103,13 @@ static void matrix(PSSParameterSpec pss) throws Exception { "-------", "----------------", "------", "--------", "------"); // KeyPairGenerator chooses SPI when getInstance() is called. - String[] provsForKPG = {"SunRsaSign", "SunMSCAPI"}; + String[] provsForKPG = {System.getProperty("test.provider.name", "SunRsaSign"), + "SunMSCAPI"}; // "-" means no preferred provider. In this case, SPI is chosen // when initSign/initVerify is called. Worth testing. - String[] provsForSignature = {"SunRsaSign", "SunMSCAPI", "-"}; + String[] provsForSignature = {System.getProperty("test.provider.name", "SunRsaSign"), + "SunMSCAPI", "-"}; int pos = 0; for (String pg : provsForKPG) { diff --git a/test/jdk/sun/security/pkcs/pkcs8/TestLeadingZeros.java b/test/jdk/sun/security/pkcs/pkcs8/TestLeadingZeros.java index 92a20450157..4291f4e25c1 100644 --- a/test/jdk/sun/security/pkcs/pkcs8/TestLeadingZeros.java +++ b/test/jdk/sun/security/pkcs/pkcs8/TestLeadingZeros.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -50,7 +50,8 @@ public class TestLeadingZeros { }; public static void main(String[] argv) throws Exception { - KeyFactory factory = KeyFactory.getInstance("DSA", "SUN"); + KeyFactory factory = KeyFactory.getInstance("DSA", + System.getProperty("test.provider.name", "SUN")); for (String encodings : PKCS8_ENCODINGS) { byte[] encodingBytes = hexToBytes(encodings); diff --git a/test/jdk/sun/security/pkcs11/Cipher/EncryptionPadding.java b/test/jdk/sun/security/pkcs11/Cipher/EncryptionPadding.java index 8757c0bab7a..7e1f0561f6c 100644 --- a/test/jdk/sun/security/pkcs11/Cipher/EncryptionPadding.java +++ b/test/jdk/sun/security/pkcs11/Cipher/EncryptionPadding.java @@ -93,9 +93,10 @@ private static void testWithInputSize(Provider p, int inputSize, sunPKCS11cipher.doFinal(ByteBuffer.allocate(0), cipherText); } - Cipher sunJCECipher = Cipher.getInstance(transformation, "SunJCE"); - sunJCECipher.init(Cipher.DECRYPT_MODE, key); - byte[] sunJCEPlain = sunJCECipher.doFinal(cipherText.array()); + Cipher providerCipher = Cipher.getInstance(transformation, + System.getProperty("test.provider.name", "SunJCE")); + providerCipher.init(Cipher.DECRYPT_MODE, key); + byte[] sunJCEPlain = providerCipher.doFinal(cipherText.array()); if (!Arrays.equals(plainText, sunJCEPlain)) { throw new Exception("Cross-provider cipher test failed."); diff --git a/test/jdk/sun/security/pkcs11/Cipher/KeyWrap/NISTWrapKAT.java b/test/jdk/sun/security/pkcs11/Cipher/KeyWrap/NISTWrapKAT.java index e6724d38321..e1f32ea8076 100644 --- a/test/jdk/sun/security/pkcs11/Cipher/KeyWrap/NISTWrapKAT.java +++ b/test/jdk/sun/security/pkcs11/Cipher/KeyWrap/NISTWrapKAT.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -259,9 +259,12 @@ public void testKeyWrap(String algo, String key, int keyLen, System.out.println("=> skip, exceeds max allowed size " + allowed); return; } - Cipher c1 = Cipher.getInstance(algo, "SunJCE"); - Cipher c2 = Cipher.getInstance(algo, "SunJCE"); - Cipher c3 = Cipher.getInstance(algo, "SunJCE"); + Cipher c1 = Cipher.getInstance(algo, + System.getProperty("test.provider.name", "SunJCE")); + Cipher c2 = Cipher.getInstance(algo, + System.getProperty("test.provider.name", "SunJCE")); + Cipher c3 = Cipher.getInstance(algo, + System.getProperty("test.provider.name", "SunJCE")); byte[] keyVal = toBytes(key, keyLen << 1); byte[] dataVal = toBytes(data, dataLen << 1); @@ -319,9 +322,12 @@ public void testEnc(String algo, String key, int keyLen, String data, System.out.println("=> skip, exceeds max allowed size " + allowed); return; } - Cipher c1 = Cipher.getInstance(algo, "SunJCE"); - Cipher c2 = Cipher.getInstance(algo, "SunJCE"); - Cipher c3 = Cipher.getInstance(algo, "SunJCE"); + Cipher c1 = Cipher.getInstance(algo, + System.getProperty("test.provider.name", "SunJCE")); + Cipher c2 = Cipher.getInstance(algo, + System.getProperty("test.provider.name", "SunJCE")); + Cipher c3 = Cipher.getInstance(algo, + System.getProperty("test.provider.name", "SunJCE")); byte[] keyVal = toBytes(key, keyLen << 1); byte[] dataVal = toBytes(data, dataLen << 1); diff --git a/test/jdk/sun/security/pkcs11/Cipher/KeyWrap/TestGeneral.java b/test/jdk/sun/security/pkcs11/Cipher/KeyWrap/TestGeneral.java index 7ff5ec6563b..0cfb4557572 100644 --- a/test/jdk/sun/security/pkcs11/Cipher/KeyWrap/TestGeneral.java +++ b/test/jdk/sun/security/pkcs11/Cipher/KeyWrap/TestGeneral.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -245,7 +245,8 @@ public void main(Provider p) throws Exception { SecretKey aes256 = new SecretKeySpec(DATA_32, "AES"); SecretKey any256 = new SecretKeySpec(DATA_32, "ANY"); PrivateKey priv = KeyPairGenerator.getInstance - ("RSA", "SunRsaSign").generateKeyPair().getPrivate(); + ("RSA", System.getProperty("test.provider.name","SunRsaSign")) + .generateKeyPair().getPrivate(); String[] algos = { "AES/KW/PKCS5Padding", "AES/KW/NoPadding", "AES/KWP/NoPadding" diff --git a/test/jdk/sun/security/pkcs11/Cipher/PBECipher.java b/test/jdk/sun/security/pkcs11/Cipher/PBECipher.java index 04e9adf9663..242d09f6e9b 100644 --- a/test/jdk/sun/security/pkcs11/Cipher/PBECipher.java +++ b/test/jdk/sun/security/pkcs11/Cipher/PBECipher.java @@ -75,7 +75,8 @@ private enum Configuration { AnonymousPBEKey, } - private static Provider sunJCE = Security.getProvider("SunJCE"); + private static Provider sunJCE = Security.getProvider( + System.getProperty("test.provider.name", "SunJCE")); private record AssertionData(String pbeCipherAlgo, String cipherAlgo, BigInteger expectedCiphertext) {} diff --git a/test/jdk/sun/security/pkcs11/Cipher/TestPKCS5PaddingError.java b/test/jdk/sun/security/pkcs11/Cipher/TestPKCS5PaddingError.java index d192526bf4b..cf8e000fce7 100644 --- a/test/jdk/sun/security/pkcs11/Cipher/TestPKCS5PaddingError.java +++ b/test/jdk/sun/security/pkcs11/Cipher/TestPKCS5PaddingError.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -78,7 +78,7 @@ public void main(Provider p) throws Exception { KeyGenerator.getInstance(currTest.keyAlgo, p); SecretKey key = kg.generateKey(); Cipher c1 = Cipher.getInstance(currTest.transformation, - "SunJCE"); + System.getProperty("test.provider.name", "SunJCE")); c1.init(Cipher.ENCRYPT_MODE, key); byte[] cipherText = c1.doFinal(plainText); AlgorithmParameters params = c1.getParameters(); diff --git a/test/jdk/sun/security/pkcs11/Cipher/TestRSACipher.java b/test/jdk/sun/security/pkcs11/Cipher/TestRSACipher.java index 233cb4e623e..6799b19d3e7 100644 --- a/test/jdk/sun/security/pkcs11/Cipher/TestRSACipher.java +++ b/test/jdk/sun/security/pkcs11/Cipher/TestRSACipher.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,6 +44,7 @@ import javax.crypto.BadPaddingException; import javax.crypto.Cipher; import javax.crypto.IllegalBlockSizeException; +import jdk.test.lib.security.SecurityUtils; public class TestRSACipher extends PKCS11Test { @@ -58,8 +59,10 @@ public void main(Provider p) throws Exception { System.out.println("Not supported by provider, skipping"); return; } - KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA", p); - kpg.initialize(1024); + String kpgAlgorithm = "RSA"; + int keySize = SecurityUtils.getTestKeySize(kpgAlgorithm); + KeyPairGenerator kpg = KeyPairGenerator.getInstance(kpgAlgorithm, p); + kpg.initialize(keySize); KeyPair kp = kpg.generateKeyPair(); PublicKey publicKey = kp.getPublic(); PrivateKey privateKey = kp.getPrivate(); @@ -70,7 +73,8 @@ public void main(Provider p) throws Exception { for (String rsaAlgo: RSA_ALGOS) { Cipher c1 = Cipher.getInstance(rsaAlgo, p); - Cipher c2 = Cipher.getInstance(rsaAlgo, "SunJCE"); + Cipher c2 = Cipher.getInstance(rsaAlgo, + System.getProperty("test.provider.name", "SunJCE")); c1.init(Cipher.ENCRYPT_MODE, publicKey); e = c1.doFinal(b); @@ -112,7 +116,8 @@ public void main(Provider p) throws Exception { c1.update(b); e = c1.doFinal(); - c1.update(new byte[256]); + // Longer buffer size to verify IllegalBlockSizeException is thrown + c1.update(new byte[keySize / 4]); try { e = c1.doFinal(); throw new Exception("completed call"); diff --git a/test/jdk/sun/security/pkcs11/Cipher/TestRSACipherWrap.java b/test/jdk/sun/security/pkcs11/Cipher/TestRSACipherWrap.java index 7191d5baac5..0be916ebf9e 100644 --- a/test/jdk/sun/security/pkcs11/Cipher/TestRSACipherWrap.java +++ b/test/jdk/sun/security/pkcs11/Cipher/TestRSACipherWrap.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -43,6 +43,7 @@ import javax.crypto.KeyGenerator; import javax.crypto.SecretKey; import javax.crypto.spec.SecretKeySpec; +import jdk.test.lib.security.SecurityUtils; public class TestRSACipherWrap extends PKCS11Test { @@ -57,13 +58,15 @@ public void main(Provider p) throws Exception { System.out.println(RSA_ALGOS[0] + " unsupported, skipping"); return; } - KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA", p); - kpg.initialize(1024); + String kpgAlgorithm = "RSA"; + KeyPairGenerator kpg = KeyPairGenerator.getInstance(kpgAlgorithm, p); + kpg.initialize(SecurityUtils.getTestKeySize(kpgAlgorithm)); KeyPair kp = kpg.generateKeyPair(); for (String rsaAlgo: RSA_ALGOS) { Cipher cipherPKCS11 = Cipher.getInstance(rsaAlgo, p); - Cipher cipherJce = Cipher.getInstance(rsaAlgo, "SunJCE"); + Cipher cipherJce = Cipher.getInstance(rsaAlgo, + System.getProperty("test.provider.name", "SunJCE")); String algos[] = {"AES", "RC2", "Blowfish"}; int keySizes[] = {128, 256}; diff --git a/test/jdk/sun/security/pkcs11/Cipher/TestRawRSACipher.java b/test/jdk/sun/security/pkcs11/Cipher/TestRawRSACipher.java index 9eceea3a394..fe6433d096e 100644 --- a/test/jdk/sun/security/pkcs11/Cipher/TestRawRSACipher.java +++ b/test/jdk/sun/security/pkcs11/Cipher/TestRawRSACipher.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,6 +41,7 @@ import java.util.HexFormat; import java.util.Random; import javax.crypto.Cipher; +import jdk.test.lib.security.SecurityUtils; public class TestRawRSACipher extends PKCS11Test { @@ -53,8 +54,9 @@ public void main(Provider p) throws Exception { return; } - final int KEY_LEN = 1024; - KeyPairGenerator kpGen = KeyPairGenerator.getInstance("RSA", p); + String kpgAlgorithm = "RSA"; + final int KEY_LEN = SecurityUtils.getTestKeySize(kpgAlgorithm); + KeyPairGenerator kpGen = KeyPairGenerator.getInstance(kpgAlgorithm, p); kpGen.initialize(KEY_LEN); KeyPair kp = kpGen.generateKeyPair(); Random random = new Random(); @@ -64,7 +66,8 @@ public void main(Provider p) throws Exception { plainText[0] = 0; // to ensure that it's less than modulus Cipher c1 = Cipher.getInstance("RSA/ECB/NoPadding", p); - Cipher c2 = Cipher.getInstance("RSA/ECB/NoPadding", "SunJCE"); + Cipher c2 = Cipher.getInstance("RSA/ECB/NoPadding", + System.getProperty("test.provider.name", "SunJCE")); c1.init(Cipher.ENCRYPT_MODE, kp.getPublic()); c2.init(Cipher.DECRYPT_MODE, kp.getPrivate()); diff --git a/test/jdk/sun/security/pkcs11/Cipher/TestSymmCiphers.java b/test/jdk/sun/security/pkcs11/Cipher/TestSymmCiphers.java index e0a7d53e1c1..2395b329dd6 100644 --- a/test/jdk/sun/security/pkcs11/Cipher/TestSymmCiphers.java +++ b/test/jdk/sun/security/pkcs11/Cipher/TestSymmCiphers.java @@ -103,7 +103,7 @@ public void main(Provider p) throws Exception { SecretKey key = kg.generateKey(); Cipher c1 = Cipher.getInstance(currTest.transformation, p); Cipher c2 = Cipher.getInstance(currTest.transformation, - "SunJCE"); + System.getProperty("test.provider.name", "SunJCE")); byte[] plainTxt = new byte[currTest.dataSize]; random.nextBytes(plainTxt); diff --git a/test/jdk/sun/security/pkcs11/Cipher/TestSymmCiphersNoPad.java b/test/jdk/sun/security/pkcs11/Cipher/TestSymmCiphersNoPad.java index 2288a5699fb..7505c21a1ab 100644 --- a/test/jdk/sun/security/pkcs11/Cipher/TestSymmCiphersNoPad.java +++ b/test/jdk/sun/security/pkcs11/Cipher/TestSymmCiphersNoPad.java @@ -89,7 +89,7 @@ public void main(Provider p) throws Exception { SecretKey key = kg.generateKey(); Cipher c1 = Cipher.getInstance(currTest.transformation, p); Cipher c2 = Cipher.getInstance(currTest.transformation, - "SunJCE"); + System.getProperty("test.provider.name", "SunJCE")); byte[] plainTxt = new byte[currTest.dataSize]; random.nextBytes(plainTxt); diff --git a/test/jdk/sun/security/pkcs11/KeyAgreement/TestDH.java b/test/jdk/sun/security/pkcs11/KeyAgreement/TestDH.java index d5569f0f3cd..13b09d16dcf 100644 --- a/test/jdk/sun/security/pkcs11/KeyAgreement/TestDH.java +++ b/test/jdk/sun/security/pkcs11/KeyAgreement/TestDH.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,6 +38,7 @@ import java.util.Arrays; import javax.crypto.KeyAgreement; import javax.crypto.SecretKey; +import jdk.test.lib.security.SecurityUtils; public class TestDH extends PKCS11Test { @@ -47,8 +48,9 @@ public void main(Provider p) throws Exception { System.out.println("DH not supported, skipping"); return; } - KeyPairGenerator kpg = KeyPairGenerator.getInstance("DH", p); - kpg.initialize(512); + String kpgAlgorithm = "DH"; + KeyPairGenerator kpg = KeyPairGenerator.getInstance(kpgAlgorithm, p); + kpg.initialize(SecurityUtils.getTestKeySize(kpgAlgorithm)); KeyPair kp1 = kpg.generateKeyPair(); KeyPair kp2 = kpg.generateKeyPair(); @@ -68,7 +70,8 @@ public void main(Provider p) throws Exception { throw new Exception("Secrets (1,2) do not match"); } - ka2 = KeyAgreement.getInstance("DH", "SunJCE"); + ka2 = KeyAgreement.getInstance("DH", + System.getProperty("test.provider.name", "SunJCE")); ka2.init(kp1.getPrivate()); ka2.doPhase(kp2.getPublic(), true); System.out.println("Derive 3..."); @@ -101,7 +104,8 @@ private static void testAlgorithm(KeyAgreement ka1, KeyPair kp1, ka1.init(kp1.getPrivate()); ka1.doPhase(kp2.getPublic(), true); - System.out.println("Derive " + algorithm + " using SunJCE..."); + System.out.println("Derive " + algorithm + " using " + + System.getProperty("test.provider.name", "SunJCE") + "..."); key1 = ka1.generateSecret(algorithm); ka2.init(kp1.getPrivate()); diff --git a/test/jdk/sun/security/pkcs11/KeyAgreement/TestInterop.java b/test/jdk/sun/security/pkcs11/KeyAgreement/TestInterop.java index 146a6505423..7f6f79e767b 100644 --- a/test/jdk/sun/security/pkcs11/KeyAgreement/TestInterop.java +++ b/test/jdk/sun/security/pkcs11/KeyAgreement/TestInterop.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,43 +39,40 @@ import javax.crypto.KeyAgreement; import javax.crypto.spec.DHPrivateKeySpec; import javax.crypto.spec.DHPublicKeySpec; +import jdk.test.lib.security.DiffieHellmanGroup; +import jdk.test.lib.security.SecurityUtils; public class TestInterop extends PKCS11Test { - private final static BigInteger p = new BigInteger - ("171718397966129586011229151993178480901904202533705695869569760169920539" - + "80807543778874708672297590042574075430109846864794139516459381007417046" - + "27996080624930219892858374168155487210358743785481212360509485282294161" - + "39585571568998066586304075565145536350296006867635076744949977849997684" - + "222020336013226588207303"); - - private final static BigInteger g = new BigInteger("2"); - private final static BigInteger ya = new BigInteger - ("687709211571508809414670982463565909269384277848448625781941269577397703" - + "73675199968849153119146758339814638228795348558483510369322822476757204" - + "22158455966026517829008713407587339322132253724742557954802911059639161" - + "24827916158465757962384625410294483756242900146397201260757102085985457" - + "09397033481077351036224"); + ("22272412859242949963897309866268099957623364986192222381531147912319" + + "23153170556019072276127184001075566033823724518300406542189341984" + + "14728033901164887842157675409022004721268960808255834930605035809" + + "96449867261598768663006346373969582073599358922631400907241847771" + + "58539394502794451638884093173505103869438428833148912071609829581" + + "89477284513896649100113024962862016311693389603523142235630316916" + + "51727812401021776761600004971782662420311224757086651213529674905" + + "34921437167341469749945865459714558842881915928697452568830704027" + + "08840053484115995358953663434943150292283157101600109003253293611" + + "67575903571371898272633920086"); private final static BigInteger xa = new BigInteger - ("104917367119952955556289227181599819745346393858545449202252025137706135" - + "98100778613457655440586438263591136003106529323555991109623536177695714" - + "66884181531401472902830508361532232717792847436112280721439936797741371" - + "245140912614191507"); + ("20959988947516815975588968321965141642005944293655257916834342975849"); private final static BigInteger yb = new BigInteger - ("163887874871842952463100699681506173424091615364591742415764095471629919" - + "08421025296419917755446931473037086355546823601999684501737493240373415" - + "65608293667837249198973539289354492348897732633852665609611113031379864" - + "58514616034107537409230452318065341748503347627733368519091332060477528" - + "173423377887175351037810"); + ("1788841814501653834923092375117807364896992833810838802030127811094" + + "8450381275318704655838368105000403140578033341448162321874634765" + + "6870663019881556386613144025875613921737258766185138415793010195" + + "3802511267742963370821568963965936108932734114202964873644126233" + + "6937947954023458790417933403303562491144788202839815534782475160" + + "7813094179390506418017926774832227342290968359943612529948409558" + + "4647213355501260440663649115694263879691520265343063263385211121" + + "3396751542827391711077192604441343359832896902306354119121777576" + + "6479255602858536672821464920683781338851326155035757018336622673" + + "39973666608754923308482789421630138499"); private final static BigInteger xb = new BigInteger - ("127757517533485947079959908591028646859165238853082197617179368337276371" - + "51601819447716934542027725311863797141734616730248519214531856941516613" - + "30313414180008978013330410484011186019824874948204261839391153650949864" - + "429505597086564709"); + ("37339373137107550077381337769340105015086522284791968753218309293526"); @Override public void main(Provider prov) throws Exception { @@ -90,14 +87,20 @@ public void main(Provider prov) throws Exception { DHPrivateKeySpec privateSpec; KeyFactory kf = KeyFactory.getInstance("DH"); KeyAgreement ka = KeyAgreement.getInstance("DH", prov); - KeyAgreement kbSunJCE = KeyAgreement.getInstance("DH", "SunJCE"); - DHPrivateKeySpec privSpecA = new DHPrivateKeySpec(xa, p, g); - DHPublicKeySpec pubSpecA = new DHPublicKeySpec(ya, p, g); + KeyAgreement kbSunJCE = KeyAgreement.getInstance("DH", + System.getProperty("test.provider.name", "SunJCE")); + DiffieHellmanGroup dhGroup = SecurityUtils.getTestDHGroup(); + DHPrivateKeySpec privSpecA = new DHPrivateKeySpec(xa, dhGroup.getPrime(), + dhGroup.getBase()); + DHPublicKeySpec pubSpecA = new DHPublicKeySpec(ya, dhGroup.getPrime(), + dhGroup.getBase()); PrivateKey privA = kf.generatePrivate(privSpecA); PublicKey pubA = kf.generatePublic(pubSpecA); - DHPrivateKeySpec privSpecB = new DHPrivateKeySpec(xb, p, g); - DHPublicKeySpec pubSpecB = new DHPublicKeySpec(yb, p, g); + DHPrivateKeySpec privSpecB = new DHPrivateKeySpec(xb, dhGroup.getPrime(), + dhGroup.getBase()); + DHPublicKeySpec pubSpecB = new DHPublicKeySpec(yb, dhGroup.getPrime(), + dhGroup.getBase()); PrivateKey privB = kf.generatePrivate(privSpecB); PublicKey pubB = kf.generatePublic(pubSpecB); @@ -109,6 +112,10 @@ public void main(Provider prov) throws Exception { kbSunJCE.doPhase(pubA, true); byte[] n2 = kbSunJCE.generateSecret(); + // verify that a leading zero is present in secrets + if (n1[0] != 0 || n2[0] != 0) { + throw new Exception("First byte is not zero as expected"); + } if (Arrays.equals(n1, n2) == false) { throw new Exception("values mismatch!"); } else { diff --git a/test/jdk/sun/security/pkcs11/KeyStore/Basic.java b/test/jdk/sun/security/pkcs11/KeyStore/Basic.java index 0ac7f37d59c..b6c7af91b57 100644 --- a/test/jdk/sun/security/pkcs11/KeyStore/Basic.java +++ b/test/jdk/sun/security/pkcs11/KeyStore/Basic.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -142,7 +142,8 @@ public void main(Provider p) throws Exception { // get private keys KeyFactory kf = KeyFactory.getInstance("RSA"); - KeyFactory dsaKf = KeyFactory.getInstance("DSA", "SUN"); + KeyFactory dsaKf = KeyFactory.getInstance("DSA", + System.getProperty("test.provider.name", "SUN")); ObjectInputStream ois1 = new ObjectInputStream (new FileInputStream(new File(DIR, "pk1.key"))); diff --git a/test/jdk/sun/security/pkcs11/Mac/PBAMac.java b/test/jdk/sun/security/pkcs11/Mac/PBAMac.java index d0b3312c52b..c9b5e2c3e7b 100644 --- a/test/jdk/sun/security/pkcs11/Mac/PBAMac.java +++ b/test/jdk/sun/security/pkcs11/Mac/PBAMac.java @@ -66,7 +66,8 @@ private enum Configuration { AnonymousPBEKey, } - private static Provider sunJCE = Security.getProvider("SunJCE"); + private static Provider sunJCE = Security.getProvider( + System.getProperty("test.provider.name", "SunJCE")); private record AssertionData(String pbeHmacAlgo, String hmacAlgo, BigInteger expectedMac) {} diff --git a/test/jdk/sun/security/pkcs11/MessageDigest/ReinitDigest.java b/test/jdk/sun/security/pkcs11/MessageDigest/ReinitDigest.java index 132ba84f679..90ed49b42f5 100644 --- a/test/jdk/sun/security/pkcs11/MessageDigest/ReinitDigest.java +++ b/test/jdk/sun/security/pkcs11/MessageDigest/ReinitDigest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -73,7 +73,8 @@ public void main(Provider p) throws Exception { private void doTest(String alg, Provider p, byte[] data1, byte[] data2) throws Exception { System.out.println("Testing " + alg); - MessageDigest md1 = MessageDigest.getInstance(alg, "SUN"); + MessageDigest md1 = MessageDigest.getInstance(alg, + System.getProperty("test.provider.name", "SUN")); byte[] d1 = md1.digest(data1); MessageDigest md2 = MessageDigest.getInstance(alg, p); checkInstances(md1, md2); diff --git a/test/jdk/sun/security/pkcs11/Signature/SigInteropPSS.java b/test/jdk/sun/security/pkcs11/Signature/SigInteropPSS.java index 11147022771..d5b22400bff 100644 --- a/test/jdk/sun/security/pkcs11/Signature/SigInteropPSS.java +++ b/test/jdk/sun/security/pkcs11/Signature/SigInteropPSS.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -59,7 +59,8 @@ public void main(Provider p) throws Exception { } Signature sigSunRsaSign = - Signature.getInstance("RSASSA-PSS", "SunRsaSign"); + Signature.getInstance("RSASSA-PSS", + System.getProperty("test.provider.name", "SunRsaSign")); KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA", p); kpg.initialize(3072); diff --git a/test/jdk/sun/security/pkcs11/Signature/SigInteropPSS2.java b/test/jdk/sun/security/pkcs11/Signature/SigInteropPSS2.java index c15f10aab3e..dfe56167848 100644 --- a/test/jdk/sun/security/pkcs11/Signature/SigInteropPSS2.java +++ b/test/jdk/sun/security/pkcs11/Signature/SigInteropPSS2.java @@ -51,8 +51,9 @@ public static void main(String[] args) throws Exception { @Override public void main(Provider p) throws Exception { - Provider sunRsaSign = Security.getProvider("SunRsaSign"); - Security.removeProvider("SunRsaSign"); + String providerName = System.getProperty("test.provider.name", "SunRsaSign"); + Provider sunRsaSign = Security.getProvider(providerName); + Security.removeProvider(providerName); Signature sigPkcs11; Signature sigSunRsaSign = diff --git a/test/jdk/sun/security/pkcs11/Signature/TestDSAKeyLength.java b/test/jdk/sun/security/pkcs11/Signature/TestDSAKeyLength.java index b2ab96c90c6..d2515fa0f5a 100644 --- a/test/jdk/sun/security/pkcs11/Signature/TestDSAKeyLength.java +++ b/test/jdk/sun/security/pkcs11/Signature/TestDSAKeyLength.java @@ -62,7 +62,8 @@ protected boolean skipTest(Provider provider) { @Override public void main(Provider provider) throws Exception { - KeyPairGenerator kpg = KeyPairGenerator.getInstance("DSA", "SUN"); + KeyPairGenerator kpg = KeyPairGenerator.getInstance("DSA", + System.getProperty("test.provider.name", "SUN")); kpg.initialize(2048, new SecureRandom()); KeyPair pair = kpg.generateKeyPair(); diff --git a/test/jdk/sun/security/pkcs11/policy b/test/jdk/sun/security/pkcs11/policy index 54281a78179..d5a78b6ba82 100644 --- a/test/jdk/sun/security/pkcs11/policy +++ b/test/jdk/sun/security/pkcs11/policy @@ -1,3 +1,4 @@ grant { permission java.lang.RuntimePermission "setSecurityManager"; -}; \ No newline at end of file + permission java.util.PropertyPermission "test.provider.name", "read"; +}; diff --git a/test/jdk/sun/security/pkcs11/rsa/GenKeyStore.java b/test/jdk/sun/security/pkcs11/rsa/GenKeyStore.java index 629a504a040..26178e9a576 100644 --- a/test/jdk/sun/security/pkcs11/rsa/GenKeyStore.java +++ b/test/jdk/sun/security/pkcs11/rsa/GenKeyStore.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -74,7 +74,8 @@ private static void addToKeyStore(KeyStore ks, KeyPair kp, String name) throws E private static void generateKeyPair(KeyStore ks, int keyLength, String alias) throws Exception { System.out.println("Generating " + keyLength + " keypair " + alias + "..."); - KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA", "SunRsaSign"); + KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA", + System.getProperty("test.provider.name", "SunRsaSign")); kpg.initialize(keyLength); KeyPair kp = kpg.generateKeyPair(); addToKeyStore(ks, kp, alias); diff --git a/test/jdk/sun/security/pkcs11/rsa/rsakeys.ks.policy b/test/jdk/sun/security/pkcs11/rsa/rsakeys.ks.policy index 4a0b0d2c46d..6cc9a8f0248 100644 --- a/test/jdk/sun/security/pkcs11/rsa/rsakeys.ks.policy +++ b/test/jdk/sun/security/pkcs11/rsa/rsakeys.ks.policy @@ -1,4 +1,5 @@ grant { permission java.lang.RuntimePermission "setSecurityManager"; permission java.io.FilePermission "${test.src}/rsakeys.ks", "read"; -}; \ No newline at end of file + permission java.util.PropertyPermission "test.provider.name", "read"; +}; diff --git a/test/jdk/sun/security/provider/DSA/SupportedDSAParamGen.java b/test/jdk/sun/security/provider/DSA/SupportedDSAParamGen.java index 52a97b34a3e..5dcd86e2474 100644 --- a/test/jdk/sun/security/provider/DSA/SupportedDSAParamGen.java +++ b/test/jdk/sun/security/provider/DSA/SupportedDSAParamGen.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2016, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,7 +40,8 @@ public class SupportedDSAParamGen { public static void main(String[] args) throws Exception { AlgorithmParameterGenerator apg = - AlgorithmParameterGenerator.getInstance("DSA", "SUN"); + AlgorithmParameterGenerator.getInstance("DSA", + System.getProperty("test.provider.name", "SUN")); DSAGenParameterSpec spec = new DSAGenParameterSpec( Integer.valueOf(args[0]).intValue(), diff --git a/test/jdk/sun/security/provider/DSA/TestAlgParameterGenerator.java b/test/jdk/sun/security/provider/DSA/TestAlgParameterGenerator.java index cf39a5bab5e..2eac80d91bb 100644 --- a/test/jdk/sun/security/provider/DSA/TestAlgParameterGenerator.java +++ b/test/jdk/sun/security/provider/DSA/TestAlgParameterGenerator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -73,7 +73,8 @@ private static void checkParamStrength(AlgorithmParameters param, public static void main(String[] args) throws Exception { AlgorithmParameterGenerator apg - = AlgorithmParameterGenerator.getInstance("DSA", "SUN"); + = AlgorithmParameterGenerator.getInstance("DSA", + System.getProperty("test.provider.name", "SUN")); long start, stop; // make sure no-init still works diff --git a/test/jdk/sun/security/provider/DSA/TestDSA.java b/test/jdk/sun/security/provider/DSA/TestDSA.java index 5d3228949f5..918f18ed081 100644 --- a/test/jdk/sun/security/provider/DSA/TestDSA.java +++ b/test/jdk/sun/security/provider/DSA/TestDSA.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -108,7 +108,7 @@ private static void verify(Provider provider, String alg, PublicKey key, byte[] public static void main(String[] args) throws Exception { long start = System.currentTimeMillis(); - Provider provider = Security.getProvider("SUN"); + Provider provider = Security.getProvider(System.getProperty("test.provider.name", "SUN")); System.out.println("Testing provider " + provider + "..."); KeyFactory kf = KeyFactory.getInstance("DSA", provider); diff --git a/test/jdk/sun/security/provider/DSA/TestDSA2.java b/test/jdk/sun/security/provider/DSA/TestDSA2.java index 320acce4880..ed3111695f1 100644 --- a/test/jdk/sun/security/provider/DSA/TestDSA2.java +++ b/test/jdk/sun/security/provider/DSA/TestDSA2.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,8 @@ public class TestDSA2 { // NOTE: need to explictly specify provider since the more // preferred provider SunPKCS11 provider only supports up // 1024 bits. - private static final String PROV = "SUN"; + private static final String PROV = + System.getProperty("test.provider.name", "SUN"); private static final String[] SIG_ALGOS = { "NONEwithDSA", diff --git a/test/jdk/sun/security/provider/DSA/TestKeyPairGenerator.java b/test/jdk/sun/security/provider/DSA/TestKeyPairGenerator.java index 105c50015da..f2ddcec9d8d 100644 --- a/test/jdk/sun/security/provider/DSA/TestKeyPairGenerator.java +++ b/test/jdk/sun/security/provider/DSA/TestKeyPairGenerator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -57,10 +57,12 @@ public static void main(String[] args) throws Exception { // problem was when not calling initialize() // do that twice to artifically inflate the time // on JDKs that do not have the fix - kpg = KeyPairGenerator.getInstance("DSA", "SUN"); + kpg = KeyPairGenerator.getInstance("DSA", + System.getProperty("test.provider.name", "SUN")); kp = kpg.generateKeyPair(); - kpg = KeyPairGenerator.getInstance("DSA", "SUN"); + kpg = KeyPairGenerator.getInstance("DSA", + System.getProperty("test.provider.name", "SUN")); kp = kpg.generateKeyPair(); // some other basic tests diff --git a/test/jdk/sun/security/provider/KeyStore/CaseSensitiveAliases.java b/test/jdk/sun/security/provider/KeyStore/CaseSensitiveAliases.java index e11a8ac87dc..fd47d0ac60f 100644 --- a/test/jdk/sun/security/provider/KeyStore/CaseSensitiveAliases.java +++ b/test/jdk/sun/security/provider/KeyStore/CaseSensitiveAliases.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,6 +24,7 @@ /* * @test * @bug 5091374 5100603 + * @library /test/lib * @summary make sure the JKS case sensitivity works correctly * @author Andreas Sterbenz */ @@ -34,6 +35,7 @@ import java.security.*; import java.security.cert.*; import java.security.cert.Certificate; +import jdk.test.lib.security.SecurityUtils; public class CaseSensitiveAliases { @@ -90,8 +92,9 @@ private static void main(String jks, boolean caseInsensitive) throws Exception { X509Certificate[] a1 = {c1}; X509Certificate[] a2 = {c2}; - KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA"); - kpg.initialize(512); + String kpgAlgorithm = "RSA"; + KeyPairGenerator kpg = KeyPairGenerator.getInstance(kpgAlgorithm); + kpg.initialize(SecurityUtils.getTestKeySize(kpgAlgorithm)); PrivateKey p1 = kpg.generateKeyPair().getPrivate(); PrivateKey p2 = kpg.generateKeyPair().getPrivate(); diff --git a/test/jdk/sun/security/provider/MessageDigest/DigestKAT.java b/test/jdk/sun/security/provider/MessageDigest/DigestKAT.java index 1f797330c48..ce3c9b3c7a9 100644 --- a/test/jdk/sun/security/provider/MessageDigest/DigestKAT.java +++ b/test/jdk/sun/security/provider/MessageDigest/DigestKAT.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -177,7 +177,7 @@ private static Test t(String alg, byte[] data, String digest) { static void runTests(Test[] tests) throws Exception { long start = System.currentTimeMillis(); - Provider p = Security.getProvider("SUN"); + Provider p = Security.getProvider(System.getProperty("test.provider.name","SUN")); System.out.println("Testing provider " + p.getName() + "..."); for (int i = 0; i < tests.length; i++) { Test test = tests[i]; diff --git a/test/jdk/sun/security/provider/MessageDigest/Offsets.java b/test/jdk/sun/security/provider/MessageDigest/Offsets.java index 44850c2970d..2c800fcb854 100644 --- a/test/jdk/sun/security/provider/MessageDigest/Offsets.java +++ b/test/jdk/sun/security/provider/MessageDigest/Offsets.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -47,7 +47,8 @@ private static void outOfBounds(MessageDigest md, int arrayLen, int ofs, int len private static void test(String algorithm, int minOfs, int maxOfs, int minLen, int maxLen) throws Exception { Random random = new Random(); - MessageDigest md = MessageDigest.getInstance(algorithm, "SUN"); + MessageDigest md = MessageDigest.getInstance(algorithm, + System.getProperty("test.provider.name", "SUN")); System.out.println("Testing " + algorithm + "..."); outOfBounds(md, 16, 0, 32); outOfBounds(md, 16, -8, 16); diff --git a/test/jdk/sun/security/provider/MessageDigest/TestSHAClone.java b/test/jdk/sun/security/provider/MessageDigest/TestSHAClone.java index ac809153b39..28c2dd6fb77 100644 --- a/test/jdk/sun/security/provider/MessageDigest/TestSHAClone.java +++ b/test/jdk/sun/security/provider/MessageDigest/TestSHAClone.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -75,7 +75,8 @@ private void run() throws Exception { public static void main(String[] argv) throws Exception { - Provider p = Security.getProvider("SUN"); + Provider p = Security.getProvider( + System.getProperty("test.provider.name", "SUN")); for (int i=0; i DATA = Arrays.asList( diff --git a/test/jdk/sun/security/provider/NSASuiteB/TestSHAwithDSASignatureOids.java b/test/jdk/sun/security/provider/NSASuiteB/TestSHAwithDSASignatureOids.java index dad84ccfd7e..c7f1ce75ca4 100644 --- a/test/jdk/sun/security/provider/NSASuiteB/TestSHAwithDSASignatureOids.java +++ b/test/jdk/sun/security/provider/NSASuiteB/TestSHAwithDSASignatureOids.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,10 +23,12 @@ import java.util.Arrays; import java.util.List; +import jdk.test.lib.security.SecurityUtils; /* * @test * @bug 8075286 + * @library /test/lib * @summary Test the SHAwithDSA signature algorithm OIDs in JDK. * OID and algorithm transformation string should match. * Both could be able to be used to generate the algorithm instance. @@ -40,8 +42,10 @@ public class TestSHAwithDSASignatureOids { new OidAlgorithmPair("2.16.840.1.101.3.4.3.2", "SHA256withDSA")); public static void main(String[] args) throws Exception { - TestSignatureOidHelper helper = new TestSignatureOidHelper("DSA", - "SUN", 1024, DATA); + String kpgAlgorithm = "DSA"; + TestSignatureOidHelper helper = new TestSignatureOidHelper(kpgAlgorithm, + System.getProperty("test.provider.name", "SUN"), + SecurityUtils.getTestKeySize(kpgAlgorithm), DATA); helper.execute(); } } diff --git a/test/jdk/sun/security/rsa/BrokenRSAPrivateCrtKey.java b/test/jdk/sun/security/rsa/BrokenRSAPrivateCrtKey.java index 0f03cdde6fc..aef92647396 100644 --- a/test/jdk/sun/security/rsa/BrokenRSAPrivateCrtKey.java +++ b/test/jdk/sun/security/rsa/BrokenRSAPrivateCrtKey.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,6 +24,7 @@ /* * @test * @bug 4503229 8220016 + * @library /test/lib * @summary default RSA KeyFactory can return broken RSAPrivateCrtKey objects * This test was taken directly from the bug report, which * was fixed in the crippled JSAFE provider, and needed @@ -35,12 +36,15 @@ import java.security.interfaces.*; import java.security.spec.*; import java.math.BigInteger; +import jdk.test.lib.security.SecurityUtils; public class BrokenRSAPrivateCrtKey { public static void main(String[] args) throws Exception { + String kpgAlgorithm = "RSA"; KeyPairGenerator generator = - KeyPairGenerator.getInstance("RSA", "SunRsaSign"); - generator.initialize(512); + KeyPairGenerator.getInstance(kpgAlgorithm, + System.getProperty("test.provider.name", "SunRsaSign")); + generator.initialize(SecurityUtils.getTestKeySize(kpgAlgorithm)); KeyPair pair = generator.generateKeyPair(); @@ -55,7 +59,8 @@ public static void main(String[] args) throws Exception { privatekey.getPrimeExponentQ(), privatekey.getCrtCoefficient()); - KeyFactory factory = KeyFactory.getInstance("RSA", "SunRsaSign"); + KeyFactory factory = KeyFactory.getInstance("RSA", + System.getProperty("test.provider.name", "SunRsaSign")); PrivateKey privatekey2 = factory.generatePrivate(spec); diff --git a/test/jdk/sun/security/rsa/GenKeyStore.java b/test/jdk/sun/security/rsa/GenKeyStore.java index 629a504a040..26178e9a576 100644 --- a/test/jdk/sun/security/rsa/GenKeyStore.java +++ b/test/jdk/sun/security/rsa/GenKeyStore.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -74,7 +74,8 @@ private static void addToKeyStore(KeyStore ks, KeyPair kp, String name) throws E private static void generateKeyPair(KeyStore ks, int keyLength, String alias) throws Exception { System.out.println("Generating " + keyLength + " keypair " + alias + "..."); - KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA", "SunRsaSign"); + KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA", + System.getProperty("test.provider.name", "SunRsaSign")); kpg.initialize(keyLength); KeyPair kp = kpg.generateKeyPair(); addToKeyStore(ks, kp, alias); diff --git a/test/jdk/sun/security/rsa/KeySizeTest.java b/test/jdk/sun/security/rsa/KeySizeTest.java index 35f9902b8c3..129a3539b51 100644 --- a/test/jdk/sun/security/rsa/KeySizeTest.java +++ b/test/jdk/sun/security/rsa/KeySizeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -53,7 +53,8 @@ public class KeySizeTest { /** * JDK default RSA Provider. */ - private static final String PROVIDER_NAME = "SunRsaSign"; + private static final String PROVIDER_NAME = + System.getProperty("test.provider.name", "SunRsaSign"); public static void main(String[] args) throws Exception { int iKeyPairSize = Integer.parseInt(args[0]); diff --git a/test/jdk/sun/security/rsa/PrivateKeyEqualityTest.java b/test/jdk/sun/security/rsa/PrivateKeyEqualityTest.java index 1a3a6df756a..3ed4aae37b0 100644 --- a/test/jdk/sun/security/rsa/PrivateKeyEqualityTest.java +++ b/test/jdk/sun/security/rsa/PrivateKeyEqualityTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -46,7 +46,8 @@ public class PrivateKeyEqualityTest { /** * JDK default RSA Provider. */ - private static final String PROVIDER_NAME = "SunRsaSign"; + private static final String PROVIDER_NAME = + System.getProperty("test.provider.name", "SunRsaSign"); public static void main(String[] args) throws NoSuchAlgorithmException, NoSuchProviderException, InvalidKeySpecException { diff --git a/test/jdk/sun/security/rsa/SignatureTest.java b/test/jdk/sun/security/rsa/SignatureTest.java index 15df96354b3..d48d7ca481b 100644 --- a/test/jdk/sun/security/rsa/SignatureTest.java +++ b/test/jdk/sun/security/rsa/SignatureTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -61,7 +61,8 @@ public class SignatureTest { /** * JDK default RSA Provider. */ - private static final String PROVIDER = "SunRsaSign"; + private static final String PROVIDER = + System.getProperty("test.provider.name", "SunRsaSign"); /** * How much times signature updated. diff --git a/test/jdk/sun/security/rsa/SpecTest.java b/test/jdk/sun/security/rsa/SpecTest.java index 43ccf3ca718..8cc0bca9898 100644 --- a/test/jdk/sun/security/rsa/SpecTest.java +++ b/test/jdk/sun/security/rsa/SpecTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -53,7 +53,8 @@ public class SpecTest { /** * JDK default RSA Provider. */ - private static final String PROVIDER = "SunRsaSign"; + private static final String PROVIDER = + System.getProperty("test.provider.name", "SunRsaSign"); /** * diff --git a/test/jdk/sun/security/rsa/TestCACerts.java b/test/jdk/sun/security/rsa/TestCACerts.java index 14ed4229472..2d8a1246e5e 100644 --- a/test/jdk/sun/security/rsa/TestCACerts.java +++ b/test/jdk/sun/security/rsa/TestCACerts.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,7 +38,8 @@ public class TestCACerts { - private final static String PROVIDER = "SunRsaSign"; + private final static String PROVIDER = + System.getProperty("test.provider.name", "SunRsaSign"); private final static char SEP = File.separatorChar; diff --git a/test/jdk/sun/security/rsa/TestKeyFactory.java b/test/jdk/sun/security/rsa/TestKeyFactory.java index 8a4f4b7f47f..8be2037a833 100644 --- a/test/jdk/sun/security/rsa/TestKeyFactory.java +++ b/test/jdk/sun/security/rsa/TestKeyFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -228,7 +228,8 @@ private static void test(KeyFactory kf, Key key) throws Exception { public static void main(String[] args) throws Exception { long start = System.currentTimeMillis(); KeyStore ks = getKeyStore(); - KeyFactory kf = KeyFactory.getInstance("RSA", "SunRsaSign"); + KeyFactory kf = KeyFactory.getInstance("RSA", + System.getProperty("test.provider.name", "SunRsaSign")); for (Enumeration e = ks.aliases(); e.hasMoreElements(); ) { String alias = (String)e.nextElement(); Key key = null; diff --git a/test/jdk/sun/security/rsa/TestKeyPairGenerator.java b/test/jdk/sun/security/rsa/TestKeyPairGenerator.java index 72ab7e73acf..ea4d92fd6a3 100644 --- a/test/jdk/sun/security/rsa/TestKeyPairGenerator.java +++ b/test/jdk/sun/security/rsa/TestKeyPairGenerator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,6 +40,7 @@ import java.security.interfaces.*; import java.security.spec.*; +import jdk.test.lib.security.SecurityUtils; import jdk.test.lib.SigTestUtil; import static jdk.test.lib.SigTestUtil.SignatureType; @@ -111,14 +112,16 @@ private static void testInvalidSignature(KeyPair kp1, KeyPair kp2) throws Except public static void main(String[] args) throws Exception { long start = System.currentTimeMillis(); - provider = Security.getProvider("SunRsaSign"); + provider = Security.getProvider( + System.getProperty("test.provider.name", "SunRsaSign")); data = new byte[2048]; - // keypair generation is very slow, test only a few short keys - int[] keyLengths = {512, 512, 1024}; + String kpgAlgorithm = "RSA"; + int keySize = SecurityUtils.getTestKeySize(kpgAlgorithm); + int[] keyLengths = {keySize, keySize, keySize + 1024}; BigInteger[] pubExps = {null, BigInteger.valueOf(3), null}; KeyPair[] keyPairs = new KeyPair[3]; new Random().nextBytes(data); - KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA", provider); + KeyPairGenerator kpg = KeyPairGenerator.getInstance(kpgAlgorithm, provider); for (int i = 0; i < keyLengths.length; i++) { int len = keyLengths[i]; BigInteger exp = pubExps[i]; diff --git a/test/jdk/sun/security/rsa/TestKeyPairGeneratorExponent.java b/test/jdk/sun/security/rsa/TestKeyPairGeneratorExponent.java index 7f17ed7bc48..2c60d66664e 100644 --- a/test/jdk/sun/security/rsa/TestKeyPairGeneratorExponent.java +++ b/test/jdk/sun/security/rsa/TestKeyPairGeneratorExponent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,6 +24,7 @@ /** * @test * @bug 8216012 + * @library /test/lib * @summary Tests the RSA public key exponent for KeyPairGenerator * @run main/timeout=60 TestKeyPairGeneratorExponent */ @@ -33,14 +34,16 @@ import java.security.*; import java.security.interfaces.*; import java.security.spec.*; +import jdk.test.lib.security.SecurityUtils; public class TestKeyPairGeneratorExponent { - private static int keyLen = 512; + private static final String KPG_ALGORITHM = "RSA"; + private static final int KEY_LENGTH = SecurityUtils.getTestKeySize(KPG_ALGORITHM); private static BigInteger[] validExponents = new BigInteger[] { RSAKeyGenParameterSpec.F0, RSAKeyGenParameterSpec.F4, - BigInteger.ONE.shiftLeft(keyLen - 1).subtract(BigInteger.ONE) + BigInteger.ONE.shiftLeft(KEY_LENGTH - 1).subtract(BigInteger.ONE) }; private static BigInteger[] invalidExponents = new BigInteger[] { @@ -55,7 +58,7 @@ public static void testValidExponents(KeyPairGenerator kpg, BigInteger exponent) { System.out.println("Testing exponent = " + exponent.toString(16)); try { - kpg.initialize(new RSAKeyGenParameterSpec(keyLen, exponent)); + kpg.initialize(new RSAKeyGenParameterSpec(KEY_LENGTH, exponent)); kpg.generateKeyPair(); System.out.println("OK, key pair generated"); } catch(InvalidAlgorithmParameterException iape){ @@ -67,7 +70,7 @@ public static void testInvalidExponents(KeyPairGenerator kpg, BigInteger exponent) { System.out.println("Testing exponent = " + exponent.toString(16)); try { - kpg.initialize(new RSAKeyGenParameterSpec(keyLen, exponent)); + kpg.initialize(new RSAKeyGenParameterSpec(KEY_LENGTH, exponent)); kpg.generateKeyPair(); throw new RuntimeException("Error: Expected IAPE not thrown."); } catch(InvalidAlgorithmParameterException iape){ @@ -81,7 +84,8 @@ public static void testInvalidExponents(KeyPairGenerator kpg, public static void main(String[] args) throws Exception { KeyPairGenerator kpg = - KeyPairGenerator.getInstance("RSA", "SunRsaSign"); + KeyPairGenerator.getInstance(KPG_ALGORITHM, + System.getProperty("test.provider.name", "SunRsaSign")); for(BigInteger validExponent : validExponents) { testValidExponents(kpg, validExponent); diff --git a/test/jdk/sun/security/rsa/TestKeyPairGeneratorInit.java b/test/jdk/sun/security/rsa/TestKeyPairGeneratorInit.java index e87d5a5b6a4..7d85c56e684 100644 --- a/test/jdk/sun/security/rsa/TestKeyPairGeneratorInit.java +++ b/test/jdk/sun/security/rsa/TestKeyPairGeneratorInit.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,11 +24,13 @@ /** * @test * @bug 8211049 + * @library /test/lib * @summary make sure the supplied SecureRandom object is used */ import java.security.*; import java.security.interfaces.*; +import jdk.test.lib.security.SecurityUtils; public class TestKeyPairGeneratorInit { @@ -45,10 +47,12 @@ public void nextBytes(byte[] bytes) { } public static void main(String[] args) throws Exception { + String kpgAlgorithm = "RSA"; KeyPairGenerator kpg = - KeyPairGenerator.getInstance("RSA", "SunRsaSign"); + KeyPairGenerator.getInstance(kpgAlgorithm, + System.getProperty("test.provider.name", "SunRsaSign")); MySecureRandom rnd = new MySecureRandom(); - kpg.initialize(2048, rnd); + kpg.initialize(SecurityUtils.getTestKeySize(kpgAlgorithm), rnd); System.out.println("Generate keypair then check"); KeyPair kp = kpg.generateKeyPair(); if (!rnd.isUsed) { diff --git a/test/jdk/sun/security/rsa/TestKeyPairGeneratorLength.java b/test/jdk/sun/security/rsa/TestKeyPairGeneratorLength.java index 8959ede5f30..765ca485bbc 100644 --- a/test/jdk/sun/security/rsa/TestKeyPairGeneratorLength.java +++ b/test/jdk/sun/security/rsa/TestKeyPairGeneratorLength.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,23 +24,28 @@ /** * @test * @bug 5078280 + * @library /test/lib * @summary make sure generated key pairs are exactly the requested length * @author Andreas Sterbenz */ import java.security.*; import java.security.interfaces.*; +import jdk.test.lib.security.SecurityUtils; public class TestKeyPairGeneratorLength { + private static final String KPG_ALGORITHM = "RSA"; + private static final int KEY_LENGTH = SecurityUtils.getTestKeySize(KPG_ALGORITHM); public static void main(String[] args) throws Exception { - test(512); - test(513); + test(KEY_LENGTH); + test(KEY_LENGTH + 1); System.out.println("Done."); } private static void test(int len) throws Exception { - KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA", "SunRsaSign"); + KeyPairGenerator kpg = KeyPairGenerator.getInstance(KPG_ALGORITHM, + System.getProperty("test.provider.name", "SunRsaSign")); kpg.initialize(len); for (int i = 0; i < 6; i++) { System.out.println("Generating keypair " + len + " bit keypair " + (i + 1) + "..."); diff --git a/test/jdk/sun/security/rsa/TestRSAOidSupport.java b/test/jdk/sun/security/rsa/TestRSAOidSupport.java index 2cd06258609..551fa33cd8a 100644 --- a/test/jdk/sun/security/rsa/TestRSAOidSupport.java +++ b/test/jdk/sun/security/rsa/TestRSAOidSupport.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -59,14 +59,16 @@ public static void main(String[] args) throws Exception { X509EncodedKeySpec x509Spec = new X509EncodedKeySpec (toByteArray(DER_BYTES)); String keyAlgo = "RSA"; - KeyFactory kf = KeyFactory.getInstance(keyAlgo, "SunRsaSign"); + KeyFactory kf = KeyFactory.getInstance(keyAlgo, + System.getProperty("test.provider.name", "SunRsaSign")); RSAPublicKey rsaKey = (RSAPublicKey) kf.generatePublic(x509Spec); if (rsaKey.getAlgorithm() != keyAlgo) { throw new RuntimeException("Key algo should be " + keyAlgo + ", but got " + rsaKey.getAlgorithm()); } - kf = KeyFactory.getInstance("RSASSA-PSS", "SunRsaSign"); + kf = KeyFactory.getInstance("RSASSA-PSS", + System.getProperty("test.provider.name", "SunRsaSign")); try { kf.generatePublic(x509Spec); throw new RuntimeException("Should throw IKSE"); diff --git a/test/jdk/sun/security/rsa/TestSigGen15.java b/test/jdk/sun/security/rsa/TestSigGen15.java index 12cc028b072..480ed8d878c 100644 --- a/test/jdk/sun/security/rsa/TestSigGen15.java +++ b/test/jdk/sun/security/rsa/TestSigGen15.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -71,7 +71,8 @@ public static void main(String[] args) throws Exception { static boolean runTest(List records) throws Exception { boolean success = true; //for (Provider provider : Security.getProviders()) { - Provider p = Security.getProvider("SunRsaSign"); + Provider p = Security.getProvider( + System.getProperty("test.provider.name","SunRsaSign")); KeyFactory kf = KeyFactory.getInstance("RSA", p); for (SigRecord sr : records) { System.out.println("==Testing Record : " + sr + "=="); diff --git a/test/jdk/sun/security/rsa/TestSignatures.java b/test/jdk/sun/security/rsa/TestSignatures.java index 3a6a086b7db..0296ac21d64 100644 --- a/test/jdk/sun/security/rsa/TestSignatures.java +++ b/test/jdk/sun/security/rsa/TestSignatures.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -111,7 +111,8 @@ private static void test(PrivateKey privateKey, PublicKey publicKey) public static void main(String[] args) throws Exception { long start = System.currentTimeMillis(); - provider = Security.getProvider("SunRsaSign"); + provider = Security.getProvider( + System.getProperty("test.provider.name", "SunRsaSign")); data = new byte[2048]; new Random().nextBytes(data); KeyStore ks = getKeyStore(); diff --git a/test/jdk/sun/security/rsa/WithoutNULL.java b/test/jdk/sun/security/rsa/WithoutNULL.java index 64cf831099d..39daca6d304 100644 --- a/test/jdk/sun/security/rsa/WithoutNULL.java +++ b/test/jdk/sun/security/rsa/WithoutNULL.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2023, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -48,7 +48,8 @@ public static void main(String[] args) throws Exception { b8oaWkxk069jDTM1RhllPJZkAjeQRbw4gkg4N6wKZz9B/jdSRMNJg/b9QdRYZOHOBxsEHMbUREPV DoCOLaxB8eIXX0EWkiE="""); - Signature s = Signature.getInstance("SHA1withRSA", "SunRsaSign"); + Signature s = Signature.getInstance("SHA1withRSA", + System.getProperty("test.provider.name", "SunRsaSign")); s.initVerify(KeyFactory.getInstance("RSA").generatePublic(new X509EncodedKeySpec(key))); if (!s.verify(sig)) { throw new RuntimeException("Does not verify"); diff --git a/test/jdk/sun/security/rsa/pss/DefaultParamSpec.java b/test/jdk/sun/security/rsa/pss/DefaultParamSpec.java index 6f121c75fd2..782fbe510b7 100644 --- a/test/jdk/sun/security/rsa/pss/DefaultParamSpec.java +++ b/test/jdk/sun/security/rsa/pss/DefaultParamSpec.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,10 +30,12 @@ import java.security.spec.PSSParameterSpec; import java.security.spec.RSAKeyGenParameterSpec; import java.util.Date; +import jdk.test.lib.security.SecurityUtils; /** * @test * @bug 8242811 + * @library /test/lib * @modules java.base/sun.security.x509 * @summary AlgorithmId::getDefaultAlgorithmParameterSpec returns incompatible * PSSParameterSpec for an RSASSA-PSS key @@ -42,7 +44,7 @@ public class DefaultParamSpec { public static void main(String[] args) throws Exception { KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSASSA-PSS"); KeyFactory kf = KeyFactory.getInstance("RSASSA-PSS"); - kpg.initialize(new RSAKeyGenParameterSpec(2048, + kpg.initialize(new RSAKeyGenParameterSpec(SecurityUtils.getTestKeySize("RSA"), RSAKeyGenParameterSpec.F4, new PSSParameterSpec( "SHA-384", "MGF1", diff --git a/test/jdk/sun/security/rsa/pss/InitAgain.java b/test/jdk/sun/security/rsa/pss/InitAgain.java index 209d5f46178..9b1963c2ee0 100644 --- a/test/jdk/sun/security/rsa/pss/InitAgain.java +++ b/test/jdk/sun/security/rsa/pss/InitAgain.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,10 +22,12 @@ */ import java.security.*; import java.security.spec.*; +import jdk.test.lib.security.SecurityUtils; /** * @test * @bug 8205445 + * @library /test/lib * @summary Make sure old state is cleared when init is called again */ public class InitAgain { @@ -40,8 +42,9 @@ public static void main(String[] args) throws Exception { s1.setParameter(PSSParameterSpec.DEFAULT); s2.setParameter(PSSParameterSpec.DEFAULT); - KeyPairGenerator kpg = KeyPairGenerator.getInstance("RSA"); - kpg.initialize(1024); + String kpgAlgorithm = "RSA"; + KeyPairGenerator kpg = KeyPairGenerator.getInstance(kpgAlgorithm); + kpg.initialize(SecurityUtils.getTestKeySize(kpgAlgorithm)); KeyPair kp = kpg.generateKeyPair(); s1.initSign(kp.getPrivate()); diff --git a/test/jdk/sun/security/rsa/pss/PSSKeyCompatibility.java b/test/jdk/sun/security/rsa/pss/PSSKeyCompatibility.java index 4961a2a2ad8..5515e770c26 100644 --- a/test/jdk/sun/security/rsa/pss/PSSKeyCompatibility.java +++ b/test/jdk/sun/security/rsa/pss/PSSKeyCompatibility.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -51,7 +51,8 @@ public class PSSKeyCompatibility { private static final String ALGO = "RSASSA-PSS"; private static final String OID = "1.2.840.113549.1.1.10"; - private static final String PROVIDER = "SunRsaSign"; + private static final String PROVIDER = + System.getProperty("test.provider.name", "SunRsaSign"); public static void main(String[] args) { diff --git a/test/jdk/sun/security/rsa/pss/PSSParametersTest.java b/test/jdk/sun/security/rsa/pss/PSSParametersTest.java index c71e5bb34a4..a489b3273ad 100644 --- a/test/jdk/sun/security/rsa/pss/PSSParametersTest.java +++ b/test/jdk/sun/security/rsa/pss/PSSParametersTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -39,7 +39,8 @@ public class PSSParametersTest { /** * JDK default RSA Provider. */ - private static final String PROVIDER = "SunRsaSign"; + private static final String PROVIDER = + System.getProperty("test.provider.name", "SunRsaSign"); private static final String PSS_ALGO = "RSASSA-PSS"; private static final String PSS_OID = "1.2.840.113549.1.1.10"; diff --git a/test/jdk/sun/security/rsa/pss/SerializedPSSKey.java b/test/jdk/sun/security/rsa/pss/SerializedPSSKey.java index eb0bd1dde7a..f946427092c 100644 --- a/test/jdk/sun/security/rsa/pss/SerializedPSSKey.java +++ b/test/jdk/sun/security/rsa/pss/SerializedPSSKey.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -50,9 +50,11 @@ import java.security.spec.RSAPublicKeySpec; import java.security.spec.X509EncodedKeySpec; import java.util.Arrays; +import jdk.test.lib.security.SecurityUtils; /** * @test @bug 8242335 + * @library /test/lib * @summary Test RSASSA-PSS serialized keys * @run main SerializedPSSKey */ @@ -60,8 +62,9 @@ public class SerializedPSSKey { private static final String ALGO = "RSASSA-PSS"; private static final String OID = "1.2.840.113549.1.1.10"; - private static final String PROVIDER = "SunRsaSign"; - private static final int KEY_SIZE = 2048; + private static final String PROVIDER = + System.getProperty("test.provider.name", "SunRsaSign"); + private static final int KEY_SIZE = SecurityUtils.getTestKeySize("RSA"); private static final byte[] DATA = "Test".getBytes(); /** * Digest algorithms to test w/ RSASSA-PSS signature algorithms diff --git a/test/jdk/sun/security/rsa/pss/SignatureTest2.java b/test/jdk/sun/security/rsa/pss/SignatureTest2.java index ea548d04dad..7d3d76ef0ae 100644 --- a/test/jdk/sun/security/rsa/pss/SignatureTest2.java +++ b/test/jdk/sun/security/rsa/pss/SignatureTest2.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -51,7 +51,8 @@ public class SignatureTest2 { /** * JDK default RSA Provider. */ - private static final String PROVIDER = "SunRsaSign"; + private static final String PROVIDER = + System.getProperty("test.provider.name", "SunRsaSign"); /** * How much times signature updated. diff --git a/test/jdk/sun/security/rsa/pss/SignatureTestPSS.java b/test/jdk/sun/security/rsa/pss/SignatureTestPSS.java index daa0fc51d8a..82580b0c354 100644 --- a/test/jdk/sun/security/rsa/pss/SignatureTestPSS.java +++ b/test/jdk/sun/security/rsa/pss/SignatureTestPSS.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -57,7 +57,8 @@ public class SignatureTestPSS { /** * JDK default RSA Provider. */ - private static final String PROVIDER = "SunRsaSign"; + private static final String PROVIDER = + System.getProperty("test.provider.name", "SunRsaSign"); /** * How much times signature updated. diff --git a/test/jdk/sun/security/rsa/pss/TestPSSKeySupport.java b/test/jdk/sun/security/rsa/pss/TestPSSKeySupport.java index 5e8c48a178a..44d1324b00e 100644 --- a/test/jdk/sun/security/rsa/pss/TestPSSKeySupport.java +++ b/test/jdk/sun/security/rsa/pss/TestPSSKeySupport.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,6 +24,7 @@ /** * @test * @bug 8146293 8242556 8172366 8254717 + * @library /test/lib * @summary Test RSASSA-PSS Key related support such as KeyPairGenerator * and KeyFactory of the SunRsaSign provider */ @@ -35,6 +36,7 @@ import java.security.*; import java.security.interfaces.*; import java.security.spec.*; +import jdk.test.lib.security.SecurityUtils; public class TestPSSKeySupport { @@ -130,11 +132,13 @@ private static void checkKeyPair(KeyPair kp) throws Exception { } public static void main(String[] args) throws Exception { + int keySize = SecurityUtils.getTestKeySize("RSA"); KeyPairGenerator kpg = - KeyPairGenerator.getInstance(ALGO, "SunRsaSign"); + KeyPairGenerator.getInstance(ALGO, + System.getProperty("test.provider.name", "SunRsaSign")); // Algorithm-Independent Initialization - kpg.initialize(2048); + kpg.initialize(keySize); KeyPair kp = kpg.generateKeyPair(); checkKeyPair(kp); BigInteger pubExp = ((RSAPublicKey)kp.getPublic()).getPublicExponent(); @@ -142,17 +146,18 @@ public static void main(String[] args) throws Exception { // Algorithm-specific Initialization PSSParameterSpec params = new PSSParameterSpec("SHA-256", "MGF1", MGF1ParameterSpec.SHA256, 32, 1); - kpg.initialize(new RSAKeyGenParameterSpec(2048, pubExp, params)); + kpg.initialize(new RSAKeyGenParameterSpec(keySize, pubExp, params)); KeyPair kp2 = kpg.generateKeyPair(); checkKeyPair(kp2); params = new PSSParameterSpec("SHA3-256", "MGF1", new MGF1ParameterSpec("SHA3-256"), 32, 1); - kpg.initialize(new RSAKeyGenParameterSpec(2048, pubExp, params)); + kpg.initialize(new RSAKeyGenParameterSpec(keySize, pubExp, params)); KeyPair kp3 = kpg.generateKeyPair(); checkKeyPair(kp3); - KeyFactory kf = KeyFactory.getInstance(ALGO, "SunRsaSign"); + KeyFactory kf = KeyFactory.getInstance(ALGO, + System.getProperty("test.provider.name", "SunRsaSign")); test(kf, kp.getPublic()); test(kf, kp.getPrivate()); test(kf, kp2.getPublic()); diff --git a/test/jdk/sun/security/rsa/pss/TestSigGenPSS.java b/test/jdk/sun/security/rsa/pss/TestSigGenPSS.java index dfadef03f04..cbda2b1df93 100644 --- a/test/jdk/sun/security/rsa/pss/TestSigGenPSS.java +++ b/test/jdk/sun/security/rsa/pss/TestSigGenPSS.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -62,7 +62,8 @@ public void nextBytes(byte[] bytes) { public static void main(String[] args) throws Exception { //for (Provider provider : Security.getProviders()) { - Provider p = Security.getProvider("SunRsaSign"); + Provider p = Security.getProvider( + System.getProperty("test.provider.name", "SunRsaSign")); Signature sig; try { sig = Signature.getInstance("RSASSA-PSS", p); diff --git a/test/jdk/sun/security/ssl/HandshakeHash/DigestBase.java b/test/jdk/sun/security/ssl/HandshakeHash/DigestBase.java index a92de6fff6e..437973049a8 100644 --- a/test/jdk/sun/security/ssl/HandshakeHash/DigestBase.java +++ b/test/jdk/sun/security/ssl/HandshakeHash/DigestBase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -59,13 +59,13 @@ public MD5() throws Exception { public static final class SHA extends DigestBase { public SHA() throws Exception { - super("SHA", "SUN"); + super("SHA", System.getProperty("test.provider.name", "SUN")); } } public static final class SHA256 extends DigestBase { public SHA256() throws Exception { - super("SHA-256", "SUN"); + super("SHA-256", System.getProperty("test.provider.name", "SUN")); } } } diff --git a/test/jdk/sun/security/ssl/X509TrustManagerImpl/PKIXExtendedTM.java b/test/jdk/sun/security/ssl/X509TrustManagerImpl/PKIXExtendedTM.java index 1cf22f04293..e2e5e066f9c 100644 --- a/test/jdk/sun/security/ssl/X509TrustManagerImpl/PKIXExtendedTM.java +++ b/test/jdk/sun/security/ssl/X509TrustManagerImpl/PKIXExtendedTM.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -56,354 +56,495 @@ * * TLS server certificate: * server private key: - * -----BEGIN RSA PRIVATE KEY----- - * Proc-Type: 4,ENCRYPTED - * DEK-Info: DES-EDE3-CBC,D9AE407F6D0E389A * - * WPrA7TFol/cQCcp9oHnXWNpYlvRbbIcQj0m+RKT2Iuzfus+DHt3Zadf8nJpKfX2e - * h2rnhlzCN9M7djRDooZKDOPCsdBn51Au7HlZF3S3Opgo7D8XFM1a8t1Je4ke14oI - * nw6QKYsBblRziPnP2PZ0zvX24nOv7bbY8beynlJHGs00VWSFdoH2DS0aE1p6D+3n - * ptJuJ75dVfZFK4X7162APlNXevX8D6PEQpSiRw1rjjGGcnvQ4HdWk3BxDVDcCNJb - * Y1aGNRxsjTDvPi3R9Qx2M+W03QzEPx4SR3ZHVskeSJHaetM0TM/w/45Paq4GokXP - * ZeTnbEx1xmjkA7h+t4doLL4watx5F6yLsJzu8xB3lt/1EtmkYtLz1t7X4BetPAXz - * zS69X/VwhKfsOI3qXBWuL2oHPyhDmT1gcaUQwEPSV6ogHEEQEDXdiUS8heNK13KF - * TCQYFkETvV2BLxUhV1hypPzRQ6tUpJiAbD5KmoK2lD9slshG2QtvKQq0/bgkDY5J - * LhDHV2dtcZ3kDPkkZXpbcJQvoeH3d09C5sIsuTFo2zgNR6oETHUc5TzP6FY2YYRa - * QcK5HcmtsRRiXFm01ac+aMejJUIujjFt84SiKWT/73vC8AmY4tYcJBLjCg4XIxSH - * fdDFLL1YZENNO5ivlp8mdiHqcawx+36L7DrEZQ8RZt6cqST5t/+XTdM74s6k81GT - * pNsa82P2K2zmIUZ/DL2mKjW1vfRByw1NQFEBkN3vdyZxYfM/JyUzX4hbjXBEkh9Q - * QYrcwLKLjis2QzSvK04B3bvRzRb+4ocWiso8ZPAXAIxZFBWDpTMM2A== - * -----END RSA PRIVATE KEY----- - * - * -----BEGIN RSA PRIVATE KEY----- - * MIICXAIBAAKBgQClrFscN6LdmYktsnm4j9VIpecchBeNaZzGrG358h0fORna03Ie - * buxEzHCk3LoAMPagTz1UemFqzFfQCn+VKBg/mtmU8hvIJIh+/p0PPftXUwizIDPU - * PxdHFNHN6gjYDnVOr77M0uyvqXpJ38LZrLgkQJCmA1Yq0DAFQCxPq9l0iQIDAQAB - * AoGAbqcbg1E1mkR99uOJoNeQYKFOJyGiiXTMnXV1TseC4+PDfQBU7Dax35GcesBi - * CtapIpFKKS5D+ozY6b7ZT8ojxuQ/uHLPAvz0WDR3ds4iRF8tyu71Q1ZHcQsJa17y - * yO7UbkSSKn/Mp9Rb+/dKqftUGNXVFLqgHBOzN2s3We3bbbECQQDYBPKOg3hkaGHo - * OhpHKqtQ6EVkldihG/3i4WejRonelXN+HRh1KrB2HBx0M8D/qAzP1i3rNSlSHer4 - * 59YRTJnHAkEAxFX/sVYSn07BHv9Zhn6XXct/Cj43z/tKNbzlNbcxqQwQerw3IH51 - * 8UH2YOA+GD3lXbKp+MytoFLWv8zg4YT/LwJAfqan75Z1R6lLffRS49bIiq8jwE16 - * rTrUJ+kv8jKxMqc9B3vXkxpsS1M/+4E8bqgAmvpgAb8xcsvHsBd9ErdukQJBAKs2 - * j67W75BrPjBI34pQ1LEfp56IGWXOrq1kF8IbCjxv3+MYRT6Z6UJFkpRymNPNDjsC - * dgUYgITiGJHUGXuw3lMCQHEHqo9ZtXz92yFT+VhsNc29B8m/sqUJdtCcMd/jGpAF - * u6GHufjqIZBpQsk63wbwESAPZZ+kk1O1kS5GIRLX608= - * -----END RSA PRIVATE KEY----- - * - * Private-Key: (1024 bit) + * Private-Key: (2048 bit, 2 primes) * modulus: - * 00:a5:ac:5b:1c:37:a2:dd:99:89:2d:b2:79:b8:8f: - * d5:48:a5:e7:1c:84:17:8d:69:9c:c6:ac:6d:f9:f2: - * 1d:1f:39:19:da:d3:72:1e:6e:ec:44:cc:70:a4:dc: - * ba:00:30:f6:a0:4f:3d:54:7a:61:6a:cc:57:d0:0a: - * 7f:95:28:18:3f:9a:d9:94:f2:1b:c8:24:88:7e:fe: - * 9d:0f:3d:fb:57:53:08:b3:20:33:d4:3f:17:47:14: - * d1:cd:ea:08:d8:0e:75:4e:af:be:cc:d2:ec:af:a9: - * 7a:49:df:c2:d9:ac:b8:24:40:90:a6:03:56:2a:d0: - * 30:05:40:2c:4f:ab:d9:74:89 + * 00:9a:0c:e0:8f:a8:02:7e:5a:ef:ed:b2:42:ad:08: + * 4e:91:ba:c2:ad:9b:79:d7:9b:0f:fd:d2:f8:15:2f: + * 19:89:80:10:00:02:19:6d:27:c2:90:d7:a5:23:53: + * 74:6e:64:28:7c:24:aa:ed:ea:21:59:dc:a3:5c:b5: + * c9:42:31:4f:a2:de:fb:09:7c:73:ed:88:04:34:f1: + * 15:ad:3d:60:cd:ca:c5:13:99:d3:9f:9b:b2:92:70: + * cb:ba:4b:3d:20:96:ad:be:92:53:ed:54:3b:c5:14: + * bd:cf:d4:0f:cb:05:4f:fd:2b:9e:e0:50:bb:65:13: + * 92:c0:d6:bd:4d:02:0c:70:b6:65:d4:7d:b4:4d:c3: + * df:2c:08:9e:d2:3e:69:32:46:6f:6f:ca:d1:73:a4: + * 94:07:ef:14:e3:da:9e:2f:c0:ac:0e:10:33:4c:68: + * 79:f3:79:40:d6:e9:3c:c2:e6:70:e0:89:ce:a0:7a: + * a8:84:28:85:32:37:08:b0:cf:b1:7f:5f:bc:1f:a5: + * 3d:ef:d6:68:a8:17:21:5f:87:d5:4b:b5:cc:ee:78: + * 8d:dd:b1:28:6a:c0:fb:64:bd:b7:70:02:33:03:0b: + * b8:b8:bb:08:82:f6:8e:05:27:d1:3b:e6:c5:ac:4d: + * 85:5b:a1:1d:a3:48:5d:03:15:76:63:6c:71:21:3e: + * 98:cd * publicExponent: 65537 (0x10001) * privateExponent: - * 6e:a7:1b:83:51:35:9a:44:7d:f6:e3:89:a0:d7:90: - * 60:a1:4e:27:21:a2:89:74:cc:9d:75:75:4e:c7:82: - * e3:e3:c3:7d:00:54:ec:36:b1:df:91:9c:7a:c0:62: - * 0a:d6:a9:22:91:4a:29:2e:43:fa:8c:d8:e9:be:d9: - * 4f:ca:23:c6:e4:3f:b8:72:cf:02:fc:f4:58:34:77: - * 76:ce:22:44:5f:2d:ca:ee:f5:43:56:47:71:0b:09: - * 6b:5e:f2:c8:ee:d4:6e:44:92:2a:7f:cc:a7:d4:5b: - * fb:f7:4a:a9:fb:54:18:d5:d5:14:ba:a0:1c:13:b3: - * 37:6b:37:59:ed:db:6d:b1 + * 68:87:36:54:a3:c6:d5:5f:f5:0f:4f:76:c8:9c:2b: + * 5b:dc:e2:be:14:12:2f:c7:0a:a9:cb:5e:04:59:ca: + * 35:2f:8d:2b:c4:40:e6:7d:25:1b:4d:07:c3:99:9c: + * 16:4f:a5:dc:de:b0:90:f0:de:22:70:80:f4:a6:70: + * e2:96:3d:18:21:bf:2b:27:a4:2d:d7:ae:2b:12:2f: + * 08:36:ee:99:94:ed:f6:a7:d9:1d:a2:f3:1f:44:a4: + * 28:4b:67:35:d6:a8:1b:f8:84:34:34:84:bd:ec:9e: + * 03:08:3c:93:20:8e:af:15:cb:1f:20:08:97:c4:19: + * 3e:fa:36:c6:ab:0e:2f:e7:b3:c0:a7:bc:e4:e0:a6: + * 08:1c:69:20:4d:78:bd:7a:e5:25:48:60:9e:2e:50: + * 8d:36:1e:07:e9:d5:0d:39:67:41:42:24:db:87:e5: + * 77:76:fd:5e:d5:c6:e5:d3:b0:98:71:48:69:47:4f: + * 46:05:0c:9e:58:45:2e:e2:27:d0:f6:11:05:78:ad: + * 83:5a:5b:ec:d7:2e:26:5a:a5:4f:9e:52:84:2c:1f: + * 59:1a:78:56:0a:44:54:c6:37:64:01:ca:e4:a8:01: + * c7:86:c1:b4:d6:6c:7a:15:9a:65:69:46:9e:fd:f6: + * 08:17:0c:6c:ac:38:bd:c2:cd:da:ef:54:7a:48:92: + * 4d * prime1: - * 00:d8:04:f2:8e:83:78:64:68:61:e8:3a:1a:47:2a: - * ab:50:e8:45:64:95:d8:a1:1b:fd:e2:e1:67:a3:46: - * 89:de:95:73:7e:1d:18:75:2a:b0:76:1c:1c:74:33: - * c0:ff:a8:0c:cf:d6:2d:eb:35:29:52:1d:ea:f8:e7: - * d6:11:4c:99:c7 + * 00:e4:43:cc:51:25:aa:1d:90:41:95:2c:e8:9f:aa: + * 1c:9b:ea:bd:fd:29:e5:68:6b:28:00:ec:31:31:36: + * d0:3d:84:db:c5:5d:32:f6:38:b9:04:4f:45:cb:19: + * f5:88:cd:a8:fc:70:b8:6d:98:68:a6:b4:9e:c1:da: + * fd:db:eb:1a:53:3c:3b:e6:85:d2:6f:03:45:7a:ad: + * 49:8c:c3:96:a7:46:a4:bb:3b:48:d3:d7:1c:b4:3c: + * f7:04:0a:a3:85:9d:94:3e:bd:35:f5:34:21:3d:08: + * 89:df:c5:54:af:cf:90:f7:d8:5c:57:c5:77:5a:c8: + * d1:b3:8f:ee:01:5c:07:13:3f * prime2: - * 00:c4:55:ff:b1:56:12:9f:4e:c1:1e:ff:59:86:7e: - * 97:5d:cb:7f:0a:3e:37:cf:fb:4a:35:bc:e5:35:b7: - * 31:a9:0c:10:7a:bc:37:20:7e:75:f1:41:f6:60:e0: - * 3e:18:3d:e5:5d:b2:a9:f8:cc:ad:a0:52:d6:bf:cc: - * e0:e1:84:ff:2f + * 00:ac:c4:a0:cc:7c:51:db:65:0a:02:da:bc:d8:77: + * 21:8c:d3:30:ae:ec:50:60:4b:b9:39:c7:2d:bd:98: + * aa:4f:9b:44:74:ab:f8:86:de:e2:44:15:73:7a:cd: + * d5:46:f2:03:62:c5:87:9c:6d:91:d5:7a:9a:17:c2: + * c6:2f:29:0e:8a:a4:a9:f4:c2:63:a2:77:97:bf:c6: + * 90:e8:39:70:87:cc:fd:62:4f:d2:3d:e7:47:70:fb: + * f3:bd:bd:5c:9c:77:fe:23:33:7d:83:ef:cb:0e:4e: + * f1:dd:05:47:40:97:f4:da:b6:1f:b9:8d:e2:92:04: + * 09:be:fb:6a:97:29:27:ac:f3 * exponent1: - * 7e:a6:a7:ef:96:75:47:a9:4b:7d:f4:52:e3:d6:c8: - * 8a:af:23:c0:4d:7a:ad:3a:d4:27:e9:2f:f2:32:b1: - * 32:a7:3d:07:7b:d7:93:1a:6c:4b:53:3f:fb:81:3c: - * 6e:a8:00:9a:fa:60:01:bf:31:72:cb:c7:b0:17:7d: - * 12:b7:6e:91 + * 3f:08:1d:b6:56:b1:38:02:aa:a9:77:c2:30:bc:b7: + * b3:b2:49:8e:4b:f0:66:3a:18:cc:d0:6b:f1:0c:12: + * ca:ba:12:39:d8:b7:86:d8:38:f6:e0:b1:04:19:81: + * fc:a9:d5:bd:07:9f:55:dc:1d:21:d3:84:77:41:72: + * 92:34:c4:8b:31:79:d4:f9:25:17:b4:8e:8e:06:a5: + * e5:b1:e8:ba:fe:3d:e4:d9:c5:0d:82:3c:11:e5:37: + * cc:ac:e7:64:b1:13:cb:93:52:00:08:ca:18:e1:6f: + * b9:13:f3:83:ac:cc:7a:34:0b:a3:cd:0a:5d:4e:50: + * e1:c5:9f:d2:4e:48:41:df * exponent2: - * 00:ab:36:8f:ae:d6:ef:90:6b:3e:30:48:df:8a:50: - * d4:b1:1f:a7:9e:88:19:65:ce:ae:ad:64:17:c2:1b: - * 0a:3c:6f:df:e3:18:45:3e:99:e9:42:45:92:94:72: - * 98:d3:cd:0e:3b:02:76:05:18:80:84:e2:18:91:d4: - * 19:7b:b0:de:53 + * 02:c7:fb:8a:af:29:a6:2d:7f:36:c2:8c:ad:b3:65: + * 3f:de:1a:77:86:68:58:d4:7f:3b:d5:df:ff:a0:58: + * 85:85:8b:59:91:77:23:bc:ac:c9:c9:ca:9d:1c:79: + * 25:76:39:e5:ba:26:4f:b7:57:d4:a6:ef:9a:18:51: + * 96:6a:c3:c8:29:94:6e:d3:3e:45:5c:45:7e:19:d5: + * 35:57:cf:5e:f0:46:d7:f1:4f:02:1e:1a:01:50:9d: + * 00:dd:ee:82:ba:4f:c6:03:4b:2e:f7:8a:3e:45:b9: + * 11:04:c7:bb:db:76:5e:9a:f5:f1:c7:bd:f0:f9:cd: + * aa:5c:63:bf:e1:32:b9:4f * coefficient: - * 71:07:aa:8f:59:b5:7c:fd:db:21:53:f9:58:6c:35: - * cd:bd:07:c9:bf:b2:a5:09:76:d0:9c:31:df:e3:1a: - * 90:05:bb:a1:87:b9:f8:ea:21:90:69:42:c9:3a:df: - * 06:f0:11:20:0f:65:9f:a4:93:53:b5:91:2e:46:21: - * 12:d7:eb:4f - * + * 50:4c:e6:1e:23:f3:e2:2b:d6:3f:87:53:fb:19:53: + * 4b:84:21:0b:77:31:ed:8d:c3:0c:ea:31:b0:a6:38: + * a9:e6:44:6e:18:05:53:8f:4a:5f:75:e5:3e:b5:26: + * 9b:46:3d:73:e7:c1:2a:a6:3e:c3:cd:41:b1:a6:55: + * 57:84:11:13:ec:44:92:59:7f:dd:0d:67:30:d3:b7: + * 13:ee:9e:2d:ea:be:b3:ca:4a:f0:6e:4f:22:e8:be: + * 8b:8d:9b:2c:30:a5:ed:2c:2b:13:4c:f7:61:19:64: + * 35:9d:b0:c8:10:85:01:e7:2a:70:13:00:39:c5:73: + * 63:34:fd:28:2d:7f:8d:20 + * -----BEGIN PRIVATE KEY----- + * MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCaDOCPqAJ+Wu/t + * skKtCE6RusKtm3nXmw/90vgVLxmJgBAAAhltJ8KQ16UjU3RuZCh8JKrt6iFZ3KNc + * tclCMU+i3vsJfHPtiAQ08RWtPWDNysUTmdOfm7KScMu6Sz0glq2+klPtVDvFFL3P + * 1A/LBU/9K57gULtlE5LA1r1NAgxwtmXUfbRNw98sCJ7SPmkyRm9vytFzpJQH7xTj + * 2p4vwKwOEDNMaHnzeUDW6TzC5nDgic6geqiEKIUyNwiwz7F/X7wfpT3v1mioFyFf + * h9VLtczueI3dsShqwPtkvbdwAjMDC7i4uwiC9o4FJ9E75sWsTYVboR2jSF0DFXZj + * bHEhPpjNAgMBAAECggEAaIc2VKPG1V/1D092yJwrW9zivhQSL8cKqcteBFnKNS+N + * K8RA5n0lG00Hw5mcFk+l3N6wkPDeInCA9KZw4pY9GCG/KyekLdeuKxIvCDbumZTt + * 9qfZHaLzH0SkKEtnNdaoG/iENDSEveyeAwg8kyCOrxXLHyAIl8QZPvo2xqsOL+ez + * wKe85OCmCBxpIE14vXrlJUhgni5QjTYeB+nVDTlnQUIk24fld3b9XtXG5dOwmHFI + * aUdPRgUMnlhFLuIn0PYRBXitg1pb7NcuJlqlT55ShCwfWRp4VgpEVMY3ZAHK5KgB + * x4bBtNZsehWaZWlGnv32CBcMbKw4vcLN2u9UekiSTQKBgQDkQ8xRJaodkEGVLOif + * qhyb6r39KeVoaygA7DExNtA9hNvFXTL2OLkET0XLGfWIzaj8cLhtmGimtJ7B2v3b + * 6xpTPDvmhdJvA0V6rUmMw5anRqS7O0jT1xy0PPcECqOFnZQ+vTX1NCE9CInfxVSv + * z5D32FxXxXdayNGzj+4BXAcTPwKBgQCsxKDMfFHbZQoC2rzYdyGM0zCu7FBgS7k5 + * xy29mKpPm0R0q/iG3uJEFXN6zdVG8gNixYecbZHVepoXwsYvKQ6KpKn0wmOid5e/ + * xpDoOXCHzP1iT9I950dw+/O9vVycd/4jM32D78sOTvHdBUdAl/Tath+5jeKSBAm+ + * +2qXKSes8wKBgD8IHbZWsTgCqql3wjC8t7OySY5L8GY6GMzQa/EMEsq6EjnYt4bY + * OPbgsQQZgfyp1b0Hn1XcHSHThHdBcpI0xIsxedT5JRe0jo4GpeWx6Lr+PeTZxQ2C + * PBHlN8ys52SxE8uTUgAIyhjhb7kT84OszHo0C6PNCl1OUOHFn9JOSEHfAoGAAsf7 + * iq8ppi1/NsKMrbNlP94ad4ZoWNR/O9Xf/6BYhYWLWZF3I7ysycnKnRx5JXY55bom + * T7dX1KbvmhhRlmrDyCmUbtM+RVxFfhnVNVfPXvBG1/FPAh4aAVCdAN3ugrpPxgNL + * LveKPkW5EQTHu9t2Xpr18ce98PnNqlxjv+EyuU8CgYBQTOYeI/PiK9Y/h1P7GVNL + * hCELdzHtjcMM6jGwpjip5kRuGAVTj0pfdeU+tSabRj1z58Eqpj7DzUGxplVXhBET + * 7ESSWX/dDWcw07cT7p4t6r6zykrwbk8i6L6LjZssMKXtLCsTTPdhGWQ1nbDIEIUB + * 5ypwEwA5xXNjNP0oLX+NIA== + * -----END PRIVATE KEY----- * * server certificate: - * Data: - * Version: 3 (0x2) - * Serial Number: 8 (0x8) - * Signature Algorithm: md5WithRSAEncryption - * Issuer: C=US, ST=Some-State, L=Some-City, O=Some-Org - * Validity - * Not Before: Dec 8 03:43:04 2008 GMT - * Not After : Aug 25 03:43:04 2028 GMT - * Subject: C=US, ST=Some-State, L=Some-City, O=Some-Org, OU=SSL-Server, CN=localhost - * Subject Public Key Info: - * Public Key Algorithm: rsaEncryption - * RSA Public Key: (1024 bit) - * Modulus (1024 bit): - * 00:a5:ac:5b:1c:37:a2:dd:99:89:2d:b2:79:b8:8f: - * d5:48:a5:e7:1c:84:17:8d:69:9c:c6:ac:6d:f9:f2: - * 1d:1f:39:19:da:d3:72:1e:6e:ec:44:cc:70:a4:dc: - * ba:00:30:f6:a0:4f:3d:54:7a:61:6a:cc:57:d0:0a: - * 7f:95:28:18:3f:9a:d9:94:f2:1b:c8:24:88:7e:fe: - * 9d:0f:3d:fb:57:53:08:b3:20:33:d4:3f:17:47:14: - * d1:cd:ea:08:d8:0e:75:4e:af:be:cc:d2:ec:af:a9: - * 7a:49:df:c2:d9:ac:b8:24:40:90:a6:03:56:2a:d0: - * 30:05:40:2c:4f:ab:d9:74:89 - * Exponent: 65537 (0x10001) - * X509v3 extensions: - * X509v3 Basic Constraints: - * CA:FALSE - * X509v3 Key Usage: - * Digital Signature, Non Repudiation, Key Encipherment - * X509v3 Subject Key Identifier: - * ED:6E:DB:F4:B5:56:C8:FB:1A:06:61:3F:0F:08:BB:A6:04:D8:16:54 - * X509v3 Authority Key Identifier: - * keyid:FA:B9:51:BF:4C:E7:D9:86:98:33:F9:E7:CB:1E:F1:33:49:F7:A8:14 - * - * X509v3 Subject Alternative Name: critical - * DNS:localhost - * Signature Algorithm: md5WithRSAEncryption0 - * + * Data: + * Version: 3 (0x2) + * Serial Number: 106315679 (0x6563f9f) + * Signature Algorithm: sha1WithRSAEncryption + * Issuer: C=Us, ST=Some-State, L=Some-City, O=Some-Org + * Validity + * Not Before: Jul 1 04:16:55 2024 GMT + * Not After : Jul 2 04:16:55 2034 GMT + * Subject: C=US, ST=Some-State, L=Some-City, O=Some-Org, CN=localhost ou=SSL-Server + * Subject Public Key Info: + * Public Key Algorithm: rsaEncryption + * Public-Key: (2048 bit) + * Modulus: + * 00:9a:0c:e0:8f:a8:02:7e:5a:ef:ed:b2:42:ad:08: + * 4e:91:ba:c2:ad:9b:79:d7:9b:0f:fd:d2:f8:15:2f: + * 19:89:80:10:00:02:19:6d:27:c2:90:d7:a5:23:53: + * 74:6e:64:28:7c:24:aa:ed:ea:21:59:dc:a3:5c:b5: + * c9:42:31:4f:a2:de:fb:09:7c:73:ed:88:04:34:f1: + * 15:ad:3d:60:cd:ca:c5:13:99:d3:9f:9b:b2:92:70: + * cb:ba:4b:3d:20:96:ad:be:92:53:ed:54:3b:c5:14: + * bd:cf:d4:0f:cb:05:4f:fd:2b:9e:e0:50:bb:65:13: + * 92:c0:d6:bd:4d:02:0c:70:b6:65:d4:7d:b4:4d:c3: + * df:2c:08:9e:d2:3e:69:32:46:6f:6f:ca:d1:73:a4: + * 94:07:ef:14:e3:da:9e:2f:c0:ac:0e:10:33:4c:68: + * 79:f3:79:40:d6:e9:3c:c2:e6:70:e0:89:ce:a0:7a: + * a8:84:28:85:32:37:08:b0:cf:b1:7f:5f:bc:1f:a5: + * 3d:ef:d6:68:a8:17:21:5f:87:d5:4b:b5:cc:ee:78: + * 8d:dd:b1:28:6a:c0:fb:64:bd:b7:70:02:33:03:0b: + * b8:b8:bb:08:82:f6:8e:05:27:d1:3b:e6:c5:ac:4d: + * 85:5b:a1:1d:a3:48:5d:03:15:76:63:6c:71:21:3e: + * 98:cd + * Exponent: 65537 (0x10001) + * X509v3 extensions: + * X509v3 Subject Key Identifier: + * 5C:AF:44:B1:48:B8:59:9A:64:53:9D:2E:A6:B2:09:D3:0A:92:04:83 + * X509v3 Key Usage: + * Digital Signature, Non Repudiation, Key Encipherment + * X509v3 Subject Alternative Name: critical + * DNS:localhost + * X509v3 Basic Constraints: + * CA:FALSE + * X509v3 Authority Key Identifier: + * E0:03:90:F6:4F:BB:57:E6:7E:AF:5C:94:25:B3:85:DA:16:0A:51:40 + * Signature Algorithm: sha1WithRSAEncryption + * Signature Value: + * 9d:22:49:5f:56:23:e6:80:35:cc:ab:44:1c:27:bd:c9:8d:89: + * 93:49:58:e8:c1:7a:68:dd:cf:bd:e0:12:76:06:54:cd:2f:62: + * 9b:54:84:f2:bb:90:a0:bb:37:e2:13:1d:f3:df:41:aa:e0:fe: + * c0:ef:46:78:8d:aa:f4:1b:70:ad:a9:16:24:fa:15:4a:c6:0a: + * 8d:e1:99:93:00:a9:d4:b6:08:5d:8e:65:03:dc:d0:95:fc:95: + * 61:a6:ad:b5:ab:4d:a6:e0:05:48:8c:db:42:42:8a:d6:5e:c0: + * 2a:a0:11:15:b8:07:69:5c:3f:99:a0:bd:53:65:db:4e:cf:46: + * 61:93:09:7b:81:40:ff:5c:fe:4c:eb:f4:ac:de:1f:38:ad:b2: + * 60:28:f6:0e:9f:46:e7:07:8f:20:9a:a4:e1:8f:ab:54:99:76: + * 82:d8:9e:70:c4:da:98:85:71:af:3b:54:e4:01:b4:9e:83:d0: + * 7b:c6:8d:1f:ed:25:08:89:05:e9:87:97:76:5a:a3:85:c3:f8: + * 59:d7:bb:3b:5a:db:cb:ed:5d:ff:ac:21:b9:9a:e2:65:0a:bc: + * de:d1:dc:53:94:98:44:97:91:b3:1b:6b:80:0b:9b:57:b3:ae: + * 5c:7c:35:ca:39:71:f7:4e:8f:4a:d7:eb:0b:25:da:b2:1e:17: + * 48:b8:eb:09 * -----BEGIN CERTIFICATE----- - * MIICpDCCAg2gAwIBAgIBCDANBgkqhkiG9w0BAQQFADBJMQswCQYDVQQGEwJVUzET - * MBEGA1UECBMKU29tZS1TdGF0ZTESMBAGA1UEBxMJU29tZS1DaXR5MREwDwYDVQQK - * EwhTb21lLU9yZzAeFw0wODEyMDgwMzQzMDRaFw0yODA4MjUwMzQzMDRaMHIxCzAJ - * BgNVBAYTAlVTMRMwEQYDVQQIEwpTb21lLVN0YXRlMRIwEAYDVQQHEwlTb21lLUNp - * dHkxETAPBgNVBAoTCFNvbWUtT3JnMRMwEQYDVQQLEwpTU0wtU2VydmVyMRIwEAYD - * VQQDEwlsb2NhbGhvc3QwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAKWsWxw3 - * ot2ZiS2yebiP1Uil5xyEF41pnMasbfnyHR85GdrTch5u7ETMcKTcugAw9qBPPVR6 - * YWrMV9AKf5UoGD+a2ZTyG8gkiH7+nQ89+1dTCLMgM9Q/F0cU0c3qCNgOdU6vvszS - * 7K+peknfwtmsuCRAkKYDVirQMAVALE+r2XSJAgMBAAGjczBxMAkGA1UdEwQCMAAw - * CwYDVR0PBAQDAgXgMB0GA1UdDgQWBBTtbtv0tVbI+xoGYT8PCLumBNgWVDAfBgNV - * HSMEGDAWgBT6uVG/TOfZhpgz+efLHvEzSfeoFDAXBgNVHREBAf8EDTALgglsb2Nh - * bGhvc3QwDQYJKoZIhvcNAQEEBQADgYEAoqVTciHtcvsUj+YaTct8tUh3aTCsKsac - * PHhfQ+ObjiXSgxsKYTX7ym/wk/wvlbUcbqLKxsu7qrcJitH+H9heV1hEHEu65Uoi - * nRugFruyOrwvAylV8Cm2af7ddilmYJ+sdJA6N2M3xJRxR0G2LFHEXDNEjYReyexn - * JqCpf5uZGOo= + * MIIDpTCCAo2gAwIBAgIEBlY/nzANBgkqhkiG9w0BAQUFADBJMQswCQYDVQQGEwJV + * czETMBEGA1UECBMKU29tZS1TdGF0ZTESMBAGA1UEBxMJU29tZS1DaXR5MREwDwYD + * VQQKEwhTb21lLU9yZzAeFw0yNDA3MDEwNDE2NTVaFw0zNDA3MDIwNDE2NTVaMGsx + * CzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpTb21lLVN0YXRlMRIwEAYDVQQHEwlTb21l + * LUNpdHkxETAPBgNVBAoTCFNvbWUtT3JnMSAwHgYDVQQDExdsb2NhbGhvc3Qgb3U9 + * U1NMLVNlcnZlcjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJoM4I+o + * An5a7+2yQq0ITpG6wq2bedebD/3S+BUvGYmAEAACGW0nwpDXpSNTdG5kKHwkqu3q + * IVnco1y1yUIxT6Le+wl8c+2IBDTxFa09YM3KxROZ05+bspJwy7pLPSCWrb6SU+1U + * O8UUvc/UD8sFT/0rnuBQu2UTksDWvU0CDHC2ZdR9tE3D3ywIntI+aTJGb2/K0XOk + * lAfvFOPani/ArA4QM0xoefN5QNbpPMLmcOCJzqB6qIQohTI3CLDPsX9fvB+lPe/W + * aKgXIV+H1Uu1zO54jd2xKGrA+2S9t3ACMwMLuLi7CIL2jgUn0TvmxaxNhVuhHaNI + * XQMVdmNscSE+mM0CAwEAAaNzMHEwHQYDVR0OBBYEFFyvRLFIuFmaZFOdLqayCdMK + * kgSDMAsGA1UdDwQEAwIF4DAXBgNVHREBAf8EDTALgglsb2NhbGhvc3QwCQYDVR0T + * BAIwADAfBgNVHSMEGDAWgBTgA5D2T7tX5n6vXJQls4XaFgpRQDANBgkqhkiG9w0B + * AQUFAAOCAQEAnSJJX1Yj5oA1zKtEHCe9yY2Jk0lY6MF6aN3PveASdgZUzS9im1SE + * 8ruQoLs34hMd899BquD+wO9GeI2q9BtwrakWJPoVSsYKjeGZkwCp1LYIXY5lA9zQ + * lfyVYaattatNpuAFSIzbQkKK1l7AKqARFbgHaVw/maC9U2XbTs9GYZMJe4FA/1z+ + * TOv0rN4fOK2yYCj2Dp9G5wePIJqk4Y+rVJl2gtiecMTamIVxrztU5AG0noPQe8aN + * H+0lCIkF6YeXdlqjhcP4Wde7O1rby+1d/6whuZriZQq83tHcU5SYRJeRsxtrgAub + * V7OuXHw1yjlx906PStfrCyXash4XSLjrCQ== * -----END CERTIFICATE----- * * * TLS client certificate: * client private key: - * ----BEGIN RSA PRIVATE KEY----- - * Proc-Type: 4,ENCRYPTED - * DEK-Info: DES-EDE3-CBC,FA2A435CD35A9390 - * - * Z+Y2uaETbsUWIyJUyVu1UV2G4rgFYJyACZT6Tp1KjRtxflSh2kXkJ9MpuXMXA0V4 - * Yy3fDzPqCL9NJmQAYRlAx/W/+j4F5EyMWDIx8fUxzONRZyoiwF7jLm+KscAfv6Pf - * q7ItWOdj3z7IYrwlB8YIGd3F2cDKT3S+lYRk7rKb/qT7itbuHnY4Ardh3yl+MZak - * jBp+ELUlRsUqSr1V0LoM+0rCCykarpyfhpxEcqsrl0v9Cyi5uhU50/oKv5zql3SH - * l2ImgDjp3batAs8+Bd4NF2aqi0a7Hy44JUHxRm4caZryU/i/D9N1MbuM6882HLat - * 5N0G+NaIUfywa8mjwq2D5aiit18HqKA6XeRRYeJ5Dvu9DCO4GeFSwcUFIBMI0L46 - * 7s114+oDodg57pMgITi+04vmUxvqlN9aiyd7f5Fgd7PeHGeOdbMz1NaJLJaPI9++ - * NakK8eK9iwT/Gdq0Uap5/CHW7vCT5PO+h3HY0STH0lWStXhdWnFO04zTdywsbSp+ - * DLpHeFT66shfeUlxR0PsCbG9vPRt/QmGLeYQZITppWo/ylSq4j+pRIuXvuWHdBRN - * rTZ8QF4Y7AxQUXVz1j1++s6ZMHTzaK2i9HrhmDs1MbJl+QwWre3Xpv3LvTVz3k5U - * wX8kuY1m3STt71QCaRWENq5sRaMImLxZbxc/ivFl9RAzUqo4NCxLod/QgA4iLqtO - * ztnlpzwlC/F8HbQ1oqYWwnZAPhzU/cULtstl+Yrws2c2atO323LbPXZqbASySgig - * sNpFXQMObdfP6LN23bY+1SvtK7V4NUTNhpdIc6INQAQ= - * -----END RSA PRIVATE KEY----- - * - * -----BEGIN RSA PRIVATE KEY----- - * MIICWwIBAAKBgQC78EA2rCZUTvSjWgAvaSFvuXo6k+yi9uGOx2PYLxIwmS6w8o/4 - * Jy0keCiE9wG/jUR53TvSVfPOPLJbIX3v/TNKsaP/xsibuQ98QTWX+ds6BWAFFa9Z - * F5KjEK0WHOQHU6+odqJWKpLT+SjgeM9eH0irXBnd4WdDunWN9YKsQ5JEGwIDAQAB - * AoGAEbdqNj0wN85hnWyEi/ObJU8UyKTdL9eaF72QGfcF/fLSxfd3vurihIeXOkGW - * tpn4lIxYcVGM9CognhqgJpl11jFTQzn1KqZ+NEJRKkCHA4hDabKJbSC9fXHvRwrf - * BsFpZqgiNxp3HseUTiwnaUVeyPgMt/jAj5nB5Sib+UyUxrECQQDnNQBiF2aifEg6 - * zbJOOC7he5CHAdkFxSxWVFVHL6EfXfqdLVkUohMbgZv+XxyIeU2biOExSg49Kds3 - * FOKgTau1AkEA0Bd1haj6QuCo8I0AXm2WO+MMTZMTvtHD/bGjKNM+fT4I8rKYnQRX - * 1acHdqS9Xx2rNJqZgkMmpESIdPR2fc4yjwJALFeM6EMmqvj8/VIf5UJ/Mz14fXwM - * PEARfckUxd9LnnFutCBTWlKvKXJVEZb6KO5ixPaegc57Jp3Vbh3yTN44lQJADD/1 - * SSMDaIB1MYP7a5Oj7m6VQNPRq8AJe5vDcRnOae0G9dKRrVyeFxO4GsHj6/+BHp2j - * P8nYMn9eURQ7DXjf/QJAAQzMlWnKGSO8pyTDtnQx3hRMoUkOEhmNq4bQhLkYqtnY - * FcqpUQ2qMjW+NiNWk5HnTrMS3L9EdJobMUzaNZLy4w== - * -----END RSA PRIVATE KEY----- * - * Private-Key: (1024 bit) + * Private-Key: (2048 bit, 2 primes) * modulus: - * 00:bb:f0:40:36:ac:26:54:4e:f4:a3:5a:00:2f:69: - * 21:6f:b9:7a:3a:93:ec:a2:f6:e1:8e:c7:63:d8:2f: - * 12:30:99:2e:b0:f2:8f:f8:27:2d:24:78:28:84:f7: - * 01:bf:8d:44:79:dd:3b:d2:55:f3:ce:3c:b2:5b:21: - * 7d:ef:fd:33:4a:b1:a3:ff:c6:c8:9b:b9:0f:7c:41: - * 35:97:f9:db:3a:05:60:05:15:af:59:17:92:a3:10: - * ad:16:1c:e4:07:53:af:a8:76:a2:56:2a:92:d3:f9: - * 28:e0:78:cf:5e:1f:48:ab:5c:19:dd:e1:67:43:ba: - * 75:8d:f5:82:ac:43:92:44:1b + * 00:cc:bf:92:3c:a6:57:74:1f:58:ad:c7:69:88:6f: + * 59:32:47:50:60:22:e4:98:49:0e:3e:1d:b8:ba:e2: + * 3b:b6:71:5b:fd:64:02:6d:0d:50:77:72:6e:a8:3d: + * 5d:d4:bd:1f:76:51:dc:9a:d0:d6:3e:d0:31:a5:24: + * 5a:2c:be:77:fa:88:a1:fa:06:41:c8:0f:47:70:47: + * 24:99:50:52:44:5b:30:62:5b:65:35:c4:28:b0:5c: + * ee:d0:1b:eb:39:2b:0b:a1:ac:96:48:da:56:6c:e0: + * e3:e6:e3:dd:45:cb:51:33:8d:40:43:d7:f0:a4:31: + * aa:b5:c0:df:4b:df:2b:0a:ed:7e:10:0c:ae:1f:96: + * a2:10:1e:6b:d0:f9:37:8b:df:0d:0e:02:35:f8:58: + * bc:6e:b5:57:0e:2f:ea:20:e6:73:9a:e5:6b:82:70: + * 25:bb:51:9a:7c:9d:e2:50:3d:cf:1e:24:3e:92:55: + * cf:2a:ad:0d:84:8f:a8:43:24:cd:ad:50:64:74:c2: + * 73:b6:e1:92:1c:b2:2b:8c:2d:7b:96:a6:41:61:5c: + * 1b:8f:78:28:51:40:ed:41:90:ce:1d:b8:26:81:47: + * 6b:e3:57:41:74:4e:20:f0:5a:1b:97:37:91:86:19: + * c5:f2:6d:04:c9:78:2b:5a:16:bc:fc:2b:71:5b:d0: + * 00:4f * publicExponent: 65537 (0x10001) * privateExponent: - * 11:b7:6a:36:3d:30:37:ce:61:9d:6c:84:8b:f3:9b: - * 25:4f:14:c8:a4:dd:2f:d7:9a:17:bd:90:19:f7:05: - * fd:f2:d2:c5:f7:77:be:ea:e2:84:87:97:3a:41:96: - * b6:99:f8:94:8c:58:71:51:8c:f4:2a:20:9e:1a:a0: - * 26:99:75:d6:31:53:43:39:f5:2a:a6:7e:34:42:51: - * 2a:40:87:03:88:43:69:b2:89:6d:20:bd:7d:71:ef: - * 47:0a:df:06:c1:69:66:a8:22:37:1a:77:1e:c7:94: - * 4e:2c:27:69:45:5e:c8:f8:0c:b7:f8:c0:8f:99:c1: - * e5:28:9b:f9:4c:94:c6:b1 + * 62:b2:d6:63:b6:2b:e2:26:5a:31:2b:37:8c:35:60: + * e2:03:ce:93:09:3e:f8:c9:fe:bb:a2:c8:32:0e:6c: + * 8a:7e:0a:c2:13:3b:b8:25:fa:ec:19:95:8e:34:46: + * cf:0e:7b:e4:25:82:1a:7f:21:48:16:44:58:3f:35: + * d8:eb:d8:1a:45:53:0f:9b:84:8a:54:13:33:e4:97: + * 97:f0:48:37:fb:5d:4f:8c:8f:35:63:e1:d9:62:73: + * 1c:8e:d8:cd:2e:1a:e5:4c:b5:05:59:7a:df:f1:68: + * eb:1c:5c:c6:10:44:8c:7d:42:c5:71:8a:e7:1b:aa: + * 17:03:6a:a0:c0:6b:97:50:17:ad:6e:5e:d9:db:6f: + * 3e:e9:3f:35:c3:45:bc:e8:3d:5a:b4:b9:3f:53:80: + * 64:dc:12:24:35:35:bd:98:bb:8d:fa:19:a3:5e:9e: + * ac:70:4a:fc:8d:ae:55:8b:71:81:0e:4d:c8:2f:87: + * b0:44:f7:4f:dc:a8:c8:50:b5:95:24:63:74:13:54: + * 58:de:fc:e0:75:eb:f4:06:58:83:12:4c:56:c4:c4: + * 18:0c:ea:a3:e7:25:a3:de:19:23:a2:5a:2a:b6:56: + * 04:bc:65:ba:7c:0a:f4:91:10:22:88:3f:9d:be:58: + * 43:4c:2e:ad:db:d6:32:cf:8e:b5:05:55:39:8b:e1: + * 01 * prime1: - * 00:e7:35:00:62:17:66:a2:7c:48:3a:cd:b2:4e:38: - * 2e:e1:7b:90:87:01:d9:05:c5:2c:56:54:55:47:2f: - * a1:1f:5d:fa:9d:2d:59:14:a2:13:1b:81:9b:fe:5f: - * 1c:88:79:4d:9b:88:e1:31:4a:0e:3d:29:db:37:14: - * e2:a0:4d:ab:b5 + * 00:f1:da:c2:8a:e5:66:45:8a:14:fc:08:6e:fb:aa: + * 50:d2:8c:b1:c4:f4:88:26:d4:b8:c4:63:30:ca:e3: + * 0c:6c:50:d4:93:5c:1c:13:37:60:21:11:3b:d1:f1: + * 9f:4c:0d:7b:0e:53:3d:c9:a4:fb:fa:6b:9e:b4:0a: + * 5d:d3:50:88:d7:be:c3:88:b2:b1:8a:6e:7b:d6:70: + * 88:96:a4:fe:90:ef:d1:84:ad:a8:9e:9f:3a:68:3f: + * 3f:82:07:be:c2:44:1e:d5:a1:a9:1a:db:39:d7:7f: + * 0c:6e:35:5b:1d:33:1b:a9:cd:38:2a:64:d1:70:2a: + * fe:b9:c2:b6:ed:59:19:73:b1 * prime2: - * 00:d0:17:75:85:a8:fa:42:e0:a8:f0:8d:00:5e:6d: - * 96:3b:e3:0c:4d:93:13:be:d1:c3:fd:b1:a3:28:d3: - * 3e:7d:3e:08:f2:b2:98:9d:04:57:d5:a7:07:76:a4: - * bd:5f:1d:ab:34:9a:99:82:43:26:a4:44:88:74:f4: - * 76:7d:ce:32:8f + * 00:d8:b9:3a:38:6c:79:cd:0b:1f:2b:34:74:bf:7a: + * 3d:0c:21:5a:a6:ea:f2:9e:de:68:42:05:7f:ea:a5: + * 00:c9:10:f8:fd:c5:05:8d:03:45:5d:4f:6f:fa:6e: + * 9d:ef:ad:8a:ec:83:d4:ed:57:f3:86:73:15:2f:d2: + * 67:70:d1:62:ef:1d:25:08:59:47:20:62:47:16:35: + * e1:57:38:bf:39:dd:fc:b9:c8:d8:23:53:e2:02:7d: + * 22:31:4c:66:72:96:df:d8:7c:01:2c:71:00:89:18: + * e9:8c:08:44:8c:64:1f:93:9b:7a:97:26:c9:50:d0: + * 87:b2:48:a8:19:71:e1:b3:ff * exponent1: - * 2c:57:8c:e8:43:26:aa:f8:fc:fd:52:1f:e5:42:7f: - * 33:3d:78:7d:7c:0c:3c:40:11:7d:c9:14:c5:df:4b: - * 9e:71:6e:b4:20:53:5a:52:af:29:72:55:11:96:fa: - * 28:ee:62:c4:f6:9e:81:ce:7b:26:9d:d5:6e:1d:f2: - * 4c:de:38:95 + * 23:98:dd:35:70:5a:43:35:f5:ac:ba:d9:0a:f5:a0: + * 7b:bc:f5:95:55:a0:8c:86:96:c3:61:0e:17:6e:9f: + * af:79:9e:30:2a:48:7f:93:90:f4:8d:02:ce:fd:cf: + * 42:74:61:7e:54:46:2d:dd:b8:b0:bd:12:58:d1:85: + * c9:ca:7a:b9:b6:7c:35:2c:87:f1:26:1d:d8:0c:2c: + * 2e:70:0e:7f:ea:ac:5d:e8:e9:7e:9f:55:0b:6e:f3: + * bc:01:c3:d3:f8:0e:c9:c6:c7:8b:0a:65:53:10:82: + * 15:de:88:90:9d:ab:1e:ac:f3:ed:59:75:72:1b:01: + * ee:f9:77:cf:2b:64:11:a1 * exponent2: - * 0c:3f:f5:49:23:03:68:80:75:31:83:fb:6b:93:a3: - * ee:6e:95:40:d3:d1:ab:c0:09:7b:9b:c3:71:19:ce: - * 69:ed:06:f5:d2:91:ad:5c:9e:17:13:b8:1a:c1:e3: - * eb:ff:81:1e:9d:a3:3f:c9:d8:32:7f:5e:51:14:3b: - * 0d:78:df:fd + * 00:9e:29:6f:87:c6:02:8d:d5:54:05:df:de:63:ee: + * fd:a6:60:a1:1b:b7:d3:20:86:07:68:47:43:37:26: + * fc:0f:c0:c7:35:cc:17:64:f5:c2:25:7a:d7:a9:d8: + * 18:82:d6:0f:d0:d3:d5:0c:f1:66:d3:f4:20:be:29: + * bb:3b:e6:53:61:55:cf:b4:ec:12:b0:5b:88:ad:78: + * dc:df:1e:96:cf:d0:65:a3:e0:23:7c:84:b7:28:41: + * d2:36:50:1f:63:f9:1f:9b:89:c4:01:7e:e6:79:27: + * 29:29:fc:ce:a9:f6:57:e5:0d:4e:c6:08:94:5a:da: + * 14:6d:d4:00:79:b1:56:9a:59 * coefficient: - * 01:0c:cc:95:69:ca:19:23:bc:a7:24:c3:b6:74:31: - * de:14:4c:a1:49:0e:12:19:8d:ab:86:d0:84:b9:18: - * aa:d9:d8:15:ca:a9:51:0d:aa:32:35:be:36:23:56: - * 93:91:e7:4e:b3:12:dc:bf:44:74:9a:1b:31:4c:da: - * 35:92:f2:e3 + * 6c:73:0d:fe:c7:22:15:5d:8c:a1:91:2b:d1:88:e8: + * 91:f9:d0:3e:d0:ba:c4:74:88:ce:14:20:4e:1e:4b: + * c5:91:8f:c1:56:e9:74:e0:f6:cf:71:91:ed:2c:f5: + * 90:9d:d6:c8:cd:f5:79:dc:6e:b3:83:3e:fa:d6:b4: + * 60:d9:3a:52:12:76:9d:92:fb:db:26:ee:43:33:c4: + * 0b:84:74:1b:91:e0:41:8b:cc:cc:24:da:52:af:2d: + * 42:e7:11:57:0d:aa:66:af:1a:ba:c2:8e:6a:ee:8f: + * 2c:e6:5b:76:38:96:bb:7a:2f:59:fe:de:a1:02:fc: + * 12:3a:aa:9f:3c:0e:a4:78 + * writing RSA key + * -----BEGIN PRIVATE KEY----- + * MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDMv5I8pld0H1it + * x2mIb1kyR1BgIuSYSQ4+Hbi64ju2cVv9ZAJtDVB3cm6oPV3UvR92Udya0NY+0DGl + * JFosvnf6iKH6BkHID0dwRySZUFJEWzBiW2U1xCiwXO7QG+s5KwuhrJZI2lZs4OPm + * 491Fy1EzjUBD1/CkMaq1wN9L3ysK7X4QDK4flqIQHmvQ+TeL3w0OAjX4WLxutVcO + * L+og5nOa5WuCcCW7UZp8neJQPc8eJD6SVc8qrQ2Ej6hDJM2tUGR0wnO24ZIcsiuM + * LXuWpkFhXBuPeChRQO1BkM4duCaBR2vjV0F0TiDwWhuXN5GGGcXybQTJeCtaFrz8 + * K3Fb0ABPAgMBAAECggEAYrLWY7Yr4iZaMSs3jDVg4gPOkwk++Mn+u6LIMg5sin4K + * whM7uCX67BmVjjRGzw575CWCGn8hSBZEWD812OvYGkVTD5uEilQTM+SXl/BIN/td + * T4yPNWPh2WJzHI7YzS4a5Uy1BVl63/Fo6xxcxhBEjH1CxXGK5xuqFwNqoMBrl1AX + * rW5e2dtvPuk/NcNFvOg9WrS5P1OAZNwSJDU1vZi7jfoZo16erHBK/I2uVYtxgQ5N + * yC+HsET3T9yoyFC1lSRjdBNUWN784HXr9AZYgxJMVsTEGAzqo+clo94ZI6JaKrZW + * BLxlunwK9JEQIog/nb5YQ0wurdvWMs+OtQVVOYvhAQKBgQDx2sKK5WZFihT8CG77 + * qlDSjLHE9Igm1LjEYzDK4wxsUNSTXBwTN2AhETvR8Z9MDXsOUz3JpPv6a560Cl3T + * UIjXvsOIsrGKbnvWcIiWpP6Q79GEraienzpoPz+CB77CRB7Voaka2znXfwxuNVsd + * MxupzTgqZNFwKv65wrbtWRlzsQKBgQDYuTo4bHnNCx8rNHS/ej0MIVqm6vKe3mhC + * BX/qpQDJEPj9xQWNA0VdT2/6bp3vrYrsg9TtV/OGcxUv0mdw0WLvHSUIWUcgYkcW + * NeFXOL853fy5yNgjU+ICfSIxTGZylt/YfAEscQCJGOmMCESMZB+Tm3qXJslQ0Iey + * SKgZceGz/wKBgCOY3TVwWkM19ay62Qr1oHu89ZVVoIyGlsNhDhdun695njAqSH+T + * kPSNAs79z0J0YX5URi3duLC9EljRhcnKerm2fDUsh/EmHdgMLC5wDn/qrF3o6X6f + * VQtu87wBw9P4DsnGx4sKZVMQghXeiJCdqx6s8+1ZdXIbAe75d88rZBGhAoGBAJ4p + * b4fGAo3VVAXf3mPu/aZgoRu30yCGB2hHQzcm/A/AxzXMF2T1wiV616nYGILWD9DT + * 1QzxZtP0IL4puzvmU2FVz7TsErBbiK143N8els/QZaPgI3yEtyhB0jZQH2P5H5uJ + * xAF+5nknKSn8zqn2V+UNTsYIlFraFG3UAHmxVppZAoGAbHMN/sciFV2MoZEr0Yjo + * kfnQPtC6xHSIzhQgTh5LxZGPwVbpdOD2z3GR7Sz1kJ3WyM31edxus4M++ta0YNk6 + * UhJ2nZL72ybuQzPEC4R0G5HgQYvMzCTaUq8tQucRVw2qZq8ausKOau6PLOZbdjiW + * u3ovWf7eoQL8EjqqnzwOpHg= + * -----END PRIVATE KEY----- * * client certificate: - * Data: - * Version: 3 (0x2) - * Serial Number: 9 (0x9) - * Signature Algorithm: md5WithRSAEncryption - * Issuer: C=US, ST=Some-State, L=Some-City, O=Some-Org - * Validity - * Not Before: Dec 8 03:43:24 2008 GMT - * Not After : Aug 25 03:43:24 2028 GMT - * Subject: C=US, ST=Some-State, L=Some-City, O=Some-Org, OU=SSL-Client, CN=localhost - * Subject Public Key Info: - * Public Key Algorithm: rsaEncryption - * RSA Public Key: (1024 bit) - * Modulus (1024 bit): - * 00:bb:f0:40:36:ac:26:54:4e:f4:a3:5a:00:2f:69: - * 21:6f:b9:7a:3a:93:ec:a2:f6:e1:8e:c7:63:d8:2f: - * 12:30:99:2e:b0:f2:8f:f8:27:2d:24:78:28:84:f7: - * 01:bf:8d:44:79:dd:3b:d2:55:f3:ce:3c:b2:5b:21: - * 7d:ef:fd:33:4a:b1:a3:ff:c6:c8:9b:b9:0f:7c:41: - * 35:97:f9:db:3a:05:60:05:15:af:59:17:92:a3:10: - * ad:16:1c:e4:07:53:af:a8:76:a2:56:2a:92:d3:f9: - * 28:e0:78:cf:5e:1f:48:ab:5c:19:dd:e1:67:43:ba: - * 75:8d:f5:82:ac:43:92:44:1b - * Exponent: 65537 (0x10001) - * X509v3 extensions: - * X509v3 Basic Constraints: - * CA:FALSE - * X509v3 Key Usage: - * Digital Signature, Non Repudiation, Key Encipherment - * X509v3 Subject Key Identifier: - * CD:BB:C8:85:AA:91:BD:FD:1D:BE:CD:67:7C:FF:B3:E9:4C:A8:22:E6 - * X509v3 Authority Key Identifier: - * keyid:FA:B9:51:BF:4C:E7:D9:86:98:33:F9:E7:CB:1E:F1:33:49:F7:A8:14 - * - * X509v3 Subject Alternative Name: critical - * DNS:localhost - * Signature Algorithm: md5WithRSAEncryption - * + * Data: + * Version: 3 (0x2) + * Serial Number: 1500699355 (0x5972dadb) + * Signature Algorithm: sha1WithRSAEncryption + * Issuer: C=Us, ST=Some-State, L=Some-City, O=Some-Org + * Validity + * Not Before: Jul 1 04:16:52 2024 GMT + * Not After : Jul 2 04:16:52 2034 GMT + * Subject: C=US, ST=Some-State, L=Some-City, O=Some-Org, CN=localhost ou=SSL-Client + * Subject Public Key Info: + * Public Key Algorithm: rsaEncryption + * Public-Key: (2048 bit) + * Modulus: + * 00:cc:bf:92:3c:a6:57:74:1f:58:ad:c7:69:88:6f: + * 59:32:47:50:60:22:e4:98:49:0e:3e:1d:b8:ba:e2: + * 3b:b6:71:5b:fd:64:02:6d:0d:50:77:72:6e:a8:3d: + * 5d:d4:bd:1f:76:51:dc:9a:d0:d6:3e:d0:31:a5:24: + * 5a:2c:be:77:fa:88:a1:fa:06:41:c8:0f:47:70:47: + * 24:99:50:52:44:5b:30:62:5b:65:35:c4:28:b0:5c: + * ee:d0:1b:eb:39:2b:0b:a1:ac:96:48:da:56:6c:e0: + * e3:e6:e3:dd:45:cb:51:33:8d:40:43:d7:f0:a4:31: + * aa:b5:c0:df:4b:df:2b:0a:ed:7e:10:0c:ae:1f:96: + * a2:10:1e:6b:d0:f9:37:8b:df:0d:0e:02:35:f8:58: + * bc:6e:b5:57:0e:2f:ea:20:e6:73:9a:e5:6b:82:70: + * 25:bb:51:9a:7c:9d:e2:50:3d:cf:1e:24:3e:92:55: + * cf:2a:ad:0d:84:8f:a8:43:24:cd:ad:50:64:74:c2: + * 73:b6:e1:92:1c:b2:2b:8c:2d:7b:96:a6:41:61:5c: + * 1b:8f:78:28:51:40:ed:41:90:ce:1d:b8:26:81:47: + * 6b:e3:57:41:74:4e:20:f0:5a:1b:97:37:91:86:19: + * c5:f2:6d:04:c9:78:2b:5a:16:bc:fc:2b:71:5b:d0: + * 00:4f + * Exponent: 65537 (0x10001) + * X509v3 extensions: + * X509v3 Subject Key Identifier: + * CD:45:E2:05:92:88:A3:C7:49:28:E7:D3:37:B7:13:92:FB:B1:36:C4 + * X509v3 Key Usage: + * Digital Signature, Non Repudiation, Key Encipherment + * X509v3 Subject Alternative Name: critical + * DNS:localhost + * X509v3 Basic Constraints: + * CA:FALSE + * X509v3 Authority Key Identifier: + * E0:03:90:F6:4F:BB:57:E6:7E:AF:5C:94:25:B3:85:DA:16:0A:51:40 + * Signature Algorithm: sha1WithRSAEncryption + * Signature Value: + * 23:6e:e9:5d:80:0d:b3:86:c9:cd:17:81:33:bd:5b:aa:c0:65: + * 4c:6b:9f:fa:ee:32:e9:89:e1:d0:c7:1d:5c:43:7e:94:ac:83: + * af:91:90:4c:26:61:8d:fe:6b:1a:aa:6e:61:39:b3:24:4a:dc: + * 92:c8:ca:f2:80:b0:05:41:0c:b3:dd:ed:b7:81:42:9a:1e:4e: + * f2:80:6c:72:62:8b:bd:d4:cd:23:7d:7c:e8:6f:e3:67:89:6a: + * 79:19:dd:f6:57:62:12:fa:eb:cd:66:c3:d2:d8:40:5a:1c:dd: + * 7f:9f:b2:34:e9:2a:d6:14:52:ba:6e:a8:9b:0d:a9:a1:03:bf: + * c4:0d:92:3d:59:e4:a9:8e:20:41:39:99:81:70:9d:d0:68:98: + * fc:5f:49:4a:92:e5:a2:c1:51:61:f6:1e:49:56:0b:b6:8c:57: + * db:08:2a:f0:a3:04:dc:a1:04:a2:5c:d0:90:4f:13:8d:1c:e6: + * 2e:7a:63:9c:32:40:65:59:04:5d:71:90:5a:a8:db:6a:30:42: + * 57:5b:0b:df:ce:a1:1f:fa:23:71:f3:57:12:c4:1c:66:3b:37: + * 77:32:28:a7:fb:ad:ee:86:51:4c:80:2f:dd:c8:5b:9f:a7:15: + * 07:fa:2b:5a:ee:93:00:5f:a6:43:22:1b:40:52:15:66:01:84: + * 32:9e:71:21 * -----BEGIN CERTIFICATE----- - * MIICpDCCAg2gAwIBAgIBCTANBgkqhkiG9w0BAQQFADBJMQswCQYDVQQGEwJVUzET - * MBEGA1UECBMKU29tZS1TdGF0ZTESMBAGA1UEBxMJU29tZS1DaXR5MREwDwYDVQQK - * EwhTb21lLU9yZzAeFw0wODEyMDgwMzQzMjRaFw0yODA4MjUwMzQzMjRaMHIxCzAJ - * BgNVBAYTAlVTMRMwEQYDVQQIEwpTb21lLVN0YXRlMRIwEAYDVQQHEwlTb21lLUNp - * dHkxETAPBgNVBAoTCFNvbWUtT3JnMRMwEQYDVQQLEwpTU0wtQ2xpZW50MRIwEAYD - * VQQDEwlsb2NhbGhvc3QwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBALvwQDas - * JlRO9KNaAC9pIW+5ejqT7KL24Y7HY9gvEjCZLrDyj/gnLSR4KIT3Ab+NRHndO9JV - * 8848slshfe/9M0qxo//GyJu5D3xBNZf52zoFYAUVr1kXkqMQrRYc5AdTr6h2olYq - * ktP5KOB4z14fSKtcGd3hZ0O6dY31gqxDkkQbAgMBAAGjczBxMAkGA1UdEwQCMAAw - * CwYDVR0PBAQDAgXgMB0GA1UdDgQWBBTNu8iFqpG9/R2+zWd8/7PpTKgi5jAfBgNV - * HSMEGDAWgBT6uVG/TOfZhpgz+efLHvEzSfeoFDAXBgNVHREBAf8EDTALgglsb2Nh - * bGhvc3QwDQYJKoZIhvcNAQEEBQADgYEAm25gJyqW1JznQ1EyOtTGswBVwfgBOf+F - * HJuBTcflYQLbTD/AETPQJGvZU9tdhuLtbG3OPhR7vSY8zeAbfM3dbH7QFr3r47Gj - * XEH7qM/MX+Z3ifVaC4MeJmrYQkYFSuKeyyKpdRVX4w4nnFHF6OsNASsYrMW6LpxN - * cl/epUcHL7E= + * MIIDpTCCAo2gAwIBAgIEWXLa2zANBgkqhkiG9w0BAQUFADBJMQswCQYDVQQGEwJV + * czETMBEGA1UECBMKU29tZS1TdGF0ZTESMBAGA1UEBxMJU29tZS1DaXR5MREwDwYD + * VQQKEwhTb21lLU9yZzAeFw0yNDA3MDEwNDE2NTJaFw0zNDA3MDIwNDE2NTJaMGsx + * CzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpTb21lLVN0YXRlMRIwEAYDVQQHEwlTb21l + * LUNpdHkxETAPBgNVBAoTCFNvbWUtT3JnMSAwHgYDVQQDExdsb2NhbGhvc3Qgb3U9 + * U1NMLUNsaWVudDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMy/kjym + * V3QfWK3HaYhvWTJHUGAi5JhJDj4duLriO7ZxW/1kAm0NUHdybqg9XdS9H3ZR3JrQ + * 1j7QMaUkWiy+d/qIofoGQcgPR3BHJJlQUkRbMGJbZTXEKLBc7tAb6zkrC6Gslkja + * Vmzg4+bj3UXLUTONQEPX8KQxqrXA30vfKwrtfhAMrh+WohAea9D5N4vfDQ4CNfhY + * vG61Vw4v6iDmc5rla4JwJbtRmnyd4lA9zx4kPpJVzyqtDYSPqEMkza1QZHTCc7bh + * khyyK4wte5amQWFcG494KFFA7UGQzh24JoFHa+NXQXROIPBaG5c3kYYZxfJtBMl4 + * K1oWvPwrcVvQAE8CAwEAAaNzMHEwHQYDVR0OBBYEFM1F4gWSiKPHSSjn0ze3E5L7 + * sTbEMAsGA1UdDwQEAwIF4DAXBgNVHREBAf8EDTALgglsb2NhbGhvc3QwCQYDVR0T + * BAIwADAfBgNVHSMEGDAWgBTgA5D2T7tX5n6vXJQls4XaFgpRQDANBgkqhkiG9w0B + * AQUFAAOCAQEAI27pXYANs4bJzReBM71bqsBlTGuf+u4y6Ynh0McdXEN+lKyDr5GQ + * TCZhjf5rGqpuYTmzJErcksjK8oCwBUEMs93tt4FCmh5O8oBscmKLvdTNI3186G/j + * Z4lqeRnd9ldiEvrrzWbD0thAWhzdf5+yNOkq1hRSum6omw2poQO/xA2SPVnkqY4g + * QTmZgXCd0GiY/F9JSpLlosFRYfYeSVYLtoxX2wgq8KME3KEEolzQkE8TjRzmLnpj + * nDJAZVkEXXGQWqjbajBCV1sL386hH/ojcfNXEsQcZjs3dzIop/ut7oZRTIAv3chb + * n6cVB/orWu6TAF+mQyIbQFIVZgGEMp5xIQ== * -----END CERTIFICATE----- * * - * * Trusted CA certificate: * Certificate: * Data: - * Version: 3 (0x2) - * Serial Number: 0 (0x0) - * Signature Algorithm: md5WithRSAEncryption - * Issuer: C=US, ST=Some-State, L=Some-City, O=Some-Org - * Validity - * Not Before: Dec 8 02:43:36 2008 GMT - * Not After : Aug 25 02:43:36 2028 GMT - * Subject: C=US, ST=Some-State, L=Some-City, O=Some-Org - * Subject Public Key Info: - * Public Key Algorithm: rsaEncryption - * RSA Public Key: (1024 bit) - * Modulus (1024 bit): - * 00:cb:c4:38:20:07:be:88:a7:93:b0:a1:43:51:2d: - * d7:8e:85:af:54:dd:ad:a2:7b:23:5b:cf:99:13:53: - * 99:45:7d:ee:6d:ba:2d:bf:e3:ad:6e:3d:9f:1a:f9: - * 03:97:e0:17:55:ae:11:26:57:de:01:29:8e:05:3f: - * 21:f7:e7:36:e8:2e:37:d7:48:ac:53:d6:60:0e:c7: - * 50:6d:f6:c5:85:f7:8b:a6:c5:91:35:72:3c:94:ee: - * f1:17:f0:71:e3:ec:1b:ce:ca:4e:40:42:b0:6d:ee: - * 6a:0e:d6:e5:ad:3c:0f:c9:ba:82:4f:78:f8:89:97: - * 89:2a:95:12:4c:d8:09:2a:e9 - * Exponent: 65537 (0x10001) - * X509v3 extensions: - * X509v3 Subject Key Identifier: - * FA:B9:51:BF:4C:E7:D9:86:98:33:F9:E7:CB:1E:F1:33:49:F7:A8:14 - * X509v3 Authority Key Identifier: - * keyid:FA:B9:51:BF:4C:E7:D9:86:98:33:F9:E7:CB:1E:F1:33:49:F7:A8:14 - * DirName:/C=US/ST=Some-State/L=Some-City/O=Some-Org - * serial:00 - * - * X509v3 Basic Constraints: - * CA:TRUE - * Signature Algorithm: md5WithRSAEncryption - * + * Version: 3 (0x2) + * Serial Number: 1539881479 (0x5bc8ba07) + * Signature Algorithm: sha1WithRSAEncryption + * Issuer: C=Us, ST=Some-State, L=Some-City, O=Some-Org + * Validity + * Not Before: Jul 1 04:16:50 2024 GMT + * Not After : Jul 2 04:16:50 2034 GMT + * Subject: C=Us, ST=Some-State, L=Some-City, O=Some-Org + * Subject Public Key Info: + * Public Key Algorithm: rsaEncryption + * Public-Key: (2048 bit) + * Modulus: + * 00:bc:a6:55:60:3f:17:74:39:ba:71:8c:ef:11:3f: + * 9d:36:47:d5:02:d1:4d:9d:7e:b8:fe:59:b1:2b:f1: + * b7:b0:0c:31:57:eb:9c:9d:13:f5:4c:5f:fc:c4:9e: + * f9:75:09:0f:96:8f:05:77:30:a8:35:48:71:96:e4: + * a5:7d:1a:81:fb:e6:bf:90:80:60:5d:11:20:54:16: + * 0b:6d:df:64:de:18:d5:98:51:38:9d:c9:d6:5f:de: + * 9d:de:fe:a8:5f:d3:25:3d:ad:f3:2b:45:c8:4a:80: + * 97:14:7b:85:9d:cf:59:08:bb:c7:67:ac:8b:29:f3: + * 1e:93:bf:fb:82:53:c5:ae:b4:bc:55:30:15:a8:7e: + * 3f:82:22:59:43:cc:d2:62:e7:65:67:72:ec:10:8a: + * fc:05:90:91:72:dd:e9:6f:e2:9f:0c:ab:a1:83:55: + * 02:23:b7:a3:c3:50:ab:be:0b:bb:51:75:50:d1:a8: + * c9:e5:f5:06:fe:00:09:a6:1b:8a:16:29:0d:ab:00: + * 3e:bc:d2:73:d9:37:d7:d9:9a:58:6e:2d:2a:f6:76: + * ae:f4:ea:6d:70:de:7f:e3:04:43:c0:4f:91:3f:78: + * 58:d7:c2:ad:74:eb:04:9d:d0:7e:82:b8:7a:97:44: + * 61:fa:41:45:a6:ca:7d:a5:2e:fc:f9:a6:cf:61:cd: + * 75:bf + * Exponent: 65537 (0x10001) + * X509v3 extensions: + * X509v3 Subject Key Identifier: + * E0:03:90:F6:4F:BB:57:E6:7E:AF:5C:94:25:B3:85:DA:16:0A:51:40 + * X509v3 Basic Constraints: critical + * CA:TRUE + * Signature Algorithm: sha1WithRSAEncryption + * Signature Value: + * 1f:89:34:e3:ee:05:33:3b:18:ca:96:13:3d:ad:cd:5a:e6:24: + * 46:94:36:ad:37:a5:36:a9:92:37:f9:ed:07:dd:44:5b:c9:2e: + * 68:f7:82:f3:58:1c:64:ed:64:d0:ad:eb:30:15:e0:04:3a:d7: + * c8:c7:9d:65:76:ae:84:e4:2e:2d:0d:68:09:0d:e5:ae:cc:a7: + * 54:86:ad:ff:00:95:85:01:49:db:5b:8e:c2:6f:e7:19:10:17: + * f7:03:b9:a8:97:21:a2:fc:7f:c0:e0:7a:12:64:b8:70:f5:e8: + * b6:e1:25:f7:eb:32:3e:46:ce:43:55:fc:0b:62:59:90:61:63: + * f9:94:6c:95:63:31:1b:00:59:1f:72:9d:d0:0b:4f:cd:02:eb: + * de:20:4e:60:48:4e:ea:ad:3c:0f:1d:bf:1a:69:3d:a8:3d:8b: + * f5:a2:ae:8c:4f:d7:0e:b3:e1:9b:b3:2c:89:19:18:da:db:e1: + * 6d:d5:ab:c8:b8:48:57:d8:8b:33:01:d4:97:91:d9:da:34:a1: + * ef:36:00:e1:38:19:34:8f:0d:47:af:57:cf:59:d6:8b:0d:9e: + * 89:05:82:3d:3c:f3:45:1d:4a:3f:0e:0f:5a:28:6f:5c:e1:e9: + * 60:72:87:28:b6:97:44:8b:d7:c6:cd:cb:dc:5a:5d:60:f1:b4: + * 37:ee:44:db * -----BEGIN CERTIFICATE----- - * MIICrDCCAhWgAwIBAgIBADANBgkqhkiG9w0BAQQFADBJMQswCQYDVQQGEwJVUzET - * MBEGA1UECBMKU29tZS1TdGF0ZTESMBAGA1UEBxMJU29tZS1DaXR5MREwDwYDVQQK - * EwhTb21lLU9yZzAeFw0wODEyMDgwMjQzMzZaFw0yODA4MjUwMjQzMzZaMEkxCzAJ - * BgNVBAYTAlVTMRMwEQYDVQQIEwpTb21lLVN0YXRlMRIwEAYDVQQHEwlTb21lLUNp - * dHkxETAPBgNVBAoTCFNvbWUtT3JnMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKB - * gQDLxDggB76Ip5OwoUNRLdeOha9U3a2ieyNbz5kTU5lFfe5tui2/461uPZ8a+QOX - * 4BdVrhEmV94BKY4FPyH35zboLjfXSKxT1mAOx1Bt9sWF94umxZE1cjyU7vEX8HHj - * 7BvOyk5AQrBt7moO1uWtPA/JuoJPePiJl4kqlRJM2Akq6QIDAQABo4GjMIGgMB0G - * A1UdDgQWBBT6uVG/TOfZhpgz+efLHvEzSfeoFDBxBgNVHSMEajBogBT6uVG/TOfZ - * hpgz+efLHvEzSfeoFKFNpEswSTELMAkGA1UEBhMCVVMxEzARBgNVBAgTClNvbWUt - * U3RhdGUxEjAQBgNVBAcTCVNvbWUtQ2l0eTERMA8GA1UEChMIU29tZS1PcmeCAQAw - * DAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQQFAAOBgQBcIm534U123Hz+rtyYO5uA - * ofd81G6FnTfEAV8Kw9fGyyEbQZclBv34A9JsFKeMvU4OFIaixD7nLZ/NZ+IWbhmZ - * LovmJXyCkOufea73pNiZ+f/4/ScZaIlM/PRycQSqbFNd4j9Wott+08qxHPLpsf3P - * 6Mvf0r1PNTY2hwTJLJmKtg== - * -----END CERTIFICATE--- + * MIIDQjCCAiqgAwIBAgIEW8i6BzANBgkqhkiG9w0BAQUFADBJMQswCQYDVQQGEwJV + * czETMBEGA1UECBMKU29tZS1TdGF0ZTESMBAGA1UEBxMJU29tZS1DaXR5MREwDwYD + * VQQKEwhTb21lLU9yZzAeFw0yNDA3MDEwNDE2NTBaFw0zNDA3MDIwNDE2NTBaMEkx + * CzAJBgNVBAYTAlVzMRMwEQYDVQQIEwpTb21lLVN0YXRlMRIwEAYDVQQHEwlTb21l + * LUNpdHkxETAPBgNVBAoTCFNvbWUtT3JnMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A + * MIIBCgKCAQEAvKZVYD8XdDm6cYzvET+dNkfVAtFNnX64/lmxK/G3sAwxV+ucnRP1 + * TF/8xJ75dQkPlo8FdzCoNUhxluSlfRqB++a/kIBgXREgVBYLbd9k3hjVmFE4ncnW + * X96d3v6oX9MlPa3zK0XISoCXFHuFnc9ZCLvHZ6yLKfMek7/7glPFrrS8VTAVqH4/ + * giJZQ8zSYudlZ3LsEIr8BZCRct3pb+KfDKuhg1UCI7ejw1Crvgu7UXVQ0ajJ5fUG + * /gAJphuKFikNqwA+vNJz2TfX2ZpYbi0q9nau9OptcN5/4wRDwE+RP3hY18KtdOsE + * ndB+grh6l0Rh+kFFpsp9pS78+abPYc11vwIDAQABozIwMDAdBgNVHQ4EFgQU4AOQ + * 9k+7V+Z+r1yUJbOF2hYKUUAwDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQUF + * AAOCAQEAH4k04+4FMzsYypYTPa3NWuYkRpQ2rTelNqmSN/ntB91EW8kuaPeC81gc + * ZO1k0K3rMBXgBDrXyMedZXauhOQuLQ1oCQ3lrsynVIat/wCVhQFJ21uOwm/nGRAX + * 9wO5qJchovx/wOB6EmS4cPXotuEl9+syPkbOQ1X8C2JZkGFj+ZRslWMxGwBZH3Kd + * 0AtPzQLr3iBOYEhO6q08Dx2/Gmk9qD2L9aKujE/XDrPhm7MsiRkY2tvhbdWryLhI + * V9iLMwHUl5HZ2jSh7zYA4TgZNI8NR69Xz1nWiw2eiQWCPTzzRR1KPw4PWihvXOHp + * YHKHKLaXRIvXxs3L3FpdYPG0N+5E2w== + * */ @@ -427,201 +568,342 @@ public class PKIXExtendedTM { */ static String trusedCertStr = "-----BEGIN CERTIFICATE-----\n" + - "MIICrDCCAhWgAwIBAgIBADANBgkqhkiG9w0BAQQFADBJMQswCQYDVQQGEwJVUzET\n" + - "MBEGA1UECBMKU29tZS1TdGF0ZTESMBAGA1UEBxMJU29tZS1DaXR5MREwDwYDVQQK\n" + - "EwhTb21lLU9yZzAeFw0wODEyMDgwMjQzMzZaFw0yODA4MjUwMjQzMzZaMEkxCzAJ\n" + - "BgNVBAYTAlVTMRMwEQYDVQQIEwpTb21lLVN0YXRlMRIwEAYDVQQHEwlTb21lLUNp\n" + - "dHkxETAPBgNVBAoTCFNvbWUtT3JnMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKB\n" + - "gQDLxDggB76Ip5OwoUNRLdeOha9U3a2ieyNbz5kTU5lFfe5tui2/461uPZ8a+QOX\n" + - "4BdVrhEmV94BKY4FPyH35zboLjfXSKxT1mAOx1Bt9sWF94umxZE1cjyU7vEX8HHj\n" + - "7BvOyk5AQrBt7moO1uWtPA/JuoJPePiJl4kqlRJM2Akq6QIDAQABo4GjMIGgMB0G\n" + - "A1UdDgQWBBT6uVG/TOfZhpgz+efLHvEzSfeoFDBxBgNVHSMEajBogBT6uVG/TOfZ\n" + - "hpgz+efLHvEzSfeoFKFNpEswSTELMAkGA1UEBhMCVVMxEzARBgNVBAgTClNvbWUt\n" + - "U3RhdGUxEjAQBgNVBAcTCVNvbWUtQ2l0eTERMA8GA1UEChMIU29tZS1PcmeCAQAw\n" + - "DAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQQFAAOBgQBcIm534U123Hz+rtyYO5uA\n" + - "ofd81G6FnTfEAV8Kw9fGyyEbQZclBv34A9JsFKeMvU4OFIaixD7nLZ/NZ+IWbhmZ\n" + - "LovmJXyCkOufea73pNiZ+f/4/ScZaIlM/PRycQSqbFNd4j9Wott+08qxHPLpsf3P\n" + - "6Mvf0r1PNTY2hwTJLJmKtg==\n" + + "MIIDQjCCAiqgAwIBAgIEW8i6BzANBgkqhkiG9w0BAQUFADBJMQswCQYDVQQGEwJV\n" + + "czETMBEGA1UECBMKU29tZS1TdGF0ZTESMBAGA1UEBxMJU29tZS1DaXR5MREwDwYD\n" + + "VQQKEwhTb21lLU9yZzAeFw0yNDA3MDEwNDE2NTBaFw0zNDA3MDIwNDE2NTBaMEkx\n" + + "CzAJBgNVBAYTAlVzMRMwEQYDVQQIEwpTb21lLVN0YXRlMRIwEAYDVQQHEwlTb21l\n" + + "LUNpdHkxETAPBgNVBAoTCFNvbWUtT3JnMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A\n" + + "MIIBCgKCAQEAvKZVYD8XdDm6cYzvET+dNkfVAtFNnX64/lmxK/G3sAwxV+ucnRP1\n" + + "TF/8xJ75dQkPlo8FdzCoNUhxluSlfRqB++a/kIBgXREgVBYLbd9k3hjVmFE4ncnW\n" + + "X96d3v6oX9MlPa3zK0XISoCXFHuFnc9ZCLvHZ6yLKfMek7/7glPFrrS8VTAVqH4/\n" + + "giJZQ8zSYudlZ3LsEIr8BZCRct3pb+KfDKuhg1UCI7ejw1Crvgu7UXVQ0ajJ5fUG\n" + + "/gAJphuKFikNqwA+vNJz2TfX2ZpYbi0q9nau9OptcN5/4wRDwE+RP3hY18KtdOsE\n" + + "ndB+grh6l0Rh+kFFpsp9pS78+abPYc11vwIDAQABozIwMDAdBgNVHQ4EFgQU4AOQ\n" + + "9k+7V+Z+r1yUJbOF2hYKUUAwDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQUF\n" + + "AAOCAQEAH4k04+4FMzsYypYTPa3NWuYkRpQ2rTelNqmSN/ntB91EW8kuaPeC81gc\n" + + "ZO1k0K3rMBXgBDrXyMedZXauhOQuLQ1oCQ3lrsynVIat/wCVhQFJ21uOwm/nGRAX\n" + + "9wO5qJchovx/wOB6EmS4cPXotuEl9+syPkbOQ1X8C2JZkGFj+ZRslWMxGwBZH3Kd\n" + + "0AtPzQLr3iBOYEhO6q08Dx2/Gmk9qD2L9aKujE/XDrPhm7MsiRkY2tvhbdWryLhI\n" + + "V9iLMwHUl5HZ2jSh7zYA4TgZNI8NR69Xz1nWiw2eiQWCPTzzRR1KPw4PWihvXOHp\n" + + "YHKHKLaXRIvXxs3L3FpdYPG0N+5E2w==\n" + "-----END CERTIFICATE-----"; static String serverCertStr = "-----BEGIN CERTIFICATE-----\n" + - "MIICpDCCAg2gAwIBAgIBCDANBgkqhkiG9w0BAQQFADBJMQswCQYDVQQGEwJVUzET\n" + - "MBEGA1UECBMKU29tZS1TdGF0ZTESMBAGA1UEBxMJU29tZS1DaXR5MREwDwYDVQQK\n" + - "EwhTb21lLU9yZzAeFw0wODEyMDgwMzQzMDRaFw0yODA4MjUwMzQzMDRaMHIxCzAJ\n" + - "BgNVBAYTAlVTMRMwEQYDVQQIEwpTb21lLVN0YXRlMRIwEAYDVQQHEwlTb21lLUNp\n" + - "dHkxETAPBgNVBAoTCFNvbWUtT3JnMRMwEQYDVQQLEwpTU0wtU2VydmVyMRIwEAYD\n" + - "VQQDEwlsb2NhbGhvc3QwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAKWsWxw3\n" + - "ot2ZiS2yebiP1Uil5xyEF41pnMasbfnyHR85GdrTch5u7ETMcKTcugAw9qBPPVR6\n" + - "YWrMV9AKf5UoGD+a2ZTyG8gkiH7+nQ89+1dTCLMgM9Q/F0cU0c3qCNgOdU6vvszS\n" + - "7K+peknfwtmsuCRAkKYDVirQMAVALE+r2XSJAgMBAAGjczBxMAkGA1UdEwQCMAAw\n" + - "CwYDVR0PBAQDAgXgMB0GA1UdDgQWBBTtbtv0tVbI+xoGYT8PCLumBNgWVDAfBgNV\n" + - "HSMEGDAWgBT6uVG/TOfZhpgz+efLHvEzSfeoFDAXBgNVHREBAf8EDTALgglsb2Nh\n" + - "bGhvc3QwDQYJKoZIhvcNAQEEBQADgYEAoqVTciHtcvsUj+YaTct8tUh3aTCsKsac\n" + - "PHhfQ+ObjiXSgxsKYTX7ym/wk/wvlbUcbqLKxsu7qrcJitH+H9heV1hEHEu65Uoi\n" + - "nRugFruyOrwvAylV8Cm2af7ddilmYJ+sdJA6N2M3xJRxR0G2LFHEXDNEjYReyexn\n" + - "JqCpf5uZGOo=\n" + + "MIIDpTCCAo2gAwIBAgIEBlY/nzANBgkqhkiG9w0BAQUFADBJMQswCQYDVQQGEwJV\n" + + "czETMBEGA1UECBMKU29tZS1TdGF0ZTESMBAGA1UEBxMJU29tZS1DaXR5MREwDwYD\n" + + "VQQKEwhTb21lLU9yZzAeFw0yNDA3MDEwNDE2NTVaFw0zNDA3MDIwNDE2NTVaMGsx\n" + + "CzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpTb21lLVN0YXRlMRIwEAYDVQQHEwlTb21l\n" + + "LUNpdHkxETAPBgNVBAoTCFNvbWUtT3JnMSAwHgYDVQQDExdsb2NhbGhvc3Qgb3U9\n" + + "U1NMLVNlcnZlcjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJoM4I+o\n" + + "An5a7+2yQq0ITpG6wq2bedebD/3S+BUvGYmAEAACGW0nwpDXpSNTdG5kKHwkqu3q\n" + + "IVnco1y1yUIxT6Le+wl8c+2IBDTxFa09YM3KxROZ05+bspJwy7pLPSCWrb6SU+1U\n" + + "O8UUvc/UD8sFT/0rnuBQu2UTksDWvU0CDHC2ZdR9tE3D3ywIntI+aTJGb2/K0XOk\n" + + "lAfvFOPani/ArA4QM0xoefN5QNbpPMLmcOCJzqB6qIQohTI3CLDPsX9fvB+lPe/W\n" + + "aKgXIV+H1Uu1zO54jd2xKGrA+2S9t3ACMwMLuLi7CIL2jgUn0TvmxaxNhVuhHaNI\n" + + "XQMVdmNscSE+mM0CAwEAAaNzMHEwHQYDVR0OBBYEFFyvRLFIuFmaZFOdLqayCdMK\n" + + "kgSDMAsGA1UdDwQEAwIF4DAXBgNVHREBAf8EDTALgglsb2NhbGhvc3QwCQYDVR0T\n" + + "BAIwADAfBgNVHSMEGDAWgBTgA5D2T7tX5n6vXJQls4XaFgpRQDANBgkqhkiG9w0B\n" + + "AQUFAAOCAQEAnSJJX1Yj5oA1zKtEHCe9yY2Jk0lY6MF6aN3PveASdgZUzS9im1SE\n" + + "8ruQoLs34hMd899BquD+wO9GeI2q9BtwrakWJPoVSsYKjeGZkwCp1LYIXY5lA9zQ\n" + + "lfyVYaattatNpuAFSIzbQkKK1l7AKqARFbgHaVw/maC9U2XbTs9GYZMJe4FA/1z+\n" + + "TOv0rN4fOK2yYCj2Dp9G5wePIJqk4Y+rVJl2gtiecMTamIVxrztU5AG0noPQe8aN\n" + + "H+0lCIkF6YeXdlqjhcP4Wde7O1rby+1d/6whuZriZQq83tHcU5SYRJeRsxtrgAub\n" + + "V7OuXHw1yjlx906PStfrCyXash4XSLjrCQ==\n" + "-----END CERTIFICATE-----"; static String clientCertStr = "-----BEGIN CERTIFICATE-----\n" + - "MIICpDCCAg2gAwIBAgIBCTANBgkqhkiG9w0BAQQFADBJMQswCQYDVQQGEwJVUzET\n" + - "MBEGA1UECBMKU29tZS1TdGF0ZTESMBAGA1UEBxMJU29tZS1DaXR5MREwDwYDVQQK\n" + - "EwhTb21lLU9yZzAeFw0wODEyMDgwMzQzMjRaFw0yODA4MjUwMzQzMjRaMHIxCzAJ\n" + - "BgNVBAYTAlVTMRMwEQYDVQQIEwpTb21lLVN0YXRlMRIwEAYDVQQHEwlTb21lLUNp\n" + - "dHkxETAPBgNVBAoTCFNvbWUtT3JnMRMwEQYDVQQLEwpTU0wtQ2xpZW50MRIwEAYD\n" + - "VQQDEwlsb2NhbGhvc3QwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBALvwQDas\n" + - "JlRO9KNaAC9pIW+5ejqT7KL24Y7HY9gvEjCZLrDyj/gnLSR4KIT3Ab+NRHndO9JV\n" + - "8848slshfe/9M0qxo//GyJu5D3xBNZf52zoFYAUVr1kXkqMQrRYc5AdTr6h2olYq\n" + - "ktP5KOB4z14fSKtcGd3hZ0O6dY31gqxDkkQbAgMBAAGjczBxMAkGA1UdEwQCMAAw\n" + - "CwYDVR0PBAQDAgXgMB0GA1UdDgQWBBTNu8iFqpG9/R2+zWd8/7PpTKgi5jAfBgNV\n" + - "HSMEGDAWgBT6uVG/TOfZhpgz+efLHvEzSfeoFDAXBgNVHREBAf8EDTALgglsb2Nh\n" + - "bGhvc3QwDQYJKoZIhvcNAQEEBQADgYEAm25gJyqW1JznQ1EyOtTGswBVwfgBOf+F\n" + - "HJuBTcflYQLbTD/AETPQJGvZU9tdhuLtbG3OPhR7vSY8zeAbfM3dbH7QFr3r47Gj\n" + - "XEH7qM/MX+Z3ifVaC4MeJmrYQkYFSuKeyyKpdRVX4w4nnFHF6OsNASsYrMW6LpxN\n" + - "cl/epUcHL7E=\n" + + "MIIDpTCCAo2gAwIBAgIEWXLa2zANBgkqhkiG9w0BAQUFADBJMQswCQYDVQQGEwJV\n" + + "czETMBEGA1UECBMKU29tZS1TdGF0ZTESMBAGA1UEBxMJU29tZS1DaXR5MREwDwYD\n" + + "VQQKEwhTb21lLU9yZzAeFw0yNDA3MDEwNDE2NTJaFw0zNDA3MDIwNDE2NTJaMGsx\n" + + "CzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpTb21lLVN0YXRlMRIwEAYDVQQHEwlTb21l\n" + + "LUNpdHkxETAPBgNVBAoTCFNvbWUtT3JnMSAwHgYDVQQDExdsb2NhbGhvc3Qgb3U9\n" + + "U1NMLUNsaWVudDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMy/kjym\n" + + "V3QfWK3HaYhvWTJHUGAi5JhJDj4duLriO7ZxW/1kAm0NUHdybqg9XdS9H3ZR3JrQ\n" + + "1j7QMaUkWiy+d/qIofoGQcgPR3BHJJlQUkRbMGJbZTXEKLBc7tAb6zkrC6Gslkja\n" + + "Vmzg4+bj3UXLUTONQEPX8KQxqrXA30vfKwrtfhAMrh+WohAea9D5N4vfDQ4CNfhY\n" + + "vG61Vw4v6iDmc5rla4JwJbtRmnyd4lA9zx4kPpJVzyqtDYSPqEMkza1QZHTCc7bh\n" + + "khyyK4wte5amQWFcG494KFFA7UGQzh24JoFHa+NXQXROIPBaG5c3kYYZxfJtBMl4\n" + + "K1oWvPwrcVvQAE8CAwEAAaNzMHEwHQYDVR0OBBYEFM1F4gWSiKPHSSjn0ze3E5L7\n" + + "sTbEMAsGA1UdDwQEAwIF4DAXBgNVHREBAf8EDTALgglsb2NhbGhvc3QwCQYDVR0T\n" + + "BAIwADAfBgNVHSMEGDAWgBTgA5D2T7tX5n6vXJQls4XaFgpRQDANBgkqhkiG9w0B\n" + + "AQUFAAOCAQEAI27pXYANs4bJzReBM71bqsBlTGuf+u4y6Ynh0McdXEN+lKyDr5GQ\n" + + "TCZhjf5rGqpuYTmzJErcksjK8oCwBUEMs93tt4FCmh5O8oBscmKLvdTNI3186G/j\n" + + "Z4lqeRnd9ldiEvrrzWbD0thAWhzdf5+yNOkq1hRSum6omw2poQO/xA2SPVnkqY4g\n" + + "QTmZgXCd0GiY/F9JSpLlosFRYfYeSVYLtoxX2wgq8KME3KEEolzQkE8TjRzmLnpj\n" + + "nDJAZVkEXXGQWqjbajBCV1sL386hH/ojcfNXEsQcZjs3dzIop/ut7oZRTIAv3chb\n" + + "n6cVB/orWu6TAF+mQyIbQFIVZgGEMp5xIQ==\n" + "-----END CERTIFICATE-----"; static byte serverPrivateExponent[] = { - (byte)0x6e, (byte)0xa7, (byte)0x1b, (byte)0x83, - (byte)0x51, (byte)0x35, (byte)0x9a, (byte)0x44, - (byte)0x7d, (byte)0xf6, (byte)0xe3, (byte)0x89, - (byte)0xa0, (byte)0xd7, (byte)0x90, (byte)0x60, - (byte)0xa1, (byte)0x4e, (byte)0x27, (byte)0x21, - (byte)0xa2, (byte)0x89, (byte)0x74, (byte)0xcc, - (byte)0x9d, (byte)0x75, (byte)0x75, (byte)0x4e, - (byte)0xc7, (byte)0x82, (byte)0xe3, (byte)0xe3, - (byte)0xc3, (byte)0x7d, (byte)0x00, (byte)0x54, - (byte)0xec, (byte)0x36, (byte)0xb1, (byte)0xdf, - (byte)0x91, (byte)0x9c, (byte)0x7a, (byte)0xc0, - (byte)0x62, (byte)0x0a, (byte)0xd6, (byte)0xa9, - (byte)0x22, (byte)0x91, (byte)0x4a, (byte)0x29, - (byte)0x2e, (byte)0x43, (byte)0xfa, (byte)0x8c, - (byte)0xd8, (byte)0xe9, (byte)0xbe, (byte)0xd9, - (byte)0x4f, (byte)0xca, (byte)0x23, (byte)0xc6, - (byte)0xe4, (byte)0x3f, (byte)0xb8, (byte)0x72, - (byte)0xcf, (byte)0x02, (byte)0xfc, (byte)0xf4, - (byte)0x58, (byte)0x34, (byte)0x77, (byte)0x76, - (byte)0xce, (byte)0x22, (byte)0x44, (byte)0x5f, - (byte)0x2d, (byte)0xca, (byte)0xee, (byte)0xf5, - (byte)0x43, (byte)0x56, (byte)0x47, (byte)0x71, - (byte)0x0b, (byte)0x09, (byte)0x6b, (byte)0x5e, - (byte)0xf2, (byte)0xc8, (byte)0xee, (byte)0xd4, - (byte)0x6e, (byte)0x44, (byte)0x92, (byte)0x2a, - (byte)0x7f, (byte)0xcc, (byte)0xa7, (byte)0xd4, - (byte)0x5b, (byte)0xfb, (byte)0xf7, (byte)0x4a, - (byte)0xa9, (byte)0xfb, (byte)0x54, (byte)0x18, - (byte)0xd5, (byte)0xd5, (byte)0x14, (byte)0xba, - (byte)0xa0, (byte)0x1c, (byte)0x13, (byte)0xb3, - (byte)0x37, (byte)0x6b, (byte)0x37, (byte)0x59, - (byte)0xed, (byte)0xdb, (byte)0x6d, (byte)0xb1 + (byte)0x68, (byte)0x87, (byte)0x36, (byte)0x54, + (byte)0xa3, (byte)0xc6, (byte)0xd5, (byte)0x5f, + (byte)0xf5, (byte)0x0f, (byte)0x4f, (byte)0x76, + (byte)0xc8, (byte)0x9c, (byte)0x2b, (byte)0x5b, + (byte)0xdc, (byte)0xe2, (byte)0xbe, (byte)0x14, + (byte)0x12, (byte)0x2f, (byte)0xc7, (byte)0x0a, + (byte)0xa9, (byte)0xcb, (byte)0x5e, (byte)0x04, + (byte)0x59, (byte)0xca, (byte)0x35, (byte)0x2f, + (byte)0x8d, (byte)0x2b, (byte)0xc4, (byte)0x40, + (byte)0xe6, (byte)0x7d, (byte)0x25, (byte)0x1b, + (byte)0x4d, (byte)0x07, (byte)0xc3, (byte)0x99, + (byte)0x9c, (byte)0x16, (byte)0x4f, (byte)0xa5, + (byte)0xdc, (byte)0xde, (byte)0xb0, (byte)0x90, + (byte)0xf0, (byte)0xde, (byte)0x22, (byte)0x70, + (byte)0x80, (byte)0xf4, (byte)0xa6, (byte)0x70, + (byte)0xe2, (byte)0x96, (byte)0x3d, (byte)0x18, + (byte)0x21, (byte)0xbf, (byte)0x2b, (byte)0x27, + (byte)0xa4, (byte)0x2d, (byte)0xd7, (byte)0xae, + (byte)0x2b, (byte)0x12, (byte)0x2f, (byte)0x08, + (byte)0x36, (byte)0xee, (byte)0x99, (byte)0x94, + (byte)0xed, (byte)0xf6, (byte)0xa7, (byte)0xd9, + (byte)0x1d, (byte)0xa2, (byte)0xf3, (byte)0x1f, + (byte)0x44, (byte)0xa4, (byte)0x28, (byte)0x4b, + (byte)0x67, (byte)0x35, (byte)0xd6, (byte)0xa8, + (byte)0x1b, (byte)0xf8, (byte)0x84, (byte)0x34, + (byte)0x34, (byte)0x84, (byte)0xbd, (byte)0xec, + (byte)0x9e, (byte)0x03, (byte)0x08, (byte)0x3c, + (byte)0x93, (byte)0x20, (byte)0x8e, (byte)0xaf, + (byte)0x15, (byte)0xcb, (byte)0x1f, (byte)0x20, + (byte)0x08, (byte)0x97, (byte)0xc4, (byte)0x19, + (byte)0x3e, (byte)0xfa, (byte)0x36, (byte)0xc6, + (byte)0xab, (byte)0x0e, (byte)0x2f, (byte)0xe7, + (byte)0xb3, (byte)0xc0, (byte)0xa7, (byte)0xbc, + (byte)0xe4, (byte)0xe0, (byte)0xa6, (byte)0x08, + (byte)0x1c, (byte)0x69, (byte)0x20, (byte)0x4d, + (byte)0x78, (byte)0xbd, (byte)0x7a, (byte)0xe5, + (byte)0x25, (byte)0x48, (byte)0x60, (byte)0x9e, + (byte)0x2e, (byte)0x50, (byte)0x8d, (byte)0x36, + (byte)0x1e, (byte)0x07, (byte)0xe9, (byte)0xd5, + (byte)0x0d, (byte)0x39, (byte)0x67, (byte)0x41, + (byte)0x42, (byte)0x24, (byte)0xdb, (byte)0x87, + (byte)0xe5, (byte)0x77, (byte)0x76, (byte)0xfd, + (byte)0x5e, (byte)0xd5, (byte)0xc6, (byte)0xe5, + (byte)0xd3, (byte)0xb0, (byte)0x98, (byte)0x71, + (byte)0x48, (byte)0x69, (byte)0x47, (byte)0x4f, + (byte)0x46, (byte)0x05, (byte)0x0c, (byte)0x9e, + (byte)0x58, (byte)0x45, (byte)0x2e, (byte)0xe2, + (byte)0x27, (byte)0xd0, (byte)0xf6, (byte)0x11, + (byte)0x05, (byte)0x78, (byte)0xad, (byte)0x83, + (byte)0x5a, (byte)0x5b, (byte)0xec, (byte)0xd7, + (byte)0x2e, (byte)0x26, (byte)0x5a, (byte)0xa5, + (byte)0x4f, (byte)0x9e, (byte)0x52, (byte)0x84, + (byte)0x2c, (byte)0x1f, (byte)0x59, (byte)0x1a, + (byte)0x78, (byte)0x56, (byte)0x0a, (byte)0x44, + (byte)0x54, (byte)0xc6, (byte)0x37, (byte)0x64, + (byte)0x01, (byte)0xca, (byte)0xe4, (byte)0xa8, + (byte)0x01, (byte)0xc7, (byte)0x86, (byte)0xc1, + (byte)0xb4, (byte)0xd6, (byte)0x6c, (byte)0x7a, + (byte)0x15, (byte)0x9a, (byte)0x65, (byte)0x69, + (byte)0x46, (byte)0x9e, (byte)0xfd, (byte)0xf6, + (byte)0x08, (byte)0x17, (byte)0x0c, (byte)0x6c, + (byte)0xac, (byte)0x38, (byte)0xbd, (byte)0xc2, + (byte)0xcd, (byte)0xda, (byte)0xef, (byte)0x54, + (byte)0x7a, (byte)0x48, (byte)0x92, (byte)0x4d }; static byte serverModulus[] = { - (byte)0x00, - (byte)0xa5, (byte)0xac, (byte)0x5b, (byte)0x1c, - (byte)0x37, (byte)0xa2, (byte)0xdd, (byte)0x99, - (byte)0x89, (byte)0x2d, (byte)0xb2, (byte)0x79, - (byte)0xb8, (byte)0x8f, (byte)0xd5, (byte)0x48, - (byte)0xa5, (byte)0xe7, (byte)0x1c, (byte)0x84, - (byte)0x17, (byte)0x8d, (byte)0x69, (byte)0x9c, - (byte)0xc6, (byte)0xac, (byte)0x6d, (byte)0xf9, - (byte)0xf2, (byte)0x1d, (byte)0x1f, (byte)0x39, - (byte)0x19, (byte)0xda, (byte)0xd3, (byte)0x72, - (byte)0x1e, (byte)0x6e, (byte)0xec, (byte)0x44, - (byte)0xcc, (byte)0x70, (byte)0xa4, (byte)0xdc, - (byte)0xba, (byte)0x00, (byte)0x30, (byte)0xf6, - (byte)0xa0, (byte)0x4f, (byte)0x3d, (byte)0x54, - (byte)0x7a, (byte)0x61, (byte)0x6a, (byte)0xcc, - (byte)0x57, (byte)0xd0, (byte)0x0a, (byte)0x7f, - (byte)0x95, (byte)0x28, (byte)0x18, (byte)0x3f, - (byte)0x9a, (byte)0xd9, (byte)0x94, (byte)0xf2, - (byte)0x1b, (byte)0xc8, (byte)0x24, (byte)0x88, - (byte)0x7e, (byte)0xfe, (byte)0x9d, (byte)0x0f, - (byte)0x3d, (byte)0xfb, (byte)0x57, (byte)0x53, - (byte)0x08, (byte)0xb3, (byte)0x20, (byte)0x33, - (byte)0xd4, (byte)0x3f, (byte)0x17, (byte)0x47, - (byte)0x14, (byte)0xd1, (byte)0xcd, (byte)0xea, - (byte)0x08, (byte)0xd8, (byte)0x0e, (byte)0x75, - (byte)0x4e, (byte)0xaf, (byte)0xbe, (byte)0xcc, - (byte)0xd2, (byte)0xec, (byte)0xaf, (byte)0xa9, - (byte)0x7a, (byte)0x49, (byte)0xdf, (byte)0xc2, - (byte)0xd9, (byte)0xac, (byte)0xb8, (byte)0x24, - (byte)0x40, (byte)0x90, (byte)0xa6, (byte)0x03, - (byte)0x56, (byte)0x2a, (byte)0xd0, (byte)0x30, - (byte)0x05, (byte)0x40, (byte)0x2c, (byte)0x4f, - (byte)0xab, (byte)0xd9, (byte)0x74, (byte)0x89 + (byte)0x00, (byte)0x9a, (byte)0x0c, (byte)0xe0, + (byte)0x8f, (byte)0xa8, (byte)0x02, (byte)0x7e, + (byte)0x5a, (byte)0xef, (byte)0xed, (byte)0xb2, + (byte)0x42, (byte)0xad, (byte)0x08, (byte)0x4e, + (byte)0x91, (byte)0xba, (byte)0xc2, (byte)0xad, + (byte)0x9b, (byte)0x79, (byte)0xd7, (byte)0x9b, + (byte)0x0f, (byte)0xfd, (byte)0xd2, (byte)0xf8, + (byte)0x15, (byte)0x2f, (byte)0x19, (byte)0x89, + (byte)0x80, (byte)0x10, (byte)0x00, (byte)0x02, + (byte)0x19, (byte)0x6d, (byte)0x27, (byte)0xc2, + (byte)0x90, (byte)0xd7, (byte)0xa5, (byte)0x23, + (byte)0x53, (byte)0x74, (byte)0x6e, (byte)0x64, + (byte)0x28, (byte)0x7c, (byte)0x24, (byte)0xaa, + (byte)0xed, (byte)0xea, (byte)0x21, (byte)0x59, + (byte)0xdc, (byte)0xa3, (byte)0x5c, (byte)0xb5, + (byte)0xc9, (byte)0x42, (byte)0x31, (byte)0x4f, + (byte)0xa2, (byte)0xde, (byte)0xfb, (byte)0x09, + (byte)0x7c, (byte)0x73, (byte)0xed, (byte)0x88, + (byte)0x04, (byte)0x34, (byte)0xf1, (byte)0x15, + (byte)0xad, (byte)0x3d, (byte)0x60, (byte)0xcd, + (byte)0xca, (byte)0xc5, (byte)0x13, (byte)0x99, + (byte)0xd3, (byte)0x9f, (byte)0x9b, (byte)0xb2, + (byte)0x92, (byte)0x70, (byte)0xcb, (byte)0xba, + (byte)0x4b, (byte)0x3d, (byte)0x20, (byte)0x96, + (byte)0xad, (byte)0xbe, (byte)0x92, (byte)0x53, + (byte)0xed, (byte)0x54, (byte)0x3b, (byte)0xc5, + (byte)0x14, (byte)0xbd, (byte)0xcf, (byte)0xd4, + (byte)0x0f, (byte)0xcb, (byte)0x05, (byte)0x4f, + (byte)0xfd, (byte)0x2b, (byte)0x9e, (byte)0xe0, + (byte)0x50, (byte)0xbb, (byte)0x65, (byte)0x13, + (byte)0x92, (byte)0xc0, (byte)0xd6, (byte)0xbd, + (byte)0x4d, (byte)0x02, (byte)0x0c, (byte)0x70, + (byte)0xb6, (byte)0x65, (byte)0xd4, (byte)0x7d, + (byte)0xb4, (byte)0x4d, (byte)0xc3, (byte)0xdf, + (byte)0x2c, (byte)0x08, (byte)0x9e, (byte)0xd2, + (byte)0x3e, (byte)0x69, (byte)0x32, (byte)0x46, + (byte)0x6f, (byte)0x6f, (byte)0xca, (byte)0xd1, + (byte)0x73, (byte)0xa4, (byte)0x94, (byte)0x07, + (byte)0xef, (byte)0x14, (byte)0xe3, (byte)0xda, + (byte)0x9e, (byte)0x2f, (byte)0xc0, (byte)0xac, + (byte)0x0e, (byte)0x10, (byte)0x33, (byte)0x4c, + (byte)0x68, (byte)0x79, (byte)0xf3, (byte)0x79, + (byte)0x40, (byte)0xd6, (byte)0xe9, (byte)0x3c, + (byte)0xc2, (byte)0xe6, (byte)0x70, (byte)0xe0, + (byte)0x89, (byte)0xce, (byte)0xa0, (byte)0x7a, + (byte)0xa8, (byte)0x84, (byte)0x28, (byte)0x85, + (byte)0x32, (byte)0x37, (byte)0x08, (byte)0xb0, + (byte)0xcf, (byte)0xb1, (byte)0x7f, (byte)0x5f, + (byte)0xbc, (byte)0x1f, (byte)0xa5, (byte)0x3d, + (byte)0xef, (byte)0xd6, (byte)0x68, (byte)0xa8, + (byte)0x17, (byte)0x21, (byte)0x5f, (byte)0x87, + (byte)0xd5, (byte)0x4b, (byte)0xb5, (byte)0xcc, + (byte)0xee, (byte)0x78, (byte)0x8d, (byte)0xdd, + (byte)0xb1, (byte)0x28, (byte)0x6a, (byte)0xc0, + (byte)0xfb, (byte)0x64, (byte)0xbd, (byte)0xb7, + (byte)0x70, (byte)0x02, (byte)0x33, (byte)0x03, + (byte)0x0b, (byte)0xb8, (byte)0xb8, (byte)0xbb, + (byte)0x08, (byte)0x82, (byte)0xf6, (byte)0x8e, + (byte)0x05, (byte)0x27, (byte)0xd1, (byte)0x3b, + (byte)0xe6, (byte)0xc5, (byte)0xac, (byte)0x4d, + (byte)0x85, (byte)0x5b, (byte)0xa1, (byte)0x1d, + (byte)0xa3, (byte)0x48, (byte)0x5d, (byte)0x03, + (byte)0x15, (byte)0x76, (byte)0x63, (byte)0x6c, + (byte)0x71, (byte)0x21, (byte)0x3e, (byte)0x98, + (byte)0xcd }; static byte clientPrivateExponent[] = { - (byte)0x11, (byte)0xb7, (byte)0x6a, (byte)0x36, - (byte)0x3d, (byte)0x30, (byte)0x37, (byte)0xce, - (byte)0x61, (byte)0x9d, (byte)0x6c, (byte)0x84, - (byte)0x8b, (byte)0xf3, (byte)0x9b, (byte)0x25, - (byte)0x4f, (byte)0x14, (byte)0xc8, (byte)0xa4, - (byte)0xdd, (byte)0x2f, (byte)0xd7, (byte)0x9a, - (byte)0x17, (byte)0xbd, (byte)0x90, (byte)0x19, - (byte)0xf7, (byte)0x05, (byte)0xfd, (byte)0xf2, - (byte)0xd2, (byte)0xc5, (byte)0xf7, (byte)0x77, - (byte)0xbe, (byte)0xea, (byte)0xe2, (byte)0x84, - (byte)0x87, (byte)0x97, (byte)0x3a, (byte)0x41, - (byte)0x96, (byte)0xb6, (byte)0x99, (byte)0xf8, - (byte)0x94, (byte)0x8c, (byte)0x58, (byte)0x71, - (byte)0x51, (byte)0x8c, (byte)0xf4, (byte)0x2a, - (byte)0x20, (byte)0x9e, (byte)0x1a, (byte)0xa0, - (byte)0x26, (byte)0x99, (byte)0x75, (byte)0xd6, - (byte)0x31, (byte)0x53, (byte)0x43, (byte)0x39, - (byte)0xf5, (byte)0x2a, (byte)0xa6, (byte)0x7e, - (byte)0x34, (byte)0x42, (byte)0x51, (byte)0x2a, - (byte)0x40, (byte)0x87, (byte)0x03, (byte)0x88, - (byte)0x43, (byte)0x69, (byte)0xb2, (byte)0x89, - (byte)0x6d, (byte)0x20, (byte)0xbd, (byte)0x7d, - (byte)0x71, (byte)0xef, (byte)0x47, (byte)0x0a, - (byte)0xdf, (byte)0x06, (byte)0xc1, (byte)0x69, - (byte)0x66, (byte)0xa8, (byte)0x22, (byte)0x37, - (byte)0x1a, (byte)0x77, (byte)0x1e, (byte)0xc7, - (byte)0x94, (byte)0x4e, (byte)0x2c, (byte)0x27, - (byte)0x69, (byte)0x45, (byte)0x5e, (byte)0xc8, - (byte)0xf8, (byte)0x0c, (byte)0xb7, (byte)0xf8, - (byte)0xc0, (byte)0x8f, (byte)0x99, (byte)0xc1, - (byte)0xe5, (byte)0x28, (byte)0x9b, (byte)0xf9, - (byte)0x4c, (byte)0x94, (byte)0xc6, (byte)0xb1 + (byte)0x62, (byte)0xb2, (byte)0xd6, (byte)0x63, + (byte)0xb6, (byte)0x2b, (byte)0xe2, (byte)0x26, + (byte)0x5a, (byte)0x31, (byte)0x2b, (byte)0x37, + (byte)0x8c, (byte)0x35, (byte)0x60, (byte)0xe2, + (byte)0x03, (byte)0xce, (byte)0x93, (byte)0x09, + (byte)0x3e, (byte)0xf8, (byte)0xc9, (byte)0xfe, + (byte)0xbb, (byte)0xa2, (byte)0xc8, (byte)0x32, + (byte)0x0e, (byte)0x6c, (byte)0x8a, (byte)0x7e, + (byte)0x0a, (byte)0xc2, (byte)0x13, (byte)0x3b, + (byte)0xb8, (byte)0x25, (byte)0xfa, (byte)0xec, + (byte)0x19, (byte)0x95, (byte)0x8e, (byte)0x34, + (byte)0x46, (byte)0xcf, (byte)0x0e, (byte)0x7b, + (byte)0xe4, (byte)0x25, (byte)0x82, (byte)0x1a, + (byte)0x7f, (byte)0x21, (byte)0x48, (byte)0x16, + (byte)0x44, (byte)0x58, (byte)0x3f, (byte)0x35, + (byte)0xd8, (byte)0xeb, (byte)0xd8, (byte)0x1a, + (byte)0x45, (byte)0x53, (byte)0x0f, (byte)0x9b, + (byte)0x84, (byte)0x8a, (byte)0x54, (byte)0x13, + (byte)0x33, (byte)0xe4, (byte)0x97, (byte)0x97, + (byte)0xf0, (byte)0x48, (byte)0x37, (byte)0xfb, + (byte)0x5d, (byte)0x4f, (byte)0x8c, (byte)0x8f, + (byte)0x35, (byte)0x63, (byte)0xe1, (byte)0xd9, + (byte)0x62, (byte)0x73, (byte)0x1c, (byte)0x8e, + (byte)0xd8, (byte)0xcd, (byte)0x2e, (byte)0x1a, + (byte)0xe5, (byte)0x4c, (byte)0xb5, (byte)0x05, + (byte)0x59, (byte)0x7a, (byte)0xdf, (byte)0xf1, + (byte)0x68, (byte)0xeb, (byte)0x1c, (byte)0x5c, + (byte)0xc6, (byte)0x10, (byte)0x44, (byte)0x8c, + (byte)0x7d, (byte)0x42, (byte)0xc5, (byte)0x71, + (byte)0x8a, (byte)0xe7, (byte)0x1b, (byte)0xaa, + (byte)0x17, (byte)0x03, (byte)0x6a, (byte)0xa0, + (byte)0xc0, (byte)0x6b, (byte)0x97, (byte)0x50, + (byte)0x17, (byte)0xad, (byte)0x6e, (byte)0x5e, + (byte)0xd9, (byte)0xdb, (byte)0x6f, (byte)0x3e, + (byte)0xe9, (byte)0x3f, (byte)0x35, (byte)0xc3, + (byte)0x45, (byte)0xbc, (byte)0xe8, (byte)0x3d, + (byte)0x5a, (byte)0xb4, (byte)0xb9, (byte)0x3f, + (byte)0x53, (byte)0x80, (byte)0x64, (byte)0xdc, + (byte)0x12, (byte)0x24, (byte)0x35, (byte)0x35, + (byte)0xbd, (byte)0x98, (byte)0xbb, (byte)0x8d, + (byte)0xfa, (byte)0x19, (byte)0xa3, (byte)0x5e, + (byte)0x9e, (byte)0xac, (byte)0x70, (byte)0x4a, + (byte)0xfc, (byte)0x8d, (byte)0xae, (byte)0x55, + (byte)0x8b, (byte)0x71, (byte)0x81, (byte)0x0e, + (byte)0x4d, (byte)0xc8, (byte)0x2f, (byte)0x87, + (byte)0xb0, (byte)0x44, (byte)0xf7, (byte)0x4f, + (byte)0xdc, (byte)0xa8, (byte)0xc8, (byte)0x50, + (byte)0xb5, (byte)0x95, (byte)0x24, (byte)0x63, + (byte)0x74, (byte)0x13, (byte)0x54, (byte)0x58, + (byte)0xde, (byte)0xfc, (byte)0xe0, (byte)0x75, + (byte)0xeb, (byte)0xf4, (byte)0x06, (byte)0x58, + (byte)0x83, (byte)0x12, (byte)0x4c, (byte)0x56, + (byte)0xc4, (byte)0xc4, (byte)0x18, (byte)0x0c, + (byte)0xea, (byte)0xa3, (byte)0xe7, (byte)0x25, + (byte)0xa3, (byte)0xde, (byte)0x19, (byte)0x23, + (byte)0xa2, (byte)0x5a, (byte)0x2a, (byte)0xb6, + (byte)0x56, (byte)0x04, (byte)0xbc, (byte)0x65, + (byte)0xba, (byte)0x7c, (byte)0x0a, (byte)0xf4, + (byte)0x91, (byte)0x10, (byte)0x22, (byte)0x88, + (byte)0x3f, (byte)0x9d, (byte)0xbe, (byte)0x58, + (byte)0x43, (byte)0x4c, (byte)0x2e, (byte)0xad, + (byte)0xdb, (byte)0xd6, (byte)0x32, (byte)0xcf, + (byte)0x8e, (byte)0xb5, (byte)0x05, (byte)0x55, + (byte)0x39, (byte)0x8b, (byte)0xe1, (byte)0x01 }; static byte clientModulus[] = { - (byte)0x00, - (byte)0xbb, (byte)0xf0, (byte)0x40, (byte)0x36, - (byte)0xac, (byte)0x26, (byte)0x54, (byte)0x4e, - (byte)0xf4, (byte)0xa3, (byte)0x5a, (byte)0x00, - (byte)0x2f, (byte)0x69, (byte)0x21, (byte)0x6f, - (byte)0xb9, (byte)0x7a, (byte)0x3a, (byte)0x93, - (byte)0xec, (byte)0xa2, (byte)0xf6, (byte)0xe1, - (byte)0x8e, (byte)0xc7, (byte)0x63, (byte)0xd8, - (byte)0x2f, (byte)0x12, (byte)0x30, (byte)0x99, - (byte)0x2e, (byte)0xb0, (byte)0xf2, (byte)0x8f, - (byte)0xf8, (byte)0x27, (byte)0x2d, (byte)0x24, - (byte)0x78, (byte)0x28, (byte)0x84, (byte)0xf7, - (byte)0x01, (byte)0xbf, (byte)0x8d, (byte)0x44, - (byte)0x79, (byte)0xdd, (byte)0x3b, (byte)0xd2, - (byte)0x55, (byte)0xf3, (byte)0xce, (byte)0x3c, - (byte)0xb2, (byte)0x5b, (byte)0x21, (byte)0x7d, - (byte)0xef, (byte)0xfd, (byte)0x33, (byte)0x4a, - (byte)0xb1, (byte)0xa3, (byte)0xff, (byte)0xc6, - (byte)0xc8, (byte)0x9b, (byte)0xb9, (byte)0x0f, - (byte)0x7c, (byte)0x41, (byte)0x35, (byte)0x97, - (byte)0xf9, (byte)0xdb, (byte)0x3a, (byte)0x05, - (byte)0x60, (byte)0x05, (byte)0x15, (byte)0xaf, - (byte)0x59, (byte)0x17, (byte)0x92, (byte)0xa3, - (byte)0x10, (byte)0xad, (byte)0x16, (byte)0x1c, - (byte)0xe4, (byte)0x07, (byte)0x53, (byte)0xaf, - (byte)0xa8, (byte)0x76, (byte)0xa2, (byte)0x56, - (byte)0x2a, (byte)0x92, (byte)0xd3, (byte)0xf9, - (byte)0x28, (byte)0xe0, (byte)0x78, (byte)0xcf, - (byte)0x5e, (byte)0x1f, (byte)0x48, (byte)0xab, - (byte)0x5c, (byte)0x19, (byte)0xdd, (byte)0xe1, - (byte)0x67, (byte)0x43, (byte)0xba, (byte)0x75, - (byte)0x8d, (byte)0xf5, (byte)0x82, (byte)0xac, - (byte)0x43, (byte)0x92, (byte)0x44, (byte)0x1b + (byte)0x00, (byte)0xcc, (byte)0xbf, (byte)0x92, + (byte)0x3c, (byte)0xa6, (byte)0x57, (byte)0x74, + (byte)0x1f, (byte)0x58, (byte)0xad, (byte)0xc7, + (byte)0x69, (byte)0x88, (byte)0x6f, (byte)0x59, + (byte)0x32, (byte)0x47, (byte)0x50, (byte)0x60, + (byte)0x22, (byte)0xe4, (byte)0x98, (byte)0x49, + (byte)0x0e, (byte)0x3e, (byte)0x1d, (byte)0xb8, + (byte)0xba, (byte)0xe2, (byte)0x3b, (byte)0xb6, + (byte)0x71, (byte)0x5b, (byte)0xfd, (byte)0x64, + (byte)0x02, (byte)0x6d, (byte)0x0d, (byte)0x50, + (byte)0x77, (byte)0x72, (byte)0x6e, (byte)0xa8, + (byte)0x3d, (byte)0x5d, (byte)0xd4, (byte)0xbd, + (byte)0x1f, (byte)0x76, (byte)0x51, (byte)0xdc, + (byte)0x9a, (byte)0xd0, (byte)0xd6, (byte)0x3e, + (byte)0xd0, (byte)0x31, (byte)0xa5, (byte)0x24, + (byte)0x5a, (byte)0x2c, (byte)0xbe, (byte)0x77, + (byte)0xfa, (byte)0x88, (byte)0xa1, (byte)0xfa, + (byte)0x06, (byte)0x41, (byte)0xc8, (byte)0x0f, + (byte)0x47, (byte)0x70, (byte)0x47, (byte)0x24, + (byte)0x99, (byte)0x50, (byte)0x52, (byte)0x44, + (byte)0x5b, (byte)0x30, (byte)0x62, (byte)0x5b, + (byte)0x65, (byte)0x35, (byte)0xc4, (byte)0x28, + (byte)0xb0, (byte)0x5c, (byte)0xee, (byte)0xd0, + (byte)0x1b, (byte)0xeb, (byte)0x39, (byte)0x2b, + (byte)0x0b, (byte)0xa1, (byte)0xac, (byte)0x96, + (byte)0x48, (byte)0xda, (byte)0x56, (byte)0x6c, + (byte)0xe0, (byte)0xe3, (byte)0xe6, (byte)0xe3, + (byte)0xdd, (byte)0x45, (byte)0xcb, (byte)0x51, + (byte)0x33, (byte)0x8d, (byte)0x40, (byte)0x43, + (byte)0xd7, (byte)0xf0, (byte)0xa4, (byte)0x31, + (byte)0xaa, (byte)0xb5, (byte)0xc0, (byte)0xdf, + (byte)0x4b, (byte)0xdf, (byte)0x2b, (byte)0x0a, + (byte)0xed, (byte)0x7e, (byte)0x10, (byte)0x0c, + (byte)0xae, (byte)0x1f, (byte)0x96, (byte)0xa2, + (byte)0x10, (byte)0x1e, (byte)0x6b, (byte)0xd0, + (byte)0xf9, (byte)0x37, (byte)0x8b, (byte)0xdf, + (byte)0x0d, (byte)0x0e, (byte)0x02, (byte)0x35, + (byte)0xf8, (byte)0x58, (byte)0xbc, (byte)0x6e, + (byte)0xb5, (byte)0x57, (byte)0x0e, (byte)0x2f, + (byte)0xea, (byte)0x20, (byte)0xe6, (byte)0x73, + (byte)0x9a, (byte)0xe5, (byte)0x6b, (byte)0x82, + (byte)0x70, (byte)0x25, (byte)0xbb, (byte)0x51, + (byte)0x9a, (byte)0x7c, (byte)0x9d, (byte)0xe2, + (byte)0x50, (byte)0x3d, (byte)0xcf, (byte)0x1e, + (byte)0x24, (byte)0x3e, (byte)0x92, (byte)0x55, + (byte)0xcf, (byte)0x2a, (byte)0xad, (byte)0x0d, + (byte)0x84, (byte)0x8f, (byte)0xa8, (byte)0x43, + (byte)0x24, (byte)0xcd, (byte)0xad, (byte)0x50, + (byte)0x64, (byte)0x74, (byte)0xc2, (byte)0x73, + (byte)0xb6, (byte)0xe1, (byte)0x92, (byte)0x1c, + (byte)0xb2, (byte)0x2b, (byte)0x8c, (byte)0x2d, + (byte)0x7b, (byte)0x96, (byte)0xa6, (byte)0x41, + (byte)0x61, (byte)0x5c, (byte)0x1b, (byte)0x8f, + (byte)0x78, (byte)0x28, (byte)0x51, (byte)0x40, + (byte)0xed, (byte)0x41, (byte)0x90, (byte)0xce, + (byte)0x1d, (byte)0xb8, (byte)0x26, (byte)0x81, + (byte)0x47, (byte)0x6b, (byte)0xe3, (byte)0x57, + (byte)0x41, (byte)0x74, (byte)0x4e, (byte)0x20, + (byte)0xf0, (byte)0x5a, (byte)0x1b, (byte)0x97, + (byte)0x37, (byte)0x91, (byte)0x86, (byte)0x19, + (byte)0xc5, (byte)0xf2, (byte)0x6d, (byte)0x04, + (byte)0xc9, (byte)0x78, (byte)0x2b, (byte)0x5a, + (byte)0x16, (byte)0xbc, (byte)0xfc, (byte)0x2b, + (byte)0x71, (byte)0x5b, (byte)0xd0, (byte)0x00, + (byte)0x4f }; static char passphrase[] = "passphrase".toCharArray(); @@ -808,26 +1090,26 @@ static class Test { } static Test[] tests = { - // MD5 is used in this test case, don't disable MD5 algorithm. + // SHA1 is used in this test case, don't disable SHA1 algorithm. new Test( "SSLv3, RC4, DH keySize < 768", "MD2, RSA keySize < 1024", false), - // Disable MD5 but only if cert chains back to public root CA, should - // pass because the MD5 cert in this test case is issued by test CA + // Disable SHA1 but only if cert chains back to public root CA, should + // pass because the SHA1 cert in this test case is issued by test CA new Test( "SSLv3, RC4, DH keySize < 768", - "MD2, MD5 jdkCA, RSA keySize < 1024", + "MD2, SHA1 jdkCA, RSA keySize < 1024", false), - // Disable MD5 alg via TLS property and expect failure + // Disable SHA1 alg via TLS property and expect failure new Test( - "SSLv3, MD5, RC4, DH keySize < 768", + "SSLv3, SHA1, RC4, DH keySize < 768", "MD2, RSA keySize < 1024", true), - // Disable MD5 alg via certpath property and expect failure + // Disable SHA1 alg via certpath property and expect failure new Test( "SSLv3, RC4, DH keySize < 768", - "MD2, MD5, RSA keySize < 1024", + "MD2, SHA1, RSA keySize < 1024", true), }; @@ -850,7 +1132,7 @@ public static void main(String args[]) throws Exception { try { new PKIXExtendedTM(); if (test.fail) { - throw new Exception("Expected MD5 certificate to be blocked"); + throw new Exception("Expected SHA1 certificate to be blocked"); } } catch (Exception e) { if (test.fail) { diff --git a/test/jdk/sun/security/ssl/X509TrustManagerImpl/SunX509ExtendedTM.java b/test/jdk/sun/security/ssl/X509TrustManagerImpl/SunX509ExtendedTM.java index ec893f90703..f95aee76dab 100644 --- a/test/jdk/sun/security/ssl/X509TrustManagerImpl/SunX509ExtendedTM.java +++ b/test/jdk/sun/security/ssl/X509TrustManagerImpl/SunX509ExtendedTM.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -52,357 +52,497 @@ * * TLS server certificate: * server private key: - * -----BEGIN RSA PRIVATE KEY----- - * Proc-Type: 4,ENCRYPTED - * DEK-Info: DES-EDE3-CBC,D9AE407F6D0E389A * - * WPrA7TFol/cQCcp9oHnXWNpYlvRbbIcQj0m+RKT2Iuzfus+DHt3Zadf8nJpKfX2e - * h2rnhlzCN9M7djRDooZKDOPCsdBn51Au7HlZF3S3Opgo7D8XFM1a8t1Je4ke14oI - * nw6QKYsBblRziPnP2PZ0zvX24nOv7bbY8beynlJHGs00VWSFdoH2DS0aE1p6D+3n - * ptJuJ75dVfZFK4X7162APlNXevX8D6PEQpSiRw1rjjGGcnvQ4HdWk3BxDVDcCNJb - * Y1aGNRxsjTDvPi3R9Qx2M+W03QzEPx4SR3ZHVskeSJHaetM0TM/w/45Paq4GokXP - * ZeTnbEx1xmjkA7h+t4doLL4watx5F6yLsJzu8xB3lt/1EtmkYtLz1t7X4BetPAXz - * zS69X/VwhKfsOI3qXBWuL2oHPyhDmT1gcaUQwEPSV6ogHEEQEDXdiUS8heNK13KF - * TCQYFkETvV2BLxUhV1hypPzRQ6tUpJiAbD5KmoK2lD9slshG2QtvKQq0/bgkDY5J - * LhDHV2dtcZ3kDPkkZXpbcJQvoeH3d09C5sIsuTFo2zgNR6oETHUc5TzP6FY2YYRa - * QcK5HcmtsRRiXFm01ac+aMejJUIujjFt84SiKWT/73vC8AmY4tYcJBLjCg4XIxSH - * fdDFLL1YZENNO5ivlp8mdiHqcawx+36L7DrEZQ8RZt6cqST5t/+XTdM74s6k81GT - * pNsa82P2K2zmIUZ/DL2mKjW1vfRByw1NQFEBkN3vdyZxYfM/JyUzX4hbjXBEkh9Q - * QYrcwLKLjis2QzSvK04B3bvRzRb+4ocWiso8ZPAXAIxZFBWDpTMM2A== - * -----END RSA PRIVATE KEY----- - * - * -----BEGIN RSA PRIVATE KEY----- - * MIICXAIBAAKBgQClrFscN6LdmYktsnm4j9VIpecchBeNaZzGrG358h0fORna03Ie - * buxEzHCk3LoAMPagTz1UemFqzFfQCn+VKBg/mtmU8hvIJIh+/p0PPftXUwizIDPU - * PxdHFNHN6gjYDnVOr77M0uyvqXpJ38LZrLgkQJCmA1Yq0DAFQCxPq9l0iQIDAQAB - * AoGAbqcbg1E1mkR99uOJoNeQYKFOJyGiiXTMnXV1TseC4+PDfQBU7Dax35GcesBi - * CtapIpFKKS5D+ozY6b7ZT8ojxuQ/uHLPAvz0WDR3ds4iRF8tyu71Q1ZHcQsJa17y - * yO7UbkSSKn/Mp9Rb+/dKqftUGNXVFLqgHBOzN2s3We3bbbECQQDYBPKOg3hkaGHo - * OhpHKqtQ6EVkldihG/3i4WejRonelXN+HRh1KrB2HBx0M8D/qAzP1i3rNSlSHer4 - * 59YRTJnHAkEAxFX/sVYSn07BHv9Zhn6XXct/Cj43z/tKNbzlNbcxqQwQerw3IH51 - * 8UH2YOA+GD3lXbKp+MytoFLWv8zg4YT/LwJAfqan75Z1R6lLffRS49bIiq8jwE16 - * rTrUJ+kv8jKxMqc9B3vXkxpsS1M/+4E8bqgAmvpgAb8xcsvHsBd9ErdukQJBAKs2 - * j67W75BrPjBI34pQ1LEfp56IGWXOrq1kF8IbCjxv3+MYRT6Z6UJFkpRymNPNDjsC - * dgUYgITiGJHUGXuw3lMCQHEHqo9ZtXz92yFT+VhsNc29B8m/sqUJdtCcMd/jGpAF - * u6GHufjqIZBpQsk63wbwESAPZZ+kk1O1kS5GIRLX608= - * -----END RSA PRIVATE KEY----- - * - * Private-Key: (1024 bit) + * Private-Key: (2048 bit, 2 primes) * modulus: - * 00:a5:ac:5b:1c:37:a2:dd:99:89:2d:b2:79:b8:8f: - * d5:48:a5:e7:1c:84:17:8d:69:9c:c6:ac:6d:f9:f2: - * 1d:1f:39:19:da:d3:72:1e:6e:ec:44:cc:70:a4:dc: - * ba:00:30:f6:a0:4f:3d:54:7a:61:6a:cc:57:d0:0a: - * 7f:95:28:18:3f:9a:d9:94:f2:1b:c8:24:88:7e:fe: - * 9d:0f:3d:fb:57:53:08:b3:20:33:d4:3f:17:47:14: - * d1:cd:ea:08:d8:0e:75:4e:af:be:cc:d2:ec:af:a9: - * 7a:49:df:c2:d9:ac:b8:24:40:90:a6:03:56:2a:d0: - * 30:05:40:2c:4f:ab:d9:74:89 + * 00:9a:0c:e0:8f:a8:02:7e:5a:ef:ed:b2:42:ad:08: + * 4e:91:ba:c2:ad:9b:79:d7:9b:0f:fd:d2:f8:15:2f: + * 19:89:80:10:00:02:19:6d:27:c2:90:d7:a5:23:53: + * 74:6e:64:28:7c:24:aa:ed:ea:21:59:dc:a3:5c:b5: + * c9:42:31:4f:a2:de:fb:09:7c:73:ed:88:04:34:f1: + * 15:ad:3d:60:cd:ca:c5:13:99:d3:9f:9b:b2:92:70: + * cb:ba:4b:3d:20:96:ad:be:92:53:ed:54:3b:c5:14: + * bd:cf:d4:0f:cb:05:4f:fd:2b:9e:e0:50:bb:65:13: + * 92:c0:d6:bd:4d:02:0c:70:b6:65:d4:7d:b4:4d:c3: + * df:2c:08:9e:d2:3e:69:32:46:6f:6f:ca:d1:73:a4: + * 94:07:ef:14:e3:da:9e:2f:c0:ac:0e:10:33:4c:68: + * 79:f3:79:40:d6:e9:3c:c2:e6:70:e0:89:ce:a0:7a: + * a8:84:28:85:32:37:08:b0:cf:b1:7f:5f:bc:1f:a5: + * 3d:ef:d6:68:a8:17:21:5f:87:d5:4b:b5:cc:ee:78: + * 8d:dd:b1:28:6a:c0:fb:64:bd:b7:70:02:33:03:0b: + * b8:b8:bb:08:82:f6:8e:05:27:d1:3b:e6:c5:ac:4d: + * 85:5b:a1:1d:a3:48:5d:03:15:76:63:6c:71:21:3e: + * 98:cd * publicExponent: 65537 (0x10001) * privateExponent: - * 6e:a7:1b:83:51:35:9a:44:7d:f6:e3:89:a0:d7:90: - * 60:a1:4e:27:21:a2:89:74:cc:9d:75:75:4e:c7:82: - * e3:e3:c3:7d:00:54:ec:36:b1:df:91:9c:7a:c0:62: - * 0a:d6:a9:22:91:4a:29:2e:43:fa:8c:d8:e9:be:d9: - * 4f:ca:23:c6:e4:3f:b8:72:cf:02:fc:f4:58:34:77: - * 76:ce:22:44:5f:2d:ca:ee:f5:43:56:47:71:0b:09: - * 6b:5e:f2:c8:ee:d4:6e:44:92:2a:7f:cc:a7:d4:5b: - * fb:f7:4a:a9:fb:54:18:d5:d5:14:ba:a0:1c:13:b3: - * 37:6b:37:59:ed:db:6d:b1 + * 68:87:36:54:a3:c6:d5:5f:f5:0f:4f:76:c8:9c:2b: + * 5b:dc:e2:be:14:12:2f:c7:0a:a9:cb:5e:04:59:ca: + * 35:2f:8d:2b:c4:40:e6:7d:25:1b:4d:07:c3:99:9c: + * 16:4f:a5:dc:de:b0:90:f0:de:22:70:80:f4:a6:70: + * e2:96:3d:18:21:bf:2b:27:a4:2d:d7:ae:2b:12:2f: + * 08:36:ee:99:94:ed:f6:a7:d9:1d:a2:f3:1f:44:a4: + * 28:4b:67:35:d6:a8:1b:f8:84:34:34:84:bd:ec:9e: + * 03:08:3c:93:20:8e:af:15:cb:1f:20:08:97:c4:19: + * 3e:fa:36:c6:ab:0e:2f:e7:b3:c0:a7:bc:e4:e0:a6: + * 08:1c:69:20:4d:78:bd:7a:e5:25:48:60:9e:2e:50: + * 8d:36:1e:07:e9:d5:0d:39:67:41:42:24:db:87:e5: + * 77:76:fd:5e:d5:c6:e5:d3:b0:98:71:48:69:47:4f: + * 46:05:0c:9e:58:45:2e:e2:27:d0:f6:11:05:78:ad: + * 83:5a:5b:ec:d7:2e:26:5a:a5:4f:9e:52:84:2c:1f: + * 59:1a:78:56:0a:44:54:c6:37:64:01:ca:e4:a8:01: + * c7:86:c1:b4:d6:6c:7a:15:9a:65:69:46:9e:fd:f6: + * 08:17:0c:6c:ac:38:bd:c2:cd:da:ef:54:7a:48:92: + * 4d * prime1: - * 00:d8:04:f2:8e:83:78:64:68:61:e8:3a:1a:47:2a: - * ab:50:e8:45:64:95:d8:a1:1b:fd:e2:e1:67:a3:46: - * 89:de:95:73:7e:1d:18:75:2a:b0:76:1c:1c:74:33: - * c0:ff:a8:0c:cf:d6:2d:eb:35:29:52:1d:ea:f8:e7: - * d6:11:4c:99:c7 + * 00:e4:43:cc:51:25:aa:1d:90:41:95:2c:e8:9f:aa: + * 1c:9b:ea:bd:fd:29:e5:68:6b:28:00:ec:31:31:36: + * d0:3d:84:db:c5:5d:32:f6:38:b9:04:4f:45:cb:19: + * f5:88:cd:a8:fc:70:b8:6d:98:68:a6:b4:9e:c1:da: + * fd:db:eb:1a:53:3c:3b:e6:85:d2:6f:03:45:7a:ad: + * 49:8c:c3:96:a7:46:a4:bb:3b:48:d3:d7:1c:b4:3c: + * f7:04:0a:a3:85:9d:94:3e:bd:35:f5:34:21:3d:08: + * 89:df:c5:54:af:cf:90:f7:d8:5c:57:c5:77:5a:c8: + * d1:b3:8f:ee:01:5c:07:13:3f * prime2: - * 00:c4:55:ff:b1:56:12:9f:4e:c1:1e:ff:59:86:7e: - * 97:5d:cb:7f:0a:3e:37:cf:fb:4a:35:bc:e5:35:b7: - * 31:a9:0c:10:7a:bc:37:20:7e:75:f1:41:f6:60:e0: - * 3e:18:3d:e5:5d:b2:a9:f8:cc:ad:a0:52:d6:bf:cc: - * e0:e1:84:ff:2f + * 00:ac:c4:a0:cc:7c:51:db:65:0a:02:da:bc:d8:77: + * 21:8c:d3:30:ae:ec:50:60:4b:b9:39:c7:2d:bd:98: + * aa:4f:9b:44:74:ab:f8:86:de:e2:44:15:73:7a:cd: + * d5:46:f2:03:62:c5:87:9c:6d:91:d5:7a:9a:17:c2: + * c6:2f:29:0e:8a:a4:a9:f4:c2:63:a2:77:97:bf:c6: + * 90:e8:39:70:87:cc:fd:62:4f:d2:3d:e7:47:70:fb: + * f3:bd:bd:5c:9c:77:fe:23:33:7d:83:ef:cb:0e:4e: + * f1:dd:05:47:40:97:f4:da:b6:1f:b9:8d:e2:92:04: + * 09:be:fb:6a:97:29:27:ac:f3 * exponent1: - * 7e:a6:a7:ef:96:75:47:a9:4b:7d:f4:52:e3:d6:c8: - * 8a:af:23:c0:4d:7a:ad:3a:d4:27:e9:2f:f2:32:b1: - * 32:a7:3d:07:7b:d7:93:1a:6c:4b:53:3f:fb:81:3c: - * 6e:a8:00:9a:fa:60:01:bf:31:72:cb:c7:b0:17:7d: - * 12:b7:6e:91 + * 3f:08:1d:b6:56:b1:38:02:aa:a9:77:c2:30:bc:b7: + * b3:b2:49:8e:4b:f0:66:3a:18:cc:d0:6b:f1:0c:12: + * ca:ba:12:39:d8:b7:86:d8:38:f6:e0:b1:04:19:81: + * fc:a9:d5:bd:07:9f:55:dc:1d:21:d3:84:77:41:72: + * 92:34:c4:8b:31:79:d4:f9:25:17:b4:8e:8e:06:a5: + * e5:b1:e8:ba:fe:3d:e4:d9:c5:0d:82:3c:11:e5:37: + * cc:ac:e7:64:b1:13:cb:93:52:00:08:ca:18:e1:6f: + * b9:13:f3:83:ac:cc:7a:34:0b:a3:cd:0a:5d:4e:50: + * e1:c5:9f:d2:4e:48:41:df * exponent2: - * 00:ab:36:8f:ae:d6:ef:90:6b:3e:30:48:df:8a:50: - * d4:b1:1f:a7:9e:88:19:65:ce:ae:ad:64:17:c2:1b: - * 0a:3c:6f:df:e3:18:45:3e:99:e9:42:45:92:94:72: - * 98:d3:cd:0e:3b:02:76:05:18:80:84:e2:18:91:d4: - * 19:7b:b0:de:53 + * 02:c7:fb:8a:af:29:a6:2d:7f:36:c2:8c:ad:b3:65: + * 3f:de:1a:77:86:68:58:d4:7f:3b:d5:df:ff:a0:58: + * 85:85:8b:59:91:77:23:bc:ac:c9:c9:ca:9d:1c:79: + * 25:76:39:e5:ba:26:4f:b7:57:d4:a6:ef:9a:18:51: + * 96:6a:c3:c8:29:94:6e:d3:3e:45:5c:45:7e:19:d5: + * 35:57:cf:5e:f0:46:d7:f1:4f:02:1e:1a:01:50:9d: + * 00:dd:ee:82:ba:4f:c6:03:4b:2e:f7:8a:3e:45:b9: + * 11:04:c7:bb:db:76:5e:9a:f5:f1:c7:bd:f0:f9:cd: + * aa:5c:63:bf:e1:32:b9:4f * coefficient: - * 71:07:aa:8f:59:b5:7c:fd:db:21:53:f9:58:6c:35: - * cd:bd:07:c9:bf:b2:a5:09:76:d0:9c:31:df:e3:1a: - * 90:05:bb:a1:87:b9:f8:ea:21:90:69:42:c9:3a:df: - * 06:f0:11:20:0f:65:9f:a4:93:53:b5:91:2e:46:21: - * 12:d7:eb:4f - * + * 50:4c:e6:1e:23:f3:e2:2b:d6:3f:87:53:fb:19:53: + * 4b:84:21:0b:77:31:ed:8d:c3:0c:ea:31:b0:a6:38: + * a9:e6:44:6e:18:05:53:8f:4a:5f:75:e5:3e:b5:26: + * 9b:46:3d:73:e7:c1:2a:a6:3e:c3:cd:41:b1:a6:55: + * 57:84:11:13:ec:44:92:59:7f:dd:0d:67:30:d3:b7: + * 13:ee:9e:2d:ea:be:b3:ca:4a:f0:6e:4f:22:e8:be: + * 8b:8d:9b:2c:30:a5:ed:2c:2b:13:4c:f7:61:19:64: + * 35:9d:b0:c8:10:85:01:e7:2a:70:13:00:39:c5:73: + * 63:34:fd:28:2d:7f:8d:20 + * -----BEGIN PRIVATE KEY----- + * MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCaDOCPqAJ+Wu/t + * skKtCE6RusKtm3nXmw/90vgVLxmJgBAAAhltJ8KQ16UjU3RuZCh8JKrt6iFZ3KNc + * tclCMU+i3vsJfHPtiAQ08RWtPWDNysUTmdOfm7KScMu6Sz0glq2+klPtVDvFFL3P + * 1A/LBU/9K57gULtlE5LA1r1NAgxwtmXUfbRNw98sCJ7SPmkyRm9vytFzpJQH7xTj + * 2p4vwKwOEDNMaHnzeUDW6TzC5nDgic6geqiEKIUyNwiwz7F/X7wfpT3v1mioFyFf + * h9VLtczueI3dsShqwPtkvbdwAjMDC7i4uwiC9o4FJ9E75sWsTYVboR2jSF0DFXZj + * bHEhPpjNAgMBAAECggEAaIc2VKPG1V/1D092yJwrW9zivhQSL8cKqcteBFnKNS+N + * K8RA5n0lG00Hw5mcFk+l3N6wkPDeInCA9KZw4pY9GCG/KyekLdeuKxIvCDbumZTt + * 9qfZHaLzH0SkKEtnNdaoG/iENDSEveyeAwg8kyCOrxXLHyAIl8QZPvo2xqsOL+ez + * wKe85OCmCBxpIE14vXrlJUhgni5QjTYeB+nVDTlnQUIk24fld3b9XtXG5dOwmHFI + * aUdPRgUMnlhFLuIn0PYRBXitg1pb7NcuJlqlT55ShCwfWRp4VgpEVMY3ZAHK5KgB + * x4bBtNZsehWaZWlGnv32CBcMbKw4vcLN2u9UekiSTQKBgQDkQ8xRJaodkEGVLOif + * qhyb6r39KeVoaygA7DExNtA9hNvFXTL2OLkET0XLGfWIzaj8cLhtmGimtJ7B2v3b + * 6xpTPDvmhdJvA0V6rUmMw5anRqS7O0jT1xy0PPcECqOFnZQ+vTX1NCE9CInfxVSv + * z5D32FxXxXdayNGzj+4BXAcTPwKBgQCsxKDMfFHbZQoC2rzYdyGM0zCu7FBgS7k5 + * xy29mKpPm0R0q/iG3uJEFXN6zdVG8gNixYecbZHVepoXwsYvKQ6KpKn0wmOid5e/ + * xpDoOXCHzP1iT9I950dw+/O9vVycd/4jM32D78sOTvHdBUdAl/Tath+5jeKSBAm+ + * +2qXKSes8wKBgD8IHbZWsTgCqql3wjC8t7OySY5L8GY6GMzQa/EMEsq6EjnYt4bY + * OPbgsQQZgfyp1b0Hn1XcHSHThHdBcpI0xIsxedT5JRe0jo4GpeWx6Lr+PeTZxQ2C + * PBHlN8ys52SxE8uTUgAIyhjhb7kT84OszHo0C6PNCl1OUOHFn9JOSEHfAoGAAsf7 + * iq8ppi1/NsKMrbNlP94ad4ZoWNR/O9Xf/6BYhYWLWZF3I7ysycnKnRx5JXY55bom + * T7dX1KbvmhhRlmrDyCmUbtM+RVxFfhnVNVfPXvBG1/FPAh4aAVCdAN3ugrpPxgNL + * LveKPkW5EQTHu9t2Xpr18ce98PnNqlxjv+EyuU8CgYBQTOYeI/PiK9Y/h1P7GVNL + * hCELdzHtjcMM6jGwpjip5kRuGAVTj0pfdeU+tSabRj1z58Eqpj7DzUGxplVXhBET + * 7ESSWX/dDWcw07cT7p4t6r6zykrwbk8i6L6LjZssMKXtLCsTTPdhGWQ1nbDIEIUB + * 5ypwEwA5xXNjNP0oLX+NIA== + * -----END PRIVATE KEY----- * * server certificate: - * Data: - * Version: 3 (0x2) - * Serial Number: 8 (0x8) - * Signature Algorithm: md5WithRSAEncryption - * Issuer: C=US, ST=Some-State, L=Some-City, O=Some-Org - * Validity - * Not Before: Dec 8 03:43:04 2008 GMT - * Not After : Aug 25 03:43:04 2028 GMT - * Subject: C=US, ST=Some-State, L=Some-City, O=Some-Org, OU=SSL-Server, CN=localhost - * Subject Public Key Info: - * Public Key Algorithm: rsaEncryption - * RSA Public Key: (1024 bit) - * Modulus (1024 bit): - * 00:a5:ac:5b:1c:37:a2:dd:99:89:2d:b2:79:b8:8f: - * d5:48:a5:e7:1c:84:17:8d:69:9c:c6:ac:6d:f9:f2: - * 1d:1f:39:19:da:d3:72:1e:6e:ec:44:cc:70:a4:dc: - * ba:00:30:f6:a0:4f:3d:54:7a:61:6a:cc:57:d0:0a: - * 7f:95:28:18:3f:9a:d9:94:f2:1b:c8:24:88:7e:fe: - * 9d:0f:3d:fb:57:53:08:b3:20:33:d4:3f:17:47:14: - * d1:cd:ea:08:d8:0e:75:4e:af:be:cc:d2:ec:af:a9: - * 7a:49:df:c2:d9:ac:b8:24:40:90:a6:03:56:2a:d0: - * 30:05:40:2c:4f:ab:d9:74:89 - * Exponent: 65537 (0x10001) - * X509v3 extensions: - * X509v3 Basic Constraints: - * CA:FALSE - * X509v3 Key Usage: - * Digital Signature, Non Repudiation, Key Encipherment - * X509v3 Subject Key Identifier: - * ED:6E:DB:F4:B5:56:C8:FB:1A:06:61:3F:0F:08:BB:A6:04:D8:16:54 - * X509v3 Authority Key Identifier: - * keyid:FA:B9:51:BF:4C:E7:D9:86:98:33:F9:E7:CB:1E:F1:33:49:F7:A8:14 - * - * X509v3 Subject Alternative Name: critical - * DNS:localhost - * Signature Algorithm: md5WithRSAEncryption0 - * + * Data: + * Version: 3 (0x2) + * Serial Number: 106315679 (0x6563f9f) + * Signature Algorithm: sha1WithRSAEncryption + * Issuer: C=Us, ST=Some-State, L=Some-City, O=Some-Org + * Validity + * Not Before: Jul 1 04:16:55 2024 GMT + * Not After : Jul 2 04:16:55 2034 GMT + * Subject: C=US, ST=Some-State, L=Some-City, O=Some-Org, CN=localhost ou=SSL-Server + * Subject Public Key Info: + * Public Key Algorithm: rsaEncryption + * Public-Key: (2048 bit) + * Modulus: + * 00:9a:0c:e0:8f:a8:02:7e:5a:ef:ed:b2:42:ad:08: + * 4e:91:ba:c2:ad:9b:79:d7:9b:0f:fd:d2:f8:15:2f: + * 19:89:80:10:00:02:19:6d:27:c2:90:d7:a5:23:53: + * 74:6e:64:28:7c:24:aa:ed:ea:21:59:dc:a3:5c:b5: + * c9:42:31:4f:a2:de:fb:09:7c:73:ed:88:04:34:f1: + * 15:ad:3d:60:cd:ca:c5:13:99:d3:9f:9b:b2:92:70: + * cb:ba:4b:3d:20:96:ad:be:92:53:ed:54:3b:c5:14: + * bd:cf:d4:0f:cb:05:4f:fd:2b:9e:e0:50:bb:65:13: + * 92:c0:d6:bd:4d:02:0c:70:b6:65:d4:7d:b4:4d:c3: + * df:2c:08:9e:d2:3e:69:32:46:6f:6f:ca:d1:73:a4: + * 94:07:ef:14:e3:da:9e:2f:c0:ac:0e:10:33:4c:68: + * 79:f3:79:40:d6:e9:3c:c2:e6:70:e0:89:ce:a0:7a: + * a8:84:28:85:32:37:08:b0:cf:b1:7f:5f:bc:1f:a5: + * 3d:ef:d6:68:a8:17:21:5f:87:d5:4b:b5:cc:ee:78: + * 8d:dd:b1:28:6a:c0:fb:64:bd:b7:70:02:33:03:0b: + * b8:b8:bb:08:82:f6:8e:05:27:d1:3b:e6:c5:ac:4d: + * 85:5b:a1:1d:a3:48:5d:03:15:76:63:6c:71:21:3e: + * 98:cd + * Exponent: 65537 (0x10001) + * X509v3 extensions: + * X509v3 Subject Key Identifier: + * 5C:AF:44:B1:48:B8:59:9A:64:53:9D:2E:A6:B2:09:D3:0A:92:04:83 + * X509v3 Key Usage: + * Digital Signature, Non Repudiation, Key Encipherment + * X509v3 Subject Alternative Name: critical + * DNS:localhost + * X509v3 Basic Constraints: + * CA:FALSE + * X509v3 Authority Key Identifier: + * E0:03:90:F6:4F:BB:57:E6:7E:AF:5C:94:25:B3:85:DA:16:0A:51:40 + * Signature Algorithm: sha1WithRSAEncryption + * Signature Value: + * 9d:22:49:5f:56:23:e6:80:35:cc:ab:44:1c:27:bd:c9:8d:89: + * 93:49:58:e8:c1:7a:68:dd:cf:bd:e0:12:76:06:54:cd:2f:62: + * 9b:54:84:f2:bb:90:a0:bb:37:e2:13:1d:f3:df:41:aa:e0:fe: + * c0:ef:46:78:8d:aa:f4:1b:70:ad:a9:16:24:fa:15:4a:c6:0a: + * 8d:e1:99:93:00:a9:d4:b6:08:5d:8e:65:03:dc:d0:95:fc:95: + * 61:a6:ad:b5:ab:4d:a6:e0:05:48:8c:db:42:42:8a:d6:5e:c0: + * 2a:a0:11:15:b8:07:69:5c:3f:99:a0:bd:53:65:db:4e:cf:46: + * 61:93:09:7b:81:40:ff:5c:fe:4c:eb:f4:ac:de:1f:38:ad:b2: + * 60:28:f6:0e:9f:46:e7:07:8f:20:9a:a4:e1:8f:ab:54:99:76: + * 82:d8:9e:70:c4:da:98:85:71:af:3b:54:e4:01:b4:9e:83:d0: + * 7b:c6:8d:1f:ed:25:08:89:05:e9:87:97:76:5a:a3:85:c3:f8: + * 59:d7:bb:3b:5a:db:cb:ed:5d:ff:ac:21:b9:9a:e2:65:0a:bc: + * de:d1:dc:53:94:98:44:97:91:b3:1b:6b:80:0b:9b:57:b3:ae: + * 5c:7c:35:ca:39:71:f7:4e:8f:4a:d7:eb:0b:25:da:b2:1e:17: + * 48:b8:eb:09 * -----BEGIN CERTIFICATE----- - * MIICpDCCAg2gAwIBAgIBCDANBgkqhkiG9w0BAQQFADBJMQswCQYDVQQGEwJVUzET - * MBEGA1UECBMKU29tZS1TdGF0ZTESMBAGA1UEBxMJU29tZS1DaXR5MREwDwYDVQQK - * EwhTb21lLU9yZzAeFw0wODEyMDgwMzQzMDRaFw0yODA4MjUwMzQzMDRaMHIxCzAJ - * BgNVBAYTAlVTMRMwEQYDVQQIEwpTb21lLVN0YXRlMRIwEAYDVQQHEwlTb21lLUNp - * dHkxETAPBgNVBAoTCFNvbWUtT3JnMRMwEQYDVQQLEwpTU0wtU2VydmVyMRIwEAYD - * VQQDEwlsb2NhbGhvc3QwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAKWsWxw3 - * ot2ZiS2yebiP1Uil5xyEF41pnMasbfnyHR85GdrTch5u7ETMcKTcugAw9qBPPVR6 - * YWrMV9AKf5UoGD+a2ZTyG8gkiH7+nQ89+1dTCLMgM9Q/F0cU0c3qCNgOdU6vvszS - * 7K+peknfwtmsuCRAkKYDVirQMAVALE+r2XSJAgMBAAGjczBxMAkGA1UdEwQCMAAw - * CwYDVR0PBAQDAgXgMB0GA1UdDgQWBBTtbtv0tVbI+xoGYT8PCLumBNgWVDAfBgNV - * HSMEGDAWgBT6uVG/TOfZhpgz+efLHvEzSfeoFDAXBgNVHREBAf8EDTALgglsb2Nh - * bGhvc3QwDQYJKoZIhvcNAQEEBQADgYEAoqVTciHtcvsUj+YaTct8tUh3aTCsKsac - * PHhfQ+ObjiXSgxsKYTX7ym/wk/wvlbUcbqLKxsu7qrcJitH+H9heV1hEHEu65Uoi - * nRugFruyOrwvAylV8Cm2af7ddilmYJ+sdJA6N2M3xJRxR0G2LFHEXDNEjYReyexn - * JqCpf5uZGOo= + * MIIDpTCCAo2gAwIBAgIEBlY/nzANBgkqhkiG9w0BAQUFADBJMQswCQYDVQQGEwJV + * czETMBEGA1UECBMKU29tZS1TdGF0ZTESMBAGA1UEBxMJU29tZS1DaXR5MREwDwYD + * VQQKEwhTb21lLU9yZzAeFw0yNDA3MDEwNDE2NTVaFw0zNDA3MDIwNDE2NTVaMGsx + * CzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpTb21lLVN0YXRlMRIwEAYDVQQHEwlTb21l + * LUNpdHkxETAPBgNVBAoTCFNvbWUtT3JnMSAwHgYDVQQDExdsb2NhbGhvc3Qgb3U9 + * U1NMLVNlcnZlcjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJoM4I+o + * An5a7+2yQq0ITpG6wq2bedebD/3S+BUvGYmAEAACGW0nwpDXpSNTdG5kKHwkqu3q + * IVnco1y1yUIxT6Le+wl8c+2IBDTxFa09YM3KxROZ05+bspJwy7pLPSCWrb6SU+1U + * O8UUvc/UD8sFT/0rnuBQu2UTksDWvU0CDHC2ZdR9tE3D3ywIntI+aTJGb2/K0XOk + * lAfvFOPani/ArA4QM0xoefN5QNbpPMLmcOCJzqB6qIQohTI3CLDPsX9fvB+lPe/W + * aKgXIV+H1Uu1zO54jd2xKGrA+2S9t3ACMwMLuLi7CIL2jgUn0TvmxaxNhVuhHaNI + * XQMVdmNscSE+mM0CAwEAAaNzMHEwHQYDVR0OBBYEFFyvRLFIuFmaZFOdLqayCdMK + * kgSDMAsGA1UdDwQEAwIF4DAXBgNVHREBAf8EDTALgglsb2NhbGhvc3QwCQYDVR0T + * BAIwADAfBgNVHSMEGDAWgBTgA5D2T7tX5n6vXJQls4XaFgpRQDANBgkqhkiG9w0B + * AQUFAAOCAQEAnSJJX1Yj5oA1zKtEHCe9yY2Jk0lY6MF6aN3PveASdgZUzS9im1SE + * 8ruQoLs34hMd899BquD+wO9GeI2q9BtwrakWJPoVSsYKjeGZkwCp1LYIXY5lA9zQ + * lfyVYaattatNpuAFSIzbQkKK1l7AKqARFbgHaVw/maC9U2XbTs9GYZMJe4FA/1z+ + * TOv0rN4fOK2yYCj2Dp9G5wePIJqk4Y+rVJl2gtiecMTamIVxrztU5AG0noPQe8aN + * H+0lCIkF6YeXdlqjhcP4Wde7O1rby+1d/6whuZriZQq83tHcU5SYRJeRsxtrgAub + * V7OuXHw1yjlx906PStfrCyXash4XSLjrCQ== * -----END CERTIFICATE----- * * * TLS client certificate: * client private key: - * ----BEGIN RSA PRIVATE KEY----- - * Proc-Type: 4,ENCRYPTED - * DEK-Info: DES-EDE3-CBC,FA2A435CD35A9390 - * - * Z+Y2uaETbsUWIyJUyVu1UV2G4rgFYJyACZT6Tp1KjRtxflSh2kXkJ9MpuXMXA0V4 - * Yy3fDzPqCL9NJmQAYRlAx/W/+j4F5EyMWDIx8fUxzONRZyoiwF7jLm+KscAfv6Pf - * q7ItWOdj3z7IYrwlB8YIGd3F2cDKT3S+lYRk7rKb/qT7itbuHnY4Ardh3yl+MZak - * jBp+ELUlRsUqSr1V0LoM+0rCCykarpyfhpxEcqsrl0v9Cyi5uhU50/oKv5zql3SH - * l2ImgDjp3batAs8+Bd4NF2aqi0a7Hy44JUHxRm4caZryU/i/D9N1MbuM6882HLat - * 5N0G+NaIUfywa8mjwq2D5aiit18HqKA6XeRRYeJ5Dvu9DCO4GeFSwcUFIBMI0L46 - * 7s114+oDodg57pMgITi+04vmUxvqlN9aiyd7f5Fgd7PeHGeOdbMz1NaJLJaPI9++ - * NakK8eK9iwT/Gdq0Uap5/CHW7vCT5PO+h3HY0STH0lWStXhdWnFO04zTdywsbSp+ - * DLpHeFT66shfeUlxR0PsCbG9vPRt/QmGLeYQZITppWo/ylSq4j+pRIuXvuWHdBRN - * rTZ8QF4Y7AxQUXVz1j1++s6ZMHTzaK2i9HrhmDs1MbJl+QwWre3Xpv3LvTVz3k5U - * wX8kuY1m3STt71QCaRWENq5sRaMImLxZbxc/ivFl9RAzUqo4NCxLod/QgA4iLqtO - * ztnlpzwlC/F8HbQ1oqYWwnZAPhzU/cULtstl+Yrws2c2atO323LbPXZqbASySgig - * sNpFXQMObdfP6LN23bY+1SvtK7V4NUTNhpdIc6INQAQ= - * -----END RSA PRIVATE KEY----- - * - * -----BEGIN RSA PRIVATE KEY----- - * MIICWwIBAAKBgQC78EA2rCZUTvSjWgAvaSFvuXo6k+yi9uGOx2PYLxIwmS6w8o/4 - * Jy0keCiE9wG/jUR53TvSVfPOPLJbIX3v/TNKsaP/xsibuQ98QTWX+ds6BWAFFa9Z - * F5KjEK0WHOQHU6+odqJWKpLT+SjgeM9eH0irXBnd4WdDunWN9YKsQ5JEGwIDAQAB - * AoGAEbdqNj0wN85hnWyEi/ObJU8UyKTdL9eaF72QGfcF/fLSxfd3vurihIeXOkGW - * tpn4lIxYcVGM9CognhqgJpl11jFTQzn1KqZ+NEJRKkCHA4hDabKJbSC9fXHvRwrf - * BsFpZqgiNxp3HseUTiwnaUVeyPgMt/jAj5nB5Sib+UyUxrECQQDnNQBiF2aifEg6 - * zbJOOC7he5CHAdkFxSxWVFVHL6EfXfqdLVkUohMbgZv+XxyIeU2biOExSg49Kds3 - * FOKgTau1AkEA0Bd1haj6QuCo8I0AXm2WO+MMTZMTvtHD/bGjKNM+fT4I8rKYnQRX - * 1acHdqS9Xx2rNJqZgkMmpESIdPR2fc4yjwJALFeM6EMmqvj8/VIf5UJ/Mz14fXwM - * PEARfckUxd9LnnFutCBTWlKvKXJVEZb6KO5ixPaegc57Jp3Vbh3yTN44lQJADD/1 - * SSMDaIB1MYP7a5Oj7m6VQNPRq8AJe5vDcRnOae0G9dKRrVyeFxO4GsHj6/+BHp2j - * P8nYMn9eURQ7DXjf/QJAAQzMlWnKGSO8pyTDtnQx3hRMoUkOEhmNq4bQhLkYqtnY - * FcqpUQ2qMjW+NiNWk5HnTrMS3L9EdJobMUzaNZLy4w== - * -----END RSA PRIVATE KEY----- * - * Private-Key: (1024 bit) + * Private-Key: (2048 bit, 2 primes) * modulus: - * 00:bb:f0:40:36:ac:26:54:4e:f4:a3:5a:00:2f:69: - * 21:6f:b9:7a:3a:93:ec:a2:f6:e1:8e:c7:63:d8:2f: - * 12:30:99:2e:b0:f2:8f:f8:27:2d:24:78:28:84:f7: - * 01:bf:8d:44:79:dd:3b:d2:55:f3:ce:3c:b2:5b:21: - * 7d:ef:fd:33:4a:b1:a3:ff:c6:c8:9b:b9:0f:7c:41: - * 35:97:f9:db:3a:05:60:05:15:af:59:17:92:a3:10: - * ad:16:1c:e4:07:53:af:a8:76:a2:56:2a:92:d3:f9: - * 28:e0:78:cf:5e:1f:48:ab:5c:19:dd:e1:67:43:ba: - * 75:8d:f5:82:ac:43:92:44:1b + * 00:cc:bf:92:3c:a6:57:74:1f:58:ad:c7:69:88:6f: + * 59:32:47:50:60:22:e4:98:49:0e:3e:1d:b8:ba:e2: + * 3b:b6:71:5b:fd:64:02:6d:0d:50:77:72:6e:a8:3d: + * 5d:d4:bd:1f:76:51:dc:9a:d0:d6:3e:d0:31:a5:24: + * 5a:2c:be:77:fa:88:a1:fa:06:41:c8:0f:47:70:47: + * 24:99:50:52:44:5b:30:62:5b:65:35:c4:28:b0:5c: + * ee:d0:1b:eb:39:2b:0b:a1:ac:96:48:da:56:6c:e0: + * e3:e6:e3:dd:45:cb:51:33:8d:40:43:d7:f0:a4:31: + * aa:b5:c0:df:4b:df:2b:0a:ed:7e:10:0c:ae:1f:96: + * a2:10:1e:6b:d0:f9:37:8b:df:0d:0e:02:35:f8:58: + * bc:6e:b5:57:0e:2f:ea:20:e6:73:9a:e5:6b:82:70: + * 25:bb:51:9a:7c:9d:e2:50:3d:cf:1e:24:3e:92:55: + * cf:2a:ad:0d:84:8f:a8:43:24:cd:ad:50:64:74:c2: + * 73:b6:e1:92:1c:b2:2b:8c:2d:7b:96:a6:41:61:5c: + * 1b:8f:78:28:51:40:ed:41:90:ce:1d:b8:26:81:47: + * 6b:e3:57:41:74:4e:20:f0:5a:1b:97:37:91:86:19: + * c5:f2:6d:04:c9:78:2b:5a:16:bc:fc:2b:71:5b:d0: + * 00:4f * publicExponent: 65537 (0x10001) * privateExponent: - * 11:b7:6a:36:3d:30:37:ce:61:9d:6c:84:8b:f3:9b: - * 25:4f:14:c8:a4:dd:2f:d7:9a:17:bd:90:19:f7:05: - * fd:f2:d2:c5:f7:77:be:ea:e2:84:87:97:3a:41:96: - * b6:99:f8:94:8c:58:71:51:8c:f4:2a:20:9e:1a:a0: - * 26:99:75:d6:31:53:43:39:f5:2a:a6:7e:34:42:51: - * 2a:40:87:03:88:43:69:b2:89:6d:20:bd:7d:71:ef: - * 47:0a:df:06:c1:69:66:a8:22:37:1a:77:1e:c7:94: - * 4e:2c:27:69:45:5e:c8:f8:0c:b7:f8:c0:8f:99:c1: - * e5:28:9b:f9:4c:94:c6:b1 + * 62:b2:d6:63:b6:2b:e2:26:5a:31:2b:37:8c:35:60: + * e2:03:ce:93:09:3e:f8:c9:fe:bb:a2:c8:32:0e:6c: + * 8a:7e:0a:c2:13:3b:b8:25:fa:ec:19:95:8e:34:46: + * cf:0e:7b:e4:25:82:1a:7f:21:48:16:44:58:3f:35: + * d8:eb:d8:1a:45:53:0f:9b:84:8a:54:13:33:e4:97: + * 97:f0:48:37:fb:5d:4f:8c:8f:35:63:e1:d9:62:73: + * 1c:8e:d8:cd:2e:1a:e5:4c:b5:05:59:7a:df:f1:68: + * eb:1c:5c:c6:10:44:8c:7d:42:c5:71:8a:e7:1b:aa: + * 17:03:6a:a0:c0:6b:97:50:17:ad:6e:5e:d9:db:6f: + * 3e:e9:3f:35:c3:45:bc:e8:3d:5a:b4:b9:3f:53:80: + * 64:dc:12:24:35:35:bd:98:bb:8d:fa:19:a3:5e:9e: + * ac:70:4a:fc:8d:ae:55:8b:71:81:0e:4d:c8:2f:87: + * b0:44:f7:4f:dc:a8:c8:50:b5:95:24:63:74:13:54: + * 58:de:fc:e0:75:eb:f4:06:58:83:12:4c:56:c4:c4: + * 18:0c:ea:a3:e7:25:a3:de:19:23:a2:5a:2a:b6:56: + * 04:bc:65:ba:7c:0a:f4:91:10:22:88:3f:9d:be:58: + * 43:4c:2e:ad:db:d6:32:cf:8e:b5:05:55:39:8b:e1: + * 01 * prime1: - * 00:e7:35:00:62:17:66:a2:7c:48:3a:cd:b2:4e:38: - * 2e:e1:7b:90:87:01:d9:05:c5:2c:56:54:55:47:2f: - * a1:1f:5d:fa:9d:2d:59:14:a2:13:1b:81:9b:fe:5f: - * 1c:88:79:4d:9b:88:e1:31:4a:0e:3d:29:db:37:14: - * e2:a0:4d:ab:b5 + * 00:f1:da:c2:8a:e5:66:45:8a:14:fc:08:6e:fb:aa: + * 50:d2:8c:b1:c4:f4:88:26:d4:b8:c4:63:30:ca:e3: + * 0c:6c:50:d4:93:5c:1c:13:37:60:21:11:3b:d1:f1: + * 9f:4c:0d:7b:0e:53:3d:c9:a4:fb:fa:6b:9e:b4:0a: + * 5d:d3:50:88:d7:be:c3:88:b2:b1:8a:6e:7b:d6:70: + * 88:96:a4:fe:90:ef:d1:84:ad:a8:9e:9f:3a:68:3f: + * 3f:82:07:be:c2:44:1e:d5:a1:a9:1a:db:39:d7:7f: + * 0c:6e:35:5b:1d:33:1b:a9:cd:38:2a:64:d1:70:2a: + * fe:b9:c2:b6:ed:59:19:73:b1 * prime2: - * 00:d0:17:75:85:a8:fa:42:e0:a8:f0:8d:00:5e:6d: - * 96:3b:e3:0c:4d:93:13:be:d1:c3:fd:b1:a3:28:d3: - * 3e:7d:3e:08:f2:b2:98:9d:04:57:d5:a7:07:76:a4: - * bd:5f:1d:ab:34:9a:99:82:43:26:a4:44:88:74:f4: - * 76:7d:ce:32:8f + * 00:d8:b9:3a:38:6c:79:cd:0b:1f:2b:34:74:bf:7a: + * 3d:0c:21:5a:a6:ea:f2:9e:de:68:42:05:7f:ea:a5: + * 00:c9:10:f8:fd:c5:05:8d:03:45:5d:4f:6f:fa:6e: + * 9d:ef:ad:8a:ec:83:d4:ed:57:f3:86:73:15:2f:d2: + * 67:70:d1:62:ef:1d:25:08:59:47:20:62:47:16:35: + * e1:57:38:bf:39:dd:fc:b9:c8:d8:23:53:e2:02:7d: + * 22:31:4c:66:72:96:df:d8:7c:01:2c:71:00:89:18: + * e9:8c:08:44:8c:64:1f:93:9b:7a:97:26:c9:50:d0: + * 87:b2:48:a8:19:71:e1:b3:ff * exponent1: - * 2c:57:8c:e8:43:26:aa:f8:fc:fd:52:1f:e5:42:7f: - * 33:3d:78:7d:7c:0c:3c:40:11:7d:c9:14:c5:df:4b: - * 9e:71:6e:b4:20:53:5a:52:af:29:72:55:11:96:fa: - * 28:ee:62:c4:f6:9e:81:ce:7b:26:9d:d5:6e:1d:f2: - * 4c:de:38:95 + * 23:98:dd:35:70:5a:43:35:f5:ac:ba:d9:0a:f5:a0: + * 7b:bc:f5:95:55:a0:8c:86:96:c3:61:0e:17:6e:9f: + * af:79:9e:30:2a:48:7f:93:90:f4:8d:02:ce:fd:cf: + * 42:74:61:7e:54:46:2d:dd:b8:b0:bd:12:58:d1:85: + * c9:ca:7a:b9:b6:7c:35:2c:87:f1:26:1d:d8:0c:2c: + * 2e:70:0e:7f:ea:ac:5d:e8:e9:7e:9f:55:0b:6e:f3: + * bc:01:c3:d3:f8:0e:c9:c6:c7:8b:0a:65:53:10:82: + * 15:de:88:90:9d:ab:1e:ac:f3:ed:59:75:72:1b:01: + * ee:f9:77:cf:2b:64:11:a1 * exponent2: - * 0c:3f:f5:49:23:03:68:80:75:31:83:fb:6b:93:a3: - * ee:6e:95:40:d3:d1:ab:c0:09:7b:9b:c3:71:19:ce: - * 69:ed:06:f5:d2:91:ad:5c:9e:17:13:b8:1a:c1:e3: - * eb:ff:81:1e:9d:a3:3f:c9:d8:32:7f:5e:51:14:3b: - * 0d:78:df:fd + * 00:9e:29:6f:87:c6:02:8d:d5:54:05:df:de:63:ee: + * fd:a6:60:a1:1b:b7:d3:20:86:07:68:47:43:37:26: + * fc:0f:c0:c7:35:cc:17:64:f5:c2:25:7a:d7:a9:d8: + * 18:82:d6:0f:d0:d3:d5:0c:f1:66:d3:f4:20:be:29: + * bb:3b:e6:53:61:55:cf:b4:ec:12:b0:5b:88:ad:78: + * dc:df:1e:96:cf:d0:65:a3:e0:23:7c:84:b7:28:41: + * d2:36:50:1f:63:f9:1f:9b:89:c4:01:7e:e6:79:27: + * 29:29:fc:ce:a9:f6:57:e5:0d:4e:c6:08:94:5a:da: + * 14:6d:d4:00:79:b1:56:9a:59 * coefficient: - * 01:0c:cc:95:69:ca:19:23:bc:a7:24:c3:b6:74:31: - * de:14:4c:a1:49:0e:12:19:8d:ab:86:d0:84:b9:18: - * aa:d9:d8:15:ca:a9:51:0d:aa:32:35:be:36:23:56: - * 93:91:e7:4e:b3:12:dc:bf:44:74:9a:1b:31:4c:da: - * 35:92:f2:e3 + * 6c:73:0d:fe:c7:22:15:5d:8c:a1:91:2b:d1:88:e8: + * 91:f9:d0:3e:d0:ba:c4:74:88:ce:14:20:4e:1e:4b: + * c5:91:8f:c1:56:e9:74:e0:f6:cf:71:91:ed:2c:f5: + * 90:9d:d6:c8:cd:f5:79:dc:6e:b3:83:3e:fa:d6:b4: + * 60:d9:3a:52:12:76:9d:92:fb:db:26:ee:43:33:c4: + * 0b:84:74:1b:91:e0:41:8b:cc:cc:24:da:52:af:2d: + * 42:e7:11:57:0d:aa:66:af:1a:ba:c2:8e:6a:ee:8f: + * 2c:e6:5b:76:38:96:bb:7a:2f:59:fe:de:a1:02:fc: + * 12:3a:aa:9f:3c:0e:a4:78 + * writing RSA key + * -----BEGIN PRIVATE KEY----- + * MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDMv5I8pld0H1it + * x2mIb1kyR1BgIuSYSQ4+Hbi64ju2cVv9ZAJtDVB3cm6oPV3UvR92Udya0NY+0DGl + * JFosvnf6iKH6BkHID0dwRySZUFJEWzBiW2U1xCiwXO7QG+s5KwuhrJZI2lZs4OPm + * 491Fy1EzjUBD1/CkMaq1wN9L3ysK7X4QDK4flqIQHmvQ+TeL3w0OAjX4WLxutVcO + * L+og5nOa5WuCcCW7UZp8neJQPc8eJD6SVc8qrQ2Ej6hDJM2tUGR0wnO24ZIcsiuM + * LXuWpkFhXBuPeChRQO1BkM4duCaBR2vjV0F0TiDwWhuXN5GGGcXybQTJeCtaFrz8 + * K3Fb0ABPAgMBAAECggEAYrLWY7Yr4iZaMSs3jDVg4gPOkwk++Mn+u6LIMg5sin4K + * whM7uCX67BmVjjRGzw575CWCGn8hSBZEWD812OvYGkVTD5uEilQTM+SXl/BIN/td + * T4yPNWPh2WJzHI7YzS4a5Uy1BVl63/Fo6xxcxhBEjH1CxXGK5xuqFwNqoMBrl1AX + * rW5e2dtvPuk/NcNFvOg9WrS5P1OAZNwSJDU1vZi7jfoZo16erHBK/I2uVYtxgQ5N + * yC+HsET3T9yoyFC1lSRjdBNUWN784HXr9AZYgxJMVsTEGAzqo+clo94ZI6JaKrZW + * BLxlunwK9JEQIog/nb5YQ0wurdvWMs+OtQVVOYvhAQKBgQDx2sKK5WZFihT8CG77 + * qlDSjLHE9Igm1LjEYzDK4wxsUNSTXBwTN2AhETvR8Z9MDXsOUz3JpPv6a560Cl3T + * UIjXvsOIsrGKbnvWcIiWpP6Q79GEraienzpoPz+CB77CRB7Voaka2znXfwxuNVsd + * MxupzTgqZNFwKv65wrbtWRlzsQKBgQDYuTo4bHnNCx8rNHS/ej0MIVqm6vKe3mhC + * BX/qpQDJEPj9xQWNA0VdT2/6bp3vrYrsg9TtV/OGcxUv0mdw0WLvHSUIWUcgYkcW + * NeFXOL853fy5yNgjU+ICfSIxTGZylt/YfAEscQCJGOmMCESMZB+Tm3qXJslQ0Iey + * SKgZceGz/wKBgCOY3TVwWkM19ay62Qr1oHu89ZVVoIyGlsNhDhdun695njAqSH+T + * kPSNAs79z0J0YX5URi3duLC9EljRhcnKerm2fDUsh/EmHdgMLC5wDn/qrF3o6X6f + * VQtu87wBw9P4DsnGx4sKZVMQghXeiJCdqx6s8+1ZdXIbAe75d88rZBGhAoGBAJ4p + * b4fGAo3VVAXf3mPu/aZgoRu30yCGB2hHQzcm/A/AxzXMF2T1wiV616nYGILWD9DT + * 1QzxZtP0IL4puzvmU2FVz7TsErBbiK143N8els/QZaPgI3yEtyhB0jZQH2P5H5uJ + * xAF+5nknKSn8zqn2V+UNTsYIlFraFG3UAHmxVppZAoGAbHMN/sciFV2MoZEr0Yjo + * kfnQPtC6xHSIzhQgTh5LxZGPwVbpdOD2z3GR7Sz1kJ3WyM31edxus4M++ta0YNk6 + * UhJ2nZL72ybuQzPEC4R0G5HgQYvMzCTaUq8tQucRVw2qZq8ausKOau6PLOZbdjiW + * u3ovWf7eoQL8EjqqnzwOpHg= + * -----END PRIVATE KEY----- * * client certificate: - * Data: - * Version: 3 (0x2) - * Serial Number: 9 (0x9) - * Signature Algorithm: md5WithRSAEncryption - * Issuer: C=US, ST=Some-State, L=Some-City, O=Some-Org - * Validity - * Not Before: Dec 8 03:43:24 2008 GMT - * Not After : Aug 25 03:43:24 2028 GMT - * Subject: C=US, ST=Some-State, L=Some-City, O=Some-Org, OU=SSL-Client, CN=localhost - * Subject Public Key Info: - * Public Key Algorithm: rsaEncryption - * RSA Public Key: (1024 bit) - * Modulus (1024 bit): - * 00:bb:f0:40:36:ac:26:54:4e:f4:a3:5a:00:2f:69: - * 21:6f:b9:7a:3a:93:ec:a2:f6:e1:8e:c7:63:d8:2f: - * 12:30:99:2e:b0:f2:8f:f8:27:2d:24:78:28:84:f7: - * 01:bf:8d:44:79:dd:3b:d2:55:f3:ce:3c:b2:5b:21: - * 7d:ef:fd:33:4a:b1:a3:ff:c6:c8:9b:b9:0f:7c:41: - * 35:97:f9:db:3a:05:60:05:15:af:59:17:92:a3:10: - * ad:16:1c:e4:07:53:af:a8:76:a2:56:2a:92:d3:f9: - * 28:e0:78:cf:5e:1f:48:ab:5c:19:dd:e1:67:43:ba: - * 75:8d:f5:82:ac:43:92:44:1b - * Exponent: 65537 (0x10001) - * X509v3 extensions: - * X509v3 Basic Constraints: - * CA:FALSE - * X509v3 Key Usage: - * Digital Signature, Non Repudiation, Key Encipherment - * X509v3 Subject Key Identifier: - * CD:BB:C8:85:AA:91:BD:FD:1D:BE:CD:67:7C:FF:B3:E9:4C:A8:22:E6 - * X509v3 Authority Key Identifier: - * keyid:FA:B9:51:BF:4C:E7:D9:86:98:33:F9:E7:CB:1E:F1:33:49:F7:A8:14 - * - * X509v3 Subject Alternative Name: critical - * DNS:localhost - * Signature Algorithm: md5WithRSAEncryption - * + * Data: + * Version: 3 (0x2) + * Serial Number: 1500699355 (0x5972dadb) + * Signature Algorithm: sha1WithRSAEncryption + * Issuer: C=Us, ST=Some-State, L=Some-City, O=Some-Org + * Validity + * Not Before: Jul 1 04:16:52 2024 GMT + * Not After : Jul 2 04:16:52 2034 GMT + * Subject: C=US, ST=Some-State, L=Some-City, O=Some-Org, CN=localhost ou=SSL-Client + * Subject Public Key Info: + * Public Key Algorithm: rsaEncryption + * Public-Key: (2048 bit) + * Modulus: + * 00:cc:bf:92:3c:a6:57:74:1f:58:ad:c7:69:88:6f: + * 59:32:47:50:60:22:e4:98:49:0e:3e:1d:b8:ba:e2: + * 3b:b6:71:5b:fd:64:02:6d:0d:50:77:72:6e:a8:3d: + * 5d:d4:bd:1f:76:51:dc:9a:d0:d6:3e:d0:31:a5:24: + * 5a:2c:be:77:fa:88:a1:fa:06:41:c8:0f:47:70:47: + * 24:99:50:52:44:5b:30:62:5b:65:35:c4:28:b0:5c: + * ee:d0:1b:eb:39:2b:0b:a1:ac:96:48:da:56:6c:e0: + * e3:e6:e3:dd:45:cb:51:33:8d:40:43:d7:f0:a4:31: + * aa:b5:c0:df:4b:df:2b:0a:ed:7e:10:0c:ae:1f:96: + * a2:10:1e:6b:d0:f9:37:8b:df:0d:0e:02:35:f8:58: + * bc:6e:b5:57:0e:2f:ea:20:e6:73:9a:e5:6b:82:70: + * 25:bb:51:9a:7c:9d:e2:50:3d:cf:1e:24:3e:92:55: + * cf:2a:ad:0d:84:8f:a8:43:24:cd:ad:50:64:74:c2: + * 73:b6:e1:92:1c:b2:2b:8c:2d:7b:96:a6:41:61:5c: + * 1b:8f:78:28:51:40:ed:41:90:ce:1d:b8:26:81:47: + * 6b:e3:57:41:74:4e:20:f0:5a:1b:97:37:91:86:19: + * c5:f2:6d:04:c9:78:2b:5a:16:bc:fc:2b:71:5b:d0: + * 00:4f + * Exponent: 65537 (0x10001) + * X509v3 extensions: + * X509v3 Subject Key Identifier: + * CD:45:E2:05:92:88:A3:C7:49:28:E7:D3:37:B7:13:92:FB:B1:36:C4 + * X509v3 Key Usage: + * Digital Signature, Non Repudiation, Key Encipherment + * X509v3 Subject Alternative Name: critical + * DNS:localhost + * X509v3 Basic Constraints: + * CA:FALSE + * X509v3 Authority Key Identifier: + * E0:03:90:F6:4F:BB:57:E6:7E:AF:5C:94:25:B3:85:DA:16:0A:51:40 + * Signature Algorithm: sha1WithRSAEncryption + * Signature Value: + * 23:6e:e9:5d:80:0d:b3:86:c9:cd:17:81:33:bd:5b:aa:c0:65: + * 4c:6b:9f:fa:ee:32:e9:89:e1:d0:c7:1d:5c:43:7e:94:ac:83: + * af:91:90:4c:26:61:8d:fe:6b:1a:aa:6e:61:39:b3:24:4a:dc: + * 92:c8:ca:f2:80:b0:05:41:0c:b3:dd:ed:b7:81:42:9a:1e:4e: + * f2:80:6c:72:62:8b:bd:d4:cd:23:7d:7c:e8:6f:e3:67:89:6a: + * 79:19:dd:f6:57:62:12:fa:eb:cd:66:c3:d2:d8:40:5a:1c:dd: + * 7f:9f:b2:34:e9:2a:d6:14:52:ba:6e:a8:9b:0d:a9:a1:03:bf: + * c4:0d:92:3d:59:e4:a9:8e:20:41:39:99:81:70:9d:d0:68:98: + * fc:5f:49:4a:92:e5:a2:c1:51:61:f6:1e:49:56:0b:b6:8c:57: + * db:08:2a:f0:a3:04:dc:a1:04:a2:5c:d0:90:4f:13:8d:1c:e6: + * 2e:7a:63:9c:32:40:65:59:04:5d:71:90:5a:a8:db:6a:30:42: + * 57:5b:0b:df:ce:a1:1f:fa:23:71:f3:57:12:c4:1c:66:3b:37: + * 77:32:28:a7:fb:ad:ee:86:51:4c:80:2f:dd:c8:5b:9f:a7:15: + * 07:fa:2b:5a:ee:93:00:5f:a6:43:22:1b:40:52:15:66:01:84: + * 32:9e:71:21 * -----BEGIN CERTIFICATE----- - * MIICpDCCAg2gAwIBAgIBCTANBgkqhkiG9w0BAQQFADBJMQswCQYDVQQGEwJVUzET - * MBEGA1UECBMKU29tZS1TdGF0ZTESMBAGA1UEBxMJU29tZS1DaXR5MREwDwYDVQQK - * EwhTb21lLU9yZzAeFw0wODEyMDgwMzQzMjRaFw0yODA4MjUwMzQzMjRaMHIxCzAJ - * BgNVBAYTAlVTMRMwEQYDVQQIEwpTb21lLVN0YXRlMRIwEAYDVQQHEwlTb21lLUNp - * dHkxETAPBgNVBAoTCFNvbWUtT3JnMRMwEQYDVQQLEwpTU0wtQ2xpZW50MRIwEAYD - * VQQDEwlsb2NhbGhvc3QwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBALvwQDas - * JlRO9KNaAC9pIW+5ejqT7KL24Y7HY9gvEjCZLrDyj/gnLSR4KIT3Ab+NRHndO9JV - * 8848slshfe/9M0qxo//GyJu5D3xBNZf52zoFYAUVr1kXkqMQrRYc5AdTr6h2olYq - * ktP5KOB4z14fSKtcGd3hZ0O6dY31gqxDkkQbAgMBAAGjczBxMAkGA1UdEwQCMAAw - * CwYDVR0PBAQDAgXgMB0GA1UdDgQWBBTNu8iFqpG9/R2+zWd8/7PpTKgi5jAfBgNV - * HSMEGDAWgBT6uVG/TOfZhpgz+efLHvEzSfeoFDAXBgNVHREBAf8EDTALgglsb2Nh - * bGhvc3QwDQYJKoZIhvcNAQEEBQADgYEAm25gJyqW1JznQ1EyOtTGswBVwfgBOf+F - * HJuBTcflYQLbTD/AETPQJGvZU9tdhuLtbG3OPhR7vSY8zeAbfM3dbH7QFr3r47Gj - * XEH7qM/MX+Z3ifVaC4MeJmrYQkYFSuKeyyKpdRVX4w4nnFHF6OsNASsYrMW6LpxN - * cl/epUcHL7E= + * MIIDpTCCAo2gAwIBAgIEWXLa2zANBgkqhkiG9w0BAQUFADBJMQswCQYDVQQGEwJV + * czETMBEGA1UECBMKU29tZS1TdGF0ZTESMBAGA1UEBxMJU29tZS1DaXR5MREwDwYD + * VQQKEwhTb21lLU9yZzAeFw0yNDA3MDEwNDE2NTJaFw0zNDA3MDIwNDE2NTJaMGsx + * CzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpTb21lLVN0YXRlMRIwEAYDVQQHEwlTb21l + * LUNpdHkxETAPBgNVBAoTCFNvbWUtT3JnMSAwHgYDVQQDExdsb2NhbGhvc3Qgb3U9 + * U1NMLUNsaWVudDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMy/kjym + * V3QfWK3HaYhvWTJHUGAi5JhJDj4duLriO7ZxW/1kAm0NUHdybqg9XdS9H3ZR3JrQ + * 1j7QMaUkWiy+d/qIofoGQcgPR3BHJJlQUkRbMGJbZTXEKLBc7tAb6zkrC6Gslkja + * Vmzg4+bj3UXLUTONQEPX8KQxqrXA30vfKwrtfhAMrh+WohAea9D5N4vfDQ4CNfhY + * vG61Vw4v6iDmc5rla4JwJbtRmnyd4lA9zx4kPpJVzyqtDYSPqEMkza1QZHTCc7bh + * khyyK4wte5amQWFcG494KFFA7UGQzh24JoFHa+NXQXROIPBaG5c3kYYZxfJtBMl4 + * K1oWvPwrcVvQAE8CAwEAAaNzMHEwHQYDVR0OBBYEFM1F4gWSiKPHSSjn0ze3E5L7 + * sTbEMAsGA1UdDwQEAwIF4DAXBgNVHREBAf8EDTALgglsb2NhbGhvc3QwCQYDVR0T + * BAIwADAfBgNVHSMEGDAWgBTgA5D2T7tX5n6vXJQls4XaFgpRQDANBgkqhkiG9w0B + * AQUFAAOCAQEAI27pXYANs4bJzReBM71bqsBlTGuf+u4y6Ynh0McdXEN+lKyDr5GQ + * TCZhjf5rGqpuYTmzJErcksjK8oCwBUEMs93tt4FCmh5O8oBscmKLvdTNI3186G/j + * Z4lqeRnd9ldiEvrrzWbD0thAWhzdf5+yNOkq1hRSum6omw2poQO/xA2SPVnkqY4g + * QTmZgXCd0GiY/F9JSpLlosFRYfYeSVYLtoxX2wgq8KME3KEEolzQkE8TjRzmLnpj + * nDJAZVkEXXGQWqjbajBCV1sL386hH/ojcfNXEsQcZjs3dzIop/ut7oZRTIAv3chb + * n6cVB/orWu6TAF+mQyIbQFIVZgGEMp5xIQ== * -----END CERTIFICATE----- * * - * * Trusted CA certificate: * Certificate: * Data: - * Version: 3 (0x2) - * Serial Number: 0 (0x0) - * Signature Algorithm: md5WithRSAEncryption - * Issuer: C=US, ST=Some-State, L=Some-City, O=Some-Org - * Validity - * Not Before: Dec 8 02:43:36 2008 GMT - * Not After : Aug 25 02:43:36 2028 GMT - * Subject: C=US, ST=Some-State, L=Some-City, O=Some-Org - * Subject Public Key Info: - * Public Key Algorithm: rsaEncryption - * RSA Public Key: (1024 bit) - * Modulus (1024 bit): - * 00:cb:c4:38:20:07:be:88:a7:93:b0:a1:43:51:2d: - * d7:8e:85:af:54:dd:ad:a2:7b:23:5b:cf:99:13:53: - * 99:45:7d:ee:6d:ba:2d:bf:e3:ad:6e:3d:9f:1a:f9: - * 03:97:e0:17:55:ae:11:26:57:de:01:29:8e:05:3f: - * 21:f7:e7:36:e8:2e:37:d7:48:ac:53:d6:60:0e:c7: - * 50:6d:f6:c5:85:f7:8b:a6:c5:91:35:72:3c:94:ee: - * f1:17:f0:71:e3:ec:1b:ce:ca:4e:40:42:b0:6d:ee: - * 6a:0e:d6:e5:ad:3c:0f:c9:ba:82:4f:78:f8:89:97: - * 89:2a:95:12:4c:d8:09:2a:e9 - * Exponent: 65537 (0x10001) - * X509v3 extensions: - * X509v3 Subject Key Identifier: - * FA:B9:51:BF:4C:E7:D9:86:98:33:F9:E7:CB:1E:F1:33:49:F7:A8:14 - * X509v3 Authority Key Identifier: - * keyid:FA:B9:51:BF:4C:E7:D9:86:98:33:F9:E7:CB:1E:F1:33:49:F7:A8:14 - * DirName:/C=US/ST=Some-State/L=Some-City/O=Some-Org - * serial:00 - * - * X509v3 Basic Constraints: - * CA:TRUE - * Signature Algorithm: md5WithRSAEncryption - * + * Version: 3 (0x2) + * Serial Number: 1539881479 (0x5bc8ba07) + * Signature Algorithm: sha1WithRSAEncryption + * Issuer: C=Us, ST=Some-State, L=Some-City, O=Some-Org + * Validity + * Not Before: Jul 1 04:16:50 2024 GMT + * Not After : Jul 2 04:16:50 2034 GMT + * Subject: C=Us, ST=Some-State, L=Some-City, O=Some-Org + * Subject Public Key Info: + * Public Key Algorithm: rsaEncryption + * Public-Key: (2048 bit) + * Modulus: + * 00:bc:a6:55:60:3f:17:74:39:ba:71:8c:ef:11:3f: + * 9d:36:47:d5:02:d1:4d:9d:7e:b8:fe:59:b1:2b:f1: + * b7:b0:0c:31:57:eb:9c:9d:13:f5:4c:5f:fc:c4:9e: + * f9:75:09:0f:96:8f:05:77:30:a8:35:48:71:96:e4: + * a5:7d:1a:81:fb:e6:bf:90:80:60:5d:11:20:54:16: + * 0b:6d:df:64:de:18:d5:98:51:38:9d:c9:d6:5f:de: + * 9d:de:fe:a8:5f:d3:25:3d:ad:f3:2b:45:c8:4a:80: + * 97:14:7b:85:9d:cf:59:08:bb:c7:67:ac:8b:29:f3: + * 1e:93:bf:fb:82:53:c5:ae:b4:bc:55:30:15:a8:7e: + * 3f:82:22:59:43:cc:d2:62:e7:65:67:72:ec:10:8a: + * fc:05:90:91:72:dd:e9:6f:e2:9f:0c:ab:a1:83:55: + * 02:23:b7:a3:c3:50:ab:be:0b:bb:51:75:50:d1:a8: + * c9:e5:f5:06:fe:00:09:a6:1b:8a:16:29:0d:ab:00: + * 3e:bc:d2:73:d9:37:d7:d9:9a:58:6e:2d:2a:f6:76: + * ae:f4:ea:6d:70:de:7f:e3:04:43:c0:4f:91:3f:78: + * 58:d7:c2:ad:74:eb:04:9d:d0:7e:82:b8:7a:97:44: + * 61:fa:41:45:a6:ca:7d:a5:2e:fc:f9:a6:cf:61:cd: + * 75:bf + * Exponent: 65537 (0x10001) + * X509v3 extensions: + * X509v3 Subject Key Identifier: + * E0:03:90:F6:4F:BB:57:E6:7E:AF:5C:94:25:B3:85:DA:16:0A:51:40 + * X509v3 Basic Constraints: critical + * CA:TRUE + * Signature Algorithm: sha1WithRSAEncryption + * Signature Value: + * 1f:89:34:e3:ee:05:33:3b:18:ca:96:13:3d:ad:cd:5a:e6:24: + * 46:94:36:ad:37:a5:36:a9:92:37:f9:ed:07:dd:44:5b:c9:2e: + * 68:f7:82:f3:58:1c:64:ed:64:d0:ad:eb:30:15:e0:04:3a:d7: + * c8:c7:9d:65:76:ae:84:e4:2e:2d:0d:68:09:0d:e5:ae:cc:a7: + * 54:86:ad:ff:00:95:85:01:49:db:5b:8e:c2:6f:e7:19:10:17: + * f7:03:b9:a8:97:21:a2:fc:7f:c0:e0:7a:12:64:b8:70:f5:e8: + * b6:e1:25:f7:eb:32:3e:46:ce:43:55:fc:0b:62:59:90:61:63: + * f9:94:6c:95:63:31:1b:00:59:1f:72:9d:d0:0b:4f:cd:02:eb: + * de:20:4e:60:48:4e:ea:ad:3c:0f:1d:bf:1a:69:3d:a8:3d:8b: + * f5:a2:ae:8c:4f:d7:0e:b3:e1:9b:b3:2c:89:19:18:da:db:e1: + * 6d:d5:ab:c8:b8:48:57:d8:8b:33:01:d4:97:91:d9:da:34:a1: + * ef:36:00:e1:38:19:34:8f:0d:47:af:57:cf:59:d6:8b:0d:9e: + * 89:05:82:3d:3c:f3:45:1d:4a:3f:0e:0f:5a:28:6f:5c:e1:e9: + * 60:72:87:28:b6:97:44:8b:d7:c6:cd:cb:dc:5a:5d:60:f1:b4: + * 37:ee:44:db * -----BEGIN CERTIFICATE----- - * MIICrDCCAhWgAwIBAgIBADANBgkqhkiG9w0BAQQFADBJMQswCQYDVQQGEwJVUzET - * MBEGA1UECBMKU29tZS1TdGF0ZTESMBAGA1UEBxMJU29tZS1DaXR5MREwDwYDVQQK - * EwhTb21lLU9yZzAeFw0wODEyMDgwMjQzMzZaFw0yODA4MjUwMjQzMzZaMEkxCzAJ - * BgNVBAYTAlVTMRMwEQYDVQQIEwpTb21lLVN0YXRlMRIwEAYDVQQHEwlTb21lLUNp - * dHkxETAPBgNVBAoTCFNvbWUtT3JnMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKB - * gQDLxDggB76Ip5OwoUNRLdeOha9U3a2ieyNbz5kTU5lFfe5tui2/461uPZ8a+QOX - * 4BdVrhEmV94BKY4FPyH35zboLjfXSKxT1mAOx1Bt9sWF94umxZE1cjyU7vEX8HHj - * 7BvOyk5AQrBt7moO1uWtPA/JuoJPePiJl4kqlRJM2Akq6QIDAQABo4GjMIGgMB0G - * A1UdDgQWBBT6uVG/TOfZhpgz+efLHvEzSfeoFDBxBgNVHSMEajBogBT6uVG/TOfZ - * hpgz+efLHvEzSfeoFKFNpEswSTELMAkGA1UEBhMCVVMxEzARBgNVBAgTClNvbWUt - * U3RhdGUxEjAQBgNVBAcTCVNvbWUtQ2l0eTERMA8GA1UEChMIU29tZS1PcmeCAQAw - * DAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQQFAAOBgQBcIm534U123Hz+rtyYO5uA - * ofd81G6FnTfEAV8Kw9fGyyEbQZclBv34A9JsFKeMvU4OFIaixD7nLZ/NZ+IWbhmZ - * LovmJXyCkOufea73pNiZ+f/4/ScZaIlM/PRycQSqbFNd4j9Wott+08qxHPLpsf3P - * 6Mvf0r1PNTY2hwTJLJmKtg== + * MIIDQjCCAiqgAwIBAgIEW8i6BzANBgkqhkiG9w0BAQUFADBJMQswCQYDVQQGEwJV + * czETMBEGA1UECBMKU29tZS1TdGF0ZTESMBAGA1UEBxMJU29tZS1DaXR5MREwDwYD + * VQQKEwhTb21lLU9yZzAeFw0yNDA3MDEwNDE2NTBaFw0zNDA3MDIwNDE2NTBaMEkx + * CzAJBgNVBAYTAlVzMRMwEQYDVQQIEwpTb21lLVN0YXRlMRIwEAYDVQQHEwlTb21l + * LUNpdHkxETAPBgNVBAoTCFNvbWUtT3JnMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A + * MIIBCgKCAQEAvKZVYD8XdDm6cYzvET+dNkfVAtFNnX64/lmxK/G3sAwxV+ucnRP1 + * TF/8xJ75dQkPlo8FdzCoNUhxluSlfRqB++a/kIBgXREgVBYLbd9k3hjVmFE4ncnW + * X96d3v6oX9MlPa3zK0XISoCXFHuFnc9ZCLvHZ6yLKfMek7/7glPFrrS8VTAVqH4/ + * giJZQ8zSYudlZ3LsEIr8BZCRct3pb+KfDKuhg1UCI7ejw1Crvgu7UXVQ0ajJ5fUG + * /gAJphuKFikNqwA+vNJz2TfX2ZpYbi0q9nau9OptcN5/4wRDwE+RP3hY18KtdOsE + * ndB+grh6l0Rh+kFFpsp9pS78+abPYc11vwIDAQABozIwMDAdBgNVHQ4EFgQU4AOQ + * 9k+7V+Z+r1yUJbOF2hYKUUAwDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQUF + * AAOCAQEAH4k04+4FMzsYypYTPa3NWuYkRpQ2rTelNqmSN/ntB91EW8kuaPeC81gc + * ZO1k0K3rMBXgBDrXyMedZXauhOQuLQ1oCQ3lrsynVIat/wCVhQFJ21uOwm/nGRAX + * 9wO5qJchovx/wOB6EmS4cPXotuEl9+syPkbOQ1X8C2JZkGFj+ZRslWMxGwBZH3Kd + * 0AtPzQLr3iBOYEhO6q08Dx2/Gmk9qD2L9aKujE/XDrPhm7MsiRkY2tvhbdWryLhI + * V9iLMwHUl5HZ2jSh7zYA4TgZNI8NR69Xz1nWiw2eiQWCPTzzRR1KPw4PWihvXOHp + * YHKHKLaXRIvXxs3L3FpdYPG0N+5E2w== * -----END CERTIFICATE--- */ - public class SunX509ExtendedTM { /* @@ -423,201 +563,342 @@ public class SunX509ExtendedTM { */ static String trusedCertStr = "-----BEGIN CERTIFICATE-----\n" + - "MIICrDCCAhWgAwIBAgIBADANBgkqhkiG9w0BAQQFADBJMQswCQYDVQQGEwJVUzET\n" + - "MBEGA1UECBMKU29tZS1TdGF0ZTESMBAGA1UEBxMJU29tZS1DaXR5MREwDwYDVQQK\n" + - "EwhTb21lLU9yZzAeFw0wODEyMDgwMjQzMzZaFw0yODA4MjUwMjQzMzZaMEkxCzAJ\n" + - "BgNVBAYTAlVTMRMwEQYDVQQIEwpTb21lLVN0YXRlMRIwEAYDVQQHEwlTb21lLUNp\n" + - "dHkxETAPBgNVBAoTCFNvbWUtT3JnMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKB\n" + - "gQDLxDggB76Ip5OwoUNRLdeOha9U3a2ieyNbz5kTU5lFfe5tui2/461uPZ8a+QOX\n" + - "4BdVrhEmV94BKY4FPyH35zboLjfXSKxT1mAOx1Bt9sWF94umxZE1cjyU7vEX8HHj\n" + - "7BvOyk5AQrBt7moO1uWtPA/JuoJPePiJl4kqlRJM2Akq6QIDAQABo4GjMIGgMB0G\n" + - "A1UdDgQWBBT6uVG/TOfZhpgz+efLHvEzSfeoFDBxBgNVHSMEajBogBT6uVG/TOfZ\n" + - "hpgz+efLHvEzSfeoFKFNpEswSTELMAkGA1UEBhMCVVMxEzARBgNVBAgTClNvbWUt\n" + - "U3RhdGUxEjAQBgNVBAcTCVNvbWUtQ2l0eTERMA8GA1UEChMIU29tZS1PcmeCAQAw\n" + - "DAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQQFAAOBgQBcIm534U123Hz+rtyYO5uA\n" + - "ofd81G6FnTfEAV8Kw9fGyyEbQZclBv34A9JsFKeMvU4OFIaixD7nLZ/NZ+IWbhmZ\n" + - "LovmJXyCkOufea73pNiZ+f/4/ScZaIlM/PRycQSqbFNd4j9Wott+08qxHPLpsf3P\n" + - "6Mvf0r1PNTY2hwTJLJmKtg==\n" + + "MIIDQjCCAiqgAwIBAgIEW8i6BzANBgkqhkiG9w0BAQUFADBJMQswCQYDVQQGEwJV\n" + + "czETMBEGA1UECBMKU29tZS1TdGF0ZTESMBAGA1UEBxMJU29tZS1DaXR5MREwDwYD\n" + + "VQQKEwhTb21lLU9yZzAeFw0yNDA3MDEwNDE2NTBaFw0zNDA3MDIwNDE2NTBaMEkx\n" + + "CzAJBgNVBAYTAlVzMRMwEQYDVQQIEwpTb21lLVN0YXRlMRIwEAYDVQQHEwlTb21l\n" + + "LUNpdHkxETAPBgNVBAoTCFNvbWUtT3JnMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8A\n" + + "MIIBCgKCAQEAvKZVYD8XdDm6cYzvET+dNkfVAtFNnX64/lmxK/G3sAwxV+ucnRP1\n" + + "TF/8xJ75dQkPlo8FdzCoNUhxluSlfRqB++a/kIBgXREgVBYLbd9k3hjVmFE4ncnW\n" + + "X96d3v6oX9MlPa3zK0XISoCXFHuFnc9ZCLvHZ6yLKfMek7/7glPFrrS8VTAVqH4/\n" + + "giJZQ8zSYudlZ3LsEIr8BZCRct3pb+KfDKuhg1UCI7ejw1Crvgu7UXVQ0ajJ5fUG\n" + + "/gAJphuKFikNqwA+vNJz2TfX2ZpYbi0q9nau9OptcN5/4wRDwE+RP3hY18KtdOsE\n" + + "ndB+grh6l0Rh+kFFpsp9pS78+abPYc11vwIDAQABozIwMDAdBgNVHQ4EFgQU4AOQ\n" + + "9k+7V+Z+r1yUJbOF2hYKUUAwDwYDVR0TAQH/BAUwAwEB/zANBgkqhkiG9w0BAQUF\n" + + "AAOCAQEAH4k04+4FMzsYypYTPa3NWuYkRpQ2rTelNqmSN/ntB91EW8kuaPeC81gc\n" + + "ZO1k0K3rMBXgBDrXyMedZXauhOQuLQ1oCQ3lrsynVIat/wCVhQFJ21uOwm/nGRAX\n" + + "9wO5qJchovx/wOB6EmS4cPXotuEl9+syPkbOQ1X8C2JZkGFj+ZRslWMxGwBZH3Kd\n" + + "0AtPzQLr3iBOYEhO6q08Dx2/Gmk9qD2L9aKujE/XDrPhm7MsiRkY2tvhbdWryLhI\n" + + "V9iLMwHUl5HZ2jSh7zYA4TgZNI8NR69Xz1nWiw2eiQWCPTzzRR1KPw4PWihvXOHp\n" + + "YHKHKLaXRIvXxs3L3FpdYPG0N+5E2w==\n" + "-----END CERTIFICATE-----"; static String serverCertStr = "-----BEGIN CERTIFICATE-----\n" + - "MIICpDCCAg2gAwIBAgIBCDANBgkqhkiG9w0BAQQFADBJMQswCQYDVQQGEwJVUzET\n" + - "MBEGA1UECBMKU29tZS1TdGF0ZTESMBAGA1UEBxMJU29tZS1DaXR5MREwDwYDVQQK\n" + - "EwhTb21lLU9yZzAeFw0wODEyMDgwMzQzMDRaFw0yODA4MjUwMzQzMDRaMHIxCzAJ\n" + - "BgNVBAYTAlVTMRMwEQYDVQQIEwpTb21lLVN0YXRlMRIwEAYDVQQHEwlTb21lLUNp\n" + - "dHkxETAPBgNVBAoTCFNvbWUtT3JnMRMwEQYDVQQLEwpTU0wtU2VydmVyMRIwEAYD\n" + - "VQQDEwlsb2NhbGhvc3QwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAKWsWxw3\n" + - "ot2ZiS2yebiP1Uil5xyEF41pnMasbfnyHR85GdrTch5u7ETMcKTcugAw9qBPPVR6\n" + - "YWrMV9AKf5UoGD+a2ZTyG8gkiH7+nQ89+1dTCLMgM9Q/F0cU0c3qCNgOdU6vvszS\n" + - "7K+peknfwtmsuCRAkKYDVirQMAVALE+r2XSJAgMBAAGjczBxMAkGA1UdEwQCMAAw\n" + - "CwYDVR0PBAQDAgXgMB0GA1UdDgQWBBTtbtv0tVbI+xoGYT8PCLumBNgWVDAfBgNV\n" + - "HSMEGDAWgBT6uVG/TOfZhpgz+efLHvEzSfeoFDAXBgNVHREBAf8EDTALgglsb2Nh\n" + - "bGhvc3QwDQYJKoZIhvcNAQEEBQADgYEAoqVTciHtcvsUj+YaTct8tUh3aTCsKsac\n" + - "PHhfQ+ObjiXSgxsKYTX7ym/wk/wvlbUcbqLKxsu7qrcJitH+H9heV1hEHEu65Uoi\n" + - "nRugFruyOrwvAylV8Cm2af7ddilmYJ+sdJA6N2M3xJRxR0G2LFHEXDNEjYReyexn\n" + - "JqCpf5uZGOo=\n" + + "MIIDpTCCAo2gAwIBAgIEBlY/nzANBgkqhkiG9w0BAQUFADBJMQswCQYDVQQGEwJV\n" + + "czETMBEGA1UECBMKU29tZS1TdGF0ZTESMBAGA1UEBxMJU29tZS1DaXR5MREwDwYD\n" + + "VQQKEwhTb21lLU9yZzAeFw0yNDA3MDEwNDE2NTVaFw0zNDA3MDIwNDE2NTVaMGsx\n" + + "CzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpTb21lLVN0YXRlMRIwEAYDVQQHEwlTb21l\n" + + "LUNpdHkxETAPBgNVBAoTCFNvbWUtT3JnMSAwHgYDVQQDExdsb2NhbGhvc3Qgb3U9\n" + + "U1NMLVNlcnZlcjCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAJoM4I+o\n" + + "An5a7+2yQq0ITpG6wq2bedebD/3S+BUvGYmAEAACGW0nwpDXpSNTdG5kKHwkqu3q\n" + + "IVnco1y1yUIxT6Le+wl8c+2IBDTxFa09YM3KxROZ05+bspJwy7pLPSCWrb6SU+1U\n" + + "O8UUvc/UD8sFT/0rnuBQu2UTksDWvU0CDHC2ZdR9tE3D3ywIntI+aTJGb2/K0XOk\n" + + "lAfvFOPani/ArA4QM0xoefN5QNbpPMLmcOCJzqB6qIQohTI3CLDPsX9fvB+lPe/W\n" + + "aKgXIV+H1Uu1zO54jd2xKGrA+2S9t3ACMwMLuLi7CIL2jgUn0TvmxaxNhVuhHaNI\n" + + "XQMVdmNscSE+mM0CAwEAAaNzMHEwHQYDVR0OBBYEFFyvRLFIuFmaZFOdLqayCdMK\n" + + "kgSDMAsGA1UdDwQEAwIF4DAXBgNVHREBAf8EDTALgglsb2NhbGhvc3QwCQYDVR0T\n" + + "BAIwADAfBgNVHSMEGDAWgBTgA5D2T7tX5n6vXJQls4XaFgpRQDANBgkqhkiG9w0B\n" + + "AQUFAAOCAQEAnSJJX1Yj5oA1zKtEHCe9yY2Jk0lY6MF6aN3PveASdgZUzS9im1SE\n" + + "8ruQoLs34hMd899BquD+wO9GeI2q9BtwrakWJPoVSsYKjeGZkwCp1LYIXY5lA9zQ\n" + + "lfyVYaattatNpuAFSIzbQkKK1l7AKqARFbgHaVw/maC9U2XbTs9GYZMJe4FA/1z+\n" + + "TOv0rN4fOK2yYCj2Dp9G5wePIJqk4Y+rVJl2gtiecMTamIVxrztU5AG0noPQe8aN\n" + + "H+0lCIkF6YeXdlqjhcP4Wde7O1rby+1d/6whuZriZQq83tHcU5SYRJeRsxtrgAub\n" + + "V7OuXHw1yjlx906PStfrCyXash4XSLjrCQ==\n" + "-----END CERTIFICATE-----"; static String clientCertStr = "-----BEGIN CERTIFICATE-----\n" + - "MIICpDCCAg2gAwIBAgIBCTANBgkqhkiG9w0BAQQFADBJMQswCQYDVQQGEwJVUzET\n" + - "MBEGA1UECBMKU29tZS1TdGF0ZTESMBAGA1UEBxMJU29tZS1DaXR5MREwDwYDVQQK\n" + - "EwhTb21lLU9yZzAeFw0wODEyMDgwMzQzMjRaFw0yODA4MjUwMzQzMjRaMHIxCzAJ\n" + - "BgNVBAYTAlVTMRMwEQYDVQQIEwpTb21lLVN0YXRlMRIwEAYDVQQHEwlTb21lLUNp\n" + - "dHkxETAPBgNVBAoTCFNvbWUtT3JnMRMwEQYDVQQLEwpTU0wtQ2xpZW50MRIwEAYD\n" + - "VQQDEwlsb2NhbGhvc3QwgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBALvwQDas\n" + - "JlRO9KNaAC9pIW+5ejqT7KL24Y7HY9gvEjCZLrDyj/gnLSR4KIT3Ab+NRHndO9JV\n" + - "8848slshfe/9M0qxo//GyJu5D3xBNZf52zoFYAUVr1kXkqMQrRYc5AdTr6h2olYq\n" + - "ktP5KOB4z14fSKtcGd3hZ0O6dY31gqxDkkQbAgMBAAGjczBxMAkGA1UdEwQCMAAw\n" + - "CwYDVR0PBAQDAgXgMB0GA1UdDgQWBBTNu8iFqpG9/R2+zWd8/7PpTKgi5jAfBgNV\n" + - "HSMEGDAWgBT6uVG/TOfZhpgz+efLHvEzSfeoFDAXBgNVHREBAf8EDTALgglsb2Nh\n" + - "bGhvc3QwDQYJKoZIhvcNAQEEBQADgYEAm25gJyqW1JznQ1EyOtTGswBVwfgBOf+F\n" + - "HJuBTcflYQLbTD/AETPQJGvZU9tdhuLtbG3OPhR7vSY8zeAbfM3dbH7QFr3r47Gj\n" + - "XEH7qM/MX+Z3ifVaC4MeJmrYQkYFSuKeyyKpdRVX4w4nnFHF6OsNASsYrMW6LpxN\n" + - "cl/epUcHL7E=\n" + + "MIIDpTCCAo2gAwIBAgIEWXLa2zANBgkqhkiG9w0BAQUFADBJMQswCQYDVQQGEwJV\n" + + "czETMBEGA1UECBMKU29tZS1TdGF0ZTESMBAGA1UEBxMJU29tZS1DaXR5MREwDwYD\n" + + "VQQKEwhTb21lLU9yZzAeFw0yNDA3MDEwNDE2NTJaFw0zNDA3MDIwNDE2NTJaMGsx\n" + + "CzAJBgNVBAYTAlVTMRMwEQYDVQQIEwpTb21lLVN0YXRlMRIwEAYDVQQHEwlTb21l\n" + + "LUNpdHkxETAPBgNVBAoTCFNvbWUtT3JnMSAwHgYDVQQDExdsb2NhbGhvc3Qgb3U9\n" + + "U1NMLUNsaWVudDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMy/kjym\n" + + "V3QfWK3HaYhvWTJHUGAi5JhJDj4duLriO7ZxW/1kAm0NUHdybqg9XdS9H3ZR3JrQ\n" + + "1j7QMaUkWiy+d/qIofoGQcgPR3BHJJlQUkRbMGJbZTXEKLBc7tAb6zkrC6Gslkja\n" + + "Vmzg4+bj3UXLUTONQEPX8KQxqrXA30vfKwrtfhAMrh+WohAea9D5N4vfDQ4CNfhY\n" + + "vG61Vw4v6iDmc5rla4JwJbtRmnyd4lA9zx4kPpJVzyqtDYSPqEMkza1QZHTCc7bh\n" + + "khyyK4wte5amQWFcG494KFFA7UGQzh24JoFHa+NXQXROIPBaG5c3kYYZxfJtBMl4\n" + + "K1oWvPwrcVvQAE8CAwEAAaNzMHEwHQYDVR0OBBYEFM1F4gWSiKPHSSjn0ze3E5L7\n" + + "sTbEMAsGA1UdDwQEAwIF4DAXBgNVHREBAf8EDTALgglsb2NhbGhvc3QwCQYDVR0T\n" + + "BAIwADAfBgNVHSMEGDAWgBTgA5D2T7tX5n6vXJQls4XaFgpRQDANBgkqhkiG9w0B\n" + + "AQUFAAOCAQEAI27pXYANs4bJzReBM71bqsBlTGuf+u4y6Ynh0McdXEN+lKyDr5GQ\n" + + "TCZhjf5rGqpuYTmzJErcksjK8oCwBUEMs93tt4FCmh5O8oBscmKLvdTNI3186G/j\n" + + "Z4lqeRnd9ldiEvrrzWbD0thAWhzdf5+yNOkq1hRSum6omw2poQO/xA2SPVnkqY4g\n" + + "QTmZgXCd0GiY/F9JSpLlosFRYfYeSVYLtoxX2wgq8KME3KEEolzQkE8TjRzmLnpj\n" + + "nDJAZVkEXXGQWqjbajBCV1sL386hH/ojcfNXEsQcZjs3dzIop/ut7oZRTIAv3chb\n" + + "n6cVB/orWu6TAF+mQyIbQFIVZgGEMp5xIQ==\n" + "-----END CERTIFICATE-----"; static byte serverPrivateExponent[] = { - (byte)0x6e, (byte)0xa7, (byte)0x1b, (byte)0x83, - (byte)0x51, (byte)0x35, (byte)0x9a, (byte)0x44, - (byte)0x7d, (byte)0xf6, (byte)0xe3, (byte)0x89, - (byte)0xa0, (byte)0xd7, (byte)0x90, (byte)0x60, - (byte)0xa1, (byte)0x4e, (byte)0x27, (byte)0x21, - (byte)0xa2, (byte)0x89, (byte)0x74, (byte)0xcc, - (byte)0x9d, (byte)0x75, (byte)0x75, (byte)0x4e, - (byte)0xc7, (byte)0x82, (byte)0xe3, (byte)0xe3, - (byte)0xc3, (byte)0x7d, (byte)0x00, (byte)0x54, - (byte)0xec, (byte)0x36, (byte)0xb1, (byte)0xdf, - (byte)0x91, (byte)0x9c, (byte)0x7a, (byte)0xc0, - (byte)0x62, (byte)0x0a, (byte)0xd6, (byte)0xa9, - (byte)0x22, (byte)0x91, (byte)0x4a, (byte)0x29, - (byte)0x2e, (byte)0x43, (byte)0xfa, (byte)0x8c, - (byte)0xd8, (byte)0xe9, (byte)0xbe, (byte)0xd9, - (byte)0x4f, (byte)0xca, (byte)0x23, (byte)0xc6, - (byte)0xe4, (byte)0x3f, (byte)0xb8, (byte)0x72, - (byte)0xcf, (byte)0x02, (byte)0xfc, (byte)0xf4, - (byte)0x58, (byte)0x34, (byte)0x77, (byte)0x76, - (byte)0xce, (byte)0x22, (byte)0x44, (byte)0x5f, - (byte)0x2d, (byte)0xca, (byte)0xee, (byte)0xf5, - (byte)0x43, (byte)0x56, (byte)0x47, (byte)0x71, - (byte)0x0b, (byte)0x09, (byte)0x6b, (byte)0x5e, - (byte)0xf2, (byte)0xc8, (byte)0xee, (byte)0xd4, - (byte)0x6e, (byte)0x44, (byte)0x92, (byte)0x2a, - (byte)0x7f, (byte)0xcc, (byte)0xa7, (byte)0xd4, - (byte)0x5b, (byte)0xfb, (byte)0xf7, (byte)0x4a, - (byte)0xa9, (byte)0xfb, (byte)0x54, (byte)0x18, - (byte)0xd5, (byte)0xd5, (byte)0x14, (byte)0xba, - (byte)0xa0, (byte)0x1c, (byte)0x13, (byte)0xb3, - (byte)0x37, (byte)0x6b, (byte)0x37, (byte)0x59, - (byte)0xed, (byte)0xdb, (byte)0x6d, (byte)0xb1 + (byte)0x68, (byte)0x87, (byte)0x36, (byte)0x54, + (byte)0xa3, (byte)0xc6, (byte)0xd5, (byte)0x5f, + (byte)0xf5, (byte)0x0f, (byte)0x4f, (byte)0x76, + (byte)0xc8, (byte)0x9c, (byte)0x2b, (byte)0x5b, + (byte)0xdc, (byte)0xe2, (byte)0xbe, (byte)0x14, + (byte)0x12, (byte)0x2f, (byte)0xc7, (byte)0x0a, + (byte)0xa9, (byte)0xcb, (byte)0x5e, (byte)0x04, + (byte)0x59, (byte)0xca, (byte)0x35, (byte)0x2f, + (byte)0x8d, (byte)0x2b, (byte)0xc4, (byte)0x40, + (byte)0xe6, (byte)0x7d, (byte)0x25, (byte)0x1b, + (byte)0x4d, (byte)0x07, (byte)0xc3, (byte)0x99, + (byte)0x9c, (byte)0x16, (byte)0x4f, (byte)0xa5, + (byte)0xdc, (byte)0xde, (byte)0xb0, (byte)0x90, + (byte)0xf0, (byte)0xde, (byte)0x22, (byte)0x70, + (byte)0x80, (byte)0xf4, (byte)0xa6, (byte)0x70, + (byte)0xe2, (byte)0x96, (byte)0x3d, (byte)0x18, + (byte)0x21, (byte)0xbf, (byte)0x2b, (byte)0x27, + (byte)0xa4, (byte)0x2d, (byte)0xd7, (byte)0xae, + (byte)0x2b, (byte)0x12, (byte)0x2f, (byte)0x08, + (byte)0x36, (byte)0xee, (byte)0x99, (byte)0x94, + (byte)0xed, (byte)0xf6, (byte)0xa7, (byte)0xd9, + (byte)0x1d, (byte)0xa2, (byte)0xf3, (byte)0x1f, + (byte)0x44, (byte)0xa4, (byte)0x28, (byte)0x4b, + (byte)0x67, (byte)0x35, (byte)0xd6, (byte)0xa8, + (byte)0x1b, (byte)0xf8, (byte)0x84, (byte)0x34, + (byte)0x34, (byte)0x84, (byte)0xbd, (byte)0xec, + (byte)0x9e, (byte)0x03, (byte)0x08, (byte)0x3c, + (byte)0x93, (byte)0x20, (byte)0x8e, (byte)0xaf, + (byte)0x15, (byte)0xcb, (byte)0x1f, (byte)0x20, + (byte)0x08, (byte)0x97, (byte)0xc4, (byte)0x19, + (byte)0x3e, (byte)0xfa, (byte)0x36, (byte)0xc6, + (byte)0xab, (byte)0x0e, (byte)0x2f, (byte)0xe7, + (byte)0xb3, (byte)0xc0, (byte)0xa7, (byte)0xbc, + (byte)0xe4, (byte)0xe0, (byte)0xa6, (byte)0x08, + (byte)0x1c, (byte)0x69, (byte)0x20, (byte)0x4d, + (byte)0x78, (byte)0xbd, (byte)0x7a, (byte)0xe5, + (byte)0x25, (byte)0x48, (byte)0x60, (byte)0x9e, + (byte)0x2e, (byte)0x50, (byte)0x8d, (byte)0x36, + (byte)0x1e, (byte)0x07, (byte)0xe9, (byte)0xd5, + (byte)0x0d, (byte)0x39, (byte)0x67, (byte)0x41, + (byte)0x42, (byte)0x24, (byte)0xdb, (byte)0x87, + (byte)0xe5, (byte)0x77, (byte)0x76, (byte)0xfd, + (byte)0x5e, (byte)0xd5, (byte)0xc6, (byte)0xe5, + (byte)0xd3, (byte)0xb0, (byte)0x98, (byte)0x71, + (byte)0x48, (byte)0x69, (byte)0x47, (byte)0x4f, + (byte)0x46, (byte)0x05, (byte)0x0c, (byte)0x9e, + (byte)0x58, (byte)0x45, (byte)0x2e, (byte)0xe2, + (byte)0x27, (byte)0xd0, (byte)0xf6, (byte)0x11, + (byte)0x05, (byte)0x78, (byte)0xad, (byte)0x83, + (byte)0x5a, (byte)0x5b, (byte)0xec, (byte)0xd7, + (byte)0x2e, (byte)0x26, (byte)0x5a, (byte)0xa5, + (byte)0x4f, (byte)0x9e, (byte)0x52, (byte)0x84, + (byte)0x2c, (byte)0x1f, (byte)0x59, (byte)0x1a, + (byte)0x78, (byte)0x56, (byte)0x0a, (byte)0x44, + (byte)0x54, (byte)0xc6, (byte)0x37, (byte)0x64, + (byte)0x01, (byte)0xca, (byte)0xe4, (byte)0xa8, + (byte)0x01, (byte)0xc7, (byte)0x86, (byte)0xc1, + (byte)0xb4, (byte)0xd6, (byte)0x6c, (byte)0x7a, + (byte)0x15, (byte)0x9a, (byte)0x65, (byte)0x69, + (byte)0x46, (byte)0x9e, (byte)0xfd, (byte)0xf6, + (byte)0x08, (byte)0x17, (byte)0x0c, (byte)0x6c, + (byte)0xac, (byte)0x38, (byte)0xbd, (byte)0xc2, + (byte)0xcd, (byte)0xda, (byte)0xef, (byte)0x54, + (byte)0x7a, (byte)0x48, (byte)0x92, (byte)0x4d }; static byte serverModulus[] = { - (byte)0x00, - (byte)0xa5, (byte)0xac, (byte)0x5b, (byte)0x1c, - (byte)0x37, (byte)0xa2, (byte)0xdd, (byte)0x99, - (byte)0x89, (byte)0x2d, (byte)0xb2, (byte)0x79, - (byte)0xb8, (byte)0x8f, (byte)0xd5, (byte)0x48, - (byte)0xa5, (byte)0xe7, (byte)0x1c, (byte)0x84, - (byte)0x17, (byte)0x8d, (byte)0x69, (byte)0x9c, - (byte)0xc6, (byte)0xac, (byte)0x6d, (byte)0xf9, - (byte)0xf2, (byte)0x1d, (byte)0x1f, (byte)0x39, - (byte)0x19, (byte)0xda, (byte)0xd3, (byte)0x72, - (byte)0x1e, (byte)0x6e, (byte)0xec, (byte)0x44, - (byte)0xcc, (byte)0x70, (byte)0xa4, (byte)0xdc, - (byte)0xba, (byte)0x00, (byte)0x30, (byte)0xf6, - (byte)0xa0, (byte)0x4f, (byte)0x3d, (byte)0x54, - (byte)0x7a, (byte)0x61, (byte)0x6a, (byte)0xcc, - (byte)0x57, (byte)0xd0, (byte)0x0a, (byte)0x7f, - (byte)0x95, (byte)0x28, (byte)0x18, (byte)0x3f, - (byte)0x9a, (byte)0xd9, (byte)0x94, (byte)0xf2, - (byte)0x1b, (byte)0xc8, (byte)0x24, (byte)0x88, - (byte)0x7e, (byte)0xfe, (byte)0x9d, (byte)0x0f, - (byte)0x3d, (byte)0xfb, (byte)0x57, (byte)0x53, - (byte)0x08, (byte)0xb3, (byte)0x20, (byte)0x33, - (byte)0xd4, (byte)0x3f, (byte)0x17, (byte)0x47, - (byte)0x14, (byte)0xd1, (byte)0xcd, (byte)0xea, - (byte)0x08, (byte)0xd8, (byte)0x0e, (byte)0x75, - (byte)0x4e, (byte)0xaf, (byte)0xbe, (byte)0xcc, - (byte)0xd2, (byte)0xec, (byte)0xaf, (byte)0xa9, - (byte)0x7a, (byte)0x49, (byte)0xdf, (byte)0xc2, - (byte)0xd9, (byte)0xac, (byte)0xb8, (byte)0x24, - (byte)0x40, (byte)0x90, (byte)0xa6, (byte)0x03, - (byte)0x56, (byte)0x2a, (byte)0xd0, (byte)0x30, - (byte)0x05, (byte)0x40, (byte)0x2c, (byte)0x4f, - (byte)0xab, (byte)0xd9, (byte)0x74, (byte)0x89 + (byte)0x00, (byte)0x9a, (byte)0x0c, (byte)0xe0, + (byte)0x8f, (byte)0xa8, (byte)0x02, (byte)0x7e, + (byte)0x5a, (byte)0xef, (byte)0xed, (byte)0xb2, + (byte)0x42, (byte)0xad, (byte)0x08, (byte)0x4e, + (byte)0x91, (byte)0xba, (byte)0xc2, (byte)0xad, + (byte)0x9b, (byte)0x79, (byte)0xd7, (byte)0x9b, + (byte)0x0f, (byte)0xfd, (byte)0xd2, (byte)0xf8, + (byte)0x15, (byte)0x2f, (byte)0x19, (byte)0x89, + (byte)0x80, (byte)0x10, (byte)0x00, (byte)0x02, + (byte)0x19, (byte)0x6d, (byte)0x27, (byte)0xc2, + (byte)0x90, (byte)0xd7, (byte)0xa5, (byte)0x23, + (byte)0x53, (byte)0x74, (byte)0x6e, (byte)0x64, + (byte)0x28, (byte)0x7c, (byte)0x24, (byte)0xaa, + (byte)0xed, (byte)0xea, (byte)0x21, (byte)0x59, + (byte)0xdc, (byte)0xa3, (byte)0x5c, (byte)0xb5, + (byte)0xc9, (byte)0x42, (byte)0x31, (byte)0x4f, + (byte)0xa2, (byte)0xde, (byte)0xfb, (byte)0x09, + (byte)0x7c, (byte)0x73, (byte)0xed, (byte)0x88, + (byte)0x04, (byte)0x34, (byte)0xf1, (byte)0x15, + (byte)0xad, (byte)0x3d, (byte)0x60, (byte)0xcd, + (byte)0xca, (byte)0xc5, (byte)0x13, (byte)0x99, + (byte)0xd3, (byte)0x9f, (byte)0x9b, (byte)0xb2, + (byte)0x92, (byte)0x70, (byte)0xcb, (byte)0xba, + (byte)0x4b, (byte)0x3d, (byte)0x20, (byte)0x96, + (byte)0xad, (byte)0xbe, (byte)0x92, (byte)0x53, + (byte)0xed, (byte)0x54, (byte)0x3b, (byte)0xc5, + (byte)0x14, (byte)0xbd, (byte)0xcf, (byte)0xd4, + (byte)0x0f, (byte)0xcb, (byte)0x05, (byte)0x4f, + (byte)0xfd, (byte)0x2b, (byte)0x9e, (byte)0xe0, + (byte)0x50, (byte)0xbb, (byte)0x65, (byte)0x13, + (byte)0x92, (byte)0xc0, (byte)0xd6, (byte)0xbd, + (byte)0x4d, (byte)0x02, (byte)0x0c, (byte)0x70, + (byte)0xb6, (byte)0x65, (byte)0xd4, (byte)0x7d, + (byte)0xb4, (byte)0x4d, (byte)0xc3, (byte)0xdf, + (byte)0x2c, (byte)0x08, (byte)0x9e, (byte)0xd2, + (byte)0x3e, (byte)0x69, (byte)0x32, (byte)0x46, + (byte)0x6f, (byte)0x6f, (byte)0xca, (byte)0xd1, + (byte)0x73, (byte)0xa4, (byte)0x94, (byte)0x07, + (byte)0xef, (byte)0x14, (byte)0xe3, (byte)0xda, + (byte)0x9e, (byte)0x2f, (byte)0xc0, (byte)0xac, + (byte)0x0e, (byte)0x10, (byte)0x33, (byte)0x4c, + (byte)0x68, (byte)0x79, (byte)0xf3, (byte)0x79, + (byte)0x40, (byte)0xd6, (byte)0xe9, (byte)0x3c, + (byte)0xc2, (byte)0xe6, (byte)0x70, (byte)0xe0, + (byte)0x89, (byte)0xce, (byte)0xa0, (byte)0x7a, + (byte)0xa8, (byte)0x84, (byte)0x28, (byte)0x85, + (byte)0x32, (byte)0x37, (byte)0x08, (byte)0xb0, + (byte)0xcf, (byte)0xb1, (byte)0x7f, (byte)0x5f, + (byte)0xbc, (byte)0x1f, (byte)0xa5, (byte)0x3d, + (byte)0xef, (byte)0xd6, (byte)0x68, (byte)0xa8, + (byte)0x17, (byte)0x21, (byte)0x5f, (byte)0x87, + (byte)0xd5, (byte)0x4b, (byte)0xb5, (byte)0xcc, + (byte)0xee, (byte)0x78, (byte)0x8d, (byte)0xdd, + (byte)0xb1, (byte)0x28, (byte)0x6a, (byte)0xc0, + (byte)0xfb, (byte)0x64, (byte)0xbd, (byte)0xb7, + (byte)0x70, (byte)0x02, (byte)0x33, (byte)0x03, + (byte)0x0b, (byte)0xb8, (byte)0xb8, (byte)0xbb, + (byte)0x08, (byte)0x82, (byte)0xf6, (byte)0x8e, + (byte)0x05, (byte)0x27, (byte)0xd1, (byte)0x3b, + (byte)0xe6, (byte)0xc5, (byte)0xac, (byte)0x4d, + (byte)0x85, (byte)0x5b, (byte)0xa1, (byte)0x1d, + (byte)0xa3, (byte)0x48, (byte)0x5d, (byte)0x03, + (byte)0x15, (byte)0x76, (byte)0x63, (byte)0x6c, + (byte)0x71, (byte)0x21, (byte)0x3e, (byte)0x98, + (byte)0xcd }; static byte clientPrivateExponent[] = { - (byte)0x11, (byte)0xb7, (byte)0x6a, (byte)0x36, - (byte)0x3d, (byte)0x30, (byte)0x37, (byte)0xce, - (byte)0x61, (byte)0x9d, (byte)0x6c, (byte)0x84, - (byte)0x8b, (byte)0xf3, (byte)0x9b, (byte)0x25, - (byte)0x4f, (byte)0x14, (byte)0xc8, (byte)0xa4, - (byte)0xdd, (byte)0x2f, (byte)0xd7, (byte)0x9a, - (byte)0x17, (byte)0xbd, (byte)0x90, (byte)0x19, - (byte)0xf7, (byte)0x05, (byte)0xfd, (byte)0xf2, - (byte)0xd2, (byte)0xc5, (byte)0xf7, (byte)0x77, - (byte)0xbe, (byte)0xea, (byte)0xe2, (byte)0x84, - (byte)0x87, (byte)0x97, (byte)0x3a, (byte)0x41, - (byte)0x96, (byte)0xb6, (byte)0x99, (byte)0xf8, - (byte)0x94, (byte)0x8c, (byte)0x58, (byte)0x71, - (byte)0x51, (byte)0x8c, (byte)0xf4, (byte)0x2a, - (byte)0x20, (byte)0x9e, (byte)0x1a, (byte)0xa0, - (byte)0x26, (byte)0x99, (byte)0x75, (byte)0xd6, - (byte)0x31, (byte)0x53, (byte)0x43, (byte)0x39, - (byte)0xf5, (byte)0x2a, (byte)0xa6, (byte)0x7e, - (byte)0x34, (byte)0x42, (byte)0x51, (byte)0x2a, - (byte)0x40, (byte)0x87, (byte)0x03, (byte)0x88, - (byte)0x43, (byte)0x69, (byte)0xb2, (byte)0x89, - (byte)0x6d, (byte)0x20, (byte)0xbd, (byte)0x7d, - (byte)0x71, (byte)0xef, (byte)0x47, (byte)0x0a, - (byte)0xdf, (byte)0x06, (byte)0xc1, (byte)0x69, - (byte)0x66, (byte)0xa8, (byte)0x22, (byte)0x37, - (byte)0x1a, (byte)0x77, (byte)0x1e, (byte)0xc7, - (byte)0x94, (byte)0x4e, (byte)0x2c, (byte)0x27, - (byte)0x69, (byte)0x45, (byte)0x5e, (byte)0xc8, - (byte)0xf8, (byte)0x0c, (byte)0xb7, (byte)0xf8, - (byte)0xc0, (byte)0x8f, (byte)0x99, (byte)0xc1, - (byte)0xe5, (byte)0x28, (byte)0x9b, (byte)0xf9, - (byte)0x4c, (byte)0x94, (byte)0xc6, (byte)0xb1 + (byte)0x62, (byte)0xb2, (byte)0xd6, (byte)0x63, + (byte)0xb6, (byte)0x2b, (byte)0xe2, (byte)0x26, + (byte)0x5a, (byte)0x31, (byte)0x2b, (byte)0x37, + (byte)0x8c, (byte)0x35, (byte)0x60, (byte)0xe2, + (byte)0x03, (byte)0xce, (byte)0x93, (byte)0x09, + (byte)0x3e, (byte)0xf8, (byte)0xc9, (byte)0xfe, + (byte)0xbb, (byte)0xa2, (byte)0xc8, (byte)0x32, + (byte)0x0e, (byte)0x6c, (byte)0x8a, (byte)0x7e, + (byte)0x0a, (byte)0xc2, (byte)0x13, (byte)0x3b, + (byte)0xb8, (byte)0x25, (byte)0xfa, (byte)0xec, + (byte)0x19, (byte)0x95, (byte)0x8e, (byte)0x34, + (byte)0x46, (byte)0xcf, (byte)0x0e, (byte)0x7b, + (byte)0xe4, (byte)0x25, (byte)0x82, (byte)0x1a, + (byte)0x7f, (byte)0x21, (byte)0x48, (byte)0x16, + (byte)0x44, (byte)0x58, (byte)0x3f, (byte)0x35, + (byte)0xd8, (byte)0xeb, (byte)0xd8, (byte)0x1a, + (byte)0x45, (byte)0x53, (byte)0x0f, (byte)0x9b, + (byte)0x84, (byte)0x8a, (byte)0x54, (byte)0x13, + (byte)0x33, (byte)0xe4, (byte)0x97, (byte)0x97, + (byte)0xf0, (byte)0x48, (byte)0x37, (byte)0xfb, + (byte)0x5d, (byte)0x4f, (byte)0x8c, (byte)0x8f, + (byte)0x35, (byte)0x63, (byte)0xe1, (byte)0xd9, + (byte)0x62, (byte)0x73, (byte)0x1c, (byte)0x8e, + (byte)0xd8, (byte)0xcd, (byte)0x2e, (byte)0x1a, + (byte)0xe5, (byte)0x4c, (byte)0xb5, (byte)0x05, + (byte)0x59, (byte)0x7a, (byte)0xdf, (byte)0xf1, + (byte)0x68, (byte)0xeb, (byte)0x1c, (byte)0x5c, + (byte)0xc6, (byte)0x10, (byte)0x44, (byte)0x8c, + (byte)0x7d, (byte)0x42, (byte)0xc5, (byte)0x71, + (byte)0x8a, (byte)0xe7, (byte)0x1b, (byte)0xaa, + (byte)0x17, (byte)0x03, (byte)0x6a, (byte)0xa0, + (byte)0xc0, (byte)0x6b, (byte)0x97, (byte)0x50, + (byte)0x17, (byte)0xad, (byte)0x6e, (byte)0x5e, + (byte)0xd9, (byte)0xdb, (byte)0x6f, (byte)0x3e, + (byte)0xe9, (byte)0x3f, (byte)0x35, (byte)0xc3, + (byte)0x45, (byte)0xbc, (byte)0xe8, (byte)0x3d, + (byte)0x5a, (byte)0xb4, (byte)0xb9, (byte)0x3f, + (byte)0x53, (byte)0x80, (byte)0x64, (byte)0xdc, + (byte)0x12, (byte)0x24, (byte)0x35, (byte)0x35, + (byte)0xbd, (byte)0x98, (byte)0xbb, (byte)0x8d, + (byte)0xfa, (byte)0x19, (byte)0xa3, (byte)0x5e, + (byte)0x9e, (byte)0xac, (byte)0x70, (byte)0x4a, + (byte)0xfc, (byte)0x8d, (byte)0xae, (byte)0x55, + (byte)0x8b, (byte)0x71, (byte)0x81, (byte)0x0e, + (byte)0x4d, (byte)0xc8, (byte)0x2f, (byte)0x87, + (byte)0xb0, (byte)0x44, (byte)0xf7, (byte)0x4f, + (byte)0xdc, (byte)0xa8, (byte)0xc8, (byte)0x50, + (byte)0xb5, (byte)0x95, (byte)0x24, (byte)0x63, + (byte)0x74, (byte)0x13, (byte)0x54, (byte)0x58, + (byte)0xde, (byte)0xfc, (byte)0xe0, (byte)0x75, + (byte)0xeb, (byte)0xf4, (byte)0x06, (byte)0x58, + (byte)0x83, (byte)0x12, (byte)0x4c, (byte)0x56, + (byte)0xc4, (byte)0xc4, (byte)0x18, (byte)0x0c, + (byte)0xea, (byte)0xa3, (byte)0xe7, (byte)0x25, + (byte)0xa3, (byte)0xde, (byte)0x19, (byte)0x23, + (byte)0xa2, (byte)0x5a, (byte)0x2a, (byte)0xb6, + (byte)0x56, (byte)0x04, (byte)0xbc, (byte)0x65, + (byte)0xba, (byte)0x7c, (byte)0x0a, (byte)0xf4, + (byte)0x91, (byte)0x10, (byte)0x22, (byte)0x88, + (byte)0x3f, (byte)0x9d, (byte)0xbe, (byte)0x58, + (byte)0x43, (byte)0x4c, (byte)0x2e, (byte)0xad, + (byte)0xdb, (byte)0xd6, (byte)0x32, (byte)0xcf, + (byte)0x8e, (byte)0xb5, (byte)0x05, (byte)0x55, + (byte)0x39, (byte)0x8b, (byte)0xe1, (byte)0x01 }; static byte clientModulus[] = { - (byte)0x00, - (byte)0xbb, (byte)0xf0, (byte)0x40, (byte)0x36, - (byte)0xac, (byte)0x26, (byte)0x54, (byte)0x4e, - (byte)0xf4, (byte)0xa3, (byte)0x5a, (byte)0x00, - (byte)0x2f, (byte)0x69, (byte)0x21, (byte)0x6f, - (byte)0xb9, (byte)0x7a, (byte)0x3a, (byte)0x93, - (byte)0xec, (byte)0xa2, (byte)0xf6, (byte)0xe1, - (byte)0x8e, (byte)0xc7, (byte)0x63, (byte)0xd8, - (byte)0x2f, (byte)0x12, (byte)0x30, (byte)0x99, - (byte)0x2e, (byte)0xb0, (byte)0xf2, (byte)0x8f, - (byte)0xf8, (byte)0x27, (byte)0x2d, (byte)0x24, - (byte)0x78, (byte)0x28, (byte)0x84, (byte)0xf7, - (byte)0x01, (byte)0xbf, (byte)0x8d, (byte)0x44, - (byte)0x79, (byte)0xdd, (byte)0x3b, (byte)0xd2, - (byte)0x55, (byte)0xf3, (byte)0xce, (byte)0x3c, - (byte)0xb2, (byte)0x5b, (byte)0x21, (byte)0x7d, - (byte)0xef, (byte)0xfd, (byte)0x33, (byte)0x4a, - (byte)0xb1, (byte)0xa3, (byte)0xff, (byte)0xc6, - (byte)0xc8, (byte)0x9b, (byte)0xb9, (byte)0x0f, - (byte)0x7c, (byte)0x41, (byte)0x35, (byte)0x97, - (byte)0xf9, (byte)0xdb, (byte)0x3a, (byte)0x05, - (byte)0x60, (byte)0x05, (byte)0x15, (byte)0xaf, - (byte)0x59, (byte)0x17, (byte)0x92, (byte)0xa3, - (byte)0x10, (byte)0xad, (byte)0x16, (byte)0x1c, - (byte)0xe4, (byte)0x07, (byte)0x53, (byte)0xaf, - (byte)0xa8, (byte)0x76, (byte)0xa2, (byte)0x56, - (byte)0x2a, (byte)0x92, (byte)0xd3, (byte)0xf9, - (byte)0x28, (byte)0xe0, (byte)0x78, (byte)0xcf, - (byte)0x5e, (byte)0x1f, (byte)0x48, (byte)0xab, - (byte)0x5c, (byte)0x19, (byte)0xdd, (byte)0xe1, - (byte)0x67, (byte)0x43, (byte)0xba, (byte)0x75, - (byte)0x8d, (byte)0xf5, (byte)0x82, (byte)0xac, - (byte)0x43, (byte)0x92, (byte)0x44, (byte)0x1b + (byte)0x00, (byte)0xcc, (byte)0xbf, (byte)0x92, + (byte)0x3c, (byte)0xa6, (byte)0x57, (byte)0x74, + (byte)0x1f, (byte)0x58, (byte)0xad, (byte)0xc7, + (byte)0x69, (byte)0x88, (byte)0x6f, (byte)0x59, + (byte)0x32, (byte)0x47, (byte)0x50, (byte)0x60, + (byte)0x22, (byte)0xe4, (byte)0x98, (byte)0x49, + (byte)0x0e, (byte)0x3e, (byte)0x1d, (byte)0xb8, + (byte)0xba, (byte)0xe2, (byte)0x3b, (byte)0xb6, + (byte)0x71, (byte)0x5b, (byte)0xfd, (byte)0x64, + (byte)0x02, (byte)0x6d, (byte)0x0d, (byte)0x50, + (byte)0x77, (byte)0x72, (byte)0x6e, (byte)0xa8, + (byte)0x3d, (byte)0x5d, (byte)0xd4, (byte)0xbd, + (byte)0x1f, (byte)0x76, (byte)0x51, (byte)0xdc, + (byte)0x9a, (byte)0xd0, (byte)0xd6, (byte)0x3e, + (byte)0xd0, (byte)0x31, (byte)0xa5, (byte)0x24, + (byte)0x5a, (byte)0x2c, (byte)0xbe, (byte)0x77, + (byte)0xfa, (byte)0x88, (byte)0xa1, (byte)0xfa, + (byte)0x06, (byte)0x41, (byte)0xc8, (byte)0x0f, + (byte)0x47, (byte)0x70, (byte)0x47, (byte)0x24, + (byte)0x99, (byte)0x50, (byte)0x52, (byte)0x44, + (byte)0x5b, (byte)0x30, (byte)0x62, (byte)0x5b, + (byte)0x65, (byte)0x35, (byte)0xc4, (byte)0x28, + (byte)0xb0, (byte)0x5c, (byte)0xee, (byte)0xd0, + (byte)0x1b, (byte)0xeb, (byte)0x39, (byte)0x2b, + (byte)0x0b, (byte)0xa1, (byte)0xac, (byte)0x96, + (byte)0x48, (byte)0xda, (byte)0x56, (byte)0x6c, + (byte)0xe0, (byte)0xe3, (byte)0xe6, (byte)0xe3, + (byte)0xdd, (byte)0x45, (byte)0xcb, (byte)0x51, + (byte)0x33, (byte)0x8d, (byte)0x40, (byte)0x43, + (byte)0xd7, (byte)0xf0, (byte)0xa4, (byte)0x31, + (byte)0xaa, (byte)0xb5, (byte)0xc0, (byte)0xdf, + (byte)0x4b, (byte)0xdf, (byte)0x2b, (byte)0x0a, + (byte)0xed, (byte)0x7e, (byte)0x10, (byte)0x0c, + (byte)0xae, (byte)0x1f, (byte)0x96, (byte)0xa2, + (byte)0x10, (byte)0x1e, (byte)0x6b, (byte)0xd0, + (byte)0xf9, (byte)0x37, (byte)0x8b, (byte)0xdf, + (byte)0x0d, (byte)0x0e, (byte)0x02, (byte)0x35, + (byte)0xf8, (byte)0x58, (byte)0xbc, (byte)0x6e, + (byte)0xb5, (byte)0x57, (byte)0x0e, (byte)0x2f, + (byte)0xea, (byte)0x20, (byte)0xe6, (byte)0x73, + (byte)0x9a, (byte)0xe5, (byte)0x6b, (byte)0x82, + (byte)0x70, (byte)0x25, (byte)0xbb, (byte)0x51, + (byte)0x9a, (byte)0x7c, (byte)0x9d, (byte)0xe2, + (byte)0x50, (byte)0x3d, (byte)0xcf, (byte)0x1e, + (byte)0x24, (byte)0x3e, (byte)0x92, (byte)0x55, + (byte)0xcf, (byte)0x2a, (byte)0xad, (byte)0x0d, + (byte)0x84, (byte)0x8f, (byte)0xa8, (byte)0x43, + (byte)0x24, (byte)0xcd, (byte)0xad, (byte)0x50, + (byte)0x64, (byte)0x74, (byte)0xc2, (byte)0x73, + (byte)0xb6, (byte)0xe1, (byte)0x92, (byte)0x1c, + (byte)0xb2, (byte)0x2b, (byte)0x8c, (byte)0x2d, + (byte)0x7b, (byte)0x96, (byte)0xa6, (byte)0x41, + (byte)0x61, (byte)0x5c, (byte)0x1b, (byte)0x8f, + (byte)0x78, (byte)0x28, (byte)0x51, (byte)0x40, + (byte)0xed, (byte)0x41, (byte)0x90, (byte)0xce, + (byte)0x1d, (byte)0xb8, (byte)0x26, (byte)0x81, + (byte)0x47, (byte)0x6b, (byte)0xe3, (byte)0x57, + (byte)0x41, (byte)0x74, (byte)0x4e, (byte)0x20, + (byte)0xf0, (byte)0x5a, (byte)0x1b, (byte)0x97, + (byte)0x37, (byte)0x91, (byte)0x86, (byte)0x19, + (byte)0xc5, (byte)0xf2, (byte)0x6d, (byte)0x04, + (byte)0xc9, (byte)0x78, (byte)0x2b, (byte)0x5a, + (byte)0x16, (byte)0xbc, (byte)0xfc, (byte)0x2b, + (byte)0x71, (byte)0x5b, (byte)0xd0, (byte)0x00, + (byte)0x4f }; static char passphrase[] = "passphrase".toCharArray(); @@ -795,11 +1076,11 @@ private static SSLContext getSSLContext(String trusedCertStr, volatile Exception clientException = null; public static void main(String args[]) throws Exception { - // MD5 is used in this test case, don't disable MD5 algorithm. + // SHA1 is used in this test case, don't disable SHA1 algorithm. Security.setProperty("jdk.certpath.disabledAlgorithms", - "MD2, RSA keySize < 1024"); + "MD2, MD5, RSA keySize < 1024"); Security.setProperty("jdk.tls.disabledAlgorithms", - "SSLv3, RC4, DH keySize < 768"); + "SSLv3, RC4, MD5withRSA, DH keySize < 768"); if (debug) System.setProperty("javax.net.debug", "all"); diff --git a/test/jdk/sun/security/x509/AlgorithmId/NonStandardNames.java b/test/jdk/sun/security/x509/AlgorithmId/NonStandardNames.java index a8098561d4e..f12e5717682 100644 --- a/test/jdk/sun/security/x509/AlgorithmId/NonStandardNames.java +++ b/test/jdk/sun/security/x509/AlgorithmId/NonStandardNames.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,6 +24,7 @@ /* * @test * @bug 7180907 8277224 + * @library /test/lib * @summary Jarsigner -verify fails if rsa file used sha-256 with authenticated attributes * @modules java.base/sun.security.pkcs * java.base/sun.security.tools.keytool @@ -36,6 +37,7 @@ import java.security.MessageDigest; import java.security.Signature; import java.security.cert.X509Certificate; +import jdk.test.lib.security.SecurityUtils; import sun.security.pkcs.ContentInfo; import sun.security.pkcs.PKCS7; import sun.security.pkcs.PKCS9Attribute; @@ -52,8 +54,9 @@ public static void main(String[] args) throws Exception { byte[] data = "Hello".getBytes(); X500Name n = new X500Name("cn=Me"); - CertAndKeyGen cakg = new CertAndKeyGen("RSA", "SHA256withRSA"); - cakg.generate(1024); + String kpgAlgorithm = "RSA"; + CertAndKeyGen cakg = new CertAndKeyGen(kpgAlgorithm, "SHA256withRSA"); + cakg.generate(SecurityUtils.getTestKeySize(kpgAlgorithm)); X509Certificate cert = cakg.getSelfCertificate(n, 1000); MessageDigest md = MessageDigest.getInstance("SHA-256"); diff --git a/test/jdk/sun/security/x509/X509CRLImpl/UnexpectedCCE.java b/test/jdk/sun/security/x509/X509CRLImpl/UnexpectedCCE.java new file mode 100644 index 00000000000..85acf520b43 --- /dev/null +++ b/test/jdk/sun/security/x509/X509CRLImpl/UnexpectedCCE.java @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8336665 + * @summary Verify that generateCRLs method does not throw ClassCastException. + * It should throw CRLException instead. + * @library /test/lib + */ +import java.security.NoSuchProviderException; +import java.security.cert.*; +import java.io.ByteArrayInputStream; +import java.util.Base64; + +import jdk.test.lib.Utils; + +public class UnexpectedCCE { + static CertificateFactory cf = null; + + public static void main(String[] av ) throws CertificateException, + NoSuchProviderException { + + // Fuzzed data input stream looks like an x509.OIDName + // in the CertificateIssuerExtension. A CRLException is thrown + // because an X500Name is expected. + byte[] encoded_1 = Base64.getDecoder().decode(""" + MIIBljCCAVMCAQEwCwYHKoZIzjgEAwUAMC0xEzARBgoJkiaJk/IsZAEZEwNjb20xFjA\ + UBgoJkiaJjvIsZAEZEwZ0ZXN0Q0EXDTAzMDcxNTE2MjAwNVoXDTAzMDcyMDE2MjAwNV\ + owgdIwUwIBBBcNMDMwNzE1MTYyMDAzWjA/MD0GA1UdHQEB/wQzMDGILzETMBEGCgmSJ\ + omT8ixkARkMA2NvbTEYMBYGCgmSJomT8ixkARkTCGNlcnRzUlVTMBICAQMXDTAzMDcx\ + NTE2MjAwNFowUwIBAhcNMDMwNzE1MTYyMDA0WjA/MD0GA1UdIQEB/wQzMDEwGAYDVQQ\ + DExEwDyqGMDEUMgAwgDAuRQA1MRYGCgmSJomT8ixkARkTCG15VGVzdENBMBICAQEXDT\ + AzMDcxNTE2MjAwNFqgHzAdMA8GA1UdHAEB/wQFMAOEAf8wCgYDVR0UAwACAQIwCwYHK\ + oZIzjgEAwUAAzAAMC0CFBaZDryEEOr8Cw7sOAAAAKaDgtHcAhUAkUenJpwYZgS6IPjy\ + AjZG+RfHdO4="""); + + // Fuzzed data input stream looks like an x509.X400Address + // in the CertificateIssuerExtension. A CRLException is thrown + // because an X500Name is expected. + byte[] encoded_2 = Base64.getDecoder().decode(""" + MIIBljCCAVMCAQEwCwYHKoZIzjgEAwUAMC0xEzARBgoJkiaJk/IsZAEZEwNjb20xFjA\ + UBgoJkiaJk/IsZAEZEwZ0ZXN0J0EXDTAzMDcxNTE2MjAwNVoXDTAzMDcyMDE2MjAwNV\ + owgdIwUwIBBBcNMDMwNzE1MTYyMDA0WjA/MD0GA1UdHQEB/wQzMDGkLzETMBEGCgmSJ\ + omT8ixkARkTA2NvbTEYMBYGCgmSJomT8ixkARkTCGNlcnRzUlVTMBICAQMXDTAzMDcx\ + NTE2MjAwNFowUwIBAhcNMDMwNzE1MTYyMDA0WjA/MD0GA1UdHQEB/wQzMDGjLzETMBE\ + GCgmSJomT8ixkARkTA2NvGG0wMRYGCgmSJomT8ixkARkTCG15VGVzdENBMBICAQEXDT\ + AzMDcxNTE2MjAwNVqgHzAdMGAGA1UdHAEB/wQFMAOEAf8wCgYDVR0UBAMCAQIwCwYHK\ + oZIzjgEAwUAAzAAMC0CFBaZDryEEOr8Cw7sJa07gqaDgtHcAhUAkUenJpwYZgS6IPjy\ + AjZG+RfHdO4="""); + + cf = CertificateFactory.getInstance("X.509", "SUN"); + + run(encoded_1); + run(encoded_2); + } + + private static void run(byte[] buf) { + Utils.runAndCheckException( + () -> cf.generateCRLs(new ByteArrayInputStream(buf)), + CRLException.class); + } +} diff --git a/test/jdk/sun/security/x509/X509CRLImpl/Verify.java b/test/jdk/sun/security/x509/X509CRLImpl/Verify.java index ed92b6548ec..911f53f5120 100644 --- a/test/jdk/sun/security/x509/X509CRLImpl/Verify.java +++ b/test/jdk/sun/security/x509/X509CRLImpl/Verify.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,45 +35,61 @@ public class Verify { static String selfSignedCertStr = "-----BEGIN CERTIFICATE-----\n" + - "MIICPjCCAaegAwIBAgIBADANBgkqhkiG9w0BAQQFADAfMQswCQYDVQQGEwJVUzEQ\n" + - "MA4GA1UEChMHRXhhbXBsZTAeFw0wOTA0MjcwMjI0MzJaFw0zMDA0MDcwMjI0MzJa\n" + - "MB8xCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFtcGxlMIGfMA0GCSqGSIb3DQEB\n" + - "AQUAA4GNADCBiQKBgQC4OTag24sTxL2tXTNuvpmUEtdxrYAZoFsslFQ60T+WD9wQ\n" + - "Jeiw87FSPsR2vxRuv0j8DNm2a4h7LNNIFcLurfNldbz5pvgZ7VqdbbUMPE9qP85n\n" + - "jgDl4woyRTSUeRI4A7O0CO6NpES21dtbdhroWQrEkHxpnrDPxsxrz5gf2m3gqwID\n" + - "AQABo4GJMIGGMB0GA1UdDgQWBBSCJd0hpl5PdAD9IZS+Hzng4lXLGzBHBgNVHSME\n" + - "QDA+gBSCJd0hpl5PdAD9IZS+Hzng4lXLG6EjpCEwHzELMAkGA1UEBhMCVVMxEDAO\n" + - "BgNVBAoTB0V4YW1wbGWCAQAwDwYDVR0TAQH/BAUwAwEB/zALBgNVHQ8EBAMCAgQw\n" + - "DQYJKoZIhvcNAQEEBQADgYEAluy6HIjWcq009lTLmhp+Np6dxU78pInBK8RZkza0\n" + - "484qGaxFGD3UGyZkI5uWmsH2XuMbuox5khfIq6781gmkPBHXBIEtJN8eLusOHEye\n" + - "iE8h7WI+N3qa6Pj56WionMrioqC/3X+b06o147bbhx8U0vkYv/HyPaITOFfMXTdz\n" + - "Vjw=\n" + + "MIIDVzCCAj+gAwIBAgIUUM/RKxE2Rcc6zYLWLxNolpLnuiwwDQYJKoZIhvcNAQEL\n" + + "BQAwOzENMAsGA1UEAwwEUk9PVDEQMA4GA1UECgwHRXhhbXBsZTELMAkGA1UECAwC\n" + + "Q0ExCzAJBgNVBAYTAlVTMB4XDTI0MDYxOTA0NDc1N1oXDTM0MDYxOTA0NDc1N1ow\n" + + "OzENMAsGA1UEAwwEUk9PVDEQMA4GA1UECgwHRXhhbXBsZTELMAkGA1UECAwCQ0Ex\n" + + "CzAJBgNVBAYTAlVTMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAohRG\n" + + "eq8/CniUqWEtpm1gBp+PWENpYgeaALAUgFdBBa6ao7mESjxRG8teaNRcszmoL3Rl\n" + + "TH5hLycHA00G5qsALXo4Cj9wAGfR3LbA0HlTurdw3NNk76twQXZpuE19YNYQonbR\n" + + "Mm2sgTd2YcrNWmGpthgNiUaT837Yt7RCuurPo4zi1y6g/NJwyLtn775S86NrV5PT\n" + + "4vaBCsB5+eCm01CBgzBq3I0OY5oosopNUjmFL4LYccZZ2YAOUY0fvxfsMZD5EDcj\n" + + "KrgKBspjmolfn5g5lA5vdVthG2/TxTIdLss69+NsGS1RBkSKGiQNKnRnAB9/gHwc\n" + + "2ryHKJRMQrV+JGMjrQIDAQABo1MwUTAdBgNVHQ4EFgQUW6jZ+mcCEMAQTUzJH2F0\n" + + "TwMTOMswHwYDVR0jBBgwFoAUW6jZ+mcCEMAQTUzJH2F0TwMTOMswDwYDVR0TAQH/\n" + + "BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEAB8T/EfVh602S1GJD2tJ1ck9TwutF\n" + + "2VSoSRKajMOabbwjzKEAeJ9rNcWiy60rSvDuL8i4IL52R7fHhlJaDg9FVjmkiWSO\n" + + "VPiIZuOyvUtsc9++AM741RK9OrEMETvAtbtEMU6du7LiFk2KcnDTHfcNihtM/TNZ\n" + + "1bzEKuSfQydBNPkO3Ftmveygj7QGX+Kgppp7RXXUFzySYxrlA1usgNhVXY/qhFiJ\n" + + "jhTU33iZgwiKxpY+zj/Gmk5sdOCEk7e1P06IB3eIopdRTMGJCeCBKyFyXND38kNC\n" + + "bTIPnuOdE73M2AW0LWuPv6UQZVBv5A82WMT9f8Hq9H2cHbuhgL/ozyFSWw==\n" + "-----END CERTIFICATE-----"; static String crlIssuerCertStr = "-----BEGIN CERTIFICATE-----\n" + - "MIICKzCCAZSgAwIBAgIBAjANBgkqhkiG9w0BAQQFADAfMQswCQYDVQQGEwJVUzEQ\n" + - "MA4GA1UEChMHRXhhbXBsZTAeFw0wOTA0MjcwMjI0MzNaFw0yOTAxMTIwMjI0MzNa\n" + - "MB8xCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFtcGxlMIGfMA0GCSqGSIb3DQEB\n" + - "AQUAA4GNADCBiQKBgQDMJeBMBybHykI/YpwUJ4O9euqDSLb1kpWpceBS8TVqvgBC\n" + - "SgUJWtFZL0i6bdvF6mMdlbuBkGzhXqHiVAi96/zRLbUC9F8SMEJ6MuD+YhQ0ZFTQ\n" + - "atKy8zf8O9XzztelLJ26Gqb7QPV133WY3haAqHtCXOhEKkCN16NOYNC37DTaJwID\n" + - "AQABo3cwdTAdBgNVHQ4EFgQULXSWzXzUOIpOJpzbSCpW42IJUugwRwYDVR0jBEAw\n" + - "PoAUgiXdIaZeT3QA/SGUvh854OJVyxuhI6QhMB8xCzAJBgNVBAYTAlVTMRAwDgYD\n" + - "VQQKEwdFeGFtcGxlggEAMAsGA1UdDwQEAwIBAjANBgkqhkiG9w0BAQQFAAOBgQAY\n" + - "eMnf5AHSNlyUlzXk8o2S0h4gCuvKX6C3kFfKuZcWvFAbx4yQOWLS2s15/nzR4+AP\n" + - "FGX3lgJjROyAh7fGedTQK+NFWwkM2ag1g3hXktnlnT1qHohi0w31nVBJxXEDO/Ck\n" + - "uJTpJGt8XxxbFaw5v7cHy7XuTAeU/sekvjEiNHW00Q==\n" + + "MIIDeTCCAmGgAwIBAgIBATANBgkqhkiG9w0BAQUFADA7MQ0wCwYDVQQDDARST09U\n" + + "MRAwDgYDVQQKDAdFeGFtcGxlMQswCQYDVQQIDAJDQTELMAkGA1UEBhMCVVMwHhcN\n" + + "MjQwNjE5MDQ0NzU3WhcNMjYwNjE4MDQ0NzU3WjA5MQswCQYDVQQDDAJDQTELMAkG\n" + + "A1UECAwCQ0ExCzAJBgNVBAYTAlVTMRAwDgYDVQQKDAdFeGFtcGxlMIIBIjANBgkq\n" + + "hkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAn3wVMxoa3mgqk7fbg+UEj3vDfdR+o0dL\n" + + "UeDqtkM/KHQg2h16LTRsRM+bGcDAg8pz/8RNK+jiCq5lXylUtOYEIKzD2NTrycOH\n" + + "gAt92vt01cusZrnvdf+wKFNzDQea1q1fgNFbFdWZZ7Ia+BvR9dYdwbyX7LPKPth5\n" + + "aSmvwhKivETV6mTU17dMls/8OjQ+oUydBggVjhpjS+xYCBa09ie2dR+eGrluCaF5\n" + + "gspoTeQxAOOytBoL4+DECEPsAyr7/guMOdmWUbPDvfYL+97N6imXUh4XtQ7+xHTd\n" + + "OWWwAhS7JjqcalADSNUClU54VVGbZ9NmIjDiSPc1bvam4FxicuqrBQIDAQABo4GJ\n" + + "MIGGMAwGA1UdEwQFMAMBAf8wHQYDVR0OBBYEFMPkRHT0w2v7Nx2SN/i+2hJIj/5x\n" + + "MB8GA1UdIwQYMBaAFFuo2fpnAhDAEE1MyR9hdE8DEzjLMAsGA1UdDwQEAwIBAjAp\n" + + "BgNVHR8EIjAgMB6gHKAahhhodHRwOi8vdGVzdC5jb20vcm9vdC5jcmwwDQYJKoZI\n" + + "hvcNAQEFBQADggEBAIsREfhopvEGrbVjbaRsBmGlMAblqiTWF3DklU4BfXGQ7u+2\n" + + "z/Dvl5rehGkWIU5GmBY/DFWN/Tgt6yJU+d1ismKj+zhWI8IT7dLKJnSP0Sei0zqr\n" + + "qsIj/y5Xzmd2XpQ52V3KtDy4t7YQJ+nRKUrqLzSKHvOXOQgScK2RL4FZx0gah/bJ\n" + + "YCKq6zonC59lZ6ftJ2j9Ny9wNulHBlgS0p8q+Z42IfdfVgrLmbXoHNmKjVKdrs1Z\n" + + "HCva3WKMOkVFdejOuvPSnSw4Iob479nC3V12YtFAgeYMoBMPgZHcuWce4IC9Ts7z\n" + + "w8Xo1Fv3aNOygWdXdVDL79jkOJo2wO8yIe+J6Ig=\n" + "-----END CERTIFICATE-----"; static String crlStr = "-----BEGIN X509 CRL-----\n" + - "MIIBGzCBhQIBATANBgkqhkiG9w0BAQQFADAfMQswCQYDVQQGEwJVUzEQMA4GA1UE\n" + - "ChMHRXhhbXBsZRcNMDkwNDI3MDIzODA0WhcNMjgwNjI2MDIzODA0WjAiMCACAQUX\n" + - "DTA5MDQyNzAyMzgwMFowDDAKBgNVHRUEAwoBBKAOMAwwCgYDVR0UBAMCAQIwDQYJ\n" + - "KoZIhvcNAQEEBQADgYEAoarfzXEtw3ZDi4f9U8eSvRIipHSyxOrJC7HR/hM5VhmY\n" + - "CErChny6x9lBVg9s57tfD/P9PSzBLusCcHwHMAbMOEcTltVVKUWZnnbumpywlYyg\n" + - "oKLrE9+yCOkYUOpiRlz43/3vkEL5hjIKMcDSZnPKBZi1h16Yj2hPe9GMibNip54=\n" + + "MIIBtjCBnwIBATANBgkqhkiG9w0BAQUFADA5MQswCQYDVQQDDAJDQTELMAkGA1UE\n" + + "CAwCQ0ExCzAJBgNVBAYTAlVTMRAwDgYDVQQKDAdFeGFtcGxlFw0yNDA2MTkwNDQ3\n" + + "NThaFw0yNjA2MTgwNDQ3NThaMCIwIAIBAhcNMjQwNjE5MDQ0NzU4WjAMMAoGA1Ud\n" + + "FQQDCgEEoA4wDDAKBgNVHRQEAwIBATANBgkqhkiG9w0BAQUFAAOCAQEAkN0owWtq\n" + + "We0SznF9rAAADLMfB/2GKBQpqsJXXwE9FnCm8emSDtHpud+NZL+PAy9g050et8nl\n" + + "CNey/FBMJJMN3b3SZKkHA2MR4qJmHfeFnlE5mHnUHg7gH0a1u7H7wf0Z/L6eZNWy\n" + + "dB905II7Ej0GBuPnLsKNMDBtGtDuSPXCvmaBsKDe8awaEA1VchZKVLzg+8hEC0vt\n" + + "60jz9HrDpFun99IKTTCxBT+9GrW38GbPMxj0rLAL4n75SrfPdeFPj0t5fksOC7a7\n" + + "SLO9t+UC89SMTsoIwVjHIFIUxw5FHpuUfgOQ7PtjhpLd2Pm5u5Pe2gv4Q41xVgVW\n" + + "hVMagRPmAQAniQ==\n" + "-----END X509 CRL-----"; private static X509CRL crl; @@ -87,7 +103,8 @@ public static void main(String[] args) throws Exception { * Verify CRL with its own public key. * Should pass. */ - verifyCRL(crlIssuerCertPubKey, "SunRsaSign"); + verifyCRL(crlIssuerCertPubKey, + System.getProperty("test.provider.name", "SunRsaSign")); /* * Try to verify CRL with a provider that does not have a Signature @@ -103,11 +120,12 @@ public static void main(String[] args) throws Exception { /* * Try to verify CRL with a provider that has a Signature implementation - * but not of the right algorithm (MD5withRSA). + * but not of the right algorithm (SHA1withRSA). * Should fail with NoSuchAlgorithmException. */ try { - verifyCRL(crlIssuerCertPubKey, "SUN"); + verifyCRL(crlIssuerCertPubKey, + System.getProperty("test.provider.name", "SUN")); throw new RuntimeException("Didn't catch the exception properly"); } catch (NoSuchAlgorithmException e) { System.out.println("Caught the correct exception."); @@ -118,7 +136,8 @@ public static void main(String[] args) throws Exception { * Should fail with SignatureException. */ try { - verifyCRL(selfSignedCertPubKey, "SunRsaSign"); + verifyCRL(selfSignedCertPubKey, + System.getProperty("test.provider.name","SunRsaSign")); throw new RuntimeException("Didn't catch the exception properly"); } catch (SignatureException e) { System.out.println("Caught the correct exception."); @@ -148,6 +167,7 @@ private static void verifyCRL(PublicKey key, String providerName) throws CRLException, NoSuchAlgorithmException, InvalidKeyException, SignatureException { Provider provider = Security.getProvider(providerName); + System.out.println("Provider = " + provider.getName()); if (provider == null) { throw new RuntimeException("Provider " + providerName + " not found."); diff --git a/test/jdk/sun/security/x509/X509CertImpl/Verify.java b/test/jdk/sun/security/x509/X509CertImpl/Verify.java index cffee273e6f..0b98758ee4c 100644 --- a/test/jdk/sun/security/x509/X509CertImpl/Verify.java +++ b/test/jdk/sun/security/x509/X509CertImpl/Verify.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,35 +36,47 @@ public class Verify { static String selfSignedCertStr = "-----BEGIN CERTIFICATE-----\n" + - "MIICPjCCAaegAwIBAgIBADANBgkqhkiG9w0BAQQFADAfMQswCQYDVQQGEwJVUzEQ\n" + - "MA4GA1UEChMHRXhhbXBsZTAeFw0wOTA0MjcwMjI0MzJaFw0zMDA0MDcwMjI0MzJa\n" + - "MB8xCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFtcGxlMIGfMA0GCSqGSIb3DQEB\n" + - "AQUAA4GNADCBiQKBgQC4OTag24sTxL2tXTNuvpmUEtdxrYAZoFsslFQ60T+WD9wQ\n" + - "Jeiw87FSPsR2vxRuv0j8DNm2a4h7LNNIFcLurfNldbz5pvgZ7VqdbbUMPE9qP85n\n" + - "jgDl4woyRTSUeRI4A7O0CO6NpES21dtbdhroWQrEkHxpnrDPxsxrz5gf2m3gqwID\n" + - "AQABo4GJMIGGMB0GA1UdDgQWBBSCJd0hpl5PdAD9IZS+Hzng4lXLGzBHBgNVHSME\n" + - "QDA+gBSCJd0hpl5PdAD9IZS+Hzng4lXLG6EjpCEwHzELMAkGA1UEBhMCVVMxEDAO\n" + - "BgNVBAoTB0V4YW1wbGWCAQAwDwYDVR0TAQH/BAUwAwEB/zALBgNVHQ8EBAMCAgQw\n" + - "DQYJKoZIhvcNAQEEBQADgYEAluy6HIjWcq009lTLmhp+Np6dxU78pInBK8RZkza0\n" + - "484qGaxFGD3UGyZkI5uWmsH2XuMbuox5khfIq6781gmkPBHXBIEtJN8eLusOHEye\n" + - "iE8h7WI+N3qa6Pj56WionMrioqC/3X+b06o147bbhx8U0vkYv/HyPaITOFfMXTdz\n" + - "Vjw=\n" + + "MIIDVzCCAj+gAwIBAgIUUM/RKxE2Rcc6zYLWLxNolpLnuiwwDQYJKoZIhvcNAQEL\n" + + "BQAwOzENMAsGA1UEAwwEUk9PVDEQMA4GA1UECgwHRXhhbXBsZTELMAkGA1UECAwC\n" + + "Q0ExCzAJBgNVBAYTAlVTMB4XDTI0MDYxOTA0NDc1N1oXDTM0MDYxOTA0NDc1N1ow\n" + + "OzENMAsGA1UEAwwEUk9PVDEQMA4GA1UECgwHRXhhbXBsZTELMAkGA1UECAwCQ0Ex\n" + + "CzAJBgNVBAYTAlVTMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAohRG\n" + + "eq8/CniUqWEtpm1gBp+PWENpYgeaALAUgFdBBa6ao7mESjxRG8teaNRcszmoL3Rl\n" + + "TH5hLycHA00G5qsALXo4Cj9wAGfR3LbA0HlTurdw3NNk76twQXZpuE19YNYQonbR\n" + + "Mm2sgTd2YcrNWmGpthgNiUaT837Yt7RCuurPo4zi1y6g/NJwyLtn775S86NrV5PT\n" + + "4vaBCsB5+eCm01CBgzBq3I0OY5oosopNUjmFL4LYccZZ2YAOUY0fvxfsMZD5EDcj\n" + + "KrgKBspjmolfn5g5lA5vdVthG2/TxTIdLss69+NsGS1RBkSKGiQNKnRnAB9/gHwc\n" + + "2ryHKJRMQrV+JGMjrQIDAQABo1MwUTAdBgNVHQ4EFgQUW6jZ+mcCEMAQTUzJH2F0\n" + + "TwMTOMswHwYDVR0jBBgwFoAUW6jZ+mcCEMAQTUzJH2F0TwMTOMswDwYDVR0TAQH/\n" + + "BAUwAwEB/zANBgkqhkiG9w0BAQsFAAOCAQEAB8T/EfVh602S1GJD2tJ1ck9TwutF\n" + + "2VSoSRKajMOabbwjzKEAeJ9rNcWiy60rSvDuL8i4IL52R7fHhlJaDg9FVjmkiWSO\n" + + "VPiIZuOyvUtsc9++AM741RK9OrEMETvAtbtEMU6du7LiFk2KcnDTHfcNihtM/TNZ\n" + + "1bzEKuSfQydBNPkO3Ftmveygj7QGX+Kgppp7RXXUFzySYxrlA1usgNhVXY/qhFiJ\n" + + "jhTU33iZgwiKxpY+zj/Gmk5sdOCEk7e1P06IB3eIopdRTMGJCeCBKyFyXND38kNC\n" + + "bTIPnuOdE73M2AW0LWuPv6UQZVBv5A82WMT9f8Hq9H2cHbuhgL/ozyFSWw==\n" + "-----END CERTIFICATE-----"; static String crlIssuerCertStr = "-----BEGIN CERTIFICATE-----\n" + - "MIICKzCCAZSgAwIBAgIBAjANBgkqhkiG9w0BAQQFADAfMQswCQYDVQQGEwJVUzEQ\n" + - "MA4GA1UEChMHRXhhbXBsZTAeFw0wOTA0MjcwMjI0MzNaFw0yOTAxMTIwMjI0MzNa\n" + - "MB8xCzAJBgNVBAYTAlVTMRAwDgYDVQQKEwdFeGFtcGxlMIGfMA0GCSqGSIb3DQEB\n" + - "AQUAA4GNADCBiQKBgQDMJeBMBybHykI/YpwUJ4O9euqDSLb1kpWpceBS8TVqvgBC\n" + - "SgUJWtFZL0i6bdvF6mMdlbuBkGzhXqHiVAi96/zRLbUC9F8SMEJ6MuD+YhQ0ZFTQ\n" + - "atKy8zf8O9XzztelLJ26Gqb7QPV133WY3haAqHtCXOhEKkCN16NOYNC37DTaJwID\n" + - "AQABo3cwdTAdBgNVHQ4EFgQULXSWzXzUOIpOJpzbSCpW42IJUugwRwYDVR0jBEAw\n" + - "PoAUgiXdIaZeT3QA/SGUvh854OJVyxuhI6QhMB8xCzAJBgNVBAYTAlVTMRAwDgYD\n" + - "VQQKEwdFeGFtcGxlggEAMAsGA1UdDwQEAwIBAjANBgkqhkiG9w0BAQQFAAOBgQAY\n" + - "eMnf5AHSNlyUlzXk8o2S0h4gCuvKX6C3kFfKuZcWvFAbx4yQOWLS2s15/nzR4+AP\n" + - "FGX3lgJjROyAh7fGedTQK+NFWwkM2ag1g3hXktnlnT1qHohi0w31nVBJxXEDO/Ck\n" + - "uJTpJGt8XxxbFaw5v7cHy7XuTAeU/sekvjEiNHW00Q==\n" + + "MIIDeTCCAmGgAwIBAgIBATANBgkqhkiG9w0BAQUFADA7MQ0wCwYDVQQDDARST09U\n" + + "MRAwDgYDVQQKDAdFeGFtcGxlMQswCQYDVQQIDAJDQTELMAkGA1UEBhMCVVMwHhcN\n" + + "MjQwNjE5MDQ0NzU3WhcNMjYwNjE4MDQ0NzU3WjA5MQswCQYDVQQDDAJDQTELMAkG\n" + + "A1UECAwCQ0ExCzAJBgNVBAYTAlVTMRAwDgYDVQQKDAdFeGFtcGxlMIIBIjANBgkq\n" + + "hkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAn3wVMxoa3mgqk7fbg+UEj3vDfdR+o0dL\n" + + "UeDqtkM/KHQg2h16LTRsRM+bGcDAg8pz/8RNK+jiCq5lXylUtOYEIKzD2NTrycOH\n" + + "gAt92vt01cusZrnvdf+wKFNzDQea1q1fgNFbFdWZZ7Ia+BvR9dYdwbyX7LPKPth5\n" + + "aSmvwhKivETV6mTU17dMls/8OjQ+oUydBggVjhpjS+xYCBa09ie2dR+eGrluCaF5\n" + + "gspoTeQxAOOytBoL4+DECEPsAyr7/guMOdmWUbPDvfYL+97N6imXUh4XtQ7+xHTd\n" + + "OWWwAhS7JjqcalADSNUClU54VVGbZ9NmIjDiSPc1bvam4FxicuqrBQIDAQABo4GJ\n" + + "MIGGMAwGA1UdEwQFMAMBAf8wHQYDVR0OBBYEFMPkRHT0w2v7Nx2SN/i+2hJIj/5x\n" + + "MB8GA1UdIwQYMBaAFFuo2fpnAhDAEE1MyR9hdE8DEzjLMAsGA1UdDwQEAwIBAjAp\n" + + "BgNVHR8EIjAgMB6gHKAahhhodHRwOi8vdGVzdC5jb20vcm9vdC5jcmwwDQYJKoZI\n" + + "hvcNAQEFBQADggEBAIsREfhopvEGrbVjbaRsBmGlMAblqiTWF3DklU4BfXGQ7u+2\n" + + "z/Dvl5rehGkWIU5GmBY/DFWN/Tgt6yJU+d1ismKj+zhWI8IT7dLKJnSP0Sei0zqr\n" + + "qsIj/y5Xzmd2XpQ52V3KtDy4t7YQJ+nRKUrqLzSKHvOXOQgScK2RL4FZx0gah/bJ\n" + + "YCKq6zonC59lZ6ftJ2j9Ny9wNulHBlgS0p8q+Z42IfdfVgrLmbXoHNmKjVKdrs1Z\n" + + "HCva3WKMOkVFdejOuvPSnSw4Iob479nC3V12YtFAgeYMoBMPgZHcuWce4IC9Ts7z\n" + + "w8Xo1Fv3aNOygWdXdVDL79jkOJo2wO8yIe+J6Ig=\n" + "-----END CERTIFICATE-----"; private static X509Certificate cert; @@ -78,7 +90,8 @@ public static void main(String[] args) throws Exception { * Verify certificate with its own public key. * Should pass. */ - verifyCert(selfSignedCertPubKey,"SunRsaSign"); + verifyCert(selfSignedCertPubKey, + System.getProperty("test.provider.name", "SunRsaSign")); /* * Try to verify certificate with a provider that does not have a @@ -86,7 +99,8 @@ public static void main(String[] args) throws Exception { * Should fail with NoSuchAlgorithmException. */ try { - verifyCert(selfSignedCertPubKey, "SunJCE"); + verifyCert(selfSignedCertPubKey, + System.getProperty("test.provider.name", "SunJCE")); throw new RuntimeException("Didn't catch the exception properly"); } catch (NoSuchAlgorithmException e) { System.out.println("Caught the correct exception."); @@ -94,11 +108,12 @@ public static void main(String[] args) throws Exception { /* * Try to verify certificate with a provider that has a Signature - * implementation but not of the right algorithm (MD5withRSA). + * implementation but not of the right algorithm (SHA1withRSA). * Should fail with NoSuchAlgorithmException. */ try { - verifyCert(selfSignedCertPubKey, "SUN"); + verifyCert(selfSignedCertPubKey, + System.getProperty("test.provider.name", "SUN")); throw new RuntimeException("Didn't catch the exception properly"); } catch (NoSuchAlgorithmException e) { System.out.println("Caught the correct exception."); @@ -109,7 +124,8 @@ public static void main(String[] args) throws Exception { * Should fail with SignatureException. */ try { - verifyCert(crlIssuerCertPubKey, "SunRsaSign"); + verifyCert(crlIssuerCertPubKey, + System.getProperty("test.provider.name", "SunRsaSign")); throw new RuntimeException("Didn't catch the exception properly"); } catch (SignatureException e) { System.out.println("Caught the correct exception."); diff --git a/test/jdk/sun/tools/jmap/BasicJMapTest.java b/test/jdk/sun/tools/jmap/BasicJMapTest.java index d8a24ef05fa..991648b96c2 100644 --- a/test/jdk/sun/tools/jmap/BasicJMapTest.java +++ b/test/jdk/sun/tools/jmap/BasicJMapTest.java @@ -87,8 +87,8 @@ */ /* - * @test id=ZSinglegen - * @requires vm.gc.ZSinglegen + * @test id=Z + * @requires vm.gc.Z * @summary Unit test for jmap utility (Z GC) * @key intermittent * @library /test/lib @@ -96,20 +96,7 @@ * @build jdk.test.lib.hprof.model.* * @build jdk.test.lib.hprof.parser.* * @build jdk.test.lib.hprof.util.* - * @run main/othervm/timeout=240 -XX:+UseZGC -XX:-ZGenerational BasicJMapTest - */ - -/* - * @test id=ZGenerational - * @requires vm.gc.ZGenerational - * @summary Unit test for jmap utility (Z GC) - * @key intermittent - * @library /test/lib - * @build jdk.test.lib.hprof.* - * @build jdk.test.lib.hprof.model.* - * @build jdk.test.lib.hprof.parser.* - * @build jdk.test.lib.hprof.util.* - * @run main/othervm/timeout=240 -XX:+UseZGC -XX:+ZGenerational BasicJMapTest + * @run main/othervm/timeout=240 -XX:+UseZGC BasicJMapTest */ public class BasicJMapTest { diff --git a/test/jdk/tools/jar/ExtractFilesTest.java b/test/jdk/tools/jar/ExtractFilesTest.java index b829b770fc8..26e0d103d51 100644 --- a/test/jdk/tools/jar/ExtractFilesTest.java +++ b/test/jdk/tools/jar/ExtractFilesTest.java @@ -88,7 +88,7 @@ public void testExtract() throws IOException { " inflated: testfile1" + nl + " inflated: testfile2" + nl; rm("META-INF testfile1 testfile2"); - Assertions.assertArrayEquals(baos.toByteArray(), output.getBytes()); + assertOutputContains(output); } /** @@ -105,7 +105,7 @@ public void testOverwrite() throws IOException { " inflated: testfile2" + nl; Assertions.assertEquals("testfile1", cat("testfile1")); rm("META-INF testfile1 testfile2"); - Assertions.assertArrayEquals(baos.toByteArray(), output.getBytes()); + assertOutputContains(output); } /** @@ -123,7 +123,7 @@ public void testKeptOldFile() throws IOException { Assertions.assertEquals("", cat("testfile1")); Assertions.assertEquals("testfile2", cat("testfile2")); rm("META-INF testfile1 testfile2"); - Assertions.assertArrayEquals(baos.toByteArray(), output.getBytes()); + assertOutputContains(output); } /** @@ -141,7 +141,7 @@ public void testGnuOptionsKeptOldFile() throws IOException { Assertions.assertEquals("", cat("testfile1")); Assertions.assertEquals("", cat("testfile2")); rm("META-INF testfile1 testfile2"); - Assertions.assertArrayEquals(baos.toByteArray(), output.getBytes()); + assertOutputContains(output); } /** @@ -159,7 +159,7 @@ public void testGnuLongOptionsKeptOldFile() throws IOException { Assertions.assertEquals("testfile1", cat("testfile1")); Assertions.assertEquals("", cat("testfile2")); rm("META-INF testfile1 testfile2"); - Assertions.assertArrayEquals(baos.toByteArray(), output.getBytes()); + assertOutputContains(output); } /** @@ -175,10 +175,14 @@ public void testWarningOnInvalidKeepOption() throws IOException { "testfile1" + nl + "testfile2" + nl; - Assertions.assertArrayEquals(baos.toByteArray(), output.getBytes()); + assertOutputContains(output); Assertions.assertEquals("Warning: The --keep-old-files/-k/k option is not valid with current usage, will be ignored." + nl, err); } + private void assertOutputContains(String expected) { + Assertions.assertTrue(baos.toString().contains(expected)); + } + private Stream mkpath(String... args) { return Arrays.stream(args).map(d -> Path.of(".", d.split("/"))); } diff --git a/test/jdk/tools/jar/MultipleManifestTest.java b/test/jdk/tools/jar/MultipleManifestTest.java index 951ce4bb890..231f6ba1ec6 100644 --- a/test/jdk/tools/jar/MultipleManifestTest.java +++ b/test/jdk/tools/jar/MultipleManifestTest.java @@ -154,7 +154,7 @@ public void testOverwrite() throws IOException { " inflated: entry1.txt" + nl + " inflated: META-INF/MANIFEST.MF" + nl + " inflated: entry2.txt" + nl; - Assertions.assertArrayEquals(baos.toByteArray(), output.getBytes()); + assertOutputContains(output); } /** @@ -170,7 +170,7 @@ public void testKeptOldFile() throws IOException { " inflated: entry1.txt" + nl + " skipped: META-INF/MANIFEST.MF exists" + nl + " inflated: entry2.txt" + nl; - Assertions.assertArrayEquals(baos.toByteArray(), output.getBytes()); + assertOutputContains(output); } private String getManifestVersion() throws IOException { @@ -199,6 +199,10 @@ private void jar(String cmdline) throws IOException { } } + private void assertOutputContains(String expected) { + Assertions.assertTrue(baos.toString().contains(expected)); + } + private void println() throws IOException { System.out.println(new String(baos.toByteArray())); } diff --git a/test/jdk/tools/jpackage/helpers-test/jdk/jpackage/test/DirectoryContentVerifierTest.java b/test/jdk/tools/jpackage/helpers-test/jdk/jpackage/test/DirectoryContentVerifierTest.java new file mode 100644 index 00000000000..cf910445abf --- /dev/null +++ b/test/jdk/tools/jpackage/helpers-test/jdk/jpackage/test/DirectoryContentVerifierTest.java @@ -0,0 +1,171 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package jdk.jpackage.test; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Set; +import java.util.function.BiConsumer; +import static java.util.stream.Collectors.toSet; +import java.util.stream.Stream; +import jdk.jpackage.test.Annotations.Parameters; +import jdk.jpackage.test.Annotations.Test; +import static jdk.jpackage.test.DirectoryContentVerifierTest.AssertType.CONTAINS; +import static jdk.jpackage.test.DirectoryContentVerifierTest.AssertType.MATCH; +import jdk.jpackage.test.TKit.DirectoryContentVerifier; +import static jdk.jpackage.test.TKit.assertAssert; + +/* + * @test + * @summary Test TKit.DirectoryContentVerifier from jpackage test library + * @library /test/jdk/tools/jpackage/helpers + * @build jdk.jpackage.test.* + * @modules jdk.jpackage/jdk.jpackage.internal + * @compile DirectoryContentVerifierTest.java + * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main + * --jpt-run=jdk.jpackage.test.DirectoryContentVerifierTest + */ +public class DirectoryContentVerifierTest { + + enum AssertType { + MATCH(DirectoryContentVerifier::match), + CONTAINS(DirectoryContentVerifier::contains), + ; + + AssertType(BiConsumer> assertFunc) { + this.assertFunc = assertFunc; + } + + private final BiConsumer> assertFunc; + } + + private static ArgsBuilder buildArgs() { + return new ArgsBuilder(); + } + + private static class ArgsBuilder { + + void applyTo(List data) { + data.add(new Object[]{expectedPaths, actualPaths, assertOp, success}); + } + + void applyVariantsTo(List data) { + applyTo(data); + boolean pathGroupsEqual = List.of(expectedPaths).equals(List.of(actualPaths)); + if (assertOp == MATCH) { + if (!pathGroupsEqual) { + data.add(new Object[]{actualPaths, expectedPaths, MATCH, success}); + } + if (success) { + data.add(new Object[]{expectedPaths, actualPaths, CONTAINS, success}); + if (!pathGroupsEqual) { + data.add(new Object[]{actualPaths, expectedPaths, CONTAINS, success}); + } + } + } + } + + ArgsBuilder expectedPaths(String... paths) { + expectedPaths = paths; + return this; + } + + ArgsBuilder actualPaths(String... paths) { + actualPaths = paths; + return this; + } + + ArgsBuilder assertOp(AssertType v) { + assertOp = v; + return this; + } + + ArgsBuilder expectFail() { + success = false; + return this; + } + + private String[] expectedPaths = new String[0]; + private String[] actualPaths = new String[0]; + private AssertType assertOp = MATCH; + private boolean success = true; + } + + @Parameters + public static Collection input() { + List data = new ArrayList<>(); + buildArgs().applyVariantsTo(data); + buildArgs().actualPaths("foo").assertOp(CONTAINS).applyTo(data); + buildArgs().actualPaths("zoo").expectFail().applyVariantsTo(data); + buildArgs().actualPaths("boo").expectedPaths("boo").applyVariantsTo(data); + if (TKit.isWindows()) { + buildArgs().actualPaths("moo").expectedPaths("Moo").applyVariantsTo(data); + } else { + buildArgs().actualPaths("moo").expectedPaths("Moo").expectFail().applyVariantsTo(data); + } + buildArgs().actualPaths("hello").expectedPaths().expectFail().applyVariantsTo(data); + buildArgs().actualPaths("123").expectedPaths("456").expectFail().applyVariantsTo(data); + buildArgs().actualPaths("a", "b", "c").expectedPaths("b", "a", "c").applyVariantsTo(data); + buildArgs().actualPaths("AA", "BB", "CC").expectedPaths("BB", "AA").expectFail().applyVariantsTo(data); + buildArgs().actualPaths("AA", "BB", "CC").expectedPaths("BB", "AA").assertOp(CONTAINS).applyTo(data); + buildArgs().actualPaths("AA", "BB", "CC").expectedPaths("BB", "DD", "AA").expectFail().assertOp(CONTAINS).applyTo(data); + buildArgs().actualPaths("AA", "BB", "CC").expectedPaths("BB", "DD", "AA").expectFail().applyTo(data); + return data; + } + + public DirectoryContentVerifierTest(String[] expectedPaths, String[] actualPaths, + AssertType assertOp, Boolean success) { + this.expectedPaths = conv(expectedPaths); + this.actualPaths = conv(actualPaths); + this.assertOp = assertOp; + this.success = success; + } + + @Test + public void test() { + TKit.withTempDirectory("basedir", this::test); + } + + private void test(Path basedir) throws IOException { + for (var path : actualPaths) { + Files.createFile(basedir.resolve(path)); + } + + var testee = TKit.assertDirectoryContent(basedir); + + assertAssert(success, () -> assertOp.assertFunc.accept(testee, expectedPaths)); + } + + private static Set conv(String... paths) { + return Stream.of(paths).map(Path::of).collect(toSet()); + } + + private final Set expectedPaths; + private final Set actualPaths; + private final AssertType assertOp; + private final boolean success; +} diff --git a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/CommandArguments.java b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/CommandArguments.java index 5b4cf3aef71..e5941918938 100644 --- a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/CommandArguments.java +++ b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/CommandArguments.java @@ -34,30 +34,35 @@ public class CommandArguments { args = new ArrayList<>(); } - final public T addArgument(String v) { + public final T clearArguments() { + args.clear(); + return (T) this; + } + + public final T addArgument(String v) { args.add(v); return (T) this; } - final public T addArguments(List v) { + public final T addArguments(List v) { args.addAll(v); return (T) this; } - final public T addArgument(Path v) { + public final T addArgument(Path v) { return addArgument(v.toString()); } - final public T addArguments(String... v) { + public final T addArguments(String... v) { return addArguments(Arrays.asList(v)); } - final public T addPathArguments(List v) { + public final T addPathArguments(List v) { return addArguments(v.stream().map((p) -> p.toString()).collect( Collectors.toList())); } - final public List getAllArguments() { + public final List getAllArguments() { return List.copyOf(args); } diff --git a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/JPackageCommand.java b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/JPackageCommand.java index fd62d6c7d88..18384db34db 100644 --- a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/JPackageCommand.java +++ b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/JPackageCommand.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -52,6 +52,7 @@ import static jdk.jpackage.test.AdditionalLauncher.forEachAdditionalLauncher; import jdk.jpackage.test.Functional.ThrowingConsumer; import jdk.jpackage.test.Functional.ThrowingFunction; +import jdk.jpackage.test.Functional.ThrowingRunnable; import jdk.jpackage.test.Functional.ThrowingSupplier; /** @@ -76,6 +77,8 @@ public JPackageCommand(JPackageCommand cmd) { immutable = cmd.immutable; prerequisiteActions = new Actions(cmd.prerequisiteActions); verifyActions = new Actions(cmd.verifyActions); + appLayoutAsserts = cmd.appLayoutAsserts; + executeInDirectory = cmd.executeInDirectory; } JPackageCommand createImmutableCopy() { @@ -198,7 +201,10 @@ public PackageType packageType() { } public Path outputDir() { - return getArgumentValue("--dest", () -> Path.of("."), Path::of); + var path = getArgumentValue("--dest", () -> Path.of("."), Path::of); + return Optional.ofNullable(executeInDirectory).map(base -> { + return base.resolve(path); + }).orElse(path); } public Path inputDir() { @@ -691,6 +697,12 @@ public JPackageCommand useToolProvider(boolean v) { return this; } + public JPackageCommand setDirectory(Path v) { + verifyMutable(); + executeInDirectory = v; + return this; + } + public JPackageCommand saveConsoleOutput(boolean v) { verifyMutable(); saveConsoleOutput = v; @@ -733,6 +745,7 @@ public JPackageCommand executeVerifyActions() { private Executor createExecutor() { Executor exec = new Executor() .saveOutput(saveConsoleOutput).dumpOutput(!suppressOutput) + .setDirectory(executeInDirectory) .addArguments(args); if (isWithToolProvider()) { @@ -755,18 +768,19 @@ public Executor.Result execute(int expectedExitCode) { executePrerequisiteActions(); if (hasArgument("--dest")) { - if (isImagePackageType()) { - TKit.deleteDirectoryContentsRecursive(outputDir()); - } else { - nullableOutputBundle().ifPresent(path -> { - if (ThrowingSupplier.toSupplier(() -> TKit.deleteIfExists( - path)).get()) { + nullableOutputBundle().ifPresent(path -> { + ThrowingRunnable.toRunnable(() -> { + if (Files.isDirectory(path)) { + TKit.deleteDirectoryRecursive(path, String.format( + "Delete [%s] folder before running jpackage", + path)); + } else if (TKit.deleteIfExists(path)) { TKit.trace(String.format( "Deleted [%s] file before running jpackage", path)); } - }); - } + }).run(); + }); } Path resourceDir = getArgumentValue("--resource-dir", () -> null, Path::of); @@ -816,22 +830,69 @@ public JPackageCommand assertImageCreated() { return this; } - JPackageCommand assertAppLayout() { - assertAppImageFile(); - assertPackageFile(); - - TKit.assertDirectoryExists(appRuntimeDirectory()); - - if (!isRuntime()) { - TKit.assertExecutableFileExists(appLauncherPath()); - TKit.assertFileExists(appLauncherCfgPath(null)); - + public static enum AppLayoutAssert { + APP_IMAGE_FILE(JPackageCommand::assertAppImageFile), + PACKAGE_FILE(JPackageCommand::assertPackageFile), + MAIN_LAUNCHER(cmd -> { + if (cmd.isRuntime()) { + TKit.assertPathExists(convertFromRuntime(cmd).appLauncherPath(), false); + } else { + TKit.assertExecutableFileExists(cmd.appLauncherPath()); + } + }), + MAIN_LAUNCHER_CFG_FILE(cmd -> { + if (cmd.isRuntime()) { + TKit.assertPathExists(convertFromRuntime(cmd).appLauncherCfgPath(null), false); + } else { + TKit.assertFileExists(cmd.appLauncherCfgPath(null)); + } + }), + RUNTIME_DIRECTORY(cmd -> { + TKit.assertDirectoryExists(cmd.appRuntimeDirectory()); if (TKit.isOSX()) { - TKit.assertFileExists(appRuntimeDirectory().resolve( - "Contents/MacOS/libjli.dylib")); + var libjliPath = cmd.appRuntimeDirectory().resolve("Contents/MacOS/libjli.dylib"); + if (cmd.isRuntime()) { + TKit.assertPathExists(libjliPath, false); + } else { + TKit.assertFileExists(libjliPath); + } + } + }), + MAC_BUNDLE_STRUCTURE(cmd -> { + if (TKit.isOSX()) { + MacHelper.verifyBundleStructure(cmd); } + }), + ; + + AppLayoutAssert(Consumer action) { + this.action = action; + } + + private static JPackageCommand convertFromRuntime(JPackageCommand cmd) { + var copy = new JPackageCommand(cmd); + copy.immutable = false; + copy.removeArgumentWithValue("--runtime-image"); + return copy; } + private final Consumer action; + } + + public JPackageCommand setAppLayoutAsserts(AppLayoutAssert ... asserts) { + appLayoutAsserts = Set.of(asserts); + return this; + } + + public JPackageCommand excludeAppLayoutAsserts(AppLayoutAssert... asserts) { + return setAppLayoutAsserts(Stream.of(asserts).filter(Predicate.not( + appLayoutAsserts::contains)).toArray(AppLayoutAssert[]::new)); + } + + JPackageCommand assertAppLayout() { + for (var appLayoutAssert : appLayoutAsserts.stream().sorted().toList()) { + appLayoutAssert.action.accept(this); + } return this; } @@ -1111,9 +1172,11 @@ public void run() { private boolean immutable; private final Actions prerequisiteActions; private final Actions verifyActions; + private Path executeInDirectory; + private Set appLayoutAsserts = Set.of(AppLayoutAssert.values()); private static boolean defaultWithToolProvider; - private final static Map PACKAGE_TYPES = Functional.identity( + private static final Map PACKAGE_TYPES = Functional.identity( () -> { Map reply = new HashMap<>(); for (PackageType type : PackageType.values()) { @@ -1122,7 +1185,7 @@ public void run() { return reply; }).get(); - public final static Path DEFAULT_RUNTIME_IMAGE = Functional.identity(() -> { + public static final Path DEFAULT_RUNTIME_IMAGE = Functional.identity(() -> { // Set the property to the path of run-time image to speed up // building app images and platform bundles by avoiding running jlink // The value of the property will be automativcally appended to @@ -1135,5 +1198,5 @@ public void run() { return null; }).get(); - private final static String UNPACKED_PATH_ARGNAME = "jpt-unpacked-folder"; + private static final String UNPACKED_PATH_ARGNAME = "jpt-unpacked-folder"; } diff --git a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/JavaAppDesc.java b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/JavaAppDesc.java index 6a798012ca7..5b49b01a443 100644 --- a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/JavaAppDesc.java +++ b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/JavaAppDesc.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -216,7 +216,9 @@ public static JavaAppDesc parse(final String javaAppDesc) { components[0].length() - 1); desc.setWithMainClass(true); } - desc.setClassName(components[0]); + if (!components[0].isEmpty()) { + desc.setClassName(components[0]); + } if (components.length == 2) { desc.setModuleVersion(components[1]); } diff --git a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/MacHelper.java b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/MacHelper.java index ded548aface..8068e1d858f 100644 --- a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/MacHelper.java +++ b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/MacHelper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,6 +35,7 @@ import java.util.Set; import java.util.regex.Pattern; import java.util.stream.Collectors; +import static java.util.stream.Collectors.toSet; import java.util.stream.Stream; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; @@ -257,6 +258,20 @@ static PackageHandlers createPkgPackageHandlers() { return pkg; } + static void verifyBundleStructure(JPackageCommand cmd) { + Path bundleRoot; + if (cmd.isImagePackageType()) { + bundleRoot = cmd.outputBundle(); + } else { + bundleRoot = cmd.pathToUnpackedPackageFile( + cmd.appInstallationDirectory()); + } + + TKit.assertDirectoryContent(bundleRoot).match(Path.of("Contents")); + TKit.assertDirectoryContent(bundleRoot.resolve("Contents")).match( + cmd.isRuntime() ? RUNTIME_BUNDLE_CONTENTS : APP_BUNDLE_CONTENTS); + } + static String getBundleName(JPackageCommand cmd) { cmd.verifyIsOfType(PackageType.MAC); return String.format("%s-%s%s", getPackageName(cmd), cmd.version(), @@ -390,5 +405,19 @@ private static Method initGetServicePListFileName() { static final Set CRITICAL_RUNTIME_FILES = Set.of(Path.of( "Contents/Home/lib/server/libjvm.dylib")); - private final static Method getServicePListFileName = initGetServicePListFileName(); + private static final Method getServicePListFileName = initGetServicePListFileName(); + + private static final Set APP_BUNDLE_CONTENTS = Stream.of( + "Info.plist", + "MacOS", + "app", + "runtime", + "Resources", + "PkgInfo", + "_CodeSignature" + ).map(Path::of).collect(toSet()); + + private static final Set RUNTIME_BUNDLE_CONTENTS = Stream.of( + "Home" + ).map(Path::of).collect(toSet()); } diff --git a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/PackageTest.java b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/PackageTest.java index d597c62d83f..7882d4cd92d 100644 --- a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/PackageTest.java +++ b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/PackageTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -127,6 +127,15 @@ public PackageTest setExpectedExitCode(int v) { return this; } + public PackageTest ignoreBundleOutputDir() { + return ignoreBundleOutputDir(true); + } + + public PackageTest ignoreBundleOutputDir(boolean v) { + ignoreBundleOutputDir = v; + return this; + } + private PackageTest addInitializer(ThrowingConsumer v, String id) { if (id != null) { @@ -368,7 +377,7 @@ protected void runAction(Action... action) { private final List> handlers; } - final static class PackageHandlers { + static final class PackageHandlers { Consumer installHandler; Consumer uninstallHandler; BiFunction unpackHandler; @@ -528,7 +537,7 @@ private void handleAction(Action action, T handler, private final JPackageCommand cmd = Functional.identity(() -> { JPackageCommand result = new JPackageCommand(); result.setDefaultInputOutput().setDefaultAppName(); - if (BUNDLE_OUTPUT_DIR != null) { + if (BUNDLE_OUTPUT_DIR != null && !ignoreBundleOutputDir) { result.setArgumentValue("--dest", BUNDLE_OUTPUT_DIR.toString()); } type.applyTo(result); @@ -777,8 +786,9 @@ private static Map createDefaultPackageHandlers() private Map handlers; private Set namedInitializers; private Map packageHandlers; + private boolean ignoreBundleOutputDir; - private final static File BUNDLE_OUTPUT_DIR; + private static final File BUNDLE_OUTPUT_DIR; static { final String propertyName = "output"; diff --git a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/TKit.java b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/TKit.java index cd32f32f63d..ca1224aafd7 100644 --- a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/TKit.java +++ b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/TKit.java @@ -40,10 +40,12 @@ import java.nio.file.WatchService; import java.text.SimpleDateFormat; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.Date; +import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -57,13 +59,14 @@ import java.util.function.Predicate; import java.util.function.Supplier; import java.util.stream.Collectors; +import static java.util.stream.Collectors.toSet; import java.util.stream.Stream; import jdk.jpackage.test.Functional.ExceptionBox; import jdk.jpackage.test.Functional.ThrowingConsumer; import jdk.jpackage.test.Functional.ThrowingRunnable; import jdk.jpackage.test.Functional.ThrowingSupplier; -final public class TKit { +public final class TKit { private static final String OS = System.getProperty("os.name").toLowerCase(); @@ -84,7 +87,7 @@ final public class TKit { return TEST_SRC_ROOT.resolve("../../../../src/jdk.jpackage").normalize().toAbsolutePath(); }).get(); - public final static String ICON_SUFFIX = Functional.identity(() -> { + public static final String ICON_SUFFIX = Functional.identity(() -> { if (isOSX()) { return ".icns"; } @@ -273,7 +276,23 @@ public static void error(String v) { throw new AssertionError(v); } - private final static String TEMP_FILE_PREFIX = null; + static void assertAssert(boolean expectedSuccess, Runnable runnable) { + try { + runnable.run(); + } catch (AssertionError err) { + if (expectedSuccess) { + assertUnexpected("Assertion failed"); + } else { + return; + } + } + + if (!expectedSuccess) { + assertUnexpected("Assertion passed"); + } + } + + private static final String TEMP_FILE_PREFIX = null; private static Path createUniqueFileName(String defaultName) { final String[] nameComponents; @@ -296,7 +315,9 @@ private static Path createUniqueFileName(String defaultName) { if (!path.toFile().exists()) { return path; } - nameComponents[0] = String.format("%s.%d", baseName, i); + // Don't use period (.) as a separator. OSX codesign fails to sign folders + // with subfolders with names like "input.0". + nameComponents[0] = String.format("%s-%d", baseName, i); } throw new IllegalStateException(String.format( "Failed to create unique file name from [%s] basename after %d attempts", @@ -673,26 +694,40 @@ public static void assertPathExists(Path path, boolean exists) { assertTrue(path.toFile().exists(), String.format( "Check [%s] path exists", path)); } else { - assertFalse(path.toFile().exists(), String.format( + assertTrue(!path.toFile().exists(), String.format( "Check [%s] path doesn't exist", path)); } } - public static void assertPathNotEmptyDirectory(Path path) { - if (Files.isDirectory(path)) { + public static void assertDirectoryNotEmpty(Path path) { + assertDirectoryExists(path, Optional.of(false)); + } + + public static void assertDirectoryEmpty(Path path) { + assertDirectoryExists(path, Optional.of(true)); + } + + public static void assertDirectoryExists(Path path, Optional isEmptyCheck) { + assertPathExists(path, true); + boolean isDirectory = Files.isDirectory(path); + if (isEmptyCheck.isEmpty() || !isDirectory) { + assertTrue(isDirectory, String.format("Check [%s] is a directory", path)); + } else { ThrowingRunnable.toRunnable(() -> { try (var files = Files.list(path)) { - TKit.assertFalse(files.findFirst().isEmpty(), String.format - ("Check [%s] is not an empty directory", path)); + boolean actualIsEmpty = files.findFirst().isEmpty(); + if (isEmptyCheck.get()) { + TKit.assertTrue(actualIsEmpty, String.format("Check [%s] is not an empty directory", path)); + } else { + TKit.assertTrue(!actualIsEmpty, String.format("Check [%s] is an empty directory", path)); + } } }).run(); - } + } } public static void assertDirectoryExists(Path path) { - assertPathExists(path, true); - assertTrue(path.toFile().isDirectory(), String.format( - "Check [%s] is a directory", path)); + assertDirectoryExists(path, Optional.empty()); } public static void assertSymbolicLinkExists(Path path) { @@ -724,6 +759,101 @@ public static void assertUnexpected(String msg) { error(concatMessages("Unexpected", msg)); } + public static DirectoryContentVerifier assertDirectoryContent(Path dir) { + return new DirectoryContentVerifier(dir); + } + + public static final class DirectoryContentVerifier { + public DirectoryContentVerifier(Path baseDir) { + this(baseDir, ThrowingSupplier.toSupplier(() -> { + try (var files = Files.list(baseDir)) { + return files.map(Path::getFileName).collect(toSet()); + } + }).get()); + } + + public void match(Path ... expected) { + DirectoryContentVerifier.this.match(Set.of(expected)); + } + + public void match(Set expected) { + currentTest.notifyAssert(); + + var comm = Comm.compare(content, expected); + if (!comm.unique1.isEmpty() && !comm.unique2.isEmpty()) { + error(String.format( + "assertDirectoryContentEquals(%s): Some expected %s. Unexpected %s. Missing %s", + baseDir, format(comm.common), format(comm.unique1), format(comm.unique2))); + } else if (!comm.unique1.isEmpty()) { + error(String.format( + "assertDirectoryContentEquals%s: Expected %s. Unexpected %s", + baseDir, format(comm.common), format(comm.unique1))); + } else if (!comm.unique2.isEmpty()) { + error(String.format( + "assertDirectoryContentEquals(%s): Some expected %s. Missing %s", + baseDir, format(comm.common), format(comm.unique2))); + } else { + traceAssert(String.format( + "assertDirectoryContentEquals(%s): Expected %s", + baseDir, format(expected))); + } + } + + public void contains(Path ... expected) { + contains(Set.of(expected)); + } + + public void contains(Set expected) { + currentTest.notifyAssert(); + + var comm = Comm.compare(content, expected); + if (!comm.unique2.isEmpty()) { + error(String.format( + "assertDirectoryContentContains(%s): Some expected %s. Missing %s", + baseDir, format(comm.common), format(comm.unique2))); + } else { + traceAssert(String.format( + "assertDirectoryContentContains(%s): Expected %s", + baseDir, format(expected))); + } + } + + public DirectoryContentVerifier removeAll(Path ... paths) { + Set newContent = new HashSet<>(content); + newContent.removeAll(List.of(paths)); + return new DirectoryContentVerifier(baseDir, newContent); + } + + private DirectoryContentVerifier(Path baseDir, Set contents) { + this.baseDir = baseDir; + this.content = contents; + } + + private static record Comm(Set common, Set unique1, Set unique2) { + static Comm compare(Set a, Set b) { + Set common = new HashSet<>(a); + common.retainAll(b); + + Set unique1 = new HashSet<>(a); + unique1.removeAll(common); + + Set unique2 = new HashSet<>(b); + unique2.removeAll(common); + + return new Comm(common, unique1, unique2); + } + } + + private static String format(Set paths) { + return Arrays.toString( + paths.stream().sorted().map(Path::toString).toArray( + String[]::new)); + } + + private final Path baseDir; + private final Set content; + } + public static void assertStringListEquals(List expected, List actual, String msg) { currentTest.notifyAssert(); @@ -801,7 +931,7 @@ public void close() throws IOException { }; } - public final static class TextStreamVerifier { + public static final class TextStreamVerifier { TextStreamVerifier(String value) { this.value = value; predicate(String::contains); @@ -864,7 +994,7 @@ public void apply(Stream lines) { private String label; private boolean negate; private Supplier createException; - final private String value; + private final String value; } public static TextStreamVerifier assertTextStream(String what) { diff --git a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/TestBuilder.java b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/TestBuilder.java index 27da5a0a28c..bb699ba3b9c 100644 --- a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/TestBuilder.java +++ b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/TestBuilder.java @@ -392,6 +392,9 @@ private static Stream toMethodCalls(Object[] ctorArgs, Method method } private static Object fromString(String value, Class toType) { + if (toType.isEnum()) { + return Enum.valueOf(toType, value); + } Function converter = conv.get(toType); if (converter == null) { throw new RuntimeException(String.format( diff --git a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/WindowsHelper.java b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/WindowsHelper.java index 1a4dbd22897..b7fd904325d 100644 --- a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/WindowsHelper.java +++ b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/WindowsHelper.java @@ -322,7 +322,7 @@ private void verifyStartMenuShortcut(Path shortcutsRoot, boolean exists) { Path shortcutPath = shortcutsRoot.resolve(startMenuShortcutPath); verifyShortcut(shortcutPath, exists); if (!exists) { - TKit.assertPathNotEmptyDirectory(shortcutPath.getParent()); + TKit.assertDirectoryNotEmpty(shortcutPath.getParent()); } } diff --git a/test/jdk/tools/jpackage/junit/jdk.jpackage/jdk/jpackage/internal/DeployParamsTest.java b/test/jdk/tools/jpackage/junit/jdk.jpackage/jdk/jpackage/internal/DeployParamsTest.java index 53fe04509b0..18ca8836790 100644 --- a/test/jdk/tools/jpackage/junit/jdk.jpackage/jdk/jpackage/internal/DeployParamsTest.java +++ b/test/jdk/tools/jpackage/junit/jdk.jpackage/jdk/jpackage/internal/DeployParamsTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,12 +22,9 @@ */ package jdk.jpackage.internal; -import java.nio.file.Path; -import java.io.IOException; import org.hamcrest.BaseMatcher; import org.hamcrest.Description; import org.junit.Rule; -import org.junit.Before; import org.junit.Test; import org.junit.rules.ExpectedException; import org.junit.rules.TemporaryFolder; @@ -40,11 +37,6 @@ public class DeployParamsTest { @Rule public final ExpectedException thrown = ExpectedException.none(); - @Before - public void setUp() throws IOException { - testRoot = tempFolder.newFolder().toPath(); - } - @Test public void testValidAppName() throws PackagerException { initParamsAppName(); @@ -115,7 +107,6 @@ public void describeTo(Description d) { private void initParamsAppName() { params = new DeployParams(); - params.setOutput(testRoot); params.addBundleArgument(Arguments.CLIOptions.APPCLASS.getId(), "TestClass"); params.addBundleArgument(Arguments.CLIOptions.MAIN_JAR.getId(), @@ -128,6 +119,5 @@ private void setAppNameAndValidate(String appName) throws PackagerException { params.validate(); } - private Path testRoot = null; private DeployParams params; } diff --git a/test/jdk/tools/jpackage/share/AppContentTest.java b/test/jdk/tools/jpackage/share/AppContentTest.java index a343e20d8a7..94362530751 100644 --- a/test/jdk/tools/jpackage/share/AppContentTest.java +++ b/test/jdk/tools/jpackage/share/AppContentTest.java @@ -21,23 +21,25 @@ * questions. */ -import java.nio.file.Path; +import java.io.IOException; import java.nio.file.Files; -import jdk.jpackage.internal.ApplicationLayout; +import java.nio.file.Path; import jdk.jpackage.test.PackageTest; -import jdk.jpackage.test.PackageType; import jdk.jpackage.test.TKit; import jdk.jpackage.test.Annotations.Test; -import jdk.jpackage.test.Annotations.Parameter; import jdk.jpackage.test.Annotations.Parameters; import java.util.Arrays; import java.util.Collection; import java.util.List; +import static java.util.stream.Collectors.joining; +import java.util.stream.Stream; +import jdk.jpackage.internal.IOUtils; +import jdk.jpackage.test.Functional.ThrowingFunction; +import jdk.jpackage.test.JPackageCommand; -import jdk.internal.util.OSVersion; /** - * Tests generation of packages with input folder containing empty folders. + * Tests generation of packages with additional content in app image. */ /* @@ -55,14 +57,18 @@ */ public class AppContentTest { - private static final String TEST_JAVA = TKit.TEST_SRC_ROOT.resolve( - "apps/PrintEnv.java").toString(); - private static final String TEST_DUKE = TKit.TEST_SRC_ROOT.resolve( - "apps/dukeplug.png").toString(); - private static final String TEST_DIR = TKit.TEST_SRC_ROOT.resolve( - "apps").toString(); - private static final String TEST_BAD = TKit.TEST_SRC_ROOT.resolve( - "non-existant").toString(); + private static final String TEST_JAVA = "apps/PrintEnv.java"; + private static final String TEST_DUKE = "apps/dukeplug.png"; + private static final String TEST_DIR = "apps"; + private static final String TEST_BAD = "non-existant"; + + // On OSX `--app-content` paths will be copied into the "Contents" folder + // of the output app image. + // "codesign" imposes restrictions on the directory structure of "Contents" folder. + // In particular, random files should be placed in "Contents/Resources" folder + // otherwise "codesign" will fail to sign. + // Need to prepare arguments for `--app-content` accordingly. + private final static boolean copyInResources = TKit.isOSX(); private final List testPathArgs; @@ -82,37 +88,90 @@ public AppContentTest(String... testPathArgs) { @Test public void test() throws Exception { - - // On macOS signing may or may not work for modified app bundles. - // It works on macOS 15 and up, but fails on macOS below 15. final int expectedJPackageExitCode; - final boolean isMacOS15 = (OSVersion.current().compareTo( - new OSVersion(15, 0, 0)) > 0); - if (testPathArgs.contains(TEST_BAD) || (TKit.isOSX() && !isMacOS15)) { + if (testPathArgs.contains(TEST_BAD)) { expectedJPackageExitCode = 1; } else { expectedJPackageExitCode = 0; } + var appContentInitializer = new AppContentInitializer(testPathArgs); + new PackageTest().configureHelloApp() - .addInitializer(cmd -> { - for (String arg : testPathArgs) { - cmd.addArguments("--app-content", arg); - } - }) + .addRunOnceInitializer(appContentInitializer::initAppContent) + .addInitializer(appContentInitializer::applyTo) .addInstallVerifier(cmd -> { - ApplicationLayout appLayout = cmd.appLayout(); - Path contentDir = appLayout.contentDirectory(); + Path baseDir = getAppContentRoot(cmd); for (String arg : testPathArgs) { List paths = Arrays.asList(arg.split(",")); for (String p : paths) { Path name = Path.of(p).getFileName(); - TKit.assertPathExists(contentDir.resolve(name), true); + TKit.assertPathExists(baseDir.resolve(name), true); } } }) .setExpectedExitCode(expectedJPackageExitCode) .run(); + } + + private static Path getAppContentRoot(JPackageCommand cmd) { + Path contentDir = cmd.appLayout().contentDirectory(); + if (copyInResources) { + return contentDir.resolve("Resources"); + } else { + return contentDir; } + } + + private static final class AppContentInitializer { + AppContentInitializer(List appContentArgs) { + appContentPathGroups = appContentArgs.stream().map(arg -> { + return Stream.of(arg.split(",")).map(Path::of).toList(); + }).toList(); + } + + void initAppContent() { + jpackageArgs = appContentPathGroups.stream() + .map(AppContentInitializer::initAppContentPaths) + .mapMulti((appContentPaths, consumer) -> { + consumer.accept("--app-content"); + consumer.accept( + appContentPaths.stream().map(Path::toString).collect( + joining(","))); + }).toList(); + } + + void applyTo(JPackageCommand cmd) { + cmd.addArguments(jpackageArgs); + } + + private static Path copyAppContentPath(Path appContentPath) throws IOException { + var appContentArg = TKit.createTempDirectory("app-content").resolve("Resources"); + var srcPath = TKit.TEST_SRC_ROOT.resolve(appContentPath); + var dstPath = appContentArg.resolve(srcPath.getFileName()); + Files.createDirectories(dstPath.getParent()); + IOUtils.copyRecursive(srcPath, dstPath); + return appContentArg; + } + + private static List initAppContentPaths(List appContentPaths) { + if (copyInResources) { + return appContentPaths.stream().map(appContentPath -> { + if (appContentPath.endsWith(TEST_BAD)) { + return appContentPath; + } else { + return ThrowingFunction.toFunction( + AppContentInitializer::copyAppContentPath).apply( + appContentPath); + } + }).toList(); + } else { + return appContentPaths.stream().map(TKit.TEST_SRC_ROOT::resolve).toList(); + } + } + + private List jpackageArgs; + private final List> appContentPathGroups; + } } diff --git a/test/jdk/tools/jpackage/share/EmptyFolderBase.java b/test/jdk/tools/jpackage/share/EmptyFolderBase.java deleted file mode 100644 index 092996ad039..00000000000 --- a/test/jdk/tools/jpackage/share/EmptyFolderBase.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2020, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -import java.io.File; -import java.io.IOException; -import java.nio.file.Path; -import jdk.jpackage.test.TKit; - -public class EmptyFolderBase { - - // Note: To specify file use ".txt" extension. - // Note: createDirStrcture() will call mkdir() or createNewFile() for paths defined - // in dirStruct, so make sure paths are defined in order. - - // folder-empty - // folder-not-empty - // folder-not-empty/folder-empty - // folder-not-empty/another-folder-empty - // folder-not-empty/folder-non-empty2 - // folder-not-empty/folder-non-empty2/file.txt - private static final String [] DIR_STRUCT = { - "folder-empty", - "folder-not-empty", - "folder-not-empty" + File.separator + "folder-empty", - "folder-not-empty" + File.separator + "another-folder-empty", - "folder-not-empty" + File.separator + "folder-non-empty2", - "folder-not-empty" + File.separator + "folder-non-empty2" + File.separator + - "file.txt" - }; - - // See dirStruct - public static void createDirStrcture(Path inputPath) throws IOException { - File input = new File(inputPath.toString()); - input.mkdir(); - - for (String p : DIR_STRUCT) { - File f = new File(input, p); - if (p.endsWith(".txt")) { - f.createNewFile(); - } else { - f.mkdir(); - } - } - } - - public static void validateDirStrcture(Path appDirPath) { - for (String p : DIR_STRUCT) { - Path path = appDirPath.resolve(p); - TKit.assertPathExists(path, true); - } - } -} diff --git a/test/jdk/tools/jpackage/share/EmptyFolderPackageTest.java b/test/jdk/tools/jpackage/share/EmptyFolderPackageTest.java deleted file mode 100644 index c7af050c685..00000000000 --- a/test/jdk/tools/jpackage/share/EmptyFolderPackageTest.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (c) 2020, 2021, 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -import java.nio.file.Path; -import jdk.jpackage.internal.ApplicationLayout; -import jdk.jpackage.test.PackageTest; -import jdk.jpackage.test.PackageType; -import jdk.jpackage.test.Annotations.Test; - -/** - * Tests generation of packages with input folder containing empty folders. - */ - -/* - * @test - * @summary jpackage with input containing empty folders - * @library ../helpers - * @library /test/lib - * @key jpackagePlatformPackage - * @build EmptyFolderBase - * @build jdk.jpackage.test.* - * @build EmptyFolderPackageTest - * @modules jdk.jpackage/jdk.jpackage.internal - * @run main/othervm/timeout=720 -Xmx512m jdk.jpackage.test.Main - * --jpt-run=EmptyFolderPackageTest - */ -public class EmptyFolderPackageTest { - - @Test - public static void test() throws Exception { - new PackageTest().configureHelloApp() - .addInitializer(cmd -> { - Path input = cmd.inputDir(); - EmptyFolderBase.createDirStrcture(input); - }) - .addInstallVerifier(cmd -> { - if (cmd.packageType() == PackageType.WIN_MSI) { - if (cmd.isPackageUnpacked("Not running file " - + "structure check for empty folders")) { - return; - } - } - - ApplicationLayout appLayout = cmd.appLayout(); - Path appDir = appLayout.appDirectory(); - EmptyFolderBase.validateDirStrcture(appDir); - }) - .run(); - } -} diff --git a/test/jdk/tools/jpackage/share/EmptyFolderTest.java b/test/jdk/tools/jpackage/share/EmptyFolderTest.java index a41c4a66702..230d8a039ea 100644 --- a/test/jdk/tools/jpackage/share/EmptyFolderTest.java +++ b/test/jdk/tools/jpackage/share/EmptyFolderTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,44 +21,113 @@ * questions. */ +import java.io.IOException; +import java.nio.file.Files; import java.nio.file.Path; -import jdk.jpackage.test.JPackageCommand; +import jdk.jpackage.test.PackageTest; import jdk.jpackage.test.Annotations.Test; -import jdk.jpackage.internal.ApplicationLayout; +import jdk.jpackage.test.JPackageCommand; +import jdk.jpackage.test.PackageType; +import jdk.jpackage.test.TKit; /** - * Tests generation of app image with input folder containing empty folders. + * Tests generation of packages and app image with input folder containing empty folders. + */ + +/* + * @test + * @summary jpackage for package with input containing empty folders + * @library ../helpers + * @library /test/lib + * @key jpackagePlatformPackage + * @build jdk.jpackage.test.* + * @build EmptyFolderTest + * @modules jdk.jpackage/jdk.jpackage.internal + * @run main/othervm/timeout=720 -Xmx512m jdk.jpackage.test.Main + * --jpt-run=EmptyFolderTest.testPackage */ /* * @test - * @summary jpackage with input containing empty folders + * @summary jpackage for app image with input containing empty folders * @library ../helpers * @library /test/lib - * @build EmptyFolderBase * @build jdk.jpackage.test.* * @build EmptyFolderTest * @modules jdk.jpackage/jdk.jpackage.internal * @run main/othervm -Xmx512m jdk.jpackage.test.Main - * --jpt-run=EmptyFolderTest + * --jpt-run=EmptyFolderTest.testAppImage */ + public class EmptyFolderTest { @Test - public static void test() throws Exception { - JPackageCommand cmd = JPackageCommand.helloAppImage(); + public static void testPackage() { + new PackageTest() + .configureHelloApp() + .addInitializer(EmptyFolderTest::createDirTree) + .addInitializer(cmd -> { + cmd.setArgumentValue("--name", "EmptyFolderPackageTest"); + }) + .addInstallVerifier(EmptyFolderTest::validateDirTree) + .run(); + } + + @Test + public static void testAppImage() throws IOException { + var cmd = JPackageCommand.helloAppImage(); // Add more files into input folder - Path input = cmd.inputDir(); - EmptyFolderBase.createDirStrcture(input); + createDirTree(cmd); // Create app image cmd.executeAndAssertHelloAppImageCreated(); - // Verify directory strcture - ApplicationLayout appLayout = cmd.appLayout(); - Path appDir = appLayout.appDirectory(); - EmptyFolderBase.validateDirStrcture(appDir); + // Verify directory structure + validateDirTree(cmd); + } + + private static void createDirTree(JPackageCommand cmd) throws IOException { + var baseDir = cmd.inputDir(); + for (var path : DIR_STRUCT) { + path = baseDir.resolve(path); + if (isFile(path)) { + Files.createDirectories(path.getParent()); + Files.write(path, new byte[0]); + } else { + Files.createDirectories(path); + } + } + } + + private static void validateDirTree(JPackageCommand cmd) { + var outputBaseDir = cmd.appLayout().appDirectory(); + var inputBaseDir = cmd.inputDir(); + for (var path : DIR_STRUCT) { + Path outputPath = outputBaseDir.resolve(path); + if (isFile(outputPath)) { + TKit.assertFileExists(outputPath); + } else if (!PackageType.WINDOWS.contains(cmd.packageType())) { + TKit.assertDirectoryExists(outputPath); + } else if (inputBaseDir.resolve(path).toFile().list().length == 0) { + // MSI packages don't support empty folders + TKit.assertPathExists(outputPath, false); + } else { + TKit.assertDirectoryNotEmpty(outputPath); + } + } + } + + private static boolean isFile(Path path) { + return path.getFileName().toString().endsWith(".txt"); } + // Note: To specify file use ".txt" extension. + private static final Path [] DIR_STRUCT = { + Path.of("folder-empty"), + Path.of("folder-not-empty"), + Path.of("folder-not-empty", "folder-empty"), + Path.of("folder-not-empty", "another-folder-empty"), + Path.of("folder-not-empty", "folder-non-empty2", "file.txt") + }; } diff --git a/test/jdk/tools/jpackage/share/InOutPathTest.java b/test/jdk/tools/jpackage/share/InOutPathTest.java new file mode 100644 index 00000000000..699d88e3189 --- /dev/null +++ b/test/jdk/tools/jpackage/share/InOutPathTest.java @@ -0,0 +1,266 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; +import java.util.Set; +import java.util.function.Predicate; +import static java.util.stream.Collectors.toSet; +import java.util.stream.Stream; +import jdk.jpackage.internal.AppImageFile; +import jdk.jpackage.internal.ApplicationLayout; +import jdk.jpackage.internal.PackageFile; +import jdk.jpackage.test.Annotations; +import jdk.jpackage.test.Annotations.Test; +import jdk.jpackage.test.Functional.ThrowingConsumer; +import jdk.jpackage.test.JPackageCommand; +import jdk.jpackage.test.JPackageCommand.AppLayoutAssert; +import jdk.jpackage.test.PackageTest; +import jdk.jpackage.test.PackageType; +import static jdk.jpackage.test.RunnablePackageTest.Action.CREATE_AND_UNPACK; +import jdk.jpackage.test.TKit; + +/* + * @test + * @summary Test jpackage command line with overlapping input and output paths + * @library ../helpers + * @build jdk.jpackage.test.* + * @modules jdk.jpackage/jdk.jpackage.internal + * @compile InOutPathTest.java + * @run main/othervm/timeout=360 -Xmx512m jdk.jpackage.test.Main + * --jpt-run=InOutPathTest + */ +public final class InOutPathTest { + + @Annotations.Parameters + public static Collection input() { + List data = new ArrayList<>(); + + for (var packageTypes : List.of(PackageType.IMAGE.toString(), ALL_NATIVE_PACKAGE_TYPES)) { + data.addAll(List.of(new Object[][]{ + {packageTypes, wrap(InOutPathTest::outputDirInInputDir, "--dest in --input")}, + {packageTypes, wrap(InOutPathTest::outputDirSameAsInputDir, "--dest same as --input")}, + {packageTypes, wrap(InOutPathTest::tempDirInInputDir, "--temp in --input")}, + {packageTypes, wrap(cmd -> { + outputDirInInputDir(cmd); + tempDirInInputDir(cmd); + }, "--dest and --temp in --input")}, + })); + data.addAll(additionalContentInput(packageTypes, "--app-content")); + } + + data.addAll(List.of(new Object[][]{ + {PackageType.IMAGE.toString(), wrap(cmd -> { + additionalContent(cmd, "--app-content", cmd.outputBundle()); + }, "--app-content same as output bundle")}, + })); + + if (TKit.isOSX()) { + data.addAll(additionalContentInput(PackageType.MAC_DMG.toString(), + "--mac-dmg-content")); + } + + return data; + } + + private static List additionalContentInput(String packageTypes, String argName) { + List data = new ArrayList<>(); + + data.addAll(List.of(new Object[][]{ + {packageTypes, wrap(cmd -> { + additionalContent(cmd, argName, cmd.inputDir()); + }, argName + " same as --input")}, + })); + + if (!TKit.isOSX()) { + data.addAll(List.of(new Object[][]{ + {packageTypes, wrap(cmd -> { + additionalContent(cmd, argName, cmd.inputDir().resolve("foo")); + }, argName + " in --input")}, + {packageTypes, wrap(cmd -> { + additionalContent(cmd, argName, cmd.outputDir().resolve("bar")); + }, argName + " in --dest")}, + {packageTypes, wrap(cmd -> { + additionalContent(cmd, argName, cmd.outputDir()); + }, argName + " same as --dest")}, + {packageTypes, wrap(cmd -> { + tempDirInInputDir(cmd); + var tempDir = cmd.getArgumentValue("--temp"); + Files.createDirectories(Path.of(tempDir)); + cmd.addArguments(argName, tempDir); + }, argName + " as --temp; --temp in --input")}, + })); + } + + return data; + } + + public InOutPathTest(String packageTypes, Envelope configure) { + if (ALL_NATIVE_PACKAGE_TYPES.equals(packageTypes)) { + this.packageTypes = PackageType.NATIVE; + } else { + this.packageTypes = Stream.of(packageTypes.split(",")).map( + PackageType::valueOf).collect(toSet()); + } + this.configure = configure.value; + } + + @Test + public void test() throws Throwable { + runTest(packageTypes, configure); + } + + private static Envelope wrap(ThrowingConsumer v, String label) { + return new Envelope(v, label); + } + + private static boolean isAppImageValid(JPackageCommand cmd) { + return !cmd.hasArgument("--app-content") && !cmd.hasArgument("--mac-dmg-content"); + } + + private static void runTest(Set packageTypes, + ThrowingConsumer configure) throws Throwable { + ThrowingConsumer configureWrapper = cmd -> { + // Make sure the input directory is empty in every test run. + // This is needed because jpackage output directories in this test + // are subdirectories of the input directory. + cmd.setInputToEmptyDirectory(); + configure.accept(cmd); + if (cmd.hasArgument("--temp") && cmd.isImagePackageType()) { + // Request to build app image wit user supplied temp directory, + // ignore external runtime if any to make use of the temp directory + // for runtime generation. + cmd.ignoreDefaultRuntime(true); + } else { + cmd.setFakeRuntime(); + } + + if (!isAppImageValid(cmd)) { + // Standard asserts for .jpackage.xml fail in messed up app image. Disable them. + // Other standard asserts for app image contents should pass. + cmd.excludeAppLayoutAsserts(AppLayoutAssert.APP_IMAGE_FILE); + } + }; + + if (packageTypes.contains(PackageType.IMAGE)) { + JPackageCommand cmd = JPackageCommand.helloAppImage(JAR_PATH.toString() + ":"); + configureWrapper.accept(cmd); + cmd.executeAndAssertHelloAppImageCreated(); + if (isAppImageValid(cmd)) { + verifyAppImage(cmd); + } + } else { + new PackageTest() + .forTypes(packageTypes) + .configureHelloApp(JAR_PATH.toString() + ":") + .addInitializer(configureWrapper) + .addInstallVerifier(InOutPathTest::verifyAppImage) + .run(CREATE_AND_UNPACK); + } + } + + private static void outputDirInInputDir(JPackageCommand cmd) throws + IOException { + // Set output dir as a subdir of input dir + Path outputDir = cmd.inputDir().resolve("out"); + TKit.createDirectories(outputDir); + cmd.setArgumentValue("--dest", outputDir); + } + + private static void outputDirSameAsInputDir(JPackageCommand cmd) throws + IOException { + // Set output dir the same as the input dir + cmd.setArgumentValue("--dest", cmd.inputDir()); + } + + private static void tempDirInInputDir(JPackageCommand cmd) { + // Set temp dir as a subdir of input dir + Path tmpDir = cmd.inputDir().resolve("tmp"); + cmd.setArgumentValue("--temp", tmpDir); + } + + private static void additionalContent(JPackageCommand cmd, + String argName, Path base) throws IOException { + Path appContentFile = base.resolve(base.toString().replaceAll("[\\\\/]", + "-") + "-foo.txt"); + TKit.createDirectories(appContentFile.getParent()); + TKit.createTextFile(appContentFile, List.of("Hello Duke!")); + cmd.addArguments(argName, appContentFile.getParent()); + } + + private static void verifyAppImage(JPackageCommand cmd) throws IOException { + if (!isAppImageValid(cmd)) { + // Don't verify the contents of app image as it is invalid. + // jpackage exited without getting stuck in infinite spiral. + // No more expectations from the tool for the give arguments. + return; + } + + final Path rootDir = cmd.isImagePackageType() ? cmd.outputBundle() : cmd.pathToUnpackedPackageFile( + cmd.appInstallationDirectory()); + final Path appDir = ApplicationLayout.platformAppImage().resolveAt( + rootDir).appDirectory(); + + final var knownFiles = Set.of( + JAR_PATH.getName(0).toString(), + PackageFile.getPathInAppImage(Path.of("")).getFileName().toString(), + AppImageFile.getPathInAppImage(Path.of("")).getFileName().toString(), + cmd.name() + ".cfg" + ); + + TKit.assertFileExists(appDir.resolve(JAR_PATH)); + + try (Stream actualFilesStream = Files.list(appDir)) { + var unexpectedFiles = actualFilesStream.map(path -> { + return path.getFileName().toString(); + }).filter(Predicate.not(knownFiles::contains)).toList(); + TKit.assertStringListEquals(List.of(), unexpectedFiles, + "Check there are no unexpected files in `app` folder"); + } + } + + private static final record Envelope(ThrowingConsumer value, String label) { + @Override + public String toString() { + // Will produce the same test description for the same label every + // time it's executed. + // The test runner will keep the same test output directory. + return label; + } + } + + private final Set packageTypes; + private final ThrowingConsumer configure; + + // Placing jar file in the "Resources" subdir of the input directory would allow + // to use the input directory with `--app-content` on OSX. + // For other platforms it doesn't matter. Keep it the same across + // all platforms for simplicity. + private static final Path JAR_PATH = Path.of("Resources/duke.jar"); + + private static final String ALL_NATIVE_PACKAGE_TYPES = "NATIVE"; +} diff --git a/test/jdk/tools/jpackage/share/RuntimeImageTest.java b/test/jdk/tools/jpackage/share/RuntimeImageTest.java index 44088778589..64908b6ac99 100644 --- a/test/jdk/tools/jpackage/share/RuntimeImageTest.java +++ b/test/jdk/tools/jpackage/share/RuntimeImageTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,7 +25,6 @@ import java.nio.file.Path; import jdk.jpackage.test.TKit; import jdk.jpackage.test.Annotations.Test; -import jdk.jpackage.test.Annotations.Parameter; import jdk.jpackage.test.JPackageCommand; import jdk.jpackage.test.JavaTool; import jdk.jpackage.test.Executor; @@ -45,10 +44,7 @@ public class RuntimeImageTest { @Test - @Parameter("0") - @Parameter("1") - @Parameter("2") - public static void test(String compression) throws Exception { + public static void test() throws Exception { final Path workDir = TKit.createTempDirectory("runtime").resolve("data"); final Path jlinkOutputDir = workDir.resolve("temp.runtime"); Files.createDirectories(jlinkOutputDir.getParent()); @@ -58,7 +54,6 @@ public static void test(String compression) throws Exception { .dumpOutput() .addArguments( "--output", jlinkOutputDir.toString(), - "--compress=" + compression, "--add-modules", "ALL-MODULE-PATH", "--strip-debug", "--no-header-files", diff --git a/test/jdk/tools/jpackage/share/RuntimePackageTest.java b/test/jdk/tools/jpackage/share/RuntimePackageTest.java index 12edff1cea5..da58ed3a73c 100644 --- a/test/jdk/tools/jpackage/share/RuntimePackageTest.java +++ b/test/jdk/tools/jpackage/share/RuntimePackageTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -113,7 +113,6 @@ private static PackageTest init(Set types) { .dumpOutput() .addArguments( "--output", runtimeImageDir.toString(), - "--compress=0", "--add-modules", "ALL-MODULE-PATH", "--strip-debug", "--no-header-files", diff --git a/test/jdk/tools/jpackage/share/jdk/jpackage/tests/BasicTest.java b/test/jdk/tools/jpackage/share/jdk/jpackage/tests/BasicTest.java index 7603264c437..5118600d341 100644 --- a/test/jdk/tools/jpackage/share/jdk/jpackage/tests/BasicTest.java +++ b/test/jdk/tools/jpackage/share/jdk/jpackage/tests/BasicTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,9 +28,9 @@ import java.nio.file.Path; import java.util.List; import java.util.ArrayList; +import java.util.Optional; import java.util.function.Function; import java.util.function.Predicate; -import java.util.function.Supplier; import java.util.regex.Pattern; import java.util.stream.Stream; import jdk.jpackage.test.TKit; @@ -42,6 +42,8 @@ import jdk.jpackage.test.JavaTool; import jdk.jpackage.test.Annotations.Test; import jdk.jpackage.test.Annotations.Parameter; +import jdk.jpackage.test.Functional.ThrowingConsumer; +import static jdk.jpackage.test.RunnablePackageTest.Action.CREATE_AND_UNPACK; import static jdk.jpackage.test.WindowsHelper.getTempDirectory; @@ -250,6 +252,63 @@ public void testWhitespaceInPaths() { .executeAndAssertHelloAppImageCreated(); } + @Test + @Parameter("true") + @Parameter("false") + public void testNoOutputDir(boolean appImage) throws Throwable { + var cmd = JPackageCommand.helloAppImage(); + + final var execDir = cmd.outputDir(); + + final ThrowingConsumer initializer = cmdNoOutputDir -> { + cmd.executePrerequisiteActions(); + + final var pkgType = cmdNoOutputDir.packageType(); + + cmdNoOutputDir + .clearArguments() + .addArguments(cmd.getAllArguments()) + // Restore the value of `--type` parameter. + .setPackageType(pkgType) + .removeArgumentWithValue("--dest") + .setArgumentValue("--input", execDir.relativize(cmd.inputDir())) + .setDirectory(execDir) + // Force to use jpackage as executable because we need to + // change the current directory. + .useToolProvider(false); + + Optional.ofNullable(cmdNoOutputDir.getArgumentValue("--runtime-image", + () -> null, Path::of)).ifPresent(runtimePath -> { + if (!runtimePath.isAbsolute()) { + cmdNoOutputDir.setArgumentValue("--runtime-image", + execDir.relativize(runtimePath)); + } + }); + + // JPackageCommand.execute() will not do the cleanup if `--dest` parameter + // is not specified, do it manually. + TKit.createDirectories(execDir); + TKit.deleteDirectoryContentsRecursive(execDir); + }; + + if (appImage) { + var cmdNoOutputDir = new JPackageCommand() + .setPackageType(cmd.packageType()); + initializer.accept(cmdNoOutputDir); + cmdNoOutputDir.executeAndAssertHelloAppImageCreated(); + } else { + // Save time by packing non-functional runtime. + // Build the runtime in app image only. This is sufficient coverage. + cmd.setFakeRuntime(); + new PackageTest() + .addInitializer(initializer) + .addInstallVerifier(HelloApp::executeLauncherAndVerifyOutput) + // Prevent adding `--dest` parameter to jpackage command line. + .ignoreBundleOutputDir() + .run(CREATE_AND_UNPACK); + } + } + @Test @Parameter("ALL-MODULE-PATH") @Parameter("ALL-DEFAULT") @@ -265,49 +324,64 @@ public void testAddModules(String... addModulesArg) { cmd.executeAndAssertHelloAppImageCreated(); } + public static enum TestTempType { + TEMPDIR_EMPTY, + TEMPDIR_NOT_EMPTY, + TEMPDIR_NOT_EXIST, + } + /** * Test --temp option. Doesn't make much sense for app image as temporary * directory is used only on Windows. Test it in packaging mode. - * @throws IOException */ @Test - @Parameter("true") - @Parameter("false") - public void testTemp(boolean withExistingTempDir) throws IOException { + @Parameter("TEMPDIR_EMPTY") + @Parameter("TEMPDIR_NOT_EMPTY") + @Parameter("TEMPDIR_NOT_EXIST") + public void testTemp(TestTempType type) throws IOException { final Path tempRoot = TKit.createTempDirectory("tmp"); - Supplier createTest = () -> { - return new PackageTest() - .configureHelloApp() - // Force save of package bundle in test work directory. - .addInitializer(JPackageCommand::setDefaultInputOutput) - .addInitializer(cmd -> { - Path tempDir = getTempDirectory(cmd, tempRoot); - if (withExistingTempDir) { - Files.createDirectories(tempDir); - } else { - Files.createDirectories(tempDir.getParent()); + var pkgTest = new PackageTest() + .configureHelloApp() + // Force save of package bundle in test work directory. + .addInitializer(JPackageCommand::setDefaultInputOutput) + .addInitializer(cmd -> { + Path tempDir = getTempDirectory(cmd, tempRoot); + switch (type) { + case TEMPDIR_EMPTY -> Files.createDirectories(tempDir); + case TEMPDIR_NOT_EXIST -> Files.createDirectories(tempDir.getParent()); + case TEMPDIR_NOT_EMPTY -> { + Files.createDirectories(tempDir); + TKit.createTextFile(tempDir.resolve("foo.txt"), List.of( + "Hello Duke!")); + } } cmd.addArguments("--temp", tempDir); + } + ); + + if (TestTempType.TEMPDIR_NOT_EMPTY.equals(type)) { + pkgTest.setExpectedExitCode(1).addBundleVerifier(cmd -> { + // Check jpackage didn't use the supplied directory. + Path tempDir = getTempDirectory(cmd, tempRoot); + String[] tempDirContents = tempDir.toFile().list(); + TKit.assertStringListEquals(List.of("foo.txt"), List.of( + tempDirContents), String.format( + "Check the contents of the supplied temporary directory [%s]", + tempDir)); + TKit.assertStringListEquals(List.of("Hello Duke!"), + Files.readAllLines(tempDir.resolve(tempDirContents[0])), + "Check the contents of the file in the supplied temporary directory"); }); - }; + } else { + pkgTest.addBundleVerifier(cmd -> { + // Check jpackage used the supplied directory. + Path tempDir = getTempDirectory(cmd, tempRoot); + TKit.assertDirectoryNotEmpty(tempDir); + }); + } - createTest.get() - .addBundleVerifier(cmd -> { - // Check jpackage actually used the supplied directory. - Path tempDir = getTempDirectory(cmd, tempRoot); - TKit.assertNotEquals(0, tempDir.toFile().list().length, - String.format( - "Check jpackage wrote some data in the supplied temporary directory [%s]", - tempDir)); - }) - .run(PackageTest.Action.CREATE); - - createTest.get() - // Temporary directory should not be empty, - // jpackage should exit with error. - .setExpectedExitCode(1) - .run(PackageTest.Action.CREATE); + pkgTest.run(PackageTest.Action.CREATE); } @Test diff --git a/test/jtreg-ext/requires/VMProps.java b/test/jtreg-ext/requires/VMProps.java index 465c641d442..4f00846116c 100644 --- a/test/jtreg-ext/requires/VMProps.java +++ b/test/jtreg-ext/requires/VMProps.java @@ -323,17 +323,6 @@ protected void vmGC(SafeMap map) { for (GC gc: GC.values()) { map.put("vm.gc." + gc.name(), () -> "" + vmGCProperty.test(gc)); } - - // Special handling for ZGC modes - var vmGCZ = vmGCProperty.test(GC.Z); - var genZ = WB.getBooleanVMFlag("ZGenerational"); - var genZIsDefault = WB.isDefaultVMFlag("ZGenerational"); - // vm.gc.ZGenerational=true means: - // vm.gc.Z is true and ZGenerational is either explicitly true, or default - map.put("vm.gc.ZGenerational", () -> "" + (vmGCZ && (genZ || genZIsDefault))); - // vm.gc.ZSinglegen=true means: - // vm.gc.Z is true and ZGenerational is either explicitly false, or default - map.put("vm.gc.ZSinglegen", () -> "" + (vmGCZ && (!genZ || genZIsDefault))); } /** @@ -388,7 +377,6 @@ protected void vmOptFinalFlags(SafeMap map) { vmOptFinalFlag(map, "UseCompressedOops"); vmOptFinalFlag(map, "UseLargePages"); vmOptFinalFlag(map, "UseVectorizedMismatchIntrinsic"); - vmOptFinalFlag(map, "ZGenerational"); } /** diff --git a/test/langtools/tools/javac/processing/model/type/AnnotatedTypeToString/AnnotatedTypeToString.java b/test/langtools/tools/javac/processing/model/type/AnnotatedTypeToString/AnnotatedTypeToString.java index 54538e44346..6967f271dcd 100644 --- a/test/langtools/tools/javac/processing/model/type/AnnotatedTypeToString/AnnotatedTypeToString.java +++ b/test/langtools/tools/javac/processing/model/type/AnnotatedTypeToString/AnnotatedTypeToString.java @@ -23,7 +23,7 @@ /* * @test - * @bug 8284220 + * @bug 8284220 8342934 * @summary Tests DeclaredType.toString with type annotations present, for example that '@A * Map.Entry' is printed as 'java.util.@A Map.Entry' (and not '@A java.util.Map.Entry' or * 'java.util.@A Entry'). diff --git a/test/langtools/tools/javac/processing/model/type/AnnotatedTypeToString/Test.java b/test/langtools/tools/javac/processing/model/type/AnnotatedTypeToString/Test.java index 570407a363a..8311344ea9d 100644 --- a/test/langtools/tools/javac/processing/model/type/AnnotatedTypeToString/Test.java +++ b/test/langtools/tools/javac/processing/model/type/AnnotatedTypeToString/Test.java @@ -32,6 +32,10 @@ @Target(ElementType.TYPE_USE) @interface A {} +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE_USE) +@interface B {} + public class Test { static class StaticNested { static class InnerMostStaticNested {} @@ -41,8 +45,8 @@ class Inner { class InnerMost {} } - @ExpectedToString("p.Test.@p.A StaticNested") - @A StaticNested i; + @ExpectedToString("p.Test.@p.A @p.B StaticNested") + @A @B StaticNested i; @ExpectedToString("p.Test.StaticNested.@p.A InnerMostStaticNested") StaticNested.@A InnerMostStaticNested j; diff --git a/test/langtools/tools/javac/sealed/PrivateMembersInPermitClause.java b/test/langtools/tools/javac/sealed/PrivateMembersInPermitClause.java new file mode 100644 index 00000000000..0350b74e0e2 --- /dev/null +++ b/test/langtools/tools/javac/sealed/PrivateMembersInPermitClause.java @@ -0,0 +1,182 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/** + * @test + * @bug 8338981 + * @summary Access to private classes should be permitted inside the permits clause of the enclosing top-level class. + * @library /tools/lib + * @modules jdk.compiler/com.sun.tools.javac.api + * jdk.compiler/com.sun.tools.javac.main + * jdk.compiler/com.sun.tools.javac.util + * @build toolbox.ToolBox toolbox.JavacTask toolbox.Task + * @run main PrivateMembersInPermitClause -source 19+ + */ +import java.nio.file.Path; +import java.util.Objects; +import toolbox.Task; +import java.util.List; + +public class PrivateMembersInPermitClause extends toolbox.TestRunner { + + private final toolbox.ToolBox tb; + + public PrivateMembersInPermitClause() { + super(System.err); + tb = new toolbox.ToolBox(); + } + + public static void main(String... args) throws Exception { + new PrivateMembersInPermitClause().runTests(); + } + + public void runTests() throws Exception { + runTests(_ -> new Object[] {}); + } + + /** + * Tests that a private class in the permits clause compiles successfully. + */ + @Test + public void privateClassPermitted() throws Exception { + var root = Path.of("src"); + tb.writeJavaFiles(root, + """ + sealed class S permits S.A { + private static final class A extends S {} + } + """ + ); + + new toolbox.JavacTask(tb) + .files(root.resolve("S.java")) + .run(toolbox.Task.Expect.SUCCESS); + } + + /** + * Tests that a private class from another top-level class in the permits clause fails to compile. + */ + @Test + public void otherTopLevelPrivateClassFails() throws Exception { + var root = Path.of("src"); + tb.writeJavaFiles(root, + """ + public class S { + private static final class A extends S {} + } + sealed class T permits S.A { + } + """ + ); + var expectedErrors = List.of( + "S.java:4:25: compiler.err.report.access: S.A, private, S", + "1 error" + ); + + var compileErrors = new toolbox.JavacTask(tb) + .files(root.resolve("S.java")) + .options("-XDrawDiagnostics") + .run(toolbox.Task.Expect.FAIL) + .getOutputLines(Task.OutputKind.DIRECT); + + if (!Objects.equals(compileErrors, expectedErrors)) { + throw new AssertionError("Expected errors: " + expectedErrors + ", but got: " + compileErrors); + } + } + + /** + * Tests that a private class in the permits clause of an inner class compiles successfully. + */ + @Test + public void privateClassInInnerPermitted() throws Exception { + var root = Path.of("src"); + tb.writeJavaFiles(root, + """ + public sealed class S permits S.T.A { + static class T { + private static final class A extends S {} + } + } + """ + ); + + new toolbox.JavacTask(tb) + .files(root.resolve("S.java")) + .run(toolbox.Task.Expect.SUCCESS); + } + + /** + * Tests that a private class in the permits clause contained in a sibling private inner class compiles successfully. + */ + @Test + public void siblingPrivateClassesPermitted() throws Exception { + var root = Path.of("src"); + tb.writeJavaFiles(root, + """ + public class S { + private static class A { + private static class B extends C.D {} + } + private static class C { + private static class D {} + } + } + """ + ); + + new toolbox.JavacTask(tb) + .files(root.resolve("S.java")) + .run(toolbox.Task.Expect.SUCCESS); + } + + /** + * Tests that a private class in the permits clause of a sealed class does not compile when the release is lower than 19. + */ + @Test + public void testSourceLowerThan19() throws Exception { + var root = Path.of("src"); + tb.writeJavaFiles(root, + """ + sealed class S permits S.A { + private static final class A extends S {} + } + """ + ); + + var expectedErrors = List.of( + "S.java:1:25: compiler.err.report.access: S.A, private, S", + "S.java:2:26: compiler.err.cant.inherit.from.sealed: S", + "2 errors" + ); + + var actualOutput = new toolbox.JavacTask(tb) + .files(root.resolve("S.java")) + .options("--release", "18", "-XDrawDiagnostics") + .run(toolbox.Task.Expect.FAIL) + .getOutputLines(Task.OutputKind.DIRECT); + + if (!Objects.equals(actualOutput, expectedErrors)) { + throw new AssertionError("Expected errors: " + expectedErrors + ", but got: " + actualOutput); + } + } +} diff --git a/test/langtools/tools/javap/ClassWriterCodeIndentTest.java b/test/langtools/tools/javap/ClassWriterCodeIndentTest.java new file mode 100644 index 00000000000..993c0a4364a --- /dev/null +++ b/test/langtools/tools/javap/ClassWriterCodeIndentTest.java @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8034066 + * @summary javap incorrect indentation when CodeWriter called via ClassWriter + * @run main ClassWriterCodeIndentTest + * @modules jdk.jdeps/com.sun.tools.javap + */ + +import java.io.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class ClassWriterCodeIndentTest { + public static void main(String[] args) { + new ClassWriterCodeIndentTest().run(); + } + + public void run() { + /* + * Partial expected output within a larger file. There exists another "Code: " section above, and thus we + * select the second occurrence in `findNthMatchPrecedingSpaces(output, "Code:", 1);` + * ... + * Code: + * 0: iconst_0 + * 1: istore_1 + * StackMap locals: this int + * StackMap stack: + * ... + */ + String output = javap(); + + int codeHeaderIndent = findNthMatchPrecedingSpaces(output, "Code:", 1); + int detailIndent = findNthMatchPrecedingSpaces(output, "StackMap ", 0); + int bytecodeIndent = findNthMatchPrecedingSpaces(output, "0: iconst_0", 0); + + if (detailIndent - codeHeaderIndent != 2) { + error("Details are not indented correctly with respect to code header."); + } + + if (bytecodeIndent - codeHeaderIndent != 5) { + error("Bytecode is not indented correctly with respect to code header."); + } + + if (errors > 0) { + throw new Error(errors + " found."); + } + } + + String javap() { + StringWriter sw = new StringWriter(); + PrintWriter out = new PrintWriter(sw); + int rc = com.sun.tools.javap.Main.run(new String[]{"-c", "-XDdetails:stackMaps", + System.getProperty("test.classes") + "/EmptyLoop.class"}, out); + if (rc != 0) + throw new Error("javap failed. rc=" + rc); + out.close(); + System.out.println(sw.toString()); + return sw.toString(); + } + + public static int findNthMatchPrecedingSpaces(String inputString, String searchString, int occurrence) { + String regex = "^(\\s*)" + Pattern.quote(searchString); + Pattern pattern = Pattern.compile(regex, Pattern.MULTILINE); + Matcher matcher = pattern.matcher(inputString); + + int count = 0; + while (matcher.find()) { + if (count == occurrence) { + return matcher.group(1).length(); + } + count++; + } + + throw new Error("Could not find " + searchString + " in " + inputString); + } + + void error(String msg) { + System.err.println(msg); + errors++; + } + + int errors; +} + +class EmptyLoop { + public void emptyLoop() { + for (int i = 0; i < 10; i++) { + } + } +} \ No newline at end of file diff --git a/test/lib/jdk/test/lib/compiler/InMemoryJavaCompiler.java b/test/lib/jdk/test/lib/compiler/InMemoryJavaCompiler.java index 6016e48bf4e..4722ef3b67a 100644 --- a/test/lib/jdk/test/lib/compiler/InMemoryJavaCompiler.java +++ b/test/lib/jdk/test/lib/compiler/InMemoryJavaCompiler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,11 +26,18 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.OutputStream; +import java.io.StringWriter; +import java.io.Writer; import java.net.URI; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collection; +import java.util.HashMap; +import java.util.LinkedList; import java.util.List; +import java.util.Map; +import java.util.Map.Entry; import javax.tools.FileObject; import javax.tools.ForwardingJavaFileManager; @@ -76,36 +83,6 @@ * */ public class InMemoryJavaCompiler { - private static class MemoryJavaFileObject extends SimpleJavaFileObject { - private final String className; - private final CharSequence sourceCode; - private final ByteArrayOutputStream byteCode; - - public MemoryJavaFileObject(String className, CharSequence sourceCode) { - super(URI.create("string:///" + className.replace('.','/') + Kind.SOURCE.extension), Kind.SOURCE); - this.className = className; - this.sourceCode = sourceCode; - this.byteCode = new ByteArrayOutputStream(); - } - - @Override - public CharSequence getCharContent(boolean ignoreEncodingErrors) { - return sourceCode; - } - - @Override - public OutputStream openOutputStream() throws IOException { - return byteCode; - } - - public byte[] getByteCode() { - return byteCode.toByteArray(); - } - - public String getClassName() { - return className; - } - } private static class FileManagerWrapper extends ForwardingJavaFileManager { private static final Location PATCH_LOCATION = new Location() { @@ -119,12 +96,13 @@ public boolean isOutputLocation() { return false; } }; - private final MemoryJavaFileObject file; + private final SourceFile srcFile; + private ClassFile clsFile; private final String moduleOverride; - public FileManagerWrapper(MemoryJavaFileObject file, String moduleOverride) { + public FileManagerWrapper(SourceFile file, String moduleOverride) { super(getCompiler().getStandardFileManager(null, null, null)); - this.file = file; + this.srcFile = file; this.moduleOverride = moduleOverride; } @@ -132,16 +110,17 @@ public FileManagerWrapper(MemoryJavaFileObject file, String moduleOverride) { public JavaFileObject getJavaFileForOutput(Location location, String className, Kind kind, FileObject sibling) throws IOException { - if (!file.getClassName().equals(className)) { - throw new IOException("Expected class with name " + file.getClassName() + + if (!srcFile.getClassName().equals(className)) { + throw new IOException("Expected class with name " + srcFile.getClassName() + ", but got " + className); } - return file; + clsFile = new ClassFile(className); + return clsFile; } @Override public Location getLocationForModule(Location location, JavaFileObject fo) throws IOException { - if (fo == file && moduleOverride != null) { + if (fo == srcFile && moduleOverride != null) { return PATCH_LOCATION; } return super.getLocationForModule(location, fo); @@ -160,6 +139,100 @@ public boolean hasLocation(Location location) { return super.hasLocation(location) || location == StandardLocation.PATCH_MODULE_PATH; } + public byte[] getByteCode() { + return clsFile.toByteArray(); + } + + } + + // Wraper for class file + static class ClassFile extends SimpleJavaFileObject { + + private final ByteArrayOutputStream baos = new ByteArrayOutputStream(); + + protected ClassFile(String name) { + super(URI.create("memo:///" + name.replace('.', '/') + Kind.CLASS.extension), Kind.CLASS); + } + + @Override + public ByteArrayOutputStream openOutputStream() { return this.baos; } + + byte[] toByteArray() { return baos.toByteArray(); } + } + + // File manager which spawns ClassFile instances by demand + static class FileManager extends ForwardingJavaFileManager { + + private Map classesMap = new HashMap(); + + protected FileManager(JavaFileManager fileManager) { + super(fileManager); + } + + @Override + public ClassFile getJavaFileForOutput(Location location, String name, JavaFileObject.Kind kind, FileObject source) { + ClassFile classFile = new ClassFile(name); + classesMap.put(name, classFile); + return classFile; + } + + public Map getByteCode() { + Map result = new HashMap(); + for (Entry entry : classesMap.entrySet()) { + result.put(entry.getKey(), entry.getValue().toByteArray()); + } + return result; + } + } + + // Wrapper for source file + static class SourceFile extends SimpleJavaFileObject { + + private CharSequence sourceCode; + private String className; + + public SourceFile(String name, CharSequence sourceCode) { + super(URI.create("memo:///" + name.replace('.', '/') + Kind.SOURCE.extension), Kind.SOURCE); + this.sourceCode = sourceCode; + this.className = name; + } + + @Override + public CharSequence getCharContent(boolean ignore) { + return this.sourceCode; + } + + public String getClassName() { + return this.className; + } + } + + /** + * Compiles the list of classes with the given map of name and source code. + * This overloaded version of compile is useful for batch compile use cases. + * + * @param inputMap The map containing the name of the class and corresponding source code + * @throws RuntimeException if the compilation did not succeed + * @return The resulting byte code from the compilation + */ + public static Map compile(Map inputMap) { + Collection sourceFiles = new LinkedList(); + for (Entry entry : inputMap.entrySet()) { + sourceFiles.add(new SourceFile(entry.getKey(), entry.getValue())); + } + + JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); + FileManager fileManager = new FileManager(compiler.getStandardFileManager(null, null, null)); + + Writer writer = new StringWriter(); + Boolean exitCode = compiler.getTask(writer, fileManager, null, null, null, sourceFiles).call(); + if (!exitCode) { + System.out.println("*********** javac output begin ***********"); + System.out.println(writer.toString()); + System.out.println("*********** javac output end ***********"); + throw new RuntimeException("Test bug: in memory compilation failed."); + } + return fileManager.getByteCode(); } /** @@ -173,7 +246,7 @@ public boolean hasLocation(Location location) { * @return The resulting byte code from the compilation */ public static byte[] compile(String className, CharSequence sourceCode, String... options) { - MemoryJavaFileObject file = new MemoryJavaFileObject(className, sourceCode); + SourceFile file = new SourceFile(className, sourceCode); List opts = new ArrayList<>(); String moduleOverride = null; for (String opt : options) { @@ -183,13 +256,13 @@ public static byte[] compile(String className, CharSequence sourceCode, String.. opts.add(opt); } } - try (JavaFileManager fileManager = new FileManagerWrapper(file, moduleOverride)) { + try (FileManagerWrapper fileManager = new FileManagerWrapper(file, moduleOverride)) { CompilationTask task = getCompiler().getTask(null, fileManager, null, opts, null, Arrays.asList(file)); if (!task.call()) { throw new RuntimeException("Could not compile " + className + " with source code " + sourceCode); } - return file.getByteCode(); + return fileManager.getByteCode(); } catch (IOException ioe) { throw new RuntimeException(ioe); } diff --git a/test/lib/jdk/test/lib/security/DiffieHellmanGroup.java b/test/lib/jdk/test/lib/security/DiffieHellmanGroup.java new file mode 100644 index 00000000000..b8f7c0c34be --- /dev/null +++ b/test/lib/jdk/test/lib/security/DiffieHellmanGroup.java @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.test.lib.security; + +import java.math.BigInteger; + +/** + * An enumeration of DH groups for tests. + */ +public enum DiffieHellmanGroup { + + /** + * RFC 7919 - ffdhe2048. + */ + ffdhe2048(new BigInteger("FFFFFFFFFFFFFFFFADF85458A2BB4A9AAFDC5620273D3CF1" + + "D8B9C583CE2D3695A9E13641146433FBCC939DCE249B3EF9" + + "7D2FE363630C75D8F681B202AEC4617AD3DF1ED5D5FD6561" + + "2433F51F5F066ED0856365553DED1AF3B557135E7F57C935" + + "984F0C70E0E68B77E2A689DAF3EFE8721DF158A136ADE735" + + "30ACCA4F483A797ABC0AB182B324FB61D108A94BB2C8E3FB" + + "B96ADAB760D7F4681D4F42A3DE394DF4AE56EDE76372BB19" + + "0B07A7C8EE0A6D709E02FCE1CDF7E2ECC03404CD28342F61" + + "9172FE9CE98583FF8E4F1232EEF28183C3FE3B1B4C6FAD73" + + "3BB5FCBC2EC22005C58EF1837D1683B2C6F34A26C1B2EFFA" + + "886B423861285C97FFFFFFFFFFFFFFFF", 16), 2), + /** + * RFC 7919 - ffdhe3072. + */ + ffdhe3072(new BigInteger("FFFFFFFFFFFFFFFFADF85458A2BB4A9AAFDC5620273D3CF1" + + "D8B9C583CE2D3695A9E13641146433FBCC939DCE249B3EF9" + + "7D2FE363630C75D8F681B202AEC4617AD3DF1ED5D5FD6561" + + "2433F51F5F066ED0856365553DED1AF3B557135E7F57C935" + + "984F0C70E0E68B77E2A689DAF3EFE8721DF158A136ADE735" + + "30ACCA4F483A797ABC0AB182B324FB61D108A94BB2C8E3FB" + + "B96ADAB760D7F4681D4F42A3DE394DF4AE56EDE76372BB19" + + "0B07A7C8EE0A6D709E02FCE1CDF7E2ECC03404CD28342F61" + + "9172FE9CE98583FF8E4F1232EEF28183C3FE3B1B4C6FAD73" + + "3BB5FCBC2EC22005C58EF1837D1683B2C6F34A26C1B2EFFA" + + "886B4238611FCFDCDE355B3B6519035BBC34F4DEF99C0238" + + "61B46FC9D6E6C9077AD91D2691F7F7EE598CB0FAC186D91C" + + "AEFE130985139270B4130C93BC437944F4FD4452E2D74DD3" + + "64F2E21E71F54BFF5CAE82AB9C9DF69EE86D2BC522363A0D" + + "ABC521979B0DEADA1DBF9A42D5C4484E0ABCD06BFA53DDEF" + + "3C1B20EE3FD59D7C25E41D2B66C62E37FFFFFFFFFFFFFFFF", 16), 2), + /** + * RFC 7919 - ffdhe4096. + */ + ffdhe4096(new BigInteger("FFFFFFFFFFFFFFFFADF85458A2BB4A9AAFDC5620273D3CF1" + + "D8B9C583CE2D3695A9E13641146433FBCC939DCE249B3EF9" + + "7D2FE363630C75D8F681B202AEC4617AD3DF1ED5D5FD6561" + + "2433F51F5F066ED0856365553DED1AF3B557135E7F57C935" + + "984F0C70E0E68B77E2A689DAF3EFE8721DF158A136ADE735" + + "30ACCA4F483A797ABC0AB182B324FB61D108A94BB2C8E3FB" + + "B96ADAB760D7F4681D4F42A3DE394DF4AE56EDE76372BB19" + + "0B07A7C8EE0A6D709E02FCE1CDF7E2ECC03404CD28342F61" + + "9172FE9CE98583FF8E4F1232EEF28183C3FE3B1B4C6FAD73" + + "3BB5FCBC2EC22005C58EF1837D1683B2C6F34A26C1B2EFFA" + + "886B4238611FCFDCDE355B3B6519035BBC34F4DEF99C0238" + + "61B46FC9D6E6C9077AD91D2691F7F7EE598CB0FAC186D91C" + + "AEFE130985139270B4130C93BC437944F4FD4452E2D74DD3" + + "64F2E21E71F54BFF5CAE82AB9C9DF69EE86D2BC522363A0D" + + "ABC521979B0DEADA1DBF9A42D5C4484E0ABCD06BFA53DDEF" + + "3C1B20EE3FD59D7C25E41D2B669E1EF16E6F52C3164DF4FB" + + "7930E9E4E58857B6AC7D5F42D69F6D187763CF1D55034004" + + "87F55BA57E31CC7A7135C886EFB4318AED6A1E012D9E6832" + + "A907600A918130C46DC778F971AD0038092999A333CB8B7A" + + "1A1DB93D7140003C2A4ECEA9F98D0ACC0A8291CDCEC97DCF" + + "8EC9B55A7F88A46B4DB5A851F44182E1C68A007E5E655F6A" + + "FFFFFFFFFFFFFFFF", 16), 2); + + + public BigInteger getPrime() { + return prime; + } + + private final BigInteger prime; + + public BigInteger getBase() { + return base; + } + + private final BigInteger base; + + DiffieHellmanGroup(BigInteger prime, int base) { + this.prime = prime; + this.base = BigInteger.valueOf(base); + } +} diff --git a/test/lib/jdk/test/lib/security/SecurityUtils.java b/test/lib/jdk/test/lib/security/SecurityUtils.java index 319416a466c..2885440e2a2 100644 --- a/test/lib/jdk/test/lib/security/SecurityUtils.java +++ b/test/lib/jdk/test/lib/security/SecurityUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2018, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,12 +30,34 @@ import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; +import jdk.test.lib.security.DiffieHellmanGroup; /** * Common library for various security test helper functions. */ public final class SecurityUtils { + /* + * Key Sizes for various algorithms. + */ + private enum KeySize{ + RSA(2048), + DSA(2048), + DH(2048); + + private final int keySize; + KeySize(int keySize) { + this.keySize = keySize; + } + + @Override + public String toString() { + return String.valueOf(keySize); + } + } + + private final static int DEFAULT_SALTSIZE = 16; + private static String getCacerts() { String sep = File.separator; return System.getProperty("java.home") + sep @@ -107,6 +129,44 @@ public static void removeAlgsFromDSigPolicy(String... algs) { removeFromDSigPolicy("disallowAlg", List.of(algs)); } + /** + * Returns a salt size for tests + */ + public static int getTestSaltSize() { + return DEFAULT_SALTSIZE; + } + + /** + * Returns a key size in bits for tests, depending on the specified algorithm + */ + public static int getTestKeySize(String algo) { + return switch (algo) { + case "RSA" -> KeySize.RSA.keySize; + case "DSA" -> KeySize.DSA.keySize; + case "DH", "DiffieHellman" -> KeySize.DH.keySize; + default -> throw new RuntimeException("Test key size not defined for " + algo); + }; + } + + /** + * Returns a DH predefined group for tests + */ + public static DiffieHellmanGroup getTestDHGroup() { + return getTestDHGroup(2048); + } + + /** + * Returns a DH predefined group for tests, depending on the specified prime size + */ + public static DiffieHellmanGroup getTestDHGroup(int primeSize) { + return switch(primeSize) { + case 2048 -> DiffieHellmanGroup.ffdhe2048; + case 3072 -> DiffieHellmanGroup.ffdhe3072; + case 4096 -> DiffieHellmanGroup.ffdhe4096; + default -> throw new RuntimeException("Test DH group not defined for " + primeSize); + }; + } + private static void removeFromDSigPolicy(String rule, List algs) { String value = Security.getProperty("jdk.xml.dsig.secureValidationPolicy"); value = Arrays.stream(value.split(",")) diff --git a/test/micro/org/openjdk/bench/java/lang/CallerClassBench.java b/test/micro/org/openjdk/bench/java/lang/CallerClassBench.java index 01399c7c270..742c1c29b7a 100644 --- a/test/micro/org/openjdk/bench/java/lang/CallerClassBench.java +++ b/test/micro/org/openjdk/bench/java/lang/CallerClassBench.java @@ -36,7 +36,7 @@ @Warmup(iterations = 5, time = 1) @Measurement(iterations = 5, time = 1) -@Fork(value = 3, jvmArgsAppend = {"-Xmx1g", "-Xms1g"}) +@Fork(value = 3, jvmArgs = {"-Xmx1g", "-Xms1g"}) @State(Scope.Benchmark) @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.MICROSECONDS) diff --git a/test/micro/org/openjdk/bench/java/lang/ObjectHashCode.java b/test/micro/org/openjdk/bench/java/lang/ObjectHashCode.java index 9b89f6d1b5a..3cc836cd59e 100644 --- a/test/micro/org/openjdk/bench/java/lang/ObjectHashCode.java +++ b/test/micro/org/openjdk/bench/java/lang/ObjectHashCode.java @@ -50,37 +50,37 @@ public int mode_default() { // Experimental hashCode generation schemes. See synchronizer.cpp get_next_hash /* @Benchmark - @Fork(jvmArgsPrepend = {"-XX:+UnlockExperimentalVMOptions", "-XX:hashCode=0"}) + @Fork(jvmArgs = {"-XX:+UnlockExperimentalVMOptions", "-XX:hashCode=0"}) public int mode_0() { return System.identityHashCode(new Object()); } @Benchmark - @Fork(jvmArgsPrepend = {"-XX:+UnlockExperimentalVMOptions", "-XX:hashCode=1"}) + @Fork(jvmArgs = {"-XX:+UnlockExperimentalVMOptions", "-XX:hashCode=1"}) public int mode_1() { return System.identityHashCode(new Object()); } @Benchmark - @Fork(jvmArgsPrepend = {"-XX:+UnlockExperimentalVMOptions", "-XX:hashCode=2"}) + @Fork(jvmArgs = {"-XX:+UnlockExperimentalVMOptions", "-XX:hashCode=2"}) public int mode_2() { return System.identityHashCode(new Object()); } @Benchmark - @Fork(jvmArgsPrepend = {"-XX:+UnlockExperimentalVMOptions", "-XX:hashCode=3"}) + @Fork(jvmArgs = {"-XX:+UnlockExperimentalVMOptions", "-XX:hashCode=3"}) public int mode_3() { return System.identityHashCode(new Object()); } @Benchmark - @Fork(jvmArgsPrepend = {"-XX:+UnlockExperimentalVMOptions", "-XX:hashCode=4"}) + @Fork(jvmArgs = {"-XX:+UnlockExperimentalVMOptions", "-XX:hashCode=4"}) public int mode_4() { return System.identityHashCode(new Object()); } @Benchmark - @Fork(jvmArgsPrepend = {"-XX:+UnlockExperimentalVMOptions", "-XX:hashCode=5"}) + @Fork(jvmArgs = {"-XX:+UnlockExperimentalVMOptions", "-XX:hashCode=5"}) public int mode_5() { return System.identityHashCode(new Object()); } diff --git a/test/micro/org/openjdk/bench/java/lang/ScopedValues.java b/test/micro/org/openjdk/bench/java/lang/ScopedValues.java index f11bc805b7f..70c97d57551 100644 --- a/test/micro/org/openjdk/bench/java/lang/ScopedValues.java +++ b/test/micro/org/openjdk/bench/java/lang/ScopedValues.java @@ -40,7 +40,7 @@ @Measurement(iterations=10, time=1) @Threads(1) @Fork(value = 1, - jvmArgsPrepend = {"-Djmh.executor.class=org.openjdk.bench.java.lang.ScopedValuesExecutorService", + jvmArgs = {"-Djmh.executor.class=org.openjdk.bench.java.lang.ScopedValuesExecutorService", "-Djmh.executor=CUSTOM", "-Djmh.blackhole.mode=COMPILER", "--enable-preview"}) diff --git a/test/micro/org/openjdk/bench/java/lang/StringHashCode.java b/test/micro/org/openjdk/bench/java/lang/StringHashCode.java index 20735a3bf76..5578712f0f9 100644 --- a/test/micro/org/openjdk/bench/java/lang/StringHashCode.java +++ b/test/micro/org/openjdk/bench/java/lang/StringHashCode.java @@ -96,7 +96,7 @@ public int empty() { @State(Scope.Thread) @Warmup(iterations = 5, time = 1) @Measurement(iterations = 5, time = 1) - @Fork(value = 3, jvmArgsAppend = {"--add-exports", "java.base/java.lang=ALL-UNNAMED", "--add-opens", "java.base/java.lang=ALL-UNNAMED"}) + @Fork(value = 3, jvmArgs = {"--add-exports", "java.base/java.lang=ALL-UNNAMED", "--add-opens", "java.base/java.lang=ALL-UNNAMED"}) public static class Algorithm { private final static String alphabet = "abcdefghijklmnopqrstuvwxyz"; diff --git a/test/micro/org/openjdk/bench/java/lang/classfile/TypeKindBench.java b/test/micro/org/openjdk/bench/java/lang/classfile/TypeKindBench.java index c8d9ad85d54..43d94f0385a 100644 --- a/test/micro/org/openjdk/bench/java/lang/classfile/TypeKindBench.java +++ b/test/micro/org/openjdk/bench/java/lang/classfile/TypeKindBench.java @@ -50,7 +50,7 @@ @OutputTimeUnit(TimeUnit.NANOSECONDS) @Warmup(iterations = 3, time = 2) @Measurement(iterations = 6, time = 1) -@Fork(jvmArgsAppend = "--enable-preview", value = 1) +@Fork(jvmArgs = "--enable-preview", value = 1) @State(Scope.Thread) public class TypeKindBench { diff --git a/test/micro/org/openjdk/bench/java/lang/classfile/Utf8EntryWriteTo.java b/test/micro/org/openjdk/bench/java/lang/classfile/Utf8EntryWriteTo.java index a124b079268..db27d318699 100644 --- a/test/micro/org/openjdk/bench/java/lang/classfile/Utf8EntryWriteTo.java +++ b/test/micro/org/openjdk/bench/java/lang/classfile/Utf8EntryWriteTo.java @@ -56,7 +56,7 @@ @OutputTimeUnit(TimeUnit.NANOSECONDS) @Warmup(iterations = 1, time = 2) @Measurement(iterations = 3, time = 1) -@Fork(jvmArgsAppend = "--enable-preview", value = 3) +@Fork(jvmArgs = "--enable-preview", value = 3) @State(Scope.Thread) public class Utf8EntryWriteTo { static final ClassDesc STRING_BUILDER = ClassDesc.ofDescriptor("Ljava/lang/StringBuilder;"); diff --git a/test/micro/org/openjdk/bench/java/lang/foreign/AllocFromSliceTest.java b/test/micro/org/openjdk/bench/java/lang/foreign/AllocFromSliceTest.java index 390add8801c..16a915af2ed 100644 --- a/test/micro/org/openjdk/bench/java/lang/foreign/AllocFromSliceTest.java +++ b/test/micro/org/openjdk/bench/java/lang/foreign/AllocFromSliceTest.java @@ -45,7 +45,7 @@ @Measurement(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS) @State(org.openjdk.jmh.annotations.Scope.Thread) @OutputTimeUnit(TimeUnit.NANOSECONDS) -@Fork(value = 3, jvmArgsAppend = { "--enable-native-access=ALL-UNNAMED" }) +@Fork(value = 3, jvmArgs = { "--enable-native-access=ALL-UNNAMED" }) public class AllocFromSliceTest extends CLayouts { @Param({"5", "20", "100", "500", "1000"}) diff --git a/test/micro/org/openjdk/bench/java/lang/foreign/AllocFromTest.java b/test/micro/org/openjdk/bench/java/lang/foreign/AllocFromTest.java index fcd79870ca0..520c1ad5a9b 100644 --- a/test/micro/org/openjdk/bench/java/lang/foreign/AllocFromTest.java +++ b/test/micro/org/openjdk/bench/java/lang/foreign/AllocFromTest.java @@ -48,7 +48,7 @@ @Measurement(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS) @State(org.openjdk.jmh.annotations.Scope.Thread) @OutputTimeUnit(TimeUnit.NANOSECONDS) -@Fork(value = 3, jvmArgsAppend = { "--enable-native-access=ALL-UNNAMED" }) +@Fork(value = 3, jvmArgs = { "--enable-native-access=ALL-UNNAMED" }) public class AllocFromTest extends CLayouts { Arena arena = Arena.ofConfined(); diff --git a/test/micro/org/openjdk/bench/java/lang/foreign/AllocTest.java b/test/micro/org/openjdk/bench/java/lang/foreign/AllocTest.java index 4ae2c0364dc..d9b268a1846 100644 --- a/test/micro/org/openjdk/bench/java/lang/foreign/AllocTest.java +++ b/test/micro/org/openjdk/bench/java/lang/foreign/AllocTest.java @@ -50,7 +50,7 @@ @Measurement(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS) @State(org.openjdk.jmh.annotations.Scope.Thread) @OutputTimeUnit(TimeUnit.NANOSECONDS) -@Fork(value = 3, jvmArgsAppend = { "--enable-native-access=ALL-UNNAMED" }) +@Fork(value = 3, jvmArgs = { "--enable-native-access=ALL-UNNAMED" }) public class AllocTest extends CLayouts { Arena arena = Arena.ofConfined(); diff --git a/test/micro/org/openjdk/bench/java/lang/foreign/CallByRefHighArity.java b/test/micro/org/openjdk/bench/java/lang/foreign/CallByRefHighArity.java new file mode 100644 index 00000000000..417a7c39c1a --- /dev/null +++ b/test/micro/org/openjdk/bench/java/lang/foreign/CallByRefHighArity.java @@ -0,0 +1,247 @@ +/* + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package org.openjdk.bench.java.lang.foreign; + +import org.openjdk.jmh.annotations.*; + +import java.lang.foreign.*; +import java.lang.invoke.*; +import java.util.concurrent.TimeUnit; +import java.util.function.Supplier; + +@BenchmarkMode(Mode.AverageTime) +@Warmup(iterations = 5, time = 500, timeUnit = TimeUnit.MILLISECONDS) +@Measurement(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS) +@State(org.openjdk.jmh.annotations.Scope.Thread) +@OutputTimeUnit(TimeUnit.NANOSECONDS) +@Fork(value = 3, jvmArgsAppend = { "--enable-native-access=ALL-UNNAMED", "-Djava.library.path=micro/native" }) +public class CallByRefHighArity { + + static { + System.loadLibrary("CallByRefHighArity"); + } + + @Param + SegmentKind kind; + + public enum SegmentKind { + CONFINED, + SHARED, + GLOBAL, + HEAP + } + + Supplier segmentSupplier; + Arena arena; + + @Setup + public void setup() { + if (kind == SegmentKind.CONFINED) { + arena = Arena.ofConfined(); + MemorySegment segment = arena.allocateFrom(ValueLayout.JAVA_INT, 0); + segmentSupplier = () -> segment; + } else if (kind == SegmentKind.SHARED) { + arena = Arena.ofShared(); + MemorySegment segment = arena.allocateFrom(ValueLayout.JAVA_INT, 0); + segmentSupplier = () -> segment; + } else if (kind == SegmentKind.HEAP) { + byte[] array = new byte[8]; + MemorySegment segment = MemorySegment.ofArray(array); + segmentSupplier = () -> segment; + } else { // global + segmentSupplier = () -> MemorySegment.ofAddress(0); + } + } + + @TearDown + public void tearDown() { + if (arena != null) { + arena.close(); + } + } + + // A shared library that exports the functions below + private static final SymbolLookup LOOKUP = SymbolLookup.loaderLookup(); + + // void noop_params0() {} + private static final MethodHandle MH_NOOP_PARAMS0 = Linker.nativeLinker() + .downcallHandle(FunctionDescriptor.ofVoid(), Linker.Option.critical(true)) + .bindTo(LOOKUP.find("noop_params0").orElseThrow()); + + // void noop_params1(void *param0) {} + private static final MethodHandle MH_NOOP_PARAMS1 = Linker.nativeLinker() + .downcallHandle(FunctionDescriptor.ofVoid( + ValueLayout.ADDRESS + ), Linker.Option.critical(true)) + .bindTo(LOOKUP.find("noop_params1").orElseThrow()); + + // void noop_params2(void *param0, void *param1) {} + private static final MethodHandle MH_NOOP_PARAMS2 = Linker.nativeLinker() + .downcallHandle(FunctionDescriptor.ofVoid( + ValueLayout.ADDRESS, + ValueLayout.ADDRESS + ), Linker.Option.critical(true)) + .bindTo(LOOKUP.find("noop_params2").orElseThrow()); + + // void noop_params3(void *param0, void *param1, void *param2) {} + private static final MethodHandle MH_NOOP_PARAMS3 = Linker.nativeLinker() + .downcallHandle(FunctionDescriptor.ofVoid( + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS + ), Linker.Option.critical(true)) + .bindTo(LOOKUP.find("noop_params3").orElseThrow()); + + // void noop_params4(void *param0, void *param1, void *param2, void *param3) {} + private static final MethodHandle MH_NOOP_PARAMS4 = Linker.nativeLinker() + .downcallHandle(FunctionDescriptor.ofVoid( + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS + ), Linker.Option.critical(true)) + .bindTo(LOOKUP.find("noop_params4").orElseThrow()); + + // void noop_params5(int param0, int param1, void *param2, void *param3, void *param4) {} + private static final MethodHandle MH_NOOP_PARAMS5 = Linker.nativeLinker() + .downcallHandle(FunctionDescriptor.ofVoid( + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS + ), Linker.Option.critical(true)) + .bindTo(LOOKUP.find("noop_params5").orElseThrow()); + + // void noop_params10(void *param0, void *param1, void *param2, void *param3, void *param4, + // void *param5, void *param6, void *param7, void *param8, void *param9) {} + private static final MethodHandle MH_NOOP_PARAMS10 = Linker.nativeLinker() + .downcallHandle(FunctionDescriptor.ofVoid( + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS, + ValueLayout.ADDRESS + ), Linker.Option.critical(true)) + .bindTo(LOOKUP.find("noop_params10").orElseThrow()); + + @Benchmark + public void noop_params0() { + try { + MH_NOOP_PARAMS0.invokeExact(); + } catch (Throwable t) { + throw new AssertionError(t); + } + } + + @Benchmark + public void noop_params1() { + try { + MH_NOOP_PARAMS1.invokeExact( + segmentSupplier.get() + ); + } catch (Throwable t) { + throw new AssertionError(t); + } + } + + @Benchmark + public void noop_params2() { + try { + MH_NOOP_PARAMS2.invokeExact( + segmentSupplier.get(), + segmentSupplier.get() + ); + } catch (Throwable t) { + throw new AssertionError(t); + } + } + + @Benchmark + public void noop_params3() { + try { + MH_NOOP_PARAMS3.invokeExact( + segmentSupplier.get(), + segmentSupplier.get(), + segmentSupplier.get() + ); + } catch (Throwable t) { + throw new AssertionError(t); + } + } + + @Benchmark + public void noop_params4() { + try { + MH_NOOP_PARAMS4.invokeExact( + segmentSupplier.get(), + segmentSupplier.get(), + segmentSupplier.get(), + segmentSupplier.get() + ); + } catch (Throwable t) { + throw new AssertionError(t); + } + } + + @Benchmark + public void noop_params5() { + try { + MH_NOOP_PARAMS5.invokeExact( + segmentSupplier.get(), + segmentSupplier.get(), + segmentSupplier.get(), + segmentSupplier.get(), + segmentSupplier.get() + ); + } catch (Throwable t) { + throw new AssertionError(t); + } + } + + @Benchmark + public void noop_params10() { + try { + MH_NOOP_PARAMS10.invokeExact( + segmentSupplier.get(), + segmentSupplier.get(), + segmentSupplier.get(), + segmentSupplier.get(), + segmentSupplier.get(), + segmentSupplier.get(), + segmentSupplier.get(), + segmentSupplier.get(), + segmentSupplier.get(), + segmentSupplier.get() + ); + } catch (Throwable t) { + throw new AssertionError(t); + } + } +} diff --git a/test/micro/org/openjdk/bench/java/lang/foreign/CallOverheadConstant.java b/test/micro/org/openjdk/bench/java/lang/foreign/CallOverheadConstant.java index 7f20d094b8e..8e618da44ad 100644 --- a/test/micro/org/openjdk/bench/java/lang/foreign/CallOverheadConstant.java +++ b/test/micro/org/openjdk/bench/java/lang/foreign/CallOverheadConstant.java @@ -41,7 +41,7 @@ @Measurement(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS) @State(org.openjdk.jmh.annotations.Scope.Thread) @OutputTimeUnit(TimeUnit.NANOSECONDS) -@Fork(value = 3, jvmArgsAppend = { "--enable-native-access=ALL-UNNAMED", "-Djava.library.path=micro/native" }) +@Fork(value = 3, jvmArgs = { "--enable-native-access=ALL-UNNAMED", "-Djava.library.path=micro/native" }) public class CallOverheadConstant { @Benchmark diff --git a/test/micro/org/openjdk/bench/java/lang/foreign/CallOverheadVirtual.java b/test/micro/org/openjdk/bench/java/lang/foreign/CallOverheadVirtual.java index d6b7028d287..274c11a87cf 100644 --- a/test/micro/org/openjdk/bench/java/lang/foreign/CallOverheadVirtual.java +++ b/test/micro/org/openjdk/bench/java/lang/foreign/CallOverheadVirtual.java @@ -41,7 +41,7 @@ @Measurement(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS) @State(org.openjdk.jmh.annotations.Scope.Thread) @OutputTimeUnit(TimeUnit.NANOSECONDS) -@Fork(value = 3, jvmArgsAppend = { "--enable-native-access=ALL-UNNAMED", "-Djava.library.path=micro/native" }) +@Fork(value = 3, jvmArgs = { "--enable-native-access=ALL-UNNAMED", "-Djava.library.path=micro/native" }) public class CallOverheadVirtual { @Benchmark diff --git a/test/micro/org/openjdk/bench/java/lang/foreign/CriticalCalls.java b/test/micro/org/openjdk/bench/java/lang/foreign/CriticalCalls.java index 0f384f81685..1b62d2c7264 100644 --- a/test/micro/org/openjdk/bench/java/lang/foreign/CriticalCalls.java +++ b/test/micro/org/openjdk/bench/java/lang/foreign/CriticalCalls.java @@ -51,7 +51,7 @@ @Measurement(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS) @State(org.openjdk.jmh.annotations.Scope.Thread) @OutputTimeUnit(TimeUnit.NANOSECONDS) -@Fork(value = 3, jvmArgsAppend = { "--enable-native-access=ALL-UNNAMED", "-Djava.library.path=micro/native" }) +@Fork(value = 3, jvmArgs = { "--enable-native-access=ALL-UNNAMED", "-Djava.library.path=micro/native" }) public class CriticalCalls { static final MethodHandle PINNED; diff --git a/test/micro/org/openjdk/bench/java/lang/foreign/InternalStrLen.java b/test/micro/org/openjdk/bench/java/lang/foreign/InternalStrLen.java index 81ed675c7d9..2db15bfe265 100644 --- a/test/micro/org/openjdk/bench/java/lang/foreign/InternalStrLen.java +++ b/test/micro/org/openjdk/bench/java/lang/foreign/InternalStrLen.java @@ -50,7 +50,7 @@ @Measurement(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS) @State(Scope.Benchmark) @OutputTimeUnit(TimeUnit.NANOSECONDS) -@Fork(value = 3, jvmArgsAppend = {"--add-exports=java.base/jdk.internal.foreign=ALL-UNNAMED", "--enable-native-access=ALL-UNNAMED", "--enable-preview"}) +@Fork(value = 3, jvmArgs = {"--add-exports=java.base/jdk.internal.foreign=ALL-UNNAMED", "--enable-native-access=ALL-UNNAMED", "--enable-preview"}) public class InternalStrLen { private MemorySegment singleByteSegment; diff --git a/test/micro/org/openjdk/bench/java/lang/foreign/LinkUpcall.java b/test/micro/org/openjdk/bench/java/lang/foreign/LinkUpcall.java index 57c8bd029ba..bf1d35801d2 100644 --- a/test/micro/org/openjdk/bench/java/lang/foreign/LinkUpcall.java +++ b/test/micro/org/openjdk/bench/java/lang/foreign/LinkUpcall.java @@ -47,7 +47,7 @@ @Measurement(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS) @State(Scope.Benchmark) @OutputTimeUnit(TimeUnit.MICROSECONDS) -@Fork(value = 3, jvmArgsAppend = { "--enable-native-access=ALL-UNNAMED" }) +@Fork(value = 3, jvmArgs = { "--enable-native-access=ALL-UNNAMED" }) public class LinkUpcall extends CLayouts { static final Linker LINKER = Linker.nativeLinker(); diff --git a/test/micro/org/openjdk/bench/java/lang/foreign/LoopOverNonConstantAsType.java b/test/micro/org/openjdk/bench/java/lang/foreign/LoopOverNonConstantAsType.java index 1fbe431b2f2..834d051cff0 100644 --- a/test/micro/org/openjdk/bench/java/lang/foreign/LoopOverNonConstantAsType.java +++ b/test/micro/org/openjdk/bench/java/lang/foreign/LoopOverNonConstantAsType.java @@ -54,7 +54,7 @@ @Measurement(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS) @State(org.openjdk.jmh.annotations.Scope.Thread) @OutputTimeUnit(TimeUnit.MILLISECONDS) -@Fork(value = 3, jvmArgsAppend = { "-XX:-TieredCompilation" }) +@Fork(value = 3, jvmArgs = { "-XX:-TieredCompilation" }) public class LoopOverNonConstantAsType extends JavaLayouts { static final Unsafe unsafe = Utils.unsafe; diff --git a/test/micro/org/openjdk/bench/java/lang/foreign/LoopOverOfAddress.java b/test/micro/org/openjdk/bench/java/lang/foreign/LoopOverOfAddress.java index 740d8a2c783..91f2c9e4579 100644 --- a/test/micro/org/openjdk/bench/java/lang/foreign/LoopOverOfAddress.java +++ b/test/micro/org/openjdk/bench/java/lang/foreign/LoopOverOfAddress.java @@ -43,7 +43,7 @@ @Measurement(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS) @State(org.openjdk.jmh.annotations.Scope.Thread) @OutputTimeUnit(TimeUnit.MILLISECONDS) -@Fork(value = 3, jvmArgsAppend = { "--enable-native-access=ALL-UNNAMED" }) +@Fork(value = 3, jvmArgs = { "--enable-native-access=ALL-UNNAMED" }) public class LoopOverOfAddress extends JavaLayouts { static final int ITERATIONS = 1_000_000; diff --git a/test/micro/org/openjdk/bench/java/lang/foreign/MemorySegmentCopyUnsafe.java b/test/micro/org/openjdk/bench/java/lang/foreign/MemorySegmentCopyUnsafe.java index 4b6db5f9618..c5cdd26016d 100644 --- a/test/micro/org/openjdk/bench/java/lang/foreign/MemorySegmentCopyUnsafe.java +++ b/test/micro/org/openjdk/bench/java/lang/foreign/MemorySegmentCopyUnsafe.java @@ -45,7 +45,7 @@ @Measurement(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS) @State(org.openjdk.jmh.annotations.Scope.Thread) @OutputTimeUnit(TimeUnit.NANOSECONDS) -@Fork(value = 3, jvmArgsAppend = {"--enable-native-access=ALL-UNNAMED"}) +@Fork(value = 3, jvmArgs = {"--enable-native-access=ALL-UNNAMED"}) public class MemorySegmentCopyUnsafe { static final Unsafe UNSAFE = Utils.unsafe; diff --git a/test/micro/org/openjdk/bench/java/lang/foreign/MemorySegmentGetUnsafe.java b/test/micro/org/openjdk/bench/java/lang/foreign/MemorySegmentGetUnsafe.java index 233c9672935..31303e51141 100644 --- a/test/micro/org/openjdk/bench/java/lang/foreign/MemorySegmentGetUnsafe.java +++ b/test/micro/org/openjdk/bench/java/lang/foreign/MemorySegmentGetUnsafe.java @@ -50,7 +50,7 @@ @Measurement(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS) @State(org.openjdk.jmh.annotations.Scope.Thread) @OutputTimeUnit(TimeUnit.NANOSECONDS) -@Fork(value = 3, jvmArgsAppend = {"--enable-native-access=ALL-UNNAMED"}) +@Fork(value = 3, jvmArgs = {"--enable-native-access=ALL-UNNAMED"}) public class MemorySegmentGetUnsafe { static final Unsafe UNSAFE = Utils.unsafe; diff --git a/test/micro/org/openjdk/bench/java/lang/foreign/MemorySegmentZeroUnsafe.java b/test/micro/org/openjdk/bench/java/lang/foreign/MemorySegmentZeroUnsafe.java index ba705e2ecd4..6a52ed3fc5b 100644 --- a/test/micro/org/openjdk/bench/java/lang/foreign/MemorySegmentZeroUnsafe.java +++ b/test/micro/org/openjdk/bench/java/lang/foreign/MemorySegmentZeroUnsafe.java @@ -44,7 +44,7 @@ @Measurement(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS) @State(org.openjdk.jmh.annotations.Scope.Thread) @OutputTimeUnit(TimeUnit.NANOSECONDS) -@Fork(value = 3, jvmArgsAppend = {"--enable-native-access=ALL-UNNAMED"}) +@Fork(value = 3, jvmArgs = {"--enable-native-access=ALL-UNNAMED"}) public class MemorySegmentZeroUnsafe { static final Unsafe UNSAFE = Utils.unsafe; diff --git a/test/micro/org/openjdk/bench/java/lang/foreign/PointerInvoke.java b/test/micro/org/openjdk/bench/java/lang/foreign/PointerInvoke.java index ab77ae630c1..63975e47c7d 100644 --- a/test/micro/org/openjdk/bench/java/lang/foreign/PointerInvoke.java +++ b/test/micro/org/openjdk/bench/java/lang/foreign/PointerInvoke.java @@ -43,7 +43,7 @@ @Measurement(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS) @State(org.openjdk.jmh.annotations.Scope.Thread) @OutputTimeUnit(TimeUnit.NANOSECONDS) -@Fork(value = 3, jvmArgsAppend = { "--enable-native-access=ALL-UNNAMED", "-Djava.library.path=micro/native" }) +@Fork(value = 3, jvmArgs = { "--enable-native-access=ALL-UNNAMED", "-Djava.library.path=micro/native" }) public class PointerInvoke extends CLayouts { Arena arena = Arena.ofConfined(); diff --git a/test/micro/org/openjdk/bench/java/lang/foreign/QSort.java b/test/micro/org/openjdk/bench/java/lang/foreign/QSort.java index 76298ae0739..b21e812c503 100644 --- a/test/micro/org/openjdk/bench/java/lang/foreign/QSort.java +++ b/test/micro/org/openjdk/bench/java/lang/foreign/QSort.java @@ -46,7 +46,7 @@ @Measurement(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS) @State(org.openjdk.jmh.annotations.Scope.Thread) @OutputTimeUnit(TimeUnit.NANOSECONDS) -@Fork(value = 3, jvmArgsAppend = { "--enable-native-access=ALL-UNNAMED", "-Djava.library.path=micro/native" }) +@Fork(value = 3, jvmArgs = { "--enable-native-access=ALL-UNNAMED", "-Djava.library.path=micro/native" }) public class QSort extends CLayouts { static final Linker abi = Linker.nativeLinker(); diff --git a/test/micro/org/openjdk/bench/java/lang/foreign/SegmentBulkCopy.java b/test/micro/org/openjdk/bench/java/lang/foreign/SegmentBulkCopy.java index 22ef139aac0..ca6f21d20e9 100644 --- a/test/micro/org/openjdk/bench/java/lang/foreign/SegmentBulkCopy.java +++ b/test/micro/org/openjdk/bench/java/lang/foreign/SegmentBulkCopy.java @@ -84,25 +84,25 @@ public void bufferCopy() { dstBuffer.put(srcBuffer); } - @Fork(value = 3, jvmArgsAppend = {"-Djava.lang.foreign.native.threshold.power.copy=31"}) + @Fork(value = 3, jvmArgs = {"-Djava.lang.foreign.native.threshold.power.copy=31"}) @Benchmark public void heapSegmentCopyJava() { MemorySegment.copy(heapSrcSegment, 0, heapDstSegment, 0, ELEM_SIZE); } - @Fork(value = 3, jvmArgsAppend = {"-Djava.lang.foreign.native.threshold.power.copy=0"}) + @Fork(value = 3, jvmArgs = {"-Djava.lang.foreign.native.threshold.power.copy=0"}) @Benchmark public void heapSegmentCopyUnsafe() { MemorySegment.copy(heapSrcSegment, 0, heapDstSegment, 0, ELEM_SIZE); } - @Fork(value = 3, jvmArgsAppend = {"-Djava.lang.foreign.native.threshold.power.copy=31"}) + @Fork(value = 3, jvmArgs = {"-Djava.lang.foreign.native.threshold.power.copy=31"}) @Benchmark public void nativeSegmentCopyJava() { MemorySegment.copy(nativeSrcSegment, 0, nativeDstSegment, 0, ELEM_SIZE); } - @Fork(value = 3, jvmArgsAppend = {"-Djava.lang.foreign.native.threshold.power.copy=0"}) + @Fork(value = 3, jvmArgs = {"-Djava.lang.foreign.native.threshold.power.copy=0"}) @Benchmark public void nativeSegmentCopyUnsafe() { MemorySegment.copy(nativeSrcSegment, 0, nativeDstSegment, 0, ELEM_SIZE); diff --git a/test/micro/org/openjdk/bench/java/lang/foreign/SegmentBulkFill.java b/test/micro/org/openjdk/bench/java/lang/foreign/SegmentBulkFill.java index 95ca7228969..eb19fc56ac2 100644 --- a/test/micro/org/openjdk/bench/java/lang/foreign/SegmentBulkFill.java +++ b/test/micro/org/openjdk/bench/java/lang/foreign/SegmentBulkFill.java @@ -74,37 +74,37 @@ public void arraysFill() { Arrays.fill(array, (byte) 0); } - @Fork(value = 3, jvmArgsAppend = {"-Djava.lang.foreign.native.threshold.power.fill=31"}) + @Fork(value = 3, jvmArgs = {"-Djava.lang.foreign.native.threshold.power.fill=31"}) @Benchmark public void heapSegmentFillJava() { heapSegment.fill((byte) 0); } - @Fork(value = 3, jvmArgsAppend = {"-Djava.lang.foreign.native.threshold.power.fill=0"}) + @Fork(value = 3, jvmArgs = {"-Djava.lang.foreign.native.threshold.power.fill=0"}) @Benchmark public void heapSegmentFillUnsafe() { heapSegment.fill((byte) 0); } - @Fork(value = 3, jvmArgsAppend = {"-Djava.lang.foreign.native.threshold.power.fill=31"}) + @Fork(value = 3, jvmArgs = {"-Djava.lang.foreign.native.threshold.power.fill=31"}) @Benchmark public void nativeSegmentFillJava() { nativeSegment.fill((byte) 0); } - @Fork(value = 3, jvmArgsAppend = {"-Djava.lang.foreign.native.threshold.power.fill=0"}) + @Fork(value = 3, jvmArgs = {"-Djava.lang.foreign.native.threshold.power.fill=0"}) @Benchmark public void nativeSegmentFillUnsafe() { nativeSegment.fill((byte) 0); } - @Fork(value = 3, jvmArgsAppend = {"-Djava.lang.foreign.native.threshold.power.fill=31"}) + @Fork(value = 3, jvmArgs = {"-Djava.lang.foreign.native.threshold.power.fill=31"}) @Benchmark public void unalignedSegmentFillJava() { unalignedSegment.fill((byte) 0); } - @Fork(value = 3, jvmArgsAppend = {"-Djava.lang.foreign.native.threshold.power.fill=0"}) + @Fork(value = 3, jvmArgs = {"-Djava.lang.foreign.native.threshold.power.fill=0"}) @Benchmark public void unalignedSegmentFillUnsafe() { unalignedSegment.fill((byte) 0); diff --git a/test/micro/org/openjdk/bench/java/lang/foreign/SegmentBulkMismatch.java b/test/micro/org/openjdk/bench/java/lang/foreign/SegmentBulkMismatch.java index 5656b2f6b9f..61ceb7b956e 100644 --- a/test/micro/org/openjdk/bench/java/lang/foreign/SegmentBulkMismatch.java +++ b/test/micro/org/openjdk/bench/java/lang/foreign/SegmentBulkMismatch.java @@ -79,25 +79,25 @@ public void setup() { dstHeap = MemorySegment.ofArray(dstArray); } - @Fork(value = 3, jvmArgsAppend = {"-Djava.lang.foreign.native.threshold.power.mismatch=31"}) + @Fork(value = 3, jvmArgs = {"-Djava.lang.foreign.native.threshold.power.mismatch=31"}) @Benchmark public long nativeSegmentJava() { return srcNative.mismatch(dstNative); } - @Fork(value = 3, jvmArgsAppend = {"-Djava.lang.foreign.native.threshold.power.mismatch=31"}) + @Fork(value = 3, jvmArgs = {"-Djava.lang.foreign.native.threshold.power.mismatch=31"}) @Benchmark public long heapSegmentJava() { return srcHeap.mismatch(dstHeap); } - @Fork(value = 3, jvmArgsAppend = {"-Djava.lang.foreign.native.threshold.power.mismatch=0"}) + @Fork(value = 3, jvmArgs = {"-Djava.lang.foreign.native.threshold.power.mismatch=0"}) @Benchmark public long nativeSegmentUnsafe() { return srcNative.mismatch(dstNative); } - @Fork(value = 3, jvmArgsAppend = {"-Djava.lang.foreign.native.threshold.power.mismatch=0"}) + @Fork(value = 3, jvmArgs = {"-Djava.lang.foreign.native.threshold.power.mismatch=0"}) @Benchmark public long heapSegmentUnsafe() { return srcHeap.mismatch(dstHeap); diff --git a/test/micro/org/openjdk/bench/java/lang/foreign/StrLenTest.java b/test/micro/org/openjdk/bench/java/lang/foreign/StrLenTest.java index 2ad723eadf3..04562e0ec00 100644 --- a/test/micro/org/openjdk/bench/java/lang/foreign/StrLenTest.java +++ b/test/micro/org/openjdk/bench/java/lang/foreign/StrLenTest.java @@ -48,7 +48,7 @@ @Measurement(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS) @State(org.openjdk.jmh.annotations.Scope.Thread) @OutputTimeUnit(TimeUnit.NANOSECONDS) -@Fork(value = 3, jvmArgsAppend = { "--enable-native-access=ALL-UNNAMED", "-Djava.library.path=micro/native" }) +@Fork(value = 3, jvmArgs = { "--enable-native-access=ALL-UNNAMED", "-Djava.library.path=micro/native" }) public class StrLenTest extends CLayouts { Arena arena = Arena.ofConfined(); diff --git a/test/micro/org/openjdk/bench/java/lang/foreign/ToCStringTest.java b/test/micro/org/openjdk/bench/java/lang/foreign/ToCStringTest.java index 7ba9384958e..41d7deb2ebe 100644 --- a/test/micro/org/openjdk/bench/java/lang/foreign/ToCStringTest.java +++ b/test/micro/org/openjdk/bench/java/lang/foreign/ToCStringTest.java @@ -51,7 +51,7 @@ @Measurement(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS) @State(org.openjdk.jmh.annotations.Scope.Thread) @OutputTimeUnit(TimeUnit.NANOSECONDS) -@Fork(value = 3, jvmArgsAppend = { "--enable-native-access=ALL-UNNAMED", "-Djava.library.path=micro/native" }) +@Fork(value = 3, jvmArgs = { "--enable-native-access=ALL-UNNAMED", "-Djava.library.path=micro/native" }) public class ToCStringTest extends CLayouts { @Param({"5", "20", "100", "200"}) diff --git a/test/micro/org/openjdk/bench/java/lang/foreign/ToJavaStringTest.java b/test/micro/org/openjdk/bench/java/lang/foreign/ToJavaStringTest.java index f6f26f72a6a..02b1a47d03f 100644 --- a/test/micro/org/openjdk/bench/java/lang/foreign/ToJavaStringTest.java +++ b/test/micro/org/openjdk/bench/java/lang/foreign/ToJavaStringTest.java @@ -43,7 +43,7 @@ @Measurement(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS) @State(Scope.Benchmark) @OutputTimeUnit(TimeUnit.NANOSECONDS) -@Fork(value = 3, jvmArgsAppend = { "--enable-native-access=ALL-UNNAMED", "--enable-preview", "-Djava.library.path=micro/native" }) +@Fork(value = 3, jvmArgs = { "--enable-native-access=ALL-UNNAMED", "--enable-preview", "-Djava.library.path=micro/native" }) public class ToJavaStringTest { private MemorySegment strSegment; diff --git a/test/micro/org/openjdk/bench/java/lang/foreign/UnrolledAccess.java b/test/micro/org/openjdk/bench/java/lang/foreign/UnrolledAccess.java index 6888f82e529..36c2ba32887 100644 --- a/test/micro/org/openjdk/bench/java/lang/foreign/UnrolledAccess.java +++ b/test/micro/org/openjdk/bench/java/lang/foreign/UnrolledAccess.java @@ -40,7 +40,7 @@ @Measurement(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS) @State(org.openjdk.jmh.annotations.Scope.Thread) @OutputTimeUnit(TimeUnit.MICROSECONDS) -@Fork(value = 3, jvmArgsAppend = { "--enable-native-access=ALL-UNNAMED" }) +@Fork(value = 3, jvmArgs = { "--enable-native-access=ALL-UNNAMED" }) public class UnrolledAccess extends JavaLayouts { static final Unsafe U = Utils.unsafe; diff --git a/test/micro/org/openjdk/bench/java/lang/foreign/Upcalls.java b/test/micro/org/openjdk/bench/java/lang/foreign/Upcalls.java index 1b852e6ff9d..9b6ec3fe058 100644 --- a/test/micro/org/openjdk/bench/java/lang/foreign/Upcalls.java +++ b/test/micro/org/openjdk/bench/java/lang/foreign/Upcalls.java @@ -45,7 +45,7 @@ @Measurement(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS) @State(org.openjdk.jmh.annotations.Scope.Thread) @OutputTimeUnit(TimeUnit.NANOSECONDS) -@Fork(value = 3, jvmArgsAppend = { "--enable-native-access=ALL-UNNAMED", "-Djava.library.path=micro/native" }) +@Fork(value = 3, jvmArgs = { "--enable-native-access=ALL-UNNAMED", "-Djava.library.path=micro/native" }) public class Upcalls extends CLayouts { static final Linker abi = Linker.nativeLinker(); diff --git a/src/hotspot/os/bsd/gc/x/xLargePages_bsd.cpp b/test/micro/org/openjdk/bench/java/lang/foreign/libCallByRefHighArity.c similarity index 60% rename from src/hotspot/os/bsd/gc/x/xLargePages_bsd.cpp rename to test/micro/org/openjdk/bench/java/lang/foreign/libCallByRefHighArity.c index 1c82e831208..02eedb79f02 100644 --- a/src/hotspot/os/bsd/gc/x/xLargePages_bsd.cpp +++ b/test/micro/org/openjdk/bench/java/lang/foreign/libCallByRefHighArity.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -21,14 +21,13 @@ * questions. */ -#include "precompiled.hpp" -#include "gc/x/xLargePages.hpp" -#include "runtime/globals.hpp" +#include "export.h" -void XLargePages::pd_initialize() { - if (UseLargePages) { - _state = Explicit; - } else { - _state = Disabled; - } -} +EXPORT void noop_params0() {} +EXPORT void noop_params1(void *param0) {} +EXPORT void noop_params2(void *param0, void *param1) {} +EXPORT void noop_params3(void *param0, void *param1, void *param2) {} +EXPORT void noop_params4(void *param0, void *param1, void *param2, void *param3) {} +EXPORT void noop_params5(void *param0, void *param1, void *param2, void *param3, void *param4) {} +EXPORT void noop_params10(void *param0, void *param1, void *param2, void *param3, void *param4, + void *param5, void *param6, void *param7, void *param8, void *param9) {} diff --git a/test/micro/org/openjdk/bench/java/lang/foreign/pointers/PointerBench.java b/test/micro/org/openjdk/bench/java/lang/foreign/pointers/PointerBench.java index 9eabd7d0e78..b93b613f8c6 100644 --- a/test/micro/org/openjdk/bench/java/lang/foreign/pointers/PointerBench.java +++ b/test/micro/org/openjdk/bench/java/lang/foreign/pointers/PointerBench.java @@ -46,7 +46,7 @@ @Warmup(iterations = 3, time = 500, timeUnit = TimeUnit.MILLISECONDS) @Measurement(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS) @OutputTimeUnit(TimeUnit.MILLISECONDS) -@Fork(value = 3, jvmArgsAppend = { "--enable-native-access=ALL-UNNAMED" }) +@Fork(value = 3, jvmArgs = { "--enable-native-access=ALL-UNNAMED" }) @State(Scope.Benchmark) public class PointerBench { diff --git a/test/micro/org/openjdk/bench/java/lang/foreign/points/PointsAccess.java b/test/micro/org/openjdk/bench/java/lang/foreign/points/PointsAccess.java index e649468fc97..eeedf18c771 100644 --- a/test/micro/org/openjdk/bench/java/lang/foreign/points/PointsAccess.java +++ b/test/micro/org/openjdk/bench/java/lang/foreign/points/PointsAccess.java @@ -43,7 +43,7 @@ @Measurement(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS) @State(org.openjdk.jmh.annotations.Scope.Thread) @OutputTimeUnit(TimeUnit.NANOSECONDS) -@Fork(value = 3, jvmArgsAppend = { "--enable-native-access=ALL-UNNAMED", "-Djava.library.path=micro/native" }) +@Fork(value = 3, jvmArgs = { "--enable-native-access=ALL-UNNAMED", "-Djava.library.path=micro/native" }) public class PointsAccess { BBPoint BBPoint; diff --git a/test/micro/org/openjdk/bench/java/lang/foreign/points/PointsAlloc.java b/test/micro/org/openjdk/bench/java/lang/foreign/points/PointsAlloc.java index f9d254ed975..a210e459c21 100644 --- a/test/micro/org/openjdk/bench/java/lang/foreign/points/PointsAlloc.java +++ b/test/micro/org/openjdk/bench/java/lang/foreign/points/PointsAlloc.java @@ -41,7 +41,7 @@ @Measurement(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS) @State(org.openjdk.jmh.annotations.Scope.Thread) @OutputTimeUnit(TimeUnit.NANOSECONDS) -@Fork(value = 3, jvmArgsAppend = { "--enable-native-access=ALL-UNNAMED", "-Djava.library.path=micro/native" }) +@Fork(value = 3, jvmArgs = { "--enable-native-access=ALL-UNNAMED", "-Djava.library.path=micro/native" }) public class PointsAlloc { @Benchmark diff --git a/test/micro/org/openjdk/bench/java/lang/foreign/points/PointsDistance.java b/test/micro/org/openjdk/bench/java/lang/foreign/points/PointsDistance.java index fa86137ff02..a42b8ac0947 100644 --- a/test/micro/org/openjdk/bench/java/lang/foreign/points/PointsDistance.java +++ b/test/micro/org/openjdk/bench/java/lang/foreign/points/PointsDistance.java @@ -43,7 +43,7 @@ @Measurement(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS) @State(org.openjdk.jmh.annotations.Scope.Thread) @OutputTimeUnit(TimeUnit.NANOSECONDS) -@Fork(value = 3, jvmArgsAppend = { "--enable-native-access=ALL-UNNAMED", "-Djava.library.path=micro/native" }) +@Fork(value = 3, jvmArgs = { "--enable-native-access=ALL-UNNAMED", "-Djava.library.path=micro/native" }) public class PointsDistance { BBPoint jniP1; diff --git a/test/micro/org/openjdk/bench/java/lang/foreign/points/PointsFree.java b/test/micro/org/openjdk/bench/java/lang/foreign/points/PointsFree.java index 51bd7738eda..bb41de670d8 100644 --- a/test/micro/org/openjdk/bench/java/lang/foreign/points/PointsFree.java +++ b/test/micro/org/openjdk/bench/java/lang/foreign/points/PointsFree.java @@ -42,7 +42,7 @@ @Measurement(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS) @State(org.openjdk.jmh.annotations.Scope.Thread) @OutputTimeUnit(TimeUnit.NANOSECONDS) -@Fork(value = 3, jvmArgsAppend = { "--enable-native-access=ALL-UNNAMED", "-Djava.library.path=micro/native" }) +@Fork(value = 3, jvmArgs = { "--enable-native-access=ALL-UNNAMED", "-Djava.library.path=micro/native" }) public class PointsFree { JNIPoint jniPoint; diff --git a/test/micro/org/openjdk/bench/java/lang/foreign/xor/XorTest.java b/test/micro/org/openjdk/bench/java/lang/foreign/xor/XorTest.java index 8ff8a4d1816..40ae114e8fa 100644 --- a/test/micro/org/openjdk/bench/java/lang/foreign/xor/XorTest.java +++ b/test/micro/org/openjdk/bench/java/lang/foreign/xor/XorTest.java @@ -19,7 +19,7 @@ @Measurement(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS) @State(org.openjdk.jmh.annotations.Scope.Thread) @OutputTimeUnit(TimeUnit.MILLISECONDS) -@Fork(value = 3, jvmArgsAppend = { "--enable-native-access=ALL-UNNAMED", "-Djava.library.path=micro/native" }) +@Fork(value = 3, jvmArgs = { "--enable-native-access=ALL-UNNAMED", "-Djava.library.path=micro/native" }) public class XorTest { diff --git a/test/micro/org/openjdk/bench/java/lang/invoke/LazyStaticColdStart.java b/test/micro/org/openjdk/bench/java/lang/invoke/LazyStaticColdStart.java index fb73901adf4..49a77d9539e 100644 --- a/test/micro/org/openjdk/bench/java/lang/invoke/LazyStaticColdStart.java +++ b/test/micro/org/openjdk/bench/java/lang/invoke/LazyStaticColdStart.java @@ -52,7 +52,7 @@ @BenchmarkMode(Mode.SingleShotTime) @OutputTimeUnit(TimeUnit.MICROSECONDS) @State(Scope.Thread) -@Fork(value = 10, warmups = 5, jvmArgsAppend = { +@Fork(value = 10, warmups = 5, jvmArgs = { "--enable-preview" }) public class LazyStaticColdStart { diff --git a/test/micro/org/openjdk/bench/java/lang/invoke/Wrappers.java b/test/micro/org/openjdk/bench/java/lang/invoke/Wrappers.java index 61aea6b6dcf..c1725487529 100644 --- a/test/micro/org/openjdk/bench/java/lang/invoke/Wrappers.java +++ b/test/micro/org/openjdk/bench/java/lang/invoke/Wrappers.java @@ -45,7 +45,7 @@ @Measurement(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS) @OutputTimeUnit(TimeUnit.NANOSECONDS) @State(Scope.Thread) -@Fork(value = 3, jvmArgsAppend = "--add-exports=java.base/sun.invoke.util=ALL-UNNAMED") +@Fork(value = 3, jvmArgs = "--add-exports=java.base/sun.invoke.util=ALL-UNNAMED") public class Wrappers { public static Class[] PRIM_CLASSES = { diff --git a/test/micro/org/openjdk/bench/java/lang/reflect/proxy/ProxyGeneratorBench.java b/test/micro/org/openjdk/bench/java/lang/reflect/proxy/ProxyGeneratorBench.java index 33934317300..6963a040b65 100644 --- a/test/micro/org/openjdk/bench/java/lang/reflect/proxy/ProxyGeneratorBench.java +++ b/test/micro/org/openjdk/bench/java/lang/reflect/proxy/ProxyGeneratorBench.java @@ -45,7 +45,7 @@ */ @Warmup(iterations = 5, time = 2) @Measurement(iterations = 5, time = 2) -@Fork(value = 1, jvmArgsPrepend = "--add-opens=java.base/java.lang.reflect=ALL-UNNAMED") +@Fork(value = 1, jvmArgs = "--add-opens=java.base/java.lang.reflect=ALL-UNNAMED") @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) @State(Scope.Thread) diff --git a/test/micro/org/openjdk/bench/java/net/NetworkInterfaceLookup.java b/test/micro/org/openjdk/bench/java/net/NetworkInterfaceLookup.java index 2a77e6a16ec..4b1a5bc439a 100644 --- a/test/micro/org/openjdk/bench/java/net/NetworkInterfaceLookup.java +++ b/test/micro/org/openjdk/bench/java/net/NetworkInterfaceLookup.java @@ -45,7 +45,7 @@ @BenchmarkMode(Mode.Throughput) @OutputTimeUnit(TimeUnit.SECONDS) @State(Scope.Thread) -@Fork(value = 2, jvmArgsAppend = "--add-opens=java.base/java.net=ALL-UNNAMED") +@Fork(value = 2, jvmArgs = "--add-opens=java.base/java.net=ALL-UNNAMED") @Warmup(iterations = 5, time = 1) @Measurement(iterations = 5, time = 1) public class NetworkInterfaceLookup { diff --git a/test/micro/org/openjdk/bench/java/net/SocketChannelConnectionSetup.java b/test/micro/org/openjdk/bench/java/net/SocketChannelConnectionSetup.java index c4100568161..704cca94af0 100644 --- a/test/micro/org/openjdk/bench/java/net/SocketChannelConnectionSetup.java +++ b/test/micro/org/openjdk/bench/java/net/SocketChannelConnectionSetup.java @@ -125,7 +125,7 @@ public static void main(String[] args) throws RunnerException { opt = new OptionsBuilder() .include(org.openjdk.bench.java.net.SocketChannelConnectionSetup.class.getSimpleName()) - .jvmArgsPrepend("-Djdk.net.useFastTcpLoopback=true") + .jvmArgs("-Djdk.net.useFastTcpLoopback=true") .warmupForks(1) .forks(2) .build(); diff --git a/test/micro/org/openjdk/bench/java/net/SocketEventOverhead.java b/test/micro/org/openjdk/bench/java/net/SocketEventOverhead.java index a898aff5283..f386fb1620d 100644 --- a/test/micro/org/openjdk/bench/java/net/SocketEventOverhead.java +++ b/test/micro/org/openjdk/bench/java/net/SocketEventOverhead.java @@ -45,7 +45,7 @@ @State(Scope.Thread) public class SocketEventOverhead { - @Fork(value = 1, jvmArgsAppend = { + @Fork(value = 1, jvmArgs = { "--add-exports", "java.base/jdk.internal.event=ALL-UNNAMED" }) @Benchmark @@ -53,7 +53,7 @@ public int socketWriteJFRDisabled(SkeletonFixture fixture) { return fixture.write(); } - @Fork(value = 1, jvmArgsAppend = { + @Fork(value = 1, jvmArgs = { "--add-exports", "java.base/jdk.internal.event=ALL-UNNAMED", "-XX:StartFlightRecording:jdk.SocketWrite#enabled=false"}) @@ -62,7 +62,7 @@ public int socketWriteJFREnabledEventDisabled(SkeletonFixture fixture) { return fixture.write(); } - @Fork(value = 1, jvmArgsAppend = { + @Fork(value = 1, jvmArgs = { "--add-exports", "java.base/jdk.internal.event=ALL-UNNAMED", "-XX:StartFlightRecording:jdk.SocketWrite#enabled=true,jdk.SocketWrite#threshold=1s"}) @@ -71,7 +71,7 @@ public int socketWriteJFREnabledEventNotEmitted(SkeletonFixture fixture) { return fixture.write(); } - @Fork(value = 1, jvmArgsAppend = { + @Fork(value = 1, jvmArgs = { "--add-exports","java.base/jdk.internal.event=ALL-UNNAMED", "-XX:StartFlightRecording:jdk.SocketWrite#enabled=true,jdk.SocketWrite#threshold=0ms,disk=false,jdk.SocketWrite#stackTrace=false"}) @Benchmark @@ -79,7 +79,7 @@ public int socketWriteJFREnabledEventEmitted(SkeletonFixture fixture) { return fixture.write(); } - @Fork(value = 1, jvmArgsAppend = { + @Fork(value = 1, jvmArgs = { "--add-exports", "java.base/jdk.internal.event=ALL-UNNAMED" }) @Benchmark @@ -87,7 +87,7 @@ public int socketReadJFRDisabled(SkeletonFixture fixture) { return fixture.read(); } - @Fork(value = 1, jvmArgsAppend = { + @Fork(value = 1, jvmArgs = { "--add-exports", "java.base/jdk.internal.event=ALL-UNNAMED", "-XX:StartFlightRecording:jdk.SocketRead#enabled=false"}) @@ -96,7 +96,7 @@ public int socketReadJFREnabledEventDisabled(SkeletonFixture fixture) { return fixture.read(); } - @Fork(value = 1, jvmArgsAppend = { + @Fork(value = 1, jvmArgs = { "--add-exports", "java.base/jdk.internal.event=ALL-UNNAMED", "-XX:StartFlightRecording:jdk.SocketRead#enabled=true,jdk.SocketRead#threshold=1s"}) @@ -105,7 +105,7 @@ public int socketReadJFREnabledEventNotEmitted(SkeletonFixture fixture) { return fixture.read(); } - @Fork(value = 1, jvmArgsAppend = { + @Fork(value = 1, jvmArgs = { "--add-exports","java.base/jdk.internal.event=ALL-UNNAMED", "-XX:StartFlightRecording:jdk.SocketRead#enabled=true,jdk.SocketRead#threshold=0ms,disk=false,jdk.SocketRead#stackTrace=false"}) @Benchmark diff --git a/test/micro/org/openjdk/bench/java/net/ThreadLocalParseUtil.java b/test/micro/org/openjdk/bench/java/net/ThreadLocalParseUtil.java index 93af26379a7..180de650ede 100644 --- a/test/micro/org/openjdk/bench/java/net/ThreadLocalParseUtil.java +++ b/test/micro/org/openjdk/bench/java/net/ThreadLocalParseUtil.java @@ -48,7 +48,7 @@ @State(Scope.Thread) @Warmup(iterations = 5, time = 1) @Measurement(iterations = 5, time = 1) -@Fork(value = 1, jvmArgsAppend = "--add-exports=java.base/sun.net.www=ALL-UNNAMED") +@Fork(value = 1, jvmArgs = "--add-exports=java.base/sun.net.www=ALL-UNNAMED") public class ThreadLocalParseUtil { private static final MethodHandle MH_DECODE; diff --git a/test/micro/org/openjdk/bench/java/security/AlgorithmConstraintsPermits.java b/test/micro/org/openjdk/bench/java/security/AlgorithmConstraintsPermits.java index 46e68ea627f..683d069bc7e 100644 --- a/test/micro/org/openjdk/bench/java/security/AlgorithmConstraintsPermits.java +++ b/test/micro/org/openjdk/bench/java/security/AlgorithmConstraintsPermits.java @@ -45,7 +45,7 @@ @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) -@Fork(value = 3, jvmArgsAppend = {"--add-exports", "java.base/sun.security.util=ALL-UNNAMED"}) +@Fork(value = 3, jvmArgs = {"--add-exports", "java.base/sun.security.util=ALL-UNNAMED"}) @State(Scope.Thread) @Warmup(iterations = 5, time = 1) @Measurement(iterations = 5, time = 1) diff --git a/test/micro/org/openjdk/bench/java/security/CacheBench.java b/test/micro/org/openjdk/bench/java/security/CacheBench.java index 9b7c39a3cf2..7366a18c020 100644 --- a/test/micro/org/openjdk/bench/java/security/CacheBench.java +++ b/test/micro/org/openjdk/bench/java/security/CacheBench.java @@ -44,7 +44,7 @@ @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) -@Fork(value = 3, jvmArgsAppend = {"--add-exports", "java.base/sun.security.util=ALL-UNNAMED"}) +@Fork(value = 3, jvmArgs = {"--add-exports", "java.base/sun.security.util=ALL-UNNAMED"}) @Warmup(iterations = 5, time = 1) @Measurement(iterations = 5, time = 1) public class CacheBench { diff --git a/test/micro/org/openjdk/bench/java/security/CipherSuiteBench.java b/test/micro/org/openjdk/bench/java/security/CipherSuiteBench.java index dcda7c252f0..c78fbb5dbb1 100644 --- a/test/micro/org/openjdk/bench/java/security/CipherSuiteBench.java +++ b/test/micro/org/openjdk/bench/java/security/CipherSuiteBench.java @@ -30,7 +30,7 @@ import java.util.concurrent.TimeUnit; -@Fork(value = 3, jvmArgsAppend = {"--add-exports", "java.base/sun.security.ssl=ALL-UNNAMED", "--add-opens", "java.base/sun.security.ssl=ALL-UNNAMED"}) +@Fork(value = 3, jvmArgs = {"--add-exports", "java.base/sun.security.ssl=ALL-UNNAMED", "--add-opens", "java.base/sun.security.ssl=ALL-UNNAMED"}) @State(Scope.Thread) @OutputTimeUnit(TimeUnit.MICROSECONDS) @BenchmarkMode(Mode.Throughput) diff --git a/test/micro/org/openjdk/bench/java/security/HSS.java b/test/micro/org/openjdk/bench/java/security/HSS.java index d89147406dc..c2f746d2449 100644 --- a/test/micro/org/openjdk/bench/java/security/HSS.java +++ b/test/micro/org/openjdk/bench/java/security/HSS.java @@ -55,7 +55,7 @@ @OutputTimeUnit(TimeUnit.MICROSECONDS) @Warmup(iterations = 5, time = 1) @Measurement(iterations = 5, time = 1) -@Fork(value = 3, jvmArgsAppend = {"--add-exports", "java.base/sun.security.util=ALL-UNNAMED"}) +@Fork(value = 3, jvmArgs = {"--add-exports", "java.base/sun.security.util=ALL-UNNAMED"}) // Tests 1-2 are from RFC 8554, Appendix F. diff --git a/test/micro/org/openjdk/bench/java/security/MessageDigests.java b/test/micro/org/openjdk/bench/java/security/MessageDigests.java index a3ab483c39c..2a4e3933d31 100644 --- a/test/micro/org/openjdk/bench/java/security/MessageDigests.java +++ b/test/micro/org/openjdk/bench/java/security/MessageDigests.java @@ -47,7 +47,7 @@ @OutputTimeUnit(TimeUnit.MILLISECONDS) @Warmup(iterations = 5, time = 1) @Measurement(iterations = 5, time = 1) -@Fork(jvmArgsAppend = {"-Xms1024m", "-Xmx1024m", "-Xmn768m", "-XX:+UseParallelGC"}, value = 3) +@Fork(jvmArgs = {"-Xms1024m", "-Xmx1024m", "-Xmn768m", "-XX:+UseParallelGC"}, value = 3) public class MessageDigests { @Param({"64", "16384"}) diff --git a/test/micro/org/openjdk/bench/java/security/PKCS12KeyStores.java b/test/micro/org/openjdk/bench/java/security/PKCS12KeyStores.java index f68b4503ef5..065bd96c4bf 100644 --- a/test/micro/org/openjdk/bench/java/security/PKCS12KeyStores.java +++ b/test/micro/org/openjdk/bench/java/security/PKCS12KeyStores.java @@ -41,7 +41,7 @@ @Warmup(iterations = 5, time = 1) @Measurement(iterations = 5, time = 1) @BenchmarkMode(Mode.AverageTime) -@Fork(jvmArgsAppend = {"-Xms1024m", "-Xmx1024m", "-Xmn768m", "-XX:+UseParallelGC"}, value = 3) +@Fork(jvmArgs = {"-Xms1024m", "-Xmx1024m", "-Xmn768m", "-XX:+UseParallelGC"}, value = 3) public class PKCS12KeyStores { private static final char[] PASS = "changeit".toCharArray(); diff --git a/test/micro/org/openjdk/bench/java/security/ProtectionDomainBench.java b/test/micro/org/openjdk/bench/java/security/ProtectionDomainBench.java index ec85e09634f..cf302d83e9b 100644 --- a/test/micro/org/openjdk/bench/java/security/ProtectionDomainBench.java +++ b/test/micro/org/openjdk/bench/java/security/ProtectionDomainBench.java @@ -123,7 +123,7 @@ void work() throws ClassNotFoundException { } @Benchmark - @Fork(value = 3, jvmArgsPrepend={"-Djava.security.manager=allow"}) + @Fork(value = 3, jvmArgs={"-Djava.security.manager=allow"}) public void withSecurityManager() throws ClassNotFoundException { work(); } diff --git a/test/micro/org/openjdk/bench/java/security/Signatures.java b/test/micro/org/openjdk/bench/java/security/Signatures.java index 7a14cb24b88..1bd72334343 100644 --- a/test/micro/org/openjdk/bench/java/security/Signatures.java +++ b/test/micro/org/openjdk/bench/java/security/Signatures.java @@ -34,7 +34,7 @@ @State(Scope.Thread) @Warmup(iterations = 5, time = 1) @Measurement(iterations = 5, time = 1) -@Fork(jvmArgsAppend = {"-Xms1024m", "-Xmx1024m", "-Xmn768m", "-XX:+UseParallelGC"}, value = 3) +@Fork(jvmArgs = {"-Xms1024m", "-Xmx1024m", "-Xmn768m", "-XX:+UseParallelGC"}, value = 3) public class Signatures { private static Signature signer; diff --git a/test/micro/org/openjdk/bench/java/util/ArraysSort.java b/test/micro/org/openjdk/bench/java/util/ArraysSort.java index 4cd45d79412..d32bfa7fd2d 100644 --- a/test/micro/org/openjdk/bench/java/util/ArraysSort.java +++ b/test/micro/org/openjdk/bench/java/util/ArraysSort.java @@ -47,7 +47,7 @@ /** * Performance test of Arrays.sort() methods */ -@Fork(value=1, jvmArgsAppend={"-XX:CompileThreshold=1", "-XX:-TieredCompilation"}) +@Fork(value=1, jvmArgs={"-XX:CompileThreshold=1", "-XX:-TieredCompilation"}) @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.MICROSECONDS) @State(Scope.Thread) diff --git a/test/micro/org/openjdk/bench/java/util/ListArgs.java b/test/micro/org/openjdk/bench/java/util/ListArgs.java index 073214ce2a1..d44d8b604ef 100644 --- a/test/micro/org/openjdk/bench/java/util/ListArgs.java +++ b/test/micro/org/openjdk/bench/java/util/ListArgs.java @@ -36,7 +36,7 @@ */ @State(Scope.Thread) @OutputTimeUnit(TimeUnit.MILLISECONDS) -@Fork(value = 3, jvmArgsAppend = { "-verbose:gc", "-XX:+UseParallelGC", "-Xms4g", "-Xmx4g", "-Xint" }) +@Fork(value = 3, jvmArgs = { "-verbose:gc", "-XX:+UseParallelGC", "-Xms4g", "-Xmx4g", "-Xint" }) @Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) @Measurement(iterations = 5, time = 2, timeUnit = TimeUnit.SECONDS) public class ListArgs { diff --git a/test/micro/org/openjdk/bench/java/util/StringJoinerBenchmark.java b/test/micro/org/openjdk/bench/java/util/StringJoinerBenchmark.java index 6df0045ef32..38b6389db54 100644 --- a/test/micro/org/openjdk/bench/java/util/StringJoinerBenchmark.java +++ b/test/micro/org/openjdk/bench/java/util/StringJoinerBenchmark.java @@ -45,7 +45,7 @@ @OutputTimeUnit(TimeUnit.NANOSECONDS) @Warmup(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS) @Measurement(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS) -@Fork(value = 3, jvmArgsAppend = {"-Xms1g", "-Xmx1g"}) +@Fork(value = 3, jvmArgs = {"-Xms1g", "-Xmx1g"}) public class StringJoinerBenchmark { @Benchmark diff --git a/test/micro/org/openjdk/bench/java/util/jar/JarFileGetEntry.java b/test/micro/org/openjdk/bench/java/util/jar/JarFileGetEntry.java index bc2182e00b4..a0c3938e8eb 100644 --- a/test/micro/org/openjdk/bench/java/util/jar/JarFileGetEntry.java +++ b/test/micro/org/openjdk/bench/java/util/jar/JarFileGetEntry.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,9 +31,12 @@ import java.nio.file.Files; import java.util.Random; import java.util.concurrent.TimeUnit; +import java.util.jar.Attributes; import java.util.jar.JarFile; import java.util.jar.JarOutputStream; +import java.util.jar.Manifest; import java.util.zip.ZipEntry; +import java.util.zip.ZipFile; /** * Simple benchmark measuring cost of looking up entries in a jar file. @@ -71,6 +74,9 @@ public class JarFileGetEntry { @Param({"512", "1024"}) private int size; + @Param({"false", "true"}) + private boolean mr; + public JarFile jarFile; public String[] entryNames; public String[] missingEntryNames; @@ -91,9 +97,20 @@ public void beforeRun() throws IOException { entryNames = new String[size]; missingEntryNames = new String[size]; + Manifest man = new Manifest(); + man.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0"); + if (mr) { + man.getMainAttributes().put(Attributes.Name.MULTI_RELEASE, "true"); + } try (FileOutputStream fos = new FileOutputStream(tempFile); - JarOutputStream jos = new JarOutputStream(fos)) { + JarOutputStream jos = new JarOutputStream(fos, man)) { + if (mr) { + // Add a few versioned entries + jos.putNextEntry(new ZipEntry("META-INF/versions/9/module-info.class")); + jos.putNextEntry(new ZipEntry("META-INF/versions/17/foo/library/Library.class")); + jos.putNextEntry(new ZipEntry("META-INF/versions/21/foo/library/Library.class")); + } Random random = new Random(4711); for (int i = 0; i < size; i++) { String ename = "entry-" + (random.nextInt(90000) + 10000) + "-" + i; @@ -107,7 +124,7 @@ public void beforeRun() throws IOException { } } - jarFile = new JarFile(tempFile); + jarFile = new JarFile(tempFile, true, ZipFile.OPEN_READ, mr ? JarFile.runtimeVersion() : JarFile.baseVersion()); } @Benchmark diff --git a/test/micro/org/openjdk/bench/java/util/stream/ops/ref/GatherFMRPar.java b/test/micro/org/openjdk/bench/java/util/stream/ops/ref/GatherFMRPar.java index 476299df76e..cd83ab86034 100644 --- a/test/micro/org/openjdk/bench/java/util/stream/ops/ref/GatherFMRPar.java +++ b/test/micro/org/openjdk/bench/java/util/stream/ops/ref/GatherFMRPar.java @@ -49,7 +49,7 @@ @BenchmarkMode(Mode.Throughput) @Warmup(iterations = 4, time = 5, timeUnit = TimeUnit.SECONDS) @Measurement(iterations = 7, time = 5, timeUnit = TimeUnit.SECONDS) -@Fork(jvmArgsAppend = "--enable-preview", value = 1) +@Fork(jvmArgs = "--enable-preview", value = 1) @OutputTimeUnit(TimeUnit.SECONDS) @State(Scope.Thread) public class GatherFMRPar { diff --git a/test/micro/org/openjdk/bench/java/util/stream/ops/ref/GatherFMRSeq.java b/test/micro/org/openjdk/bench/java/util/stream/ops/ref/GatherFMRSeq.java index 05e48e16d07..a1973a45831 100644 --- a/test/micro/org/openjdk/bench/java/util/stream/ops/ref/GatherFMRSeq.java +++ b/test/micro/org/openjdk/bench/java/util/stream/ops/ref/GatherFMRSeq.java @@ -49,7 +49,7 @@ @BenchmarkMode(Mode.Throughput) @Warmup(iterations = 4, time = 5, timeUnit = TimeUnit.SECONDS) @Measurement(iterations = 7, time = 5, timeUnit = TimeUnit.SECONDS) -@Fork(jvmArgsAppend = "--enable-preview", value = 1) +@Fork(jvmArgs = "--enable-preview", value = 1) @OutputTimeUnit(TimeUnit.SECONDS) @State(Scope.Thread) public class GatherFMRSeq { diff --git a/test/micro/org/openjdk/bench/java/util/stream/ops/ref/GatherFlatMapInfinitySeq.java b/test/micro/org/openjdk/bench/java/util/stream/ops/ref/GatherFlatMapInfinitySeq.java index 09c38f83484..2b804551dbf 100644 --- a/test/micro/org/openjdk/bench/java/util/stream/ops/ref/GatherFlatMapInfinitySeq.java +++ b/test/micro/org/openjdk/bench/java/util/stream/ops/ref/GatherFlatMapInfinitySeq.java @@ -48,7 +48,7 @@ @BenchmarkMode(Mode.Throughput) @Warmup(iterations = 4, time = 5, timeUnit = TimeUnit.SECONDS) @Measurement(iterations = 7, time = 5, timeUnit = TimeUnit.SECONDS) -@Fork(jvmArgsAppend = "--enable-preview", value = 1) +@Fork(jvmArgs = "--enable-preview", value = 1) @OutputTimeUnit(TimeUnit.SECONDS) @State(Scope.Thread) public class GatherFlatMapInfinitySeq { diff --git a/test/micro/org/openjdk/bench/java/util/stream/ops/ref/GatherFlatMapSeq.java b/test/micro/org/openjdk/bench/java/util/stream/ops/ref/GatherFlatMapSeq.java index a13ee01a851..31c1f047c12 100644 --- a/test/micro/org/openjdk/bench/java/util/stream/ops/ref/GatherFlatMapSeq.java +++ b/test/micro/org/openjdk/bench/java/util/stream/ops/ref/GatherFlatMapSeq.java @@ -48,7 +48,7 @@ @BenchmarkMode(Mode.Throughput) @Warmup(iterations = 4, time = 5, timeUnit = TimeUnit.SECONDS) @Measurement(iterations = 7, time = 5, timeUnit = TimeUnit.SECONDS) -@Fork(jvmArgsAppend = "--enable-preview", value = 1) +@Fork(jvmArgs = "--enable-preview", value = 1) @OutputTimeUnit(TimeUnit.SECONDS) @State(Scope.Thread) public class GatherFlatMapSeq { diff --git a/test/micro/org/openjdk/bench/java/util/stream/ops/ref/GatherMapPar.java b/test/micro/org/openjdk/bench/java/util/stream/ops/ref/GatherMapPar.java index 62c2d03b1b1..b7c60af6cdd 100644 --- a/test/micro/org/openjdk/bench/java/util/stream/ops/ref/GatherMapPar.java +++ b/test/micro/org/openjdk/bench/java/util/stream/ops/ref/GatherMapPar.java @@ -48,7 +48,7 @@ @BenchmarkMode(Mode.Throughput) @Warmup(iterations = 4, time = 5, timeUnit = TimeUnit.SECONDS) @Measurement(iterations = 7, time = 5, timeUnit = TimeUnit.SECONDS) -@Fork(jvmArgsAppend = "--enable-preview", value = 1) +@Fork(jvmArgs = "--enable-preview", value = 1) @OutputTimeUnit(TimeUnit.SECONDS) @State(Scope.Thread) public class GatherMapPar { diff --git a/test/micro/org/openjdk/bench/java/util/stream/ops/ref/GatherMapSeq.java b/test/micro/org/openjdk/bench/java/util/stream/ops/ref/GatherMapSeq.java index 1e842c0c09e..1dbbbd05009 100644 --- a/test/micro/org/openjdk/bench/java/util/stream/ops/ref/GatherMapSeq.java +++ b/test/micro/org/openjdk/bench/java/util/stream/ops/ref/GatherMapSeq.java @@ -48,7 +48,7 @@ @BenchmarkMode(Mode.Throughput) @Warmup(iterations = 4, time = 5, timeUnit = TimeUnit.SECONDS) @Measurement(iterations = 7, time = 5, timeUnit = TimeUnit.SECONDS) -@Fork(jvmArgsAppend = "--enable-preview", value = 1) +@Fork(jvmArgs = "--enable-preview", value = 1) @OutputTimeUnit(TimeUnit.SECONDS) @State(Scope.Thread) public class GatherMapSeq { diff --git a/test/micro/org/openjdk/bench/java/util/stream/ops/ref/GatherMiscPar.java b/test/micro/org/openjdk/bench/java/util/stream/ops/ref/GatherMiscPar.java index 578e470ec5c..12f5c98702b 100644 --- a/test/micro/org/openjdk/bench/java/util/stream/ops/ref/GatherMiscPar.java +++ b/test/micro/org/openjdk/bench/java/util/stream/ops/ref/GatherMiscPar.java @@ -49,7 +49,7 @@ @BenchmarkMode(Mode.Throughput) @Warmup(iterations = 4, time = 5, timeUnit = TimeUnit.SECONDS) @Measurement(iterations = 7, time = 5, timeUnit = TimeUnit.SECONDS) -@Fork(jvmArgsAppend = "--enable-preview", value = 1) +@Fork(jvmArgs = "--enable-preview", value = 1) @OutputTimeUnit(TimeUnit.SECONDS) @State(Scope.Thread) public class GatherMiscPar { diff --git a/test/micro/org/openjdk/bench/java/util/stream/ops/ref/GatherMiscSeq.java b/test/micro/org/openjdk/bench/java/util/stream/ops/ref/GatherMiscSeq.java index 0d7d9bdef9f..a60d02af7b6 100644 --- a/test/micro/org/openjdk/bench/java/util/stream/ops/ref/GatherMiscSeq.java +++ b/test/micro/org/openjdk/bench/java/util/stream/ops/ref/GatherMiscSeq.java @@ -51,7 +51,7 @@ @BenchmarkMode(Mode.Throughput) @Warmup(iterations = 4, time = 5, timeUnit = TimeUnit.SECONDS) @Measurement(iterations = 7, time = 5, timeUnit = TimeUnit.SECONDS) -@Fork(jvmArgsAppend = "--enable-preview", value = 1) +@Fork(jvmArgs = "--enable-preview", value = 1) @OutputTimeUnit(TimeUnit.SECONDS) @State(Scope.Thread) public class GatherMiscSeq { diff --git a/test/micro/org/openjdk/bench/java/util/stream/ops/ref/GatherReducePar.java b/test/micro/org/openjdk/bench/java/util/stream/ops/ref/GatherReducePar.java index 2f2d0b06bd7..6742ee98590 100644 --- a/test/micro/org/openjdk/bench/java/util/stream/ops/ref/GatherReducePar.java +++ b/test/micro/org/openjdk/bench/java/util/stream/ops/ref/GatherReducePar.java @@ -49,7 +49,7 @@ @BenchmarkMode(Mode.Throughput) @Warmup(iterations = 4, time = 5, timeUnit = TimeUnit.SECONDS) @Measurement(iterations = 7, time = 5, timeUnit = TimeUnit.SECONDS) -@Fork(jvmArgsAppend = "--enable-preview", value = 1) +@Fork(jvmArgs = "--enable-preview", value = 1) @OutputTimeUnit(TimeUnit.SECONDS) @State(Scope.Thread) public class GatherReducePar { diff --git a/test/micro/org/openjdk/bench/java/util/stream/ops/ref/GatherReduceSeq.java b/test/micro/org/openjdk/bench/java/util/stream/ops/ref/GatherReduceSeq.java index 7d8540d0ed4..7356fdb979b 100644 --- a/test/micro/org/openjdk/bench/java/util/stream/ops/ref/GatherReduceSeq.java +++ b/test/micro/org/openjdk/bench/java/util/stream/ops/ref/GatherReduceSeq.java @@ -51,7 +51,7 @@ @BenchmarkMode(Mode.Throughput) @Warmup(iterations = 4, time = 5, timeUnit = TimeUnit.SECONDS) @Measurement(iterations = 7, time = 5, timeUnit = TimeUnit.SECONDS) -@Fork(jvmArgsAppend = "--enable-preview", value = 1) +@Fork(jvmArgs = "--enable-preview", value = 1) @OutputTimeUnit(TimeUnit.SECONDS) @State(Scope.Thread) public class GatherReduceSeq { diff --git a/test/micro/org/openjdk/bench/java/util/stream/ops/ref/GatherWhileOrdered.java b/test/micro/org/openjdk/bench/java/util/stream/ops/ref/GatherWhileOrdered.java index 6e9e5fec1fa..f0b3fef4438 100644 --- a/test/micro/org/openjdk/bench/java/util/stream/ops/ref/GatherWhileOrdered.java +++ b/test/micro/org/openjdk/bench/java/util/stream/ops/ref/GatherWhileOrdered.java @@ -49,7 +49,7 @@ @BenchmarkMode(Mode.Throughput) @Warmup(iterations = 4, time = 5, timeUnit = TimeUnit.SECONDS) @Measurement(iterations = 7, time = 5, timeUnit = TimeUnit.SECONDS) -@Fork(jvmArgsAppend = "--enable-preview", value = 1) +@Fork(jvmArgs = "--enable-preview", value = 1) @OutputTimeUnit(TimeUnit.SECONDS) @State(Scope.Thread) public class GatherWhileOrdered { diff --git a/test/micro/org/openjdk/bench/javax/crypto/AES.java b/test/micro/org/openjdk/bench/javax/crypto/AES.java index 23ecdb33f94..8bd4a6ff9b3 100644 --- a/test/micro/org/openjdk/bench/javax/crypto/AES.java +++ b/test/micro/org/openjdk/bench/javax/crypto/AES.java @@ -59,19 +59,19 @@ public void setup() throws Exception { } @Benchmark - @Fork(jvmArgsAppend = {"-XX:+UnlockDiagnosticVMOptions", "-XX:-UseAES", "-XX:-UseAESIntrinsics"}) + @Fork(jvmArgs = {"-XX:+UnlockDiagnosticVMOptions", "-XX:-UseAES", "-XX:-UseAESIntrinsics"}) public byte[] testBaseline() throws Exception { return cipher.doFinal(src); } @Benchmark - @Fork(jvmArgsAppend = {"-XX:+UnlockDiagnosticVMOptions", "-XX:+UseAES", "-XX:-UseAESIntrinsics"}) + @Fork(jvmArgs = {"-XX:+UnlockDiagnosticVMOptions", "-XX:+UseAES", "-XX:-UseAESIntrinsics"}) public byte[] testUseAes() throws Exception { return cipher.doFinal(src); } @Benchmark - @Fork(jvmArgsAppend = {"-XX:+UnlockDiagnosticVMOptions", "-XX:+UseAES", "-XX:+UseAESIntrinsics"}) + @Fork(jvmArgs = {"-XX:+UnlockDiagnosticVMOptions", "-XX:+UseAES", "-XX:+UseAESIntrinsics"}) public byte[] testUseAesIntrinsics() throws Exception { return cipher.doFinal(src); } diff --git a/test/micro/org/openjdk/bench/javax/crypto/AESReinit.java b/test/micro/org/openjdk/bench/javax/crypto/AESReinit.java index 16f8b930633..b2378576f2c 100644 --- a/test/micro/org/openjdk/bench/javax/crypto/AESReinit.java +++ b/test/micro/org/openjdk/bench/javax/crypto/AESReinit.java @@ -32,7 +32,7 @@ @Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) @Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) -@Fork(value = 3, jvmArgsAppend = {"-Xms1g", "-Xmx1g"}) +@Fork(value = 3, jvmArgs = {"-Xms1g", "-Xmx1g"}) @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) @State(Scope.Thread) diff --git a/test/micro/org/openjdk/bench/javax/crypto/Crypto.java b/test/micro/org/openjdk/bench/javax/crypto/Crypto.java index 6a9a49bd84e..38e88d0171e 100644 --- a/test/micro/org/openjdk/bench/javax/crypto/Crypto.java +++ b/test/micro/org/openjdk/bench/javax/crypto/Crypto.java @@ -51,7 +51,7 @@ @OutputTimeUnit(TimeUnit.MILLISECONDS) @Warmup(iterations = 5) @Measurement(iterations = 10) -@Fork(jvmArgsAppend = {"-Xms1024m", "-Xmx1024m", "-Xmn768m", "-XX:+UseParallelGC"}, value = 5) +@Fork(jvmArgs = {"-Xms1024m", "-Xmx1024m", "-Xmn768m", "-XX:+UseParallelGC"}, value = 5) public class Crypto { @Param({"64", "1024", "16384"}) diff --git a/test/micro/org/openjdk/bench/javax/crypto/full/CryptoBase.java b/test/micro/org/openjdk/bench/javax/crypto/full/CryptoBase.java index c0fbcdcaa01..b2d08204d7b 100644 --- a/test/micro/org/openjdk/bench/javax/crypto/full/CryptoBase.java +++ b/test/micro/org/openjdk/bench/javax/crypto/full/CryptoBase.java @@ -45,7 +45,7 @@ import java.util.concurrent.TimeUnit; -@Fork(jvmArgsAppend = {"-XX:+AlwaysPreTouch"}, value = 5) +@Fork(jvmArgs = {"-XX:+AlwaysPreTouch"}, value = 5) @Warmup(iterations = 3, time = 3) @Measurement(iterations = 8, time = 2) @OutputTimeUnit(TimeUnit.SECONDS) diff --git a/test/micro/org/openjdk/bench/javax/crypto/full/Poly1305DigestBench.java b/test/micro/org/openjdk/bench/javax/crypto/full/Poly1305DigestBench.java index 529ce9a2b32..bff0918b7a8 100644 --- a/test/micro/org/openjdk/bench/javax/crypto/full/Poly1305DigestBench.java +++ b/test/micro/org/openjdk/bench/javax/crypto/full/Poly1305DigestBench.java @@ -41,7 +41,7 @@ @Measurement(iterations = 3, time = 10) @Warmup(iterations = 3, time = 10) -@Fork(value = 1, jvmArgsAppend = {"--add-opens", "java.base/com.sun.crypto.provider=ALL-UNNAMED"}) +@Fork(value = 1, jvmArgs = {"--add-opens", "java.base/com.sun.crypto.provider=ALL-UNNAMED"}) public class Poly1305DigestBench extends CryptoBase { public static final int SET_SIZE = 128; diff --git a/test/micro/org/openjdk/bench/javax/crypto/full/PolynomialP256Bench.java b/test/micro/org/openjdk/bench/javax/crypto/full/PolynomialP256Bench.java index 94c247c9080..34a6bd761ff 100644 --- a/test/micro/org/openjdk/bench/javax/crypto/full/PolynomialP256Bench.java +++ b/test/micro/org/openjdk/bench/javax/crypto/full/PolynomialP256Bench.java @@ -40,7 +40,7 @@ import sun.security.util.math.MutableIntegerModuloP; import sun.security.util.math.ImmutableIntegerModuloP; -@Fork(jvmArgsAppend = {"-XX:+AlwaysPreTouch", +@Fork(jvmArgs = {"-XX:+AlwaysPreTouch", "--add-exports", "java.base/sun.security.util.math.intpoly=ALL-UNNAMED", "--add-exports", "java.base/sun.security.util.math=ALL-UNNAMED"}, value = 1) @Warmup(iterations = 3, time = 3) diff --git a/test/micro/org/openjdk/bench/jdk/classfile/AbstractCorpusBenchmark.java b/test/micro/org/openjdk/bench/jdk/classfile/AbstractCorpusBenchmark.java index b714f1c5ff9..5f64e114877 100644 --- a/test/micro/org/openjdk/bench/jdk/classfile/AbstractCorpusBenchmark.java +++ b/test/micro/org/openjdk/bench/jdk/classfile/AbstractCorpusBenchmark.java @@ -43,7 +43,7 @@ */ @Warmup(iterations = 2) @Measurement(iterations = 4) -@Fork(value = 1, jvmArgsAppend = { +@Fork(value = 1, jvmArgs = { "--add-exports", "java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED", "--add-exports", "java.base/jdk.internal.org.objectweb.asm.tree=ALL-UNNAMED", "--enable-preview", diff --git a/test/micro/org/openjdk/bench/jdk/classfile/ClassfileBenchmark.java b/test/micro/org/openjdk/bench/jdk/classfile/ClassfileBenchmark.java index c07eff075c9..ecd671feaac 100644 --- a/test/micro/org/openjdk/bench/jdk/classfile/ClassfileBenchmark.java +++ b/test/micro/org/openjdk/bench/jdk/classfile/ClassfileBenchmark.java @@ -50,7 +50,7 @@ */ @Warmup(iterations = 3) @Measurement(iterations = 5) -@Fork(value = 1, jvmArgsAppend = { +@Fork(value = 1, jvmArgs = { "--enable-preview"}) @State(Scope.Benchmark) diff --git a/test/micro/org/openjdk/bench/jdk/classfile/CodeAttributeTools.java b/test/micro/org/openjdk/bench/jdk/classfile/CodeAttributeTools.java index 4239f70504b..877a36e3864 100644 --- a/test/micro/org/openjdk/bench/jdk/classfile/CodeAttributeTools.java +++ b/test/micro/org/openjdk/bench/jdk/classfile/CodeAttributeTools.java @@ -55,7 +55,7 @@ @BenchmarkMode(Mode.Throughput) @State(Scope.Benchmark) -@Fork(value = 1, jvmArgsAppend = { +@Fork(value = 1, jvmArgs = { "--enable-preview", "--add-exports", "java.base/jdk.internal.classfile.impl=ALL-UNNAMED"}) @Warmup(iterations = 2) diff --git a/test/micro/org/openjdk/bench/jdk/classfile/ConstantPoolBuildingClassEntry.java b/test/micro/org/openjdk/bench/jdk/classfile/ConstantPoolBuildingClassEntry.java index 0f8bf0449af..afb586dabe7 100644 --- a/test/micro/org/openjdk/bench/jdk/classfile/ConstantPoolBuildingClassEntry.java +++ b/test/micro/org/openjdk/bench/jdk/classfile/ConstantPoolBuildingClassEntry.java @@ -43,7 +43,7 @@ @Measurement(iterations = 5) @OutputTimeUnit(TimeUnit.MILLISECONDS) @BenchmarkMode(Mode.Throughput) -@Fork(value = 1, jvmArgsAppend = {"--enable-preview"}) +@Fork(value = 1, jvmArgs = {"--enable-preview"}) @State(Scope.Benchmark) public class ConstantPoolBuildingClassEntry { // JDK-8338546 diff --git a/test/micro/org/openjdk/bench/jdk/classfile/RebuildMethodBodies.java b/test/micro/org/openjdk/bench/jdk/classfile/RebuildMethodBodies.java index 07deec0ae48..f6542983e13 100644 --- a/test/micro/org/openjdk/bench/jdk/classfile/RebuildMethodBodies.java +++ b/test/micro/org/openjdk/bench/jdk/classfile/RebuildMethodBodies.java @@ -37,7 +37,7 @@ @BenchmarkMode(Mode.Throughput) @State(Scope.Benchmark) -@Fork(value = 1, jvmArgsAppend = { +@Fork(value = 1, jvmArgs = { "--enable-preview"}) @Warmup(iterations = 2) @Measurement(iterations = 4) diff --git a/test/micro/org/openjdk/bench/jdk/classfile/RepeatedModelTraversal.java b/test/micro/org/openjdk/bench/jdk/classfile/RepeatedModelTraversal.java index 45fcbe0f5a5..b9c9082625c 100644 --- a/test/micro/org/openjdk/bench/jdk/classfile/RepeatedModelTraversal.java +++ b/test/micro/org/openjdk/bench/jdk/classfile/RepeatedModelTraversal.java @@ -36,7 +36,7 @@ @BenchmarkMode(Mode.Throughput) @State(Scope.Benchmark) -@Fork(value = 1, jvmArgsAppend = { +@Fork(value = 1, jvmArgs = { "--enable-preview"}) @Warmup(iterations = 3) @Measurement(iterations = 4) diff --git a/test/micro/org/openjdk/bench/jdk/classfile/Write.java b/test/micro/org/openjdk/bench/jdk/classfile/Write.java index 6e041cf6436..19dfabbdce8 100644 --- a/test/micro/org/openjdk/bench/jdk/classfile/Write.java +++ b/test/micro/org/openjdk/bench/jdk/classfile/Write.java @@ -56,7 +56,7 @@ */ @Warmup(iterations = 3) @Measurement(iterations = 5) -@Fork(value = 1, jvmArgsAppend = { +@Fork(value = 1, jvmArgs = { "--add-exports", "java.base/jdk.internal.org.objectweb.asm=ALL-UNNAMED", "--add-exports", "java.base/jdk.internal.org.objectweb.asm.tree=ALL-UNNAMED", "--enable-preview", diff --git a/test/micro/org/openjdk/bench/jdk/incubator/vector/ArrayMismatchBenchmark.java b/test/micro/org/openjdk/bench/jdk/incubator/vector/ArrayMismatchBenchmark.java index c6c34e890fa..8d0cce89f98 100644 --- a/test/micro/org/openjdk/bench/jdk/incubator/vector/ArrayMismatchBenchmark.java +++ b/test/micro/org/openjdk/bench/jdk/incubator/vector/ArrayMismatchBenchmark.java @@ -47,7 +47,7 @@ @OutputTimeUnit(TimeUnit.MILLISECONDS) @State(Scope.Thread) -@Fork(jvmArgsPrepend = {"--add-modules=jdk.incubator.vector"}) +@Fork(jvmArgs = {"--add-modules=jdk.incubator.vector"}) public class ArrayMismatchBenchmark { @Param({"9", "257", "100000"}) diff --git a/test/micro/org/openjdk/bench/jdk/incubator/vector/BlackScholes.java b/test/micro/org/openjdk/bench/jdk/incubator/vector/BlackScholes.java index f58821b6697..5db2c6b7d07 100644 --- a/test/micro/org/openjdk/bench/jdk/incubator/vector/BlackScholes.java +++ b/test/micro/org/openjdk/bench/jdk/incubator/vector/BlackScholes.java @@ -39,7 +39,7 @@ @State(Scope.Thread) @Warmup(iterations = 3, time = 5) @Measurement(iterations = 3, time = 5) -@Fork(jvmArgsPrepend = {"--add-modules=jdk.incubator.vector"}) +@Fork(jvmArgs = {"--add-modules=jdk.incubator.vector"}) public class BlackScholes { @Param("1024") diff --git a/test/micro/org/openjdk/bench/jdk/incubator/vector/ColumnFilterBenchmark.java b/test/micro/org/openjdk/bench/jdk/incubator/vector/ColumnFilterBenchmark.java index d41d5404250..e78bd2172a0 100644 --- a/test/micro/org/openjdk/bench/jdk/incubator/vector/ColumnFilterBenchmark.java +++ b/test/micro/org/openjdk/bench/jdk/incubator/vector/ColumnFilterBenchmark.java @@ -32,7 +32,7 @@ @OutputTimeUnit(TimeUnit.MILLISECONDS) @State(Scope.Thread) -@Fork(jvmArgsPrepend = {"--add-modules=jdk.incubator.vector", "-XX:UseAVX=2"}) +@Fork(jvmArgs = {"--add-modules=jdk.incubator.vector", "-XX:UseAVX=2"}) public class ColumnFilterBenchmark { @Param({"1024", "2047", "4096"}) int size; diff --git a/test/micro/org/openjdk/bench/jdk/incubator/vector/EqualsIgnoreCaseBenchmark.java b/test/micro/org/openjdk/bench/jdk/incubator/vector/EqualsIgnoreCaseBenchmark.java index 888029f3c11..20d7646586d 100644 --- a/test/micro/org/openjdk/bench/jdk/incubator/vector/EqualsIgnoreCaseBenchmark.java +++ b/test/micro/org/openjdk/bench/jdk/incubator/vector/EqualsIgnoreCaseBenchmark.java @@ -46,7 +46,7 @@ @State(Scope.Benchmark) @Warmup(iterations = 5, time = 1) @Measurement(iterations = 5, time = 1) -@Fork(value = 3, jvmArgsPrepend = {"--add-modules=jdk.incubator.vector"}) +@Fork(value = 3, jvmArgs = {"--add-modules=jdk.incubator.vector"}) public class EqualsIgnoreCaseBenchmark { static final VectorSpecies SPECIES = ByteVector.SPECIES_PREFERRED; private byte[] a; diff --git a/test/micro/org/openjdk/bench/jdk/incubator/vector/GatherOperationsBenchmark.java b/test/micro/org/openjdk/bench/jdk/incubator/vector/GatherOperationsBenchmark.java index 7a7578fcf84..09c467cea5b 100644 --- a/test/micro/org/openjdk/bench/jdk/incubator/vector/GatherOperationsBenchmark.java +++ b/test/micro/org/openjdk/bench/jdk/incubator/vector/GatherOperationsBenchmark.java @@ -32,7 +32,7 @@ @OutputTimeUnit(TimeUnit.MILLISECONDS) @State(Scope.Thread) -@Fork(jvmArgsPrepend = {"--add-modules=jdk.incubator.vector"}) +@Fork(jvmArgs = {"--add-modules=jdk.incubator.vector"}) public class GatherOperationsBenchmark { @Param({"64", "256", "1024", "4096"}) int SIZE; diff --git a/test/micro/org/openjdk/bench/jdk/incubator/vector/IndexInRangeBenchmark.java b/test/micro/org/openjdk/bench/jdk/incubator/vector/IndexInRangeBenchmark.java index 66a9b3fc522..1875ea00feb 100644 --- a/test/micro/org/openjdk/bench/jdk/incubator/vector/IndexInRangeBenchmark.java +++ b/test/micro/org/openjdk/bench/jdk/incubator/vector/IndexInRangeBenchmark.java @@ -32,7 +32,7 @@ @State(Scope.Thread) @Warmup(iterations = 3, time = 1) @Measurement(iterations = 5, time = 1) -@Fork(value = 1, jvmArgsPrepend = {"--add-modules=jdk.incubator.vector"}) +@Fork(value = 1, jvmArgs = {"--add-modules=jdk.incubator.vector"}) public class IndexInRangeBenchmark { @Param({"7", "256", "259", "512"}) private int size; diff --git a/test/micro/org/openjdk/bench/jdk/incubator/vector/IndexVectorBenchmark.java b/test/micro/org/openjdk/bench/jdk/incubator/vector/IndexVectorBenchmark.java index 120ae94bd06..584e73c4886 100644 --- a/test/micro/org/openjdk/bench/jdk/incubator/vector/IndexVectorBenchmark.java +++ b/test/micro/org/openjdk/bench/jdk/incubator/vector/IndexVectorBenchmark.java @@ -32,7 +32,7 @@ @State(Scope.Thread) @Warmup(iterations = 3, time = 1) @Measurement(iterations = 5, time = 1) -@Fork(value = 1, jvmArgsPrepend = {"--add-modules=jdk.incubator.vector"}) +@Fork(value = 1, jvmArgs = {"--add-modules=jdk.incubator.vector"}) public class IndexVectorBenchmark { @Param({"1024"}) private int size; diff --git a/test/micro/org/openjdk/bench/jdk/incubator/vector/LoadMaskedIOOBEBenchmark.java b/test/micro/org/openjdk/bench/jdk/incubator/vector/LoadMaskedIOOBEBenchmark.java index 869c98ef29f..52e64d8e096 100644 --- a/test/micro/org/openjdk/bench/jdk/incubator/vector/LoadMaskedIOOBEBenchmark.java +++ b/test/micro/org/openjdk/bench/jdk/incubator/vector/LoadMaskedIOOBEBenchmark.java @@ -32,7 +32,7 @@ @State(Scope.Thread) @Warmup(iterations = 3, time = 1) @Measurement(iterations = 5, time = 1) -@Fork(value = 1, jvmArgsPrepend = {"--add-modules=jdk.incubator.vector"}) +@Fork(value = 1, jvmArgs = {"--add-modules=jdk.incubator.vector"}) public class LoadMaskedIOOBEBenchmark { @Param({"1026"}) private int inSize; diff --git a/test/micro/org/openjdk/bench/jdk/incubator/vector/MaskCastOperationsBenchmark.java b/test/micro/org/openjdk/bench/jdk/incubator/vector/MaskCastOperationsBenchmark.java index 93871392f26..e277fd9114f 100644 --- a/test/micro/org/openjdk/bench/jdk/incubator/vector/MaskCastOperationsBenchmark.java +++ b/test/micro/org/openjdk/bench/jdk/incubator/vector/MaskCastOperationsBenchmark.java @@ -30,7 +30,7 @@ @OutputTimeUnit(TimeUnit.MILLISECONDS) @State(Scope.Thread) -@Fork(jvmArgsPrepend = {"--add-modules=jdk.incubator.vector"}) +@Fork(jvmArgs = {"--add-modules=jdk.incubator.vector"}) public class MaskCastOperationsBenchmark { VectorMask bmask64; VectorMask bmask128; diff --git a/test/micro/org/openjdk/bench/jdk/incubator/vector/MaskFromLongBenchmark.java b/test/micro/org/openjdk/bench/jdk/incubator/vector/MaskFromLongBenchmark.java index a7c73ea6460..ee0fadd6db8 100644 --- a/test/micro/org/openjdk/bench/jdk/incubator/vector/MaskFromLongBenchmark.java +++ b/test/micro/org/openjdk/bench/jdk/incubator/vector/MaskFromLongBenchmark.java @@ -29,7 +29,7 @@ @OutputTimeUnit(TimeUnit.MILLISECONDS) @State(Scope.Thread) -@Fork(jvmArgsPrepend = {"--add-modules=jdk.incubator.vector"}) +@Fork(jvmArgs = {"--add-modules=jdk.incubator.vector"}) public class MaskFromLongBenchmark { private static final int ITERATION = 20000; diff --git a/test/micro/org/openjdk/bench/jdk/incubator/vector/MaskQueryOperationsBenchmark.java b/test/micro/org/openjdk/bench/jdk/incubator/vector/MaskQueryOperationsBenchmark.java index 373bd5017cc..20537fe74f6 100644 --- a/test/micro/org/openjdk/bench/jdk/incubator/vector/MaskQueryOperationsBenchmark.java +++ b/test/micro/org/openjdk/bench/jdk/incubator/vector/MaskQueryOperationsBenchmark.java @@ -31,7 +31,7 @@ @OutputTimeUnit(TimeUnit.MILLISECONDS) @State(Scope.Thread) -@Fork(jvmArgsPrepend = {"--add-modules=jdk.incubator.vector"}) +@Fork(jvmArgs = {"--add-modules=jdk.incubator.vector"}) public class MaskQueryOperationsBenchmark { @Param({"128","256","512"}) int bits; diff --git a/test/micro/org/openjdk/bench/jdk/incubator/vector/MaskedLogicOpts.java b/test/micro/org/openjdk/bench/jdk/incubator/vector/MaskedLogicOpts.java index 97922c2f9ee..eb08aa38b8f 100644 --- a/test/micro/org/openjdk/bench/jdk/incubator/vector/MaskedLogicOpts.java +++ b/test/micro/org/openjdk/bench/jdk/incubator/vector/MaskedLogicOpts.java @@ -32,7 +32,7 @@ @BenchmarkMode(Mode.Throughput) @OutputTimeUnit(TimeUnit.SECONDS) @State(Scope.Thread) -@Fork(jvmArgsPrepend = {"--add-modules=jdk.incubator.vector"}) +@Fork(jvmArgs = {"--add-modules=jdk.incubator.vector"}) public class MaskedLogicOpts { @Param({"256","512","1024"}) private int ARRAYLEN; diff --git a/test/micro/org/openjdk/bench/jdk/incubator/vector/MemorySegmentVectorAccess.java b/test/micro/org/openjdk/bench/jdk/incubator/vector/MemorySegmentVectorAccess.java index 55248290f0e..a85ba440dce 100644 --- a/test/micro/org/openjdk/bench/jdk/incubator/vector/MemorySegmentVectorAccess.java +++ b/test/micro/org/openjdk/bench/jdk/incubator/vector/MemorySegmentVectorAccess.java @@ -48,7 +48,7 @@ @Measurement(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS) @State(org.openjdk.jmh.annotations.Scope.Thread) @OutputTimeUnit(TimeUnit.NANOSECONDS) -@Fork(value = 1, jvmArgsAppend = { +@Fork(value = 1, jvmArgs = { "--add-modules=jdk.incubator.vector", "--enable-native-access", "ALL-UNNAMED"}) public class MemorySegmentVectorAccess { diff --git a/test/micro/org/openjdk/bench/jdk/incubator/vector/RearrangeBytesBenchmark.java b/test/micro/org/openjdk/bench/jdk/incubator/vector/RearrangeBytesBenchmark.java index daa15d41067..375ae9a0395 100644 --- a/test/micro/org/openjdk/bench/jdk/incubator/vector/RearrangeBytesBenchmark.java +++ b/test/micro/org/openjdk/bench/jdk/incubator/vector/RearrangeBytesBenchmark.java @@ -32,7 +32,7 @@ @OutputTimeUnit(TimeUnit.MILLISECONDS) @State(Scope.Thread) -@Fork(jvmArgsPrepend = {"--add-modules=jdk.incubator.vector"}) +@Fork(jvmArgs = {"--add-modules=jdk.incubator.vector"}) public class RearrangeBytesBenchmark { @Param({"256", "512", "1024"}) int size; diff --git a/test/micro/org/openjdk/bench/jdk/incubator/vector/RotateBenchmark.java b/test/micro/org/openjdk/bench/jdk/incubator/vector/RotateBenchmark.java index 3628479342a..0ebf844e94b 100644 --- a/test/micro/org/openjdk/bench/jdk/incubator/vector/RotateBenchmark.java +++ b/test/micro/org/openjdk/bench/jdk/incubator/vector/RotateBenchmark.java @@ -32,7 +32,7 @@ @OutputTimeUnit(TimeUnit.MILLISECONDS) @State(Scope.Thread) -@Fork(jvmArgsPrepend = {"--add-modules=jdk.incubator.vector"}) +@Fork(jvmArgs = {"--add-modules=jdk.incubator.vector"}) public class RotateBenchmark { @Param({"256","512"}) int size; diff --git a/test/micro/org/openjdk/bench/jdk/incubator/vector/SelectFromBenchmark.java b/test/micro/org/openjdk/bench/jdk/incubator/vector/SelectFromBenchmark.java index 18614617e6c..1a370596c08 100644 --- a/test/micro/org/openjdk/bench/jdk/incubator/vector/SelectFromBenchmark.java +++ b/test/micro/org/openjdk/bench/jdk/incubator/vector/SelectFromBenchmark.java @@ -33,7 +33,7 @@ @OutputTimeUnit(TimeUnit.MILLISECONDS) @State(Scope.Thread) -@Fork(jvmArgsPrepend = {"--add-modules=jdk.incubator.vector"}) +@Fork(jvmArgs = {"--add-modules=jdk.incubator.vector"}) public class SelectFromBenchmark { @Param({"1024","2048"}) int size; diff --git a/test/micro/org/openjdk/bench/jdk/incubator/vector/StoreMaskTrueCount.java b/test/micro/org/openjdk/bench/jdk/incubator/vector/StoreMaskTrueCount.java index 372edd0cfb5..db9f7cf1028 100644 --- a/test/micro/org/openjdk/bench/jdk/incubator/vector/StoreMaskTrueCount.java +++ b/test/micro/org/openjdk/bench/jdk/incubator/vector/StoreMaskTrueCount.java @@ -30,7 +30,7 @@ @OutputTimeUnit(TimeUnit.MILLISECONDS) @State(Scope.Thread) -@Fork(jvmArgsPrepend = {"--add-modules=jdk.incubator.vector"}) +@Fork(jvmArgs = {"--add-modules=jdk.incubator.vector"}) public class StoreMaskTrueCount { private static final VectorSpecies S_SPECIES = ShortVector.SPECIES_PREFERRED; private static final VectorSpecies I_SPECIES = IntVector.SPECIES_PREFERRED; diff --git a/test/micro/org/openjdk/bench/jdk/incubator/vector/StoreMaskedBenchmark.java b/test/micro/org/openjdk/bench/jdk/incubator/vector/StoreMaskedBenchmark.java index e5c21527e4a..626de9b898c 100644 --- a/test/micro/org/openjdk/bench/jdk/incubator/vector/StoreMaskedBenchmark.java +++ b/test/micro/org/openjdk/bench/jdk/incubator/vector/StoreMaskedBenchmark.java @@ -32,7 +32,7 @@ @State(Scope.Thread) @Warmup(iterations = 3, time = 1) @Measurement(iterations = 5, time = 1) -@Fork(value = 1, jvmArgsPrepend = {"--add-modules=jdk.incubator.vector"}) +@Fork(value = 1, jvmArgs = {"--add-modules=jdk.incubator.vector"}) public class StoreMaskedBenchmark { @Param({"1024"}) private int size; diff --git a/test/micro/org/openjdk/bench/jdk/incubator/vector/StoreMaskedIOOBEBenchmark.java b/test/micro/org/openjdk/bench/jdk/incubator/vector/StoreMaskedIOOBEBenchmark.java index 1855338552e..241bd081d3a 100644 --- a/test/micro/org/openjdk/bench/jdk/incubator/vector/StoreMaskedIOOBEBenchmark.java +++ b/test/micro/org/openjdk/bench/jdk/incubator/vector/StoreMaskedIOOBEBenchmark.java @@ -31,7 +31,7 @@ @State(Scope.Thread) @Warmup(iterations = 3, time = 1) @Measurement(iterations = 5, time = 1) -@Fork(value = 1, jvmArgsPrepend = {"--add-modules=jdk.incubator.vector"}) +@Fork(value = 1, jvmArgs = {"--add-modules=jdk.incubator.vector"}) public class StoreMaskedIOOBEBenchmark { @Param({"1024"}) private int inSize; diff --git a/test/micro/org/openjdk/bench/jdk/incubator/vector/TestLoadSegmentVarious.java b/test/micro/org/openjdk/bench/jdk/incubator/vector/TestLoadSegmentVarious.java index 5ec17c26ca5..53564edab2d 100644 --- a/test/micro/org/openjdk/bench/jdk/incubator/vector/TestLoadSegmentVarious.java +++ b/test/micro/org/openjdk/bench/jdk/incubator/vector/TestLoadSegmentVarious.java @@ -46,7 +46,7 @@ @Measurement(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS) @State(org.openjdk.jmh.annotations.Scope.Thread) @OutputTimeUnit(TimeUnit.NANOSECONDS) -@Fork(value = 1, jvmArgsAppend = { +@Fork(value = 1, jvmArgs = { "--add-modules=jdk.incubator.vector", "--enable-native-access", "ALL-UNNAMED"}) public class TestLoadSegmentVarious { diff --git a/test/micro/org/openjdk/bench/jdk/incubator/vector/TestLoadStoreBytes.java b/test/micro/org/openjdk/bench/jdk/incubator/vector/TestLoadStoreBytes.java index 3ea1943e703..feac109230a 100644 --- a/test/micro/org/openjdk/bench/jdk/incubator/vector/TestLoadStoreBytes.java +++ b/test/micro/org/openjdk/bench/jdk/incubator/vector/TestLoadStoreBytes.java @@ -47,7 +47,7 @@ @Measurement(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS) @State(org.openjdk.jmh.annotations.Scope.Thread) @OutputTimeUnit(TimeUnit.NANOSECONDS) -@Fork(value = 1, jvmArgsAppend = { +@Fork(value = 1, jvmArgs = { "--add-modules=jdk.incubator.vector", "--enable-native-access", "ALL-UNNAMED", "-Djdk.incubator.vector.VECTOR_ACCESS_OOB_CHECK=1"}) diff --git a/test/micro/org/openjdk/bench/jdk/incubator/vector/TestLoadStoreShorts.java b/test/micro/org/openjdk/bench/jdk/incubator/vector/TestLoadStoreShorts.java index d6c6531d3f8..842313357bd 100644 --- a/test/micro/org/openjdk/bench/jdk/incubator/vector/TestLoadStoreShorts.java +++ b/test/micro/org/openjdk/bench/jdk/incubator/vector/TestLoadStoreShorts.java @@ -50,7 +50,7 @@ @Measurement(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS) @State(org.openjdk.jmh.annotations.Scope.Thread) @OutputTimeUnit(TimeUnit.NANOSECONDS) -@Fork(value = 1, jvmArgsAppend = { +@Fork(value = 1, jvmArgs = { "--add-modules=jdk.incubator.vector", "--enable-native-access", "ALL-UNNAMED"}) public class TestLoadStoreShorts { diff --git a/test/micro/org/openjdk/bench/jdk/incubator/vector/VectorExtractBenchmark.java b/test/micro/org/openjdk/bench/jdk/incubator/vector/VectorExtractBenchmark.java index 4715cdb08ba..6358cb0a5d4 100644 --- a/test/micro/org/openjdk/bench/jdk/incubator/vector/VectorExtractBenchmark.java +++ b/test/micro/org/openjdk/bench/jdk/incubator/vector/VectorExtractBenchmark.java @@ -28,7 +28,7 @@ @OutputTimeUnit(TimeUnit.MILLISECONDS) @State(Scope.Thread) -@Fork(jvmArgsPrepend = {"--add-modules=jdk.incubator.vector"}) +@Fork(jvmArgs = {"--add-modules=jdk.incubator.vector"}) public class VectorExtractBenchmark { private int idx = 0; private boolean[] res = new boolean[8]; diff --git a/test/micro/org/openjdk/bench/jdk/incubator/vector/VectorFPtoIntCastOperations.java b/test/micro/org/openjdk/bench/jdk/incubator/vector/VectorFPtoIntCastOperations.java index b66fc9646a0..35069af60f6 100644 --- a/test/micro/org/openjdk/bench/jdk/incubator/vector/VectorFPtoIntCastOperations.java +++ b/test/micro/org/openjdk/bench/jdk/incubator/vector/VectorFPtoIntCastOperations.java @@ -31,7 +31,7 @@ @OutputTimeUnit(TimeUnit.MILLISECONDS) @State(Scope.Thread) -@Fork(jvmArgsPrepend = {"--add-modules=jdk.incubator.vector"}) +@Fork(jvmArgs = {"--add-modules=jdk.incubator.vector"}) public class VectorFPtoIntCastOperations { @Param({"512", "1024"}) static int SIZE; diff --git a/test/micro/org/openjdk/bench/jdk/incubator/vector/VectorZeroExtend.java b/test/micro/org/openjdk/bench/jdk/incubator/vector/VectorZeroExtend.java index 503d80356da..e250ddd9008 100644 --- a/test/micro/org/openjdk/bench/jdk/incubator/vector/VectorZeroExtend.java +++ b/test/micro/org/openjdk/bench/jdk/incubator/vector/VectorZeroExtend.java @@ -32,7 +32,7 @@ @OutputTimeUnit(TimeUnit.MILLISECONDS) @State(Scope.Thread) -@Fork(jvmArgsPrepend = {"--add-modules=jdk.incubator.vector"}) +@Fork(jvmArgs = {"--add-modules=jdk.incubator.vector"}) public class VectorZeroExtend { private static final VectorSpecies B_SPECIES = ByteVector.SPECIES_PREFERRED; private static final VectorSpecies S_SPECIES = ShortVector.SPECIES_PREFERRED; diff --git a/test/micro/org/openjdk/bench/jdk/preview/patterns/Exactness.java b/test/micro/org/openjdk/bench/jdk/preview/patterns/Exactness.java index 675f5bda398..34971ccf93a 100644 --- a/test/micro/org/openjdk/bench/jdk/preview/patterns/Exactness.java +++ b/test/micro/org/openjdk/bench/jdk/preview/patterns/Exactness.java @@ -35,7 +35,7 @@ @Measurement(iterations=5, time=1) @Threads(2) @Fork(value = 1, - jvmArgsPrepend = {"-Djmh.blackhole.mode=COMPILER", + jvmArgs = {"-Djmh.blackhole.mode=COMPILER", "--enable-preview"}) @State(Scope.Thread) @SuppressWarnings("preview") diff --git a/test/micro/org/openjdk/bench/vm/compiler/AllocationMerges.java b/test/micro/org/openjdk/bench/vm/compiler/AllocationMerges.java index 84c6c5c6483..b4b833cd95a 100644 --- a/test/micro/org/openjdk/bench/vm/compiler/AllocationMerges.java +++ b/test/micro/org/openjdk/bench/vm/compiler/AllocationMerges.java @@ -1194,7 +1194,7 @@ public void testString_two_caller(Blackhole bh) { // ------------------ Utility for Benchmarking ------------------- // - @Fork(value = 3, jvmArgsPrepend = { + @Fork(value = 3, jvmArgs = { "-XX:+UnlockDiagnosticVMOptions", "-XX:+UseTLAB", "-XX:-ReduceAllocationMerges", @@ -1202,7 +1202,7 @@ public void testString_two_caller(Blackhole bh) { public static class NopRAM extends AllocationMerges { } - @Fork(value = 3, jvmArgsPrepend = { + @Fork(value = 3, jvmArgs = { "-XX:+UnlockDiagnosticVMOptions", "-XX:+ReduceAllocationMerges", }) diff --git a/test/micro/org/openjdk/bench/vm/compiler/ClearMemory.java b/test/micro/org/openjdk/bench/vm/compiler/ClearMemory.java index f70b4aa734a..434805875c1 100644 --- a/test/micro/org/openjdk/bench/vm/compiler/ClearMemory.java +++ b/test/micro/org/openjdk/bench/vm/compiler/ClearMemory.java @@ -38,7 +38,7 @@ import java.util.concurrent.TimeUnit; -@Fork(value = 3, jvmArgsPrepend = {"-XX:-EliminateAllocations", "-XX:-DoEscapeAnalysis"}) +@Fork(value = 3, jvmArgs = {"-XX:-EliminateAllocations", "-XX:-DoEscapeAnalysis"}) @BenchmarkMode(Mode.Throughput) @OutputTimeUnit(TimeUnit.SECONDS) @State(Scope.Thread) diff --git a/test/micro/org/openjdk/bench/vm/compiler/ConstructorBarriers.java b/test/micro/org/openjdk/bench/vm/compiler/ConstructorBarriers.java index 7adbbe0e1a7..83dc38552fa 100644 --- a/test/micro/org/openjdk/bench/vm/compiler/ConstructorBarriers.java +++ b/test/micro/org/openjdk/bench/vm/compiler/ConstructorBarriers.java @@ -41,7 +41,7 @@ @State(Scope.Thread) @Warmup(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS) @Measurement(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS) -@Fork(value = 3, jvmArgsAppend = {"-Xms512m", "-Xmx512m", "-XX:+AlwaysPreTouch", "-XX:+UseParallelGC"}) +@Fork(value = 3, jvmArgs = {"-Xms512m", "-Xmx512m", "-XX:+AlwaysPreTouch", "-XX:+UseParallelGC"}) public class ConstructorBarriers { // Checks the barrier coalescing/optimization around field initializations. diff --git a/test/micro/org/openjdk/bench/vm/compiler/InterfacePrivateCalls.java b/test/micro/org/openjdk/bench/vm/compiler/InterfacePrivateCalls.java index 7ccc91901de..7e8800a3fbe 100644 --- a/test/micro/org/openjdk/bench/vm/compiler/InterfacePrivateCalls.java +++ b/test/micro/org/openjdk/bench/vm/compiler/InterfacePrivateCalls.java @@ -64,7 +64,7 @@ public void setupTrial() { @Benchmark @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) - @Fork(value=3, jvmArgsAppend={"-XX:TieredStopAtLevel=1"}) + @Fork(value=3, jvmArgs={"-XX:TieredStopAtLevel=1"}) public void invokePrivateInterfaceMethodC1() { for (int i = 0; i < objs.length; ++i) { objs[i].foo(); diff --git a/test/micro/org/openjdk/bench/vm/compiler/MergeStoreBench.java b/test/micro/org/openjdk/bench/vm/compiler/MergeStoreBench.java index 26c8287c4de..870422de256 100644 --- a/test/micro/org/openjdk/bench/vm/compiler/MergeStoreBench.java +++ b/test/micro/org/openjdk/bench/vm/compiler/MergeStoreBench.java @@ -43,7 +43,7 @@ @State(Scope.Thread) @Warmup(iterations = 10, time = 500, timeUnit = TimeUnit.MILLISECONDS) @Measurement(iterations = 5, time = 1000, timeUnit = TimeUnit.MILLISECONDS) -@Fork(value = 3, jvmArgsAppend = {"--add-exports", "java.base/jdk.internal.misc=ALL-UNNAMED"}) +@Fork(value = 3, jvmArgs = {"--add-exports", "java.base/jdk.internal.misc=ALL-UNNAMED"}) public class MergeStoreBench { private static final Unsafe UNSAFE = Unsafe.getUnsafe(); diff --git a/test/micro/org/openjdk/bench/vm/compiler/MergeStores.java b/test/micro/org/openjdk/bench/vm/compiler/MergeStores.java index 84017573c07..93d98116ecc 100644 --- a/test/micro/org/openjdk/bench/vm/compiler/MergeStores.java +++ b/test/micro/org/openjdk/bench/vm/compiler/MergeStores.java @@ -43,7 +43,7 @@ @OutputTimeUnit(TimeUnit.NANOSECONDS) @Warmup(iterations = 3, time = 3) @Measurement(iterations = 3, time = 3) -@Fork(value = 3, jvmArgsAppend = { +@Fork(value = 3, jvmArgs = { "--add-exports", "java.base/jdk.internal.misc=ALL-UNNAMED", "--add-exports", "java.base/jdk.internal.util=ALL-UNNAMED"}) @State(Scope.Benchmark) diff --git a/test/micro/org/openjdk/bench/vm/compiler/SecondarySuperCacheHits.java b/test/micro/org/openjdk/bench/vm/compiler/SecondarySuperCacheHits.java index aaaf0edb258..69eaf875363 100644 --- a/test/micro/org/openjdk/bench/vm/compiler/SecondarySuperCacheHits.java +++ b/test/micro/org/openjdk/bench/vm/compiler/SecondarySuperCacheHits.java @@ -30,7 +30,7 @@ @Warmup(iterations = 5, time = 300, timeUnit = TimeUnit.MILLISECONDS) @Measurement(iterations = 5, time = 300, timeUnit = TimeUnit.MILLISECONDS) -@Fork(value = 3, jvmArgsAppend = {"-XX:+TieredCompilation", "-XX:TieredStopAtLevel=1"}) +@Fork(value = 3, jvmArgs = {"-XX:+TieredCompilation", "-XX:TieredStopAtLevel=1"}) @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) @Threads(1) diff --git a/test/micro/org/openjdk/bench/vm/compiler/SecondarySuperCacheInterContention.java b/test/micro/org/openjdk/bench/vm/compiler/SecondarySuperCacheInterContention.java index 3cafa582c09..03c6d75607b 100644 --- a/test/micro/org/openjdk/bench/vm/compiler/SecondarySuperCacheInterContention.java +++ b/test/micro/org/openjdk/bench/vm/compiler/SecondarySuperCacheInterContention.java @@ -30,7 +30,7 @@ @Warmup(iterations = 5, time = 300, timeUnit = TimeUnit.MILLISECONDS) @Measurement(iterations = 5, time = 300, timeUnit = TimeUnit.MILLISECONDS) -@Fork(value = 3, jvmArgsAppend = {"-XX:+TieredCompilation", "-XX:TieredStopAtLevel=1"}) +@Fork(value = 3, jvmArgs = {"-XX:+TieredCompilation", "-XX:TieredStopAtLevel=1"}) @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) @Threads(Threads.MAX) diff --git a/test/micro/org/openjdk/bench/vm/compiler/SecondarySuperCacheIntraContention.java b/test/micro/org/openjdk/bench/vm/compiler/SecondarySuperCacheIntraContention.java index b97d49e2e60..3c30c69a864 100644 --- a/test/micro/org/openjdk/bench/vm/compiler/SecondarySuperCacheIntraContention.java +++ b/test/micro/org/openjdk/bench/vm/compiler/SecondarySuperCacheIntraContention.java @@ -30,7 +30,7 @@ @Warmup(iterations = 5, time = 300, timeUnit = TimeUnit.MILLISECONDS) @Measurement(iterations = 5, time = 300, timeUnit = TimeUnit.MILLISECONDS) -@Fork(value = 3, jvmArgsAppend = {"-XX:+TieredCompilation", "-XX:TieredStopAtLevel=1"}) +@Fork(value = 3, jvmArgs = {"-XX:+TieredCompilation", "-XX:TieredStopAtLevel=1"}) @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) @Threads(Threads.MAX) diff --git a/test/micro/org/openjdk/bench/vm/compiler/SubIdealC0Minus_YPlusC1_.java b/test/micro/org/openjdk/bench/vm/compiler/SubIdealC0Minus_YPlusC1_.java index 17728f6bc25..5ac4e58dce6 100644 --- a/test/micro/org/openjdk/bench/vm/compiler/SubIdealC0Minus_YPlusC1_.java +++ b/test/micro/org/openjdk/bench/vm/compiler/SubIdealC0Minus_YPlusC1_.java @@ -47,7 +47,7 @@ @State(Scope.Thread) @Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) @Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS) -@Fork(value = 3 , jvmArgsAppend = {"-XX:-TieredCompilation", "-Xbatch", "-Xcomp"}) +@Fork(value = 3 , jvmArgs = {"-XX:-TieredCompilation", "-Xbatch", "-Xcomp"}) public class SubIdealC0Minus_YPlusC1_ { private static final int I_C0 = 1234567; diff --git a/test/micro/org/openjdk/bench/vm/compiler/TypeVectorOperations.java b/test/micro/org/openjdk/bench/vm/compiler/TypeVectorOperations.java index a3e4445664c..c39107fdd00 100644 --- a/test/micro/org/openjdk/bench/vm/compiler/TypeVectorOperations.java +++ b/test/micro/org/openjdk/bench/vm/compiler/TypeVectorOperations.java @@ -382,7 +382,7 @@ public void andZ() { } @Benchmark - @Fork(jvmArgsPrepend = {"-XX:+UseCMoveUnconditionally", "-XX:+UseVectorCmov"}) + @Fork(jvmArgs = {"-XX:+UseCMoveUnconditionally", "-XX:+UseVectorCmov"}) public void cmoveD() { for (int i = 0; i < COUNT; i++) { resD[i] = resD[i] < doubles[i] ? resD[i] : doubles[i]; @@ -390,21 +390,21 @@ public void cmoveD() { } @Benchmark - @Fork(jvmArgsPrepend = {"-XX:+UseCMoveUnconditionally", "-XX:+UseVectorCmov"}) + @Fork(jvmArgs = {"-XX:+UseCMoveUnconditionally", "-XX:+UseVectorCmov"}) public void cmoveF() { for (int i = 0; i < COUNT; i++) { resF[i] = resF[i] < floats[i] ? resF[i] : floats[i]; } } - @Fork(value = 2, jvmArgsPrepend = { + @Fork(value = 2, jvmArgs = { "-XX:+UseSuperWord" }) public static class TypeVectorOperationsSuperWord extends TypeVectorOperations { } - @Fork(value = 2, jvmArgsPrepend = { + @Fork(value = 2, jvmArgs = { "-XX:-UseSuperWord" }) public static class TypeVectorOperationsNonSuperWord extends TypeVectorOperations { diff --git a/test/micro/org/openjdk/bench/vm/compiler/VectorAlignment.java b/test/micro/org/openjdk/bench/vm/compiler/VectorAlignment.java index 7fff4952c8e..1d684260d89 100644 --- a/test/micro/org/openjdk/bench/vm/compiler/VectorAlignment.java +++ b/test/micro/org/openjdk/bench/vm/compiler/VectorAlignment.java @@ -293,22 +293,22 @@ public void bench401_hand_unrolled_misaligned() { } } - @Fork(value = 1, jvmArgsPrepend = { + @Fork(value = 1, jvmArgs = { "-XX:+UseSuperWord", "-XX:CompileCommand=Option,*::*,Vectorize" }) public static class VectorAlignmentSuperWordWithVectorize extends VectorAlignment {} - @Fork(value = 1, jvmArgsPrepend = { + @Fork(value = 1, jvmArgs = { "-XX:+UseSuperWord", "-XX:+AlignVector" }) public static class VectorAlignmentSuperWordAlignVector extends VectorAlignment {} - @Fork(value = 1, jvmArgsPrepend = { + @Fork(value = 1, jvmArgs = { "-XX:+UseSuperWord" }) public static class VectorAlignmentSuperWord extends VectorAlignment {} - @Fork(value = 1, jvmArgsPrepend = { + @Fork(value = 1, jvmArgs = { "-XX:-UseSuperWord" }) public static class VectorAlignmentNoSuperWord extends VectorAlignment {} diff --git a/test/micro/org/openjdk/bench/vm/compiler/VectorBitCount.java b/test/micro/org/openjdk/bench/vm/compiler/VectorBitCount.java index 49b644a64f1..cfb37b71caf 100644 --- a/test/micro/org/openjdk/bench/vm/compiler/VectorBitCount.java +++ b/test/micro/org/openjdk/bench/vm/compiler/VectorBitCount.java @@ -72,14 +72,14 @@ public int[] longBitCount() { } - @Fork(value = 2, jvmArgsPrepend = { + @Fork(value = 2, jvmArgs = { "-XX:+UseSuperWord" }) public static class WithSuperword extends VectorBitCount { } - @Fork(value = 2, jvmArgsPrepend = { + @Fork(value = 2, jvmArgs = { "-XX:-UseSuperWord" }) public static class NoSuperword extends VectorBitCount { diff --git a/test/micro/org/openjdk/bench/vm/compiler/VectorLoadToStoreForwarding.java b/test/micro/org/openjdk/bench/vm/compiler/VectorLoadToStoreForwarding.java index efbf99c6ce5..1aed0fc3321 100644 --- a/test/micro/org/openjdk/bench/vm/compiler/VectorLoadToStoreForwarding.java +++ b/test/micro/org/openjdk/bench/vm/compiler/VectorLoadToStoreForwarding.java @@ -200,12 +200,12 @@ public void benchmark_20() { } } - @Fork(value = 1, jvmArgsPrepend = { + @Fork(value = 1, jvmArgs = { "-XX:+UseSuperWord" }) public static class VectorLoadToStoreForwardingSuperWord extends VectorLoadToStoreForwarding {} - @Fork(value = 1, jvmArgsPrepend = { + @Fork(value = 1, jvmArgs = { "-XX:-UseSuperWord" }) public static class VectorLoadToStoreForwardingNoSuperWord extends VectorLoadToStoreForwarding {} diff --git a/test/micro/org/openjdk/bench/vm/compiler/VectorReduction.java b/test/micro/org/openjdk/bench/vm/compiler/VectorReduction.java index 9b293b6b7e5..1507dd211e6 100644 --- a/test/micro/org/openjdk/bench/vm/compiler/VectorReduction.java +++ b/test/micro/org/openjdk/bench/vm/compiler/VectorReduction.java @@ -176,14 +176,14 @@ public void andRedIOnGlobalAccumulator() { } } - @Fork(value = 2, jvmArgsPrepend = { + @Fork(value = 2, jvmArgs = { "-XX:+UseSuperWord" }) public static class WithSuperword extends VectorReduction { } - @Fork(value = 2, jvmArgsPrepend = { + @Fork(value = 2, jvmArgs = { "-XX:-UseSuperWord" }) public static class NoSuperword extends VectorReduction { diff --git a/test/micro/org/openjdk/bench/vm/compiler/VectorReduction2.java b/test/micro/org/openjdk/bench/vm/compiler/VectorReduction2.java index 5ec34a0423f..ec614cb324b 100644 --- a/test/micro/org/openjdk/bench/vm/compiler/VectorReduction2.java +++ b/test/micro/org/openjdk/bench/vm/compiler/VectorReduction2.java @@ -1445,10 +1445,10 @@ public void doubleMaxBig(Blackhole bh) { bh.consume(acc); } - @Fork(value = 1, jvmArgsPrepend = {"-XX:+UseSuperWord"}) + @Fork(value = 1, jvmArgs = {"-XX:+UseSuperWord"}) public static class WithSuperword extends VectorReduction2 {} - @Fork(value = 1, jvmArgsPrepend = {"-XX:-UseSuperWord"}) + @Fork(value = 1, jvmArgs = {"-XX:-UseSuperWord"}) public static class NoSuperword extends VectorReduction2 {} } diff --git a/test/micro/org/openjdk/bench/vm/compiler/VectorReductionFloatingMinMax.java b/test/micro/org/openjdk/bench/vm/compiler/VectorReductionFloatingMinMax.java index d25d22f12b1..870164b8050 100644 --- a/test/micro/org/openjdk/bench/vm/compiler/VectorReductionFloatingMinMax.java +++ b/test/micro/org/openjdk/bench/vm/compiler/VectorReductionFloatingMinMax.java @@ -69,7 +69,7 @@ public void init() { } @Benchmark - @Fork(jvmArgsPrepend = {"-XX:-SuperWordLoopUnrollAnalysis"}) + @Fork(jvmArgs = {"-XX:-SuperWordLoopUnrollAnalysis"}) public void maxRedF(Blackhole bh) { float max = 0.0f; for (int i = 0; i < COUNT_FLOAT; i++) { @@ -79,7 +79,7 @@ public void maxRedF(Blackhole bh) { } @Benchmark - @Fork(jvmArgsPrepend = {"-XX:-SuperWordLoopUnrollAnalysis"}) + @Fork(jvmArgs = {"-XX:-SuperWordLoopUnrollAnalysis"}) public void minRedF(Blackhole bh) { float min = 0.0f; for (int i = 0; i < COUNT_FLOAT; i++) { diff --git a/test/micro/org/openjdk/bench/vm/compiler/overhead/SimpleRepeatCompilation.java b/test/micro/org/openjdk/bench/vm/compiler/overhead/SimpleRepeatCompilation.java index 0605050ed2a..9538e13df2d 100644 --- a/test/micro/org/openjdk/bench/vm/compiler/overhead/SimpleRepeatCompilation.java +++ b/test/micro/org/openjdk/bench/vm/compiler/overhead/SimpleRepeatCompilation.java @@ -52,25 +52,25 @@ public class SimpleRepeatCompilation { = "-XX:CompileCommand=option,org/openjdk/bench/vm/compiler/overhead/SimpleRepeatCompilation.mixHashCode,intx,RepeatCompilation,500"; @Benchmark - @Fork(jvmArgsAppend={"-Xbatch", MIXHASH_METHOD}) + @Fork(jvmArgs={"-Xbatch", MIXHASH_METHOD}) public int mixHashCode_repeat() { return loop_hashCode(); } @Benchmark - @Fork(jvmArgsAppend={"-Xbatch", "-XX:-TieredCompilation", MIXHASH_METHOD}) + @Fork(jvmArgs={"-Xbatch", "-XX:-TieredCompilation", MIXHASH_METHOD}) public int mixHashCode_repeat_c2() { return loop_hashCode(); } @Benchmark - @Fork(jvmArgsAppend={"-Xbatch", "-XX:TieredStopAtLevel=1", MIXHASH_METHOD}) + @Fork(jvmArgs={"-Xbatch", "-XX:TieredStopAtLevel=1", MIXHASH_METHOD}) public int mixHashCode_repeat_c1() { return loop_hashCode(); } @Benchmark - @Fork(jvmArgsAppend={"-Xbatch"}) + @Fork(jvmArgs={"-Xbatch"}) public int mixHashCode_baseline() { return loop_hashCode(); } @@ -95,25 +95,25 @@ public int mixHashCode(String value) { = "-XX:CompileCommand=option,org/openjdk/bench/vm/compiler/overhead/SimpleRepeatCompilation.trivialMath,intx,RepeatCompilation,2000"; @Benchmark - @Fork(jvmArgsAppend={"-Xbatch",TRIVIAL_MATH_METHOD}) + @Fork(jvmArgs={"-Xbatch",TRIVIAL_MATH_METHOD}) public int trivialMath_repeat() { return loop_trivialMath(); } @Benchmark - @Fork(jvmArgsAppend={"-Xbatch", "-XX:-TieredCompilation", TRIVIAL_MATH_METHOD}) + @Fork(jvmArgs={"-Xbatch", "-XX:-TieredCompilation", TRIVIAL_MATH_METHOD}) public int trivialMath_repeat_c2() { return loop_trivialMath(); } @Benchmark - @Fork(jvmArgsAppend={"-Xbatch", "-XX:TieredStopAtLevel=1", TRIVIAL_MATH_METHOD}) + @Fork(jvmArgs={"-Xbatch", "-XX:TieredStopAtLevel=1", TRIVIAL_MATH_METHOD}) public int trivialMath_repeat_c1() { return loop_trivialMath(); } @Benchmark - @Fork(jvmArgsAppend={"-Xbatch"}) + @Fork(jvmArgs={"-Xbatch"}) public int trivialMath_baseline() { return loop_trivialMath(); } @@ -135,25 +135,25 @@ public int trivialMath(int a, int b) { = "-XX:CompileCommand=option,org/openjdk/bench/vm/compiler/overhead/SimpleRepeatCompilation.largeMethod,intx,RepeatCompilation,100"; @Benchmark - @Fork(jvmArgsAppend={"-Xbatch",LARGE_METHOD}) + @Fork(jvmArgs={"-Xbatch",LARGE_METHOD}) public int largeMethod_repeat() { return loop_largeMethod(); } @Benchmark - @Fork(jvmArgsAppend={"-Xbatch", "-XX:-TieredCompilation", LARGE_METHOD}) + @Fork(jvmArgs={"-Xbatch", "-XX:-TieredCompilation", LARGE_METHOD}) public int largeMethod_repeat_c2() { return loop_largeMethod(); } @Benchmark - @Fork(jvmArgsAppend={"-Xbatch", "-XX:TieredStopAtLevel=1", LARGE_METHOD}) + @Fork(jvmArgs={"-Xbatch", "-XX:TieredStopAtLevel=1", LARGE_METHOD}) public int largeMethod_repeat_c1() { return loop_largeMethod(); } @Benchmark - @Fork(jvmArgsAppend={"-Xbatch"}) + @Fork(jvmArgs={"-Xbatch"}) public int largeMethod_baseline() { return loop_largeMethod(); } diff --git a/test/micro/org/openjdk/bench/vm/compiler/x86/BasicRules.java b/test/micro/org/openjdk/bench/vm/compiler/x86/BasicRules.java index 4b04e168f16..fa13fae42cc 100644 --- a/test/micro/org/openjdk/bench/vm/compiler/x86/BasicRules.java +++ b/test/micro/org/openjdk/bench/vm/compiler/x86/BasicRules.java @@ -31,7 +31,7 @@ @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) @State(Scope.Thread) -@Fork(value = 3, jvmArgsAppend = "-XX:-UseSuperWord") +@Fork(value = 3, jvmArgs = "-XX:-UseSuperWord") @Warmup(time = 1, timeUnit = TimeUnit.SECONDS) @Measurement(time = 1, timeUnit = TimeUnit.SECONDS) public class BasicRules { diff --git a/test/micro/org/openjdk/bench/vm/compiler/x86/ConvertF2I.java b/test/micro/org/openjdk/bench/vm/compiler/x86/ConvertF2I.java index 406da5f65e5..dd807532e72 100644 --- a/test/micro/org/openjdk/bench/vm/compiler/x86/ConvertF2I.java +++ b/test/micro/org/openjdk/bench/vm/compiler/x86/ConvertF2I.java @@ -31,7 +31,7 @@ @State(Scope.Thread) @Warmup(iterations = 5, time = 1) @Measurement(iterations = 5, time = 1) -@Fork(value = 1, jvmArgsAppend = {"-XX:-UseSuperWord"}) +@Fork(value = 1, jvmArgs = {"-XX:-UseSuperWord"}) public class ConvertF2I { static final int LENGTH = 1000; int[] intArray = new int[LENGTH]; diff --git a/test/micro/org/openjdk/bench/vm/compiler/x86/LeaInstruction.java b/test/micro/org/openjdk/bench/vm/compiler/x86/LeaInstruction.java index f4cd27a5dd4..fb4be3ec454 100644 --- a/test/micro/org/openjdk/bench/vm/compiler/x86/LeaInstruction.java +++ b/test/micro/org/openjdk/bench/vm/compiler/x86/LeaInstruction.java @@ -29,7 +29,7 @@ @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) -@Fork(value = 2, jvmArgsAppend = {"-XX:LoopUnrollLimit=1"}) +@Fork(value = 2, jvmArgs = {"-XX:LoopUnrollLimit=1"}) @Warmup(iterations = 4, time = 2, timeUnit = TimeUnit.SECONDS) @Measurement(iterations = 4, time = 2, timeUnit = TimeUnit.SECONDS) @State(Scope.Thread) diff --git a/test/micro/org/openjdk/bench/vm/fences/SafePublishing.java b/test/micro/org/openjdk/bench/vm/fences/SafePublishing.java index e18564c4c3a..d5b1ae24872 100644 --- a/test/micro/org/openjdk/bench/vm/fences/SafePublishing.java +++ b/test/micro/org/openjdk/bench/vm/fences/SafePublishing.java @@ -30,7 +30,7 @@ @Warmup(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS) @Measurement(iterations = 3, time = 1, timeUnit = TimeUnit.SECONDS) -@Fork(value = 3, jvmArgsAppend = {"-XX:+UseParallelGC", "-Xmx128m"}) +@Fork(value = 3, jvmArgs = {"-XX:+UseParallelGC", "-Xmx128m"}) @BenchmarkMode(Mode.AverageTime) @OutputTimeUnit(TimeUnit.NANOSECONDS) @State(Scope.Thread) diff --git a/test/micro/org/openjdk/bench/vm/gc/MicroLargePages.java b/test/micro/org/openjdk/bench/vm/gc/MicroLargePages.java index 67702cfe607..66044f8249d 100644 --- a/test/micro/org/openjdk/bench/vm/gc/MicroLargePages.java +++ b/test/micro/org/openjdk/bench/vm/gc/MicroLargePages.java @@ -29,7 +29,7 @@ @OutputTimeUnit(TimeUnit.MINUTES) @State(Scope.Thread) -@Fork(jvmArgsAppend = {"-Xmx256m", "-XX:+UseLargePages", "-XX:LargePageSizeInBytes=1g", "-Xlog:pagesize"}, value = 5) +@Fork(jvmArgs = {"-Xmx256m", "-XX:+UseLargePages", "-XX:LargePageSizeInBytes=1g", "-Xlog:pagesize"}, value = 5) public class MicroLargePages { diff --git a/test/micro/org/openjdk/bench/vm/gc/RawAllocationRate.java b/test/micro/org/openjdk/bench/vm/gc/RawAllocationRate.java index 4faf3e19535..a0987ddd8d8 100644 --- a/test/micro/org/openjdk/bench/vm/gc/RawAllocationRate.java +++ b/test/micro/org/openjdk/bench/vm/gc/RawAllocationRate.java @@ -80,7 +80,7 @@ public Object[] arrayTest() { } @Benchmark - @Fork(jvmArgsAppend={"-XX:TieredStopAtLevel=1"}) + @Fork(jvmArgs={"-XX:TieredStopAtLevel=1"}) public Object[] arrayTest_C1() { return arrayTest(); } @@ -106,7 +106,7 @@ public Object[] instanceTest() { } @Benchmark - @Fork(jvmArgsAppend={"-XX:TieredStopAtLevel=1"}) + @Fork(jvmArgs={"-XX:TieredStopAtLevel=1"}) public Object[] instanceTest_C1() { return instanceTest(); } diff --git a/test/micro/org/openjdk/bench/vm/gc/systemgc/AllDead.java b/test/micro/org/openjdk/bench/vm/gc/systemgc/AllDead.java index 12e1ff25454..6e41ec0610e 100644 --- a/test/micro/org/openjdk/bench/vm/gc/systemgc/AllDead.java +++ b/test/micro/org/openjdk/bench/vm/gc/systemgc/AllDead.java @@ -36,7 +36,7 @@ import java.util.concurrent.TimeUnit; @BenchmarkMode(Mode.SingleShotTime) -@Fork(value=25, jvmArgsAppend={"-Xmx5g", "-Xms5g", "-Xmn3g", "-XX:+AlwaysPreTouch"}) +@Fork(value=25, jvmArgs={"-Xmx5g", "-Xms5g", "-Xmn3g", "-XX:+AlwaysPreTouch"}) @OutputTimeUnit(TimeUnit.MILLISECONDS) @State(Scope.Benchmark) public class AllDead { diff --git a/test/micro/org/openjdk/bench/vm/gc/systemgc/AllLive.java b/test/micro/org/openjdk/bench/vm/gc/systemgc/AllLive.java index ddd9f56cf60..2a2bf060833 100644 --- a/test/micro/org/openjdk/bench/vm/gc/systemgc/AllLive.java +++ b/test/micro/org/openjdk/bench/vm/gc/systemgc/AllLive.java @@ -36,7 +36,7 @@ import java.util.concurrent.TimeUnit; @BenchmarkMode(Mode.SingleShotTime) -@Fork(value=25, jvmArgsAppend={"-Xmx5g", "-Xms5g", "-Xmn3g", "-XX:+AlwaysPreTouch"}) +@Fork(value=25, jvmArgs={"-Xmx5g", "-Xms5g", "-Xmn3g", "-XX:+AlwaysPreTouch"}) @OutputTimeUnit(TimeUnit.MILLISECONDS) @State(Scope.Benchmark) public class AllLive { diff --git a/test/micro/org/openjdk/bench/vm/gc/systemgc/DifferentObjectSizesArray.java b/test/micro/org/openjdk/bench/vm/gc/systemgc/DifferentObjectSizesArray.java index a4dcfdaaeb5..4de7c4a8f84 100644 --- a/test/micro/org/openjdk/bench/vm/gc/systemgc/DifferentObjectSizesArray.java +++ b/test/micro/org/openjdk/bench/vm/gc/systemgc/DifferentObjectSizesArray.java @@ -35,7 +35,7 @@ import java.util.concurrent.TimeUnit; @BenchmarkMode(Mode.SingleShotTime) -@Fork(value=25, jvmArgsAppend={"-Xmx5g", "-Xms5g", "-Xmn3g", "-XX:+AlwaysPreTouch"}) +@Fork(value=25, jvmArgs={"-Xmx5g", "-Xms5g", "-Xmn3g", "-XX:+AlwaysPreTouch"}) @OutputTimeUnit(TimeUnit.MILLISECONDS) @State(Scope.Benchmark) public class DifferentObjectSizesArray { diff --git a/test/micro/org/openjdk/bench/vm/gc/systemgc/DifferentObjectSizesHashMap.java b/test/micro/org/openjdk/bench/vm/gc/systemgc/DifferentObjectSizesHashMap.java index 83914725161..960223f5035 100644 --- a/test/micro/org/openjdk/bench/vm/gc/systemgc/DifferentObjectSizesHashMap.java +++ b/test/micro/org/openjdk/bench/vm/gc/systemgc/DifferentObjectSizesHashMap.java @@ -36,7 +36,7 @@ import java.util.concurrent.TimeUnit; @BenchmarkMode(Mode.SingleShotTime) -@Fork(value=25, jvmArgsAppend={"-Xmx5g", "-Xms5g", "-Xmn3g", "-XX:+AlwaysPreTouch"}) +@Fork(value=25, jvmArgs={"-Xmx5g", "-Xms5g", "-Xmn3g", "-XX:+AlwaysPreTouch"}) @OutputTimeUnit(TimeUnit.MILLISECONDS) @State(Scope.Benchmark) public class DifferentObjectSizesHashMap { diff --git a/test/micro/org/openjdk/bench/vm/gc/systemgc/DifferentObjectSizesTreeMap.java b/test/micro/org/openjdk/bench/vm/gc/systemgc/DifferentObjectSizesTreeMap.java index 66aaffff693..d1fea505ac0 100644 --- a/test/micro/org/openjdk/bench/vm/gc/systemgc/DifferentObjectSizesTreeMap.java +++ b/test/micro/org/openjdk/bench/vm/gc/systemgc/DifferentObjectSizesTreeMap.java @@ -36,7 +36,7 @@ import java.util.concurrent.TimeUnit; @BenchmarkMode(Mode.SingleShotTime) -@Fork(value=25, jvmArgsAppend={"-Xmx5g", "-Xms5g", "-Xmn3g", "-XX:+AlwaysPreTouch"}) +@Fork(value=25, jvmArgs={"-Xmx5g", "-Xms5g", "-Xmn3g", "-XX:+AlwaysPreTouch"}) @OutputTimeUnit(TimeUnit.MILLISECONDS) @State(Scope.Benchmark) public class DifferentObjectSizesTreeMap { diff --git a/test/micro/org/openjdk/bench/vm/gc/systemgc/HalfDeadFirstPart.java b/test/micro/org/openjdk/bench/vm/gc/systemgc/HalfDeadFirstPart.java index 80cefbfe10f..339e31d7032 100644 --- a/test/micro/org/openjdk/bench/vm/gc/systemgc/HalfDeadFirstPart.java +++ b/test/micro/org/openjdk/bench/vm/gc/systemgc/HalfDeadFirstPart.java @@ -36,7 +36,7 @@ import java.util.concurrent.TimeUnit; @BenchmarkMode(Mode.SingleShotTime) -@Fork(value=25, jvmArgsAppend={"-Xmx5g", "-Xms5g", "-Xmn3g", "-XX:+AlwaysPreTouch"}) +@Fork(value=25, jvmArgs={"-Xmx5g", "-Xms5g", "-Xmn3g", "-XX:+AlwaysPreTouch"}) @OutputTimeUnit(TimeUnit.MILLISECONDS) @State(Scope.Benchmark) public class HalfDeadFirstPart { diff --git a/test/micro/org/openjdk/bench/vm/gc/systemgc/HalfDeadInterleaved.java b/test/micro/org/openjdk/bench/vm/gc/systemgc/HalfDeadInterleaved.java index bda9ccfa213..07eda82f2c9 100644 --- a/test/micro/org/openjdk/bench/vm/gc/systemgc/HalfDeadInterleaved.java +++ b/test/micro/org/openjdk/bench/vm/gc/systemgc/HalfDeadInterleaved.java @@ -36,7 +36,7 @@ import java.util.concurrent.TimeUnit; @BenchmarkMode(Mode.SingleShotTime) -@Fork(value=25, jvmArgsAppend={"-Xmx5g", "-Xms5g", "-Xmn3g", "-XX:+AlwaysPreTouch"}) +@Fork(value=25, jvmArgs={"-Xmx5g", "-Xms5g", "-Xmn3g", "-XX:+AlwaysPreTouch"}) @OutputTimeUnit(TimeUnit.MILLISECONDS) @State(Scope.Benchmark) public class HalfDeadInterleaved { diff --git a/test/micro/org/openjdk/bench/vm/gc/systemgc/HalfDeadInterleavedChunks.java b/test/micro/org/openjdk/bench/vm/gc/systemgc/HalfDeadInterleavedChunks.java index 06955381f5c..a5d6dce91a9 100644 --- a/test/micro/org/openjdk/bench/vm/gc/systemgc/HalfDeadInterleavedChunks.java +++ b/test/micro/org/openjdk/bench/vm/gc/systemgc/HalfDeadInterleavedChunks.java @@ -36,7 +36,7 @@ import java.util.concurrent.TimeUnit; @BenchmarkMode(Mode.SingleShotTime) -@Fork(value=25, jvmArgsAppend={"-Xmx5g", "-Xms5g", "-Xmn3g", "-XX:+AlwaysPreTouch"}) +@Fork(value=25, jvmArgs={"-Xmx5g", "-Xms5g", "-Xmn3g", "-XX:+AlwaysPreTouch"}) @OutputTimeUnit(TimeUnit.MILLISECONDS) @State(Scope.Benchmark) public class HalfDeadInterleavedChunks { diff --git a/test/micro/org/openjdk/bench/vm/gc/systemgc/HalfDeadSecondPart.java b/test/micro/org/openjdk/bench/vm/gc/systemgc/HalfDeadSecondPart.java index 89606f5a07a..838aeb4820b 100644 --- a/test/micro/org/openjdk/bench/vm/gc/systemgc/HalfDeadSecondPart.java +++ b/test/micro/org/openjdk/bench/vm/gc/systemgc/HalfDeadSecondPart.java @@ -36,7 +36,7 @@ import java.util.concurrent.TimeUnit; @BenchmarkMode(Mode.SingleShotTime) -@Fork(value=25, jvmArgsAppend={"-Xmx5g", "-Xms5g", "-Xmn3g", "-XX:+AlwaysPreTouch"}) +@Fork(value=25, jvmArgs={"-Xmx5g", "-Xms5g", "-Xmn3g", "-XX:+AlwaysPreTouch"}) @OutputTimeUnit(TimeUnit.MILLISECONDS) @State(Scope.Benchmark) public class HalfDeadSecondPart { diff --git a/test/micro/org/openjdk/bench/vm/gc/systemgc/HalfHashedHalfDead.java b/test/micro/org/openjdk/bench/vm/gc/systemgc/HalfHashedHalfDead.java index 6692e02a135..eaba46e04e9 100644 --- a/test/micro/org/openjdk/bench/vm/gc/systemgc/HalfHashedHalfDead.java +++ b/test/micro/org/openjdk/bench/vm/gc/systemgc/HalfHashedHalfDead.java @@ -36,7 +36,7 @@ import java.util.concurrent.TimeUnit; @BenchmarkMode(Mode.SingleShotTime) -@Fork(value=25, jvmArgsAppend={"-Xmx5g", "-Xms5g", "-Xmn3g", "-XX:+AlwaysPreTouch"}) +@Fork(value=25, jvmArgs={"-Xmx5g", "-Xms5g", "-Xmn3g", "-XX:+AlwaysPreTouch"}) @OutputTimeUnit(TimeUnit.MILLISECONDS) @State(Scope.Benchmark) public class HalfHashedHalfDead { diff --git a/test/micro/org/openjdk/bench/vm/gc/systemgc/NoObjects.java b/test/micro/org/openjdk/bench/vm/gc/systemgc/NoObjects.java index a2e35e55061..96461c8106c 100644 --- a/test/micro/org/openjdk/bench/vm/gc/systemgc/NoObjects.java +++ b/test/micro/org/openjdk/bench/vm/gc/systemgc/NoObjects.java @@ -31,7 +31,7 @@ import java.util.concurrent.TimeUnit; @BenchmarkMode(Mode.SingleShotTime) -@Fork(value=25, jvmArgsAppend={"-Xmx5g", "-Xms5g", "-Xmn3g", "-XX:+AlwaysPreTouch"}) +@Fork(value=25, jvmArgs={"-Xmx5g", "-Xms5g", "-Xmn3g", "-XX:+AlwaysPreTouch"}) @OutputTimeUnit(TimeUnit.MILLISECONDS) public class NoObjects { diff --git a/test/micro/org/openjdk/bench/vm/gc/systemgc/OneBigObject.java b/test/micro/org/openjdk/bench/vm/gc/systemgc/OneBigObject.java index 5601abdcb70..ef2c436efd7 100644 --- a/test/micro/org/openjdk/bench/vm/gc/systemgc/OneBigObject.java +++ b/test/micro/org/openjdk/bench/vm/gc/systemgc/OneBigObject.java @@ -35,7 +35,7 @@ import java.util.concurrent.TimeUnit; @BenchmarkMode(Mode.SingleShotTime) -@Fork(value=25, jvmArgsAppend={"-Xmx5g", "-Xms5g", "-Xmn3g", "-XX:+AlwaysPreTouch"}) +@Fork(value=25, jvmArgs={"-Xmx5g", "-Xms5g", "-Xmn3g", "-XX:+AlwaysPreTouch"}) @OutputTimeUnit(TimeUnit.MILLISECONDS) @State(Scope.Benchmark) public class OneBigObject { diff --git a/test/micro/org/openjdk/bench/vm/lang/TypePollution.java b/test/micro/org/openjdk/bench/vm/lang/TypePollution.java index aa1a0207587..4994bcf9c2d 100644 --- a/test/micro/org/openjdk/bench/vm/lang/TypePollution.java +++ b/test/micro/org/openjdk/bench/vm/lang/TypePollution.java @@ -105,28 +105,28 @@ public void setup() { int probe = 99; @Benchmark - @Fork(jvmArgsAppend={"-XX:+UnlockDiagnosticVMOptions", "-XX:-UseSecondarySupersTable", "-XX:-UseSecondarySupersCache"}) + @Fork(jvmArgs={"-XX:+UnlockDiagnosticVMOptions", "-XX:-UseSecondarySupersTable", "-XX:-UseSecondarySupersCache"}) @OutputTimeUnit(TimeUnit.MILLISECONDS) public long parallelInstanceOfInterfaceSwitchLinearNoSCC() { return parallelInstanceOfInterfaceSwitch(); } @Benchmark - @Fork(jvmArgsAppend={"-XX:+UnlockDiagnosticVMOptions", "-XX:-UseSecondarySupersTable", "-XX:+UseSecondarySupersCache"}) + @Fork(jvmArgs={"-XX:+UnlockDiagnosticVMOptions", "-XX:-UseSecondarySupersTable", "-XX:+UseSecondarySupersCache"}) @OutputTimeUnit(TimeUnit.MILLISECONDS) public long parallelInstanceOfInterfaceSwitchLinearSCC() { return parallelInstanceOfInterfaceSwitch(); } @Benchmark - @Fork(jvmArgsAppend={"-XX:+UnlockDiagnosticVMOptions", "-XX:+UseSecondarySupersTable", "-XX:-UseSecondarySupersCache"}) + @Fork(jvmArgs={"-XX:+UnlockDiagnosticVMOptions", "-XX:+UseSecondarySupersTable", "-XX:-UseSecondarySupersCache"}) @OutputTimeUnit(TimeUnit.MILLISECONDS) public long parallelInstanceOfInterfaceSwitchTableNoSCC() { return parallelInstanceOfInterfaceSwitch(); } @Benchmark - @Fork(jvmArgsAppend={"-XX:+UnlockDiagnosticVMOptions", "-XX:+UseSecondarySupersTable", "-XX:+UseSecondarySupersCache"}) + @Fork(jvmArgs={"-XX:+UnlockDiagnosticVMOptions", "-XX:+UseSecondarySupersTable", "-XX:+UseSecondarySupersCache"}) @OutputTimeUnit(TimeUnit.MILLISECONDS) public long parallelInstanceOfInterfaceSwitchTableSCC() { return parallelInstanceOfInterfaceSwitch(); @@ -149,25 +149,25 @@ long parallelInstanceOfInterfaceSwitch() { } @Benchmark - @Fork(jvmArgsAppend={"-XX:+UnlockDiagnosticVMOptions", "-XX:-UseSecondarySupersTable", "-XX:-UseSecondarySupersCache"}) + @Fork(jvmArgs={"-XX:+UnlockDiagnosticVMOptions", "-XX:-UseSecondarySupersTable", "-XX:-UseSecondarySupersCache"}) public int instanceOfInterfaceSwitchLinearNoSCC() { return instanceOfInterfaceSwitch(); } @Benchmark - @Fork(jvmArgsAppend={"-XX:+UnlockDiagnosticVMOptions", "-XX:-UseSecondarySupersTable", "-XX:+UseSecondarySupersCache"}) + @Fork(jvmArgs={"-XX:+UnlockDiagnosticVMOptions", "-XX:-UseSecondarySupersTable", "-XX:+UseSecondarySupersCache"}) public int instanceOfInterfaceSwitchLinearSCC() { return instanceOfInterfaceSwitch(); } @Benchmark - @Fork(jvmArgsAppend={"-XX:+UnlockDiagnosticVMOptions", "-XX:+UseSecondarySupersTable", "-XX:-UseSecondarySupersCache"}) + @Fork(jvmArgs={"-XX:+UnlockDiagnosticVMOptions", "-XX:+UseSecondarySupersTable", "-XX:-UseSecondarySupersCache"}) public int instanceOfInterfaceSwitchTableNoSCC() { return instanceOfInterfaceSwitch(); } @Benchmark - @Fork(jvmArgsAppend={"-XX:+UnlockDiagnosticVMOptions", "-XX:+UseSecondarySupersTable", "-XX:+UseSecondarySupersCache"}) + @Fork(jvmArgs={"-XX:+UnlockDiagnosticVMOptions", "-XX:+UseSecondarySupersTable", "-XX:+UseSecondarySupersCache"}) public int instanceOfInterfaceSwitchTableSCC() { return instanceOfInterfaceSwitch(); } diff --git a/test/micro/org/openjdk/bench/vm/runtime/NMTBenchmark.java b/test/micro/org/openjdk/bench/vm/runtime/NMTBenchmark.java index 8d05d37792c..d88c66bd15f 100644 --- a/test/micro/org/openjdk/bench/vm/runtime/NMTBenchmark.java +++ b/test/micro/org/openjdk/bench/vm/runtime/NMTBenchmark.java @@ -243,12 +243,12 @@ public void mixAllocateReallocateMemory() throws InterruptedException { public static final String ADD_EXPORTS = "--add-exports"; public static final String MISC_PACKAGE = "java.base/jdk.internal.misc=ALL-UNNAMED"; // used for Unsafe API - @Fork(value = 2, jvmArgsPrepend = { "-XX:NativeMemoryTracking=off", ADD_EXPORTS, MISC_PACKAGE}) + @Fork(value = 2, jvmArgs = { "-XX:NativeMemoryTracking=off", ADD_EXPORTS, MISC_PACKAGE}) public static class NMTOff extends NMTBenchmark { } - @Fork(value = 2, jvmArgsPrepend = { "-XX:NativeMemoryTracking=summary", ADD_EXPORTS, MISC_PACKAGE}) + @Fork(value = 2, jvmArgs = { "-XX:NativeMemoryTracking=summary", ADD_EXPORTS, MISC_PACKAGE}) public static class NMTSummary extends NMTBenchmark { } - @Fork(value = 2, jvmArgsPrepend = { "-XX:NativeMemoryTracking=detail", ADD_EXPORTS, MISC_PACKAGE}) + @Fork(value = 2, jvmArgs = { "-XX:NativeMemoryTracking=detail", ADD_EXPORTS, MISC_PACKAGE}) public static class NMTDetail extends NMTBenchmark { } } diff --git a/test/micro/org/openjdk/bench/vm/runtime/NMTBenchmark_wb.java b/test/micro/org/openjdk/bench/vm/runtime/NMTBenchmark_wb.java index 12e7a1140c8..059fff9f2ee 100644 --- a/test/micro/org/openjdk/bench/vm/runtime/NMTBenchmark_wb.java +++ b/test/micro/org/openjdk/bench/vm/runtime/NMTBenchmark_wb.java @@ -137,13 +137,13 @@ public void virtualMemoryTests() { public static final String WB_JAR_APPEND = "-Xbootclasspath/a:lib-test/wb.jar"; - @Fork(value = 2, jvmArgsPrepend = { WB_JAR_APPEND, WB_UNLOCK_OPTION, WB_API, ADD_EXPORTS, MISC_PACKAGE, "-XX:NativeMemoryTracking=off"}) + @Fork(value = 2, jvmArgs = { WB_JAR_APPEND, WB_UNLOCK_OPTION, WB_API, ADD_EXPORTS, MISC_PACKAGE, "-XX:NativeMemoryTracking=off"}) public static class NMTOff extends NMTBenchmark_wb { } - @Fork(value = 2, jvmArgsPrepend = { WB_JAR_APPEND, WB_UNLOCK_OPTION, WB_API, ADD_EXPORTS, MISC_PACKAGE, "-XX:NativeMemoryTracking=summary"}) + @Fork(value = 2, jvmArgs = { WB_JAR_APPEND, WB_UNLOCK_OPTION, WB_API, ADD_EXPORTS, MISC_PACKAGE, "-XX:NativeMemoryTracking=summary"}) public static class NMTSummary extends NMTBenchmark_wb { } - // @Fork(value = 2, jvmArgsPrepend = { WB_JAR_APPEND, WB_UNLOCK_OPTION, WB_API, ADD_EXPORTS, MISC_PACKAGE, "-XX:NativeMemoryTracking=detail"}) + // @Fork(value = 2, jvmArgs = { WB_JAR_APPEND, WB_UNLOCK_OPTION, WB_API, ADD_EXPORTS, MISC_PACKAGE, "-XX:NativeMemoryTracking=detail"}) // public static class NMTDetail extends NMTBenchmark_wb { } } \ No newline at end of file