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

C2: Static field accesses in clinit can trigger deoptimizations

    XMLWordPrintable

Details

    • b07

    Backports

      Description

        FULL PRODUCT VERSION :
        java version "9-ea"
        Java(TM) SE Runtime Environment (build 9-ea+170)
        Java HotSpot(TM) 64-Bit Server VM (build 9-ea+170, mixed mode)

        A DESCRIPTION OF THE PROBLEM :
        Below is a small test case in which JIT compiler produces a very slow code even in comparison with interpreter.
        The first 30-40 iterations of outer cycle runs quite fast, 2-3 ms each. Further it begins to degrade hundreds of times up do 600-1000 ms.
        With -Xcomp option it works slowly from the very beginning.
        Reproduced always on x64 JVM and with -server option on x86 JVM.
        Reproduced on Java 8_05 as well. Didn't tested on Java 7.

        The presence of lambda does not affect reproducibility, the code just shorter.

        I associate the bug with the C2 compiler.

        THE PROBLEM WAS REPRODUCIBLE WITH -Xint FLAG: No

        THE PROBLEM WAS REPRODUCIBLE WITH -server FLAG: Yes

        STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
        Run the attached source sode.

        REPRODUCIBILITY :
        This bug can be reproduced always.

        ---------- BEGIN SOURCE ----------
        public class Test {
            static int n;
            static {
                Runnable r = () -> n = new Integer(0);
                for (int i=0; i<1000; ++i) {
                    long t = System.currentTimeMillis();
                    for (int j=0; j<100000; ++j) {
                        r.run();
                    }
                    t = System.currentTimeMillis() - t;
                    System.out.printf("%2d %6d\n", i, t);
                }
            }

            public static void main(String[] args) {
            }
        }
        ---------- END SOURCE ----------

        CUSTOMER SUBMITTED WORKAROUND :
        Do not put the code in a static section.

        Attachments

          Issue Links

            Activity

              People

                vlivanov Vladimir Ivanov
                webbuggrp Webbug Group
                Votes:
                0 Vote for this issue
                Watchers:
                7 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: