Search in sources :

Example 1 with VerificationError

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

the class VerifyFrameDoesNotEscapePhase method run.

@Override
protected void run(StructuredGraph graph) {
    for (NewFrameNode virtualFrame : graph.getNodes(NewFrameNode.TYPE)) {
        for (MethodCallTargetNode callTarget : virtualFrame.usages().filter(MethodCallTargetNode.class)) {
            if (callTarget.invoke() != null) {
                String properties = callTarget.getDebugProperties().toString();
                String arguments = callTarget.arguments().toString();
                Throwable exception = new VerificationError("Frame escapes at: %s#%s\nproperties:%s\narguments: %s", callTarget, callTarget.targetMethod(), properties, arguments);
                throw GraphUtil.approxSourceException(callTarget, exception);
            }
        }
    }
}
Also used : NewFrameNode(org.graalvm.compiler.truffle.compiler.nodes.frame.NewFrameNode) MethodCallTargetNode(org.graalvm.compiler.nodes.java.MethodCallTargetNode) VerificationError(org.graalvm.compiler.graph.VerificationError)

Example 2 with VerificationError

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

the class EnsureVirtualizedNode method virtualize.

@Override
public void virtualize(VirtualizerTool tool) {
    ValueNode alias = tool.getAlias(object);
    if (alias instanceof VirtualObjectNode) {
        VirtualObjectNode virtual = (VirtualObjectNode) alias;
        if (virtual instanceof VirtualBoxingNode) {
            Throwable exception = new VerificationError("ensureVirtual is not valid for boxing objects: %s", virtual.type().getName());
            throw GraphUtil.approxSourceException(this, exception);
        }
        if (!localOnly) {
            tool.setEnsureVirtualized(virtual, true);
        }
        tool.delete();
    }
}
Also used : VerificationError(org.graalvm.compiler.graph.VerificationError) ValueNode(org.graalvm.compiler.nodes.ValueNode)

Example 3 with VerificationError

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

the class NodeCostUtil method phaseFulfillsSizeContract.

public static void phaseFulfillsSizeContract(StructuredGraph graph, int codeSizeBefore, int codeSizeAfter, PhaseSizeContract contract) {
    sizeVerificationCount.increment(graph.getDebug());
    final double codeSizeIncrease = contract.codeSizeIncrease();
    final double graphSizeDelta = codeSizeBefore * DELTA;
    if (deltaCompare(codeSizeAfter, codeSizeBefore * codeSizeIncrease, graphSizeDelta) > 0) {
        ResolvedJavaMethod method = graph.method();
        double increase = (double) codeSizeAfter / (double) codeSizeBefore;
        throw new VerificationError("Phase %s expects to increase code size by at most a factor of %.2f but an increase of %.2f was seen (code size before: %d, after: %d)%s", contract.contractorName(), codeSizeIncrease, increase, codeSizeBefore, codeSizeAfter, method != null ? " when compiling method " + method.format("%H.%n(%p)") + "." : ".");
    }
}
Also used : VerificationError(org.graalvm.compiler.graph.VerificationError) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 4 with VerificationError

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

the class EnsureVirtualizedNode method ensureVirtualFailure.

public static void ensureVirtualFailure(Node location, Stamp stamp) {
    String additionalReason = "";
    if (location instanceof FixedWithNextNode && !(location instanceof EnsureVirtualizedNode)) {
        FixedWithNextNode fixedWithNextNode = (FixedWithNextNode) location;
        FixedNode next = fixedWithNextNode.next();
        if (next instanceof StoreFieldNode) {
            additionalReason = " (must not store virtual object into a field)";
        } else if (next instanceof Invoke) {
            additionalReason = " (must not pass virtual object into an invoke that cannot be inlined)";
        } else {
            additionalReason = " (must not let virtual object escape at node " + next + ")";
        }
    }
    Throwable exception = new VerificationError("Object of type %s should not be materialized%s:", StampTool.typeOrNull(stamp).getName(), additionalReason);
    Node pos;
    if (location instanceof FixedWithNextNode) {
        pos = ((FixedWithNextNode) location).next();
    } else if (location instanceof AbstractEndNode) {
        pos = ((AbstractEndNode) location).merge();
    } else {
        pos = location;
    }
    throw GraphUtil.approxSourceException(pos, exception);
}
Also used : FixedWithNextNode(org.graalvm.compiler.nodes.FixedWithNextNode) StoreFieldNode(org.graalvm.compiler.nodes.java.StoreFieldNode) VerificationError(org.graalvm.compiler.graph.VerificationError) FixedNode(org.graalvm.compiler.nodes.FixedNode) AbstractEndNode(org.graalvm.compiler.nodes.AbstractEndNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) StoreFieldNode(org.graalvm.compiler.nodes.java.StoreFieldNode) Node(org.graalvm.compiler.graph.Node) FixedWithNextNode(org.graalvm.compiler.nodes.FixedWithNextNode) AbstractEndNode(org.graalvm.compiler.nodes.AbstractEndNode) FixedNode(org.graalvm.compiler.nodes.FixedNode) Invoke(org.graalvm.compiler.nodes.Invoke)

Aggregations

VerificationError (org.graalvm.compiler.graph.VerificationError)4 ValueNode (org.graalvm.compiler.nodes.ValueNode)2 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)1 Node (org.graalvm.compiler.graph.Node)1 AbstractEndNode (org.graalvm.compiler.nodes.AbstractEndNode)1 FixedNode (org.graalvm.compiler.nodes.FixedNode)1 FixedWithNextNode (org.graalvm.compiler.nodes.FixedWithNextNode)1 Invoke (org.graalvm.compiler.nodes.Invoke)1 MethodCallTargetNode (org.graalvm.compiler.nodes.java.MethodCallTargetNode)1 StoreFieldNode (org.graalvm.compiler.nodes.java.StoreFieldNode)1 NewFrameNode (org.graalvm.compiler.truffle.compiler.nodes.frame.NewFrameNode)1