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

Integer/Long.compress gets wrong type from CompressBitsNode::Value

XMLWordPrintable

    • b08

        I found this during work with the Template Framework JDK-8344942.

        [~thartmann] found it was a regression of JDK-8283894, which was my suspicion after tracing it back to code in CompressBitsNode::Value and more specifically bitshuffle_value, on this line:

        hi = mask_max_bw < max_bw ? (1L << mask_max_bw) - 1 : src_type->hi_as_long();

        Reproduce the result like this:

        java -Xbatch -XX:CompileCommand=compileonly,Test::test -XX:+PrintIdeal Test.java
        CompileCommand: compileonly Test.test bool compileonly = true
        AFTER: print_ideal
          0 Root === 0 28 [[ 0 1 3 21 ]] inner
          3 Start === 3 0 [[ 3 5 6 7 8 9 ]] #{0:control, 1:abIO, 2:memory, 3:rawptr:BotPTR, 4:return_address}
          5 Parm === 3 [[ 28 ]] Control !jvms: Test::test @ bci:-1 (line 26)
          6 Parm === 3 [[ 28 ]] I_O !jvms: Test::test @ bci:-1 (line 26)
          7 Parm === 3 [[ 28 ]] Memory Memory: @BotPTR *+bot, idx=Bot; !jvms: Test::test @ bci:-1 (line 26)
          8 Parm === 3 [[ 28 ]] FramePtr !jvms: Test::test @ bci:-1 (line 26)
          9 Parm === 3 [[ 28 ]] ReturnAdr !jvms: Test::test @ bci:-1 (line 26)
         21 ConI === 0 [[ 28 ]] #int:min
         28 Return === 5 6 7 8 9 returns 21 [[ 0 ]]
        Exception in thread "main" java.lang.RuntimeException: Bad value: -2147483648 0
        at Test.main(Test.java:36)

        We can see from the PrintIdeal, that the Integer.compress has been constant folded to the wrong value.


        ------------------------------------------------------------- The identical issue exists for long:

        ./java -Xbatch -XX:CompileCommand=compileonly,TestL::test -XX:+PrintIdeal TestL.java
        CompileCommand: compileonly TestL.test bool compileonly = true
        AFTER: print_ideal
          0 Root === 0 28 [[ 0 1 3 21 ]] inner
          3 Start === 3 0 [[ 3 5 6 7 8 9 ]] #{0:control, 1:abIO, 2:memory, 3:rawptr:BotPTR, 4:return_address}
          5 Parm === 3 [[ 28 ]] Control !jvms: TestL::test @ bci:-1 (line 7)
          6 Parm === 3 [[ 28 ]] I_O !jvms: TestL::test @ bci:-1 (line 7)
          7 Parm === 3 [[ 28 ]] Memory Memory: @BotPTR *+bot, idx=Bot; !jvms: TestL::test @ bci:-1 (line 7)
          8 Parm === 3 [[ 28 ]] FramePtr !jvms: TestL::test @ bci:-1 (line 7)
          9 Parm === 3 [[ 28 ]] ReturnAdr !jvms: TestL::test @ bci:-1 (line 7)
         21 ConL === 0 [[ 28 ]] #long:min
         28 Return === 5 6 7 8 9 returns 21 [[ 0 ]]
        Exception in thread "main" java.lang.RuntimeException: Bad value: -9223372036854775808 0
        at TestL.main(TestL.java:17)

          1. Test.java
            1 kB
          2. TestL.java
            0.5 kB

              jbhateja Jatin Bhateja
              epeter Emanuel Peter
              Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

                Created:
                Updated:
                Resolved: