From edcc4a753512d6fb2020c08d3356a516d840a6dc Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Thu, 1 Sep 2022 18:10:47 +0200 Subject: [PATCH 01/85] Add downstreaming action (#1) --- .github/workflows/downstream.yml | 68 ++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 .github/workflows/downstream.yml diff --git a/.github/workflows/downstream.yml b/.github/workflows/downstream.yml new file mode 100644 index 0000000000000..af4d68a0f2d33 --- /dev/null +++ b/.github/workflows/downstream.yml @@ -0,0 +1,68 @@ +# +# Copyright (c) 2022, Rivos Inc. and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute 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: 'OpenJDK Downstreaming' + +on: + schedule: + # Trigger on every Mondays at 07:00 UTC (09:00 CET, 00:00 PT) + - cron: '0 6 * * 1' + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +permissions: + pull-requests: write + +jobs: + fetch-push-pr: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + token: ${{ secrets.WORKFLOW_TOKEN }} + - name: "Create Pull Request" + run: | + # 1. fetch + git remote add upstream https://github.com/openjdk/jdk.git + git fetch --tags upstream master + + # 2. push + TAG=$(git tag | grep --extended-regexp '^jdk\-.*' | sort --version-sort | tail --lines 1 | tr --delete '\n') + test -n "$TAG" + git checkout -b merge-upstream $TAG + git push origin merge-upstream $TAG + + # 3. pr + gh pr create \ + --repo rivosinc/jdk \ + --base master \ + --head merge-upstream \ + --title "Merge $TAG into master" \ + --body "This is an automated pull request." \ + --reviewer "luhenry" || true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From a22db3e378fe2cec2661d6352fea7e5b2905c6e3 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Fri, 2 Sep 2022 14:21:11 +0200 Subject: [PATCH 02/85] Follow convention of branch naming (#3) --- .github/workflows/downstream.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/downstream.yml b/.github/workflows/downstream.yml index af4d68a0f2d33..74480270208f9 100644 --- a/.github/workflows/downstream.yml +++ b/.github/workflows/downstream.yml @@ -53,15 +53,15 @@ jobs: # 2. push TAG=$(git tag | grep --extended-regexp '^jdk\-.*' | sort --version-sort | tail --lines 1 | tr --delete '\n') test -n "$TAG" - git checkout -b merge-upstream $TAG - git push origin merge-upstream $TAG + git checkout -b rivos/merge-upstream $TAG + git push origin rivos/merge-upstream $TAG # 3. pr gh pr create \ --repo rivosinc/jdk \ - --base master \ - --head merge-upstream \ - --title "Merge $TAG into master" \ + --base rivos/main \ + --head rivos/merge-upstream \ + --title "Merge $TAG into rivos/main" \ --body "This is an automated pull request." \ --reviewer "luhenry" || true env: From 0f0edebfef0c42a1dadefc1006dab316cbd20a35 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Sat, 3 Sep 2022 14:37:30 +0200 Subject: [PATCH 03/85] Add rivos/gitlab-ci.yml file (#4) Currently builds sysroot for riscv64 and build the OpenJDK with it. Next we want to add testing. --- rivos/gitlab-ci.yml | 78 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 rivos/gitlab-ci.yml diff --git a/rivos/gitlab-ci.yml b/rivos/gitlab-ci.yml new file mode 100644 index 0000000000000..137cf3a370ede --- /dev/null +++ b/rivos/gitlab-ci.yml @@ -0,0 +1,78 @@ + +image: ubuntu:20.04 + +stages: + - sysroot + - build + +create-sysroot: + stage: sysroot + tags: + - docker-qemu-binfmt + cache: + - key: sysroot-ubuntu-jammy-riscv64 + paths: + - sysroot + script: + # early exit if sysroot is coming from the cache + - test -d sysroot && exit 0 + - apt-get update + - apt-get install -y debootstrap qemu-user-static + - | + qemu-debootstrap \ + --verbose \ + --arch=riscv64 \ + --components=main,universe \ + --include=fakeroot,symlinks,build-essential,libx11-dev,libxext-dev,libxrender-dev,libxrandr-dev,libxtst-dev,libxt-dev,libcups2-dev,libfontconfig1-dev,libasound2-dev,libfreetype6-dev,libpng-dev \ + --resolve-deps \ + jammy \ + sysroot + - chroot sysroot symlinks -cr . + - rm -rf sysroot/{dev,proc,run,sys} + artifacts: + when: always + paths: + - sysroot + +build-linux-riscv64: + stage: build + dependencies: + - create-sysroot + script: + - apt-get update + - | + apt-get install -y \ + autoconf \ + build-essential \ + curl \ + file \ + g++ \ + g++-riscv64-linux-gnu \ + gcc \ + gcc-riscv64-linux-gnu \ + libasound2-dev \ + libcups2-dev \ + libxrandr-dev \ + libxtst-dev \ + unzip \ + zip \ + zlib1g-dev + - | + mkdir -p /usr/lib/jvm/zulu-18 + curl -L https://cdn.azul.com/zulu/bin/zulu18.32.13-ca-jdk18.0.2.1-linux_x64.tar.gz \ + | tar -xzf - -C /usr/lib/jvm/zulu-18 --strip-components 1 + - | + bash configure \ + --openjdk-target=riscv64-linux-gnu \ + --with-conf-name=linux-riscv64 \ + --with-version-opt=${CI_COMMIT_REF_SLUG}-${CI_COMMIT_SHORT_SHA} \ + --with-sysroot=$(pwd)/sysroot \ + --with-boot-jdk=/usr/lib/jvm/zulu-18 \ + --disable-precompiled-headers + - make jdk-image test-image LOG_LEVEL=info + artifacts: + when: always + paths: + - config.log # in case of error during configure + - build/linux-riscv64/images/jdk + - build/linux-riscv64/images/test From 573adfd10d69461ddc018c8140010624ccb7cd66 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Sun, 4 Sep 2022 14:13:21 +0200 Subject: [PATCH 04/85] Add cross-compilation to riscv64 on CI (#5) --- .github/workflows/build-cross-compile.yml | 36 ++++++++++++++++++----- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build-cross-compile.yml b/.github/workflows/build-cross-compile.yml index 6398489c842c7..d2347647722b7 100644 --- a/.github/workflows/build-cross-compile.yml +++ b/.github/workflows/build-cross-compile.yml @@ -51,20 +51,39 @@ jobs: - arm - s390x - ppc64le + - riscv64 include: - target-cpu: aarch64 - debian-arch: arm64 gnu-arch: aarch64 + dist-arch: arm64 + dist-name: buster + dist-repository: https://httpredir.debian.org/debian/ + dist-components: 'main' - target-cpu: arm - debian-arch: armhf gnu-arch: arm + dist-arch: armhf + dist-name: buster + dist-repository: https://httpredir.debian.org/debian/ + dist-components: 'main' gnu-abi: eabihf - target-cpu: s390x - debian-arch: s390x gnu-arch: s390x + dist-arch: s390x + dist-name: buster + dist-repository: https://httpredir.debian.org/debian/ + dist-components: 'main' - target-cpu: ppc64le - debian-arch: ppc64el gnu-arch: powerpc64le + dist-arch: ppc64el + dist-name: buster + dist-repository: https://httpredir.debian.org/debian/ + dist-components: 'main' + - target-cpu: riscv64 + gnu-arch: riscv64 + dist-arch: riscv64 + dist-name: focal + dist-repository: http://ports.ubuntu.com/ubuntu-ports + dist-components: 'main,universe' steps: - name: 'Checkout the JDK source' @@ -102,7 +121,7 @@ jobs: uses: actions/cache@v3 with: path: sysroot - key: sysroot-${{ matrix.debian-arch }}-${{ hashFiles('./.github/workflows/build-cross-compile.yml') }} + key: sysroot-${{ matrix.dist-arch }}-${{ hashFiles('./.github/workflows/build-cross-compile.yml') }} - name: 'Install sysroot dependencies' run: sudo apt-get install debootstrap qemu-user-static @@ -111,13 +130,14 @@ jobs: - name: 'Create sysroot' run: > sudo qemu-debootstrap - --arch=${{ matrix.debian-arch }} --verbose + --arch=${{ matrix.dist-arch }} + --components=${{ matrix.dist-components }} --include=fakeroot,symlinks,build-essential,libx11-dev,libxext-dev,libxrender-dev,libxrandr-dev,libxtst-dev,libxt-dev,libcups2-dev,libfontconfig1-dev,libasound2-dev,libfreetype6-dev,libpng-dev --resolve-deps - buster + ${{ matrix.dist-name }} sysroot - https://httpredir.debian.org/debian/ + ${{ matrix.dist-repository }} if: steps.get-cached-sysroot.outputs.cache-hit != 'true' - name: 'Prepare sysroot' From 4751d5ca4103b4c48bfb872f188b39deea135103 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Tue, 6 Sep 2022 09:11:43 +0200 Subject: [PATCH 05/85] Integrate to Rivos SDK (#7) --- rivos/gitlab-ci.yml | 209 +++++++++++++++++++++++++++++++++++++++----- 1 file changed, 186 insertions(+), 23 deletions(-) diff --git a/rivos/gitlab-ci.yml b/rivos/gitlab-ci.yml index 137cf3a370ede..99cfd8e0fdce9 100644 --- a/rivos/gitlab-ci.yml +++ b/rivos/gitlab-ci.yml @@ -1,21 +1,67 @@ -image: ubuntu:20.04 +include: + - project: 'rv/it/int/rivos-sdk' + ref: rivos/main + file: '/packager/gitlab-ci-packaging-helper.yml' -stages: - - sysroot - - build +variables: + CACHE_VERSION: "v2" -create-sysroot: - stage: sysroot +prepare-version: + after_script: + - | + if test -n "${CI_COMMIT_TAG}" && test "${CI_COMMIT_TAG}" =~ '^jdk\-'; then + echo "JDK_VERSION_TAG=${CI_COMMIT_TAG#jdk-}" >> gitvars.env + else + echo "JDK_VERSION_TAG=${CI_COMMIT_REF_SLUG}-${CI_COMMIT_SHORT_SHA}" >> gitvars.env + fi + # Debugging helper + - cat gitvars.env + +create-sysroot-ubuntu-jammy-amd64: + stage: prebuild + image: ubuntu:20.04 + cache: + - key: sysroot-ubuntu-jammy-amd64-${CACHE_VERSION} + paths: + - sysroot-ubuntu-jammy-amd64 + script: + # early exit if sysroot-ubuntu-jammy-amd64 is coming from the cache + - test -d sysroot-ubuntu-jammy-amd64 && exit 0 + - apt-get update + - apt-get install -y debootstrap + - | + debootstrap \ + --verbose \ + --components=main,universe \ + --include=symlinks,qemu-user-static \ + --resolve-deps \ + jammy \ + sysroot-ubuntu-jammy-amd64 + - chroot sysroot-ubuntu-jammy-amd64 symlinks -cr . + - rm -rf sysroot-ubuntu-jammy-amd64/{dev,proc,run,sys} + artifacts: + when: always + paths: + - sysroot-ubuntu-jammy-amd64 + +create-sysroot-ubuntu-jammy-rv64: + stage: prebuild + image: ubuntu:20.04 tags: - docker-qemu-binfmt + dependencies: + - create-sysroot-ubuntu-jammy-amd64 + needs: + - create-sysroot-ubuntu-jammy-amd64 cache: - - key: sysroot-ubuntu-jammy-riscv64 + - when: on_success + key: sysroot-ubuntu-jammy-rv64-${CACHE_VERSION} paths: - - sysroot + - sysroot-ubuntu-jammy-rv64 script: - # early exit if sysroot is coming from the cache - - test -d sysroot && exit 0 + # early exit if sysroot-ubuntu-jammy-rv64 is coming from the cache + - test -d sysroot-ubuntu-jammy-rv64 && exit 0 - apt-get update - apt-get install -y debootstrap qemu-user-static - | @@ -23,21 +69,80 @@ create-sysroot: --verbose \ --arch=riscv64 \ --components=main,universe \ - --include=fakeroot,symlinks,build-essential,libx11-dev,libxext-dev,libxrender-dev,libxrandr-dev,libxtst-dev,libxt-dev,libcups2-dev,libfontconfig1-dev,libasound2-dev,libfreetype6-dev,libpng-dev \ + --include=symlinks,build-essential,libx11-dev,libxext-dev,libxrender-dev,libxrandr-dev,libxtst-dev,libxt-dev,libcups2-dev,libfontconfig1-dev,libasound2-dev,libfreetype6-dev,libpng-dev \ --resolve-deps \ jammy \ - sysroot - - chroot sysroot symlinks -cr . - - rm -rf sysroot/{dev,proc,run,sys} + sysroot-ubuntu-jammy-rv64 + - cp -a sysroot-ubuntu-jammy-amd64/usr/bin/qemu-riscv64-static sysroot-ubuntu-jammy-rv64/usr/bin + - chroot sysroot-ubuntu-jammy-rv64 symlinks -cr . + - rm -rf sysroot-ubuntu-jammy-rv64/{dev,proc,run,sys} artifacts: when: always paths: - - sysroot + - sysroot-ubuntu-jammy-rv64 -build-linux-riscv64: +build-linux-amd64: stage: build + image: ubuntu:20.04 dependencies: - - create-sysroot + - prepare-version + needs: + - prepare-version + script: + - apt-get update + - | + apt-get install -y \ + autoconf \ + build-essential \ + curl \ + file \ + g++ \ + gcc \ + libx11-dev \ + libxext-dev \ + libxrender-dev \ + libxrandr-dev \ + libxtst-dev \ + libxt-dev \ + libcups2-dev \ + libfontconfig1-dev \ + libasound2-dev \ + libfreetype6-dev \ + libpng-dev \ + unzip \ + zip \ + zlib1g-dev + - | + mkdir -p /usr/lib/jvm/zulu-18 + curl -L https://cdn.azul.com/zulu/bin/zulu18.32.13-ca-jdk18.0.2.1-linux_x64.tar.gz \ + | tar -xzf - -C /usr/lib/jvm/zulu-18 --strip-components 1 + - | + bash configure \ + --openjdk-target=x86_64-linux-gnu \ + --with-conf-name=linux-amd64 \ + --with-version-opt=${JDK_VERSION_TAG} \ + --with-boot-jdk=/usr/lib/jvm/zulu-18 \ + --disable-precompiled-headers \ + --with-zlib=system + - make jdk-image test-image LOG_LEVEL=info + artifacts: + when: always + paths: + - config.log # in case of error during configure + - build/linux-amd64/images/jdk + - build/linux-amd64/images/test + +build-linux-rv64: + stage: build + image: ubuntu:20.04 + dependencies: + - prepare-version + - create-sysroot-ubuntu-jammy-rv64 + - build-linux-amd64 + needs: + - prepare-version + - create-sysroot-ubuntu-jammy-rv64 + - build-linux-amd64 script: - apt-get update - | @@ -64,15 +169,73 @@ build-linux-riscv64: - | bash configure \ --openjdk-target=riscv64-linux-gnu \ - --with-conf-name=linux-riscv64 \ - --with-version-opt=${CI_COMMIT_REF_SLUG}-${CI_COMMIT_SHORT_SHA} \ - --with-sysroot=$(pwd)/sysroot \ + --with-conf-name=linux-rv64 \ + --with-version-opt=${JDK_VERSION_TAG} \ + --with-sysroot=$(pwd)/sysroot-ubuntu-jammy-rv64 \ --with-boot-jdk=/usr/lib/jvm/zulu-18 \ - --disable-precompiled-headers + --with-build-jdk=$(pwd)/build/linux-amd64/images/jdk \ + --disable-precompiled-headers \ + --with-zlib=system - make jdk-image test-image LOG_LEVEL=info artifacts: when: always paths: - config.log # in case of error during configure - - build/linux-riscv64/images/jdk - - build/linux-riscv64/images/test + - build/linux-rv64/images/jdk + - build/linux-rv64/images/test + +package-tar: + stage: deploy + image: ubuntu:20.04 + dependencies: + - prepare-version + - build-linux-amd64 + - build-linux-rv64 + needs: + - prepare-version + - build-linux-amd64 + - build-linux-rv64 + script: + - apt-get update + - apt-get install -y curl + - tar -czf jdk-${JDK_VERSION_TAG}-linux-amd64.tar.gz -C build/linux-amd64/images jdk + - 'curl -i --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file jdk-${JDK_VERSION_TAG}-linux-amd64.tar.gz "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/jdk/${JDK_VERSION_TAG}/jdk-${JDK_VERSION_TAG}-linux-amd64.tar.gz"' + - tar -czf jdk-${JDK_VERSION_TAG}-linux-rv64.tar.gz -C build/linux-rv64/images jdk + - 'curl -i --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file jdk-${JDK_VERSION_TAG}-linux-rv64.tar.gz "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/jdk/${JDK_VERSION_TAG}/jdk-${JDK_VERSION_TAG}-linux-rv64.tar.gz"' + +package-deb: + extends: .deploy-deb + dependencies: + - prepare-version + - build-linux-amd64 + - build-linux-rv64 + needs: + - prepare-version + - build-linux-amd64 + - build-linux-rv64 + variables: + PKG_ARCH: "all" + PKG_DIRECTORIES: "/rivos/jdk;/rivos/sysroot/riscv/jdk" + PKG_LICENSE: "GPL-2.0 license" + PKG_UPSTREAM_VERSION: "${JDK_VERSION_TAG}" + before_script: + # clean up pre-built binaries from the rivos-sdk + - rm -rf /rivos/jdk /rivos/sysroot/riscv/jdk + # move the previous temporary install + - cp -a build/linux-amd64/images/jdk /rivos/ + - cp -a build/linux-rv64/images/jdk /rivos/sysroot/riscv/ + +deploy-module-ubuntu: + extends: .deploy-module + dependencies: + - prepare-version + - build-linux-amd64 + needs: + - prepare-version + - build-linux-amd64 + variables: + CONTENT_PATH: "build/linux-amd64/images/jdk" + +# Rebuild the rivos-sdk where we are exporting the artifacts built here. +update-sdk: + extends: .update-sdk From 4e12331cd2bbad75dbb9d08fd923550f3e2afa1e Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Tue, 6 Sep 2022 19:34:53 +0200 Subject: [PATCH 06/85] Extract version number for package (#8) --- rivos/gitlab-ci.yml | 54 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 46 insertions(+), 8 deletions(-) diff --git a/rivos/gitlab-ci.yml b/rivos/gitlab-ci.yml index 99cfd8e0fdce9..6a2554ce06e39 100644 --- a/rivos/gitlab-ci.yml +++ b/rivos/gitlab-ci.yml @@ -10,10 +10,17 @@ variables: prepare-version: after_script: - | - if test -n "${CI_COMMIT_TAG}" && test "${CI_COMMIT_TAG}" =~ '^jdk\-'; then - echo "JDK_VERSION_TAG=${CI_COMMIT_TAG#jdk-}" >> gitvars.env + source make/conf/version-numbers.conf + if test -n "${CI_COMMIT_TAG}" && test "${CI_COMMIT_TAG}" =~ '^jdk\-\(.*\)-rivos$'; then + echo "JDK_VERSION_PKG=$(echo "${CI_COMMIT_TAG}" | sed 's/^jdk-\(.*\)-rivos$/\1/')" >> gitvars.env + echo "JDK_VERSION_TAG=${JDK_VERSION_PKG}" >> gitvars.env + echo "JDK_VERSION_PRE=ea" >> gitvars.env + echo "JDK_VERSION_OPT=" >> gitvars.env else + echo "JDK_VERSION_PKG=${DEFAULT_VERSION_FEATURE}" >> gitvars.env echo "JDK_VERSION_TAG=${CI_COMMIT_REF_SLUG}-${CI_COMMIT_SHORT_SHA}" >> gitvars.env + echo "JDK_VERSION_PRE=internal" >> gitvars.env + echo "JDK_VERSION_OPT=${CI_COMMIT_REF_SLUG}-${CI_COMMIT_SHORT_SHA}" >> gitvars.env fi # Debugging helper - cat gitvars.env @@ -120,7 +127,9 @@ build-linux-amd64: bash configure \ --openjdk-target=x86_64-linux-gnu \ --with-conf-name=linux-amd64 \ - --with-version-opt=${JDK_VERSION_TAG} \ + --with-vendor-name="Rivos Inc" \ + --with-version-pre="${JDK_VERSION_PRE}" \ + --with-version-opt="${JDK_VERSION_OPT}" \ --with-boot-jdk=/usr/lib/jvm/zulu-18 \ --disable-precompiled-headers \ --with-zlib=system @@ -170,7 +179,9 @@ build-linux-rv64: bash configure \ --openjdk-target=riscv64-linux-gnu \ --with-conf-name=linux-rv64 \ - --with-version-opt=${JDK_VERSION_TAG} \ + --with-vendor-name="Rivos Inc" \ + --with-version-pre="${JDK_VERSION_PRE}" \ + --with-version-opt="${JDK_VERSION_OPT}" \ --with-sysroot=$(pwd)/sysroot-ubuntu-jammy-rv64 \ --with-boot-jdk=/usr/lib/jvm/zulu-18 \ --with-build-jdk=$(pwd)/build/linux-amd64/images/jdk \ @@ -215,15 +226,42 @@ package-deb: - build-linux-rv64 variables: PKG_ARCH: "all" - PKG_DIRECTORIES: "/rivos/jdk;/rivos/sysroot/riscv/jdk" + PKG_DIRECTORIES: "/rivos/jdk;/rivos/sysroot/riscv/rivos/jdk" PKG_LICENSE: "GPL-2.0 license" - PKG_UPSTREAM_VERSION: "${JDK_VERSION_TAG}" + PKG_UPSTREAM_VERSION: "${JDK_VERSION_PKG}" before_script: # clean up pre-built binaries from the rivos-sdk - - rm -rf /rivos/jdk /rivos/sysroot/riscv/jdk + - rm -rf /rivos/jdk /rivos/sysroot/riscv/rivos/jdk # move the previous temporary install + - mkdir -p /rivos/sysroot/riscv/rivos - cp -a build/linux-amd64/images/jdk /rivos/ - - cp -a build/linux-rv64/images/jdk /rivos/sysroot/riscv/ + - cp -a build/linux-rv64/images/jdk /rivos/sysroot/riscv/rivos + # remove *.debuginfo files, they take a lot of space + - find /rivos/jdk /rivos/sysroot/riscv/rivos/jdk -name '*.debuginfo' -exec rm -f {} \; -print + +package-deb-dbg: + extends: .deploy-deb + dependencies: + - prepare-version + - build-linux-amd64 + - build-linux-rv64 + needs: + - prepare-version + - build-linux-amd64 + - build-linux-rv64 + variables: + PKG_ARCH: "all" + PKG_DIRECTORIES: "/rivos/jdk;/rivos/sysroot/riscv/rivos/jdk" + PKG_LICENSE: "GPL-2.0 license" + PKG_NAME: "${PROJECT_NAME}-dbg" + PKG_UPSTREAM_VERSION: "${JDK_VERSION_PKG}" + before_script: + # clean up pre-built binaries from the rivos-sdk + - rm -rf /rivos/jdk /rivos/sysroot/riscv/rivos/jdk + # move the previous temporary install + - mkdir -p /rivos/sysroot/riscv/rivos + - cp -a build/linux-amd64/images/jdk /rivos/ + - cp -a build/linux-rv64/images/jdk /rivos/sysroot/riscv/rivos deploy-module-ubuntu: extends: .deploy-module From 6aeff805d084ebfdd791c8559f816edd711032de Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Thu, 8 Sep 2022 23:04:07 +0200 Subject: [PATCH 07/85] Run downstreaming job every day (#9) --- .github/workflows/downstream.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/downstream.yml b/.github/workflows/downstream.yml index 74480270208f9..41a63da0d3371 100644 --- a/.github/workflows/downstream.yml +++ b/.github/workflows/downstream.yml @@ -27,8 +27,8 @@ name: 'OpenJDK Downstreaming' on: schedule: - # Trigger on every Mondays at 07:00 UTC (09:00 CET, 00:00 PT) - - cron: '0 6 * * 1' + # Trigger on every day at 07:00 UTC (09:00 CET, 00:00 PT) + - cron: '0 6 * * 1-5' concurrency: group: ${{ github.workflow }}-${{ github.ref }} From 0b3d85dd1f33d0f987d5f3f6a168ba5da3490319 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Fri, 9 Sep 2022 10:40:10 +0200 Subject: [PATCH 08/85] PROT_WRITE doesn't imply PROT_READ on RISC-V (#10) https://lkml.org/lkml/2022/9/8/1066 --- src/hotspot/os/linux/os_linux.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hotspot/os/linux/os_linux.cpp b/src/hotspot/os/linux/os_linux.cpp index f3c9c4a2c8fd3..d253046c6924d 100644 --- a/src/hotspot/os/linux/os_linux.cpp +++ b/src/hotspot/os/linux/os_linux.cpp @@ -4308,7 +4308,7 @@ static void check_pax(void) { #ifndef ZERO size_t size = os::vm_page_size(); - void* p = ::mmap(NULL, size, PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0); + void* p = ::mmap(NULL, size, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0); if (p == MAP_FAILED) { log_debug(os)("os_linux.cpp: check_pax: mmap failed (%s)" , os::strerror(errno)); vm_exit_out_of_memory(size, OOM_MMAP_ERROR, "failed to allocate memory for PaX check."); From 5be1125c49ec4a170aaba084ef8b310534cfaceb Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Fri, 9 Sep 2022 10:41:39 +0200 Subject: [PATCH 09/85] Support sv57 on RISC-V (#11) It was added to the Kernel in 5.18 https://riscv.org/news/2022/03/risc-v-gets-sv57-based-virtual-memory-other-improvements-for-linux-5-18-michael-larabel-phoronix/ --- src/hotspot/cpu/riscv/assembler_riscv.cpp | 12 ++++--- .../cpu/riscv/c1_LIRAssembler_riscv.hpp | 2 +- .../cpu/riscv/c2_MacroAssembler_riscv.cpp | 2 +- src/hotspot/cpu/riscv/compiledIC_riscv.cpp | 4 +-- .../gc/shared/barrierSetNMethod_riscv.cpp | 2 +- .../cpu/riscv/macroAssembler_riscv.cpp | 24 +++++++------ .../cpu/riscv/macroAssembler_riscv.hpp | 6 ++-- src/hotspot/cpu/riscv/nativeInst_riscv.cpp | 14 ++++---- src/hotspot/cpu/riscv/nativeInst_riscv.hpp | 34 ++++++++++++------- src/hotspot/cpu/riscv/riscv.ad | 4 +-- 10 files changed, 60 insertions(+), 44 deletions(-) diff --git a/src/hotspot/cpu/riscv/assembler_riscv.cpp b/src/hotspot/cpu/riscv/assembler_riscv.cpp index 32b06e30c79f8..d175153354958 100644 --- a/src/hotspot/cpu/riscv/assembler_riscv.cpp +++ b/src/hotspot/cpu/riscv/assembler_riscv.cpp @@ -281,10 +281,10 @@ void Assembler::movptr_with_offset(Register Rd, address addr, int32_t &offset) { block_comment(buffer); } #endif - assert(is_unsigned_imm_in_range(imm64, 47, 0) || (imm64 == (int64_t)-1), - "bit 47 overflows in address constant"); + assert(is_unsigned_imm_in_range(imm64, 56, 0) || (imm64 == (int64_t)-1), + "bit 56 overflows in address constant"); // Load upper 31 bits - int64_t imm = imm64 >> 17; + int64_t imm = imm64 >> 26; int64_t upper = imm, lower = imm; lower = (lower << 52) >> 52; upper -= lower; @@ -292,12 +292,16 @@ void Assembler::movptr_with_offset(Register Rd, address addr, int32_t &offset) { lui(Rd, upper); addi(Rd, Rd, lower); + // Load the next 9 bits. + slli(Rd, Rd, 9); + addi(Rd, Rd, (imm64 >> 17) & 0x1ff); + // Load the rest 17 bits. slli(Rd, Rd, 11); addi(Rd, Rd, (imm64 >> 6) & 0x7ff); - slli(Rd, Rd, 6); // This offset will be used by following jalr/ld. + slli(Rd, Rd, 6); offset = imm64 & 0x3f; } diff --git a/src/hotspot/cpu/riscv/c1_LIRAssembler_riscv.hpp b/src/hotspot/cpu/riscv/c1_LIRAssembler_riscv.hpp index 051328c3a8a3f..2bd8c17fcdead 100644 --- a/src/hotspot/cpu/riscv/c1_LIRAssembler_riscv.hpp +++ b/src/hotspot/cpu/riscv/c1_LIRAssembler_riscv.hpp @@ -71,7 +71,7 @@ friend class ArrayCopyStub; enum { // See emit_static_call_stub for detail // CompiledStaticCall::to_interp_stub_size() (14) + CompiledStaticCall::to_trampoline_stub_size() (1 + 3 + address) - _call_stub_size = 14 * NativeInstruction::instruction_size + + _call_stub_size = 16 * NativeInstruction::instruction_size + (NativeInstruction::instruction_size + NativeCallTrampolineStub::instruction_size), // See emit_exception_handler for detail // verify_not_null_oop + far_call + should_not_reach_here + invalidate_registers(DEBUG_ONLY) diff --git a/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp b/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp index 3061be8b4c104..b1cf73c1a9c99 100644 --- a/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp +++ b/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp @@ -268,7 +268,7 @@ void C2_MacroAssembler::emit_entry_barrier_stub(C2EntryBarrierStub* stub) { } int C2_MacroAssembler::entry_barrier_stub_size() { - return 8 * 4 + 4; // 4 bytes for alignment margin + return 10 * 4 + 4; // 4 bytes for alignment margin } // Search for needle in haystack and return index or -1 diff --git a/src/hotspot/cpu/riscv/compiledIC_riscv.cpp b/src/hotspot/cpu/riscv/compiledIC_riscv.cpp index d202db92a4cbd..6520871c75625 100644 --- a/src/hotspot/cpu/riscv/compiledIC_riscv.cpp +++ b/src/hotspot/cpu/riscv/compiledIC_riscv.cpp @@ -69,8 +69,8 @@ address CompiledStaticCall::emit_to_interp_stub(CodeBuffer &cbuf, address mark) #undef __ int CompiledStaticCall::to_interp_stub_size() { - // (lui, addi, slli, addi, slli, addi) + (lui, addi, slli, addi, slli) + jalr - return 12 * NativeInstruction::instruction_size; + // (lui, addi, slli, addi, slli, addi, slli, addi) + (lui, addi, slli, addi, slli, addi, slli) + jalr + return 16 * NativeInstruction::instruction_size; } int CompiledStaticCall::to_trampoline_stub_size() { diff --git a/src/hotspot/cpu/riscv/gc/shared/barrierSetNMethod_riscv.cpp b/src/hotspot/cpu/riscv/gc/shared/barrierSetNMethod_riscv.cpp index 33126326a974c..6dc75d21600b0 100644 --- a/src/hotspot/cpu/riscv/gc/shared/barrierSetNMethod_riscv.cpp +++ b/src/hotspot/cpu/riscv/gc/shared/barrierSetNMethod_riscv.cpp @@ -40,7 +40,7 @@ static int slow_path_size(nmethod* nm) { // The slow path code is out of line with C2. // Leave a jal to the stub in the fast path. - return nm->is_compiled_by_c2() ? 1 : 8; + return nm->is_compiled_by_c2() ? 1 : 10; } static int entry_barrier_offset(nmethod* nm) { diff --git a/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp b/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp index 399e87b294702..612d27c2a0af5 100644 --- a/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp +++ b/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp @@ -1177,13 +1177,14 @@ static int patch_offset_in_pc_relative(address branch, int64_t offset) { } static int patch_addr_in_movptr(address branch, address target) { - const int MOVPTR_INSTRUCTIONS_NUM = 6; // lui + addi + slli + addi + slli + addi/jalr/load - int32_t lower = ((intptr_t)target << 35) >> 35; - int64_t upper = ((intptr_t)target - lower) >> 29; - Assembler::patch(branch + 0, 31, 12, upper & 0xfffff); // Lui. target[48:29] + target[28] ==> branch[31:12] - Assembler::patch(branch + 4, 31, 20, (lower >> 17) & 0xfff); // Addi. target[28:17] ==> branch[31:20] - Assembler::patch(branch + 12, 31, 20, (lower >> 6) & 0x7ff); // Addi. target[16: 6] ==> branch[31:20] - Assembler::patch(branch + 20, 31, 20, lower & 0x3f); // Addi/Jalr/Load. target[ 5: 0] ==> branch[31:20] + const int MOVPTR_INSTRUCTIONS_NUM = 8; // lui + addi + slli + addi + slli + addi + slli + addi/jalr/load + int64_t lower = ((intptr_t)target << 26) >> 26; + int64_t upper = ((intptr_t)target - lower) >> 38; + Assembler::patch(branch + 0, 31, 12, upper & 0xfffff); // Lui. target[57:38] + target[37] ==> branch[31:12] + Assembler::patch(branch + 4, 31, 20, (lower >> 26) & 0xfff); // Addi. target[37:26] ==> branch[31:20] + Assembler::patch(branch + 12, 31, 20, (lower >> 17) & 0x1ff); // Addi. target[25:17] ==> branch[31:20] + Assembler::patch(branch + 20, 31, 20, (lower >> 6) & 0x7ff); // Addi. target[16: 6] ==> branch[31:20] + Assembler::patch(branch + 28, 31, 20, lower & 0x3f); // Addi/Jalr/Load. target[ 5: 0] ==> branch[31:20] return MOVPTR_INSTRUCTIONS_NUM * NativeInstruction::instruction_size; } @@ -1255,10 +1256,11 @@ static long get_offset_of_pc_relative(address insn_addr) { static address get_target_of_movptr(address insn_addr) { assert_cond(insn_addr != NULL); - intptr_t target_address = (((int64_t)Assembler::sextract(((unsigned*)insn_addr)[0], 31, 12)) & 0xfffff) << 29; // Lui. - target_address += ((int64_t)Assembler::sextract(((unsigned*)insn_addr)[1], 31, 20)) << 17; // Addi. - target_address += ((int64_t)Assembler::sextract(((unsigned*)insn_addr)[3], 31, 20)) << 6; // Addi. - target_address += ((int64_t)Assembler::sextract(((unsigned*)insn_addr)[5], 31, 20)); // Addi/Jalr/Load. + intptr_t target_address = (((int64_t)Assembler::sextract(((unsigned*)insn_addr)[0], 31, 12)) & 0xfffff) << 38; // Lui. + target_address += ((int64_t)Assembler::sextract(((unsigned*)insn_addr)[1], 31, 20)) << 26; // Addi. + target_address += ((int64_t)Assembler::sextract(((unsigned*)insn_addr)[3], 31, 20)) << 17; // Addi. + target_address += ((int64_t)Assembler::sextract(((unsigned*)insn_addr)[5], 31, 20)) << 6; // Addi. + target_address += ((int64_t)Assembler::sextract(((unsigned*)insn_addr)[7], 31, 20)); // Addi/Jalr/Load. return (address) target_address; } diff --git a/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp b/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp index 3b855297dd2a7..b895e7b030545 100644 --- a/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp +++ b/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp @@ -812,10 +812,10 @@ class MacroAssembler: public Assembler { #endif void repne_scan(Register addr, Register value, Register count, Register tmp); - // Return true if an address is within the 48-bit RISCV64 address space. + // Return true if an address is within the 57-bit RISCV64 address space. bool is_valid_riscv64_address(address addr) { - // sv48: must have bits 63–48 all equal to bit 47 - return ((uintptr_t)addr >> 47) == 0; + // sv57: must have bits 63–57 all equal to bit 56 + return ((uintptr_t)addr >> 56) == 0; } void ld_constant(Register dest, const Address &const_addr) { diff --git a/src/hotspot/cpu/riscv/nativeInst_riscv.cpp b/src/hotspot/cpu/riscv/nativeInst_riscv.cpp index 8969b158273e3..22dc75917cc14 100644 --- a/src/hotspot/cpu/riscv/nativeInst_riscv.cpp +++ b/src/hotspot/cpu/riscv/nativeInst_riscv.cpp @@ -87,12 +87,14 @@ bool NativeInstruction::is_load_pc_relative_at(address instr) { bool NativeInstruction::is_movptr_at(address instr) { return is_lui_at(instr) && // Lui is_addi_at(instr + instruction_size) && // Addi - is_slli_shift_at(instr + instruction_size * 2, 11) && // Slli Rd, Rs, 11 + is_slli_shift_at(instr + instruction_size * 2, 9) && // Slli Rd, Rs, 9 is_addi_at(instr + instruction_size * 3) && // Addi - is_slli_shift_at(instr + instruction_size * 4, 6) && // Slli Rd, Rs, 6 - (is_addi_at(instr + instruction_size * 5) || - is_jalr_at(instr + instruction_size * 5) || - is_load_at(instr + instruction_size * 5)) && // Addi/Jalr/Load + is_slli_shift_at(instr + instruction_size * 4, 11) && // Slli Rd, Rs, 11 + is_addi_at(instr + instruction_size * 5) && // Addi + is_slli_shift_at(instr + instruction_size * 6, 6) && // Slli Rd, Rs, 6 + (is_addi_at(instr + instruction_size * 7) || + is_jalr_at(instr + instruction_size * 7) || + is_load_at(instr + instruction_size * 7)) && // Addi/Jalr/Load check_movptr_data_dependency(instr); } @@ -383,7 +385,7 @@ void NativeGeneralJump::insert_unconditional(address code_pos, address entry) { MacroAssembler a(&cb); int32_t offset = 0; - a.movptr_with_offset(t0, entry, offset); // lui, addi, slli, addi, slli + a.movptr_with_offset(t0, entry, offset); // lui, addi, slli, addi, slli, addi, slli a.jalr(x0, t0, offset); // jalr ICache::invalidate_range(code_pos, instruction_size); diff --git a/src/hotspot/cpu/riscv/nativeInst_riscv.hpp b/src/hotspot/cpu/riscv/nativeInst_riscv.hpp index 96ddd872e2584..b9f7b6738e996 100644 --- a/src/hotspot/cpu/riscv/nativeInst_riscv.hpp +++ b/src/hotspot/cpu/riscv/nativeInst_riscv.hpp @@ -96,6 +96,8 @@ class NativeInstruction { // slli // addi // slli + // addi + // slli // addi/jalr/load static bool check_movptr_data_dependency(address instr) { address lui = instr; @@ -103,7 +105,9 @@ class NativeInstruction { address slli1 = addi1 + instruction_size; address addi2 = slli1 + instruction_size; address slli2 = addi2 + instruction_size; - address last_instr = slli2 + instruction_size; + address addi3 = slli1 + instruction_size; + address slli3 = addi3 + instruction_size; + address last_instr = slli3 + instruction_size; return extract_rs1(addi1) == extract_rd(lui) && extract_rs1(addi1) == extract_rd(addi1) && extract_rs1(slli1) == extract_rd(addi1) && @@ -112,7 +116,11 @@ class NativeInstruction { extract_rs1(addi2) == extract_rd(addi2) && extract_rs1(slli2) == extract_rd(addi2) && extract_rs1(slli2) == extract_rd(slli2) && - extract_rs1(last_instr) == extract_rd(slli2); + extract_rs1(addi3) == extract_rd(slli2) && + extract_rs1(addi3) == extract_rd(addi3) && + extract_rs1(slli3) == extract_rd(addi3) && + extract_rs1(slli3) == extract_rd(slli3) && + extract_rs1(last_instr) == extract_rd(slli3); } // the instruction sequence of li64 is as below: @@ -327,8 +335,8 @@ inline NativeCall* nativeCall_before(address return_address) { class NativeMovConstReg: public NativeInstruction { public: enum RISCV_specific_constants { - movptr_instruction_size = 6 * NativeInstruction::instruction_size, // lui, addi, slli, addi, slli, addi. See movptr(). - movptr_with_offset_instruction_size = 5 * NativeInstruction::instruction_size, // lui, addi, slli, addi, slli. See movptr_with_offset(). + movptr_instruction_size = 8 * NativeInstruction::instruction_size, // lui, addi, slli, addi, slli, addi, slli, addi. See movptr(). + movptr_with_offset_instruction_size = 7 * NativeInstruction::instruction_size, // lui, addi, slli, addi, slli, addi, slli. See movptr_with_offset(). load_pc_relative_instruction_size = 2 * NativeInstruction::instruction_size, // auipc, ld instruction_offset = 0, displacement_offset = 0 @@ -336,17 +344,17 @@ class NativeMovConstReg: public NativeInstruction { address instruction_address() const { return addr_at(instruction_offset); } address next_instruction_address() const { - // if the instruction at 5 * instruction_size is addi, - // it means a lui + addi + slli + addi + slli + addi instruction sequence, - // and the next instruction address should be addr_at(6 * instruction_size). - // However, when the instruction at 5 * instruction_size isn't addi, - // the next instruction address should be addr_at(5 * instruction_size) + // if the instruction at 7 * instruction_size is addi, + // it means a lui + addi + slli + addi + slli + addi + slli + addi instruction sequence, + // and the next instruction address should be addr_at(8 * instruction_size). + // However, when the instruction at 7 * instruction_size isn't addi, + // the next instruction address should be addr_at(7 * instruction_size) if (nativeInstruction_at(instruction_address())->is_movptr()) { if (is_addi_at(addr_at(movptr_with_offset_instruction_size))) { - // Assume: lui, addi, slli, addi, slli, addi + // Assume: lui, addi, slli, addi, slli, addi, slli, addi return addr_at(movptr_instruction_size); } else { - // Assume: lui, addi, slli, addi, slli + // Assume: lui, addi, slli, addi, slli, addi, slli return addr_at(movptr_with_offset_instruction_size); } } else if (is_load_pc_relative_at(instruction_address())) { @@ -461,10 +469,10 @@ inline NativeJump* nativeJump_at(address addr) { class NativeGeneralJump: public NativeJump { public: enum RISCV_specific_constants { - instruction_size = 6 * NativeInstruction::instruction_size, // lui, addi, slli, addi, slli, jalr + instruction_size = 8 * NativeInstruction::instruction_size, // lui, addi, slli, addi, slli, addi, slli, jalr instruction_offset = 0, data_offset = 0, - next_instruction_offset = 6 * NativeInstruction::instruction_size // lui, addi, slli, addi, slli, jalr + next_instruction_offset = 8 * NativeInstruction::instruction_size // lui, addi, slli, addi, slli, addi, slli, jalr }; address jump_destination() const; diff --git a/src/hotspot/cpu/riscv/riscv.ad b/src/hotspot/cpu/riscv/riscv.ad index 4393e84cd60b2..089d9f208b752 100644 --- a/src/hotspot/cpu/riscv/riscv.ad +++ b/src/hotspot/cpu/riscv/riscv.ad @@ -1173,7 +1173,7 @@ int MachCallRuntimeNode::ret_addr_offset() { // for real runtime callouts it will be 11 instructions // see riscv_enc_java_to_runtime // la(t1, retaddr) -> auipc + addi - // la(t0, RuntimeAddress(addr)) -> lui + addi + slli + addi + slli + addi + // la(t0, RuntimeAddress(addr)) -> lui + addi + slli + addi + slli + addi + slli + addi // addi(sp, sp, -2 * wordSize) -> addi // sd(t1, Address(sp, wordSize)) -> sd // jalr(t0) -> jalr @@ -1181,7 +1181,7 @@ int MachCallRuntimeNode::ret_addr_offset() { if (cb != NULL) { return 1 * NativeInstruction::instruction_size; } else { - return 11 * NativeInstruction::instruction_size; + return 13 * NativeInstruction::instruction_size; } } From c94ab55ff8160b0195b8f48fdda201df56c544d5 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Wed, 14 Sep 2022 18:07:36 +0200 Subject: [PATCH 10/85] Revert "Support sv57 on RISC-V (#11)" (#13) It doesn't work as expected. Local testing didn't catch the failing cases. We really need the proper test suite.. Reverting for now, and once we've proper CI, I'll rework the original patch and make it work. This reverts commit 5be1125c49ec4a170aaba084ef8b310534cfaceb. --- src/hotspot/cpu/riscv/assembler_riscv.cpp | 12 +++---- .../cpu/riscv/c1_LIRAssembler_riscv.hpp | 2 +- .../cpu/riscv/c2_MacroAssembler_riscv.cpp | 2 +- src/hotspot/cpu/riscv/compiledIC_riscv.cpp | 4 +-- .../gc/shared/barrierSetNMethod_riscv.cpp | 2 +- .../cpu/riscv/macroAssembler_riscv.cpp | 24 ++++++------- .../cpu/riscv/macroAssembler_riscv.hpp | 6 ++-- src/hotspot/cpu/riscv/nativeInst_riscv.cpp | 14 ++++---- src/hotspot/cpu/riscv/nativeInst_riscv.hpp | 34 +++++++------------ src/hotspot/cpu/riscv/riscv.ad | 4 +-- 10 files changed, 44 insertions(+), 60 deletions(-) diff --git a/src/hotspot/cpu/riscv/assembler_riscv.cpp b/src/hotspot/cpu/riscv/assembler_riscv.cpp index d175153354958..32b06e30c79f8 100644 --- a/src/hotspot/cpu/riscv/assembler_riscv.cpp +++ b/src/hotspot/cpu/riscv/assembler_riscv.cpp @@ -281,10 +281,10 @@ void Assembler::movptr_with_offset(Register Rd, address addr, int32_t &offset) { block_comment(buffer); } #endif - assert(is_unsigned_imm_in_range(imm64, 56, 0) || (imm64 == (int64_t)-1), - "bit 56 overflows in address constant"); + assert(is_unsigned_imm_in_range(imm64, 47, 0) || (imm64 == (int64_t)-1), + "bit 47 overflows in address constant"); // Load upper 31 bits - int64_t imm = imm64 >> 26; + int64_t imm = imm64 >> 17; int64_t upper = imm, lower = imm; lower = (lower << 52) >> 52; upper -= lower; @@ -292,16 +292,12 @@ void Assembler::movptr_with_offset(Register Rd, address addr, int32_t &offset) { lui(Rd, upper); addi(Rd, Rd, lower); - // Load the next 9 bits. - slli(Rd, Rd, 9); - addi(Rd, Rd, (imm64 >> 17) & 0x1ff); - // Load the rest 17 bits. slli(Rd, Rd, 11); addi(Rd, Rd, (imm64 >> 6) & 0x7ff); + slli(Rd, Rd, 6); // This offset will be used by following jalr/ld. - slli(Rd, Rd, 6); offset = imm64 & 0x3f; } diff --git a/src/hotspot/cpu/riscv/c1_LIRAssembler_riscv.hpp b/src/hotspot/cpu/riscv/c1_LIRAssembler_riscv.hpp index 2bd8c17fcdead..051328c3a8a3f 100644 --- a/src/hotspot/cpu/riscv/c1_LIRAssembler_riscv.hpp +++ b/src/hotspot/cpu/riscv/c1_LIRAssembler_riscv.hpp @@ -71,7 +71,7 @@ friend class ArrayCopyStub; enum { // See emit_static_call_stub for detail // CompiledStaticCall::to_interp_stub_size() (14) + CompiledStaticCall::to_trampoline_stub_size() (1 + 3 + address) - _call_stub_size = 16 * NativeInstruction::instruction_size + + _call_stub_size = 14 * NativeInstruction::instruction_size + (NativeInstruction::instruction_size + NativeCallTrampolineStub::instruction_size), // See emit_exception_handler for detail // verify_not_null_oop + far_call + should_not_reach_here + invalidate_registers(DEBUG_ONLY) diff --git a/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp b/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp index b1cf73c1a9c99..3061be8b4c104 100644 --- a/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp +++ b/src/hotspot/cpu/riscv/c2_MacroAssembler_riscv.cpp @@ -268,7 +268,7 @@ void C2_MacroAssembler::emit_entry_barrier_stub(C2EntryBarrierStub* stub) { } int C2_MacroAssembler::entry_barrier_stub_size() { - return 10 * 4 + 4; // 4 bytes for alignment margin + return 8 * 4 + 4; // 4 bytes for alignment margin } // Search for needle in haystack and return index or -1 diff --git a/src/hotspot/cpu/riscv/compiledIC_riscv.cpp b/src/hotspot/cpu/riscv/compiledIC_riscv.cpp index 6520871c75625..d202db92a4cbd 100644 --- a/src/hotspot/cpu/riscv/compiledIC_riscv.cpp +++ b/src/hotspot/cpu/riscv/compiledIC_riscv.cpp @@ -69,8 +69,8 @@ address CompiledStaticCall::emit_to_interp_stub(CodeBuffer &cbuf, address mark) #undef __ int CompiledStaticCall::to_interp_stub_size() { - // (lui, addi, slli, addi, slli, addi, slli, addi) + (lui, addi, slli, addi, slli, addi, slli) + jalr - return 16 * NativeInstruction::instruction_size; + // (lui, addi, slli, addi, slli, addi) + (lui, addi, slli, addi, slli) + jalr + return 12 * NativeInstruction::instruction_size; } int CompiledStaticCall::to_trampoline_stub_size() { diff --git a/src/hotspot/cpu/riscv/gc/shared/barrierSetNMethod_riscv.cpp b/src/hotspot/cpu/riscv/gc/shared/barrierSetNMethod_riscv.cpp index 6dc75d21600b0..33126326a974c 100644 --- a/src/hotspot/cpu/riscv/gc/shared/barrierSetNMethod_riscv.cpp +++ b/src/hotspot/cpu/riscv/gc/shared/barrierSetNMethod_riscv.cpp @@ -40,7 +40,7 @@ static int slow_path_size(nmethod* nm) { // The slow path code is out of line with C2. // Leave a jal to the stub in the fast path. - return nm->is_compiled_by_c2() ? 1 : 10; + return nm->is_compiled_by_c2() ? 1 : 8; } static int entry_barrier_offset(nmethod* nm) { diff --git a/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp b/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp index 112e6dffbb022..368ccb163890d 100644 --- a/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp +++ b/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp @@ -1177,14 +1177,13 @@ static int patch_offset_in_pc_relative(address branch, int64_t offset) { } static int patch_addr_in_movptr(address branch, address target) { - const int MOVPTR_INSTRUCTIONS_NUM = 8; // lui + addi + slli + addi + slli + addi + slli + addi/jalr/load - int64_t lower = ((intptr_t)target << 26) >> 26; - int64_t upper = ((intptr_t)target - lower) >> 38; - Assembler::patch(branch + 0, 31, 12, upper & 0xfffff); // Lui. target[57:38] + target[37] ==> branch[31:12] - Assembler::patch(branch + 4, 31, 20, (lower >> 26) & 0xfff); // Addi. target[37:26] ==> branch[31:20] - Assembler::patch(branch + 12, 31, 20, (lower >> 17) & 0x1ff); // Addi. target[25:17] ==> branch[31:20] - Assembler::patch(branch + 20, 31, 20, (lower >> 6) & 0x7ff); // Addi. target[16: 6] ==> branch[31:20] - Assembler::patch(branch + 28, 31, 20, lower & 0x3f); // Addi/Jalr/Load. target[ 5: 0] ==> branch[31:20] + const int MOVPTR_INSTRUCTIONS_NUM = 6; // lui + addi + slli + addi + slli + addi/jalr/load + int32_t lower = ((intptr_t)target << 35) >> 35; + int64_t upper = ((intptr_t)target - lower) >> 29; + Assembler::patch(branch + 0, 31, 12, upper & 0xfffff); // Lui. target[48:29] + target[28] ==> branch[31:12] + Assembler::patch(branch + 4, 31, 20, (lower >> 17) & 0xfff); // Addi. target[28:17] ==> branch[31:20] + Assembler::patch(branch + 12, 31, 20, (lower >> 6) & 0x7ff); // Addi. target[16: 6] ==> branch[31:20] + Assembler::patch(branch + 20, 31, 20, lower & 0x3f); // Addi/Jalr/Load. target[ 5: 0] ==> branch[31:20] return MOVPTR_INSTRUCTIONS_NUM * NativeInstruction::instruction_size; } @@ -1256,11 +1255,10 @@ static long get_offset_of_pc_relative(address insn_addr) { static address get_target_of_movptr(address insn_addr) { assert_cond(insn_addr != NULL); - intptr_t target_address = (((int64_t)Assembler::sextract(((unsigned*)insn_addr)[0], 31, 12)) & 0xfffff) << 38; // Lui. - target_address += ((int64_t)Assembler::sextract(((unsigned*)insn_addr)[1], 31, 20)) << 26; // Addi. - target_address += ((int64_t)Assembler::sextract(((unsigned*)insn_addr)[3], 31, 20)) << 17; // Addi. - target_address += ((int64_t)Assembler::sextract(((unsigned*)insn_addr)[5], 31, 20)) << 6; // Addi. - target_address += ((int64_t)Assembler::sextract(((unsigned*)insn_addr)[7], 31, 20)); // Addi/Jalr/Load. + intptr_t target_address = (((int64_t)Assembler::sextract(((unsigned*)insn_addr)[0], 31, 12)) & 0xfffff) << 29; // Lui. + target_address += ((int64_t)Assembler::sextract(((unsigned*)insn_addr)[1], 31, 20)) << 17; // Addi. + target_address += ((int64_t)Assembler::sextract(((unsigned*)insn_addr)[3], 31, 20)) << 6; // Addi. + target_address += ((int64_t)Assembler::sextract(((unsigned*)insn_addr)[5], 31, 20)); // Addi/Jalr/Load. return (address) target_address; } diff --git a/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp b/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp index 6eb8e6e0932d6..8f225280bcedc 100644 --- a/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp +++ b/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp @@ -812,10 +812,10 @@ class MacroAssembler: public Assembler { #endif void repne_scan(Register addr, Register value, Register count, Register tmp); - // Return true if an address is within the 57-bit RISCV64 address space. + // Return true if an address is within the 48-bit RISCV64 address space. bool is_valid_riscv64_address(address addr) { - // sv57: must have bits 63–57 all equal to bit 56 - return ((uintptr_t)addr >> 56) == 0; + // sv48: must have bits 63–48 all equal to bit 47 + return ((uintptr_t)addr >> 47) == 0; } void ld_constant(Register dest, const Address &const_addr) { diff --git a/src/hotspot/cpu/riscv/nativeInst_riscv.cpp b/src/hotspot/cpu/riscv/nativeInst_riscv.cpp index 22dc75917cc14..8969b158273e3 100644 --- a/src/hotspot/cpu/riscv/nativeInst_riscv.cpp +++ b/src/hotspot/cpu/riscv/nativeInst_riscv.cpp @@ -87,14 +87,12 @@ bool NativeInstruction::is_load_pc_relative_at(address instr) { bool NativeInstruction::is_movptr_at(address instr) { return is_lui_at(instr) && // Lui is_addi_at(instr + instruction_size) && // Addi - is_slli_shift_at(instr + instruction_size * 2, 9) && // Slli Rd, Rs, 9 + is_slli_shift_at(instr + instruction_size * 2, 11) && // Slli Rd, Rs, 11 is_addi_at(instr + instruction_size * 3) && // Addi - is_slli_shift_at(instr + instruction_size * 4, 11) && // Slli Rd, Rs, 11 - is_addi_at(instr + instruction_size * 5) && // Addi - is_slli_shift_at(instr + instruction_size * 6, 6) && // Slli Rd, Rs, 6 - (is_addi_at(instr + instruction_size * 7) || - is_jalr_at(instr + instruction_size * 7) || - is_load_at(instr + instruction_size * 7)) && // Addi/Jalr/Load + is_slli_shift_at(instr + instruction_size * 4, 6) && // Slli Rd, Rs, 6 + (is_addi_at(instr + instruction_size * 5) || + is_jalr_at(instr + instruction_size * 5) || + is_load_at(instr + instruction_size * 5)) && // Addi/Jalr/Load check_movptr_data_dependency(instr); } @@ -385,7 +383,7 @@ void NativeGeneralJump::insert_unconditional(address code_pos, address entry) { MacroAssembler a(&cb); int32_t offset = 0; - a.movptr_with_offset(t0, entry, offset); // lui, addi, slli, addi, slli, addi, slli + a.movptr_with_offset(t0, entry, offset); // lui, addi, slli, addi, slli a.jalr(x0, t0, offset); // jalr ICache::invalidate_range(code_pos, instruction_size); diff --git a/src/hotspot/cpu/riscv/nativeInst_riscv.hpp b/src/hotspot/cpu/riscv/nativeInst_riscv.hpp index b9f7b6738e996..96ddd872e2584 100644 --- a/src/hotspot/cpu/riscv/nativeInst_riscv.hpp +++ b/src/hotspot/cpu/riscv/nativeInst_riscv.hpp @@ -96,8 +96,6 @@ class NativeInstruction { // slli // addi // slli - // addi - // slli // addi/jalr/load static bool check_movptr_data_dependency(address instr) { address lui = instr; @@ -105,9 +103,7 @@ class NativeInstruction { address slli1 = addi1 + instruction_size; address addi2 = slli1 + instruction_size; address slli2 = addi2 + instruction_size; - address addi3 = slli1 + instruction_size; - address slli3 = addi3 + instruction_size; - address last_instr = slli3 + instruction_size; + address last_instr = slli2 + instruction_size; return extract_rs1(addi1) == extract_rd(lui) && extract_rs1(addi1) == extract_rd(addi1) && extract_rs1(slli1) == extract_rd(addi1) && @@ -116,11 +112,7 @@ class NativeInstruction { extract_rs1(addi2) == extract_rd(addi2) && extract_rs1(slli2) == extract_rd(addi2) && extract_rs1(slli2) == extract_rd(slli2) && - extract_rs1(addi3) == extract_rd(slli2) && - extract_rs1(addi3) == extract_rd(addi3) && - extract_rs1(slli3) == extract_rd(addi3) && - extract_rs1(slli3) == extract_rd(slli3) && - extract_rs1(last_instr) == extract_rd(slli3); + extract_rs1(last_instr) == extract_rd(slli2); } // the instruction sequence of li64 is as below: @@ -335,8 +327,8 @@ inline NativeCall* nativeCall_before(address return_address) { class NativeMovConstReg: public NativeInstruction { public: enum RISCV_specific_constants { - movptr_instruction_size = 8 * NativeInstruction::instruction_size, // lui, addi, slli, addi, slli, addi, slli, addi. See movptr(). - movptr_with_offset_instruction_size = 7 * NativeInstruction::instruction_size, // lui, addi, slli, addi, slli, addi, slli. See movptr_with_offset(). + movptr_instruction_size = 6 * NativeInstruction::instruction_size, // lui, addi, slli, addi, slli, addi. See movptr(). + movptr_with_offset_instruction_size = 5 * NativeInstruction::instruction_size, // lui, addi, slli, addi, slli. See movptr_with_offset(). load_pc_relative_instruction_size = 2 * NativeInstruction::instruction_size, // auipc, ld instruction_offset = 0, displacement_offset = 0 @@ -344,17 +336,17 @@ class NativeMovConstReg: public NativeInstruction { address instruction_address() const { return addr_at(instruction_offset); } address next_instruction_address() const { - // if the instruction at 7 * instruction_size is addi, - // it means a lui + addi + slli + addi + slli + addi + slli + addi instruction sequence, - // and the next instruction address should be addr_at(8 * instruction_size). - // However, when the instruction at 7 * instruction_size isn't addi, - // the next instruction address should be addr_at(7 * instruction_size) + // if the instruction at 5 * instruction_size is addi, + // it means a lui + addi + slli + addi + slli + addi instruction sequence, + // and the next instruction address should be addr_at(6 * instruction_size). + // However, when the instruction at 5 * instruction_size isn't addi, + // the next instruction address should be addr_at(5 * instruction_size) if (nativeInstruction_at(instruction_address())->is_movptr()) { if (is_addi_at(addr_at(movptr_with_offset_instruction_size))) { - // Assume: lui, addi, slli, addi, slli, addi, slli, addi + // Assume: lui, addi, slli, addi, slli, addi return addr_at(movptr_instruction_size); } else { - // Assume: lui, addi, slli, addi, slli, addi, slli + // Assume: lui, addi, slli, addi, slli return addr_at(movptr_with_offset_instruction_size); } } else if (is_load_pc_relative_at(instruction_address())) { @@ -469,10 +461,10 @@ inline NativeJump* nativeJump_at(address addr) { class NativeGeneralJump: public NativeJump { public: enum RISCV_specific_constants { - instruction_size = 8 * NativeInstruction::instruction_size, // lui, addi, slli, addi, slli, addi, slli, jalr + instruction_size = 6 * NativeInstruction::instruction_size, // lui, addi, slli, addi, slli, jalr instruction_offset = 0, data_offset = 0, - next_instruction_offset = 8 * NativeInstruction::instruction_size // lui, addi, slli, addi, slli, addi, slli, jalr + next_instruction_offset = 6 * NativeInstruction::instruction_size // lui, addi, slli, addi, slli, jalr }; address jump_destination() const; diff --git a/src/hotspot/cpu/riscv/riscv.ad b/src/hotspot/cpu/riscv/riscv.ad index 7355744cbaba4..af9f643897f50 100644 --- a/src/hotspot/cpu/riscv/riscv.ad +++ b/src/hotspot/cpu/riscv/riscv.ad @@ -1173,7 +1173,7 @@ int MachCallRuntimeNode::ret_addr_offset() { // for real runtime callouts it will be 11 instructions // see riscv_enc_java_to_runtime // la(t1, retaddr) -> auipc + addi - // la(t0, RuntimeAddress(addr)) -> lui + addi + slli + addi + slli + addi + slli + addi + // la(t0, RuntimeAddress(addr)) -> lui + addi + slli + addi + slli + addi // addi(sp, sp, -2 * wordSize) -> addi // sd(t1, Address(sp, wordSize)) -> sd // jalr(t0) -> jalr @@ -1181,7 +1181,7 @@ int MachCallRuntimeNode::ret_addr_offset() { if (cb != NULL) { return 1 * NativeInstruction::instruction_size; } else { - return 13 * NativeInstruction::instruction_size; + return 11 * NativeInstruction::instruction_size; } } From 4c88e66b654e4c29ede7c221d223298497fa06c2 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Thu, 15 Sep 2022 15:17:50 +0200 Subject: [PATCH 11/85] Allow cross-compilation of hsdis (#15) It also adds out-of-tree building of binutils so we can share the same sources for different target architectures. --- make/autoconf/lib-hsdis.m4 | 40 +++++++++++++++-------- src/utils/hsdis/binutils/hsdis-binutils.c | 4 ++- 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/make/autoconf/lib-hsdis.m4 b/make/autoconf/lib-hsdis.m4 index d72bbf6df320f..ac8a5ad701bd1 100644 --- a/make/autoconf/lib-hsdis.m4 +++ b/make/autoconf/lib-hsdis.m4 @@ -134,6 +134,8 @@ AC_DEFUN([LIB_BUILD_BINUTILS], BINUTILS_SRC="$with_binutils_src" UTIL_FIXUP_PATH(BINUTILS_SRC) + BINUTILS_DIR="${OUTPUTDIR}/binutils" + if ! test -d $BINUTILS_SRC; then AC_MSG_ERROR([--with-binutils-src is not pointing to a directory]) fi @@ -141,10 +143,14 @@ AC_DEFUN([LIB_BUILD_BINUTILS], AC_MSG_ERROR([--with-binutils-src does not look like a binutils source directory]) fi - if test -e $BINUTILS_SRC/bfd/libbfd.a && \ - test -e $BINUTILS_SRC/opcodes/libopcodes.a && \ - test -e $BINUTILS_SRC/libiberty/libiberty.a && \ - test -e $BINUTILS_SRC/zlib/libz.a; then + if ! test -d $BINUTILS_DIR; then + $MKDIR -p $BINUTILS_DIR + fi + + if test -e $BINUTILS_DIR/bfd/libbfd.a && \ + test -e $BINUTILS_DIR/opcodes/libopcodes.a && \ + test -e $BINUTILS_DIR/libiberty/libiberty.a && \ + test -e $BINUTILS_DIR/zlib/libz.a; then AC_MSG_NOTICE([Found binutils binaries in binutils source directory -- not building]) else # On Windows, we cannot build with the normal Microsoft CL, but must instead use @@ -175,16 +181,20 @@ AC_DEFUN([LIB_BUILD_BINUTILS], fi else binutils_cc="$CC $SYSROOT_CFLAGS" - binutils_target="" + if test "x$COMPILE_TYPE" = "xcross"; then + binutils_target="--host=$OPENJDK_TARGET_CPU-$OPENJDK_TARGET_OS-$OPENJDK_TARGET_LIBC --target=$OPENJDK_TARGET_CPU-$OPENJDK_TARGET_OS-$OPENJDK_TARGET_LIBC" + else + binutils_target="" + fi fi binutils_cflags="$binutils_cflags $MACHINE_FLAG $JVM_PICFLAG $C_O_FLAG_NORM" AC_MSG_NOTICE([Running binutils configure]) - AC_MSG_NOTICE([configure command line: ./configure --disable-nls CFLAGS="$binutils_cflags" CC="$binutils_cc" $binutils_target]) + AC_MSG_NOTICE([configure command line: cd $BINUTILS_DIR && $BINUTILS_SRC/configure --disable-nls CFLAGS="$binutils_cflags" CC="$binutils_cc" $binutils_target]) saved_dir=`pwd` - cd "$BINUTILS_SRC" - ./configure --disable-nls CFLAGS="$binutils_cflags" CC="$binutils_cc" $binutils_target - if test $? -ne 0 || ! test -e $BINUTILS_SRC/Makefile; then + cd "$BINUTILS_DIR" + $BINUTILS_SRC/configure --disable-nls CFLAGS="$binutils_cflags" CC="$binutils_cc" $binutils_target + if test $? -ne 0 || ! test -e $BINUTILS_DIR/Makefile; then AC_MSG_NOTICE([Automatic building of binutils failed on configure. Try building it manually]) AC_MSG_ERROR([Cannot continue]) fi @@ -197,8 +207,6 @@ AC_DEFUN([LIB_BUILD_BINUTILS], cd $saved_dir AC_MSG_NOTICE([Building of binutils done]) fi - - BINUTILS_DIR="$BINUTILS_SRC" ]) ################################################################################ @@ -234,8 +242,14 @@ AC_DEFUN([LIB_SETUP_HSDIS_BINUTILS], elif test "x$BINUTILS_DIR" != x; then if test -e $BINUTILS_DIR/bfd/libbfd.a && \ test -e $BINUTILS_DIR/opcodes/libopcodes.a && \ - test -e $BINUTILS_DIR/libiberty/libiberty.a; then - HSDIS_CFLAGS="-I$BINUTILS_DIR/include -I$BINUTILS_DIR/bfd -DLIBARCH_$OPENJDK_TARGET_CPU_LEGACY_LIB" + test -e $BINUTILS_DIR/libiberty/libiberty.a && \ + test -e $BINUTILS_DIR/zlib/libz.a; then + HSDIS_CFLAGS="-DLIBARCH_$OPENJDK_TARGET_CPU_LEGACY_LIB" + if test -n "$BINUTILS_SRC"; then + HSDIS_CFLAGS="$HSDIS_CFLAGS -I$BINUTILS_SRC/include -I$BINUTILS_DIR/bfd" + else + HSDIS_CFLAGS="$HSDIS_CFLAGS -I$BINUTILS_DIR/include -I$BINUTILS_DIR/bfd" + fi HSDIS_LDFLAGS="" HSDIS_LIBS="$BINUTILS_DIR/bfd/libbfd.a $BINUTILS_DIR/opcodes/libopcodes.a $BINUTILS_DIR/libiberty/libiberty.a $BINUTILS_DIR/zlib/libz.a" fi diff --git a/src/utils/hsdis/binutils/hsdis-binutils.c b/src/utils/hsdis/binutils/hsdis-binutils.c index 279ed53ba5d24..602283dd6571e 100644 --- a/src/utils/hsdis/binutils/hsdis-binutils.c +++ b/src/utils/hsdis/binutils/hsdis-binutils.c @@ -566,7 +566,9 @@ static void init_disassemble_info_from_bfd(struct disassemble_info* dinfo, dinfo->flavour = bfd_get_flavour(abfd); dinfo->arch = bfd_get_arch(abfd); dinfo->mach = bfd_get_mach(abfd); - dinfo->disassembler_options = disassembler_options; + dinfo->disassembler_options = + disassembler_options != NULL && disassembler_options[0] != '\0' ? + disassembler_options : NULL; #ifdef SEC_ELF_OCTETS /* bfd_octets_per_byte() has 2 args since binutils 2.34 */ dinfo->octets_per_byte = bfd_octets_per_byte (abfd, NULL); From 89fc1f5f8ca35e2275afb13927fd1fa6366c5bd8 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Fri, 16 Sep 2022 14:23:45 +0200 Subject: [PATCH 12/85] Reduce size of rivos-sdk-jdk-dbg package (#14) Remove duplicated files with rivos-sdk-jdk --- rivos/gitlab-ci.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/rivos/gitlab-ci.yml b/rivos/gitlab-ci.yml index 6a2554ce06e39..2d5fb70bf1f1d 100644 --- a/rivos/gitlab-ci.yml +++ b/rivos/gitlab-ci.yml @@ -237,7 +237,7 @@ package-deb: - cp -a build/linux-amd64/images/jdk /rivos/ - cp -a build/linux-rv64/images/jdk /rivos/sysroot/riscv/rivos # remove *.debuginfo files, they take a lot of space - - find /rivos/jdk /rivos/sysroot/riscv/rivos/jdk -name '*.debuginfo' -exec rm -f {} \; -print + - find /rivos/jdk /rivos/sysroot/riscv/rivos/jdk -type f -name '*.debuginfo' -exec rm -f {} \; -print package-deb-dbg: extends: .deploy-deb @@ -262,6 +262,9 @@ package-deb-dbg: - mkdir -p /rivos/sysroot/riscv/rivos - cp -a build/linux-amd64/images/jdk /rivos/ - cp -a build/linux-rv64/images/jdk /rivos/sysroot/riscv/rivos + # remove non *.debuginfo files, we only want *.debuginfo for the -dbg package + - find /rivos/jdk /rivos/sysroot/riscv/rivos/jdk \( -xtype f -or -xtype l \) -not -name '*.debuginfo' -exec rm -f {} \; -print + - find /rivos/jdk /rivos/sysroot/riscv/rivos/jdk -type d -print | sort -r | xargs -I{} bash -c "rmdir {} || true" deploy-module-ubuntu: extends: .deploy-module From 6f7cb58de0270649e44d763a4388ba6a4da70f8d Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Wed, 21 Sep 2022 22:10:10 +0200 Subject: [PATCH 13/85] Add Gem5CheckpointerProfiler to trigger gem5 checkpoints at beginning of a JMH benchmark iteration (#18) Add Gem5CheckpointerProfiler to trigger gem5 checkpoints at beginning of a JMH benchmark iteration --- .../bench/util/Gem5CheckpointProfiler.java | 100 ++++++++++++++++++ 1 file changed, 100 insertions(+) create mode 100644 test/micro/org/openjdk/bench/util/Gem5CheckpointProfiler.java diff --git a/test/micro/org/openjdk/bench/util/Gem5CheckpointProfiler.java b/test/micro/org/openjdk/bench/util/Gem5CheckpointProfiler.java new file mode 100644 index 0000000000000..5be3352257ec6 --- /dev/null +++ b/test/micro/org/openjdk/bench/util/Gem5CheckpointProfiler.java @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2022, Rivos 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. + */ + +package org.openjdk.bench.util; + +import org.openjdk.jmh.infra.BenchmarkParams; +import org.openjdk.jmh.infra.IterationParams; +import org.openjdk.jmh.profile.InternalProfiler; +import org.openjdk.jmh.results.IterationResult; +import org.openjdk.jmh.results.Result; + +import java.lang.reflect.Method; +import java.util.Collection; +import java.util.Collections; +import java.util.Map; + +import static java.util.concurrent.TimeUnit.NANOSECONDS;; + +public class Gem5CheckpointProfiler implements InternalProfiler { + + static final Object gem5Instance; + static final Method gem5CheckpointMethod; + + static { + try { + Class gem5Class = Class.forName("gem5.Ops"); + gem5CheckpointMethod = getGem5CheckpointMethod(gem5Class); + gem5Instance = getGem5Instance(gem5Class); + } catch (Exception e) { + throw new RuntimeException("Failed to load Gem5 Ops", e); + } + } + + private static Method getGem5CheckpointMethod(Class gem5Class) throws Exception { + // void checkpoint(long ns_delay, long ns_period) + return gem5Class.getMethod("checkpoint", long.class, long.class); + } + + @SuppressWarnings("unchecked") + private static Object getGem5Instance(Class gem5Class) throws Exception { + return ((Map)gem5Class.getField("callTypes").get(null)).get("default"); + } + + /** + * Human-readable one-line description of the profiler. + * @return description + */ + public String getDescription() { + return "gem5 checkpointing"; + } + + /** + * Run this code before starting the next benchmark iteration. + * + * @param benchmarkParams benchmark parameters used for current launch + * @param iterationParams iteration parameters used for current launch + */ + public void beforeIteration(BenchmarkParams benchmarkParams, IterationParams iterationParams) { + try { + // artificially delay by 1us to not capture the setting up of the iterations + gem5CheckpointMethod.invoke(gem5Instance, Long.valueOf(1000), Long.valueOf(iterationParams.getTime().convertTo(NANOSECONDS))); + } catch (Exception e) { + throw new RuntimeException("Failed to ivoke Gem5 checkpointing", e); + } + } + + /** + * Run this code after a benchmark iteration finished + * + * @param benchmarkParams benchmark parameters used for current launch + * @param iterationParams iteration parameters used for current launch + * @param result iteration result + * @return profiler results + */ + public Collection afterIteration(BenchmarkParams benchmarkParams, IterationParams iterationParams, IterationResult result) { + return Collections.emptyList(); + } + + private static final native void m5_checkpoint(long ns_delay, long ns_period); +} From 80fbe153680aa3e64a853a9b9b09ab2fa1b7df80 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Fri, 23 Sep 2022 10:30:53 +0200 Subject: [PATCH 14/85] Push upstream/master to master (#20) * Also push upstream to master That will allow to run our GHA CI on vanilla upstream * Rework cron schedule to take GHA duration into account --- .github/workflows/downstream.yml | 34 ++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/.github/workflows/downstream.yml b/.github/workflows/downstream.yml index 41a63da0d3371..198e416650bcc 100644 --- a/.github/workflows/downstream.yml +++ b/.github/workflows/downstream.yml @@ -27,8 +27,11 @@ name: 'OpenJDK Downstreaming' on: schedule: - # Trigger on every day at 07:00 UTC (09:00 CET, 00:00 PT) - - cron: '0 6 * * 1-5' + # Trigger on Sunday to Friday at 21:00 UTC (23:00 CET, 14:00 PT) + # It triggers at least 9 hours before start of the working day in CET + # since that's when I would want to review it. And given GHA takes a long + # time to run, we want to start doing it as early as possible + - cron: '0 21 * * 0-4' concurrency: group: ${{ github.workflow }}-${{ github.ref }} @@ -44,25 +47,36 @@ jobs: - uses: actions/checkout@v3 with: token: ${{ secrets.WORKFLOW_TOKEN }} - - name: "Create Pull Request" + + - name: "Fetch" + id: fetch run: | - # 1. fetch git remote add upstream https://github.com/openjdk/jdk.git git fetch --tags upstream master - # 2. push TAG=$(git tag | grep --extended-regexp '^jdk\-.*' | sort --version-sort | tail --lines 1 | tr --delete '\n') test -n "$TAG" - git checkout -b rivos/merge-upstream $TAG - git push origin rivos/merge-upstream $TAG - # 3. pr + echo "::set-output name=tag::$TAG" + + - name: "Push" + run: | + git push origin ${{ steps.fetch.outputs.tag }} + + git checkout -B master ${{ steps.fetch.outputs.tag }} + git push origin master + + git checkout -B rivos/merge-upstream ${{ steps.fetch.outputs.tag }} + git push origin rivos/merge-upstream + + - name: "Create PR" + run: | gh pr create \ --repo rivosinc/jdk \ --base rivos/main \ --head rivos/merge-upstream \ - --title "Merge $TAG into rivos/main" \ - --body "This is an automated pull request." \ + --title "Merge ${{ steps.fetch.outputs.tag }} into rivos/main" \ + --body "" \ --reviewer "luhenry" || true env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 1e6f366b5df1f6287eac27685df53939bdae5962 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Tue, 27 Sep 2022 10:21:56 +0200 Subject: [PATCH 15/85] Run GHA tests on cross-compile targets (#16) --- .github/actions/create-sysroot/action.yml | 83 ++++++ .github/actions/get-bundles/action.yml | 38 +-- .../init-platform-variables/action.yml | 94 +++++++ .github/workflows/build-cross-compile.yml | 129 +++++----- .github/workflows/main.yml | 120 ++++++++- .github/workflows/test-cross-compile.yml | 238 ++++++++++++++++++ test/hotspot/jtreg/ProblemList-GHA.txt | 88 +++++++ test/jdk/ProblemList-GHA.txt | 39 +++ test/langtools/ProblemList-GHA.txt | 32 +++ 9 files changed, 768 insertions(+), 93 deletions(-) create mode 100644 .github/actions/create-sysroot/action.yml create mode 100644 .github/actions/init-platform-variables/action.yml create mode 100644 .github/workflows/test-cross-compile.yml create mode 100644 test/hotspot/jtreg/ProblemList-GHA.txt create mode 100644 test/jdk/ProblemList-GHA.txt create mode 100644 test/langtools/ProblemList-GHA.txt diff --git a/.github/actions/create-sysroot/action.yml b/.github/actions/create-sysroot/action.yml new file mode 100644 index 0000000000000..5c2433776e503 --- /dev/null +++ b/.github/actions/create-sysroot/action.yml @@ -0,0 +1,83 @@ +# +# 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. 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: 'Create sysroot' +description: 'Create the sysroot to cross-compile and test the OpenJDK' +inputs: + target-cpu: + description: 'Target CPU architecture' + required: true + gnu-arch: + description: 'GNU CPU architecture' + required: true + debian-arch: + description: 'Debian CPU architecture' + required: true + debian-repository: + description: 'Debian repository' + required: true + debian-version: + description: 'Debian version' + required: true + debian-keyring: + description: 'Debian keyring' + required: false + +runs: + using: composite + steps: + - name: 'Check cache for sysroot' + id: get-cached-sysroot + uses: actions/cache@v3 + with: + path: sysroot + key: sysroot-${{ inputs.debian-arch }}-${{ inputs.debian-version }}-${{ hashFiles('./.github/actions/create-sysroot/action.yml') }} + + - name: 'Install sysroot dependencies' + run: sudo apt-get install debootstrap qemu-user-static + shell: bash + if: steps.get-cached-sysroot.outputs.cache-hit != 'true' + + - name: 'Create sysroot' + run: > + sudo qemu-debootstrap + --arch=${{ inputs.debian-arch }} + --verbose + --include=fakeroot,symlinks,build-essential,make,libx11-dev,libxext-dev,libxrender-dev,libxrandr-dev,libxtst-dev,libxt-dev,libcups2-dev,libfontconfig1-dev,libasound2-dev,libfreetype6-dev,libpng-dev,libatomic1 + --resolve-deps + $(test -n "${{ inputs.debian-keyring }}" && echo "--keyring=${{ inputs.debian-keyring }}") + ${{ inputs.debian-version }} + sysroot + ${{ inputs.debian-repository }} + shell: bash + if: steps.get-cached-sysroot.outputs.cache-hit != 'true' + + - name: 'Prepare sysroot' + run: | + # Prepare sysroot and remove unused files to minimize cache + sudo chroot sysroot symlinks -cr . + sudo rm -rf sysroot/{dev,proc,run,sys} + shell: bash + if: steps.get-cached-sysroot.outputs.cache-hit != 'true' diff --git a/.github/actions/get-bundles/action.yml b/.github/actions/get-bundles/action.yml index ba22b16706943..07f09ba5e5d76 100644 --- a/.github/actions/get-bundles/action.yml +++ b/.github/actions/get-bundles/action.yml @@ -32,6 +32,10 @@ inputs: debug-suffix: description: 'File name suffix denoting debug level, possibly empty' required: false + path: + description: 'Path to the installed JDK bundle' + required: false + default: 'bundles' outputs: jdk-path: description: 'Path to the installed JDK bundle' @@ -51,40 +55,40 @@ runs: uses: actions/download-artifact@v3 with: name: bundles-${{ inputs.platform }}${{ inputs.debug-suffix }} - path: bundles + path: ${{ inputs.path }} continue-on-error: true - name: 'Download bundles artifact (retry)' uses: actions/download-artifact@v3 with: name: bundles-${{ inputs.platform }}${{ inputs.debug-suffix }} - path: bundles + path: ${{ inputs.path }} if: steps.download-bundles.outcome == 'failure' - name: 'Unpack bundles' run: | - if [[ -e bundles/jdk-${{ inputs.platform }}${{ inputs.debug-suffix }}.zip ]]; then + if [[ -e ${{ inputs.path }}/jdk-${{ inputs.platform }}${{ inputs.debug-suffix }}.zip ]]; then echo 'Unpacking jdk bundle...' - mkdir -p bundles/jdk - unzip -q bundles/jdk-${{ inputs.platform }}${{ inputs.debug-suffix }}.zip -d bundles/jdk + mkdir -p ${{ inputs.path }}/jdk + unzip -q ${{ inputs.path }}/jdk-${{ inputs.platform }}${{ inputs.debug-suffix }}.zip -d ${{ inputs.path }}/jdk fi - if [[ -e bundles/jdk-${{ inputs.platform }}${{ inputs.debug-suffix }}.tar.gz ]]; then + if [[ -e ${{ inputs.path }}/jdk-${{ inputs.platform }}${{ inputs.debug-suffix }}.tar.gz ]]; then echo 'Unpacking jdk bundle...' - mkdir -p bundles/jdk - tar -xf bundles/jdk-${{ inputs.platform }}${{ inputs.debug-suffix }}.tar.gz -C bundles/jdk + mkdir -p ${{ inputs.path }}/jdk + tar -xf ${{ inputs.path }}/jdk-${{ inputs.platform }}${{ inputs.debug-suffix }}.tar.gz -C ${{ inputs.path }}/jdk fi - if [[ -e bundles/symbols-${{ inputs.platform }}${{ inputs.debug-suffix }}.tar.gz ]]; then + if [[ -e ${{ inputs.path }}/symbols-${{ inputs.platform }}${{ inputs.debug-suffix }}.tar.gz ]]; then echo 'Unpacking symbols bundle...' - mkdir -p bundles/symbols - tar -xf bundles/symbols-${{ inputs.platform }}${{ inputs.debug-suffix }}.tar.gz -C bundles/symbols + mkdir -p ${{ inputs.path }}/symbols + tar -xf ${{ inputs.path }}/symbols-${{ inputs.platform }}${{ inputs.debug-suffix }}.tar.gz -C ${{ inputs.path }}/symbols fi - if [[ -e bundles/tests-${{ inputs.platform }}${{ inputs.debug-suffix }}.tar.gz ]]; then + if [[ -e ${{ inputs.path }}/tests-${{ inputs.platform }}${{ inputs.debug-suffix }}.tar.gz ]]; then echo 'Unpacking tests bundle...' - mkdir -p bundles/tests - tar -xf bundles/tests-${{ inputs.platform }}${{ inputs.debug-suffix }}.tar.gz -C bundles/tests + mkdir -p ${{ inputs.path }}/tests + tar -xf ${{ inputs.path }}/tests-${{ inputs.platform }}${{ inputs.debug-suffix }}.tar.gz -C ${{ inputs.path }}/tests fi shell: bash @@ -93,9 +97,9 @@ runs: run: | # Export the paths - jdk_dir="$GITHUB_WORKSPACE/$(dirname $(find bundles/jdk -name bin -type d))" - symbols_dir="$GITHUB_WORKSPACE/$(dirname $(find bundles/symbols -name bin -type d))" - tests_dir="$GITHUB_WORKSPACE/bundles/tests" + jdk_dir="$GITHUB_WORKSPACE/$(dirname $(find ${{ inputs.path }}/jdk -name bin -type d))" + symbols_dir="$GITHUB_WORKSPACE/$(dirname $(find ${{ inputs.path }}/symbols -name bin -type d))" + tests_dir="$GITHUB_WORKSPACE/${{ inputs.path }}/tests" if [[ '${{ runner.os }}' == 'Windows' ]]; then jdk_dir="$(cygpath $jdk_dir)" diff --git a/.github/actions/init-platform-variables/action.yml b/.github/actions/init-platform-variables/action.yml new file mode 100644 index 0000000000000..8e50dee72efd4 --- /dev/null +++ b/.github/actions/init-platform-variables/action.yml @@ -0,0 +1,94 @@ +# +# 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. 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: 'Initialize Platform Variables' +description: 'Initialize the platform-specific variables used for cross-compilation' +inputs: + platform: + description: 'Target Platform' + required: true +outputs: + target-cpu: + description: 'Target CPU Archictecture' + value: ${{ steps.platform-variables.outputs.target-cpu }} + gnu-arch: + description: 'Target GNU Architecture' + value: ${{ steps.platform-variables.outputs.gnu-arch }} + debian-arch: + description: 'Target Debian Architecture' + value: ${{ steps.platform-variables.outputs.debian-arch }} + debian-repository: + description: 'Target Debian Repository' + value: ${{ steps.platform-variables.outputs.debian-repository }} + debian-version: + description: 'Target Debian Version' + value: ${{ steps.platform-variables.outputs.debian-version }} + gnu-abi: + description: 'Target GNU ABI' + value: ${{ steps.platform-variables.outputs.gnu-abi }} + +runs: + using: composite + steps: + - name: 'Initialize platform variables' + id: platform-variables + run: | + if [[ '${{ inputs.platform }}' == 'linux-aarch64' ]]; then + echo '::set-output name=target-cpu::aarch64' + echo '::set-output name=gnu-arch::aarch64' + echo '::set-output name=debian-arch::arm64' + echo '::set-output name=debian-repository::https://httpredir.debian.org/debian/' + echo '::set-output name=debian-version::bullseye' + elif [[ '${{ inputs.platform }}' == 'linux-arm' ]]; then + echo '::set-output name=target-cpu::arm' + echo '::set-output name=gnu-arch::arm' + echo '::set-output name=gnu-abi::eabihf' + echo '::set-output name=debian-arch::armhf' + echo '::set-output name=debian-repository::https://httpredir.debian.org/debian/' + echo '::set-output name=debian-version::bullseye' + elif [[ '${{ inputs.platform }}' == 'linux-s390x' ]]; then + echo '::set-output name=target-cpu::s390x' + echo '::set-output name=gnu-arch::s390x' + echo '::set-output name=debian-arch::s390x' + echo '::set-output name=debian-repository::https://httpredir.debian.org/debian/' + echo '::set-output name=debian-version::bullseye' + elif [[ '${{ inputs.platform }}' == 'linux-ppc64le' ]]; then + echo '::set-output name=target-cpu::ppc64le' + echo '::set-output name=gnu-arch::powerpc64le' + echo '::set-output name=debian-arch::ppc64el' + echo '::set-output name=debian-repository::https://httpredir.debian.org/debian/' + echo '::set-output name=debian-version::bullseye' + elif [[ '${{ inputs.platform }}' == 'linux-riscv64' ]]; then + echo '::set-output name=target-cpu::riscv64' + echo '::set-output name=gnu-arch::riscv64' + echo '::set-output name=debian-arch::riscv64' + echo '::set-output name=debian-repository::https://deb.debian.org/debian-ports' + echo '::set-output name=debian-keyring::/usr/share/keyrings/debian-ports-archive-keyring.gpg' + echo '::set-output name=debian-version::sid' + else + echo "Unknown platform ${{ inputs.platform }}" + exit 1 + fi + shell: bash diff --git a/.github/workflows/build-cross-compile.yml b/.github/workflows/build-cross-compile.yml index fc482f49a7fb5..bcc5fba0aae8a 100644 --- a/.github/workflows/build-cross-compile.yml +++ b/.github/workflows/build-cross-compile.yml @@ -28,6 +28,9 @@ name: 'Build (cross-compile)' on: workflow_call: inputs: + platform: + required: true + type: string gcc-major-version: required: true type: string @@ -40,6 +43,14 @@ on: extra-conf-options: required: false type: string + make-target: + required: false + type: string + default: 'product-bundles test-bundles' + debug-levels: + required: false + type: string + default: '[ "debug", "release" ]' jobs: build-cross-compile: @@ -49,40 +60,11 @@ jobs: strategy: fail-fast: false matrix: - target-cpu: - - aarch64 - - arm - - s390x - - ppc64le - - riscv64 + debug-level: ${{ fromJSON(inputs.debug-levels) }} include: - - target-cpu: aarch64 - gnu-arch: aarch64 - debian-arch: arm64 - debian-repository: https://httpredir.debian.org/debian/ - debian-version: bullseye - - target-cpu: arm - gnu-arch: arm - debian-arch: armhf - debian-repository: https://httpredir.debian.org/debian/ - debian-version: bullseye - gnu-abi: eabihf - - target-cpu: s390x - gnu-arch: s390x - debian-arch: s390x - debian-repository: https://httpredir.debian.org/debian/ - debian-version: bullseye - - target-cpu: ppc64le - gnu-arch: powerpc64le - debian-arch: ppc64el - debian-repository: https://httpredir.debian.org/debian/ - debian-version: bullseye - - target-cpu: riscv64 - gnu-arch: riscv64 - debian-arch: riscv64 - debian-repository: https://deb.debian.org/debian-ports - debian-keyring: /usr/share/keyrings/debian-ports-archive-keyring.gpg - debian-version: sid + - debug-level: debug + flags: --with-debug-level=fastdebug + suffix: -debug steps: - name: 'Checkout the JDK source' @@ -94,12 +76,27 @@ jobs: with: platform: linux-x64 + - name: 'Get JTReg' + id: jtreg + uses: ./.github/actions/get-jtreg + + - name: 'Get GTest' + id: gtest + uses: ./.github/actions/get-gtest + # Use linux-x64 JDK bundle as build JDK - name: 'Get build JDK' id: buildjdk uses: ./.github/actions/get-bundles with: platform: linux-x64 + path: buildjdk + + - name: 'Initialize platform variables' + id: platform-variables + uses: ./.github/actions/init-platform-variables + with: + platform: ${{ inputs.platform }} # Upgrading apt to solve libc6 installation bugs, see JDK-8260460. - name: 'Install toolchain and dependencies' @@ -110,58 +107,39 @@ jobs: sudo apt-get install \ gcc-${{ inputs.gcc-major-version }}=${{ inputs.apt-gcc-version }} \ g++-${{ inputs.gcc-major-version }}=${{ inputs.apt-gcc-version }} \ - gcc-${{ inputs.gcc-major-version }}-${{ matrix.gnu-arch }}-linux-gnu${{ matrix.gnu-abi}}=${{ inputs.apt-gcc-cross-version }} \ - g++-${{ inputs.gcc-major-version }}-${{ matrix.gnu-arch }}-linux-gnu${{ matrix.gnu-abi}}=${{ inputs.apt-gcc-cross-version }} \ + gcc-${{ inputs.gcc-major-version }}-${{ steps.platform-variables.outputs.gnu-arch }}-linux-gnu${{ steps.platform-variables.outputs.gnu-abi }}=${{ inputs.apt-gcc-cross-version }} \ + g++-${{ inputs.gcc-major-version }}-${{ steps.platform-variables.outputs.gnu-arch }}-linux-gnu${{ steps.platform-variables.outputs.gnu-abi }}=${{ inputs.apt-gcc-cross-version }} \ libxrandr-dev libxtst-dev libcups2-dev libasound2-dev \ debian-ports-archive-keyring sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${{ inputs.gcc-major-version }} 100 --slave /usr/bin/g++ g++ /usr/bin/g++-${{ inputs.gcc-major-version }} - - name: 'Check cache for sysroot' - id: get-cached-sysroot - uses: actions/cache@v3 - with: - path: sysroot - key: sysroot-${{ matrix.debian-arch }}-${{ hashFiles('./.github/workflows/build-cross-compile.yml') }} - - - name: 'Install sysroot dependencies' - run: sudo apt-get install debootstrap qemu-user-static - if: steps.get-cached-sysroot.outputs.cache-hit != 'true' - - name: 'Create sysroot' - run: > - sudo qemu-debootstrap - --arch=${{ matrix.debian-arch }} - --verbose - --include=fakeroot,symlinks,build-essential,libx11-dev,libxext-dev,libxrender-dev,libxrandr-dev,libxtst-dev,libxt-dev,libcups2-dev,libfontconfig1-dev,libasound2-dev,libfreetype6-dev,libpng-dev - --resolve-deps - $(test -n "${{ matrix.debian-keyring }}" && echo "--keyring=${{ matrix.debian-keyring }}") - ${{ matrix.debian-version }} - sysroot - ${{ matrix.debian-repository }} - if: steps.get-cached-sysroot.outputs.cache-hit != 'true' - - - name: 'Prepare sysroot' - run: | - # Prepare sysroot and remove unused files to minimize cache - sudo chroot sysroot symlinks -cr . - sudo chown ${USER} -R sysroot - rm -rf sysroot/{dev,proc,run,sys} - if: steps.get-cached-sysroot.outputs.cache-hit != 'true' + uses: ./.github/actions/create-sysroot + with: + target-cpu: ${{ steps.platform-variables.outputs.target-cpu }} + gnu-arch: ${{ steps.platform-variables.outputs.gnu-arch }} + debian-arch: ${{ steps.platform-variables.outputs.debian-arch }} + debian-repository: ${{ steps.platform-variables.outputs.debian-repository }} + debian-version: ${{ steps.platform-variables.outputs.debian-version }} + debian-keyring: ${{ steps.platform-variables.outputs.debian-keyring }} - name: 'Configure' run: > bash configure - --with-conf-name=linux-${{ matrix.target-cpu }} + --with-conf-name=linux-${{ steps.platform-variables.outputs.target-cpu }} + ${{ matrix.flags }} --with-version-opt=${GITHUB_ACTOR}-${GITHUB_SHA} --with-boot-jdk=${{ steps.bootjdk.outputs.path }} + --with-jtreg=${{ steps.jtreg.outputs.path }} + --with-gtest=${{ steps.gtest.outputs.path }} + --enable-jtreg-failure-handler --with-zlib=system - --enable-debug --disable-precompiled-headers - --openjdk-target=${{ matrix.gnu-arch }}-linux-gnu${{ matrix.gnu-abi}} + --openjdk-target=${{ steps.platform-variables.outputs.gnu-arch }}-linux-gnu${{ steps.platform-variables.outputs.gnu-abi }} --with-sysroot=sysroot --with-build-jdk=${{ steps.buildjdk.outputs.jdk-path }} - CC=${{ matrix.gnu-arch }}-linux-gnu${{ matrix.gnu-abi}}-gcc-${{ inputs.gcc-major-version }} - CXX=${{ matrix.gnu-arch }}-linux-gnu${{ matrix.gnu-abi}}-g++-${{ inputs.gcc-major-version }} + CC=${{ steps.platform-variables.outputs.gnu-arch }}-linux-gnu${{ steps.platform-variables.outputs.gnu-abi }}-gcc-${{ inputs.gcc-major-version }} + CXX=${{ steps.platform-variables.outputs.gnu-arch }}-linux-gnu${{ steps.platform-variables.outputs.gnu-abi }}-g++-${{ inputs.gcc-major-version }} ${{ inputs.extra-conf-options }} || ( echo "Dumping config.log:" && cat config.log && @@ -171,5 +149,12 @@ jobs: id: build uses: ./.github/actions/do-build with: - make-target: 'hotspot' - platform: linux-${{ matrix.target-cpu }} + make-target: '${{ inputs.make-target }}' + platform: '${{ inputs.platform }}' + debug-suffix: '${{ matrix.suffix }}' + + - name: 'Upload bundles' + uses: ./.github/actions/upload-bundles + with: + platform: '${{ inputs.platform }}' + debug-suffix: '${{ matrix.suffix }}' diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ebd7cc687666c..edcab37927c9b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -28,7 +28,6 @@ name: 'OpenJDK GHA Sanity Checks' on: push: branches-ignore: - - master - pr/* workflow_dispatch: inputs: @@ -197,13 +196,66 @@ jobs: extra-conf-options: '--with-debug-level=optimized --disable-precompiled-headers' if: needs.select.outputs.linux-x64-variants == 'true' - build-linux-cross-compile: - name: linux-cross-compile + build-linux-aarch64: + name: linux-aarch64 needs: - select - build-linux-x64 uses: ./.github/workflows/build-cross-compile.yml with: + platform: linux-aarch64 + gcc-major-version: '10' + apt-gcc-version: '10.3.0-15ubuntu1' + apt-gcc-cross-version: '10.3.0-8ubuntu1cross1' + if: needs.select.outputs.linux-cross-compile == 'true' + + build-linux-arm: + name: linux-arm + needs: + - select + - build-linux-x64 + uses: ./.github/workflows/build-cross-compile.yml + with: + platform: linux-arm + gcc-major-version: '10' + apt-gcc-version: '10.3.0-15ubuntu1' + apt-gcc-cross-version: '10.3.0-8ubuntu1cross1' + if: needs.select.outputs.linux-cross-compile == 'true' + + build-linux-ppc64le: + name: linux-ppc64le + needs: + - select + - build-linux-x64 + uses: ./.github/workflows/build-cross-compile.yml + with: + platform: linux-ppc64le + gcc-major-version: '10' + apt-gcc-version: '10.3.0-15ubuntu1' + apt-gcc-cross-version: '10.3.0-8ubuntu1cross1' + if: needs.select.outputs.linux-cross-compile == 'true' + + build-linux-riscv64: + name: linux-riscv64 + needs: + - select + - build-linux-x64 + uses: ./.github/workflows/build-cross-compile.yml + with: + platform: linux-riscv64 + gcc-major-version: '10' + apt-gcc-version: '10.3.0-15ubuntu1' + apt-gcc-cross-version: '10.3.0-8ubuntu1cross1' + if: needs.select.outputs.linux-cross-compile == 'true' + + build-linux-s390x: + name: linux-s390x + needs: + - select + - build-linux-x64 + uses: ./.github/workflows/build-cross-compile.yml + with: + platform: linux-s390x gcc-major-version: '10' apt-gcc-version: '10.3.0-15ubuntu1' apt-gcc-cross-version: '10.3.0-8ubuntu1cross1' @@ -274,6 +326,57 @@ jobs: bootjdk-platform: linux-x64 runs-on: ubuntu-22.04 + test-linux-aarch64: + name: linux-aarch64 + needs: + - build-linux-aarch64 + uses: ./.github/workflows/test-cross-compile.yml + with: + platform: linux-aarch64 + bootjdk-platform: linux-x64 + runs-on: ubuntu-22.04 + + # test-linux-arm: + # name: linux-arm + # needs: + # - build-linux-arm + # uses: ./.github/workflows/test-cross-compile.yml + # with: + # platform: linux-arm + # bootjdk-platform: linux-x64 + # runs-on: ubuntu-22.04 + # if: EXTRA_TEST_PLATFORMS == 'true' + + # test-linux-ppc64le: + # name: linux-ppc64le + # needs: + # - build-linux-ppc64le + # uses: ./.github/workflows/test-cross-compile.yml + # with: + # platform: linux-ppc64le + # bootjdk-platform: linux-x64 + # runs-on: ubuntu-22.04 + + test-linux-riscv64: + name: linux-riscv64 + needs: + - build-linux-riscv64 + uses: ./.github/workflows/test-cross-compile.yml + with: + platform: linux-riscv64 + bootjdk-platform: linux-x64 + runs-on: ubuntu-22.04 + + # test-linux-s390x: + # name: linux-s390x + # needs: + # - build-linux-s390x + # uses: ./.github/workflows/test-cross-compile.yml + # with: + # platform: linux-s390x + # bootjdk-platform: linux-x64 + # runs-on: ubuntu-22.04 + test-macos-x64: name: macos-x64 needs: @@ -306,13 +409,22 @@ jobs: - build-linux-x64-hs-zero - build-linux-x64-hs-minimal - build-linux-x64-hs-optimized - - build-linux-cross-compile + - build-linux-aarch64 + - build-linux-arm + - build-linux-s390x + - build-linux-ppc64le + - build-linux-riscv64 - build-macos-x64 - build-macos-aarch64 - build-windows-x64 - build-windows-aarch64 - test-linux-x64 - test-linux-x86 + - test-linux-aarch64 + # - test-linux-arm + # - test-linux-ppc64le + - test-linux-riscv64 + # - test-linux-s390x - test-macos-x64 - test-windows-x64 diff --git a/.github/workflows/test-cross-compile.yml b/.github/workflows/test-cross-compile.yml new file mode 100644 index 0000000000000..d43d362fd6316 --- /dev/null +++ b/.github/workflows/test-cross-compile.yml @@ -0,0 +1,238 @@ +# +# 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. 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: 'Run tests (cross-compile)' + +on: + workflow_call: + inputs: + platform: + required: true + type: string + bootjdk-platform: + required: true + type: string + runs-on: + required: true + type: string + +jobs: + test: + name: test + runs-on: ${{ inputs.runs-on }} + defaults: + run: + shell: bash + + strategy: + fail-fast: false + matrix: + test-name: + - 'jdk/tier1 part 1' + - 'jdk/tier1 part 2' + - 'jdk/tier1 part 3' + - 'langtools/tier1' + - 'hs/tier1 common' + - 'hs/tier1 compiler 1' + - 'hs/tier1 compiler 2' + - 'hs/tier1 compiler 3' + - 'hs/tier1 compiler not xcomp' + - 'hs/tier1 gc' + - 'hs/tier1 runtime' + - 'hs/tier1 serviceability' + + include: + - test-name: 'jdk/tier1 part 1' + test-suite: 'test/jdk/:tier1_part1' + + - test-name: 'jdk/tier1 part 2' + test-suite: 'test/jdk/:tier1_part2' + + - test-name: 'jdk/tier1 part 3' + test-suite: 'test/jdk/:tier1_part3' + + - test-name: 'langtools/tier1' + test-suite: 'test/langtools/:tier1' + + - test-name: 'hs/tier1 common' + test-suite: 'test/hotspot/jtreg/:tier1_common' + debug-suffix: -debug + + - test-name: 'hs/tier1 compiler 1' + test-suite: 'test/hotspot/jtreg/:tier1_compiler_1' + debug-suffix: -debug + + - test-name: 'hs/tier1 compiler 2' + test-suite: 'test/hotspot/jtreg/:tier1_compiler_2' + debug-suffix: -debug + + - test-name: 'hs/tier1 compiler 3' + test-suite: 'test/hotspot/jtreg/:tier1_compiler_3' + debug-suffix: -debug + + - test-name: 'hs/tier1 compiler not xcomp' + test-suite: 'test/hotspot/jtreg/:tier1_compiler_not_xcomp' + debug-suffix: -debug + + - test-name: 'hs/tier1 gc' + test-suite: 'test/hotspot/jtreg/:tier1_gc' + debug-suffix: -debug + + - test-name: 'hs/tier1 runtime' + test-suite: 'test/hotspot/jtreg/:tier1_runtime' + debug-suffix: -debug + + - test-name: 'hs/tier1 serviceability' + test-suite: 'test/hotspot/jtreg/:tier1_serviceability' + debug-suffix: -debug + + steps: + - name: 'Checkout the JDK source' + uses: actions/checkout@v3 + + - name: 'Initialize platform variables' + id: platform-variables + uses: ./.github/actions/init-platform-variables + with: + platform: ${{ inputs.platform }} + + - name: 'Get the BootJDK' + id: bootjdk + uses: ./.github/actions/get-bootjdk + with: + platform: ${{ inputs.bootjdk-platform }} + + - name: 'Get JTReg' + id: jtreg + uses: ./.github/actions/get-jtreg + + - name: 'Get bundles' + id: bundles + uses: ./.github/actions/get-bundles + with: + platform: ${{ inputs.platform }} + debug-suffix: ${{ matrix.debug-suffix }} + + - name: 'Install dependencies' + run: | + sudo apt-get update + sudo apt-get install qemu-user-static + + - name: 'Create sysroot' + uses: ./.github/actions/create-sysroot + with: + target-cpu: ${{ steps.platform-variables.outputs.target-cpu }} + gnu-arch: ${{ steps.platform-variables.outputs.gnu-arch }} + debian-arch: ${{ steps.platform-variables.outputs.debian-arch }} + debian-repository: ${{ steps.platform-variables.outputs.debian-repository }} + debian-version: sid # it's necessary to get libc 2.34 + debian-keyring: ${{ steps.platform-variables.outputs.debian-keyring }} + + - name: 'Mount folders in sysroot' + run: | + sudo mkdir -p sysroot/dev sysroot/proc sysroot/run sysroot/sys sysroot/usr/lib64 sysroot/usr/lib/x86_64-linux-gnu sysroot/home/runner + sudo ln -s -r sysroot/usr/lib64 sysroot/lib64 + sudo chown $(id -u):$(id -g) sysroot/home/runner + sudo mount --bind /dev sysroot/dev + sudo mount --bind /proc sysroot/proc + sudo mount --bind /run sysroot/run + sudo mount --bind /sys sysroot/sys + sudo mount --bind /usr/lib64 sysroot/usr/lib64 + sudo mount --bind /usr/lib/x86_64-linux-gnu sysroot/usr/lib/x86_64-linux-gnu + sudo mount --bind /home/runner sysroot/home/runner + + - name: 'Run tests' + id: run-tests + run: > + sudo chroot --userspec=$(id -u):$(id -g) sysroot bash -x -c " + cd $GITHUB_WORKSPACE; + make test-prebuilt + TEST='${{ matrix.test-suite }}' + BOOT_JDK=${{ steps.bootjdk.outputs.path }} + JT_HOME=${{ steps.jtreg.outputs.path }} + JDK_IMAGE_DIR=${{ steps.bundles.outputs.jdk-path }} + SYMBOLS_IMAGE_DIR=${{ steps.bundles.outputs.symbols-path }} + TEST_IMAGE_DIR=${{ steps.bundles.outputs.tests-path }} + JTREG='JAVA_OPTIONS=-XX:-CreateCoredumpOnCrash;VERBOSE=fail,error,time;KEYWORDS=!headful' + JTREG_EXTRA_PROBLEM_LISTS='ProblemList-GHA.txt' + && bash ./.github/scripts/gen-test-summary.sh "$GITHUB_STEP_SUMMARY" + " + + - name: 'Umount folders in sysroot' + run: | + sudo rm sysroot/lib64 + sudo umount -l sysroot/dev + sudo umount -l sysroot/proc + sudo umount -l sysroot/run + sudo umount -l sysroot/sys + sudo umount -l sysroot/usr/lib64 + sudo umount -l sysroot/usr/lib/x86_64-linux-gnu + sudo umount -l sysroot/home/runner + + # This is a separate step, since if the markdown from a step gets bigger than + # 1024 kB it is skipped, but then the short summary above is still generated + - name: 'Generate test report' + run: bash ./.github/scripts/gen-test-results.sh "$GITHUB_STEP_SUMMARY" + if: always() + + - name: 'Package test results' + id: package + run: | + # Package test-results and relevant parts of test-support + mkdir results + + if [[ -d build/run-test-prebuilt/test-results ]]; then + cd build/run-test-prebuilt/test-results/ + zip -r -9 "$GITHUB_WORKSPACE/results/test-results.zip" . + cd $GITHUB_WORKSPACE + else + echo '::warning ::Missing test-results directory' + fi + + if [[ -d build/run-test-prebuilt/test-support ]]; then + cd build/run-test-prebuilt/test-support/ + zip -r -9 "$GITHUB_WORKSPACE/results/test-support.zip" . -i *.jtr -i */hs_err*.log -i */replay*.log + cd $GITHUB_WORKSPACE + else + echo '::warning ::Missing test-support directory' + fi + + artifact_name="results-${{ inputs.platform }}-$(echo ${{ matrix.test-name }} | tr '/ ' '__')" + echo "::set-output name=artifact-name::$artifact_name" + if: always() + + - name: 'Upload test results' + uses: actions/upload-artifact@v3 + with: + path: results + name: ${{ steps.package.outputs.artifact-name }} + if: always() + + # This is the best way I found to abort the job with an error message + - name: 'Notify about test failures' + uses: actions/github-script@v6 + with: + script: core.setFailed('${{ steps.run-tests.outputs.error-message }}') + if: always() && steps.run-tests.outputs.failure == 'true' diff --git a/test/hotspot/jtreg/ProblemList-GHA.txt b/test/hotspot/jtreg/ProblemList-GHA.txt new file mode 100644 index 0000000000000..2b72b467a6dbb --- /dev/null +++ b/test/hotspot/jtreg/ProblemList-GHA.txt @@ -0,0 +1,88 @@ +# +# Copyright (c) 2022, Rivos 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. +# + +# :tier1_common + +gtest/GTestWrapper.java 0 linux-riscv64 +gtest/LargePageGtests.java#use-large-pages 0 linux-riscv64 +gtest/LargePageGtests.java#use-large-pages-1G 0 linux-riscv64 +gtest/LargePageGtests.java#use-large-pages-sysV 0 linux-riscv64 +gtest/NMTGtests.java#nmt-detail 0 linux-riscv64 +gtest/NMTGtests.java#nmt-off 0 linux-riscv64 +gtest/NMTGtests.java#nmt-summary 0 linux-riscv64 + +# :tier1_serviceability + +serviceability/dcmd/framework/HelpTest.java 0 linux-aarch64,linux-riscv64 +serviceability/dcmd/framework/InvalidCommandTest.java 0 linux-aarch64,linux-riscv64 +serviceability/dcmd/framework/VMVersionTest.java 0 linux-aarch64,linux-riscv64 +serviceability/tmtools/jstat/GcCapacityTest.java 0 linux-aarch64,linux-riscv64 +serviceability/tmtools/jstat/GcCauseTest01.java 0 linux-aarch64,linux-riscv64 +serviceability/tmtools/jstat/GcCauseTest02.java 0 linux-aarch64,linux-riscv64 +serviceability/tmtools/jstat/GcCauseTest03.java 0 linux-aarch64,linux-riscv64 +serviceability/tmtools/jstat/GcNewTest.java 0 linux-aarch64,linux-riscv64 +serviceability/tmtools/jstat/GcTest01.java 0 linux-aarch64,linux-riscv64 +serviceability/tmtools/jstat/GcTest02.java 0 linux-aarch64,linux-riscv64 + +# :tier1_gc + +gc/arguments/TestNewRatioFlag.java 0 linux-aarch64 +gc/arguments/TestUseCompressedOopsFlagsWithUlimit.java 0 linux-aarch64,linux-riscv64 +gc/g1/humongousObjects/TestHumongousClassLoader.java 0 linux-aarch64,linux-riscv64 +gc/shenandoah/options/TestThreadCounts.java 0 linux-aarch64 +gc/stringdedup/TestStringDeduplicationAgeThreshold.java#Z 0 linux-aarch64 + +# :tier1_runtime + +runtime/cds/CheckDefaultArchiveFile.java 0 linux-aarch64,linux-riscv64 +runtime/CreateMirror/ArraysNewInstanceBug.java 0 linux-aarch64 +runtime/LoadClass/LongBCP.java 0 linux-aarch64,linux-riscv64 +runtime/NMT/CheckForProperDetailStackTrace.java 0 linux-aarch64 +runtime/NMT/CommitOverlappingRegions.java 0 linux-aarch64 +runtime/NMT/NMTInitializationTest.java#default_long-detail 0 linux-aarch64 +runtime/NMT/NMTInitializationTest.java#normal-detail 0 linux-aarch64 +runtime/NMT/PrintNMTStatistics.java 0 linux-aarch64 +runtime/NMT/VirtualAllocCommitMerge.java 0 linux-aarch64 +runtime/NMT/VirtualAllocCommitUncommitRecommit.java 0 linux-aarch64 +runtime/os/TestTracePageSizes.java#compiler-options 0 linux-riscv64 +runtime/os/TestTracePageSizes.java#G1 0 linux-riscv64 +runtime/os/TestTracePageSizes.java#Parallel 0 linux-riscv64 +runtime/os/TestTracePageSizes.java#Serial 0 linux-riscv64 +runtime/posixSig/TestPosixSig.java 0 linux-riscv64 + +# :tier1_compiler + +compiler/blackhole/BlackholeIntrinsicTest.java 0 linux-aarch64,linux-riscv64 +compiler/c2/irTests/TestAutoVectorization2DArray.java 0 linux-riscv64 +compiler/c2/irTests/TestFPComparison.java 0 linux-riscv64 +compiler/c2/irTests/TestVectorizeURShiftSubword.java 0 linux-aarch64 +compiler/c2/TestShiftRightAndAccumulate.java#id0 0 linux-aarch64 +compiler/c2/TestShiftRightAndAccumulate.java#id0 0 linux-aarch64 +compiler/c2/TestShiftRightAndAccumulate.java#id0 0 linux-riscv64 +compiler/c2/TestStressRecompilation.java 0 linux-aarch64 +compiler/c2/TestStressRecompilation.java 0 linux-aarch64 +compiler/c2/TestStressRecompilation.java 0 linux-riscv64 +compiler/jvmci/compilerToVM/IterateFramesNative.java 0 linux-aarch64 +compiler/loopopts/TestUnreachableInnerLoop.java 0 linux-riscv64 +compiler/runtime/safepoints/TestRegisterRestoring.java 0 linux-aarch64 +compiler/vectorization/TestAutoVecIntMinMax.java 0 linux-riscv64 diff --git a/test/jdk/ProblemList-GHA.txt b/test/jdk/ProblemList-GHA.txt new file mode 100644 index 0000000000000..d3ad7fc73d488 --- /dev/null +++ b/test/jdk/ProblemList-GHA.txt @@ -0,0 +1,39 @@ +# +# Copyright (c) 2022, Rivos 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. +# + +# :tier1_part1 + +java/lang/invoke/lambda/LambdaFileEncodingSerialization.java 0 linux-aarch64 +java/lang/invoke/lambda/LogGeneratedClassesTest.java 0 linux-aarch64,linux-riscv64 +java/lang/ProcessHandle/InfoTest.java 0 linux-aarch64,linux-riscv64 + +# :tier1_part2 + +java/util/concurrent/locks/Lock/TimedAcquireLeak.java 0 linux-riscv64 +java/util/concurrent/tck/JSR166TestCase.java 0 linux-riscv64 +java/util/DoubleSummaryStatistics/NegativeCompensation.java 0 linux-riscv64 +java/util/ServiceLoader/basic/ServiceLoaderBasicTest.java 0 linux-riscv64 + +# :tier1_part3 + +java/math/BigInteger/LargeValueExceptions.java 0 linux-aarch64 diff --git a/test/langtools/ProblemList-GHA.txt b/test/langtools/ProblemList-GHA.txt new file mode 100644 index 0000000000000..7954a890fca37 --- /dev/null +++ b/test/langtools/ProblemList-GHA.txt @@ -0,0 +1,32 @@ +# +# Copyright (c) 2022, Rivos 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. +# + +jdk/javadoc/tool/testLocaleOption/TestLocaleOption.java 0 linux-aarch64,linux-riscv64 +jdk/jshell/CommandCompletionTest.java 0 linux-aarch64,linux-riscv64 +jdk/jshell/CompletenessTest.java 0 linux-aarch64 +jdk/jshell/ForwardReferenceImportTest.java 0 linux-riscv64 +jdk/jshell/ModifiersTest.java 0 linux-aarch64 +jdk/jshell/ToolProviderTest.java 0 linux-aarch64,linux-riscv64 +jdk/jshell/ToolTabSnippetTest.java 0 linux-aarch64,linux-riscv64 +tools/javac/ClassPathTest/ClassPathTest.java 0 linux-riscv64 +tools/javac/main/EnvVariableTest.java 0 linux-aarch64 From c5a8f93c701ad982f423b6507e162928c21388e5 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Sat, 1 Oct 2022 13:41:13 +0200 Subject: [PATCH 16/85] Run tests on pull requests (#23) --- .github/workflows/main.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index edcab37927c9b..bcc6502b228af 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -26,9 +26,9 @@ name: 'OpenJDK GHA Sanity Checks' on: - push: - branches-ignore: - - pr/* + pull_request: + branches: + - rivos/main workflow_dispatch: inputs: platforms: @@ -78,7 +78,7 @@ jobs: if [[ $GITHUB_EVENT_NAME == workflow_dispatch ]]; then input='${{ github.event.inputs.platforms }}' - elif [[ $GITHUB_EVENT_NAME == push ]]; then + elif [[ $GITHUB_EVENT_NAME == push || $GITHUB_EVENT_NAME == pull_request ]]; then input='${{ secrets.JDK_SUBMIT_PLATFORMS }}' else echo 'Internal error in GHA' From 69ec20394ef53ca75fc10be053bd61d635dd352c Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Mon, 3 Oct 2022 09:43:41 +0200 Subject: [PATCH 17/85] Also run tests on push to rivos/main (#24) --- .github/workflows/main.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index bcc6502b228af..daff7738fa557 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -29,6 +29,9 @@ on: pull_request: branches: - rivos/main + push: + branches: + - rivos/main workflow_dispatch: inputs: platforms: From 06f274f05236285c133b1c8c414b2e5f9ac01eca Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Thu, 13 Oct 2022 09:38:03 +0200 Subject: [PATCH 18/85] Push upstream/master to master (#26) --- .github/workflows/downstream.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/downstream.yml b/.github/workflows/downstream.yml index 198e416650bcc..cfa9b225bfae6 100644 --- a/.github/workflows/downstream.yml +++ b/.github/workflows/downstream.yml @@ -63,12 +63,12 @@ jobs: run: | git push origin ${{ steps.fetch.outputs.tag }} - git checkout -B master ${{ steps.fetch.outputs.tag }} - git push origin master - git checkout -B rivos/merge-upstream ${{ steps.fetch.outputs.tag }} git push origin rivos/merge-upstream + git checkout -B master upstream/master + git push origin master + - name: "Create PR" run: | gh pr create \ From 4952ed4a032daf8994758fe3bfeae8cf026cb010 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Fri, 14 Oct 2022 18:47:14 +0200 Subject: [PATCH 19/85] Disable linux-aarch64 testing on GitHub CI (#28) It's delaying the results from CI --- .github/workflows/main.yml | 20 +++++------ test/hotspot/jtreg/ProblemList-GHA.txt | 48 ++++++++------------------ test/jdk/ProblemList-GHA.txt | 9 ++--- test/langtools/ProblemList-GHA.txt | 11 +++--- 4 files changed, 31 insertions(+), 57 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 41a48c0195f65..d8ebf682e2595 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -357,15 +357,15 @@ jobs: bootjdk-platform: linux-x64 runs-on: ubuntu-22.04 - test-linux-aarch64: - name: linux-aarch64 - needs: - - build-linux-aarch64 - uses: ./.github/workflows/test-cross-compile.yml - with: - platform: linux-aarch64 - bootjdk-platform: linux-x64 - runs-on: ubuntu-22.04 + # test-linux-aarch64: + # name: linux-aarch64 + # needs: + # - build-linux-aarch64 + # uses: ./.github/workflows/test-cross-compile.yml + # with: + # platform: linux-aarch64 + # bootjdk-platform: linux-x64 + # runs-on: ubuntu-22.04 # test-linux-arm: # name: linux-arm @@ -451,7 +451,7 @@ jobs: - build-windows-aarch64 - test-linux-x64 - test-linux-x86 - - test-linux-aarch64 + # - test-linux-aarch64 # - test-linux-arm # - test-linux-ppc64le - test-linux-riscv64 diff --git a/test/hotspot/jtreg/ProblemList-GHA.txt b/test/hotspot/jtreg/ProblemList-GHA.txt index 2b72b467a6dbb..d40ab6312c203 100644 --- a/test/hotspot/jtreg/ProblemList-GHA.txt +++ b/test/hotspot/jtreg/ProblemList-GHA.txt @@ -33,37 +33,26 @@ gtest/NMTGtests.java#nmt-summary 0 linux- # :tier1_serviceability -serviceability/dcmd/framework/HelpTest.java 0 linux-aarch64,linux-riscv64 -serviceability/dcmd/framework/InvalidCommandTest.java 0 linux-aarch64,linux-riscv64 -serviceability/dcmd/framework/VMVersionTest.java 0 linux-aarch64,linux-riscv64 -serviceability/tmtools/jstat/GcCapacityTest.java 0 linux-aarch64,linux-riscv64 -serviceability/tmtools/jstat/GcCauseTest01.java 0 linux-aarch64,linux-riscv64 -serviceability/tmtools/jstat/GcCauseTest02.java 0 linux-aarch64,linux-riscv64 -serviceability/tmtools/jstat/GcCauseTest03.java 0 linux-aarch64,linux-riscv64 -serviceability/tmtools/jstat/GcNewTest.java 0 linux-aarch64,linux-riscv64 -serviceability/tmtools/jstat/GcTest01.java 0 linux-aarch64,linux-riscv64 -serviceability/tmtools/jstat/GcTest02.java 0 linux-aarch64,linux-riscv64 +serviceability/dcmd/framework/HelpTest.java 0 linux-riscv64 +serviceability/dcmd/framework/InvalidCommandTest.java 0 linux-riscv64 +serviceability/dcmd/framework/VMVersionTest.java 0 linux-riscv64 +serviceability/tmtools/jstat/GcCapacityTest.java 0 linux-riscv64 +serviceability/tmtools/jstat/GcCauseTest01.java 0 linux-riscv64 +serviceability/tmtools/jstat/GcCauseTest02.java 0 linux-riscv64 +serviceability/tmtools/jstat/GcCauseTest03.java 0 linux-riscv64 +serviceability/tmtools/jstat/GcNewTest.java 0 linux-riscv64 +serviceability/tmtools/jstat/GcTest01.java 0 linux-riscv64 +serviceability/tmtools/jstat/GcTest02.java 0 linux-riscv64 # :tier1_gc -gc/arguments/TestNewRatioFlag.java 0 linux-aarch64 -gc/arguments/TestUseCompressedOopsFlagsWithUlimit.java 0 linux-aarch64,linux-riscv64 -gc/g1/humongousObjects/TestHumongousClassLoader.java 0 linux-aarch64,linux-riscv64 -gc/shenandoah/options/TestThreadCounts.java 0 linux-aarch64 -gc/stringdedup/TestStringDeduplicationAgeThreshold.java#Z 0 linux-aarch64 +gc/arguments/TestUseCompressedOopsFlagsWithUlimit.java 0 linux-riscv64 +gc/g1/humongousObjects/TestHumongousClassLoader.java 0 linux-riscv64 # :tier1_runtime -runtime/cds/CheckDefaultArchiveFile.java 0 linux-aarch64,linux-riscv64 -runtime/CreateMirror/ArraysNewInstanceBug.java 0 linux-aarch64 -runtime/LoadClass/LongBCP.java 0 linux-aarch64,linux-riscv64 -runtime/NMT/CheckForProperDetailStackTrace.java 0 linux-aarch64 -runtime/NMT/CommitOverlappingRegions.java 0 linux-aarch64 -runtime/NMT/NMTInitializationTest.java#default_long-detail 0 linux-aarch64 -runtime/NMT/NMTInitializationTest.java#normal-detail 0 linux-aarch64 -runtime/NMT/PrintNMTStatistics.java 0 linux-aarch64 -runtime/NMT/VirtualAllocCommitMerge.java 0 linux-aarch64 -runtime/NMT/VirtualAllocCommitUncommitRecommit.java 0 linux-aarch64 +runtime/cds/CheckDefaultArchiveFile.java 0 linux-riscv64 +runtime/LoadClass/LongBCP.java 0 linux-riscv64 runtime/os/TestTracePageSizes.java#compiler-options 0 linux-riscv64 runtime/os/TestTracePageSizes.java#G1 0 linux-riscv64 runtime/os/TestTracePageSizes.java#Parallel 0 linux-riscv64 @@ -72,17 +61,10 @@ runtime/posixSig/TestPosixSig.java 0 linux- # :tier1_compiler -compiler/blackhole/BlackholeIntrinsicTest.java 0 linux-aarch64,linux-riscv64 +compiler/blackhole/BlackholeIntrinsicTest.java 0 linux-riscv64 compiler/c2/irTests/TestAutoVectorization2DArray.java 0 linux-riscv64 compiler/c2/irTests/TestFPComparison.java 0 linux-riscv64 -compiler/c2/irTests/TestVectorizeURShiftSubword.java 0 linux-aarch64 -compiler/c2/TestShiftRightAndAccumulate.java#id0 0 linux-aarch64 -compiler/c2/TestShiftRightAndAccumulate.java#id0 0 linux-aarch64 compiler/c2/TestShiftRightAndAccumulate.java#id0 0 linux-riscv64 -compiler/c2/TestStressRecompilation.java 0 linux-aarch64 -compiler/c2/TestStressRecompilation.java 0 linux-aarch64 compiler/c2/TestStressRecompilation.java 0 linux-riscv64 -compiler/jvmci/compilerToVM/IterateFramesNative.java 0 linux-aarch64 compiler/loopopts/TestUnreachableInnerLoop.java 0 linux-riscv64 -compiler/runtime/safepoints/TestRegisterRestoring.java 0 linux-aarch64 compiler/vectorization/TestAutoVecIntMinMax.java 0 linux-riscv64 diff --git a/test/jdk/ProblemList-GHA.txt b/test/jdk/ProblemList-GHA.txt index d3ad7fc73d488..6a33f6c73ae35 100644 --- a/test/jdk/ProblemList-GHA.txt +++ b/test/jdk/ProblemList-GHA.txt @@ -23,9 +23,8 @@ # :tier1_part1 -java/lang/invoke/lambda/LambdaFileEncodingSerialization.java 0 linux-aarch64 -java/lang/invoke/lambda/LogGeneratedClassesTest.java 0 linux-aarch64,linux-riscv64 -java/lang/ProcessHandle/InfoTest.java 0 linux-aarch64,linux-riscv64 +java/lang/invoke/lambda/LogGeneratedClassesTest.java 0 linux-riscv64 +java/lang/ProcessHandle/InfoTest.java 0 linux-riscv64 # :tier1_part2 @@ -33,7 +32,3 @@ java/util/concurrent/locks/Lock/TimedAcquireLeak.java 0 linux- java/util/concurrent/tck/JSR166TestCase.java 0 linux-riscv64 java/util/DoubleSummaryStatistics/NegativeCompensation.java 0 linux-riscv64 java/util/ServiceLoader/basic/ServiceLoaderBasicTest.java 0 linux-riscv64 - -# :tier1_part3 - -java/math/BigInteger/LargeValueExceptions.java 0 linux-aarch64 diff --git a/test/langtools/ProblemList-GHA.txt b/test/langtools/ProblemList-GHA.txt index 7954a890fca37..63be191010333 100644 --- a/test/langtools/ProblemList-GHA.txt +++ b/test/langtools/ProblemList-GHA.txt @@ -21,12 +21,9 @@ # questions. # -jdk/javadoc/tool/testLocaleOption/TestLocaleOption.java 0 linux-aarch64,linux-riscv64 -jdk/jshell/CommandCompletionTest.java 0 linux-aarch64,linux-riscv64 -jdk/jshell/CompletenessTest.java 0 linux-aarch64 +jdk/javadoc/tool/testLocaleOption/TestLocaleOption.java 0 linux-riscv64 +jdk/jshell/CommandCompletionTest.java 0 linux-riscv64 jdk/jshell/ForwardReferenceImportTest.java 0 linux-riscv64 -jdk/jshell/ModifiersTest.java 0 linux-aarch64 -jdk/jshell/ToolProviderTest.java 0 linux-aarch64,linux-riscv64 -jdk/jshell/ToolTabSnippetTest.java 0 linux-aarch64,linux-riscv64 +jdk/jshell/ToolProviderTest.java 0 linux-riscv64 +jdk/jshell/ToolTabSnippetTest.java 0 linux-riscv64 tools/javac/ClassPathTest/ClassPathTest.java 0 linux-riscv64 -tools/javac/main/EnvVariableTest.java 0 linux-aarch64 From fd6b1102d77bd3bcfff27a870316f3386d0a9748 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Fri, 14 Oct 2022 19:05:49 +0200 Subject: [PATCH 20/85] Enable tests passing locally on riscv64 (#31) They are only timeouting on CI because they take time and machines on GHA are slow. We need a better solution than disabling them. (retries?) --- test/hotspot/jtreg/ProblemList-GHA.txt | 34 -------------------------- test/jdk/ProblemList-GHA.txt | 12 --------- test/langtools/ProblemList-GHA.txt | 1 - 3 files changed, 47 deletions(-) diff --git a/test/hotspot/jtreg/ProblemList-GHA.txt b/test/hotspot/jtreg/ProblemList-GHA.txt index d40ab6312c203..c8c90ea341b50 100644 --- a/test/hotspot/jtreg/ProblemList-GHA.txt +++ b/test/hotspot/jtreg/ProblemList-GHA.txt @@ -31,40 +31,6 @@ gtest/NMTGtests.java#nmt-detail 0 linux- gtest/NMTGtests.java#nmt-off 0 linux-riscv64 gtest/NMTGtests.java#nmt-summary 0 linux-riscv64 -# :tier1_serviceability - -serviceability/dcmd/framework/HelpTest.java 0 linux-riscv64 -serviceability/dcmd/framework/InvalidCommandTest.java 0 linux-riscv64 -serviceability/dcmd/framework/VMVersionTest.java 0 linux-riscv64 -serviceability/tmtools/jstat/GcCapacityTest.java 0 linux-riscv64 -serviceability/tmtools/jstat/GcCauseTest01.java 0 linux-riscv64 -serviceability/tmtools/jstat/GcCauseTest02.java 0 linux-riscv64 -serviceability/tmtools/jstat/GcCauseTest03.java 0 linux-riscv64 -serviceability/tmtools/jstat/GcNewTest.java 0 linux-riscv64 -serviceability/tmtools/jstat/GcTest01.java 0 linux-riscv64 -serviceability/tmtools/jstat/GcTest02.java 0 linux-riscv64 - -# :tier1_gc - -gc/arguments/TestUseCompressedOopsFlagsWithUlimit.java 0 linux-riscv64 -gc/g1/humongousObjects/TestHumongousClassLoader.java 0 linux-riscv64 - # :tier1_runtime runtime/cds/CheckDefaultArchiveFile.java 0 linux-riscv64 -runtime/LoadClass/LongBCP.java 0 linux-riscv64 -runtime/os/TestTracePageSizes.java#compiler-options 0 linux-riscv64 -runtime/os/TestTracePageSizes.java#G1 0 linux-riscv64 -runtime/os/TestTracePageSizes.java#Parallel 0 linux-riscv64 -runtime/os/TestTracePageSizes.java#Serial 0 linux-riscv64 -runtime/posixSig/TestPosixSig.java 0 linux-riscv64 - -# :tier1_compiler - -compiler/blackhole/BlackholeIntrinsicTest.java 0 linux-riscv64 -compiler/c2/irTests/TestAutoVectorization2DArray.java 0 linux-riscv64 -compiler/c2/irTests/TestFPComparison.java 0 linux-riscv64 -compiler/c2/TestShiftRightAndAccumulate.java#id0 0 linux-riscv64 -compiler/c2/TestStressRecompilation.java 0 linux-riscv64 -compiler/loopopts/TestUnreachableInnerLoop.java 0 linux-riscv64 -compiler/vectorization/TestAutoVecIntMinMax.java 0 linux-riscv64 diff --git a/test/jdk/ProblemList-GHA.txt b/test/jdk/ProblemList-GHA.txt index 6a33f6c73ae35..6a35a81795ae6 100644 --- a/test/jdk/ProblemList-GHA.txt +++ b/test/jdk/ProblemList-GHA.txt @@ -20,15 +20,3 @@ # or visit www.oracle.com if you need additional information or have any # questions. # - -# :tier1_part1 - -java/lang/invoke/lambda/LogGeneratedClassesTest.java 0 linux-riscv64 -java/lang/ProcessHandle/InfoTest.java 0 linux-riscv64 - -# :tier1_part2 - -java/util/concurrent/locks/Lock/TimedAcquireLeak.java 0 linux-riscv64 -java/util/concurrent/tck/JSR166TestCase.java 0 linux-riscv64 -java/util/DoubleSummaryStatistics/NegativeCompensation.java 0 linux-riscv64 -java/util/ServiceLoader/basic/ServiceLoaderBasicTest.java 0 linux-riscv64 diff --git a/test/langtools/ProblemList-GHA.txt b/test/langtools/ProblemList-GHA.txt index 63be191010333..e88cfebbc063d 100644 --- a/test/langtools/ProblemList-GHA.txt +++ b/test/langtools/ProblemList-GHA.txt @@ -21,7 +21,6 @@ # questions. # -jdk/javadoc/tool/testLocaleOption/TestLocaleOption.java 0 linux-riscv64 jdk/jshell/CommandCompletionTest.java 0 linux-riscv64 jdk/jshell/ForwardReferenceImportTest.java 0 linux-riscv64 jdk/jshell/ToolProviderTest.java 0 linux-riscv64 From eb9d451937830ebe9d8d129355dfd742acf0e818 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Fri, 14 Oct 2022 19:06:47 +0200 Subject: [PATCH 21/85] Do not push rivos/merge-upstream if there is nothing to merge (#32) --- .github/workflows/downstream.yml | 35 ++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/.github/workflows/downstream.yml b/.github/workflows/downstream.yml index cfa9b225bfae6..fa38e04ca17f7 100644 --- a/.github/workflows/downstream.yml +++ b/.github/workflows/downstream.yml @@ -54,29 +54,42 @@ jobs: git remote add upstream https://github.com/openjdk/jdk.git git fetch --tags upstream master + - name: "Configure" + id: configure + run: | TAG=$(git tag | grep --extended-regexp '^jdk\-.*' | sort --version-sort | tail --lines 1 | tr --delete '\n') test -n "$TAG" echo "::set-output name=tag::$TAG" + if [ -n "$(git merge-tree $(git merge-base $TAG rivos/main) rivos/main $TAG" ]; then + echo "::set-output name=diff::true" + else + echo "::set-output name=diff::false" + fi + - name: "Push" run: | - git push origin ${{ steps.fetch.outputs.tag }} - - git checkout -B rivos/merge-upstream ${{ steps.fetch.outputs.tag }} - git push origin rivos/merge-upstream + git push origin ${{ steps.configure.outputs.tag }} git checkout -B master upstream/master git push origin master + if [ "${{ steps.configure.outputs.diff }}" = "true" ]; then + git checkout -B rivos/merge-upstream ${{ steps.configure.outputs.tag }} + git push origin rivos/merge-upstream + fi + - name: "Create PR" run: | - gh pr create \ - --repo rivosinc/jdk \ - --base rivos/main \ - --head rivos/merge-upstream \ - --title "Merge ${{ steps.fetch.outputs.tag }} into rivos/main" \ - --body "" \ - --reviewer "luhenry" || true + if [ "${{ steps.configure.outputs.diff }}" = "true" ]; then + gh pr create \ + --repo rivosinc/jdk \ + --base rivos/main \ + --head rivos/merge-upstream \ + --title "Merge ${{ steps.configure.outputs.tag }} into rivos/main" \ + --body "" \ + --reviewer "luhenry" || true + fi env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 3fe870deb50506224656557112493f1b4bc0cb63 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Sat, 15 Oct 2022 16:20:09 +0200 Subject: [PATCH 22/85] 8295282: Use Zicboz/cbo.zero to zero-out memory on RISC-V (#30) Similarly to AArch64 DC.ZVA, the RISC-V Zicboz [1] extension provides the cbo.zero [2] instruction that allows to zero out memory a cache-line at a time. This should be faster than storing zeroes 64bits at a time. [1] https://github.com/riscv/riscv-CMOs [2] https://github.com/riscv/riscv-CMOs/blob/master/cmobase/Zicboz.adoc#insns-cbo_zero --- src/hotspot/cpu/riscv/assembler_riscv.hpp | 38 +++++++++++++++++++ src/hotspot/cpu/riscv/globals_riscv.hpp | 5 +++ .../cpu/riscv/macroAssembler_riscv.cpp | 38 +++++++++++++++++++ .../cpu/riscv/macroAssembler_riscv.hpp | 1 + src/hotspot/cpu/riscv/stubGenerator_riscv.cpp | 15 +++++++- src/hotspot/cpu/riscv/vm_version_riscv.cpp | 13 +++++++ src/hotspot/cpu/riscv/vm_version_riscv.hpp | 3 ++ .../linux_riscv/vm_version_linux_riscv.cpp | 2 + 8 files changed, 113 insertions(+), 2 deletions(-) diff --git a/src/hotspot/cpu/riscv/assembler_riscv.hpp b/src/hotspot/cpu/riscv/assembler_riscv.hpp index 53853bcce3563..1f8007f602734 100644 --- a/src/hotspot/cpu/riscv/assembler_riscv.hpp +++ b/src/hotspot/cpu/riscv/assembler_riscv.hpp @@ -3006,6 +3006,44 @@ enum Nf { #undef INSN +// Cache Management Operations +#define INSN(NAME, funct) \ + void NAME(Register Rs1) { \ + unsigned insn = 0; \ + patch((address)&insn, 6, 0, 0b0001111); \ + patch((address)&insn, 14, 12, 0b010); \ + patch_reg((address)&insn, 15, Rs1); \ + patch((address)&insn, 31, 20, funct); \ + emit(insn); \ + } + + INSN(cbo_inval, 0b0000000000000); + INSN(cbo_clean, 0b0000000000001); + INSN(cbo_flush, 0b0000000000010); + INSN(cbo_zero, 0b0000000001000); + +#undef INSN + +#define INSN(NAME, funct) \ + void NAME(Register Rs1, int32_t offset) { \ + guarantee((offset & 0x1f) == 0, "offset lowest 5 bits must be zero"); \ + int32_t upperOffset = offset >> 5; \ + unsigned insn = 0; \ + patch((address)&insn, 6, 0, 0b0010011); \ + patch((address)&insn, 14, 12, 0b110); \ + patch_reg((address)&insn, 15, Rs1); \ + patch((address)&insn, 24, 20, funct); \ + upperOffset &= 0x7f; \ + patch((address)&insn, 31, 25, upperOffset); \ + emit(insn); \ + } + + INSN(prefetch_i, 0b0000000000000); + INSN(prefetch_r, 0b0000000000001); + INSN(prefetch_w, 0b0000000000010); + +#undef INSN + // --------------------------------------------------------------------------------------- void bgt(Register Rs, Register Rt, const address &dest); diff --git a/src/hotspot/cpu/riscv/globals_riscv.hpp b/src/hotspot/cpu/riscv/globals_riscv.hpp index 3b73bb422369a..f4d1de41c336f 100644 --- a/src/hotspot/cpu/riscv/globals_riscv.hpp +++ b/src/hotspot/cpu/riscv/globals_riscv.hpp @@ -82,6 +82,8 @@ define_pd_global(intx, InlineSmallCode, 1000); \ product(bool, NearCpool, true, \ "constant pool is close to instructions") \ + product(bool, UseBlockZeroing, false, \ + "Use Zicboz for block zeroing") \ product(intx, BlockZeroingLowLimit, 256, \ "Minimum size in bytes when block zeroing will be used") \ range(1, max_jint) \ @@ -95,6 +97,9 @@ define_pd_global(intx, InlineSmallCode, 1000); product(bool, UseRVC, false, EXPERIMENTAL, "Use RVC instructions") \ product(bool, UseZba, false, EXPERIMENTAL, "Use Zba instructions") \ product(bool, UseZbb, false, EXPERIMENTAL, "Use Zbb instructions") \ + 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, UseRVVForBigIntegerShiftIntrinsics, true, \ "Use RVV instructions for left/right shift of BigInteger") diff --git a/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp b/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp index debfcfb4cf99f..17f47d17d7148 100644 --- a/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp +++ b/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp @@ -3744,6 +3744,44 @@ void MacroAssembler::fill_words(Register base, Register cnt, Register value) bind(fini); } +// Zero blocks of memory by using CBO.ZERO. +// +// Aligns the base address first sufficiently for CBO.ZERO, then uses +// CBO.ZERO repeatedly for every full block. cnt is the size to be +// zeroed in HeapWords. Returns the count of words left to be zeroed +// in cnt. +// +// NOTE: This is intended to be used in the zero_blocks() stub. If +// you want to use it elsewhere, note that cnt must be >= 2*zva_length. +void MacroAssembler::zero_dcache_blocks(Register base, Register cnt) { + Label initial_table_end, loop_cbo_zero; + + // Align base with cache line size. + neg(t0, base); + andi(t0, t0, VM_Version::cache_line_size() - 1); + + // t0: the number of bytes to be filled to align the base with cache line size. + add(base, base, t0); + srai(t1, t0, 3); + sub(cnt, cnt, t1); + add(t2, zr, zr); + wrap_label(t2, initial_table_end, (Assembler::jal_jalr_insn)&MacroAssembler::movptr); + srli(t1, t0, 1); + sub(t1, t2, t1); + j(t1); + for (int i = -VM_Version::cache_line_size() + 8; i < 0; i += 8) { + sd(zr, Address(base, i)); + } + bind(initial_table_end); + + li(t0, VM_Version::cache_line_size() >> 3); + bind(loop_cbo_zero); + cbo_zero(base); + sub(cnt, cnt, t0); + add(base, base, VM_Version::cache_line_size()); + bge(cnt, t0, loop_cbo_zero); +} + #define FCVT_SAFE(FLOATCVT, FLOATEQ) \ void MacroAssembler:: FLOATCVT##_safe(Register dst, FloatRegister src, Register tmp) { \ Label L_Okay; \ diff --git a/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp b/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp index 3fe21bfc4420c..d51ec2ac12f39 100644 --- a/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp +++ b/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp @@ -784,6 +784,7 @@ class MacroAssembler: public Assembler { address zero_words(Register ptr, Register cnt); void fill_words(Register base, Register cnt, Register value); void zero_memory(Register addr, Register len, Register tmp); + void zero_dcache_blocks(Register base, Register cnt); // shift left by shamt and add void shadd(Register Rd, Register Rs1, Register Rs2, Register tmp, int shamt); diff --git a/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp b/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp index b409581cc464e..8a49f42b263e8 100644 --- a/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp +++ b/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp @@ -677,6 +677,17 @@ class StubGenerator: public StubCodeGenerator { StubCodeMark mark(this, "StubRoutines", "zero_blocks"); address start = __ pc(); + if (UseBlockZeroing) { + // Ensure count >= cache_line_size so that it still deserves a cbo.zero + // after alignment. + Label small; + int low_limit = MAX2(VM_Version::cache_line_size(), (int)BlockZeroingLowLimit); + __ li(t0, low_limit); + __ blt(cnt, t0, small); + __ zero_dcache_blocks(base, cnt); + __ bind(small); + } + { // Clear the remaining blocks. Label loop; @@ -684,9 +695,9 @@ class StubGenerator: public StubCodeGenerator { __ bltz(cnt, done); __ bind(loop); for (int i = 0; i < MacroAssembler::zero_words_block_size; i++) { - __ sd(zr, Address(base, 0)); - __ add(base, base, 8); + __ sd(zr, Address(base, i << 3)); } + __ add(base, base, MacroAssembler::zero_words_block_size << 3); __ sub(cnt, cnt, MacroAssembler::zero_words_block_size); __ bgez(cnt, loop); __ bind(done); diff --git a/src/hotspot/cpu/riscv/vm_version_riscv.cpp b/src/hotspot/cpu/riscv/vm_version_riscv.cpp index 02133dbb59529..10b77bedd44c6 100644 --- a/src/hotspot/cpu/riscv/vm_version_riscv.cpp +++ b/src/hotspot/cpu/riscv/vm_version_riscv.cpp @@ -31,6 +31,7 @@ #include "utilities/macros.hpp" const char* VM_Version::_uarch = ""; +uint32_t VM_Version::_cache_line_size; uint32_t VM_Version::_initial_vector_length = 0; void VM_Version::initialize() { @@ -127,6 +128,18 @@ void VM_Version::initialize() { FLAG_SET_DEFAULT(UsePopCountInstruction, false); } + if (UseZicboz) { + if (FLAG_IS_DEFAULT(UseBlockZeroing)) { + FLAG_SET_DEFAULT(UseBlockZeroing, true); + } + if (FLAG_IS_DEFAULT(BlockZeroingLowLimit)) { + FLAG_SET_DEFAULT(BlockZeroingLowLimit, 4 * VM_Version::cache_line_size()); + } + } else if (UseBlockZeroing) { + warning("Zicboz is not available on this CPU"); + FLAG_SET_DEFAULT(UseBlockZeroing, false); + } + char buf[512]; buf[0] = '\0'; if (_uarch != NULL && strcmp(_uarch, "") != 0) snprintf(buf, sizeof(buf), "%s,", _uarch); diff --git a/src/hotspot/cpu/riscv/vm_version_riscv.hpp b/src/hotspot/cpu/riscv/vm_version_riscv.hpp index 1d6eeb97504c9..e6e72166bd673 100644 --- a/src/hotspot/cpu/riscv/vm_version_riscv.hpp +++ b/src/hotspot/cpu/riscv/vm_version_riscv.hpp @@ -40,6 +40,7 @@ class VM_Version : public Abstract_VM_Version { protected: static const char* _uarch; + static uint32_t _cache_line_size; static uint32_t _initial_vector_length; static void get_os_cpu_info(); static uint32_t get_current_vector_length(); @@ -66,6 +67,8 @@ class VM_Version : public Abstract_VM_Version { }; static void initialize_cpu_information(void); + + static int cache_line_size() { return _cache_line_size; } }; #endif // CPU_RISCV_VM_VERSION_RISCV_HPP diff --git a/src/hotspot/os_cpu/linux_riscv/vm_version_linux_riscv.cpp b/src/hotspot/os_cpu/linux_riscv/vm_version_linux_riscv.cpp index a954dcf5768ce..bcaa8b0101b1a 100644 --- a/src/hotspot/os_cpu/linux_riscv/vm_version_linux_riscv.cpp +++ b/src/hotspot/os_cpu/linux_riscv/vm_version_linux_riscv.cpp @@ -113,4 +113,6 @@ void VM_Version::get_os_cpu_info() { } fclose(f); } + + _cache_line_size = 64; } From 35ae048439fce123d3c74918ff1cbac4b04c5572 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Sun, 16 Oct 2022 10:12:02 +0000 Subject: [PATCH 23/85] Add some scripts to ease development --- .gdbinit | 4 ++++ configure-amd64.sh | 14 ++++++++++++++ configure-riscv64.sh | 17 +++++++++++++++++ make.sh | 5 +++++ run-tests.sh | 41 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 81 insertions(+) create mode 100644 .gdbinit create mode 100755 configure-amd64.sh create mode 100755 configure-riscv64.sh create mode 100755 make.sh create mode 100644 run-tests.sh diff --git a/.gdbinit b/.gdbinit new file mode 100644 index 0000000000000..739baa48b5928 --- /dev/null +++ b/.gdbinit @@ -0,0 +1,4 @@ +set sysroot /sysroot/focal-riscv64 + +handle SIGILL nostop noprint +handle SIGSEGV nostop noprint \ No newline at end of file diff --git a/configure-amd64.sh b/configure-amd64.sh new file mode 100755 index 0000000000000..6948d59b29d78 --- /dev/null +++ b/configure-amd64.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +DIST=${DIST:-focal} + +ARGS=( + --with-boot-jdk=/rivos/jdk + --with-zlib=system + --with-sysroot=/sysroot/$DIST-amd64 + --with-jmh=/workspace/jmh/build/images/jmh + --with-jtreg=/workspace/jtreg/build/images/jtreg + --with-hsdis=binutils --with-binutils-src=/workspace/binutils --enable-hsdis-bundling +) + +/sysroot/run-in.sh /sysroot/$DIST-amd64 bash configure ${ARGS[@]} $* diff --git a/configure-riscv64.sh b/configure-riscv64.sh new file mode 100755 index 0000000000000..da281077eb789 --- /dev/null +++ b/configure-riscv64.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +DIST=${DIST:-focal} + +ARGS=( + --openjdk-target=riscv64-linux-gnu + --with-boot-jdk=/rivos/jdk + --with-build-jdk=$(pwd)/build/linux-x86_64-server-release/images/jdk + # --with-debug-level=slowdebug + --with-zlib=system + --with-sysroot=/sysroot/$DIST-riscv64 + --with-jmh=/workspace/jmh/build/images/jmh + --with-jtreg=/workspace/jtreg/build/images/jtreg + --with-hsdis=binutils --with-binutils-src=/workspace/binutils --enable-hsdis-bundling +) + +/sysroot/run-in.sh /sysroot/$DIST-amd64 bash configure ${ARGS[@]} $* diff --git a/make.sh b/make.sh new file mode 100755 index 0000000000000..c7e678f4a271e --- /dev/null +++ b/make.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +DIST=${DIST:-focal} + +/sysroot/run-in.sh /sysroot/$DIST-amd64 make $* diff --git a/run-tests.sh b/run-tests.sh new file mode 100644 index 0000000000000..8234554ee9b77 --- /dev/null +++ b/run-tests.sh @@ -0,0 +1,41 @@ +#!/bin/bash + +CONF=${CONF:-linux-riscv64-server-release} + +TESTSUITE=test/hotspot/jtreg +NATIVEPATH=build/${CONF}/images/test/hotspot/jtreg/native + +TMPDIR=${TMPDIR:-/workspace/jdk/build/run-test/tmp} +mkdir -p ${TMPDIR} + +ARGS=( + # JVM arguments + -Xms64M + -Xmx1600M + -Duser.language=en + -Duser.country=US + -Djava.library.path="build/${CONF}/images/test/failure_handler" + -Dprogram=jtreg + -jar /workspace/jtreg/build/images/jtreg/lib/jtreg.jar + # JTreg arguments + -agentvm + -verbose:summary,time + -retain:fail,error + -concurrency:$(nproc) + -timeoutFactor:16 + -vmoption:-XX:MaxRAMPercentage=12.5 + -vmoption:-Djava.io.tmpdir="${TMPDIR}" + -automatic + -ignore:quiet + -e:JIB_DATA_DIR + -e:TEST_IMAGE_DIR=build/${CONF}/images/test + -dir:/workspace/jdk + -reportDir:/workspace/jdk/build/run-test/test-results + -workDir:/workspace/jdk/build/run-test/test-support + -testjdk:build/${CONF}/images/jdk + $(test -n "${NATIVEPATH}" && echo "-nativepath:${NATIVEPATH}"|| true) + -exclude:${TESTSUITE}/ProblemList.txt + -exclude:${TESTSUITE}/ProblemList-GHA.txt +) + +build/${CONF}/images/jdk/bin/java ${ARGS[@]} ${*:-${TESTSUITE}} From 26ecae414fa9a1af15f8e5be2fab1eb80337ff90 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Mon, 17 Oct 2022 10:40:52 +0200 Subject: [PATCH 24/85] Fix typo (#33) --- .github/workflows/downstream.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/downstream.yml b/.github/workflows/downstream.yml index fa38e04ca17f7..e76337231a443 100644 --- a/.github/workflows/downstream.yml +++ b/.github/workflows/downstream.yml @@ -62,7 +62,7 @@ jobs: echo "::set-output name=tag::$TAG" - if [ -n "$(git merge-tree $(git merge-base $TAG rivos/main) rivos/main $TAG" ]; then + if [ -n "$(git merge-tree $(git merge-base $TAG rivos/main) rivos/main $TAG)" ]; then echo "::set-output name=diff::true" else echo "::set-output name=diff::false" From e7cf57fa7ef1bcb0e5d8badb58e736fe9ee5dbbb Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Mon, 17 Oct 2022 10:50:15 +0200 Subject: [PATCH 25/85] Allow manual run of Downstreaming GHA (#34) --- .github/workflows/downstream.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/downstream.yml b/.github/workflows/downstream.yml index e76337231a443..31ad9eb533328 100644 --- a/.github/workflows/downstream.yml +++ b/.github/workflows/downstream.yml @@ -32,6 +32,8 @@ on: # since that's when I would want to review it. And given GHA takes a long # time to run, we want to start doing it as early as possible - cron: '0 21 * * 0-4' + workflow_dispatch: + inputs: {} concurrency: group: ${{ github.workflow }}-${{ github.ref }} From 3e12baf1555a2020eade7e52f263eba0c037395a Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Mon, 17 Oct 2022 18:14:37 +0200 Subject: [PATCH 26/85] Bump GitLab boot JDK to Java 20 (#35) --- rivos/gitlab-ci.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/rivos/gitlab-ci.yml b/rivos/gitlab-ci.yml index 2d5fb70bf1f1d..c9dc1a54310d8 100644 --- a/rivos/gitlab-ci.yml +++ b/rivos/gitlab-ci.yml @@ -120,9 +120,9 @@ build-linux-amd64: zip \ zlib1g-dev - | - mkdir -p /usr/lib/jvm/zulu-18 - curl -L https://cdn.azul.com/zulu/bin/zulu18.32.13-ca-jdk18.0.2.1-linux_x64.tar.gz \ - | tar -xzf - -C /usr/lib/jvm/zulu-18 --strip-components 1 + mkdir -p /usr/lib/jvm/zulu-20 + curl -L https://cdn.azul.com/zulu/bin/zulu20.0.45-ea-jdk20.0.0-ea.17-linux_x64.tar.gz \ + | tar -xzf - -C /usr/lib/jvm/zulu-20 --strip-components 1 - | bash configure \ --openjdk-target=x86_64-linux-gnu \ @@ -130,7 +130,7 @@ build-linux-amd64: --with-vendor-name="Rivos Inc" \ --with-version-pre="${JDK_VERSION_PRE}" \ --with-version-opt="${JDK_VERSION_OPT}" \ - --with-boot-jdk=/usr/lib/jvm/zulu-18 \ + --with-boot-jdk=/usr/lib/jvm/zulu-20 \ --disable-precompiled-headers \ --with-zlib=system - make jdk-image test-image LOG_LEVEL=info @@ -172,9 +172,9 @@ build-linux-rv64: zip \ zlib1g-dev - | - mkdir -p /usr/lib/jvm/zulu-18 - curl -L https://cdn.azul.com/zulu/bin/zulu18.32.13-ca-jdk18.0.2.1-linux_x64.tar.gz \ - | tar -xzf - -C /usr/lib/jvm/zulu-18 --strip-components 1 + mkdir -p /usr/lib/jvm/zulu-20 + curl -L https://cdn.azul.com/zulu/bin/zulu20.0.45-ea-jdk20.0.0-ea.17-linux_x64.tar.gz \ + | tar -xzf - -C /usr/lib/jvm/zulu-20 --strip-components 1 - | bash configure \ --openjdk-target=riscv64-linux-gnu \ @@ -183,7 +183,7 @@ build-linux-rv64: --with-version-pre="${JDK_VERSION_PRE}" \ --with-version-opt="${JDK_VERSION_OPT}" \ --with-sysroot=$(pwd)/sysroot-ubuntu-jammy-rv64 \ - --with-boot-jdk=/usr/lib/jvm/zulu-18 \ + --with-boot-jdk=/usr/lib/jvm/zulu-20 \ --with-build-jdk=$(pwd)/build/linux-amd64/images/jdk \ --disable-precompiled-headers \ --with-zlib=system From 73a37b6ffa1d10bdb98fc4ba25c8c9300e944b5b Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Thu, 20 Oct 2022 11:26:59 +0200 Subject: [PATCH 27/85] Fix downstream pipeline (#39) It would previously fail on merge-tree which expects two branches and no tags. Also rename the merge branch to `merge-` so that we can support merging multiple tags in parallel. --- .github/workflows/downstream.yml | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/.github/workflows/downstream.yml b/.github/workflows/downstream.yml index 31ad9eb533328..93ff66c64a0dd 100644 --- a/.github/workflows/downstream.yml +++ b/.github/workflows/downstream.yml @@ -49,6 +49,8 @@ jobs: - uses: actions/checkout@v3 with: token: ${{ secrets.WORKFLOW_TOKEN }} + ref: 'rivos/main' + fetch-depth: 0 - name: "Fetch" id: fetch @@ -63,23 +65,15 @@ jobs: test -n "$TAG" echo "::set-output name=tag::$TAG" - - if [ -n "$(git merge-tree $(git merge-base $TAG rivos/main) rivos/main $TAG)" ]; then - echo "::set-output name=diff::true" - else - echo "::set-output name=diff::false" - fi + echo "::set-output name=diff::$(test -n "$(git diff rivos/main...$TAG)" && echo "true" || echo "false")" - name: "Push" run: | git push origin ${{ steps.configure.outputs.tag }} - git checkout -B master upstream/master - git push origin master - if [ "${{ steps.configure.outputs.diff }}" = "true" ]; then - git checkout -B rivos/merge-upstream ${{ steps.configure.outputs.tag }} - git push origin rivos/merge-upstream + git branch -f rivos/merge-${{ steps.configure.outputs.tag }} ${{ steps.configure.outputs.tag }} + git push origin rivos/merge-${{ steps.configure.outputs.tag }} fi - name: "Create PR" @@ -88,7 +82,7 @@ jobs: gh pr create \ --repo rivosinc/jdk \ --base rivos/main \ - --head rivos/merge-upstream \ + --head rivos/merge-${{ steps.configure.outputs.tag }} \ --title "Merge ${{ steps.configure.outputs.tag }} into rivos/main" \ --body "" \ --reviewer "luhenry" || true From 50843a76a950e969414999c5592e13ea62f0b9fa Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Thu, 20 Oct 2022 13:58:33 +0000 Subject: [PATCH 28/85] Fix compilation --- src/hotspot/cpu/riscv/macroAssembler_riscv.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp b/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp index 9ac7ceebcec65..34681b1e880e1 100644 --- a/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp +++ b/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp @@ -4113,7 +4113,7 @@ void MacroAssembler::zero_dcache_blocks(Register base, Register cnt) { srai(t1, t0, 3); sub(cnt, cnt, t1); add(t2, zr, zr); - wrap_label(t2, initial_table_end, (Assembler::jal_jalr_insn)&MacroAssembler::movptr); + wrap_label(t2, initial_table_end, (MacroAssembler::jal_jalr_insn)&MacroAssembler::movptr); srli(t1, t0, 1); sub(t1, t2, t1); j(t1); From 54f5aa160d593550d1a2738f98f658010f09f5a0 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Fri, 21 Oct 2022 08:02:16 +0200 Subject: [PATCH 29/85] Add UseZtso to optimize memory fences on TSO-enabled platforms (#40) --- src/hotspot/cpu/riscv/globals_riscv.hpp | 1 + .../cpu/riscv/macroAssembler_riscv.hpp | 27 ++++++++++++------- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/hotspot/cpu/riscv/globals_riscv.hpp b/src/hotspot/cpu/riscv/globals_riscv.hpp index f4d1de41c336f..8c8e7623a5b7e 100644 --- a/src/hotspot/cpu/riscv/globals_riscv.hpp +++ b/src/hotspot/cpu/riscv/globals_riscv.hpp @@ -100,6 +100,7 @@ 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, UseRVVForBigIntegerShiftIntrinsics, true, \ "Use RVV instructions for left/right shift of BigInteger") diff --git a/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp b/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp index 71e28c32f4e20..442cb192288af 100644 --- a/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp +++ b/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp @@ -347,21 +347,30 @@ class MacroAssembler: public Assembler { static void membar_mask_to_pred_succ(uint32_t order_constraint, uint32_t& predecessor, uint32_t& successor) { predecessor = (order_constraint >> 2) & 0x3; successor = order_constraint & 0x3; - - // extend rw -> iorw: - // 01(w) -> 0101(ow) - // 10(r) -> 1010(ir) - // 11(rw)-> 1111(iorw) - if (UseConservativeFence) { - predecessor |= predecessor << 2; - successor |= successor << 2; - } } static int pred_succ_to_membar_mask(uint32_t predecessor, uint32_t successor) { return ((predecessor & 0x3) << 2) | (successor & 0x3); } + void fence(uint32_t predecessor, uint32_t successor) { + if (UseZtso) { + // do not emit fence if it's not at least a StoreLoad fence + if (!((predecessor & w) && (successor & r))) { + return; + } + } + if (UseConservativeFence) { + // extend rw -> iorw: + // 01(w) -> 0101(ow) + // 10(r) -> 1010(ir) + // 11(rw)-> 1111(iorw) + predecessor |= (predecessor & 0b11) << 2; + successor |= (successor & 0b11) << 2; + } + Assembler::fence(predecessor, successor); + } + // prints msg, dumps registers and stops execution void stop(const char* msg); From 99b559b3746b538234d171762b7602d915aca50b Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Sat, 22 Oct 2022 16:33:49 +0200 Subject: [PATCH 30/85] Add failing tests to ProblemList-GHA.txt (#41) --- test/hotspot/jtreg/ProblemList-GHA.txt | 33 ++++++++++++++++++++++++++ test/jdk/ProblemList-GHA.txt | 9 +++++++ 2 files changed, 42 insertions(+) diff --git a/test/hotspot/jtreg/ProblemList-GHA.txt b/test/hotspot/jtreg/ProblemList-GHA.txt index c8c90ea341b50..4192f48a1284f 100644 --- a/test/hotspot/jtreg/ProblemList-GHA.txt +++ b/test/hotspot/jtreg/ProblemList-GHA.txt @@ -31,6 +31,39 @@ gtest/NMTGtests.java#nmt-detail 0 linux- gtest/NMTGtests.java#nmt-off 0 linux-riscv64 gtest/NMTGtests.java#nmt-summary 0 linux-riscv64 + +# tier1_compiler_1 + +compiler/c2/irTests/TestAutoVectorization2DArray.java 0 linux-riscv64 +compiler/c2/irTests/TestFPComparison.java 0 linux-riscv64 + +# tier1_compiler_3 + +compiler/loopopts/TestUnreachableInnerLoop.java 0 linux-riscv64 +compiler/vectorization/TestAutoVecIntMinMax.java 0 linux-riscv64 + +# tier1_gc + +gc/arguments/TestUseCompressedOopsFlagsWithUlimit.java 0 linux-riscv64 + # :tier1_runtime runtime/cds/CheckDefaultArchiveFile.java 0 linux-riscv64 +runtime/LoadClass/LongBCP.java 0 linux-riscv64 +runtime/os/TestTracePageSizes.java#compiler-options 0 linux-riscv64 +runtime/os/TestTracePageSizes.java#G1 0 linux-riscv64 +runtime/os/TestTracePageSizes.java#Parallel 0 linux-riscv64 +runtime/os/TestTracePageSizes.java#Serial 0 linux-riscv64 + +# tier1_serviceability + +serviceability/dcmd/framework/HelpTest.java 0 linux-riscv64 +serviceability/dcmd/framework/InvalidCommandTest.java 0 linux-riscv64 +serviceability/dcmd/framework/VMVersionTest.java 0 linux-riscv64 +serviceability/tmtools/jstat/GcCapacityTest.java 0 linux-riscv64 +serviceability/tmtools/jstat/GcCauseTest01.java 0 linux-riscv64 +serviceability/tmtools/jstat/GcCauseTest02.java 0 linux-riscv64 +serviceability/tmtools/jstat/GcCauseTest03.java 0 linux-riscv64 +serviceability/tmtools/jstat/GcNewTest.java 0 linux-riscv64 +serviceability/tmtools/jstat/GcTest01.java 0 linux-riscv64 +serviceability/tmtools/jstat/GcTest02.java 0 linux-riscv64 \ No newline at end of file diff --git a/test/jdk/ProblemList-GHA.txt b/test/jdk/ProblemList-GHA.txt index 6a35a81795ae6..e93af7dbc3b71 100644 --- a/test/jdk/ProblemList-GHA.txt +++ b/test/jdk/ProblemList-GHA.txt @@ -20,3 +20,12 @@ # or visit www.oracle.com if you need additional information or have any # questions. # + +# jdk / tier1_part_1 + +java/lang/ProcessHandle/InfoTest.java 0 linux-riscv64 +java/lang/invoke/lambda/LogGeneratedClassesTest.java 0 linux-riscv64 + +# jdk / tier1_part_2 + +java/util/concurrent/locks/Lock/TimedAcquireLeak.java 0 linux-riscv64 From f76aaa103a682fa08578f67bda60dd884a457ba1 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Mon, 24 Oct 2022 22:57:58 +0200 Subject: [PATCH 31/85] Increase timeout factor for cross-compile tests (#42) --- .github/workflows/test-cross-compile.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test-cross-compile.yml b/.github/workflows/test-cross-compile.yml index d43d362fd6316..45857c76389b3 100644 --- a/.github/workflows/test-cross-compile.yml +++ b/.github/workflows/test-cross-compile.yml @@ -175,7 +175,7 @@ jobs: JDK_IMAGE_DIR=${{ steps.bundles.outputs.jdk-path }} SYMBOLS_IMAGE_DIR=${{ steps.bundles.outputs.symbols-path }} TEST_IMAGE_DIR=${{ steps.bundles.outputs.tests-path }} - JTREG='JAVA_OPTIONS=-XX:-CreateCoredumpOnCrash;VERBOSE=fail,error,time;KEYWORDS=!headful' + JTREG='JAVA_OPTIONS=-XX:-CreateCoredumpOnCrash;VERBOSE=fail,error,time;KEYWORDS=!headful;TIMEOUT_FACTOR=8' JTREG_EXTRA_PROBLEM_LISTS='ProblemList-GHA.txt' && bash ./.github/scripts/gen-test-summary.sh "$GITHUB_STEP_SUMMARY" " From fb691082094f4ab2b2c71098e0cf48ba101ec60b Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Wed, 26 Oct 2022 10:15:57 +0200 Subject: [PATCH 32/85] 8295382: Implement SHA-256 Intrinsic on RISC-V (#37) --- src/hotspot/cpu/riscv/assembler_riscv.hpp | 32 +++ src/hotspot/cpu/riscv/globals_riscv.hpp | 2 + .../cpu/riscv/macroAssembler_riscv.hpp | 25 ++ src/hotspot/cpu/riscv/stubGenerator_riscv.cpp | 264 ++++++++++++++++++ src/hotspot/cpu/riscv/vm_version_riscv.cpp | 6 +- 5 files changed, 328 insertions(+), 1 deletion(-) diff --git a/src/hotspot/cpu/riscv/assembler_riscv.hpp b/src/hotspot/cpu/riscv/assembler_riscv.hpp index 0f4099294485f..47d8707770d01 100644 --- a/src/hotspot/cpu/riscv/assembler_riscv.hpp +++ b/src/hotspot/cpu/riscv/assembler_riscv.hpp @@ -1242,6 +1242,10 @@ enum VectorMask { INSN(vnmsac_vv, 0b1010111, 0b010, 0b101111); INSN(vmacc_vv, 0b1010111, 0b010, 0b101101); + // Vector Register Gather Instructions + INSN(vrgather_vv, 0b1010111, 0b000, 0b001100); + INSN(vrgatherei16_vv, 0b1010111, 0b000, 0b001110); + #undef INSN #define INSN(NAME, op, funct3, funct6) \ @@ -1502,6 +1506,28 @@ enum VectorMask { #undef INSN +#define INSN(NAME, op, funct3, vm, funct6) \ + void NAME(VectorRegister Vd, VectorRegister Vs1, VectorRegister Vs2) { \ + patch_VArith(op, Vd, funct3, Vs1->raw_encoding(), Vs2, vm, funct6); \ + } + + // Vector Integer Merge Instructions + INSN(vmerge_vvm, 0b1010111, 0b000, 0b0, 0b010111); + +#undef INSN + +#define INSN(NAME, op, funct3, vm, funct6) \ + void NAME(VectorRegister Vd, VectorRegister Vs1, VectorRegister Vs2) { \ + patch_VArith(op, Vd, funct3, Vs1->raw_encoding(), Vs2, vm, funct6); \ + } + + // Vector SHA-2 Instructions + INSN(vsha2ms_vv, 0b0001011, 0b000, 0b1, 0b100000); + INSN(vsha2cl_vv, 0b0001011, 0b000, 0b1, 0b100001); + INSN(vsha2ch_vv, 0b0001011, 0b000, 0b1, 0b100010); + +#undef INSN + #define INSN(NAME, op, funct3, Vs2, vm, funct6) \ void NAME(VectorRegister Vd, int32_t imm) { \ guarantee(is_imm_in_range(imm, 5, 0), "imm is invalid"); \ @@ -1597,6 +1623,9 @@ enum Nf { // Vector Load/Store Instructions INSN(vl1r_v, 0b0000111, 0b01000, 0b1, 0b00, g1); + INSN(vl2r_v, 0b0000111, 0b01000, 0b1, 0b00, g2); + INSN(vl4r_v, 0b0000111, 0b01000, 0b1, 0b00, g4); + INSN(vl8r_v, 0b0000111, 0b01000, 0b1, 0b00, g8); #undef INSN @@ -1607,6 +1636,9 @@ enum Nf { // Vector Load/Store Instructions INSN(vs1r_v, 0b0100111, 0b000, 0b01000, 0b1, 0b00, 0b0, g1); + INSN(vs2r_v, 0b0100111, 0b000, 0b01000, 0b1, 0b00, 0b0, g2); + INSN(vs4r_v, 0b0100111, 0b000, 0b01000, 0b1, 0b00, 0b0, g4); + INSN(vs8r_v, 0b0100111, 0b000, 0b01000, 0b1, 0b00, 0b0, g8); #undef INSN diff --git a/src/hotspot/cpu/riscv/globals_riscv.hpp b/src/hotspot/cpu/riscv/globals_riscv.hpp index 8c8e7623a5b7e..802a478bb217d 100644 --- a/src/hotspot/cpu/riscv/globals_riscv.hpp +++ b/src/hotspot/cpu/riscv/globals_riscv.hpp @@ -101,6 +101,8 @@ define_pd_global(intx, InlineSmallCode, 1000); 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, UseZvknha, false, EXPERIMENTAL, "Use Zvknha instructions") \ + product(bool, UseZvknhb, false, EXPERIMENTAL, "Use Zvknhb instructions") \ product(bool, UseRVVForBigIntegerShiftIntrinsics, true, \ "Use RVV instructions for left/right shift of BigInteger") diff --git a/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp b/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp index 442cb192288af..efc4cdb2886dc 100644 --- a/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp +++ b/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp @@ -1157,6 +1157,31 @@ class MacroAssembler: public Assembler { } } + void vl1re8_v(VectorRegister Vd, Register Rs) { vl1r_v(Vd, Rs, 0b000, true); } + void vl1re16_v(VectorRegister Vd, Register Rs) { vl1r_v(Vd, Rs, 0b101, true); } + void vl1re32_v(VectorRegister Vd, Register Rs) { vl1r_v(Vd, Rs, 0b110, true); } + void vl1re64_v(VectorRegister Vd, Register Rs) { vl1r_v(Vd, Rs, 0b111, true); } + void vl2re8_v(VectorRegister Vd, Register Rs) { vl2r_v(Vd, Rs, 0b000, true); } + void vl2re16_v(VectorRegister Vd, Register Rs) { vl2r_v(Vd, Rs, 0b101, true); } + void vl2re32_v(VectorRegister Vd, Register Rs) { vl2r_v(Vd, Rs, 0b110, true); } + void vl2re64_v(VectorRegister Vd, Register Rs) { vl2r_v(Vd, Rs, 0b111, true); } + void vl4re8_v(VectorRegister Vd, Register Rs) { vl4r_v(Vd, Rs, 0b000, true); } + void vl4re16_v(VectorRegister Vd, Register Rs) { vl4r_v(Vd, Rs, 0b101, true); } + void vl4re32_v(VectorRegister Vd, Register Rs) { vl4r_v(Vd, Rs, 0b110, true); } + void vl4re64_v(VectorRegister Vd, Register Rs) { vl4r_v(Vd, Rs, 0b111, true); } + void vl8re8_v(VectorRegister Vd, Register Rs) { vl8r_v(Vd, Rs, 0b000, true); } + void vl8re16_v(VectorRegister Vd, Register Rs) { vl8r_v(Vd, Rs, 0b101, true); } + void vl8re32_v(VectorRegister Vd, Register Rs) { vl8r_v(Vd, Rs, 0b110, true); } + void vl8re64_v(VectorRegister Vd, Register Rs) { vl8r_v(Vd, Rs, 0b111, true); } + + void vnot_v(VectorRegister Vd, VectorRegister Vs, VectorMask vm = unmasked) { + vxor_vi(Vd, Vs, -1, vm); + } + + void vmsltu_vi(VectorRegister Vd, VectorRegister Vs2, int32_t imm, VectorMask vm = unmasked) { + vmsleu_vi(Vd, Vs2, imm-1, vm); + } + static const int zero_words_block_size; void cast_primitive_type(BasicType type, Register Rt) { diff --git a/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp b/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp index 2175485fb7012..978232ba3e7b6 100644 --- a/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp +++ b/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp @@ -3674,6 +3674,265 @@ class StubGenerator: public StubCodeGenerator { }; #endif // COMPILER2 + + // Arguments: + // + // Inputs: + // c_rarg0 - byte[] source+offset + // c_rarg1 - int[] SHA.state + // c_rarg2 - int offset + // c_rarg3 - int limit + // + address generate_sha256_implCompress(bool multi_block, const char *name) { + static const uint32_t round_consts[64] = { + 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, + 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, + 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, + 0x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174, + 0xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc, + 0x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da, + 0x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7, + 0xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967, + 0x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13, + 0x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85, + 0xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3, + 0xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070, + 0x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5, + 0x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3, + 0x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208, + 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2, + }; + __ align(CodeEntryAlignment); + StubCodeMark mark(this, "StubRoutines", name); + address start = __ pc(); + + Register buf = c_rarg0; + Register state = c_rarg1; + Register ofs = c_rarg2; + Register limit = c_rarg3; + + Label multi_block_loop; + + __ enter(); + + __ vsetivli(x0, 4, Assembler::e32, Assembler::m1, Assembler::ma, Assembler::ta); + __ vle32_v(v16, c_rarg1); + __ add(c_rarg1, c_rarg1, 16); + __ vle32_v(v17, c_rarg1); + + __ bind(multi_block_loop); + + __ vsetivli(x0, 4, Assembler::e32, Assembler::m1, Assembler::ma, Assembler::ta); + __ vle32_v(v20, c_rarg0); + __ add(c_rarg0, c_rarg0, 16); + __ vle32_v(v21, c_rarg0); + __ add(c_rarg0, c_rarg0, 16); + __ vle32_v(v22, c_rarg0); + __ add(c_rarg0, c_rarg0, 16); + __ vle32_v(v23, c_rarg0); + __ add(c_rarg0, c_rarg0, 16); + + __ vsetivli(x0, 16, Assembler::e8, Assembler::m1, Assembler::ma, Assembler::ta); + __ vid_v(v24); + __ vxor_vi(v24, v24, 0x3); + __ vrgather_vv(v10, v20, v24); + __ vrgather_vv(v11, v21, v24); + __ vrgather_vv(v12, v22, v24); + __ vrgather_vv(v13, v23, v24); + __ vrgather_vv(v26, v16, v24); + __ vrgather_vv(v27, v17, v24); + + __ vsetivli(x0, 4, Assembler::e32, Assembler::m1, Assembler::ma, Assembler::ta); + + __ vid_v(v31); + __ vadd_vi(v30, v31, 2); + __ vmsltu_vi(v0, v31, 2); + __ vrgather_vv(v17, v26, v30, Assembler::v0_t); + __ vmerge_vvm(v17, v27, v17); + __ vadd_vi(v30, v31, -2); + __ vnot_v(v0, v0); + __ vrgather_vv(v16, v27, v30, Assembler::v0_t); + __ vmerge_vvm(v16, v26, v16); + + __ vid_v(v0); + __ vmseq_vi(v0, v0, 0x0); + + __ la(t0, ExternalAddress((address)round_consts)); + + // Quad-round 0 (+0, Wt from oldest to newest in v10->v11->v12->v13) + __ vl1re32_v(v15, t0); + __ add(t0, t0, 16); + __ vadd_vv(v14, v15, v10); + __ vsha2cl_vv(v17, v16, v14); + __ vsha2ch_vv(v16, v17, v14); + __ vmerge_vvm(v14, v12, v11); + __ vsha2ms_vv(v10, v14, v13); // Generate W[19:16] + + // Quad-round 1 (+1, v11->v12->v13->v10) + __ vl1re32_v(v15, t0); + __ add(t0, t0, 16); + __ vadd_vv(v14, v15, v11); + __ vsha2cl_vv(v17, v16, v14); + __ vsha2ch_vv(v16, v17, v14); + __ vmerge_vvm(v14, v13, v12); + __ vsha2ms_vv(v11, v14, v10); // Generate W[23:20] + + // Quad-round 2 (+2, v12->v13->v10->v11) + __ vl1re32_v(v15, t0); + __ add(t0, t0, 16); + __ vadd_vv(v14, v15, v12); + __ vsha2cl_vv(v17, v16, v14); + __ vsha2ch_vv(v16, v17, v14); + __ vmerge_vvm(v14, v10, v13); + __ vsha2ms_vv(v12, v14, v11); // Generate W[27:24] + + // Quad-round 3 (+3, v13->v10->v11->v12) + __ vl1re32_v(v15, t0); + __ add(t0, t0, 16); + __ vadd_vv(v14, v15, v13); + __ vsha2cl_vv(v17, v16, v14); + __ vsha2ch_vv(v16, v17, v14); + __ vmerge_vvm(v14, v11, v10); + __ vsha2ms_vv(v13, v14, v12); // Generate W[31:28] + + // Quad-round 4 (+0, v10->v11->v12->v13) + __ vl1re32_v(v15, t0); + __ add(t0, t0, 16); + __ vadd_vv(v14, v15, v10); + __ vsha2cl_vv(v17, v16, v14); + __ vsha2ch_vv(v16, v17, v14); + __ vmerge_vvm(v14, v12, v11); + __ vsha2ms_vv(v10, v14, v13); // Generate W[35:32] + + // Quad-round 5 (+1, v11->v12->v13->v10) + __ vl1re32_v(v15, t0); + __ add(t0, t0, 16); + __ vadd_vv(v14, v15, v11); + __ vsha2cl_vv(v17, v16, v14); + __ vsha2ch_vv(v16, v17, v14); + __ vmerge_vvm(v14, v13, v12); + __ vsha2ms_vv(v11, v14, v10); // Generate W[39:36] + + // Quad-round 6 (+2, v12->v13->v10->v11) + __ vl1re32_v(v15, t0); + __ add(t0, t0, 16); + __ vadd_vv(v14, v15, v12); + __ vsha2cl_vv(v17, v16, v14); + __ vsha2ch_vv(v16, v17, v14); + __ vmerge_vvm(v14, v10, v13); + __ vsha2ms_vv(v12, v14, v11); // Generate W[43:40] + + // Quad-round 7 (+3, v13->v10->v11->v12) + __ vl1re32_v(v15, t0); + __ add(t0, t0, 16); + __ vadd_vv(v14, v15, v13); + __ vsha2cl_vv(v17, v16, v14); + __ vsha2ch_vv(v16, v17, v14); + __ vmerge_vvm(v14, v11, v10); + __ vsha2ms_vv(v13, v14, v12); // Generate W[47:44] + + // Quad-round 8 (+0, v10->v11->v12->v13) + __ vl1re32_v(v15, t0); + __ add(t0, t0, 16); + __ vadd_vv(v14, v15, v10); + __ vsha2cl_vv(v17, v16, v14); + __ vsha2ch_vv(v16, v17, v14); + __ vmerge_vvm(v14, v12, v11); + __ vsha2ms_vv(v10, v14, v13); // Generate W[51:48] + + // Quad-round 9 (+1, v11->v12->v13->v10) + __ vl1re32_v(v15, t0); + __ add(t0, t0, 16); + __ vadd_vv(v14, v15, v11); + __ vsha2cl_vv(v17, v16, v14); + __ vsha2ch_vv(v16, v17, v14); + __ vmerge_vvm(v14, v13, v12); + __ vsha2ms_vv(v11, v14, v10); // Generate W[55:52] + + // Quad-round 10 (+2, v12->v13->v10->v11) + __ vl1re32_v(v15, t0); + __ add(t0, t0, 16); + __ vadd_vv(v14, v15, v12); + __ vsha2cl_vv(v17, v16, v14); + __ vsha2ch_vv(v16, v17, v14); + __ vmerge_vvm(v14, v10, v13); + __ vsha2ms_vv(v12, v14, v11); // Generate W[59:56] + + // Quad-round 11 (+3, v13->v10->v11->v12) + __ vl1re32_v(v15, t0); + __ add(t0, t0, 16); + __ vadd_vv(v14, v15, v13); + __ vsha2cl_vv(v17, v16, v14); + __ vsha2ch_vv(v16, v17, v14); + __ vmerge_vvm(v14, v11, v10); + __ vsha2ms_vv(v13, v14, v12); // Generate W[63:60] + + // Quad-round 12 (+0, v10->v11->v12->v13) + __ vl1re32_v(v15, t0); + __ add(t0, t0, 16); + __ vadd_vv(v14, v15, v10); + __ vsha2cl_vv(v17, v16, v14); + __ vsha2ch_vv(v16, v17, v14); + + // Quad-round 13 (+1, v11->v12->v13->v10) + __ vl1re32_v(v15, t0); + __ add(t0, t0, 16); + __ vadd_vv(v14, v15, v11); + __ vsha2cl_vv(v17, v16, v14); + __ vsha2ch_vv(v16, v17, v14); + + // Quad-round 14 (+2, v12->v13->v10->v11) + __ vl1re32_v(v15, t0); + __ add(t0, t0, 16); + __ vadd_vv(v14, v15, v12); + __ vsha2cl_vv(v17, v16, v14); + __ vsha2ch_vv(v16, v17, v14); + + // Quad-round 15 (+3, v13->v10->v11->v12) + __ vl1re32_v(v15, t0); + __ add(t0, t0, 16); + __ vadd_vv(v14, v15, v13); + __ vsha2cl_vv(v17, v16, v14); + __ vsha2ch_vv(v16, v17, v14); + + __ vid_v(v31); + + __ vadd_vi(v30, v31, 2); + __ vmsltu_vi(v0, v31, 2); + __ vrgather_vv(v19, v16, v30, Assembler::v0_t); + __ vmerge_vvm(v19, v17, v19); + __ vadd_vi(v30, v31, -2); + __ vnot_v(v0, v0); + __ vrgather_vv(v18, v17, v30, Assembler::v0_t); + __ vmerge_vvm(v18, v16, v18); + + __ vadd_vv(v18, v26, v18); + __ vadd_vv(v19, v27, v19); + + __ vsetivli(x0, 16, Assembler::e8, Assembler::m1, Assembler::ma, Assembler::ta); + __ vid_v(v24); + __ vxor_vi(v24, v24, 0x3); + + __ vrgather_vv(v16, v18, v24); + __ vrgather_vv(v17, v19, v24); + + if (multi_block) { + __ add(ofs, ofs, 64); + __ ble(ofs, limit, multi_block_loop); + __ mv(c_rarg0, ofs); // return ofs + } + + __ vsetivli(x0, 4, Assembler::e32, Assembler::m1, Assembler::ma, Assembler::ta); + __ vle32_v(v17, c_rarg1); + __ add(c_rarg1, c_rarg1, -16); + __ vle32_v(v16, c_rarg1); + + __ leave(); + __ ret(); + + return start; + } + // Continuation point for throwing of implicit exceptions that are // not handled in the current activation. Fabricates an exception // oop and initiates normal exception dispatching in this @@ -3960,6 +4219,11 @@ class StubGenerator: public StubCodeGenerator { } #endif + if (UseSHA256Intrinsics) { + StubRoutines::_sha256_implCompress = generate_sha256_implCompress(false, "sha256_implCompress"); + StubRoutines::_sha256_implCompressMB = generate_sha256_implCompress(true, "sha256_implCompressMB"); + } + generate_compare_long_strings(); generate_string_indexof_stubs(); diff --git a/src/hotspot/cpu/riscv/vm_version_riscv.cpp b/src/hotspot/cpu/riscv/vm_version_riscv.cpp index 10b77bedd44c6..4cf8ad7328089 100644 --- a/src/hotspot/cpu/riscv/vm_version_riscv.cpp +++ b/src/hotspot/cpu/riscv/vm_version_riscv.cpp @@ -71,7 +71,11 @@ void VM_Version::initialize() { FLAG_SET_DEFAULT(UseSHA1Intrinsics, false); } - if (UseSHA256Intrinsics) { + if (UseZvknha) { + if (FLAG_IS_DEFAULT(UseSHA256Intrinsics)) { + FLAG_SET_DEFAULT(UseSHA256Intrinsics, true); + } + } else if (UseSHA256Intrinsics) { warning("Intrinsics for SHA-224 and SHA-256 crypto hash functions not available on this CPU."); FLAG_SET_DEFAULT(UseSHA256Intrinsics, false); } From 88784667d14155236bd889c8bc712fb551e6bae3 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Wed, 26 Oct 2022 14:08:27 +0200 Subject: [PATCH 33/85] Update gcc version (#44) --- .github/workflows/main.yml | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d8ebf682e2595..68f88b85b3d4d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -132,7 +132,7 @@ jobs: with: platform: linux-x64 gcc-major-version: '10' - apt-gcc-version: '10.3.0-15ubuntu1' + apt-gcc-version: '10.4.0-4ubuntu1~22.04' configure-arguments: ${{ github.event.inputs.configure-arguments }} make-arguments: ${{ github.event.inputs.make-arguments }} # The linux-x64 jdk bundle is used as buildjdk for the cross-compile job @@ -146,7 +146,7 @@ jobs: platform: linux-x86 gcc-major-version: '10' gcc-package-suffix: '-multilib' - apt-gcc-version: '10.3.0-15ubuntu1' + apt-gcc-version: '10.4.0-4ubuntu1~22.04' apt-architecture: 'i386' # Some multilib libraries do not have proper inter-dependencies, so we have to # install their dependencies manually. @@ -165,7 +165,7 @@ jobs: make-target: 'hotspot' debug-levels: '[ "debug" ]' gcc-major-version: '10' - apt-gcc-version: '10.3.0-15ubuntu1' + apt-gcc-version: '10.4.0-4ubuntu1~22.04' extra-conf-options: '--disable-precompiled-headers' configure-arguments: ${{ github.event.inputs.configure-arguments }} make-arguments: ${{ github.event.inputs.make-arguments }} @@ -180,7 +180,7 @@ jobs: make-target: 'hotspot' debug-levels: '[ "debug" ]' gcc-major-version: '10' - apt-gcc-version: '10.3.0-15ubuntu1' + apt-gcc-version: '10.4.0-4ubuntu1~22.04' extra-conf-options: '--with-jvm-variants=zero --disable-precompiled-headers' configure-arguments: ${{ github.event.inputs.configure-arguments }} make-arguments: ${{ github.event.inputs.make-arguments }} @@ -195,7 +195,7 @@ jobs: make-target: 'hotspot' debug-levels: '[ "debug" ]' gcc-major-version: '10' - apt-gcc-version: '10.3.0-15ubuntu1' + apt-gcc-version: '10.4.0-4ubuntu1~22.04' extra-conf-options: '--with-jvm-variants=minimal --disable-precompiled-headers' configure-arguments: ${{ github.event.inputs.configure-arguments }} make-arguments: ${{ github.event.inputs.make-arguments }} @@ -211,7 +211,7 @@ jobs: # Technically this is not the "debug" level, but we can't inject a new matrix state for just this job debug-levels: '[ "debug" ]' gcc-major-version: '10' - apt-gcc-version: '10.3.0-15ubuntu1' + apt-gcc-version: '10.4.0-4ubuntu1~22.04' extra-conf-options: '--with-debug-level=optimized --disable-precompiled-headers' configure-arguments: ${{ github.event.inputs.configure-arguments }} make-arguments: ${{ github.event.inputs.make-arguments }} @@ -226,8 +226,8 @@ jobs: with: platform: linux-aarch64 gcc-major-version: '10' - apt-gcc-version: '10.3.0-15ubuntu1' - apt-gcc-cross-version: '10.3.0-8ubuntu1cross1' + apt-gcc-version: '10.4.0-4ubuntu1~22.04' + apt-gcc-cross-version: '10.4.0-4ubuntu1~22.04cross1' if: needs.select.outputs.linux-cross-compile == 'true' build-linux-arm: @@ -239,8 +239,8 @@ jobs: with: platform: linux-arm gcc-major-version: '10' - apt-gcc-version: '10.3.0-15ubuntu1' - apt-gcc-cross-version: '10.3.0-8ubuntu1cross1' + apt-gcc-version: '10.4.0-4ubuntu1~22.04' + apt-gcc-cross-version: '10.4.0-4ubuntu1~22.04cross1' if: needs.select.outputs.linux-cross-compile == 'true' build-linux-ppc64le: @@ -252,8 +252,8 @@ jobs: with: platform: linux-ppc64le gcc-major-version: '10' - apt-gcc-version: '10.3.0-15ubuntu1' - apt-gcc-cross-version: '10.3.0-8ubuntu1cross1' + apt-gcc-version: '10.4.0-4ubuntu1~22.04' + apt-gcc-cross-version: '10.4.0-4ubuntu1~22.04cross1' if: needs.select.outputs.linux-cross-compile == 'true' build-linux-riscv64: @@ -265,8 +265,8 @@ jobs: with: platform: linux-riscv64 gcc-major-version: '10' - apt-gcc-version: '10.3.0-15ubuntu1' - apt-gcc-cross-version: '10.3.0-8ubuntu1cross1' + apt-gcc-version: '10.4.0-4ubuntu1~22.04' + apt-gcc-cross-version: '10.4.0-4ubuntu1~22.04cross1' if: needs.select.outputs.linux-cross-compile == 'true' build-linux-s390x: @@ -278,8 +278,8 @@ jobs: with: platform: linux-s390x gcc-major-version: '10' - apt-gcc-version: '10.3.0-15ubuntu1' - apt-gcc-cross-version: '10.3.0-8ubuntu1cross1' + apt-gcc-version: '10.4.0-4ubuntu1~22.04' + apt-gcc-cross-version: '10.4.0-4ubuntu1~22.04cross1' configure-arguments: ${{ github.event.inputs.configure-arguments }} make-arguments: ${{ github.event.inputs.make-arguments }} if: needs.select.outputs.linux-cross-compile == 'true' From e5c7b03ba90178c86c21639b05345ccbb17e3637 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Thu, 27 Oct 2022 19:00:25 +0200 Subject: [PATCH 34/85] Use assignee rather than reviewer for downstreaming PRs (#46) --- .github/workflows/downstream.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/downstream.yml b/.github/workflows/downstream.yml index 93ff66c64a0dd..860a95a505ab5 100644 --- a/.github/workflows/downstream.yml +++ b/.github/workflows/downstream.yml @@ -85,7 +85,7 @@ jobs: --head rivos/merge-${{ steps.configure.outputs.tag }} \ --title "Merge ${{ steps.configure.outputs.tag }} into rivos/main" \ --body "" \ - --reviewer "luhenry" || true + --assignee "luhenry" || true fi env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} From 288f919d7701514807018a637a79cf94cc2bec66 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Fri, 28 Oct 2022 21:09:45 +0200 Subject: [PATCH 35/85] 8295383: Implement SHA-512 Intrinsic on RISC-V (#43) --- src/hotspot/cpu/riscv/stubGenerator_riscv.cpp | 302 ++++++++++++++++++ src/hotspot/cpu/riscv/vm_version_riscv.cpp | 6 +- 2 files changed, 307 insertions(+), 1 deletion(-) diff --git a/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp b/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp index 1ffe42b624494..ec69d6c98a555 100644 --- a/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp +++ b/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp @@ -3932,6 +3932,304 @@ class StubGenerator: public StubCodeGenerator { return start; } + // Arguments: + // + // Inputs: + // c_rarg0 - byte[] source+offset + // c_rarg1 - int[] SHA.state + // c_rarg2 - int offset + // c_rarg3 - int limit + // + address generate_sha512_implCompress(bool multi_block, const char *name) { + static const uint64_t round_consts[80] = { + 0x428a2f98d728ae22l, 0x7137449123ef65cdl, 0xb5c0fbcfec4d3b2fl, + 0xe9b5dba58189dbbcl, 0x3956c25bf348b538l, 0x59f111f1b605d019l, + 0x923f82a4af194f9bl, 0xab1c5ed5da6d8118l, 0xd807aa98a3030242l, + 0x12835b0145706fbel, 0x243185be4ee4b28cl, 0x550c7dc3d5ffb4e2l, + 0x72be5d74f27b896fl, 0x80deb1fe3b1696b1l, 0x9bdc06a725c71235l, + 0xc19bf174cf692694l, 0xe49b69c19ef14ad2l, 0xefbe4786384f25e3l, + 0x0fc19dc68b8cd5b5l, 0x240ca1cc77ac9c65l, 0x2de92c6f592b0275l, + 0x4a7484aa6ea6e483l, 0x5cb0a9dcbd41fbd4l, 0x76f988da831153b5l, + 0x983e5152ee66dfabl, 0xa831c66d2db43210l, 0xb00327c898fb213fl, + 0xbf597fc7beef0ee4l, 0xc6e00bf33da88fc2l, 0xd5a79147930aa725l, + 0x06ca6351e003826fl, 0x142929670a0e6e70l, 0x27b70a8546d22ffcl, + 0x2e1b21385c26c926l, 0x4d2c6dfc5ac42aedl, 0x53380d139d95b3dfl, + 0x650a73548baf63del, 0x766a0abb3c77b2a8l, 0x81c2c92e47edaee6l, + 0x92722c851482353bl, 0xa2bfe8a14cf10364l, 0xa81a664bbc423001l, + 0xc24b8b70d0f89791l, 0xc76c51a30654be30l, 0xd192e819d6ef5218l, + 0xd69906245565a910l, 0xf40e35855771202al, 0x106aa07032bbd1b8l, + 0x19a4c116b8d2d0c8l, 0x1e376c085141ab53l, 0x2748774cdf8eeb99l, + 0x34b0bcb5e19b48a8l, 0x391c0cb3c5c95a63l, 0x4ed8aa4ae3418acbl, + 0x5b9cca4f7763e373l, 0x682e6ff3d6b2b8a3l, 0x748f82ee5defb2fcl, + 0x78a5636f43172f60l, 0x84c87814a1f0ab72l, 0x8cc702081a6439ecl, + 0x90befffa23631e28l, 0xa4506cebde82bde9l, 0xbef9a3f7b2c67915l, + 0xc67178f2e372532bl, 0xca273eceea26619cl, 0xd186b8c721c0c207l, + 0xeada7dd6cde0eb1el, 0xf57d4f7fee6ed178l, 0x06f067aa72176fbal, + 0x0a637dc5a2c898a6l, 0x113f9804bef90dael, 0x1b710b35131c471bl, + 0x28db77f523047d84l, 0x32caab7b40c72493l, 0x3c9ebe0a15c9bebcl, + 0x431d67c49c100d4cl, 0x4cc5d4becb3e42b6l, 0x597f299cfc657e2al, + 0x5fcb6fab3ad6faecl, 0x6c44198c4a475817l + }; + __ align(CodeEntryAlignment); + StubCodeMark mark(this, "StubRoutines", name); + address start = __ pc(); + + Register buf = c_rarg0; + Register state = c_rarg1; + Register ofs = c_rarg2; + Register limit = c_rarg3; + + Label multi_block_loop; + + __ enter(); + + __ vsetivli(x0, 4, Assembler::e64, Assembler::m1, Assembler::ma, Assembler::ta); + __ vle64_v(v16, c_rarg1); + __ addi(c_rarg1, c_rarg1, 32); + __ vle64_v(v17, c_rarg1); + + __ bind(multi_block_loop); + + __ vsetivli(x0, 4, Assembler::e64, Assembler::m1, Assembler::ma, Assembler::ta); + __ vle64_v(v20, c_rarg0); + __ add(c_rarg0, c_rarg0, 32); + __ vle64_v(v21, c_rarg0); + __ add(c_rarg0, c_rarg0, 32); + __ vle64_v(v22, c_rarg0); + __ add(c_rarg0, c_rarg0, 32); + __ vle64_v(v23, c_rarg0); + __ add(c_rarg0, c_rarg0, 32); + + __ li(t0, 32); + __ vsetvli(x0, t0, Assembler::e8, Assembler::m1, Assembler::ma, Assembler::ta); + __ vid_v(v24); + __ vxor_vi(v24, v24, 0x7); + __ vrgather_vv(v26, v16, v24); + __ vrgather_vv(v27, v17, v24); + + __ vsetivli(x0, 4, Assembler::e64, Assembler::m1, Assembler::ma, Assembler::ta); + __ vid_v(v31); + __ vadd_vi(v30, v31, 2); + __ vmsltu_vi(v0, v31, 2); + __ vrgather_vv(v17, v26, v30, Assembler::v0_t); + __ vmerge_vvm(v17, v27, v17); + __ vadd_vi(v30, v31, -2); + __ vnot_v(v0, v0); + __ vrgather_vv(v16, v27, v30, Assembler::v0_t); + __ vmerge_vvm(v16, v26, v16); + + __ li(t0, 32); + __ vsetvli(x0, t0, Assembler::e8, Assembler::m1, Assembler::ma, Assembler::ta); + __ vid_v(v24); + __ vxor_vi(v24, v24, 0x7); + __ vrgather_vv(v10, v20, v24); + __ vrgather_vv(v11, v21, v24); + __ vrgather_vv(v12, v22, v24); + __ vrgather_vv(v13, v23, v24); + + __ vsetivli(x0, 4, Assembler::e64, Assembler::m1, Assembler::ma, Assembler::ta); + + __ vid_v(v0); + __ vmseq_vi(v0, v0, 0x0); + + __ la(t0, ExternalAddress((address)round_consts)); + + __ vl1re64_v(v15, t0); + __ addi(t0, t0, 32); + __ vadd_vv(v14, v15, v10); + __ vsha2cl_vv(v17, v16, v14); + __ vsha2ch_vv(v16, v17, v14); + __ vmerge_vvm(v14, v12, v11); + __ vsha2ms_vv(v10, v14, v13); + + __ vl1re64_v(v15, t0); + __ addi(t0, t0, 32); + __ vadd_vv(v14, v15, v11); + __ vsha2cl_vv(v17, v16, v14); + __ vsha2ch_vv(v16, v17, v14); + __ vmerge_vvm(v14, v13, v12); + __ vsha2ms_vv(v11, v14, v10); + + __ vl1re64_v(v15, t0); + __ addi(t0, t0, 32); + __ vadd_vv(v14, v15, v12); + __ vsha2cl_vv(v17, v16, v14); + __ vsha2ch_vv(v16, v17, v14); + __ vmerge_vvm(v14, v10, v13); + __ vsha2ms_vv(v12, v14, v11); + + __ vl1re64_v(v15, t0); + __ addi(t0, t0, 32); + __ vadd_vv(v14, v15, v13); + __ vsha2cl_vv(v17, v16, v14); + __ vsha2ch_vv(v16, v17, v14); + __ vmerge_vvm(v14, v11, v10); + __ vsha2ms_vv(v13, v14, v12); + + __ vl1re64_v(v15, t0); + __ addi(t0, t0, 32); + __ vadd_vv(v14, v15, v10); + __ vsha2cl_vv(v17, v16, v14); + __ vsha2ch_vv(v16, v17, v14); + __ vmerge_vvm(v14, v12, v11); + __ vsha2ms_vv(v10, v14, v13); + + __ vl1re64_v(v15, t0); + __ addi(t0, t0, 32); + __ vadd_vv(v14, v15, v11); + __ vsha2cl_vv(v17, v16, v14); + __ vsha2ch_vv(v16, v17, v14); + __ vmerge_vvm(v14, v13, v12); + __ vsha2ms_vv(v11, v14, v10); + + __ vl1re64_v(v15, t0); + __ addi(t0, t0, 32); + __ vadd_vv(v14, v15, v12); + __ vsha2cl_vv(v17, v16, v14); + __ vsha2ch_vv(v16, v17, v14); + __ vmerge_vvm(v14, v10, v13); + __ vsha2ms_vv(v12, v14, v11); + + __ vl1re64_v(v15, t0); + __ addi(t0, t0, 32); + __ vadd_vv(v14, v15, v13); + __ vsha2cl_vv(v17, v16, v14); + __ vsha2ch_vv(v16, v17, v14); + __ vmerge_vvm(v14, v11, v10); + __ vsha2ms_vv(v13, v14, v12); + + __ vl1re64_v(v15, t0); + __ addi(t0, t0, 32); + __ vadd_vv(v14, v15, v10); + __ vsha2cl_vv(v17, v16, v14); + __ vsha2ch_vv(v16, v17, v14); + __ vmerge_vvm(v14, v12, v11); + __ vsha2ms_vv(v10, v14, v13); + + __ vl1re64_v(v15, t0); + __ addi(t0, t0, 32); + __ vadd_vv(v14, v15, v11); + __ vsha2cl_vv(v17, v16, v14); + __ vsha2ch_vv(v16, v17, v14); + __ vmerge_vvm(v14, v13, v12); + __ vsha2ms_vv(v11, v14, v10); + + __ vl1re64_v(v15, t0); + __ addi(t0, t0, 32); + __ vadd_vv(v14, v15, v12); + __ vsha2cl_vv(v17, v16, v14); + __ vsha2ch_vv(v16, v17, v14); + __ vmerge_vvm(v14, v10, v13); + __ vsha2ms_vv(v12, v14, v11); + + __ vl1re64_v(v15, t0); + __ addi(t0, t0, 32); + __ vadd_vv(v14, v15, v13); + __ vsha2cl_vv(v17, v16, v14); + __ vsha2ch_vv(v16, v17, v14); + __ vmerge_vvm(v14, v11, v10); + __ vsha2ms_vv(v13, v14, v12); + + __ vl1re64_v(v15, t0); + __ addi(t0, t0, 32); + __ vadd_vv(v14, v15, v10); + __ vsha2cl_vv(v17, v16, v14); + __ vsha2ch_vv(v16, v17, v14); + __ vmerge_vvm(v14, v12, v11); + __ vsha2ms_vv(v10, v14, v13); + + __ vl1re64_v(v15, t0); + __ addi(t0, t0, 32); + __ vadd_vv(v14, v15, v11); + __ vsha2cl_vv(v17, v16, v14); + __ vsha2ch_vv(v16, v17, v14); + __ vmerge_vvm(v14, v13, v12); + __ vsha2ms_vv(v11, v14, v10); + + __ vl1re64_v(v15, t0); + __ addi(t0, t0, 32); + __ vadd_vv(v14, v15, v12); + __ vsha2cl_vv(v17, v16, v14); + __ vsha2ch_vv(v16, v17, v14); + __ vmerge_vvm(v14, v10, v13); + __ vsha2ms_vv(v12, v14, v11); + + __ vl1re64_v(v15, t0); + __ addi(t0, t0, 32); + __ vadd_vv(v14, v15, v13); + __ vsha2cl_vv(v17, v16, v14); + __ vsha2ch_vv(v16, v17, v14); + __ vmerge_vvm(v14, v11, v10); + __ vsha2ms_vv(v13, v14, v12); + + __ vl1re64_v(v15, t0); + __ addi(t0, t0, 32); + __ vadd_vv(v14, v15, v10); + __ vsha2cl_vv(v17, v16, v14); + __ vsha2ch_vv(v16, v17, v14); + __ vmerge_vvm(v14, v12, v11); + __ vsha2ms_vv(v10, v14, v13); + + __ vl1re64_v(v15, t0); + __ addi(t0, t0, 32); + __ vadd_vv(v14, v15, v11); + __ vsha2cl_vv(v17, v16, v14); + __ vsha2ch_vv(v16, v17, v14); + __ vmerge_vvm(v14, v13, v12); + __ vsha2ms_vv(v11, v14, v10); + + __ vl1re64_v(v15, t0); + __ addi(t0, t0, 32); + __ vadd_vv(v14, v15, v12); + __ vsha2cl_vv(v17, v16, v14); + __ vsha2ch_vv(v16, v17, v14); + __ vmerge_vvm(v14, v10, v13); + __ vsha2ms_vv(v12, v14, v11); + + __ vl1re64_v(v15, t0); + __ addi(t0, t0, 32); + __ vadd_vv(v14, v15, v13); + __ vsha2cl_vv(v17, v16, v14); + __ vsha2ch_vv(v16, v17, v14); + + __ vid_v(v31); + + __ vadd_vi(v30, v31, 2); + __ vmsltu_vi(v0, v31, 2); + __ vrgather_vv(v19, v16, v30, Assembler::v0_t); + __ vmerge_vvm(v19, v17, v19); + __ vadd_vi(v30, v31, -2); + __ vnot_v(v0, v0); + __ vrgather_vv(v18, v17, v30, Assembler::v0_t); + __ vmerge_vvm(v18, v16, v18); + + __ vadd_vv(v18, v26, v18); + __ vadd_vv(v19, v27, v19); + + __ li(t0, 32); + __ vsetvli(x0, t0, Assembler::e8, Assembler::m1, Assembler::ma, Assembler::ta); + __ vid_v(v24); + __ vxor_vi(v24, v24, 0x7); + __ vrgather_vv(v16, v18, v24); + __ vrgather_vv(v17, v19, v24); + + if (multi_block) { + __ add(ofs, ofs, 128); + __ ble(ofs, limit, multi_block_loop); + __ mv(c_rarg0, ofs); // return ofs + } + + __ vsetivli(x0, 4, Assembler::e64, Assembler::m1, Assembler::ma, Assembler::ta); + __ vse64_v(v17, c_rarg1); + __ addi(c_rarg1, c_rarg1, -32); + __ vse64_v(v16, c_rarg1); + + __ leave(); + __ ret(); + + return start; + } + // Continuation point for throwing of implicit exceptions that are // not handled in the current activation. Fabricates an exception // oop and initiates normal exception dispatching in this @@ -4222,6 +4520,10 @@ class StubGenerator: public StubCodeGenerator { StubRoutines::_sha256_implCompress = generate_sha256_implCompress(false, "sha256_implCompress"); StubRoutines::_sha256_implCompressMB = generate_sha256_implCompress(true, "sha256_implCompressMB"); } + if (UseSHA512Intrinsics) { + StubRoutines::_sha512_implCompress = generate_sha512_implCompress(false, "sha512_implCompress"); + StubRoutines::_sha512_implCompressMB = generate_sha512_implCompress(true, "sha512_implCompressMB"); + } generate_compare_long_strings(); diff --git a/src/hotspot/cpu/riscv/vm_version_riscv.cpp b/src/hotspot/cpu/riscv/vm_version_riscv.cpp index adddfd57ba210..36d418951ed79 100644 --- a/src/hotspot/cpu/riscv/vm_version_riscv.cpp +++ b/src/hotspot/cpu/riscv/vm_version_riscv.cpp @@ -124,7 +124,11 @@ void VM_Version::initialize() { FLAG_SET_DEFAULT(UseSHA256Intrinsics, false); } - if (UseSHA512Intrinsics) { + if (UseZvknhb) { + if (FLAG_IS_DEFAULT(UseSHA512Intrinsics)) { + FLAG_SET_DEFAULT(UseSHA512Intrinsics, true); + } + } else if (UseSHA512Intrinsics) { warning("Intrinsics for SHA-384 and SHA-512 crypto hash functions not available on this CPU."); FLAG_SET_DEFAULT(UseSHA512Intrinsics, false); } From 4700525d70d2d22c3a2ad8ed582e164b8e5fb100 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Fri, 28 Oct 2022 21:14:19 +0200 Subject: [PATCH 36/85] Remove dead code (#47) --- src/hotspot/cpu/riscv/vm_version_riscv.cpp | 1 - src/hotspot/cpu/riscv/vm_version_riscv.hpp | 3 - .../linux_riscv/vm_version_linux_riscv.cpp | 2 - .../bench/util/Gem5CheckpointProfiler.java | 100 ------------------ 4 files changed, 106 deletions(-) delete mode 100644 test/micro/org/openjdk/bench/util/Gem5CheckpointProfiler.java diff --git a/src/hotspot/cpu/riscv/vm_version_riscv.cpp b/src/hotspot/cpu/riscv/vm_version_riscv.cpp index 36d418951ed79..3d2cf233d175e 100644 --- a/src/hotspot/cpu/riscv/vm_version_riscv.cpp +++ b/src/hotspot/cpu/riscv/vm_version_riscv.cpp @@ -31,7 +31,6 @@ #include "utilities/macros.hpp" const char* VM_Version::_uarch = ""; -uint32_t VM_Version::_cache_line_size; uint32_t VM_Version::_initial_vector_length = 0; void VM_Version::initialize() { diff --git a/src/hotspot/cpu/riscv/vm_version_riscv.hpp b/src/hotspot/cpu/riscv/vm_version_riscv.hpp index e6e72166bd673..1d6eeb97504c9 100644 --- a/src/hotspot/cpu/riscv/vm_version_riscv.hpp +++ b/src/hotspot/cpu/riscv/vm_version_riscv.hpp @@ -40,7 +40,6 @@ class VM_Version : public Abstract_VM_Version { protected: static const char* _uarch; - static uint32_t _cache_line_size; static uint32_t _initial_vector_length; static void get_os_cpu_info(); static uint32_t get_current_vector_length(); @@ -67,8 +66,6 @@ class VM_Version : public Abstract_VM_Version { }; static void initialize_cpu_information(void); - - static int cache_line_size() { return _cache_line_size; } }; #endif // CPU_RISCV_VM_VERSION_RISCV_HPP diff --git a/src/hotspot/os_cpu/linux_riscv/vm_version_linux_riscv.cpp b/src/hotspot/os_cpu/linux_riscv/vm_version_linux_riscv.cpp index bcaa8b0101b1a..a954dcf5768ce 100644 --- a/src/hotspot/os_cpu/linux_riscv/vm_version_linux_riscv.cpp +++ b/src/hotspot/os_cpu/linux_riscv/vm_version_linux_riscv.cpp @@ -113,6 +113,4 @@ void VM_Version::get_os_cpu_info() { } fclose(f); } - - _cache_line_size = 64; } diff --git a/test/micro/org/openjdk/bench/util/Gem5CheckpointProfiler.java b/test/micro/org/openjdk/bench/util/Gem5CheckpointProfiler.java deleted file mode 100644 index 5be3352257ec6..0000000000000 --- a/test/micro/org/openjdk/bench/util/Gem5CheckpointProfiler.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (c) 2022, Rivos 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. - */ - -package org.openjdk.bench.util; - -import org.openjdk.jmh.infra.BenchmarkParams; -import org.openjdk.jmh.infra.IterationParams; -import org.openjdk.jmh.profile.InternalProfiler; -import org.openjdk.jmh.results.IterationResult; -import org.openjdk.jmh.results.Result; - -import java.lang.reflect.Method; -import java.util.Collection; -import java.util.Collections; -import java.util.Map; - -import static java.util.concurrent.TimeUnit.NANOSECONDS;; - -public class Gem5CheckpointProfiler implements InternalProfiler { - - static final Object gem5Instance; - static final Method gem5CheckpointMethod; - - static { - try { - Class gem5Class = Class.forName("gem5.Ops"); - gem5CheckpointMethod = getGem5CheckpointMethod(gem5Class); - gem5Instance = getGem5Instance(gem5Class); - } catch (Exception e) { - throw new RuntimeException("Failed to load Gem5 Ops", e); - } - } - - private static Method getGem5CheckpointMethod(Class gem5Class) throws Exception { - // void checkpoint(long ns_delay, long ns_period) - return gem5Class.getMethod("checkpoint", long.class, long.class); - } - - @SuppressWarnings("unchecked") - private static Object getGem5Instance(Class gem5Class) throws Exception { - return ((Map)gem5Class.getField("callTypes").get(null)).get("default"); - } - - /** - * Human-readable one-line description of the profiler. - * @return description - */ - public String getDescription() { - return "gem5 checkpointing"; - } - - /** - * Run this code before starting the next benchmark iteration. - * - * @param benchmarkParams benchmark parameters used for current launch - * @param iterationParams iteration parameters used for current launch - */ - public void beforeIteration(BenchmarkParams benchmarkParams, IterationParams iterationParams) { - try { - // artificially delay by 1us to not capture the setting up of the iterations - gem5CheckpointMethod.invoke(gem5Instance, Long.valueOf(1000), Long.valueOf(iterationParams.getTime().convertTo(NANOSECONDS))); - } catch (Exception e) { - throw new RuntimeException("Failed to ivoke Gem5 checkpointing", e); - } - } - - /** - * Run this code after a benchmark iteration finished - * - * @param benchmarkParams benchmark parameters used for current launch - * @param iterationParams iteration parameters used for current launch - * @param result iteration result - * @return profiler results - */ - public Collection afterIteration(BenchmarkParams benchmarkParams, IterationParams iterationParams, IterationResult result) { - return Collections.emptyList(); - } - - private static final native void m5_checkpoint(long ns_delay, long ns_period); -} From 297f27e19169370c18082c478064432e175283bd Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Sun, 30 Oct 2022 23:15:38 +0100 Subject: [PATCH 37/85] Make sure posix_spawn works on qemu-user mode (#49) --- src/java.base/unix/native/libjava/ProcessImpl_md.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/java.base/unix/native/libjava/ProcessImpl_md.c b/src/java.base/unix/native/libjava/ProcessImpl_md.c index a01a67ed35b92..82d07eb047d40 100644 --- a/src/java.base/unix/native/libjava/ProcessImpl_md.c +++ b/src/java.base/unix/native/libjava/ProcessImpl_md.c @@ -488,7 +488,7 @@ spawnChild(JNIEnv *env, jobject process, ChildStuff *c, const char *helperpath) pid_t resultPid; int i, offset, rval, bufsize, magic; char *buf, buf1[16]; - char *hlpargs[2]; + char *hlpargs[3]; SpawnInfo sp; /* need to tell helper which fd is for receiving the childstuff @@ -496,8 +496,9 @@ spawnChild(JNIEnv *env, jobject process, ChildStuff *c, const char *helperpath) */ snprintf(buf1, sizeof(buf1), "%d:%d", c->childenv[0], c->fail[1]); /* put the fd string as argument to the helper cmd */ - hlpargs[0] = buf1; - hlpargs[1] = 0; + hlpargs[0] = (char*)helperpath; + hlpargs[1] = buf1; + hlpargs[2] = 0; /* Following items are sent down the pipe to the helper * after it is spawned. From 564ac55491c65ab95d3ac2ff5572e362730e35cd Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Sun, 30 Oct 2022 23:16:07 +0100 Subject: [PATCH 38/85] Fix ::set-output being deprecated warning (#48) --- .../init-platform-variables/action.yml | 54 +++++++++---------- .github/workflows/downstream.yml | 4 +- .github/workflows/test-cross-compile.yml | 2 +- 3 files changed, 30 insertions(+), 30 deletions(-) diff --git a/.github/actions/init-platform-variables/action.yml b/.github/actions/init-platform-variables/action.yml index 8e50dee72efd4..7aecc37f959de 100644 --- a/.github/actions/init-platform-variables/action.yml +++ b/.github/actions/init-platform-variables/action.yml @@ -56,37 +56,37 @@ runs: id: platform-variables run: | if [[ '${{ inputs.platform }}' == 'linux-aarch64' ]]; then - echo '::set-output name=target-cpu::aarch64' - echo '::set-output name=gnu-arch::aarch64' - echo '::set-output name=debian-arch::arm64' - echo '::set-output name=debian-repository::https://httpredir.debian.org/debian/' - echo '::set-output name=debian-version::bullseye' + echo "target-cpu=aarch64" >> $GITHUB_OUTPUT + echo "gnu-arch=aarch64" >> $GITHUB_OUTPUT + echo "debian-arch=arm64" >> $GITHUB_OUTPUT + echo "debian-repository=https://httpredir.debian.org/debian/" >> $GITHUB_OUTPUT + echo "debian-version=bullseye" >> $GITHUB_OUTPUT elif [[ '${{ inputs.platform }}' == 'linux-arm' ]]; then - echo '::set-output name=target-cpu::arm' - echo '::set-output name=gnu-arch::arm' - echo '::set-output name=gnu-abi::eabihf' - echo '::set-output name=debian-arch::armhf' - echo '::set-output name=debian-repository::https://httpredir.debian.org/debian/' - echo '::set-output name=debian-version::bullseye' + echo "target-cpu=arm" >> $GITHUB_OUTPUT + echo "gnu-arch=arm" >> $GITHUB_OUTPUT + echo "gnu-abi=eabihf" >> $GITHUB_OUTPUT + echo "debian-arch=armhf" >> $GITHUB_OUTPUT + echo "debian-repository=https://httpredir.debian.org/debian/" >> $GITHUB_OUTPUT + echo "debian-version=bullseye" >> $GITHUB_OUTPUT elif [[ '${{ inputs.platform }}' == 'linux-s390x' ]]; then - echo '::set-output name=target-cpu::s390x' - echo '::set-output name=gnu-arch::s390x' - echo '::set-output name=debian-arch::s390x' - echo '::set-output name=debian-repository::https://httpredir.debian.org/debian/' - echo '::set-output name=debian-version::bullseye' + echo "target-cpu=s390x" >> $GITHUB_OUTPUT + echo "gnu-arch=s390x" >> $GITHUB_OUTPUT + echo "debian-arch=s390x" >> $GITHUB_OUTPUT + echo "debian-repository=https://httpredir.debian.org/debian/" >> $GITHUB_OUTPUT + echo "debian-version=bullseye" >> $GITHUB_OUTPUT elif [[ '${{ inputs.platform }}' == 'linux-ppc64le' ]]; then - echo '::set-output name=target-cpu::ppc64le' - echo '::set-output name=gnu-arch::powerpc64le' - echo '::set-output name=debian-arch::ppc64el' - echo '::set-output name=debian-repository::https://httpredir.debian.org/debian/' - echo '::set-output name=debian-version::bullseye' + echo "target-cpu=ppc64le" >> $GITHUB_OUTPUT + echo "gnu-arch=powerpc64le" >> $GITHUB_OUTPUT + echo "debian-arch=ppc64el" >> $GITHUB_OUTPUT + echo "debian-repository=https://httpredir.debian.org/debian/" >> $GITHUB_OUTPUT + echo "debian-version=bullseye" >> $GITHUB_OUTPUT elif [[ '${{ inputs.platform }}' == 'linux-riscv64' ]]; then - echo '::set-output name=target-cpu::riscv64' - echo '::set-output name=gnu-arch::riscv64' - echo '::set-output name=debian-arch::riscv64' - echo '::set-output name=debian-repository::https://deb.debian.org/debian-ports' - echo '::set-output name=debian-keyring::/usr/share/keyrings/debian-ports-archive-keyring.gpg' - echo '::set-output name=debian-version::sid' + echo "target-cpu=riscv64" >> $GITHUB_OUTPUT + echo "gnu-arch=riscv64" >> $GITHUB_OUTPUT + echo "debian-arch=riscv64" >> $GITHUB_OUTPUT + echo "debian-repository=https://deb.debian.org/debian-ports" >> $GITHUB_OUTPUT + echo "debian-keyring=/usr/share/keyrings/debian-ports-archive-keyring.gpg" >> $GITHUB_OUTPUT + echo "debian-version=sid" >> $GITHUB_OUTPUT else echo "Unknown platform ${{ inputs.platform }}" exit 1 diff --git a/.github/workflows/downstream.yml b/.github/workflows/downstream.yml index 860a95a505ab5..788497add392d 100644 --- a/.github/workflows/downstream.yml +++ b/.github/workflows/downstream.yml @@ -64,8 +64,8 @@ jobs: TAG=$(git tag | grep --extended-regexp '^jdk\-.*' | sort --version-sort | tail --lines 1 | tr --delete '\n') test -n "$TAG" - echo "::set-output name=tag::$TAG" - echo "::set-output name=diff::$(test -n "$(git diff rivos/main...$TAG)" && echo "true" || echo "false")" + echo "tag=$TAG" >> $GITHUB_OUTPUT + echo "diff=$(test -n "$(git diff rivos/main...$TAG)" && echo "true" || echo "false")" >> $GITHUB_OUTPUT - name: "Push" run: | diff --git a/.github/workflows/test-cross-compile.yml b/.github/workflows/test-cross-compile.yml index 45857c76389b3..24d2c60f87526 100644 --- a/.github/workflows/test-cross-compile.yml +++ b/.github/workflows/test-cross-compile.yml @@ -220,7 +220,7 @@ jobs: fi artifact_name="results-${{ inputs.platform }}-$(echo ${{ matrix.test-name }} | tr '/ ' '__')" - echo "::set-output name=artifact-name::$artifact_name" + echo "artifact-name=$artifact_name" >> $GITHUB_OUTPUT if: always() - name: 'Upload test results' From 3b73e07924db645b4465bb638b225d705944cdfe Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Sun, 30 Oct 2022 23:16:21 +0100 Subject: [PATCH 39/85] Some fixes for helper scripts (#51) It makes it easier to use worktrees --- configure-riscv64.sh | 2 +- run-tests.sh | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/configure-riscv64.sh b/configure-riscv64.sh index da281077eb789..75f41ae1dc105 100755 --- a/configure-riscv64.sh +++ b/configure-riscv64.sh @@ -5,7 +5,7 @@ DIST=${DIST:-focal} ARGS=( --openjdk-target=riscv64-linux-gnu --with-boot-jdk=/rivos/jdk - --with-build-jdk=$(pwd)/build/linux-x86_64-server-release/images/jdk + --with-build-jdk=/workspace/jdk/build/linux-x86_64-server-release/images/jdk # --with-debug-level=slowdebug --with-zlib=system --with-sysroot=/sysroot/$DIST-riscv64 diff --git a/run-tests.sh b/run-tests.sh index 8234554ee9b77..a8cb88c99c42f 100644 --- a/run-tests.sh +++ b/run-tests.sh @@ -3,9 +3,9 @@ CONF=${CONF:-linux-riscv64-server-release} TESTSUITE=test/hotspot/jtreg -NATIVEPATH=build/${CONF}/images/test/hotspot/jtreg/native +NATIVEPATH=$(pwd)/build/${CONF}/images/test/hotspot/jtreg/native -TMPDIR=${TMPDIR:-/workspace/jdk/build/run-test/tmp} +TMPDIR=${TMPDIR:-$(pwd)/build/run-test/tmp} mkdir -p ${TMPDIR} ARGS=( @@ -14,7 +14,7 @@ ARGS=( -Xmx1600M -Duser.language=en -Duser.country=US - -Djava.library.path="build/${CONF}/images/test/failure_handler" + -Djava.library.path="$(pwd)/build/${CONF}/images/test/failure_handler" -Dprogram=jtreg -jar /workspace/jtreg/build/images/jtreg/lib/jtreg.jar # JTreg arguments @@ -28,11 +28,11 @@ ARGS=( -automatic -ignore:quiet -e:JIB_DATA_DIR - -e:TEST_IMAGE_DIR=build/${CONF}/images/test - -dir:/workspace/jdk - -reportDir:/workspace/jdk/build/run-test/test-results - -workDir:/workspace/jdk/build/run-test/test-support - -testjdk:build/${CONF}/images/jdk + -e:TEST_IMAGE_DIR=$(pwd)/build/${CONF}/images/test + -dir:$(pwd) + -reportDir:$(pwd)/build/run-test/test-results + -workDir:$(pwd)/build/run-test/test-support + -testjdk:$(pwd)/build/${CONF}/images/jdk $(test -n "${NATIVEPATH}" && echo "-nativepath:${NATIVEPATH}"|| true) -exclude:${TESTSUITE}/ProblemList.txt -exclude:${TESTSUITE}/ProblemList-GHA.txt From eb7be7afec8f01d279c2d074104145b5aa90512a Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Tue, 1 Nov 2022 09:37:54 +0100 Subject: [PATCH 40/85] Log when a thread is starting (#50) Our checkpointing code doesn't support thread starting very well. Make sure we have a way to log and debug it. --- src/hotspot/share/logging/logAsyncWriter.hpp | 4 ---- src/hotspot/share/runtime/javaThread.cpp | 5 +++++ src/hotspot/share/runtime/nonJavaThread.cpp | 7 +++++++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/hotspot/share/logging/logAsyncWriter.hpp b/src/hotspot/share/logging/logAsyncWriter.hpp index b81015cd2deb8..6298dacf0c465 100644 --- a/src/hotspot/share/logging/logAsyncWriter.hpp +++ b/src/hotspot/share/logging/logAsyncWriter.hpp @@ -167,10 +167,6 @@ class AsyncLogWriter : public NonJavaThread { void enqueue_locked(LogFileStreamOutput* output, const LogDecorations& decorations, const char* msg); void write(); void run() override; - void pre_run() override { - NonJavaThread::pre_run(); - log_debug(logging, thread)("starting AsyncLog Thread tid = " INTX_FORMAT, os::current_thread_id()); - } const char* name() const override { return "AsyncLog Thread"; } const char* type_name() const override { return "AsyncLogWriter"; } void print_on(outputStream* st) const override { diff --git a/src/hotspot/share/runtime/javaThread.cpp b/src/hotspot/share/runtime/javaThread.cpp index d2d637d1451d4..e0798221e8de1 100644 --- a/src/hotspot/share/runtime/javaThread.cpp +++ b/src/hotspot/share/runtime/javaThread.cpp @@ -641,6 +641,11 @@ JavaThread::~JavaThread() { // First JavaThread specific code executed by a new Java thread. void JavaThread::pre_run() { + { + ResourceMark rm; + log_debug(logging, thread)("Starting %s thread, tid = " INTX_FORMAT, name(), os::current_thread_id()); + } + // empty - see comments in run() } diff --git a/src/hotspot/share/runtime/nonJavaThread.cpp b/src/hotspot/share/runtime/nonJavaThread.cpp index 32e4962bd73d9..a5bcefaeee252 100644 --- a/src/hotspot/share/runtime/nonJavaThread.cpp +++ b/src/hotspot/share/runtime/nonJavaThread.cpp @@ -26,6 +26,7 @@ #include "jvm_io.h" #include "gc/shared/barrierSet.hpp" #include "gc/shared/gcId.hpp" +#include "logging/log.hpp" #include "runtime/atomic.hpp" #include "runtime/javaThread.hpp" #include "runtime/jniHandles.hpp" @@ -36,6 +37,7 @@ #include "utilities/defaultStream.hpp" #include "utilities/singleWriterSynchronizer.hpp" #include "utilities/vmError.hpp" +#include "memory/resourceArea.hpp" #if INCLUDE_JFR #include "jfr/jfr.hpp" @@ -103,6 +105,11 @@ void NonJavaThread::remove_from_the_list() { } void NonJavaThread::pre_run() { + { + ResourceMark rm; + log_debug(logging, thread)("Starting %s thread, tid = " INTX_FORMAT, name(), os::current_thread_id()); + } + add_to_the_list(); // This is slightly odd in that NamedThread is a subclass, but From 68b4e89fc36c059c92ee03e9143313f2fca9cbd5 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Wed, 9 Nov 2022 18:40:20 +0100 Subject: [PATCH 41/85] Update rivos/gitlab-ci.yml file (#53) * Update rivos/gitlab-ci.yml file * 8294241: Deprecate URL public constructors Reviewed-by: joehw, prr, alanb, aefimov, michaelm Co-authored-by: Daniel Fuchs --- rivos/gitlab-ci.yml | 285 ++++++------- src/java.base/share/classes/java/io/File.java | 4 +- .../java/net/HttpConnectSocketImpl.java | 3 +- .../classes/java/net/JarURLConnection.java | 9 +- src/java.base/share/classes/java/net/URI.java | 2 +- src/java.base/share/classes/java/net/URL.java | 130 +++++- .../share/classes/java/security/Security.java | 10 +- .../javax/crypto/JceSecurity.java.template | 5 +- .../javax/crypto/ProviderVerifier.java | 1 + .../jdk/internal/loader/URLClassPath.java | 33 +- .../jdk/internal/module/ModulePatcher.java | 6 +- .../share/classes/sun/net/util/URLUtil.java | 1 + .../share/classes/sun/net/www/ParseUtil.java | 4 +- .../www/protocol/http/HttpURLConnection.java | 23 +- .../sun/net/www/protocol/jar/Handler.java | 15 +- .../jrt/JavaRuntimeURLConnection.java | 4 +- .../sun/security/provider/ConfigFile.java | 9 +- .../sun/security/provider/PolicyFile.java | 11 +- .../sun/security/provider/SeedGenerator.java | 1 + .../sun/security/provider/certpath/OCSP.java | 3 +- .../sun/security/tools/KeyStoreUtil.java | 3 +- .../classes/sun/security/tools/PathList.java | 4 +- .../classes/sun/security/util/PolicyUtil.java | 12 +- .../sun/net/www/protocol/file/Handler.java | 5 +- .../sun/security/provider/NativePRNG.java | 5 +- .../sun/net/www/protocol/file/Handler.java | 5 +- .../net/www/protocol/jar/JarFileFactory.java | 5 +- .../sun/lwawt/macosx/CDataTransferer.java | 6 +- .../classes/sun/lwawt/macosx/LWCToolkit.java | 4 +- .../com/sun/java/swing/plaf/gtk/Metacity.java | 6 +- .../share/classes/java/applet/Applet.java | 10 +- .../share/classes/java/awt/SplashScreen.java | 6 +- .../share/classes/java/beans/Beans.java | 12 +- .../classes/javax/swing/JEditorPane.java | 10 +- .../javax/swing/plaf/synth/SynthParser.java | 4 +- .../classes/javax/swing/text/html/CSS.java | 4 +- .../javax/swing/text/html/FormView.java | 7 +- .../javax/swing/text/html/FrameView.java | 6 +- .../javax/swing/text/html/HTMLDocument.java | 7 +- .../javax/swing/text/html/HTMLEditorKit.java | 13 +- .../javax/swing/text/html/ImageView.java | 3 +- .../javax/swing/text/html/IsindexView.java | 1 + .../javax/swing/text/html/StyleSheet.java | 2 + .../classes/sun/awt/image/URLImageSource.java | 9 +- .../unix/classes/sun/print/CUPSPrinter.java | 4 +- .../classes/sun/print/IPPPrintService.java | 12 +- .../sun/print/PrintServiceLookupProvider.java | 12 +- .../sun/awt/windows/WDataTransferer.java | 6 +- .../javax/management/loading/MLet.java | 5 +- .../javax/management/loading/MLetContent.java | 8 +- .../javax/management/loading/MLetParser.java | 1 + .../com/sun/jndi/ldap/VersionHelper.java | 1 + .../sun/naming/internal/VersionHelper.java | 6 +- .../classes/sun/rmi/server/LoaderHandler.java | 4 +- .../com/sun/tools/script/shell/Main.java | 6 +- .../sql/rowset/serial/SerialDatalink.java | 3 +- .../internal/xsltc/dom/DocumentCache.java | 1 + .../xsltc/trax/TransformerFactoryImpl.java | 3 +- .../internal/xsltc/trax/TransformerImpl.java | 3 +- .../internal/impl/XMLEntityManager.java | 4 +- .../internal/xinclude/XIncludeTextReader.java | 3 +- .../xml/internal/serializer/CharInfo.java | 3 +- .../xml/internal/serializer/Encodings.java | 3 +- .../serializer/dom3/LSSerializerImpl.java | 2 + .../internal/utils/ListingErrorHandler.java | 9 +- .../classes/javax/xml/catalog/BaseEntry.java | 8 +- .../javax/xml/catalog/CatalogImpl.java | 3 +- .../xml/catalog/CatalogResolverImpl.java | 15 +- .../jdk/xml/internal/SecuritySupport.java | 1 + .../com/sun/tools/javac/file/FSInfo.java | 3 +- .../com/sun/tools/javac/launcher/Main.java | 6 +- .../tools/javac/processing/ServiceProxy.java | 3 +- .../sun/security/tools/jarsigner/Main.java | 3 +- .../doclets/formats/html/HtmlOptions.java | 5 +- .../internal/doclets/toolkit/util/Extern.java | 7 +- .../classes/sun/tools/jconsole/JConsole.java | 4 +- .../jdk/internal/jshell/tool/JShellTool.java | 8 +- .../execution/DefaultLoaderDelegate.java | 7 +- .../auth/module/KeyStoreLoginModule.java | 11 +- test/jdk/java/net/URL/URIToURLTest.java | 7 +- test/jdk/java/net/URL/URLFromURITest.java | 377 ++++++++++++++++++ .../bench/java/net/ThreadLocalParseUtil.java | 3 +- .../java/security/ProtectionDomainBench.java | 1 + 83 files changed, 979 insertions(+), 300 deletions(-) create mode 100644 test/jdk/java/net/URL/URLFromURITest.java diff --git a/rivos/gitlab-ci.yml b/rivos/gitlab-ci.yml index c9dc1a54310d8..64346c3aa0b25 100644 --- a/rivos/gitlab-ci.yml +++ b/rivos/gitlab-ci.yml @@ -5,7 +5,8 @@ include: file: '/packager/gitlab-ci-packaging-helper.yml' variables: - CACHE_VERSION: "v2" + CACHE_VERSION: "v6" + BUILD_JDK_VERSION: 20 prepare-version: after_script: @@ -25,133 +26,58 @@ prepare-version: # Debugging helper - cat gitvars.env -create-sysroot-ubuntu-jammy-amd64: - stage: prebuild - image: ubuntu:20.04 - cache: - - key: sysroot-ubuntu-jammy-amd64-${CACHE_VERSION} - paths: - - sysroot-ubuntu-jammy-amd64 - script: - # early exit if sysroot-ubuntu-jammy-amd64 is coming from the cache - - test -d sysroot-ubuntu-jammy-amd64 && exit 0 - - apt-get update - - apt-get install -y debootstrap - - | - debootstrap \ - --verbose \ - --components=main,universe \ - --include=symlinks,qemu-user-static \ - --resolve-deps \ - jammy \ - sysroot-ubuntu-jammy-amd64 - - chroot sysroot-ubuntu-jammy-amd64 symlinks -cr . - - rm -rf sysroot-ubuntu-jammy-amd64/{dev,proc,run,sys} - artifacts: - when: always - paths: - - sysroot-ubuntu-jammy-amd64 - -create-sysroot-ubuntu-jammy-rv64: +.create-sysroot: stage: prebuild image: ubuntu:20.04 tags: - docker-qemu-binfmt - dependencies: - - create-sysroot-ubuntu-jammy-amd64 - needs: - - create-sysroot-ubuntu-jammy-amd64 cache: - when: on_success - key: sysroot-ubuntu-jammy-rv64-${CACHE_VERSION} + key: sysroot-${UBUNTU_CODENAME}-${PKG_ARCH}-${CACHE_VERSION} paths: - - sysroot-ubuntu-jammy-rv64 + - sysroot-${UBUNTU_CODENAME}-${PKG_ARCH} script: - # early exit if sysroot-ubuntu-jammy-rv64 is coming from the cache - - test -d sysroot-ubuntu-jammy-rv64 && exit 0 + # early exit if sysroot-${UBUNTU_CODENAME}-${PKG_ARCH} is coming from the cache + - test -d sysroot-${UBUNTU_CODENAME}-${PKG_ARCH} && exit 0 - apt-get update - apt-get install -y debootstrap qemu-user-static - | qemu-debootstrap \ --verbose \ - --arch=riscv64 \ + --arch=${PKG_ARCH} \ --components=main,universe \ --include=symlinks,build-essential,libx11-dev,libxext-dev,libxrender-dev,libxrandr-dev,libxtst-dev,libxt-dev,libcups2-dev,libfontconfig1-dev,libasound2-dev,libfreetype6-dev,libpng-dev \ - --resolve-deps \ - jammy \ - sysroot-ubuntu-jammy-rv64 - - cp -a sysroot-ubuntu-jammy-amd64/usr/bin/qemu-riscv64-static sysroot-ubuntu-jammy-rv64/usr/bin - - chroot sysroot-ubuntu-jammy-rv64 symlinks -cr . - - rm -rf sysroot-ubuntu-jammy-rv64/{dev,proc,run,sys} + ${UBUNTU_CODENAME} \ + sysroot-${UBUNTU_CODENAME}-${PKG_ARCH} \ + || (cat sysroot-${UBUNTU_CODENAME}-${PKG_ARCH}/debootstrap/debootstrap.log; exit 1) + - chroot sysroot-${UBUNTU_CODENAME}-${PKG_ARCH} symlinks -cr . + - rm -rf sysroot-${UBUNTU_CODENAME}-${PKG_ARCH}/{dev,proc,run,sys} artifacts: when: always paths: - - sysroot-ubuntu-jammy-rv64 + - sysroot-${UBUNTU_CODENAME}-${PKG_ARCH} -build-linux-amd64: - stage: build - image: ubuntu:20.04 +create-sysroot-amd64: + extends: .create-sysroot dependencies: - prepare-version needs: - prepare-version - script: - - apt-get update - - | - apt-get install -y \ - autoconf \ - build-essential \ - curl \ - file \ - g++ \ - gcc \ - libx11-dev \ - libxext-dev \ - libxrender-dev \ - libxrandr-dev \ - libxtst-dev \ - libxt-dev \ - libcups2-dev \ - libfontconfig1-dev \ - libasound2-dev \ - libfreetype6-dev \ - libpng-dev \ - unzip \ - zip \ - zlib1g-dev - - | - mkdir -p /usr/lib/jvm/zulu-20 - curl -L https://cdn.azul.com/zulu/bin/zulu20.0.45-ea-jdk20.0.0-ea.17-linux_x64.tar.gz \ - | tar -xzf - -C /usr/lib/jvm/zulu-20 --strip-components 1 - - | - bash configure \ - --openjdk-target=x86_64-linux-gnu \ - --with-conf-name=linux-amd64 \ - --with-vendor-name="Rivos Inc" \ - --with-version-pre="${JDK_VERSION_PRE}" \ - --with-version-opt="${JDK_VERSION_OPT}" \ - --with-boot-jdk=/usr/lib/jvm/zulu-20 \ - --disable-precompiled-headers \ - --with-zlib=system - - make jdk-image test-image LOG_LEVEL=info - artifacts: - when: always - paths: - - config.log # in case of error during configure - - build/linux-amd64/images/jdk - - build/linux-amd64/images/test + variables: + PKG_ARCH: amd64 -build-linux-rv64: - stage: build - image: ubuntu:20.04 +create-sysroot-riscv64: + extends: .create-sysroot dependencies: - prepare-version - - create-sysroot-ubuntu-jammy-rv64 - - build-linux-amd64 needs: - prepare-version - - create-sysroot-ubuntu-jammy-rv64 - - build-linux-amd64 + variables: + PKG_ARCH: riscv64 + +.build-linux: + stage: build + image: ubuntu:20.04 script: - apt-get update - | @@ -161,39 +87,59 @@ build-linux-rv64: curl \ file \ g++ \ - g++-riscv64-linux-gnu \ gcc \ - gcc-riscv64-linux-gnu \ - libasound2-dev \ - libcups2-dev \ - libxrandr-dev \ - libxtst-dev \ + $(test "${PKG_ARCH}" = "riscv64" && echo "g++-riscv64-linux-gnu" || true) \ + $(test "${PKG_ARCH}" = "riscv64" && echo "gcc-riscv64-linux-gnu" || true) \ unzip \ zip \ zlib1g-dev - | - mkdir -p /usr/lib/jvm/zulu-20 - curl -L https://cdn.azul.com/zulu/bin/zulu20.0.45-ea-jdk20.0.0-ea.17-linux_x64.tar.gz \ - | tar -xzf - -C /usr/lib/jvm/zulu-20 --strip-components 1 + mkdir -p /usr/lib/jvm/temurin-${BUILD_JDK_VERSION} + curl -L https://api.adoptium.net/v3/binary/latest/${BUILD_JDK_VERSION}/ea/linux/x64/jdk/hotspot/normal/eclipse\?project\=jdk \ + | tar -xzf - -C /usr/lib/jvm/temurin-${BUILD_JDK_VERSION} --strip-components 1 - | bash configure \ - --openjdk-target=riscv64-linux-gnu \ - --with-conf-name=linux-rv64 \ + --openjdk-target=${PKG_ARCH}-linux-gnu \ + --with-conf-name=linux-${PKG_ARCH} \ --with-vendor-name="Rivos Inc" \ --with-version-pre="${JDK_VERSION_PRE}" \ --with-version-opt="${JDK_VERSION_OPT}" \ - --with-sysroot=$(pwd)/sysroot-ubuntu-jammy-rv64 \ - --with-boot-jdk=/usr/lib/jvm/zulu-20 \ - --with-build-jdk=$(pwd)/build/linux-amd64/images/jdk \ + --with-sysroot=$(pwd)/sysroot-${UBUNTU_CODENAME}-${PKG_ARCH} \ + --with-boot-jdk=/usr/lib/jvm/temurin-20 \ + --with-build-jdk=/usr/lib/jvm/temurin-20 \ --disable-precompiled-headers \ --with-zlib=system - - make jdk-image test-image LOG_LEVEL=info + - make ${MAKE_TARGETS} LOG_LEVEL=info artifacts: when: always paths: - config.log # in case of error during configure - - build/linux-rv64/images/jdk - - build/linux-rv64/images/test + - build/linux-${PKG_ARCH}/images/jdk + - build/linux-${PKG_ARCH}/images/test + +build-linux-amd64: + extends: .build-linux + dependencies: + - prepare-version + - create-sysroot-amd64 + needs: + - prepare-version + - create-sysroot-amd64 + variables: + PKG_ARCH: amd64 + MAKE_TARGETS: jdk-image + +build-linux-riscv64: + extends: .build-linux + dependencies: + - prepare-version + - create-sysroot-riscv64 + needs: + - prepare-version + - create-sysroot-riscv64 + variables: + PKG_ARCH: riscv64 + MAKE_TARGETS: jdk-image test-image package-tar: stage: deploy @@ -201,70 +147,101 @@ package-tar: dependencies: - prepare-version - build-linux-amd64 - - build-linux-rv64 + - build-linux-riscv64 needs: - prepare-version - build-linux-amd64 - - build-linux-rv64 + - build-linux-riscv64 script: - apt-get update - apt-get install -y curl - tar -czf jdk-${JDK_VERSION_TAG}-linux-amd64.tar.gz -C build/linux-amd64/images jdk - 'curl -i --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file jdk-${JDK_VERSION_TAG}-linux-amd64.tar.gz "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/jdk/${JDK_VERSION_TAG}/jdk-${JDK_VERSION_TAG}-linux-amd64.tar.gz"' - - tar -czf jdk-${JDK_VERSION_TAG}-linux-rv64.tar.gz -C build/linux-rv64/images jdk - - 'curl -i --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file jdk-${JDK_VERSION_TAG}-linux-rv64.tar.gz "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/jdk/${JDK_VERSION_TAG}/jdk-${JDK_VERSION_TAG}-linux-rv64.tar.gz"' + - tar -czf jdk-${JDK_VERSION_TAG}-linux-riscv64.tar.gz -C build/linux-riscv64/images jdk + - 'curl -i --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file jdk-${JDK_VERSION_TAG}-linux-riscv64.tar.gz "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/jdk/${JDK_VERSION_TAG}/jdk-${JDK_VERSION_TAG}-linux-riscv64.tar.gz"' -package-deb: +.package-deb: extends: .deploy-deb + variables: + PKG_LICENSE: "GPL-2.0 license" + PKG_UPSTREAM_VERSION: "${JDK_VERSION_PKG}" + before_script: + # PKG_DIRECTORIES must be set + - test -n "${PKG_DIRECTORIES}" || exit 1 + # PKG_ARCH must be set + - test -n "${PKG_ARCH}" || exit 1 + # clean up pre-built binaries from the rivos-sdk + - rm -rf $(echo "${PKG_DIRECTORIES}" | tr ';' ' ') + # move the previous temporary install + - | + cp -av build/linux-${PKG_ARCH}/images/jdk /rivos/ + if [ "${PKG_ARCH}" = "amd64" ]; then + # put linux-riscv64 build in sysroot + mkdir -p /rivos/sysroot/riscv/rivos + cp -av build/linux-riscv64/images/jdk /rivos/sysroot/riscv/rivos + fi + - | + if [ "${PKG_DBG}" = "true" ]; then + find $(echo "${PKG_DIRECTORIES}" | tr ';' ' ') \( -xtype f -or -xtype l \) -not -name '*.debuginfo' -exec rm -f {} \; -print + find $(echo "${PKG_DIRECTORIES}" | tr ';' ' ') -type d -print | sort -r | xargs -I{} bash -c "rmdir {} || true" + else + # remove *.debuginfo files, they take a lot of space + find $(echo "${PKG_DIRECTORIES}" | tr ';' ' ') -type f -name '*.debuginfo' -exec rm -f {} \; -print + fi + +package-deb-amd64: + extends: .package-deb dependencies: - prepare-version - build-linux-amd64 - - build-linux-rv64 + - build-linux-riscv64 needs: - prepare-version - build-linux-amd64 - - build-linux-rv64 + - build-linux-riscv64 variables: - PKG_ARCH: "all" PKG_DIRECTORIES: "/rivos/jdk;/rivos/sysroot/riscv/rivos/jdk" - PKG_LICENSE: "GPL-2.0 license" - PKG_UPSTREAM_VERSION: "${JDK_VERSION_PKG}" - before_script: - # clean up pre-built binaries from the rivos-sdk - - rm -rf /rivos/jdk /rivos/sysroot/riscv/rivos/jdk - # move the previous temporary install - - mkdir -p /rivos/sysroot/riscv/rivos - - cp -a build/linux-amd64/images/jdk /rivos/ - - cp -a build/linux-rv64/images/jdk /rivos/sysroot/riscv/rivos - # remove *.debuginfo files, they take a lot of space - - find /rivos/jdk /rivos/sysroot/riscv/rivos/jdk -type f -name '*.debuginfo' -exec rm -f {} \; -print + PKG_ARCH: "amd64" -package-deb-dbg: - extends: .deploy-deb +package-deb-riscv64: + extends: .package-deb + dependencies: + - prepare-version + - build-linux-riscv64 + needs: + - prepare-version + - build-linux-riscv64 + variables: + PKG_DIRECTORIES: "/rivos/jdk" + PKG_ARCH: "riscv64" + +package-deb-dbg-amd64: + extends: .package-deb dependencies: - prepare-version - build-linux-amd64 - - build-linux-rv64 + - build-linux-riscv64 needs: - prepare-version - build-linux-amd64 - - build-linux-rv64 + - build-linux-riscv64 variables: - PKG_ARCH: "all" PKG_DIRECTORIES: "/rivos/jdk;/rivos/sysroot/riscv/rivos/jdk" - PKG_LICENSE: "GPL-2.0 license" - PKG_NAME: "${PROJECT_NAME}-dbg" - PKG_UPSTREAM_VERSION: "${JDK_VERSION_PKG}" - before_script: - # clean up pre-built binaries from the rivos-sdk - - rm -rf /rivos/jdk /rivos/sysroot/riscv/rivos/jdk - # move the previous temporary install - - mkdir -p /rivos/sysroot/riscv/rivos - - cp -a build/linux-amd64/images/jdk /rivos/ - - cp -a build/linux-rv64/images/jdk /rivos/sysroot/riscv/rivos - # remove non *.debuginfo files, we only want *.debuginfo for the -dbg package - - find /rivos/jdk /rivos/sysroot/riscv/rivos/jdk \( -xtype f -or -xtype l \) -not -name '*.debuginfo' -exec rm -f {} \; -print - - find /rivos/jdk /rivos/sysroot/riscv/rivos/jdk -type d -print | sort -r | xargs -I{} bash -c "rmdir {} || true" + PKG_ARCH: "amd64" + PKG_DBG: "true" + +package-deb-dbg-riscv64: + extends: .package-deb + dependencies: + - prepare-version + - build-linux-riscv64 + needs: + - prepare-version + - build-linux-riscv64 + variables: + PKG_DIRECTORIES: "/rivos/jdk" + PKG_ARCH: "riscv64" + PKG_DBG: "true" deploy-module-ubuntu: extends: .deploy-module diff --git a/src/java.base/share/classes/java/io/File.java b/src/java.base/share/classes/java/io/File.java index 8f1e88219fecd..2e3b8b0a9e480 100644 --- a/src/java.base/share/classes/java/io/File.java +++ b/src/java.base/share/classes/java/io/File.java @@ -694,7 +694,9 @@ public URL toURL() throws MalformedURLException { if (isInvalid()) { throw new MalformedURLException("Invalid file path"); } - return new URL("file", "", slashify(getAbsolutePath(), isDirectory())); + @SuppressWarnings("deprecation") + var result = new URL("file", "", slashify(getAbsolutePath(), isDirectory())); + return result; } /** diff --git a/src/java.base/share/classes/java/net/HttpConnectSocketImpl.java b/src/java.base/share/classes/java/net/HttpConnectSocketImpl.java index c0988050ef07a..c959816dadfbb 100644 --- a/src/java.base/share/classes/java/net/HttpConnectSocketImpl.java +++ b/src/java.base/share/classes/java/net/HttpConnectSocketImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 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 @@ -184,6 +184,7 @@ private Socket doTunnel(String urlString, int connectTimeout) throws IOException { Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(server, port)); + @SuppressWarnings("deprecation") URL destURL = new URL(urlString); HttpURLConnection conn = (HttpURLConnection) destURL.openConnection(proxy); conn.setConnectTimeout(connectTimeout); diff --git a/src/java.base/share/classes/java/net/JarURLConnection.java b/src/java.base/share/classes/java/net/JarURLConnection.java index 232a548e0a756..2c2734b08d7ba 100644 --- a/src/java.base/share/classes/java/net/JarURLConnection.java +++ b/src/java.base/share/classes/java/net/JarURLConnection.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -172,14 +172,17 @@ private void parseSpecs(URL url) throws MalformedURLException { throw new MalformedURLException("no !/ found in url spec:" + spec); } - jarFileURL = new URL(spec.substring(0, separator++)); + @SuppressWarnings("deprecation") + var _unused = jarFileURL = new URL(spec.substring(0, separator++)); + /* * The url argument may have had a runtime fragment appended, so * we need to add a runtime fragment to the jarFileURL to enable * runtime versioning when the underlying jar file is opened. */ if ("runtime".equals(url.getRef())) { - jarFileURL = new URL(jarFileURL, "#runtime"); + @SuppressWarnings("deprecation") + var _unused2 = jarFileURL = new URL(jarFileURL, "#runtime"); } entryName = null; diff --git a/src/java.base/share/classes/java/net/URI.java b/src/java.base/share/classes/java/net/URI.java index 9b42c0347ac3b..b532d41059e1d 100644 --- a/src/java.base/share/classes/java/net/URI.java +++ b/src/java.base/share/classes/java/net/URI.java @@ -1133,7 +1133,7 @@ public URI relativize(URI uri) { * or if some other error occurred while constructing the URL */ public URL toURL() throws MalformedURLException { - return URL.fromURI(this); + return URL.of(this, null); } // -- Component access methods -- diff --git a/src/java.base/share/classes/java/net/URL.java b/src/java.base/share/classes/java/net/URL.java index f247bfebb63d2..56793be1e974f 100644 --- a/src/java.base/share/classes/java/net/URL.java +++ b/src/java.base/share/classes/java/net/URL.java @@ -129,6 +129,26 @@ * the protocol, host name, or port number is missing, the value is * inherited from the fully specified URL. The file component must be * specified. The optional fragment is not inherited. + * + *

Constructing instances of {@code URL}

+ * + * The {@code java.net.URL} constructors are deprecated. + * Developers are encouraged to use {@link URI java.net.URI} to parse + * or construct a {@code URL}. In cases where an instance of {@code + * java.net.URL} is needed to open a connection, {@link URI} can be used + * to construct or parse the URL string, possibly calling {@link + * URI#parseServerAuthority()} to validate that the authority component + * can be parsed as a server-based authority, and then calling + * {@link URI#toURL()} to create the {@code URL} instance. + *

+ * The URL constructors are specified to throw + * {@link MalformedURLException} but the actual parsing/validation + * that is performed is implementation dependent. Some parsing/validation + * may be delayed until later, when the underlying {@linkplain + * URLStreamHandler stream handler's implementation} is called. + * Being able to construct an instance of {@code URL} doesn't + * provide any guarantee about its conformance to the URL + * syntax specification. *

* The URL class does not itself encode or decode any URL components * according to the escaping mechanism defined in RFC2396. It is the @@ -152,6 +172,7 @@ * * @apiNote * + * * Applications working with file paths and file URIs should take great * care to use the appropriate methods to convert between the two. * The {@link Path#of(URI)} factory method and the {@link File#File(URI)} @@ -164,6 +185,11 @@ * from the direct string representation of a {@code File} or {@code Path} * instance. *

+ * Before constructing a {@code URL} from a {@code URI}, and depending + * on the protocol involved, applications should consider validating + * whether the URI authority {@linkplain URI#parseServerAuthority() + * can be parsed as server-based}. + *

* Some components of a URL or URI, such as userinfo, may * be abused to construct misleading URLs or URIs. Applications * that deal with URLs or URIs should take into account @@ -373,7 +399,11 @@ public final class URL implements java.io.Serializable { * @see java.net.URLStreamHandler * @see java.net.URLStreamHandlerFactory#createURLStreamHandler( * java.lang.String) + * @deprecated Use {@link URI#toURL()} to construct an instance of URL. See the note on + * constructor deprecation for more + * details. */ + @Deprecated(since = "20") public URL(String protocol, String host, int port, String file) throws MalformedURLException { @@ -399,7 +429,11 @@ public URL(String protocol, String host, int port, String file) * rejects, or is known to reject, the {@code URL} * @see java.net.URL#URL(java.lang.String, java.lang.String, * int, java.lang.String) + * @deprecated Use {@link URI#toURL()} to construct an instance of URL. See the note on + * constructor deprecation for more + * details. */ + @Deprecated(since = "20") public URL(String protocol, String host, String file) throws MalformedURLException { this(protocol, host, -1, file); @@ -446,7 +480,13 @@ public URL(String protocol, String host, String file) * java.lang.String) * @see SecurityManager#checkPermission * @see java.net.NetPermission + * @deprecated + * Use {@link #of(URI, URLStreamHandler)} to construct an instance of URL + * associated with a custom protocol handler. + * See the note on constructor deprecation + * for more details. */ + @Deprecated(since = "20") public URL(String protocol, String host, int port, String file, URLStreamHandler handler) throws MalformedURLException { if (handler != null) { @@ -533,7 +573,11 @@ public URL(String protocol, String host, int port, String file, * URLStreamHandler#parseURL parseURL method} throws * {@code IllegalArgumentException} * @see java.net.URL#URL(java.net.URL, java.lang.String) + * @deprecated Use {@link URI#toURL()} to construct an instance of URL. See the note on + * constructor deprecation for more + * details. */ + @Deprecated(since = "20") public URL(String spec) throws MalformedURLException { this(null, spec); } @@ -593,7 +637,11 @@ public URL(String spec) throws MalformedURLException { * @see java.net.URLStreamHandler * @see java.net.URLStreamHandler#parseURL(java.net.URL, * java.lang.String, int, int) + * @deprecated Use {@link URI#toURL()} to construct an instance of URL. See the note on + * constructor deprecation for more + * details. */ + @Deprecated(since = "20") public URL(URL context, String spec) throws MalformedURLException { this(context, spec, null); } @@ -626,7 +674,13 @@ public URL(URL context, String spec) throws MalformedURLException { * @see java.net.URLStreamHandler * @see java.net.URLStreamHandler#parseURL(java.net.URL, * java.lang.String, int, int) + * @deprecated + * Use {@link #of(URI, URLStreamHandler)} to construct an instance of URL + * associated with a custom protocol handler. + * See the note on constructor deprecation + * for more details. */ + @Deprecated(since = "20") public URL(URL context, String spec, URLStreamHandler handler) throws MalformedURLException { @@ -748,23 +802,70 @@ public URL(URL context, String spec, URLStreamHandler handler) } /** - * Creates a URL from a URI, as if by invoking {@code uri.toURL()}. + * Creates a URL from a URI, as if by invoking {@code uri.toURL()}, but + * associating it with the given {@code URLStreamHandler}, if allowed. + * + * @apiNote + * Applications should consider performing additional integrity + * checks before constructing a {@code URL} and opening a connection. + * See the API note in the class level API + * documentation. + * + * @implSpec The implementation of this method includes calling the {@link + * URLStreamHandler#parseURL(URL, String, int, int) parseURL} method on the + * selected handler. + * + * @param uri the {@code URI} from which the returned {@code URL} should + * be built + * @param handler a custom protocol stream handler for + * the returned {@code URL}. Can be {@code null}, + * in which case the default stream handler for + * the protocol if any, will be used. + * + * @return a new {@code URL} instance created from the given {@code URI} + * and associated with the given {@code URLStreamHandler}, if any + * + * @throws NullPointerException if {@code uri} is {@code null} + * + * @throws IllegalArgumentException if no protocol is specified + * (the {@linkplain URI#getScheme() uri scheme} is {@code null}), or + * if the {@code URLStreamHandler} is not {@code null} and can not be + * set for the given protocol + * + * @throws MalformedURLException if an unknown protocol is found, + * or the given URI fails to comply with the specific + * syntax of the associated protocol, or the + * underlying stream handler's {@linkplain + * URLStreamHandler#parseURL(URL, String, int, int) + * parseURL method} throws {@code IllegalArgumentException} + * + * @throws SecurityException + * if a security manager exists and its + * {@code checkPermission} method doesn't allow + * specifying a stream handler * * @see java.net.URI#toURL() + * + * @since 20 */ - static URL fromURI(URI uri) throws MalformedURLException { + public static URL of(URI uri, URLStreamHandler handler) + throws MalformedURLException { if (!uri.isAbsolute()) { throw new IllegalArgumentException("URI is not absolute"); } + String protocol = uri.getScheme(); + // fast path for canonical jrt:/... URLs + // // In general we need to go via Handler.parseURL, but for the jrt // protocol we enforce that the Handler is not overridable and can // optimize URI to URL conversion. // // Case-sensitive comparison for performance; malformed protocols will // be handled correctly by the slow path. - if (protocol.equals("jrt") && !uri.isOpaque() + if (handler == null && protocol.equals("jrt") && !uri.isOpaque() + && uri.getRawAuthority() == null && uri.getRawFragment() == null) { String query = uri.getRawQuery(); @@ -780,9 +881,28 @@ static URL fromURI(URI uri) throws MalformedURLException { int port = uri.getPort(); return new URL("jrt", host, port, file, null); - } else { - return new URL((URL)null, uri.toString(), null); } + + // slow path (will work for non-canonical forms of jrt: too) + + if ("url".equalsIgnoreCase(protocol)) {; + String uristr = uri.toString(); + try { + URI inner = new URI(uristr.substring(4)); + if (inner.isAbsolute()) { + protocol = inner.getScheme(); + } + } catch (URISyntaxException use) { + throw new MalformedURLException(use.getMessage()); + } + } + + if (handler != null && !isOverrideable(protocol)) { + throw new IllegalArgumentException("Can't override URLStreamHandler for protocol " + + protocol); + } + + return new URL((URL)null, uri.toString(), handler); } /* diff --git a/src/java.base/share/classes/java/security/Security.java b/src/java.base/share/classes/java/security/Security.java index dcfe3b4d6bbe4..257dc172ee2af 100644 --- a/src/java.base/share/classes/java/security/Security.java +++ b/src/java.base/share/classes/java/security/Security.java @@ -25,6 +25,7 @@ package java.security; +import java.net.MalformedURLException; import java.util.*; import java.util.concurrent.ConcurrentHashMap; import java.io.*; @@ -135,10 +136,10 @@ private static boolean loadProps(File masterFile, String extraPropFile, boolean File propFile = new File(extraPropFile); URL propURL; if (propFile.exists()) { - propURL = new URL + propURL = newURL ("file:" + propFile.getCanonicalPath()); } else { - propURL = new URL(extraPropFile); + propURL = newURL(extraPropFile); } is = propURL.openStream(); @@ -993,4 +994,9 @@ public static Set getAlgorithms(String serviceName) { } return Collections.unmodifiableSet(result); } + + @SuppressWarnings("deprecation") + private static URL newURL(String spec) throws MalformedURLException { + return new URL(spec); + } } diff --git a/src/java.base/share/classes/javax/crypto/JceSecurity.java.template b/src/java.base/share/classes/javax/crypto/JceSecurity.java.template index 69ca07dbc6d92..220dd6f1f5c64 100644 --- a/src/java.base/share/classes/javax/crypto/JceSecurity.java.template +++ b/src/java.base/share/classes/javax/crypto/JceSecurity.java.template @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -243,7 +243,8 @@ final class JceSecurity { static { try { - NULL_URL = new URL("http://null.oracle.com/"); + @SuppressWarnings("deprecation") + var _unused = NULL_URL = new URL("http://null.oracle.com/"); } catch (Exception e) { throw new RuntimeException(e); } diff --git a/src/java.base/share/classes/javax/crypto/ProviderVerifier.java b/src/java.base/share/classes/javax/crypto/ProviderVerifier.java index c7344b852dee7..cbfd02c32f4f7 100644 --- a/src/java.base/share/classes/javax/crypto/ProviderVerifier.java +++ b/src/java.base/share/classes/javax/crypto/ProviderVerifier.java @@ -91,6 +91,7 @@ void verify() throws IOException { // If the protocol of jarURL isn't "jar", we should // construct a JAR URL so we can open a JarURLConnection // for verifying this provider. + @SuppressWarnings("deprecation") final URL url = jarURL.getProtocol().equalsIgnoreCase("jar")? jarURL : new URL("jar:" + jarURL + "!/"); diff --git a/src/java.base/share/classes/jdk/internal/loader/URLClassPath.java b/src/java.base/share/classes/jdk/internal/loader/URLClassPath.java index 71c09fc7b6a6f..7b49189418dba 100644 --- a/src/java.base/share/classes/jdk/internal/loader/URLClassPath.java +++ b/src/java.base/share/classes/jdk/internal/loader/URLClassPath.java @@ -493,6 +493,7 @@ public Loader run() throws IOException { isDefaultJarHandler(url) && file.endsWith("!/")) { // extract the nested URL + @SuppressWarnings("deprecation") URL nestedUrl = new URL(file.substring(0, file.length() - 2)); return new JarLoader(nestedUrl, jarHandler, lmap, acc); } else { @@ -605,7 +606,8 @@ final URL getBaseURL() { URL findResource(final String name, boolean check) { URL url; try { - url = new URL(base, ParseUtil.encodePath(name, false)); + @SuppressWarnings("deprecation") + var _unused = url = new URL(base, ParseUtil.encodePath(name, false)); } catch (MalformedURLException e) { return null; } @@ -641,7 +643,8 @@ URL findResource(final String name, boolean check) { Resource getResource(final String name, boolean check) { final URL url; try { - url = new URL(base, ParseUtil.encodePath(name, false)); + @SuppressWarnings("deprecation") + var _unused = url = new URL(base, ParseUtil.encodePath(name, false)); } catch (MalformedURLException e) { return null; } @@ -729,7 +732,7 @@ private JarLoader(URL url, URLStreamHandler jarHandler, @SuppressWarnings("removal") AccessControlContext acc) throws IOException { - super(new URL("jar", "", -1, url + "!/", jarHandler)); + super(newURL("jar", "", -1, url + "!/", jarHandler)); csu = url; handler = jarHandler; lmap = loaderMap; @@ -738,6 +741,13 @@ private JarLoader(URL url, URLStreamHandler jarHandler, ensureOpen(); } + @SuppressWarnings("deprecation") + private static URL newURL(String protocol, String host, int port, String file, URLStreamHandler handler) + throws MalformedURLException + { + return new URL(protocol, host, port, file, handler); + } + @Override public void close () throws IOException { // closing is synchronized at higher level @@ -782,6 +792,7 @@ public Void run() throws IOException { // URL until we actually need to try to load something from them. for (int i = 0; i < jarfiles.length; i++) { try { + @SuppressWarnings("deprecation") URL jarURL = new URL(csu, jarfiles[i]); // If a non-null loader already exists, leave it alone. String urlNoFragString = URLUtil.urlNoFragString(jarURL); @@ -829,6 +840,7 @@ private JarFile getJarFile(URL url) throws IOException { return checkJar(new JarFile(new File(p.getPath()), true, ZipFile.OPEN_READ, JarFile.runtimeVersion())); } + @SuppressWarnings("deprecation") URLConnection uc = (new URL(getBaseURL(), "#runtime")).openConnection(); uc.setRequestProperty(USER_AGENT_JAVA_VERSION, JAVA_VERSION); JarFile jarFile = ((JarURLConnection)uc).getJarFile(); @@ -862,7 +874,8 @@ Resource checkResource(final String name, boolean check, } else { nm = name; } - url = new URL(getBaseURL(), ParseUtil.encodePath(nm, false)); + @SuppressWarnings("deprecation") + var _unused = url = new URL(getBaseURL(), ParseUtil.encodePath(nm, false)); if (check) { URLClassPath.check(url); } @@ -993,7 +1006,8 @@ Resource getResource(final String name, boolean check, final URL url; try{ - url = new URL(csu, jarName); + @SuppressWarnings("deprecation") + var _unused = url = new URL(csu, jarName); String urlNoFragString = URLUtil.urlNoFragString(url); if ((newLoader = (JarLoader)lmap.get(urlNoFragString)) == null) { /* no loader has been set up for this jar file @@ -1116,6 +1130,7 @@ private static URL[] parseClassPath(URL base, String value) int i = 0; while (st.hasMoreTokens()) { String path = st.nextToken(); + @SuppressWarnings("deprecation") URL url = DISABLE_CP_URL_CHECK ? new URL(base, path) : tryResolve(base, path); if (url != null) { urls[i] = url; @@ -1152,6 +1167,7 @@ static URL tryResolve(URL base, String input) throws MalformedURLException { * @throws MalformedURLException */ static URL tryResolveFile(URL base, String input) throws MalformedURLException { + @SuppressWarnings("deprecation") URL retVal = new URL(base, input); if (input.indexOf(':') >= 0 && !"file".equalsIgnoreCase(retVal.getProtocol())) { @@ -1173,6 +1189,7 @@ static URL tryResolveFile(URL base, String input) throws MalformedURLException { static URL tryResolveNonFile(URL base, String input) throws MalformedURLException { String child = input.replace(File.separatorChar, '/'); if (isRelative(child)) { + @SuppressWarnings("deprecation") URL url = new URL(base, child); String bp = base.getPath(); String urlp = url.getPath(); @@ -1217,7 +1234,8 @@ private FileLoader(URL url) throws IOException { String path = url.getFile().replace('/', File.separatorChar); path = ParseUtil.decode(path); dir = (new File(path)).getCanonicalFile(); - normalizedBase = new URL(getBaseURL(), "."); + @SuppressWarnings("deprecation") + var _unused = normalizedBase = new URL(getBaseURL(), "."); } /* @@ -1236,7 +1254,8 @@ URL findResource(final String name, boolean check) { Resource getResource(final String name, boolean check) { final URL url; try { - url = new URL(getBaseURL(), ParseUtil.encodePath(name, false)); + @SuppressWarnings("deprecation") + var _unused = url = new URL(getBaseURL(), ParseUtil.encodePath(name, false)); if (url.getFile().startsWith(normalizedBase.getFile()) == false) { // requested resource had ../..'s in path diff --git a/src/java.base/share/classes/jdk/internal/module/ModulePatcher.java b/src/java.base/share/classes/jdk/internal/module/ModulePatcher.java index 607357352f914..ce837027faa26 100644 --- a/src/java.base/share/classes/jdk/internal/module/ModulePatcher.java +++ b/src/java.base/share/classes/jdk/internal/module/ModulePatcher.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -454,7 +454,9 @@ public String getName() { public URL getURL() { String encodedPath = ParseUtil.encodePath(name, false); try { - return new URL("jar:" + csURL + "!/" + encodedPath); + @SuppressWarnings("deprecation") + var result = new URL("jar:" + csURL + "!/" + encodedPath); + return result; } catch (MalformedURLException e) { return null; } diff --git a/src/java.base/share/classes/sun/net/util/URLUtil.java b/src/java.base/share/classes/sun/net/util/URLUtil.java index a3cf4d7fb16a4..6d80825e901c7 100644 --- a/src/java.base/share/classes/sun/net/util/URLUtil.java +++ b/src/java.base/share/classes/sun/net/util/URLUtil.java @@ -95,6 +95,7 @@ public static Permission getConnectPermission(URL url) throws IOException { String urlString = url.toString(); int bangPos = urlString.indexOf("!/"); urlString = urlString.substring(4, bangPos > -1 ? bangPos : urlString.length()); + @SuppressWarnings("deprecation") URL u = new URL(urlString); return getURLConnectPermission(u); // If protocol is HTTP or HTTPS than use URLPermission object diff --git a/src/java.base/share/classes/sun/net/www/ParseUtil.java b/src/java.base/share/classes/sun/net/www/ParseUtil.java index d84fa82b19e42..def688ad96a3a 100644 --- a/src/java.base/share/classes/sun/net/www/ParseUtil.java +++ b/src/java.base/share/classes/sun/net/www/ParseUtil.java @@ -239,7 +239,9 @@ public static URL fileToEncodedURL(File file) if (!path.endsWith("/") && file.isDirectory()) { path = path + "/"; } - return new URL("file", "", path); + @SuppressWarnings("deprecation") + var result = new URL("file", "", path); + return result; } public static java.net.URI toURI(URL url) { diff --git a/src/java.base/share/classes/sun/net/www/protocol/http/HttpURLConnection.java b/src/java.base/share/classes/sun/net/www/protocol/http/HttpURLConnection.java index 0e8584eece5c8..36f5e3cb37fcd 100644 --- a/src/java.base/share/classes/sun/net/www/protocol/http/HttpURLConnection.java +++ b/src/java.base/share/classes/sun/net/www/protocol/http/HttpURLConnection.java @@ -987,7 +987,7 @@ public static InputStream openConnectionCheckRedirects(URLConnection c) String loc = http.getHeaderField("Location"); URL target = null; if (loc != null) { - target = new URL(base, loc); + target = newURL(base, loc); } http.disconnect(); if (target == null @@ -1885,7 +1885,7 @@ private InputStream getInputStream0() throws IOException { String path = tok.nextToken(); try { /* path could be an abs_path or a complete URI */ - URL u = new URL (url, path); + URL u = newURL (url, path); DigestAuthentication d = new DigestAuthentication ( false, u, realm, "Digest", pw, digestparams, srv.authenticatorKey); @@ -2502,6 +2502,7 @@ public InetAddress run() if (ret == null && defaultAuth != null && defaultAuth.schemeSupported(scheme)) { try { + @SuppressWarnings("deprecation") URL u = new URL("http", host, port, "/"); String a = defaultAuth.authString(u, scheme, realm); if (a != null) { @@ -2616,7 +2617,7 @@ private AuthenticationInfo getServerAuthentication(AuthenticationHeader authhdr) if (NTLMAuthenticationProxy.supported) { URL url1; try { - url1 = new URL (url, "/"); /* truncate the path */ + url1 = newURL (url, "/"); /* truncate the path */ } catch (Exception e) { url1 = url; } @@ -2774,14 +2775,14 @@ private boolean followRedirect() throws IOException { URL locUrl; try { - locUrl = new URL(loc); + locUrl = newURL(loc); if (!url.getProtocol().equalsIgnoreCase(locUrl.getProtocol())) { return false; } } catch (MalformedURLException mue) { - // treat loc as a relative URI to conform to popular browsers - locUrl = new URL(url, loc); + // treat loc as a relative URI to conform to popular browsers + locUrl = newURL(url, loc); } final URL locUrl0 = locUrl; @@ -3994,6 +3995,16 @@ public void close() throws IOException { } } } + + @SuppressWarnings("deprecation") + private static URL newURL(String spec) throws MalformedURLException { + return new URL(spec); + } + + @SuppressWarnings("deprecation") + private static URL newURL(URL context, String spec) throws MalformedURLException { + return new URL(context, spec); + } } /** An input stream that just returns EOF. This is for diff --git a/src/java.base/share/classes/sun/net/www/protocol/jar/Handler.java b/src/java.base/share/classes/sun/net/www/protocol/jar/Handler.java index 48381c8a276c3..2884f825b8439 100644 --- a/src/java.base/share/classes/sun/net/www/protocol/jar/Handler.java +++ b/src/java.base/share/classes/sun/net/www/protocol/jar/Handler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -78,8 +78,8 @@ protected boolean sameFile(URL u1, URL u2) { URL enclosedURL1 = null, enclosedURL2 = null; try { - enclosedURL1 = new URL(file1.substring(0, sep1)); - enclosedURL2 = new URL(file2.substring(0, sep2)); + enclosedURL1 = newURL(file1.substring(0, sep1)); + enclosedURL2 = newURL(file2.substring(0, sep2)); } catch (MalformedURLException unused) { return super.sameFile(u1, u2); } @@ -108,7 +108,7 @@ protected int hashCode(URL u) { URL enclosedURL = null; String fileWithoutEntry = file.substring(0, sep); try { - enclosedURL = new URL(fileWithoutEntry); + enclosedURL = newURL(fileWithoutEntry); h += enclosedURL.hashCode(); } catch (MalformedURLException unused) { h += fileWithoutEntry.hashCode(); @@ -179,7 +179,7 @@ private String parseAbsoluteSpec(String spec) { // test the inner URL try { String innerSpec = spec.substring(0, index - 1); - new URL(innerSpec); + newURL(innerSpec); } catch (MalformedURLException e) { throw new NullPointerException("invalid url: " + spec + " (" + e + ")"); @@ -259,4 +259,9 @@ private static String doCanonicalize(String file) { return file; } + + @SuppressWarnings("deprecation") + private static URL newURL(String spec) throws MalformedURLException { + return new URL(spec); + } } diff --git a/src/java.base/share/classes/sun/net/www/protocol/jrt/JavaRuntimeURLConnection.java b/src/java.base/share/classes/sun/net/www/protocol/jrt/JavaRuntimeURLConnection.java index f8b10485f5778..b4cd98870ca23 100644 --- a/src/java.base/share/classes/sun/net/www/protocol/jrt/JavaRuntimeURLConnection.java +++ b/src/java.base/share/classes/sun/net/www/protocol/jrt/JavaRuntimeURLConnection.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 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 @@ -166,6 +166,7 @@ public Permission getPermission() { /** * Returns a jrt URL for the given module and resource name. */ + @SuppressWarnings("deprecation") private static URL toJrtURL(String module, String name) { try { return new URL("jrt:/" + module + "/" + name); @@ -177,6 +178,7 @@ private static URL toJrtURL(String module, String name) { /** * Returns a jrt URL for the given module. */ + @SuppressWarnings("deprecation") private static URL toJrtURL(String module) { try { return new URL("jrt:/" + module); diff --git a/src/java.base/share/classes/sun/security/provider/ConfigFile.java b/src/java.base/share/classes/sun/security/provider/ConfigFile.java index ae72c9ad6ad32..775e36c61baa6 100644 --- a/src/java.base/share/classes/sun/security/provider/ConfigFile.java +++ b/src/java.base/share/classes/sun/security/provider/ConfigFile.java @@ -256,7 +256,7 @@ private void init() throws IOException { URL configURL; try { - configURL = new URL(extra_config); + configURL = newURL(extra_config); } catch (MalformedURLException mue) { File configFile = new File(extra_config); if (configFile.exists()) { @@ -293,7 +293,7 @@ private void init() throws IOException { if (debugConfig != null) { debugConfig.println("\tReading config: " + config_url); } - init(new URL(config_url), newConfig); + init(newURL(config_url), newConfig); initialized = true; } catch (PropertyExpander.ExpandException peee) { throw ioException("Unable.to.properly.expand.config", @@ -669,4 +669,9 @@ private IOException ioException(String resourceKey, Object... args) { return new IOException(form.format(args)); } } + + @SuppressWarnings("deprecation") + private static URL newURL(String spec) throws MalformedURLException { + return new URL(spec); + } } diff --git a/src/java.base/share/classes/sun/security/provider/PolicyFile.java b/src/java.base/share/classes/sun/security/provider/PolicyFile.java index 640fb63dd259e..f69f513dc9fcf 100644 --- a/src/java.base/share/classes/sun/security/provider/PolicyFile.java +++ b/src/java.base/share/classes/sun/security/provider/PolicyFile.java @@ -414,7 +414,7 @@ public Boolean run() { policyURL = ParseUtil.fileToEncodedURL (new File(policyFile.getCanonicalPath())); } else { - policyURL = new URL(extra_policy); + policyURL = newURL(extra_policy); } if (debug != null) { debug.println("reading "+policyURL); @@ -672,7 +672,7 @@ private CodeSource getCodeSource(PolicyParser.GrantEntry ge, KeyStore keyStore, URL location; if (ge.codeBase != null) - location = new URL(ge.codeBase); + location = newURL(ge.codeBase); else location = null; @@ -1607,7 +1607,7 @@ private CodeSource canonicalizeCodebase(CodeSource cs, int separator = spec.indexOf("!/"); if (separator != -1) { try { - u = new URL(spec.substring(0, separator)); + u = newURL(spec.substring(0, separator)); } catch (MalformedURLException e) { // Fail silently. In this case, url stays what // it was above @@ -2223,4 +2223,9 @@ ProtectionDomainCache getPdMapping() { } } } + + @SuppressWarnings("deprecation") + private static URL newURL(String spec) throws MalformedURLException { + return new URL(spec); + } } diff --git a/src/java.base/share/classes/sun/security/provider/SeedGenerator.java b/src/java.base/share/classes/sun/security/provider/SeedGenerator.java index d9eb83ff60dd2..94ffc26ab3fbb 100644 --- a/src/java.base/share/classes/sun/security/provider/SeedGenerator.java +++ b/src/java.base/share/classes/sun/security/provider/SeedGenerator.java @@ -504,6 +504,7 @@ static class URLSeedGenerator extends SeedGenerator { @SuppressWarnings("removal") private void init() throws IOException { + @SuppressWarnings("deprecation") final URL device = new URL(deviceName); try { seedStream = java.security.AccessController.doPrivileged diff --git a/src/java.base/share/classes/sun/security/provider/certpath/OCSP.java b/src/java.base/share/classes/sun/security/provider/certpath/OCSP.java index 4ad35683aa1b1..eaef53598b7f1 100644 --- a/src/java.base/share/classes/sun/security/provider/certpath/OCSP.java +++ b/src/java.base/share/classes/sun/security/provider/certpath/OCSP.java @@ -183,7 +183,8 @@ public static byte[] getOCSPBytes(List certIds, URI responderURI, Base64.getEncoder().encodeToString(bytes), UTF_8)); if (encodedGetReq.length() <= 255) { - url = new URL(encodedGetReq.toString()); + @SuppressWarnings("deprecation") + var _unused = url = new URL(encodedGetReq.toString()); con = (HttpURLConnection)url.openConnection(); con.setDoOutput(true); con.setDoInput(true); diff --git a/src/java.base/share/classes/sun/security/tools/KeyStoreUtil.java b/src/java.base/share/classes/sun/security/tools/KeyStoreUtil.java index 7492c4cda93eb..cb025e7431585 100644 --- a/src/java.base/share/classes/sun/security/tools/KeyStoreUtil.java +++ b/src/java.base/share/classes/sun/security/tools/KeyStoreUtil.java @@ -155,7 +155,8 @@ public static char[] getPassWithModifier(String modifier, String arg, try { URL url; try { - url = new URL(arg); + @SuppressWarnings("deprecation") + var _unused = url = new URL(arg); } catch (java.net.MalformedURLException mue) { File f = new File(arg); if (f.exists()) { diff --git a/src/java.base/share/classes/sun/security/tools/PathList.java b/src/java.base/share/classes/sun/security/tools/PathList.java index ef524c4582192..79ff0e8055329 100644 --- a/src/java.base/share/classes/sun/security/tools/PathList.java +++ b/src/java.base/share/classes/sun/security/tools/PathList.java @@ -99,7 +99,9 @@ private static URL fileToURL(File file) { name = name + "/"; } try { - return new URL("file", "", name); + @SuppressWarnings("deprecation") + var result = new URL("file", "", name); + return result; } catch (MalformedURLException e) { throw new IllegalArgumentException("file"); } diff --git a/src/java.base/share/classes/sun/security/util/PolicyUtil.java b/src/java.base/share/classes/sun/security/util/PolicyUtil.java index 150d2cf98efbb..dc29f97ca044e 100644 --- a/src/java.base/share/classes/sun/security/util/PolicyUtil.java +++ b/src/java.base/share/classes/sun/security/util/PolicyUtil.java @@ -110,14 +110,16 @@ public static InputStream getInputStream(URL url) throws IOException { if (storePassURL != null) { URL passURL; try { - passURL = new URL(storePassURL); + @SuppressWarnings("deprecation") + var _unused = passURL = new URL(storePassURL); // absolute URL } catch (MalformedURLException e) { // relative URL if (policyUrl == null) { throw e; } - passURL = new URL(policyUrl, storePassURL); + @SuppressWarnings("deprecation") + var _unused = passURL = new URL(policyUrl, storePassURL); } if (debug != null) { @@ -138,14 +140,16 @@ public static InputStream getInputStream(URL url) throws IOException { */ URL keyStoreUrl; try { - keyStoreUrl = new URL(keyStoreName); + @SuppressWarnings("deprecation") + var _unused = keyStoreUrl = new URL(keyStoreName); // absolute URL } catch (MalformedURLException e) { // relative URL if (policyUrl == null) { throw e; } - keyStoreUrl = new URL(policyUrl, keyStoreName); + @SuppressWarnings("deprecation") + var _unused = keyStoreUrl = new URL(policyUrl, keyStoreName); } if (debug != null) { diff --git a/src/java.base/unix/classes/sun/net/www/protocol/file/Handler.java b/src/java.base/unix/classes/sun/net/www/protocol/file/Handler.java index 207e95d27f8fd..4b2c110b3e1df 100644 --- a/src/java.base/unix/classes/sun/net/www/protocol/file/Handler.java +++ b/src/java.base/unix/classes/sun/net/www/protocol/file/Handler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1994, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1994, 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 @@ -77,7 +77,8 @@ public URLConnection openConnection(URL u, Proxy p) URL ru; try { - ru = new URL("ftp", host, u.getFile() + + @SuppressWarnings("deprecation") + var _unused = ru = new URL("ftp", host, u.getFile() + (u.getRef() == null ? "": "#" + u.getRef())); if (p != null) { uc = ru.openConnection(p); diff --git a/src/java.base/unix/classes/sun/security/provider/NativePRNG.java b/src/java.base/unix/classes/sun/security/provider/NativePRNG.java index 5bdd85c4f898c..25548bfeb8096 100644 --- a/src/java.base/unix/classes/sun/security/provider/NativePRNG.java +++ b/src/java.base/unix/classes/sun/security/provider/NativePRNG.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -108,7 +108,8 @@ private static URL getEgdUrl() { debug.println("NativePRNG egdUrl: " + egdSource); } try { - egdUrl = new URL(egdSource); + @SuppressWarnings("deprecation") + var _unused = egdUrl = new URL(egdSource); if (!egdUrl.getProtocol().equalsIgnoreCase("file")) { return null; } diff --git a/src/java.base/windows/classes/sun/net/www/protocol/file/Handler.java b/src/java.base/windows/classes/sun/net/www/protocol/file/Handler.java index 18ccda6e7c1d9..2865aa32a95ff 100644 --- a/src/java.base/windows/classes/sun/net/www/protocol/file/Handler.java +++ b/src/java.base/windows/classes/sun/net/www/protocol/file/Handler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -94,7 +94,8 @@ public URLConnection openConnection(URL url, Proxy p) URL newurl; try { - newurl = new URL("ftp", host, file + + @SuppressWarnings("deprecation") + var _unused = newurl = new URL("ftp", host, file + (url.getRef() == null ? "": "#" + url.getRef())); if (p != null) { diff --git a/src/java.base/windows/classes/sun/net/www/protocol/jar/JarFileFactory.java b/src/java.base/windows/classes/sun/net/www/protocol/jar/JarFileFactory.java index 8f8808bd5eb99..178ffe84a0643 100644 --- a/src/java.base/windows/classes/sun/net/www/protocol/jar/JarFileFactory.java +++ b/src/java.base/windows/classes/sun/net/www/protocol/jar/JarFileFactory.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -155,7 +155,8 @@ private URL urlFor(URL url) throws IOException { if (host != null && !host.isEmpty() && !host.equalsIgnoreCase("localhost")) { - url = new URL("file", "", "//" + host + url.getPath()); + @SuppressWarnings("deprecation") + var _unused = url = new URL("file", "", "//" + host + url.getPath()); } } return url; diff --git a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CDataTransferer.java b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CDataTransferer.java index 0a7591bd064f4..32cd2efa79564 100644 --- a/src/java.desktop/macosx/classes/sun/lwawt/macosx/CDataTransferer.java +++ b/src/java.desktop/macosx/classes/sun/lwawt/macosx/CDataTransferer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 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 @@ -145,7 +145,9 @@ public Object translateBytes(byte[] bytes, DataFlavor flavor, String xml = new String(bytes, charset); // macosx pasteboard returns a property list that consists of one URL // let's extract it. - return new URL(extractURL(xml)); + @SuppressWarnings("deprecation") + var result = new URL(extractURL(xml)); + return result; } if(isUriListFlavor(flavor) && format == CF_FILE) { diff --git a/src/java.desktop/macosx/classes/sun/lwawt/macosx/LWCToolkit.java b/src/java.desktop/macosx/classes/sun/lwawt/macosx/LWCToolkit.java index 075e4d54f598a..d430825bb8565 100644 --- a/src/java.desktop/macosx/classes/sun/lwawt/macosx/LWCToolkit.java +++ b/src/java.desktop/macosx/classes/sun/lwawt/macosx/LWCToolkit.java @@ -999,8 +999,10 @@ public boolean enableInputMethodsForTextComponent() { private static URL getScaledImageURL(URL url) { try { String scaledImagePath = getScaledImageName(url.getPath()); - return scaledImagePath == null ? null : new URL(url.getProtocol(), + @SuppressWarnings("deprecation") + var result = scaledImagePath == null ? null : new URL(url.getProtocol(), url.getHost(), url.getPort(), scaledImagePath); + return result; } catch (MalformedURLException e) { return null; } diff --git a/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/Metacity.java b/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/Metacity.java index dc9838154415b..295e474579bd7 100644 --- a/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/Metacity.java +++ b/src/java.desktop/share/classes/com/sun/java/swing/plaf/gtk/Metacity.java @@ -157,6 +157,7 @@ protected Metacity(String themeName) throws IOException, ParserConfigurationExce this.themeName = themeName; themeDir = getThemeDir(themeName); if (themeDir != null) { + @SuppressWarnings("deprecation") URL themeURL = new URL(themeDir, "metacity-theme-1.xml"); xmlDoc = getXMLDoc(themeURL); if (xmlDoc == null) { @@ -558,7 +559,8 @@ public Object run() { if (url != null) { String str = url.toString(); try { - themeDir = new URL(str.substring(0, str.lastIndexOf('/'))+"/"); + @SuppressWarnings("deprecation") + var _unused = themeDir = new URL(str.substring(0, str.lastIndexOf('/'))+"/"); } catch (MalformedURLException ex) { themeDir = null; } @@ -576,6 +578,7 @@ public Object run() { } // Note: this is a small file (< 1024 bytes) so it's not worth // starting an XML parser or even to use a buffered reader. + @SuppressWarnings("deprecation") URL url = new URL(new File(userHome).toURI().toURL(), ".gconf/apps/metacity/general/%25gconf.xml"); // Pending: verify character encoding spec for gconf @@ -668,6 +671,7 @@ protected Image getImage(String key) { if (image == null) { if (themeDir != null) { try { + @SuppressWarnings("deprecation") URL url = new URL(themeDir, key); image = (Image)new Privileged().doPrivileged(Privileged.GET_IMAGE, url); } catch (MalformedURLException ex) { diff --git a/src/java.desktop/share/classes/java/applet/Applet.java b/src/java.desktop/share/classes/java/applet/Applet.java index 9f0373205d876..1d0e25e117767 100644 --- a/src/java.desktop/share/classes/java/applet/Applet.java +++ b/src/java.desktop/share/classes/java/applet/Applet.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 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 @@ -313,7 +313,9 @@ public Image getImage(URL url) { */ public Image getImage(URL url, String name) { try { - return getImage(new URL(url, name)); + @SuppressWarnings("deprecation") + var u = new URL(url, name); + return getImage(u); } catch (MalformedURLException e) { return null; } @@ -363,7 +365,9 @@ public AudioClip getAudioClip(URL url) { */ public AudioClip getAudioClip(URL url, String name) { try { - return getAudioClip(new URL(url, name)); + @SuppressWarnings("deprecation") + var u = new URL(url, name); + return getAudioClip(u); } catch (MalformedURLException e) { return null; } diff --git a/src/java.desktop/share/classes/java/awt/SplashScreen.java b/src/java.desktop/share/classes/java/awt/SplashScreen.java index b7318bd04a65f..a7939f4a385c5 100644 --- a/src/java.desktop/share/classes/java/awt/SplashScreen.java +++ b/src/java.desktop/share/classes/java/awt/SplashScreen.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -224,7 +224,9 @@ public URL getImageURL() throws IllegalStateException { String jarName = _getImageJarName(splashPtr); if (fileName != null) { if (jarName != null) { - imageURL = new URL("jar:"+(new File(jarName).toURL().toString())+"!/"+fileName); + @SuppressWarnings("deprecation") + var _unused = imageURL = + new URL("jar:"+(new File(jarName).toURL().toString())+"!/"+fileName); } else { imageURL = new File(fileName).toURL(); } diff --git a/src/java.desktop/share/classes/java/beans/Beans.java b/src/java.desktop/share/classes/java/beans/Beans.java index 131473f83bf94..6dd1aa9f39c1a 100644 --- a/src/java.desktop/share/classes/java/beans/Beans.java +++ b/src/java.desktop/share/classes/java/beans/Beans.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 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 @@ -44,6 +44,7 @@ import java.lang.reflect.Modifier; +import java.net.MalformedURLException; import java.net.URL; import java.util.Enumeration; @@ -304,13 +305,13 @@ public static Object instantiate(ClassLoader cls, String beanName, if (s.endsWith(resourceName)) { int ix = s.length() - resourceName.length(); - codeBase = new URL(s.substring(0,ix)); + codeBase = newURL(s.substring(0,ix)); docBase = codeBase; ix = s.lastIndexOf('/'); if (ix >= 0) { - docBase = new URL(s.substring(0,ix+1)); + docBase = newURL(s.substring(0,ix+1)); } } } @@ -356,6 +357,11 @@ private static void unsafeBeanContextAdd(BeanContext beanContext, Object res) { beanContext.add(res); } + @SuppressWarnings("deprecation") + private static URL newURL(String spec) throws MalformedURLException { + return new URL(spec); + } + /** * From a given bean, obtain an object representing a specified * type view of that source object. diff --git a/src/java.desktop/share/classes/javax/swing/JEditorPane.java b/src/java.desktop/share/classes/javax/swing/JEditorPane.java index 236e187fde81c..ee2f174206c0a 100644 --- a/src/java.desktop/share/classes/javax/swing/JEditorPane.java +++ b/src/java.desktop/share/classes/javax/swing/JEditorPane.java @@ -795,9 +795,11 @@ protected InputStream getStream(URL page) throws IOException { if (redirect) { String loc = conn.getHeaderField("Location"); if (loc.startsWith("http", 0)) { - page = new URL(loc); + @SuppressWarnings("deprecation") + var _unused = page = new URL(loc); } else { - page = new URL(page, loc); + @SuppressWarnings("deprecation") + var _unused = page = new URL(page, loc); } return getStream(page); } @@ -926,6 +928,7 @@ public void setPage(String url) throws IOException { if (url == null) { throw new IOException("invalid url"); } + @SuppressWarnings("deprecation") URL page = new URL(url); setPage(page); } @@ -1948,7 +1951,8 @@ public Object getAccessibleActionObject(int i) { if (href != null) { URL u; try { - u = new URL(JEditorPane.this.getPage(), href); + @SuppressWarnings("deprecation") + var _unused = u = new URL(JEditorPane.this.getPage(), href); } catch (MalformedURLException m) { u = null; } diff --git a/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthParser.java b/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthParser.java index 71dda727219b8..2da1f958718b6 100644 --- a/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthParser.java +++ b/src/java.desktop/share/classes/javax/swing/plaf/synth/SynthParser.java @@ -260,7 +260,9 @@ private URL getResource(String path) { return _classResourceBase.getResource(path); } else { try { - return new URL(_urlResourceBase, path); + @SuppressWarnings("deprecation") + var result = new URL(_urlResourceBase, path); + return result; } catch (MalformedURLException mue) { return null; } diff --git a/src/java.desktop/share/classes/javax/swing/text/html/CSS.java b/src/java.desktop/share/classes/javax/swing/text/html/CSS.java index 73087bd20225f..37a0c9306172b 100644 --- a/src/java.desktop/share/classes/javax/swing/text/html/CSS.java +++ b/src/java.desktop/share/classes/javax/swing/text/html/CSS.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -1293,6 +1293,7 @@ static URL getURL(URL base, String cssString) { } // Absolute first try { + @SuppressWarnings("deprecation") URL url = new URL(cssString); if (url != null) { return url; @@ -1303,6 +1304,7 @@ static URL getURL(URL base, String cssString) { if (base != null) { // Relative URL, try from base try { + @SuppressWarnings("deprecation") URL url = new URL(base, cssString); return url; } diff --git a/src/java.desktop/share/classes/javax/swing/text/html/FormView.java b/src/java.desktop/share/classes/javax/swing/text/html/FormView.java index 62ebaa5fdbe72..8af4f9e2f1e19 100644 --- a/src/java.desktop/share/classes/javax/swing/text/html/FormView.java +++ b/src/java.desktop/share/classes/javax/swing/text/html/FormView.java @@ -276,6 +276,7 @@ private JComponent createInputComponent(AttributeSet attr, Object model) { JButton button; try { URL base = ((HTMLDocument)getElement().getDocument()).getBase(); + @SuppressWarnings("deprecation") URL srcURL = new URL(base, srcAtt); Icon icon = new ImageIcon(srcURL); button = new JButton(icon); @@ -515,13 +516,15 @@ protected void submitData(String data) { String action = (String) attrs.getAttribute(HTML.Attribute.ACTION); URL actionURL; try { - actionURL = (action == null) + @SuppressWarnings("deprecation") + var _unused = actionURL = (action == null) ? new URL(base.getProtocol(), base.getHost(), base.getPort(), base.getFile()) : new URL(base, action); if (!isPostMethod) { String query = data.toString(); - actionURL = new URL(actionURL + "?" + query); + @SuppressWarnings("deprecation") + var _unused2 = actionURL = new URL(actionURL + "?" + query); } } catch (MalformedURLException e) { actionURL = null; diff --git a/src/java.desktop/share/classes/javax/swing/text/html/FrameView.java b/src/java.desktop/share/classes/javax/swing/text/html/FrameView.java index 5ecbaefa70961..345f947a9cce1 100644 --- a/src/java.desktop/share/classes/javax/swing/text/html/FrameView.java +++ b/src/java.desktop/share/classes/javax/swing/text/html/FrameView.java @@ -71,7 +71,8 @@ protected Component createComponent() { if (srcAtt != null && !srcAtt.isEmpty()) { try { URL base = ((HTMLDocument)elem.getDocument()).getBase(); - src = new URL(base, srcAtt); + @SuppressWarnings("deprecation") + var _unused = src = new URL(base, srcAtt); htmlPane = new FrameEditorPane(); htmlPane.addHyperlinkListener(this); JEditorPane host = getHostPane(); @@ -373,7 +374,8 @@ public void changedUpdate(DocumentEvent e, Shape a, ViewFactory f) { } Object postData = movePostData(htmlPane, null); - src = new URL(base, srcAtt); + @SuppressWarnings("deprecation") + var _unused = src = new URL(base, srcAtt); if (oldPage.equals(src) && (src.getRef() == null) && (postData == null)) { return; } diff --git a/src/java.desktop/share/classes/javax/swing/text/html/HTMLDocument.java b/src/java.desktop/share/classes/javax/swing/text/html/HTMLDocument.java index c75425fd2877c..61463eb431fb3 100644 --- a/src/java.desktop/share/classes/javax/swing/text/html/HTMLDocument.java +++ b/src/java.desktop/share/classes/javax/swing/text/html/HTMLDocument.java @@ -3528,6 +3528,7 @@ public void start(HTML.Tag t, MutableAttributeSet attr) { String href = (String) attr.getAttribute(HTML.Attribute.HREF); if (href != null) { try { + @SuppressWarnings("deprecation") URL newBase = new URL(base, href); setBase(newBase); hasBaseTag = true; @@ -4122,10 +4123,12 @@ void addCSSRules(String rules) { void linkCSSStyleSheet(String href) { URL url; try { - url = new URL(base, href); + @SuppressWarnings("deprecation") + var _unused = url = new URL(base, href); } catch (MalformedURLException mfe) { try { - url = new URL(href); + @SuppressWarnings("deprecation") + var _unused = url = new URL(href); } catch (MalformedURLException mfe2) { url = null; } diff --git a/src/java.desktop/share/classes/javax/swing/text/html/HTMLEditorKit.java b/src/java.desktop/share/classes/javax/swing/text/html/HTMLEditorKit.java index 4347e96d675a3..24e8c255547c7 100644 --- a/src/java.desktop/share/classes/javax/swing/text/html/HTMLEditorKit.java +++ b/src/java.desktop/share/classes/javax/swing/text/html/HTMLEditorKit.java @@ -969,7 +969,8 @@ HyperlinkEvent createHyperlinkEvent(JEditorPane html, URL u; try { URL base = hdoc.getBase(); - u = new URL(base, href); + @SuppressWarnings("deprecation") + var _unused = u = new URL(base, href); // Following is a workaround for 1.2, in which // new URL("file://...", "#...") causes the filename to // be lost. @@ -979,7 +980,8 @@ HyperlinkEvent createHyperlinkEvent(JEditorPane html, String newFile = u.getFile(); if (baseFile != null && newFile != null && !newFile.startsWith(baseFile)) { - u = new URL(base, baseFile + href); + @SuppressWarnings("deprecation") + var _unused2 = u = new URL(base, baseFile + href); } } } catch (MalformedURLException m) { @@ -1013,7 +1015,8 @@ void fireEvents(JEditorPane editor, HTMLDocument doc, String href, // fire an exited event on the old link URL u; try { - u = new URL(doc.getBase(), this.href); + @SuppressWarnings("deprecation") + var _unused = u = new URL(doc.getBase(), this.href); } catch (MalformedURLException m) { u = null; } @@ -1026,7 +1029,8 @@ void fireEvents(JEditorPane editor, HTMLDocument doc, String href, // fire an entered event on the new link URL u; try { - u = new URL(doc.getBase(), href); + @SuppressWarnings("deprecation") + var _unused = u = new URL(doc.getBase(), href); } catch (MalformedURLException m) { u = null; } @@ -2392,6 +2396,7 @@ private void activateLink(String href, HTMLDocument doc, try { URL page = (URL)doc.getProperty(Document.StreamDescriptionProperty); + @SuppressWarnings("deprecation") URL url = new URL(page, href); HyperlinkEvent linkEvent = new HyperlinkEvent (editor, HyperlinkEvent.EventType. diff --git a/src/java.desktop/share/classes/javax/swing/text/html/ImageView.java b/src/java.desktop/share/classes/javax/swing/text/html/ImageView.java index c48b00e56a3d4..9f7b334edbebd 100644 --- a/src/java.desktop/share/classes/javax/swing/text/html/ImageView.java +++ b/src/java.desktop/share/classes/javax/swing/text/html/ImageView.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -196,6 +196,7 @@ public URL getImageURL() { URL reference = ((HTMLDocument)getDocument()).getBase(); try { + @SuppressWarnings("deprecation") URL u = new URL(reference,src); return u; } catch (MalformedURLException e) { diff --git a/src/java.desktop/share/classes/javax/swing/text/html/IsindexView.java b/src/java.desktop/share/classes/javax/swing/text/html/IsindexView.java index 4b2fb1e1c7369..22c345027ae9f 100644 --- a/src/java.desktop/share/classes/javax/swing/text/html/IsindexView.java +++ b/src/java.desktop/share/classes/javax/swing/text/html/IsindexView.java @@ -104,6 +104,7 @@ public void actionPerformed(ActionEvent evt) { action = hdoc.getBase().toString(); } try { + @SuppressWarnings("deprecation") URL url = new URL(action+"?"+data); JEditorPane pane = (JEditorPane)getContainer(); pane.setPage(url); diff --git a/src/java.desktop/share/classes/javax/swing/text/html/StyleSheet.java b/src/java.desktop/share/classes/javax/swing/text/html/StyleSheet.java index a10988c19b3d2..fd3c75829e861 100644 --- a/src/java.desktop/share/classes/javax/swing/text/html/StyleSheet.java +++ b/src/java.desktop/share/classes/javax/swing/text/html/StyleSheet.java @@ -2105,11 +2105,13 @@ public static final class ListPainter implements Serializable { tmpstr = st.nextToken(); if (st.hasMoreTokens()) tmpstr = st.nextToken(); + @SuppressWarnings("deprecation") URL u = new URL(tmpstr); img = new ImageIcon(u); } catch (MalformedURLException e) { if (tmpstr != null && ss != null && ss.getBase() != null) { try { + @SuppressWarnings("deprecation") URL u = new URL(ss.getBase(), tmpstr); img = new ImageIcon(u); } catch (MalformedURLException murle) { diff --git a/src/java.desktop/share/classes/sun/awt/image/URLImageSource.java b/src/java.desktop/share/classes/sun/awt/image/URLImageSource.java index 379b3e46cf592..0cb44ae64b0bc 100644 --- a/src/java.desktop/share/classes/sun/awt/image/URLImageSource.java +++ b/src/java.desktop/share/classes/sun/awt/image/URLImageSource.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 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 @@ -58,7 +58,7 @@ public URLImageSource(URL u) { } public URLImageSource(String href) throws MalformedURLException { - this(new URL(null, href)); + this(newURL(null, href)); } public URLImageSource(URL u, URLConnection uc) { @@ -159,4 +159,9 @@ protected ImageDecoder getDecoder() { } return id; } + + @SuppressWarnings("deprecation") + private static URL newURL(URL context, String spec) throws MalformedURLException { + return new URL(context, spec); + } } diff --git a/src/java.desktop/unix/classes/sun/print/CUPSPrinter.java b/src/java.desktop/unix/classes/sun/print/CUPSPrinter.java index 0e398edef8575..e2a69c79c3e11 100644 --- a/src/java.desktop/unix/classes/sun/print/CUPSPrinter.java +++ b/src/java.desktop/unix/classes/sun/print/CUPSPrinter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -291,6 +291,7 @@ static String[] getDefaultPrinter() { return printerInfo.clone(); } try { + @SuppressWarnings("deprecation") URL url = new URL("http", getServer(), getPort(), ""); final HttpURLConnection urlConnection = IPPPrintService.getIPPConnection(url); @@ -405,6 +406,7 @@ static String[] getAllPrinters() { } try { + @SuppressWarnings("deprecation") URL url = new URL("http", getServer(), getPort(), ""); final HttpURLConnection urlConnection = diff --git a/src/java.desktop/unix/classes/sun/print/IPPPrintService.java b/src/java.desktop/unix/classes/sun/print/IPPPrintService.java index 82cb84a14550e..91be3e06a5a7a 100644 --- a/src/java.desktop/unix/classes/sun/print/IPPPrintService.java +++ b/src/java.desktop/unix/classes/sun/print/IPPPrintService.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -36,6 +36,7 @@ import java.io.OutputStream; import java.io.OutputStreamWriter; import java.net.HttpURLConnection; +import java.net.MalformedURLException; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; @@ -406,7 +407,7 @@ protected static void debug_println(String str) { defaultMediaIndex = -1; try { myURL = - new URL(uriStr.replaceFirst("ipp", "http")); + newURL(uriStr.replaceFirst("ipp", "http")); } catch (Exception e) { IPPPrintService.debug_println(debugPrefix+ " IPPPrintService, myURL="+ @@ -1762,7 +1763,7 @@ public synchronized boolean isPostscript() { if (isCupsPrinter) { try { urlConnection = getIPPConnection( - new URL(myURL+".ppd")); + newURL(myURL+".ppd")); InputStream is = urlConnection.getInputStream(); if (is != null) { @@ -2076,4 +2077,9 @@ public boolean equals(Object obj) { public int hashCode() { return this.getClass().hashCode()+getName().hashCode(); } + + @SuppressWarnings("deprecation") + private static URL newURL(String spec) throws MalformedURLException { + return new URL(spec); + } } diff --git a/src/java.desktop/unix/classes/sun/print/PrintServiceLookupProvider.java b/src/java.desktop/unix/classes/sun/print/PrintServiceLookupProvider.java index 7fa1b201340c5..75e77e23a121e 100644 --- a/src/java.desktop/unix/classes/sun/print/PrintServiceLookupProvider.java +++ b/src/java.desktop/unix/classes/sun/print/PrintServiceLookupProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -27,6 +27,7 @@ import java.io.BufferedReader; import java.io.IOException; +import java.net.MalformedURLException; import java.security.PrivilegedAction; import java.util.ArrayList; import java.util.Vector; @@ -475,7 +476,7 @@ private PrintService getServiceByName(PrinterName nameAttr) { if (CUPSPrinter.isCupsRunning()) { try { return new IPPPrintService(name, - new URL("http://"+ + newURL("http://"+ CUPSPrinter.getServer()+":"+ CUPSPrinter.getPort()+"/"+ name)); @@ -687,7 +688,7 @@ public synchronized PrintService getDefaultPrintService() { psuri, true); } else { defaultPS = new IPPPrintService(defaultPrinter, - new URL("http://"+ + newURL("http://"+ CUPSPrinter.getServer()+":"+ CUPSPrinter.getPort()+"/"+ defaultPrinter)); @@ -969,4 +970,9 @@ public void run() { } } } + + @SuppressWarnings("deprecation") + private static URL newURL(String spec) throws MalformedURLException { + return new URL(spec); + } } diff --git a/src/java.desktop/windows/classes/sun/awt/windows/WDataTransferer.java b/src/java.desktop/windows/classes/sun/awt/windows/WDataTransferer.java index 456300c6197c5..d665047c795db 100644 --- a/src/java.desktop/windows/classes/sun/awt/windows/WDataTransferer.java +++ b/src/java.desktop/windows/classes/sun/awt/windows/WDataTransferer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 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 @@ -271,7 +271,9 @@ public Object translateBytes(byte[] bytes, DataFlavor flavor, long format, } catch (UnsupportedFlavorException cannotHappen) { } } - return new URL(new String(bytes, charset)); + @SuppressWarnings("deprecation") + var result = new URL(new String(bytes, charset)); + return result; } return super.translateBytes(bytes , flavor, format, diff --git a/src/java.management/share/classes/javax/management/loading/MLet.java b/src/java.management/share/classes/javax/management/loading/MLet.java index ec6ab22e09634..250e5945645ce 100644 --- a/src/java.management/share/classes/javax/management/loading/MLet.java +++ b/src/java.management/share/classes/javax/management/loading/MLet.java @@ -406,6 +406,7 @@ public void addURL(URL url) { */ public void addURL(String url) throws ServiceNotFoundException { try { + @SuppressWarnings("deprecation") URL ur = new URL(url); if (!Arrays.asList(getURLs()).contains(ur)) super.addURL(ur); @@ -571,8 +572,10 @@ public Set getMBeansFromURL(String url) // Appends the specified JAR file URL to the list of // URLs to search for classes and resources. try { + @SuppressWarnings("deprecation") + var u = new URL(codebase.toString() + tok); if (!Arrays.asList(getURLs()) - .contains(new URL(codebase.toString() + tok))) { + .contains(u)) { addURL(codebase + tok); } } catch (MalformedURLException me) { diff --git a/src/java.management/share/classes/javax/management/loading/MLetContent.java b/src/java.management/share/classes/javax/management/loading/MLetContent.java index 3001c06eb2ace..32b099a3615f7 100644 --- a/src/java.management/share/classes/javax/management/loading/MLetContent.java +++ b/src/java.management/share/classes/javax/management/loading/MLetContent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -102,7 +102,8 @@ public MLetContent(URL url, Map attributes, att += "/"; } try { - baseURL = new URL(documentURL, att); + @SuppressWarnings("deprecation") + var _unused = baseURL = new URL(documentURL, att); } catch (MalformedURLException e) { // OK : Move to next block as baseURL could not be initialized. } @@ -112,7 +113,8 @@ public MLetContent(URL url, Map attributes, int i = file.lastIndexOf('/'); if (i >= 0 && i < file.length() - 1) { try { - baseURL = new URL(documentURL, file.substring(0, i + 1)); + @SuppressWarnings("deprecation") + var _unused = baseURL = new URL(documentURL, file.substring(0, i + 1)); } catch (MalformedURLException e) { // OK : Move to next block as baseURL could not be initialized. } diff --git a/src/java.management/share/classes/javax/management/loading/MLetParser.java b/src/java.management/share/classes/javax/management/loading/MLetParser.java index ef8df7e91baae..0e53b1ddcc603 100644 --- a/src/java.management/share/classes/javax/management/loading/MLetParser.java +++ b/src/java.management/share/classes/javax/management/loading/MLetParser.java @@ -249,6 +249,7 @@ public List parse(URL url) throws IOException { /** * Parse the document pointed by the URL urlname */ + @SuppressWarnings("deprecation") public List parseURL(String urlname) throws IOException { // Parse the document // diff --git a/src/java.naming/share/classes/com/sun/jndi/ldap/VersionHelper.java b/src/java.naming/share/classes/com/sun/jndi/ldap/VersionHelper.java index 7d11ead19643c..1d7565e00e3ad 100644 --- a/src/java.naming/share/classes/com/sun/jndi/ldap/VersionHelper.java +++ b/src/java.naming/share/classes/com/sun/jndi/ldap/VersionHelper.java @@ -126,6 +126,7 @@ private ClassLoader getContextClassLoader() { return AccessController.doPrivileged(act); } + @SuppressWarnings("deprecation") private static URL[] getUrlArray(String[] url) throws MalformedURLException { URL[] urlArray = new URL[url.length]; for (int i = 0; i < urlArray.length; i++) { diff --git a/src/java.naming/share/classes/com/sun/naming/internal/VersionHelper.java b/src/java.naming/share/classes/com/sun/naming/internal/VersionHelper.java index 21f1b19921d81..6dbdb6f420b10 100644 --- a/src/java.naming/share/classes/com/sun/naming/internal/VersionHelper.java +++ b/src/java.naming/share/classes/com/sun/naming/internal/VersionHelper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -285,7 +285,9 @@ private static URL[] getUrlArray(String codebase) StringTokenizer parser = new StringTokenizer(codebase); List list = new ArrayList<>(); while (parser.hasMoreTokens()) { - list.add(new URL(parser.nextToken())); + @SuppressWarnings("deprecation") + var u = new URL(parser.nextToken()); + list.add(u); } return list.toArray(new URL[0]); } diff --git a/src/java.rmi/share/classes/sun/rmi/server/LoaderHandler.java b/src/java.rmi/share/classes/sun/rmi/server/LoaderHandler.java index 8b3586b40a0fd..7e840a8690612 100644 --- a/src/java.rmi/share/classes/sun/rmi/server/LoaderHandler.java +++ b/src/java.rmi/share/classes/sun/rmi/server/LoaderHandler.java @@ -773,7 +773,9 @@ private static URL[] pathToURLs(String path) StringTokenizer st = new StringTokenizer(path); // divide by spaces URL[] urls = new URL[st.countTokens()]; for (int i = 0; st.hasMoreTokens(); i++) { - urls[i] = new URL(st.nextToken()); + @SuppressWarnings("deprecation") + var url = new URL(st.nextToken()); + urls[i] = url; } synchronized (pathToURLsCache) { pathToURLsCache.put(path, diff --git a/src/java.scripting/share/classes/com/sun/tools/script/shell/Main.java b/src/java.scripting/share/classes/com/sun/tools/script/shell/Main.java index b928aa6e5f94a..55b0daa1a61e1 100644 --- a/src/java.scripting/share/classes/com/sun/tools/script/shell/Main.java +++ b/src/java.scripting/share/classes/com/sun/tools/script/shell/Main.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 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 @@ -540,7 +540,9 @@ private static URL fileToURL(File file) { name = name + "/"; } try { - return new URL("file", "", name); + @SuppressWarnings("deprecation") + var result = new URL("file", "", name); + return result; } catch (MalformedURLException e) { throw new IllegalArgumentException("file"); } diff --git a/src/java.sql.rowset/share/classes/javax/sql/rowset/serial/SerialDatalink.java b/src/java.sql.rowset/share/classes/javax/sql/rowset/serial/SerialDatalink.java index 4deea4c6b5a7f..477dd030e5c9b 100644 --- a/src/java.sql.rowset/share/classes/javax/sql/rowset/serial/SerialDatalink.java +++ b/src/java.sql.rowset/share/classes/javax/sql/rowset/serial/SerialDatalink.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 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 @@ -97,6 +97,7 @@ public SerialDatalink(URL url) throws SerialException { * URL object in the Java programming language. * @throws SerialException if the URL object cannot be de-serialized */ + @SuppressWarnings("deprecation") public URL getDatalink() throws SerialException { URL aURL = null; diff --git a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/dom/DocumentCache.java b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/dom/DocumentCache.java index c6722c98465ce..e50acc829f3b9 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/dom/DocumentCache.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/dom/DocumentCache.java @@ -194,6 +194,7 @@ public DocumentCache(int size, XSLTCDTMManager dtmManager) throws SAXException { */ private final long getLastModified(String uri) { try { + @SuppressWarnings("deprecation") URL url = new URL(uri); URLConnection connection = url.openConnection(); long timestamp = connection.getLastModified(); diff --git a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl.java b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl.java index 03fef860517cd..a93c76b41f470 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl.java @@ -1605,7 +1605,8 @@ private String getStylesheetFileName(Source source) else { URL url; try { - url = new URL(systemId); + @SuppressWarnings("deprecation") + URL _unused = url = new URL(systemId); } catch (MalformedURLException e) { return null; diff --git a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerImpl.java b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerImpl.java index a7a122d07aa43..3772ecf789cee 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerImpl.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerImpl.java @@ -521,7 +521,8 @@ else if (result instanceof StreamResult) { } } else if (systemId.startsWith("http:")) { - url = new URL(systemId); + @SuppressWarnings("deprecation") + URL _unused = url = new URL(systemId); final URLConnection connection = url.openConnection(); _tohFactory.setOutputStream(_ostream = connection.getOutputStream()); return _tohFactory.getSerializationHandler(); diff --git a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java index 8a01f74e79032..6cee549dbe276 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2022, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -647,6 +647,7 @@ public String setupCurrentEntity(boolean reference, String name, XMLInputSource if (reader == null) { stream = xmlInputSource.getByteStream(); if (stream == null) { + @SuppressWarnings("deprecation") URL location = new URL(expandedSystemId); URLConnection connect = location.openConnection(); if (!(connect instanceof HttpURLConnection)) { @@ -2037,6 +2038,7 @@ else if (gNeedEscaping[b]) { public static OutputStream createOutputStream(String uri) throws IOException { // URI was specified. Handle relative URIs. final String expanded = XMLEntityManager.expandSystemId(uri, null, true); + @SuppressWarnings("deprecation") final URL url = new URL(expanded != null ? expanded : uri); OutputStream out = null; String protocol = url.getProtocol(); diff --git a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/xinclude/XIncludeTextReader.java b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/xinclude/XIncludeTextReader.java index a2b27f771e8ad..8e2f8abcb139f 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/xinclude/XIncludeTextReader.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/xinclude/XIncludeTextReader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2018, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -125,6 +125,7 @@ protected Reader getReader(XMLInputSource source) throws IOException { else { String expandedSystemId = XMLEntityManager.expandSystemId(source.getSystemId(), source.getBaseSystemId(), false); + @SuppressWarnings("deprecation") URL url = new URL(expandedSystemId); URLConnection urlCon = url.openConnection(); diff --git a/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/CharInfo.java b/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/CharInfo.java index ba93113c8804c..30249a08e3a72 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/CharInfo.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/CharInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -220,6 +220,7 @@ private CharInfo(String entitiesResource, String method, boolean internal) if (is == null) { try { + @SuppressWarnings("deprecation") URL url = new URL(entitiesResource); is = url.openStream(); } catch (Exception e) { diff --git a/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/Encodings.java b/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/Encodings.java index 79b4673420211..a88606d5085e8 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/Encodings.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/Encodings.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -335,6 +335,7 @@ private InputStream openEncodingsFileStream() throws MalformedURLException, IOEx } if (urlString != null && urlString.length() > 0) { + @SuppressWarnings("deprecation") URL url = new URL(urlString); is = url.openStream(); } diff --git a/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/dom3/LSSerializerImpl.java b/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/dom3/LSSerializerImpl.java index a740550b796e5..6863df3afed47 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/dom3/LSSerializerImpl.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xml/internal/serializer/dom3/LSSerializerImpl.java @@ -956,6 +956,7 @@ public boolean write(Node nodeArg, LSOutput destination) throws LSException { // Expand the System Id and obtain an absolute URI for it. String absoluteURI = SystemIDResolver.getAbsoluteURI(uri); + @SuppressWarnings("deprecation") URL url = new URL(absoluteURI); OutputStream urlOutStream = null; String protocol = url.getProtocol(); @@ -1234,6 +1235,7 @@ public boolean writeToURI(Node nodeArg, String uri) throws LSException { // REVISIT: Can this be used to get an absolute expanded URI String absoluteURI = SystemIDResolver.getAbsoluteURI(uri); + @SuppressWarnings("deprecation") URL url = new URL(absoluteURI); OutputStream urlOutStream = null; String protocol = url.getProtocol(); diff --git a/src/java.xml/share/classes/com/sun/org/apache/xml/internal/utils/ListingErrorHandler.java b/src/java.xml/share/classes/com/sun/org/apache/xml/internal/utils/ListingErrorHandler.java index 21fe4995377f3..75aef58130aa1 100644 --- a/src/java.xml/share/classes/com/sun/org/apache/xml/internal/utils/ListingErrorHandler.java +++ b/src/java.xml/share/classes/com/sun/org/apache/xml/internal/utils/ListingErrorHandler.java @@ -25,6 +25,7 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; +import java.net.MalformedURLException; import java.net.URL; import java.net.URLConnection; @@ -413,7 +414,7 @@ protected static String getSourceLine(String sourceUrl, int lineNum) try { // Try to get a URL from it as-is - url = new URL(sourceUrl); + url = newURL(sourceUrl); } catch (java.net.MalformedURLException mue) { @@ -431,7 +432,7 @@ protected static String getSourceLine(String sourceUrl, int lineNum) else { // The url is relative, so attempt to get absolute - url = new URL(SystemIDResolver.getAbsoluteURI(sourceUrl)); + url = newURL(SystemIDResolver.getAbsoluteURI(sourceUrl)); // If this fails, allow the exception to propagate } } @@ -562,4 +563,8 @@ public boolean getThrowOnFatalError() /** If we should throw exception on fatalErrors; default:true. */ protected boolean throwOnFatalError = true; + @SuppressWarnings("deprecation") + private static URL newURL(String spec) throws MalformedURLException { + return new URL(spec); + } } diff --git a/src/java.xml/share/classes/javax/xml/catalog/BaseEntry.java b/src/java.xml/share/classes/javax/xml/catalog/BaseEntry.java index 3d5718d661db4..e6d804859cf90 100644 --- a/src/java.xml/share/classes/javax/xml/catalog/BaseEntry.java +++ b/src/java.xml/share/classes/javax/xml/catalog/BaseEntry.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -223,9 +223,11 @@ URL verifyURI(String arg, URL base, String uri) { try { if (base != null) { - url = new URL(base, uri); + @SuppressWarnings("deprecation") + URL _unused = url = new URL(base, uri); } else { - url = new URL(uri); + @SuppressWarnings("deprecation") + URL _unused = url = new URL(uri); } } catch (MalformedURLException e) { CatalogMessages.reportIAE(ERR_INVALID_ARGUMENT, diff --git a/src/java.xml/share/classes/javax/xml/catalog/CatalogImpl.java b/src/java.xml/share/classes/javax/xml/catalog/CatalogImpl.java index 6bbbdc77b7dd4..72cd64fca3d03 100644 --- a/src/java.xml/share/classes/javax/xml/catalog/CatalogImpl.java +++ b/src/java.xml/share/classes/javax/xml/catalog/CatalogImpl.java @@ -140,7 +140,8 @@ public CatalogImpl(CatalogImpl parent, CatalogFeatures f, URI... uris) throws Ca if (verifyCatalogFile(null, uri)) { systemId = temp; try { - baseURI = new URL(systemId); + @SuppressWarnings("deprecation") + URL _unused = baseURI = new URL(systemId); } catch (MalformedURLException e) { CatalogMessages.reportRunTimeError(CatalogMessages.ERR_INVALID_PATH, new Object[]{temp}, e); diff --git a/src/java.xml/share/classes/javax/xml/catalog/CatalogResolverImpl.java b/src/java.xml/share/classes/javax/xml/catalog/CatalogResolverImpl.java index 0977479ca9d02..062148e406a62 100644 --- a/src/java.xml/share/classes/javax/xml/catalog/CatalogResolverImpl.java +++ b/src/java.xml/share/classes/javax/xml/catalog/CatalogResolverImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -154,14 +154,15 @@ public Source resolve(String href, String base) { new Object[]{href, base}); } try { - URL url = null; - if (base == null) { - url = new URL(uri); + @SuppressWarnings("deprecation") + URL url = new URL(uri); result = url.toString(); } else { + @SuppressWarnings("deprecation") URL baseURL = new URL(base); - url = (href.length() == 0 ? baseURL : new URL(baseURL, uri)); + @SuppressWarnings("deprecation") + URL url = (href.length() == 0 ? baseURL : new URL(baseURL, uri)); result = url.toString(); } } catch (java.net.MalformedURLException mue) { @@ -219,7 +220,9 @@ public InputStream resolveEntity(String publicId, String systemId, String baseUr if (is != null && !is.isEmpty()) { try { - return new URL(is.getSystemId()).openStream(); + @SuppressWarnings("deprecation") + InputStream result = new URL(is.getSystemId()).openStream(); + return result; } catch (IOException ex) { //considered as no mapping. } diff --git a/src/java.xml/share/classes/jdk/xml/internal/SecuritySupport.java b/src/java.xml/share/classes/jdk/xml/internal/SecuritySupport.java index adf557bf2c726..78962261de12c 100644 --- a/src/java.xml/share/classes/jdk/xml/internal/SecuritySupport.java +++ b/src/java.xml/share/classes/jdk/xml/internal/SecuritySupport.java @@ -340,6 +340,7 @@ public static String checkAccess(String systemId, String allowedProtocols, if (!systemId.contains(":")) { protocol = "file"; } else { + @SuppressWarnings("deprecation") URL url = new URL(systemId); protocol = url.getProtocol(); if (protocol.equalsIgnoreCase("jar")) { diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/file/FSInfo.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/file/FSInfo.java index ab0d3d8e3fd32..9a0402aae342b 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/file/FSInfo.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/file/FSInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 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 @@ -137,6 +137,7 @@ public List getJarClassPath(Path file) throws IOException { * @throws MalformedURLException */ static URL tryResolveFile(URL base, String input) throws MalformedURLException { + @SuppressWarnings("deprecation") URL retVal = new URL(base, input); if (input.indexOf(':') >= 0 && !"file".equalsIgnoreCase(retVal.getProtocol())) { // 'input' contains a ':', which might be a scheme, or might be diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/launcher/Main.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/launcher/Main.java index 7727928bdbe12..8d907dba293d2 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/launcher/Main.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/launcher/Main.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -690,7 +690,9 @@ public URL findResource(String name) { } try { - return new URL(PROTOCOL, null, -1, name, handler); + @SuppressWarnings("deprecation") + var result = new URL(PROTOCOL, null, -1, name, handler); + return result; } catch (MalformedURLException e) { return null; } diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/ServiceProxy.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/ServiceProxy.java index c932bb2d766ee..20324629ef48a 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/ServiceProxy.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/processing/ServiceProxy.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 @@ -138,6 +138,7 @@ public static boolean hasService(Class service, URL[] urls) for (URL url: urls) { try { String fullName = prefix + service.getName(); + @SuppressWarnings("deprecation") URL u = new URL(url, fullName); boolean found = parse(service, u); if (found) diff --git a/src/jdk.jartool/share/classes/sun/security/tools/jarsigner/Main.java b/src/jdk.jartool/share/classes/sun/security/tools/jarsigner/Main.java index a78ee38508806..8aec39aab2fb0 100644 --- a/src/jdk.jartool/share/classes/sun/security/tools/jarsigner/Main.java +++ b/src/jdk.jartool/share/classes/sun/security/tools/jarsigner/Main.java @@ -2253,7 +2253,8 @@ void loadKeyStore(String keyStoreName, boolean prompt) { keyStoreName = keyStoreName.replace(File.separatorChar, '/'); URL url = null; try { - url = new URL(keyStoreName); + @SuppressWarnings("deprecation") + var _unused = url = new URL(keyStoreName); } catch (java.net.MalformedURLException e) { // try as file url = new File(keyStoreName).toURI().toURL(); diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlOptions.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlOptions.java index ca1602a45e722..e7f0c934c158d 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlOptions.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlOptions.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 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 @@ -458,7 +458,8 @@ public boolean process(String opt, List args) { public boolean process(String opt, List args) { docrootParent = args.get(0); try { - new URL(docrootParent); + @SuppressWarnings("deprecation") + var _unused = new URL(docrootParent); } catch (MalformedURLException e) { messages.error("doclet.MalformedURL", docrootParent); return false; diff --git a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Extern.java b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Extern.java index 4079675307439..4fbfc2dac77a5 100644 --- a/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Extern.java +++ b/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Extern.java @@ -578,7 +578,8 @@ private String checkLinkCompatibility(String packageName, String moduleName, Str public boolean isUrl (String urlCandidate) { try { - new URL(urlCandidate); + @SuppressWarnings("deprecation") + var _unused = new URL(urlCandidate); //No exception was thrown, so this must really be a URL. return true; } catch (MalformedURLException e) { @@ -587,6 +588,7 @@ public boolean isUrl (String urlCandidate) { } } + @SuppressWarnings("deprecation") private URL toURL(String url) throws Fault { try { return new URL(url); @@ -632,7 +634,8 @@ private InputStream open(URL url) throws IOException { String loc = http.getHeaderField("Location"); URL target = null; if (loc != null) { - target = new URL(base, loc); + @SuppressWarnings("deprecation") + var _unused = target = new URL(base, loc); } http.disconnect(); if (target == null || redirects >= 5) { diff --git a/src/jdk.jconsole/share/classes/sun/tools/jconsole/JConsole.java b/src/jdk.jconsole/share/classes/sun/tools/jconsole/JConsole.java index 908f1e5056c91..ea9526b2b73d7 100644 --- a/src/jdk.jconsole/share/classes/sun/tools/jconsole/JConsole.java +++ b/src/jdk.jconsole/share/classes/sun/tools/jconsole/JConsole.java @@ -1047,7 +1047,9 @@ private static URL fileToURL(File file) throws MalformedURLException { if (!file.isFile()) { name = name + "/"; } - return new URL("file", "", name); + @SuppressWarnings("deprecation") + var result = new URL("file", "", name); + return result; } diff --git a/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java b/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java index 14e9f49ff230f..7a7b6239ffca9 100644 --- a/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java +++ b/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 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 @@ -3077,7 +3077,8 @@ private boolean runFile(String filename, String context) { path = toPathResolvingUserHome(filename); } catch (InvalidPathException ipe) { try { - url = new URL(filename); + @SuppressWarnings("deprecation") + var _unused = url = new URL(filename); if (url.getProtocol().equalsIgnoreCase("file")) { path = Paths.get(url.toURI()); } @@ -3092,7 +3093,8 @@ private boolean runFile(String filename, String context) { } else { if (url == null) { try { - url = new URL(filename); + @SuppressWarnings("deprecation") + var _unused = url = new URL(filename); } catch (MalformedURLException mue) { throw new FileNotFoundException(filename); } diff --git a/src/jdk.jshell/share/classes/jdk/jshell/execution/DefaultLoaderDelegate.java b/src/jdk.jshell/share/classes/jdk/jshell/execution/DefaultLoaderDelegate.java index 5a266b384cfc2..27bf0b95ebec4 100644 --- a/src/jdk.jshell/share/classes/jdk/jshell/execution/DefaultLoaderDelegate.java +++ b/src/jdk.jshell/share/classes/jdk/jshell/execution/DefaultLoaderDelegate.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -185,9 +185,8 @@ public Enumeration findResources(String name) throws IOException { private URL doFindResource(String name) { if (classFiles.containsKey(name)) { try { - return new URL(null, - new URI("jshell", null, "/" + name, null).toString(), - new ResourceURLStreamHandler(name)); + return URL.of(new URI("jshell", null, "/" + name, null), + new ResourceURLStreamHandler(name)); } catch (MalformedURLException | URISyntaxException ex) { throw new InternalError(ex); } diff --git a/src/jdk.security.auth/share/classes/com/sun/security/auth/module/KeyStoreLoginModule.java b/src/jdk.security.auth/share/classes/com/sun/security/auth/module/KeyStoreLoginModule.java index 19610eeac260e..7e3c597a131ce 100644 --- a/src/jdk.security.auth/share/classes/com/sun/security/auth/module/KeyStoreLoginModule.java +++ b/src/jdk.security.auth/share/classes/com/sun/security/auth/module/KeyStoreLoginModule.java @@ -393,7 +393,7 @@ private void checkStorePass() throws LoginException { } InputStream in = null; try { - in = new URL(keyStorePasswordURL).openStream(); + in = newURL(keyStorePasswordURL).openStream(); keyStorePassword = Password.readPassword(in); } catch (IOException e) { LoginException le = new LoginException @@ -421,7 +421,7 @@ private void checkKeyPass() throws LoginException { } else { InputStream in = null; try { - in = new URL(privateKeyPasswordURL).openStream(); + in = newURL(privateKeyPasswordURL).openStream(); privateKeyPassword = Password.readPassword(in); } catch (IOException e) { LoginException le = new LoginException @@ -599,7 +599,7 @@ private void getKeyStoreInfo() throws LoginException { // if using protected auth path, keyStorePassword will be null keyStore.load(null, keyStorePassword); } else { - in = new URL(keyStoreURL).openStream(); + in = newURL(keyStoreURL).openStream(); keyStore.load(in, keyStorePassword); } } catch (MalformedURLException e) { @@ -911,4 +911,9 @@ private void debugPrint(String message) { System.err.println("Debug KeyStoreLoginModule: " + message); } } + + @SuppressWarnings("deprecation") + private static URL newURL(String spec) throws MalformedURLException { + return new URL(spec); + } } diff --git a/test/jdk/java/net/URL/URIToURLTest.java b/test/jdk/java/net/URL/URIToURLTest.java index 81fc0ee5b0aa3..d70f53505b1c7 100644 --- a/test/jdk/java/net/URL/URIToURLTest.java +++ b/test/jdk/java/net/URL/URIToURLTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 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 @@ -83,6 +83,11 @@ public static void main(String args[]) throws Exception { boolean userInfoCheck = userInfo == null? url.getUserInfo() == null : userInfo.equals(url.getUserInfo()); + if (!userInfoCheck) { + throw new RuntimeException("uri.userInfo is " + userInfo + + " url.userInfo is " + + url.getUserInfo()); + } if (uri.getPort() != url.getPort()) throw new RuntimeException("uri.port is " + uri.getPort() + " url's is " + diff --git a/test/jdk/java/net/URL/URLFromURITest.java b/test/jdk/java/net/URL/URLFromURITest.java new file mode 100644 index 0000000000000..874120f9abfd3 --- /dev/null +++ b/test/jdk/java/net/URL/URLFromURITest.java @@ -0,0 +1,377 @@ +/* + * 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. + */ + +/* @test + * @bug 8294241 + * @library /test/lib + * @modules java.base/java.net:+open + * @summary Test URL::fromURI(URI, URLStreamHandler) + * @run junit/othervm URLFromURITest + */ + +import java.io.IOException; +import java.lang.invoke.MethodHandles; +import java.lang.invoke.MethodHandles.Lookup; +import java.lang.invoke.VarHandle; +import java.net.MalformedURLException; +import java.net.URI; +import java.net.URL; +import java.net.URLConnection; +import java.net.URLStreamHandler; +import java.util.Locale; +import java.util.Random; +import java.util.concurrent.atomic.AtomicInteger; +import java.util.stream.Stream; +import jdk.test.lib.RandomFactory; + +import org.junit.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; + +import static org.junit.jupiter.api.Assertions.*; + +public class URLFromURITest { + + static final Random RAND = RandomFactory.getRandom(); + + record TestInput(String uri, URLStreamHandler handler) { + static TestInput withNoHandler(String uri) { + return new TestInput(uri, null); + } + TestInput withCustomHandler() { + return new TestInput(uri(), new CustomStreamHandler()); + } + TestInput withUrlPrefix() {return inputWithUrlPrefix(this);} + } + + static URI uriWithUrlPrefix(URI uri) { + return URI.create(stringWithUrlPrefix(uri.toString())); + } + + static String stringWithUrlPrefix(String uriStr) { + if (uriStr.regionMatches(true, 0, "url:", 0, 4)) return uriStr; + return RAND.nextBoolean() ? "url:" + uriStr : "Url:" + uriStr; + } + + static TestInput inputWithUrlPrefix(TestInput input) { + String uriStr = input.uri(); + var handler = input.handler(); + + var urlUriStr = stringWithUrlPrefix(uriStr); + if (uriStr.equals(urlUriStr)) return null; + + var urlURI = URI.create(urlUriStr); + try { + new URL(null, urlURI.toString(), handler); + } catch (Throwable t) { + System.err.println("skipping new URL(null, \"" + urlURI + "\", handler): " + t); + return null; + } + return new TestInput(urlUriStr, handler); + } + + static Stream uris() { + var uris = Stream.of( + "http://jag:cafebabe@java.sun.com:94/b/c/d?q#g", + "http://[1080:0:0:0:8:800:200C:417A]/index.html", + "http://a/b/c/d;p?q", + "mailto:mduerst@ifi.unizh.ch", + "http:comp.infosystems.www.servers.unix", + "http://j%41g:cafeb%41be@java.sun.com:94/%41/b/c/d?q#g", + "jar:file:///x.jar!/", + "jmod:/java.base", + "jmod:///java.base"); + + if (hasFtp()) { + uris = Stream.concat(uris, + Stream.of("ftp://ftp.is.co.za/rfc/rfc1808.txt")); + } + + return uris; + } + + static Stream nonOverridableUris() { + return Stream.of("file:///nohost/%41/", + "file://with.host/%41/", + "file:/x/y/z", + "jrt:/java.base/java/lang/Integer.class", + "jrt:///java.base/java/lang/Integer.class"); + } + static Stream withNoHandler() { + return Stream.concat(uris(), nonOverridableUris()) + .map(TestInput::withNoHandler); + } + + static Stream withCustomHandler() { + var withHandlers = uris() + .map(TestInput::withNoHandler) + .map(TestInput::withCustomHandler); + return Stream.concat(withHandlers, Stream.of( + new TestInput("foo:bar:baz", new CustomStreamHandler()), + new TestInput("jar:file:///x.jar!/", new CustomStreamHandler()), + new TestInput("jar:jar:file///x.jar!/bing", new CustomStreamHandler()), + new TestInput("blah://localhost:80/x/y/z", new CustomStreamHandler()) + )); + } + + static Stream overridingNonOverridable() { + return nonOverridableUris().map(TestInput::withNoHandler) + .map(TestInput::withCustomHandler); + } + + @Test + public void checkExceptions() { + var noscheme = URI.create("http"); + var unknown = URI.create("unknown:///foo/bar"); + var opaque = URI.create("opaque:opaque-path"); + var jrt = URI.create("jrt:/java.base/java.lang.Integer.class"); + var file = URI.create("file:/"); + var unoscheme = uriWithUrlPrefix(noscheme); + var uunknown = uriWithUrlPrefix(unknown); + var uopaque = uriWithUrlPrefix(opaque); + var ujrt = uriWithUrlPrefix(jrt); + var ufile = uriWithUrlPrefix(file); + var handler = new CustomStreamHandler(); + assertThrows(NullPointerException.class, () -> URL.of(null, null)); + assertThrows(NullPointerException.class, () -> URL.of(null, handler)); + assertThrows(IllegalArgumentException.class, () -> URL.of(noscheme, null)); + assertThrows(IllegalArgumentException.class, () -> URL.of(noscheme, handler)); + assertThrows(IllegalArgumentException.class, () -> URL.of(jrt, handler)); + assertThrows(IllegalArgumentException.class, () -> URL.of(file, handler)); + assertThrows(IllegalArgumentException.class, () -> URL.of(ujrt, handler)); + assertThrows(IllegalArgumentException.class, () -> URL.of(ufile, handler)); + assertThrows(MalformedURLException.class, () -> URL.of(unknown, null)); + assertThrows(MalformedURLException.class, () -> URL.of(opaque, null)); + assertThrows(MalformedURLException.class, () -> URL.of(uunknown, null)); + assertThrows(MalformedURLException.class, () -> URL.of(uopaque, null)); + assertThrows(MalformedURLException.class, () -> URL.of(unoscheme, null)); + assertThrows(MalformedURLException.class, () -> URL.of(unoscheme, handler)); + } + + @ParameterizedTest + @MethodSource(value = "withNoHandler") + public void testWithNoHandler(TestInput input) throws Exception { + String uriStr = input.uri(); + URLStreamHandler handler = input.handler(); + System.err.println("testWithNoHandler: " + uriStr); + assertNull(handler, input + ": input handler"); + URI uri = new URI(uriStr); + URL url = URL.of(uri, handler); + checkNoHandler(input, uri, url); + var urlInput = input.withUrlPrefix(); + if (urlInput != null) { + try { + var urlURI = URI.create(input.uri()); + checkNoHandler(urlInput, uri, URL.of(urlURI, null)); + } catch (Throwable x) { + throw new AssertionError("Failed: " + urlInput.uri() + " with: " + x, x); + } + } + } + + private void checkNoHandler(TestInput input, URI uri, URL url) throws Exception { + System.err.println("Testing: " + uri); + checkURL(input, uri, url); + URLStreamHandler urlHandler = URLAccess.getHandler(url); + assertNotNull(urlHandler, input + ": URL.handler"); + assertNull(urlHandler.getClass().getClassLoader(), + input + ": URL.handler class loader"); + } + + @ParameterizedTest + @MethodSource(value = "withCustomHandler") + public void checkCustomHandler(TestInput input) throws Exception { + String uriStr = input.uri(); + URLStreamHandler handler = input.handler(); + System.err.println("testWithCustomHandler: " + input); + assertNotNull(handler, input + ": input handler"); + URI uri = new URI(uriStr); + URL url = URL.of(uri, handler); + checkCustomHandler(input, uri, url, handler); + var urlInput = input.withUrlPrefix(); + if (urlInput != null) { + urlInput = urlInput.withCustomHandler(); + handler = urlInput.handler(); + try { + var urlURI = URI.create(urlInput.uri()); + checkCustomHandler(urlInput, uri, URL.of(urlURI, handler), handler); + } catch (Throwable x) { + throw new AssertionError("Failed with handler: " + urlInput.uri() + " with: " + x, x); + } + } + } + + private void checkCustomHandler(TestInput input, URI uri, URL url, + URLStreamHandler handler) throws Exception { + System.err.println("Testing: " + uri); + checkURL(input, uri, url); + URLStreamHandler urlHandler = URLAccess.getHandler(url); + assertSame(handler, urlHandler, input + ": URL.handler"); + URLConnection c = url.openConnection(); + assertNotNull(c, input + ": opened connection"); + assertEquals(CustomURLConnection.class, c.getClass(), + input + ": connection class"); + assertEquals(CustomStreamHandler.class, urlHandler.getClass(), + input + ": handler class"); + assertEquals(((CustomURLConnection)c).handler, handler, input + ": handler"); + assertEquals(c.getURL(), url, input + ": connection url"); + var customHandler = (CustomStreamHandler)urlHandler; + assertEquals(customHandler.parseURLCalled(), 1, "parseURL calls"); + } + + @ParameterizedTest + @MethodSource(value = "overridingNonOverridable") + public void testOverridingNonOverridable(TestInput input) throws Exception { + String uriStr = input.uri(); + URLStreamHandler handler = input.handler(); + System.err.println("testOverridingNonOverridable: " + input); + assertNotNull(handler, input + ": input handler"); + URI uri = new URI(uriStr); + try { + URL url = URL.of(uri, handler); + throw new AssertionError("Should not be able to specify handler for: " + uriStr); + } catch (IllegalArgumentException x) { + System.err.println("Got expected exception: " + x); + } + } + + private static boolean isFileBased(URI uri) { + String scheme = uri.getScheme(); + boolean isJrt = "jrt".equals(scheme.toLowerCase(Locale.ROOT)); + boolean isJmod = "jmod".equals(scheme.toLowerCase(Locale.ROOT)); + boolean isFile = "file".equals(scheme.toLowerCase(Locale.ROOT)); + return isJmod || isJrt || isFile; + } + + private static void checkURL(TestInput input, URI uri, URL url) throws MalformedURLException { + String scheme = uri.getScheme(); + assertEquals(scheme, url.getProtocol(), input + ": scheme"); + + if (uri.isOpaque()) { + String ssp = uri.getSchemeSpecificPart(); + assertEquals(ssp, url.getPath(), input + ": ssp"); + } else { + String authority = uri.getRawAuthority(); + boolean isHierarchical = uri.toString().startsWith(scheme + "://"); + boolean isFileBased = isFileBased(uri); + + // Network based URLs usually follow URI, but file based + // protocol handlers have a few discrepancies in how they + // treat an absent authority: + // - URI authority is null if there is no authority, always + // - URL authority is null or empty depending on the protocol + // and on whether the URL is hierarchical or not. + if (isFileBased && authority == null) { + // jrt: takes a fastpath - so that jrt:/ is equivalent to jrt:/// + if (scheme.equals("jrt")) { + authority = ""; + } + if (isHierarchical) { + authority = ""; + } + } + assertEquals(authority, url.getAuthority(), input + ": authority"); + + // Network based URLs usually follow URI, but file based + // protocol handlers have a few discrepancies in how they + // treat an absent host: + String host = uri.getHost(); + if (isFileBased && host == null) { + host = ""; + } + + assertEquals(host, url.getHost(), input + ": host"); + if (host != null) { + String userInfo = uri.getRawUserInfo(); + assertEquals(userInfo, url.getUserInfo(), input + ": userInfo"); + assertEquals(uri.getPort(), url.getPort(), input + ": port"); + } + + String path = uri.getRawPath(); + assertEquals(path, url.getPath(), input + ": path"); + + String query = uri.getQuery(); + assertEquals(query, url.getQuery(), input + ": query"); + } + String frag = uri.getRawFragment(); + assertEquals(frag, url.getRef(), input + ": fragment"); + } + + @SuppressWarnings("deprecation") + private static boolean hasFtp() { + try { + return new java.net.URL("ftp://localhost/") != null; + } catch (java.net.MalformedURLException x) { + System.err.println("FTP not supported by this runtime."); + return false; + } + } + + static class CustomURLConnection extends URLConnection { + + public final CustomStreamHandler handler; + CustomURLConnection(CustomStreamHandler handler, URL url) { + super(url); + this.handler = handler; + } + + @Override + public void connect() throws IOException { + + } + } + static class CustomStreamHandler extends URLStreamHandler { + + final AtomicInteger parseURLCalled = new AtomicInteger(); + + @Override + protected void parseURL(URL u, String spec, int start, int limit) { + parseURLCalled.incrementAndGet(); + super.parseURL(u, spec, start, limit); + } + + @Override + protected URLConnection openConnection(URL u) throws IOException { + return new CustomURLConnection(this, u); + } + + public int parseURLCalled() { + return parseURLCalled.get(); + } + } + + static final class URLAccess { + static final VarHandle HANDLER; + static { + try { + Lookup lookup = MethodHandles.privateLookupIn(URL.class, MethodHandles.lookup()); + HANDLER = lookup.findVarHandle(URL.class, "handler", URLStreamHandler.class); + } catch (Exception x) { + throw new ExceptionInInitializerError(x); + } + } + static URLStreamHandler getHandler(URL url) { + return (URLStreamHandler)HANDLER.get(url); + } + } +} diff --git a/test/micro/org/openjdk/bench/java/net/ThreadLocalParseUtil.java b/test/micro/org/openjdk/bench/java/net/ThreadLocalParseUtil.java index 37d03d7f35343..93af26379a7cc 100644 --- a/test/micro/org/openjdk/bench/java/net/ThreadLocalParseUtil.java +++ b/test/micro/org/openjdk/bench/java/net/ThreadLocalParseUtil.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -72,6 +72,7 @@ public String decodeTest() throws Throwable { @Benchmark public URI appendEncodedTest() throws Throwable { + @SuppressWarnings("deprecation") URL url = new URL("https://example.com/xyz/abc/def?query=#30"); return (URI) MH_TO_URI.invokeExact(url); } diff --git a/test/micro/org/openjdk/bench/java/security/ProtectionDomainBench.java b/test/micro/org/openjdk/bench/java/security/ProtectionDomainBench.java index 83765805f77c6..ec85e09634f04 100644 --- a/test/micro/org/openjdk/bench/java/security/ProtectionDomainBench.java +++ b/test/micro/org/openjdk/bench/java/security/ProtectionDomainBench.java @@ -79,6 +79,7 @@ public void setupClasses() throws Exception { cs = new CodeSource[numberOfCodeSources]; for (int i = 0; i < numberOfCodeSources; i++) { + @SuppressWarnings("deprecation") URL u = new URL("file:/tmp/duke" + i); cs[i] = new CodeSource(u, (java.security.cert.Certificate[]) null); } From 84f30ba17015c55d2b01c88917f8b5e8e1da87e2 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Wed, 9 Nov 2022 22:15:01 +0100 Subject: [PATCH 42/85] Update rivos/gitlab-ci.yml file (#54) --- rivos/gitlab-ci.yml | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/rivos/gitlab-ci.yml b/rivos/gitlab-ci.yml index 64346c3aa0b25..0368051423038 100644 --- a/rivos/gitlab-ci.yml +++ b/rivos/gitlab-ci.yml @@ -243,16 +243,17 @@ package-deb-dbg-riscv64: PKG_ARCH: "riscv64" PKG_DBG: "true" -deploy-module-ubuntu: - extends: .deploy-module - dependencies: - - prepare-version - - build-linux-amd64 - needs: - - prepare-version - - build-linux-amd64 - variables: - CONTENT_PATH: "build/linux-amd64/images/jdk" +# deploy-module-ubuntu: +# extends: .deploy-module +# dependencies: +# - prepare-version +# - build-linux-amd64 +# needs: +# - prepare-version +# - build-linux-amd64 +# variables: +# CONTENT_PATH: "build/linux-amd64/images/jdk" +# UBUNTU2204_INSTALL_PATH: "${SDK_MODULES_ROOT}/ubuntu.22.04/x86_64/${CI_PROJECT_NAME}/${VERSION_TAG}" # Rebuild the rivos-sdk where we are exporting the artifacts built here. update-sdk: From 89bf232fa9e282cadb6e631c973ac1fef305669e Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Mon, 21 Nov 2022 20:00:14 +0100 Subject: [PATCH 43/85] Rename jdk-dbg package (#57) --- rivos/gitlab-ci.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/rivos/gitlab-ci.yml b/rivos/gitlab-ci.yml index 0368051423038..7b071d6313e2d 100644 --- a/rivos/gitlab-ci.yml +++ b/rivos/gitlab-ci.yml @@ -226,6 +226,7 @@ package-deb-dbg-amd64: - build-linux-amd64 - build-linux-riscv64 variables: + PKG_NAME: "${PROJECT_NAME}-dbg" PKG_DIRECTORIES: "/rivos/jdk;/rivos/sysroot/riscv/rivos/jdk" PKG_ARCH: "amd64" PKG_DBG: "true" @@ -239,6 +240,7 @@ package-deb-dbg-riscv64: - prepare-version - build-linux-riscv64 variables: + PKG_NAME: "${PROJECT_NAME}-dbg" PKG_DIRECTORIES: "/rivos/jdk" PKG_ARCH: "riscv64" PKG_DBG: "true" From d7c7028d28bbf8fea236372608e338474dc59c85 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Fri, 13 Jan 2023 10:31:00 +0100 Subject: [PATCH 44/85] Remove dependency on build JDK (#66) --- rivos/gitlab-ci.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/rivos/gitlab-ci.yml b/rivos/gitlab-ci.yml index 7b071d6313e2d..6ff318bc47483 100644 --- a/rivos/gitlab-ci.yml +++ b/rivos/gitlab-ci.yml @@ -106,7 +106,6 @@ create-sysroot-riscv64: --with-version-opt="${JDK_VERSION_OPT}" \ --with-sysroot=$(pwd)/sysroot-${UBUNTU_CODENAME}-${PKG_ARCH} \ --with-boot-jdk=/usr/lib/jvm/temurin-20 \ - --with-build-jdk=/usr/lib/jvm/temurin-20 \ --disable-precompiled-headers \ --with-zlib=system - make ${MAKE_TARGETS} LOG_LEVEL=info From 1cd2374aabd4952dc475b3b3a4029e59319a6c5f Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Wed, 25 Jan 2023 11:21:36 -0800 Subject: [PATCH 45/85] Reimplement sha256 and sha512 stubs with latest sample (#67) https://github.com/rivosinc/riscv-code-samples/blob/b7582afe988c53e9bd07426ec064fe9907ca1750/zvk-vector-crypto/zvknh.s --- src/hotspot/cpu/riscv/assembler_riscv.hpp | 81 +- src/hotspot/cpu/riscv/globals_riscv.hpp | 1 + .../cpu/riscv/macroAssembler_riscv.hpp | 4 + src/hotspot/cpu/riscv/stubGenerator_riscv.cpp | 806 +++++++++++++----- src/hotspot/cpu/riscv/vm_version_riscv.cpp | 4 +- 5 files changed, 652 insertions(+), 244 deletions(-) diff --git a/src/hotspot/cpu/riscv/assembler_riscv.hpp b/src/hotspot/cpu/riscv/assembler_riscv.hpp index 9430062507f09..43d02bbdc33fe 100644 --- a/src/hotspot/cpu/riscv/assembler_riscv.hpp +++ b/src/hotspot/cpu/riscv/assembler_riscv.hpp @@ -1293,6 +1293,10 @@ enum VectorMask { INSN(vsrl_vi, 0b1010111, 0b011, 0b101000); INSN(vsll_vi, 0b1010111, 0b011, 0b100101); + // Vector Slide Instructions + INSN(vslideup_vi, 0b1010111, 0b011, 0b001110); + INSN(vslidedown_vi, 0b1010111, 0b011, 0b001111); + #undef INSN #define INSN(NAME, op, funct3, funct6) \ @@ -1316,6 +1320,13 @@ enum VectorMask { INSN(vnmsac_vv, 0b1010111, 0b010, 0b101111); INSN(vmacc_vv, 0b1010111, 0b010, 0b101101); +#undef INSN + +#define INSN(NAME, op, funct3, funct6) \ + void NAME(VectorRegister Vd, VectorRegister Vs2, VectorRegister Vs1, VectorMask vm = unmasked) { \ + patch_VArith(op, Vd, funct3, Vs1->raw_encoding(), Vs2, vm, funct6); \ + } + // Vector Register Gather Instructions INSN(vrgather_vv, 0b1010111, 0b000, 0b001100); INSN(vrgatherei16_vv, 0b1010111, 0b000, 0b001110); @@ -1333,6 +1344,12 @@ enum VectorMask { INSN(vnmsac_vx, 0b1010111, 0b110, 0b101111); INSN(vmacc_vx, 0b1010111, 0b110, 0b101101); + // Vector Slide Instructions + INSN(vslideup_vx, 0b1010111, 0b100, 0b001110); + INSN(vslide1up_vx, 0b1010111, 0b110, 0b001110); + INSN(vslidedown_vx, 0b1010111, 0b100, 0b001111); + INSN(vslide1down_vx, 0b1010111, 0b110, 0b001111); + #undef INSN #define INSN(NAME, op, funct3, funct6) \ @@ -1571,7 +1588,7 @@ enum VectorMask { #undef INSN #define INSN(NAME, op, funct3, vm, funct6) \ - void NAME(VectorRegister Vd, VectorRegister Vs1, VectorRegister Vs2) { \ + void NAME(VectorRegister Vd, VectorRegister Vs2, VectorRegister Vs1) { \ patch_VArith(op, Vd, funct3, Vs1->raw_encoding(), Vs2, vm, funct6); \ } @@ -1580,18 +1597,6 @@ enum VectorMask { #undef INSN -#define INSN(NAME, op, funct3, vm, funct6) \ - void NAME(VectorRegister Vd, VectorRegister Vs1, VectorRegister Vs2) { \ - patch_VArith(op, Vd, funct3, Vs1->raw_encoding(), Vs2, vm, funct6); \ - } - - // Vector SHA-2 Instructions - INSN(vsha2ms_vv, 0b0001011, 0b000, 0b1, 0b100000); - INSN(vsha2cl_vv, 0b0001011, 0b000, 0b1, 0b100001); - INSN(vsha2ch_vv, 0b0001011, 0b000, 0b1, 0b100010); - -#undef INSN - #define INSN(NAME, op, funct3, Vs2, vm, funct6) \ void NAME(VectorRegister Vd, int32_t imm) { \ guarantee(is_imm_in_range(imm, 5, 0), "imm is invalid"); \ @@ -1637,7 +1642,6 @@ enum VectorMask { INSN(vmv_v_x, 0b1010111, 0b100, v0, 0b1, 0b010111); #undef INSN -#undef patch_VArith #define INSN(NAME, op, funct13, funct6) \ void NAME(VectorRegister Vd, VectorMask vm = unmasked) { \ @@ -1786,6 +1790,55 @@ enum Nf { #undef INSN #undef patch_VLdSt +// ==================================== +// RISC-V Vector Crypto Extension +// ==================================== + +#define INSN(NAME, op, funct3, funct6) \ + void NAME(VectorRegister Vd, VectorRegister Vs2, VectorRegister Vs1, VectorMask vm = unmasked) { \ + patch_VArith(op, Vd, funct3, Vs1->raw_encoding(), Vs2, vm, funct6); \ + } + + // Vector Bit-manipulation used in Cryptography (Zvkb) Extension + INSN(vandn_vv, 0b1010111, 0b000, 0b000001); + INSN(vandn_vx, 0b1010111, 0b100, 0b000001); + INSN(vandn_vi, 0b1010111, 0b011, 0b000001); + INSN(vclmul_vv, 0b1010111, 0b010, 0b001100); + INSN(vclmul_vx, 0b1010111, 0b110, 0b001100); + INSN(vclmulh_vv, 0b1010111, 0b010, 0b001101); + INSN(vclmulh_vx, 0b1010111, 0b110, 0b001101); + INSN(vror_vv, 0b1010111, 0b000, 0b010100); + INSN(vror_vx, 0b1010111, 0b100, 0b010100); + INSN(vrol_vv, 0b1010111, 0b000, 0b010101); + INSN(vrol_vx, 0b1010111, 0b100, 0b010101); + +#undef INSN + +#define INSN(NAME, op, funct3, Vs1, funct6) \ + void NAME(VectorRegister Vd, VectorRegister Vs2, VectorMask vm = unmasked) { \ + patch_VArith(op, Vd, funct3, Vs1, Vs2, vm, funct6); \ + } + + // Vector Bit-manipulation used in Cryptography (Zvkb) Extension + INSN(vbrev8_v, 0b1010111, 0b010, 0b01000, 0b010010); + INSN(vrev8_v, 0b1010111, 0b010, 0b01001, 0b010010); + +#undef INSN + +#define INSN(NAME, op, funct3, vm, funct6) \ + void NAME(VectorRegister Vd, VectorRegister Vs2, VectorRegister Vs1) { \ + patch_VArith(op, Vd, funct3, Vs1->raw_encoding(), Vs2, vm, funct6); \ + } + + // Vector SHA-2 Secure Hash (Zvknh[ab]) Extension + INSN(vsha2ms_vv, 0b1110111, 0b010, 0b1, 0b101101); + INSN(vsha2ch_vv, 0b1110111, 0b010, 0b1, 0b101110); + INSN(vsha2cl_vv, 0b1110111, 0b010, 0b1, 0b101111); + +#undef INSN + +#undef patch_VArith + // ==================================== // RISC-V Bit-Manipulation Extension // Currently only support Zba, Zbb and Zbs bitmanip extensions. diff --git a/src/hotspot/cpu/riscv/globals_riscv.hpp b/src/hotspot/cpu/riscv/globals_riscv.hpp index c9bc30916933f..eee9866eafd69 100644 --- a/src/hotspot/cpu/riscv/globals_riscv.hpp +++ b/src/hotspot/cpu/riscv/globals_riscv.hpp @@ -109,6 +109,7 @@ define_pd_global(intx, InlineSmallCode, 1000); 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, UseZvkb, false, EXPERIMENTAL, "Use Zvkb instructions") \ product(bool, UseZvknha, false, EXPERIMENTAL, "Use Zvknha instructions") \ product(bool, UseZvknhb, false, EXPERIMENTAL, "Use Zvknhb instructions") \ product(bool, UseRVVForBigIntegerShiftIntrinsics, true, \ diff --git a/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp b/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp index ff2e987a54580..3ccd4b8c8b799 100644 --- a/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp +++ b/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp @@ -1278,6 +1278,10 @@ class MacroAssembler: public Assembler { vmsleu_vi(Vd, Vs2, imm-1, vm); } + inline void vmsgeu_vi(VectorRegister Vd, VectorRegister Vs2, int32_t imm, VectorMask vm = unmasked) { + vmsgtu_vi(Vd, Vs2, imm-1, vm); + } + static const int zero_words_block_size; void cast_primitive_type(BasicType type, Register Rt) { diff --git a/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp b/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp index f60a47ff4db88..02fbec22e9a8b 100644 --- a/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp +++ b/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp @@ -3753,211 +3753,370 @@ class StubGenerator: public StubCodeGenerator { Register state = c_rarg1; Register ofs = c_rarg2; Register limit = c_rarg3; + Register consts = t0; Label multi_block_loop; __ enter(); - __ vsetivli(x0, 4, Assembler::e32, Assembler::m1, Assembler::ma, Assembler::ta); - __ vle32_v(v16, c_rarg1); - __ add(c_rarg1, c_rarg1, 16); - __ vle32_v(v17, c_rarg1); - - __ bind(multi_block_loop); + // Register use in this function: + // + // VECTORS + // v10 - v13 (512-bits / 4*128 bits / 4*4*32 bits), hold the message + // schedule words (Wt). They start with the message block + // content (W0 to W15), then further words in the message + // schedule generated via vsha2ms from previous Wt. + // Initially: + // v10 = W[ 3:0] = { W3, W2, W1, W0} + // v11 = W[ 7:4] = { W7, W6, W5, W4} + // v12 = W[ 11:8] = {W11, W10, W9, W8} + // v13 = W[15:12] = {W15, W14, W13, W12} + // + // v16 - v17 hold the working state variables (a, b, ..., h) + // v16 = {a[t],b[t],e[t],f[t]} + // v17 = {c[t],d[t],g[t],h[t]} + // Initially: + // v16 = {H5i-1, H4i-1, H1i-1 , H0i-1} + // v17 = {H7i-i, H6i-1, H3i-1 , H2i-1} + // + // v0 = masks for vrgather/vmerge. Single value during the 16 rounds. + // + // v14 = temporary, Wt+Kt + // v15 = temporary, Kt + // + // v18/v19 = temporaries, in the epilogue, to re-arrange + // and byte-swap v16/v17 + // + // v26/v27 = hold the initial values of the hash, byte-swapped. + // + // v30/v31 = used to generate masks, vrgather indices. + // + // During most of the function the vector state is configured so that each + // vector is interpreted as containing four 32 bits (e32) elements (128 bits). + // Set vectors as 4 * 32 bits + // + // e32: vector of 32b/4B elements + // m1: LMUL=1 + // ta: tail agnostic (don't care about those lanes) + // ma: mask agnostic (don't care about those lanes) + // x0 is not written, we known the number of vector elements, 8. __ vsetivli(x0, 4, Assembler::e32, Assembler::m1, Assembler::ma, Assembler::ta); - __ vle32_v(v20, c_rarg0); - __ add(c_rarg0, c_rarg0, 16); - __ vle32_v(v21, c_rarg0); - __ add(c_rarg0, c_rarg0, 16); - __ vle32_v(v22, c_rarg0); - __ add(c_rarg0, c_rarg0, 16); - __ vle32_v(v23, c_rarg0); - __ add(c_rarg0, c_rarg0, 16); - - __ vsetivli(x0, 16, Assembler::e8, Assembler::m1, Assembler::ma, Assembler::ta); - __ vid_v(v24); - __ vxor_vi(v24, v24, 0x3); - __ vrgather_vv(v10, v20, v24); - __ vrgather_vv(v11, v21, v24); - __ vrgather_vv(v12, v22, v24); - __ vrgather_vv(v13, v23, v24); - __ vrgather_vv(v26, v16, v24); - __ vrgather_vv(v27, v17, v24); - __ vsetivli(x0, 4, Assembler::e32, Assembler::m1, Assembler::ma, Assembler::ta); + // Load H[0..8] to produce + // v16 = {a,b,e,f} + // v17 = {c,d,g,h} + __ vle32_v(v16, state); // v16 = {d,c,b,a} + __ addi(state, state, 16); + __ vle32_v(v17, state); // v17 = {h,g,f,e} + + __ vid_v(v30); // v30 = {3,2,1,0} + __ vxor_vi(v30, v30, 0x3); // v30 = {0,1,2,3} + __ vrgather_vv(v26, v16, v30); // v26 = {a,b,c,d} + __ vrgather_vv(v27, v17, v30); // v27 = {e,f,g,h} + __ vmsgeu_vi(v0, v30, 2); // v0 = {f,f,t,t} + // Copy elements [3..2] of v26 ({d,c}) into elements [3..2] of v17. + __ vslideup_vi(v17, v26, 2); // v17 = {c,d,_,_} + // Merge elements [1..0] of v27 ({g,h}) into elements [1..0] of v17 + __ vmerge_vvm(v17, v17, v27); // v17 = {c,d,g,h} + // Copy elements [1..0] of v27 ({f,e}) into elements [1..0] of v16. + __ vslidedown_vi(v16, v27, 2); // v16 = {_,_,e,f} + // Merge elements [3..2] of v26 ({a,b}) into elements [3..2] of v16 + __ vmerge_vvm(v16, v26, v16); // v16 = {a,b,e,f} + + __ bind(multi_block_loop); - __ vid_v(v31); - __ vadd_vi(v30, v31, 2); - __ vmsltu_vi(v0, v31, 2); - __ vrgather_vv(v17, v26, v30, Assembler::v0_t); - __ vmerge_vvm(v17, v27, v17); - __ vadd_vi(v30, v31, -2); - __ vnot_v(v0, v0); - __ vrgather_vv(v16, v27, v30, Assembler::v0_t); - __ vmerge_vvm(v16, v26, v16); + // Capture the initial H values in v26 and v27 to allow for computing + // the resulting H', since H' = H+{a',b',c',...,h'}. + __ vmv_v_v(v26, v16); + __ vmv_v_v(v27, v17); + // Load the 512-bits of the message block in v10-v13 and perform + // an endian swap on each 4 bytes element. + // + // If Zvkb is not implemented, one can use vrgather with the right index + // sequence. It requires loading in separate registers since the destination + // of vrgather cannot overlap the source. + // // We generate the lane (byte) index sequence + // // v24 = [3 2 1 0 7 6 5 4 11 10 9 8 15 14 13 12] + // // gives us "N ^ 3" as a nice formula to generate + // // this sequence. 'vid' gives us the N. + // // + // // We switch the vector type to SEW=8 temporarily. + // vsetivli x0, 16, e8, m1, ta, ma + // vid.v v24 + // vxor.vi v24, v24, 0x3 + // // Byteswap the bytes in each word of the text. + // vrgather.vv v10, v20, v24 + // vrgather.vv v11, v21, v24 + // vrgather.vv v12, v22, v24 + // vrgather.vv v13, v23, v24 + // // Switch back to SEW=32 + // vsetivli x0, 4, e32, m1, ta, ma + __ vle32_v(v10, buf); + __ vrev8_v(v10, v10); + __ addi(buf, buf, 16); + __ vle32_v(v11, buf); + __ vrev8_v(v11, v11); + __ addi(buf, buf, 16); + __ vle32_v(v12, buf); + __ vrev8_v(v12, v12); + __ addi(buf, buf, 16); + __ vle32_v(v13, buf); + __ vrev8_v(v13, v13); + + // Set v0 up for the vmerge that replaces the first word (idx==0) __ vid_v(v0); - __ vmseq_vi(v0, v0, 0x0); + __ vmseq_vi(v0, v0, 0x0); // v0.mask[i] = (i == 0 ? 1 : 0) - __ la(t0, ExternalAddress((address)round_consts)); + __ la(consts, ExternalAddress((address)round_consts)); - // Quad-round 0 (+0, Wt from oldest to newest in v10->v11->v12->v13) - __ vl1re32_v(v15, t0); - __ add(t0, t0, 16); + // Overview of the logic in each "quad round". + // + // The code below repeats 16 times the logic implementing four rounds + // of the SHA-256 core loop as documented by NIST. 16 "quad rounds" + // to implementing the 64 single rounds. + // + // // Load four word (u32) constants (K[t+3], K[t+2], K[t+1], K[t+0]) + // // Output: + // // v15 = {K[t+3], K[t+2], K[t+1], K[t+0]} + // vl1re32.v v15, ofs + // + // // Increment word contant address by stride (16 bytes, 4*4B, 128b) + // addi ofs, ofs, 16 + // + // // Add constants to message schedule words: + // // Input + // // v15 = {K[t+3], K[t+2], K[t+1], K[t+0]} + // // v10 = {W[t+3], W[t+2], W[t+1], W[t+0]}; // Vt0 = W[3:0]; + // // Output + // // v14 = {W[t+3]+K[t+3], W[t+2]+K[t+2], W[t+1]+K[t+1], W[t+0]+K[t+0]} + // vadd.vv v14, v15, v10 + // + // // 2 rounds of working variables updates. + // // v17[t+4] <- v17[t], v16[t], v14[t] + // // Input: + // // v17 = {c[t],d[t],g[t],h[t]} " = v17[t] " + // // v16 = {a[t],b[t],e[t],f[t]} + // // v14 = {W[t+3]+K[t+3], W[t+2]+K[t+2], W[t+1]+K[t+1], W[t+0]+K[t+0]} + // // Output: + // // v17 = {f[t+2],e[t+2],b[t+2],a[t+2]} " = v16[t+2] " + // // = {h[t+4],g[t+4],d[t+4],c[t+4]} " = v17[t+4] " + // vsha2cl.vv v17, v16, v14 + // + // // 2 rounds of working variables updates. + // // v16[t+4] <- v16[t], v16[t+2], v14[t] + // // Input + // // v16 = {a[t],b[t],e[t],f[t]} " = v16[t] " + // // = {h[t+2],g[t+2],d[t+2],c[t+2]} " = v17[t+2] " + // // v17 = {f[t+2],e[t+2],b[t+2],a[t+2]} " = v16[t+2] " + // // v14 = {W[t+3]+K[t+3], W[t+2]+K[t+2], W[t+1]+K[t+1], W[t+0]+K[t+0]} + // // Output: + // // v16 = {f[t+4],e[t+4],b[t+4],a[t+4]} " = v16[t+4] " + // vsha2ch.vv v16, v17, v14 + // + // // Combine 2QW into 1QW + // // + // // To generate the next 4 words, "new_v10"/"v14" from v10-v13, vsha2ms needs + // // v10[0..3], v11[0], v12[1..3], v13[0, 2..3] + // // and it can only take 3 vectors as inputs. Hence we need to combine + // // v11[0] and v12[1..3] in a single vector. + // // + // // vmerge Vt4, Vt1, Vt2, V0 + // // Input + // // V0 = mask // first word from v12, 1..3 words from v11 + // // V12 = {Wt-8, Wt-7, Wt-6, Wt-5} + // // V11 = {Wt-12, Wt-11, Wt-10, Wt-9} + // // Output + // // Vt4 = {Wt-12, Wt-7, Wt-6, Wt-5} + // vmerge.vvm v14, v12, v11, v0 + // + // // Generate next Four Message Schedule Words (hence allowing for 4 more rounds) + // // Input + // // V10 = {W[t+ 3], W[t+ 2], W[t+ 1], W[t+ 0]} W[ 3: 0] + // // V13 = {W[t+15], W[t+14], W[t+13], W[t+12]} W[15:12] + // // V14 = {W[t+11], W[t+10], W[t+ 9], W[t+ 4]} W[11: 9,4] + // // Output (next four message schedule words) + // // v10 = {W[t+19], W[t+18], W[t+17], W[t+16]} W[19:16] + // vsha2ms.vv v10, v14, v13 + // + // BEFORE + // v10 - v13 hold the message schedule words (initially the block words) + // v10 = W[ 3: 0] "oldest" + // v11 = W[ 7: 4] + // v12 = W[11: 8] + // v13 = W[15:12] "newest" + // + // vt6 - vt7 hold the working state variables + // v16 = {a[t],b[t],e[t],f[t]} // initially {H5,H4,H1,H0} + // v17 = {c[t],d[t],g[t],h[t]} // initially {H7,H6,H3,H2} + // + // AFTER + // v10 - v13 hold the message schedule words (initially the block words) + // v11 = W[ 7: 4] "oldest" + // v12 = W[11: 8] + // v13 = W[15:12] + // v10 = W[19:16] "newest" + // + // v16 and v17 hold the working state variables + // v16 = {a[t+4],b[t+4],e[t+4],f[t+4]} + // v17 = {c[t+4],d[t+4],g[t+4],h[t+4]} + // + // The group of vectors v10,v11,v12,v13 is "rotated" by one in each quad-round, + // hence the uses of those vectors rotate in each round, and we get back to the + // initial configuration every 4 quad-rounds. We could avoid those changes at + // the cost of moving those vectors at the end of each quad-rounds. + + //-------------------------------------------------------------------------------- + // Quad-round 0 (+0, v10->v11->v12->v13) + __ vl1re32_v(v15, consts); + __ addi(consts, consts, 16); __ vadd_vv(v14, v15, v10); __ vsha2cl_vv(v17, v16, v14); __ vsha2ch_vv(v16, v17, v14); __ vmerge_vvm(v14, v12, v11); __ vsha2ms_vv(v10, v14, v13); // Generate W[19:16] - + //-------------------------------------------------------------------------------- // Quad-round 1 (+1, v11->v12->v13->v10) - __ vl1re32_v(v15, t0); - __ add(t0, t0, 16); + __ vl1re32_v(v15, consts); + __ addi(consts, consts, 16); __ vadd_vv(v14, v15, v11); __ vsha2cl_vv(v17, v16, v14); __ vsha2ch_vv(v16, v17, v14); __ vmerge_vvm(v14, v13, v12); __ vsha2ms_vv(v11, v14, v10); // Generate W[23:20] - + //-------------------------------------------------------------------------------- // Quad-round 2 (+2, v12->v13->v10->v11) - __ vl1re32_v(v15, t0); - __ add(t0, t0, 16); + __ vl1re32_v(v15, consts); + __ addi(consts, consts, 16); __ vadd_vv(v14, v15, v12); __ vsha2cl_vv(v17, v16, v14); __ vsha2ch_vv(v16, v17, v14); __ vmerge_vvm(v14, v10, v13); __ vsha2ms_vv(v12, v14, v11); // Generate W[27:24] - + //-------------------------------------------------------------------------------- // Quad-round 3 (+3, v13->v10->v11->v12) - __ vl1re32_v(v15, t0); - __ add(t0, t0, 16); + __ vl1re32_v(v15, consts); + __ addi(consts, consts, 16); __ vadd_vv(v14, v15, v13); __ vsha2cl_vv(v17, v16, v14); __ vsha2ch_vv(v16, v17, v14); __ vmerge_vvm(v14, v11, v10); __ vsha2ms_vv(v13, v14, v12); // Generate W[31:28] + //-------------------------------------------------------------------------------- // Quad-round 4 (+0, v10->v11->v12->v13) - __ vl1re32_v(v15, t0); - __ add(t0, t0, 16); + __ vl1re32_v(v15, consts); + __ addi(consts, consts, 16); __ vadd_vv(v14, v15, v10); __ vsha2cl_vv(v17, v16, v14); __ vsha2ch_vv(v16, v17, v14); __ vmerge_vvm(v14, v12, v11); __ vsha2ms_vv(v10, v14, v13); // Generate W[35:32] - + //-------------------------------------------------------------------------------- // Quad-round 5 (+1, v11->v12->v13->v10) - __ vl1re32_v(v15, t0); - __ add(t0, t0, 16); + __ vl1re32_v(v15, consts); + __ addi(consts, consts, 16); __ vadd_vv(v14, v15, v11); __ vsha2cl_vv(v17, v16, v14); __ vsha2ch_vv(v16, v17, v14); __ vmerge_vvm(v14, v13, v12); __ vsha2ms_vv(v11, v14, v10); // Generate W[39:36] - + //-------------------------------------------------------------------------------- // Quad-round 6 (+2, v12->v13->v10->v11) - __ vl1re32_v(v15, t0); - __ add(t0, t0, 16); + __ vl1re32_v(v15, consts); + __ addi(consts, consts, 16); __ vadd_vv(v14, v15, v12); __ vsha2cl_vv(v17, v16, v14); __ vsha2ch_vv(v16, v17, v14); __ vmerge_vvm(v14, v10, v13); __ vsha2ms_vv(v12, v14, v11); // Generate W[43:40] - + //-------------------------------------------------------------------------------- // Quad-round 7 (+3, v13->v10->v11->v12) - __ vl1re32_v(v15, t0); - __ add(t0, t0, 16); + __ vl1re32_v(v15, consts); + __ addi(consts, consts, 16); __ vadd_vv(v14, v15, v13); __ vsha2cl_vv(v17, v16, v14); __ vsha2ch_vv(v16, v17, v14); __ vmerge_vvm(v14, v11, v10); __ vsha2ms_vv(v13, v14, v12); // Generate W[47:44] + //-------------------------------------------------------------------------------- // Quad-round 8 (+0, v10->v11->v12->v13) - __ vl1re32_v(v15, t0); - __ add(t0, t0, 16); + __ vl1re32_v(v15, consts); + __ addi(consts, consts, 16); __ vadd_vv(v14, v15, v10); __ vsha2cl_vv(v17, v16, v14); __ vsha2ch_vv(v16, v17, v14); __ vmerge_vvm(v14, v12, v11); __ vsha2ms_vv(v10, v14, v13); // Generate W[51:48] - + //-------------------------------------------------------------------------------- // Quad-round 9 (+1, v11->v12->v13->v10) - __ vl1re32_v(v15, t0); - __ add(t0, t0, 16); + __ vl1re32_v(v15, consts); + __ addi(consts, consts, 16); __ vadd_vv(v14, v15, v11); __ vsha2cl_vv(v17, v16, v14); __ vsha2ch_vv(v16, v17, v14); __ vmerge_vvm(v14, v13, v12); __ vsha2ms_vv(v11, v14, v10); // Generate W[55:52] - + //-------------------------------------------------------------------------------- // Quad-round 10 (+2, v12->v13->v10->v11) - __ vl1re32_v(v15, t0); - __ add(t0, t0, 16); + __ vl1re32_v(v15, consts); + __ addi(consts, consts, 16); __ vadd_vv(v14, v15, v12); __ vsha2cl_vv(v17, v16, v14); __ vsha2ch_vv(v16, v17, v14); __ vmerge_vvm(v14, v10, v13); __ vsha2ms_vv(v12, v14, v11); // Generate W[59:56] - + //-------------------------------------------------------------------------------- // Quad-round 11 (+3, v13->v10->v11->v12) - __ vl1re32_v(v15, t0); - __ add(t0, t0, 16); + __ vl1re32_v(v15, consts); + __ addi(consts, consts, 16); __ vadd_vv(v14, v15, v13); __ vsha2cl_vv(v17, v16, v14); __ vsha2ch_vv(v16, v17, v14); __ vmerge_vvm(v14, v11, v10); __ vsha2ms_vv(v13, v14, v12); // Generate W[63:60] + //-------------------------------------------------------------------------------- // Quad-round 12 (+0, v10->v11->v12->v13) - __ vl1re32_v(v15, t0); - __ add(t0, t0, 16); + // Note that we stop generating new message schedule words (Wt, v10-13) + // as we already generated all the words we end up consuming (i.e., W[63:60]). + __ vl1re32_v(v15, consts); + __ addi(consts, consts, 16); __ vadd_vv(v14, v15, v10); __ vsha2cl_vv(v17, v16, v14); __ vsha2ch_vv(v16, v17, v14); - + //-------------------------------------------------------------------------------- // Quad-round 13 (+1, v11->v12->v13->v10) - __ vl1re32_v(v15, t0); - __ add(t0, t0, 16); + __ vl1re32_v(v15, consts); + __ addi(consts, consts, 16); __ vadd_vv(v14, v15, v11); __ vsha2cl_vv(v17, v16, v14); __ vsha2ch_vv(v16, v17, v14); - + //-------------------------------------------------------------------------------- // Quad-round 14 (+2, v12->v13->v10->v11) - __ vl1re32_v(v15, t0); - __ add(t0, t0, 16); + __ vl1re32_v(v15, consts); + __ addi(consts, consts, 16); __ vadd_vv(v14, v15, v12); __ vsha2cl_vv(v17, v16, v14); __ vsha2ch_vv(v16, v17, v14); - + //-------------------------------------------------------------------------------- // Quad-round 15 (+3, v13->v10->v11->v12) - __ vl1re32_v(v15, t0); - __ add(t0, t0, 16); + __ vl1re32_v(v15, consts); + // No consts increment needed __ vadd_vv(v14, v15, v13); __ vsha2cl_vv(v17, v16, v14); __ vsha2ch_vv(v16, v17, v14); - __ vid_v(v31); - - __ vadd_vi(v30, v31, 2); - __ vmsltu_vi(v0, v31, 2); - __ vrgather_vv(v19, v16, v30, Assembler::v0_t); - __ vmerge_vvm(v19, v17, v19); - __ vadd_vi(v30, v31, -2); - __ vnot_v(v0, v0); - __ vrgather_vv(v18, v17, v30, Assembler::v0_t); - __ vmerge_vvm(v18, v16, v18); + //-------------------------------------------------------------------------------- + // Compute the updated hash value H' + // H' = H + {h',g',...,b',a'} + // = {h,g,...,b,a} + {h',g',...,b',a'} + // = {h+h',g+g',...,b+b',a+a'} - __ vadd_vv(v18, v26, v18); - __ vadd_vv(v19, v27, v19); - - __ vsetivli(x0, 16, Assembler::e8, Assembler::m1, Assembler::ma, Assembler::ta); - __ vid_v(v24); - __ vxor_vi(v24, v24, 0x3); - - __ vrgather_vv(v16, v18, v24); - __ vrgather_vv(v17, v19, v24); + __ vadd_vv(v16, v26, v16); + __ vadd_vv(v17, v27, v17); if (multi_block) { __ add(ofs, ofs, 64); @@ -3965,10 +4124,27 @@ class StubGenerator: public StubCodeGenerator { __ mv(c_rarg0, ofs); // return ofs } - __ vsetivli(x0, 4, Assembler::e32, Assembler::m1, Assembler::ma, Assembler::ta); - __ vle32_v(v17, c_rarg1); - __ add(c_rarg1, c_rarg1, -16); - __ vle32_v(v16, c_rarg1); + // Store H[0..8] = {a,b,c,d,e,f,g,h} from + // v16 = {f,e,b,a} + // v17 = {h,g,d,c} + __ vid_v(v30); // v30 = {3,2,1,0} + __ vxor_vi(v30, v30, 0x3); // v30 = {0,1,2,3} + __ vrgather_vv(v26, v16, v30); // v26 = {f,e,b,a} + __ vrgather_vv(v27, v17, v30); // v27 = {h,g,d,c} + __ vmsgeu_vi(v0, v30, 2); // v0 = {f,f,t,t} + // Copy elements [3..2] of v26 ({f,e}) into elements [1..0] of v17. + __ vslidedown_vi(v17, v26, 2); // v17 = {_,_,f,e} + // Merge elements [3..2] of v27 ({g,h}) into elements [3..2] of v17 + __ vmerge_vvm(v17, v27, v17); // v17 = {h,g,f,e} + // Copy elements [1..0] of v27 ({c,d}) into elements [3..2] of v16. + __ vslideup_vi(v16, v27, 2); // v16 = {d,c,_,_} + // Merge elements [1..0] of v26 ({a,b}) into elements [1..0] of v16 + __ vmerge_vvm(v16, v16, v26); // v16 = {d,c,b,a} + + // Save the hash + __ vse32_v(v17, state); + __ addi(state, state, -16); + __ vse32_v(v16, state); __ leave(); __ ret(); @@ -4022,240 +4198,397 @@ class StubGenerator: public StubCodeGenerator { Register state = c_rarg1; Register ofs = c_rarg2; Register limit = c_rarg3; + Register consts = t0; Label multi_block_loop; __ enter(); - __ vsetivli(x0, 4, Assembler::e64, Assembler::m1, Assembler::ma, Assembler::ta); - __ vle64_v(v16, c_rarg1); - __ addi(c_rarg1, c_rarg1, 32); - __ vle64_v(v17, c_rarg1); - - __ bind(multi_block_loop); + // Register use in this function: + // + // VECTORS + // v10 - v13 (1024-bits / 4*256 bits / 4*4*64 bits), hold the message + // schedule words (Wt). They start with the message block + // content (W0 to W15), then further words in the message + // schedule generated via vsha2ms from previous Wt. + // Initially: + // v10 = W[ 3:0] = { W3, W2, W1, W0} + // v11 = W[ 7:4] = { W7, W6, W5, W4} + // v12 = W[ 11:8] = {W11, W10, W9, W8} + // v13 = W[15:12] = {W15, W14, W13, W12} + // + // v16 - v17 hold the working state variables (a, b, ..., h) + // v16 = {f[t],e[t],b[t],a[t]} + // v17 = {h[t],g[t],d[t],c[t]} + // Initially: + // v16 = {H5i-1, H4i-1, H1i-1 , H0i-1} + // v17 = {H7i-i, H6i-1, H3i-1 , H2i-1} + // + // v0 = masks for vrgather/vmerge. Single value during the 16 rounds. + // + // v14 = temporary, Wt+Kt + // v15 = temporary, Kt + // + // v18/v19 = temporaries, in the epilogue, to re-arrange + // and byte-swap v16/v17 + // + // v26/v27 = hold the initial values of the hash, byte-swapped. + // + // v30/v31 = used to generate masks, vrgather indices. + // + // During most of the function the vector state is configured so that each + // vector is interpreted as containing four 64 bits (e64) elements (256 bits). + // Set vectors as 4 * 64 + // + // e64: vector of 64b/8B elements + // m1: LMUL=1 + // ta: tail agnostic (don't care about those lanes) + // ma: mask agnostic (don't care about those lanes) + // x0 is not written, we known the number of vector elements, 2. __ vsetivli(x0, 4, Assembler::e64, Assembler::m1, Assembler::ma, Assembler::ta); - __ vle64_v(v20, c_rarg0); - __ add(c_rarg0, c_rarg0, 32); - __ vle64_v(v21, c_rarg0); - __ add(c_rarg0, c_rarg0, 32); - __ vle64_v(v22, c_rarg0); - __ add(c_rarg0, c_rarg0, 32); - __ vle64_v(v23, c_rarg0); - __ add(c_rarg0, c_rarg0, 32); - - __ li(t0, 32); - __ vsetvli(x0, t0, Assembler::e8, Assembler::m1, Assembler::ma, Assembler::ta); - __ vid_v(v24); - __ vxor_vi(v24, v24, 0x7); - __ vrgather_vv(v26, v16, v24); - __ vrgather_vv(v27, v17, v24); - __ vsetivli(x0, 4, Assembler::e64, Assembler::m1, Assembler::ma, Assembler::ta); - __ vid_v(v31); - __ vadd_vi(v30, v31, 2); - __ vmsltu_vi(v0, v31, 2); - __ vrgather_vv(v17, v26, v30, Assembler::v0_t); - __ vmerge_vvm(v17, v27, v17); - __ vadd_vi(v30, v31, -2); - __ vnot_v(v0, v0); - __ vrgather_vv(v16, v27, v30, Assembler::v0_t); - __ vmerge_vvm(v16, v26, v16); - - __ li(t0, 32); - __ vsetvli(x0, t0, Assembler::e8, Assembler::m1, Assembler::ma, Assembler::ta); - __ vid_v(v24); - __ vxor_vi(v24, v24, 0x7); - __ vrgather_vv(v10, v20, v24); - __ vrgather_vv(v11, v21, v24); - __ vrgather_vv(v12, v22, v24); - __ vrgather_vv(v13, v23, v24); + // Load H[0..8] to produce + // v16 = {a,b,e,f} + // v17 = {c,d,g,h} + __ vle64_v(v16, state); // v16 = {d,c,b,a} + __ addi(state, state, 32); + __ vle64_v(v17, state); // v17 = {h,g,f,e} + + __ vid_v(v30); // v30 = {3,2,1,0} + __ vxor_vi(v30, v30, 0x3); // v30 = {0,1,2,3} + __ vrgather_vv(v26, v16, v30); // v26 = {a,b,c,d} + __ vrgather_vv(v27, v17, v30); // v27 = {e,f,g,h} + __ vmsgeu_vi(v0, v30, 2); // v0 = {f,f,t,t} + // Copy elements [3..2] of v26 ({d,c}) into elements [3..2] of v17. + __ vslideup_vi(v17, v26, 2); // v17 = {c,d,_,_} + // Merge elements [1..0] of v27 ({g,h}) into elements [1..0] of v17 + __ vmerge_vvm(v17, v17, v27); // v17 = {c,d,g,h} + // Copy elements [1..0] of v27 ({f,e}) into elements [1..0] of v16. + __ vslidedown_vi(v16, v27, 2); // v16 = {_,_,e,f} + // Merge elements [3..2] of v26 ({a,b}) into elements [3..2] of v16 + __ vmerge_vvm(v16, v26, v16); // v16 = {a,b,e,f} - __ vsetivli(x0, 4, Assembler::e64, Assembler::m1, Assembler::ma, Assembler::ta); + __ bind(multi_block_loop); + // Capture the initial H values in v26 and v27 to allow for computing + // the resulting H', since H' = H+{a',b',c',...,h'}. + __ vmv_v_v(v26, v16); + __ vmv_v_v(v27, v17); + + // Load the 1024-bits of the message block in v10-v13 and perform + // an endian swap on each 8 bytes element. + // + // If Zvkb is not implemented, similar to SHA-256, one can use vrgather + // with an index sequence to byte-swap. + // sequence = [3 2 1 0 7 6 5 4 11 10 9 8 15 14 13 12] + // gives us "N ^ 3" as a nice formula to generate + // this sequence. 'vid' gives us the N. + __ vle64_v(v10, buf); + __ vrev8_v(v10, v10); + __ add(buf, buf, 32); + __ vle64_v(v11, buf); + __ vrev8_v(v11, v11); + __ add(buf, buf, 32); + __ vle64_v(v12, buf); + __ vrev8_v(v12, v12); + __ add(buf, buf, 32); + __ vle64_v(v13, buf); + __ vrev8_v(v13, v13); + + // Set v0 up for the vmerge that replaces the first word (idx==0) __ vid_v(v0); - __ vmseq_vi(v0, v0, 0x0); + __ vmseq_vi(v0, v0, 0x0); // v0.mask[i] = (i == 0 ? 1 : 0) - __ la(t0, ExternalAddress((address)round_consts)); + __ la(consts, ExternalAddress((address)round_consts)); - __ vl1re64_v(v15, t0); - __ addi(t0, t0, 32); + // Overview of the logic in each "quad round". + // + // The code below repeats 20 times the logic implementing four rounds + // of the SHA-512 core loop as documented by NIST. 20 "quad rounds" + // to implementing the 80 single rounds. + // + // // Load four word (u64) constants (K[t+3], K[t+2], K[t+1], K[t+0]) + // // Output: + // // v15 = {K[t+3], K[t+2], K[t+1], K[t+0]} + // vl1re32.v v15, (a2) + // + // // Increment word contant address by stride (32 bytes, 4*8B, 256b) + // addi consts, consts, 32 + // + // // Add constants to message schedule words: + // // Input + // // v15 = {K[t+3], K[t+2], K[t+1], K[t+0]} + // // v10 = {W[t+3], W[t+2], W[t+1], W[t+0]}; // Vt0 = W[3:0]; + // // Output + // // v14 = {W[t+3]+K[t+3], W[t+2]+K[t+2], W[t+1]+K[t+1], W[t+0]+K[t+0]} + // vadd.vv v14, v15, v10 + // + // // 2 rounds of working variables updates. + // // v17[t+4] <- v17[t], v16[t], v14[t] + // // Input: + // // v17 = {c[t],d[t],g[t],h[t]} " = v17[t] " + // // v16 = {a[t],b[t],e[t],f[t]} + // // v14 = {W[t+3]+K[t+3], W[t+2]+K[t+2], W[t+1]+K[t+1], W[t+0]+K[t+0]} + // // Output: + // // v17 = {f[t+2],e[t+2],b[t+2],a[t+2]} " = v16[t+2] " + // // = {h[t+4],g[t+4],d[t+4],c[t+4]} " = v17[t+4] " + // vsha2cl.vv v17, v16, v14 + // + // // 2 rounds of working variables updates. + // // v16[t+4] <- v16[t], v16[t+2], v14[t] + // // Input + // // v16 = {a[t],b[t],e[t],f[t]} " = v16[t] " + // // = {h[t+2],g[t+2],d[t+2],c[t+2]} " = v17[t+2] " + // // v17 = {f[t+2],e[t+2],b[t+2],a[t+2]} " = v16[t+2] " + // // v14 = {W[t+3]+K[t+3], W[t+2]+K[t+2], W[t+1]+K[t+1], W[t+0]+K[t+0]} + // // Output: + // // v16 = {f[t+4],e[t+4],b[t+4],a[t+4]} " = v16[t+4] " + // vsha2ch.vv v16, v17, v14 + // + // // Combine 2QW into 1QW + // // + // // To generate the next 4 words, "new_v10"/"v14" from v10-v13, vsha2ms needs + // // v10[0..3], v11[0], v12[1..3], v13[0, 2..3] + // // and it can only take 3 vectors as inputs. Hence we need to combine + // // v11[0] and v12[1..3] in a single vector. + // // + // // vmerge Vt4, Vt1, Vt2, V0 + // // Input + // // V0 = mask // first word from v12, 1..3 words from v11 + // // V12 = {Wt-8, Wt-7, Wt-6, Wt-5} + // // V11 = {Wt-12, Wt-11, Wt-10, Wt-9} + // // Output + // // Vt4 = {Wt-12, Wt-7, Wt-6, Wt-5} + // vmerge.vvm v14, v12, v11, v0 + // + // // Generate next Four Message Schedule Words (hence allowing for 4 more rounds) + // // Input + // // V10 = {W[t+ 3], W[t+ 2], W[t+ 1], W[t+ 0]} W[ 3: 0] + // // V13 = {W[t+15], W[t+14], W[t+13], W[t+12]} W[15:12] + // // V14 = {W[t+11], W[t+10], W[t+ 9], W[t+ 4]} W[11: 9,4] + // // Output (next four message schedule words) + // // v10 = {W[t+19], W[t+18], W[t+17], W[t+16]} W[19:16] + // vsha2ms.vv v10, v14, v13 + // + // BEFORE + // v10 - v13 hold the message schedule words (initially the block words) + // v10 = W[ 3: 0] "oldest" + // v11 = W[ 7: 4] + // v12 = W[11: 8] + // v13 = W[15:12] "newest" + // + // vt6 - vt7 hold the working state variables + // v16 = {a[t],b[t],e[t],f[t]} // initially {H5,H4,H1,H0} + // v17 = {c[t],d[t],g[t],h[t]} // initially {H7,H6,H3,H2} + // + // AFTER + // v10 - v13 hold the message schedule words (initially the block words) + // v11 = W[ 7: 4] "oldest" + // v12 = W[11: 8] + // v13 = W[15:12] + // v10 = W[19:16] "newest" + // + // v16 and v17 hold the working state variables + // v16 = {a[t+4],b[t+4],e[t+4],f[t+4]} + // v17 = {c[t+4],d[t+4],g[t+4],h[t+4]} + // + // The group of vectors v10,v11,v12,v13 is "rotated" by one in each quad-round, + // hence the uses of those vectors rotate in each round, and we get back to the + // initial configuration every 4 quad-rounds. We could avoid those changes at + // the cost of moving those vectors at the end of each quad-rounds. + + //-------------------------------------------------------------------------------- + // Quad-round 0 (+0, v10->v11->v12->v13) + __ vl1re64_v(v15, consts); + __ addi(consts, consts, 32); __ vadd_vv(v14, v15, v10); __ vsha2cl_vv(v17, v16, v14); __ vsha2ch_vv(v16, v17, v14); __ vmerge_vvm(v14, v12, v11); __ vsha2ms_vv(v10, v14, v13); - - __ vl1re64_v(v15, t0); - __ addi(t0, t0, 32); + //-------------------------------------------------------------------------------- + // Quad-round 1 (+1, v11->v12->v13->v10) + __ vl1re64_v(v15, consts); + __ addi(consts, consts, 32); __ vadd_vv(v14, v15, v11); __ vsha2cl_vv(v17, v16, v14); __ vsha2ch_vv(v16, v17, v14); __ vmerge_vvm(v14, v13, v12); __ vsha2ms_vv(v11, v14, v10); - - __ vl1re64_v(v15, t0); - __ addi(t0, t0, 32); + //-------------------------------------------------------------------------------- + // Quad-round 2 (+2, v12->v13->v10->v11) + __ vl1re64_v(v15, consts); + __ addi(consts, consts, 32); __ vadd_vv(v14, v15, v12); __ vsha2cl_vv(v17, v16, v14); __ vsha2ch_vv(v16, v17, v14); __ vmerge_vvm(v14, v10, v13); __ vsha2ms_vv(v12, v14, v11); - - __ vl1re64_v(v15, t0); - __ addi(t0, t0, 32); + //-------------------------------------------------------------------------------- + // Quad-round 3 (+3, v13->v10->v11->v12) + __ vl1re64_v(v15, consts); + __ addi(consts, consts, 32); __ vadd_vv(v14, v15, v13); __ vsha2cl_vv(v17, v16, v14); __ vsha2ch_vv(v16, v17, v14); __ vmerge_vvm(v14, v11, v10); __ vsha2ms_vv(v13, v14, v12); - __ vl1re64_v(v15, t0); - __ addi(t0, t0, 32); + //-------------------------------------------------------------------------------- + // Quad-round 4 (+0, v10->v11->v12->v13) + __ vl1re64_v(v15, consts); + __ addi(consts, consts, 32); __ vadd_vv(v14, v15, v10); __ vsha2cl_vv(v17, v16, v14); __ vsha2ch_vv(v16, v17, v14); __ vmerge_vvm(v14, v12, v11); __ vsha2ms_vv(v10, v14, v13); - - __ vl1re64_v(v15, t0); - __ addi(t0, t0, 32); + //-------------------------------------------------------------------------------- + // Quad-round 5 (+1, v11->v12->v13->v10) + __ vl1re64_v(v15, consts); + __ addi(consts, consts, 32); __ vadd_vv(v14, v15, v11); __ vsha2cl_vv(v17, v16, v14); __ vsha2ch_vv(v16, v17, v14); __ vmerge_vvm(v14, v13, v12); __ vsha2ms_vv(v11, v14, v10); - - __ vl1re64_v(v15, t0); - __ addi(t0, t0, 32); + //-------------------------------------------------------------------------------- + // Quad-round 6 (+2, v12->v13->v10->v11) + __ vl1re64_v(v15, consts); + __ addi(consts, consts, 32); __ vadd_vv(v14, v15, v12); __ vsha2cl_vv(v17, v16, v14); __ vsha2ch_vv(v16, v17, v14); __ vmerge_vvm(v14, v10, v13); __ vsha2ms_vv(v12, v14, v11); - - __ vl1re64_v(v15, t0); - __ addi(t0, t0, 32); + //-------------------------------------------------------------------------------- + // Quad-round 7 (+3, v13->v10->v11->v12) + __ vl1re64_v(v15, consts); + __ addi(consts, consts, 32); __ vadd_vv(v14, v15, v13); __ vsha2cl_vv(v17, v16, v14); __ vsha2ch_vv(v16, v17, v14); __ vmerge_vvm(v14, v11, v10); __ vsha2ms_vv(v13, v14, v12); - __ vl1re64_v(v15, t0); - __ addi(t0, t0, 32); + //-------------------------------------------------------------------------------- + // Quad-round 8 (+0, v10->v11->v12->v13) + __ vl1re64_v(v15, consts); + __ addi(consts, consts, 32); __ vadd_vv(v14, v15, v10); __ vsha2cl_vv(v17, v16, v14); __ vsha2ch_vv(v16, v17, v14); __ vmerge_vvm(v14, v12, v11); __ vsha2ms_vv(v10, v14, v13); - - __ vl1re64_v(v15, t0); - __ addi(t0, t0, 32); + //-------------------------------------------------------------------------------- + // Quad-round 9 (+1, v11->v12->v13->v10) + __ vl1re64_v(v15, consts); + __ addi(consts, consts, 32); __ vadd_vv(v14, v15, v11); __ vsha2cl_vv(v17, v16, v14); __ vsha2ch_vv(v16, v17, v14); __ vmerge_vvm(v14, v13, v12); __ vsha2ms_vv(v11, v14, v10); - - __ vl1re64_v(v15, t0); - __ addi(t0, t0, 32); + //-------------------------------------------------------------------------------- + // Quad-round 10 (+2, v12->v13->v10->v11) + __ vl1re64_v(v15, consts); + __ addi(consts, consts, 32); __ vadd_vv(v14, v15, v12); __ vsha2cl_vv(v17, v16, v14); __ vsha2ch_vv(v16, v17, v14); __ vmerge_vvm(v14, v10, v13); __ vsha2ms_vv(v12, v14, v11); - - __ vl1re64_v(v15, t0); - __ addi(t0, t0, 32); + //-------------------------------------------------------------------------------- + // Quad-round 11 (+3, v13->v10->v11->v12) + __ vl1re64_v(v15, consts); + __ addi(consts, consts, 32); __ vadd_vv(v14, v15, v13); __ vsha2cl_vv(v17, v16, v14); __ vsha2ch_vv(v16, v17, v14); __ vmerge_vvm(v14, v11, v10); __ vsha2ms_vv(v13, v14, v12); - __ vl1re64_v(v15, t0); - __ addi(t0, t0, 32); + //-------------------------------------------------------------------------------- + // Quad-round 12 (+0, v10->v11->v12->v13) + __ vl1re64_v(v15, consts); + __ addi(consts, consts, 32); __ vadd_vv(v14, v15, v10); __ vsha2cl_vv(v17, v16, v14); __ vsha2ch_vv(v16, v17, v14); __ vmerge_vvm(v14, v12, v11); __ vsha2ms_vv(v10, v14, v13); - - __ vl1re64_v(v15, t0); - __ addi(t0, t0, 32); + //-------------------------------------------------------------------------------- + // Quad-round 13 (+1, v11->v12->v13->v10) + __ vl1re64_v(v15, consts); + __ addi(consts, consts, 32); __ vadd_vv(v14, v15, v11); __ vsha2cl_vv(v17, v16, v14); __ vsha2ch_vv(v16, v17, v14); __ vmerge_vvm(v14, v13, v12); __ vsha2ms_vv(v11, v14, v10); - - __ vl1re64_v(v15, t0); - __ addi(t0, t0, 32); + //-------------------------------------------------------------------------------- + // Quad-round 14 (+2, v12->v13->v10->v11) + __ vl1re64_v(v15, consts); + __ addi(consts, consts, 32); __ vadd_vv(v14, v15, v12); __ vsha2cl_vv(v17, v16, v14); __ vsha2ch_vv(v16, v17, v14); __ vmerge_vvm(v14, v10, v13); __ vsha2ms_vv(v12, v14, v11); - - __ vl1re64_v(v15, t0); - __ addi(t0, t0, 32); + //-------------------------------------------------------------------------------- + // Quad-round 15 (+3, v13->v10->v11->v12) + __ vl1re64_v(v15, consts); + __ addi(consts, consts, 32); __ vadd_vv(v14, v15, v13); __ vsha2cl_vv(v17, v16, v14); __ vsha2ch_vv(v16, v17, v14); __ vmerge_vvm(v14, v11, v10); __ vsha2ms_vv(v13, v14, v12); - __ vl1re64_v(v15, t0); - __ addi(t0, t0, 32); + //-------------------------------------------------------------------------------- + // Quad-round 16 (+0, v10->v11->v12->v13) + // Note that we stop generating new message schedule words (Wt, v10-13) + // as we already generated all the words we end up consuming (i.e., W[79:76]). + __ vl1re64_v(v15, consts); + __ addi(consts, consts, 32); __ vadd_vv(v14, v15, v10); __ vsha2cl_vv(v17, v16, v14); __ vsha2ch_vv(v16, v17, v14); __ vmerge_vvm(v14, v12, v11); - __ vsha2ms_vv(v10, v14, v13); - - __ vl1re64_v(v15, t0); - __ addi(t0, t0, 32); + //-------------------------------------------------------------------------------- + // Quad-round 17 (+1, v11->v12->v13->v10) + __ vl1re64_v(v15, consts); + __ addi(consts, consts, 32); __ vadd_vv(v14, v15, v11); __ vsha2cl_vv(v17, v16, v14); __ vsha2ch_vv(v16, v17, v14); __ vmerge_vvm(v14, v13, v12); - __ vsha2ms_vv(v11, v14, v10); - - __ vl1re64_v(v15, t0); - __ addi(t0, t0, 32); + //-------------------------------------------------------------------------------- + // Quad-round 18 (+2, v12->v13->v10->v11) + __ vl1re64_v(v15, consts); + __ addi(consts, consts, 32); __ vadd_vv(v14, v15, v12); __ vsha2cl_vv(v17, v16, v14); __ vsha2ch_vv(v16, v17, v14); __ vmerge_vvm(v14, v10, v13); - __ vsha2ms_vv(v12, v14, v11); - - __ vl1re64_v(v15, t0); - __ addi(t0, t0, 32); + //-------------------------------------------------------------------------------- + // Quad-round 19 (+3, v13->v10->v11->v12) + __ vl1re64_v(v15, consts); + // No consts increment needed. __ vadd_vv(v14, v15, v13); __ vsha2cl_vv(v17, v16, v14); __ vsha2ch_vv(v16, v17, v14); - __ vid_v(v31); + //-------------------------------------------------------------------------------- + // Compute the updated hash value H' + // H' = H + {h',g',...,b',a'} + // = {h,g,...,b,a} + {h',g',...,b',a'} + // = {h+h',g+g',...,b+b',a+a'} - __ vadd_vi(v30, v31, 2); - __ vmsltu_vi(v0, v31, 2); - __ vrgather_vv(v19, v16, v30, Assembler::v0_t); - __ vmerge_vvm(v19, v17, v19); - __ vadd_vi(v30, v31, -2); - __ vnot_v(v0, v0); - __ vrgather_vv(v18, v17, v30, Assembler::v0_t); - __ vmerge_vvm(v18, v16, v18); - - __ vadd_vv(v18, v26, v18); - __ vadd_vv(v19, v27, v19); - - __ li(t0, 32); - __ vsetvli(x0, t0, Assembler::e8, Assembler::m1, Assembler::ma, Assembler::ta); - __ vid_v(v24); - __ vxor_vi(v24, v24, 0x7); - __ vrgather_vv(v16, v18, v24); - __ vrgather_vv(v17, v19, v24); + // H' = H+{a',b',c',...,h'} + __ vadd_vv(v16, v26, v16); + __ vadd_vv(v17, v27, v17); if (multi_block) { __ add(ofs, ofs, 128); @@ -4263,10 +4596,27 @@ class StubGenerator: public StubCodeGenerator { __ mv(c_rarg0, ofs); // return ofs } - __ vsetivli(x0, 4, Assembler::e64, Assembler::m1, Assembler::ma, Assembler::ta); - __ vse64_v(v17, c_rarg1); - __ addi(c_rarg1, c_rarg1, -32); - __ vse64_v(v16, c_rarg1); + // Store H[0..8] = {a,b,c,d,e,f,g,h} from + // v16 = {f,e,b,a} + // v17 = {h,g,d,c} + __ vid_v(v30); // v30 = {3,2,1,0} + __ vxor_vi(v30, v30, 0x3); // v30 = {0,1,2,3} + __ vrgather_vv(v26, v16, v30); // v26 = {f,e,b,a} + __ vrgather_vv(v27, v17, v30); // v27 = {h,g,d,c} + __ vmsgeu_vi(v0, v30, 2); // v0 = {f,f,t,t} + // Copy elements [3..2] of v26 ({f,e}) into elements [1..0] of v17. + __ vslidedown_vi(v17, v26, 2); // v17 = {_,_,f,e} + // Merge elements [3..2] of v27 ({g,h}) into elements [3..2] of v17 + __ vmerge_vvm(v17, v27, v17); // v17 = {h,g,f,e} + // Copy elements [1..0] of v27 ({c,d}) into elements [3..2] of v16. + __ vslideup_vi(v16, v27, 2); // v16 = {d,c,_,_} + // Merge elements [1..0] of v26 ({a,b}) into elements [1..0] of v16 + __ vmerge_vvm(v16, v16, v26); // v16 = {d,c,b,a} + + // Save the hash + __ vse64_v(v17, state); + __ addi(state, state, -32); + __ vse64_v(v16, state); __ leave(); __ ret(); diff --git a/src/hotspot/cpu/riscv/vm_version_riscv.cpp b/src/hotspot/cpu/riscv/vm_version_riscv.cpp index aa30b81678dfb..a65665b06e883 100644 --- a/src/hotspot/cpu/riscv/vm_version_riscv.cpp +++ b/src/hotspot/cpu/riscv/vm_version_riscv.cpp @@ -126,7 +126,7 @@ void VM_Version::initialize() { FLAG_SET_DEFAULT(UseSHA1Intrinsics, false); } - if (UseZvknha) { + if (UseZvknha && UseZvkb) { if (FLAG_IS_DEFAULT(UseSHA256Intrinsics)) { FLAG_SET_DEFAULT(UseSHA256Intrinsics, true); } @@ -135,7 +135,7 @@ void VM_Version::initialize() { FLAG_SET_DEFAULT(UseSHA256Intrinsics, false); } - if (UseZvknhb) { + if (UseZvknhb && UseZvkb) { if (FLAG_IS_DEFAULT(UseSHA512Intrinsics)) { FLAG_SET_DEFAULT(UseSHA512Intrinsics, true); } From 455accd08c378039c1d1023c121b228f0949fb04 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Mon, 30 Jan 2023 06:04:42 -0800 Subject: [PATCH 46/85] Statically link libatomic (#70) This is to remove the run-time dependency on libatomic which isn't installed by default on Ubuntu or busybox distributions --- make/autoconf/libraries.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/make/autoconf/libraries.m4 b/make/autoconf/libraries.m4 index e057626b676d1..162a56fb78dcb 100644 --- a/make/autoconf/libraries.m4 +++ b/make/autoconf/libraries.m4 @@ -112,7 +112,7 @@ AC_DEFUN([LIB_SETUP_JVM_LIBS], # Because RISC-V only has word-sized atomics, it requires libatomic where # other common architectures do not, so link libatomic by default. if test "x$OPENJDK_$1_OS" = xlinux && test "x$OPENJDK_$1_CPU" = xriscv64; then - BASIC_JVM_LIBS_$1="$BASIC_JVM_LIBS_$1 -latomic" + BASIC_JVM_LIBS_$1="$BASIC_JVM_LIBS_$1 -l:libatomic.a" fi ]) From 3511f4966d0f0559be4e3a292a2624ee1027cc9d Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Mon, 27 Feb 2023 11:26:11 +0000 Subject: [PATCH 47/85] Remove dependency on sysroot for amd64 --- configure-amd64.sh | 2 +- configure-riscv64.sh | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/configure-amd64.sh b/configure-amd64.sh index 6948d59b29d78..60d471b3310e1 100755 --- a/configure-amd64.sh +++ b/configure-amd64.sh @@ -11,4 +11,4 @@ ARGS=( --with-hsdis=binutils --with-binutils-src=/workspace/binutils --enable-hsdis-bundling ) -/sysroot/run-in.sh /sysroot/$DIST-amd64 bash configure ${ARGS[@]} $* +bash configure ${ARGS[@]} $* diff --git a/configure-riscv64.sh b/configure-riscv64.sh index 75f41ae1dc105..0d663b334e579 100755 --- a/configure-riscv64.sh +++ b/configure-riscv64.sh @@ -1,17 +1,15 @@ #!/bin/bash -DIST=${DIST:-focal} - ARGS=( --openjdk-target=riscv64-linux-gnu --with-boot-jdk=/rivos/jdk - --with-build-jdk=/workspace/jdk/build/linux-x86_64-server-release/images/jdk + --with-build-jdk=/rivos/jdk # --with-debug-level=slowdebug --with-zlib=system - --with-sysroot=/sysroot/$DIST-riscv64 + --with-sysroot=/sysroot/focal-riscv64 --with-jmh=/workspace/jmh/build/images/jmh --with-jtreg=/workspace/jtreg/build/images/jtreg --with-hsdis=binutils --with-binutils-src=/workspace/binutils --enable-hsdis-bundling ) -/sysroot/run-in.sh /sysroot/$DIST-amd64 bash configure ${ARGS[@]} $* +bash configure ${ARGS[@]} $* From 8518bb485efa8f2c4b978e5b85d12e13fdf4b6eb Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Mon, 27 Feb 2023 11:27:32 +0000 Subject: [PATCH 48/85] Move configure-amd64 and configure-riscv64 to rivos/ This is to keep rivos-specific files in rivos/ --- configure-amd64.sh => rivos/configure-amd64.sh | 0 configure-riscv64.sh => rivos/configure-riscv64.sh | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename configure-amd64.sh => rivos/configure-amd64.sh (100%) rename configure-riscv64.sh => rivos/configure-riscv64.sh (100%) diff --git a/configure-amd64.sh b/rivos/configure-amd64.sh similarity index 100% rename from configure-amd64.sh rename to rivos/configure-amd64.sh diff --git a/configure-riscv64.sh b/rivos/configure-riscv64.sh similarity index 100% rename from configure-riscv64.sh rename to rivos/configure-riscv64.sh From cccaaeb3ee94e28039479d6f81bdb8235f25ca7e Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Mon, 27 Feb 2023 11:32:21 +0000 Subject: [PATCH 49/85] Add some documentation to setup Qemu user-space emulation --- rivos/README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 rivos/README.md diff --git a/rivos/README.md b/rivos/README.md new file mode 100644 index 0000000000000..747520f865bc6 --- /dev/null +++ b/rivos/README.md @@ -0,0 +1,16 @@ +# Setup + +## QEMU + +You most likely want to setup QEMU user-space emulation at the OS level to transparently execute RISC-V binaries on an x86-64 host. + +To do so, first install `rivos-sdk-qemu`: +``` +sudo apt-get update +sudo apt-get install -y rivos-sdk-qemu +``` + +Then, setup binfmt_mist with: +``` +docker run --privileged --rm -v /rivos:/rivos -e QEMU_BINARY_PATH=/rivos/qemu/bin tonistiigi/binfmt --install riscv64 +``` From 3eccffade9c4577a4bff8ef551f38e05621c9120 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Wed, 15 Mar 2023 16:51:19 +0100 Subject: [PATCH 50/85] Remove special tag for gitlab docker container (#78) --- rivos/gitlab-ci.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/rivos/gitlab-ci.yml b/rivos/gitlab-ci.yml index 6ff318bc47483..f225e1c016daa 100644 --- a/rivos/gitlab-ci.yml +++ b/rivos/gitlab-ci.yml @@ -29,8 +29,6 @@ prepare-version: .create-sysroot: stage: prebuild image: ubuntu:20.04 - tags: - - docker-qemu-binfmt cache: - when: on_success key: sysroot-${UBUNTU_CODENAME}-${PKG_ARCH}-${CACHE_VERSION} From 55eb6dcdc22586c2b38067d5e94f91b76f7919b7 Mon Sep 17 00:00:00 2001 From: Tony P <131884705+gctony@users.noreply.github.com> Date: Fri, 5 May 2023 10:13:22 -0400 Subject: [PATCH 51/85] SW-3069: Add hsdis to the JDK ci build (#87) Co-authored-by: Ludovic Henry --- rivos/gitlab-ci.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/rivos/gitlab-ci.yml b/rivos/gitlab-ci.yml index f225e1c016daa..cdd943bc459d8 100644 --- a/rivos/gitlab-ci.yml +++ b/rivos/gitlab-ci.yml @@ -7,6 +7,7 @@ include: variables: CACHE_VERSION: "v6" BUILD_JDK_VERSION: 20 + BINUTILS_DIR: binutils-2.38 prepare-version: after_script: @@ -95,6 +96,10 @@ create-sysroot-riscv64: mkdir -p /usr/lib/jvm/temurin-${BUILD_JDK_VERSION} curl -L https://api.adoptium.net/v3/binary/latest/${BUILD_JDK_VERSION}/ea/linux/x64/jdk/hotspot/normal/eclipse\?project\=jdk \ | tar -xzf - -C /usr/lib/jvm/temurin-${BUILD_JDK_VERSION} --strip-components 1 + - | + mkdir ${BINUTILS_DIR} + curl -L https://ftp.gnu.org/gnu/binutils/${BINUTILS_DIR}.tar.gz \ + | tar -xzf - -C ${BINUTILS_DIR} --strip-components 1 - | bash configure \ --openjdk-target=${PKG_ARCH}-linux-gnu \ @@ -103,9 +108,12 @@ create-sysroot-riscv64: --with-version-pre="${JDK_VERSION_PRE}" \ --with-version-opt="${JDK_VERSION_OPT}" \ --with-sysroot=$(pwd)/sysroot-${UBUNTU_CODENAME}-${PKG_ARCH} \ - --with-boot-jdk=/usr/lib/jvm/temurin-20 \ + --with-boot-jdk=/usr/lib/jvm/temurin-${BUILD_JDK_VERSION} \ --disable-precompiled-headers \ - --with-zlib=system + --with-zlib=system \ + --with-hsdis=binutils \ + --with-binutils-src=${BINUTILS_DIR} \ + --enable-hsdis-bundling - make ${MAKE_TARGETS} LOG_LEVEL=info artifacts: when: always From 1920d858a455dd974f4fb368dfa79ba4ab914973 Mon Sep 17 00:00:00 2001 From: Tony Printezis Date: Fri, 5 May 2023 11:52:49 -0700 Subject: [PATCH 52/85] SW-3326: build error on riscv after jdk-21+21 merge --- src/hotspot/cpu/riscv/assembler_riscv.hpp | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/hotspot/cpu/riscv/assembler_riscv.hpp b/src/hotspot/cpu/riscv/assembler_riscv.hpp index 474a6b1d730b3..5d75cf4e5609c 100644 --- a/src/hotspot/cpu/riscv/assembler_riscv.hpp +++ b/src/hotspot/cpu/riscv/assembler_riscv.hpp @@ -1607,16 +1607,6 @@ enum VectorMask { #undef INSN -#define INSN(NAME, op, funct3, vm, funct6) \ - void NAME(VectorRegister Vd, VectorRegister Vs2, VectorRegister Vs1) { \ - patch_VArith(op, Vd, funct3, Vs1->raw_encoding(), Vs2, vm, funct6); \ - } - - // Vector Integer Merge Instructions - INSN(vmerge_vvm, 0b1010111, 0b000, 0b0, 0b010111); - -#undef INSN - #define INSN(NAME, op, funct3, Vs2, vm, funct6) \ void NAME(VectorRegister Vd, int32_t imm) { \ guarantee(is_simm5(imm), "imm is invalid"); \ From 1717fc927b93bc0ad3c6d1adf87b63fa62cabfdd Mon Sep 17 00:00:00 2001 From: Tony P <131884705+gctony@users.noreply.github.com> Date: Tue, 9 May 2023 03:50:52 -0400 Subject: [PATCH 53/85] SW-3147: Do fastdebug builds on ci (#90) --- rivos/gitlab-ci.yml | 79 +++++++++++++++++++++++++++++++-------------- 1 file changed, 54 insertions(+), 25 deletions(-) diff --git a/rivos/gitlab-ci.yml b/rivos/gitlab-ci.yml index cdd943bc459d8..cf4c49965a442 100644 --- a/rivos/gitlab-ci.yml +++ b/rivos/gitlab-ci.yml @@ -102,8 +102,9 @@ create-sysroot-riscv64: | tar -xzf - -C ${BINUTILS_DIR} --strip-components 1 - | bash configure \ + --with-debug-level=${DEBUG_LEVEL} \ --openjdk-target=${PKG_ARCH}-linux-gnu \ - --with-conf-name=linux-${PKG_ARCH} \ + --with-conf-name=linux-${PKG_ARCH}-${DEBUG_LEVEL} \ --with-vendor-name="Rivos Inc" \ --with-version-pre="${JDK_VERSION_PRE}" \ --with-version-opt="${JDK_VERSION_OPT}" \ @@ -119,10 +120,36 @@ create-sysroot-riscv64: when: always paths: - config.log # in case of error during configure - - build/linux-${PKG_ARCH}/images/jdk - - build/linux-${PKG_ARCH}/images/test + - build/linux-${PKG_ARCH}-${DEBUG_LEVEL}/images/jdk + - build/linux-${PKG_ARCH}-${DEBUG_LEVEL}/images/test -build-linux-amd64: +build-linux-amd64-fastdebug: + extends: .build-linux + dependencies: + - prepare-version + - create-sysroot-amd64 + needs: + - prepare-version + - create-sysroot-amd64 + variables: + PKG_ARCH: amd64 + MAKE_TARGETS: jdk-image test-image + DEBUG_LEVEL: fastdebug + +build-linux-riscv64-fastdebug: + extends: .build-linux + dependencies: + - prepare-version + - create-sysroot-riscv64 + needs: + - prepare-version + - create-sysroot-riscv64 + variables: + PKG_ARCH: riscv64 + MAKE_TARGETS: jdk-image test-image + DEBUG_LEVEL: fastdebug + +build-linux-amd64-release: extends: .build-linux dependencies: - prepare-version @@ -133,8 +160,9 @@ build-linux-amd64: variables: PKG_ARCH: amd64 MAKE_TARGETS: jdk-image + DEBUG_LEVEL: release -build-linux-riscv64: +build-linux-riscv64-release: extends: .build-linux dependencies: - prepare-version @@ -145,24 +173,25 @@ build-linux-riscv64: variables: PKG_ARCH: riscv64 MAKE_TARGETS: jdk-image test-image + DEBUG_LEVEL: release package-tar: stage: deploy image: ubuntu:20.04 dependencies: - prepare-version - - build-linux-amd64 - - build-linux-riscv64 + - build-linux-amd64-release + - build-linux-riscv64-release needs: - prepare-version - - build-linux-amd64 - - build-linux-riscv64 + - build-linux-amd64-release + - build-linux-riscv64-release script: - apt-get update - apt-get install -y curl - - tar -czf jdk-${JDK_VERSION_TAG}-linux-amd64.tar.gz -C build/linux-amd64/images jdk + - tar -czf jdk-${JDK_VERSION_TAG}-linux-amd64.tar.gz -C build/linux-amd64-release/images jdk - 'curl -i --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file jdk-${JDK_VERSION_TAG}-linux-amd64.tar.gz "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/jdk/${JDK_VERSION_TAG}/jdk-${JDK_VERSION_TAG}-linux-amd64.tar.gz"' - - tar -czf jdk-${JDK_VERSION_TAG}-linux-riscv64.tar.gz -C build/linux-riscv64/images jdk + - tar -czf jdk-${JDK_VERSION_TAG}-linux-riscv64.tar.gz -C build/linux-riscv64-release/images jdk - 'curl -i --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file jdk-${JDK_VERSION_TAG}-linux-riscv64.tar.gz "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/jdk/${JDK_VERSION_TAG}/jdk-${JDK_VERSION_TAG}-linux-riscv64.tar.gz"' .package-deb: @@ -179,11 +208,11 @@ package-tar: - rm -rf $(echo "${PKG_DIRECTORIES}" | tr ';' ' ') # move the previous temporary install - | - cp -av build/linux-${PKG_ARCH}/images/jdk /rivos/ + cp -av build/linux-${PKG_ARCH}-release/images/jdk /rivos/ if [ "${PKG_ARCH}" = "amd64" ]; then # put linux-riscv64 build in sysroot mkdir -p /rivos/sysroot/riscv/rivos - cp -av build/linux-riscv64/images/jdk /rivos/sysroot/riscv/rivos + cp -av build/linux-riscv64-release/images/jdk /rivos/sysroot/riscv/rivos fi - | if [ "${PKG_DBG}" = "true" ]; then @@ -198,12 +227,12 @@ package-deb-amd64: extends: .package-deb dependencies: - prepare-version - - build-linux-amd64 - - build-linux-riscv64 + - build-linux-amd64-release + - build-linux-riscv64-release needs: - prepare-version - - build-linux-amd64 - - build-linux-riscv64 + - build-linux-amd64-release + - build-linux-riscv64-release variables: PKG_DIRECTORIES: "/rivos/jdk;/rivos/sysroot/riscv/rivos/jdk" PKG_ARCH: "amd64" @@ -212,10 +241,10 @@ package-deb-riscv64: extends: .package-deb dependencies: - prepare-version - - build-linux-riscv64 + - build-linux-riscv64-release needs: - prepare-version - - build-linux-riscv64 + - build-linux-riscv64-release variables: PKG_DIRECTORIES: "/rivos/jdk" PKG_ARCH: "riscv64" @@ -224,12 +253,12 @@ package-deb-dbg-amd64: extends: .package-deb dependencies: - prepare-version - - build-linux-amd64 - - build-linux-riscv64 + - build-linux-amd64-release + - build-linux-riscv64-release needs: - prepare-version - - build-linux-amd64 - - build-linux-riscv64 + - build-linux-amd64-release + - build-linux-riscv64-release variables: PKG_NAME: "${PROJECT_NAME}-dbg" PKG_DIRECTORIES: "/rivos/jdk;/rivos/sysroot/riscv/rivos/jdk" @@ -240,10 +269,10 @@ package-deb-dbg-riscv64: extends: .package-deb dependencies: - prepare-version - - build-linux-riscv64 + - build-linux-riscv64-release needs: - prepare-version - - build-linux-riscv64 + - build-linux-riscv64-release variables: PKG_NAME: "${PROJECT_NAME}-dbg" PKG_DIRECTORIES: "/rivos/jdk" From 1ef1840d44f0f122c043f17ce8917c79a9f6a983 Mon Sep 17 00:00:00 2001 From: Tony Printezis Date: Wed, 10 May 2023 10:10:36 -0700 Subject: [PATCH 54/85] SW-3148: Run gtests on ci --- rivos/gitlab-ci.yml | 102 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 93 insertions(+), 9 deletions(-) diff --git a/rivos/gitlab-ci.yml b/rivos/gitlab-ci.yml index cf4c49965a442..f84d73c103b7e 100644 --- a/rivos/gitlab-ci.yml +++ b/rivos/gitlab-ci.yml @@ -8,6 +8,7 @@ variables: CACHE_VERSION: "v6" BUILD_JDK_VERSION: 20 BINUTILS_DIR: binutils-2.38 + GTEST_TAG: v1.13.0 prepare-version: after_script: @@ -77,6 +78,8 @@ create-sysroot-riscv64: .build-linux: stage: build image: ubuntu:20.04 + variables: + CONF_NAME: linux-${PKG_ARCH}-${DEBUG_LEVEL} script: - apt-get update - | @@ -87,6 +90,7 @@ create-sysroot-riscv64: file \ g++ \ gcc \ + git \ $(test "${PKG_ARCH}" = "riscv64" && echo "g++-riscv64-linux-gnu" || true) \ $(test "${PKG_ARCH}" = "riscv64" && echo "gcc-riscv64-linux-gnu" || true) \ unzip \ @@ -100,11 +104,12 @@ create-sysroot-riscv64: mkdir ${BINUTILS_DIR} curl -L https://ftp.gnu.org/gnu/binutils/${BINUTILS_DIR}.tar.gz \ | tar -xzf - -C ${BINUTILS_DIR} --strip-components 1 + - git clone https://github.com/google/googletest.git -b ${GTEST_TAG} googletest - | bash configure \ --with-debug-level=${DEBUG_LEVEL} \ --openjdk-target=${PKG_ARCH}-linux-gnu \ - --with-conf-name=linux-${PKG_ARCH}-${DEBUG_LEVEL} \ + --with-conf-name=${CONF_NAME} \ --with-vendor-name="Rivos Inc" \ --with-version-pre="${JDK_VERSION_PRE}" \ --with-version-opt="${JDK_VERSION_OPT}" \ @@ -112,16 +117,20 @@ create-sysroot-riscv64: --with-boot-jdk=/usr/lib/jvm/temurin-${BUILD_JDK_VERSION} \ --disable-precompiled-headers \ --with-zlib=system \ + --with-gtest=$(pwd)/googletest \ --with-hsdis=binutils \ --with-binutils-src=${BINUTILS_DIR} \ --enable-hsdis-bundling - - make ${MAKE_TARGETS} LOG_LEVEL=info + - make jdk-image test-image LOG_LEVEL=info artifacts: when: always paths: - - config.log # in case of error during configure - - build/linux-${PKG_ARCH}-${DEBUG_LEVEL}/images/jdk - - build/linux-${PKG_ARCH}-${DEBUG_LEVEL}/images/test + - build/${CONF_NAME}/*.log + - build/${CONF_NAME}/Makefile + - build/${CONF_NAME}/make-support + - build/${CONF_NAME}/*.gmk + - build/${CONF_NAME}/images/jdk + - build/${CONF_NAME}/images/test build-linux-amd64-fastdebug: extends: .build-linux @@ -133,7 +142,6 @@ build-linux-amd64-fastdebug: - create-sysroot-amd64 variables: PKG_ARCH: amd64 - MAKE_TARGETS: jdk-image test-image DEBUG_LEVEL: fastdebug build-linux-riscv64-fastdebug: @@ -146,7 +154,6 @@ build-linux-riscv64-fastdebug: - create-sysroot-riscv64 variables: PKG_ARCH: riscv64 - MAKE_TARGETS: jdk-image test-image DEBUG_LEVEL: fastdebug build-linux-amd64-release: @@ -159,7 +166,6 @@ build-linux-amd64-release: - create-sysroot-amd64 variables: PKG_ARCH: amd64 - MAKE_TARGETS: jdk-image DEBUG_LEVEL: release build-linux-riscv64-release: @@ -172,9 +178,87 @@ build-linux-riscv64-release: - create-sysroot-riscv64 variables: PKG_ARCH: riscv64 - MAKE_TARGETS: jdk-image test-image DEBUG_LEVEL: release +.run-gtests: + stage: test + # image set in jobs that extend this + variables: + CONF_NAME: linux-${PKG_ARCH}-${DEBUG_LEVEL} + script: + - apt-get update + - | + apt-get install -y \ + build-essential \ + curl \ + git + - | + mkdir -p /usr/lib/jvm/temurin-${BUILD_JDK_VERSION} + curl -L https://api.adoptium.net/v3/binary/latest/${BUILD_JDK_VERSION}/ea/linux/x64/jdk/hotspot/normal/eclipse\?project\=jdk \ + | tar -xzf - -C /usr/lib/jvm/temurin-${BUILD_JDK_VERSION} --strip-components 1 + - git clone https://github.com/google/googletest.git -b ${GTEST_TAG} googletest + - make test-prebuilt \ + CONF=${CONF_NAME} \ + BOOT_JDK=/usr/lib/jvm/temurin-${BUILD_JDK_VERSION} \ + JDK_IMAGE_DIR=$(pwd)/build/${CONF_NAME}/images/jdk \ + TEST_IMAGE_DIR=$(pwd)/build/${CONF_NAME}/images/test \ + JT_HOME=$(pwd)/googletest \ + TEST="gtest:all" + +run-gtests-amd64-fastdebug: + extends: .run-gtests + image: ubuntu:20.04 + dependencies: + - build-linux-amd64-fastdebug + - create-sysroot-amd64 + needs: + - build-linux-amd64-fastdebug + - create-sysroot-amd64 + variables: + PKG_ARCH: amd64 + DEBUG_LEVEL: fastdebug + +# the riscv64 gtests jobs are disabled until we figure out how to run them with a more recent qemu +# run-gtests-riscv64-fastdebug: +# extends: .run-gtests +# image: gitlab.ba.rivosinc.com:5050/rv/it/int/rivos-sdk:22.04-riscv64 +# dependencies: +# - build-linux-riscv64-fastdebug +# - create-sysroot-riscv64 +# needs: +# - build-linux-riscv64-fastdebug +# - create-sysroot-riscv64 +# variables: +# PKG_ARCH: riscv64 +# DEBUG_LEVEL: fastdebug + +run-gtests-amd64-release: + extends: .run-gtests + image: ubuntu:20.04 + dependencies: + - build-linux-amd64-release + - create-sysroot-amd64 + needs: + - build-linux-amd64-release + - create-sysroot-amd64 + variables: + PKG_ARCH: amd64 + DEBUG_LEVEL: release + +# the riscv64 gtests jobs are disabled until we figure out how to run them with a more recent qemu +# run-gtests-riscv64-release: +# extends: .run-gtests +# image: gitlab.ba.rivosinc.com:5050/rv/it/int/rivos-sdk:22.04-riscv64 +# dependencies: +# - build-linux-riscv64-release +# - create-sysroot-riscv64 +# needs: +# - build-linux-riscv64-release +# - create-sysroot-riscv64 +# variables: +# PKG_ARCH: riscv64 +# DEBUG_LEVEL: release + package-tar: stage: deploy image: ubuntu:20.04 From 65f90fa89b3cbddee1e3e13e6d456e0345d8bae9 Mon Sep 17 00:00:00 2001 From: Tony Printezis Date: Thu, 11 May 2023 06:46:13 -0700 Subject: [PATCH 55/85] Changes based on code review feedback. --- rivos/gitlab-ci.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/rivos/gitlab-ci.yml b/rivos/gitlab-ci.yml index f84d73c103b7e..7fa7025ad5084 100644 --- a/rivos/gitlab-ci.yml +++ b/rivos/gitlab-ci.yml @@ -125,6 +125,7 @@ create-sysroot-riscv64: artifacts: when: always paths: + - config.log # in case of error during configure - build/${CONF_NAME}/*.log - build/${CONF_NAME}/Makefile - build/${CONF_NAME}/make-support @@ -190,19 +191,20 @@ build-linux-riscv64-release: - | apt-get install -y \ build-essential \ - curl \ - git + curl - | mkdir -p /usr/lib/jvm/temurin-${BUILD_JDK_VERSION} curl -L https://api.adoptium.net/v3/binary/latest/${BUILD_JDK_VERSION}/ea/linux/x64/jdk/hotspot/normal/eclipse\?project\=jdk \ | tar -xzf - -C /usr/lib/jvm/temurin-${BUILD_JDK_VERSION} --strip-components 1 - - git clone https://github.com/google/googletest.git -b ${GTEST_TAG} googletest + # jtreg is not needed to run the gtests but make-prebuilt requires JT_HOME to point to a dir. + # We'll just point it to an empty dir, it's not worth checking out jtreg for this. + - mkdir $(pwd)/jtreg - make test-prebuilt \ CONF=${CONF_NAME} \ BOOT_JDK=/usr/lib/jvm/temurin-${BUILD_JDK_VERSION} \ JDK_IMAGE_DIR=$(pwd)/build/${CONF_NAME}/images/jdk \ TEST_IMAGE_DIR=$(pwd)/build/${CONF_NAME}/images/test \ - JT_HOME=$(pwd)/googletest \ + JT_HOME=$(pwd)/jtreg \ TEST="gtest:all" run-gtests-amd64-fastdebug: From 26592b0de8c173e3a12015c25a4293380048e59c Mon Sep 17 00:00:00 2001 From: Tony Printezis Date: Thu, 11 May 2023 07:02:43 -0700 Subject: [PATCH 56/85] dummy change to force the MR to get updated --- rivos/gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rivos/gitlab-ci.yml b/rivos/gitlab-ci.yml index 7fa7025ad5084..07e3c309e5c34 100644 --- a/rivos/gitlab-ci.yml +++ b/rivos/gitlab-ci.yml @@ -125,7 +125,7 @@ create-sysroot-riscv64: artifacts: when: always paths: - - config.log # in case of error during configure + - config.log # in case of error during configure - build/${CONF_NAME}/*.log - build/${CONF_NAME}/Makefile - build/${CONF_NAME}/make-support From da99f0fc7f1a74c40c512dc3f9e21f45663dbd0e Mon Sep 17 00:00:00 2001 From: Tony P <131884705+gctony@users.noreply.github.com> Date: Tue, 16 May 2023 10:53:05 -0400 Subject: [PATCH 57/85] SW-3453: Make PrintCodeCacheExtension a product option (#93) --- src/hotspot/share/runtime/globals.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hotspot/share/runtime/globals.hpp b/src/hotspot/share/runtime/globals.hpp index 51fb9292b0623..7801fedc192ee 100644 --- a/src/hotspot/share/runtime/globals.hpp +++ b/src/hotspot/share/runtime/globals.hpp @@ -669,7 +669,7 @@ const int ObjectAlignmentInBytes = 8; "Tell whether the VM should register soft/weak/final/phantom " \ "references") \ \ - develop(bool, PrintCodeCacheExtension, false, \ + product(bool, PrintCodeCacheExtension, false, \ "Print extension of code cache") \ \ develop(bool, UsePrivilegedStack, true, \ From f2751e24de0ed10e8bdd1ddfe1d420d9a443be38 Mon Sep 17 00:00:00 2001 From: Tony P <131884705+gctony@users.noreply.github.com> Date: Tue, 23 May 2023 09:24:40 -0400 Subject: [PATCH 58/85] SW-3506: Add vtable/itable index to the JVMTI code gen event (#95) --- src/hotspot/share/code/vtableStubs.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/hotspot/share/code/vtableStubs.cpp b/src/hotspot/share/code/vtableStubs.cpp index 42a8a63a38fc1..caa778cfa24d2 100644 --- a/src/hotspot/share/code/vtableStubs.cpp +++ b/src/hotspot/share/code/vtableStubs.cpp @@ -239,7 +239,10 @@ address VtableStubs::find_stub(bool is_vtable_stub, int vtable_index) { // all locks. Only post this event if a new state is not required. Creating a new state would // cause a safepoint and the caller of this code has a NoSafepointVerifier. if (JvmtiExport::should_post_dynamic_code_generated()) { - JvmtiExport::post_dynamic_code_generated_while_holding_locks(is_vtable_stub? "vtable stub": "itable stub", + char buffer[32]; + jio_snprintf(buffer, sizeof(buffer), "%s stub #%d", + is_vtable_stub ? "vtable" : "itable", vtable_index); + JvmtiExport::post_dynamic_code_generated_while_holding_locks(buffer, s->code_begin(), s->code_end()); } } From f91ca9b371a4a2b02251493a5b817ab4847a7829 Mon Sep 17 00:00:00 2001 From: Tony P <131884705+gctony@users.noreply.github.com> Date: Tue, 30 May 2023 15:03:22 -0400 Subject: [PATCH 59/85] SW-3385: Enable riscv64 gtest jobs on ci (#97) * SW-3385: Enable riscv64 gtest jobs on ci * changes based on code review feedback --- rivos/gitlab-ci.yml | 72 ++++++++++++++++++++++++--------------------- 1 file changed, 39 insertions(+), 33 deletions(-) diff --git a/rivos/gitlab-ci.yml b/rivos/gitlab-ci.yml index 07e3c309e5c34..c152234ec7b88 100644 --- a/rivos/gitlab-ci.yml +++ b/rivos/gitlab-ci.yml @@ -183,7 +183,7 @@ build-linux-riscv64-release: .run-gtests: stage: test - # image set in jobs that extend this + image: ubuntu:20.04 variables: CONF_NAME: linux-${PKG_ARCH}-${DEBUG_LEVEL} script: @@ -199,8 +199,10 @@ build-linux-riscv64-release: # jtreg is not needed to run the gtests but make-prebuilt requires JT_HOME to point to a dir. # We'll just point it to an empty dir, it's not worth checking out jtreg for this. - mkdir $(pwd)/jtreg + # QEMU_LD_PREFIX is only needed for risc v but it's easier to just set it for all configurations - make test-prebuilt \ CONF=${CONF_NAME} \ + QEMU_LD_PREFIX=$(pwd)/sysroot-${UBUNTU_CODENAME}-${PKG_ARCH} \ BOOT_JDK=/usr/lib/jvm/temurin-${BUILD_JDK_VERSION} \ JDK_IMAGE_DIR=$(pwd)/build/${CONF_NAME}/images/jdk \ TEST_IMAGE_DIR=$(pwd)/build/${CONF_NAME}/images/test \ @@ -209,57 +211,61 @@ build-linux-riscv64-release: run-gtests-amd64-fastdebug: extends: .run-gtests - image: ubuntu:20.04 dependencies: - - build-linux-amd64-fastdebug + - prepare-version - create-sysroot-amd64 - needs: - build-linux-amd64-fastdebug + needs: + - prepare-version - create-sysroot-amd64 + - build-linux-amd64-fastdebug variables: PKG_ARCH: amd64 DEBUG_LEVEL: fastdebug -# the riscv64 gtests jobs are disabled until we figure out how to run them with a more recent qemu -# run-gtests-riscv64-fastdebug: -# extends: .run-gtests -# image: gitlab.ba.rivosinc.com:5050/rv/it/int/rivos-sdk:22.04-riscv64 -# dependencies: -# - build-linux-riscv64-fastdebug -# - create-sysroot-riscv64 -# needs: -# - build-linux-riscv64-fastdebug -# - create-sysroot-riscv64 -# variables: -# PKG_ARCH: riscv64 -# DEBUG_LEVEL: fastdebug +run-gtests-riscv64-fastdebug: + extends: .run-gtests + tags: ["22.04"] + dependencies: + - prepare-version + - create-sysroot-riscv64 + - build-linux-riscv64-fastdebug + needs: + - prepare-version + - create-sysroot-riscv64 + - build-linux-riscv64-fastdebug + variables: + PKG_ARCH: riscv64 + DEBUG_LEVEL: fastdebug run-gtests-amd64-release: extends: .run-gtests - image: ubuntu:20.04 dependencies: - - build-linux-amd64-release + - prepare-version - create-sysroot-amd64 - needs: - build-linux-amd64-release + needs: + - prepare-version - create-sysroot-amd64 + - build-linux-amd64-release variables: PKG_ARCH: amd64 DEBUG_LEVEL: release -# the riscv64 gtests jobs are disabled until we figure out how to run them with a more recent qemu -# run-gtests-riscv64-release: -# extends: .run-gtests -# image: gitlab.ba.rivosinc.com:5050/rv/it/int/rivos-sdk:22.04-riscv64 -# dependencies: -# - build-linux-riscv64-release -# - create-sysroot-riscv64 -# needs: -# - build-linux-riscv64-release -# - create-sysroot-riscv64 -# variables: -# PKG_ARCH: riscv64 -# DEBUG_LEVEL: release +run-gtests-riscv64-release: + extends: .run-gtests + tags: ["22.04"] + dependencies: + - prepare-version + - create-sysroot-riscv64 + - build-linux-riscv64-release + needs: + - prepare-version + - create-sysroot-riscv64 + - build-linux-riscv64-release + variables: + PKG_ARCH: riscv64 + DEBUG_LEVEL: release package-tar: stage: deploy From 1bd24938e5376f12274a63edc63c4060eab2757a Mon Sep 17 00:00:00 2001 From: Tony P <131884705+gctony@users.noreply.github.com> Date: Fri, 2 Jun 2023 12:00:41 -0400 Subject: [PATCH 60/85] SW-3656: add QEMU_CPU for gtests (#99) --- rivos/gitlab-ci.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/rivos/gitlab-ci.yml b/rivos/gitlab-ci.yml index c152234ec7b88..50a26a693b0d6 100644 --- a/rivos/gitlab-ci.yml +++ b/rivos/gitlab-ci.yml @@ -199,10 +199,11 @@ build-linux-riscv64-release: # jtreg is not needed to run the gtests but make-prebuilt requires JT_HOME to point to a dir. # We'll just point it to an empty dir, it's not worth checking out jtreg for this. - mkdir $(pwd)/jtreg - # QEMU_LD_PREFIX is only needed for risc v but it's easier to just set it for all configurations + # QEMU_LD_PREFIX and QEMU_CPU are only needed for risc v but it's easier to just set it for all configurations - make test-prebuilt \ CONF=${CONF_NAME} \ QEMU_LD_PREFIX=$(pwd)/sysroot-${UBUNTU_CODENAME}-${PKG_ARCH} \ + QEMU_CPU="rivos-sentinel,m5ops=true" \ BOOT_JDK=/usr/lib/jvm/temurin-${BUILD_JDK_VERSION} \ JDK_IMAGE_DIR=$(pwd)/build/${CONF_NAME}/images/jdk \ TEST_IMAGE_DIR=$(pwd)/build/${CONF_NAME}/images/test \ From 35b477107768ddb6e16e304b08429f97eadf2773 Mon Sep 17 00:00:00 2001 From: Tony P <131884705+gctony@users.noreply.github.com> Date: Fri, 2 Jun 2023 16:33:00 -0400 Subject: [PATCH 61/85] Undo SW-3656: add QEMU_CPU for gtests (#100) * Undo SW-3656: add QEMU_CPU for gtests * additional fix --- rivos/gitlab-ci.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/rivos/gitlab-ci.yml b/rivos/gitlab-ci.yml index 50a26a693b0d6..74e230f6b5c96 100644 --- a/rivos/gitlab-ci.yml +++ b/rivos/gitlab-ci.yml @@ -185,7 +185,7 @@ build-linux-riscv64-release: stage: test image: ubuntu:20.04 variables: - CONF_NAME: linux-${PKG_ARCH}-${DEBUG_LEVEL} + CONF: linux-${PKG_ARCH}-${DEBUG_LEVEL} script: - apt-get update - | @@ -199,14 +199,12 @@ build-linux-riscv64-release: # jtreg is not needed to run the gtests but make-prebuilt requires JT_HOME to point to a dir. # We'll just point it to an empty dir, it's not worth checking out jtreg for this. - mkdir $(pwd)/jtreg - # QEMU_LD_PREFIX and QEMU_CPU are only needed for risc v but it's easier to just set it for all configurations + # QEMU_LD_PREFIX is only needed for risc v but it's easier to just set it for all configurations - make test-prebuilt \ - CONF=${CONF_NAME} \ QEMU_LD_PREFIX=$(pwd)/sysroot-${UBUNTU_CODENAME}-${PKG_ARCH} \ - QEMU_CPU="rivos-sentinel,m5ops=true" \ BOOT_JDK=/usr/lib/jvm/temurin-${BUILD_JDK_VERSION} \ - JDK_IMAGE_DIR=$(pwd)/build/${CONF_NAME}/images/jdk \ - TEST_IMAGE_DIR=$(pwd)/build/${CONF_NAME}/images/test \ + JDK_IMAGE_DIR=$(pwd)/build/${CONF}/images/jdk \ + TEST_IMAGE_DIR=$(pwd)/build/${CONF}/images/test \ JT_HOME=$(pwd)/jtreg \ TEST="gtest:all" From 5c11fbf2207887b0ebf9c9facd1e2cd8695ef50d Mon Sep 17 00:00:00 2001 From: Tony P <131884705+gctony@users.noreply.github.com> Date: Thu, 8 Jun 2023 16:14:57 -0400 Subject: [PATCH 62/85] 8308969: make test-prebuilt doesn't return the correct exit code (#101) Reviewed-by: erikj --- make/Global.gmk | 5 +++++ make/RunTestsPrebuilt.gmk | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/make/Global.gmk b/make/Global.gmk index 618e9ca243993..b41c4051cfafd 100644 --- a/make/Global.gmk +++ b/make/Global.gmk @@ -125,6 +125,11 @@ test-prebuilt: $(MAKE) --no-print-directory -r -R -I make/common/ -f make/RunTestsPrebuilt.gmk \ test-prebuilt CUSTOM_MAKE_DIR=$(CUSTOM_MAKE_DIR) TEST="$(TEST)" ) +test-prebuilt-with-exit-code: + @( cd $(topdir) && \ + $(MAKE) --no-print-directory -r -R -I make/common/ -f make/RunTestsPrebuilt.gmk \ + test-prebuilt-with-exit-code CUSTOM_MAKE_DIR=$(CUSTOM_MAKE_DIR) TEST="$(TEST)" ) + # Alias for backwards compatibility run-test-prebuilt: test-prebuilt diff --git a/make/RunTestsPrebuilt.gmk b/make/RunTestsPrebuilt.gmk index 85c6bae63993a..ca20ccf26ad20 100644 --- a/make/RunTestsPrebuilt.gmk +++ b/make/RunTestsPrebuilt.gmk @@ -295,6 +295,11 @@ test-prebuilt: @cd $(TOPDIR) && $(MAKE) $(MAKE_ARGS) -f make/RunTests.gmk run-test \ TEST="$(TEST)" +test-prebuilt-with-exit-code: test-prebuilt + @if test -f $(MAKESUPPORT_OUTPUTDIR)/exit-with-error ; then \ + exit 1 ; \ + fi + all: test-prebuilt .PHONY: default all test-prebuilt From 99e4c1dcb61f8a38af9494f094808bc732c46647 Mon Sep 17 00:00:00 2001 From: Tony P <131884705+gctony@users.noreply.github.com> Date: Tue, 13 Jun 2023 09:24:11 -0400 Subject: [PATCH 63/85] SW-3706: run jtreg tests on ci (#104) --- rivos/gitlab-ci.yml | 378 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 318 insertions(+), 60 deletions(-) diff --git a/rivos/gitlab-ci.yml b/rivos/gitlab-ci.yml index 74e230f6b5c96..eaec067edda8b 100644 --- a/rivos/gitlab-ci.yml +++ b/rivos/gitlab-ci.yml @@ -6,9 +6,10 @@ include: variables: CACHE_VERSION: "v6" - BUILD_JDK_VERSION: 20 - BINUTILS_DIR: binutils-2.38 + BUILD_JDK_VERSION: "20" + BINUTILS_VERSION: "2.38" GTEST_TAG: v1.13.0 + JTREG_VERSION: 7.2+1 prepare-version: after_script: @@ -75,6 +76,24 @@ create-sysroot-riscv64: variables: PKG_ARCH: riscv64 +download-tools: + stage: prebuild + image: ubuntu:20.04 + script: + - apt-get update + - | + apt-get install -y \ + curl \ + zip + - | + curl -L https://builds.shipilev.net/jtreg/jtreg-${JTREG_VERSION}.zip > jtreg.zip + unzip jtreg.zip + rm -f jtreg.zip + artifacts: + when: on_success + paths: + - jtreg + .build-linux: stage: build image: ubuntu:20.04 @@ -101,9 +120,9 @@ create-sysroot-riscv64: curl -L https://api.adoptium.net/v3/binary/latest/${BUILD_JDK_VERSION}/ea/linux/x64/jdk/hotspot/normal/eclipse\?project\=jdk \ | tar -xzf - -C /usr/lib/jvm/temurin-${BUILD_JDK_VERSION} --strip-components 1 - | - mkdir ${BINUTILS_DIR} - curl -L https://ftp.gnu.org/gnu/binutils/${BINUTILS_DIR}.tar.gz \ - | tar -xzf - -C ${BINUTILS_DIR} --strip-components 1 + mkdir binutils + curl -L https://ftp.gnu.org/gnu/binutils/binutils-${BINUTILS_VERSION}.tar.gz \ + | tar -xzf - -C binutils --strip-components 1 - git clone https://github.com/google/googletest.git -b ${GTEST_TAG} googletest - | bash configure \ @@ -118,8 +137,9 @@ create-sysroot-riscv64: --disable-precompiled-headers \ --with-zlib=system \ --with-gtest=$(pwd)/googletest \ + --with-jtreg=$(pwd)/jtreg \ --with-hsdis=binutils \ - --with-binutils-src=${BINUTILS_DIR} \ + --with-binutils-src=binutils \ --enable-hsdis-bundling - make jdk-image test-image LOG_LEVEL=info artifacts: @@ -133,50 +153,46 @@ create-sysroot-riscv64: - build/${CONF_NAME}/images/jdk - build/${CONF_NAME}/images/test -build-linux-amd64-fastdebug: - extends: .build-linux +.build-dependencies-amd64: dependencies: - prepare-version + - download-tools - create-sysroot-amd64 - needs: + +.build-dependencies-riscv64: + dependencies: - prepare-version - - create-sysroot-amd64 + - download-tools + - create-sysroot-riscv64 + +build-linux-amd64-fastdebug: + extends: .build-linux + dependencies: !reference [.build-dependencies-amd64, dependencies] + needs: !reference [.build-dependencies-amd64, dependencies] variables: PKG_ARCH: amd64 DEBUG_LEVEL: fastdebug build-linux-riscv64-fastdebug: extends: .build-linux - dependencies: - - prepare-version - - create-sysroot-riscv64 - needs: - - prepare-version - - create-sysroot-riscv64 + dependencies: !reference [.build-dependencies-riscv64, dependencies] + needs: !reference [.build-dependencies-riscv64, dependencies] variables: PKG_ARCH: riscv64 DEBUG_LEVEL: fastdebug build-linux-amd64-release: extends: .build-linux - dependencies: - - prepare-version - - create-sysroot-amd64 - needs: - - prepare-version - - create-sysroot-amd64 + dependencies: !reference [.build-dependencies-amd64, dependencies] + needs: !reference [.build-dependencies-amd64, dependencies] variables: PKG_ARCH: amd64 DEBUG_LEVEL: release build-linux-riscv64-release: extends: .build-linux - dependencies: - - prepare-version - - create-sysroot-riscv64 - needs: - - prepare-version - - create-sysroot-riscv64 + dependencies: !reference [.build-dependencies-riscv64, dependencies] + needs: !reference [.build-dependencies-riscv64, dependencies] variables: PKG_ARCH: riscv64 DEBUG_LEVEL: release @@ -196,11 +212,8 @@ build-linux-riscv64-release: mkdir -p /usr/lib/jvm/temurin-${BUILD_JDK_VERSION} curl -L https://api.adoptium.net/v3/binary/latest/${BUILD_JDK_VERSION}/ea/linux/x64/jdk/hotspot/normal/eclipse\?project\=jdk \ | tar -xzf - -C /usr/lib/jvm/temurin-${BUILD_JDK_VERSION} --strip-components 1 - # jtreg is not needed to run the gtests but make-prebuilt requires JT_HOME to point to a dir. - # We'll just point it to an empty dir, it's not worth checking out jtreg for this. - - mkdir $(pwd)/jtreg # QEMU_LD_PREFIX is only needed for risc v but it's easier to just set it for all configurations - - make test-prebuilt \ + - make test-prebuilt-with-exit-code \ QEMU_LD_PREFIX=$(pwd)/sysroot-${UBUNTU_CODENAME}-${PKG_ARCH} \ BOOT_JDK=/usr/lib/jvm/temurin-${BUILD_JDK_VERSION} \ JDK_IMAGE_DIR=$(pwd)/build/${CONF}/images/jdk \ @@ -208,16 +221,47 @@ build-linux-riscv64-release: JT_HOME=$(pwd)/jtreg \ TEST="gtest:all" -run-gtests-amd64-fastdebug: - extends: .run-gtests +# The gtest and jtreg job dependencies, so we don't duplicate them in each job. +# We add the amd64-release build to use as the -compiledjdk for all jtreg jobs +# (we could skip it from the gtest jobs if we wanted...). + +.test-dependencies-amd64-fastdebug: dependencies: - prepare-version + - download-tools - create-sysroot-amd64 + - build-linux-amd64-release - build-linux-amd64-fastdebug - needs: + +.test-dependencies-riscv64-fastdebug: + dependencies: - prepare-version + - download-tools + - create-sysroot-riscv64 + - build-linux-amd64-release + - build-linux-riscv64-fastdebug + +.test-dependencies-amd64-release: + dependencies: + - prepare-version + - download-tools - create-sysroot-amd64 - - build-linux-amd64-fastdebug + - build-linux-amd64-release + +.test-dependencies-riscv64-release: + dependencies: + - prepare-version + - download-tools + - create-sysroot-riscv64 + - build-linux-amd64-release + - build-linux-riscv64-release + +# gtest + +run-gtests-amd64-fastdebug: + extends: .run-gtests + dependencies: !reference [.test-dependencies-amd64-fastdebug, dependencies] + needs: !reference [.test-dependencies-amd64-fastdebug, dependencies] variables: PKG_ARCH: amd64 DEBUG_LEVEL: fastdebug @@ -225,28 +269,16 @@ run-gtests-amd64-fastdebug: run-gtests-riscv64-fastdebug: extends: .run-gtests tags: ["22.04"] - dependencies: - - prepare-version - - create-sysroot-riscv64 - - build-linux-riscv64-fastdebug - needs: - - prepare-version - - create-sysroot-riscv64 - - build-linux-riscv64-fastdebug + dependencies: !reference [.test-dependencies-riscv64-fastdebug, dependencies] + needs: !reference [.test-dependencies-riscv64-fastdebug, dependencies] variables: PKG_ARCH: riscv64 DEBUG_LEVEL: fastdebug run-gtests-amd64-release: extends: .run-gtests - dependencies: - - prepare-version - - create-sysroot-amd64 - - build-linux-amd64-release - needs: - - prepare-version - - create-sysroot-amd64 - - build-linux-amd64-release + dependencies: !reference [.test-dependencies-amd64-release, dependencies] + needs: !reference [.test-dependencies-amd64-release, dependencies] variables: PKG_ARCH: amd64 DEBUG_LEVEL: release @@ -254,17 +286,243 @@ run-gtests-amd64-release: run-gtests-riscv64-release: extends: .run-gtests tags: ["22.04"] - dependencies: - - prepare-version - - create-sysroot-riscv64 - - build-linux-riscv64-release - needs: - - prepare-version - - create-sysroot-riscv64 - - build-linux-riscv64-release + dependencies: !reference [.test-dependencies-riscv64-release, dependencies] + needs: !reference [.test-dependencies-riscv64-release, dependencies] + variables: + PKG_ARCH: riscv64 + DEBUG_LEVEL: release + +.run-jtreg-tests: + stage: test + image: ubuntu:20.04 + variables: + CONF: linux-${PKG_ARCH}-${DEBUG_LEVEL} + script: + - apt-get update + - | + apt-get install -y \ + build-essential \ + curl + - | + mkdir -p /usr/lib/jvm/temurin-${BUILD_JDK_VERSION} + curl -L https://api.adoptium.net/v3/binary/latest/${BUILD_JDK_VERSION}/ea/linux/x64/jdk/hotspot/normal/eclipse\?project\=jdk \ + | tar -xzf - -C /usr/lib/jvm/temurin-${BUILD_JDK_VERSION} --strip-components 1 + # Some of the variables and args (e.g., QEMU_LD_PREFIX, -compilejdk) are not really needed for amd64. + # However, we just added them to keep the script simpler. + - export SYSROOT=$(pwd)/sysroot-${UBUNTU_CODENAME}-${PKG_ARCH} + - make test-prebuilt-with-exit-code \ + QEMU_LD_PREFIX=${SYSROOT} \ + BOOT_JDK=/usr/lib/jvm/temurin-${BUILD_JDK_VERSION} \ + JDK_IMAGE_DIR=$(pwd)/build/${CONF}/images/jdk \ + TEST_IMAGE_DIR=$(pwd)/build/${CONF}/images/test \ + JT_HOME=$(pwd)/jtreg \ + JTREG="OPTIONS=-compilejdk:$(pwd)/build/linux-amd64-release/images/jdk -e:QEMU_LD_PREFIX=${SYSROOT}" + +# jtreg hotspot tier1 compiler + +run-jtreg-hotspot-tier1-compiler-tests-amd64-fastdebug: + extends: .run-jtreg-tests + dependencies: !reference [.test-dependencies-amd64-fastdebug, dependencies] + needs: !reference [.test-dependencies-amd64-fastdebug, dependencies] + variables: + PKG_ARCH: amd64 + DEBUG_LEVEL: fastdebug + TEST: tier1_compiler + +run-jtreg-hotspot-tier1-compiler-tests-riscv64-fastdebug: + extends: .run-jtreg-tests + tags: ["22.04"] + dependencies: !reference [.test-dependencies-riscv64-fastdebug, dependencies] + needs: !reference [.test-dependencies-riscv64-fastdebug, dependencies] + variables: + PKG_ARCH: riscv64 + DEBUG_LEVEL: fastdebug + TEST: tier1_compiler + allow_failure: true + +run-jtreg-hotspot-tier1-compiler-tests-amd64-release: + extends: .run-jtreg-tests + dependencies: !reference [.test-dependencies-amd64-release, dependencies] + needs: !reference [.test-dependencies-amd64-release, dependencies] + variables: + PKG_ARCH: amd64 + DEBUG_LEVEL: release + TEST: tier1_compiler + +run-jtreg-hotspot-tier1-compiler-tests-riscv64-release: + extends: .run-jtreg-tests + tags: ["22.04"] + dependencies: !reference [.test-dependencies-riscv64-release, dependencies] + needs: !reference [.test-dependencies-riscv64-release, dependencies] + variables: + PKG_ARCH: riscv64 + DEBUG_LEVEL: release + TEST: tier1_compiler + allow_failure: true + +# jtreg hotspot tier1 gc + +run-jtreg-hotspot-tier1-gc-tests-amd64-fastdebug: + extends: .run-jtreg-tests + dependencies: !reference [.test-dependencies-amd64-fastdebug, dependencies] + needs: !reference [.test-dependencies-amd64-fastdebug, dependencies] + variables: + PKG_ARCH: amd64 + DEBUG_LEVEL: fastdebug + TEST: tier1_gc + +run-jtreg-hotspot-tier1-gc-tests-riscv64-fastdebug: + extends: .run-jtreg-tests + tags: ["22.04"] + dependencies: !reference [.test-dependencies-riscv64-fastdebug, dependencies] + needs: !reference [.test-dependencies-riscv64-fastdebug, dependencies] + variables: + PKG_ARCH: riscv64 + DEBUG_LEVEL: fastdebug + TEST: tier1_gc + +run-jtreg-hotspot-tier1-gc-tests-amd64-release: + extends: .run-jtreg-tests + dependencies: !reference [.test-dependencies-amd64-release, dependencies] + needs: !reference [.test-dependencies-amd64-release, dependencies] + variables: + PKG_ARCH: amd64 + DEBUG_LEVEL: release + TEST: tier1_gc + +run-jtreg-hotspot-tier1-gc-tests-riscv64-release: + extends: .run-jtreg-tests + tags: ["22.04"] + dependencies: !reference [.test-dependencies-riscv64-release, dependencies] + needs: !reference [.test-dependencies-riscv64-release, dependencies] + variables: + PKG_ARCH: riscv64 + DEBUG_LEVEL: release + TEST: tier1_gc + +# jtreg hotspot tier1 runtime + +run-jtreg-hotspot-tier1-runtime-tests-amd64-fastdebug: + extends: .run-jtreg-tests + dependencies: !reference [.test-dependencies-amd64-fastdebug, dependencies] + needs: !reference [.test-dependencies-amd64-fastdebug, dependencies] + variables: + PKG_ARCH: amd64 + DEBUG_LEVEL: fastdebug + TEST: tier1_runtime + +run-jtreg-hotspot-tier1-runtime-tests-riscv64-fastdebug: + extends: .run-jtreg-tests + tags: ["22.04"] + dependencies: !reference [.test-dependencies-riscv64-fastdebug, dependencies] + needs: !reference [.test-dependencies-riscv64-fastdebug, dependencies] + variables: + PKG_ARCH: riscv64 + DEBUG_LEVEL: fastdebug + TEST: tier1_runtime + allow_failure: true + +run-jtreg-hotspot-tier1-runtime-tests-amd64-release: + extends: .run-jtreg-tests + dependencies: !reference [.test-dependencies-amd64-release, dependencies] + needs: !reference [.test-dependencies-amd64-release, dependencies] + variables: + PKG_ARCH: amd64 + DEBUG_LEVEL: release + TEST: tier1_runtime + +run-jtreg-hotspot-tier1-runtime-tests-riscv64-release: + extends: .run-jtreg-tests + tags: ["22.04"] + dependencies: !reference [.test-dependencies-riscv64-release, dependencies] + needs: !reference [.test-dependencies-riscv64-release, dependencies] + variables: + PKG_ARCH: riscv64 + DEBUG_LEVEL: release + TEST: tier1_runtime + allow_failure: true + +# jtreg hotspot tier1 common + +run-jtreg-hotspot-tier1-common-tests-amd64-fastdebug: + extends: .run-jtreg-tests + dependencies: !reference [.test-dependencies-amd64-fastdebug, dependencies] + needs: !reference [.test-dependencies-amd64-fastdebug, dependencies] + variables: + PKG_ARCH: amd64 + DEBUG_LEVEL: fastdebug + TEST: tier1_common + +run-jtreg-hotspot-tier1-common-tests-riscv64-fastdebug: + extends: .run-jtreg-tests + tags: ["22.04"] + dependencies: !reference [.test-dependencies-riscv64-fastdebug, dependencies] + needs: !reference [.test-dependencies-riscv64-fastdebug, dependencies] + variables: + PKG_ARCH: riscv64 + DEBUG_LEVEL: fastdebug + TEST: tier1_common + +run-jtreg-hotspot-tier1-common-tests-amd64-release: + extends: .run-jtreg-tests + dependencies: !reference [.test-dependencies-amd64-release, dependencies] + needs: !reference [.test-dependencies-amd64-release, dependencies] + variables: + PKG_ARCH: amd64 + DEBUG_LEVEL: release + TEST: tier1_common + +run-jtreg-hotspot-tier1-common-tests-riscv64-release: + extends: .run-jtreg-tests + tags: ["22.04"] + dependencies: !reference [.test-dependencies-riscv64-release, dependencies] + needs: !reference [.test-dependencies-riscv64-release, dependencies] + variables: + PKG_ARCH: riscv64 + DEBUG_LEVEL: release + TEST: tier1_common + +# jtreg hotspot tier1 serviceability + +run-jtreg-hotspot-tier1-serviceability-tests-amd64-fastdebug: + extends: .run-jtreg-tests + dependencies: !reference [.test-dependencies-amd64-fastdebug, dependencies] + needs: !reference [.test-dependencies-amd64-fastdebug, dependencies] + variables: + PKG_ARCH: amd64 + DEBUG_LEVEL: fastdebug + TEST: tier1_serviceability + +run-jtreg-hotspot-tier1-serviceability-tests-riscv64-fastdebug: + extends: .run-jtreg-tests + tags: ["22.04"] + dependencies: !reference [.test-dependencies-riscv64-fastdebug, dependencies] + needs: !reference [.test-dependencies-riscv64-fastdebug, dependencies] + variables: + PKG_ARCH: riscv64 + DEBUG_LEVEL: fastdebug + TEST: tier1_serviceability + allow_failure: true + +run-jtreg-hotspot-tier1-serviceability-tests-amd64-release: + extends: .run-jtreg-tests + dependencies: !reference [.test-dependencies-amd64-release, dependencies] + needs: !reference [.test-dependencies-amd64-release, dependencies] + variables: + PKG_ARCH: amd64 + DEBUG_LEVEL: release + TEST: tier1_serviceability + +run-jtreg-hotspot-tier1-serviceability-tests-riscv64-release: + extends: .run-jtreg-tests + tags: ["22.04"] + dependencies: !reference [.test-dependencies-riscv64-release, dependencies] + needs: !reference [.test-dependencies-riscv64-release, dependencies] variables: PKG_ARCH: riscv64 DEBUG_LEVEL: release + TEST: tier1_serviceability + allow_failure: true package-tar: stage: deploy From 1146e559a4e304da06cd39f02d875ae5ae88e54e Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Wed, 14 Jun 2023 18:11:59 +0200 Subject: [PATCH 64/85] Switch base image to rivos-sdk docker container (#105) --- rivos/gitlab-ci.yml | 73 ++++++--------------------------------------- 1 file changed, 9 insertions(+), 64 deletions(-) diff --git a/rivos/gitlab-ci.yml b/rivos/gitlab-ci.yml index eaec067edda8b..7fd73220d3bdd 100644 --- a/rivos/gitlab-ci.yml +++ b/rivos/gitlab-ci.yml @@ -29,56 +29,9 @@ prepare-version: # Debugging helper - cat gitvars.env -.create-sysroot: - stage: prebuild - image: ubuntu:20.04 - cache: - - when: on_success - key: sysroot-${UBUNTU_CODENAME}-${PKG_ARCH}-${CACHE_VERSION} - paths: - - sysroot-${UBUNTU_CODENAME}-${PKG_ARCH} - script: - # early exit if sysroot-${UBUNTU_CODENAME}-${PKG_ARCH} is coming from the cache - - test -d sysroot-${UBUNTU_CODENAME}-${PKG_ARCH} && exit 0 - - apt-get update - - apt-get install -y debootstrap qemu-user-static - - | - qemu-debootstrap \ - --verbose \ - --arch=${PKG_ARCH} \ - --components=main,universe \ - --include=symlinks,build-essential,libx11-dev,libxext-dev,libxrender-dev,libxrandr-dev,libxtst-dev,libxt-dev,libcups2-dev,libfontconfig1-dev,libasound2-dev,libfreetype6-dev,libpng-dev \ - ${UBUNTU_CODENAME} \ - sysroot-${UBUNTU_CODENAME}-${PKG_ARCH} \ - || (cat sysroot-${UBUNTU_CODENAME}-${PKG_ARCH}/debootstrap/debootstrap.log; exit 1) - - chroot sysroot-${UBUNTU_CODENAME}-${PKG_ARCH} symlinks -cr . - - rm -rf sysroot-${UBUNTU_CODENAME}-${PKG_ARCH}/{dev,proc,run,sys} - artifacts: - when: always - paths: - - sysroot-${UBUNTU_CODENAME}-${PKG_ARCH} - -create-sysroot-amd64: - extends: .create-sysroot - dependencies: - - prepare-version - needs: - - prepare-version - variables: - PKG_ARCH: amd64 - -create-sysroot-riscv64: - extends: .create-sysroot - dependencies: - - prepare-version - needs: - - prepare-version - variables: - PKG_ARCH: riscv64 - download-tools: stage: prebuild - image: ubuntu:20.04 + image: gitlab.ba.rivosinc.com:5050/rv/it/int/rivos-sdk:latest script: - apt-get update - | @@ -96,7 +49,7 @@ download-tools: .build-linux: stage: build - image: ubuntu:20.04 + image: gitlab.ba.rivosinc.com:5050/rv/it/int/rivos-sdk:latest variables: CONF_NAME: linux-${PKG_ARCH}-${DEBUG_LEVEL} script: @@ -132,7 +85,7 @@ download-tools: --with-vendor-name="Rivos Inc" \ --with-version-pre="${JDK_VERSION_PRE}" \ --with-version-opt="${JDK_VERSION_OPT}" \ - --with-sysroot=$(pwd)/sysroot-${UBUNTU_CODENAME}-${PKG_ARCH} \ + $(test "${PKG_ARCH}" = "riscv64" && echo "--with-sysroot=/rivos/sysroot/riscv" || true) \ --with-boot-jdk=/usr/lib/jvm/temurin-${BUILD_JDK_VERSION} \ --disable-precompiled-headers \ --with-zlib=system \ @@ -157,13 +110,11 @@ download-tools: dependencies: - prepare-version - download-tools - - create-sysroot-amd64 .build-dependencies-riscv64: dependencies: - prepare-version - download-tools - - create-sysroot-riscv64 build-linux-amd64-fastdebug: extends: .build-linux @@ -199,7 +150,7 @@ build-linux-riscv64-release: .run-gtests: stage: test - image: ubuntu:20.04 + image: gitlab.ba.rivosinc.com:5050/rv/it/int/rivos-sdk:latest variables: CONF: linux-${PKG_ARCH}-${DEBUG_LEVEL} script: @@ -212,9 +163,8 @@ build-linux-riscv64-release: mkdir -p /usr/lib/jvm/temurin-${BUILD_JDK_VERSION} curl -L https://api.adoptium.net/v3/binary/latest/${BUILD_JDK_VERSION}/ea/linux/x64/jdk/hotspot/normal/eclipse\?project\=jdk \ | tar -xzf - -C /usr/lib/jvm/temurin-${BUILD_JDK_VERSION} --strip-components 1 - # QEMU_LD_PREFIX is only needed for risc v but it's easier to just set it for all configurations + - if [[ "${PKG_ARCH}" = "riscv64" ]]; then export QEMU_LD_PREFIX=/rivos/sysroot/riscv; fi - make test-prebuilt-with-exit-code \ - QEMU_LD_PREFIX=$(pwd)/sysroot-${UBUNTU_CODENAME}-${PKG_ARCH} \ BOOT_JDK=/usr/lib/jvm/temurin-${BUILD_JDK_VERSION} \ JDK_IMAGE_DIR=$(pwd)/build/${CONF}/images/jdk \ TEST_IMAGE_DIR=$(pwd)/build/${CONF}/images/test \ @@ -229,7 +179,6 @@ build-linux-riscv64-release: dependencies: - prepare-version - download-tools - - create-sysroot-amd64 - build-linux-amd64-release - build-linux-amd64-fastdebug @@ -237,7 +186,6 @@ build-linux-riscv64-release: dependencies: - prepare-version - download-tools - - create-sysroot-riscv64 - build-linux-amd64-release - build-linux-riscv64-fastdebug @@ -245,14 +193,12 @@ build-linux-riscv64-release: dependencies: - prepare-version - download-tools - - create-sysroot-amd64 - build-linux-amd64-release .test-dependencies-riscv64-release: dependencies: - prepare-version - download-tools - - create-sysroot-riscv64 - build-linux-amd64-release - build-linux-riscv64-release @@ -294,7 +240,7 @@ run-gtests-riscv64-release: .run-jtreg-tests: stage: test - image: ubuntu:20.04 + image: gitlab.ba.rivosinc.com:5050/rv/it/int/rivos-sdk:latest variables: CONF: linux-${PKG_ARCH}-${DEBUG_LEVEL} script: @@ -309,14 +255,13 @@ run-gtests-riscv64-release: | tar -xzf - -C /usr/lib/jvm/temurin-${BUILD_JDK_VERSION} --strip-components 1 # Some of the variables and args (e.g., QEMU_LD_PREFIX, -compilejdk) are not really needed for amd64. # However, we just added them to keep the script simpler. - - export SYSROOT=$(pwd)/sysroot-${UBUNTU_CODENAME}-${PKG_ARCH} + - if [[ "${PKG_ARCH}" = "riscv64" ]]; then export QEMU_LD_PREFIX=/rivos/sysroot/riscv; fi - make test-prebuilt-with-exit-code \ - QEMU_LD_PREFIX=${SYSROOT} \ BOOT_JDK=/usr/lib/jvm/temurin-${BUILD_JDK_VERSION} \ JDK_IMAGE_DIR=$(pwd)/build/${CONF}/images/jdk \ TEST_IMAGE_DIR=$(pwd)/build/${CONF}/images/test \ JT_HOME=$(pwd)/jtreg \ - JTREG="OPTIONS=-compilejdk:$(pwd)/build/linux-amd64-release/images/jdk -e:QEMU_LD_PREFIX=${SYSROOT}" + JTREG="OPTIONS=-compilejdk:$(pwd)/build/linux-amd64-release/images/jdk -e:QEMU_LD_PREFIX=${QEMU_LD_PREFIX}" # jtreg hotspot tier1 compiler @@ -526,7 +471,7 @@ run-jtreg-hotspot-tier1-serviceability-tests-riscv64-release: package-tar: stage: deploy - image: ubuntu:20.04 + image: gitlab.ba.rivosinc.com:5050/rv/it/int/rivos-sdk:latest dependencies: - prepare-version - build-linux-amd64-release From 8bc43f186fbe9a114ad7281cb5bb9bbccd8d95dc Mon Sep 17 00:00:00 2001 From: Tony P <131884705+gctony@users.noreply.github.com> Date: Wed, 14 Jun 2023 14:46:47 -0400 Subject: [PATCH 65/85] SW-3773: ignore jtreg failures on ci (#106) --- rivos/gitlab-ci.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/rivos/gitlab-ci.yml b/rivos/gitlab-ci.yml index 7fd73220d3bdd..7308ddb30fd11 100644 --- a/rivos/gitlab-ci.yml +++ b/rivos/gitlab-ci.yml @@ -262,6 +262,7 @@ run-gtests-riscv64-release: TEST_IMAGE_DIR=$(pwd)/build/${CONF}/images/test \ JT_HOME=$(pwd)/jtreg \ JTREG="OPTIONS=-compilejdk:$(pwd)/build/linux-amd64-release/images/jdk -e:QEMU_LD_PREFIX=${QEMU_LD_PREFIX}" + timeout: 2h # jtreg hotspot tier1 compiler @@ -273,6 +274,7 @@ run-jtreg-hotspot-tier1-compiler-tests-amd64-fastdebug: PKG_ARCH: amd64 DEBUG_LEVEL: fastdebug TEST: tier1_compiler + allow_failure: true run-jtreg-hotspot-tier1-compiler-tests-riscv64-fastdebug: extends: .run-jtreg-tests @@ -293,6 +295,7 @@ run-jtreg-hotspot-tier1-compiler-tests-amd64-release: PKG_ARCH: amd64 DEBUG_LEVEL: release TEST: tier1_compiler + allow_failure: true run-jtreg-hotspot-tier1-compiler-tests-riscv64-release: extends: .run-jtreg-tests @@ -315,6 +318,7 @@ run-jtreg-hotspot-tier1-gc-tests-amd64-fastdebug: PKG_ARCH: amd64 DEBUG_LEVEL: fastdebug TEST: tier1_gc + allow_failure: true run-jtreg-hotspot-tier1-gc-tests-riscv64-fastdebug: extends: .run-jtreg-tests @@ -325,6 +329,7 @@ run-jtreg-hotspot-tier1-gc-tests-riscv64-fastdebug: PKG_ARCH: riscv64 DEBUG_LEVEL: fastdebug TEST: tier1_gc + allow_failure: true run-jtreg-hotspot-tier1-gc-tests-amd64-release: extends: .run-jtreg-tests @@ -334,6 +339,7 @@ run-jtreg-hotspot-tier1-gc-tests-amd64-release: PKG_ARCH: amd64 DEBUG_LEVEL: release TEST: tier1_gc + allow_failure: true run-jtreg-hotspot-tier1-gc-tests-riscv64-release: extends: .run-jtreg-tests @@ -344,6 +350,7 @@ run-jtreg-hotspot-tier1-gc-tests-riscv64-release: PKG_ARCH: riscv64 DEBUG_LEVEL: release TEST: tier1_gc + allow_failure: true # jtreg hotspot tier1 runtime @@ -355,6 +362,7 @@ run-jtreg-hotspot-tier1-runtime-tests-amd64-fastdebug: PKG_ARCH: amd64 DEBUG_LEVEL: fastdebug TEST: tier1_runtime + allow_failure: true run-jtreg-hotspot-tier1-runtime-tests-riscv64-fastdebug: extends: .run-jtreg-tests @@ -375,6 +383,7 @@ run-jtreg-hotspot-tier1-runtime-tests-amd64-release: PKG_ARCH: amd64 DEBUG_LEVEL: release TEST: tier1_runtime + allow_failure: true run-jtreg-hotspot-tier1-runtime-tests-riscv64-release: extends: .run-jtreg-tests @@ -397,6 +406,7 @@ run-jtreg-hotspot-tier1-common-tests-amd64-fastdebug: PKG_ARCH: amd64 DEBUG_LEVEL: fastdebug TEST: tier1_common + allow_failure: true run-jtreg-hotspot-tier1-common-tests-riscv64-fastdebug: extends: .run-jtreg-tests @@ -407,6 +417,7 @@ run-jtreg-hotspot-tier1-common-tests-riscv64-fastdebug: PKG_ARCH: riscv64 DEBUG_LEVEL: fastdebug TEST: tier1_common + allow_failure: true run-jtreg-hotspot-tier1-common-tests-amd64-release: extends: .run-jtreg-tests @@ -416,6 +427,7 @@ run-jtreg-hotspot-tier1-common-tests-amd64-release: PKG_ARCH: amd64 DEBUG_LEVEL: release TEST: tier1_common + allow_failure: true run-jtreg-hotspot-tier1-common-tests-riscv64-release: extends: .run-jtreg-tests @@ -426,6 +438,7 @@ run-jtreg-hotspot-tier1-common-tests-riscv64-release: PKG_ARCH: riscv64 DEBUG_LEVEL: release TEST: tier1_common + allow_failure: true # jtreg hotspot tier1 serviceability @@ -437,6 +450,7 @@ run-jtreg-hotspot-tier1-serviceability-tests-amd64-fastdebug: PKG_ARCH: amd64 DEBUG_LEVEL: fastdebug TEST: tier1_serviceability + allow_failure: true run-jtreg-hotspot-tier1-serviceability-tests-riscv64-fastdebug: extends: .run-jtreg-tests @@ -457,6 +471,7 @@ run-jtreg-hotspot-tier1-serviceability-tests-amd64-release: PKG_ARCH: amd64 DEBUG_LEVEL: release TEST: tier1_serviceability + allow_failure: true run-jtreg-hotspot-tier1-serviceability-tests-riscv64-release: extends: .run-jtreg-tests From 52021fb75823bfae2ca526e031730fe2db35a4f1 Mon Sep 17 00:00:00 2001 From: Tony P <131884705+gctony@users.noreply.github.com> Date: Thu, 15 Jun 2023 14:35:44 -0400 Subject: [PATCH 66/85] SW-3762: gtest codestrings fails infrequently (#107) --- test/hotspot/gtest/code/test_codestrings.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/hotspot/gtest/code/test_codestrings.cpp b/test/hotspot/gtest/code/test_codestrings.cpp index bd25da7620853..41798de404ab9 100644 --- a/test/hotspot/gtest/code/test_codestrings.cpp +++ b/test/hotspot/gtest/code/test_codestrings.cpp @@ -262,7 +262,7 @@ static void buffer_blob_test() BufferBlob::free(blob); } -#if defined(PPC) || defined(S390) +#if defined(PPC) || defined(S390) || defined(RISCV64) // Neither ppc nor s390 compiler use code strings TEST_VM(codestrings, DISABLED_validate) #else From 25d8d2c1300eca50b6663d3f93e6b9c621a9eb13 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Mon, 19 Jun 2023 11:46:59 +0200 Subject: [PATCH 67/85] Try merge rivos/main into rivos/merge-* (#109) That avoids having to do it manually even when there are no conflicts. --- .github/workflows/downstream.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/downstream.yml b/.github/workflows/downstream.yml index 788497add392d..f25cfae7dca49 100644 --- a/.github/workflows/downstream.yml +++ b/.github/workflows/downstream.yml @@ -73,6 +73,16 @@ jobs: if [ "${{ steps.configure.outputs.diff }}" = "true" ]; then git branch -f rivos/merge-${{ steps.configure.outputs.tag }} ${{ steps.configure.outputs.tag }} + + git checkout rivos/merge-${{ steps.configure.outputs.tag }} + if ! git merge --no-ff --no-edit origin/rivos/main; then + # Print the conflicts + git diff + + # Abort the merge and let assignee manually resolve them + git merge --abort + fi + git push origin rivos/merge-${{ steps.configure.outputs.tag }} fi From 49df6b74c8711719d589d2db439ac5f309a29f4e Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Fri, 23 Jun 2023 12:15:53 +0200 Subject: [PATCH 68/85] Setup user for downstream merge commit (#110) --- .github/workflows/downstream.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/downstream.yml b/.github/workflows/downstream.yml index f25cfae7dca49..3431a53fd35ec 100644 --- a/.github/workflows/downstream.yml +++ b/.github/workflows/downstream.yml @@ -75,6 +75,9 @@ jobs: git branch -f rivos/merge-${{ steps.configure.outputs.tag }} ${{ steps.configure.outputs.tag }} git checkout rivos/merge-${{ steps.configure.outputs.tag }} + # Setup user for merge commit + git config user.name "Ludovic Henry" + git config user.email "ludovic@rivosinc.com" if ! git merge --no-ff --no-edit origin/rivos/main; then # Print the conflicts git diff From 3ab923a043cb0968ceaa9bbd26109aec1dfe0e9d Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Wed, 28 Jun 2023 10:03:15 +0200 Subject: [PATCH 69/85] 8310949: RISC-V: Initialize UseUnalignedAccesses (#112) --- src/hotspot/cpu/riscv/vm_version_riscv.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/hotspot/cpu/riscv/vm_version_riscv.cpp b/src/hotspot/cpu/riscv/vm_version_riscv.cpp index 89c819eaf54b7..35f026019d0ee 100644 --- a/src/hotspot/cpu/riscv/vm_version_riscv.cpp +++ b/src/hotspot/cpu/riscv/vm_version_riscv.cpp @@ -232,6 +232,13 @@ void VM_Version::initialize() { FLAG_SET_DEFAULT(UseBlockZeroing, false); } + // This machine allows unaligned memory accesses + if (FLAG_IS_DEFAULT(UseUnalignedAccesses)) { + FLAG_SET_DEFAULT(UseUnalignedAccesses, + unaligned_access.value() != MISALIGNED_UNKNOWN && + unaligned_access.value() != MISALIGNED_UNSUPPORTED); + } + #ifdef COMPILER2 c2_initialize(); #endif // COMPILER2 From e5bad76de3b0064721e8d9a4e3b89c7a02ee868f Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Wed, 2 Aug 2023 12:03:03 +0200 Subject: [PATCH 70/85] Split riscv64 build from amd64 package (#118) --- rivos/gitlab-ci.yml | 59 +++++++++++++++++++++++++++++++-------------- 1 file changed, 41 insertions(+), 18 deletions(-) diff --git a/rivos/gitlab-ci.yml b/rivos/gitlab-ci.yml index 7308ddb30fd11..f7e26ea02538d 100644 --- a/rivos/gitlab-ci.yml +++ b/rivos/gitlab-ci.yml @@ -508,28 +508,26 @@ package-tar: variables: PKG_LICENSE: "GPL-2.0 license" PKG_UPSTREAM_VERSION: "${JDK_VERSION_PKG}" + PKG_DIRECTORIES: "${PKG_DIRECTORY}" + BUILD_ARCH: "$PKG_ARCH" before_script: # PKG_DIRECTORIES must be set - test -n "${PKG_DIRECTORIES}" || exit 1 # PKG_ARCH must be set - test -n "${PKG_ARCH}" || exit 1 # clean up pre-built binaries from the rivos-sdk - - rm -rf $(echo "${PKG_DIRECTORIES}" | tr ';' ' ') + - rm -rf "${PKG_DIRECTORY}" + - mkdir -p "${PKG_DIRECTORY}" # move the previous temporary install - | - cp -av build/linux-${PKG_ARCH}-release/images/jdk /rivos/ - if [ "${PKG_ARCH}" = "amd64" ]; then - # put linux-riscv64 build in sysroot - mkdir -p /rivos/sysroot/riscv/rivos - cp -av build/linux-riscv64-release/images/jdk /rivos/sysroot/riscv/rivos - fi + cp -av build/linux-${BUILD_ARCH}-release/images/jdk/ "${PKG_DIRECTORY}" - | if [ "${PKG_DBG}" = "true" ]; then - find $(echo "${PKG_DIRECTORIES}" | tr ';' ' ') \( -xtype f -or -xtype l \) -not -name '*.debuginfo' -exec rm -f {} \; -print - find $(echo "${PKG_DIRECTORIES}" | tr ';' ' ') -type d -print | sort -r | xargs -I{} bash -c "rmdir {} || true" + find "${PKG_DIRECTORY}" \( -xtype f -or -xtype l \) -not -name '*.debuginfo' -exec rm -f {} \; -print + find "${PKG_DIRECTORY}" -type d -print | sort -r | xargs -I{} bash -c "rmdir {} || true" else # remove *.debuginfo files, they take a lot of space - find $(echo "${PKG_DIRECTORIES}" | tr ';' ' ') -type f -name '*.debuginfo' -exec rm -f {} \; -print + find "${PKG_DIRECTORY}" -type f -name '*.debuginfo' -exec rm -f {} \; -print fi package-deb-amd64: @@ -537,13 +535,11 @@ package-deb-amd64: dependencies: - prepare-version - build-linux-amd64-release - - build-linux-riscv64-release needs: - prepare-version - build-linux-amd64-release - - build-linux-riscv64-release variables: - PKG_DIRECTORIES: "/rivos/jdk;/rivos/sysroot/riscv/rivos/jdk" + PKG_DIRECTORY: "/rivos/jdk" PKG_ARCH: "amd64" package-deb-riscv64: @@ -555,22 +551,34 @@ package-deb-riscv64: - prepare-version - build-linux-riscv64-release variables: - PKG_DIRECTORIES: "/rivos/jdk" + PKG_DIRECTORY: "/rivos/jdk" PKG_ARCH: "riscv64" +package-deb-cross-riscv64: + extends: .package-deb + dependencies: + - prepare-version + - build-linux-riscv64-release + needs: + - prepare-version + - build-linux-riscv64-release + variables: + PKG_NAME: "${PROJECT_NAME}-cross-riscv64" + PKG_DIRECTORY: "/rivos/sysroot/riscv/rivos/jdk" + PKG_ARCH: "amd64" + BUILD_ARCH: "riscv64" + package-deb-dbg-amd64: extends: .package-deb dependencies: - prepare-version - build-linux-amd64-release - - build-linux-riscv64-release needs: - prepare-version - build-linux-amd64-release - - build-linux-riscv64-release variables: PKG_NAME: "${PROJECT_NAME}-dbg" - PKG_DIRECTORIES: "/rivos/jdk;/rivos/sysroot/riscv/rivos/jdk" + PKG_DIRECTORY: "/rivos/jdk" PKG_ARCH: "amd64" PKG_DBG: "true" @@ -584,10 +592,25 @@ package-deb-dbg-riscv64: - build-linux-riscv64-release variables: PKG_NAME: "${PROJECT_NAME}-dbg" - PKG_DIRECTORIES: "/rivos/jdk" + PKG_DIRECTORY: "/rivos/jdk" PKG_ARCH: "riscv64" PKG_DBG: "true" +package-deb-dbg-cross-riscv64: + extends: .package-deb + dependencies: + - prepare-version + - build-linux-riscv64-release + needs: + - prepare-version + - build-linux-riscv64-release + variables: + PKG_NAME: "${PROJECT_NAME}-cross-riscv64-dbg" + PKG_DIRECTORY: "/rivos/sysroot/riscv/rivos/jdk" + PKG_ARCH: "amd64" + BUILD_ARCH: "riscv64" + PKG_DBG: "true" + # deploy-module-ubuntu: # extends: .deploy-module # dependencies: From c17db038e3786e10b4e8276650f0f663232c66cf Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Mon, 7 Aug 2023 11:03:40 +0200 Subject: [PATCH 71/85] Fix package folder (#120) It would install to /rivos/jdk/jdk instead of /rivos/jdk --- rivos/gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rivos/gitlab-ci.yml b/rivos/gitlab-ci.yml index f7e26ea02538d..2c964375ae1d9 100644 --- a/rivos/gitlab-ci.yml +++ b/rivos/gitlab-ci.yml @@ -520,7 +520,7 @@ package-tar: - mkdir -p "${PKG_DIRECTORY}" # move the previous temporary install - | - cp -av build/linux-${BUILD_ARCH}-release/images/jdk/ "${PKG_DIRECTORY}" + cp -av build/linux-${BUILD_ARCH}-release/images/jdk/* "${PKG_DIRECTORY}" - | if [ "${PKG_DBG}" = "true" ]; then find "${PKG_DIRECTORY}" \( -xtype f -or -xtype l \) -not -name '*.debuginfo' -exec rm -f {} \; -print From f84ec703f05867d035e36ff19444c948b668ec56 Mon Sep 17 00:00:00 2001 From: Robbin Ehn Date: Thu, 17 Aug 2023 16:47:14 +0200 Subject: [PATCH 72/85] RIVOS: Binutils fix --- make/autoconf/lib-hsdis.m4 | 22 ++++++++++++++-------- src/utils/hsdis/binutils/hsdis-binutils.c | 23 +++++++++++++++++++++++ 2 files changed, 37 insertions(+), 8 deletions(-) diff --git a/make/autoconf/lib-hsdis.m4 b/make/autoconf/lib-hsdis.m4 index 470a0ae8358d5..f5cc73fc62f72 100644 --- a/make/autoconf/lib-hsdis.m4 +++ b/make/autoconf/lib-hsdis.m4 @@ -147,10 +147,11 @@ AC_DEFUN([LIB_BUILD_BINUTILS], $MKDIR -p $BINUTILS_DIR fi - if test -e $BINUTILS_DIR/bfd/libbfd.a && \ - test -e $BINUTILS_DIR/opcodes/libopcodes.a && \ - test -e $BINUTILS_DIR/libiberty/libiberty.a && \ - test -e $BINUTILS_DIR/zlib/libz.a; then + # We don't know the version, not checking for libsframe.a + if test -e $BINUTILS_DIR/bfd/.libs/libbfd.a && \ + test -e $BINUTILS_DIR/opcodes/libopcodes.a && \ + test -e $BINUTILS_DIR/libiberty/libiberty.a && \ + test -e $BINUTILS_DIR/zlib/libz.a ; then AC_MSG_NOTICE([Found binutils binaries in binutils source directory -- not building]) else # On Windows, we cannot build with the normal Microsoft CL, but must instead use @@ -190,10 +191,10 @@ AC_DEFUN([LIB_BUILD_BINUTILS], binutils_cflags="$binutils_cflags $MACHINE_FLAG $JVM_PICFLAG $C_O_FLAG_NORM" AC_MSG_NOTICE([Running binutils configure]) - AC_MSG_NOTICE([configure command line: cd $BINUTILS_DIR && $BINUTILS_SRC/configure --disable-nls CFLAGS="$binutils_cflags" CC="$binutils_cc" AR="$AR" $binutils_target]) + AC_MSG_NOTICE([configure command line: cd $BINUTILS_DIR && $BINUTILS_SRC/configure --without-zstd --disable-nls CFLAGS="$binutils_cflags" CC="$binutils_cc" AR="$AR" $binutils_target]) saved_dir=`pwd` cd "$BINUTILS_DIR" - $BINUTILS_SRC/configure --disable-nls CFLAGS="$binutils_cflags" CC="$binutils_cc" AR="$AR" $binutils_target + $BINUTILS_SRC/configure --without-zstd --disable-nls CFLAGS="$binutils_cflags" CC="$binutils_cc" AR="$AR" $binutils_target if test $? -ne 0 || ! test -e $BINUTILS_DIR/Makefile; then AC_MSG_NOTICE([Automatic building of binutils failed on configure. Try building it manually]) AC_MSG_ERROR([Cannot continue]) @@ -238,9 +239,10 @@ AC_DEFUN([LIB_SETUP_HSDIS_BINUTILS], AC_CHECK_LIB(opcodes, disassembler, [ HSDIS_LIBS="$HSDIS_LIBS -lopcodes" ], [ binutils_system_error="libopcodes not found" ]) AC_CHECK_LIB(iberty, xmalloc, [ HSDIS_LIBS="$HSDIS_LIBS -liberty" ], [ binutils_system_error="libiberty not found" ]) AC_CHECK_LIB(z, deflate, [ HSDIS_LIBS="$HSDIS_LIBS -lz" ], [ binutils_system_error="libz not found" ]) + AC_CHECK_LIB(sframe, frame, [ HSDIS_LIBS="$HSDIS_LIBS -lsframe" ], ) HSDIS_CFLAGS="-DLIBARCH_$OPENJDK_TARGET_CPU_LEGACY_LIB" elif test "x$BINUTILS_DIR" != x; then - if test -e $BINUTILS_DIR/bfd/libbfd.a && \ + if test -e $BINUTILS_DIR/bfd/.libs/libbfd.a && \ test -e $BINUTILS_DIR/opcodes/libopcodes.a && \ test -e $BINUTILS_DIR/libiberty/libiberty.a && \ test -e $BINUTILS_DIR/zlib/libz.a; then @@ -251,7 +253,11 @@ AC_DEFUN([LIB_SETUP_HSDIS_BINUTILS], HSDIS_CFLAGS="$HSDIS_CFLAGS -I$BINUTILS_DIR/include -I$BINUTILS_DIR/bfd" fi HSDIS_LDFLAGS="" - HSDIS_LIBS="$BINUTILS_DIR/bfd/libbfd.a $BINUTILS_DIR/opcodes/libopcodes.a $BINUTILS_DIR/libiberty/libiberty.a $BINUTILS_DIR/zlib/libz.a" + HSDIS_LIBS="$BINUTILS_DIR/bfd/.libs/libbfd.a $BINUTILS_DIR/opcodes/libopcodes.a $BINUTILS_DIR/libiberty/libiberty.a $BINUTILS_DIR/zlib/libz.a" + # If we have libsframe add it. + if test -e $BINUTILS_DIR/libsframe/.libs/libsframe.a; then + HSDIS_LIBS="$BINUTILS_DIR/bfd/.libs/libbfd.a $BINUTILS_DIR/opcodes/libopcodes.a $BINUTILS_DIR/libiberty/libiberty.a $BINUTILS_DIR/zlib/libz.a $BINUTILS_DIR/libsframe/.libs/libsframe.a" + fi fi fi diff --git a/src/utils/hsdis/binutils/hsdis-binutils.c b/src/utils/hsdis/binutils/hsdis-binutils.c index 602283dd6571e..a5155dd94b400 100644 --- a/src/utils/hsdis/binutils/hsdis-binutils.c +++ b/src/utils/hsdis/binutils/hsdis-binutils.c @@ -59,6 +59,7 @@ #include #include +#include #include #include "hsdis.h" @@ -556,12 +557,34 @@ static void parse_fake_insn(disassembler_ftype dfn, dinfo->fprintf_func = fprintf_func; } +static fprintf_ftype target_fprintf_func = NULL; + +#if BFD_VERSION >= 239000000 +static int wrapper_fprintf_styled_ftype(void *v, enum disassembler_style style_unused, const char* fmt, ...) { + char buffer[1024] = {}; + va_list args; + int r; + va_start(args, fmt); + r = vsnprintf(buffer, sizeof(buffer), fmt, args); + va_end(args); + if (target_fprintf_func != NULL) { + return target_fprintf_func(v, "%s", buffer); + } + return r; +} +#endif + static void init_disassemble_info_from_bfd(struct disassemble_info* dinfo, void *stream, fprintf_ftype fprintf_func, bfd* abfd, char* disassembler_options) { + target_fprintf_func = fprintf_func; +#if BFD_VERSION >= 239000000 + init_disassemble_info(dinfo, stream, fprintf_func, wrapper_fprintf_styled_ftype); +#else init_disassemble_info(dinfo, stream, fprintf_func); +#endif dinfo->flavour = bfd_get_flavour(abfd); dinfo->arch = bfd_get_arch(abfd); From 934c8c29e3a87ebc8c4e907e484b40adfdaa54ed Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Fri, 8 Sep 2023 10:03:51 +0200 Subject: [PATCH 73/85] Implement support for Zacas for non-narrow atomic cmpxchg (#121) --- src/hotspot/cpu/riscv/assembler_riscv.hpp | 2 + src/hotspot/cpu/riscv/globals_riscv.hpp | 1 + .../cpu/riscv/macroAssembler_riscv.cpp | 198 +++++++++++++++--- .../cpu/riscv/macroAssembler_riscv.hpp | 13 ++ src/hotspot/cpu/riscv/vm_version_riscv.hpp | 1 + .../linux_riscv/vm_version_linux_riscv.cpp | 1 + 6 files changed, 186 insertions(+), 30 deletions(-) diff --git a/src/hotspot/cpu/riscv/assembler_riscv.hpp b/src/hotspot/cpu/riscv/assembler_riscv.hpp index 9b635122caba6..0c2ff80bacbd3 100644 --- a/src/hotspot/cpu/riscv/assembler_riscv.hpp +++ b/src/hotspot/cpu/riscv/assembler_riscv.hpp @@ -758,6 +758,8 @@ enum Aqrl {relaxed = 0b00, rl = 0b01, aq = 0b10, aqrl = 0b11}; INSN(amomax_d , 0b0101111, 0b011, 0b10100); INSN(amominu_d, 0b0101111, 0b011, 0b11000); INSN(amomaxu_d, 0b0101111, 0b011, 0b11100); + INSN(amocas_w, 0b0101111, 0b010, 0b00101); + INSN(amocas_d, 0b0101111, 0b011, 0b00101); #undef INSN enum operand_size { int8, int16, int32, uint32, int64 }; diff --git a/src/hotspot/cpu/riscv/globals_riscv.hpp b/src/hotspot/cpu/riscv/globals_riscv.hpp index dd375c2c0f82f..0799b1f6d1c0f 100644 --- a/src/hotspot/cpu/riscv/globals_riscv.hpp +++ b/src/hotspot/cpu/riscv/globals_riscv.hpp @@ -102,6 +102,7 @@ define_pd_global(intx, InlineSmallCode, 1000); product(bool, UseRVC, false, "Use RVC instructions") \ product(bool, UseRVA22U64, false, EXPERIMENTAL, "Use RVA22U64 profile") \ product(bool, UseRVV, false, EXPERIMENTAL, "Use RVV instructions") \ + product(bool, UseZacas, false, EXPERIMENTAL, "Use Zacas instructions") \ product(bool, UseZba, false, EXPERIMENTAL, "Use Zba instructions") \ product(bool, UseZbb, false, EXPERIMENTAL, "Use Zbb instructions") \ product(bool, UseZbs, false, EXPERIMENTAL, "Use Zbs instructions") \ diff --git a/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp b/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp index 6817218659839..b4986996ffecf 100644 --- a/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp +++ b/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp @@ -2589,20 +2589,26 @@ void MacroAssembler::cmpxchgptr(Register oldv, Register newv, Register addr, Reg // oldv holds comparison value // newv holds value to write in exchange // addr identifies memory word to compare against/update - Label retry_load, nope; - bind(retry_load); - // Load reserved from the memory location - lr_d(tmp, addr, Assembler::aqrl); - // Fail and exit if it is not what we expect - bne(tmp, oldv, nope); - // If the store conditional succeeds, tmp will be zero - sc_d(tmp, newv, addr, Assembler::rl); - beqz(tmp, succeed); - // Retry only when the store conditional failed - j(retry_load); - - bind(nope); - membar(AnyAny); + if (UseZacas) { + mv(tmp, oldv); + atomic_cas(tmp, newv, addr, Assembler::int64, Assembler::aq, Assembler::rl); + beq(tmp, oldv, succeed); + } else { + Label retry_load, nope; + bind(retry_load); + // Load reserved from the memory location + lr_d(tmp, addr, Assembler::aqrl); + // Fail and exit if it is not what we expect + bne(tmp, oldv, nope); + // If the store conditional succeeds, tmp will be zero + sc_d(tmp, newv, addr, Assembler::rl); + beqz(tmp, succeed); + // Retry only when the store conditional failed + j(retry_load); + bind(nope); + membar(AnyAny); + } + mv(oldv, tmp); if (fail != nullptr) { j(*fail); @@ -2674,7 +2680,7 @@ void MacroAssembler::cmpxchg_narrow_value_helper(Register addr, Register expecte } sll(mask, mask, shift); - xori(not_mask, mask, -1); + notr(not_mask, mask); sll(expected, expected, shift); andr(expected, expected, mask); @@ -2684,7 +2690,7 @@ void MacroAssembler::cmpxchg_narrow_value_helper(Register addr, Register expecte } // cmpxchg_narrow_value will kill t0, t1, expected, new_val and tmps. -// It's designed to implement compare and swap byte/boolean/char/short by lr.w/sc.w, +// It's designed to implement compare and swap byte/boolean/char/short by lr.w/sc.w or amocas.w, // which are forced to work with 4-byte aligned address. void MacroAssembler::cmpxchg_narrow_value(Register addr, Register expected, Register new_val, @@ -2699,14 +2705,29 @@ void MacroAssembler::cmpxchg_narrow_value(Register addr, Register expected, Label retry, fail, done; bind(retry); - lr_w(old, aligned_addr, acquire); - andr(tmp, old, mask); - bne(tmp, expected, fail); - andr(tmp, old, not_mask); - orr(tmp, tmp, new_val); - sc_w(tmp, tmp, aligned_addr, release); - bnez(tmp, retry); + if (UseZacas) { + lw(old, aligned_addr); + + // if old & mask != expected + andr(tmp, old, mask); + bne(tmp, expected, fail); + + andr(tmp, old, not_mask); + orr(tmp, tmp, new_val); + + atomic_cas(old, tmp, aligned_addr, size, acquire, release); + bne(tmp, old, retry); + } else { + lr_w(old, aligned_addr, acquire); + andr(tmp, old, mask); + bne(tmp, expected, fail); + + andr(tmp, old, not_mask); + orr(tmp, tmp, new_val); + sc_w(tmp, tmp, aligned_addr, release); + bnez(tmp, retry); + } if (result_as_bool) { mv(result, 1); @@ -2746,14 +2767,28 @@ void MacroAssembler::weak_cmpxchg_narrow_value(Register addr, Register expected, Label fail, done; - lr_w(old, aligned_addr, acquire); - andr(tmp, old, mask); - bne(tmp, expected, fail); + if (UseZacas) { + lw(old, aligned_addr); + + // if old & mask != expected + andr(tmp, old, mask); + bne(tmp, expected, fail); + + andr(tmp, old, not_mask); + orr(tmp, tmp, new_val); - andr(tmp, old, not_mask); - orr(tmp, tmp, new_val); - sc_w(tmp, tmp, aligned_addr, release); - bnez(tmp, fail); + atomic_cas(tmp, new_val, addr, size, acquire, release); + bne(tmp, old, fail); + } else { + lr_w(old, aligned_addr, acquire); + andr(tmp, old, mask); + bne(tmp, expected, fail); + + andr(tmp, old, not_mask); + orr(tmp, tmp, new_val); + sc_w(tmp, tmp, aligned_addr, release); + bnez(tmp, fail); + } // Success mv(result, 1); @@ -2776,6 +2811,21 @@ void MacroAssembler::cmpxchg(Register addr, Register expected, assert_different_registers(expected, t0); assert_different_registers(new_val, t0); + if (UseZacas) { + if (result_as_bool) { + mv(t0, expected); + atomic_cas(t0, new_val, addr, size, acquire, release); + xorr(t0, t0, expected); + seqz(result, t0); + } else { + if (result != expected) { + mv(result, expected); + } + atomic_cas(result, new_val, addr, size, acquire, release); + } + return; + } + Label retry_load, done, ne_done; bind(retry_load); load_reserved(addr, size, acquire); @@ -2807,6 +2857,11 @@ void MacroAssembler::cmpxchg_weak(Register addr, Register expected, enum operand_size size, Assembler::Aqrl acquire, Assembler::Aqrl release, Register result) { + if (UseZacas) { + cmpxchg(addr, expected, new_val, size, acquire, release, result, false); + return; + } + assert_different_registers(addr, t0); assert_different_registers(expected, t0); assert_different_registers(new_val, t0); @@ -2873,6 +2928,89 @@ ATOMIC_XCHGU(xchgalwu, xchgalw) #undef ATOMIC_XCHGU +#define ATOMIC_CAS(OP, AOP, ACQUIRE, RELEASE) \ +void MacroAssembler::atomic_##OP(Register prev, Register newv, Register addr) { \ + assert(UseZacas, "invariant"); \ + prev = prev->is_valid() ? prev : zr; \ + AOP(prev, addr, newv, (Assembler::Aqrl)(ACQUIRE | RELEASE)); \ + return; \ +} + +ATOMIC_CAS(cas, amocas_d, Assembler::relaxed, Assembler::relaxed) +ATOMIC_CAS(casw, amocas_w, Assembler::relaxed, Assembler::relaxed) +ATOMIC_CAS(casl, amocas_d, Assembler::relaxed, Assembler::rl) +ATOMIC_CAS(caslw, amocas_w, Assembler::relaxed, Assembler::rl) +ATOMIC_CAS(casal, amocas_d, Assembler::aq, Assembler::rl) +ATOMIC_CAS(casalw, amocas_w, Assembler::aq, Assembler::rl) + +#undef ATOMIC_CAS + +#define ATOMIC_CASU(OP1, OP2) \ +void MacroAssembler::atomic_##OP1(Register prev, Register newv, Register addr) { \ + atomic_##OP2(prev, newv, addr); \ + zero_extend(prev, prev, 32); \ + return; \ +} + +ATOMIC_CASU(caswu, casw) +ATOMIC_CASU(caslwu, caslw) +ATOMIC_CASU(casalwu, casalw) + +#undef ATOMIC_CASU + +void MacroAssembler::atomic_cas( + Register prev, Register newv, Register addr, enum operand_size size, Assembler::Aqrl acquire, Assembler::Aqrl release) { + switch (size) { + case int64: + switch ((Assembler::Aqrl)(acquire | release)) { + case Assembler::relaxed: + atomic_cas(prev, newv, addr); + break; + case Assembler::rl: + atomic_casl(prev, newv, addr); + break; + case Assembler::aqrl: + atomic_casal(prev, newv, addr); + break; + default: + ShouldNotReachHere(); + } + break; + case int32: + switch ((Assembler::Aqrl)(acquire | release)) { + case Assembler::relaxed: + atomic_casw(prev, newv, addr); + break; + case Assembler::rl: + atomic_caslw(prev, newv, addr); + break; + case Assembler::aqrl: + atomic_casalw(prev, newv, addr); + break; + default: + ShouldNotReachHere(); + } + break; + case uint32: + switch ((Assembler::Aqrl)(acquire | release)) { + case Assembler::relaxed: + atomic_caswu(prev, newv, addr); + break; + case Assembler::rl: + atomic_caslwu(prev, newv, addr); + break; + case Assembler::aqrl: + atomic_casalwu(prev, newv, addr); + break; + default: + ShouldNotReachHere(); + } + break; + default: + ShouldNotReachHere(); + } +} + void MacroAssembler::far_jump(Address entry, Register tmp) { assert(ReservedCodeCacheSize < 4*G, "branch out of range"); assert(CodeCache::find_blob(entry.target()) != nullptr, diff --git a/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp b/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp index 09c5b21562ae3..e264f27e4cc0a 100644 --- a/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp +++ b/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp @@ -1046,6 +1046,19 @@ class MacroAssembler: public Assembler { void atomic_xchgwu(Register prev, Register newv, Register addr); void atomic_xchgalwu(Register prev, Register newv, Register addr); + void atomic_cas(Register prev, Register newv, Register addr); + void atomic_casw(Register prev, Register newv, Register addr); + void atomic_casl(Register prev, Register newv, Register addr); + void atomic_caslw(Register prev, Register newv, Register addr); + void atomic_casal(Register prev, Register newv, Register addr); + void atomic_casalw(Register prev, Register newv, Register addr); + void atomic_caswu(Register prev, Register newv, Register addr); + void atomic_caslwu(Register prev, Register newv, Register addr); + void atomic_casalwu(Register prev, Register newv, Register addr); + + void atomic_cas(Register prev, Register newv, Register addr, enum operand_size size, + Assembler::Aqrl acquire = Assembler::relaxed, Assembler::Aqrl release = Assembler::relaxed); + static bool far_branches() { return ReservedCodeCacheSize > branch_range; } diff --git a/src/hotspot/cpu/riscv/vm_version_riscv.hpp b/src/hotspot/cpu/riscv/vm_version_riscv.hpp index 39c4150cea8e9..5b6a348753e93 100644 --- a/src/hotspot/cpu/riscv/vm_version_riscv.hpp +++ b/src/hotspot/cpu/riscv/vm_version_riscv.hpp @@ -135,6 +135,7 @@ class VM_Version : public Abstract_VM_Version { decl(ext_Zifencei , "Zifencei" , RV_NO_FLAG_BIT, true , NO_UPDATE_DEFAULT) \ decl(ext_Zic64b , "Zic64b" , RV_NO_FLAG_BIT, true , UPDATE_DEFAULT(UseZic64b)) \ decl(ext_Zihintpause , "Zihintpause" , RV_NO_FLAG_BIT, true , UPDATE_DEFAULT(UseZihintpause)) \ + decl(ext_Zacas , "Zacas" , RV_NO_FLAG_BIT, true , UPDATE_DEFAULT(UseZacas)) \ decl(mvendorid , "VendorId" , RV_NO_FLAG_BIT, false, NO_UPDATE_DEFAULT) \ decl(marchid , "ArchId" , RV_NO_FLAG_BIT, false, NO_UPDATE_DEFAULT) \ decl(mimpid , "ImpId" , RV_NO_FLAG_BIT, false, NO_UPDATE_DEFAULT) \ diff --git a/src/hotspot/os_cpu/linux_riscv/vm_version_linux_riscv.cpp b/src/hotspot/os_cpu/linux_riscv/vm_version_linux_riscv.cpp index 54c8ae13bfa71..4532cd4133a14 100644 --- a/src/hotspot/os_cpu/linux_riscv/vm_version_linux_riscv.cpp +++ b/src/hotspot/os_cpu/linux_riscv/vm_version_linux_riscv.cpp @@ -245,6 +245,7 @@ void VM_Version::rivos_features() { ext_Zifencei.enable_feature(); ext_Zic64b.enable_feature(); ext_Zihintpause.enable_feature(); + ext_Zacas.enable_feature(); unaligned_access.enable_feature(MISALIGNED_FAST); satp_mode.enable_feature(VM_SV48); From 69a6c52f56d7b055731cbd5e622c7ebeccb4edbf Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Fri, 8 Sep 2023 14:05:35 +0200 Subject: [PATCH 74/85] Disable conservative fences on Rivos hardware (#131) --- src/hotspot/cpu/riscv/vm_version_riscv.cpp | 11 +++++++++++ src/hotspot/cpu/riscv/vm_version_riscv.hpp | 6 ++++++ .../os_cpu/linux_riscv/vm_version_linux_riscv.cpp | 5 +---- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/hotspot/cpu/riscv/vm_version_riscv.cpp b/src/hotspot/cpu/riscv/vm_version_riscv.cpp index 1ba4dbbdc8314..37a49732ee35d 100644 --- a/src/hotspot/cpu/riscv/vm_version_riscv.cpp +++ b/src/hotspot/cpu/riscv/vm_version_riscv.cpp @@ -99,6 +99,17 @@ void VM_Version::initialize() { } } + // Enable vendor specific features + + if (mvendorid.enabled()) { + // Rivos + if (mvendorid.value() == RIVOS) { + if (FLAG_IS_DEFAULT(UseConservativeFence)) { + FLAG_SET_DEFAULT(UseConservativeFence, false); + } + } + } + if (UseZic64b) { if (CacheLineSize != 64) { assert(!FLAG_IS_DEFAULT(CacheLineSize), "default cache line size should be 64 bytes"); diff --git a/src/hotspot/cpu/riscv/vm_version_riscv.hpp b/src/hotspot/cpu/riscv/vm_version_riscv.hpp index 5b6a348753e93..561ddf4595dd3 100644 --- a/src/hotspot/cpu/riscv/vm_version_riscv.hpp +++ b/src/hotspot/cpu/riscv/vm_version_riscv.hpp @@ -40,6 +40,12 @@ class RiscvHwprobe; class VM_Version : public Abstract_VM_Version { friend RiscvHwprobe; private: + + // JEDEC encoded as ((bank - 1) << 7) | (0x7f & JEDEC) + enum VendorId { + RIVOS = 0x6cf, // JEDEC: 0x4f, Bank: 14 + }; + class RVFeatureValue { const char* const _pretty; const bool _feature_string; diff --git a/src/hotspot/os_cpu/linux_riscv/vm_version_linux_riscv.cpp b/src/hotspot/os_cpu/linux_riscv/vm_version_linux_riscv.cpp index 4532cd4133a14..f54fb6307c868 100644 --- a/src/hotspot/os_cpu/linux_riscv/vm_version_linux_riscv.cpp +++ b/src/hotspot/os_cpu/linux_riscv/vm_version_linux_riscv.cpp @@ -207,14 +207,11 @@ char* VM_Version::os_uarch_additional_features() { } void VM_Version::vendor_features() { - // JEDEC encoded as ((bank - 1) << 7) | (0x7f & JEDEC) - static constexpr int RIVOS_MVENDORID = 0x6cf; // JEDEC: 0x4f, Bank: 14 - if (!mvendorid.enabled()) { return; } switch (mvendorid.value()) { - case RIVOS_MVENDORID: + case RIVOS: rivos_features(); break; default: From 89f266ebcab36a66241b030cf303d7d27d3a1a04 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Fri, 8 Sep 2023 15:14:49 +0200 Subject: [PATCH 75/85] Add CODEOWNERS file for default PR reviewers (#134) --- CODEOWNERS | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 CODEOWNERS diff --git a/CODEOWNERS b/CODEOWNERS new file mode 100644 index 0000000000000..f36d1b8fb7bb4 --- /dev/null +++ b/CODEOWNERS @@ -0,0 +1,2 @@ +# Default owners to managed runtimes team +* @rivosinc/managed-runtimes From 7fe63d43996217fd1118566f0d4c7ed95fc8a419 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Fri, 8 Sep 2023 15:15:10 +0200 Subject: [PATCH 76/85] Remove duplicated update to UseUnalignedAccesses (#133) It's a leftover from a downstreaming merge --- src/hotspot/cpu/riscv/vm_version_riscv.cpp | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/hotspot/cpu/riscv/vm_version_riscv.cpp b/src/hotspot/cpu/riscv/vm_version_riscv.cpp index 37a49732ee35d..bdeffadb3fe61 100644 --- a/src/hotspot/cpu/riscv/vm_version_riscv.cpp +++ b/src/hotspot/cpu/riscv/vm_version_riscv.cpp @@ -249,13 +249,6 @@ void VM_Version::initialize() { FLAG_SET_DEFAULT(UseBlockZeroing, false); } - // This machine allows unaligned memory accesses - if (FLAG_IS_DEFAULT(UseUnalignedAccesses)) { - FLAG_SET_DEFAULT(UseUnalignedAccesses, - unaligned_access.value() != MISALIGNED_UNKNOWN && - unaligned_access.value() != MISALIGNED_UNSUPPORTED); - } - #ifdef COMPILER2 c2_initialize(); #endif // COMPILER2 From 9173bf3befcc42ff7a54e6292c148638a8c8c8a0 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Fri, 22 Sep 2023 15:43:28 +0200 Subject: [PATCH 77/85] Re-add conservative fence when UseConservativeFence is set (#137) It was moved as part of the Ztso support --- src/hotspot/cpu/riscv/macroAssembler_riscv.hpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp b/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp index 3205ea80e2644..31f012b3d7a3d 100644 --- a/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp +++ b/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp @@ -361,6 +361,15 @@ class MacroAssembler: public Assembler { uint32_t& predecessor, uint32_t& successor) { predecessor = (order_constraint >> 2) & 0x3; successor = order_constraint & 0x3; + + // extend rw -> iorw: + // 01(w) -> 0101(ow) + // 10(r) -> 1010(ir) + // 11(rw)-> 1111(iorw) + if (UseConservativeFence) { + predecessor |= predecessor << 2; + successor |= successor << 2; + } } static int pred_succ_to_membar_mask(uint32_t predecessor, uint32_t successor) { From 9b38817181393490499ba8c6e18829e81155b838 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Mon, 23 Oct 2023 09:44:49 +0200 Subject: [PATCH 78/85] Bump build jdk version (#142) --- rivos/gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rivos/gitlab-ci.yml b/rivos/gitlab-ci.yml index 2bb3389ebfb58..072f62dae66c3 100644 --- a/rivos/gitlab-ci.yml +++ b/rivos/gitlab-ci.yml @@ -6,7 +6,7 @@ include: variables: CACHE_VERSION: "v6" - BUILD_JDK_VERSION: "20" + BUILD_JDK_VERSION: "21" BINUTILS_VERSION: "2.38" GTEST_TAG: "v1.14.0" JTREG_VERSION: "7.3.1+1" From ff334da55f58ad85070c54218cac2d70c93ac7d7 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Tue, 31 Oct 2023 13:22:30 +0100 Subject: [PATCH 79/85] Use rivos-sdk sysroot to cross-compile JDK (#144) --- rivos/configure-riscv64.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rivos/configure-riscv64.sh b/rivos/configure-riscv64.sh index 0d663b334e579..7a5ec73ae3c31 100755 --- a/rivos/configure-riscv64.sh +++ b/rivos/configure-riscv64.sh @@ -6,7 +6,7 @@ ARGS=( --with-build-jdk=/rivos/jdk # --with-debug-level=slowdebug --with-zlib=system - --with-sysroot=/sysroot/focal-riscv64 + --with-sysroot=/rivos/sysroot/riscv --with-jmh=/workspace/jmh/build/images/jmh --with-jtreg=/workspace/jtreg/build/images/jtreg --with-hsdis=binutils --with-binutils-src=/workspace/binutils --enable-hsdis-bundling From da7b749692e9e34461de9aa2755e2e9b43fbabd3 Mon Sep 17 00:00:00 2001 From: Robbin Ehn Date: Mon, 13 Nov 2023 10:48:57 +0100 Subject: [PATCH 80/85] Fix hsdis binutils compilation (#147) It is now identical to upstream. --- src/utils/hsdis/binutils/hsdis-binutils.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/utils/hsdis/binutils/hsdis-binutils.c b/src/utils/hsdis/binutils/hsdis-binutils.c index c005422a3df85..d011dc579b5dd 100644 --- a/src/utils/hsdis/binutils/hsdis-binutils.c +++ b/src/utils/hsdis/binutils/hsdis-binutils.c @@ -60,7 +60,6 @@ #endif #include -#include #include #include "hsdis.h" @@ -591,9 +590,7 @@ static void init_disassemble_info_from_bfd(struct disassemble_info* dinfo, dinfo->flavour = bfd_get_flavour(abfd); dinfo->arch = bfd_get_arch(abfd); dinfo->mach = bfd_get_mach(abfd); - dinfo->disassembler_options = - disassembler_options != NULL && disassembler_options[0] != '\0' ? - disassembler_options : NULL; + dinfo->disassembler_options = disassembler_options; #ifdef SEC_ELF_OCTETS /* bfd_octets_per_byte() has 2 args since binutils 2.34 */ dinfo->octets_per_byte = bfd_octets_per_byte (abfd, NULL); From 5ee8012b884dbecf81cc5c86088a8bfa5f4cd412 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Mon, 20 Nov 2023 14:07:21 +0100 Subject: [PATCH 81/85] Remove testing on GHA (#149) It now matches what's done upstream. By reducing the diff, we make it easier to downstream anything. Testing also happens on Gitlab anyway. --- .github/actions/create-sysroot/action.yml | 84 ------- .github/actions/get-bundles/action.yml | 38 ++- .../init-platform-variables/action.yml | 93 ------- .github/workflows/build-cross-compile.yml | 126 ++++++---- .github/workflows/main.yml | 121 +-------- .github/workflows/test-cross-compile.yml | 238 ------------------ 6 files changed, 94 insertions(+), 606 deletions(-) delete mode 100644 .github/actions/create-sysroot/action.yml delete mode 100644 .github/actions/init-platform-variables/action.yml delete mode 100644 .github/workflows/test-cross-compile.yml diff --git a/.github/actions/create-sysroot/action.yml b/.github/actions/create-sysroot/action.yml deleted file mode 100644 index 54603eaa1e3fe..0000000000000 --- a/.github/actions/create-sysroot/action.yml +++ /dev/null @@ -1,84 +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. 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: 'Create sysroot' -description: 'Create the sysroot to cross-compile and test the OpenJDK' -inputs: - target-cpu: - description: 'Target CPU architecture' - required: true - gnu-arch: - description: 'GNU CPU architecture' - required: true - debian-arch: - description: 'Debian CPU architecture' - required: true - debian-repository: - description: 'Debian repository' - required: true - debian-version: - description: 'Debian version' - required: true - debian-keyring: - description: 'Debian keyring' - required: false - -runs: - using: composite - steps: - - name: 'Check cache for sysroot' - id: get-cached-sysroot - uses: actions/cache@v3 - with: - path: sysroot - key: sysroot-${{ inputs.debian-arch }}-${{ inputs.debian-version }}-${{ hashFiles('./.github/actions/create-sysroot/action.yml') }} - - - name: 'Install sysroot dependencies' - run: sudo apt-get install debootstrap qemu-user-static - shell: bash - if: steps.get-cached-sysroot.outputs.cache-hit != 'true' - - - name: 'Create sysroot' - run: > - sudo debootstrap - --arch=${{ inputs.debian-arch }} - --verbose - --include=fakeroot,symlinks,build-essential,make,libx11-dev,libxext-dev,libxrender-dev,libxrandr-dev,libxtst-dev,libxt-dev,libcups2-dev,libfontconfig1-dev,libasound2-dev,libfreetype-dev,libpng-dev,libatomic1 - --resolve-deps - --variant=minbase - $(test -n "${{ inputs.debian-keyring }}" && echo "--keyring=${{ inputs.debian-keyring }}") - ${{ inputs.debian-version }} - sysroot - ${{ inputs.debian-repository }} - shell: bash - if: steps.get-cached-sysroot.outputs.cache-hit != 'true' - - - name: 'Prepare sysroot' - run: | - # Prepare sysroot and remove unused files to minimize cache - sudo chroot sysroot symlinks -cr . - sudo rm -rf sysroot/{dev,proc,run,sys} - shell: bash - if: steps.get-cached-sysroot.outputs.cache-hit != 'true' diff --git a/.github/actions/get-bundles/action.yml b/.github/actions/get-bundles/action.yml index 4ee56d2b99336..956e1520cfbaa 100644 --- a/.github/actions/get-bundles/action.yml +++ b/.github/actions/get-bundles/action.yml @@ -32,10 +32,6 @@ inputs: debug-suffix: description: 'File name suffix denoting debug level, possibly empty' required: false - path: - description: 'Path to the installed JDK bundle' - required: false - default: 'bundles' outputs: jdk-path: description: 'Path to the installed JDK bundle' @@ -55,40 +51,40 @@ runs: uses: actions/download-artifact@v3 with: name: bundles-${{ inputs.platform }}${{ inputs.debug-suffix }} - path: ${{ inputs.path }} + path: bundles continue-on-error: true - name: 'Download bundles artifact (retry)' uses: actions/download-artifact@v3 with: name: bundles-${{ inputs.platform }}${{ inputs.debug-suffix }} - path: ${{ inputs.path }} + path: bundles if: steps.download-bundles.outcome == 'failure' - name: 'Unpack bundles' run: | - if [[ -e ${{ inputs.path }}/jdk-${{ inputs.platform }}${{ inputs.debug-suffix }}.zip ]]; then + if [[ -e bundles/jdk-${{ inputs.platform }}${{ inputs.debug-suffix }}.zip ]]; then echo 'Unpacking jdk bundle...' - mkdir -p ${{ inputs.path }}/jdk - unzip -q ${{ inputs.path }}/jdk-${{ inputs.platform }}${{ inputs.debug-suffix }}.zip -d ${{ inputs.path }}/jdk + mkdir -p bundles/jdk + unzip -q bundles/jdk-${{ inputs.platform }}${{ inputs.debug-suffix }}.zip -d bundles/jdk fi - if [[ -e ${{ inputs.path }}/jdk-${{ inputs.platform }}${{ inputs.debug-suffix }}.tar.gz ]]; then + if [[ -e bundles/jdk-${{ inputs.platform }}${{ inputs.debug-suffix }}.tar.gz ]]; then echo 'Unpacking jdk bundle...' - mkdir -p ${{ inputs.path }}/jdk - tar -xf ${{ inputs.path }}/jdk-${{ inputs.platform }}${{ inputs.debug-suffix }}.tar.gz -C ${{ inputs.path }}/jdk + mkdir -p bundles/jdk + tar -xf bundles/jdk-${{ inputs.platform }}${{ inputs.debug-suffix }}.tar.gz -C bundles/jdk fi - if [[ -e ${{ inputs.path }}/symbols-${{ inputs.platform }}${{ inputs.debug-suffix }}.tar.gz ]]; then + if [[ -e bundles/symbols-${{ inputs.platform }}${{ inputs.debug-suffix }}.tar.gz ]]; then echo 'Unpacking symbols bundle...' - mkdir -p ${{ inputs.path }}/symbols - tar -xf ${{ inputs.path }}/symbols-${{ inputs.platform }}${{ inputs.debug-suffix }}.tar.gz -C ${{ inputs.path }}/symbols + mkdir -p bundles/symbols + tar -xf bundles/symbols-${{ inputs.platform }}${{ inputs.debug-suffix }}.tar.gz -C bundles/symbols fi - if [[ -e ${{ inputs.path }}/tests-${{ inputs.platform }}${{ inputs.debug-suffix }}.tar.gz ]]; then + if [[ -e bundles/tests-${{ inputs.platform }}${{ inputs.debug-suffix }}.tar.gz ]]; then echo 'Unpacking tests bundle...' - mkdir -p ${{ inputs.path }}/tests - tar -xf ${{ inputs.path }}/tests-${{ inputs.platform }}${{ inputs.debug-suffix }}.tar.gz -C ${{ inputs.path }}/tests + mkdir -p bundles/tests + tar -xf bundles/tests-${{ inputs.platform }}${{ inputs.debug-suffix }}.tar.gz -C bundles/tests fi shell: bash @@ -97,9 +93,9 @@ runs: run: | # Export the paths - jdk_dir="$GITHUB_WORKSPACE/$(dirname $(find ${{ inputs.path }}/jdk -name bin -type d))" - symbols_dir="$GITHUB_WORKSPACE/$(dirname $(find ${{ inputs.path }}/symbols -name bin -type d))" - tests_dir="$GITHUB_WORKSPACE/${{ inputs.path }}/tests" + jdk_dir="$GITHUB_WORKSPACE/$(dirname $(find bundles/jdk -name bin -type d))" + symbols_dir="$GITHUB_WORKSPACE/$(dirname $(find bundles/symbols -name bin -type d))" + tests_dir="$GITHUB_WORKSPACE/bundles/tests" if [[ '${{ runner.os }}' == 'Windows' ]]; then jdk_dir="$(cygpath $jdk_dir)" diff --git a/.github/actions/init-platform-variables/action.yml b/.github/actions/init-platform-variables/action.yml deleted file mode 100644 index 6cc056f55936c..0000000000000 --- a/.github/actions/init-platform-variables/action.yml +++ /dev/null @@ -1,93 +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. 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: 'Initialize Platform Variables' -description: 'Initialize the platform-specific variables used for cross-compilation' -inputs: - platform: - description: 'Target Platform' - required: true -outputs: - target-cpu: - description: 'Target CPU Archictecture' - value: ${{ steps.platform-variables.outputs.target-cpu }} - gnu-arch: - description: 'Target GNU Architecture' - value: ${{ steps.platform-variables.outputs.gnu-arch }} - debian-arch: - description: 'Target Debian Architecture' - value: ${{ steps.platform-variables.outputs.debian-arch }} - debian-repository: - description: 'Target Debian Repository' - value: ${{ steps.platform-variables.outputs.debian-repository }} - debian-version: - description: 'Target Debian Version' - value: ${{ steps.platform-variables.outputs.debian-version }} - gnu-abi: - description: 'Target GNU ABI' - value: ${{ steps.platform-variables.outputs.gnu-abi }} - -runs: - using: composite - steps: - - name: 'Initialize platform variables' - id: platform-variables - run: | - if [[ '${{ inputs.platform }}' == 'linux-aarch64' ]]; then - echo "target-cpu=aarch64" >> $GITHUB_OUTPUT - echo "gnu-arch=aarch64" >> $GITHUB_OUTPUT - echo "debian-arch=arm64" >> $GITHUB_OUTPUT - echo "debian-repository=https://httpredir.debian.org/debian/" >> $GITHUB_OUTPUT - echo "debian-version=bullseye" >> $GITHUB_OUTPUT - elif [[ '${{ inputs.platform }}' == 'linux-arm' ]]; then - echo "target-cpu=arm" >> $GITHUB_OUTPUT - echo "gnu-arch=arm" >> $GITHUB_OUTPUT - echo "gnu-abi=eabihf" >> $GITHUB_OUTPUT - echo "debian-arch=armhf" >> $GITHUB_OUTPUT - echo "debian-repository=https://httpredir.debian.org/debian/" >> $GITHUB_OUTPUT - echo "debian-version=bullseye" >> $GITHUB_OUTPUT - elif [[ '${{ inputs.platform }}' == 'linux-s390x' ]]; then - echo "target-cpu=s390x" >> $GITHUB_OUTPUT - echo "gnu-arch=s390x" >> $GITHUB_OUTPUT - echo "debian-arch=s390x" >> $GITHUB_OUTPUT - echo "debian-repository=https://httpredir.debian.org/debian/" >> $GITHUB_OUTPUT - echo "debian-version=bullseye" >> $GITHUB_OUTPUT - elif [[ '${{ inputs.platform }}' == 'linux-ppc64le' ]]; then - echo "target-cpu=ppc64le" >> $GITHUB_OUTPUT - echo "gnu-arch=powerpc64le" >> $GITHUB_OUTPUT - echo "debian-arch=ppc64el" >> $GITHUB_OUTPUT - echo "debian-repository=https://httpredir.debian.org/debian/" >> $GITHUB_OUTPUT - echo "debian-version=bullseye" >> $GITHUB_OUTPUT - elif [[ '${{ inputs.platform }}' == 'linux-riscv64' ]]; then - echo "target-cpu=riscv64" >> $GITHUB_OUTPUT - echo "gnu-arch=riscv64" >> $GITHUB_OUTPUT - echo "debian-arch=riscv64" >> $GITHUB_OUTPUT - echo "debian-repository=https://httpredir.debian.org/debian/" >> $GITHUB_OUTPUT - echo "debian-version=sid" >> $GITHUB_OUTPUT - else - echo "Unknown platform ${{ inputs.platform }}" - exit 1 - fi - shell: bash diff --git a/.github/workflows/build-cross-compile.yml b/.github/workflows/build-cross-compile.yml index 22168ac8173ee..5db69f07d98c5 100644 --- a/.github/workflows/build-cross-compile.yml +++ b/.github/workflows/build-cross-compile.yml @@ -28,9 +28,6 @@ name: 'Build (cross-compile)' on: workflow_call: inputs: - platform: - required: true - type: string gcc-major-version: required: true type: string @@ -43,14 +40,6 @@ on: make-arguments: required: false type: string - make-target: - required: false - type: string - default: 'product-bundles test-bundles' - debug-levels: - required: false - type: string - default: '[ "debug", "release" ]' jobs: build-cross-compile: @@ -60,11 +49,39 @@ jobs: strategy: fail-fast: false matrix: - debug-level: ${{ fromJSON(inputs.debug-levels) }} + target-cpu: + - aarch64 + - arm + - s390x + - ppc64le + - riscv64 include: - - debug-level: debug - flags: --with-debug-level=fastdebug - suffix: -debug + - target-cpu: aarch64 + gnu-arch: aarch64 + debian-arch: arm64 + debian-repository: https://httpredir.debian.org/debian/ + debian-version: bullseye + - target-cpu: arm + gnu-arch: arm + debian-arch: armhf + debian-repository: https://httpredir.debian.org/debian/ + debian-version: bullseye + gnu-abi: eabihf + - target-cpu: s390x + gnu-arch: s390x + debian-arch: s390x + debian-repository: https://httpredir.debian.org/debian/ + debian-version: bullseye + - target-cpu: ppc64le + gnu-arch: powerpc64le + debian-arch: ppc64el + debian-repository: https://httpredir.debian.org/debian/ + debian-version: bullseye + - target-cpu: riscv64 + gnu-arch: riscv64 + debian-arch: riscv64 + debian-repository: https://httpredir.debian.org/debian/ + debian-version: sid steps: - name: 'Checkout the JDK source' @@ -82,17 +99,6 @@ jobs: uses: ./.github/actions/get-bundles with: platform: linux-x64 - path: buildjdk - - - name: 'Initialize platform variables' - id: platform-variables - uses: ./.github/actions/init-platform-variables - with: - platform: ${{ inputs.platform }} - - - name: 'Get JTReg' - id: jtreg - uses: ./.github/actions/get-jtreg - name: 'Get GTest' id: gtest @@ -107,39 +113,62 @@ jobs: sudo apt-get install \ gcc-${{ inputs.gcc-major-version }} \ g++-${{ inputs.gcc-major-version }} \ - gcc-${{ inputs.gcc-major-version }}-${{ steps.platform-variables.outputs.gnu-arch }}-linux-gnu${{ steps.platform-variables.outputs.gnu-abi }} \ - g++-${{ inputs.gcc-major-version }}-${{ steps.platform-variables.outputs.gnu-arch }}-linux-gnu${{ steps.platform-variables.outputs.gnu-abi }} \ + gcc-${{ inputs.gcc-major-version }}-${{ matrix.gnu-arch }}-linux-gnu${{ matrix.gnu-abi}} \ + g++-${{ inputs.gcc-major-version }}-${{ matrix.gnu-arch }}-linux-gnu${{ matrix.gnu-abi}} \ libxrandr-dev libxtst-dev libcups2-dev libasound2-dev sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-${{ inputs.gcc-major-version }} 100 --slave /usr/bin/g++ g++ /usr/bin/g++-${{ inputs.gcc-major-version }} - - name: 'Create sysroot' - uses: ./.github/actions/create-sysroot + - name: 'Check cache for sysroot' + id: get-cached-sysroot + uses: actions/cache@v3 with: - target-cpu: ${{ steps.platform-variables.outputs.target-cpu }} - gnu-arch: ${{ steps.platform-variables.outputs.gnu-arch }} - debian-arch: ${{ steps.platform-variables.outputs.debian-arch }} - debian-repository: ${{ steps.platform-variables.outputs.debian-repository }} - debian-version: ${{ steps.platform-variables.outputs.debian-version }} - debian-keyring: ${{ steps.platform-variables.outputs.debian-keyring }} + path: sysroot + key: sysroot-${{ matrix.debian-arch }}-${{ hashFiles('./.github/workflows/build-cross-compile.yml') }} + + - name: 'Install sysroot dependencies' + run: sudo apt-get install debootstrap qemu-user-static + if: steps.get-cached-sysroot.outputs.cache-hit != 'true' + + - name: 'Create sysroot' + run: > + sudo debootstrap + --arch=${{ matrix.debian-arch }} + --verbose + --include=fakeroot,symlinks,build-essential,libx11-dev,libxext-dev,libxrender-dev,libxrandr-dev,libxtst-dev,libxt-dev,libcups2-dev,libfontconfig1-dev,libasound2-dev,libfreetype-dev,libpng-dev + --resolve-deps + --variant=minbase + ${{ matrix.debian-version }} + sysroot + ${{ matrix.debian-repository }} + if: steps.get-cached-sysroot.outputs.cache-hit != 'true' + + - name: 'Prepare sysroot' + run: | + # Prepare sysroot and remove unused files to minimize cache + sudo chroot sysroot symlinks -cr . + sudo chown ${USER} -R sysroot + rm -rf sysroot/{dev,proc,run,sys,var} + rm -rf sysroot/usr/{sbin,bin,share} + rm -rf sysroot/usr/lib/{apt,gcc,udev,systemd} + rm -rf sysroot/usr/libexec/gcc + if: steps.get-cached-sysroot.outputs.cache-hit != 'true' - name: 'Configure' run: > bash configure - --with-conf-name=linux-${{ steps.platform-variables.outputs.target-cpu }} - ${{ matrix.flags }} + --with-conf-name=linux-${{ matrix.target-cpu }} --with-version-opt=${GITHUB_ACTOR}-${GITHUB_SHA} --with-boot-jdk=${{ steps.bootjdk.outputs.path }} --with-gtest=${{ steps.gtest.outputs.path }} - --with-jtreg=${{ steps.jtreg.outputs.path }} - --enable-jtreg-failure-handler --with-zlib=system + --enable-debug --disable-precompiled-headers - --openjdk-target=${{ steps.platform-variables.outputs.gnu-arch }}-linux-gnu${{ steps.platform-variables.outputs.gnu-abi }} + --openjdk-target=${{ matrix.gnu-arch }}-linux-gnu${{ matrix.gnu-abi}} --with-sysroot=sysroot --with-build-jdk=${{ steps.buildjdk.outputs.jdk-path }} --with-jmod-compress=zip-1 - CC=${{ steps.platform-variables.outputs.gnu-arch }}-linux-gnu${{ steps.platform-variables.outputs.gnu-abi }}-gcc-${{ inputs.gcc-major-version }} - CXX=${{ steps.platform-variables.outputs.gnu-arch }}-linux-gnu${{ steps.platform-variables.outputs.gnu-abi }}-g++-${{ inputs.gcc-major-version }} + CC=${{ matrix.gnu-arch }}-linux-gnu${{ matrix.gnu-abi}}-gcc-${{ inputs.gcc-major-version }} + CXX=${{ matrix.gnu-arch }}-linux-gnu${{ matrix.gnu-abi}}-g++-${{ inputs.gcc-major-version }} ${{ inputs.extra-conf-options }} ${{ inputs.configure-arguments }} || ( echo "Dumping config.log:" && cat config.log && @@ -149,12 +178,5 @@ jobs: id: build uses: ./.github/actions/do-build with: - make-target: '${{ inputs.make-target }} ${{ inputs.make-arguments }}' - platform: '${{ inputs.platform }}' - debug-suffix: '${{ matrix.suffix }}' - - - name: 'Upload bundles' - uses: ./.github/actions/upload-bundles - with: - platform: '${{ inputs.platform }}' - debug-suffix: '${{ matrix.suffix }}' + make-target: 'hotspot ${{ inputs.make-arguments }}' + platform: linux-${{ matrix.target-cpu }} diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index df42200ba29db..49cbd633e6bfa 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -91,10 +91,6 @@ jobs: else input='${{ secrets.JDK_SUBMIT_PLATFORMS }}' fi - else - >&2 echo 'Internal error in GHA' - echo 'false' - return fi normalized_input="$(echo ,$input, | tr -d ' ')" @@ -215,64 +211,13 @@ jobs: make-arguments: ${{ github.event.inputs.make-arguments }} if: needs.select.outputs.linux-x64-variants == 'true' - build-linux-aarch64: - name: linux-aarch64 - needs: - - select - - build-linux-x64 - uses: ./.github/workflows/build-cross-compile.yml - with: - platform: linux-aarch64 - 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' - - build-linux-arm: - name: linux-arm - needs: - - select - - build-linux-x64 - uses: ./.github/workflows/build-cross-compile.yml - with: - platform: linux-arm - 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' - - build-linux-ppc64le: - name: linux-ppc64le - needs: - - select - - build-linux-x64 - uses: ./.github/workflows/build-cross-compile.yml - with: - platform: linux-ppc64le - gcc-major-version: '10' - if: needs.select.outputs.linux-cross-compile == 'true' - - build-linux-riscv64: - name: linux-riscv64 + build-linux-cross-compile: + name: linux-cross-compile needs: - select - build-linux-x64 uses: ./.github/workflows/build-cross-compile.yml with: - platform: linux-riscv64 - 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' - - build-linux-s390x: - name: linux-s390x - needs: - - select - - build-linux-x64 - uses: ./.github/workflows/build-cross-compile.yml - with: - platform: linux-s390x gcc-major-version: '10' configure-arguments: ${{ github.event.inputs.configure-arguments }} make-arguments: ${{ github.event.inputs.make-arguments }} @@ -367,57 +312,6 @@ jobs: bootjdk-platform: linux-x64 runs-on: ubuntu-22.04 - # test-linux-aarch64: - # name: linux-aarch64 - # needs: - # - build-linux-aarch64 - # uses: ./.github/workflows/test-cross-compile.yml - # with: - # platform: linux-aarch64 - # bootjdk-platform: linux-x64 - # runs-on: ubuntu-22.04 - - # test-linux-arm: - # name: linux-arm - # needs: - # - build-linux-arm - # uses: ./.github/workflows/test-cross-compile.yml - # with: - # platform: linux-arm - # bootjdk-platform: linux-x64 - # runs-on: ubuntu-22.04 - # if: EXTRA_TEST_PLATFORMS == 'true' - - # test-linux-ppc64le: - # name: linux-ppc64le - # needs: - # - build-linux-ppc64le - # uses: ./.github/workflows/test-cross-compile.yml - # with: - # platform: linux-ppc64le - # bootjdk-platform: linux-x64 - # runs-on: ubuntu-22.04 - - test-linux-riscv64: - name: linux-riscv64 - needs: - - build-linux-riscv64 - uses: ./.github/workflows/test-cross-compile.yml - with: - platform: linux-riscv64 - bootjdk-platform: linux-x64 - runs-on: ubuntu-22.04 - - # test-linux-s390x: - # name: linux-s390x - # needs: - # - build-linux-s390x - # uses: ./.github/workflows/test-cross-compile.yml - # with: - # platform: linux-s390x - # bootjdk-platform: linux-x64 - # runs-on: ubuntu-22.04 - test-macos-x64: name: macos-x64 needs: @@ -450,22 +344,13 @@ jobs: - build-linux-x64-hs-zero - build-linux-x64-hs-minimal - build-linux-x64-hs-optimized - - build-linux-aarch64 - - build-linux-arm - - build-linux-s390x - - build-linux-ppc64le - - build-linux-riscv64 + - build-linux-cross-compile - build-macos-x64 - build-macos-aarch64 - build-windows-x64 - build-windows-aarch64 - test-linux-x64 - test-linux-x86 - # - test-linux-aarch64 - # - test-linux-arm - # - test-linux-ppc64le - - test-linux-riscv64 - # - test-linux-s390x - test-macos-x64 - test-windows-x64 diff --git a/.github/workflows/test-cross-compile.yml b/.github/workflows/test-cross-compile.yml deleted file mode 100644 index 24d2c60f87526..0000000000000 --- a/.github/workflows/test-cross-compile.yml +++ /dev/null @@ -1,238 +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. 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: 'Run tests (cross-compile)' - -on: - workflow_call: - inputs: - platform: - required: true - type: string - bootjdk-platform: - required: true - type: string - runs-on: - required: true - type: string - -jobs: - test: - name: test - runs-on: ${{ inputs.runs-on }} - defaults: - run: - shell: bash - - strategy: - fail-fast: false - matrix: - test-name: - - 'jdk/tier1 part 1' - - 'jdk/tier1 part 2' - - 'jdk/tier1 part 3' - - 'langtools/tier1' - - 'hs/tier1 common' - - 'hs/tier1 compiler 1' - - 'hs/tier1 compiler 2' - - 'hs/tier1 compiler 3' - - 'hs/tier1 compiler not xcomp' - - 'hs/tier1 gc' - - 'hs/tier1 runtime' - - 'hs/tier1 serviceability' - - include: - - test-name: 'jdk/tier1 part 1' - test-suite: 'test/jdk/:tier1_part1' - - - test-name: 'jdk/tier1 part 2' - test-suite: 'test/jdk/:tier1_part2' - - - test-name: 'jdk/tier1 part 3' - test-suite: 'test/jdk/:tier1_part3' - - - test-name: 'langtools/tier1' - test-suite: 'test/langtools/:tier1' - - - test-name: 'hs/tier1 common' - test-suite: 'test/hotspot/jtreg/:tier1_common' - debug-suffix: -debug - - - test-name: 'hs/tier1 compiler 1' - test-suite: 'test/hotspot/jtreg/:tier1_compiler_1' - debug-suffix: -debug - - - test-name: 'hs/tier1 compiler 2' - test-suite: 'test/hotspot/jtreg/:tier1_compiler_2' - debug-suffix: -debug - - - test-name: 'hs/tier1 compiler 3' - test-suite: 'test/hotspot/jtreg/:tier1_compiler_3' - debug-suffix: -debug - - - test-name: 'hs/tier1 compiler not xcomp' - test-suite: 'test/hotspot/jtreg/:tier1_compiler_not_xcomp' - debug-suffix: -debug - - - test-name: 'hs/tier1 gc' - test-suite: 'test/hotspot/jtreg/:tier1_gc' - debug-suffix: -debug - - - test-name: 'hs/tier1 runtime' - test-suite: 'test/hotspot/jtreg/:tier1_runtime' - debug-suffix: -debug - - - test-name: 'hs/tier1 serviceability' - test-suite: 'test/hotspot/jtreg/:tier1_serviceability' - debug-suffix: -debug - - steps: - - name: 'Checkout the JDK source' - uses: actions/checkout@v3 - - - name: 'Initialize platform variables' - id: platform-variables - uses: ./.github/actions/init-platform-variables - with: - platform: ${{ inputs.platform }} - - - name: 'Get the BootJDK' - id: bootjdk - uses: ./.github/actions/get-bootjdk - with: - platform: ${{ inputs.bootjdk-platform }} - - - name: 'Get JTReg' - id: jtreg - uses: ./.github/actions/get-jtreg - - - name: 'Get bundles' - id: bundles - uses: ./.github/actions/get-bundles - with: - platform: ${{ inputs.platform }} - debug-suffix: ${{ matrix.debug-suffix }} - - - name: 'Install dependencies' - run: | - sudo apt-get update - sudo apt-get install qemu-user-static - - - name: 'Create sysroot' - uses: ./.github/actions/create-sysroot - with: - target-cpu: ${{ steps.platform-variables.outputs.target-cpu }} - gnu-arch: ${{ steps.platform-variables.outputs.gnu-arch }} - debian-arch: ${{ steps.platform-variables.outputs.debian-arch }} - debian-repository: ${{ steps.platform-variables.outputs.debian-repository }} - debian-version: sid # it's necessary to get libc 2.34 - debian-keyring: ${{ steps.platform-variables.outputs.debian-keyring }} - - - name: 'Mount folders in sysroot' - run: | - sudo mkdir -p sysroot/dev sysroot/proc sysroot/run sysroot/sys sysroot/usr/lib64 sysroot/usr/lib/x86_64-linux-gnu sysroot/home/runner - sudo ln -s -r sysroot/usr/lib64 sysroot/lib64 - sudo chown $(id -u):$(id -g) sysroot/home/runner - sudo mount --bind /dev sysroot/dev - sudo mount --bind /proc sysroot/proc - sudo mount --bind /run sysroot/run - sudo mount --bind /sys sysroot/sys - sudo mount --bind /usr/lib64 sysroot/usr/lib64 - sudo mount --bind /usr/lib/x86_64-linux-gnu sysroot/usr/lib/x86_64-linux-gnu - sudo mount --bind /home/runner sysroot/home/runner - - - name: 'Run tests' - id: run-tests - run: > - sudo chroot --userspec=$(id -u):$(id -g) sysroot bash -x -c " - cd $GITHUB_WORKSPACE; - make test-prebuilt - TEST='${{ matrix.test-suite }}' - BOOT_JDK=${{ steps.bootjdk.outputs.path }} - JT_HOME=${{ steps.jtreg.outputs.path }} - JDK_IMAGE_DIR=${{ steps.bundles.outputs.jdk-path }} - SYMBOLS_IMAGE_DIR=${{ steps.bundles.outputs.symbols-path }} - TEST_IMAGE_DIR=${{ steps.bundles.outputs.tests-path }} - JTREG='JAVA_OPTIONS=-XX:-CreateCoredumpOnCrash;VERBOSE=fail,error,time;KEYWORDS=!headful;TIMEOUT_FACTOR=8' - JTREG_EXTRA_PROBLEM_LISTS='ProblemList-GHA.txt' - && bash ./.github/scripts/gen-test-summary.sh "$GITHUB_STEP_SUMMARY" - " - - - name: 'Umount folders in sysroot' - run: | - sudo rm sysroot/lib64 - sudo umount -l sysroot/dev - sudo umount -l sysroot/proc - sudo umount -l sysroot/run - sudo umount -l sysroot/sys - sudo umount -l sysroot/usr/lib64 - sudo umount -l sysroot/usr/lib/x86_64-linux-gnu - sudo umount -l sysroot/home/runner - - # This is a separate step, since if the markdown from a step gets bigger than - # 1024 kB it is skipped, but then the short summary above is still generated - - name: 'Generate test report' - run: bash ./.github/scripts/gen-test-results.sh "$GITHUB_STEP_SUMMARY" - if: always() - - - name: 'Package test results' - id: package - run: | - # Package test-results and relevant parts of test-support - mkdir results - - if [[ -d build/run-test-prebuilt/test-results ]]; then - cd build/run-test-prebuilt/test-results/ - zip -r -9 "$GITHUB_WORKSPACE/results/test-results.zip" . - cd $GITHUB_WORKSPACE - else - echo '::warning ::Missing test-results directory' - fi - - if [[ -d build/run-test-prebuilt/test-support ]]; then - cd build/run-test-prebuilt/test-support/ - zip -r -9 "$GITHUB_WORKSPACE/results/test-support.zip" . -i *.jtr -i */hs_err*.log -i */replay*.log - cd $GITHUB_WORKSPACE - else - echo '::warning ::Missing test-support directory' - fi - - artifact_name="results-${{ inputs.platform }}-$(echo ${{ matrix.test-name }} | tr '/ ' '__')" - echo "artifact-name=$artifact_name" >> $GITHUB_OUTPUT - if: always() - - - name: 'Upload test results' - uses: actions/upload-artifact@v3 - with: - path: results - name: ${{ steps.package.outputs.artifact-name }} - if: always() - - # This is the best way I found to abort the job with an error message - - name: 'Notify about test failures' - uses: actions/github-script@v6 - with: - script: core.setFailed('${{ steps.run-tests.outputs.error-message }}') - if: always() && steps.run-tests.outputs.failure == 'true' From 828480046c02543394d358380785b8df6b67d5d3 Mon Sep 17 00:00:00 2001 From: Robbin Ehn Date: Mon, 11 Dec 2023 12:51:34 +0100 Subject: [PATCH 82/85] Don't enable zacas (#154) --- src/hotspot/os_cpu/linux_riscv/vm_version_linux_riscv.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/hotspot/os_cpu/linux_riscv/vm_version_linux_riscv.cpp b/src/hotspot/os_cpu/linux_riscv/vm_version_linux_riscv.cpp index 3b8654a9d7162..6e93406b1a353 100644 --- a/src/hotspot/os_cpu/linux_riscv/vm_version_linux_riscv.cpp +++ b/src/hotspot/os_cpu/linux_riscv/vm_version_linux_riscv.cpp @@ -245,7 +245,6 @@ void VM_Version::rivos_features() { ext_Zic64b.enable_feature(); ext_Ztso.enable_feature(); ext_Zihintpause.enable_feature(); - ext_Zacas.enable_feature(); unaligned_access.enable_feature(MISALIGNED_FAST); satp_mode.enable_feature(VM_SV48); From 61691d9d073e7360fcaceb56b2d5145c24f604ab Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Tue, 12 Dec 2023 22:07:23 +0100 Subject: [PATCH 83/85] Update run-tests.sh (#155) --- run-tests.sh | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/run-tests.sh b/run-tests.sh index a8cb88c99c42f..84a6b82594021 100644 --- a/run-tests.sh +++ b/run-tests.sh @@ -1,5 +1,7 @@ #!/bin/bash +# ex: QEMU_LD_PREFIX=/rivos/sysroot/riscv QEMU_CPU=rivos-sentinel-ga0 CONF=linux-riscv64-server-release bash run-tests.sh test/hotspot/jtreg:tier1 + CONF=${CONF:-linux-riscv64-server-release} TESTSUITE=test/hotspot/jtreg @@ -16,10 +18,10 @@ ARGS=( -Duser.country=US -Djava.library.path="$(pwd)/build/${CONF}/images/test/failure_handler" -Dprogram=jtreg - -jar /workspace/jtreg/build/images/jtreg/lib/jtreg.jar + -jar /opt/jtreg/lib/jtreg.jar # download from https://builds.shipilev.net/jtreg/ # JTreg arguments -agentvm - -verbose:summary,time + -verbose:summary -retain:fail,error -concurrency:$(nproc) -timeoutFactor:16 @@ -32,10 +34,14 @@ ARGS=( -dir:$(pwd) -reportDir:$(pwd)/build/run-test/test-results -workDir:$(pwd)/build/run-test/test-support + -compilejdk:/rivos/jdk -testjdk:$(pwd)/build/${CONF}/images/jdk + -e:QEMU_LD_PREFIX -e:QEMU_CPU + -javaoption:-XX:+UnlockExperimentalVMOptions + # -javaoption:-XX:+UseZacas or any other JVM option for the testjdk $(test -n "${NATIVEPATH}" && echo "-nativepath:${NATIVEPATH}"|| true) -exclude:${TESTSUITE}/ProblemList.txt -exclude:${TESTSUITE}/ProblemList-GHA.txt ) -build/${CONF}/images/jdk/bin/java ${ARGS[@]} ${*:-${TESTSUITE}} +/rivos/jdk/bin/java ${ARGS[@]} ${*:-${TESTSUITE}} From f1acbdf680a1e3c4b15aaac708aad881eca500bf Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Fri, 15 Dec 2023 01:03:53 +0100 Subject: [PATCH 84/85] Add -march flags to compilation (#157) --- rivos/gitlab-ci.yml | 86 ++++++++++++++++++++++++++------------------- 1 file changed, 49 insertions(+), 37 deletions(-) diff --git a/rivos/gitlab-ci.yml b/rivos/gitlab-ci.yml index 072f62dae66c3..23f84f37ba87a 100644 --- a/rivos/gitlab-ci.yml +++ b/rivos/gitlab-ci.yml @@ -10,6 +10,10 @@ variables: BINUTILS_VERSION: "2.38" GTEST_TAG: "v1.14.0" JTREG_VERSION: "7.3.1+1" + MARCH_AMD64: "x86-64-v3" + # MARCH_RISCV64: "rv64gcv_zvl256b_zba_zbb_zbs_zicond_zfa_ztso_zacas" # Zicond/Zfa/Ztso/Zacas not supported by GCC yet + MARCH_RISCV64: "rv64gcv_zvl256b_zba_zbb_zbs" + QEMU_CPU: rv64,v=true,vlen=256,elen=64,vext_spec=v1.0,zba=true,zbb=true,zbs=true prepare-version: after_script: @@ -33,11 +37,11 @@ download-tools: stage: prebuild image: gitlab.ba.rivosinc.com:5050/rv/it/int/rivos-sdk:latest script: - - apt-get update - - | - apt-get install -y \ - curl \ - zip + - > + apt-get update -qq && + apt-get install -qq -y + curl + zip - | curl -L https://builds.shipilev.net/jtreg/jtreg-${JTREG_VERSION}.zip > jtreg.zip unzip jtreg.zip @@ -53,21 +57,21 @@ download-tools: variables: CONF_NAME: linux-${PKG_ARCH}-${DEBUG_LEVEL} script: - - apt-get update - - | - apt-get install -y \ - autoconf \ - build-essential \ - curl \ - file \ - g++ \ - gcc \ - git \ - $(test "${PKG_ARCH}" = "riscv64" && echo "g++-riscv64-linux-gnu" || true) \ - $(test "${PKG_ARCH}" = "riscv64" && echo "gcc-riscv64-linux-gnu" || true) \ - unzip \ - zip \ - zlib1g-dev + - > + apt-get update -qq && + apt-get install -qq -y + autoconf + build-essential + curl + file + g++ + gcc + git + $(test "${PKG_ARCH}" = "riscv64" && echo "g++-12-riscv64-linux-gnu" || true) + $(test "${PKG_ARCH}" = "riscv64" && echo "gcc-12-riscv64-linux-gnu" || true) + unzip + zip + zlib1g-dev - | mkdir -p /usr/lib/jvm/temurin-${BUILD_JDK_VERSION} curl -L https://api.adoptium.net/v3/binary/latest/${BUILD_JDK_VERSION}/ea/linux/x64/jdk/hotspot/normal/eclipse\?project\=jdk \ @@ -77,23 +81,27 @@ download-tools: curl -L https://ftp.gnu.org/gnu/binutils/binutils-${BINUTILS_VERSION}.tar.gz \ | tar -xzf - -C binutils --strip-components 1 - git clone https://github.com/google/googletest.git -b ${GTEST_TAG} googletest - - | - bash configure \ - --with-debug-level=${DEBUG_LEVEL} \ - --openjdk-target=${PKG_ARCH}-linux-gnu \ - --with-conf-name=${CONF_NAME} \ - --with-vendor-name="Rivos Inc" \ - --with-version-pre="${JDK_VERSION_PRE}" \ - --with-version-opt="${JDK_VERSION_OPT}" \ - $(test "${PKG_ARCH}" = "riscv64" && echo "--with-sysroot=/rivos/sysroot/riscv" || true) \ - --with-boot-jdk=/usr/lib/jvm/temurin-${BUILD_JDK_VERSION} \ - --disable-precompiled-headers \ - --with-zlib=system \ - --with-gtest=$(pwd)/googletest \ - --with-jtreg=$(pwd)/jtreg \ - --with-hsdis=binutils \ - --with-binutils-src=binutils \ - --enable-hsdis-bundling + - > + bash configure + $(test "${PKG_ARCH}" = "riscv64" && echo "CC=riscv64-linux-gnu-gcc-12" || true) + $(test "${PKG_ARCH}" = "riscv64" && echo "CXX=riscv64-linux-gnu-g++-12" || true) + --with-debug-level=${DEBUG_LEVEL} + --openjdk-target=${PKG_ARCH}-linux-gnu + --with-conf-name=${CONF_NAME} + --with-vendor-name="Rivos Inc" + --with-version-pre="${JDK_VERSION_PRE}" + --with-version-opt="${JDK_VERSION_OPT}" + $(test "${PKG_ARCH}" = "riscv64" && echo "--with-sysroot=/rivos/sysroot/riscv" || true) + --with-boot-jdk=/usr/lib/jvm/temurin-${BUILD_JDK_VERSION} + --disable-precompiled-headers + --with-zlib=system + --with-gtest=$(pwd)/googletest + --with-jtreg=$(pwd)/jtreg + --with-hsdis=binutils + --with-binutils-src=binutils + --enable-hsdis-bundling + --with-extra-cflags="-march=${MARCH}" + --with-extra-cxxflags="-march=${MARCH}" - make jdk-image test-image LOG_LEVEL=info artifacts: when: always @@ -123,6 +131,7 @@ build-linux-amd64-fastdebug: variables: PKG_ARCH: amd64 DEBUG_LEVEL: fastdebug + MARCH: ${MARCH_AMD64} build-linux-riscv64-fastdebug: extends: .build-linux @@ -131,6 +140,7 @@ build-linux-riscv64-fastdebug: variables: PKG_ARCH: riscv64 DEBUG_LEVEL: fastdebug + MARCH: ${MARCH_RISCV64} build-linux-amd64-release: extends: .build-linux @@ -139,6 +149,7 @@ build-linux-amd64-release: variables: PKG_ARCH: amd64 DEBUG_LEVEL: release + MARCH: ${MARCH_AMD64} build-linux-riscv64-release: extends: .build-linux @@ -147,6 +158,7 @@ build-linux-riscv64-release: variables: PKG_ARCH: riscv64 DEBUG_LEVEL: release + MARCH: ${MARCH_RISCV64} .run-gtests: stage: test From b86a8bc4e46a9b766a706e7ac9f8b60abc266fd5 Mon Sep 17 00:00:00 2001 From: Ludovic Henry Date: Mon, 17 Jun 2024 16:33:25 +0200 Subject: [PATCH 85/85] ci: Bump build JDK to 23 (#178) --- rivos/gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rivos/gitlab-ci.yml b/rivos/gitlab-ci.yml index 23f84f37ba87a..38f20dbc71b9d 100644 --- a/rivos/gitlab-ci.yml +++ b/rivos/gitlab-ci.yml @@ -6,7 +6,7 @@ include: variables: CACHE_VERSION: "v6" - BUILD_JDK_VERSION: "21" + BUILD_JDK_VERSION: "23" BINUTILS_VERSION: "2.38" GTEST_TAG: "v1.14.0" JTREG_VERSION: "7.3.1+1"