changeset 447:a49289c99587

meth-info-8008688.patch: fix regression on BigArityTest
author jrose
date Tue, 02 Jul 2013 17:15:57 -0700
parents 0591b53a4471
children 5e0f932f8ef0
files meth-info-8008688.patch
diffstat 1 files changed, 67 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/meth-info-8008688.patch	Wed Jun 26 22:38:32 2013 -0700
+++ b/meth-info-8008688.patch	Tue Jul 02 17:15:57 2013 -0700
@@ -266,9 +266,75 @@
      boolean isInvokeSpecial() {
          return false;  // DMH.Special returns true
      }
+@@ -1356,7 +1361,7 @@
+     MethodHandle rebind() {
+         // Bind 'this' into a new invoker, of the known class BMH.
+         MethodType type2 = type();
+-        LambdaForm form2 = reinvokerForm(type2.basicType());
++        LambdaForm form2 = reinvokerForm(this);
+         // form2 = lambda (bmh, arg*) { thismh = bmh[0]; invokeBasic(thismh, arg*) }
+         return BoundMethodHandle.bindSingle(type2, form2, this);
+     }
+@@ -1369,23 +1374,38 @@
+     /** Create a LF which simply reinvokes a target of the given basic type.
+      *  The target MH must override {@link #reinvokerTarget} to provide the target.
+      */
+-    static LambdaForm reinvokerForm(MethodType mtype) {
+-        mtype = mtype.basicType();
++    static LambdaForm reinvokerForm(MethodHandle target) {
++        MethodType mtype = target.type().basicType();
+         LambdaForm reinvoker = mtype.form().cachedLambdaForm(MethodTypeForm.LF_REINVOKE);
+         if (reinvoker != null)  return reinvoker;
+-        MethodHandle MH_invokeBasic = MethodHandles.basicInvoker(mtype);
++        if (mtype.parameterSlotCount() >= MethodType.MAX_MH_ARITY)
++            return makeReinvokerForm(target.type(), target);  // cannot cache this
++        reinvoker = makeReinvokerForm(mtype, null);
++        return mtype.form().setCachedLambdaForm(MethodTypeForm.LF_REINVOKE, reinvoker);
++    }
++    private static LambdaForm makeReinvokerForm(MethodType mtype, MethodHandle customTargetOrNull) {
++        boolean customized = (customTargetOrNull != null);
++        MethodHandle MH_invokeBasic = customized ? null : MethodHandles.basicInvoker(mtype);
+         final int THIS_BMH    = 0;
+         final int ARG_BASE    = 1;
+         final int ARG_LIMIT   = ARG_BASE + mtype.parameterCount();
+         int nameCursor = ARG_LIMIT;
+-        final int NEXT_MH     = nameCursor++;
++        final int NEXT_MH     = customized ? -1 : nameCursor++;
+         final int REINVOKE    = nameCursor++;
+         LambdaForm.Name[] names = LambdaForm.arguments(nameCursor - ARG_LIMIT, mtype.invokerType());
+-        names[NEXT_MH] = new LambdaForm.Name(NF_reinvokerTarget, names[THIS_BMH]);
+-        Object[] targetArgs = Arrays.copyOfRange(names, THIS_BMH, ARG_LIMIT, Object[].class);
+-        targetArgs[0] = names[NEXT_MH];  // overwrite this MH with next MH
+-        names[REINVOKE] = new LambdaForm.Name(MH_invokeBasic, targetArgs);
+-        return mtype.form().setCachedLambdaForm(MethodTypeForm.LF_REINVOKE, new LambdaForm("BMH.reinvoke", ARG_LIMIT, names));
++        Object[] targetArgs;
++        MethodHandle targetMH;
++        if (customized) {
++            targetArgs = Arrays.copyOfRange(names, ARG_BASE, ARG_LIMIT, Object[].class);
++            targetMH = customTargetOrNull;
++        } else {
++            names[NEXT_MH] = new LambdaForm.Name(NF_reinvokerTarget, names[THIS_BMH]);
++            targetArgs = Arrays.copyOfRange(names, THIS_BMH, ARG_LIMIT, Object[].class);
++            targetArgs[0] = names[NEXT_MH];  // overwrite this MH with next MH
++            targetMH = MethodHandles.basicInvoker(mtype);
++        }
++        names[REINVOKE] = new LambdaForm.Name(targetMH, targetArgs);
++        return new LambdaForm("BMH.reinvoke", ARG_LIMIT, names);
+     }
+ 
+     private static final LambdaForm.NamedFunction NF_reinvokerTarget;
 diff --git a/src/share/classes/java/lang/invoke/MethodHandleImpl.java b/src/share/classes/java/lang/invoke/MethodHandleImpl.java
 --- a/src/share/classes/java/lang/invoke/MethodHandleImpl.java
 +++ b/src/share/classes/java/lang/invoke/MethodHandleImpl.java
+@@ -317,7 +317,7 @@
+         private MethodHandle cache;
+ 
+         AsVarargsCollector(MethodHandle target, MethodType type, Class<?> arrayType) {
+-            super(type, reinvokerForm(type));
++            super(type, reinvokerForm(target));
+             this.target = target;
+             this.arrayType = arrayType;
+             this.cache = target.asCollector(arrayType, 0);
 @@ -777,16 +777,27 @@
      }
      static <T extends Throwable> Empty throwException(T t) throws T { throw t; }
@@ -340,7 +406,7 @@
 +        private final MemberName member;
 +
 +        private WrappedMember(MethodHandle target, MethodType type, MemberName member) {
-+            super(type, reinvokerForm(type));
++            super(type, reinvokerForm(target));
 +            this.target = target;
 +            this.member = member;
 +        }