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

java/lang/Math/DivModTests.java should not compare pointers

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P4
    • 8
    • 8
    • core-libs
    • b91
    • Verified

    Description

      I am working on Boxing elimination in Hotspot JIT and the java/lang/Math/DivModTests.java fails like next:

      bash-2.05b$ bin/java -d64 -Xcomp DivModTests
      FAIL: Math.floorMod(3, 3) = 0 differs from Math.floor(x, y): 0
      FAIL: Math.floorMod(2, 3) = 2 differs from Math.floor(x, y): 2
      FAIL: Math.floorMod(1, 3) = 1 differs from Math.floor(x, y): 1
      ...
      FAIL: Long.floorMod(-9223372036854775808, -1) = 0 is different than BigDecimal result: 0
      Exception in thread "main" java.lang.RuntimeException: 51 errors found in DivMod methods.
              at DivModTests.main(DivModTests.java:48)


      The problem are next checks which compare boxing object (Integer or Long) with int (or long) value:

            140 if (fr != result) {

            243 if (fr != result) {

      javac generates pointers compare for such cases:

      119 fast_iload #8
      121 invokestatic 18 <java/lang/Integer.valueOf(I)Ljava/lang/Integer;>
      124 aload_3
      125 if_acmpeq 163

      These checks will only pass if a value is in the range of boxing cache (as they are in the test) .
      If 'result' is not in [-128,127] range the test will fail as above.

      Attachments

        Issue Links

          Activity

            People

              rriggs Roger Riggs
              kvn Vladimir Kozlov
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: