Search in sources :

Example 6 with FloatingNode

use of org.graalvm.compiler.nodes.calc.FloatingNode in project graal by oracle.

the class IntegerExactArithmeticSplitNode method lower.

static void lower(LoweringTool tool, IntegerExactArithmeticNode node) {
    if (node.asNode().graph().getGuardsStage() == StructuredGraph.GuardsStage.FIXED_DEOPTS) {
        FloatingNode floatingNode = (FloatingNode) node;
        FixedWithNextNode previous = tool.lastFixedNode();
        FixedNode next = previous.next();
        previous.setNext(null);
        DeoptimizeNode deopt = floatingNode.graph().add(new DeoptimizeNode(DeoptimizationAction.InvalidateReprofile, DeoptimizationReason.ArithmeticException));
        AbstractBeginNode normalBegin = floatingNode.graph().add(new BeginNode());
        normalBegin.setNext(next);
        IntegerExactArithmeticSplitNode split = node.createSplit(normalBegin, BeginNode.begin(deopt));
        previous.setNext(split);
        floatingNode.replaceAndDelete(split);
    }
}
Also used : FixedWithNextNode(org.graalvm.compiler.nodes.FixedWithNextNode) AbstractBeginNode(org.graalvm.compiler.nodes.AbstractBeginNode) BeginNode(org.graalvm.compiler.nodes.BeginNode) FloatingNode(org.graalvm.compiler.nodes.calc.FloatingNode) DeoptimizeNode(org.graalvm.compiler.nodes.DeoptimizeNode) FixedNode(org.graalvm.compiler.nodes.FixedNode) AbstractBeginNode(org.graalvm.compiler.nodes.AbstractBeginNode)

Example 7 with FloatingNode

use of org.graalvm.compiler.nodes.calc.FloatingNode in project graal by oracle.

the class FrameStateBuilder method initializeForMethodStart.

public void initializeForMethodStart(Assumptions assumptions, boolean eagerResolve, Plugins plugins) {
    int javaIndex = 0;
    int index = 0;
    ResolvedJavaMethod method = getMethod();
    ResolvedJavaType originalType = method.getDeclaringClass();
    if (!method.isStatic()) {
        // add the receiver
        FloatingNode receiver = null;
        StampPair receiverStamp = null;
        if (plugins != null) {
            receiverStamp = plugins.getOverridingStamp(tool, originalType, true);
        }
        if (receiverStamp == null) {
            receiverStamp = StampFactory.forDeclaredType(assumptions, originalType, true);
        }
        if (plugins != null) {
            for (ParameterPlugin plugin : plugins.getParameterPlugins()) {
                receiver = plugin.interceptParameter(tool, index, receiverStamp);
                if (receiver != null) {
                    break;
                }
            }
        }
        if (receiver == null) {
            receiver = new ParameterNode(javaIndex, receiverStamp);
        }
        locals[javaIndex] = graph.addOrUniqueWithInputs(receiver);
        javaIndex = 1;
        index = 1;
    }
    Signature sig = method.getSignature();
    int max = sig.getParameterCount(false);
    ResolvedJavaType accessingClass = originalType;
    for (int i = 0; i < max; i++) {
        JavaType type = sig.getParameterType(i, accessingClass);
        if (eagerResolve) {
            type = type.resolve(accessingClass);
        }
        JavaKind kind = type.getJavaKind();
        StampPair stamp = null;
        if (plugins != null) {
            stamp = plugins.getOverridingStamp(tool, type, false);
        }
        if (stamp == null) {
            stamp = StampFactory.forDeclaredType(assumptions, type, false);
        }
        FloatingNode param = null;
        if (plugins != null) {
            for (ParameterPlugin plugin : plugins.getParameterPlugins()) {
                param = plugin.interceptParameter(tool, index, stamp);
                if (param != null) {
                    break;
                }
            }
        }
        if (param == null) {
            param = new ParameterNode(index, stamp);
        }
        locals[javaIndex] = graph.addOrUniqueWithInputs(param);
        javaIndex++;
        if (kind.needsTwoSlots()) {
            locals[javaIndex] = TWO_SLOT_MARKER;
            javaIndex++;
        }
        index++;
    }
}
Also used : ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType) JavaType(jdk.vm.ci.meta.JavaType) ParameterPlugin(org.graalvm.compiler.nodes.graphbuilderconf.ParameterPlugin) ParameterNode(org.graalvm.compiler.nodes.ParameterNode) Signature(jdk.vm.ci.meta.Signature) StampPair(org.graalvm.compiler.core.common.type.StampPair) FloatingNode(org.graalvm.compiler.nodes.calc.FloatingNode) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType) JavaKind(jdk.vm.ci.meta.JavaKind)

Example 8 with FloatingNode

use of org.graalvm.compiler.nodes.calc.FloatingNode in project graal by oracle.

the class DefaultHotSpotLoweringProvider method throwCachedException.

private boolean throwCachedException(BytecodeExceptionNode node) {
    Throwable exception;
    if (node.getExceptionClass() == NullPointerException.class) {
        exception = Exceptions.cachedNullPointerException;
    } else if (node.getExceptionClass() == ArrayIndexOutOfBoundsException.class) {
        exception = Exceptions.cachedArrayIndexOutOfBoundsException;
    } else {
        return false;
    }
    StructuredGraph graph = node.graph();
    FloatingNode exceptionNode = ConstantNode.forConstant(constantReflection.forObject(exception), metaAccess, graph);
    graph.replaceFixedWithFloating(node, exceptionNode);
    return true;
}
Also used : StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) FloatingNode(org.graalvm.compiler.nodes.calc.FloatingNode)

Example 9 with FloatingNode

use of org.graalvm.compiler.nodes.calc.FloatingNode in project graal by oracle.

the class ReplaceConstantNodesPhase method findFixedBeforeFloating.

/**
 * Find the first {@link FixedWithNextNode} that is currently scheduled before the given
 * floating node.
 *
 * @param graph
 * @param node start search from this node up
 * @return the first {@link FixedWithNextNode}
 */
private static FixedWithNextNode findFixedBeforeFloating(StructuredGraph graph, FloatingNode node) {
    ScheduleResult schedule = graph.getLastSchedule();
    NodeMap<Block> nodeToBlock = schedule.getNodeToBlockMap();
    Block block = nodeToBlock.get(node);
    BlockMap<List<Node>> blockToNodes = schedule.getBlockToNodesMap();
    FixedWithNextNode result = null;
    for (Node n : blockToNodes.get(block)) {
        if (n.equals(node)) {
            break;
        }
        if (n instanceof FixedWithNextNode) {
            result = (FixedWithNextNode) n;
        }
    }
    assert result != null;
    return result;
}
Also used : FixedWithNextNode(org.graalvm.compiler.nodes.FixedWithNextNode) ScheduleResult(org.graalvm.compiler.nodes.StructuredGraph.ScheduleResult) LoadMethodCountersNode(org.graalvm.compiler.hotspot.nodes.aot.LoadMethodCountersNode) AbstractMergeNode(org.graalvm.compiler.nodes.AbstractMergeNode) LoadConstantIndirectlyFixedNode(org.graalvm.compiler.hotspot.nodes.aot.LoadConstantIndirectlyFixedNode) LoadConstantIndirectlyNode(org.graalvm.compiler.hotspot.nodes.aot.LoadConstantIndirectlyNode) LoopBeginNode(org.graalvm.compiler.nodes.LoopBeginNode) ResolveDynamicConstantNode(org.graalvm.compiler.hotspot.nodes.aot.ResolveDynamicConstantNode) AbstractBeginNode(org.graalvm.compiler.nodes.AbstractBeginNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) ResolveConstantNode(org.graalvm.compiler.hotspot.nodes.aot.ResolveConstantNode) FloatingNode(org.graalvm.compiler.nodes.calc.FloatingNode) ConstantNode(org.graalvm.compiler.nodes.ConstantNode) InitializeKlassNode(org.graalvm.compiler.hotspot.nodes.aot.InitializeKlassNode) FixedNode(org.graalvm.compiler.nodes.FixedNode) ResolveMethodAndLoadCountersNode(org.graalvm.compiler.hotspot.nodes.aot.ResolveMethodAndLoadCountersNode) LoopExitNode(org.graalvm.compiler.nodes.LoopExitNode) Node(org.graalvm.compiler.graph.Node) FixedWithNextNode(org.graalvm.compiler.nodes.FixedWithNextNode) Block(org.graalvm.compiler.nodes.cfg.Block) List(java.util.List)

Example 10 with FloatingNode

use of org.graalvm.compiler.nodes.calc.FloatingNode in project graal by oracle.

the class CFGPrinter method printNode.

private void printNode(Node node, boolean unscheduled) {
    assert !printedNodes.isMarked(node);
    printedNodes.mark(node);
    if (!(node instanceof ValuePhiNode)) {
        for (Node input : node.inputs()) {
            if (!inFixedSchedule(input) && !printedNodes.isMarked(input)) {
                printNode(input, true);
            }
        }
    }
    if (unscheduled) {
        assert lir == null && schedule == null : "unscheduled nodes can only be present before LIR generation";
        out.print("f ").print(HOVER_START).print("u").print(HOVER_SEP).print("unscheduled").print(HOVER_END).println(COLUMN_END);
    } else if (node instanceof FixedWithNextNode) {
        out.print("f ").print(HOVER_START).print("#").print(HOVER_SEP).print("fixed with next").print(HOVER_END).println(COLUMN_END);
    } else if (node instanceof FixedNode) {
        out.print("f ").print(HOVER_START).print("*").print(HOVER_SEP).print("fixed").print(HOVER_END).println(COLUMN_END);
    } else if (node instanceof FloatingNode) {
        out.print("f ").print(HOVER_START).print("~").print(HOVER_SEP).print("floating").print(HOVER_END).println(COLUMN_END);
    }
    out.print("tid ").print(nodeToString(node)).println(COLUMN_END);
    if (nodeLirGenerator != null) {
        Value operand = nodeLirGenerator.hasOperand(node) ? nodeLirGenerator.operand(node) : null;
        if (operand != null) {
            out.print("result ").print(operand.toString()).println(COLUMN_END);
        }
    }
    if (node instanceof StateSplit) {
        StateSplit stateSplit = (StateSplit) node;
        if (stateSplit.stateAfter() != null) {
            String state = stateToString(stateSplit.stateAfter());
            out.print("st ").print(HOVER_START).print("st").print(HOVER_SEP).print(state).print(HOVER_END).println(COLUMN_END);
        }
    }
    Map<Object, Object> props = new TreeMap<>(node.getDebugProperties());
    out.print("d ").print(HOVER_START).print("d").print(HOVER_SEP);
    out.println("=== Debug Properties ===");
    for (Map.Entry<Object, Object> entry : props.entrySet()) {
        out.print(entry.getKey().toString()).print(": ").print(entry.getValue() == null ? "[null]" : entry.getValue().toString()).println();
    }
    out.println("=== Inputs ===");
    printNamedNodes(node, node.inputPositions().iterator(), "", "\n", null);
    out.println("=== Succesors ===");
    printNamedNodes(node, node.successorPositions().iterator(), "", "\n", null);
    out.println("=== Usages ===");
    if (!node.hasNoUsages()) {
        for (Node usage : node.usages()) {
            out.print(nodeToString(usage)).print(" ");
        }
        out.println();
    }
    out.println("=== Predecessor ===");
    out.print(nodeToString(node.predecessor())).print(" ");
    out.print(HOVER_END).println(COLUMN_END);
    out.print("instruction ");
    out.print(HOVER_START).print(node.getNodeClass().shortName()).print(HOVER_SEP).print(node.getClass().getName()).print(HOVER_END).print(" ");
    printNamedNodes(node, node.inputPositions().iterator(), "", "", "#NDF");
    printNamedNodes(node, node.successorPositions().iterator(), "#", "", "#NDF");
    for (Map.Entry<Object, Object> entry : props.entrySet()) {
        String key = entry.getKey().toString();
        if (key.startsWith("data.") && !key.equals("data.stamp")) {
            out.print(key.substring("data.".length())).print(": ").print(entry.getValue() == null ? "[null]" : entry.getValue().toString()).print(" ");
        }
    }
    out.print(COLUMN_END).print(' ').println(COLUMN_END);
}
Also used : FixedWithNextNode(org.graalvm.compiler.nodes.FixedWithNextNode) ValuePhiNode(org.graalvm.compiler.nodes.ValuePhiNode) FloatingNode(org.graalvm.compiler.nodes.calc.FloatingNode) ValuePhiNode(org.graalvm.compiler.nodes.ValuePhiNode) AbstractMergeNode(org.graalvm.compiler.nodes.AbstractMergeNode) FixedNode(org.graalvm.compiler.nodes.FixedNode) AbstractBeginNode(org.graalvm.compiler.nodes.AbstractBeginNode) AbstractEndNode(org.graalvm.compiler.nodes.AbstractEndNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) Node(org.graalvm.compiler.graph.Node) FixedWithNextNode(org.graalvm.compiler.nodes.FixedWithNextNode) PhiNode(org.graalvm.compiler.nodes.PhiNode) FixedNode(org.graalvm.compiler.nodes.FixedNode) TreeMap(java.util.TreeMap) Value(jdk.vm.ci.meta.Value) FloatingNode(org.graalvm.compiler.nodes.calc.FloatingNode) Map(java.util.Map) NodeMap(org.graalvm.compiler.graph.NodeMap) NodeBitMap(org.graalvm.compiler.graph.NodeBitMap) TreeMap(java.util.TreeMap) StateSplit(org.graalvm.compiler.nodes.StateSplit)

Aggregations

FloatingNode (org.graalvm.compiler.nodes.calc.FloatingNode)11 Node (org.graalvm.compiler.graph.Node)8 FixedNode (org.graalvm.compiler.nodes.FixedNode)8 AbstractBeginNode (org.graalvm.compiler.nodes.AbstractBeginNode)7 FixedWithNextNode (org.graalvm.compiler.nodes.FixedWithNextNode)7 ValueNode (org.graalvm.compiler.nodes.ValueNode)7 PhiNode (org.graalvm.compiler.nodes.PhiNode)6 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)6 AbstractMergeNode (org.graalvm.compiler.nodes.AbstractMergeNode)5 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)4 LoopBeginNode (org.graalvm.compiler.nodes.LoopBeginNode)4 ControlSinkNode (org.graalvm.compiler.nodes.ControlSinkNode)3 ParameterNode (org.graalvm.compiler.nodes.ParameterNode)3 ArrayList (java.util.ArrayList)2 List (java.util.List)2 DebugCloseable (org.graalvm.compiler.debug.DebugCloseable)2 DebugContext (org.graalvm.compiler.debug.DebugContext)2 BeginNode (org.graalvm.compiler.nodes.BeginNode)2 FixedGuardNode (org.graalvm.compiler.nodes.FixedGuardNode)2 LogicNode (org.graalvm.compiler.nodes.LogicNode)2