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

EscapeAnalysis doesn't work for -Xcomp -XX:-TieredCompilation as in other modes

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Cannot Reproduce
    • Icon: P4 P4
    • tbd
    • 9, 10
    • hotspot

      step1: Try to compile simple class:

      import java.lang.reflect.Method;

      public class test {
          private static final int ITERATIONS = 100000;

          public static void main(String[] args) {
              new test().test();
          }

          private void test() {
              for (int i = 0; i < ITERATIONS; i++) {
                  testMethod();
              }
          }

          private void testMethod() {
              Helper helper = new Helper("" + System.currentTimeMillis());
              if (helper.string.length() < 1) {
                  throw new AssertionError("impossible");
              }
          }

          private class Helper {
              public String string;

              public Helper(String s) {
                  this.string = s;
              }
          }
      }

      step2:
      run this class with following vm options:
      1) -XX:+TieredCompilation -XX:+PrintCompilation -XX:+PrintEscapeAnalysis -XX:+Verbose
      2) -XX:-TieredCompilation -XX:+PrintCompilation -XX:+PrintEscapeAnalysis -XX:+Verbose
      3) -Xcomp -XX:+TieredCompilation -XX:+PrintCompilation -XX:+PrintEscapeAnalysis -XX:+Verbose
      4) -Xcomp -XX:-TieredCompilation -XX:+PrintCompilation -XX:+PrintEscapeAnalysis -XX:+Verbose

      A console log for testMethod escape analysis will have different results for first 3 launch and another for launch number 4.

      A first string is the most interesting one:
      for vmoptions set 1-2-3:
      JavaObject NoEscape(NoEscape) [ 1171F 993F [ 37 42 ]] 25 Allocate === 5 6 7 8 1 ( 23 21 22 1 10 1 ) [[ 26 27 28 35 36 37 ]] ... test::testMethod ... bci:0

      and for vmoptions set 4:
      JavaObject ArgEscape(GlobalEscape) [ 192F [ 37 42 ]] 25 Allocate === 5 6 7 8 1 ( 23 21 22 1 10 1 ) [[ 26 27 28 35 36 37 ]] ... test::testMethod ... bci:0


      So, a helper object is considered to be escaped and can be stack allocated for first 3 cases and considered to be ArgEscape(GlobalEscape) for 4th case, which seems to be wrong

            vlivanov Vladimir Ivanov
            dpochepk Dmitrij Pochepko
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: