diff --git a/Add-riscv64-support.patch b/Add-riscv64-support.patch index 7e2d50c2e6427d152e7f6a395a5bcf81883b5a40..9c4b0037f373976b77b2fa943372e2b48143bb6f 100644 --- a/Add-riscv64-support.patch +++ b/Add-riscv64-support.patch @@ -1,176 +1,3 @@ -diff --git a/.github/workflows/build-cross-compile.yml b/.github/workflows/build-cross-compile.yml -index 385b097b9f..4eebe79871 100644 ---- a/.github/workflows/build-cross-compile.yml -+++ b/.github/workflows/build-cross-compile.yml -@@ -54,28 +54,39 @@ jobs: - - arm - - s390x - - ppc64le -+ - riscv64 - include: - - target-cpu: aarch64 - gnu-arch: aarch64 - debian-arch: arm64 - debian-repository: https://httpredir.debian.org/debian/ - debian-version: bullseye -+ tolerate-sysroot-errors: false - - target-cpu: arm - gnu-arch: arm - debian-arch: armhf - debian-repository: https://httpredir.debian.org/debian/ - debian-version: bullseye -+ tolerate-sysroot-errors: false - gnu-abi: eabihf - - target-cpu: s390x - gnu-arch: s390x - debian-arch: s390x - debian-repository: https://httpredir.debian.org/debian/ - debian-version: bullseye -+ tolerate-sysroot-errors: false - - target-cpu: ppc64le - gnu-arch: powerpc64le - debian-arch: ppc64el - debian-repository: https://httpredir.debian.org/debian/ - debian-version: bullseye -+ tolerate-sysroot-errors: false -+ - target-cpu: riscv64 -+ gnu-arch: riscv64 -+ debian-arch: riscv64 -+ debian-repository: https://snapshot.debian.org/archive/debian/20240228T034848Z/ -+ debian-version: sid -+ tolerate-sysroot-errors: true - - steps: - - name: 'Checkout the JDK source' -@@ -113,6 +124,7 @@ jobs: - if: steps.get-cached-sysroot.outputs.cache-hit != 'true' - - - name: 'Create sysroot' -+ id: create-sysroot - run: > - sudo debootstrap - --arch=${{ matrix.debian-arch }} -@@ -123,6 +135,7 @@ jobs: - ${{ matrix.debian-version }} - sysroot - ${{ matrix.debian-repository }} -+ continue-on-error: ${{ matrix.tolerate-sysroot-errors }} - if: steps.get-cached-sysroot.outputs.cache-hit != 'true' - - - name: 'Prepare sysroot' -@@ -134,7 +147,12 @@ jobs: - 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' -+ if: steps.create-sysroot.outcome == 'success' && steps.get-cached-sysroot.outputs.cache-hit != 'true' -+ -+ - name: 'Remove broken sysroot' -+ run: | -+ sudo rm -rf sysroot/ -+ if: steps.create-sysroot.outcome != 'success' && steps.get-cached-sysroot.outputs.cache-hit != 'true' - - - name: 'Configure' - run: > -@@ -153,6 +171,7 @@ jobs: - echo "Dumping config.log:" && - cat config.log && - exit 1) -+ if: steps.create-sysroot.outcome == 'success' || steps.get-cached-sysroot.outputs.cache-hit == 'true' - - - name: 'Build' - id: build -@@ -160,3 +179,4 @@ jobs: - with: - make-target: 'hotspot ${{ inputs.make-arguments }}' - platform: linux-${{ matrix.target-cpu }} -+ if: steps.create-sysroot.outcome == 'success' || steps.get-cached-sysroot.outputs.cache-hit == 'true' -diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml -index 4186c451b7..678f5a038e 100644 ---- a/.github/workflows/build-macos.yml -+++ b/.github/workflows/build-macos.yml -@@ -55,7 +55,7 @@ on: - jobs: - build-macos: - name: build -- runs-on: macos-13 -+ runs-on: macos-12 - - strategy: - fail-fast: false -diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml -index 78a8e1e0d4..46cae3afbf 100644 ---- a/.github/workflows/main.yml -+++ b/.github/workflows/main.yml -@@ -223,7 +223,7 @@ jobs: - uses: ./.github/workflows/build-macos.yml - with: - platform: macos-x64 -- xcode-toolset-version: '14.3.1' -+ xcode-toolset-version: '13.4.1' - configure-arguments: ${{ github.event.inputs.configure-arguments }} - make-arguments: ${{ github.event.inputs.make-arguments }} - if: needs.select.outputs.macos-x64 == 'true' -@@ -234,7 +234,7 @@ jobs: - uses: ./.github/workflows/build-macos.yml - with: - platform: macos-aarch64 -- xcode-toolset-version: '14.3.1' -+ xcode-toolset-version: '13.4.1' - extra-conf-options: '--openjdk-target=aarch64-apple-darwin' - configure-arguments: ${{ github.event.inputs.configure-arguments }} - make-arguments: ${{ github.event.inputs.make-arguments }} -@@ -298,7 +298,7 @@ jobs: - with: - platform: macos-x64 - bootjdk-platform: macos-x64 -- runs-on: macos-13 -+ runs-on: macos-12 - - test-windows-x64: - name: windows-x64 -@@ -341,7 +341,7 @@ jobs: - -H 'Accept: application/vnd.github+json' \ - -H 'Authorization: Bearer ${{ github.token }}' \ - -H 'X-GitHub-Api-Version: 2022-11-28' \ -- '${{ github.api_url }}/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts')" -+ '${{ github.api_url }}/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts?per_page=100')" - BUNDLE_ARTIFACT_IDS="$(echo "$ALL_ARTIFACT_IDS" | jq -r -c '.artifacts | map(select(.name|startswith("bundles-"))) | .[].id')" - for id in $BUNDLE_ARTIFACT_IDS; do - echo "Removing $id" -diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml -index c3560f2135..dacf8eaba1 100644 ---- a/.github/workflows/test.yml -+++ b/.github/workflows/test.yml -@@ -127,7 +127,7 @@ jobs: - run: | - # On macOS we need to install some dependencies for testing - brew install make -- sudo xcode-select --switch /Applications/Xcode_14.3.1.app/Contents/Developer -+ sudo xcode-select --switch /Applications/Xcode_13.4.1.app/Contents/Developer - # This will make GNU make available as 'make' and not only as 'gmake' - echo '/usr/local/opt/make/libexec/gnubin' >> $GITHUB_PATH - if: runner.os == 'macOS' -diff --git a/.jcheck/conf b/.jcheck/conf -index 5636278120..d13b1bf5e8 100644 ---- a/.jcheck/conf -+++ b/.jcheck/conf -@@ -1,5 +1,5 @@ - [general] --project=jdk-updates -+project=riscv-port - jbs=JDK - version=11.0.25 - -diff --git a/SECURITY.md b/SECURITY.md -new file mode 100644 -index 0000000000..f4c5e7e67c ---- /dev/null -+++ b/SECURITY.md -@@ -0,0 +1,3 @@ -+# JDK Vulnerabilities -+ -+Please follow the process outlined in the [OpenJDK Vulnerability Policy](https://openjdk.org/groups/vulnerability/report) to disclose vulnerabilities in the JDK. diff --git a/make/autoconf/build-aux/config.sub b/make/autoconf/build-aux/config.sub index 3c280ac7c0..6c66c221e0 100644 --- a/make/autoconf/build-aux/config.sub @@ -198,7 +25,7 @@ index 3c280ac7c0..6c66c221e0 100644 if ! echo $* | grep '^aarch64-' >/dev/null ; then . $DIR/autoconf-config.sub "$@" diff --git a/make/autoconf/hotspot.m4 b/make/autoconf/hotspot.m4 -index 9bb34363e5..f84e8f84c6 100644 +index 2c52fd98c6..dbab814bc3 100644 --- a/make/autoconf/hotspot.m4 +++ b/make/autoconf/hotspot.m4 @@ -370,7 +370,8 @@ AC_DEFUN_ONCE([HOTSPOT_SETUP_JVM_FEATURES], @@ -231,19 +58,6 @@ index 5d1d9efa39..565ca18e20 100644 # The cpu defines below are for zero, we don't support them directly. elif test "x$OPENJDK_$1_CPU" = xsparc; then -diff --git a/make/autoconf/version-numbers b/make/autoconf/version-numbers -index fe5e0d9850..c02b769bf2 100644 ---- a/make/autoconf/version-numbers -+++ b/make/autoconf/version-numbers -@@ -37,7 +37,7 @@ DEFAULT_VERSION_DATE=2024-10-15 - DEFAULT_VERSION_CLASSFILE_MAJOR=55 # "`$EXPR $DEFAULT_VERSION_FEATURE + 44`" - DEFAULT_VERSION_CLASSFILE_MINOR=0 - DEFAULT_ACCEPTABLE_BOOT_VERSIONS="10 11" --DEFAULT_PROMOTED_VERSION_PRE= -+DEFAULT_PROMOTED_VERSION_PRE=ea - - LAUNCHER_NAME=openjdk - PRODUCT_NAME=OpenJDK diff --git a/make/hotspot/gensrc/GensrcAdlc.gmk b/make/hotspot/gensrc/GensrcAdlc.gmk index c5a3ac5724..51137b99db 100644 --- a/make/hotspot/gensrc/GensrcAdlc.gmk @@ -268,94 +82,6 @@ index c5a3ac5724..51137b99db 100644 ifeq ($(call check-jvm-feature, shenandoahgc), true) AD_SRC_FILES += $(call uniq, $(wildcard $(foreach d, $(AD_SRC_ROOTS), \ $d/cpu/$(HOTSPOT_TARGET_CPU_ARCH)/gc/shenandoah/shenandoah_$(HOTSPOT_TARGET_CPU).ad \ -diff --git a/make/hotspot/lib/JvmFlags.gmk b/make/hotspot/lib/JvmFlags.gmk -index 3246c83155..1a91eb0079 100644 ---- a/make/hotspot/lib/JvmFlags.gmk -+++ b/make/hotspot/lib/JvmFlags.gmk -@@ -67,10 +67,12 @@ JVM_CFLAGS_TARGET_DEFINES += \ - # - - ifeq ($(DEBUG_LEVEL), release) -+ # release builds disable uses of assert macro from . -+ JVM_CFLAGS_DEBUGLEVEL := -DNDEBUG - # For hotspot, release builds differ internally between "optimized" and "product" - # in that "optimize" does not define PRODUCT. - ifneq ($(HOTSPOT_DEBUG_LEVEL), optimized) -- JVM_CFLAGS_DEBUGLEVEL := -DPRODUCT -+ JVM_CFLAGS_DEBUGLEVEL += -DPRODUCT - endif - else ifeq ($(DEBUG_LEVEL), fastdebug) - JVM_CFLAGS_DEBUGLEVEL := -DASSERT -diff --git a/make/jdk/src/classes/build/tools/tzdb/TzdbZoneRulesProvider.java b/make/jdk/src/classes/build/tools/tzdb/TzdbZoneRulesProvider.java -index f02537c305..ef94e3879c 100644 ---- a/make/jdk/src/classes/build/tools/tzdb/TzdbZoneRulesProvider.java -+++ b/make/jdk/src/classes/build/tools/tzdb/TzdbZoneRulesProvider.java -@@ -1,5 +1,5 @@ - /* -- * Copyright (c) 2014, 2019, Oracle and/or its affiliates. All rights reserved. -+ * Copyright (c) 2014, 2024, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it -@@ -363,33 +363,35 @@ class TzdbZoneRulesProvider { - } - - Month parseMonth(String mon) { -- switch (mon) { -- case "Jan": return Month.JANUARY; -- case "Feb": return Month.FEBRUARY; -- case "Mar": return Month.MARCH; -- case "Apr": return Month.APRIL; -- case "May": return Month.MAY; -- case "Jun": return Month.JUNE; -- case "Jul": return Month.JULY; -- case "Aug": return Month.AUGUST; -- case "Sep": return Month.SEPTEMBER; -- case "Oct": return Month.OCTOBER; -- case "Nov": return Month.NOVEMBER; -- case "Dec": return Month.DECEMBER; -- } -+ int len = mon.length(); -+ -+ if (mon.regionMatches(true, 0, "January", 0, len)) return Month.JANUARY; -+ if (mon.regionMatches(true, 0, "February", 0, len)) return Month.FEBRUARY; -+ if (mon.regionMatches(true, 0, "March", 0, len)) return Month.MARCH; -+ if (mon.regionMatches(true, 0, "April", 0, len)) return Month.APRIL; -+ if (mon.regionMatches(true, 0, "May", 0, len)) return Month.MAY; -+ if (mon.regionMatches(true, 0, "June", 0, len)) return Month.JUNE; -+ if (mon.regionMatches(true, 0, "July", 0, len)) return Month.JULY; -+ if (mon.regionMatches(true, 0, "August", 0, len)) return Month.AUGUST; -+ if (mon.regionMatches(true, 0, "September", 0, len)) return Month.SEPTEMBER; -+ if (mon.regionMatches(true, 0, "October", 0, len)) return Month.OCTOBER; -+ if (mon.regionMatches(true, 0, "November", 0, len)) return Month.NOVEMBER; -+ if (mon.regionMatches(true, 0, "December", 0, len)) return Month.DECEMBER; -+ - throw new IllegalArgumentException("Unknown month: " + mon); - } - - DayOfWeek parseDayOfWeek(String dow) { -- switch (dow) { -- case "Mon": return DayOfWeek.MONDAY; -- case "Tue": return DayOfWeek.TUESDAY; -- case "Wed": return DayOfWeek.WEDNESDAY; -- case "Thu": return DayOfWeek.THURSDAY; -- case "Fri": return DayOfWeek.FRIDAY; -- case "Sat": return DayOfWeek.SATURDAY; -- case "Sun": return DayOfWeek.SUNDAY; -- } -+ int len = dow.length(); -+ -+ if (dow.regionMatches(true, 0, "Monday", 0, len)) return DayOfWeek.MONDAY; -+ if (dow.regionMatches(true, 0, "Tuesday", 0, len)) return DayOfWeek.TUESDAY; -+ if (dow.regionMatches(true, 0, "Wednesday", 0, len)) return DayOfWeek.WEDNESDAY; -+ if (dow.regionMatches(true, 0, "Thursday", 0, len)) return DayOfWeek.THURSDAY; -+ if (dow.regionMatches(true, 0, "Friday", 0, len)) return DayOfWeek.FRIDAY; -+ if (dow.regionMatches(true, 0, "Saturday", 0, len)) return DayOfWeek.SATURDAY; -+ if (dow.regionMatches(true, 0, "Sunday", 0, len)) return DayOfWeek.SUNDAY; -+ - throw new IllegalArgumentException("Unknown day-of-week: " + dow); - } - diff --git a/src/hotspot/cpu/riscv/abstractInterpreter_riscv.cpp b/src/hotspot/cpu/riscv/abstractInterpreter_riscv.cpp new file mode 100644 index 0000000000..31c63abe71 @@ -541,10 +267,10 @@ index 0000000000..31c63abe71 +} diff --git a/src/hotspot/cpu/riscv/assembler_riscv.cpp b/src/hotspot/cpu/riscv/assembler_riscv.cpp new file mode 100644 -index 0000000000..67c6f1eccb +index 0000000000..a83d43a8f1 --- /dev/null +++ b/src/hotspot/cpu/riscv/assembler_riscv.cpp -@@ -0,0 +1,337 @@ +@@ -0,0 +1,365 @@ +/* + * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, Red Hat Inc. All rights reserved. @@ -597,7 +323,7 @@ index 0000000000..67c6f1eccb + } +} + -+void Assembler::addw(Register Rd, Register Rn, int32_t increment, Register temp) { ++void Assembler::addw(Register Rd, Register Rn, int64_t increment, Register temp) { + if (is_imm_in_range(increment, 12, 0)) { + addiw(Rd, Rn, increment); + } else { @@ -617,7 +343,7 @@ index 0000000000..67c6f1eccb + } +} + -+void Assembler::subw(Register Rd, Register Rn, int32_t decrement, Register temp) { ++void Assembler::subw(Register Rd, Register Rn, int64_t decrement, Register temp) { + if (is_imm_in_range(-decrement, 12, 0)) { + addiw(Rd, Rn, -decrement); + } else { @@ -663,6 +389,33 @@ index 0000000000..67c6f1eccb + } +} + ++void Assembler::li64(Register Rd, int64_t imm) { ++ // Load upper 32 bits. upper = imm[63:32], but if imm[31] == 1 or ++ // (imm[31:28] == 0x7ff && imm[19] == 1), upper = imm[63:32] + 1. ++ int64_t lower = imm & 0xffffffff; ++ lower -= ((lower << 44) >> 44); ++ int64_t tmp_imm = ((uint64_t)(imm & 0xffffffff00000000)) + (uint64_t)lower; ++ int32_t upper = (tmp_imm - (int32_t)lower) >> 32; ++ ++ // Load upper 32 bits ++ int64_t up = upper, lo = upper; ++ lo = (lo << 52) >> 52; ++ up -= lo; ++ up = (int32_t)up; ++ lui(Rd, up); ++ addi(Rd, Rd, lo); ++ ++ // Load the rest 32 bits. ++ slli(Rd, Rd, 12); ++ addi(Rd, Rd, (int32_t)lower >> 20); ++ slli(Rd, Rd, 12); ++ lower = ((int32_t)imm << 12) >> 20; ++ addi(Rd, Rd, lower); ++ slli(Rd, Rd, 8); ++ lower = imm & 0xff; ++ addi(Rd, Rd, lower); ++} ++ +void Assembler::li32(Register Rd, int32_t imm) { + // int32_t is in range 0x8000 0000 ~ 0x7fff ffff, and imm[31] is the sign bit + int64_t upper = imm, lower = imm; @@ -671,6 +424,7 @@ index 0000000000..67c6f1eccb + upper = (int32_t)upper; + // lui Rd, imm[31:12] + imm[11] + lui(Rd, upper); ++ // use addiw to distinguish li32 to li64 + addiw(Rd, Rd, lower); +} + @@ -734,7 +488,7 @@ index 0000000000..67c6f1eccb + void Assembler::NAME(const Address &adr, Register temp) { \ + switch (adr.getMode()) { \ + case Address::literal: { \ -+ relocate(adr.rspec()); \ ++ code_section()->relocate(pc(), adr.rspec()); \ + NAME(adr.target(), temp); \ + break; \ + } \ @@ -792,7 +546,7 @@ index 0000000000..67c6f1eccb +} + +void Assembler::movptr_with_offset(Register Rd, address addr, int32_t &offset) { -+ int64_t imm64 = (int64_t)addr; ++ uintptr_t imm64 = (uintptr_t)addr; +#ifndef PRODUCT + { + char buffer[64]; @@ -800,10 +554,10 @@ index 0000000000..67c6f1eccb + block_comment(buffer); + } +#endif -+ assert(is_unsigned_imm_in_range(imm64, 47, 0) || (imm64 == (int64_t)-1), ++ assert(is_unsigned_imm_in_range(imm64, 47, 0) || (imm64 == (uintptr_t)-1), + "bit 47 overflows in address constant"); + // Load upper 31 bits -+ int64_t imm = imm64 >> 17; ++ int32_t imm = imm64 >> 17; + int64_t upper = imm, lower = imm; + lower = (lower << 52) >> 52; + upper -= lower; @@ -884,10 +638,10 @@ index 0000000000..67c6f1eccb +} diff --git a/src/hotspot/cpu/riscv/assembler_riscv.hpp b/src/hotspot/cpu/riscv/assembler_riscv.hpp new file mode 100644 -index 0000000000..9f6c477afa +index 0000000000..9e7d271860 --- /dev/null +++ b/src/hotspot/cpu/riscv/assembler_riscv.hpp -@@ -0,0 +1,3056 @@ +@@ -0,0 +1,3057 @@ +/* + * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2020, Red Hat Inc. All rights reserved. @@ -1204,6 +958,7 @@ index 0000000000..9f6c477afa + + void _li(Register Rd, int64_t imm); // optimized load immediate + void li32(Register Rd, int32_t imm); ++ void li64(Register Rd, int64_t imm); + void movptr(Register Rd, address addr); + void movptr_with_offset(Register Rd, address addr, int32_t &offset); + void movptr(Register Rd, uintptr_t imm64); @@ -1327,9 +1082,10 @@ index 0000000000..9f6c477afa + +#define INSN_ENTRY_RELOC(result_type, header) \ + result_type header { \ ++ InstructionMark im(this); \ + guarantee(rtype == relocInfo::internal_word_type, \ + "only internal_word_type relocs make sense here"); \ -+ relocate(InternalAddress(dest).rspec()); ++ code_section()->relocate(inst_mark(), InternalAddress(dest).rspec()); + + // Load/store register (all modes) +#define INSN(NAME, op, funct3) \ @@ -1374,7 +1130,7 @@ index 0000000000..9f6c477afa + void NAME(Register Rd, const Address &adr, Register temp = t0) { \ + switch (adr.getMode()) { \ + case Address::literal: { \ -+ relocate(adr.rspec()); \ ++ code_section()->relocate(pc(), adr.rspec()); \ + NAME(Rd, adr.target()); \ + break; \ + } \ @@ -1448,7 +1204,7 @@ index 0000000000..9f6c477afa + void NAME(FloatRegister Rd, const Address &adr, Register temp = t0) { \ + switch (adr.getMode()) { \ + case Address::literal: { \ -+ relocate(adr.rspec()); \ ++ code_section()->relocate(pc(), adr.rspec()); \ + NAME(Rd, adr.target(), temp); \ + break; \ + } \ @@ -1591,7 +1347,7 @@ index 0000000000..9f6c477afa + switch (adr.getMode()) { \ + case Address::literal: { \ + assert_different_registers(Rs, temp); \ -+ relocate(adr.rspec()); \ ++ code_section()->relocate(pc(), adr.rspec()); \ + NAME(Rs, adr.target(), temp); \ + break; \ + } \ @@ -1634,7 +1390,7 @@ index 0000000000..9f6c477afa + void NAME(FloatRegister Rs, const Address &adr, Register temp = t0) { \ + switch (adr.getMode()) { \ + case Address::literal: { \ -+ relocate(adr.rspec()); \ ++ code_section()->relocate(pc(), adr.rspec()); \ + NAME(Rs, adr.target(), temp); \ + break; \ + } \ @@ -3903,12 +3659,11 @@ index 0000000000..9f6c477afa + void wrap_label(Register r, Label &L, Register t, load_insn_by_temp insn); + void wrap_label(Register r, Label &L, jal_jalr_insn insn); + -+ // Computational pseudo instructions ++ // calculate pseudoinstruction + void add(Register Rd, Register Rn, int64_t increment, Register temp = t0); -+ void addw(Register Rd, Register Rn, int32_t increment, Register temp = t0); -+ ++ void addw(Register Rd, Register Rn, int64_t increment, Register temp = t0); + void sub(Register Rd, Register Rn, int64_t decrement, Register temp = t0); -+ void subw(Register Rd, Register Rn, int32_t decrement, Register temp = t0); ++ void subw(Register Rd, Register Rn, int64_t decrement, Register temp = t0); + + // RVB pseudo instructions + // zero extend word @@ -3999,10 +3754,10 @@ index 0000000000..7ffe880398 +#endif // CPU_RISCV_ASSEMBLER_RISCV_INLINE_HPP diff --git a/src/hotspot/cpu/riscv/bytes_riscv.hpp b/src/hotspot/cpu/riscv/bytes_riscv.hpp new file mode 100644 -index 0000000000..485a5f9355 +index 0000000000..f60e0e38ae --- /dev/null +++ b/src/hotspot/cpu/riscv/bytes_riscv.hpp -@@ -0,0 +1,167 @@ +@@ -0,0 +1,165 @@ +/* + * Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2016 SAP SE. All rights reserved. @@ -4078,7 +3833,6 @@ index 0000000000..485a5f9355 + ((u8)(((u4*)p)[0])); + + case 2: -+ case 6: + return ((u8)(((u2*)p)[3]) << 48) | + ((u8)(((u2*)p)[2]) << 32) | + ((u8)(((u2*)p)[1]) << 16) | @@ -4137,7 +3891,6 @@ index 0000000000..485a5f9355 + break; + + case 2: -+ case 6: + ((u2*)p)[3] = x >> 48; + ((u2*)p)[2] = x >> 32; + ((u2*)p)[1] = x >> 16; @@ -4172,7 +3925,7 @@ index 0000000000..485a5f9355 +#endif // CPU_RISCV_BYTES_RISCV_HPP diff --git a/src/hotspot/cpu/riscv/c1_CodeStubs_riscv.cpp b/src/hotspot/cpu/riscv/c1_CodeStubs_riscv.cpp new file mode 100644 -index 0000000000..9729e16c96 +index 0000000000..12980c12de --- /dev/null +++ b/src/hotspot/cpu/riscv/c1_CodeStubs_riscv.cpp @@ -0,0 +1,339 @@ @@ -4507,7 +4260,7 @@ index 0000000000..9729e16c96 +#ifndef PRODUCT + if (PrintC1Statistics) { + __ la(t1, ExternalAddress((address)&Runtime1::_arraycopy_slowcase_cnt)); -+ __ incrementw(Address(t1)); ++ __ add_memory_int32(Address(t1), 1); + } +#endif + @@ -5563,7 +5316,7 @@ index 0000000000..ab0a9963fc +#endif // CPU_RISCV_C1_LIRASSEMBLER_ARITH_RISCV_HPP diff --git a/src/hotspot/cpu/riscv/c1_LIRAssembler_arraycopy_riscv.cpp b/src/hotspot/cpu/riscv/c1_LIRAssembler_arraycopy_riscv.cpp new file mode 100644 -index 0000000000..e6b95d3b7f +index 0000000000..b7f53e395f --- /dev/null +++ b/src/hotspot/cpu/riscv/c1_LIRAssembler_arraycopy_riscv.cpp @@ -0,0 +1,388 @@ @@ -5626,7 +5379,7 @@ index 0000000000..e6b95d3b7f + __ mv(c_rarg4, j_rarg4); +#ifndef PRODUCT + if (PrintC1Statistics) { -+ __ incrementw(ExternalAddress((address)&Runtime1::_generic_arraycopystub_cnt)); ++ __ add_memory_int32(ExternalAddress((address)&Runtime1::_generic_arraycopystub_cnt), 1); + } +#endif + __ far_call(RuntimeAddress(copyfunc_addr)); @@ -5664,14 +5417,14 @@ index 0000000000..e6b95d3b7f + if (!(flags & LIR_OpArrayCopy::LIR_OpArrayCopy::dst_objarray)) { + __ load_klass(tmp, dst); + __ lw(t0, Address(tmp, in_bytes(Klass::layout_helper_offset()))); -+ __ mv(t1, Klass::_lh_neutral_value); ++ __ li(t1, Klass::_lh_neutral_value); + __ bge(t0, t1, *stub->entry(), /* is_far */ true); + } + + if (!(flags & LIR_OpArrayCopy::LIR_OpArrayCopy::src_objarray)) { + __ load_klass(tmp, src); + __ lw(t0, Address(tmp, in_bytes(Klass::layout_helper_offset()))); -+ __ mv(t1, Klass::_lh_neutral_value); ++ __ li(t1, Klass::_lh_neutral_value); + __ bge(t0, t1, *stub->entry(), /* is_far */ true); + } + } @@ -5733,7 +5486,7 @@ index 0000000000..e6b95d3b7f + if (PrintC1Statistics) { + Label failed; + __ bnez(x10, failed); -+ __ incrementw(ExternalAddress((address)&Runtime1::_arraycopy_checkcast_cnt)); ++ __ add_memory_int32(ExternalAddress((address)&Runtime1::_arraycopy_checkcast_cnt), 1); + __ bind(failed); + } +#endif @@ -5742,7 +5495,7 @@ index 0000000000..e6b95d3b7f + +#ifndef PRODUCT + if (PrintC1Statistics) { -+ __ incrementw(ExternalAddress((address)&Runtime1::_arraycopy_checkcast_attempt_cnt)); ++ __ add_memory_int32(ExternalAddress((address)&Runtime1::_arraycopy_checkcast_attempt_cnt), 1); + } +#endif + assert_different_registers(dst, dst_pos, length, src_pos, src, x10, t0); @@ -5893,7 +5646,7 @@ index 0000000000..e6b95d3b7f + +#ifndef PRODUCT + if (PrintC1Statistics) { -+ __ incrementw(ExternalAddress(Runtime1::arraycopy_count_address(basic_type))); ++ __ add_memory_int32(ExternalAddress(Runtime1::arraycopy_count_address(basic_type)), 1); + } +#endif + arraycopy_prepare_params(src, src_pos, length, dst, dst_pos, basic_type); @@ -6015,10 +5768,10 @@ index 0000000000..06a0f248ca +#endif // CPU_RISCV_C1_LIRASSEMBLER_ARRAYCOPY_RISCV_HPP diff --git a/src/hotspot/cpu/riscv/c1_LIRAssembler_riscv.cpp b/src/hotspot/cpu/riscv/c1_LIRAssembler_riscv.cpp new file mode 100644 -index 0000000000..fb6a60fb49 +index 0000000000..1e482d7cc2 --- /dev/null +++ b/src/hotspot/cpu/riscv/c1_LIRAssembler_riscv.cpp -@@ -0,0 +1,2258 @@ +@@ -0,0 +1,2268 @@ +/* + * Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2020, Red Hat Inc. All rights reserved. @@ -7086,7 +6839,7 @@ index 0000000000..fb6a60fb49 + __ ld(t1, Address(mdo, md->byte_offset_of_slot(data, ReceiverTypeData::receiver_offset(i)))); + __ bne(recv, t1, next_test); + Address data_addr(mdo, md->byte_offset_of_slot(data, ReceiverTypeData::receiver_count_offset(i))); -+ __ increment(data_addr, DataLayout::counter_increment); ++ __ add_memory_int64(data_addr, DataLayout::counter_increment); + __ j(*update_done); + __ bind(next_test); + } @@ -7098,7 +6851,7 @@ index 0000000000..fb6a60fb49 + __ ld(t1, recv_addr); + __ bnez(t1, next_test); + __ sd(recv, recv_addr); -+ __ mv(t1, DataLayout::counter_increment); ++ __ li(t1, DataLayout::counter_increment); + __ sd(t1, Address(mdo, md->byte_offset_of_slot(data, ReceiverTypeData::receiver_count_offset(i)))); + __ j(*update_done); + __ bind(next_test); @@ -7378,7 +7131,7 @@ index 0000000000..fb6a60fb49 + // With RVC a call instruction may get 2-byte aligned. + // The address of the call instruction needs to be 4-byte aligned to + // ensure that it does not span a cache line so that it can be patched. -+ __ align(NativeInstruction::instruction_size); ++ __ align(4); +} + +void LIR_Assembler::call(LIR_OpJavaCall* op, relocInfo::relocType rtype) { @@ -7406,7 +7159,7 @@ index 0000000000..fb6a60fb49 + +void LIR_Assembler::emit_static_call_stub() { + address call_pc = __ pc(); -+ MacroAssembler::assert_alignment(call_pc); ++ assert((__ offset() % 4) == 0, "bad alignment"); + address stub = __ start_a_stub(call_stub_size()); + if (stub == NULL) { + bailout("static call stub overflow"); @@ -7584,7 +7337,7 @@ index 0000000000..fb6a60fb49 + ciKlass* receiver = vc_data->receiver(i); + if (known_klass->equals(receiver)) { + Address data_addr(mdo, md->byte_offset_of_slot(data, VirtualCallData::receiver_count_offset(i))); -+ __ increment(data_addr, DataLayout::counter_increment); ++ __ add_memory_int64(data_addr, DataLayout::counter_increment); + return; + } + } @@ -7600,7 +7353,7 @@ index 0000000000..fb6a60fb49 + __ mov_metadata(t1, known_klass->constant_encoding()); + __ sd(t1, recv_addr); + Address data_addr(mdo, md->byte_offset_of_slot(data, VirtualCallData::receiver_count_offset(i))); -+ __ increment(data_addr, DataLayout::counter_increment); ++ __ add_memory_int64(data_addr, DataLayout::counter_increment); + return; + } + } @@ -7610,13 +7363,13 @@ index 0000000000..fb6a60fb49 + type_profile_helper(mdo, md, data, recv, &update_done); + // Receiver did not match any saved receiver and there is no empty row for it. + // Increment total counter to indicate polymorphic case. -+ __ increment(counter_addr, DataLayout::counter_increment); ++ __ add_memory_int64(counter_addr, DataLayout::counter_increment); + + __ bind(update_done); + } + } else { + // Static call -+ __ increment(counter_addr, DataLayout::counter_increment); ++ __ add_memory_int64(counter_addr, DataLayout::counter_increment); + } +} + @@ -7651,7 +7404,7 @@ index 0000000000..fb6a60fb49 + + if (TypeEntries::is_type_none(current_klass)) { + __ beqz(t1, none); -+ __ mv(t0, (u1)TypeEntries::null_seen); ++ __ li(t0, (u1)TypeEntries::null_seen); + __ beq(t0, t1, none); + // There is a chance that the checks above (re-reading profiling + // data from memory) fail if another thread has just set the @@ -7701,7 +7454,7 @@ index 0000000000..fb6a60fb49 + Label ok; + __ ld(t0, mdo_addr); + __ beqz(t0, ok); -+ __ mv(t1, (u1)TypeEntries::null_seen); ++ __ li(t1, (u1)TypeEntries::null_seen); + __ beq(t0, t1, ok); + // may have been set by another thread + __ membar(MacroAssembler::LoadLoad); @@ -8176,6 +7929,16 @@ index 0000000000..fb6a60fb49 + __ bind(done); +} + ++void LIR_Assembler::add_debug_info_for_branch(address adr, CodeEmitInfo* info) { ++ _masm->code_section()->relocate(adr, relocInfo::poll_type); ++ int pc_offset = code_offset(); ++ flush_debug_info(pc_offset); ++ info->record_debug_info(compilation()->debug_info_recorder(), pc_offset); ++ if (info->exception_handlers() != NULL) { ++ compilation()->add_exception_handlers_for_pco(pc_offset, info->exception_handlers()); ++ } ++} ++ +void LIR_Assembler::type_profile(Register obj, ciMethodData* md, Register klass_RInfo, Register k_RInfo, + ciProfileData* data, Label* success, Label* failure, + Label& profile_cast_success, Label& profile_cast_failure) { @@ -8272,17 +8035,17 @@ index 0000000000..fb6a60fb49 + assert(offset_from_rsp_in_words >= 0, "invalid offset from rsp"); + int offset_from_rsp_in_bytes = offset_from_rsp_in_words * BytesPerWord; + assert(offset_from_rsp_in_bytes < frame_map()->reserved_argument_area_size(), "invalid offset"); -+ __ mv(t0, c); ++ __ li(t0, c); + __ sd(t0, Address(sp, offset_from_rsp_in_bytes)); +} + +#undef __ diff --git a/src/hotspot/cpu/riscv/c1_LIRAssembler_riscv.hpp b/src/hotspot/cpu/riscv/c1_LIRAssembler_riscv.hpp new file mode 100644 -index 0000000000..2afd61a3db +index 0000000000..5c81f1c704 --- /dev/null +++ b/src/hotspot/cpu/riscv/c1_LIRAssembler_riscv.hpp -@@ -0,0 +1,131 @@ +@@ -0,0 +1,133 @@ +/* + * Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, Red Hat Inc. All rights reserved. @@ -8343,6 +8106,8 @@ index 0000000000..2afd61a3db + ciMethodData *md, ciProfileData *data, + Register recv, Label* update_done); + ++ void add_debug_info_for_branch(address adr, CodeEmitInfo* info); ++ + void casw(Register addr, Register newval, Register cmpval); + void caswu(Register addr, Register newval, Register cmpval); + void casl(Register addr, Register newval, Register cmpval); @@ -9705,10 +9470,10 @@ index 0000000000..d7ca7b0fd0 +#endif // CPU_RISCV_C1_LINEARSCAN_RISCV_HPP diff --git a/src/hotspot/cpu/riscv/c1_MacroAssembler_riscv.cpp b/src/hotspot/cpu/riscv/c1_MacroAssembler_riscv.cpp new file mode 100644 -index 0000000000..957bfa1127 +index 0000000000..99d981f97f --- /dev/null +++ b/src/hotspot/cpu/riscv/c1_MacroAssembler_riscv.cpp -@@ -0,0 +1,444 @@ +@@ -0,0 +1,443 @@ +/* + * Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, Red Hat Inc. All rights reserved. @@ -9806,7 +9571,7 @@ index 0000000000..957bfa1127 + // assuming both the stack pointer and page_size have their least + // significant 2 bits cleared and page_size is a power of 2 + sub(hdr, hdr, sp); -+ mv(t0, aligned_mask - os::vm_page_size()); ++ li(t0, aligned_mask - os::vm_page_size()); + andr(hdr, hdr, t0); + // for recursive locking, the result is zero => save it in the displaced header + // location (NULL in the displaced hdr location indicates recursive locking) @@ -9816,7 +9581,7 @@ index 0000000000..957bfa1127 + bind(done); + if (PrintBiasedLockingStatistics) { + la(t1, ExternalAddress((address)BiasedLocking::fast_path_entry_count_addr())); -+ incrementw(Address(t1, 0)); ++ add_memory_int32(Address(t1, 0), 1); + } + return null_check_offset; +} @@ -10047,7 +9812,6 @@ index 0000000000..957bfa1127 + + +void C1_MacroAssembler::verified_entry() { -+ assert_alignment(pc()); +} + +void C1_MacroAssembler::load_parameter(int offset_in_words, Register reg) { @@ -10282,7 +10046,7 @@ index 0000000000..1950cee5dd +#endif // CPU_RISCV_C1_MACROASSEMBLER_RISCV_HPP diff --git a/src/hotspot/cpu/riscv/c1_Runtime1_riscv.cpp b/src/hotspot/cpu/riscv/c1_Runtime1_riscv.cpp new file mode 100644 -index 0000000000..ffcca64e0b +index 0000000000..329df2e1ca --- /dev/null +++ b/src/hotspot/cpu/riscv/c1_Runtime1_riscv.cpp @@ -0,0 +1,1210 @@ @@ -11293,7 +11057,7 @@ index 0000000000..ffcca64e0b + __ check_klass_subtype_slow_path(x14, x10, x12, x15, NULL, &miss); + + // fallthrough on success: -+ __ mv(t0, 1); ++ __ li(t0, 1); + __ sd(t0, Address(sp, (result_off) * VMRegImpl::stack_slot_size)); // result + __ pop_reg(RegSet::of(x10, x12, x14, x15), sp); + __ ret(); @@ -11483,7 +11247,7 @@ index 0000000000..ffcca64e0b + default: + { + StubFrame f(sasm, "unimplemented entry", dont_gc_arguments); -+ __ mv(x10, (int)id); ++ __ li(x10, (int) id); + __ call_RT(noreg, noreg, CAST_FROM_FN_PTR(address, unimplemented_entry), x10); + __ should_not_reach_here(); + } @@ -13215,13 +12979,13 @@ index 0000000000..abd5bda7e4 +#endif // CPU_RISCV_FRAME_RISCV_INLINE_HPP diff --git a/src/hotspot/cpu/riscv/gc/g1/g1BarrierSetAssembler_riscv.cpp b/src/hotspot/cpu/riscv/gc/g1/g1BarrierSetAssembler_riscv.cpp new file mode 100644 -index 0000000000..c5ccf040c7 +index 0000000000..e191cbcee2 --- /dev/null +++ b/src/hotspot/cpu/riscv/gc/g1/g1BarrierSetAssembler_riscv.cpp -@@ -0,0 +1,475 @@ +@@ -0,0 +1,481 @@ +/* + * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. -+ * Copyright (c) 2020, 2022, Huawei Technologies Co., Ltd. All rights reserved. ++ * Copyright (c) 2020, 2021, Huawei Technologies Co., Ltd. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it @@ -13266,6 +13030,7 @@ index 0000000000..c5ccf040c7 + +void G1BarrierSetAssembler::gen_write_ref_array_pre_barrier(MacroAssembler* masm, DecoratorSet decorators, + Register addr, Register count, RegSet saved_regs) { ++ assert_cond(masm != NULL); + bool dest_uninitialized = (decorators & IS_DEST_UNINITIALIZED) != 0; + if (!dest_uninitialized) { + Label done; @@ -13308,6 +13073,7 @@ index 0000000000..c5ccf040c7 + +void G1BarrierSetAssembler::gen_write_ref_array_post_barrier(MacroAssembler* masm, DecoratorSet decorators, + Register start, Register count, Register tmp, RegSet saved_regs) { ++ assert_cond(masm != NULL); + __ push_reg(saved_regs, sp); + assert_different_registers(start, count, tmp); + assert_different_registers(c_rarg0, count); @@ -13328,6 +13094,7 @@ index 0000000000..c5ccf040c7 + // directly to skip generating the check by + // InterpreterMacroAssembler::call_VM_leaf_base that checks _last_sp. + ++ assert_cond(masm != NULL); + assert(thread == xthread, "must be"); + + Label done; @@ -13395,6 +13162,7 @@ index 0000000000..c5ccf040c7 + Register thread, + Register tmp, + Register tmp2) { ++ assert_cond(masm != NULL); + assert(thread == xthread, "must be"); + assert_different_registers(store_addr, new_val, thread, tmp, tmp2, + t0); @@ -13471,6 +13239,7 @@ index 0000000000..c5ccf040c7 + +void G1BarrierSetAssembler::load_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type, + Register dst, Address src, Register tmp1, Register tmp_thread) { ++ assert_cond(masm != NULL); + bool on_oop = is_reference_type(type); + bool on_weak = (decorators & ON_WEAK_OOP_REF) != 0; + bool on_phantom = (decorators & ON_PHANTOM_OOP_REF) != 0; @@ -13494,6 +13263,7 @@ index 0000000000..c5ccf040c7 + +void G1BarrierSetAssembler::oop_store_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type, + Address dst, Register val, Register tmp1, Register tmp2) { ++ assert_cond(masm != NULL); + // flatten object address if needed + if (dst.offset() == 0) { + if (dst.base() != x13) { @@ -13817,10 +13587,10 @@ index 0000000000..8735fd014f +#endif // CPU_RISCV_GC_G1_G1GLOBALS_RISCV_HPP diff --git a/src/hotspot/cpu/riscv/gc/shared/barrierSetAssembler_riscv.cpp b/src/hotspot/cpu/riscv/gc/shared/barrierSetAssembler_riscv.cpp new file mode 100644 -index 0000000000..2b439280fa +index 0000000000..2b556b95d7 --- /dev/null +++ b/src/hotspot/cpu/riscv/gc/shared/barrierSetAssembler_riscv.cpp -@@ -0,0 +1,225 @@ +@@ -0,0 +1,231 @@ +/* + * Copyright (c) 2018, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2022, Huawei Technologies Co., Ltd. All rights reserved. @@ -13862,6 +13632,8 @@ index 0000000000..2b439280fa + +void BarrierSetAssembler::load_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type, + Register dst, Address src, Register tmp1, Register tmp_thread) { ++ assert_cond(masm != NULL); ++ + // RA is live. It must be saved around calls. + + bool in_heap = (decorators & IN_HEAP) != 0; @@ -13902,6 +13674,7 @@ index 0000000000..2b439280fa + +void BarrierSetAssembler::store_at(MacroAssembler* masm, DecoratorSet decorators, BasicType type, + Address dst, Register val, Register tmp1, Register tmp2) { ++ assert_cond(masm != NULL); + bool in_heap = (decorators & IN_HEAP) != 0; + bool in_native = (decorators & IN_NATIVE) != 0; + switch (type) { @@ -13943,6 +13716,7 @@ index 0000000000..2b439280fa + +void BarrierSetAssembler::try_resolve_jobject_in_native(MacroAssembler* masm, Register jni_env, + Register obj, Register tmp, Label& slowpath) { ++ assert_cond(masm != NULL); + // If mask changes we need to ensure that the inverse is still encodable as an immediate + STATIC_ASSERT(JNIHandles::weak_tag_mask == 1); + __ andi(obj, obj, ~JNIHandles::weak_tag_mask); @@ -13957,6 +13731,7 @@ index 0000000000..2b439280fa + Register tmp2, + Label& slow_case, + bool is_far) { ++ assert_cond(masm != NULL); + assert_different_registers(obj, tmp2); + assert_different_registers(obj, var_size_in_bytes); + Register end = tmp2; @@ -14036,6 +13811,7 @@ index 0000000000..2b439280fa + Register var_size_in_bytes, + int con_size_in_bytes, + Register tmp1) { ++ assert_cond(masm != NULL); + assert(tmp1->is_valid(), "need temp reg"); + + __ ld(tmp1, Address(xthread, in_bytes(JavaThread::allocated_bytes_offset()))); @@ -14130,10 +13906,10 @@ index 0000000000..984d94f4c3 +#endif // CPU_RISCV_GC_SHARED_BARRIERSETASSEMBLER_RISCV_HPP diff --git a/src/hotspot/cpu/riscv/gc/shared/cardTableBarrierSetAssembler_riscv.cpp b/src/hotspot/cpu/riscv/gc/shared/cardTableBarrierSetAssembler_riscv.cpp new file mode 100644 -index 0000000000..671cad68b2 +index 0000000000..81d47d61d4 --- /dev/null +++ b/src/hotspot/cpu/riscv/gc/shared/cardTableBarrierSetAssembler_riscv.cpp -@@ -0,0 +1,122 @@ +@@ -0,0 +1,125 @@ +/* + * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2022, Huawei Technologies Co., Ltd. All rights reserved. @@ -14172,6 +13948,7 @@ index 0000000000..671cad68b2 + + +void CardTableBarrierSetAssembler::store_check(MacroAssembler* masm, Register obj, Register tmp) { ++ assert_cond(masm != NULL); + assert_different_registers(obj, tmp); + BarrierSet* bs = BarrierSet::barrier_set(); + assert(bs->kind() == BarrierSet::CardTableBarrierSet, "Wrong barrier set kind"); @@ -14204,6 +13981,7 @@ index 0000000000..671cad68b2 + +void CardTableBarrierSetAssembler::gen_write_ref_array_post_barrier(MacroAssembler* masm, DecoratorSet decorators, + Register start, Register count, Register tmp, RegSet saved_regs) { ++ assert_cond(masm != NULL); + assert_different_registers(start, tmp); + assert_different_registers(count, tmp); + @@ -14251,6 +14029,7 @@ index 0000000000..671cad68b2 + if (!precise || dst.offset() == 0) { + store_check(masm, dst.base(), x13); + } else { ++ assert_cond(masm != NULL); + __ la(x13, dst); + store_check(masm, x13, t0); + } @@ -14306,13 +14085,13 @@ index 0000000000..686fe8fa47 +#endif // #ifndef CPU_RISCV_GC_SHARED_CARDTABLEBARRIERSETASSEMBLER_RISCV_HPP diff --git a/src/hotspot/cpu/riscv/gc/shared/modRefBarrierSetAssembler_riscv.cpp b/src/hotspot/cpu/riscv/gc/shared/modRefBarrierSetAssembler_riscv.cpp new file mode 100644 -index 0000000000..4b7982eb21 +index 0000000000..7aa2015f9e --- /dev/null +++ b/src/hotspot/cpu/riscv/gc/shared/modRefBarrierSetAssembler_riscv.cpp -@@ -0,0 +1,54 @@ +@@ -0,0 +1,55 @@ +/* + * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. -+ * Copyright (c) 2020, 2022, Huawei Technologies Co., Ltd. All rights reserved. ++ * Copyright (c) 2020, 2021, Huawei Technologies Co., Ltd. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it @@ -14343,6 +14122,7 @@ index 0000000000..4b7982eb21 + +void ModRefBarrierSetAssembler::arraycopy_prologue(MacroAssembler* masm, DecoratorSet decorators, bool is_oop, + Register src, Register dst, Register count, RegSet saved_regs) { ++ + if (is_oop) { + gen_write_ref_array_pre_barrier(masm, decorators, dst, count, saved_regs); + } @@ -14550,7 +14330,7 @@ index 0000000000..d19f5b859c +} diff --git a/src/hotspot/cpu/riscv/gc/shenandoah/shenandoahBarrierSetAssembler_riscv.cpp b/src/hotspot/cpu/riscv/gc/shenandoah/shenandoahBarrierSetAssembler_riscv.cpp new file mode 100644 -index 0000000000..d73ea36b24 +index 0000000000..b8534c52e7 --- /dev/null +++ b/src/hotspot/cpu/riscv/gc/shenandoah/shenandoahBarrierSetAssembler_riscv.cpp @@ -0,0 +1,715 @@ @@ -15042,7 +14822,7 @@ index 0000000000..d73ea36b24 + if (is_cae) { + __ mv(result, expected); + } else { -+ __ mv(result, 1); ++ __ addi(result, zr, 1); + } + __ j(done); + @@ -15953,7 +15733,7 @@ index 0000000000..5bf40ca820 +#endif // CPU_RISCV_ICACHE_RISCV_HPP diff --git a/src/hotspot/cpu/riscv/interp_masm_riscv.cpp b/src/hotspot/cpu/riscv/interp_masm_riscv.cpp new file mode 100644 -index 0000000000..fa5ddc34b2 +index 0000000000..b50be7e726 --- /dev/null +++ b/src/hotspot/cpu/riscv/interp_masm_riscv.cpp @@ -0,0 +1,1931 @@ @@ -16471,7 +16251,7 @@ index 0000000000..fa5ddc34b2 + bnez(t1, safepoint); + } + if (table == Interpreter::dispatch_table(state)) { -+ mv(t1, Interpreter::distance_from_dispatch_table(state)); ++ li(t1, Interpreter::distance_from_dispatch_table(state)); + add(t1, Rs, t1); + shadd(t1, t1, xdispatch, t1, 3); + } else { @@ -16764,7 +16544,7 @@ index 0000000000..fa5ddc34b2 + // least significant 3 bits clear. + // NOTE: the oopMark is in swap_reg x10 as the result of cmpxchg + sub(swap_reg, swap_reg, sp); -+ mv(t0, (int64_t)(7 - os::vm_page_size())); ++ li(t0, (int64_t)(7 - os::vm_page_size())); + andr(swap_reg, swap_reg, t0); + + // Save the test result, for recursive case, the result is zero @@ -16865,7 +16645,7 @@ index 0000000000..fa5ddc34b2 +void InterpreterMacroAssembler::set_method_data_pointer_for_bcp() { + assert(ProfileInterpreter, "must be profiling interpreter"); + Label set_mdp; -+ push_reg(RegSet::of(x10, x11), sp); // save x10, x11 ++ push_reg(0xc00, sp); // save x10, x11 + + // Test MDO to avoid the call if it is NULL. + ld(x10, Address(xmethod, in_bytes(Method::method_data_offset()))); @@ -16878,7 +16658,7 @@ index 0000000000..fa5ddc34b2 + add(x10, x11, x10); + sd(x10, Address(fp, frame::interpreter_frame_mdp_offset * wordSize)); + bind(set_mdp); -+ pop_reg(RegSet::of(x10, x11), sp); ++ pop_reg(0xc00, sp); +} + +void InterpreterMacroAssembler::verify_method_data_pointer() { @@ -17616,7 +17396,7 @@ index 0000000000..fa5ddc34b2 + + ld(t0, mdo_addr); + beqz(t0, none); -+ mv(tmp, (u1)TypeEntries::null_seen); ++ li(tmp, (u1)TypeEntries::null_seen); + beq(t0, tmp, none); + // There is a chance that the checks above (re-reading profiling + // data from memory) fail if another thread has just set the @@ -17651,10 +17431,10 @@ index 0000000000..fa5ddc34b2 + + lbu(t0, Address(mdp, in_bytes(DataLayout::tag_offset()) - off_to_start)); + if (is_virtual) { -+ mv(tmp, (u1)DataLayout::virtual_call_type_data_tag); ++ li(tmp, (u1)DataLayout::virtual_call_type_data_tag); + bne(t0, tmp, profile_continue); + } else { -+ mv(tmp, (u1)DataLayout::call_type_data_tag); ++ li(tmp, (u1)DataLayout::call_type_data_tag); + bne(t0, tmp, profile_continue); + } + @@ -17684,7 +17464,7 @@ index 0000000000..fa5ddc34b2 + mv(index, zr); // index < TypeProfileArgsLimit + bind(loop); + bgtz(index, profileReturnType); -+ mv(t0, (int)MethodData::profile_return()); ++ li(t0, (int)MethodData::profile_return()); + beqz(t0, profileArgument); // (index > 0 || MethodData::profile_return()) == false + bind(profileReturnType); + // If return value type is profiled we may have no argument to profile @@ -17692,7 +17472,7 @@ index 0000000000..fa5ddc34b2 + mv(t1, - TypeStackSlotEntries::per_arg_count()); + mul(t1, index, t1); + add(tmp, tmp, t1); -+ mv(t1, TypeStackSlotEntries::per_arg_count()); ++ li(t1, TypeStackSlotEntries::per_arg_count()); + add(t0, mdp, off_to_args); + blt(tmp, t1, done); + @@ -17703,8 +17483,8 @@ index 0000000000..fa5ddc34b2 + // stack offset o (zero based) from the start of the argument + // list, for n arguments translates into offset n - o - 1 from + // the end of the argument list -+ mv(t0, stack_slot_offset0); -+ mv(t1, slot_step); ++ li(t0, stack_slot_offset0); ++ li(t1, slot_step); + mul(t1, index, t1); + add(t0, t0, t1); + add(t0, mdp, t0); @@ -17714,8 +17494,8 @@ index 0000000000..fa5ddc34b2 + Address arg_addr = argument_address(tmp); + ld(tmp, arg_addr); + -+ mv(t0, argument_type_offset0); -+ mv(t1, type_step); ++ li(t0, argument_type_offset0); ++ li(t1, type_step); + mul(t1, index, t1); + add(t0, t0, t1); + add(mdo_addr, mdp, t0); @@ -17727,7 +17507,7 @@ index 0000000000..fa5ddc34b2 + + // increment index by 1 + addi(index, index, 1); -+ mv(t1, TypeProfileArgsLimit); ++ li(t1, TypeProfileArgsLimit); + blt(index, t1, loop); + bind(loopEnd); + @@ -17782,13 +17562,13 @@ index 0000000000..fa5ddc34b2 + // length + Label do_profile; + lbu(t0, Address(xbcp, 0)); -+ mv(tmp, (u1)Bytecodes::_invokedynamic); ++ li(tmp, (u1)Bytecodes::_invokedynamic); + beq(t0, tmp, do_profile); -+ mv(tmp, (u1)Bytecodes::_invokehandle); ++ li(tmp, (u1)Bytecodes::_invokehandle); + beq(t0, tmp, do_profile); + get_method(tmp); + lhu(t0, Address(tmp, Method::intrinsic_id_offset_in_bytes())); -+ mv(t1, vmIntrinsics::_compiledLambdaForm); ++ li(t1, vmIntrinsics::_compiledLambdaForm); + bne(t0, t1, profile_continue); + bind(do_profile); + } @@ -18179,10 +17959,10 @@ index 0000000000..4126e8ee70 +#endif // CPU_RISCV_INTERP_MASM_RISCV_HPP diff --git a/src/hotspot/cpu/riscv/interpreterRT_riscv.cpp b/src/hotspot/cpu/riscv/interpreterRT_riscv.cpp new file mode 100644 -index 0000000000..b5e6b8c512 +index 0000000000..776b078723 --- /dev/null +++ b/src/hotspot/cpu/riscv/interpreterRT_riscv.cpp -@@ -0,0 +1,305 @@ +@@ -0,0 +1,295 @@ +/* + * Copyright (c) 2003, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2020, Red Hat Inc. All rights reserved. @@ -18259,16 +18039,6 @@ index 0000000000..b5e6b8c512 + _stack_offset = 0; +} + -+// The C ABI specifies: -+// "integer scalars narrower than XLEN bits are widened according to the sign -+// of their type up to 32 bits, then sign-extended to XLEN bits." -+// Applies for both passed in register and stack. -+// -+// Java uses 32-bit stack slots; jint, jshort, jchar, jbyte uses one slot. -+// Native uses 64-bit stack slots for all integer scalar types. -+// -+// lw loads the Java stack slot, sign-extends and -+// sd store this widened integer into a 64 bit native stack slot. +void InterpreterRuntime::SignatureHandlerGenerator::pass_int() { + const Address src(from(), Interpreter::local_offset_in_bytes(offset())); + @@ -18277,7 +18047,7 @@ index 0000000000..b5e6b8c512 + __ lw(reg, src); + } else { + __ lw(x10, src); -+ __ sd(x10, Address(to(), next_stack_offset())); ++ __ sw(x10, Address(to(), next_stack_offset())); + } +} + @@ -18971,10 +18741,10 @@ index 0000000000..df3c0267ee +#endif // CPU_RISCV_JNITYPES_RISCV_HPP diff --git a/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp b/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp new file mode 100644 -index 0000000000..14e07036ac +index 0000000000..e18bd3d8e2 --- /dev/null +++ b/src/hotspot/cpu/riscv/macroAssembler_riscv.cpp -@@ -0,0 +1,5390 @@ +@@ -0,0 +1,5410 @@ +/* + * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2020, Red Hat Inc. All rights reserved. @@ -19040,24 +18810,28 @@ index 0000000000..14e07036ac + +static void pass_arg0(MacroAssembler* masm, Register arg) { + if (c_rarg0 != arg) { ++ assert_cond(masm != NULL); + masm->mv(c_rarg0, arg); + } +} + +static void pass_arg1(MacroAssembler* masm, Register arg) { + if (c_rarg1 != arg) { ++ assert_cond(masm != NULL); + masm->mv(c_rarg1, arg); + } +} + +static void pass_arg2(MacroAssembler* masm, Register arg) { + if (c_rarg2 != arg) { ++ assert_cond(masm != NULL); + masm->mv(c_rarg2, arg); + } +} + +static void pass_arg3(MacroAssembler* masm, Register arg) { + if (c_rarg3 != arg) { ++ assert_cond(masm != NULL); + masm->mv(c_rarg3, arg); + } +} @@ -19232,6 +19006,7 @@ index 0000000000..14e07036ac + if (L.is_bound()) { + set_last_Java_frame(last_java_sp, last_java_fp, target(L), tmp); + } else { ++ InstructionMark im(this); + L.add_patch_at(code(), locator()); + set_last_Java_frame(last_java_sp, last_java_fp, pc() /* Patched later */, tmp); + } @@ -19364,7 +19139,7 @@ index 0000000000..14e07036ac + // The length of the instruction sequence emitted should be independent + // of the values of the local char buffer address so that the size of mach + // nodes for scratch emit and normal emit matches. -+ movptr(t0, (address)b); ++ mv(t0, (address)b); + + // call indirectly to solve generation ordering problem + int32_t offset = 0; @@ -19403,7 +19178,7 @@ index 0000000000..14e07036ac + // The length of the instruction sequence emitted should be independent + // of the values of the local char buffer address so that the size of mach + // nodes for scratch emit and normal emit matches. -+ movptr(t0, (address)b); ++ mv(t0, (address)b); + + // call indirectly to solve generation ordering problem + int32_t offset = 0; @@ -19724,13 +19499,15 @@ index 0000000000..14e07036ac +} + +void MacroAssembler::la(Register Rd, const Address &adr) { ++ InstructionMark im(this); ++ code_section()->relocate(inst_mark(), adr.rspec()); ++ relocInfo::relocType rtype = adr.rspec().reloc()->type(); ++ + switch (adr.getMode()) { + case Address::literal: { -+ relocInfo::relocType rtype = adr.rspec().reloc()->type(); + if (rtype == relocInfo::none) { -+ mv(Rd, (intptr_t)(adr.target())); ++ li(Rd, (intptr_t)(adr.target())); + } else { -+ relocate(adr.rspec()); + movptr(Rd, adr.target()); + } + break; @@ -19937,7 +19714,7 @@ index 0000000000..14e07036ac + return count; +} + -+// Push integer registers in the bitset supplied. Don't push sp. ++// Push lots of registers in the bit set supplied. Don't push sp. +// Return the number of words pushed +int MacroAssembler::push_reg(unsigned int bitset, Register stack) { + DEBUG_ONLY(int words_pushed = 0;) @@ -19949,11 +19726,11 @@ index 0000000000..14e07036ac + int offset = is_even(count) ? 0 : wordSize; + + if (count) { -+ addi(stack, stack, -count * wordSize - offset); ++ addi(stack, stack, - count * wordSize - offset); + } + for (int i = count - 1; i >= 0; i--) { + sd(as_Register(regs[i]), Address(stack, (count - 1 - i) * wordSize + offset)); -+ DEBUG_ONLY(words_pushed++;) ++ DEBUG_ONLY(words_pushed ++;) + } + + assert(words_pushed == count, "oops, pushed != count"); @@ -19972,7 +19749,7 @@ index 0000000000..14e07036ac + + for (int i = count - 1; i >= 0; i--) { + ld(as_Register(regs[i]), Address(stack, (count - 1 - i) * wordSize + offset)); -+ DEBUG_ONLY(words_popped++;) ++ DEBUG_ONLY(words_popped ++;) + } + + if (count) { @@ -19983,11 +19760,11 @@ index 0000000000..14e07036ac + return count; +} + -+// Push floating-point registers in the bitset supplied. -+// Return the number of words pushed ++// Push float registers in the bitset, except sp. ++// Return the number of heapwords pushed. +int MacroAssembler::push_fp(unsigned int bitset, Register stack) { + CompressibleRegion cr(this); -+ DEBUG_ONLY(int words_pushed = 0;) ++ int words_pushed = 0; + unsigned char regs[32]; + int count = bitset_to_regs(bitset, regs); + int push_slots = count + (count & 1); @@ -19998,24 +19775,23 @@ index 0000000000..14e07036ac + + for (int i = count - 1; i >= 0; i--) { + fsd(as_FloatRegister(regs[i]), Address(stack, (push_slots - 1 - i) * wordSize)); -+ DEBUG_ONLY(words_pushed++;) ++ words_pushed++; + } + + assert(words_pushed == count, "oops, pushed(%d) != count(%d)", words_pushed, count); -+ + return count; +} + +int MacroAssembler::pop_fp(unsigned int bitset, Register stack) { + CompressibleRegion cr(this); -+ DEBUG_ONLY(int words_popped = 0;) ++ int words_popped = 0; + unsigned char regs[32]; + int count = bitset_to_regs(bitset, regs); + int pop_slots = count + (count & 1); + + for (int i = count - 1; i >= 0; i--) { + fld(as_FloatRegister(regs[i]), Address(stack, (pop_slots - 1 - i) * wordSize)); -+ DEBUG_ONLY(words_popped++;) ++ words_popped++; + } + + if (count) { @@ -20023,7 +19799,6 @@ index 0000000000..14e07036ac + } + + assert(words_popped == count, "oops, popped(%d) != count(%d)", words_popped, count); -+ + return count; +} + @@ -20037,7 +19812,7 @@ index 0000000000..14e07036ac + int offset = 0; + for (int i = 0; i < 32; i++) { + if (i <= f7->encoding() || i >= f28->encoding() || (i >= f10->encoding() && i <= f17->encoding())) { -+ fsd(as_FloatRegister(i), Address(sp, wordSize * (offset++))); ++ fsd(as_FloatRegister(i), Address(sp, wordSize * (offset ++))); + } + } +} @@ -20047,7 +19822,7 @@ index 0000000000..14e07036ac + int offset = 0; + for (int i = 0; i < 32; i++) { + if (i <= f7->encoding() || i >= f28->encoding() || (i >= f10->encoding() && i <= f17->encoding())) { -+ fld(as_FloatRegister(i), Address(sp, wordSize * (offset++))); ++ fld(as_FloatRegister(i), Address(sp, wordSize * (offset ++))); + } + } + addi(sp, sp, wordSize * 20); @@ -20058,19 +19833,19 @@ index 0000000000..14e07036ac +// Push all the integer registers, except zr(x0) & sp(x2) & gp(x3) & tp(x4). +void MacroAssembler::pusha() { + CompressibleRegion cr(this); -+ push_reg(RegSet::of(x1) + RegSet::range(x5, x31), sp); ++ push_reg(0xffffffe2, sp); +} + +// Pop all the integer registers, except zr(x0) & sp(x2) & gp(x3) & tp(x4). +void MacroAssembler::popa() { + CompressibleRegion cr(this); -+ pop_reg(RegSet::of(x1) + RegSet::range(x5, x31), sp); ++ pop_reg(0xffffffe2, sp); +} + +void MacroAssembler::push_CPU_state() { + CompressibleRegion cr(this); + // integer registers, except zr(x0) & ra(x1) & sp(x2) & gp(x3) & tp(x4) -+ push_reg(RegSet::range(x5, x31), sp); ++ push_reg(0xffffffe0, sp); + + // float registers + addi(sp, sp, - 32 * wordSize); @@ -20089,7 +19864,7 @@ index 0000000000..14e07036ac + addi(sp, sp, 32 * wordSize); + + // integer registers, except zr(x0) & ra(x1) & sp(x2) & gp(x3) & tp(x4) -+ pop_reg(RegSet::range(x5, x31), sp); ++ pop_reg(0xffffffe0, sp); +} + +static int patch_offset_in_jal(address branch, int64_t offset) { @@ -20128,6 +19903,27 @@ index 0000000000..14e07036ac + return MOVPTR_INSTRUCTIONS_NUM * NativeInstruction::instruction_size; +} + ++static int patch_imm_in_li64(address branch, address target) { ++ const int LI64_INSTRUCTIONS_NUM = 8; // lui + addi + slli + addi + slli + addi + slli + addi ++ int64_t lower = (intptr_t)target & 0xffffffff; ++ lower = lower - ((lower << 44) >> 44); ++ int64_t tmp_imm = ((uint64_t)((intptr_t)target & 0xffffffff00000000)) + (uint64_t)lower; ++ int32_t upper = (tmp_imm - (int32_t)lower) >> 32; ++ int64_t tmp_upper = upper, tmp_lower = upper; ++ tmp_lower = (tmp_lower << 52) >> 52; ++ tmp_upper -= tmp_lower; ++ tmp_upper >>= 12; ++ // Load upper 32 bits. Upper = target[63:32], but if target[31] = 1 or (target[31:28] == 0x7ff && target[19] == 1), ++ // upper = target[63:32] + 1. ++ Assembler::patch(branch + 0, 31, 12, tmp_upper & 0xfffff); // Lui. ++ Assembler::patch(branch + 4, 31, 20, tmp_lower & 0xfff); // Addi. ++ // Load the rest 32 bits. ++ Assembler::patch(branch + 12, 31, 20, ((int32_t)lower >> 20) & 0xfff); // Addi. ++ Assembler::patch(branch + 20, 31, 20, (((intptr_t)target << 44) >> 52) & 0xfff); // Addi. ++ Assembler::patch(branch + 28, 31, 20, (intptr_t)target & 0xff); // Addi. ++ return LI64_INSTRUCTIONS_NUM * NativeInstruction::instruction_size; ++} ++ +static int patch_imm_in_li32(address branch, int32_t target) { + const int LI32_INSTRUCTIONS_NUM = 2; // lui + addiw + int64_t upper = (intptr_t)target; @@ -20182,6 +19978,16 @@ index 0000000000..14e07036ac + return (address) target_address; +} + ++static address get_target_of_li64(address insn_addr) { ++ assert_cond(insn_addr != NULL); ++ intptr_t target_address = (((int64_t)Assembler::sextract(((unsigned*)insn_addr)[0], 31, 12)) & 0xfffff) << 44; // Lui. ++ target_address += ((int64_t)Assembler::sextract(((unsigned*)insn_addr)[1], 31, 20)) << 32; // Addi. ++ target_address += ((int64_t)Assembler::sextract(((unsigned*)insn_addr)[3], 31, 20)) << 20; // Addi. ++ target_address += ((int64_t)Assembler::sextract(((unsigned*)insn_addr)[5], 31, 20)) << 8; // Addi. ++ target_address += ((int64_t)Assembler::sextract(((unsigned*)insn_addr)[7], 31, 20)); // Addi. ++ return (address)target_address; ++} ++ +static address get_target_of_li32(address insn_addr) { + assert_cond(insn_addr != NULL); + intptr_t target_address = (((int64_t)Assembler::sextract(((unsigned*)insn_addr)[0], 31, 12)) & 0xfffff) << 12; // Lui. @@ -20202,6 +20008,8 @@ index 0000000000..14e07036ac + return patch_offset_in_pc_relative(branch, offset); + } else if (NativeInstruction::is_movptr_at(branch)) { // movptr + return patch_addr_in_movptr(branch, target); ++ } else if (NativeInstruction::is_li64_at(branch)) { // li64 ++ return patch_imm_in_li64(branch, target); + } else if (NativeInstruction::is_li32_at(branch)) { // li32 + int64_t imm = (intptr_t)target; + return patch_imm_in_li32(branch, (int32_t)imm); @@ -20227,6 +20035,8 @@ index 0000000000..14e07036ac + offset = get_offset_of_pc_relative(insn_addr); + } else if (NativeInstruction::is_movptr_at(insn_addr)) { // movptr + return get_target_of_movptr(insn_addr); ++ } else if (NativeInstruction::is_li64_at(insn_addr)) { // li64 ++ return get_target_of_li64(insn_addr); + } else if (NativeInstruction::is_li32_at(insn_addr)) { // li32 + return get_target_of_li32(insn_addr); + } else { @@ -20265,10 +20075,16 @@ index 0000000000..14e07036ac + +void MacroAssembler::mv(Register Rd, Address dest) { + assert(dest.getMode() == Address::literal, "Address mode should be Address::literal"); -+ relocate(dest.rspec()); ++ code_section()->relocate(pc(), dest.rspec()); + movptr(Rd, dest.target()); +} + ++void MacroAssembler::mv(Register Rd, address addr) { ++ // Here in case of use with relocation, use fix length instruction ++ // movptr instead of li ++ movptr(Rd, addr); ++} ++ +void MacroAssembler::mv(Register Rd, RegisterOrConstant src) { + if (src.is_register()) { + mv(Rd, src.as_register()); @@ -20508,7 +20324,7 @@ index 0000000000..14e07036ac + and_imm12(Rd, Rn, imm); + } else { + assert_different_registers(Rn, tmp); -+ mv(tmp, imm); ++ li(tmp, imm); + andr(Rd, Rn, tmp); + } +} @@ -20522,7 +20338,7 @@ index 0000000000..14e07036ac + ori(tmp1, tmp1, src.as_constant()); + } else { + assert_different_registers(tmp1, tmp2); -+ mv(tmp2, src.as_constant()); ++ li(tmp2, src.as_constant()); + orr(tmp1, tmp1, tmp2); + } + } @@ -20611,6 +20427,7 @@ index 0000000000..14e07036ac +} + +SkipIfEqual::SkipIfEqual(MacroAssembler* masm, const bool* flag_addr, bool value) { ++ assert_cond(masm != NULL); + int32_t offset = 0; + _masm = masm; + _masm->la_patchable(t0, ExternalAddress((address)flag_addr), offset); @@ -20619,6 +20436,7 @@ index 0000000000..14e07036ac +} + +SkipIfEqual::~SkipIfEqual() { ++ assert_cond(_masm != NULL); + _masm->bind(_label); + _masm = NULL; +} @@ -20749,7 +20567,7 @@ index 0000000000..14e07036ac + } + + assert_different_registers(src, xbase); -+ mv(xbase, (uintptr_t)Universe::narrow_klass_base()); ++ li(xbase, (uintptr_t)Universe::narrow_klass_base()); + + if (Universe::narrow_klass_shift() != 0) { + assert(LogKlassAlignmentInBytes == Universe::narrow_klass_shift(), "decode alg wrong"); @@ -20791,7 +20609,7 @@ index 0000000000..14e07036ac + } + + assert_different_registers(src, xbase); -+ mv(xbase, (intptr_t)Universe::narrow_klass_base()); ++ li(xbase, (intptr_t)Universe::narrow_klass_base()); + sub(dst, src, xbase); + if (Universe::narrow_klass_shift() != 0) { + assert(LogKlassAlignmentInBytes == Universe::narrow_klass_shift(), "decode alg wrong"); @@ -20944,7 +20762,7 @@ index 0000000000..14e07036ac + if (itable_index.is_register()) { + slli(t0, itable_index.as_register(), 3); + } else { -+ mv(t0, itable_index.as_constant() << 3); ++ li(t0, itable_index.as_constant() << 3); + } + add(recv_klass, recv_klass, t0); + if (itentry_off) { @@ -21135,10 +20953,10 @@ index 0000000000..14e07036ac + andi(aligned_addr, addr, ~3); + + if (size == int8) { -+ mv(mask, 0xff); ++ addi(mask, zr, 0xff); + } else { + // size == int16 case -+ mv(mask, -1); ++ addi(mask, zr, -1); + zero_extend(mask, mask, 16); + } + sll(mask, mask, shift); @@ -21178,7 +20996,7 @@ index 0000000000..14e07036ac + bnez(tmp, retry); + + if (result_as_bool) { -+ mv(result, 1); ++ addi(result, zr, 1); + j(done); + + bind(fail); @@ -21213,7 +21031,7 @@ index 0000000000..14e07036ac + assert_different_registers(addr, old, mask, not_mask, new_val, expected, shift, tmp); + cmpxchg_narrow_value_helper(addr, expected, new_val, size, tmp1, tmp2, tmp3); + -+ Label fail, done; ++ Label succ, fail, done; + + lr_w(old, aligned_addr, acquire); + andr(tmp, old, mask); @@ -21222,14 +21040,13 @@ index 0000000000..14e07036ac + andr(tmp, old, not_mask); + orr(tmp, tmp, new_val); + sc_w(tmp, tmp, aligned_addr, release); -+ bnez(tmp, fail); ++ beqz(tmp, succ); + -+ // Success -+ mv(result, 1); ++ bind(fail); ++ addi(result, zr, 1); + j(done); + -+ // Fail -+ bind(fail); ++ bind(succ); + mv(result, zr); + + bind(done); @@ -21251,7 +21068,7 @@ index 0000000000..14e07036ac + + // equal, succeed + if (result_as_bool) { -+ mv(result, 1); ++ li(result, 1); + } else { + mv(result, expected); + } @@ -21273,20 +21090,20 @@ index 0000000000..14e07036ac + enum operand_size size, + Assembler::Aqrl acquire, Assembler::Aqrl release, + Register result) { -+ Label fail, done; ++ Label fail, done, sc_done; + load_reserved(addr, size, acquire); + bne(t0, expected, fail); + store_conditional(addr, new_val, size, release); -+ bnez(t0, fail); ++ beqz(t0, sc_done); + -+ // Success -+ mv(result, 1); -+ j(done); -+ -+ // Fail ++ // fail + bind(fail); -+ mv(result, zr); ++ li(result, 1); ++ j(done); + ++ // sc_done ++ bind(sc_done); ++ mv(result, 0); + bind(done); +} + @@ -21528,7 +21345,7 @@ index 0000000000..14e07036ac + add(x15, x15, Array::base_offset_in_bytes()); + + // Set t0 to an obvious invalid value, falling through by default -+ mv(t0, -1); ++ li(t0, -1); + // Scan X12 words at [X15] for an occurrence of X10. + repne_scan(x15, x10, x12, t0); + @@ -21585,10 +21402,11 @@ index 0000000000..14e07036ac + RegSet::range(x28, x31) + ra - thread; + push_reg(saved_regs, sp); + -+ mv(ra, CAST_FROM_FN_PTR(address, Thread::current)); -+ jalr(ra); -+ if (thread != c_rarg0) { -+ mv(thread, c_rarg0); ++ int32_t offset = 0; ++ movptr_with_offset(ra, CAST_FROM_FN_PTR(address, Thread::current), offset); ++ jalr(ra, ra, offset); ++ if (thread != x10) { ++ mv(thread, x10); + } + + // restore pushed registers @@ -21598,7 +21416,7 @@ index 0000000000..14e07036ac +void MacroAssembler::load_byte_map_base(Register reg) { + jbyte *byte_map_base = + ((CardTableBarrierSet*)(BarrierSet::barrier_set()))->card_table()->byte_map_base(); -+ mv(reg, (uint64_t)byte_map_base); ++ li(reg, (uint64_t)byte_map_base); +} + +void MacroAssembler::la_patchable(Register reg1, const Address &dest, int32_t &offset) { @@ -21612,7 +21430,8 @@ index 0000000000..14e07036ac + assert(is_valid_riscv64_address(dest.target()), "bad address"); + assert(dest.getMode() == Address::literal, "la_patchable must be applied to a literal address"); + -+ relocate(dest.rspec()); ++ InstructionMark im(this); ++ code_section()->relocate(inst_mark(), dest.rspec()); + // RISC-V doesn't compute a page-aligned address, in order to partially + // compensate for the use of *signed* offsets in its base+disp12 + // addressing mode (RISC-V's PC-relative reach remains asymmetric @@ -21906,7 +21725,7 @@ index 0000000000..14e07036ac +// Read the polling page. The address of the polling page must +// already be in r. +void MacroAssembler::read_polling_page(Register dest, int32_t offset, relocInfo::relocType rtype) { -+ relocate(rtype); ++ code_section()->relocate(pc(), rtype); + lwu(zr, Address(dest, offset)); +} + @@ -21921,7 +21740,9 @@ index 0000000000..14e07036ac + } +#endif + int oop_index = oop_recorder()->find_index(obj); -+ relocate(oop_Relocation::spec(oop_index)); ++ InstructionMark im(this); ++ RelocationHolder rspec = oop_Relocation::spec(oop_index); ++ code_section()->relocate(inst_mark(), rspec); + li32(dst, 0xDEADBEEF); + zero_extend(dst, dst, 32); +} @@ -21932,8 +21753,10 @@ index 0000000000..14e07036ac + int index = oop_recorder()->find_index(k); + assert(!Universe::heap()->is_in_reserved(k), "should not be an oop"); + ++ InstructionMark im(this); ++ RelocationHolder rspec = metadata_Relocation::spec(index); ++ code_section()->relocate(inst_mark(), rspec); + narrowKlass nk = Klass::encode_klass(k); -+ relocate(metadata_Relocation::spec(index)); + li32(dst, nk); + zero_extend(dst, dst, 32); +} @@ -21968,11 +21791,6 @@ index 0000000000..14e07036ac + } + + if (cbuf != NULL) { cbuf->set_insts_mark(); } -+#ifdef ASSERT -+ if (entry.rspec().type() != relocInfo::runtime_call_type) { -+ assert_alignment(pc()); -+ } -+#endif + relocate(entry.rspec()); + if (!far_branches()) { + jal(entry.target()); @@ -22055,47 +21873,19 @@ index 0000000000..14e07036ac + } +} + -+void MacroAssembler::increment(const Address dst, int64_t value) { -+ assert(((dst.getMode() == Address::base_plus_offset && -+ is_offset_in_range(dst.offset(), 12)) || is_imm_in_range(value, 12, 0)), -+ "invalid value and address mode combination"); ++void MacroAssembler::add_memory_int64(const Address dst, int64_t imm) { + Address adr = add_memory_helper(dst); -+ assert(!adr.uses(t0), "invalid dst for address increment"); ++ assert_different_registers(adr.base(), t0); + ld(t0, adr); -+ add(t0, t0, value, t1); ++ addi(t0, t0, imm); + sd(t0, adr); +} + -+void MacroAssembler::incrementw(const Address dst, int32_t value) { -+ assert(((dst.getMode() == Address::base_plus_offset && -+ is_offset_in_range(dst.offset(), 12)) || is_imm_in_range(value, 12, 0)), -+ "invalid value and address mode combination"); ++void MacroAssembler::add_memory_int32(const Address dst, int32_t imm) { + Address adr = add_memory_helper(dst); -+ assert(!adr.uses(t0), "invalid dst for address increment"); ++ assert_different_registers(adr.base(), t0); + lwu(t0, adr); -+ addw(t0, t0, value, t1); -+ sw(t0, adr); -+} -+ -+void MacroAssembler::decrement(const Address dst, int64_t value) { -+ assert(((dst.getMode() == Address::base_plus_offset && -+ is_offset_in_range(dst.offset(), 12)) || is_imm_in_range(value, 12, 0)), -+ "invalid value and address mode combination"); -+ Address adr = add_memory_helper(dst); -+ assert(!adr.uses(t0), "invalid dst for address decrement"); -+ ld(t0, adr); -+ sub(t0, t0, value, t1); -+ sd(t0, adr); -+} -+ -+void MacroAssembler::decrementw(const Address dst, int32_t value) { -+ assert(((dst.getMode() == Address::base_plus_offset && -+ is_offset_in_range(dst.offset(), 12)) || is_imm_in_range(value, 12, 0)), -+ "invalid value and address mode combination"); -+ Address adr = add_memory_helper(dst); -+ assert(!adr.uses(t0), "invalid dst for address decrement"); -+ lwu(t0, adr); -+ subw(t0, t0, value, t1); ++ addiw(t0, t0, imm); + sw(t0, adr); +} + @@ -22175,7 +21965,7 @@ index 0000000000..14e07036ac + add(in, in, t0); + + const int unroll = 8; -+ mv(tmp, unroll); ++ li(tmp, unroll); + blt(len, tmp, L_tail_loop); + bind(L_unroll); + for (int i = 0; i < unroll; i++) { @@ -22665,7 +22455,7 @@ index 0000000000..14e07036ac + assert_different_registers(Rd, Rs, tmp1, tmp2); + Label Loop; + int step = isLL ? 8 : 16; -+ mv(Rd, -step); ++ li(Rd, -step); + mv(tmp2, Rs); + + bind(Loop); @@ -22682,7 +22472,7 @@ index 0000000000..14e07036ac +void MacroAssembler::inflate_lo32(Register Rd, Register Rs, Register tmp1, Register tmp2) +{ + assert_different_registers(Rd, Rs, tmp1, tmp2); -+ mv(tmp1, 0xFF); ++ li(tmp1, 0xFF); + mv(Rd, zr); + for (int i = 0; i <= 3; i++) + { @@ -22704,7 +22494,7 @@ index 0000000000..14e07036ac +void MacroAssembler::inflate_hi32(Register Rd, Register Rs, Register tmp1, Register tmp2) +{ + assert_different_registers(Rd, Rs, tmp1, tmp2); -+ mv(tmp1, 0xFF00000000); ++ li(tmp1, 0xFF00000000); + mv(Rd, zr); + for (int i = 0; i <= 3; i++) + { @@ -22802,7 +22592,7 @@ index 0000000000..14e07036ac + Register cnt_reg = t0; + Register loop_base = t1; + cnt = cnt - remainder; -+ mv(cnt_reg, cnt); ++ li(cnt_reg, cnt); + add(loop_base, base, remainder * wordSize); + bind(loop); + sub(cnt_reg, cnt_reg, unroll); @@ -23858,7 +23648,7 @@ index 0000000000..14e07036ac + bind(L); + + // A very short string -+ mv(t0, minCharsInWord); ++ li(t0, minCharsInWord); + ble(cnt2, t0, SHORT_STRING); + + // Compare longwords @@ -23869,7 +23659,7 @@ index 0000000000..14e07036ac + ld(tmp1, Address(str1)); + beq(str1, str2, DONE); + ld(tmp2, Address(str2)); -+ mv(t0, STUB_THRESHOLD); ++ li(t0, STUB_THRESHOLD); + bge(cnt2, t0, STUB); + sub(cnt2, cnt2, minCharsInWord); + beqz(cnt2, TAIL_CHECK); @@ -23883,7 +23673,7 @@ index 0000000000..14e07036ac + } else if (isLU) { // LU case + lwu(tmp1, Address(str1)); + ld(tmp2, Address(str2)); -+ mv(t0, STUB_THRESHOLD); ++ li(t0, STUB_THRESHOLD); + bge(cnt2, t0, STUB); + addi(cnt2, cnt2, -4); + add(str1, str1, cnt2); @@ -23897,7 +23687,7 @@ index 0000000000..14e07036ac + } else { // UL case + ld(tmp1, Address(str1)); + lwu(tmp2, Address(str2)); -+ mv(t0, STUB_THRESHOLD); ++ li(t0, STUB_THRESHOLD); + bge(cnt2, t0, STUB); + addi(cnt2, cnt2, -4); + slli(t0, cnt2, 1); @@ -24073,7 +23863,7 @@ index 0000000000..14e07036ac + + assert(elem_size == 1 || elem_size == 2, "must be char or byte"); + assert_different_registers(a1, a2, result, cnt1, t0, t1, tmp3, tmp4, tmp5, tmp6); -+ mv(elem_per_word, wordSize / elem_size); ++ li(elem_per_word, wordSize / elem_size); + + BLOCK_COMMENT("arrays_equals {"); + @@ -24367,10 +24157,10 @@ index 0000000000..14e07036ac + diff --git a/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp b/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp new file mode 100644 -index 0000000000..eca18b51f3 +index 0000000000..c660bce437 --- /dev/null +++ b/src/hotspot/cpu/riscv/macroAssembler_riscv.hpp -@@ -0,0 +1,984 @@ +@@ -0,0 +1,966 @@ +/* + * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2020, Red Hat Inc. All rights reserved. @@ -24402,7 +24192,6 @@ index 0000000000..eca18b51f3 + +#include "asm/assembler.hpp" +#include "metaprogramming/enableIf.hpp" -+#include "nativeInst_riscv.hpp" + +// MacroAssembler extends Assembler by frequently used macros. +// @@ -24447,9 +24236,6 @@ index 0000000000..eca18b51f3 + + // Alignment + void align(int modulus, int extra_offset = 0); -+ static inline void assert_alignment(address pc, int alignment = NativeInstruction::instruction_size) { -+ assert(is_aligned(pc, alignment), "bad alignment"); -+ } + + // Stack frame creation/removal + // Note that SP must be updated to the right place before saving/restoring RA and FP @@ -24871,17 +24657,12 @@ index 0000000000..eca18b51f3 + void double_blt(FloatRegister Rs1, FloatRegister Rs2, Label &l, bool is_far = false, bool is_unordered = false); + void double_bgt(FloatRegister Rs1, FloatRegister Rs2, Label &l, bool is_far = false, bool is_unordered = false); + -+private: -+ int push_reg(unsigned int bitset, Register stack); -+ int pop_reg(unsigned int bitset, Register stack); -+ int push_fp(unsigned int bitset, Register stack); -+ int pop_fp(unsigned int bitset, Register stack); -+ -+public: ++ void push_reg(RegSet regs, Register stack) { if (regs.bits()) { push_reg(regs.bits(), stack); } } ++ void pop_reg(RegSet regs, Register stack) { if (regs.bits()) { pop_reg(regs.bits(), stack); } } + void push_reg(Register Rs); + void pop_reg(Register Rd); -+ void push_reg(RegSet regs, Register stack) { if (regs.bits()) push_reg(regs.bits(), stack); } -+ void pop_reg(RegSet regs, Register stack) { if (regs.bits()) pop_reg(regs.bits(), stack); } ++ int push_reg(unsigned int bitset, Register stack); ++ int pop_reg(unsigned int bitset, Register stack); + + // Push and pop everything that might be clobbered by a native + // runtime call except t0 and t1. (They are always @@ -24912,8 +24693,6 @@ index 0000000000..eca18b51f3 + } + + // mv -+ void mv(Register Rd, address addr) { li(Rd, (int64_t)addr); } -+ + inline void mv(Register Rd, int imm64) { li(Rd, (int64_t)imm64); } + inline void mv(Register Rd, long imm64) { li(Rd, (int64_t)imm64); } + inline void mv(Register Rd, long long imm64) { li(Rd, (int64_t)imm64); } @@ -24924,6 +24703,7 @@ index 0000000000..eca18b51f3 + inline void mvw(Register Rd, int32_t imm32) { mv(Rd, imm32); } + + void mv(Register Rd, Address dest); ++ void mv(Register Rd, address dest); + void mv(Register Rd, RegisterOrConstant src); + + // logic @@ -25037,19 +24817,8 @@ index 0000000000..eca18b51f3 + address trampoline_call(Address entry, CodeBuffer* cbuf = NULL); + address ic_call(address entry, jint method_index = 0); + -+ // Support for memory inc/dec -+ // n.b. increment/decrement calls with an Address destination will -+ // need to use a scratch register to load the value to be -+ // incremented. increment/decrement calls which add or subtract a -+ // constant value other than sign-extended 12-bit immediate will need -+ // to use a 2nd scratch register to hold the constant. so, an address -+ // increment/decrement may trash both t0 and t1. -+ -+ void increment(const Address dst, int64_t value = 1); -+ void incrementw(const Address dst, int32_t value = 1); -+ -+ void decrement(const Address dst, int64_t value = 1); -+ void decrementw(const Address dst, int32_t value = 1); ++ void add_memory_int64(const Address dst, int64_t imm); ++ void add_memory_int32(const Address dst, int32_t imm); + + void cmpptr(Register src1, Address src2, Label& equal); + @@ -25187,6 +24956,9 @@ index 0000000000..eca18b51f3 + // if [src1 < src2], dst = -1; + void cmp_l2i(Register dst, Register src1, Register src2, Register tmp = t0); + ++ int push_fp(unsigned int bitset, Register stack); ++ int pop_fp(unsigned int bitset, Register stack); ++ + // vext + void vmnot_m(VectorRegister vd, VectorRegister vs); + void vncvt_x_x_w(VectorRegister vd, VectorRegister vs, VectorMask vm = unmasked); @@ -25394,10 +25166,10 @@ index 0000000000..ef968ccd96 +#endif // CPU_RISCV_MACROASSEMBLER_RISCV_INLINE_HPP diff --git a/src/hotspot/cpu/riscv/methodHandles_riscv.cpp b/src/hotspot/cpu/riscv/methodHandles_riscv.cpp new file mode 100644 -index 0000000000..3c4e8847ce +index 0000000000..fd907f77af --- /dev/null +++ b/src/hotspot/cpu/riscv/methodHandles_riscv.cpp -@@ -0,0 +1,444 @@ +@@ -0,0 +1,450 @@ +/* + * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, Red Hat Inc. All rights reserved. @@ -25447,6 +25219,7 @@ index 0000000000..3c4e8847ce +#define BIND(label) bind(label); BLOCK_COMMENT(#label ":") + +void MethodHandles::load_klass_from_Class(MacroAssembler* _masm, Register klass_reg) { ++ assert_cond(_masm != NULL); + if (VerifyMethodHandles) { + verify_klass(_masm, klass_reg, SystemDictionary::WK_KLASS_ENUM_NAME(java_lang_Class), + "MH argument is a Class"); @@ -25468,6 +25241,7 @@ index 0000000000..3c4e8847ce +void MethodHandles::verify_klass(MacroAssembler* _masm, + Register obj, SystemDictionary::WKID klass_id, + const char* error_message) { ++ assert_cond(_masm != NULL); + InstanceKlass** klass_addr = SystemDictionary::well_known_klass_addr(klass_id); + Klass* klass = SystemDictionary::well_known_klass(klass_id); + Register temp = t1; @@ -25496,6 +25270,7 @@ index 0000000000..3c4e8847ce + +void MethodHandles::jump_from_method_handle(MacroAssembler* _masm, Register method, Register temp, + bool for_compiler_entry) { ++ assert_cond(_masm != NULL); + assert(method == xmethod, "interpreter calling convention"); + Label L_no_such_method; + __ beqz(xmethod, L_no_such_method); @@ -25526,6 +25301,7 @@ index 0000000000..3c4e8847ce + Register recv, Register method_temp, + Register temp2, + bool for_compiler_entry) { ++ assert_cond(_masm != NULL); + BLOCK_COMMENT("jump_to_lambda_form {"); + // This is the initial entry point of a lazy method handle. + // After type checking, it picks up the invoker from the LambdaForm. @@ -25564,6 +25340,7 @@ index 0000000000..3c4e8847ce +// Code generation +address MethodHandles::generate_method_handle_interpreter_entry(MacroAssembler* _masm, + vmIntrinsics::ID iid) { ++ assert_cond(_masm != NULL); + const bool not_for_compiler_entry = false; // this is the interpreter entry + assert(is_signature_polymorphic(iid), "expected invoke iid"); + if (iid == vmIntrinsics::_invokeGeneric || @@ -25651,6 +25428,7 @@ index 0000000000..3c4e8847ce + Register receiver_reg, + Register member_reg, + bool for_compiler_entry) { ++ assert_cond(_masm != NULL); + assert(is_signature_polymorphic(iid), "expected invoke iid"); + // temps used in this code are not used in *either* compiled or interpreted calling sequences + Register temp1 = x7; @@ -25907,10 +25685,10 @@ index 0000000000..65493eba76 + bool for_compiler_entry); diff --git a/src/hotspot/cpu/riscv/nativeInst_riscv.cpp b/src/hotspot/cpu/riscv/nativeInst_riscv.cpp new file mode 100644 -index 0000000000..ecce8eb021 +index 0000000000..27011ad128 --- /dev/null +++ b/src/hotspot/cpu/riscv/nativeInst_riscv.cpp -@@ -0,0 +1,414 @@ +@@ -0,0 +1,417 @@ +/* + * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2020, Red Hat Inc. All rights reserved. @@ -26015,6 +25793,18 @@ index 0000000000..ecce8eb021 + check_li32_data_dependency(instr); +} + ++bool NativeInstruction::is_li64_at(address instr) { ++ return is_lui_at(instr) && // lui ++ is_addi_at(instr + instruction_size) && // addi ++ is_slli_shift_at(instr + instruction_size * 2, 12) && // Slli Rd, Rs, 12 ++ is_addi_at(instr + instruction_size * 3) && // addi ++ is_slli_shift_at(instr + instruction_size * 4, 12) && // Slli Rd, Rs, 12 ++ is_addi_at(instr + instruction_size * 5) && // addi ++ is_slli_shift_at(instr + instruction_size * 6, 8) && // Slli Rd, Rs, 8 ++ is_addi_at(instr + instruction_size * 7) && // addi ++ check_li64_data_dependency(instr); ++} ++ +void NativeCall::verify() { + assert(NativeCall::is_call_at((address)this), "unexpected code at call site"); +} @@ -26165,13 +25955,6 @@ index 0000000000..ecce8eb021 + + +void NativeJump::check_verified_entry_alignment(address entry, address verified_entry) { -+ // Patching to not_entrant can happen while activations of the method are -+ // in use. The patching in that instance must happen only when certain -+ // alignment restrictions are true. These guarantees check those -+ // conditions. -+ -+ // Must be 4 bytes aligned -+ MacroAssembler::assert_alignment(verified_entry); +} + + @@ -26251,8 +26034,6 @@ index 0000000000..ecce8eb021 + nativeInstruction_at(verified_entry)->is_sigill_zombie_not_entrant(), + "riscv cannot replace non-jump with jump"); + -+ check_verified_entry_alignment(entry, verified_entry); -+ + // Patch this nmethod atomically. + if (Assembler::reachable_from_branch_at(verified_entry, dest)) { + ptrdiff_t offset = dest - verified_entry; @@ -26327,10 +26108,10 @@ index 0000000000..ecce8eb021 +} diff --git a/src/hotspot/cpu/riscv/nativeInst_riscv.hpp b/src/hotspot/cpu/riscv/nativeInst_riscv.hpp new file mode 100644 -index 0000000000..183ab85fc9 +index 0000000000..2e5c84ee3b --- /dev/null +++ b/src/hotspot/cpu/riscv/nativeInst_riscv.hpp -@@ -0,0 +1,520 @@ +@@ -0,0 +1,555 @@ +/* + * Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2018, Red Hat Inc. All rights reserved. @@ -26447,6 +26228,40 @@ index 0000000000..183ab85fc9 + extract_rs1(last_instr) == extract_rd(slli2); + } + ++ // the instruction sequence of li64 is as below: ++ // lui ++ // addi ++ // slli ++ // addi ++ // slli ++ // addi ++ // slli ++ // addi ++ static bool check_li64_data_dependency(address instr) { ++ address lui = instr; ++ address addi1 = lui + instruction_size; ++ address slli1 = addi1 + instruction_size; ++ address addi2 = slli1 + instruction_size; ++ address slli2 = addi2 + instruction_size; ++ address addi3 = slli2 + instruction_size; ++ address slli3 = addi3 + instruction_size; ++ address addi4 = slli3 + instruction_size; ++ return extract_rs1(addi1) == extract_rd(lui) && ++ extract_rs1(addi1) == extract_rd(addi1) && ++ extract_rs1(slli1) == extract_rd(addi1) && ++ extract_rs1(slli1) == extract_rd(slli1) && ++ extract_rs1(addi2) == extract_rd(slli1) && ++ 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(addi4) == extract_rd(slli3) && ++ extract_rs1(addi4) == extract_rd(addi4); ++ } ++ + // the instruction sequence of li32 is as below: + // lui + // addiw @@ -26481,6 +26296,7 @@ index 0000000000..183ab85fc9 + + static bool is_movptr_at(address instr); + static bool is_li32_at(address instr); ++ static bool is_li64_at(address instr); + static bool is_pc_relative_at(address branch); + static bool is_load_pc_relative_at(address branch); + @@ -27724,10 +27540,10 @@ index 0000000000..840ed935d8 +#endif // CPU_RISCV_RELOCINFO_RISCV_HPP diff --git a/src/hotspot/cpu/riscv/riscv.ad b/src/hotspot/cpu/riscv/riscv.ad new file mode 100644 -index 0000000000..d54ae97200 +index 0000000000..02d6167629 --- /dev/null +++ b/src/hotspot/cpu/riscv/riscv.ad -@@ -0,0 +1,10273 @@ +@@ -0,0 +1,10280 @@ +// +// Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. +// Copyright (c) 2014, 2020, Red Hat Inc. All rights reserved. @@ -27814,8 +27630,8 @@ index 0000000000..d54ae97200 +reg_def R0_H ( NS, NS, Op_RegI, 0, x0->as_VMReg()->next() ); +reg_def R1 ( NS, SOC, Op_RegI, 1, x1->as_VMReg() ); // ra +reg_def R1_H ( NS, SOC, Op_RegI, 1, x1->as_VMReg()->next() ); -+reg_def R2 ( NS, NS, Op_RegI, 2, x2->as_VMReg() ); // sp -+reg_def R2_H ( NS, NS, Op_RegI, 2, x2->as_VMReg()->next() ); ++reg_def R2 ( NS, SOE, Op_RegI, 2, x2->as_VMReg() ); // sp ++reg_def R2_H ( NS, SOE, Op_RegI, 2, x2->as_VMReg()->next() ); +reg_def R3 ( NS, NS, Op_RegI, 3, x3->as_VMReg() ); // gp +reg_def R3_H ( NS, NS, Op_RegI, 3, x3->as_VMReg()->next() ); +reg_def R4 ( NS, NS, Op_RegI, 4, x4->as_VMReg() ); // tp @@ -28793,7 +28609,6 @@ index 0000000000..d54ae97200 + + // insert a nop at the start of the prolog so we can patch in a + // branch if we need to invalidate the method later -+ MacroAssembler::assert_alignment(__ pc()); + __ nop(); + + assert_cond(C != NULL); @@ -29141,10 +28956,6 @@ index 0000000000..d54ae97200 + __ cmp_klass(j_rarg0, t1, t0, skip); + __ far_jump(RuntimeAddress(SharedRuntime::get_ic_miss_stub())); + __ bind(skip); -+ -+ // These NOPs are critical so that verified entry point is properly -+ // 4 bytes aligned for patching by NativeJump::patch_verified_entry() -+ __ align(NativeInstruction::instruction_size); +} + +uint MachUEPNode::size(PhaseRegAlloc* ra_) const @@ -29522,7 +29333,7 @@ index 0000000000..d54ae97200 + Assembler::CompressibleRegion cr(&_masm); + int64_t con = (int64_t)$src$$constant; + Register dst_reg = as_Register($dst$$reg); -+ __ mv(dst_reg, con); ++ __ li(dst_reg, con); + %} + + enc_class riscv_enc_mov_p(iRegP dst, immP src) %{ @@ -29539,7 +29350,7 @@ index 0000000000..d54ae97200 + __ mov_metadata(dst_reg, (Metadata*)con); + } else { + assert(rtype == relocInfo::none, "unexpected reloc type"); -+ __ mv(dst_reg, $src$$constant); ++ __ li(dst_reg, $src$$constant); + } + } + %} @@ -29548,7 +29359,7 @@ index 0000000000..d54ae97200 + MacroAssembler _masm(&cbuf); + Assembler::CompressibleRegion cr(&_masm); + Register dst_reg = as_Register($dst$$reg); -+ __ mv(dst_reg, 1); ++ __ li(dst_reg, 1); + %} + + enc_class riscv_enc_mov_poll_page(iRegP dst, immPollPage src) %{ @@ -29686,7 +29497,7 @@ index 0000000000..d54ae97200 + + __ bind(miss); + if (!$primary) { -+ __ mv(cr_reg, 1); ++ __ li(cr_reg, 1); + } + + __ bind(done); @@ -29825,7 +29636,7 @@ index 0000000000..d54ae97200 + // Check if the owner is self by comparing the value in the + // markWord of object (disp_hdr) with the stack pointer. + __ sub(disp_hdr, disp_hdr, sp); -+ __ mv(tmp, (intptr_t) (~(os::vm_page_size()-1) | (uintptr_t)markOopDesc::lock_mask_in_place)); ++ __ li(tmp, (intptr_t) (~(os::vm_page_size()-1) | (uintptr_t)markOopDesc::lock_mask_in_place)); + // If (mark & lock_mask) == 0 and mark - sp < page_size, we are stack-locking and goto cont, + // hence we can store 0 as the displaced header in the box, which indicates that it is a + // recursive lock. @@ -33199,13 +33010,14 @@ index 0000000000..d54ae97200 + + format %{ + "cmpxchg_weak $mem, $oldval, $newval\t# (byte, weak) if $mem == $oldval then $mem <-- $newval\n\t" -+ "# $res == 1 when success, #@weakCompareAndSwapB" ++ "xori $res, $res, 1\t# $res == 1 when success, #@weakCompareAndSwapB" + %} + + ins_encode %{ + __ weak_cmpxchg_narrow_value(as_Register($mem$$base), $oldval$$Register, $newval$$Register, Assembler::int8, + /*acquire*/ Assembler::relaxed, /*release*/ Assembler::rl, $res$$Register, + $tmp1$$Register, $tmp2$$Register, $tmp3$$Register); ++ __ xori($res$$Register, $res$$Register, 1); + %} + + ins_pipe(pipe_slow); @@ -33222,13 +33034,14 @@ index 0000000000..d54ae97200 + + format %{ + "cmpxchg_weak $mem, $oldval, $newval\t# (short, weak) if $mem == $oldval then $mem <-- $newval\n\t" -+ "# $res == 1 when success, #@weakCompareAndSwapS" ++ "xori $res, $res, 1\t# $res == 1 when success, #@weakCompareAndSwapS" + %} + + ins_encode %{ + __ weak_cmpxchg_narrow_value(as_Register($mem$$base), $oldval$$Register, $newval$$Register, Assembler::int16, + /*acquire*/ Assembler::relaxed, /*release*/ Assembler::rl, $res$$Register, + $tmp1$$Register, $tmp2$$Register, $tmp3$$Register); ++ __ xori($res$$Register, $res$$Register, 1); + %} + + ins_pipe(pipe_slow); @@ -33242,12 +33055,13 @@ index 0000000000..d54ae97200 + + format %{ + "cmpxchg_weak $mem, $oldval, $newval\t# (int, weak) if $mem == $oldval then $mem <-- $newval\n\t" -+ "# $res == 1 when success, #@weakCompareAndSwapI" ++ "xori $res, $res, 1\t# $res == 1 when success, #@weakCompareAndSwapI" + %} + + ins_encode %{ + __ cmpxchg_weak(as_Register($mem$$base), $oldval$$Register, $newval$$Register, Assembler::int32, + /*acquire*/ Assembler::relaxed, /*release*/ Assembler::rl, $res$$Register); ++ __ xori($res$$Register, $res$$Register, 1); + %} + + ins_pipe(pipe_slow); @@ -33261,12 +33075,13 @@ index 0000000000..d54ae97200 + + format %{ + "cmpxchg_weak $mem, $oldval, $newval\t# (long, weak) if $mem == $oldval then $mem <-- $newval\n\t" -+ "# $res == 1 when success, #@weakCompareAndSwapL" ++ "xori $res, $res, 1\t# $res == 1 when success, #@weakCompareAndSwapL" + %} + + ins_encode %{ + __ cmpxchg_weak(as_Register($mem$$base), $oldval$$Register, $newval$$Register, Assembler::int64, + /*acquire*/ Assembler::relaxed, /*release*/ Assembler::rl, $res$$Register); ++ __ xori($res$$Register, $res$$Register, 1); + %} + + ins_pipe(pipe_slow); @@ -33280,12 +33095,13 @@ index 0000000000..d54ae97200 + + format %{ + "cmpxchg_weak $mem, $oldval, $newval\t# (narrow oop, weak) if $mem == $oldval then $mem <-- $newval\n\t" -+ "# $res == 1 when success, #@weakCompareAndSwapN" ++ "xori $res, $res, 1\t# $res == 1 when success, #@weakCompareAndSwapN" + %} + + ins_encode %{ + __ cmpxchg_weak(as_Register($mem$$base), $oldval$$Register, $newval$$Register, Assembler::uint32, + /*acquire*/ Assembler::relaxed, /*release*/ Assembler::rl, $res$$Register); ++ __ xori($res$$Register, $res$$Register, 1); + %} + + ins_pipe(pipe_slow); @@ -33299,12 +33115,13 @@ index 0000000000..d54ae97200 + + format %{ + "cmpxchg_weak $mem, $oldval, $newval\t# (ptr, weak) if $mem == $oldval then $mem <-- $newval\n\t" -+ "# $res == 1 when success, #@weakCompareAndSwapP" ++ "xori $res, $res, 1\t# $res == 1 when success, #@weakCompareAndSwapP" + %} + + ins_encode %{ + __ cmpxchg_weak(as_Register($mem$$base), $oldval$$Register, $newval$$Register, Assembler::int64, + /*acquire*/ Assembler::relaxed, /*release*/ Assembler::rl, $res$$Register); ++ __ xori($res$$Register, $res$$Register, 1); + %} + + ins_pipe(pipe_slow); @@ -33323,13 +33140,14 @@ index 0000000000..d54ae97200 + + format %{ + "cmpxchg_weak_acq $mem, $oldval, $newval\t# (byte, weak) if $mem == $oldval then $mem <-- $newval\n\t" -+ "# $res == 1 when success, #@weakCompareAndSwapBAcq" ++ "xori $res, $res, 1\t# $res == 1 when success, #@weakCompareAndSwapBAcq" + %} + + ins_encode %{ + __ weak_cmpxchg_narrow_value(as_Register($mem$$base), $oldval$$Register, $newval$$Register, Assembler::int8, + /*acquire*/ Assembler::aq, /*release*/ Assembler::rl, $res$$Register, + $tmp1$$Register, $tmp2$$Register, $tmp3$$Register); ++ __ xori($res$$Register, $res$$Register, 1); + %} + + ins_pipe(pipe_slow); @@ -33348,13 +33166,14 @@ index 0000000000..d54ae97200 + + format %{ + "cmpxchg_weak_acq $mem, $oldval, $newval\t# (short, weak) if $mem == $oldval then $mem <-- $newval\n\t" -+ "# $res == 1 when success, #@weakCompareAndSwapSAcq" ++ "xori $res, $res, 1\t# $res == 1 when success, #@weakCompareAndSwapSAcq" + %} + + ins_encode %{ + __ weak_cmpxchg_narrow_value(as_Register($mem$$base), $oldval$$Register, $newval$$Register, Assembler::int16, + /*acquire*/ Assembler::aq, /*release*/ Assembler::rl, $res$$Register, + $tmp1$$Register, $tmp2$$Register, $tmp3$$Register); ++ __ xori($res$$Register, $res$$Register, 1); + %} + + ins_pipe(pipe_slow); @@ -33370,12 +33189,13 @@ index 0000000000..d54ae97200 + + format %{ + "cmpxchg_weak_acq $mem, $oldval, $newval\t# (int, weak) if $mem == $oldval then $mem <-- $newval\n\t" -+ "# $res == 1 when success, #@weakCompareAndSwapIAcq" ++ "xori $res, $res, 1\t# $res == 1 when success, #@weakCompareAndSwapIAcq" + %} + + ins_encode %{ + __ cmpxchg_weak(as_Register($mem$$base), $oldval$$Register, $newval$$Register, Assembler::int32, + /*acquire*/ Assembler::aq, /*release*/ Assembler::rl, $res$$Register); ++ __ xori($res$$Register, $res$$Register, 1); + %} + + ins_pipe(pipe_slow); @@ -33391,12 +33211,13 @@ index 0000000000..d54ae97200 + + format %{ + "cmpxchg_weak_acq $mem, $oldval, $newval\t# (long, weak) if $mem == $oldval then $mem <-- $newval\n\t" -+ "# $res == 1 when success, #@weakCompareAndSwapLAcq" ++ "xori $res, $res, 1\t# $res == 1 when success, #@weakCompareAndSwapLAcq" + %} + + ins_encode %{ + __ cmpxchg_weak(as_Register($mem$$base), $oldval$$Register, $newval$$Register, Assembler::int64, + /*acquire*/ Assembler::aq, /*release*/ Assembler::rl, $res$$Register); ++ __ xori($res$$Register, $res$$Register, 1); + %} + + ins_pipe(pipe_slow); @@ -33412,12 +33233,13 @@ index 0000000000..d54ae97200 + + format %{ + "cmpxchg_weak_acq $mem, $oldval, $newval\t# (narrow oop, weak) if $mem == $oldval then $mem <-- $newval\n\t" -+ "# $res == 1 when success, #@weakCompareAndSwapNAcq" ++ "xori $res, $res, 1\t# $res == 1 when success, #@weakCompareAndSwapNAcq" + %} + + ins_encode %{ + __ cmpxchg_weak(as_Register($mem$$base), $oldval$$Register, $newval$$Register, Assembler::uint32, + /*acquire*/ Assembler::aq, /*release*/ Assembler::rl, $res$$Register); ++ __ xori($res$$Register, $res$$Register, 1); + %} + + ins_pipe(pipe_slow); @@ -33433,12 +33255,13 @@ index 0000000000..d54ae97200 + + format %{ + "cmpxchg_weak_acq $mem, $oldval, $newval\t# (ptr, weak) if $mem == $oldval then $mem <-- $newval\n\t" -+ "\t# $res == 1 when success, #@weakCompareAndSwapPAcq" ++ "xori $res, $res, 1\t# $res == 1 when success, #@weakCompareAndSwapPAcq" + %} + + ins_encode %{ + __ cmpxchg_weak(as_Register($mem$$base), $oldval$$Register, $newval$$Register, Assembler::int64, + /*acquire*/ Assembler::aq, /*release*/ Assembler::rl, $res$$Register); ++ __ xori($res$$Register, $res$$Register, 1); + %} + + ins_pipe(pipe_slow); @@ -38476,10 +38299,10 @@ index 0000000000..7dda004cd3 \ No newline at end of file diff --git a/src/hotspot/cpu/riscv/sharedRuntime_riscv.cpp b/src/hotspot/cpu/riscv/sharedRuntime_riscv.cpp new file mode 100644 -index 0000000000..7b1112b388 +index 0000000000..f41a496093 --- /dev/null +++ b/src/hotspot/cpu/riscv/sharedRuntime_riscv.cpp -@@ -0,0 +1,2661 @@ +@@ -0,0 +1,2666 @@ +/* + * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2020, Red Hat Inc. All rights reserved. @@ -38611,6 +38434,7 @@ index 0000000000..7b1112b388 +}; + +OopMap* RegisterSaver::save_live_registers(MacroAssembler* masm, int additional_frame_words, int* total_frame_words) { ++ assert_cond(masm != NULL && total_frame_words != NULL); + int frame_size_in_bytes = align_up(additional_frame_words * wordSize + ra_offset_in_bytes() + wordSize, 16); + // OopMap frame size is in compiler stack slots (jint's) not bytes or words + int frame_size_in_slots = frame_size_in_bytes / BytesPerInt; @@ -38658,6 +38482,7 @@ index 0000000000..7b1112b388 +} + +void RegisterSaver::restore_live_registers(MacroAssembler* masm) { ++ assert_cond(masm != NULL); + __ pop_CPU_state(); + __ leave(); +} @@ -38788,6 +38613,7 @@ index 0000000000..7b1112b388 + +// Patch the callers callsite with entry to compiled code if it exists. +static void patch_callers_callsite(MacroAssembler *masm) { ++ assert_cond(masm != NULL); + Label L; + __ ld(t0, Address(xmethod, in_bytes(Method::code_offset()))); + __ beqz(t0, L); @@ -38896,7 +38722,7 @@ index 0000000000..7b1112b388 + __ sd(t0, Address(sp, next_off), /*temp register*/esp); +#ifdef ASSERT + // Overwrite the unused slot with known junk -+ __ mv(t0, 0xdeadffffdeadaaaaul); ++ __ li(t0, 0xdeadffffdeadaaaaul); + __ sd(t0, Address(sp, st_off), /*temp register*/esp); +#endif /* ASSERT */ + } else { @@ -38915,7 +38741,7 @@ index 0000000000..7b1112b388 + // long/double in gpr +#ifdef ASSERT + // Overwrite the unused slot with known junk -+ __ mv(t0, 0xdeadffffdeadaaabul); ++ __ li(t0, 0xdeadffffdeadaaabul); + __ sd(t0, Address(sp, st_off), /*temp register*/esp); +#endif /* ASSERT */ + __ sd(r, Address(sp, next_off)); @@ -38931,7 +38757,7 @@ index 0000000000..7b1112b388 + } else { +#ifdef ASSERT + // Overwrite the unused slot with known junk -+ __ mv(t0, 0xdeadffffdeadaaacul); ++ __ li(t0, 0xdeadffffdeadaaacul); + __ sd(t0, Address(sp, st_off), /*temp register*/esp); +#endif /* ASSERT */ + __ fsd(r_1->as_FloatRegister(), Address(sp, next_off)); @@ -39186,21 +39012,16 @@ index 0000000000..7b1112b388 + return stk_args; +} + -+// The C ABI specifies: -+// "integer scalars narrower than XLEN bits are widened according to the sign -+// of their type up to 32 bits, then sign-extended to XLEN bits." -+// Applies for both passed in register and stack. -+// -+// Java uses 32-bit stack slots; jint, jshort, jchar, jbyte uses one slot. -+// Native uses 64-bit stack slots for all integer scalar types. -+// -+// lw loads the Java stack slot, sign-extends and -+// sd store this widened integer into a 64 bit native stack slot. ++// On 64 bit we will store integer like items to the stack as ++// 64 bits items (riscv64 abi) even though java would only store ++// 32bits for a parameter. On 32bit it will simply be 32 bits ++// So this routine will do 32->32 on 32bit and 32->64 on 64bit +static void move32_64(MacroAssembler* masm, VMRegPair src, VMRegPair dst) { ++ assert_cond(masm != NULL); + if (src.first()->is_stack()) { + if (dst.first()->is_stack()) { + // stack to stack -+ __ lw(t0, Address(fp, reg2offset_in(src.first()))); ++ __ ld(t0, Address(fp, reg2offset_in(src.first()))); + __ sd(t0, Address(sp, reg2offset_out(dst.first()))); + } else { + // stack to reg @@ -39226,6 +39047,7 @@ index 0000000000..7b1112b388 + VMRegPair dst, + bool is_receiver, + int* receiver_offset) { ++ assert_cond(masm != NULL && map != NULL && receiver_offset != NULL); + // must pass a handle. First figure out the location we use as a handle + Register rHandle = dst.first()->is_stack() ? t1 : dst.first()->as_Register(); + @@ -39308,6 +39130,7 @@ index 0000000000..7b1112b388 +static void float_move(MacroAssembler* masm, VMRegPair src, VMRegPair dst) { + assert(src.first()->is_stack() && dst.first()->is_stack() || + src.first()->is_reg() && dst.first()->is_reg() || src.first()->is_stack() && dst.first()->is_reg(), "Unexpected error"); ++ assert_cond(masm != NULL); + if (src.first()->is_stack()) { + if (dst.first()->is_stack()) { + __ lwu(t0, Address(fp, reg2offset_in(src.first()))); @@ -39328,6 +39151,7 @@ index 0000000000..7b1112b388 + +// A long move +static void long_move(MacroAssembler* masm, VMRegPair src, VMRegPair dst) { ++ assert_cond(masm != NULL); + if (src.first()->is_stack()) { + if (dst.first()->is_stack()) { + // stack to stack @@ -39351,6 +39175,7 @@ index 0000000000..7b1112b388 +static void double_move(MacroAssembler* masm, VMRegPair src, VMRegPair dst) { + assert(src.first()->is_stack() && dst.first()->is_stack() || + src.first()->is_reg() && dst.first()->is_reg() || src.first()->is_stack() && dst.first()->is_reg(), "Unexpected error"); ++ assert_cond(masm != NULL); + if (src.first()->is_stack()) { + if (dst.first()->is_stack()) { + __ ld(t0, Address(fp, reg2offset_in(src.first()))); @@ -39370,6 +39195,7 @@ index 0000000000..7b1112b388 +} + +void SharedRuntime::save_native_result(MacroAssembler *masm, BasicType ret_type, int frame_slots) { ++ assert_cond(masm != NULL); + // We always ignore the frame_slots arg and just use the space just below frame pointer + // which by this time is free to use + switch (ret_type) { @@ -39387,6 +39213,7 @@ index 0000000000..7b1112b388 +} + +void SharedRuntime::restore_native_result(MacroAssembler *masm, BasicType ret_type, int frame_slots) { ++ assert_cond(masm != NULL); + // We always ignore the frame_slots arg and just use the space just below frame pointer + // which by this time is free to use + switch (ret_type) { @@ -39404,6 +39231,7 @@ index 0000000000..7b1112b388 +} + +static void save_args(MacroAssembler *masm, int arg_count, int first_arg, VMRegPair *args) { ++ assert_cond(masm != NULL && args != NULL); + RegSet x; + for ( int i = first_arg ; i < arg_count ; i++ ) { + if (args[i].first()->is_Register()) { @@ -39417,6 +39245,7 @@ index 0000000000..7b1112b388 +} + +static void restore_args(MacroAssembler *masm, int arg_count, int first_arg, VMRegPair *args) { ++ assert_cond(masm != NULL && args != NULL); + RegSet x; + for ( int i = first_arg ; i < arg_count ; i++ ) { + if (args[i].first()->is_Register()) { @@ -39437,6 +39266,7 @@ index 0000000000..7b1112b388 +} + +static void rt_call(MacroAssembler* masm, address dest) { ++ assert_cond(masm != NULL); + CodeBlob *cb = CodeCache::find_blob(dest); + if (cb) { + __ far_call(RuntimeAddress(dest)); @@ -39569,7 +39399,6 @@ index 0000000000..7b1112b388 + int vep_offset = ((intptr_t)__ pc()) - start; + + // First instruction must be a nop as it may need to be patched on deoptimisation -+ MacroAssembler::assert_alignment(__ pc()); + __ nop(); + gen_special_dispatch(masm, + method, @@ -39721,7 +39550,6 @@ index 0000000000..7b1112b388 + + // If we have to make this method not-entrant we'll overwrite its + // first instruction with a jump. -+ MacroAssembler::assert_alignment(__ pc()); + __ nop(); + + // Generate stack overflow check @@ -40381,7 +40209,7 @@ index 0000000000..7b1112b388 + // Now it is safe to overwrite any register + + // Deopt during an exception. Save exec mode for unpack_frames. -+ __ mv(xcpool, Deoptimization::Unpack_exception); // callee-saved ++ __ li(xcpool, Deoptimization::Unpack_exception); // callee-saved + + // load throwing pc from JavaThread and patch it as the return address + // of the current frame. Then clear the field in JavaThread @@ -40442,7 +40270,7 @@ index 0000000000..7b1112b388 + + __ lwu(xcpool, Address(x15, Deoptimization::UnrollBlock::unpack_kind_offset_in_bytes())); + Label noException; -+ __ mv(t0, Deoptimization::Unpack_exception); ++ __ li(t0, Deoptimization::Unpack_exception); + __ bne(xcpool, t0, noException); // Was exception pending? + __ ld(x10, Address(xthread, JavaThread::exception_oop_offset())); + __ ld(x13, Address(xthread, JavaThread::exception_pc_offset())); @@ -40521,7 +40349,7 @@ index 0000000000..7b1112b388 + __ sub(sp, sp, x9); + + // Push interpreter frames in a loop -+ __ mv(t0, 0xDEADDEAD); // Make a recognizable pattern ++ __ li(t0, 0xDEADDEAD); // Make a recognizable pattern + __ mv(t1, t0); + Label loop; + __ bind(loop); @@ -40922,7 +40750,7 @@ index 0000000000..7b1112b388 +// must do any gc of the args. +// +RuntimeStub* SharedRuntime::generate_resolve_blob(address destination, const char* name) { -+ assert(StubRoutines::forward_exception_entry() != NULL, "must be generated before"); ++ assert (StubRoutines::forward_exception_entry() != NULL, "must be generated before"); + + // allocate space for the code + ResourceMark rm; @@ -41143,7 +40971,7 @@ index 0000000000..7b1112b388 +#endif // COMPILER2 diff --git a/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp b/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp new file mode 100644 -index 0000000000..272dd9aeb3 +index 0000000000..9970229c5c --- /dev/null +++ b/src/hotspot/cpu/riscv/stubGenerator_riscv.cpp @@ -0,0 +1,3743 @@ @@ -41503,13 +41331,13 @@ index 0000000000..272dd9aeb3 + __ ld(j_rarg2, result); + Label is_long, is_float, is_double, exit; + __ ld(j_rarg1, result_type); -+ __ mv(t0, (u1)T_OBJECT); ++ __ li(t0, (u1)T_OBJECT); + __ beq(j_rarg1, t0, is_long); -+ __ mv(t0, (u1)T_LONG); ++ __ li(t0, (u1)T_LONG); + __ beq(j_rarg1, t0, is_long); -+ __ mv(t0, (u1)T_FLOAT); ++ __ li(t0, (u1)T_FLOAT); + __ beq(j_rarg1, t0, is_float); -+ __ mv(t0, (u1)T_DOUBLE); ++ __ li(t0, (u1)T_DOUBLE); + __ beq(j_rarg1, t0, is_double); + + // handle T_INT case @@ -41747,7 +41575,7 @@ index 0000000000..272dd9aeb3 + + Label exit, error; + -+ __ push_reg(RegSet::of(c_rarg2, c_rarg3), sp); // save c_rarg2 and c_rarg3 ++ __ push_reg(0x3000, sp); // save c_rarg2 and c_rarg3 + + __ la(c_rarg2, ExternalAddress((address) StubRoutines::verify_oop_count_addr())); + __ ld(c_rarg3, Address(c_rarg2)); @@ -41773,12 +41601,12 @@ index 0000000000..272dd9aeb3 + // return if everything seems ok + __ bind(exit); + -+ __ pop_reg(RegSet::of(c_rarg2, c_rarg3), sp); // pop c_rarg2 and c_rarg3 ++ __ pop_reg(0x3000, sp); // pop c_rarg2 and c_rarg3 + __ ret(); + + // handle errors + __ bind(error); -+ __ pop_reg(RegSet::of(c_rarg2, c_rarg3), sp); // pop c_rarg2 and c_rarg3 ++ __ pop_reg(0x3000, sp); // pop c_rarg2 and c_rarg3 + + __ pusha(); + // debug(char* msg, int64_t pc, int64_t regs[]) @@ -41891,7 +41719,7 @@ index 0000000000..272dd9aeb3 + { + Label L; + -+ __ mv(t0, 8); ++ __ li(t0, 8); + __ bge(count, t0, L); + __ stop("genrate_copy_longs called with < 8 words"); + __ bind(L); @@ -43092,7 +42920,7 @@ index 0000000000..272dd9aeb3 + } + + __ BIND(L_failed); -+ __ mv(x10, -1); ++ __ li(x10, -1); + __ leave(); // required for proper stackwalking of RuntimeStub frame + __ ret(); + @@ -44280,7 +44108,7 @@ index 0000000000..272dd9aeb3 + ld(Rm, Address(Rm)); + add(Rn, Pn_base, Rn); + ld(Rn, Address(Rn)); -+ mv(t0, 1); // set carry flag, i.e. no borrow ++ li(t0, 1); // set carry flag, i.e. no borrow + align(16); + bind(loop); { + notr(Rn, Rn); @@ -44445,7 +44273,7 @@ index 0000000000..272dd9aeb3 + enter(); + + // Make room. -+ mv(Ra, 512); ++ li(Ra, 512); + bgt(Rlen, Ra, argh); + slli(Ra, Rlen, exact_log2(4 * sizeof(jint))); + sub(Ra, sp, Ra); @@ -44471,7 +44299,7 @@ index 0000000000..272dd9aeb3 + { + ld(Rn, Address(Pn_base)); + mul(Rlo_mn, Rn, inv); -+ mv(t0, -1); ++ li(t0, -1); + Label ok; + beq(Rlo_mn, t0, ok); + stop("broken inverse in Montgomery multiply"); @@ -44567,7 +44395,7 @@ index 0000000000..272dd9aeb3 + enter(); + + // Make room. -+ mv(Ra, 512); ++ li(Ra, 512); + bgt(Rlen, Ra, argh); + slli(Ra, Rlen, exact_log2(4 * sizeof(jint))); + sub(Ra, sp, Ra); @@ -45116,7 +44944,7 @@ index 0000000000..0c9445e18a +#endif // CPU_RISCV_STUBROUTINES_RISCV_HPP diff --git a/src/hotspot/cpu/riscv/templateInterpreterGenerator_riscv.cpp b/src/hotspot/cpu/riscv/templateInterpreterGenerator_riscv.cpp new file mode 100644 -index 0000000000..34c85e8145 +index 0000000000..e639fa7e12 --- /dev/null +++ b/src/hotspot/cpu/riscv/templateInterpreterGenerator_riscv.cpp @@ -0,0 +1,1833 @@ @@ -45662,7 +45490,7 @@ index 0000000000..34c85e8145 + address entry = __ pc(); + __ push(state); + __ call_VM(noreg, runtime_entry); -+ __ membar(MacroAssembler::AnyAny); ++ __ fence(0xf, 0xf); + __ dispatch_via(vtos, Interpreter::_normal_table.table_for(vtos)); + return entry; +} @@ -46777,7 +46605,7 @@ index 0000000000..34c85e8145 + Label L_done; + + __ lbu(t0, Address(xbcp, 0)); -+ __ mv(t1, Bytecodes::_invokestatic); ++ __ li(t1, Bytecodes::_invokestatic); + __ bne(t1, t0, L_done); + + // The member name argument must be restored if _invokestatic is re-executed after a PopFrame call. @@ -46920,7 +46748,7 @@ index 0000000000..34c85e8145 + __ push_reg(t0); + __ push_reg(x10); + __ mv(x10, (address) &BytecodeCounter::_counter_value); -+ __ mv(t0, 1); ++ __ li(t0, 1); + __ amoadd_d(zr, x10, t0, Assembler::aqrl); + __ pop_reg(x10); + __ pop_reg(t0); @@ -46955,10 +46783,10 @@ index 0000000000..34c85e8145 +#endif // !PRODUCT diff --git a/src/hotspot/cpu/riscv/templateTable_riscv.cpp b/src/hotspot/cpu/riscv/templateTable_riscv.cpp new file mode 100644 -index 0000000000..c22fd3bfcd +index 0000000000..84b1afc7dc --- /dev/null +++ b/src/hotspot/cpu/riscv/templateTable_riscv.cpp -@@ -0,0 +1,4000 @@ +@@ -0,0 +1,4006 @@ +/* + * Copyright (c) 2003, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, Red Hat Inc. All rights reserved. @@ -47035,12 +46863,15 @@ index 0000000000..c22fd3bfcd + return iaddress(n); +} + -+static inline Address iaddress(Register r, Register temp, InterpreterMacroAssembler* _masm) { ++static inline Address iaddress(Register r, Register temp, InterpreterMacroAssembler* _masm) { ++ assert_cond(_masm != NULL); + _masm->shadd(temp, r, xlocals, temp, 3); + return Address(temp, 0); +} + -+static inline Address laddress(Register r, Register temp, InterpreterMacroAssembler* _masm) { ++static inline Address laddress(Register r, Register temp, ++ InterpreterMacroAssembler* _masm) { ++ assert_cond(_masm != NULL); + _masm->shadd(temp, r, xlocals, temp, 3); + return Address(temp, Interpreter::local_offset_in_bytes(1));; +} @@ -47049,7 +46880,8 @@ index 0000000000..c22fd3bfcd + return iaddress(r, temp, _masm); +} + -+static inline Address daddress(Register r, Register temp, InterpreterMacroAssembler* _masm) { ++static inline Address daddress(Register r, Register temp, ++ InterpreterMacroAssembler* _masm) { + return laddress(r, temp, _masm); +} + @@ -47095,6 +46927,7 @@ index 0000000000..c22fd3bfcd + Register val, + DecoratorSet decorators) { + assert(val == noreg || val == x10, "parameter is just for looks"); ++ assert_cond(_masm != NULL); + __ store_heap_oop(dst, val, x29, x11, decorators); +} + @@ -47102,6 +46935,7 @@ index 0000000000..c22fd3bfcd + Address src, + Register dst, + DecoratorSet decorators) { ++ assert_cond(_masm != NULL); + __ load_heap_oop(dst, src, x7, x11, decorators); +} + @@ -47195,13 +47029,13 @@ index 0000000000..c22fd3bfcd +void TemplateTable::iconst(int value) +{ + transition(vtos, itos); -+ __ mv(x10, value); ++ __ li(x10, value); +} + +void TemplateTable::lconst(int value) +{ + transition(vtos, ltos); -+ __ mv(x10, value); ++ __ li(x10, value); +} + +void TemplateTable::fconst(int value) @@ -50723,7 +50557,7 @@ index 0000000000..c22fd3bfcd + __ j(done); + // Come here on success + __ bind(ok_is_subtype); -+ __ mv(x10, 1); ++ __ li(x10, 1); + + // Collect counts on whether this test sees NULLs a lot or not. + if (ProfileInterpreter) { @@ -51680,7 +51514,7 @@ index 0000000000..06b70020b4 +#endif // CPU_RISCV_VM_VMREG_RISCV_INLINE_HPP diff --git a/src/hotspot/cpu/riscv/vtableStubs_riscv.cpp b/src/hotspot/cpu/riscv/vtableStubs_riscv.cpp new file mode 100644 -index 0000000000..448bb09ba7 +index 0000000000..0d205240a5 --- /dev/null +++ b/src/hotspot/cpu/riscv/vtableStubs_riscv.cpp @@ -0,0 +1,260 @@ @@ -51758,7 +51592,7 @@ index 0000000000..448bb09ba7 +#if (!defined(PRODUCT) && defined(COMPILER2)) + if (CountCompiledCalls) { + __ la(t2, ExternalAddress((address) SharedRuntime::nof_megamorphic_calls_addr())); -+ __ increment(Address(t2)); ++ __ add_memory_int64(Address(t2), 1); + } +#endif + @@ -51849,7 +51683,7 @@ index 0000000000..448bb09ba7 +#if (!defined(PRODUCT) && defined(COMPILER2)) + if (CountCompiledCalls) { + __ la(x18, ExternalAddress((address) SharedRuntime::nof_megamorphic_calls_addr())); -+ __ increment(Address(x18)); ++ __ add_memory_int64(Address(x18), 1); + } +#endif + @@ -54640,99 +54474,6 @@ index 6605ab367c..7f1bcff6b3 100644 #ifdef VM_LITTLE_ENDIAN #define LITTLE_ENDIAN_ONLY(code) code #define BIG_ENDIAN_ONLY(code) -diff --git a/src/hotspot/share/utilities/vmassert_reinstall.hpp b/src/hotspot/share/utilities/vmassert_reinstall.hpp -new file mode 100644 -index 0000000000..32d31ac0c4 ---- /dev/null -+++ b/src/hotspot/share/utilities/vmassert_reinstall.hpp -@@ -0,0 +1,36 @@ -+/* -+ * 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. -+ * -+ */ -+ -+// Intentionally no #include guard. May be included multiple times for effect. -+ -+// See vmassert_uninstall.hpp for usage. -+ -+// Remove possible stdlib assert macro (or any others, for that matter). -+#undef assert -+ -+// Reinstall HotSpot's assert macro, if previously defined. -+#ifdef vmassert -+#define assert(p, ...) vmassert(p, __VA_ARGS__) -+#endif -+ -diff --git a/src/hotspot/share/utilities/vmassert_uninstall.hpp b/src/hotspot/share/utilities/vmassert_uninstall.hpp -new file mode 100644 -index 0000000000..dd6d51633d ---- /dev/null -+++ b/src/hotspot/share/utilities/vmassert_uninstall.hpp -@@ -0,0 +1,45 @@ -+/* -+ * 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. -+ * -+ */ -+ -+// Intentionally no #include guard. May be included multiple times for effect. -+ -+// The files vmassert_uninstall.hpp and vmassert_reinstall.hpp provide a -+// workaround for the name collision between HotSpot's assert macro and the -+// Standard Library's assert macro. When including a 3rd-party header that -+// uses (and so includes) the standard assert macro, wrap that inclusion with -+// includes of these two files, e.g. -+// -+// #include "utilities/vmassert_uninstall.hpp" -+// #include
-+// #include "utilities/vmassert_reinstall.hpp" -+// -+// This removes the HotSpot macro definition while pre-processing the -+// 3rd-party header, then reinstates the HotSpot macro (if previously defined) -+// for following code. -+ -+// Remove HotSpot's assert macro, if present. -+#ifdef vmassert -+#undef assert -+#endif // vmassert -+ diff --git a/src/jdk.hotspot.agent/linux/native/libsaproc/LinuxDebuggerLocal.c b/src/jdk.hotspot.agent/linux/native/libsaproc/LinuxDebuggerLocal.c index 0d834302c5..45a927fb5e 100644 --- a/src/jdk.hotspot.agent/linux/native/libsaproc/LinuxDebuggerLocal.c @@ -56742,86 +56483,6 @@ index 7d7a6107ca..6552ce255f 100644 for(String s : KNOWN) { if(s.equals(cpu)) -diff --git a/test/hotspot/gtest/gc/shared/test_memset_with_concurrent_readers.cpp b/test/hotspot/gtest/gc/shared/test_memset_with_concurrent_readers.cpp -index 24f25b87af..7a3845e336 100644 ---- a/test/hotspot/gtest/gc/shared/test_memset_with_concurrent_readers.cpp -+++ b/test/hotspot/gtest/gc/shared/test_memset_with_concurrent_readers.cpp -@@ -1,5 +1,5 @@ - /* -- * Copyright (c) 2016, 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 -@@ -24,10 +24,13 @@ - #include "precompiled.hpp" - #include "gc/shared/memset_with_concurrent_readers.hpp" - #include "utilities/globalDefinitions.hpp" --#include "unittest.hpp" - -+#include "utilities/vmassert_uninstall.hpp" - #include - #include -+#include "utilities/vmassert_reinstall.hpp" -+ -+#include "unittest.hpp" - - static unsigned line_byte(const char* line, size_t i) { - return unsigned(line[i]) & 0xFF; -diff --git a/test/hotspot/gtest/jfr/test_networkUtilization.cpp b/test/hotspot/gtest/jfr/test_networkUtilization.cpp -index 19d6a6e2c2..42cd18356b 100644 ---- a/test/hotspot/gtest/jfr/test_networkUtilization.cpp -+++ b/test/hotspot/gtest/jfr/test_networkUtilization.cpp -@@ -1,5 +1,5 @@ - /* -- * Copyright (c) 2018, 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 -@@ -42,11 +42,13 @@ - #include "utilities/globalDefinitions.hpp" - #include "utilities/growableArray.hpp" - --#include "unittest.hpp" -- -+#include "utilities/vmassert_uninstall.hpp" - #include - #include - #include -+#include "utilities/vmassert_reinstall.hpp" -+ -+#include "unittest.hpp" - - namespace { - -diff --git a/test/hotspot/gtest/unittest.hpp b/test/hotspot/gtest/unittest.hpp -index 0494a0e240..91edf6adba 100644 ---- a/test/hotspot/gtest/unittest.hpp -+++ b/test/hotspot/gtest/unittest.hpp -@@ -28,19 +28,10 @@ - #include - - #define GTEST_DONT_DEFINE_TEST 1 --#include "gtest/gtest.h" - --// gtest/gtest.h includes assert.h which will define the assert macro, but hotspot has its --// own standards incompatible assert macro that takes two parameters. --// The workaround is to undef assert and then re-define it. The re-definition --// must unfortunately be copied since debug.hpp might already have been --// included and a second include wouldn't work due to the header guards in debug.hpp. --#ifdef assert -- #undef assert -- #ifdef vmassert -- #define assert(p, ...) vmassert(p, __VA_ARGS__) -- #endif --#endif -+#include "utilities/vmassert_uninstall.hpp" -+#include "gtest/gtest.h" -+#include "utilities/vmassert_reinstall.hpp" - - #define CONCAT(a, b) a ## b - diff --git a/test/hotspot/jtreg/compiler/c2/TestBit.java b/test/hotspot/jtreg/compiler/c2/TestBit.java index 7805918c28..823b9f39db 100644 --- a/test/hotspot/jtreg/compiler/c2/TestBit.java @@ -56852,152 +56513,6 @@ index 7805918c28..823b9f39db 100644 if (expectedTestBitInstruction != null) { output.shouldContain(expectedTestBitInstruction); -diff --git a/test/hotspot/jtreg/compiler/calls/TestManyArgs.java b/test/hotspot/jtreg/compiler/calls/TestManyArgs.java -new file mode 100644 -index 0000000000..fbd9c13d7c ---- /dev/null -+++ b/test/hotspot/jtreg/compiler/calls/TestManyArgs.java -@@ -0,0 +1,65 @@ -+/* -+ * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. -+ * Copyright (c) 2024, 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. -+ */ -+ -+/* @test -+ * @summary Pass values on stack. -+ * @requires os.arch == "riscv64" -+ * @run main/native compiler.calls.TestManyArgs -+ */ -+ -+package compiler.calls; -+ -+public class TestManyArgs { -+ static { -+ System.loadLibrary("TestManyArgs"); -+ } -+ -+ native static void scramblestack(); -+ -+ native static int checkargs(int arg0, short arg1, byte arg2, -+ int arg3, short arg4, byte arg5, -+ int arg6, short arg7, byte arg8, -+ int arg9, short arg10, byte arg11); -+ -+ static int compiledbridge(int arg0, short arg1, byte arg2, -+ int arg3, short arg4, byte arg5, -+ int arg6, short arg7, byte arg8, -+ int arg9, short arg10, byte arg11) { -+ return checkargs(arg0, arg1, arg2, arg3, arg4, arg5, -+ arg6, arg7, arg8, arg9, arg10, arg11); -+ } -+ -+ static public void main(String[] args) { -+ scramblestack(); -+ for (int i = 0; i < 20000; i++) { -+ int res = compiledbridge((int)0xf, (short)0xf, (byte)0xf, -+ (int)0xf, (short)0xf, (byte)0xf, -+ (int)0xf, (short)0xf, (byte)0xf, -+ (int)0xf, (short)0xf, (byte)0xf); -+ if (res != 0) { -+ throw new RuntimeException("Test failed"); -+ } -+ } -+ } -+} -diff --git a/test/hotspot/jtreg/compiler/calls/libTestManyArgs.c b/test/hotspot/jtreg/compiler/calls/libTestManyArgs.c -new file mode 100644 -index 0000000000..8836c79e43 ---- /dev/null -+++ b/test/hotspot/jtreg/compiler/calls/libTestManyArgs.c -@@ -0,0 +1,69 @@ -+/* -+ * Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved. -+ * Copyright (c) 2024, 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. -+ */ -+ -+#include "jni.h" -+ -+#ifdef riscv64 -+/* RV64 ABI pass all integers as 64-bit, in registers or on stack -+ * As compiler may choose to load smaller width than 64-bit if passed on stack, -+ * this test may not find any bugs. -+ * Therefore we trick the compiler todo 64-bit loads, -+ * by saying these args are jlongs. -+ */ -+JNIEXPORT jint JNICALL Java_compiler_calls_TestManyArgs_checkargs(JNIEnv* env, jclass jclazz, -+ jlong arg0, jlong arg1, jlong arg2, -+ jlong arg3, jlong arg4, jlong arg5, -+ jlong arg6, jlong arg7, jlong arg8, -+ jlong arg9, jlong arg10, jlong arg11) -+#else -+JNIEXPORT jint JNICALL Java_compiler_calls_TestManyArgs_checkargs(JNIEnv* env, jclass jclazz, -+ jint arg0, jshort arg1, jbyte arg2, -+ jint arg3, jshort arg4, jbyte arg5, -+ jint arg6, jshort arg7, jbyte arg8, -+ jint arg9, jshort arg10, jbyte arg11) -+#endif -+{ -+ if (arg0 != 0xf) return 1; -+ if (arg1 != 0xf) return 1; -+ if (arg2 != 0xf) return 1; -+ if (arg3 != 0xf) return 1; -+ if (arg4 != 0xf) return 1; -+ if (arg5 != 0xf) return 1; -+ if (arg6 != 0xf) return 1; -+ if (arg7 != 0xf) return 1; -+ if (arg8 != 0xf) return 1; -+ if (arg9 != 0xf) return 1; -+ if (arg10 != 0xf) return 1; -+ if (arg11 != 0xf) return 1; -+ return 0; -+} -+ -+JNIEXPORT -+void JNICALL Java_compiler_calls_TestManyArgs_scramblestack(JNIEnv* env, jclass jclazz) -+{ -+ volatile char stack[12*8]; -+ for (unsigned int i = 0; i < sizeof(stack); i++) { -+ stack[i] = (char)0xff; -+ } -+} diff --git a/test/hotspot/jtreg/compiler/floatingpoint/TestLibmIntrinsics.java b/test/hotspot/jtreg/compiler/floatingpoint/TestLibmIntrinsics.java new file mode 100644 index 0000000000..5a1b659bbe @@ -57638,82 +57153,6 @@ index 7774dabcb5..7afe3560f3 100644 public static final BooleanSupplier ANY_SHA_INSTRUCTION_AVAILABLE = new OrPredicate(IntrinsicPredicates.SHA1_INSTRUCTION_AVAILABLE, -diff --git a/test/hotspot/jtreg/gc/stress/TestStressG1Humongous.java b/test/hotspot/jtreg/gc/stress/TestStressG1Humongous.java -index 5aea51a24f..da63e02555 100644 ---- a/test/hotspot/jtreg/gc/stress/TestStressG1Humongous.java -+++ b/test/hotspot/jtreg/gc/stress/TestStressG1Humongous.java -@@ -24,14 +24,41 @@ - package gc.stress; - - /* -- * @test TestStressG1Humongous -+ * @test - * @key gc stress - * @summary Stress G1 by humongous allocations in situation near OOM - * @requires vm.gc.G1 - * @requires !vm.flightRecorder - * @library /test/lib - * @modules java.base/jdk.internal.misc -- * @run driver/timeout=1300 gc.stress.TestStressG1Humongous -+ * @run driver/timeout=180 gc.stress.TestStressG1Humongous 4 3 1.1 120 -+ */ -+ -+/* -+ * @test -+ * @requires vm.gc.G1 -+ * @requires !vm.flightRecorder -+ * @library /test/lib -+ * @modules java.base/jdk.internal.misc -+ * @run driver/timeout=180 gc.stress.TestStressG1Humongous 16 5 2.1 120 -+ */ -+ -+/* -+ * @test -+ * @requires vm.gc.G1 -+ * @requires !vm.flightRecorder -+ * @library /test/lib -+ * @modules java.base/jdk.internal.misc -+ * @run driver/timeout=180 gc.stress.TestStressG1Humongous 32 4 0.6 120 -+ */ -+ -+/* -+ * @test -+ * @requires vm.gc.G1 -+ * @requires !vm.flightRecorder -+ * @library /test/lib -+ * @modules java.base/jdk.internal.misc -+ * @run driver/timeout=900 gc.stress.TestStressG1Humongous 1 7 0.6 600 - */ - - import java.util.ArrayList; -@@ -48,17 +75,19 @@ import jdk.test.lib.process.OutputAnalyzer; - public class TestStressG1Humongous{ - - public static void main(String[] args) throws Exception { -+ if (args.length != 4) { -+ throw new IllegalArgumentException("Test expects 4 arguments"); -+ } -+ - // Limit heap size on 32-bit platforms - int heapSize = Platform.is32bit() ? 512 : 1024; -- // Heap size, region size, threads, humongous size, timeout -- run(heapSize, 4, 3, 1.1, 120); -- run(heapSize, 16, 5, 2.1, 120); -- run(heapSize, 32, 4, 0.6, 120); -- run(heapSize, 1, 7, 0.6, 600); -- } - -- private static void run(int heapSize, int regionSize, int threads, double humongousSize, int timeout) -- throws Exception { -+ // Region size, threads, humongous size, and timeout passed as @run arguments -+ int regionSize = Integer.parseInt(args[0]); -+ int threads = Integer.parseInt(args[1]); -+ double humongousSize = Double.parseDouble(args[2]); -+ int timeout = Integer.parseInt(args[3]); -+ - ArrayList options = new ArrayList<>(); - Collections.addAll(options, Utils.getTestJavaOpts()); - Collections.addAll(options, diff --git a/test/hotspot/jtreg/runtime/NMT/CheckForProperDetailStackTrace.java b/test/hotspot/jtreg/runtime/NMT/CheckForProperDetailStackTrace.java index 57256aa5a3..d4d43b01ae 100644 --- a/test/hotspot/jtreg/runtime/NMT/CheckForProperDetailStackTrace.java @@ -57767,620 +57206,6 @@ index 126a43a900..feb4de5388 100644 BITNESS("is32bit", "is64bit"), OS("isAix", "isLinux", "isOSX", "isSolaris", "isWindows"), VM_TYPE("isClient", "isServer", "isGraal", "isMinimal", "isZero", "isEmbedded"), -diff --git a/test/jdk/java/awt/List/MouseDraggedOutCauseScrollingTest/MouseDraggedOutCauseScrollingTest.html b/test/jdk/java/awt/List/MouseDraggedOutCauseScrollingTest/MouseDraggedOutCauseScrollingTest.html -deleted file mode 100644 -index 7049e82703..0000000000 ---- a/test/jdk/java/awt/List/MouseDraggedOutCauseScrollingTest/MouseDraggedOutCauseScrollingTest.html -+++ /dev/null -@@ -1,43 +0,0 @@ -- -- -- -- -- -- ManualYesNoTest -- -- -- --

