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

Do we need to force slots for temporaries in self-assign?

    XMLWordPrintable

Details

    • Task
    • Resolution: Fixed
    • P4
    • 8
    • 8
    • core-libs
    • None
    • b108
    • generic
    • generic

    Description

      Currently, we force the temporary symbol for an index expression in a self-assignment to get a slot. It used to be needed to avoid double evaluation of the index, e.g. in

      x[y()] += z

      However, these days we compile this to:

          ALOAD 1
          DUP
          ALOAD 2
          ACONST_NULL
          INVOKEDYNAMIC dyn:call
          ASTORE 5
          ALOAD 5
          DUP_X1
          INVOKEDYNAMIC dyn:getElem
          ALOAD 3
          INVOKEDYNAMIC ADD:OOO_I
          INVOKEDYNAMIC dyn:setElem

      Note that due to the use of DUP_X1, the ASTORE 5 and ALOAD 5 are not necessary. If we didn't use DUP_X1, then indeed we'd need the local variable slot:

          ASTORE 5
          ALOAD 5
          INVOKEDYNAMIC dyn:getElem
          ALOAD 3
          INVOKEDYNAMIC ADD:OOO_I
      -> ALOAD 5
          INVOKEDYNAMIC dyn:setElem

      It should be investigated if we can eliminate the ASTORE/ALOAD in every self-assignment scenario.

      Attachments

        Activity

          People

            attila Attila Szegedi
            attila Attila Szegedi
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: