C2: optimize stores into primitive arrays by combining values into larger store

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Fixed
    • Priority: P4
    • 23
    • Affects Version/s: 22
    • Component/s: hotspot
    • b20

      [~redestad] and [~rriggs] have recently been asking if patterns like below can be improved in C2.

      - Storing a sequence of byte constants:
              a[0] = 't';
              a[1] = 'r';
              a[2] = 'u';
              a[3] = 'e';
      - Storing a int-value:
              a[1] = (byte)v;
              a[2] = (byte)(v >> 8 );
              a[3] = (byte)(v >> 16);
              a[4] = (byte)(v >> 24);

      An alternative is to use Unsafe or "BALE":
      UNSAFE.putIntUnaligned
      ByteArrayLittleEndian.setInt

      However, [~redestad] has pointed out that using ByteArrayLittleEndian can slow down initialization of the JVM, because of varHandle overheads. And we would like to avoid using Unsafe - or rather move away from it when possible.

            Assignee:
            Emanuel Peter
            Reporter:
            Emanuel Peter
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: