Search in sources :

Example 1 with WriteNode

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

the class WriteBarrierVerificationPhase method hasAttachedBarrier.

private boolean hasAttachedBarrier(FixedWithNextNode node) {
    final Node next = node.next();
    final Node previous = node.predecessor();
    boolean validatePreBarrier = useG1GC() && (isObjectWrite(node) || !((ArrayRangeWrite) node).isInitialization());
    if (node instanceof WriteNode) {
        WriteNode writeNode = (WriteNode) node;
        if (writeNode.getLocationIdentity().isInit()) {
            validatePreBarrier = false;
        }
    }
    if (isObjectWrite(node)) {
        return (isObjectBarrier(node, next) || StampTool.isPointerAlwaysNull(getValueWritten(node))) && (!validatePreBarrier || isObjectBarrier(node, previous));
    } else if (isObjectArrayRangeWrite(node)) {
        return (isArrayBarrier(node, next) || StampTool.isPointerAlwaysNull(getValueWritten(node))) && (!validatePreBarrier || isArrayBarrier(node, previous));
    } else {
        return true;
    }
}
Also used : ArrayRangeWrite(org.graalvm.compiler.nodes.extended.ArrayRangeWrite) 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) WriteNode(org.graalvm.compiler.nodes.memory.WriteNode) LoweredAtomicReadAndWriteNode(org.graalvm.compiler.nodes.java.LoweredAtomicReadAndWriteNode)

Example 2 with WriteNode

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

the class DefaultHotSpotLoweringProvider method createWriteHub.

private WriteNode createWriteHub(StructuredGraph graph, ValueNode object, ValueNode value) {
    assert !object.isConstant() || object.asConstant().isDefaultForKind();
    ValueNode writeValue = value;
    if (runtime.getVMConfig().useCompressedClassPointers) {
        writeValue = HotSpotCompressionNode.compress(value, runtime.getVMConfig().getKlassEncoding());
    }
    AddressNode address = createOffsetAddress(graph, object, runtime.getVMConfig().hubOffset);
    return graph.add(new WriteNode(address, HUB_WRITE_LOCATION, writeValue, BarrierType.NONE));
}
Also used : ValueNode(org.graalvm.compiler.nodes.ValueNode) GetObjectAddressNode(org.graalvm.compiler.hotspot.nodes.GetObjectAddressNode) ComputeObjectAddressNode(org.graalvm.compiler.hotspot.nodes.ComputeObjectAddressNode) AddressNode(org.graalvm.compiler.nodes.memory.address.AddressNode) WriteNode(org.graalvm.compiler.nodes.memory.WriteNode)

Example 3 with WriteNode

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

the class DefaultHotSpotLoweringProvider method lowerOSRStartNode.

private void lowerOSRStartNode(OSRStartNode osrStart) {
    StructuredGraph graph = osrStart.graph();
    if (graph.getGuardsStage() == StructuredGraph.GuardsStage.FIXED_DEOPTS) {
        StartNode newStart = graph.add(new StartNode());
        ParameterNode buffer = graph.addWithoutUnique(new ParameterNode(0, StampPair.createSingle(StampFactory.forKind(runtime.getTarget().wordJavaKind))));
        ForeignCallNode migrationEnd = graph.add(new ForeignCallNode(foreignCalls, OSR_MIGRATION_END, buffer));
        migrationEnd.setStateAfter(osrStart.stateAfter());
        newStart.setNext(migrationEnd);
        FixedNode next = osrStart.next();
        osrStart.setNext(null);
        migrationEnd.setNext(next);
        graph.setStart(newStart);
        final int wordSize = target.wordSize;
        // @formatter:off
        // taken from c2 locals_addr = osr_buf + (max_locals-1)*wordSize)
        // @formatter:on
        int localsOffset = (graph.method().getMaxLocals() - 1) * wordSize;
        for (OSRLocalNode osrLocal : graph.getNodes(OSRLocalNode.TYPE)) {
            int size = osrLocal.getStackKind().getSlotCount();
            int offset = localsOffset - (osrLocal.index() + size - 1) * wordSize;
            AddressNode address = createOffsetAddress(graph, buffer, offset);
            ReadNode load = graph.add(new ReadNode(address, any(), osrLocal.stamp(NodeView.DEFAULT), BarrierType.NONE));
            osrLocal.replaceAndDelete(load);
            graph.addBeforeFixed(migrationEnd, load);
        }
        // @formatter:off
        // taken from c2 monitors_addr = osr_buf + (max_locals+mcnt*2-1)*wordSize);
        // @formatter:on
        final int lockCount = osrStart.stateAfter().locksSize();
        final int locksOffset = (graph.method().getMaxLocals() + lockCount * 2 - 1) * wordSize;
        // buffer
        for (OSRMonitorEnterNode osrMonitorEnter : graph.getNodes(OSRMonitorEnterNode.TYPE)) {
            MonitorIdNode monitorID = osrMonitorEnter.getMonitorId();
            OSRLockNode lock = (OSRLockNode) osrMonitorEnter.object();
            final int index = lock.index();
            final int offsetDisplacedHeader = locksOffset - ((index * 2) + 1) * wordSize;
            final int offsetLockObject = locksOffset - index * 2 * wordSize;
            // load the displaced mark from the osr buffer
            AddressNode addressDisplacedHeader = createOffsetAddress(graph, buffer, offsetDisplacedHeader);
            ReadNode loadDisplacedHeader = graph.add(new ReadNode(addressDisplacedHeader, any(), lock.stamp(NodeView.DEFAULT), BarrierType.NONE));
            graph.addBeforeFixed(migrationEnd, loadDisplacedHeader);
            // we need to initialize the stack slot for the lock
            BeginLockScopeNode beginLockScope = graph.add(new BeginLockScopeNode(lock.getStackKind(), monitorID.getLockDepth()));
            graph.addBeforeFixed(migrationEnd, beginLockScope);
            // write the displaced mark to the correct stack slot
            AddressNode addressDisplacedMark = createOffsetAddress(graph, beginLockScope, runtime.getVMConfig().basicLockDisplacedHeaderOffset);
            WriteNode writeStackSlot = graph.add(new WriteNode(addressDisplacedMark, DISPLACED_MARK_WORD_LOCATION, loadDisplacedHeader, BarrierType.NONE));
            graph.addBeforeFixed(migrationEnd, writeStackSlot);
            // load the lock object from the osr buffer
            AddressNode addressLockObject = createOffsetAddress(graph, buffer, offsetLockObject);
            ReadNode loadObject = graph.add(new ReadNode(addressLockObject, any(), lock.stamp(NodeView.DEFAULT), BarrierType.NONE));
            lock.replaceAndDelete(loadObject);
            graph.addBeforeFixed(migrationEnd, loadObject);
        }
        osrStart.replaceAtUsagesAndDelete(newStart);
    }
}
Also used : MonitorIdNode(org.graalvm.compiler.nodes.java.MonitorIdNode) OSRStartNode(org.graalvm.compiler.nodes.extended.OSRStartNode) StartNode(org.graalvm.compiler.nodes.StartNode) OSRLocalNode(org.graalvm.compiler.nodes.extended.OSRLocalNode) FixedNode(org.graalvm.compiler.nodes.FixedNode) OSRLockNode(org.graalvm.compiler.nodes.extended.OSRLockNode) OSRMonitorEnterNode(org.graalvm.compiler.nodes.extended.OSRMonitorEnterNode) ForeignCallNode(org.graalvm.compiler.nodes.extended.ForeignCallNode) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) ParameterNode(org.graalvm.compiler.nodes.ParameterNode) BeginLockScopeNode(org.graalvm.compiler.hotspot.nodes.BeginLockScopeNode) GetObjectAddressNode(org.graalvm.compiler.hotspot.nodes.GetObjectAddressNode) ComputeObjectAddressNode(org.graalvm.compiler.hotspot.nodes.ComputeObjectAddressNode) AddressNode(org.graalvm.compiler.nodes.memory.address.AddressNode) FloatingReadNode(org.graalvm.compiler.nodes.memory.FloatingReadNode) ReadNode(org.graalvm.compiler.nodes.memory.ReadNode) WriteNode(org.graalvm.compiler.nodes.memory.WriteNode)

Example 4 with WriteNode

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

the class DefaultHotSpotLoweringProvider method lowerStoreHubNode.

private void lowerStoreHubNode(StoreHubNode storeHub, StructuredGraph graph) {
    WriteNode hub = createWriteHub(graph, storeHub.getObject(), storeHub.getValue());
    graph.replaceFixed(storeHub, hub);
}
Also used : WriteNode(org.graalvm.compiler.nodes.memory.WriteNode)

Example 5 with WriteNode

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

the class MemoryScheduleTest method assertReadBeforeAllWritesInStartBlock.

private static void assertReadBeforeAllWritesInStartBlock(ScheduleResult schedule) {
    boolean writeNodeFound = false;
    boolean readNodeFound = false;
    for (Node node : schedule.nodesFor(schedule.getCFG().getStartBlock())) {
        if (node instanceof FloatingReadNode) {
            assertTrue(!writeNodeFound);
            readNodeFound = true;
        } else if (node instanceof WriteNode) {
            writeNodeFound = true;
        }
    }
    assertTrue(readNodeFound);
}
Also used : WriteNode(org.graalvm.compiler.nodes.memory.WriteNode) StartNode(org.graalvm.compiler.nodes.StartNode) FloatingReadNode(org.graalvm.compiler.nodes.memory.FloatingReadNode) ReturnNode(org.graalvm.compiler.nodes.ReturnNode) Node(org.graalvm.compiler.graph.Node) FloatingReadNode(org.graalvm.compiler.nodes.memory.FloatingReadNode) WriteNode(org.graalvm.compiler.nodes.memory.WriteNode)

Aggregations

WriteNode (org.graalvm.compiler.nodes.memory.WriteNode)17 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)11 ValueNode (org.graalvm.compiler.nodes.ValueNode)10 LoweredAtomicReadAndWriteNode (org.graalvm.compiler.nodes.java.LoweredAtomicReadAndWriteNode)8 AddressNode (org.graalvm.compiler.nodes.memory.address.AddressNode)8 OffsetAddressNode (org.graalvm.compiler.nodes.memory.address.OffsetAddressNode)7 JavaWriteNode (org.graalvm.compiler.nodes.extended.JavaWriteNode)6 AtomicReadAndWriteNode (org.graalvm.compiler.nodes.java.AtomicReadAndWriteNode)6 ReadNode (org.graalvm.compiler.nodes.memory.ReadNode)5 JavaKind (jdk.vm.ci.meta.JavaKind)4 FloatingReadNode (org.graalvm.compiler.nodes.memory.FloatingReadNode)4 ResolvedJavaField (jdk.vm.ci.meta.ResolvedJavaField)3 DebugCloseable (org.graalvm.compiler.debug.DebugCloseable)3 Node (org.graalvm.compiler.graph.Node)3 ResolvedJavaType (jdk.vm.ci.meta.ResolvedJavaType)2 DebugContext (org.graalvm.compiler.debug.DebugContext)2 ComputeObjectAddressNode (org.graalvm.compiler.hotspot.nodes.ComputeObjectAddressNode)2 G1PostWriteBarrier (org.graalvm.compiler.hotspot.nodes.G1PostWriteBarrier)2 G1PreWriteBarrier (org.graalvm.compiler.hotspot.nodes.G1PreWriteBarrier)2 GetObjectAddressNode (org.graalvm.compiler.hotspot.nodes.GetObjectAddressNode)2