--- old/src/java.base/share/classes/java/lang/invoke/LambdaForm.java 2017-06-12 16:46:23.000000000 +0300 +++ new/src/java.base/share/classes/java/lang/invoke/LambdaForm.java 2017-06-12 16:46:23.000000000 +0300 @@ -1092,13 +1092,24 @@ final MemberName member; private @Stable MethodHandle resolvedHandle; @Stable MethodHandle invoker; + private final MethodHandleImpl.Intrinsic intrinsicName; NamedFunction(MethodHandle resolvedHandle) { - this(resolvedHandle.internalMemberName(), resolvedHandle); + this(resolvedHandle.internalMemberName(), resolvedHandle, MethodHandleImpl.Intrinsic.NONE); + } + NamedFunction(MethodHandle resolvedHandle, MethodHandleImpl.Intrinsic intrinsic) { + this(resolvedHandle.internalMemberName(), resolvedHandle, intrinsic); } NamedFunction(MemberName member, MethodHandle resolvedHandle) { + this(member, resolvedHandle, MethodHandleImpl.Intrinsic.NONE); + } + NamedFunction(MemberName member, MethodHandle resolvedHandle, MethodHandleImpl.Intrinsic intrinsic) { this.member = member; this.resolvedHandle = resolvedHandle; + this.intrinsicName = intrinsic; + assert(resolvedHandle == null || + resolvedHandle.intrinsicName() == MethodHandleImpl.Intrinsic.NONE || + resolvedHandle.intrinsicName() == intrinsic) : resolvedHandle.intrinsicName() + " != " + intrinsic; // The following assert is almost always correct, but will fail for corner cases, such as PrivateInvokeTest. //assert(!isInvokeBasic(member)); } @@ -1111,6 +1122,7 @@ // necessary to pass BigArityTest this.member = Invokers.invokeBasicMethod(basicInvokerType); } + this.intrinsicName = MethodHandleImpl.Intrinsic.NONE; assert(isInvokeBasic(member)); } @@ -1263,8 +1275,7 @@ } public MethodHandleImpl.Intrinsic intrinsicName() { - return resolvedHandle == null ? MethodHandleImpl.Intrinsic.NONE - : resolvedHandle.intrinsicName(); + return intrinsicName; } } @@ -1741,15 +1752,15 @@ Name[] idNames = new Name[] { argument(0, L_TYPE), argument(1, type) }; idForm = new LambdaForm(2, idNames, 1, Kind.IDENTITY); idForm.compileToBytecode(); - idFun = new NamedFunction(idMem, MethodHandleImpl.makeIntrinsic( - idMem.getInvocationType(), idForm, MethodHandleImpl.Intrinsic.IDENTITY)); + idFun = new NamedFunction(idMem, SimpleMethodHandle.make(idMem.getInvocationType(), idForm), + MethodHandleImpl.Intrinsic.IDENTITY); Object zeValue = Wrapper.forBasicType(btChar).zero(); Name[] zeNames = new Name[] { argument(0, L_TYPE), new Name(idFun, zeValue) }; zeForm = new LambdaForm(1, zeNames, 1, Kind.ZERO); zeForm.compileToBytecode(); - zeFun = new NamedFunction(zeMem, MethodHandleImpl.makeIntrinsic( - zeMem.getInvocationType(), zeForm, MethodHandleImpl.Intrinsic.ZERO)); + zeFun = new NamedFunction(zeMem, SimpleMethodHandle.make(zeMem.getInvocationType(), zeForm), + MethodHandleImpl.Intrinsic.ZERO); } LF_zero[ord] = zeForm; --- old/src/java.base/share/classes/java/lang/invoke/LambdaFormEditor.java 2017-06-12 16:46:24.000000000 +0300 +++ new/src/java.base/share/classes/java/lang/invoke/LambdaFormEditor.java 2017-06-12 16:46:24.000000000 +0300 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -541,7 +541,7 @@ // adjust the arguments MethodHandle aload = MethodHandles.arrayElementGetter(erasedArrayType); for (int i = 0; i < arrayLength; i++) { - Name loadArgument = new Name(aload, spreadParam, i); + Name loadArgument = new Name(new NamedFunction(aload, Intrinsic.ARRAY_LOAD), spreadParam, i); buf.insertExpression(exprPos + i, loadArgument); buf.replaceParameterByCopy(pos + i, exprPos + i); } @@ -604,7 +604,8 @@ for (int i = 0; i < collectorArity; i++) { newParams[i] = new Name(pos + i, argType); } - Name callCombiner = new Name(arrayCollector, (Object[]) /*...*/ newParams); + Name callCombiner = new Name(new NamedFunction(arrayCollector, Intrinsic.NEW_ARRAY), + (Object[]) /*...*/ newParams); // insert the new expression int exprPos = lambdaForm.arity(); --- old/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java 2017-06-12 16:46:25.000000000 +0300 +++ new/src/java.base/share/classes/java/lang/invoke/MethodHandleImpl.java 2017-06-12 16:46:25.000000000 +0300 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -592,7 +592,7 @@ names[nameCursor++] = new Name(getFunction(NF_checkSpreadArgument), array, spreadArgCount); for (int j = 0; j < spreadArgCount; i++, j++) { indexes[i] = nameCursor; - names[nameCursor++] = new Name(aload, array, j); + names[nameCursor++] = new Name(new NamedFunction(aload, Intrinsic.ARRAY_LOAD), array, j); } } else if (i < indexes.length) { indexes[i] = argIndex; @@ -937,7 +937,7 @@ names[PROFILE] = new Name(getFunction(NF_profileBoolean), names[CALL_TEST], names[GET_COUNTERS]); } // call selectAlternative - names[SELECT_ALT] = new Name(getConstantHandle(MH_selectAlternative), names[TEST], names[GET_TARGET], names[GET_FALLBACK]); + names[SELECT_ALT] = new Name(new NamedFunction(getConstantHandle(MH_selectAlternative), Intrinsic.SELECT_ALTERNATIVE), names[TEST], names[GET_TARGET], names[GET_FALLBACK]); // call target or fallback invokeArgs[0] = names[SELECT_ALT]; @@ -1008,7 +1008,7 @@ Object[] args = new Object[invokeBasic.type().parameterCount()]; args[0] = names[GET_COLLECT_ARGS]; System.arraycopy(names, ARG_BASE, args, 1, ARG_LIMIT-ARG_BASE); - names[BOXED_ARGS] = new Name(makeIntrinsic(invokeBasic, Intrinsic.GUARD_WITH_CATCH), args); + names[BOXED_ARGS] = new Name(new NamedFunction(invokeBasic, Intrinsic.GUARD_WITH_CATCH), args); // t_{i+1}:L=MethodHandleImpl.guardWithCatch(target:L,exType:L,catcher:L,t_{i}:L); Object[] gwcArgs = new Object[] {names[GET_TARGET], names[GET_CLASS], names[GET_CATCHER], names[BOXED_ARGS]}; @@ -1896,7 +1896,7 @@ Object[] args = new Object[invokeBasic.type().parameterCount()]; args[0] = names[GET_COLLECT_ARGS]; System.arraycopy(names, ARG_BASE, args, 1, ARG_LIMIT - ARG_BASE); - names[BOXED_ARGS] = new Name(makeIntrinsic(invokeBasic, Intrinsic.LOOP), args); + names[BOXED_ARGS] = new Name(new NamedFunction(invokeBasic, Intrinsic.LOOP), args); // t_{i+1}:L=MethodHandleImpl.loop(localTypes:L,clauses:L,t_{i}:L); Object[] lArgs = @@ -2133,7 +2133,7 @@ Object[] args = new Object[invokeBasic.type().parameterCount()]; args[0] = names[GET_COLLECT_ARGS]; System.arraycopy(names, ARG_BASE, args, 1, ARG_LIMIT-ARG_BASE); - names[BOXED_ARGS] = new Name(makeIntrinsic(invokeBasic, Intrinsic.TRY_FINALLY), args); + names[BOXED_ARGS] = new Name(new NamedFunction(invokeBasic, Intrinsic.TRY_FINALLY), args); // t_{i+1}:L=MethodHandleImpl.tryFinally(target:L,exType:L,catcher:L,t_{i}:L); Object[] tfArgs = new Object[] {names[GET_TARGET], names[GET_CLEANUP], names[BOXED_ARGS]}; @@ -2225,9 +2225,8 @@ return IMPL_LOOKUP.findStatic(MethodHandleImpl.class, "fillNewTypedArray", MethodType.methodType(Object[].class, Object[].class, Integer.class, Object[].class)); case MH_selectAlternative: - return makeIntrinsic(IMPL_LOOKUP.findStatic(MethodHandleImpl.class, "selectAlternative", - MethodType.methodType(MethodHandle.class, boolean.class, MethodHandle.class, MethodHandle.class)), - Intrinsic.SELECT_ALTERNATIVE); + return IMPL_LOOKUP.findStatic(MethodHandleImpl.class, "selectAlternative", + MethodType.methodType(MethodHandle.class, boolean.class, MethodHandle.class, MethodHandle.class)); case MH_countedLoopPred: return IMPL_LOOKUP.findStatic(MethodHandleImpl.class, "countedLoopPredicate", MethodType.methodType(boolean.class, int.class, int.class));