Search in sources :

Example 1 with GraalGraphError

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

the class HotSpotDebugInfoBuilder method raiseInvalidFrameStateError.

protected void raiseInvalidFrameStateError(FrameState state) throws GraalGraphError {
    // This is a hard error since an incorrect state could crash hotspot
    NodeSourcePosition sourcePosition = state.getNodeSourcePosition();
    List<String> context = new ArrayList<>();
    ResolvedJavaMethod replacementMethodWithProblematicSideEffect = null;
    if (sourcePosition != null) {
        NodeSourcePosition pos = sourcePosition;
        while (pos != null) {
            StringBuilder sb = new StringBuilder("parsing ");
            ResolvedJavaMethod method = pos.getMethod();
            MetaUtil.appendLocation(sb, method, pos.getBCI());
            if (method.getAnnotation(MethodSubstitution.class) != null || method.getAnnotation(Snippet.class) != null) {
                replacementMethodWithProblematicSideEffect = method;
            }
            context.add(sb.toString());
            pos = pos.getCaller();
        }
    }
    String message = "Invalid frame state " + state;
    if (replacementMethodWithProblematicSideEffect != null) {
        message += " associated with a side effect in " + replacementMethodWithProblematicSideEffect.format("%H.%n(%p)") + " at a position that cannot be deoptimized to";
    }
    GraalGraphError error = new GraalGraphError(message);
    for (String c : context) {
        error.addContext(c);
    }
    throw error;
}
Also used : GraalGraphError(org.graalvm.compiler.graph.GraalGraphError) ArrayList(java.util.ArrayList) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod) NodeSourcePosition(org.graalvm.compiler.graph.NodeSourcePosition)

Example 2 with GraalGraphError

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

the class NodeLIRBuilder method doBlock.

@Override
@SuppressWarnings("try")
public void doBlock(Block block, StructuredGraph graph, BlockMap<List<Node>> blockMap) {
    OptionValues options = graph.getOptions();
    try (BlockScope blockScope = gen.getBlockScope(block)) {
        setSourcePosition(null);
        if (block == gen.getResult().getLIR().getControlFlowGraph().getStartBlock()) {
            assert block.getPredecessorCount() == 0;
            emitPrologue(graph);
        } else {
            assert block.getPredecessorCount() > 0;
            // create phi-in value array
            AbstractBeginNode begin = block.getBeginNode();
            if (begin instanceof AbstractMergeNode) {
                AbstractMergeNode merge = (AbstractMergeNode) begin;
                LabelOp label = (LabelOp) gen.getResult().getLIR().getLIRforBlock(block).get(0);
                label.setPhiValues(createPhiIn(merge));
                if (Options.PrintIRWithLIR.getValue(options) && !TTY.isSuppressed()) {
                    TTY.println("Created PhiIn: " + label);
                }
            }
        }
        doBlockPrologue(block, options);
        List<Node> nodes = blockMap.get(block);
        // Allow NodeLIRBuilder subclass to specialize code generation of any interesting groups
        // of instructions
        matchComplexExpressions(nodes);
        boolean trace = traceLIRGeneratorLevel >= 3;
        for (int i = 0; i < nodes.size(); i++) {
            Node node = nodes.get(i);
            if (node instanceof ValueNode) {
                DebugContext debug = node.getDebug();
                ValueNode valueNode = (ValueNode) node;
                if (trace) {
                    TTY.println("LIRGen for " + valueNode);
                }
                Value operand = getOperand(valueNode);
                if (operand == null) {
                    if (!peephole(valueNode)) {
                        try {
                            doRoot(valueNode);
                        } catch (GraalError e) {
                            throw GraalGraphError.transformAndAddContext(e, valueNode);
                        } catch (Throwable e) {
                            throw new GraalGraphError(e).addContext(valueNode);
                        }
                    }
                } else if (ComplexMatchValue.INTERIOR_MATCH.equals(operand)) {
                    // Doesn't need to be evaluated
                    debug.log("interior match for %s", valueNode);
                } else if (operand instanceof ComplexMatchValue) {
                    debug.log("complex match for %s", valueNode);
                    ComplexMatchValue match = (ComplexMatchValue) operand;
                    operand = match.evaluate(this);
                    if (operand != null) {
                        setResult(valueNode, operand);
                    }
                } else {
                // There can be cases in which the result of an instruction is already set
                // before by other instructions.
                }
            }
        }
        if (!gen.hasBlockEnd(block)) {
            NodeIterable<Node> successors = block.getEndNode().successors();
            assert successors.count() == block.getSuccessorCount();
            if (block.getSuccessorCount() != 1) {
                /*
                     * If we have more than one successor, we cannot just use the first one. Since
                     * successors are unordered, this would be a random choice.
                     */
                throw new GraalError("Block without BlockEndOp: " + block.getEndNode());
            }
            gen.emitJump(getLIRBlock((FixedNode) successors.first()));
        }
        assert verifyBlock(gen.getResult().getLIR(), block);
    }
}
Also used : LabelOp(org.graalvm.compiler.lir.StandardOp.LabelOp) OptionValues(org.graalvm.compiler.options.OptionValues) ValuePhiNode(org.graalvm.compiler.nodes.ValuePhiNode) AbstractMergeNode(org.graalvm.compiler.nodes.AbstractMergeNode) IfNode(org.graalvm.compiler.nodes.IfNode) VirtualObjectNode(org.graalvm.compiler.nodes.virtual.VirtualObjectNode) AbstractBeginNode(org.graalvm.compiler.nodes.AbstractBeginNode) DeoptimizingNode(org.graalvm.compiler.nodes.DeoptimizingNode) LogicNode(org.graalvm.compiler.nodes.LogicNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) DirectCallTargetNode(org.graalvm.compiler.nodes.DirectCallTargetNode) IsNullNode(org.graalvm.compiler.nodes.calc.IsNullNode) IntegerTestNode(org.graalvm.compiler.nodes.calc.IntegerTestNode) FullInfopointNode(org.graalvm.compiler.nodes.FullInfopointNode) CompareNode(org.graalvm.compiler.nodes.calc.CompareNode) IntegerSwitchNode(org.graalvm.compiler.nodes.extended.IntegerSwitchNode) LogicConstantNode(org.graalvm.compiler.nodes.LogicConstantNode) ConstantNode(org.graalvm.compiler.nodes.ConstantNode) InvokeWithExceptionNode(org.graalvm.compiler.nodes.InvokeWithExceptionNode) SwitchNode(org.graalvm.compiler.nodes.extended.SwitchNode) LoweredCallTargetNode(org.graalvm.compiler.nodes.LoweredCallTargetNode) ParameterNode(org.graalvm.compiler.nodes.ParameterNode) ConditionalNode(org.graalvm.compiler.nodes.calc.ConditionalNode) FixedNode(org.graalvm.compiler.nodes.FixedNode) IndirectCallTargetNode(org.graalvm.compiler.nodes.IndirectCallTargetNode) AbstractEndNode(org.graalvm.compiler.nodes.AbstractEndNode) LoopEndNode(org.graalvm.compiler.nodes.LoopEndNode) Node(org.graalvm.compiler.graph.Node) PhiNode(org.graalvm.compiler.nodes.PhiNode) AbstractMergeNode(org.graalvm.compiler.nodes.AbstractMergeNode) LIRGenerationDebugContext(org.graalvm.compiler.lir.debug.LIRGenerationDebugContext) DebugContext(org.graalvm.compiler.debug.DebugContext) FixedNode(org.graalvm.compiler.nodes.FixedNode) ComplexMatchValue(org.graalvm.compiler.core.match.ComplexMatchValue) AbstractBeginNode(org.graalvm.compiler.nodes.AbstractBeginNode) GraalError(org.graalvm.compiler.debug.GraalError) BlockScope(org.graalvm.compiler.lir.gen.LIRGeneratorTool.BlockScope) GraalGraphError(org.graalvm.compiler.graph.GraalGraphError) ValueNode(org.graalvm.compiler.nodes.ValueNode) ComplexMatchValue(org.graalvm.compiler.core.match.ComplexMatchValue) Value(jdk.vm.ci.meta.Value) AllocatableValue(jdk.vm.ci.meta.AllocatableValue)

Aggregations

GraalGraphError (org.graalvm.compiler.graph.GraalGraphError)2 ArrayList (java.util.ArrayList)1 AllocatableValue (jdk.vm.ci.meta.AllocatableValue)1 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)1 Value (jdk.vm.ci.meta.Value)1 ComplexMatchValue (org.graalvm.compiler.core.match.ComplexMatchValue)1 DebugContext (org.graalvm.compiler.debug.DebugContext)1 GraalError (org.graalvm.compiler.debug.GraalError)1 Node (org.graalvm.compiler.graph.Node)1 NodeSourcePosition (org.graalvm.compiler.graph.NodeSourcePosition)1 LabelOp (org.graalvm.compiler.lir.StandardOp.LabelOp)1 LIRGenerationDebugContext (org.graalvm.compiler.lir.debug.LIRGenerationDebugContext)1 BlockScope (org.graalvm.compiler.lir.gen.LIRGeneratorTool.BlockScope)1 AbstractBeginNode (org.graalvm.compiler.nodes.AbstractBeginNode)1 AbstractEndNode (org.graalvm.compiler.nodes.AbstractEndNode)1 AbstractMergeNode (org.graalvm.compiler.nodes.AbstractMergeNode)1 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)1 DeoptimizingNode (org.graalvm.compiler.nodes.DeoptimizingNode)1 DirectCallTargetNode (org.graalvm.compiler.nodes.DirectCallTargetNode)1 FixedNode (org.graalvm.compiler.nodes.FixedNode)1