< prev index next >
src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java
Print this page
*** 609,635 ****
mv.visitVarInsn(Opcodes.ALOAD, localsMap[0]);
mv.visitMethodInsn(Opcodes.INVOKESTATIC, MHI, "assertSame", LLV_SIG, false);
return true;
}
/**
* Generate an invoker method for the passed {@link LambdaForm}.
*/
private byte[] generateCustomizedCodeBytes() {
classFilePrologue();
// Suppress this method in backtraces displayed to the user.
! mv.visitAnnotation("Ljava/lang/invoke/LambdaForm$Hidden;", true);
// Mark this method as a compiled LambdaForm
! mv.visitAnnotation("Ljava/lang/invoke/LambdaForm$Compiled;", true);
if (lambdaForm.forceInline) {
// Force inlining of this invoker method.
! mv.visitAnnotation("Ljdk/internal/vm/annotation/ForceInline;", true);
} else {
! mv.visitAnnotation("Ljdk/internal/vm/annotation/DontInline;", true);
}
if (lambdaForm.customized != null) {
// Since LambdaForm is customized for a particular MethodHandle, it's safe to substitute
// receiver MethodHandle (at slot #0) with an embedded constant and use it instead.
--- 609,660 ----
mv.visitVarInsn(Opcodes.ALOAD, localsMap[0]);
mv.visitMethodInsn(Opcodes.INVOKESTATIC, MHI, "assertSame", LLV_SIG, false);
return true;
}
+ static String className(String cn) {
+ assert checkClassName(cn): "Class not found: " + cn;
+ return cn;
+ }
+
+ static boolean checkClassName(String cn) {
+ Type tp = Type.getType(cn);
+ // additional sanity so only valid "L;" descriptors work
+ if (tp.getSort() != Type.OBJECT) {
+ return false;
+ }
+ try {
+ Class<?> c = Class.forName(tp.getClassName(), false, null);
+ return true;
+ } catch (ClassNotFoundException e) {
+ return false;
+ }
+ }
+
+ static final String LF_HIDDEN_SIG = className("Ljava/lang/invoke/LambdaForm$Hidden;");
+ static final String LF_COMPILED_SIG = className("Ljava/lang/invoke/LambdaForm$Compiled;");
+ static final String FORCEINLINE_SIG = className("Ljdk/internal/vm/annotation/ForceInline;");
+ static final String DONTINLINE_SIG = className("Ljdk/internal/vm/annotation/DontInline;");
+ static final String INJECTEDPROFILE_SIG = className("Ljava/lang/invoke/InjectedProfile;");
+
/**
* Generate an invoker method for the passed {@link LambdaForm}.
*/
private byte[] generateCustomizedCodeBytes() {
classFilePrologue();
// Suppress this method in backtraces displayed to the user.
! mv.visitAnnotation(LF_HIDDEN_SIG, true);
// Mark this method as a compiled LambdaForm
! mv.visitAnnotation(LF_COMPILED_SIG, true);
if (lambdaForm.forceInline) {
// Force inlining of this invoker method.
! mv.visitAnnotation(FORCEINLINE_SIG, true);
} else {
! mv.visitAnnotation(DONTINLINE_SIG, true);
}
if (lambdaForm.customized != null) {
// Since LambdaForm is customized for a particular MethodHandle, it's safe to substitute
// receiver MethodHandle (at slot #0) with an embedded constant and use it instead.
*** 654,664 ****
case SELECT_ALTERNATIVE:
assert isSelectAlternative(i);
if (PROFILE_GWT) {
assert(name.arguments[0] instanceof Name &&
nameRefersTo((Name)name.arguments[0], MethodHandleImpl.class, "profileBoolean"));
! mv.visitAnnotation("Ljava/lang/invoke/InjectedProfile;", true);
}
onStack = emitSelectAlternative(name, lambdaForm.names[i+1]);
i++; // skip MH.invokeBasic of the selectAlternative result
continue;
case GUARD_WITH_CATCH:
--- 679,689 ----
case SELECT_ALTERNATIVE:
assert isSelectAlternative(i);
if (PROFILE_GWT) {
assert(name.arguments[0] instanceof Name &&
nameRefersTo((Name)name.arguments[0], MethodHandleImpl.class, "profileBoolean"));
! mv.visitAnnotation(INJECTEDPROFILE_SIG, true);
}
onStack = emitSelectAlternative(name, lambdaForm.names[i+1]);
i++; // skip MH.invokeBasic of the selectAlternative result
continue;
case GUARD_WITH_CATCH:
*** 1304,1317 ****
private byte[] generateLambdaFormInterpreterEntryPointBytes() {
classFilePrologue();
// Suppress this method in backtraces displayed to the user.
! mv.visitAnnotation("Ljava/lang/invoke/LambdaForm$Hidden;", true);
// Don't inline the interpreter entry.
! mv.visitAnnotation("Ljdk/internal/vm/annotation/DontInline;", true);
// create parameter array
emitIconstInsn(invokerType.parameterCount());
mv.visitTypeInsn(Opcodes.ANEWARRAY, "java/lang/Object");
--- 1329,1342 ----
private byte[] generateLambdaFormInterpreterEntryPointBytes() {
classFilePrologue();
// Suppress this method in backtraces displayed to the user.
! mv.visitAnnotation(LF_HIDDEN_SIG, true);
// Don't inline the interpreter entry.
! mv.visitAnnotation(DONTINLINE_SIG, true);
// create parameter array
emitIconstInsn(invokerType.parameterCount());
mv.visitTypeInsn(Opcodes.ANEWARRAY, "java/lang/Object");
*** 1363,1376 ****
private byte[] generateNamedFunctionInvokerImpl(MethodTypeForm typeForm) {
MethodType dstType = typeForm.erasedType();
classFilePrologue();
// Suppress this method in backtraces displayed to the user.
! mv.visitAnnotation("Ljava/lang/invoke/LambdaForm$Hidden;", true);
// Force inlining of this invoker method.
! mv.visitAnnotation("Ljdk/internal/vm/annotation/ForceInline;", true);
// Load receiver
emitAloadInsn(0);
// Load arguments from array
--- 1388,1401 ----
private byte[] generateNamedFunctionInvokerImpl(MethodTypeForm typeForm) {
MethodType dstType = typeForm.erasedType();
classFilePrologue();
// Suppress this method in backtraces displayed to the user.
! mv.visitAnnotation(LF_HIDDEN_SIG, true);
// Force inlining of this invoker method.
! mv.visitAnnotation(FORCEINLINE_SIG, true);
// Load receiver
emitAloadInsn(0);
// Load arguments from array
< prev index next >