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

given a call with boxed operands, explore possible callers for evidence of unboxed use of the operand

    Details

    • Type: Enhancement
    • Status: Open
    • Priority: P4
    • Resolution: Unresolved
    • Affects Version/s: 9, 10
    • Fix Version/s: tbd
    • Component/s: hotspot
    • Labels:

      Description

      For example, given this static method:

      void logIf(boolean flag, Supplier<String> message) {
        if (flag) System.out.println(message.get());
      }

      and this use:

      invokedynamic{ new Supplier(){ public String get() { return "it's late"; } } }

      We notice in this case that if the flag is usually false then we can delay building the anonymous class instance (under Supplier).

      After inlining, the steps become clear.
      * an inner class construction call
      * initialization into the object (as into a box) of all relevant environmental values
      * inlined invocation of logIf(false, …)
      * the closure is not created
      * inlined inaction of logIf(true, …)
      * the closure is still not created, at least until it need to escapes as a normal object
      * in normal operation, the box does not really exist

      One bit of strategy is important: Make methods more attractive to inline if they operate on their operands. Getting the operand creation into the same scope as the final operation leads to many code simplifications.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                jrose John Rose
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated: