Search in sources :

Example 21 with OffsetAddressNode

use of org.graalvm.compiler.nodes.memory.address.OffsetAddressNode 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 22 with OffsetAddressNode

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

the class HotSpotGraphBuilderPlugins method registerConstantPoolPlugins.

private static void registerConstantPoolPlugins(InvocationPlugins plugins, WordTypes wordTypes, GraalHotSpotVMConfig config, BytecodeProvider bytecodeProvider) {
    Registration r = new Registration(plugins, constantPoolClass, bytecodeProvider);
    r.register2("getSize0", Receiver.class, Object.class, new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode constantPoolOop) {
            boolean notCompressible = false;
            ValueNode constants = getMetaspaceConstantPool(b, constantPoolOop, wordTypes, config);
            AddressNode lengthAddress = b.add(new OffsetAddressNode(constants, b.add(ConstantNode.forLong(config.constantPoolLengthOffset))));
            ValueNode length = WordOperationPlugin.readOp(b, JavaKind.Int, lengthAddress, CONSTANT_POOL_LENGTH, BarrierType.NONE, notCompressible);
            b.addPush(JavaKind.Int, length);
            return true;
        }
    });
    r.register3("getIntAt0", Receiver.class, Object.class, int.class, new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode constantPoolOop, ValueNode index) {
            return readMetaspaceConstantPoolElement(b, constantPoolOop, index, JavaKind.Int, wordTypes, config);
        }
    });
    r.register3("getLongAt0", Receiver.class, Object.class, int.class, new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode constantPoolOop, ValueNode index) {
            return readMetaspaceConstantPoolElement(b, constantPoolOop, index, JavaKind.Long, wordTypes, config);
        }
    });
    r.register3("getFloatAt0", Receiver.class, Object.class, int.class, new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode constantPoolOop, ValueNode index) {
            return readMetaspaceConstantPoolElement(b, constantPoolOop, index, JavaKind.Float, wordTypes, config);
        }
    });
    r.register3("getDoubleAt0", Receiver.class, Object.class, int.class, new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode constantPoolOop, ValueNode index) {
            return readMetaspaceConstantPoolElement(b, constantPoolOop, index, JavaKind.Double, wordTypes, config);
        }
    });
}
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) Receiver(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.Receiver) OffsetAddressNode(org.graalvm.compiler.nodes.memory.address.OffsetAddressNode) AddressNode(org.graalvm.compiler.nodes.memory.address.AddressNode) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 23 with OffsetAddressNode

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

the class HotSpotGraphBuilderPlugins method readMetaspaceConstantPoolElement.

/**
 * Emits a node representing an element in a metaspace {@code ConstantPool}.
 *
 * @param constantPoolOop value of the {@code constantPoolOop} field in a ConstantPool value
 */
private static boolean readMetaspaceConstantPoolElement(GraphBuilderContext b, ValueNode constantPoolOop, ValueNode index, JavaKind elementKind, WordTypes wordTypes, GraalHotSpotVMConfig config) {
    ValueNode constants = getMetaspaceConstantPool(b, constantPoolOop, wordTypes, config);
    int shift = CodeUtil.log2(wordTypes.getWordKind().getByteCount());
    ValueNode scaledIndex = b.add(new LeftShiftNode(IntegerConvertNode.convert(index, StampFactory.forKind(JavaKind.Long), NodeView.DEFAULT), b.add(ConstantNode.forInt(shift))));
    ValueNode offset = b.add(new AddNode(scaledIndex, b.add(ConstantNode.forLong(config.constantPoolSize))));
    AddressNode elementAddress = b.add(new OffsetAddressNode(constants, offset));
    boolean notCompressible = false;
    ValueNode elementValue = WordOperationPlugin.readOp(b, elementKind, elementAddress, NamedLocationIdentity.getArrayLocation(elementKind), BarrierType.NONE, notCompressible);
    b.addPush(elementKind, elementValue);
    return true;
}
Also used : 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) LeftShiftNode(org.graalvm.compiler.nodes.calc.LeftShiftNode) AddNode(org.graalvm.compiler.nodes.calc.AddNode)

Example 24 with OffsetAddressNode

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

the class PushNodesThroughPiTest method test1.

@Ignore
@Test
@SuppressWarnings("try")
public void test1() {
    final String snippet = "test1Snippet";
    DebugContext debug = getDebugContext();
    try (DebugContext.Scope s = debug.scope("PushThroughPi", new DebugDumpScope(snippet))) {
        StructuredGraph graph = compileTestSnippet(snippet);
        for (ReadNode rn : graph.getNodes().filter(ReadNode.class)) {
            OffsetAddressNode address = (OffsetAddressNode) rn.getAddress();
            long disp = address.getOffset().asJavaConstant().asLong();
            ResolvedJavaType receiverType = StampTool.typeOrNull(address.getBase());
            ResolvedJavaField field = receiverType.findInstanceFieldWithOffset(disp, rn.getStackKind());
            assert field != null : "Node " + rn + " tries to access a field which doesn't exists for this type";
            if (field.getName().equals("x")) {
                Assert.assertTrue(address.getBase() instanceof ParameterNode);
            } else {
                Assert.assertTrue(address.getBase().toString(), address.getBase() instanceof PiNode);
            }
        }
        Assert.assertTrue(graph.getNodes().filter(IsNullNode.class).count() == 1);
    } catch (Throwable e) {
        throw debug.handle(e);
    }
}
Also used : DebugDumpScope(org.graalvm.compiler.debug.DebugDumpScope) DebugContext(org.graalvm.compiler.debug.DebugContext) PiNode(org.graalvm.compiler.nodes.PiNode) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType) ResolvedJavaField(jdk.vm.ci.meta.ResolvedJavaField) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) OffsetAddressNode(org.graalvm.compiler.nodes.memory.address.OffsetAddressNode) ParameterNode(org.graalvm.compiler.nodes.ParameterNode) IsNullNode(org.graalvm.compiler.nodes.calc.IsNullNode) ReadNode(org.graalvm.compiler.nodes.memory.ReadNode) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 25 with OffsetAddressNode

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

the class DefaultJavaLoweringProvider method createArrayAddress.

public AddressNode createArrayAddress(StructuredGraph graph, ValueNode array, JavaKind elementKind, ValueNode index) {
    ValueNode wordIndex;
    if (target.wordSize > 4) {
        wordIndex = graph.unique(new SignExtendNode(index, target.wordSize * 8));
    } else {
        assert target.wordSize == 4 : "unsupported word size";
        wordIndex = index;
    }
    int shift = CodeUtil.log2(arrayScalingFactor(elementKind));
    ValueNode scaledIndex = graph.unique(new LeftShiftNode(wordIndex, ConstantNode.forInt(shift, graph)));
    int base = arrayBaseOffset(elementKind);
    ValueNode offset = graph.unique(new AddNode(scaledIndex, ConstantNode.forIntegerKind(target.wordJavaKind, base, graph)));
    return graph.unique(new OffsetAddressNode(array, offset));
}
Also used : SignExtendNode(org.graalvm.compiler.nodes.calc.SignExtendNode) OffsetAddressNode(org.graalvm.compiler.nodes.memory.address.OffsetAddressNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) LeftShiftNode(org.graalvm.compiler.nodes.calc.LeftShiftNode) AddNode(org.graalvm.compiler.nodes.calc.AddNode)

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