JDK 9 RFC on 6667086: Double.doubleToLongBits(final double value) contains inefficient test for NaN
joe.darcy at oracle.com
Thu Jan 16 17:23:08 UTC 2014
On 01/15/2014 01:28 PM, Brian Burkhalter wrote:
> Issue: https://bugs.openjdk.java.net/browse/JDK-6667086
> Webrev: http://cr.openjdk.java.net/~bpb/6667086/webrev/
> According to micro-benckmarks, there is no statistically significant performance change due to applying this patch but the code definitely looks cleaner.
A few comments here. If you are making this change in Double, you would
make the corresponding change in Float too.
Some explanation on why I wrote these methods with the
integer-field-based null check, some processors are implemented such
that operating on the IEEE non-finite value of NaN and +/- infinity runs
much more slowly than operating on normal value, sometimes orders of
magnitude more slowly.
For the bitwise conversion methods, since we were biting the bullet to
do the conversion anyway, I thought I would avoid the worst-case cost of
tripping over a NaN by doing the NaN check on the integer value.
However, I will vote to approve the replacement of that code with
"isNaN" checks as long as Float and Double are both converted.
More information about the core-libs-dev