On 7/2/21 4:30 PM, Raffaello Giulietti wrote: > FWIW, adinn's branchless code together with > PR https://git.openjdk.java.net/jdk/pull/4660 > make both methods less vulnerable to timing attacks.
I doubt it, because HotSpot generates conditional select instructions for the popular systems, at least for C2. I guess it might on a C1-only or pure interpreter system. That certainly might be an argument for using the shift-and-add magic. With a comment that would be fine, as the difference in performance doesn't seem to be worth worrying about. We're looking at sub-nanosecond throughput. -- Andrew Haley (he/him) Java Platform Lead Engineer Red Hat UK Ltd. <https://www.redhat.com> https://keybase.io/andrewhaley EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671