C2: Optimize MemorySegment shape in int loop

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Fixed
    • Priority: P4
    • 20
    • Affects Version/s: 19, 20
    • Component/s: hotspot
    • b02

      The loop body to optimize is:
              for (int i = 0; i < size; i++) {
                  long j = i * UNSAFE.ARRAY_INT_INDEX_SCALE;

                  j = Objects.checkIndex(j, size * 4);

                  if (((base + j) & 3) != 0) {
                      throw new RuntimeException();
                  }

                  v += UNSAFE.getInt(base + j);
              }

      loop iv is first scaled, result is then casted to long, range checked and finally address of memory location is computed.

            Assignee:
            Roland Westrelin
            Reporter:
            Roland Westrelin
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: