Search in sources :

Example 11 with OffsetAddressNode

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

the class DefaultJavaLoweringProvider method lowerCompareAndSwapNode.

protected void lowerCompareAndSwapNode(UnsafeCompareAndSwapNode cas) {
    StructuredGraph graph = cas.graph();
    JavaKind valueKind = cas.getValueKind();
    ValueNode expectedValue = implicitStoreConvert(graph, valueKind, cas.expected());
    ValueNode newValue = implicitStoreConvert(graph, valueKind, cas.newValue());
    AddressNode address = graph.unique(new OffsetAddressNode(cas.object(), cas.offset()));
    LogicCompareAndSwapNode atomicNode = graph.add(new LogicCompareAndSwapNode(address, cas.getLocationIdentity(), expectedValue, newValue, compareAndSwapBarrierType(cas)));
    atomicNode.setStateAfter(cas.stateAfter());
    graph.replaceFixedWithFixed(cas, atomicNode);
}
Also used : LogicCompareAndSwapNode(org.graalvm.compiler.nodes.java.LogicCompareAndSwapNode) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) OffsetAddressNode(org.graalvm.compiler.nodes.memory.address.OffsetAddressNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) OffsetAddressNode(org.graalvm.compiler.nodes.memory.address.OffsetAddressNode) AddressNode(org.graalvm.compiler.nodes.memory.address.AddressNode) JavaKind(jdk.vm.ci.meta.JavaKind)

Example 12 with OffsetAddressNode

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

the class DefaultJavaLoweringProvider method reconstructArrayIndex.

@Override
public ValueNode reconstructArrayIndex(JavaKind elementKind, AddressNode address) {
    StructuredGraph graph = address.graph();
    ValueNode offset = ((OffsetAddressNode) address).getOffset();
    int base = arrayBaseOffset(elementKind);
    ValueNode scaledIndex = graph.unique(new SubNode(offset, ConstantNode.forIntegerStamp(offset.stamp(NodeView.DEFAULT), base, graph)));
    int shift = CodeUtil.log2(arrayScalingFactor(elementKind));
    ValueNode ret = graph.unique(new RightShiftNode(scaledIndex, ConstantNode.forInt(shift, graph)));
    return IntegerConvertNode.convert(ret, StampFactory.forKind(JavaKind.Int), graph, NodeView.DEFAULT);
}
Also used : StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) OffsetAddressNode(org.graalvm.compiler.nodes.memory.address.OffsetAddressNode) SubNode(org.graalvm.compiler.nodes.calc.SubNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) RightShiftNode(org.graalvm.compiler.nodes.calc.RightShiftNode)

Example 13 with OffsetAddressNode

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

the class ObjectAccessTest method assertRead.

private static void assertRead(StructuredGraph graph, JavaKind kind, boolean indexConvert, LocationIdentity locationIdentity) {
    JavaReadNode read = (JavaReadNode) graph.start().next();
    Assert.assertEquals(kind.getStackKind(), read.stamp(NodeView.DEFAULT).getStackKind());
    OffsetAddressNode address = (OffsetAddressNode) read.getAddress();
    Assert.assertEquals(graph.getParameter(0), address.getBase());
    Assert.assertEquals(locationIdentity, read.getLocationIdentity());
    if (indexConvert) {
        SignExtendNode convert = (SignExtendNode) address.getOffset();
        Assert.assertEquals(convert.getInputBits(), 32);
        Assert.assertEquals(convert.getResultBits(), 64);
        Assert.assertEquals(graph.getParameter(1), convert.getValue());
    } else {
        Assert.assertEquals(graph.getParameter(1), address.getOffset());
    }
    ReturnNode ret = (ReturnNode) read.next();
    Assert.assertEquals(read, ret.result());
}
Also used : JavaReadNode(org.graalvm.compiler.nodes.extended.JavaReadNode) ReturnNode(org.graalvm.compiler.nodes.ReturnNode) OffsetAddressNode(org.graalvm.compiler.nodes.memory.address.OffsetAddressNode) SignExtendNode(org.graalvm.compiler.nodes.calc.SignExtendNode)

Example 14 with OffsetAddressNode

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

the class ObjectAccessTest method assertWrite.

private static void assertWrite(StructuredGraph graph, boolean indexConvert, LocationIdentity locationIdentity) {
    JavaWriteNode write = (JavaWriteNode) graph.start().next();
    Assert.assertEquals(graph.getParameter(2), write.value());
    OffsetAddressNode address = (OffsetAddressNode) write.getAddress();
    Assert.assertEquals(graph.getParameter(0), address.getBase());
    Assert.assertEquals(BytecodeFrame.AFTER_BCI, write.stateAfter().bci);
    Assert.assertEquals(locationIdentity, write.getLocationIdentity());
    if (indexConvert) {
        SignExtendNode convert = (SignExtendNode) address.getOffset();
        Assert.assertEquals(convert.getInputBits(), 32);
        Assert.assertEquals(convert.getResultBits(), 64);
        Assert.assertEquals(graph.getParameter(1), convert.getValue());
    } else {
        Assert.assertEquals(graph.getParameter(1), address.getOffset());
    }
    ReturnNode ret = (ReturnNode) write.next();
    Assert.assertEquals(null, ret.result());
}
Also used : ReturnNode(org.graalvm.compiler.nodes.ReturnNode) OffsetAddressNode(org.graalvm.compiler.nodes.memory.address.OffsetAddressNode) SignExtendNode(org.graalvm.compiler.nodes.calc.SignExtendNode) JavaWriteNode(org.graalvm.compiler.nodes.extended.JavaWriteNode)

Example 15 with OffsetAddressNode

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

the class PointerTest method assertRead.

private void assertRead(StructuredGraph graph, JavaKind kind, boolean indexConvert, LocationIdentity locationIdentity) {
    WordCastNode cast = (WordCastNode) graph.start().next();
    JavaReadNode read = (JavaReadNode) cast.next();
    Assert.assertEquals(kind.getStackKind(), read.stamp(NodeView.DEFAULT).getStackKind());
    OffsetAddressNode address = (OffsetAddressNode) read.getAddress();
    Assert.assertEquals(cast, address.getBase());
    Assert.assertEquals(graph.getParameter(0), cast.getInput());
    Assert.assertEquals(target.wordJavaKind, cast.stamp(NodeView.DEFAULT).getStackKind());
    Assert.assertEquals(locationIdentity, read.getLocationIdentity());
    if (indexConvert) {
        SignExtendNode convert = (SignExtendNode) address.getOffset();
        Assert.assertEquals(convert.getInputBits(), 32);
        Assert.assertEquals(convert.getResultBits(), 64);
        Assert.assertEquals(graph.getParameter(1), convert.getValue());
    } else {
        Assert.assertEquals(graph.getParameter(1), address.getOffset());
    }
    ReturnNode ret = (ReturnNode) read.next();
    Assert.assertEquals(read, ret.result());
}
Also used : JavaReadNode(org.graalvm.compiler.nodes.extended.JavaReadNode) ReturnNode(org.graalvm.compiler.nodes.ReturnNode) WordCastNode(org.graalvm.compiler.word.WordCastNode) OffsetAddressNode(org.graalvm.compiler.nodes.memory.address.OffsetAddressNode) SignExtendNode(org.graalvm.compiler.nodes.calc.SignExtendNode)

Aggregations

OffsetAddressNode (org.graalvm.compiler.nodes.memory.address.OffsetAddressNode)28 ValueNode (org.graalvm.compiler.nodes.ValueNode)18 AddressNode (org.graalvm.compiler.nodes.memory.address.AddressNode)15 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)7 SignExtendNode (org.graalvm.compiler.nodes.calc.SignExtendNode)7 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)5 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)5 ReadNode (org.graalvm.compiler.nodes.memory.ReadNode)5 JavaKind (jdk.vm.ci.meta.JavaKind)4 Stamp (org.graalvm.compiler.core.common.type.Stamp)4 AddNode (org.graalvm.compiler.nodes.calc.AddNode)4 MetaAccessProvider (jdk.vm.ci.meta.MetaAccessProvider)3 ResolvedJavaType (jdk.vm.ci.meta.ResolvedJavaType)3 Node (org.graalvm.compiler.graph.Node)3 ReturnNode (org.graalvm.compiler.nodes.ReturnNode)3 LeftShiftNode (org.graalvm.compiler.nodes.calc.LeftShiftNode)3 JavaReadNode (org.graalvm.compiler.nodes.extended.JavaReadNode)3 GraphBuilderContext (org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext)3 InvocationPlugin (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin)3 Registration (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration)3