Search in sources :

Example 1 with CEntryPointPrologueBailoutNode

use of com.oracle.svm.core.graal.nodes.CEntryPointPrologueBailoutNode in project graal by oracle.

the class CEntryPointCallStubMethod method inlinePrologueAndEpilogue.

private static void inlinePrologueAndEpilogue(SubstrateGraphKit kit, InvokeNode prologueInvoke, InvokeNode epilogueInvoke, JavaKind returnKind) {
    assert (prologueInvoke != null) == (epilogueInvoke != null);
    if (prologueInvoke != null) {
        kit.inline(prologueInvoke);
        NodeIterable<CEntryPointPrologueBailoutNode> bailoutNodes = kit.getGraph().getNodes().filter(CEntryPointPrologueBailoutNode.class);
        for (CEntryPointPrologueBailoutNode node : bailoutNodes) {
            ValueNode result = node.getResult();
            switch(returnKind) {
                case Float:
                    assert result.getStackKind().isNumericFloat();
                    result = kit.unique(new FloatConvertNode(FloatConvert.D2F, result));
                    break;
                case Byte:
                case Char:
                case Short:
                case Int:
                    assert result.getStackKind().isNumericInteger();
                    result = kit.unique(new NarrowNode(result, returnKind.getBitCount()));
                    break;
                default:
                    // no conversion necessary
                    break;
            }
            ReturnNode returnNode = kit.add(new ReturnNode(result));
            node.replaceAndDelete(returnNode);
        }
        if (epilogueInvoke.isAlive()) {
            kit.inline(epilogueInvoke);
        }
    }
}
Also used : ReturnNode(org.graalvm.compiler.nodes.ReturnNode) CEntryPointPrologueBailoutNode(com.oracle.svm.core.graal.nodes.CEntryPointPrologueBailoutNode) FloatConvertNode(org.graalvm.compiler.nodes.calc.FloatConvertNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) NarrowNode(org.graalvm.compiler.nodes.calc.NarrowNode)

Example 2 with CEntryPointPrologueBailoutNode

use of com.oracle.svm.core.graal.nodes.CEntryPointPrologueBailoutNode 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)

Aggregations

CEntryPointPrologueBailoutNode (com.oracle.svm.core.graal.nodes.CEntryPointPrologueBailoutNode)2 ValueNode (org.graalvm.compiler.nodes.ValueNode)2 CEntryPointEnterNode (com.oracle.svm.core.graal.nodes.CEntryPointEnterNode)1 CEntryPointLeaveNode (com.oracle.svm.core.graal.nodes.CEntryPointLeaveNode)1 CEntryPointUtilityNode (com.oracle.svm.core.graal.nodes.CEntryPointUtilityNode)1 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)1 ReturnNode (org.graalvm.compiler.nodes.ReturnNode)1 FloatConvertNode (org.graalvm.compiler.nodes.calc.FloatConvertNode)1 NarrowNode (org.graalvm.compiler.nodes.calc.NarrowNode)1 GraphBuilderContext (org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext)1 InvocationPlugin (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin)1 Registration (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration)1