Search in sources :

Example 11 with NodeSourcePosition

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

the class FrameStateBuilder method createBytecodePosition.

public NodeSourcePosition createBytecodePosition(int bci) {
    BytecodeParser parent = parser.getParent();
    NodeSourcePosition position = create(bci, parent);
    return position;
}
Also used : NodeSourcePosition(org.graalvm.compiler.graph.NodeSourcePosition)

Example 12 with NodeSourcePosition

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

the class CollectDeoptimizationSourcePositionsPhase method run.

@Override
protected void run(StructuredGraph graph) {
    List<NodeSourcePosition> deoptimzationSourcePositions = new ArrayList<>();
    /*
         * The debugId 0 is reserved for "unknown" to avoid any possible confusion with an
         * uninitialized debugId.
         */
    deoptimzationSourcePositions.add(null);
    for (DeoptimizeNode node : graph.getNodes(DeoptimizeNode.TYPE)) {
        node.setDebugId(deoptimzationSourcePositions.size());
        deoptimzationSourcePositions.add(node.getNodeSourcePosition());
    }
    assert graph.getNodes(DynamicDeoptimizeNode.TYPE).isEmpty() : "must collect NodeSourcePosition before DeoptimizationGroupingPhase";
    graph.addAfterFixed(graph.start(), graph.add(new DeoptSourcePositionInfoNode(deoptimzationSourcePositions)));
}
Also used : ArrayList(java.util.ArrayList) DeoptimizeNode(org.graalvm.compiler.nodes.DeoptimizeNode) DynamicDeoptimizeNode(org.graalvm.compiler.nodes.DynamicDeoptimizeNode) NodeSourcePosition(org.graalvm.compiler.graph.NodeSourcePosition) DeoptSourcePositionInfoNode(com.oracle.svm.core.graal.nodes.DeoptSourcePositionInfoNode)

Example 13 with NodeSourcePosition

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

the class HotSpotCompiledCodeBuilder method getSortedSites.

/**
 * HotSpot expects sites to be presented in ascending order of PC (see
 * {@code DebugInformationRecorder::add_new_pc_offset}). In addition, it expects
 * {@link Infopoint} PCs to be unique.
 */
private static Site[] getSortedSites(CodeCacheProvider codeCache, CompilationResult target) {
    List<Site> sites = new ArrayList<>(target.getExceptionHandlers().size() + target.getInfopoints().size() + target.getDataPatches().size() + target.getMarks().size() + target.getSourceMappings().size());
    sites.addAll(target.getExceptionHandlers());
    sites.addAll(target.getInfopoints());
    sites.addAll(target.getDataPatches());
    sites.addAll(target.getMarks());
    if (codeCache.shouldDebugNonSafepoints()) {
        /*
             * Translate the source mapping into appropriate info points. In HotSpot only one
             * position can really be represented and recording the end PC seems to give the best
             * results and corresponds with what C1 and C2 do. HotSpot doesn't like to see these
             * unless -XX:+DebugNonSafepoints is enabled, so don't emit them in that case.
             */
        List<Site> sourcePositionSites = new ArrayList<>();
        for (SourceMapping source : target.getSourceMappings()) {
            NodeSourcePosition sourcePosition = source.getSourcePosition();
            if (sourcePosition.isPlaceholder() || sourcePosition.isSubstitution()) {
                // HotSpot doesn't understand any of the special positions so just drop them.
                continue;
            }
            assert sourcePosition.verify();
            sourcePosition = sourcePosition.trim();
            /*
                 * Don't add BYTECODE_POSITION info points that would potentially create conflicts.
                 * Under certain conditions the site's pc is not the pc that gets recorded by
                 * HotSpot (see @code {CodeInstaller::site_Call}). So, avoid adding any source
                 * positions that can potentially map to the same pc. To do that make sure that the
                 * source mapping doesn't contain a pc of any important Site.
                 */
            if (sourcePosition != null && !anyMatch(sites, s -> source.contains(s.pcOffset))) {
                sourcePositionSites.add(new Infopoint(source.getEndOffset(), new DebugInfo(sourcePosition), InfopointReason.BYTECODE_POSITION));
            }
        }
        sites.addAll(sourcePositionSites);
    }
    SiteComparator c = new SiteComparator();
    Collections.sort(sites, c);
    if (c.sawCollidingInfopoints) {
        Infopoint lastInfopoint = null;
        List<Site> copy = new ArrayList<>(sites.size());
        for (Site site : sites) {
            if (site instanceof Infopoint) {
                Infopoint info = (Infopoint) site;
                if (lastInfopoint == null || lastInfopoint.pcOffset != info.pcOffset) {
                    lastInfopoint = info;
                    copy.add(info);
                } else {
                    // Omit this colliding infopoint
                    assert lastInfopoint.reason.compareTo(info.reason) <= 0;
                }
            } else {
                copy.add(site);
            }
        }
        sites = copy;
    }
    return sites.toArray(new Site[sites.size()]);
}
Also used : Site(jdk.vm.ci.code.site.Site) ArrayList(java.util.ArrayList) Infopoint(jdk.vm.ci.code.site.Infopoint) SourceMapping(org.graalvm.compiler.code.SourceMapping) DebugInfo(jdk.vm.ci.code.DebugInfo) NodeSourcePosition(org.graalvm.compiler.graph.NodeSourcePosition)

Example 14 with NodeSourcePosition

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

the class DeoptimizationSourcePositionDecoder method decodeSourcePosition.

private static NodeSourcePosition decodeSourcePosition(long startOffset, Object[] deoptimizationObjectConstants, UnsafeArrayTypeReader readBuffer) {
    readBuffer.setByteIndex(startOffset);
    long callerRelativeOffset = readBuffer.getUV();
    int bci = readBuffer.getSVInt();
    ResolvedJavaMethod method = (ResolvedJavaMethod) deoptimizationObjectConstants[readBuffer.getUVInt()];
    NodeSourcePosition caller = null;
    if (callerRelativeOffset != NO_CALLER) {
        caller = decodeSourcePosition(startOffset - callerRelativeOffset, deoptimizationObjectConstants, readBuffer);
    }
    return new NodeSourcePosition(caller, method, bci);
}
Also used : ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod) NodeSourcePosition(org.graalvm.compiler.graph.NodeSourcePosition)

Example 15 with NodeSourcePosition

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

the class LoopDetector method readProperties.

protected void readProperties(MethodScope methodScope, Node node) {
    NodeSourcePosition position = (NodeSourcePosition) readObject(methodScope);
    Fields fields = node.getNodeClass().getData();
    for (int pos = 0; pos < fields.getCount(); pos++) {
        if (fields.getType(pos).isPrimitive()) {
            long primitive = methodScope.reader.getSV();
            fields.setRawPrimitive(node, pos, primitive);
        } else {
            Object value = readObject(methodScope);
            fields.putObject(node, pos, value);
        }
    }
    if (graph.trackNodeSourcePosition() && position != null) {
        node.setNodeSourcePosition(methodScope.getCallerBytecodePosition(position));
    }
}
Also used : Fields(org.graalvm.compiler.core.common.Fields) 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