JDK 9 RFR of 4477961: java.lang.Math.toDegrees(double) could be optimized

Aleksey Shipilev aleksey.shipilev at oracle.com
Mon Sep 22 21:43:47 UTC 2014


Hi Brian,

Looks OK.

On 09/23/2014 01:10 AM, Brian Burkhalter wrote:
> Summary: Change constructs like “a * B / C” and “u / V * W” to “x *
> (Y / Z)” where lower case denotes a variable and upper case a
> constant. This forces the constant value (Y / Z) to be evaluated only
> once per VM instance, and replaces division of the variable with
> multiplication. The resulting performance improvement is more than
> 300% as measure by JMH on a MacBookPro11,1 dual core i7 running Mac
> OS 10.9.5.

Hm, and this compiler transformation works in strictfp context? I hope
compilers do the constant folding in strictfp/fdlibm mode...

I would probably just go and declare the private compile-time constants.
This is safer, since: a) you are not at the mercy of optimizing compiler
anymore (have you tried the benchmark with C1?); b) the initializing
expressions are FP-strict, less opportunity for hard to diagnose numeric
problem.

-Aleksey.




More information about the core-libs-dev mailing list