8164525: Re-examine zero form link time pre-generation
Reviewed-by: vlivanov, forax
--- a/jdk/src/java.base/share/classes/java/lang/invoke/GenerateJLIClassesHelper.java Mon Aug 22 13:36:33 2016 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/GenerateJLIClassesHelper.java Mon Aug 22 12:57:43 2016 +0200
@@ -43,8 +43,16 @@
ArrayList<String> names = new ArrayList<>();
HashSet<String> dedupSet = new HashSet<>();
for (LambdaForm.BasicType type : LambdaForm.BasicType.values()) {
+ LambdaForm zero = LambdaForm.zeroForm(type);
+ String name = zero.kind.defaultLambdaName
+ + "_" + zero.returnType().basicTypeChar();
+ if (dedupSet.add(name)) {
+ names.add(name);
+ forms.add(zero);
+ }
+
LambdaForm identity = LambdaForm.identityForm(type);
- String name = identity.kind.defaultLambdaName
+ name = identity.kind.defaultLambdaName
+ "_" + identity.returnType().basicTypeChar();
if (dedupSet.add(name)) {
names.add(name);
--- a/jdk/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java Mon Aug 22 13:36:33 2016 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java Mon Aug 22 12:57:43 2016 +0200
@@ -624,6 +624,7 @@
return resolveFrom(name, invokerType, DelegatingMethodHandle.Holder.class);
}
case DELEGATE: return resolveFrom(name, invokerType, DelegatingMethodHandle.Holder.class);
+ case ZERO: // fall-through
case IDENTITY: {
name = name + "_" + form.returnType().basicTypeChar();
return resolveFrom(name, invokerType, LambdaForm.Holder.class);
--- a/jdk/src/java.base/share/classes/java/lang/invoke/LambdaForm.java Mon Aug 22 13:36:33 2016 +0200
+++ b/jdk/src/java.base/share/classes/java/lang/invoke/LambdaForm.java Mon Aug 22 12:57:43 2016 +0200
@@ -1860,13 +1860,15 @@
Name[] idNames = new Name[] { argument(0, L_TYPE), argument(1, type) };
idForm = new LambdaForm(idMem.getName(), 2, idNames, 1, Kind.IDENTITY);
idForm.compileToBytecode();
- idFun = new NamedFunction(idMem, SimpleMethodHandle.make(idMem.getInvocationType(), idForm));
+ idFun = new NamedFunction(idMem, MethodHandleImpl.makeIntrinsic(
+ 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(zeMem.getName(), 1, zeNames, 1, Kind.ZERO);
zeForm.compileToBytecode();
- zeFun = new NamedFunction(zeMem, SimpleMethodHandle.make(zeMem.getInvocationType(), zeForm));
+ zeFun = new NamedFunction(zeMem, MethodHandleImpl.makeIntrinsic(
+ zeMem.getInvocationType(), zeForm, MethodHandleImpl.Intrinsic.ZERO));
}
LF_zero[ord] = zeForm;