Search in sources :

Example 1 with ForeignCallPlugin

use of org.graalvm.compiler.nodes.graphbuilderconf.ForeignCallPlugin in project graal by oracle.

the class HotSpotGraphBuilderPlugins method registerSystemPlugins.

private static void registerSystemPlugins(InvocationPlugins plugins, ForeignCallsProvider foreignCalls) {
    Registration r = new Registration(plugins, System.class);
    r.register0("currentTimeMillis", new ForeignCallPlugin(foreignCalls, HotSpotHostForeignCallsProvider.JAVA_TIME_MILLIS));
    r.register0("nanoTime", new ForeignCallPlugin(foreignCalls, HotSpotHostForeignCallsProvider.JAVA_TIME_NANOS));
    r.register1("identityHashCode", Object.class, new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode object) {
            b.addPush(JavaKind.Int, new IdentityHashCodeNode(object));
            return true;
        }

        @Override
        public boolean inlineOnly() {
            return true;
        }
    });
    r.register5("arraycopy", Object.class, int.class, Object.class, int.class, int.class, new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode src, ValueNode srcPos, ValueNode dst, ValueNode dstPos, ValueNode length) {
            b.add(new ArrayCopyNode(b.bci(), src, srcPos, dst, dstPos, length));
            return true;
        }

        @Override
        public boolean inlineOnly() {
            return true;
        }
    });
}
Also used : IdentityHashCodeNode(org.graalvm.compiler.hotspot.replacements.IdentityHashCodeNode) ForeignCallPlugin(org.graalvm.compiler.nodes.graphbuilderconf.ForeignCallPlugin) ArrayCopyNode(org.graalvm.compiler.hotspot.replacements.arraycopy.ArrayCopyNode) GraphBuilderContext(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext) Registration(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration) ValueNode(org.graalvm.compiler.nodes.ValueNode) InvocationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin) Receiver(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.Receiver) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Aggregations

ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)1 IdentityHashCodeNode (org.graalvm.compiler.hotspot.replacements.IdentityHashCodeNode)1 ArrayCopyNode (org.graalvm.compiler.hotspot.replacements.arraycopy.ArrayCopyNode)1 ValueNode (org.graalvm.compiler.nodes.ValueNode)1 ForeignCallPlugin (org.graalvm.compiler.nodes.graphbuilderconf.ForeignCallPlugin)1 GraphBuilderContext (org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext)1 InvocationPlugin (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin)1 Receiver (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.Receiver)1 Registration (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration)1