changeset 401:0a120a3124fe

meth-lazy: refactorings, made test more stressful
author mhaupt
date Thu, 12 Jul 2012 00:47:59 +0200
parents 79c955d995f0
children 421b98214f0d
files meth-lazy-7023639.xbmh.patch
diffstat 1 files changed, 121 insertions(+), 101 deletions(-) [+]
line wrap: on
line diff
--- a/meth-lazy-7023639.xbmh.patch	Wed Jul 11 22:07:17 2012 +0200
+++ b/meth-lazy-7023639.xbmh.patch	Thu Jul 12 00:47:59 2012 +0200
@@ -3,7 +3,7 @@
 
 diff -r 25fcfb3a5f65 src/share/classes/java/lang/invoke/BoundMethodHandle.java
 --- a/src/share/classes/java/lang/invoke/BoundMethodHandle.java	Wed Jul 11 14:18:03 2012 +0200
-+++ b/src/share/classes/java/lang/invoke/BoundMethodHandle.java	Wed Jul 11 22:06:34 2012 +0200
++++ b/src/share/classes/java/lang/invoke/BoundMethodHandle.java	Thu Jul 12 00:47:38 2012 +0200
 @@ -1,5 +1,5 @@
  /*
 - * Copyright (c) 2008, 2011, Oracle and/or its affiliates. All rights reserved.
@@ -92,16 +92,16 @@
 +            case 'L': return new BMH_L(type, form, x);
 +            case 'I':
 +                assert x instanceof Integer : "expected Integer, found " + x.getClass();
-+                return (BoundMethodHandle) BMHData.get("I").constructor.invokeBasic(type, form, ((Integer) x).intValue());
++                return (BoundMethodHandle) Data.get("I").constructor.invokeBasic(type, form, ((Integer) x).intValue());
 +            case 'J':
 +                assert x instanceof Long;
 +                return new BMH_J(type, form, ((Long) x).longValue());
 +            case 'F':
 +                assert x instanceof Float;
-+                return (BoundMethodHandle) BMHData.get("F").constructor.invokeBasic(type, form, ((Float) x).floatValue());
++                return (BoundMethodHandle) Data.get("F").constructor.invokeBasic(type, form, ((Float) x).floatValue());
 +            case 'D':
 +                assert x instanceof Double;
-+                return (BoundMethodHandle) BMHData.get("D").constructor.invokeBasic(type, form, ((Double) x).doubleValue());
++                return (BoundMethodHandle) Data.get("D").constructor.invokeBasic(type, form, ((Double) x).doubleValue());
 +            default : throw new InternalError("unexpected xtype: " + xtype);
 +            }
 +        } catch (Throwable t) {
@@ -193,8 +193,8 @@
  
 -    public final Object dataValue0() {
 -        return argument;
-+    protected final BMHData myData() {
-+        return BMHData.get(types());
++    protected final Data myData() {
++        return Data.get(types());
      }
  
 -    //public final Object objectDataValue0() { return           dataValue0(); }
@@ -320,19 +320,19 @@
 +        }
 +        @Override
 +        public final BoundMethodHandle cloneExtendI(MethodType mt, LambdaForm lf, int narg) throws Throwable {
-+            return (BoundMethodHandle) BMHData.get("LI").constructor.invokeBasic(mt, lf, argL0, narg);
++            return (BoundMethodHandle) Data.get("LI").constructor.invokeBasic(mt, lf, argL0, narg);
 +        }
 +        @Override
 +        public final BoundMethodHandle cloneExtendJ(MethodType mt, LambdaForm lf, long narg) throws Throwable {
-+            return (BoundMethodHandle) BMHData.get("LJ").constructor.invokeBasic(mt, lf, argL0, narg);
++            return (BoundMethodHandle) Data.get("LJ").constructor.invokeBasic(mt, lf, argL0, narg);
 +        }
 +        @Override
 +        public final BoundMethodHandle cloneExtendF(MethodType mt, LambdaForm lf, float narg) throws Throwable {
-+            return (BoundMethodHandle) BMHData.get("LF").constructor.invokeBasic(mt, lf, argL0, narg);
++            return (BoundMethodHandle) Data.get("LF").constructor.invokeBasic(mt, lf, argL0, narg);
 +        }
 +        @Override
 +        public final BoundMethodHandle cloneExtendD(MethodType mt, LambdaForm lf, double narg) throws Throwable {
-+            return (BoundMethodHandle) BMHData.get("LD").constructor.invokeBasic(mt, lf, argL0, narg);
++            return (BoundMethodHandle) Data.get("LD").constructor.invokeBasic(mt, lf, argL0, narg);
          }
      }
  
@@ -439,7 +439,7 @@
 -            }
 -            return p.xtype;
 +        public final BoundMethodHandle cloneExtendL(MethodType mt, LambdaForm lf, Object narg) throws Throwable {
-+            return (BoundMethodHandle) BMHData.get("LLL").constructor.invokeBasic(mt, lf, argL0, argL1, narg);
++            return (BoundMethodHandle) Data.get("LLL").constructor.invokeBasic(mt, lf, argL0, argL1, narg);
          }
 -
 -        public final Object dataValue1() { return this.next.argument; }
@@ -453,7 +453,7 @@
 -            return p.argument;
 +        @Override
 +        public final BoundMethodHandle cloneExtendI(MethodType mt, LambdaForm lf, int narg) throws Throwable {
-+            return (BoundMethodHandle) BMHData.get("LLI").constructor.invokeBasic(mt, lf, argL0, argL1, narg);
++            return (BoundMethodHandle) Data.get("LLI").constructor.invokeBasic(mt, lf, argL0, argL1, narg);
          }
 -
 -        public final int   intDataValue1() { return (Integer) this.next.argument; }
@@ -475,18 +475,18 @@
 -            }
 -            return new Multiple(nextArg, type2, form2, boundValueCount, xtype, argument);
 +        public final BoundMethodHandle cloneExtendJ(MethodType mt, LambdaForm lf, long narg) throws Throwable {
-+            return (BoundMethodHandle) BMHData.get("LLJ").constructor.invokeBasic(mt, lf, argL0, argL1, narg);
++            return (BoundMethodHandle) Data.get("LLJ").constructor.invokeBasic(mt, lf, argL0, argL1, narg);
          }
 -
          @Override
 -        MethodHandle clone(MethodType type2, LambdaForm form2) {
 -            return new Multiple(next, type2, form2, boundValueCount, xtype, argument);
 +        public final BoundMethodHandle cloneExtendF(MethodType mt, LambdaForm lf, float narg) throws Throwable {
-+            return (BoundMethodHandle) BMHData.get("LLF").constructor.invokeBasic(mt, lf, argL0, argL1, narg);
++            return (BoundMethodHandle) Data.get("LLF").constructor.invokeBasic(mt, lf, argL0, argL1, narg);
 +        }
 +        @Override
 +        public final BoundMethodHandle cloneExtendD(MethodType mt, LambdaForm lf, double narg) throws Throwable {
-+            return (BoundMethodHandle) BMHData.get("LLD").constructor.invokeBasic(mt, lf, argL0, argL1, narg);
++            return (BoundMethodHandle) Data.get("LLD").constructor.invokeBasic(mt, lf, argL0, argL1, narg);
          }
      }
  
@@ -516,23 +516,23 @@
 +        }
 +        @Override
 +        public final BoundMethodHandle cloneExtendL(MethodType mt, LambdaForm lf, Object narg) throws Throwable {
-+            return (BoundMethodHandle) BMHData.get("JLL").constructor.invokeBasic(mt, lf, argJ0, argL1, narg);
++            return (BoundMethodHandle) Data.get("JLL").constructor.invokeBasic(mt, lf, argJ0, argL1, narg);
 +        }
 +        @Override
 +        public final BoundMethodHandle cloneExtendI(MethodType mt, LambdaForm lf, int narg) throws Throwable {
-+            return (BoundMethodHandle) BMHData.get("JLI").constructor.invokeBasic(mt, lf, argJ0, argL1, narg);
++            return (BoundMethodHandle) Data.get("JLI").constructor.invokeBasic(mt, lf, argJ0, argL1, narg);
 +        }
 +        @Override
 +        public final BoundMethodHandle cloneExtendJ(MethodType mt, LambdaForm lf, long narg) throws Throwable {
-+            return (BoundMethodHandle) BMHData.get("JLJ").constructor.invokeBasic(mt, lf, argJ0, argL1, narg);
++            return (BoundMethodHandle) Data.get("JLJ").constructor.invokeBasic(mt, lf, argJ0, argL1, narg);
 +        }
 +        @Override
 +        public final BoundMethodHandle cloneExtendF(MethodType mt, LambdaForm lf, float narg) throws Throwable {
-+            return (BoundMethodHandle) BMHData.get("JLF").constructor.invokeBasic(mt, lf, argJ0, argL1, narg);
++            return (BoundMethodHandle) Data.get("JLF").constructor.invokeBasic(mt, lf, argJ0, argL1, narg);
 +        }
 +        @Override
 +        public final BoundMethodHandle cloneExtendD(MethodType mt, LambdaForm lf, double narg) throws Throwable {
-+            return (BoundMethodHandle) BMHData.get("JLD").constructor.invokeBasic(mt, lf, argJ0, argL1, narg);
++            return (BoundMethodHandle) Data.get("JLD").constructor.invokeBasic(mt, lf, argJ0, argL1, narg);
 +        }
 +    }
  
@@ -561,19 +561,19 @@
 +        }
 +        @Override
 +        public final BoundMethodHandle cloneExtendI(MethodType mt, LambdaForm lf, int narg) throws Throwable {
-+            return (BoundMethodHandle) BMHData.get("JI").constructor.invokeBasic(mt, lf, argJ0, narg);
++            return (BoundMethodHandle) Data.get("JI").constructor.invokeBasic(mt, lf, argJ0, narg);
 +        }
 +        @Override
 +        public final BoundMethodHandle cloneExtendJ(MethodType mt, LambdaForm lf, long narg) throws Throwable {
-+            return (BoundMethodHandle) BMHData.get("JJ").constructor.invokeBasic(mt, lf, argJ0, narg);
++            return (BoundMethodHandle) Data.get("JJ").constructor.invokeBasic(mt, lf, argJ0, narg);
 +        }
 +        @Override
 +        public final BoundMethodHandle cloneExtendF(MethodType mt, LambdaForm lf, float narg) throws Throwable {
-+            return (BoundMethodHandle) BMHData.get("JF").constructor.invokeBasic(mt, lf, argJ0, narg);
++            return (BoundMethodHandle) Data.get("JF").constructor.invokeBasic(mt, lf, argJ0, narg);
 +        }
 +        @Override
 +        public final BoundMethodHandle cloneExtendD(MethodType mt, LambdaForm lf, double narg) throws Throwable {
-+            return (BoundMethodHandle) BMHData.get("JD").constructor.invokeBasic(mt, lf, argJ0, narg);
++            return (BoundMethodHandle) Data.get("JD").constructor.invokeBasic(mt, lf, argJ0, narg);
 +        }
 +    }
  
@@ -632,7 +632,7 @@
      /** Create a LF which simply reinvokes a target of the given basic type.
       *  The target MH must have the reinvocation target bound to value #0.
       */
