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

[lworld] C1 aastore on a Phi node needs flattened array check


    • Type: Enhancement
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: repo-valhalla
    • Fix Version/s: repo-valhalla
    • Component/s: hotspot
    • Labels:


      TestLWorld.test38 currently fails due to this issue.

      In C1, Phi nodes are created when merging two paths of execution. In the following code, a Phi node is created to merge the two switch cases. An asstore instruction is then used to store into this node.

      Sometimes when a Phi node is created, the exact type of the node cannot be determined. (E.g., the same local slot can be assigned different types in the two paths). Therefore, for type safety, in the current implementation, a Phi node is assigned to have no type (except for the very narrow case of JDK-8214742). See


      Hence, when aastore is used on a Phi node with no type info, it's possible for the targeted array to be flattened, and C1 must emit a check for flatness.

      public class CovStore3 {
          static final value class V {
              final int v0 = 0, v1 = 0;
              static V make(int n) {
                  V v = V.default;
                  v = __WithField(v.v0, 1234 + n);
                  v = __WithField(v.v1, 5678 + n);
                  return v;

          static public Object[] test38_inline() {
              return new V[42];

          static public Object[] test(Object[] oa, Object o, int i1, int i2, int num) {
              Object[] result = null;
              switch (num) {
              case 0:
                  result = test38_inline();
              case 1:
                  result = oa;
              result[i2] = o; // <<< aastore into a Phi node
              return result;

          public static void main(String args[]) {
              V v = V.make(1);
              V[] arr = new V[2];
              Object[] o = test(null, v, 0, 0, 0);
              System.out.println("Hello: " + o[0]); // v.v0 should be 1234




            • Assignee:
              iklam Ioi Lam
              iklam Ioi Lam
            • Votes:
              0 Vote for this issue
              1 Start watching this issue


              • Created: