Description
Part of the Nashorn runtime performance effort is to add VM intrinsics for the addExact, mulExact and subExact methods in java.lang.Math. We would of course like as much integer/long arithmetic with overflow exceptions as possible in java.lang.Math for intrinsification, so if these methods that were previously proposed could be put back, that'd be great.
The addExact intrinsic is basically
add eax, edx
jo fail:
ret //normal path
which would make it extremely fast and help JavaScript runtime performance
See also: http://blog.joda.org/2012/02/jdk-helper-math-methods.html
The following arithmetic operations exist in JavaScript
unary +, unary -, ++, --, add, div, mod, mul, sub, div
The unary plus that behaves like negateExact (but doesn't negate) would be useful to us all, as well as various comparison operations ifleExact(int, int), but they obviously don't belong in Math. I'm just mentioning them as reference.
The addExact intrinsic is basically
add eax, edx
jo fail:
ret //normal path
which would make it extremely fast and help JavaScript runtime performance
See also: http://blog.joda.org/2012/02/jdk-helper-math-methods.html
The following arithmetic operations exist in JavaScript
unary +, unary -, ++, --, add, div, mod, mul, sub, div
The unary plus that behaves like negateExact (but doesn't negate) would be useful to us all, as well as various comparison operations ifleExact(int, int), but they obviously don't belong in Math. I'm just mentioning them as reference.
Attachments
Issue Links
- relates to
-
JDK-8230074 Improve specification for {Math, StrictMath}.negateExact
- Resolved
-
JDK-8229485 Add decrementExact(), incrementExact(), and negateExact() to java.lang.StrictMath
- Resolved