src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java

Print this page
rev 17771 : 8184777: species logic for BoundMethodHandle doesn't scale, needs refactor

@@ -725,15 +725,15 @@
         BoundMethodHandle mh;
         try {
             if (PROFILE_GWT) {
                 int[] counts = new int[2];
                 mh = (BoundMethodHandle)
-                        BoundMethodHandle.speciesData_LLLL().constructor().invokeBasic(type, form,
+                        BoundMethodHandle.speciesData_LLLL().factory().invokeBasic(type, form,
                                 (Object) test, (Object) profile(target), (Object) profile(fallback), counts);
             } else {
                 mh = (BoundMethodHandle)
-                        BoundMethodHandle.speciesData_LLL().constructor().invokeBasic(type, form,
+                        BoundMethodHandle.speciesData_LLL().factory().invokeBasic(type, form,
                                 (Object) test, (Object) profile(target), (Object) profile(fallback));
             }
         } catch (Throwable ex) {
             throw uncaughtException(ex);
         }

@@ -913,11 +913,11 @@
         assert(CALL_TARGET == SELECT_ALT+1);  // must be true to trigger IBG.emitSelectAlternative
 
         MethodType lambdaType = basicType.invokerType();
         Name[] names = arguments(nameCursor - ARG_LIMIT, lambdaType);
 
-        BoundMethodHandle.SpeciesData data =
+        BoundMethodHandle.BMHSpecies data =
                 (GET_COUNTERS != -1) ? BoundMethodHandle.speciesData_LLLL()
                                      : BoundMethodHandle.speciesData_LLL();
         names[THIS_MH] = names[THIS_MH].withConstraint(data);
         names[GET_TEST]     = new Name(data.getterFunction(0), names[THIS_MH]);
         names[GET_TARGET]   = new Name(data.getterFunction(1), names[THIS_MH]);

@@ -990,11 +990,11 @@
         final int TRY_CATCH        = nameCursor++;
         final int UNBOX_RESULT     = nameCursor++;
 
         Name[] names = arguments(nameCursor - ARG_LIMIT, lambdaType);
 
-        BoundMethodHandle.SpeciesData data = BoundMethodHandle.speciesData_LLLLL();
+        BoundMethodHandle.BMHSpecies data = BoundMethodHandle.speciesData_LLLLL();
         names[THIS_MH]          = names[THIS_MH].withConstraint(data);
         names[GET_TARGET]       = new Name(data.getterFunction(0), names[THIS_MH]);
         names[GET_CLASS]        = new Name(data.getterFunction(1), names[THIS_MH]);
         names[GET_CATCHER]      = new Name(data.getterFunction(2), names[THIS_MH]);
         names[GET_COLLECT_ARGS] = new Name(data.getterFunction(3), names[THIS_MH]);

@@ -1035,14 +1035,14 @@
         // Box arguments and wrap them into Object[]: ValueConversions.array().
         MethodType varargsType = type.changeReturnType(Object[].class);
         MethodHandle collectArgs = varargsArray(type.parameterCount()).asType(varargsType);
         MethodHandle unboxResult = unboxResultHandle(type.returnType());
 
-        BoundMethodHandle.SpeciesData data = BoundMethodHandle.speciesData_LLLLL();
+        BoundMethodHandle.BMHSpecies data = BoundMethodHandle.speciesData_LLLLL();
         BoundMethodHandle mh;
         try {
-            mh = (BoundMethodHandle) data.constructor().invokeBasic(type, form, (Object) target, (Object) exType,
+            mh = (BoundMethodHandle) data.factory().invokeBasic(type, form, (Object) target, (Object) exType,
                     (Object) catcher, (Object) collectArgs, (Object) unboxResult);
         } catch (Throwable ex) {
             throw uncaughtException(ex);
         }
         assert(mh.type() == type);

@@ -1819,14 +1819,14 @@
         MethodHandle collectArgs = varargsArray(type.parameterCount()).asType(varargsType);
         MethodHandle unboxResult = unboxResultHandle(tloop);
 
         LoopClauses clauseData =
                 new LoopClauses(new MethodHandle[][]{toArray(init), toArray(step), toArray(pred), toArray(fini)});
-        BoundMethodHandle.SpeciesData data = BoundMethodHandle.speciesData_LLL();
+        BoundMethodHandle.BMHSpecies data = BoundMethodHandle.speciesData_LLL();
         BoundMethodHandle mh;
         try {
-            mh = (BoundMethodHandle) data.constructor().invokeBasic(type, form, (Object) clauseData,
+            mh = (BoundMethodHandle) data.factory().invokeBasic(type, form, (Object) clauseData,
                     (Object) collectArgs, (Object) unboxResult);
         } catch (Throwable ex) {
             throw uncaughtException(ex);
         }
         assert(mh.type() == type);

@@ -1882,11 +1882,11 @@
 
         LambdaForm lform = basicType.form().cachedLambdaForm(MethodTypeForm.LF_LOOP);
         if (lform == null) {
             Name[] names = arguments(nameCursor - ARG_LIMIT, lambdaType);
 
-            BoundMethodHandle.SpeciesData data = BoundMethodHandle.speciesData_LLL();
+            BoundMethodHandle.BMHSpecies data = BoundMethodHandle.speciesData_LLL();
             names[THIS_MH] = names[THIS_MH].withConstraint(data);
             names[GET_CLAUSE_DATA] = new Name(data.getterFunction(0), names[THIS_MH]);
             names[GET_COLLECT_ARGS] = new Name(data.getterFunction(1), names[THIS_MH]);
             names[GET_UNBOX_RESULT] = new Name(data.getterFunction(2), names[THIS_MH]);
 

@@ -2062,14 +2062,14 @@
         // Box arguments and wrap them into Object[]: ValueConversions.array().
         MethodType varargsType = type.changeReturnType(Object[].class);
         MethodHandle collectArgs = varargsArray(type.parameterCount()).asType(varargsType);
         MethodHandle unboxResult = unboxResultHandle(rtype);
 
-        BoundMethodHandle.SpeciesData data = BoundMethodHandle.speciesData_LLLL();
+        BoundMethodHandle.BMHSpecies data = BoundMethodHandle.speciesData_LLLL();
         BoundMethodHandle mh;
         try {
-            mh = (BoundMethodHandle) data.constructor().invokeBasic(type, form, (Object) target, (Object) cleanup,
+            mh = (BoundMethodHandle) data.factory().invokeBasic(type, form, (Object) target, (Object) cleanup,
                     (Object) collectArgs, (Object) unboxResult);
         } catch (Throwable ex) {
             throw uncaughtException(ex);
         }
         assert(mh.type() == type);

@@ -2118,11 +2118,11 @@
         final int TRY_FINALLY      = nameCursor++;
         final int UNBOX_RESULT     = nameCursor++;
 
         Name[] names = arguments(nameCursor - ARG_LIMIT, lambdaType);
 
-        BoundMethodHandle.SpeciesData data = BoundMethodHandle.speciesData_LLLL();
+        BoundMethodHandle.BMHSpecies data = BoundMethodHandle.speciesData_LLLL();
         names[THIS_MH]          = names[THIS_MH].withConstraint(data);
         names[GET_TARGET]       = new Name(data.getterFunction(0), names[THIS_MH]);
         names[GET_CLEANUP]      = new Name(data.getterFunction(1), names[THIS_MH]);
         names[GET_COLLECT_ARGS] = new Name(data.getterFunction(2), names[THIS_MH]);
         names[GET_UNBOX_RESULT] = new Name(data.getterFunction(3), names[THIS_MH]);