8144723: MethodHandleImpl.initStatics is no longer needed

Reviewed-by: vlivanov, mhaupt, forax
This commit is contained in:
Claes Redestad 2015-12-19 02:24:27 +01:00
parent fd27d80dbd
commit 4e062cde34
6 changed files with 32 additions and 47 deletions

View File

@ -83,7 +83,6 @@ private static CallSite bootstrapDynamic(MethodHandles.Lookup caller, String nam
*/
abstract
public class CallSite {
static { MethodHandleImpl.initStatics(); }
// The actual payload of this call site:
/*package-private*/

View File

@ -1073,11 +1073,6 @@ import java.util.Objects;
}
}
// static {
// System.out.println("Hello world! My methods are:");
// System.out.println(Factory.INSTANCE.getMethods(MemberName.class, true, null));
// }
static {
// Allow privileged classes outside of java.lang
jdk.internal.misc.SharedSecrets.setJavaLangInvokeAccess(new jdk.internal.misc.JavaLangInvokeAccess() {

View File

@ -420,7 +420,6 @@ mh.invokeExact(System.out, "Hello, world.");
* @author John Rose, JSR 292 EG
*/
public abstract class MethodHandle {
static { MethodHandleImpl.initStatics(); }
/**
* Internal marker interface which distinguishes (to the Java compiler)

View File

@ -32,7 +32,6 @@ import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;
import sun.invoke.empty.Empty;
import sun.invoke.util.ValueConversions;
@ -65,11 +64,6 @@ import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP;
/// Factory methods to create method handles:
static void initStatics() {
// Trigger selected static initializations.
MemberName.Factory.INSTANCE.getClass();
}
static MethodHandle makeArrayElementAccessor(Class<?> arrayClass, boolean isSetter) {
if (arrayClass == Object[].class)
return (isSetter ? ArrayAccessor.OBJECT_ARRAY_SETTER : ArrayAccessor.OBJECT_ARRAY_GETTER);
@ -700,33 +694,43 @@ import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP;
MethodHandle makeBlockInliningWrapper(MethodHandle target) {
LambdaForm lform;
if (DONT_INLINE_THRESHOLD > 0) {
lform = PRODUCE_BLOCK_INLINING_FORM.apply(target);
lform = Makers.PRODUCE_BLOCK_INLINING_FORM.apply(target);
} else {
lform = PRODUCE_REINVOKER_FORM.apply(target);
lform = Makers.PRODUCE_REINVOKER_FORM.apply(target);
}
return new CountingWrapper(target, lform,
PRODUCE_BLOCK_INLINING_FORM, PRODUCE_REINVOKER_FORM,
Makers.PRODUCE_BLOCK_INLINING_FORM, Makers.PRODUCE_REINVOKER_FORM,
DONT_INLINE_THRESHOLD);
}
/** Constructs reinvoker lambda form which block inlining during JIT-compilation for a particular method handle */
private static final Function<MethodHandle, LambdaForm> PRODUCE_BLOCK_INLINING_FORM = new Function<MethodHandle, LambdaForm>() {
@Override
public LambdaForm apply(MethodHandle target) {
return DelegatingMethodHandle.makeReinvokerForm(target,
MethodTypeForm.LF_DELEGATE_BLOCK_INLINING, CountingWrapper.class, "reinvoker.dontInline", false,
DelegatingMethodHandle.NF_getTarget, CountingWrapper.NF_maybeStopCounting);
}
};
private final static class Makers {
/** Constructs reinvoker lambda form which block inlining during JIT-compilation for a particular method handle */
static final Function<MethodHandle, LambdaForm> PRODUCE_BLOCK_INLINING_FORM = new Function<MethodHandle, LambdaForm>() {
@Override
public LambdaForm apply(MethodHandle target) {
return DelegatingMethodHandle.makeReinvokerForm(target,
MethodTypeForm.LF_DELEGATE_BLOCK_INLINING, CountingWrapper.class, "reinvoker.dontInline", false,
DelegatingMethodHandle.NF_getTarget, CountingWrapper.NF_maybeStopCounting);
}
};
/** Constructs simple reinvoker lambda form for a particular method handle */
private static final Function<MethodHandle, LambdaForm> PRODUCE_REINVOKER_FORM = new Function<MethodHandle, LambdaForm>() {
@Override
public LambdaForm apply(MethodHandle target) {
return DelegatingMethodHandle.makeReinvokerForm(target,
MethodTypeForm.LF_DELEGATE, DelegatingMethodHandle.class, DelegatingMethodHandle.NF_getTarget);
}
};
/** Constructs simple reinvoker lambda form for a particular method handle */
static final Function<MethodHandle, LambdaForm> PRODUCE_REINVOKER_FORM = new Function<MethodHandle, LambdaForm>() {
@Override
public LambdaForm apply(MethodHandle target) {
return DelegatingMethodHandle.makeReinvokerForm(target,
MethodTypeForm.LF_DELEGATE, DelegatingMethodHandle.class, DelegatingMethodHandle.NF_getTarget);
}
};
/** Maker of type-polymorphic varargs */
static final ClassValue<MethodHandle[]> TYPED_COLLECTORS = new ClassValue<MethodHandle[]>() {
@Override
protected MethodHandle[] computeValue(Class<?> type) {
return new MethodHandle[MAX_JVM_ARITY + 1];
}
};
}
/**
* Counting method handle. It has 2 states: counting and non-counting.
@ -1527,15 +1531,6 @@ import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP;
return MethodHandles.collectArguments(rightFill, 0, midFill);
}
// Type-polymorphic version of varargs maker.
private static final ClassValue<MethodHandle[]> TYPED_COLLECTORS
= new ClassValue<MethodHandle[]>() {
@Override
protected MethodHandle[] computeValue(Class<?> type) {
return new MethodHandle[256];
}
};
static final int MAX_JVM_ARITY = 255; // limit imposed by the JVM
/** Return a method handle that takes the indicated number of
@ -1557,7 +1552,7 @@ import static java.lang.invoke.MethodHandles.Lookup.IMPL_LOOKUP;
if (elemType == Object.class)
return varargsArray(nargs);
// other cases: primitive arrays, subtypes of Object[]
MethodHandle cache[] = TYPED_COLLECTORS.get(elemType);
MethodHandle cache[] = Makers.TYPED_COLLECTORS.get(elemType);
MethodHandle mh = nargs < cache.length ? cache[nargs] : null;
if (mh != null) return mh;
if (nargs == 0) {

View File

@ -87,9 +87,6 @@ class MethodHandleNatives {
private static native void registerNatives();
static {
registerNatives();
// The JVM calls MethodHandleNatives.<clinit>. Cascade the <clinit> calls as needed:
MethodHandleImpl.initStatics();
}
/**

View File

@ -61,7 +61,7 @@ public class MethodHandles {
private MethodHandles() { } // do not instantiate
private static final MemberName.Factory IMPL_NAMES = MemberName.getFactory();
static { MethodHandleImpl.initStatics(); }
// See IMPL_LOOKUP below.
//// Method handle creation from ordinary methods.