Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8022109

Evaluate adding incrementExact, decrementExact, negateExact to java.lang.Math

    XMLWordPrintable

Details

    • Enhancement
    • Resolution: Fixed
    • P3
    • 8
    • None
    • core-libs
    • None
    • b105
    • Verified

    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.

      Attachments

        Issue Links

          Activity

            People

              bpb Brian Burkhalter
              lagergren Marcus Lagergren
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: