changeset 457:93a6c619b0ca tip

rebase to current jdk8/tl (corrections)
author jrose
date Sun, 06 Oct 2013 23:35:14 -0700
parents cf0407968713
children
files meth-asm.patch meth-btype.patch meth-lfc.patch meth-tidy.patch
diffstat 4 files changed, 85 insertions(+), 69 deletions(-) [+]
line wrap: on
line diff
--- a/meth-asm.patch	Sun Oct 06 22:41:41 2013 -0700
+++ b/meth-asm.patch	Sun Oct 06 23:35:14 2013 -0700
@@ -1,5 +1,37 @@
 Improvements and cleanups to bytecode assembly for lambda forms.
 
+diff --git a/src/share/classes/java/lang/invoke/DirectMethodHandle.java b/src/share/classes/java/lang/invoke/DirectMethodHandle.java
+--- a/src/share/classes/java/lang/invoke/DirectMethodHandle.java
++++ b/src/share/classes/java/lang/invoke/DirectMethodHandle.java
+@@ -265,9 +265,10 @@
+         } else {
+             names[GET_MEMBER] = new Name(Lazy.NF_internalMemberName, names[DMH_THIS]);
+         }
++        assert(findDirectMethodHandle(names[GET_MEMBER]) == names[DMH_THIS]);
+         Object[] outArgs = Arrays.copyOfRange(names, ARG_BASE, GET_MEMBER+1, Object[].class);
+         assert(outArgs[outArgs.length-1] == names[GET_MEMBER]);  // look, shifted args!
+-        int result = LambdaForm.LAST_RESULT;
++        int result = LAST_RESULT;
+         if (doesAlloc) {
+             assert(outArgs[outArgs.length-2] == names[NEW_OBJ]);  // got to move this one
+             System.arraycopy(outArgs, 0, outArgs, 1, outArgs.length-2);
+@@ -282,6 +283,16 @@
+         return lform;
+     }
+ 
++    static Object findDirectMethodHandle(Name name) {
++        if (name.function == Lazy.NF_internalMemberName ||
++            name.function == Lazy.NF_internalMemberNameEnsureInit ||
++            name.function == Lazy.NF_constructorMethod) {
++            assert(name.arguments.length == 1);
++            return name.arguments[0];
++        }
++        return null;
++    }
++
+     private static void maybeCompile(LambdaForm lform, MemberName m) {
+         if (VerifyAccess.isSamePackage(m.getDeclaringClass(), MethodHandle.class))
+             // Help along bootstrapping...
 diff --git a/src/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java b/src/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java
 --- a/src/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java
 +++ b/src/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java
--- a/meth-btype.patch	Sun Oct 06 22:41:41 2013 -0700
+++ b/meth-btype.patch	Sun Oct 06 23:35:14 2013 -0700
@@ -795,7 +795,7 @@
          }
      }
  
-@@ -359,38 +359,48 @@
+@@ -359,47 +359,56 @@
      /*
       * NOTE: These load/store methods use the localsMap to find the correct index!
       */
@@ -861,9 +861,10 @@
      }
  
      /**
-@@ -398,8 +408,7 @@
+      * Emit a boxing call.
       *
-      * @param type primitive type class to box.
+-     * @param type primitive type class to box.
++     * @param wrapper primitive type class to box.
       */
 -    private void emitBoxing(Class<?> type) {
 -        Wrapper wrapper = Wrapper.forPrimitiveType(type);
@@ -871,9 +872,12 @@
          String owner = "java/lang/" + wrapper.wrapperType().getSimpleName();
          String name  = "valueOf";
          String desc  = "(" + wrapper.basicTypeChar() + ")L" + owner + ";";
-@@ -411,8 +420,7 @@
+@@ -409,10 +418,9 @@
+     /**
+      * Emit an unboxing call (plus preceding checkcast).
       *
-      * @param type wrapper type class to unbox.
+-     * @param type wrapper type class to unbox.
++     * @param wrapper wrapper type class to unbox.
       */
 -    private void emitUnboxing(Class<?> type) {
 -        Wrapper wrapper = Wrapper.forWrapperType(type);
--- a/meth-lfc.patch	Sun Oct 06 22:41:41 2013 -0700
+++ b/meth-lfc.patch	Sun Oct 06 23:35:14 2013 -0700
@@ -69,15 +69,15 @@
 diff --git a/src/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java b/src/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java
 --- a/src/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java
 +++ b/src/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java
-@@ -645,6 +645,7 @@
+@@ -626,6 +626,7 @@
                  emitStaticInvoke(member, name);
              } else {
                  bump(EC_bytecode_invoke_handle);
-+                if (true || member == null || member.isMethodHandleInvoke())  Thread.dumpStack(); //@@
++                //@@ if (true || member == null || member.isMethodHandleInvoke())  Thread.dumpStack(); //@@
                  emitInvoke(name);
              }
  
-@@ -835,14 +836,33 @@
+@@ -812,14 +813,33 @@
          }
      }
  
@@ -771,7 +771,7 @@
 -
      static class NamedFunction {
          final MemberName member;
-         MethodHandle resolvedHandle;
+         @Stable MethodHandle resolvedHandle;
 diff --git a/src/share/classes/java/lang/invoke/LambdaFormEditor.java b/src/share/classes/java/lang/invoke/LambdaFormEditor.java
 new file mode 100644
 --- /dev/null
@@ -1607,17 +1607,19 @@
      }
  
      /**
-@@ -1003,12 +1015,41 @@
+@@ -1003,12 +1015,43 @@
      public MethodHandle asCollector(Class<?> arrayType, int arrayLength) {
          bump(EC_transform_asCollector);
          asCollectorChecks(arrayType, arrayLength);
 -        int collectArgPos = type().parameterCount()-1;
++        /*TBW //@@
 +        if (true) {
 +            BoundMethodHandle mh = rebind();
 +            MethodType resultType = type.asCollectorType(arrayType, arrayLength);
 +            MethodType colType = MethodType.methodType(arrayType).asCollectorType(arrayType, arrayLength);
 +            LambdaForm form2 = mh.form.editor().collectArgumentsForm(0, colType, mh.speciesData());
 +        }
++        */
 +        @SuppressWarnings("LocalVariableHidesMemberVariable")
 +        MethodType type = type();
 +        int collectArgPos = type.parameterCount()-1;
@@ -1657,7 +1659,7 @@
 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
-@@ -165,8 +165,66 @@
+@@ -166,8 +166,66 @@
              return target;
          bump(EC_makePairwiseConvert);
  
@@ -1725,8 +1727,8 @@
  
      private static int countNonNull(Object[] array) {
          int count = 0;
-@@ -501,6 +559,14 @@
-             throw newInternalError(ex);
+@@ -508,6 +566,14 @@
+             }
          }
      }
 +    private static MethodHandle CHECK_NULL_SPREAD_ARGUMENT;
@@ -1734,7 +1736,7 @@
 +        MethodHandle res = CHECK_NULL_SPREAD_ARGUMENT;
 +        if (res == null)
 +            CHECK_NULL_SPREAD_ARGUMENT = res
-+                    = NF_checkSpreadArgument.resolvedHandle().rebind().bindArgumentI(1, 0);
++                    = Lazy.NF_checkSpreadArgument.resolvedHandle().rebind().bindArgumentI(1, 0);
 +        return res;
 +    }
  
@@ -1743,7 +1745,7 @@
 diff --git a/src/share/classes/java/lang/invoke/MethodHandles.java b/src/share/classes/java/lang/invoke/MethodHandles.java
 --- a/src/share/classes/java/lang/invoke/MethodHandles.java
 +++ b/src/share/classes/java/lang/invoke/MethodHandles.java
-@@ -1935,7 +1935,7 @@
+@@ -1962,7 +1962,7 @@
       */
      static public
      MethodHandle invoker(MethodType type) {
@@ -1752,7 +1754,7 @@
      }
  
      static /*non-public*/
-@@ -1991,11 +1991,15 @@
+@@ -2018,11 +2018,15 @@
       */
      public static
      MethodHandle explicitCastArguments(MethodHandle target, MethodType newType) {
@@ -1771,7 +1773,7 @@
      }
  
      /**
-@@ -2075,7 +2079,7 @@
+@@ -2102,7 +2106,7 @@
          assert(target == originalTarget || permuteArgumentChecks(reorder, newType, target.type()));
          // Note:  This may cache too many distinct LFs. Consider backing off to varargs code.
          BoundMethodHandle result = target.rebind();
@@ -1780,7 +1782,7 @@
          return result.copyWith(newType, form);
      }
  
-@@ -2321,7 +2325,10 @@
+@@ -2348,7 +2352,10 @@
          bump(EC_transform_dropArguments);
          BoundMethodHandle result = target.rebind();
          LambdaForm lform = result.form;
@@ -1792,7 +1794,7 @@
          MethodType newType = oldType.insertParameterTypes(pos, valueTypes);
          result = result.copyWith(newType, lform);
          return result;
-@@ -2473,7 +2480,15 @@
+@@ -2500,7 +2507,15 @@
      /*non-public*/ static
      MethodHandle filterArgument(MethodHandle target, int pos, MethodHandle filter) {
          filterArgumentChecks(target, pos, filter);
@@ -1809,7 +1811,7 @@
      }
  
      private static void filterArgumentsCheckArity(MethodHandle target, int pos, MethodHandle[] filters) {
-@@ -2670,7 +2685,12 @@
+@@ -2698,7 +2713,12 @@
          MethodType targetType = target.type();
          MethodType filterType = filter.type();
          filterReturnValueChecks(targetType, filterType);
@@ -1823,7 +1825,7 @@
      }
  
      private static void filterReturnValueChecks(MethodType targetType, MethodType filterType) throws RuntimeException {
-@@ -2765,7 +2785,14 @@
+@@ -2793,7 +2813,14 @@
          MethodType targetType = target.type();
          MethodType combinerType = combiner.type();
          Class<?> rtype = foldArgumentChecks(foldPos, targetType, combinerType);
@@ -1842,7 +1844,7 @@
 diff --git a/src/share/classes/java/lang/invoke/MethodTypeForm.java b/src/share/classes/java/lang/invoke/MethodTypeForm.java
 --- a/src/share/classes/java/lang/invoke/MethodTypeForm.java
 +++ b/src/share/classes/java/lang/invoke/MethodTypeForm.java
-@@ -79,7 +79,8 @@
+@@ -80,7 +80,8 @@
              LF_CS_LINKER      = 13,  // linkToCallSite_CS
              LF_MH_LINKER      = 14,  // linkToCallSite_MH
              LF_GWT            = 15,  // guardWithTest
--- a/meth-tidy.patch	Sun Oct 06 22:41:41 2013 -0700
+++ b/meth-tidy.patch	Sun Oct 06 23:35:14 2013 -0700
@@ -495,36 +495,7 @@
      /**
       * Create a LF which can invoke the given method.
       * Cache and share this structure among all methods with
-@@ -265,9 +231,10 @@
-         } else {
-             names[GET_MEMBER] = new Name(Lazy.NF_internalMemberName, names[DMH_THIS]);
-         }
-+        assert(findDirectMethodHandle(names[GET_MEMBER]) == names[DMH_THIS]);
-         Object[] outArgs = Arrays.copyOfRange(names, ARG_BASE, GET_MEMBER+1, Object[].class);
-         assert(outArgs[outArgs.length-1] == names[GET_MEMBER]);  // look, shifted args!
--        int result = LambdaForm.LAST_RESULT;
-+        int result = LAST_RESULT;
-         if (doesAlloc) {
-             assert(outArgs[outArgs.length-2] == names[NEW_OBJ]);  // got to move this one
-             System.arraycopy(outArgs, 0, outArgs, 1, outArgs.length-2);
-@@ -282,6 +249,16 @@
-         return lform;
-     }
- 
-+    static Object findDirectMethodHandle(Name name) {
-+        if (name.function == NF_internalMemberName ||
-+            name.function == NF_internalMemberNameEnsureInit ||
-+            name.function == NF_constructorMethod) {
-+            assert(name.arguments.length == 1);
-+            return name.arguments[0];
-+        }
-+        return null;
-+    }
-+
-     private static void maybeCompile(LambdaForm lform, MemberName m) {
-         if (VerifyAccess.isSamePackage(m.getDeclaringClass(), MethodHandle.class))
-             // Help along bootstrapping...
-@@ -394,8 +371,8 @@
+@@ -405,8 +371,8 @@
              return true;
          }
          @Override
@@ -535,7 +506,7 @@
          }
      }
  
-@@ -412,8 +389,8 @@
+@@ -423,8 +389,8 @@
              assert(initMethod.isResolved());
          }
          @Override
@@ -546,7 +517,7 @@
          }
      }
  
-@@ -442,8 +419,8 @@
+@@ -453,8 +419,8 @@
              return fieldType.cast(obj);
          }
          @Override
@@ -557,7 +528,7 @@
          }
      }
  
-@@ -485,8 +462,8 @@
+@@ -496,8 +462,8 @@
              return fieldType.cast(obj);
          }
          @Override
@@ -1689,7 +1660,14 @@
          }
          cache[cacheIndex] = mh;
          return mh;
-@@ -157,42 +157,46 @@
+@@ -152,47 +152,52 @@
+      * integral widening or narrowing, and floating point widening or narrowing.
+      * @param srcType required call type
+      * @param target original method handle
+-     * @param level which strength of conversion is allowed
++     * @param strict if true, only asType conversions are allowed; if false, explicitCastArguments conversions allowed
++     * @param monobox if true, unboxing conversions are assumed to be exactly typed (Integer to int only, not long or double)
+      * @return an adapter to the original handle with the desired new type,
       *          or the original target if the types are already identical
       *          or null if the adaptation cannot be made
       */
@@ -1756,7 +1734,7 @@
  
          // Now build a LambdaForm.
          MethodType lambdaType = srcType.basicType().invokerType();
-@@ -204,59 +208,20 @@
+@@ -204,59 +209,20 @@
  
          int nameCursor = INARG_LIMIT;
          for (int i = 0; i < INARG_COUNT; i++) {
@@ -1824,7 +1802,7 @@
              assert(names[nameCursor] == null);
              names[nameCursor++] = conv;
              assert(outArgs[OUTARG_BASE + i] == null);
-@@ -267,25 +232,25 @@
+@@ -267,25 +233,25 @@
          assert(nameCursor == OUT_CALL);
          names[OUT_CALL] = new Name(target, outArgs);
  
@@ -1864,7 +1842,7 @@
              assert(RETURN_CONV == names.length-1);
          }
  
-@@ -293,12 +258,88 @@
+@@ -293,12 +259,88 @@
          return SimpleMethodHandle.make(srcType, form);
      }
  
