Backport BigDecimal performance patches
Joe Darcy
joe.darcy at oracle.com
Fri Nov 5 11:05:45 PDT 2010
Dr Andrew John Hughes wrote:
> On 12:34 Thu 04 Nov , Joe Darcy wrote:
>
>> Andrew Haley wrote:
>>
>>> This is a backport of the BigDecimal performance rewrite.
>>> http://cr.openjdk.java.net/~aph/6622432-openjdk6-webrev/
>>>
>>> rev 397 : 6622432: RFE: Performance improvements to java.math.BigDecimal
>>> Reviewed-by: darcy
>>> rev 398 : 6850606: Regression from JDK 1.6.0_12
>>> Summary: The returned result from multiply should be constructed by using valueOf to take care of the INFLATED case.
>>> Reviewed-by: darcy
>>> rev 399 : 6876282: BigDecimal's divide(BigDecimal bd, RoundingFormat r) produces incorrect result
>>> Reviewed-by: darcy
>>>
>>> The patches didn't quite apply cleanly, but once I fixed them up by hand
>>> there were no regressions of either the JCK or JTreg.
>>>
>>> Given that 2000 lines of patch is rather hard to read, I have attached
>>> a diff between the patched jdk6 and the current jdk7 tree.
>>>
>>> OK for jdk6?
>>>
>>>
>>>
>> Hi Andrew.
>>
>> I approve this backport in principle, but need to look over the diffs
>> more closely before giving the final okay. There were some spec changes
>> in BigInteger/BigDecimal in JDK 7; you seem to have correctly adjusted
>> the patches for OpenJDK 6, but I just want to verify that.
>>
>> Thanks for including the diff against JDK 7; that is a big aid in
>> reviewing :-)
>>
>> -Joe
>>
>
> FWIW, the changes Andrew has backported:
>
> changeset: 1794:98558a60c555
> user: darcy
> date: Wed Oct 21 09:53:23 2009 -0700
> summary: 6560935: BigInteger.modPow() throws ArithmeticException for negative exponent
>
> changeset: 1785:0dd3d16e8183
> user: darcy
> date: Tue Oct 20 09:51:28 2009 -0700
> summary: 6371401: java.math.BigInteger.shift(Integer.MIN_VALUE) throws StackOverflowError
>
> changeset: 1246:8d2efec31d78
> user: xlu
> date: Sun May 24 16:29:57 2009 -0700
> summary: 6622432: RFE: Performance improvements to java.math.BigDecimal
>
> don't include the spec. changes, which do appear in the jdk7 diff he supplied. They seem to
> have occurred prior to OpenJDK entering Mercurial with b24. See:
>
> http://hg.openjdk.java.net/jdk7/jdk7/jdk/file/0/src/share/classes/java/math/BigInteger.java
>
> and were then reverted in OpenJDK6:
>
> changeset: 2:39e8fe7a0af1
> tag: jdk6-b00
> user: ohair
> date: Fri Jan 30 16:05:57 2009 -0800
> summary: 6755277: All initial changes to jdk7 to create openjdk 6 build 0
>
> http://hg.openjdk.java.net/jdk6/jdk6/jdk/diff/39e8fe7a0af1/src/share/classes/java/math/BigInteger.java
>
>
Thanks for the assistance with the bug archeology. The pre-Hg JDK 7 bug
for the change in the string constructor is
5017980 Allow signed positive integer to be parsed instead of a
NumerFormatException
fixed way back in JDK 7 build 3. This bug stands out for me in the
early history of OpenJDK 6. In JDK 7, because of the delegations among
the String -> number methods the specifications of 26 methods were
modified by changing the code for about 5 methods. The JCK team had
dutifully written tests included in JCK 6 to verify "+" was not accepted
as a leading character of those 26 methods so this change was the cause
of many, many JCK failures against JCK 6 in the initial backwards branch
of OpenJDK 6 from JDK 7 build 20 or so.
In any case, the patch is good and I approve the changes being backported.
Cheers,
-Joe
More information about the jdk6-dev
mailing list