Search in sources :

Example 16 with NodeSourcePosition

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

the class BinaryGraphPrinter method methodLocation.

@Override
public Iterable<SourceLanguagePosition> methodLocation(ResolvedJavaMethod method, int bci, NodeSourcePosition pos) {
    StackTraceElement e = methodStackTraceElement(method, bci, pos);
    class JavaSourcePosition implements SourceLanguagePosition {

        @Override
        public String toShortString() {
            return e.toString();
        }

        @Override
        public int getOffsetEnd() {
            return -1;
        }

        @Override
        public int getOffsetStart() {
            return -1;
        }

        @Override
        public int getLineNumber() {
            return e.getLineNumber();
        }

        @Override
        public URI getURI() {
            String path = e.getFileName();
            try {
                return path == null ? null : new URI(null, null, path, null);
            } catch (URISyntaxException ex) {
                throw new IllegalArgumentException(ex);
            }
        }

        @Override
        public String getLanguage() {
            return "Java";
        }
    }
    List<SourceLanguagePosition> arr = new ArrayList<>();
    arr.add(new JavaSourcePosition());
    NodeSourcePosition at = pos;
    while (at != null) {
        SourceLanguagePosition cur = at.getSourceLanguage();
        if (cur != null) {
            arr.add(cur);
        }
        at = at.getCaller();
    }
    return arr;
}
Also used : SourceLanguagePosition(org.graalvm.compiler.graph.SourceLanguagePosition) ArrayList(java.util.ArrayList) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) NodeSourcePosition(org.graalvm.compiler.graph.NodeSourcePosition)

Example 17 with NodeSourcePosition

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

the class InliningUtil method updateSourcePositions.

@SuppressWarnings("try")
private static void updateSourcePositions(Invoke invoke, StructuredGraph inlineGraph, UnmodifiableEconomicMap<Node, Node> duplicates, boolean isSub, Mark mark) {
    FixedNode invokeNode = invoke.asNode();
    boolean isSubstitution = isSub || inlineGraph.method().getAnnotation(MethodSubstitution.class) != null || inlineGraph.method().getAnnotation(Snippet.class) != null;
    StructuredGraph invokeGraph = invokeNode.graph();
    assert !invokeGraph.trackNodeSourcePosition() || inlineGraph.trackNodeSourcePosition() || isSubstitution : String.format("trackNodeSourcePosition mismatch %s %s != %s %s", invokeGraph, invokeGraph.trackNodeSourcePosition(), inlineGraph, inlineGraph.trackNodeSourcePosition());
    if (invokeGraph.trackNodeSourcePosition() && invoke.stateAfter() != null) {
        final NodeSourcePosition invokePos = invoke.asNode().getNodeSourcePosition();
        updateSourcePosition(invokeGraph, duplicates, mark, invokePos, isSubstitution);
    }
}
Also used : StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) FixedNode(org.graalvm.compiler.nodes.FixedNode) MethodSubstitution(org.graalvm.compiler.api.replacements.MethodSubstitution) NodeSourcePosition(org.graalvm.compiler.graph.NodeSourcePosition)

Example 18 with NodeSourcePosition

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

the class InliningUtil method updateSourcePosition.

public static void updateSourcePosition(StructuredGraph invokeGraph, UnmodifiableEconomicMap<Node, Node> duplicates, Mark mark, NodeSourcePosition invokePos, boolean isSubstitution) {
    /*
         * Not every duplicate node is newly created, so only update the position of the newly
         * created nodes.
         */
    EconomicSet<Node> newNodes = EconomicSet.create(Equivalence.DEFAULT);
    newNodes.addAll(invokeGraph.getNewNodes(mark));
    EconomicMap<NodeSourcePosition, NodeSourcePosition> posMap = EconomicMap.create(Equivalence.DEFAULT);
    UnmodifiableMapCursor<Node, Node> cursor = duplicates.getEntries();
    ResolvedJavaMethod inlineeRoot = null;
    while (cursor.advance()) {
        Node value = cursor.getValue();
        if (!newNodes.contains(value)) {
            continue;
        }
        if (isSubstitution && invokePos == null) {
            // There's no caller information so the source position for this node will be
            // invalid, so it should be cleared.
            value.clearNodeSourcePosition();
        } else {
            NodeSourcePosition pos = cursor.getKey().getNodeSourcePosition();
            if (pos != null) {
                if (inlineeRoot == null) {
                    assert (inlineeRoot = pos.getRootMethod()) != null;
                } else {
                    assert pos.verifyRootMethod(inlineeRoot);
                }
                NodeSourcePosition callerPos = posMap.get(pos);
                if (callerPos == null) {
                    callerPos = pos.addCaller(invokePos, isSubstitution);
                    posMap.put(pos, callerPos);
                }
                value.setNodeSourcePosition(callerPos);
            } else {
                if (isSubstitution) {
                    /*
                         * If no other position is provided at least attribute the substituted node
                         * to the original invoke.
                         */
                    value.setNodeSourcePosition(invokePos);
                }
            }
        }
    }
    assert invokeGraph.verifySourcePositions();
}
Also used : AbstractMergeNode(org.graalvm.compiler.nodes.AbstractMergeNode) BeginNode(org.graalvm.compiler.nodes.BeginNode) MonitorIdNode(org.graalvm.compiler.nodes.java.MonitorIdNode) MethodCallTargetNode(org.graalvm.compiler.nodes.java.MethodCallTargetNode) ReturnNode(org.graalvm.compiler.nodes.ReturnNode) CallTargetNode(org.graalvm.compiler.nodes.CallTargetNode) AbstractBeginNode(org.graalvm.compiler.nodes.AbstractBeginNode) FixedGuardNode(org.graalvm.compiler.nodes.FixedGuardNode) PiNode(org.graalvm.compiler.nodes.PiNode) LogicNode(org.graalvm.compiler.nodes.LogicNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) MonitorExitNode(org.graalvm.compiler.nodes.java.MonitorExitNode) IsNullNode(org.graalvm.compiler.nodes.calc.IsNullNode) GuardingNode(org.graalvm.compiler.nodes.extended.GuardingNode) KillingBeginNode(org.graalvm.compiler.nodes.KillingBeginNode) StartNode(org.graalvm.compiler.nodes.StartNode) InvokeWithExceptionNode(org.graalvm.compiler.nodes.InvokeWithExceptionNode) ExceptionObjectNode(org.graalvm.compiler.nodes.java.ExceptionObjectNode) InvokeNode(org.graalvm.compiler.nodes.InvokeNode) ParameterNode(org.graalvm.compiler.nodes.ParameterNode) MergeNode(org.graalvm.compiler.nodes.MergeNode) DeoptimizeNode(org.graalvm.compiler.nodes.DeoptimizeNode) FixedNode(org.graalvm.compiler.nodes.FixedNode) AbstractEndNode(org.graalvm.compiler.nodes.AbstractEndNode) UnwindNode(org.graalvm.compiler.nodes.UnwindNode) Node(org.graalvm.compiler.graph.Node) EndNode(org.graalvm.compiler.nodes.EndNode) ForeignCallNode(org.graalvm.compiler.nodes.extended.ForeignCallNode) FixedWithNextNode(org.graalvm.compiler.nodes.FixedWithNextNode) PhiNode(org.graalvm.compiler.nodes.PhiNode) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod) NodeSourcePosition(org.graalvm.compiler.graph.NodeSourcePosition)

Aggregations

NodeSourcePosition (org.graalvm.compiler.graph.NodeSourcePosition)18 ArrayList (java.util.ArrayList)6 ValueNode (org.graalvm.compiler.nodes.ValueNode)5 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)4 FixedNode (org.graalvm.compiler.nodes.FixedNode)4 Node (org.graalvm.compiler.graph.Node)3 AbstractBeginNode (org.graalvm.compiler.nodes.AbstractBeginNode)3 AbstractMergeNode (org.graalvm.compiler.nodes.AbstractMergeNode)3 FixedWithNextNode (org.graalvm.compiler.nodes.FixedWithNextNode)3 PhiNode (org.graalvm.compiler.nodes.PhiNode)3 AnalysisField (com.oracle.graal.pointsto.meta.AnalysisField)2 AnalysisType (com.oracle.graal.pointsto.meta.AnalysisType)2 CallTargetNode (org.graalvm.compiler.nodes.CallTargetNode)2 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)2 DeoptimizeNode (org.graalvm.compiler.nodes.DeoptimizeNode)2 LoopBeginNode (org.graalvm.compiler.nodes.LoopBeginNode)2 LoadIndexedNode (org.graalvm.compiler.nodes.java.LoadIndexedNode)2 MethodCallTargetNode (org.graalvm.compiler.nodes.java.MethodCallTargetNode)2 BigBang (com.oracle.graal.pointsto.BigBang)1 ActualReturnTypeFlow (com.oracle.graal.pointsto.flow.ActualReturnTypeFlow)1