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

C2: Wrong frequency computed for call sites with immature profile

XMLWordPrintable

      Immature profiles report "-1" as a call site count and callers have to handle it as a special case.
      If `ciCallProfile::count()` is used as is, it breaks call site frequency computation (makes the result negative) and, hence, negatively affects inlining decisions.

      The code below demonstrates the issue:
       
          private static final int SIZE = 1_000_000;

          @Benchmark
          public MyList<Point> erasedIndirect() {
              var result = ListMinMap.<Point>createIndirectErased(SIZE);
              for (int i = 0; i < SIZE; i++) {
                  result.set(i, erased.get(i).times(23));
              }
              return result;
          }

          static <T> MyList<T> createIndirectErased(int size) {
              return ErasedList.create(size);
          }


      7494 67 b 4 org.bench.ListMinMap::erasedIndirect (48 bytes)
        @ 2 org.bench.ListMinMap::createIndirectErased (5 bytes) inline (hot)
          @ 1 org.bench.ListMinMap$ErasedList::create (9 bytes) failed to inline: low call site frequency
      ...

      Originally reported by [~mcimadamore]

            Unassigned Unassigned
            vlivanov Vladimir Ivanov
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: