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

[lworld] C2 should respect larval state when scalarizing

XMLWordPrintable

      Currently, Unsafe.makePrivateBuffer returns an inline type. As a result, C2 attempts scalarization which leads to incorrect results.

      We would need to:
      - Make sure private buffers are never scalarized (also not in safepoints)
      - Be careful when removing redundant allocations to not replace larval buffer allocations by "normal" buffer allocations
      - Make sure the Unsafe.get*/put* operations have an effect
      - Scalarize only after finishPrivateBuffer

      This manifests, for example, with TestIntrinsics when being executed with -XX:DisableIntrinsic=_putInt because the call to Unsafe.putInt has no effect on the scalarized inline type.

      Also, code like this currently crashes C2's typesystem:
          MyValue incrementAndCheckUnsafe() {
              MyValue vt = U.makePrivateBuffer(this);
              U.putInt(vt, X_OFFSET, x + 1);
              U.putInt(vt, Y_OFFSET, y + 1);
              return vt;
          }

      This also manifests with tests being executed with -XX:+DeoptimizeALot.

            jbhateja Jatin Bhateja
            thartmann Tobias Hartmann
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: