Search in sources :

Example 21 with ReadNode

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

the class DefaultJavaLoweringProvider method createReadArrayLength.

/**
 * Creates a read node that read the array length and is guarded by a null-check.
 *
 * The created node is placed before {@code before} in the CFG.
 */
protected ReadNode createReadArrayLength(ValueNode array, FixedNode before, LoweringTool tool) {
    StructuredGraph graph = array.graph();
    ValueNode canonicalArray = this.createNullCheckedValue(skipPiWhileNonNull(array), before, tool);
    AddressNode address = createOffsetAddress(graph, canonicalArray, arrayLengthOffset());
    ReadNode readArrayLength = graph.add(new ReadNode(address, ARRAY_LENGTH_LOCATION, StampFactory.positiveInt(), BarrierType.NONE));
    graph.addBeforeFixed(before, readArrayLength);
    return readArrayLength;
}
Also used : StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) ValueNode(org.graalvm.compiler.nodes.ValueNode) OffsetAddressNode(org.graalvm.compiler.nodes.memory.address.OffsetAddressNode) AddressNode(org.graalvm.compiler.nodes.memory.address.AddressNode) JavaReadNode(org.graalvm.compiler.nodes.extended.JavaReadNode) ReadNode(org.graalvm.compiler.nodes.memory.ReadNode)

Example 22 with ReadNode

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

the class PEGraphDecoderTest method registerPlugins.

private static void registerPlugins(InvocationPlugins plugins) {
    Registration r = new Registration(plugins, PEGraphDecoderTest.class);
    r.register2("readInt", Object.class, long.class, new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver unused, ValueNode obj, ValueNode offset) {
            AddressNode address = b.add(new OffsetAddressNode(obj, offset));
            ReadNode read = b.addPush(JavaKind.Int, new ReadNode(address, LocationIdentity.any(), StampFactory.forKind(JavaKind.Int), BarrierType.NONE));
            read.setGuard(AbstractBeginNode.prevBegin(read));
            return true;
        }
    });
}
Also used : OffsetAddressNode(org.graalvm.compiler.nodes.memory.address.OffsetAddressNode) GraphBuilderContext(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext) Registration(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration) ValueNode(org.graalvm.compiler.nodes.ValueNode) InvocationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin) OffsetAddressNode(org.graalvm.compiler.nodes.memory.address.OffsetAddressNode) AddressNode(org.graalvm.compiler.nodes.memory.address.AddressNode) ReadNode(org.graalvm.compiler.nodes.memory.ReadNode) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Aggregations

ReadNode (org.graalvm.compiler.nodes.memory.ReadNode)22 ValueNode (org.graalvm.compiler.nodes.ValueNode)14 AddressNode (org.graalvm.compiler.nodes.memory.address.AddressNode)13 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)11 OffsetAddressNode (org.graalvm.compiler.nodes.memory.address.OffsetAddressNode)10 ObjectStamp (org.graalvm.compiler.core.common.type.ObjectStamp)9 Stamp (org.graalvm.compiler.core.common.type.Stamp)9 JavaReadNode (org.graalvm.compiler.nodes.extended.JavaReadNode)8 JavaKind (jdk.vm.ci.meta.JavaKind)7 FloatingReadNode (org.graalvm.compiler.nodes.memory.FloatingReadNode)6 IntegerStamp (org.graalvm.compiler.core.common.type.IntegerStamp)5 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)4 GuardingNode (org.graalvm.compiler.nodes.extended.GuardingNode)4 ResolvedJavaType (jdk.vm.ci.meta.ResolvedJavaType)3 Node (org.graalvm.compiler.graph.Node)3 ComputeObjectAddressNode (org.graalvm.compiler.hotspot.nodes.ComputeObjectAddressNode)3 GetObjectAddressNode (org.graalvm.compiler.hotspot.nodes.GetObjectAddressNode)3 GraphBuilderContext (org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext)3 Registration (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration)3 WriteNode (org.graalvm.compiler.nodes.memory.WriteNode)3