United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-8022109 : Evaluate adding incrementExact, decrementExact, negateExact to java.lang.Math

Details
Type:
Enhancement
Submit Date:
2013-08-02
Status:
Closed
Updated Date:
2017-05-17
Project Name:
JDK
Resolved Date:
2013-08-14
Component:
core-libs
OS:
Sub-Component:
java.lang
CPU:
Priority:
P3
Resolution:
Fixed
Affected Versions:
Fixed Versions:

Related Reports

Sub Tasks

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.
                                    

Comments
URL:   http://hg.openjdk.java.net/jdk8/jdk8/jdk/rev/17dfbb3f60d3
User:  lana
Date:  2013-08-26 18:32:19 +0000

                                     
2013-08-26
URL:   http://hg.openjdk.java.net/jdk8/tl/jdk/rev/17dfbb3f60d3
User:  mduigou
Date:  2013-08-14 20:38:59 +0000

                                     
2013-08-14



Hardware and Software, Engineered to Work Together