changeset 399:e3ce088d7958

meth: simplify invokedynamic linkage paths
author jrose
date Wed, 11 Jul 2012 04:52:00 -0700
parents 77f38b00af98
children 79c955d995f0
files meth-lazy-7023639.patch
diffstat 1 files changed, 56 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/meth-lazy-7023639.patch	Tue Jul 10 23:19:06 2012 -0700
+++ b/meth-lazy-7023639.patch	Wed Jul 11 04:52:00 2012 -0700
@@ -1608,7 +1608,47 @@
 diff --git a/src/share/classes/java/lang/invoke/CallSite.java b/src/share/classes/java/lang/invoke/CallSite.java
 --- a/src/share/classes/java/lang/invoke/CallSite.java
 +++ b/src/share/classes/java/lang/invoke/CallSite.java
-@@ -233,7 +233,7 @@
+@@ -86,13 +86,9 @@
+ public class CallSite {
+     static { MethodHandleImpl.initStatics(); }
+ 
+-    // Fields used only by the JVM.  Do not use or change.
+-    private MemberName vmmethod; // supplied by the JVM (ref. to calling method)
+-    private int        vmindex;  // supplied by the JVM (BCI within calling method)
+-
+     // The actual payload of this call site:
+     /*package-private*/
+-    MethodHandle target;
++    MethodHandle target;    // Note: This field is known to the JVM.  Do not change.
+ 
+     /**
+      * Make a blank call site object with the given method type.
+@@ -151,24 +147,6 @@
+         return target.type();
+     }
+ 
+-    /** Called from JVM (or low-level Java code) after the BSM returns the newly created CallSite.
+-     *  The parameters are JVM-specific.
+-     */
+-    void initializeFromJVM(String name,
+-                           MethodType type,
+-                           MemberName callerMethod,
+-                           int        callerBCI) {
+-        if (this.vmmethod != null) {
+-            // FIXME
+-            throw new BootstrapMethodError("call site has already been linked to an invokedynamic instruction");
+-        }
+-        if (!this.type().equals(type)) {
+-            throw wrongTargetType(target, type);
+-        }
+-        this.vmindex  = callerBCI;
+-        this.vmmethod = callerMethod;
+-    }
+-
+     /**
+      * Returns the target method of the call site, according to the
+      * behavior defined by this call site's specific class.
+@@ -233,7 +211,7 @@
      public abstract MethodHandle dynamicInvoker();
  
      /*non-public*/ MethodHandle makeDynamicInvoker() {
@@ -1617,6 +1657,16 @@
          MethodHandle invoker = MethodHandles.exactInvoker(this.type());
          return MethodHandles.foldArguments(invoker, getTarget);
      }
+@@ -284,8 +262,7 @@
+                              // Extra arguments for BSM, if any:
+                              Object info,
+                              // Caller information:
+-                             MemberName callerMethod, int callerBCI) {
+-        Class<?> callerClass = callerMethod.getDeclaringClass();
++                             Class<?> callerClass) {
+         Object caller = IMPL_LOOKUP.in(callerClass);
+         CallSite site;
+         try {
 diff --git a/src/share/classes/java/lang/invoke/CountingMethodHandle.java b/src/share/classes/java/lang/invoke/CountingMethodHandle.java
 --- a/src/share/classes/java/lang/invoke/CountingMethodHandle.java
 +++ b/src/share/classes/java/lang/invoke/CountingMethodHandle.java
@@ -8467,7 +8517,7 @@
              }
          }
          return true;
-@@ -299,18 +282,22 @@
+@@ -299,18 +282,21 @@
      /**
       * The JVM is linking an invokedynamic instruction.  Create a reified call site for it.
       */
@@ -8483,26 +8533,25 @@
 -     */
 -    static void checkSpreadArgument(Object av, int n) {
 -        MethodHandleStatics.checkSpreadArgument(av, n);
-+    static MemberName linkCallSite(Object callerMethodObj, int callerBCI,
++    static MemberName linkCallSite(Object callerObj,
 +                                   Object bootstrapMethodObj,
 +                                   Object nameObj, Object typeObj,
 +                                   Object staticArguments,
 +                                   Object[] appendixResult) {
 +        MethodHandle bootstrapMethod = (MethodHandle)bootstrapMethodObj;
-+        MemberName callerMethod = (MemberName)callerMethodObj;
++        Class<?> caller = (Class<?>)callerObj;
 +        String name = nameObj.toString();
 +        MethodType type = (MethodType)typeObj;
 +        appendixResult[0] = CallSite.makeSite(bootstrapMethod,
 +                                              name,
 +                                              type,
 +                                              staticArguments,
-+                                              callerMethod,
-+                                              callerBCI);
++                                              caller);
 +        return Invokers.linkToCallSiteMethod(type);
      }
  
      /**
-@@ -321,71 +308,53 @@
+@@ -321,71 +307,53 @@
      }
  
      /**