Search in sources :

Example 1 with StackValueNode

use of com.oracle.svm.core.graal.stackvalue.StackValueNode in project graal by oracle.

the class SubstrateGraphBuilderPlugins method registerStackValuePlugins.

private static void registerStackValuePlugins(InvocationPlugins plugins) {
    Registration r = new Registration(plugins, StackValue.class);
    r.register1("get", int.class, new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode sizeNode) {
            long size = longValue(b, targetMethod, sizeNode, "size");
            StackSlotIdentity slotIdentity = new StackSlotIdentity(b.getGraph().method().asStackTraceElement(b.bci()).toString());
            b.addPush(JavaKind.Object, new StackValueNode(1, size, slotIdentity));
            return true;
        }
    });
    r.register2("get", int.class, int.class, new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode numElementsNode, ValueNode elementSizeNode) {
            long numElements = longValue(b, targetMethod, numElementsNode, "numElements");
            long elementSize = longValue(b, targetMethod, elementSizeNode, "elementSize");
            StackSlotIdentity slotIdentity = new StackSlotIdentity(b.getGraph().method().asStackTraceElement(b.bci()).toString());
            b.addPush(JavaKind.Object, new StackValueNode(numElements, elementSize, slotIdentity));
            return true;
        }
    });
}
Also used : GraphBuilderContext(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext) Registration(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration) StackValueNode(com.oracle.svm.core.graal.stackvalue.StackValueNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) ConvertUnknownValueNode(com.oracle.graal.pointsto.nodes.ConvertUnknownValueNode) InvocationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin) Receiver(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.Receiver) StackSlotIdentity(com.oracle.svm.core.graal.stackvalue.StackValueNode.StackSlotIdentity) StackValueNode(com.oracle.svm.core.graal.stackvalue.StackValueNode) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Aggregations

ConvertUnknownValueNode (com.oracle.graal.pointsto.nodes.ConvertUnknownValueNode)1 StackValueNode (com.oracle.svm.core.graal.stackvalue.StackValueNode)1 StackSlotIdentity (com.oracle.svm.core.graal.stackvalue.StackValueNode.StackSlotIdentity)1 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)1 ValueNode (org.graalvm.compiler.nodes.ValueNode)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