java.lang.invoke.VolatileCallSite Java Examples

The following examples show how to use java.lang.invoke.VolatileCallSite. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: HotSpotGraphBuilderPlugins.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
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);
}
 
Example #2
Source File: VMAnonymousClasses.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
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");
}
 
Example #3
Source File: VMAnonymousClasses.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
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");
}
 
Example #4
Source File: VMAnonymousClasses.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
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");
}
 
Example #5
Source File: VMAnonymousClasses.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
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");
}
 
Example #6
Source File: VMAnonymousClasses.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
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");
}
 
Example #7
Source File: VMAnonymousClasses.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
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");
}