mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8323058: Revisit j.l.classfile.CodeBuilder API surface
Reviewed-by: briangoetz, psandoz
This commit is contained in:
parent
286cbf831c
commit
ae82405ff7
53 changed files with 725 additions and 876 deletions
|
@ -382,7 +382,7 @@ public class MethodHandleProxies {
|
|||
|
||||
// <clinit>
|
||||
clb.withMethodBody(CLASS_INIT_NAME, MTD_void, ACC_STATIC, cob -> {
|
||||
cob.constantInstruction(ifaceDesc);
|
||||
cob.loadConstant(ifaceDesc);
|
||||
cob.putstatic(proxyDesc, TYPE_NAME, CD_Class);
|
||||
cob.return_();
|
||||
});
|
||||
|
@ -406,7 +406,7 @@ public class MethodHandleProxies {
|
|||
// this.m<i> = callerBoundTarget.asType(xxType);
|
||||
cob.aload(0);
|
||||
cob.aload(3);
|
||||
cob.constantInstruction(mi.desc);
|
||||
cob.loadConstant(mi.desc);
|
||||
cob.invokevirtual(CD_MethodHandle, "asType", MTD_MethodHandle_MethodType);
|
||||
cob.putfield(proxyDesc, mi.fieldName, CD_MethodHandle);
|
||||
}
|
||||
|
@ -423,12 +423,12 @@ public class MethodHandleProxies {
|
|||
// check lookupClass
|
||||
cob.aload(0);
|
||||
cob.invokevirtual(CD_MethodHandles_Lookup, "lookupClass", MTD_Class);
|
||||
cob.constantInstruction(proxyDesc);
|
||||
cob.loadConstant(proxyDesc);
|
||||
cob.if_acmpne(failLabel);
|
||||
// check original access
|
||||
cob.aload(0);
|
||||
cob.invokevirtual(CD_MethodHandles_Lookup, "lookupModes", MTD_int);
|
||||
cob.constantInstruction(Lookup.ORIGINAL);
|
||||
cob.loadConstant(Lookup.ORIGINAL);
|
||||
cob.iand();
|
||||
cob.ifeq(failLabel);
|
||||
// success
|
||||
|
@ -452,11 +452,11 @@ public class MethodHandleProxies {
|
|||
bcb.aload(0);
|
||||
bcb.getfield(proxyDesc, mi.fieldName, CD_MethodHandle);
|
||||
for (int j = 0; j < mi.desc.parameterCount(); j++) {
|
||||
bcb.loadInstruction(TypeKind.from(mi.desc.parameterType(j)),
|
||||
bcb.loadLocal(TypeKind.from(mi.desc.parameterType(j)),
|
||||
bcb.parameterSlot(j));
|
||||
}
|
||||
bcb.invokevirtual(CD_MethodHandle, "invokeExact", mi.desc);
|
||||
bcb.returnInstruction(TypeKind.from(mi.desc.returnType()));
|
||||
bcb.return_(TypeKind.from(mi.desc.returnType()));
|
||||
}, ctb -> ctb
|
||||
// catch (Error | RuntimeException | Declared ex) { throw ex; }
|
||||
.catchingMulti(mi.thrown, CodeBuilder::athrow)
|
||||
|
|
|
@ -1124,7 +1124,7 @@ public final class StringConcatFactory {
|
|||
}
|
||||
}
|
||||
len += args.parameterCount() * ARGUMENT_SIZE_FACTOR;
|
||||
cb.constantInstruction(len);
|
||||
cb.loadConstant(len);
|
||||
cb.invokespecial(STRING_BUILDER, "<init>", INT_CONSTRUCTOR_TYPE);
|
||||
|
||||
// At this point, we have a blank StringBuilder on stack, fill it in with .append calls.
|
||||
|
@ -1137,7 +1137,7 @@ public final class StringConcatFactory {
|
|||
}
|
||||
Class<?> cl = args.parameterType(c);
|
||||
TypeKind kind = TypeKind.from(cl);
|
||||
cb.loadInstruction(kind, off);
|
||||
cb.loadLocal(kind, off);
|
||||
off += kind.slotSize();
|
||||
MethodTypeDesc desc = getSBAppendDesc(cl);
|
||||
cb.invokevirtual(STRING_BUILDER, "append", desc);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue