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

Lazily compile lambda forms to bytecode

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 19
    • core-libs
    • None

      Currently we eagerly prepare lambda forms [1].

      This entails setting the vmentry of the lambda form to a vmentry that jumps into the lambda form interpreter.

      Based on the lambda form compilation threshold, this also entails compiling the lambda form to bytecode.

      But, due to the default compilation threshold being 0, this means that we always compile a lambda form to bytecode when calling prepare, which happens eagerly inside the MethodHandle constructor.

      This means that we end up generating unused lambda form classes for method handles that are created as intermediates in a longer MH combination chain.

      We should look into lazily preparing lambda forms, to push particularly the class generation to time of first invocation, which would avoid generating many unused lambda form classes.

      Maybe this could be achieved by setting the initial vmentry of a lambda form to a stub which does an upcall to a bootstrap method that will prepare the lambda form, and then jump to the actual vmentry target.

      [1]: https://github.com/openjdk/jdk/blob/a9b9831f2a88ed3b7701d402b167a096b94aeb98/src/java.base/share/classes/java/lang/invoke/MethodHandle.java#L482

            jvernee Jorn Vernee
            jvernee Jorn Vernee
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: