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

C2: deoptimization and re-execution cycle with StringBuilder

XMLWordPrintable

      The code
      ```java
      public class C {
          final static int N = 3_000_000;

          public static void test(int i) {
              try {
                  new StringBuilder((int)(-i));
              } catch (Throwable e) {
              }
          }

          public static void loop() {
              for (int i = 0; i < N; i++) {
                  test(i);
              }
          }

          public static void main(String[] args) {
              loop();
          }
      }
      ```
      performs much worse with C2 (about 17s) that C1 or Interpreter (about 4s).

      Probably a cycle of deopt and re-execution because of repeated exception throwing.

      Originally reported in a comment of JDK-8346989.

            Unassigned Unassigned
            mchevalier Marc Chevalier
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: