8161207: remove extra MethodHandle subclass in MethodHandleImpl
Add intrinsic name to LambdaForm.NamedFunction, but keep IntrinsicMethodHandle; interim solution Co-authored-by: Vlaidmir Ivanov <vladimir.x.ivanov@oracle.com> Reviewed-by: psandoz
This commit is contained in:
parent
b20212e8ce
commit
58eac96b16
@ -1092,13 +1092,24 @@ class LambdaForm {
|
||||
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 @@ class LambdaForm {
|
||||
// necessary to pass BigArityTest
|
||||
this.member = Invokers.invokeBasicMethod(basicInvokerType);
|
||||
}
|
||||
this.intrinsicName = MethodHandleImpl.Intrinsic.NONE;
|
||||
assert(isInvokeBasic(member));
|
||||
}
|
||||
|
||||
@ -1263,8 +1275,7 @@ class LambdaForm {
|
||||
}
|
||||
|
||||
public MethodHandleImpl.Intrinsic intrinsicName() {
|
||||
return resolvedHandle == null ? MethodHandleImpl.Intrinsic.NONE
|
||||
: resolvedHandle.intrinsicName();
|
||||
return intrinsicName;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1741,15 +1752,15 @@ class LambdaForm {
|
||||
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;
|
||||
|
@ -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 @@ class LambdaFormEditor {
|
||||
// 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 @@ class LambdaFormEditor {
|
||||
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();
|
||||
|
@ -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 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
|
||||
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 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
|
||||
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 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
|
||||
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 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
|
||||
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 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
|
||||
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 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*;
|
||||
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));
|
||||
|
Loading…
x
Reference in New Issue
Block a user