Search in sources :

Example 6 with NodeSourcePosition

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

the class PointsToStats method reportPrunedTypeFlows.

private static void reportPrunedTypeFlows(BufferedWriter out) {
    doWrite(out, String.format("%-35s\n", "Summary"));
    doWrite(out, String.format("%-35s\t%-10s\n", "Type Flow Class", "Removed Count"));
    typeFlowBuilders.stream().filter(Objects::nonNull).filter(b -> !b.isMaterialized()).collect(Collectors.groupingBy(TypeFlowBuilder::getFlowClass)).forEach((flowClass, providers) -> {
        doWrite(out, String.format("%-35s\t%-10d\n", flowClass.getSimpleName(), providers.size()));
    });
    doWrite(out, String.format("\n%-35s\n", "Removed flows"));
    doWrite(out, String.format("%-35s\t%-10s\n", "Type Flow Class", "Location"));
    typeFlowBuilders.stream().filter(Objects::nonNull).filter(b -> !b.isMaterialized()).forEach((provider) -> {
        Object source = provider.getSource();
        String sourceStr;
        if (source instanceof ValueNode) {
            ValueNode value = (ValueNode) source;
            NodeSourcePosition srcPosition = value.getNodeSourcePosition();
            if (srcPosition != null) {
                sourceStr = srcPosition.toString();
            } else {
                sourceStr = value.toString() + " @ " + value.graph().method().format("%H.%n(%p)");
            }
        } else {
            sourceStr = source.toString();
        }
        doWrite(out, String.format("%-35s\t%-10s\n", provider.getFlowClass().getSimpleName(), sourceStr));
    });
}
Also used : UnknownTypeFlow(com.oracle.graal.pointsto.flow.UnknownTypeFlow) FilterTypeFlow(com.oracle.graal.pointsto.flow.FilterTypeFlow) AllInstantiatedTypeFlow(com.oracle.graal.pointsto.flow.AllInstantiatedTypeFlow) JavaWriteTypeFlow(com.oracle.graal.pointsto.flow.OffsetStoreTypeFlow.JavaWriteTypeFlow) StoreStaticFieldTypeFlow(com.oracle.graal.pointsto.flow.StoreFieldTypeFlow.StoreStaticFieldTypeFlow) StoreInstanceFieldTypeFlow(com.oracle.graal.pointsto.flow.StoreFieldTypeFlow.StoreInstanceFieldTypeFlow) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) StoreIndexedTypeFlow(com.oracle.graal.pointsto.flow.OffsetStoreTypeFlow.StoreIndexedTypeFlow) BigBang(com.oracle.graal.pointsto.BigBang) UnsafePartitionLoadTypeFlow(com.oracle.graal.pointsto.flow.OffsetLoadTypeFlow.UnsafePartitionLoadTypeFlow) Path(java.nio.file.Path) NodeSourcePosition(org.graalvm.compiler.graph.NodeSourcePosition) LoadIndexedTypeFlow(com.oracle.graal.pointsto.flow.OffsetLoadTypeFlow.LoadIndexedTypeFlow) InitialParamTypeFlow(com.oracle.graal.pointsto.flow.InitialParamTypeFlow) LoadStaticFieldTypeFlow(com.oracle.graal.pointsto.flow.LoadFieldTypeFlow.LoadStaticFieldTypeFlow) UnsafeLoadTypeFlow(com.oracle.graal.pointsto.flow.OffsetLoadTypeFlow.UnsafeLoadTypeFlow) FormalParamTypeFlow(com.oracle.graal.pointsto.flow.FormalParamTypeFlow) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) FieldSinkTypeFlow(com.oracle.graal.pointsto.flow.FieldSinkTypeFlow) AnalysisField(com.oracle.graal.pointsto.meta.AnalysisField) Collectors(java.util.stream.Collectors) AnalysisType(com.oracle.graal.pointsto.meta.AnalysisType) Objects(java.util.Objects) ValueNode(org.graalvm.compiler.nodes.ValueNode) JavaType(jdk.vm.ci.meta.JavaType) List(java.util.List) MergeTypeFlow(com.oracle.graal.pointsto.flow.MergeTypeFlow) FieldTypeFlow(com.oracle.graal.pointsto.flow.FieldTypeFlow) Entry(java.util.Map.Entry) AtomicReadTypeFlow(com.oracle.graal.pointsto.flow.OffsetLoadTypeFlow.AtomicReadTypeFlow) CompareAndSwapTypeFlow(com.oracle.graal.pointsto.flow.OffsetStoreTypeFlow.CompareAndSwapTypeFlow) LocalDateTime(java.time.LocalDateTime) InstanceOfTypeFlow(com.oracle.graal.pointsto.flow.InstanceOfTypeFlow) AllSynchronizedTypeFlow(com.oracle.graal.pointsto.flow.AllSynchronizedTypeFlow) Function(java.util.function.Function) ArrayList(java.util.ArrayList) TypeFlowBuilder(com.oracle.graal.pointsto.flow.builder.TypeFlowBuilder) DynamicNewInstanceTypeFlow(com.oracle.graal.pointsto.flow.DynamicNewInstanceTypeFlow) MonitorEnterTypeFlow(com.oracle.graal.pointsto.flow.MonitorEnterTypeFlow) AtomicWriteTypeFlow(com.oracle.graal.pointsto.flow.OffsetStoreTypeFlow.AtomicWriteTypeFlow) ActualReturnTypeFlow(com.oracle.graal.pointsto.flow.ActualReturnTypeFlow) LoadInstanceFieldTypeFlow(com.oracle.graal.pointsto.flow.LoadFieldTypeFlow.LoadInstanceFieldTypeFlow) CloneTypeFlow(com.oracle.graal.pointsto.flow.CloneTypeFlow) InvokeTypeFlow(com.oracle.graal.pointsto.flow.InvokeTypeFlow) JVMCIError(jdk.vm.ci.common.JVMCIError) SourceTypeFlow(com.oracle.graal.pointsto.flow.SourceTypeFlow) Files(java.nio.file.Files) BufferedWriter(java.io.BufferedWriter) FieldFilterTypeFlow(com.oracle.graal.pointsto.flow.FieldFilterTypeFlow) JavaReadTypeFlow(com.oracle.graal.pointsto.flow.OffsetLoadTypeFlow.JavaReadTypeFlow) FileWriter(java.io.FileWriter) FormalReturnTypeFlow(com.oracle.graal.pointsto.flow.FormalReturnTypeFlow) IOException(java.io.IOException) UnsafePartitionStoreTypeFlow(com.oracle.graal.pointsto.flow.OffsetStoreTypeFlow.UnsafePartitionStoreTypeFlow) UnsafeWriteSinkTypeFlow(com.oracle.graal.pointsto.flow.UnsafeWriteSinkTypeFlow) Consumer(java.util.function.Consumer) NewInstanceTypeFlow(com.oracle.graal.pointsto.flow.NewInstanceTypeFlow) NullCheckTypeFlow(com.oracle.graal.pointsto.flow.NullCheckTypeFlow) DateTimeFormatter(java.time.format.DateTimeFormatter) FrozenFieldFilterTypeFlow(com.oracle.graal.pointsto.flow.FrozenFieldFilterTypeFlow) UnsafeStoreTypeFlow(com.oracle.graal.pointsto.flow.OffsetStoreTypeFlow.UnsafeStoreTypeFlow) TypeFlow(com.oracle.graal.pointsto.flow.TypeFlow) ArrayElementsTypeFlow(com.oracle.graal.pointsto.flow.ArrayElementsTypeFlow) Comparator(java.util.Comparator) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod) FileSystems(java.nio.file.FileSystems) TypeFlowBuilder(com.oracle.graal.pointsto.flow.builder.TypeFlowBuilder) Objects(java.util.Objects) ValueNode(org.graalvm.compiler.nodes.ValueNode) NodeSourcePosition(org.graalvm.compiler.graph.NodeSourcePosition)

Example 7 with NodeSourcePosition

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

the class DeoptimizationSourcePositionEncoder method verifyEncoding.

private boolean verifyEncoding(List<NodeSourcePosition> deoptimzationSourcePositions) {
    for (int i = 0; i < deoptimzationSourcePositions.size(); i++) {
        NodeSourcePosition originalSourcePosition = deoptimzationSourcePositions.get(i);
        NodeSourcePosition decodedSourcePosition = DeoptimizationSourcePositionDecoder.decode(i, deoptimizationStartOffsets, deoptimizationEncodings, deoptimizationObjectConstants);
        verifySourcePosition(originalSourcePosition, decodedSourcePosition);
    }
    return true;
}
Also used : NodeSourcePosition(org.graalvm.compiler.graph.NodeSourcePosition)

Example 8 with NodeSourcePosition

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

the class DeoptimizationSourcePositionEncoder method encodeSourcePositions.

private void encodeSourcePositions(List<NodeSourcePosition> deoptimzationSourcePositions, EconomicMap<NodeSourcePosition, Long> sourcePositionStartOffsets, UnsafeArrayTypeWriter encodingBuffer) {
    for (int i = 0; i < deoptimzationSourcePositions.size(); i++) {
        NodeSourcePosition sourcePosition = deoptimzationSourcePositions.get(i);
        int startOffset;
        if (sourcePosition == null) {
            startOffset = DeoptimizationSourcePositionDecoder.NO_SOURCE_POSITION;
        } else {
            startOffset = TypeConversion.asS4(encodeSourcePositions(sourcePosition, sourcePositionStartOffsets, encodingBuffer));
            assert startOffset > DeoptimizationSourcePositionDecoder.NO_SOURCE_POSITION;
        }
        deoptimizationStartOffsets[i] = startOffset;
    }
}
Also used : NodeSourcePosition(org.graalvm.compiler.graph.NodeSourcePosition)

Example 9 with NodeSourcePosition

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

the class DeoptimizationSourcePositionEncoder method encode.

public void encode(List<NodeSourcePosition> deoptimzationSourcePositions) {
    addObjectConstants(deoptimzationSourcePositions);
    deoptimizationObjectConstants = objectConstants.encodeAll(newObjectArray(objectConstants.getLength()));
    UnsafeArrayTypeWriter encodingBuffer = UnsafeArrayTypeWriter.create(ByteArrayReader.supportsUnalignedMemoryAccess());
    EconomicMap<NodeSourcePosition, Long> sourcePositionStartOffsets = EconomicMap.create(Equivalence.IDENTITY_WITH_SYSTEM_HASHCODE);
    deoptimizationStartOffsets = newIntArray(deoptimzationSourcePositions.size());
    encodeSourcePositions(deoptimzationSourcePositions, sourcePositionStartOffsets, encodingBuffer);
    deoptimizationEncodings = encodingBuffer.toArray(newByteArray(TypeConversion.asS4(encodingBuffer.getBytesWritten())));
    verifyEncoding(deoptimzationSourcePositions);
}
Also used : UnsafeArrayTypeWriter(org.graalvm.compiler.core.common.util.UnsafeArrayTypeWriter) NodeSourcePosition(org.graalvm.compiler.graph.NodeSourcePosition)

Example 10 with NodeSourcePosition

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

the class PEGraphDecoder method handleInvoke.

@Override
protected LoopScope handleInvoke(MethodScope s, LoopScope loopScope, InvokeData invokeData) {
    PEMethodScope methodScope = (PEMethodScope) s;
    /*
         * Decode the call target, but do not add it to the graph yet. This avoids adding usages for
         * all the arguments, which are expensive to remove again when we can inline the method.
         */
    assert invokeData.invoke.callTarget() == null : "callTarget edge is ignored during decoding of Invoke";
    CallTargetNode callTarget = (CallTargetNode) decodeFloatingNode(methodScope, loopScope, invokeData.callTargetOrderId);
    if (callTarget instanceof MethodCallTargetNode) {
        MethodCallTargetNode methodCall = (MethodCallTargetNode) callTarget;
        if (methodCall.invokeKind().hasReceiver()) {
            invokeData.constantReceiver = methodCall.arguments().get(0).asJavaConstant();
            NodeSourcePosition invokePosition = invokeData.invoke.asNode().getNodeSourcePosition();
            if (invokeData.constantReceiver != null && invokePosition != null) {
            // new NodeSourcePosition(invokeData.constantReceiver,
            // invokePosition.getCaller(), invokePosition.getMethod(),
            // invokePosition.getBCI());
            }
        }
        LoopScope inlineLoopScope = trySimplifyInvoke(methodScope, loopScope, invokeData, (MethodCallTargetNode) callTarget);
        if (inlineLoopScope != null) {
            return inlineLoopScope;
        }
    }
    /* We know that we need an invoke, so now we can add the call target to the graph. */
    graph.add(callTarget);
    registerNode(loopScope, invokeData.callTargetOrderId, callTarget, false, false);
    return super.handleInvoke(methodScope, loopScope, invokeData);
}
Also used : MethodCallTargetNode(org.graalvm.compiler.nodes.java.MethodCallTargetNode) MethodCallTargetNode(org.graalvm.compiler.nodes.java.MethodCallTargetNode) CallTargetNode(org.graalvm.compiler.nodes.CallTargetNode) 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