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

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

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 23
    • 22
    • 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.

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

              Created:
              Updated:
              Resolved: