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

Scalar replacement of cloned array is broken after JDK-8238759

    Details

    • Subcomponent:
    • Introduced In Build:
      b13
    • Introduced In Version:
      15
    • Resolved In Build:
      b18

      Description

      The Integer array allocation in the following test can be scalar replaced because the array is not escaping:

      public class Test {

          public static Integer test() {
              Integer[] src = new Integer[10];
              src[0] = new Integer(42);
              Integer[] dst = (Integer[])src.clone();
              return dst[0];
          }

          public static void main(String[] args) {
              for (int i = 0; i < 100_000; ++i) {
                  test();
              }
          }
      }

      Before JDK-8238759:
      Scalar 351 CheckCastPP === 348 346 [[ 353 353 ]] #narrowoop: java/lang/Integer:exact *[int:10]:NotNull:exact *,iid=334 !jvms: Test::test @ bci:19
      ++++ Eliminated: 334 AllocateArray
      Scalar 57 CheckCastPP === 54 52 [[ 161 161 63 63 ]] #narrowoop: java/lang/Integer:exact *[int:10]:NotNull:exact *,iid=40 !jvms: Test::test @ bci:2
      ++++ Eliminated: 40 AllocateArray

      After JDK-8238759:
      NotScalar (Object is passed as argument) 351 CheckCastPP === 348 346 [[ 358 370 370 ]] #narrowoop: java/lang/Integer:exact *[int:10]:NotNull:exact *,iid=334 !jvms: Test::test @ bci:19
        >>>> 358 ArrayCopy === 348 1 333 8 1 ( 57 61 351 61 357 _ _ _ _ ) [[ 359 361 ]] void ( java/lang/Object *, int, java/lang/Object *, int, int, int, int, BotPTR *+bot, BotPTR *+bot ) (oop array clone, tightly coupled allocation) !jvms: Test::test @ bci:19
      NotScalar (Object is passed as argument) 57 CheckCastPP === 54 52 [[ 334 161 63 63 161 358 ]] #narrowoop: java/lang/Integer:exact *[int:10]:NotNull:exact *,iid=40 !jvms: Test::test @ bci:2
        >>>> 358 ArrayCopy === 348 1 333 8 1 ( 57 61 351 61 357 _ _ _ _ ) [[ 359 361 ]] void ( java/lang/Object *, int, java/lang/Object *, int, int, int, int, BotPTR *+bot, BotPTR *+bot ) (oop array clone, tightly coupled allocation) !jvms: Test::test @ bci:19
      NotScalar (Object is passed as argument) 351 CheckCastPP === 348 346 [[ 358 370 370 ]] #narrowoop: java/lang/Integer:exact *[int:10]:NotNull:exact *,iid=334 !jvms: Test::test @ bci:19
        >>>> 358 ArrayCopy === 348 1 333 8 1 ( 57 61 351 61 357 _ _ _ _ ) [[ 359 361 ]] void ( java/lang/Object *, int, java/lang/Object *, int, int, int, int, BotPTR *+bot, BotPTR *+bot ) (oop array clone, tightly coupled allocation) !jvms: Test::test @ bci:19
      NotScalar (Object is passed as argument) 57 CheckCastPP === 54 52 [[ 334 161 63 63 161 358 ]] #narrowoop: java/lang/Integer:exact *[int:10]:NotNull:exact *,iid=40 !jvms: Test::test @ bci:2
        >>>> 358 ArrayCopy === 348 1 333 8 1 ( 57 61 351 61 357 _ _ _ _ ) [[ 359 361 ]] void ( java/lang/Object *, int, java/lang/Object *, int, int, int, int, BotPTR *+bot, BotPTR *+bot ) (oop array clone, tightly coupled allocation) !jvms: Test::test @ bci:19

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                thartmann Tobias Hartmann
                Reporter:
                thartmann Tobias Hartmann
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: