Search in sources :

Example 66 with Registration

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

the class PointstoGraphBuilderPlugins method registerSystemPlugins.

public static void registerSystemPlugins(InvocationPlugins plugins) {
    Registration r = new Registration(plugins, System.class).setAllowOverwrite(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 dest, ValueNode destPos, ValueNode length) {
            b.add(new BasicArrayCopyNode(BasicArrayCopyNode.TYPE, src, srcPos, dest, destPos, length, null, b.bci()));
            return true;
        }
    });
}
Also used : GraphBuilderContext(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext) BasicArrayCopyNode(org.graalvm.compiler.replacements.nodes.BasicArrayCopyNode) 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)

Example 67 with Registration

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

the class PointstoGraphBuilderPlugins method registerArraysPlugins.

public static void registerArraysPlugins(InvocationPlugins plugins) {
    Registration r = new Registration(plugins, Arrays.class).setAllowOverwrite(true);
    r.register2("copyOf", Object[].class, int.class, new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode original, ValueNode newLength) {
            b.addPush(JavaKind.Object, new AnalysisArraysCopyOfNode(b.getInvokeReturnStamp(b.getAssumptions()).getTrustedStamp(), original, newLength));
            return true;
        }
    });
    r.register3("copyOf", Object[].class, int.class, Class.class, new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode original, ValueNode newLength, ValueNode newObjectElementType) {
            if (newObjectElementType instanceof GetClassNode || newObjectElementType.isConstant()) {
                // We can infer the concrete type of the new array
                b.addPush(JavaKind.Object, new AnalysisArraysCopyOfNode(b.getInvokeReturnStamp(b.getAssumptions()).getTrustedStamp(), original, newLength, newObjectElementType));
                return true;
            }
            return false;
        }
    });
}
Also used : GraphBuilderContext(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext) Registration(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration) GetClassNode(org.graalvm.compiler.nodes.extended.GetClassNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) AnalysisArraysCopyOfNode(com.oracle.graal.pointsto.nodes.AnalysisArraysCopyOfNode) InvocationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin) Receiver(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.Receiver) Arrays(java.util.Arrays) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 68 with Registration

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

the class JDKIntrinsicsFeature method registerSystemPlugins.

private static void registerSystemPlugins(InvocationPlugins plugins) {
    Registration r = new Registration(plugins, System.class);
    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 SubstrateArraycopyNode(src, srcPos, dst, dstPos, length, null, b.bci()));
            return true;
        }
    });
}
Also used : 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) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 69 with Registration

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

the class CEntryPointSupport method registerEntryPointActionsPlugins.

private static void registerEntryPointActionsPlugins(InvocationPlugins plugins) {
    Registration r = new Registration(plugins, CEntryPointActions.class);
    r.register1("enterCreateIsolate", CEntryPointCreateIsolateParameters.class, new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode parameters) {
            b.addPush(JavaKind.Int, new CEntryPointEnterNode(EnterAction.CreateIsolate, parameters));
            return true;
        }
    });
    r.register1("enterAttachThread", Isolate.class, new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode isolate) {
            b.addPush(JavaKind.Int, new CEntryPointEnterNode(EnterAction.AttachThread, isolate));
            return true;
        }
    });
    r.register1("enter", IsolateThread.class, new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode thread) {
            b.addPush(JavaKind.Int, new CEntryPointEnterNode(EnterAction.Enter, thread));
            return true;
        }
    });
    r.register1("enterIsolate", Isolate.class, new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode isolate) {
            b.addPush(JavaKind.Int, new CEntryPointEnterNode(EnterAction.EnterIsolate, isolate));
            return true;
        }
    });
    InvocationPlugin bailoutPlugin = new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode value) {
            b.add(new CEntryPointPrologueBailoutNode(value));
            return true;
        }
    };
    r.register1("bailoutInPrologue", WordBase.class, bailoutPlugin);
    r.register1("bailoutInPrologue", long.class, bailoutPlugin);
    r.register1("bailoutInPrologue", double.class, bailoutPlugin);
    r.register1("bailoutInPrologue", boolean.class, bailoutPlugin);
    r.register0("bailoutInPrologue", new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
            b.add(new CEntryPointPrologueBailoutNode(null));
            return true;
        }
    });
    r.register0("leave", new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
            b.addPush(JavaKind.Int, new CEntryPointLeaveNode(LeaveAction.Leave));
            return true;
        }
    });
    r.register0("leaveDetachThread", new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
            b.addPush(JavaKind.Int, new CEntryPointLeaveNode(LeaveAction.DetachThread));
            return true;
        }
    });
    r.register0("leaveTearDownIsolate", new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
            b.addPush(JavaKind.Int, new CEntryPointLeaveNode(LeaveAction.TearDownIsolate));
            return true;
        }
    });
    r.register2("failFatally", int.class, CCharPointer.class, new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode arg1, ValueNode arg2) {
            b.add(new CEntryPointUtilityNode(UtilityAction.FailFatally, arg1, arg2));
            return true;
        }
    });
}
Also used : CEntryPointPrologueBailoutNode(com.oracle.svm.core.graal.nodes.CEntryPointPrologueBailoutNode) GraphBuilderContext(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext) CEntryPointEnterNode(com.oracle.svm.core.graal.nodes.CEntryPointEnterNode) Registration(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration) CEntryPointUtilityNode(com.oracle.svm.core.graal.nodes.CEntryPointUtilityNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) InvocationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin) CEntryPointLeaveNode(com.oracle.svm.core.graal.nodes.CEntryPointLeaveNode) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 70 with Registration

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

the class CEntryPointSupport method registerEntryPointContextPlugins.

private static void registerEntryPointContextPlugins(InvocationPlugins plugins) {
    Registration r = new Registration(plugins, CEntryPointContext.class);
    r.register0("getCurrentIsolateThread", new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
            if (SubstrateOptions.MultiThreaded.getValue()) {
                b.addPush(JavaKind.Object, ReadRegisterFixedNode.forIsolateThread());
            } else if (SubstrateOptions.SpawnIsolates.getValue()) {
                ValueNode heapBase = b.add(ReadRegisterFixedNode.forHeapBase());
                ConstantNode addend = b.add(ConstantNode.forIntegerKind(FrameAccess.getWordKind(), CEntryPointSetup.SINGLE_ISOLATE_TO_SINGLE_THREAD_ADDEND));
                b.addPush(JavaKind.Object, new AddNode(heapBase, addend));
            } else {
                b.addPush(JavaKind.Object, ConstantNode.forIntegerKind(FrameAccess.getWordKind(), CEntryPointSetup.SINGLE_THREAD_SENTINEL.rawValue()));
            }
            return true;
        }
    });
    r.register0("getCurrentIsolate", new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
            if (SubstrateOptions.SpawnIsolates.getValue()) {
                b.addPush(JavaKind.Object, ReadRegisterFixedNode.forHeapBase());
            } else {
                b.addPush(JavaKind.Object, ConstantNode.forIntegerKind(FrameAccess.getWordKind(), CEntryPointSetup.SINGLE_ISOLATE_SENTINEL.rawValue()));
            }
            return true;
        }
    });
    r.register1("isCurrentThreadAttachedTo", Isolate.class, new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode isolate) {
            b.addPush(JavaKind.Boolean, new CEntryPointUtilityNode(UtilityAction.IsAttached, isolate));
            return true;
        }
    });
}
Also used : ConstantNode(org.graalvm.compiler.nodes.ConstantNode) GraphBuilderContext(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext) Registration(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration) CEntryPointUtilityNode(com.oracle.svm.core.graal.nodes.CEntryPointUtilityNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) InvocationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin) AddNode(org.graalvm.compiler.nodes.calc.AddNode) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Aggregations

Registration (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration)88 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)66 GraphBuilderContext (org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext)66 InvocationPlugin (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin)66 ValueNode (org.graalvm.compiler.nodes.ValueNode)60 Receiver (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.Receiver)52 ConvertUnknownValueNode (com.oracle.graal.pointsto.nodes.ConvertUnknownValueNode)13 StackValueNode (com.oracle.svm.core.graal.stackvalue.StackValueNode)13 ResolvedJavaType (jdk.vm.ci.meta.ResolvedJavaType)10 LogicNode (org.graalvm.compiler.nodes.LogicNode)9 FixedGuardNode (org.graalvm.compiler.nodes.FixedGuardNode)7 ResolvedJavaSymbol (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.ResolvedJavaSymbol)7 JavaKind (jdk.vm.ci.meta.JavaKind)5 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)5 DeoptimizeNode (org.graalvm.compiler.nodes.DeoptimizeNode)5 ConditionalNode (org.graalvm.compiler.nodes.calc.ConditionalNode)5 GetClassNode (org.graalvm.compiler.nodes.extended.GetClassNode)4 AnalysisArraysCopyOfNode (com.oracle.graal.pointsto.nodes.AnalysisArraysCopyOfNode)3 JavaConstant (jdk.vm.ci.meta.JavaConstant)3 BlackholeNode (org.graalvm.compiler.nodes.debug.BlackholeNode)3