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

invalid FP identity transform - (a - b) -> b - a

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      b12
    • CPU:
      generic
    • OS:
      generic
    • Verification:
      Not verified

      Backports

        Description

        Looks like static field access of uninitialized class leads to wrong 1/-0 result in case server compiler is used.

        The following test case demonstrates this:

        ======== TesterSmall_10.java ========
        final class TesterSmall_10_Class_0 {
            static float var_1 = 1;
            float var_2 = 1;
        }

        public class TesterSmall_10 {
            float var_3 = TesterSmall_10_Class_0.var_1; // changing this line to "float var_1 = 1" will make the test pass
            float var_bad;
            float var_ok;

            void test()
            {
                var_bad += 1 / -(TesterSmall_10_Class_0.var_1 -= TesterSmall_10_Class_0.var_1);

                TesterSmall_10_Class_0 t0 = new TesterSmall_10_Class_0();
                var_ok += 1 / -(t0.var_2 -= t0.var_2);
            }

            public static void main(String[] args)
            {
                    TesterSmall_10 t = new TesterSmall_10();
                    t.test();

                    System.out.println(" Tester.var_ok = " + t.var_ok);
                    System.out.println("Tester.var_bad = " + t.var_bad);

                    System.out.println((t.var_bad == t.var_ok ? "PASS" : "FAIL") + "\n");
            }
        }
        =============================================

        > java -server -Xcomp -XX:CompileOnly=Tester TesterSmall_10
         Tester.var_ok = -Infinity
        Tester.var_bad = Infinity
        FAIL

        The test passes in -Xint and with client compiler:
        > java -client -Xcomp -XX:CompileOnly=Tester TesterSmall_10
         Tester.var_ok = -Infinity
        Tester.var_bad = -Infinity
        PASS

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                never Tom Rodriguez
                Reporter:
                epavlova Ekaterina Pavlova
                Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: