RFR 7131192: BigInteger.doubleValue() is depressingly slow (original) (raw)

Brian Burkhalter brian.burkhalter at oracle.com
Mon Jun 17 18:25:33 UTC 2013


I am unable at the moment to copy anything to cr.openjdk.java.net so I am including the webrev as a patch below. I'll copy it to the online location as soon as possible.

The patch included at the end of this message fixes this issue

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7131192

Code review of the source and accompanying test was effected and all pertinent regression tests passed. Previous performance testing showed a massive improvement:

http://mail.openjdk.java.net/pipermail/core-libs-dev/2013-February/014697.html

Note that as correctness testing of 7131192 depends on the patch

http://mail.openjdk.java.net/pipermail/core-libs-dev/2013-June/017958.html

having already been applied, the present fix cannot be integrated until this prior patch has been applied.

Thanks,

Brian

HG changeset patch

Parent 35d5a218004fb1fc64c92fd3151d0a48d4f378e9

7131192: BigInteger.doubleValue() is depressingly slow. Summary: Replace invocations Double.parseDouble(toString()) and Float.parseFloat(toString()) with direct implementation of conversion from signum and mag. Reviewed-by: TBD Contributed-by: Louis Wasserman <lowasser at google.com>

diff -r 35d5a218004f src/share/classes/java/math/BigInteger.java --- a/src/share/classes/java/math/BigInteger.java Thu Jun 13 14🔞52 2013 -0700 +++ b/src/share/classes/java/math/BigInteger.java Fri Jun 14 14:10:43 2013 -0700 @@ -33,6 +33,9 @@ import java.io.*; import java.util.Arrays;

+import sun.misc.DoubleConsts; +import sun.misc.FloatConsts; + /**

@@ -2986,8 +3053,80 @@ * @return this BigInteger converted to a {@code double}. */ public double doubleValue() {

diff -r 35d5a218004f test/java/math/BigInteger/PrimitiveConversionTests.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/math/BigInteger/PrimitiveConversionTests.java Fri Jun 14 14:10:43 2013 -0700 @@ -0,0 +1,82 @@ +import static java.math.BigInteger.ONE; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; +import java.util.Random; + +/**

+}



More information about the core-libs-dev mailing list