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

Hotspot Fails To Compile Simple Method Using Long Division By 10

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 6u10
    • hotspot
    • x86
    • linux

      FULL PRODUCT VERSION :
      java version "1.6.0_10"
      Java(TM) SE Runtime Environment (build 1.6.0_10-b33)
      Java HotSpot(TM) 64-Bit Server VM (build 11.0-b15, mixed mode)

      java version "1.6.0_07"
      Java(TM) SE Runtime Environment (build 1.6.0_07-b06)
      Java HotSpot(TM) 64-Bit Server VM (build 10.0-b23, mixed mode)

      java version "1.6.0_04"
      Java(TM) SE Runtime Environment (build 1.6.0_04-b12)
      Java HotSpot(TM) 64-Bit Server VM (build 10.0-b19, mixed mode)



      FULL OS VERSION :
      Linux 2.4.21-50.ELsmp
      Linux 2.6.18-92.1.10.e15

      A DESCRIPTION OF THE PROBLEM :
      Hotspot fails to compile a simple method containing long division by a constant value of 10. If the long division is by any other constant, eg 11 then Hotspot succeeds in compiling the method

      Problem does not exist if same code is run in 32bit version of same JVM.
      Problem does not exist if integers are used instead of longs

      Suspected cause. Undesirable interaction between custom optimisation of constant division by 10 and the register allocation algorithm


      THE PROBLEM WAS REPRODUCIBLE WITH -Xint FLAG: No

      THE PROBLEM WAS REPRODUCIBLE WITH -server FLAG: Yes

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      javac Test.java
      java -XX:+PrintCompilation Test

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      Expected behaviour is the method JITFails and JITSucceeds are successfully compiled by HotSpot

      Actual behaviour the method JITFails is not compiled
      ERROR MESSAGES/STACK TRACES THAT OCCUR :
        1 Test::JITFails (34 bytes)
        2 Test::JITSucceeds (34 bytes)
        1% Test::main @ 2 (35 bytes)
        1 COMPILE SKIPPED: failed spill-split-recycle sanity check (not retryable)


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      public class Test
      {
        public static long JITFails(long num, int s)
        {
          long a;
          
          switch (s)
          {
            default:
              num = num / 10;
            case 1:
              a = num / 10;
              
              return (a);
          }
        }
        
        public static long JITSucceeds(long num, int s)
        {
          long a;
          
          switch (s)
          {
            default:
              num = num / 11;
            case 1:
              a = num / 11;
              
              return (a);
          }
        }
        
        public static void main(String [] args) {
          
          for (int i = 0; i < 100000; i++) {
            JITFails(123456L, i % 2);
            
            JITSucceeds(123456, i % 2);
          }
        }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      No work around found

            never Tom Rodriguez
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: