mozilla / rhino

Rhino is an open-source implementation of JavaScript written entirely in Java
https://rhino.github.io
Other
4.18k stars 850 forks source link

Bugs in number to string conversion #254

Open hns opened 8 years ago

hns commented 8 years ago

I recently ported the V8 double-conversion package to Java for Nashorn. I've done this previously for Rhino, the code is in the v8dtoa package. Since I did the Rhino port, the code has been pulled into a standalone library and greatly enhanced. There's now code for all three kinds of conversion (shortest, fixed, precision) as well as a Bignum-based fallback implementation, and most of all there's a very good test suite (which may have existed before, but probably as part of the greater V8 test suite).

During the Nashorn port I realized that there probably are some bugs in the Rhino port, mostly subtle ones related to signed operations on longs/ints that should be treated as unsigned. In Nashorn I made use of the new unsigned Long/Integer arithmetic API in JDK8, which is probably not an option for Rhino. Still, the Nashorn code and test suite can probably help in spotting the these issues.

http://hg.openjdk.java.net/jdk9/dev/nashorn/file/53edf7f3f10c/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/doubleconv http://hg.openjdk.java.net/jdk9/dev/nashorn/file/53edf7f3f10c/test/src/jdk/nashorn/internal/runtime/doubleconv/test

I'd be happy to help getting this fixed in Rhino. I don't have the time to do it right now. I hope I'll find some time for it soon, and of course I'd also be happy to assist anybody else willing to tackle it. A good first step would be to run FastDtoaTest against the FastDtoa.java class in Rhino.

gbrail commented 8 years ago

Of course it'd be great if you had time to work on that, but we have a few people working on the project who might pick this up. So thanks for entering it!

On Sat, Nov 14, 2015 at 12:21 AM, Hannes Wallnöfer <notifications@github.com

wrote:

I recently ported the V8 double-conversion package to Java for Nashorn. I've done this previously for Rhino, the code is in org/mozilla/javascript/v8dtoa. Since I did the Rhino port, the code has been pulled into a standalone library and greatly enhanced. There's now code for all three kinds of conversion (shortest, fixed, precision) as well as a Bignum-based fallback implementation, and most of all there's a very good test suite (which may have existed before, but probably as part of the greater V8 test suite).

During the Nashorn port I realized that there probably are some bugs in the Rhino port, mostly subtle ones related to signed operations on longs/ints that should be treated as unsigned. In Nashorn I made use of the new unsigned Long/Integer arithmetic API in JDK8, which is probably not an option for Rhino. Still, the Nashorn code and test suite can probably help in spotting the these issues.

http://hg.openjdk.java.net/jdk9/dev/nashorn/file/53edf7f3f10c/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/doubleconv

http://hg.openjdk.java.net/jdk9/dev/nashorn/file/53edf7f3f10c/test/src/jdk/nashorn/internal/runtime/doubleconv/test

I'd be happy to help getting this fixed in Rhino. I don't have the time to do it right now. I hope I'll find some time for it soon, and of course I'd also be happy to assist anybody else willing to tackle it.

— Reply to this email directly or view it on GitHub https://github.com/mozilla/rhino/issues/254.

Greg Brail | apigee https://apigee.com/ | twitter @gbrail http://twitter.com/gbrail @apigee https://twitter.com/apigee

chimbs86 commented 8 years ago

is anyone looking at this? I havent worked on rhino before, and it looks like an easy first task. Please advise

gbrail commented 8 years ago

Hannes was going to port some code from Nashorn but I don't think he has time. So that means that if you'd like to work on it, then you can go ahead. If you post updates in the GitHub issue from time to time then it'd help in case you get stuck and don't get to finish it.

On Mon, Feb 1, 2016 at 2:00 PM, Gaurav notifications@github.com wrote:

is anyone looking at this? I havent worked on rhino before, and it looks like an easy first task. Please advise

— Reply to this email directly or view it on GitHub https://github.com/mozilla/rhino/issues/254#issuecomment-178161627.

Greg Brail | apigee https://apigee.com/ | twitter @gbrail http://twitter.com/gbrail @apigee https://twitter.com/apigee

tonygermano commented 11 months ago

Links to hg.openjdk.java.net in the original post are broken. See the following links instead: https://github.com/openjdk/jdk/tree/jdk9-b94/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/doubleconv

https://github.com/openjdk/jdk/tree/jdk9-b94/nashorn/test/src/jdk/nashorn/internal/runtime/doubleconv/test

https://github.com/openjdk/jdk/blob/jdk9-b94/nashorn/test/src/jdk/nashorn/internal/runtime/doubleconv/test/FastDtoaTest.java