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

Do not use ArrayList when LambdaForm has a single ClassData

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 20
    • None
    • core-libs
    • None

      The ClassData of a LambdaForm class is always passed as an ArrayList, even if the list contains a single element

      https://github.com/openjdk/jdk/blob/21407dec0156301871a83328615e4d975c4287c4/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java#L382-L394

      We should optimize for the single-element case for a small code size and speed improvement.

      Data with the exploded JDK:

      $ java -cp . HelloWorld

      total generated LambdaForms: 34
      with a single ClassData: 34

      $ java -jar $ECLIPSE

      total generated LambdaForms: 427
      with a single ClassData: 406

      (There are no LambdaForms with 0 ClassData in either case, so that's not worth optimizing).

            iklam Ioi Lam
            iklam Ioi Lam
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: