src/share/classes/java/lang/invoke/MethodHandleImpl.java
Index
Unified diffs
Context diffs
Sdiffs
Patch
New
Old
Previous File
Next File
jdk Cdiff src/share/classes/java/lang/invoke/MethodHandleImpl.java
src/share/classes/java/lang/invoke/MethodHandleImpl.java
Print this page
rev 10351 : 8037209: Improvements and cleanups to bytecode assembly for lambda forms
Reviewed-by: vlivanov, psandoz
Contributed-by: john.r.rose@oracle.com
rev 10352 : 8038261: JSR292: cache and reuse typed array accessors
Reviewed-by: vlivanov, psandoz
Contributed-by: john.r.rose@oracle.com
rev 10353 : 8049555: Move varargsArray from sun.invoke.util package to java.lang.invoke
Reviewed-by: ?
rev 10354 : 8050052: Small cleanups in java.lang.invoke code
Reviewed-by: ?
rev 10356 : 8050166: Get rid of some package-private methods on arguments in j.l.i.MethodHandle
Reviewed-by: vlivanov, ?
Contributed-by: john.r.rose@oracle.com
rev 10357 : 8050173: Add j.l.i.MethodHandle.copyWith(MethodType, LambdaForm)
Reviewed-by: vlivanov, ?
Contributed-by: john.r.rose@oracle.com
rev 10358 : 8050174: Support overriding of isInvokeSpecial flag in WrappedMember
Reviewed-by: vlivanov, ?
Contributed-by: john.r.rose@oracle.com
rev 10359 : 8050057: Improve caching of MethodHandle reinvokers
Reviewed-by: vlivanov, ?
Contributed-by: john.r.rose@oracle.com
rev 10360 : 8050200: Make LambdaForm intrinsics detection more robust
Reviewed-by: vlivanov, ?
Contributed-by: john.r.rose@oracle.com
rev 10361 : imported patch 11.8050877.conv
rev 10362 : imported patch 12.8050884.identity
rev 10363 : imported patch 13.8050887.zero
rev 10366 : imported patch 16.constraint
rev 10367 : imported patch 17.gwt
*** 638,670 ****
static
MethodHandle makeGuardWithTest(MethodHandle test,
MethodHandle target,
MethodHandle fallback) {
! MethodType basicType = target.type().basicType();
! MethodHandle invokeBasic = MethodHandles.basicInvoker(basicType);
! int arity = basicType.parameterCount();
! int extraNames = 3;
MethodType lambdaType = basicType.invokerType();
! Name[] names = arguments(extraNames, lambdaType);
! Object[] testArgs = Arrays.copyOfRange(names, 1, 1 + arity, Object[].class);
! Object[] targetArgs = Arrays.copyOfRange(names, 0, 1 + arity, Object[].class);
// call test
! names[arity + 1] = new Name(test, testArgs);
// call selectAlternative
! Object[] selectArgs = { names[arity + 1], target, fallback };
! names[arity + 2] = new Name(Lazy.MH_selectAlternative, selectArgs);
! targetArgs[0] = names[arity + 2];
// call target or fallback
! names[arity + 3] = new Name(new NamedFunction(invokeBasic), targetArgs);
! LambdaForm form = new LambdaForm("guard", lambdaType.parameterCount(), names);
! return SimpleMethodHandle.make(target.type(), form);
}
/**
* The LambaForm shape for catchException combinator is the following:
* <blockquote><pre>{@code
--- 638,707 ----
static
MethodHandle makeGuardWithTest(MethodHandle test,
MethodHandle target,
MethodHandle fallback) {
! MethodType type = target.type();
! assert(test.type().equals(type.changeReturnType(boolean.class)) && fallback.type().equals(type));
! MethodType basicType = type.basicType();
! LambdaForm form = makeGuardWithTestForm(basicType);
! BoundMethodHandle.SpeciesData data = BoundMethodHandle.speciesData_LLL();
! BoundMethodHandle mh;
! try {
! mh = (BoundMethodHandle)
! data.constructor().invokeBasic(type, form,
! (Object) test, (Object) target, (Object) fallback);
! } catch (Throwable ex) {
! throw uncaughtException(ex);
! }
! assert(mh.type() == type);
! return mh;
! }
!
! static
! LambdaForm makeGuardWithTestForm(MethodType basicType) {
! LambdaForm lform = basicType.form().cachedLambdaForm(MethodTypeForm.LF_GWT);
! if (lform != null) return lform;
! final int THIS_MH = 0; // the BMH_LLL
! final int ARG_BASE = 1; // start of incoming arguments
! final int ARG_LIMIT = ARG_BASE + basicType.parameterCount();
! int nameCursor = ARG_LIMIT;
! final int GET_TEST = nameCursor++;
! final int GET_TARGET = nameCursor++;
! final int GET_FALLBACK = nameCursor++;
! final int CALL_TEST = nameCursor++;
! final int SELECT_ALT = nameCursor++;
! final int CALL_TARGET = nameCursor++;
! 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.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]);
! names[GET_FALLBACK] = new Name(data.getterFunction(2), names[THIS_MH]);
!
! Object[] invokeArgs = Arrays.copyOfRange(names, 0, ARG_LIMIT, Object[].class);
// call test
! MethodType testType = basicType.changeReturnType(boolean.class).basicType();
! invokeArgs[0] = names[GET_TEST];
! names[CALL_TEST] = new Name(testType, invokeArgs);
// call selectAlternative
! names[SELECT_ALT] = new Name(Lazy.MH_selectAlternative, names[CALL_TEST],
! names[GET_TARGET], names[GET_FALLBACK]);
// call target or fallback
! invokeArgs[0] = names[SELECT_ALT];
! names[CALL_TARGET] = new Name(basicType, invokeArgs);
!
! lform = new LambdaForm("guard", lambdaType.parameterCount(), names);
! return basicType.form().setCachedLambdaForm(MethodTypeForm.LF_GWT, lform);
}
/**
* The LambaForm shape for catchException combinator is the following:
* <blockquote><pre>{@code
src/share/classes/java/lang/invoke/MethodHandleImpl.java
Index
Unified diffs
Context diffs
Sdiffs
Patch
New
Old
Previous File
Next File