ManualYesNoTest
Bug ID:

-- --

See the dialog box (usually in upper left corner) for instructions

-- -- -- -- -diff --git a/test/jdk/java/awt/List/MouseDraggedOutCauseScrollingTest/MouseDraggedOutCauseScrollingTest.java b/test/jdk/java/awt/List/MouseDraggedOutCauseScrollingTest/MouseDraggedOutCauseScrollingTest.java -index 8b509a1231..446b7a3a93 100644 ---- a/test/jdk/java/awt/List/MouseDraggedOutCauseScrollingTest/MouseDraggedOutCauseScrollingTest.java -+++ b/test/jdk/java/awt/List/MouseDraggedOutCauseScrollingTest/MouseDraggedOutCauseScrollingTest.java -@@ -1,5 +1,5 @@ - /* -- * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. -+ * Copyright (c) 2013, 2024, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it -@@ -22,29 +22,29 @@ - */ - - /* -- test -+ @test - @bug 6243382 8006070 - @summary Dragging of mouse outside of a List and Choice area don't work properly on XAWT -- @author Dmitry.Cherepanov@SUN.COM area=awt.list -- @run applet/manual=yesno MouseDraggedOutCauseScrollingTest.html -+ @requires (os.family == "linux") -+ @library /java/awt/regtesthelpers -+ @run main/manual MouseDraggedOutCauseScrollingTest - */ - --import java.applet.Applet; --import java.awt.*; -+import java.awt.Choice; -+import java.awt.Frame; -+import java.awt.GridLayout; -+import java.awt.List; -+import java.awt.Toolkit; - --public class MouseDraggedOutCauseScrollingTest extends Applet --{ -- Choice choice; -- List singleList; -- List multipleList; -+public class MouseDraggedOutCauseScrollingTest { - -- public void init() -- { -- this.setLayout (new GridLayout (1, 3)); -+ static Frame createUI() { -+ Frame frame = new Frame("MouseDraggedOutCausesScrollingTest"); -+ frame.setLayout(new GridLayout(1, 3)); - -- choice = new Choice(); -- singleList = new List(3, false); -- multipleList = new List(3, true); -+ Choice choice = new Choice(); -+ List singleList = new List(3, false); -+ List multipleList = new List(3, true); - - choice.add("Choice"); - for (int i = 1; i < 100; i++){ -@@ -59,188 +59,66 @@ public class MouseDraggedOutCauseScrollingTest extends Applet - for (int i = 1; i < 100; i++) - multipleList.add(""+i); - -- this.add(choice); -- this.add(singleList); -- this.add(multipleList); -+ frame.add(choice); -+ frame.add(singleList); -+ frame.add(multipleList); -+ frame.setSize(400, 100); -+ return frame; -+ } - -+ public static void main(String[] args) throws Exception { - String toolkitName = Toolkit.getDefaultToolkit().getClass().getName(); -+ - if (!toolkitName.equals("sun.awt.X11.XToolkit")) { -- String[] instructions = -- { -- "This test is not applicable to the current platform. Press PASS" -- }; -- Sysout.createDialogWithInstructions( instructions ); -- } else { -- String[] instructions = -- { -- "0) Please note, that this is only Motif/XAWT test. At first, make the applet active", -- "1.1) Click on the choice", -- "1.2) Press the left button of the mouse and keep on any item of the choice, for example 5", -- "1.3) Drag mouse out of the area of the unfurled list, at the same time hold the X coordinate of the mouse position about the same", -- "1.4) To make sure, that when the Y coordinate of the mouse position higher of the upper bound of the list then scrolling UP of the list and selected item changes on the upper. If not, the test failed", -- "1.5) To make sure, that when the Y coordinate of the mouse position under of the lower bound of the list then scrolling DOWN of the list and selected item changes on the lower. If not, the test failed", -- "-----------------------------------", -- "2.1) Click on the single list", -- "2.2) Press the left button of the mouse and keep on any item of the list, for example 5", -- "2.3) Drag mouse out of the area of the unfurled list, at the same time hold the X coordinate of the mouse position about the same", -- "2.4) To make sure, that when the Y coordinate of the mouse position higher of the upper bound of the list then scrolling UP of the list and selected item changes on the upper. If not, the test failed", -- "2.5) To make sure, that when the Y coordinate of the mouse position under of the lower bound of the list then scrolling DOWN of the list and selected item changes on the lower. If not, the test failed", -- "-----------------------------------", -- "3.1) Click on the multiple list", -- "3.2) Press the left button of the mouse and keep on any item of the list, for example 5", -- "3.3) Drag mouse out of the area of the unfurled list, at the same time hold the X coordinate of the mouse position about the same", -- "3.4) To make sure, that when the Y coordinate of the mouse position higher of the upper bound of the list then scrolling of the list NO OCCURED and selected item NO CHANGES on the upper. If not, the test failed", -- "3.5) To make sure, that when the Y coordinate of the mouse position under of the lower bound of the list then scrolling of the list NO OCCURED and selected item NO CHANGES on the lower. If not, the test failed", -- "4) Test passed." -- }; -- Sysout.createDialogWithInstructions( instructions ); -+ System.out.println(INAPPLICABLE); -+ return; - } - -- }//End init() -- -- public void start () -- { -- setSize (400,100); -- setVisible(true); -- validate(); -- -- }// start() -- --}// class ManualYesNoTest -- --/**************************************************** -- Standard Test Machinery -- DO NOT modify anything below -- it's a standard -- chunk of code whose purpose is to make user -- interaction uniform, and thereby make it simpler -- to read and understand someone else's test. -- ****************************************************/ -- --/** -- This is part of the standard test machinery. -- It creates a dialog (with the instructions), and is the interface -- for sending text messages to the user. -- To print the instructions, send an array of strings to Sysout.createDialog -- WithInstructions method. Put one line of instructions per array entry. -- To display a message for the tester to see, simply call Sysout.println -- with the string to be displayed. -- This mimics System.out.println but works within the test harness as well -- as standalone. -- */ -- --class Sysout --{ -- private static TestDialog dialog; -- -- public static void createDialogWithInstructions( String[] instructions ) -- { -- dialog = new TestDialog( new Frame(), "Instructions" ); -- dialog.printInstructions( instructions ); -- dialog.setVisible(true); -- println( "Any messages for the tester will display here." ); -- } -- -- public static void createDialog( ) -- { -- dialog = new TestDialog( new Frame(), "Instructions" ); -- String[] defInstr = { "Instructions will appear here. ", "" } ; -- dialog.printInstructions( defInstr ); -- dialog.setVisible(true); -- println( "Any messages for the tester will display here." ); -- } -- -- -- public static void printInstructions( String[] instructions ) -- { -- dialog.printInstructions( instructions ); -- } -- -- -- public static void println( String messageIn ) -- { -- dialog.displayMessage( messageIn ); -- } -- --}// Sysout class -- --/** -- This is part of the standard test machinery. It provides a place for the -- test instructions to be displayed, and a place for interactive messages -- to the user to be displayed. -- To have the test instructions displayed, see Sysout. -- To have a message to the user be displayed, see Sysout. -- Do not call anything in this dialog directly. -- */ --class TestDialog extends Dialog --{ -- -- TextArea instructionsText; -- TextArea messageText; -- int maxStringLength = 80; -- -- //DO NOT call this directly, go through Sysout -- public TestDialog( Frame frame, String name ) -- { -- super( frame, name ); -- int scrollBoth = TextArea.SCROLLBARS_BOTH; -- instructionsText = new TextArea( "", 15, maxStringLength, scrollBoth ); -- add( "North", instructionsText ); -- -- messageText = new TextArea( "", 5, maxStringLength, scrollBoth ); -- add("Center", messageText); -- -- pack(); -- -- setVisible(true); -- }// TestDialog() -- -- //DO NOT call this directly, go through Sysout -- public void printInstructions( String[] instructions ) -- { -- //Clear out any current instructions -- instructionsText.setText( "" ); -- -- //Go down array of instruction strings -- -- String printStr, remainingStr; -- for( int i=0; i < instructions.length; i++ ) -- { -- //chop up each into pieces maxSringLength long -- remainingStr = instructions[ i ]; -- while( remainingStr.length() > 0 ) -- { -- //if longer than max then chop off first max chars to print -- if( remainingStr.length() >= maxStringLength ) -- { -- //Try to chop on a word boundary -- int posOfSpace = remainingStr. -- lastIndexOf( ' ', maxStringLength - 1 ); -- -- if( posOfSpace <= 0 ) posOfSpace = maxStringLength - 1; -- -- printStr = remainingStr.substring( 0, posOfSpace + 1 ); -- remainingStr = remainingStr.substring( posOfSpace + 1 ); -- } -- //else just print -- else -- { -- printStr = remainingStr; -- remainingStr = ""; -- } -- -- instructionsText.append( printStr + "\n" ); -- -- }// while -- -- }// for -- -- }//printInstructions() -- -- //DO NOT call this directly, go through Sysout -- public void displayMessage( String messageIn ) -- { -- messageText.append( messageIn + "\n" ); -- System.out.println(messageIn); -+ PassFailJFrame -+ .builder() -+ .instructions(INSTRUCTIONS) -+ .rows(40) -+ .columns(70) -+ .testUI(MouseDraggedOutCauseScrollingTest::createUI) -+ .build() -+ .awaitAndCheck(); - } - --}// TestDialog class -+ static final String INAPPLICABLE = "The test is not applicable to the current platform. Test PASSES."; -+ static final String INSTRUCTIONS = "0) Please note, that this is an XAWT/Linux only test. First, make the test window is active.\n" + -+ "-----------------------------------\n" + -+ "1.1) Click on the Choice.\n" + -+ "1.2) Press and hold down the left button of the mouse to select (eg) item 5 in the choice.\n" + -+ "1.3) Drag the mouse vertically out of the area of the open list,\n" + -+ " keeping the X coordinate of the mouse position about the same.\n" + -+ "1.4) Check that when the Y coordinate of the mouse position is higher than the upper bound of the list\n" + -+ " then the list continues to scrolls UP and the selected item changes at the top until you reach the topmost item.\n" + -+ " If not, the test failed. Press FAIL.\n" + -+ "1.5) Check that when the Y coordinate of the mouse position is lower than the lower bound of the list\n" + -+ " then the list continues to scroll DOWN and the selected item changes at the bottom until you reach the bottommost item.\n" + -+ " If not, the test failed. Press FAIL.\n" + -+ "-----------------------------------\n" + -+ "2.1) Click on the Single List.\n" + -+ "2.2) Press and hold down the left button of the mouse to select (eg) item 5 in the list.\n" + -+ "2.3) Drag the mouse vertically out of the area of the open list,\n" + -+ " keeping the X coordinate of the mouse position about the same.\n" + -+ "2.4) Check that when the Y coordinate of the mouse position is higher than the upper bound of the list\n" + -+ " then the list continues to scrolls UP and the selected item changes at the top until you reach the topmost item.\n" + -+ " If not, the test failed. Press FAIL.\n" + -+ "2.5) Check that when the Y coordinate of the mouse position is lower than the lower bound of the list\n" + -+ " then the list continues to scroll DOWN and the selected item changes at the bottom until you reach the bottommost item.\n" + -+ " If not, the test failed. Press FAIL.\n" + -+ "-----------------------------------\n" + -+ "3.1) Click on the Multiple List.\n" + -+ "3.2) Press and hold down the left button of the mouse to select (eg) item 5 in the list.\n" + -+ "3.3) Drag the mouse vertically out of the area of the open list,\n" + -+ " keeping the X coordinate of the mouse position about the same.\n" + -+ "3.4) Check that when the Y coordinate of the mouse is higher than the upper bound of the list\n" + -+ " that scrolling of the list DOES NOT OCCUR and the selected item IS UNCHANGED at the top.\n" + -+ " If not, the test failed. Press FAIL.\n" + -+ "3.5) Check that when the Y coordinate of the mouse is below the lower bound of the list\n" + -+ " that scrolling of the list DOES NOT OCCUR and the selected item IS UNCHANGED at the bottom.\n" + -+ " If not, the test failed. Press FAIL.\n" + -+ "-----------------------------------\n" + -+ "4) The test has now passed. Press PASS."; -+} -diff --git a/test/jdk/java/awt/Modal/PrintDialogsTest/PrintDialogsTest.html b/test/jdk/java/awt/Modal/PrintDialogsTest/PrintDialogsTest.html -index a562b886ab..e69de29bb2 100644 ---- a/test/jdk/java/awt/Modal/PrintDialogsTest/PrintDialogsTest.html -+++ b/test/jdk/java/awt/Modal/PrintDialogsTest/PrintDialogsTest.html -@@ -1,44 +0,0 @@ -- -- -- -- -- PrintDialogsTest -- -- -- -- --Please select dialog modality type and parent; also select --the print auxiliary dialog to be displayed (Page Setup or Print dialog). --Then click "Start test" button. -- --When the windows will appear check if modal blocking for Dialog works as expected. --Then push "Open" button on the Dialog to show the auxiliary dialog and check --if it blocks the rest of the application. Then close it and check correctness --of modal blocking behavior for the Dialog again. To close all the test --windows please push "Finish" button. -- --To finish the overall test push "Pass" or "Fail" button depending on result. -- -- -- -diff --git a/test/jdk/java/awt/Modal/PrintDialogsTest/PrintDialogsTest.java b/test/jdk/java/awt/Modal/PrintDialogsTest/PrintDialogsTest.java -index 989c48295b..8a07d284a9 100644 ---- a/test/jdk/java/awt/Modal/PrintDialogsTest/PrintDialogsTest.java -+++ b/test/jdk/java/awt/Modal/PrintDialogsTest/PrintDialogsTest.java -@@ -1,5 +1,5 @@ - /* -- * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. -+ * Copyright (c) 2007, 2024, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it -@@ -25,21 +25,75 @@ - /* - * @test - * @bug 8055836 8057694 8055752 -- * @summary Check if Print and Page Setup dialogs lock other windows; -+ * @summary Check if Print and Page Setup dialogs block other windows; - * check also correctness of modal behavior for other dialogs. -- * -- * @run applet/manual=yesno PrintDialogsTest.html -+ * @library /java/awt/regtesthelpers -+ * @run main/manual PrintDialogsTest - */ - - --import java.applet.Applet; --import java.awt.*; -+import java.awt.BorderLayout; -+import java.awt.Button; -+import java.awt.Checkbox; -+import java.awt.CheckboxGroup; -+import java.awt.Dialog; -+import java.awt.Frame; -+import java.awt.EventQueue; -+import java.awt.GridLayout; -+import java.awt.Label; -+import java.awt.Panel; - - import java.awt.event.ActionEvent; - import java.awt.event.ActionListener; - - --public class PrintDialogsTest extends Applet implements ActionListener { -+public class PrintDialogsTest extends Panel implements ActionListener { -+ -+ static final String INSTRUCTIONS = -+ "This test is free format, which means there is no enforced or guided sequence." + "\n" + -+ -+ "Please select each of " + "\n" + -+ "(a) The dialog parent type." + "\n" + -+ "(b) The dialog modality type" + "\n" + -+ "(c) The print dialog type (Print dialog or Page Setup dialog)" + "\n" + -+ -+ "Once the choices have been made click the \"Start test\" button." + "\n" + -+ -+ "Three windows will appear" + "\n" + -+ "(1) A Frame or a Dialog - in the case you selected \"Dialog\" as the parent type" + "\n" + -+ "(2) a Window (ie an undecorated top-level)" + "\n" + -+ "(3) A dialog with two buttons \"Open\" and \"Finish\"" + "\n" + -+ -+ "Now check as follows whether modal blocking works as expected." + "\n" + -+ "Windows (1) and (2) contain a button which you should be able to press" + "\n" + -+ "ONLY if you selected \"Non-modal\", or \"Modeless\" for modality type." + "\n" + -+ "In other cases window (3) will block input to (1) and (2)" + "\n" + -+ -+ "Then push the \"Open\" button on the Dialog to show the printing dialog and check" + "\n" + -+ "if it blocks the rest of the application - ie all of windows (1), (2) and (3)" + "\n" + -+ "should ALWAYS be blocked when the print dialog is showing." + "\n" + -+ "Now cancel the printing dialog and check the correctness of modal blocking" + "\n" + -+ "behavior for the Dialog again." + "\n" + -+ "To close all the 3 test windows please push the \"Finish\" button." + "\n" + -+ -+ "Repeat all the above for different combinations, which should include" + "\n" + -+ "using all of the Dialog parent choices and all of the Dialog Modality types." + "\n" + -+ -+ "If any behave incorrectly, note the combination of choices and press Fail." + "\n" + -+ -+ "If all behave correctly, press Pass."; -+ -+ public static void main(String[] args) throws Exception { -+ -+ PassFailJFrame.builder() -+ .instructions(INSTRUCTIONS) -+ .rows(35) -+ .columns(60) -+ .testUI(PrintDialogsTest::createUI) -+ .testTimeOut(10) -+ .build() -+ .awaitAndCheck(); -+ } - - private Button btnTest; - private Checkbox cbPage, cbPrint, -@@ -48,6 +102,14 @@ public class PrintDialogsTest extends Applet implements ActionListener { - - private CheckboxGroup groupDialog, groupParent, groupModType; - -+ private static Frame createUI() { -+ Frame frame = new Frame("Dialog Modality Testing"); -+ PrintDialogsTest test = new PrintDialogsTest(); -+ test.createGUI(); -+ frame.add(test); -+ frame.pack(); -+ return frame; -+ } - - public void actionPerformed(ActionEvent e) { - -@@ -99,13 +161,13 @@ public class PrintDialogsTest extends Applet implements ActionListener { - - setLayout(new BorderLayout()); - -- setSize(350, 200); - Panel panel = new Panel(); -- panel.setLayout(new GridLayout(18, 1)); -+ panel.setLayout(new GridLayout(21, 1)); - - btnTest = new Button("Start test"); - btnTest.addActionListener(this); - panel.add(btnTest); -+ panel.add(new Label(" ")); // spacing - - - panel.add(new Label("Dialog parent:")); -@@ -123,6 +185,7 @@ public class PrintDialogsTest extends Applet implements ActionListener { - panel.add(cbHiddFrm); - panel.add(cbDlg); - panel.add(cbFrm); -+ panel.add(new Label(" ")); // spacing - - panel.add(new Label("Dialog modality type:")); - groupModType = new CheckboxGroup(); -@@ -139,7 +202,7 @@ public class PrintDialogsTest extends Applet implements ActionListener { - panel.add(cbDocModal); - panel.add(cbTKModal); - panel.add(cbModeless); -- add(panel); -+ panel.add(new Label(" ")); // spacing - - panel.add(new Label("Print dialog type:")); - groupDialog = new CheckboxGroup(); -@@ -148,13 +211,6 @@ public class PrintDialogsTest extends Applet implements ActionListener { - panel.add(cbPage); - panel.add(cbPrint); - -- validate(); -- setVisible(true); -- } -- -- public void start() { -- try { -- EventQueue.invokeAndWait(this::createGUI); -- } catch (Exception e) {} -+ add(panel); - } - } -diff --git a/test/jdk/javax/naming/module/RunBasic.java b/test/jdk/javax/naming/module/RunBasic.java -index 512062de40..f9d259d620 100644 ---- a/test/jdk/javax/naming/module/RunBasic.java -+++ b/test/jdk/javax/naming/module/RunBasic.java -@@ -134,7 +134,15 @@ public class RunBasic { - opts.add("test/" + clsName); - opts.add("ldap://" + HOST_NAME + "/dc=ie,dc=oracle,dc=com"); - System.out.println("Running with the '" + desc + "' module..."); -+<<<<<<< HEAD -+ runJava("-Dtest.src=" + TEST_SRC, "-p", "mods", "-m", "test/" + clsName, -+ "ldap://" + HOST_NAME + "/dc=ie,dc=oracle,dc=com"); -+||||||| 82c330b464 -+ runJava("-Dtest.src=" + TEST_SRC, "-p", "mods", "-m", "test/" + clsName, -+ "ldap://localhost/dc=ie,dc=oracle,dc=com"); -+======= - runJava(opts.toArray(String[]::new)); -+>>>>>>> cee8535a9d3de8558b4b5028d68e397e508bef71 - } - - private static void runJava(String... opts) throws Throwable { -diff --git a/test/jdk/jdk/jfr/event/oldobject/TestListenerLeak.java b/test/jdk/jdk/jfr/event/oldobject/TestListenerLeak.java -index a275eda517..2cb092e60b 100644 ---- a/test/jdk/jdk/jfr/event/oldobject/TestListenerLeak.java -+++ b/test/jdk/jdk/jfr/event/oldobject/TestListenerLeak.java -@@ -1,5 +1,5 @@ - /* -- * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. -+ * Copyright (c) 2018, 2023, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it -@@ -74,15 +74,17 @@ public class TestListenerLeak { - - public static void main(String[] args) throws Exception { - WhiteBox.setWriteAllObjectSamples(true); -- -- try (Recording r = new Recording()) { -- r.enable(EventNames.OldObjectSample).withStackTrace().with("cutoff", "infinity"); -- r.start(); -- listenerLeak(); -- r.stop(); -- List events = Events.fromRecording(r); -- if (OldObjects.countMatchingEvents(events, Stuff[].class, null, null, -1, "listenerLeak") == 0) { -- throw new Exception("Could not find leak with " + Stuff[].class); -+ while (true) { -+ try (Recording r = new Recording()) { -+ r.enable(EventNames.OldObjectSample).withStackTrace().with("cutoff", "infinity"); -+ r.start(); -+ listenerLeak(); -+ r.stop(); -+ List events = Events.fromRecording(r); -+ if (OldObjects.countMatchingEvents(events, Stuff[].class, null, null, -1, "listenerLeak") != 0) { -+ return; // Success -+ } -+ System.out.println("Could not find leak with " + Stuff[].class + ". Retrying."); - } - } - } diff --git a/test/jdk/jdk/jfr/event/os/TestCPUInformation.java b/test/jdk/jdk/jfr/event/os/TestCPUInformation.java index 7990c49a1f..abeff80e5e 100644 --- a/test/jdk/jdk/jfr/event/os/TestCPUInformation.java @@ -58403,137 +57228,6 @@ index 7990c49a1f..abeff80e5e 100644 } } } -diff --git a/test/jdk/sun/util/calendar/zi/Month.java b/test/jdk/sun/util/calendar/zi/Month.java -index cb60b8d441..bab909f763 100644 ---- a/test/jdk/sun/util/calendar/zi/Month.java -+++ b/test/jdk/sun/util/calendar/zi/Month.java -@@ -1,5 +1,5 @@ - /* -- * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. -+ * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it -@@ -21,11 +21,6 @@ - * questions. - */ - --import java.util.ArrayList; --import java.util.HashMap; --import java.util.List; --import java.util.Map; -- - /** - * Month enum handles month related manipulation. - * -@@ -47,15 +42,6 @@ enum Month { - - private final String abbr; - -- private static final Map abbreviations -- = new HashMap(12); -- -- static { -- for (Month m : Month.values()) { -- abbreviations.put(m.abbr, m); -- } -- } -- - private Month(String abbr) { - this.abbr = abbr; - } -@@ -70,11 +56,22 @@ enum Month { - * @return the Month value - */ - static Month parse(String name) { -- Month m = abbreviations.get(name); -- if (m != null) { -- return m; -- } -- return null; -+ int len = name.length(); -+ -+ if (name.regionMatches(true, 0, "January", 0, len)) return Month.JANUARY; -+ if (name.regionMatches(true, 0, "February", 0, len)) return Month.FEBRUARY; -+ if (name.regionMatches(true, 0, "March", 0, len)) return Month.MARCH; -+ if (name.regionMatches(true, 0, "April", 0, len)) return Month.APRIL; -+ if (name.regionMatches(true, 0, "May", 0, len)) return Month.MAY; -+ if (name.regionMatches(true, 0, "June", 0, len)) return Month.JUNE; -+ if (name.regionMatches(true, 0, "July", 0, len)) return Month.JULY; -+ if (name.regionMatches(true, 0, "August", 0, len)) return Month.AUGUST; -+ if (name.regionMatches(true, 0, "September", 0, len)) return Month.SEPTEMBER; -+ if (name.regionMatches(true, 0, "October", 0, len)) return Month.OCTOBER; -+ if (name.regionMatches(true, 0, "November", 0, len)) return Month.NOVEMBER; -+ if (name.regionMatches(true, 0, "December", 0, len)) return Month.DECEMBER; -+ -+ throw new IllegalArgumentException("Unknown month: " + name); - } - - /** -diff --git a/test/jdk/sun/util/calendar/zi/RuleDay.java b/test/jdk/sun/util/calendar/zi/RuleDay.java -index bc730944b4..9cd81c1e52 100644 ---- a/test/jdk/sun/util/calendar/zi/RuleDay.java -+++ b/test/jdk/sun/util/calendar/zi/RuleDay.java -@@ -1,5 +1,5 @@ - /* -- * Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. -+ * Copyright (c) 2000, 2024, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it -@@ -21,11 +21,6 @@ - * questions. - */ - --import java.util.ArrayList; --import java.util.HashMap; --import java.util.List; --import java.util.Map; -- - /** - * RuleDay class represents the value of the "ON" field. The day of - * week values start from 1 following the {@link java.util.Calendar} -@@ -34,13 +29,6 @@ import java.util.Map; - * @since 1.4 - */ - class RuleDay { -- private static final Map abbreviations = new HashMap(7); -- static { -- for (DayOfWeek day : DayOfWeek.values()) { -- abbreviations.put(day.getAbbr(), day); -- } -- } -- - private String dayName = null; - private DayOfWeek dow; - private boolean lastOne = false; -@@ -166,13 +154,23 @@ class RuleDay { - return sign + toString(d); - } - -- private static DayOfWeek getDOW(String abbr) { -- return abbreviations.get(abbr); -+ private static DayOfWeek getDOW(String name) { -+ int len = name.length(); -+ -+ if (name.regionMatches(true, 0, "Monday", 0, len)) return DayOfWeek.MONDAY; -+ if (name.regionMatches(true, 0, "Tuesday", 0, len)) return DayOfWeek.TUESDAY; -+ if (name.regionMatches(true, 0, "Wednesday", 0, len)) return DayOfWeek.WEDNESDAY; -+ if (name.regionMatches(true, 0, "Thursday", 0, len)) return DayOfWeek.THURSDAY; -+ if (name.regionMatches(true, 0, "Friday", 0, len)) return DayOfWeek.FRIDAY; -+ if (name.regionMatches(true, 0, "Saturday", 0, len)) return DayOfWeek.SATURDAY; -+ if (name.regionMatches(true, 0, "Sunday", 0, len)) return DayOfWeek.SUNDAY; -+ -+ throw new IllegalArgumentException("Unknown day-of-week: " + name); - } - - /** - * Converts the specified day of week value to the day-of-week -- * name defined in {@link java.util.Calenda}. -+ * name defined in {@link java.util.Calendar}. - * @param dow 1-based day of week value - * @return the Calendar day of week name with "Calendar." prefix. - * @throws IllegalArgumentException if the specified dow value is out of range. diff --git a/test/lib/jdk/test/lib/Platform.java b/test/lib/jdk/test/lib/Platform.java index 6269373c2b..e1511772e7 100644 --- a/test/lib/jdk/test/lib/Platform.java diff --git a/G1-iterate-region-by-bitmap-rather-than-obj-size-in.patch b/G1-iterate-region-by-bitmap-rather-than-obj-size-in.patch index fc0fb3465ddce315670454a0d7996372dcc0eaaa..6272c2651de1a776ff0779ee4d0edac0236c8ecf 100755 --- a/G1-iterate-region-by-bitmap-rather-than-obj-size-in.patch +++ b/G1-iterate-region-by-bitmap-rather-than-obj-size-in.patch @@ -367,4 +367,4 @@ index 000000000..85b49171c --- /dev/null +++ b/version.txt @@ -0,0 +1 @@ -+11.0.25.0.13 ++11.0.26.0.13 diff --git a/jdk-updates-jdk11u-jdk-11.0.25-ga.tar.xz b/jdk-updates-jdk11u-jdk-11.0.26-ga.tar.xz similarity index 82% rename from jdk-updates-jdk11u-jdk-11.0.25-ga.tar.xz rename to jdk-updates-jdk11u-jdk-11.0.26-ga.tar.xz index 0a86b9fd29777e296b596675ea94439254bc3b22..83d142f67f2b3b3b51a8101f346e2f8f36495082 100644 Binary files a/jdk-updates-jdk11u-jdk-11.0.25-ga.tar.xz and b/jdk-updates-jdk11u-jdk-11.0.26-ga.tar.xz differ diff --git a/openjdk-11.spec b/openjdk-11.spec index 4bbba2155c9e050f61b48a1f0f0c1ff7a7553748..58a2fc1c7a764078bdb4a3c29a6ea31391633dc8 100644 --- a/openjdk-11.spec +++ b/openjdk-11.spec @@ -128,7 +128,7 @@ # New Version-String scheme-style defines %global majorver 11 -%global securityver 25 +%global securityver 26 # buildjdkver is usually same as %%{majorver}, # but in time of bootstrap of next jdk, it is majorver-1, # and this it is better to change it here, on single place @@ -149,12 +149,12 @@ %global origin_nice OpenJDK %global top_level_dir_name %{origin} %global minorver 0 -%global buildver 9 +%global buildver 4 %global patchver 0 %global project jdk-updates %global repo jdk11u -%global revision jdk-11.0.25-ga +%global revision jdk-11.0.26-ga %global full_revision %{project}-%{repo}-%{revision} # priority must be 7 digits in total # setting to 1, so debug ones can have 0 @@ -768,7 +768,7 @@ Provides: java-src%{?1} = %{epoch}:%{version}-%{release} Name: java-%{javaver}-%{origin} Version: %{newjavaver}.%{buildver} -Release: 3 +Release: 1 # java-1.5.0-ibm from jpackage.org set Epoch to 1 for unknown reasons # and this change was brought into RHEL-4. java-1.5.0-ibm packages # also included the epoch in their virtual provides. This created a @@ -1715,6 +1715,16 @@ cjc.mainProgram(args) -- the returns from copy_jdk_configs.lua should not affect %changelog +* Wed Feb 12 2025 Dingli Zhang - 1:11.0.26.4-1 +- update riscv64 port to 11.0.26 + +* Wed Jan 22 2025 Autistic_boyya - 1:11.0.26.4-0 +- modified G1-iterate-region-by-bitmap-rather-than-obj-size-in.patch + +* Fri Dec 27 2024 Dingli Zhang - 1:11.0.25.9-4 +- Fix build error on docker for riscv64 +- Fix bogus date in changelog + * Wed Nov 6 2024 Pan Xuefeng - 1:11.0.25.9-3 - update LoongArch64 port to 11.0.25