RFR[15] JDK-8243114: Implement montgomery{Multiply, Square}intrinsics on Windows

Simon Tooke stooke at redhat.com
Thu May 21 17:24:32 UTC 2020


Hello,

I'd like to request a review for:

JBS: https://bugs.openjdk.java.net/browse/JDK-8243114

Webrev: http://cr.openjdk.java.net/~stooke/webrevs/jdk-8243114-jdk/00/00/

This change implements the given intrinsics on Windows.

The Windows toolchain has no 128 bit integer types, and no inline asm 
(on x64 and Arm).  In addition, 'long' is 4 bytes, not 8, as it is with 
gcc.  This patch had to change some of the linux implementation to 
account for these limitations.

My gratitude for Andrew Haley for doing the heavy lifting at the core of 
this patch.

The patch, if accepted, will be offered to 11u as a potential backport.  
The changes apply cleanly modulo some line number changes.

As for the speedup, this test case:

BigInteger base = BigInteger.ONE.shiftLeft(1024);
long count = LongStream.rangeClosed(2, 100_000)
     .mapToObj(n -> BigInteger.valueOf(n).add(base))
     .filter(i -> i.isProbablePrime(50))
     .count();

goes from 1 minute 20 seconds down to about 35 seconds om my VM, over 
multiple runs.  As is the case on other platforms where the intrinsics 
are supported, they will be enabled by default on Windows.

Thank you for your time,

-Simon Tooke


Principle Software Engineer,

Red Hat Canada






More information about the security-dev mailing list