Search in sources :

Example 1 with Edges

use of org.graalvm.compiler.graph.Edges in project graal by oracle.

the class FieldsOffsetsFeature method beforeCompilation.

@Override
public void beforeCompilation(BeforeCompilationAccess a) {
    CompilationAccessImpl config = (CompilationAccessImpl) a;
    HostedMetaAccess hMetaAccess = config.getMetaAccess();
    for (FieldsOffsetsReplacement replacement : getReplacements().values()) {
        Fields fields = replacement.fields;
        long[] newOffsets = new long[fields.getCount()];
        for (int i = 0; i < newOffsets.length; i++) {
            Field field = findField(fields, i);
            assert UnsafeAccess.UNSAFE.objectFieldOffset(field) == fields.getOffsets()[i];
            newOffsets[i] = hMetaAccess.lookupJavaField(field).getLocation();
        }
        replacement.newOffsets = newOffsets;
        if (fields instanceof Edges) {
            Edges edges = (Edges) fields;
            replacement.newIterationInitMask = NodeClass.computeIterationMask(edges.type(), edges.getDirectCount(), newOffsets);
        }
        replacement.newValuesAvailable = true;
    }
}
Also used : ResolvedJavaField(jdk.vm.ci.meta.ResolvedJavaField) Field(java.lang.reflect.Field) Fields(org.graalvm.compiler.core.common.Fields) CompilationAccessImpl(com.oracle.svm.hosted.FeatureImpl.CompilationAccessImpl) Edges(org.graalvm.compiler.graph.Edges) HostedMetaAccess(com.oracle.svm.hosted.meta.HostedMetaAccess)

Example 2 with Edges

use of org.graalvm.compiler.graph.Edges in project graal by oracle.

the class LoopDetector method makeSuccessorStubs.

/**
 * Process successor edges of a node. We create the successor nodes so that we can fill the
 * successor list, but no properties or edges are loaded yet. That is done when the successor is
 * on top of the worklist in {@link #processNextNode}.
 */
protected void makeSuccessorStubs(MethodScope methodScope, LoopScope loopScope, Node node, boolean updatePredecessors) {
    Edges edges = node.getNodeClass().getSuccessorEdges();
    for (int index = 0; index < edges.getDirectCount(); index++) {
        if (skipDirectEdge(node, edges, index)) {
            continue;
        }
        int orderId = readOrderId(methodScope);
        Node value = makeStubNode(methodScope, loopScope, orderId);
        edges.initializeNode(node, index, value);
        if (updatePredecessors && value != null) {
            edges.update(node, null, value);
        }
    }
    for (int index = edges.getDirectCount(); index < edges.getCount(); index++) {
        int size = methodScope.reader.getSVInt();
        if (size != -1) {
            NodeList<Node> nodeList = new NodeSuccessorList<>(node, size);
            edges.initializeList(node, index, nodeList);
            for (int idx = 0; idx < size; idx++) {
                int orderId = readOrderId(methodScope);
                Node value = makeStubNode(methodScope, loopScope, orderId);
                nodeList.initialize(idx, value);
                if (updatePredecessors && value != null) {
                    edges.update(node, null, value);
                }
            }
        }
    }
}
Also used : NodeSuccessorList(org.graalvm.compiler.graph.NodeSuccessorList) IntegerSwitchNode(org.graalvm.compiler.nodes.extended.IntegerSwitchNode) FloatingNode(org.graalvm.compiler.nodes.calc.FloatingNode) Node(org.graalvm.compiler.graph.Node) Edges(org.graalvm.compiler.graph.Edges)

Example 3 with Edges

use of org.graalvm.compiler.graph.Edges in project graal by oracle.

the class LoopDetector method makeFloatingNodeInputs.

protected void makeFloatingNodeInputs(MethodScope methodScope, LoopScope loopScope, Node node) {
    Edges edges = node.getNodeClass().getInputEdges();
    if (node instanceof PhiNode) {
        /*
             * The inputs of phi functions are filled manually when the end nodes are processed.
             * However, the values must not be null, so initialize them with an empty list.
             */
        assert edges.getDirectCount() == 1 : "PhiNode has one direct input (the MergeNode)";
        assert edges.getCount() - edges.getDirectCount() == 1 : "PhiNode has one variable size input (the values)";
        edges.initializeList(node, edges.getDirectCount(), new NodeInputList<>(node));
    } else {
        for (int index = 0; index < edges.getDirectCount(); index++) {
            int orderId = readOrderId(methodScope);
            Node value = ensureNodeCreated(methodScope, loopScope, orderId);
            edges.initializeNode(node, index, value);
        }
        for (int index = edges.getDirectCount(); index < edges.getCount(); index++) {
            int size = methodScope.reader.getSVInt();
            if (size != -1) {
                NodeList<Node> nodeList = new NodeInputList<>(node, size);
                edges.initializeList(node, index, nodeList);
                for (int idx = 0; idx < size; idx++) {
                    int orderId = readOrderId(methodScope);
                    Node value = ensureNodeCreated(methodScope, loopScope, orderId);
                    nodeList.initialize(idx, value);
                }
            }
        }
    }
}
Also used : IntegerSwitchNode(org.graalvm.compiler.nodes.extended.IntegerSwitchNode) FloatingNode(org.graalvm.compiler.nodes.calc.FloatingNode) Node(org.graalvm.compiler.graph.Node) NodeInputList(org.graalvm.compiler.graph.NodeInputList) Edges(org.graalvm.compiler.graph.Edges)

Example 4 with Edges

use of org.graalvm.compiler.graph.Edges in project graal by oracle.

the class LoopDetector method makeFixedNodeInputs.

/**
 * Process the input edges of a node. Input nodes that have not yet been created must be
 * non-fixed nodes (because fixed nodes are processed in reverse postorder. Such non-fixed nodes
 * are created on demand (recursively since they can themselves reference not yet created
 * nodes).
 */
protected void makeFixedNodeInputs(MethodScope methodScope, LoopScope loopScope, Node node) {
    Edges edges = node.getNodeClass().getInputEdges();
    for (int index = 0; index < edges.getDirectCount(); index++) {
        if (skipDirectEdge(node, edges, index)) {
            continue;
        }
        int orderId = readOrderId(methodScope);
        Node value = ensureNodeCreated(methodScope, loopScope, orderId);
        edges.initializeNode(node, index, value);
        if (value != null && !value.isDeleted()) {
            edges.update(node, null, value);
        }
    }
    if (node instanceof AbstractMergeNode) {
        /* The ends of merge nodes are filled manually when the ends are processed. */
        assert edges.getCount() - edges.getDirectCount() == 1 : "MergeNode has one variable size input (the ends)";
        assert Edges.getNodeList(node, edges.getOffsets(), edges.getDirectCount()) != null : "Input list must have been already created";
    } else {
        for (int index = edges.getDirectCount(); index < edges.getCount(); index++) {
            int size = methodScope.reader.getSVInt();
            if (size != -1) {
                NodeList<Node> nodeList = new NodeInputList<>(node, size);
                edges.initializeList(node, index, nodeList);
                for (int idx = 0; idx < size; idx++) {
                    int orderId = readOrderId(methodScope);
                    Node value = ensureNodeCreated(methodScope, loopScope, orderId);
                    nodeList.initialize(idx, value);
                    if (value != null && !value.isDeleted()) {
                        edges.update(node, null, value);
                    }
                }
            }
        }
    }
}
Also used : IntegerSwitchNode(org.graalvm.compiler.nodes.extended.IntegerSwitchNode) FloatingNode(org.graalvm.compiler.nodes.calc.FloatingNode) Node(org.graalvm.compiler.graph.Node) NodeInputList(org.graalvm.compiler.graph.NodeInputList) Edges(org.graalvm.compiler.graph.Edges)

Aggregations

Edges (org.graalvm.compiler.graph.Edges)4 Node (org.graalvm.compiler.graph.Node)3 FloatingNode (org.graalvm.compiler.nodes.calc.FloatingNode)3 IntegerSwitchNode (org.graalvm.compiler.nodes.extended.IntegerSwitchNode)3 NodeInputList (org.graalvm.compiler.graph.NodeInputList)2 CompilationAccessImpl (com.oracle.svm.hosted.FeatureImpl.CompilationAccessImpl)1 HostedMetaAccess (com.oracle.svm.hosted.meta.HostedMetaAccess)1 Field (java.lang.reflect.Field)1 ResolvedJavaField (jdk.vm.ci.meta.ResolvedJavaField)1 Fields (org.graalvm.compiler.core.common.Fields)1 NodeSuccessorList (org.graalvm.compiler.graph.NodeSuccessorList)1