Java 类java.lang.invoke.VolatileCallSite 实例源码

项目:openjdk-jdk10    文件:HotSpotGraphBuilderPlugins.java   
private static void registerCallSitePlugins(InvocationPlugins plugins) {
    InvocationPlugin plugin = new InvocationPlugin() {
        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
            ValueNode callSite = receiver.get();
            ValueNode folded = CallSiteTargetNode.tryFold(GraphUtil.originalValue(callSite), b.getMetaAccess(), b.getAssumptions());
            if (folded != null) {
                b.addPush(JavaKind.Object, folded);
            } else {
                b.addPush(JavaKind.Object, new CallSiteTargetNode(b.getInvokeKind(), targetMethod, b.bci(), b.getInvokeReturnStamp(b.getAssumptions()), callSite));
            }
            return true;
        }

        @Override
        public boolean inlineOnly() {
            return true;
        }
    };
    plugins.register(plugin, ConstantCallSite.class, "getTarget", Receiver.class);
    plugins.register(plugin, MutableCallSite.class, "getTarget", Receiver.class);
    plugins.register(plugin, VolatileCallSite.class, "getTarget", Receiver.class);
}
项目:graal-core    文件:HotSpotGraphBuilderPlugins.java   
private static void registerCallSitePlugins(InvocationPlugins plugins) {
    InvocationPlugin plugin = new InvocationPlugin() {
        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
            ValueNode callSite = receiver.get();
            ValueNode folded = CallSiteTargetNode.tryFold(GraphUtil.originalValue(callSite), b.getMetaAccess(), b.getAssumptions());
            if (folded != null) {
                b.addPush(JavaKind.Object, folded);
            } else {
                b.addPush(JavaKind.Object, new CallSiteTargetNode(b.getInvokeKind(), targetMethod, b.bci(), b.getInvokeReturnStamp(b.getAssumptions()), callSite));
            }
            return true;
        }

        @Override
        public boolean inlineOnly() {
            return true;
        }
    };
    plugins.register(plugin, ConstantCallSite.class, "getTarget", Receiver.class);
    plugins.register(plugin, MutableCallSite.class, "getTarget", Receiver.class);
    plugins.register(plugin, VolatileCallSite.class, "getTarget", Receiver.class);
}
项目:openjdk-jdk10    文件:VMAnonymousClasses.java   
public static void main(String[] args) throws ReflectiveOperationException  {
    // Objects
    test(new Object());
    test("TEST");
    test(new VMAnonymousClasses());
    test(null);

    // Class
    test(String.class);

    // Arrays
    test(new boolean[0]);
    test(new byte[0]);
    test(new char[0]);
    test(new short[0]);
    test(new int[0]);
    test(new long[0]);
    test(new float[0]);
    test(new double[0]);
    test(new Object[0]);

    // Multi-dimensional arrays
    test(new byte[0][0]);
    test(new Object[0][0]);

    // MethodHandle-related
    MethodType   mt = MethodType.methodType(void.class, String[].class);
    MethodHandle mh = MethodHandles.lookup().findStatic(VMAnonymousClasses.class, "main", mt);
    test(mt);
    test(mh);
    test(new ConstantCallSite(mh));
    test(new MutableCallSite(MethodType.methodType(void.class)));
    test(new VolatileCallSite(MethodType.methodType(void.class)));

    System.out.println("TEST PASSED");
}
项目:openjdk9    文件:VMAnonymousClasses.java   
public static void main(String[] args) throws ReflectiveOperationException  {
    // Objects
    test(new Object());
    test("TEST");
    test(new VMAnonymousClasses());
    test(null);

    // Class
    test(String.class);

    // Arrays
    test(new boolean[0]);
    test(new byte[0]);
    test(new char[0]);
    test(new short[0]);
    test(new int[0]);
    test(new long[0]);
    test(new float[0]);
    test(new double[0]);
    test(new Object[0]);

    // Multi-dimensional arrays
    test(new byte[0][0]);
    test(new Object[0][0]);

    // MethodHandle-related
    MethodType   mt = MethodType.methodType(void.class, String[].class);
    MethodHandle mh = MethodHandles.lookup().findStatic(VMAnonymousClasses.class, "main", mt);
    test(mt);
    test(mh);
    test(new ConstantCallSite(mh));
    test(new MutableCallSite(MethodType.methodType(void.class)));
    test(new VolatileCallSite(MethodType.methodType(void.class)));

    System.out.println("TEST PASSED");
}
项目:lookaside_java-1.8.0-openjdk    文件:VMAnonymousClasses.java   
public static void main(String[] args) throws ReflectiveOperationException  {
    // Objects
    test(new Object());
    test("TEST");
    test(new VMAnonymousClasses());
    test(null);

    // Class
    test(String.class);

    // Arrays
    test(new boolean[0]);
    test(new byte[0]);
    test(new char[0]);
    test(new short[0]);
    test(new int[0]);
    test(new long[0]);
    test(new float[0]);
    test(new double[0]);
    test(new Object[0]);

    // Multi-dimensional arrays
    test(new byte[0][0]);
    test(new Object[0][0]);

    // MethodHandle-related
    MethodType   mt = MethodType.methodType(void.class, String[].class);
    MethodHandle mh = MethodHandles.lookup().findStatic(VMAnonymousClasses.class, "main", mt);
    test(mt);
    test(mh);
    test(new ConstantCallSite(mh));
    test(new MutableCallSite(MethodType.methodType(void.class)));
    test(new VolatileCallSite(MethodType.methodType(void.class)));

    System.out.println("TEST PASSED");
}
项目:infobip-open-jdk-8    文件:VMAnonymousClasses.java   
public static void main(String[] args) throws ReflectiveOperationException  {
    // Objects
    test(new Object());
    test("TEST");
    test(new VMAnonymousClasses());
    test(null);

    // Class
    test(String.class);

    // Arrays
    test(new boolean[0]);
    test(new byte[0]);
    test(new char[0]);
    test(new short[0]);
    test(new int[0]);
    test(new long[0]);
    test(new float[0]);
    test(new double[0]);
    test(new Object[0]);

    // Multi-dimensional arrays
    test(new byte[0][0]);
    test(new Object[0][0]);

    // MethodHandle-related
    MethodType   mt = MethodType.methodType(void.class, String[].class);
    MethodHandle mh = MethodHandles.lookup().findStatic(VMAnonymousClasses.class, "main", mt);
    test(mt);
    test(mh);
    test(new ConstantCallSite(mh));
    test(new MutableCallSite(MethodType.methodType(void.class)));
    test(new VolatileCallSite(MethodType.methodType(void.class)));

    System.out.println("TEST PASSED");
}