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,739 **** BoundMethodHandle mh; try { if (PROFILE_GWT) { int[] counts = new int[2]; mh = (BoundMethodHandle) ! BoundMethodHandle.speciesData_LLLL().constructor().invokeBasic(type, form, (Object) test, (Object) profile(target), (Object) profile(fallback), counts); } else { mh = (BoundMethodHandle) ! BoundMethodHandle.speciesData_LLL().constructor().invokeBasic(type, form, (Object) test, (Object) profile(target), (Object) profile(fallback)); } } catch (Throwable ex) { throw uncaughtException(ex); } --- 725,739 ---- BoundMethodHandle mh; try { if (PROFILE_GWT) { int[] counts = new int[2]; mh = (BoundMethodHandle) ! BoundMethodHandle.speciesData_LLLL().factory().invokeBasic(type, form, (Object) test, (Object) profile(target), (Object) profile(fallback), counts); } else { mh = (BoundMethodHandle) ! BoundMethodHandle.speciesData_LLL().factory().invokeBasic(type, form, (Object) test, (Object) profile(target), (Object) profile(fallback)); } } catch (Throwable ex) { throw uncaughtException(ex); }
*** 913,923 **** 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 = (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]); --- 913,923 ---- 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.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,1000 **** final int TRY_CATCH = nameCursor++; final int UNBOX_RESULT = nameCursor++; Name[] names = arguments(nameCursor - ARG_LIMIT, lambdaType); ! BoundMethodHandle.SpeciesData 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]); --- 990,1000 ---- final int TRY_CATCH = nameCursor++; final int UNBOX_RESULT = nameCursor++; Name[] names = arguments(nameCursor - ARG_LIMIT, lambdaType); ! 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,1048 **** // 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 mh; try { ! mh = (BoundMethodHandle) data.constructor().invokeBasic(type, form, (Object) target, (Object) exType, (Object) catcher, (Object) collectArgs, (Object) unboxResult); } catch (Throwable ex) { throw uncaughtException(ex); } assert(mh.type() == type); --- 1035,1048 ---- // 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.BMHSpecies data = BoundMethodHandle.speciesData_LLLLL(); BoundMethodHandle mh; try { ! 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,1832 **** 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 mh; try { ! mh = (BoundMethodHandle) data.constructor().invokeBasic(type, form, (Object) clauseData, (Object) collectArgs, (Object) unboxResult); } catch (Throwable ex) { throw uncaughtException(ex); } assert(mh.type() == type); --- 1819,1832 ---- 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.BMHSpecies data = BoundMethodHandle.speciesData_LLL(); BoundMethodHandle mh; try { ! mh = (BoundMethodHandle) data.factory().invokeBasic(type, form, (Object) clauseData, (Object) collectArgs, (Object) unboxResult); } catch (Throwable ex) { throw uncaughtException(ex); } assert(mh.type() == type);
*** 1882,1892 **** LambdaForm lform = basicType.form().cachedLambdaForm(MethodTypeForm.LF_LOOP); if (lform == null) { Name[] names = arguments(nameCursor - ARG_LIMIT, lambdaType); ! BoundMethodHandle.SpeciesData 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]); --- 1882,1892 ---- LambdaForm lform = basicType.form().cachedLambdaForm(MethodTypeForm.LF_LOOP); if (lform == null) { Name[] names = arguments(nameCursor - ARG_LIMIT, lambdaType); ! 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,2075 **** // 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 mh; try { ! mh = (BoundMethodHandle) data.constructor().invokeBasic(type, form, (Object) target, (Object) cleanup, (Object) collectArgs, (Object) unboxResult); } catch (Throwable ex) { throw uncaughtException(ex); } assert(mh.type() == type); --- 2062,2075 ---- // 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.BMHSpecies data = BoundMethodHandle.speciesData_LLLL(); BoundMethodHandle mh; try { ! 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,2128 **** final int TRY_FINALLY = nameCursor++; final int UNBOX_RESULT = nameCursor++; Name[] names = arguments(nameCursor - ARG_LIMIT, lambdaType); ! BoundMethodHandle.SpeciesData 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]); --- 2118,2128 ---- final int TRY_FINALLY = nameCursor++; final int UNBOX_RESULT = nameCursor++; Name[] names = arguments(nameCursor - ARG_LIMIT, lambdaType); ! 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]);