RFR: 8322179: RISC-V: Implement SHA-1 intrinsic

Hamlin Li mli at openjdk.org
Fri Dec 15 17:52:44 UTC 2023


Hi,
Can you review this patch to implement SHA-1 intrinsic for riscv?
Thanks!


## Test

### Functionality

tests under `test/hotspot/jtreg/compiler/intrinsics/sha`
tests found via `find test/jdk -iname "*SHA1*.java"`

### Performance

tested on `T-HEAD Light Lichee Pi 4A`

benchmark tests `MessageDigests.java GetMessageDigest.java MessageDigestBench.java MacBench.java` which are under `test/micro/org/openjdk/bench/`.

**when intrinsic is enabled**

o.o.b.java.security.GetMessageDigest.cloneInstance                    N/A         N/A           SHA-1       N/A         N/A  avgt   10        489.860 ?       6.277  ns/op
o.o.b.java.security.GetMessageDigest.getInstance                      N/A         N/A           SHA-1       N/A         N/A  avgt   10       3477.197 ?     204.203  ns/op
o.o.b.java.security.GetMessageDigest.getInstanceWithProvider          N/A         N/A           SHA-1       N/A         N/A  avgt   10       4111.164 ?     108.861  ns/op
o.o.b.java.security.MessageDigests.digest                             N/A         N/A           SHA-1        64     DEFAULT  avgt   10       3454.207 ?      53.924  ns/op
o.o.b.java.security.MessageDigests.digest                             N/A         N/A           SHA-1     16384     DEFAULT  avgt   10     184063.834 ?     677.635  ns/op
o.o.b.java.security.MessageDigests.getAndDigest                       N/A         N/A           SHA-1        64     DEFAULT  avgt   10       8260.011 ?     150.045  ns/op
o.o.b.java.security.MessageDigests.getAndDigest                       N/A         N/A           SHA-1     16384     DEFAULT  avgt   10     191325.246 ?    3298.882  ns/op
o.o.b.javax.crypto.full.MacBench.mac                             HmacSHA1         128             N/A       N/A              avgt   10       8220.886 ?      53.684  ns/op
o.o.b.javax.crypto.full.MacBench.mac                             HmacSHA1        1024             N/A       N/A              avgt   10      18006.955 ?      92.432  ns/op
o.o.b.javax.crypto.small.MessageDigestBench.digest                   SHA1     1048576             N/A       N/A              avgt   10   11688843.558 ?   34924.678  ns/op


**when intrinsic is disabled**

o.o.b.java.security.GetMessageDigest.cloneInstance                    N/A         N/A           SHA-1       N/A         N/A  avgt   10        496.890 ?       6.695  ns/op
o.o.b.java.security.GetMessageDigest.getInstance                      N/A         N/A           SHA-1       N/A         N/A  avgt   10       3832.145 ?     178.196  ns/op
o.o.b.java.security.GetMessageDigest.getInstanceWithProvider          N/A         N/A           SHA-1       N/A         N/A  avgt   10       3625.522 ?     170.757  ns/op
o.o.b.java.security.MessageDigests.digest                             N/A         N/A           SHA-1        64     DEFAULT  avgt   10      12026.787 ?     221.032  ns/op
o.o.b.java.security.MessageDigests.digest                             N/A         N/A           SHA-1     16384     DEFAULT  avgt   10    1307913.534 ?    5527.527  ns/op
o.o.b.java.security.MessageDigests.getAndDigest                       N/A         N/A           SHA-1        64     DEFAULT  avgt   10      17707.156 ?     378.556  ns/op
o.o.b.java.security.MessageDigests.getAndDigest                       N/A         N/A           SHA-1     16384     DEFAULT  avgt   10    1379660.864 ?   49441.834  ns/op
o.o.b.javax.crypto.full.MacBench.mac                             HmacSHA1         128             N/A       N/A              avgt   10      34101.577 ?     116.905  ns/op
o.o.b.javax.crypto.full.MacBench.mac                             HmacSHA1        1024             N/A       N/A              avgt   10     107906.128 ?     966.146  ns/op
o.o.b.javax.crypto.small.MessageDigestBench.digest                   SHA1     1048576             N/A       N/A              avgt   10   82834313.280 ?  311513.127  ns/op

-------------

Commit messages:
 - Initial commit

Changes: https://git.openjdk.org/jdk/pull/17130/files
 Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=17130&range=00
  Issue: https://bugs.openjdk.org/browse/JDK-8322179
  Stats: 323 lines in 4 files changed: 317 ins; 1 del; 5 mod
  Patch: https://git.openjdk.org/jdk/pull/17130.diff
  Fetch: git fetch https://git.openjdk.org/jdk.git pull/17130/head:pull/17130

PR: https://git.openjdk.org/jdk/pull/17130


More information about the hotspot-dev mailing list