Search in sources :

Example 1 with FixedAccessNode

use of org.graalvm.compiler.nodes.memory.FixedAccessNode in project graal by oracle.

the class ValueAnchorNode method simplify.

@Override
public void simplify(SimplifierTool tool) {
    while (next() instanceof ValueAnchorNode) {
        ValueAnchorNode nextAnchor = (ValueAnchorNode) next();
        if (nextAnchor.anchored == anchored || nextAnchor.anchored == null) {
            // two anchors for the same anchored -> coalesce
            // nothing anchored on the next anchor -> coalesce
            nextAnchor.replaceAtUsages(this);
            GraphUtil.removeFixedWithUnusedInputs(nextAnchor);
        } else {
            break;
        }
    }
    if (tool.allUsagesAvailable() && hasNoUsages() && next() instanceof FixedAccessNode) {
        FixedAccessNode currentNext = (FixedAccessNode) next();
        if (currentNext.getGuard() == anchored) {
            GraphUtil.removeFixedWithUnusedInputs(this);
            return;
        }
    }
    if (anchored != null && (anchored.isConstant() || anchored instanceof FixedNode)) {
        // anchoring fixed nodes and constants is useless
        removeAnchoredNode();
    }
    if (anchored == null && hasNoUsages()) {
        // anchor is not necessary any more => remove.
        GraphUtil.removeFixedWithUnusedInputs(this);
    }
}
Also used : FixedAccessNode(org.graalvm.compiler.nodes.memory.FixedAccessNode) FixedNode(org.graalvm.compiler.nodes.FixedNode)

Example 2 with FixedAccessNode

use of org.graalvm.compiler.nodes.memory.FixedAccessNode in project graal by oracle.

the class LoadVMThreadLocalNode method lower.

@Override
public void lower(LoweringTool tool) {
    assert threadLocalInfo.offset >= 0;
    ConstantNode offset = ConstantNode.forIntegerKind(FrameAccess.getWordKind(), threadLocalInfo.offset, holder.graph());
    AddressNode address = graph().unique(new OffsetAddressNode(holder, offset));
    FixedAccessNode read;
    if (SubstrateOptions.MultiThreaded.getValue()) {
        read = new CInterfaceReadNode(address, threadLocalInfo.locationIdentity, stamp(NodeView.DEFAULT), barrierType, threadLocalInfo.name);
    } else {
        read = new JavaReadNode(threadLocalInfo.storageKind, address, threadLocalInfo.locationIdentity, barrierType, true);
    }
    read = graph().add(read);
    graph().replaceFixedWithFixed(this, read);
    if (!SubstrateOptions.MultiThreaded.getValue()) {
        tool.getLowerer().lower(read, tool);
    }
}
Also used : FixedAccessNode(org.graalvm.compiler.nodes.memory.FixedAccessNode) JavaReadNode(org.graalvm.compiler.nodes.extended.JavaReadNode) ConstantNode(org.graalvm.compiler.nodes.ConstantNode) OffsetAddressNode(org.graalvm.compiler.nodes.memory.address.OffsetAddressNode) CInterfaceReadNode(com.oracle.svm.core.graal.nodes.CInterfaceReadNode) AddressNode(org.graalvm.compiler.nodes.memory.address.AddressNode) OffsetAddressNode(org.graalvm.compiler.nodes.memory.address.OffsetAddressNode)

Example 3 with FixedAccessNode

use of org.graalvm.compiler.nodes.memory.FixedAccessNode in project graal by oracle.

the class WriteBarrierVerificationPhase method validateWrite.

private void validateWrite(Node write) {
    /*
         * The currently validated write is checked in order to discover if it has an appropriate
         * attached write barrier.
         */
    if (hasAttachedBarrier((FixedWithNextNode) write)) {
        return;
    }
    NodeFlood frontier = write.graph().createNodeFlood();
    expandFrontier(frontier, write);
    Iterator<Node> iterator = frontier.iterator();
    while (iterator.hasNext()) {
        Node currentNode = iterator.next();
        if (isSafepoint(currentNode)) {
            throw new AssertionError("Write barrier must be present " + write.toString(Verbosity.All) + " / " + write.inputs());
        }
        if (useG1GC()) {
            if (!(currentNode instanceof G1PostWriteBarrier) || (!validateBarrier((FixedAccessNode) write, (ObjectWriteBarrier) currentNode))) {
                expandFrontier(frontier, currentNode);
            }
        } else {
            if (!(currentNode instanceof SerialWriteBarrier) || (!validateBarrier((FixedAccessNode) write, (ObjectWriteBarrier) currentNode)) || ((currentNode instanceof SerialWriteBarrier) && !validateBarrier((FixedAccessNode) write, (ObjectWriteBarrier) currentNode))) {
                expandFrontier(frontier, currentNode);
            }
        }
    }
}
Also used : FixedAccessNode(org.graalvm.compiler.nodes.memory.FixedAccessNode) ObjectWriteBarrier(org.graalvm.compiler.hotspot.nodes.ObjectWriteBarrier) WriteNode(org.graalvm.compiler.nodes.memory.WriteNode) LoweredAtomicReadAndWriteNode(org.graalvm.compiler.nodes.java.LoweredAtomicReadAndWriteNode) ReadNode(org.graalvm.compiler.nodes.memory.ReadNode) OffsetAddressNode(org.graalvm.compiler.nodes.memory.address.OffsetAddressNode) FixedAccessNode(org.graalvm.compiler.nodes.memory.FixedAccessNode) LoopBeginNode(org.graalvm.compiler.nodes.LoopBeginNode) DeoptimizingNode(org.graalvm.compiler.nodes.DeoptimizingNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) Node(org.graalvm.compiler.graph.Node) FixedWithNextNode(org.graalvm.compiler.nodes.FixedWithNextNode) LogicCompareAndSwapNode(org.graalvm.compiler.nodes.java.LogicCompareAndSwapNode) G1PostWriteBarrier(org.graalvm.compiler.hotspot.nodes.G1PostWriteBarrier) SerialWriteBarrier(org.graalvm.compiler.hotspot.nodes.SerialWriteBarrier) NodeFlood(org.graalvm.compiler.graph.NodeFlood)

Example 4 with FixedAccessNode

use of org.graalvm.compiler.nodes.memory.FixedAccessNode in project graal by oracle.

the class UseTrappingNullChecksPhase method replaceWithTrappingNullCheck.

private static void replaceWithTrappingNullCheck(AbstractDeoptimizeNode deopt, IfNode ifNode, LogicNode condition, DeoptimizationReason deoptimizationReason, long implicitNullCheckLimit) {
    DebugContext debug = deopt.getDebug();
    counterTrappingNullCheck.increment(debug);
    if (deopt instanceof DynamicDeoptimizeNode) {
        counterTrappingNullCheckDynamicDeoptimize.increment(debug);
    }
    if (deoptimizationReason == DeoptimizationReason.UnreachedCode) {
        counterTrappingNullCheckUnreached.increment(debug);
    }
    IsNullNode isNullNode = (IsNullNode) condition;
    AbstractBeginNode nonTrappingContinuation = ifNode.falseSuccessor();
    AbstractBeginNode trappingContinuation = ifNode.trueSuccessor();
    DeoptimizingFixedWithNextNode trappingNullCheck = null;
    FixedNode nextNonTrapping = nonTrappingContinuation.next();
    ValueNode value = isNullNode.getValue();
    if (OptImplicitNullChecks.getValue(ifNode.graph().getOptions()) && implicitNullCheckLimit > 0) {
        if (nextNonTrapping instanceof FixedAccessNode) {
            FixedAccessNode fixedAccessNode = (FixedAccessNode) nextNonTrapping;
            if (fixedAccessNode.canNullCheck()) {
                AddressNode address = fixedAccessNode.getAddress();
                ValueNode base = address.getBase();
                ValueNode index = address.getIndex();
                // intervening uncompress out of the address chain
                if (base != null && base instanceof CompressionNode) {
                    base = ((CompressionNode) base).getValue();
                }
                if (index != null && index instanceof CompressionNode) {
                    index = ((CompressionNode) index).getValue();
                }
                if (((base == value && index == null) || (base == null && index == value)) && address.getMaxConstantDisplacement() < implicitNullCheckLimit) {
                    // Opportunity for implicit null check as part of an existing read found!
                    fixedAccessNode.setStateBefore(deopt.stateBefore());
                    fixedAccessNode.setNullCheck(true);
                    deopt.graph().removeSplit(ifNode, nonTrappingContinuation);
                    trappingNullCheck = fixedAccessNode;
                    counterTrappingNullCheckExistingRead.increment(debug);
                }
            }
        }
    }
    if (trappingNullCheck == null) {
        // Need to add a null check node.
        trappingNullCheck = deopt.graph().add(new NullCheckNode(value));
        deopt.graph().replaceSplit(ifNode, trappingNullCheck, nonTrappingContinuation);
    }
    trappingNullCheck.setStateBefore(deopt.stateBefore());
    /*
         * We now have the pattern NullCheck/BeginNode/... It's possible some node is using the
         * BeginNode as a guard input, so replace guard users of the Begin with the NullCheck and
         * then remove the Begin from the graph.
         */
    nonTrappingContinuation.replaceAtUsages(InputType.Guard, trappingNullCheck);
    if (nonTrappingContinuation instanceof BeginNode) {
        GraphUtil.unlinkFixedNode(nonTrappingContinuation);
        nonTrappingContinuation.safeDelete();
    }
    GraphUtil.killCFG(trappingContinuation);
    GraphUtil.tryKillUnused(isNullNode);
}
Also used : FixedAccessNode(org.graalvm.compiler.nodes.memory.FixedAccessNode) DeoptimizingFixedWithNextNode(org.graalvm.compiler.nodes.DeoptimizingFixedWithNextNode) CompressionNode(org.graalvm.compiler.nodes.CompressionNode) IsNullNode(org.graalvm.compiler.nodes.calc.IsNullNode) NullCheckNode(org.graalvm.compiler.nodes.extended.NullCheckNode) BeginNode(org.graalvm.compiler.nodes.BeginNode) AbstractBeginNode(org.graalvm.compiler.nodes.AbstractBeginNode) DynamicDeoptimizeNode(org.graalvm.compiler.nodes.DynamicDeoptimizeNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) AddressNode(org.graalvm.compiler.nodes.memory.address.AddressNode) DebugContext(org.graalvm.compiler.debug.DebugContext) FixedNode(org.graalvm.compiler.nodes.FixedNode) AbstractBeginNode(org.graalvm.compiler.nodes.AbstractBeginNode)

Aggregations

FixedAccessNode (org.graalvm.compiler.nodes.memory.FixedAccessNode)4 FixedNode (org.graalvm.compiler.nodes.FixedNode)2 ValueNode (org.graalvm.compiler.nodes.ValueNode)2 AddressNode (org.graalvm.compiler.nodes.memory.address.AddressNode)2 OffsetAddressNode (org.graalvm.compiler.nodes.memory.address.OffsetAddressNode)2 CInterfaceReadNode (com.oracle.svm.core.graal.nodes.CInterfaceReadNode)1 DebugContext (org.graalvm.compiler.debug.DebugContext)1 Node (org.graalvm.compiler.graph.Node)1 NodeFlood (org.graalvm.compiler.graph.NodeFlood)1 G1PostWriteBarrier (org.graalvm.compiler.hotspot.nodes.G1PostWriteBarrier)1 ObjectWriteBarrier (org.graalvm.compiler.hotspot.nodes.ObjectWriteBarrier)1 SerialWriteBarrier (org.graalvm.compiler.hotspot.nodes.SerialWriteBarrier)1 AbstractBeginNode (org.graalvm.compiler.nodes.AbstractBeginNode)1 BeginNode (org.graalvm.compiler.nodes.BeginNode)1 CompressionNode (org.graalvm.compiler.nodes.CompressionNode)1 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)1 DeoptimizingFixedWithNextNode (org.graalvm.compiler.nodes.DeoptimizingFixedWithNextNode)1 DeoptimizingNode (org.graalvm.compiler.nodes.DeoptimizingNode)1 DynamicDeoptimizeNode (org.graalvm.compiler.nodes.DynamicDeoptimizeNode)1 FixedWithNextNode (org.graalvm.compiler.nodes.FixedWithNextNode)1