-@@ -342,11 +414,409 @@
+@@ -342,11 +414,410 @@
          final int NEXT_MH     = nameCursor++;
          final int REINVOKE    = nameCursor++;
          Name[] names = arguments(nameCursor - ARG_LIMIT, mtype.invokerType());
@@ -651,34 +651,34 @@
 +    /**
 +     * Meta-data wrapper for concrete BMH classes.
 +     */
-+    static class BMHData {
++    static class Data {
 +        final String                             types;
 +        final Class<? extends BoundMethodHandle> clazz;
 +        final MethodHandle                       constructor;
 +        final MethodHandle[]                     getters;
 +
-+        BMHData(String types, Class<? extends BoundMethodHandle> clazz, MethodHandle constructor, MethodHandle[] getters) {
++        Data(String types, Class<? extends BoundMethodHandle> clazz, MethodHandle constructor, MethodHandle[] getters) {
 +            this.types = types;
 +            this.clazz = clazz;
 +            this.constructor = constructor;
 +            this.getters = getters;
 +        }
 +
-+        static Map<String, BMHData> CACHE = new IdentityHashMap<>();
++        static Map<String, Data> CACHE = new IdentityHashMap<>();
 +
-+        static BMHData make(String types) {
++        static Data make(String types) {
 +            final Class<? extends BoundMethodHandle> cbmh = Factory.generateConcreteBMHClass(types);
 +            final MethodHandle ctor = Factory.makeCbmhCtor(cbmh, types);
 +            final MethodHandle[] getters = Factory.makeGetters(cbmh, types);
-+            return new BMHData(types, cbmh, ctor, getters);
++            return new Data(types, cbmh, ctor, getters);
 +        }
 +
-+        static BMHData get(String types) {
++        static Data get(String types) {
 +            final String key = types.intern();
-+            BMHData d = CACHE.get(key);
++            Data d = CACHE.get(key);
 +            if (d == null) {
 +                d = make(types);
-+                BMHData e = CACHE.get(key);
++                Data e = CACHE.get(key);
 +                if (e != null) {
 +                    d = e;
 +                } else {
@@ -690,15 +690,15 @@
 +
 +        static {
 +            // pre-fill the BMH data cache with BMH's inner classes
-+            final Class<BoundMethodHandle> bmh = BoundMethodHandle.class;
++            final Class<BoundMethodHandle> BMH = BoundMethodHandle.class;
 +            try {
-+                for (Class<?> c : bmh.getDeclaredClasses()) {
-+                    if (bmh.isAssignableFrom(c)) {
-+                        final Class<? extends BoundMethodHandle> cbmh = (Class<? extends BoundMethodHandle>) c;
++                for (Class<?> c : BMH.getDeclaredClasses()) {
++                    if (BMH.isAssignableFrom(c)) {
++                        final Class<? extends BoundMethodHandle> cbmh = c.asSubclass(BoundMethodHandle.class);
 +                        final String types = Factory.typesFromConcreteBMHClass(cbmh);
 +                        final MethodHandle ctor = Factory.makeCbmhCtor(cbmh, types);
 +                        final MethodHandle[] getters = Factory.makeGetters(cbmh, types);
-+                        final BMHData d = new BMHData(types, (Class<? extends BoundMethodHandle>) c, ctor, getters);
++                        final Data d = new Data(types, cbmh, ctor, getters);
 +                        CACHE.put(types.intern(), d);
 +                    }
 +                }
@@ -728,12 +728,12 @@
 +        static final String MH_SIG = "Ljava/lang/invoke/MethodHandle;";
 +        static final String BMH = "java/lang/invoke/BoundMethodHandle";
 +        static final String BMH_SIG = "Ljava/lang/invoke/BoundMethodHandle;";
-+        static final String BMHDATA = "java/lang/invoke/BoundMethodHandle$BMHData";
-+        static final String BMHDATA_SIG = "Ljava/lang/invoke/BoundMethodHandle$BMHData;";
++        static final String DATA = "java/lang/invoke/BoundMethodHandle$Data";
++        static final String DATA_SIG = "Ljava/lang/invoke/BoundMethodHandle$Data;";
 +
-+        static final String BMHDATA_GET_SIG = "(" + JLS_SIG + ")" + BMHDATA_SIG;
++        static final String BMHDATA_GET_SIG = "(" + JLS_SIG + ")" + DATA_SIG;
 +        static final String TYPES_SIG = "()" + JLS_SIG;
-+        static final String MYDATA_SIG = "()" + BMHDATA_SIG;
++        static final String MYDATA_SIG = "()" + DATA_SIG;
 +
 +        static final String SIG_INCIPIT = "(Ljava/lang/invoke/MethodType;Ljava/lang/invoke/LambdaForm;";
 +
@@ -861,7 +861,7 @@
 +            // obtain constructor
 +            mv.visitVarInsn(ALOAD, 0);
 +            mv.visitMethodInsn(INVOKESPECIAL, BMH, "myData", MYDATA_SIG);
-+            mv.visitFieldInsn(GETFIELD, BMHDATA, "constructor", MH_SIG);
++            mv.visitFieldInsn(GETFIELD, DATA, "constructor", MH_SIG);
 +            // load mt, lf
 +            mv.visitVarInsn(ALOAD, 1);
 +            mv.visitVarInsn(ALOAD, 2);
@@ -882,8 +882,8 @@
 +                // return BMHData.get(<extypes>).constructor.invokeBasic(mt, lf, argL0, ..., narg)
 +                // obtain constructor
 +                mv.visitLdcInsn(extypes);
-+                mv.visitMethodInsn(INVOKESTATIC, BMHDATA, "get", BMHDATA_GET_SIG);
-+                mv.visitFieldInsn(GETFIELD, BMHDATA, "constructor", MH_SIG);
++                mv.visitMethodInsn(INVOKESTATIC, DATA, "get", BMHDATA_GET_SIG);
++                mv.visitFieldInsn(GETFIELD, DATA, "constructor", MH_SIG);
 +                // load mt, lf
 +                mv.visitVarInsn(ALOAD, 1);
 +                mv.visitVarInsn(ALOAD, 2);
@@ -903,7 +903,8 @@
 +            // load class
 +            final byte[] classFile = cw.toByteArray();
 +            InvokerBytecodeGenerator.maybeDump(className, classFile);
-+            Class<? extends BoundMethodHandle> bmhClass = (Class<? extends BoundMethodHandle>) UNSAFE.defineAnonymousClass(BoundMethodHandle.class, classFile, null);
++            Class<? extends BoundMethodHandle> bmhClass =
++                UNSAFE.defineAnonymousClass(BoundMethodHandle.class, classFile, null).asSubclass(BoundMethodHandle.class);
 +            UNSAFE.ensureClassInitialized(bmhClass);
 +
 +            return bmhClass;
@@ -978,7 +979,7 @@
 +        }
 +
 +        private static String makeSignature(String types, boolean ctor) {
-+            StringBuffer buf = new StringBuffer(SIG_INCIPIT);
++            StringBuilder buf = new StringBuilder(SIG_INCIPIT);
 +            for (char c : types.toCharArray()) {
 +                buf.append(typeSig(c));
 +            }
@@ -1045,7 +1046,7 @@
  }
 diff -r 25fcfb3a5f65 src/share/classes/java/lang/invoke/CountingMethodHandle.java
 --- a/src/share/classes/java/lang/invoke/CountingMethodHandle.java	Wed Jul 11 14:18:03 2012 +0200
-+++ b/src/share/classes/java/lang/invoke/CountingMethodHandle.java	Wed Jul 11 22:06:34 2012 +0200
++++ b/src/share/classes/java/lang/invoke/CountingMethodHandle.java	Thu Jul 12 00:47:38 2012 +0200
 @@ -36,11 +36,13 @@
   *
   * @author never
@@ -1121,7 +1122,7 @@
  }
 diff -r 25fcfb3a5f65 src/share/classes/java/lang/invoke/DataBinding.java
 --- a/src/share/classes/java/lang/invoke/DataBinding.java	Wed Jul 11 14:18:03 2012 +0200
-+++ b/src/share/classes/java/lang/invoke/DataBinding.java	Wed Jul 11 22:06:34 2012 +0200
++++ b/src/share/classes/java/lang/invoke/DataBinding.java	Thu Jul 12 00:47:38 2012 +0200
 @@ -73,15 +73,12 @@
  
          @Override
@@ -1237,7 +1238,7 @@
              }
 diff -r 25fcfb3a5f65 src/share/classes/java/lang/invoke/DirectMethodHandle.java
 --- a/src/share/classes/java/lang/invoke/DirectMethodHandle.java	Wed Jul 11 14:18:03 2012 +0200
-+++ b/src/share/classes/java/lang/invoke/DirectMethodHandle.java	Wed Jul 11 22:06:34 2012 +0200
++++ b/src/share/classes/java/lang/invoke/DirectMethodHandle.java	Thu Jul 12 00:47:38 2012 +0200
 @@ -66,24 +66,22 @@
      }
  
@@ -1284,7 +1285,7 @@
      private static final MethodHandle MH_shouldBeInitialized;
 diff -r 25fcfb3a5f65 src/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java
 --- a/src/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java	Wed Jul 11 14:18:03 2012 +0200
-+++ b/src/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java	Wed Jul 11 22:06:34 2012 +0200
++++ b/src/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java	Thu Jul 12 00:47:38 2012 +0200
 @@ -27,6 +27,7 @@
  
  import sun.invoke.util.VerifyAccess;
@@ -1600,7 +1601,7 @@
  }
 diff -r 25fcfb3a5f65 src/share/classes/java/lang/invoke/Invokers.java
 --- a/src/share/classes/java/lang/invoke/Invokers.java	Wed Jul 11 14:18:03 2012 +0200
-+++ b/src/share/classes/java/lang/invoke/Invokers.java	Wed Jul 11 22:06:34 2012 +0200
++++ b/src/share/classes/java/lang/invoke/Invokers.java	Thu Jul 12 00:47:38 2012 +0200
 @@ -75,7 +75,7 @@
          if (invoker != null)  return invoker;
          MethodType mtype = targetType;
@@ -1630,7 +1631,7 @@
  
 diff -r 25fcfb3a5f65 src/share/classes/java/lang/invoke/LambdaForm.java
 --- a/src/share/classes/java/lang/invoke/LambdaForm.java	Wed Jul 11 14:18:03 2012 +0200
-+++ b/src/share/classes/java/lang/invoke/LambdaForm.java	Wed Jul 11 22:06:34 2012 +0200
++++ b/src/share/classes/java/lang/invoke/LambdaForm.java	Thu Jul 12 00:47:38 2012 +0200
 @@ -264,7 +264,7 @@
          // Do all names possess an index consistent with their local definition order?
          for (int i = 0; i < arity; i++) {
@@ -1759,7 +1760,7 @@
              for (MemberName m : MemberName.getFactory().getMethods(NamedFunction.class, false, null, null, null)) {
 diff -r 25fcfb3a5f65 src/share/classes/java/lang/invoke/MemberName.java
 --- a/src/share/classes/java/lang/invoke/MemberName.java	Wed Jul 11 14:18:03 2012 +0200
-+++ b/src/share/classes/java/lang/invoke/MemberName.java	Wed Jul 11 22:06:34 2012 +0200
++++ b/src/share/classes/java/lang/invoke/MemberName.java	Thu Jul 12 00:47:38 2012 +0200
 @@ -77,6 +77,32 @@
      //@Injected int         vmindex;
      private Object     resolution;  // if null, this guy is resolved
@@ -1795,7 +1796,7 @@
       */
 diff -r 25fcfb3a5f65 src/share/classes/java/lang/invoke/MethodHandle.java
 --- a/src/share/classes/java/lang/invoke/MethodHandle.java	Wed Jul 11 14:18:03 2012 +0200
-+++ b/src/share/classes/java/lang/invoke/MethodHandle.java	Wed Jul 11 22:06:34 2012 +0200
++++ b/src/share/classes/java/lang/invoke/MethodHandle.java	Thu Jul 12 00:47:38 2012 +0200
 @@ -28,11 +28,9 @@
  
  import java.util.*;
@@ -1851,7 +1852,7 @@
  }
 diff -r 25fcfb3a5f65 src/share/classes/java/lang/invoke/MethodHandleImpl.java
 --- a/src/share/classes/java/lang/invoke/MethodHandleImpl.java	Wed Jul 11 14:18:03 2012 +0200
-+++ b/src/share/classes/java/lang/invoke/MethodHandleImpl.java	Wed Jul 11 22:06:34 2012 +0200
++++ b/src/share/classes/java/lang/invoke/MethodHandleImpl.java	Thu Jul 12 00:47:38 2012 +0200
 @@ -186,43 +186,57 @@
      }
  
@@ -2038,7 +2039,7 @@
      private static class GuardWithCatch {
 diff -r 25fcfb3a5f65 src/share/classes/java/lang/invoke/MethodHandleNatives.java
 --- a/src/share/classes/java/lang/invoke/MethodHandleNatives.java	Wed Jul 11 14:18:03 2012 +0200
-+++ b/src/share/classes/java/lang/invoke/MethodHandleNatives.java	Wed Jul 11 22:06:34 2012 +0200
++++ b/src/share/classes/java/lang/invoke/MethodHandleNatives.java	Thu Jul 12 00:47:38 2012 +0200
 @@ -325,19 +325,13 @@
          if (defc != MethodHandle.class || refKind != REF_invokeVirtual)
              throw new LinkageError("no such method "+defc.getName()+"."+name+type);
@@ -2067,7 +2068,7 @@
      /**
 diff -r 25fcfb3a5f65 src/share/classes/java/lang/invoke/MethodType.java
 --- a/src/share/classes/java/lang/invoke/MethodType.java	Wed Jul 11 14:18:03 2012 +0200
-+++ b/src/share/classes/java/lang/invoke/MethodType.java	Wed Jul 11 22:06:34 2012 +0200
++++ b/src/share/classes/java/lang/invoke/MethodType.java	Thu Jul 12 00:47:38 2012 +0200
 @@ -108,6 +108,8 @@
      /*trusted*/ Class<?> rtype() { return rtype; }
      /*trusted*/ Class<?>[] ptypes() { return ptypes; }
@@ -2079,7 +2080,7 @@
      }
 diff -r 25fcfb3a5f65 src/share/classes/java/lang/invoke/SimpleMethodHandle.java
 --- a/src/share/classes/java/lang/invoke/SimpleMethodHandle.java	Wed Jul 11 14:18:03 2012 +0200
-+++ b/src/share/classes/java/lang/invoke/SimpleMethodHandle.java	Wed Jul 11 22:06:34 2012 +0200
++++ b/src/share/classes/java/lang/invoke/SimpleMethodHandle.java	Thu Jul 12 00:47:38 2012 +0200
 @@ -55,4 +55,10 @@
          LambdaForm form2 = internalForm().permuteArguments(1, reorder, basicTypes(newType.parameterList()));
          return new SimpleMethodHandle(newType, form2);
@@ -2093,8 +2094,8 @@
  }
 diff -r 25fcfb3a5f65 test/java/lang/invoke/MaxTest.java
 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
-+++ b/test/java/lang/invoke/MaxTest.java	Wed Jul 11 22:06:34 2012 +0200
-@@ -0,0 +1,124 @@
++++ b/test/java/lang/invoke/MaxTest.java	Thu Jul 12 00:47:38 2012 +0200
+@@ -0,0 +1,143 @@
 +/*
 + * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved.
 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
@@ -2144,22 +2145,35 @@
 +        return LOOKUP.findStatic(Math.class, "max", MethodType.methodType(t, t, t));
 +    }
 +
++    static int ITERATION_COUNT = 40000;
++    static {
++        String iterations = System.getProperty(MaxTest.class.getSimpleName() + ".ITERATION_COUNT");
++        if (iterations == null) {
++            iterations = System.getProperty(MaxTest.class.getName() + ".ITERATION_COUNT");
++        }
++        if (iterations != null) {
++            ITERATION_COUNT = Integer.parseInt(iterations);
++        }
++    }
++
 +    @Test
 +    public void testMaxLong() throws Throwable {
 +        final Class<?> C = long.class;
 +        final long P = 23L;
 +        final long Q = 42L;
 +        final long R = Math.max(P, Q);
-+        MethodHandle h = getMax(C);
-+        assertEquals((long) h.invokeExact(P, Q), R);
-+        MethodHandle bh = MethodHandles.insertArguments(h, 0, P);
-+        assertEquals((long) bh.invokeExact(Q), R);
-+        MethodHandle bbh = MethodHandles.insertArguments(bh, 0, Q);
-+        assertEquals((long) bbh.invokeExact(), R);
-+        MethodHandle b2h = MethodHandles.insertArguments(h, 1, Q);
-+        assertEquals((long) b2h.invokeExact(P), R);
-+        MethodHandle bb2h = MethodHandles.insertArguments(b2h, 0, P);
-+        assertEquals((long) bb2h.invokeExact(), R);
++        for (int i = 0; i < ITERATION_COUNT; ++i) {
++            MethodHandle h = getMax(C);
++            assertEquals((long) h.invokeExact(P, Q), R);
++            MethodHandle bh = MethodHandles.insertArguments(h, 0, P);
++            assertEquals((long) bh.invokeExact(Q), R);
++            MethodHandle bbh = MethodHandles.insertArguments(bh, 0, Q);
++            assertEquals((long) bbh.invokeExact(), R);
++            MethodHandle b2h = MethodHandles.insertArguments(h, 1, Q);
++            assertEquals((long) b2h.invokeExact(P), R);
++            MethodHandle bb2h = MethodHandles.insertArguments(b2h, 0, P);
++            assertEquals((long) bb2h.invokeExact(), R);
++        }
 +    }
 +
 +    @Test
@@ -2168,16 +2182,18 @@
 +        final int P = 23;
 +        final int Q = 42;
 +        final int R = Math.max(P, Q);
-+        MethodHandle h = getMax(C);
-+        assertEquals((int) h.invokeExact(P, Q), R);
-+        MethodHandle bh = MethodHandles.insertArguments(h, 0, P);
-+        assertEquals((int) bh.invokeExact(Q), R);
-+        MethodHandle bbh = MethodHandles.insertArguments(bh, 0, Q);
-+        assertEquals((int) bbh.invokeExact(), R);
-+        MethodHandle b2h = MethodHandles.insertArguments(h, 1, Q);
-+        assertEquals((int) b2h.invokeExact(P), R);
-+        MethodHandle bb2h = MethodHandles.insertArguments(b2h, 0, P);
-+        assertEquals((int) bb2h.invokeExact(), R);
++        for (int i = 0; i < ITERATION_COUNT; ++i) {
++            MethodHandle h = getMax(C);
++            assertEquals((int) h.invokeExact(P, Q), R);
++            MethodHandle bh = MethodHandles.insertArguments(h, 0, P);
++            assertEquals((int) bh.invokeExact(Q), R);
++            MethodHandle bbh = MethodHandles.insertArguments(bh, 0, Q);
++            assertEquals((int) bbh.invokeExact(), R);
++            MethodHandle b2h = MethodHandles.insertArguments(h, 1, Q);
++            assertEquals((int) b2h.invokeExact(P), R);
++            MethodHandle bb2h = MethodHandles.insertArguments(b2h, 0, P);
++            assertEquals((int) bb2h.invokeExact(), R);
++        }
 +    }
 +
 +    @Test
@@ -2187,16 +2203,18 @@
 +        final float Q = 42F;
 +        final float R = Math.max(P, Q);
 +        final float D = 0.1F;
-+        MethodHandle h = getMax(C);
-+        assertEquals((float) h.invokeExact(P, Q), R, D);
-+        MethodHandle bh = MethodHandles.insertArguments(h, 0, P);
-+        assertEquals((float) bh.invokeExact(Q), R, D);
-+        MethodHandle bbh = MethodHandles.insertArguments(bh, 0, Q);
-+        assertEquals((float) bbh.invokeExact(), R, D);
-+        MethodHandle b2h = MethodHandles.insertArguments(h, 1, Q);
-+        assertEquals((float) b2h.invokeExact(P), R, D);
-+        MethodHandle bb2h = MethodHandles.insertArguments(b2h, 0, P);
-+        assertEquals((float) bb2h.invokeExact(), R, D);
++        for (int i = 0; i < ITERATION_COUNT; ++i) {
++            MethodHandle h = getMax(C);
++            assertEquals((float) h.invokeExact(P, Q), R, D);
++            MethodHandle bh = MethodHandles.insertArguments(h, 0, P);
++            assertEquals((float) bh.invokeExact(Q), R, D);
++            MethodHandle bbh = MethodHandles.insertArguments(bh, 0, Q);
++            assertEquals((float) bbh.invokeExact(), R, D);
++            MethodHandle b2h = MethodHandles.insertArguments(h, 1, Q);
++            assertEquals((float) b2h.invokeExact(P), R, D);
++            MethodHandle bb2h = MethodHandles.insertArguments(b2h, 0, P);
++            assertEquals((float) bb2h.invokeExact(), R, D);
++        }
 +    }
 +
 +    @Test
@@ -2206,16 +2224,18 @@
 +        final double Q = 42F;
 +        final double R = Math.max(P, Q);
 +        final double D = 0.1;
-+        MethodHandle h = getMax(C);
-+        assertEquals((double) h.invokeExact(P, Q), R, D);
-+        MethodHandle bh = MethodHandles.insertArguments(h, 0, P);
-+        assertEquals((double) bh.invokeExact(Q), R, D);
-+        MethodHandle bbh = MethodHandles.insertArguments(bh, 0, Q);
-+        assertEquals((double) bbh.invokeExact(), R, D);
-+        MethodHandle b2h = MethodHandles.insertArguments(h, 1, Q);
-+        assertEquals((double) b2h.invokeExact(P), R, D);
-+        MethodHandle bb2h = MethodHandles.insertArguments(b2h, 0, P);
-+        assertEquals((double) bb2h.invokeExact(), R, D);
++        for (int i = 0; i < ITERATION_COUNT; ++i) {
++            MethodHandle h = getMax(C);
++            assertEquals((double) h.invokeExact(P, Q), R, D);
++            MethodHandle bh = MethodHandles.insertArguments(h, 0, P);
++            assertEquals((double) bh.invokeExact(Q), R, D);
++            MethodHandle bbh = MethodHandles.insertArguments(bh, 0, Q);
++            assertEquals((double) bbh.invokeExact(), R, D);
++            MethodHandle b2h = MethodHandles.insertArguments(h, 1, Q);
++            assertEquals((double) b2h.invokeExact(P), R, D);
++            MethodHandle bb2h = MethodHandles.insertArguments(b2h, 0, P);
++            assertEquals((double) bb2h.invokeExact(), R, D);
++        }
 +    }
 +
 +}