@@ -1959,7 +1937,7 @@
      }
  
      static MethodHandle makeVarargsCollector(MethodHandle target, Class<?> arrayType) {
-@@ -307,23 +348,29 @@
+@@ -307,23 +349,29 @@
          if (type.parameterType(last) != arrayType)
              target = target.asType(type.changeParameterType(last, arrayType));
          target = target.asFixedArity();  // make sure this attribute is turned off
@@ -1994,7 +1972,7 @@
  
          @Override
          public boolean isVarargsCollector() {
-@@ -336,6 +383,12 @@
+@@ -336,6 +384,12 @@
          }
  
          @Override
@@ -2007,7 +1985,7 @@
          public MethodHandle asTypeUncached(MethodType newType) {
              MethodType type = this.type();
              int collectArg = type.parameterCount() - 1;
-@@ -363,54 +416,15 @@
+@@ -363,54 +417,15 @@
          }
  
          @Override
@@ -2071,7 +2049,7 @@
          }
      }
  
-@@ -570,29 +584,65 @@
+@@ -570,29 +585,65 @@
      MethodHandle makeGuardWithTest(MethodHandle test,
                                     MethodHandle target,
                                     MethodHandle fallback) {
@@ -2151,7 +2129,7 @@
      }
  
      private static class GuardWithCatch {
-@@ -733,26 +783,26 @@
+@@ -733,26 +784,26 @@
          MethodType type = target.type();
          MethodType ctype = catcher.type();
          int nargs = type.parameterCount();
@@ -2186,7 +2164,7 @@
      }
  
      static
-@@ -760,9 +810,11 @@
+@@ -760,9 +811,11 @@
          assert(Throwable.class.isAssignableFrom(type.parameterType(0)));
          int arity = type.parameterCount();
          if (arity > 1) {
@@ -2200,7 +2178,7 @@
      }
  
      static MethodHandle THROW_EXCEPTION;
-@@ -798,7 +850,7 @@
+@@ -798,7 +851,7 @@
          mh = mh.bindTo(new UnsupportedOperationException("cannot reflectively invoke MethodHandle"));
          if (!method.getInvocationType().equals(mh.type()))
              throw new InternalError(method.toString());
@@ -2209,7 +2187,7 @@
          mh = mh.asVarargsCollector(Object[].class);
          assert(method.isVarargs());
          FAKE_METHOD_HANDLE_INVOKE[idx] = mh;
-@@ -835,7 +887,7 @@
+@@ -835,7 +888,7 @@
              MethodHandle vamh = prepareForInvoker(mh);
              // Cache the result of makeInjectedInvoker once per argument class.
              MethodHandle bccInvoker = CV_makeInjectedInvoker.get(hostClass);
@@ -2218,7 +2196,7 @@
          }
  
          private static MethodHandle makeInjectedInvoker(Class<?> hostClass) {
-@@ -890,12 +942,14 @@
+@@ -890,12 +943,14 @@
          }
  
          // Undo the adapter effect of prepareForInvoker:
@@ -2236,7 +2214,7 @@
              return mh;
          }
  
-@@ -959,53 +1013,57 @@
+@@ -959,53 +1014,57 @@
          }
      }