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

Implement special invoker for MH.invokeWithArguments

XMLWordPrintable

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

      Consider implementing special invoker for MH.invokeWithArguments().

      Right now, new invoker is created on every invocation.

      src/java.base/share/classes/java/lang/invoke/MethodHandle.java:
          public Object invokeWithArguments(Object... arguments) throws Throwable {
              MethodType invocationType = MethodType.genericMethodType(arguments == null ? 0 : arguments.length);
              return invocationType.invokers().spreadInvoker(0).invokeExact(asType(invocationType), arguments);
          }

      It's still fast (only 5x slower than a direct call) because LambdaForm caching saves lots of work in spreadInvoker(0) case.

            Unassigned Unassigned
            vlivanov Vladimir Ivanov
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: