8005345: JSR 292: JDK performance tweaks
Reviewed-by: kvn, jrose
This commit is contained in:
parent
f39122797e
commit
d8b54b1219
jdk/src/share/classes
java/lang/invoke
sun/invoke/util
@ -295,9 +295,6 @@ class InvokerBytecodeGenerator {
|
|||||||
|
|
||||||
String invokerDesc = invokerType.toMethodDescriptorString();
|
String invokerDesc = invokerType.toMethodDescriptorString();
|
||||||
mv = cw.visitMethod(Opcodes.ACC_STATIC, invokerName, invokerDesc, null, null);
|
mv = cw.visitMethod(Opcodes.ACC_STATIC, invokerName, invokerDesc, null, null);
|
||||||
|
|
||||||
// Force inlining of this invoker method.
|
|
||||||
mv.visitAnnotation("Ljava/lang/invoke/ForceInline;", true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -524,6 +521,9 @@ class InvokerBytecodeGenerator {
|
|||||||
// Mark this method as a compiled LambdaForm
|
// Mark this method as a compiled LambdaForm
|
||||||
mv.visitAnnotation("Ljava/lang/invoke/LambdaForm$Compiled;", true);
|
mv.visitAnnotation("Ljava/lang/invoke/LambdaForm$Compiled;", true);
|
||||||
|
|
||||||
|
// Force inlining of this invoker method.
|
||||||
|
mv.visitAnnotation("Ljava/lang/invoke/ForceInline;", true);
|
||||||
|
|
||||||
// iterate over the form's names, generating bytecode instructions for each
|
// iterate over the form's names, generating bytecode instructions for each
|
||||||
// start iterating at the first name following the arguments
|
// start iterating at the first name following the arguments
|
||||||
for (int i = lambdaForm.arity; i < lambdaForm.names.length; i++) {
|
for (int i = lambdaForm.arity; i < lambdaForm.names.length; i++) {
|
||||||
@ -943,6 +943,9 @@ class InvokerBytecodeGenerator {
|
|||||||
// Suppress this method in backtraces displayed to the user.
|
// Suppress this method in backtraces displayed to the user.
|
||||||
mv.visitAnnotation("Ljava/lang/invoke/LambdaForm$Hidden;", true);
|
mv.visitAnnotation("Ljava/lang/invoke/LambdaForm$Hidden;", true);
|
||||||
|
|
||||||
|
// Don't inline the interpreter entry.
|
||||||
|
mv.visitAnnotation("Ljava/lang/invoke/DontInline;", true);
|
||||||
|
|
||||||
// create parameter array
|
// create parameter array
|
||||||
emitIconstInsn(invokerType.parameterCount());
|
emitIconstInsn(invokerType.parameterCount());
|
||||||
mv.visitTypeInsn(Opcodes.ANEWARRAY, "java/lang/Object");
|
mv.visitTypeInsn(Opcodes.ANEWARRAY, "java/lang/Object");
|
||||||
@ -1005,6 +1008,9 @@ class InvokerBytecodeGenerator {
|
|||||||
// Suppress this method in backtraces displayed to the user.
|
// Suppress this method in backtraces displayed to the user.
|
||||||
mv.visitAnnotation("Ljava/lang/invoke/LambdaForm$Hidden;", true);
|
mv.visitAnnotation("Ljava/lang/invoke/LambdaForm$Hidden;", true);
|
||||||
|
|
||||||
|
// Force inlining of this invoker method.
|
||||||
|
mv.visitAnnotation("Ljava/lang/invoke/ForceInline;", true);
|
||||||
|
|
||||||
// Load receiver
|
// Load receiver
|
||||||
emitAloadInsn(0);
|
emitAloadInsn(0);
|
||||||
|
|
||||||
|
@ -592,6 +592,7 @@ class LambdaForm {
|
|||||||
private int invocationCounter = 0;
|
private int invocationCounter = 0;
|
||||||
|
|
||||||
@Hidden
|
@Hidden
|
||||||
|
@DontInline
|
||||||
/** Interpretively invoke this form on the given arguments. */
|
/** Interpretively invoke this form on the given arguments. */
|
||||||
Object interpretWithArguments(Object... argumentValues) throws Throwable {
|
Object interpretWithArguments(Object... argumentValues) throws Throwable {
|
||||||
if (TRACE_INTERPRETER)
|
if (TRACE_INTERPRETER)
|
||||||
@ -606,6 +607,7 @@ class LambdaForm {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Hidden
|
@Hidden
|
||||||
|
@DontInline
|
||||||
/** Evaluate a single Name within this form, applying its function to its arguments. */
|
/** Evaluate a single Name within this form, applying its function to its arguments. */
|
||||||
Object interpretName(Name name, Object[] values) throws Throwable {
|
Object interpretName(Name name, Object[] values) throws Throwable {
|
||||||
if (TRACE_INTERPRETER)
|
if (TRACE_INTERPRETER)
|
||||||
|
@ -310,9 +310,9 @@ import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP;
|
|||||||
}
|
}
|
||||||
|
|
||||||
static class AsVarargsCollector extends MethodHandle {
|
static class AsVarargsCollector extends MethodHandle {
|
||||||
MethodHandle target;
|
private final MethodHandle target;
|
||||||
final Class<?> arrayType;
|
private final Class<?> arrayType;
|
||||||
MethodHandle cache;
|
private MethodHandle cache;
|
||||||
|
|
||||||
AsVarargsCollector(MethodHandle target, MethodType type, Class<?> arrayType) {
|
AsVarargsCollector(MethodHandle target, MethodType type, Class<?> arrayType) {
|
||||||
super(type, reinvokerForm(type));
|
super(type, reinvokerForm(type));
|
||||||
|
@ -449,8 +449,16 @@ public class ValueConversions {
|
|||||||
* @param x an arbitrary reference value
|
* @param x an arbitrary reference value
|
||||||
* @return the same value x
|
* @return the same value x
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
static <T,U> T castReference(Class<? extends T> t, U x) {
|
static <T,U> T castReference(Class<? extends T> t, U x) {
|
||||||
return t.cast(x);
|
// inlined Class.cast because we can't ForceInline it
|
||||||
|
if (x != null && !t.isInstance(x))
|
||||||
|
throw newClassCastException(t, x);
|
||||||
|
return (T) x;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ClassCastException newClassCastException(Class<?> t, Object obj) {
|
||||||
|
return new ClassCastException("Cannot cast " + obj.getClass().getName() + " to " + t.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final MethodHandle IDENTITY, CAST_REFERENCE, ZERO_OBJECT, IGNORE, EMPTY,
|
private static final MethodHandle IDENTITY, CAST_REFERENCE, ZERO_OBJECT, IGNORE, EMPTY,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user