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

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

    XMLWordPrintable

    Details

    • Type: Enhancement
    • Status: Closed
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 8
    • Component/s: core-libs
    • Labels:
      None
    • Subcomponent:
    • Resolved In Build:
      b105
    • Verification:
      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

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

                Dates

                Created:
                Updated:
                Resolved: