Search in sources :

Example 1 with KlassPointerStamp

use of org.graalvm.compiler.hotspot.nodes.type.KlassPointerStamp in project graal by oracle.

the class DefaultHotSpotLoweringProvider method createReadHub.

@Override
protected ValueNode createReadHub(StructuredGraph graph, ValueNode object, LoweringTool tool) {
    if (tool.getLoweringStage() != LoweringTool.StandardLoweringStage.LOW_TIER) {
        return graph.unique(new LoadHubNode(tool.getStampProvider(), object));
    }
    assert !object.isConstant() || object.isNullConstant();
    KlassPointerStamp hubStamp = KlassPointerStamp.klassNonNull();
    if (runtime.getVMConfig().useCompressedClassPointers) {
        hubStamp = hubStamp.compressed(runtime.getVMConfig().getKlassEncoding());
    }
    AddressNode address = createOffsetAddress(graph, object, runtime.getVMConfig().hubOffset);
    LocationIdentity hubLocation = runtime.getVMConfig().useCompressedClassPointers ? COMPRESSED_HUB_LOCATION : HUB_LOCATION;
    FloatingReadNode memoryRead = graph.unique(new FloatingReadNode(address, hubLocation, null, hubStamp, null, BarrierType.NONE));
    if (runtime.getVMConfig().useCompressedClassPointers) {
        return HotSpotCompressionNode.uncompress(memoryRead, runtime.getVMConfig().getKlassEncoding());
    } else {
        return memoryRead;
    }
}
Also used : LoadHubNode(org.graalvm.compiler.nodes.extended.LoadHubNode) KlassPointerStamp(org.graalvm.compiler.hotspot.nodes.type.KlassPointerStamp) FloatingReadNode(org.graalvm.compiler.nodes.memory.FloatingReadNode) GetObjectAddressNode(org.graalvm.compiler.hotspot.nodes.GetObjectAddressNode) ComputeObjectAddressNode(org.graalvm.compiler.hotspot.nodes.ComputeObjectAddressNode) AddressNode(org.graalvm.compiler.nodes.memory.address.AddressNode) LocationIdentity(org.graalvm.word.LocationIdentity)

Example 2 with KlassPointerStamp

use of org.graalvm.compiler.hotspot.nodes.type.KlassPointerStamp in project graal by oracle.

the class AheadOfTimeCompilationTest method testPrimitiveClassObjectAOT.

@Test
public void testPrimitiveClassObjectAOT() {
    StructuredGraph result = compile("getPrimitiveClassObject", true);
    NodeIterable<ConstantNode> filter = getConstantNodes(result);
    assertDeepEquals(1, filter.count());
    Stamp constantStamp = filter.first().stamp(NodeView.DEFAULT);
    Assert.assertTrue(constantStamp instanceof KlassPointerStamp);
    int expected = runtime().getVMConfig().classMirrorIsHandle ? 3 : 2;
    assertDeepEquals(expected, result.getNodes().filter(ReadNode.class).count());
}
Also used : ConstantNode(org.graalvm.compiler.nodes.ConstantNode) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) Stamp(org.graalvm.compiler.core.common.type.Stamp) KlassPointerStamp(org.graalvm.compiler.hotspot.nodes.type.KlassPointerStamp) KlassPointerStamp(org.graalvm.compiler.hotspot.nodes.type.KlassPointerStamp) Test(org.junit.Test)

Example 3 with KlassPointerStamp

use of org.graalvm.compiler.hotspot.nodes.type.KlassPointerStamp in project graal by oracle.

the class AheadOfTimeCompilationTest method testStaticFinalObjectAOT.

@Test
public void testStaticFinalObjectAOT() {
    StructuredGraph result = compile("getStaticFinalObject", true);
    assertDeepEquals(1, getConstantNodes(result).count());
    Stamp constantStamp = getConstantNodes(result).first().stamp(NodeView.DEFAULT);
    Assert.assertTrue(constantStamp.toString(), constantStamp instanceof KlassPointerStamp);
    int expected = runtime().getVMConfig().classMirrorIsHandle ? 3 : 2;
    assertDeepEquals(expected, result.getNodes().filter(ReadNode.class).count());
}
Also used : StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) Stamp(org.graalvm.compiler.core.common.type.Stamp) KlassPointerStamp(org.graalvm.compiler.hotspot.nodes.type.KlassPointerStamp) KlassPointerStamp(org.graalvm.compiler.hotspot.nodes.type.KlassPointerStamp) Test(org.junit.Test)

Example 4 with KlassPointerStamp

use of org.graalvm.compiler.hotspot.nodes.type.KlassPointerStamp in project graal by oracle.

the class AMD64HotSpotAddressLowering method improveUncompression.

@Override
protected final boolean improveUncompression(AMD64AddressNode addr, CompressionNode compression, ValueNode other) {
    CompressEncoding encoding = compression.getEncoding();
    Scale scale = Scale.fromShift(encoding.getShift());
    if (scale == null) {
        return false;
    }
    if (heapBaseRegister != null && encoding.getBase() == heapBase) {
        if ((!generatePIC || compression.stamp(NodeView.DEFAULT) instanceof ObjectStamp) && other == null) {
            // With PIC it is only legal to do for oops since the base value may be
            // different at runtime.
            ValueNode base = compression.graph().unique(new HeapBaseNode(heapBaseRegister));
            addr.setBase(base);
        } else {
            return false;
        }
    } else if (encoding.getBase() != 0 || (generatePIC && compression.stamp(NodeView.DEFAULT) instanceof KlassPointerStamp)) {
        if (generatePIC) {
            if (other == null) {
                ValueNode base = compression.graph().unique(new GraalHotSpotVMConfigNode(config, config.MARKID_NARROW_KLASS_BASE_ADDRESS, JavaKind.Long));
                addr.setBase(base);
            } else {
                return false;
            }
        } else {
            if (updateDisplacement(addr, encoding.getBase(), false)) {
                addr.setBase(other);
            } else {
                return false;
            }
        }
    } else {
        addr.setBase(other);
    }
    addr.setScale(scale);
    addr.setIndex(compression.getValue());
    return true;
}
Also used : GraalHotSpotVMConfigNode(org.graalvm.compiler.hotspot.nodes.GraalHotSpotVMConfigNode) ObjectStamp(org.graalvm.compiler.core.common.type.ObjectStamp) KlassPointerStamp(org.graalvm.compiler.hotspot.nodes.type.KlassPointerStamp) CompressEncoding(org.graalvm.compiler.core.common.CompressEncoding) ValueNode(org.graalvm.compiler.nodes.ValueNode) Scale(org.graalvm.compiler.asm.amd64.AMD64Address.Scale)

Aggregations

KlassPointerStamp (org.graalvm.compiler.hotspot.nodes.type.KlassPointerStamp)4 Stamp (org.graalvm.compiler.core.common.type.Stamp)2 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)2 Test (org.junit.Test)2 Scale (org.graalvm.compiler.asm.amd64.AMD64Address.Scale)1 CompressEncoding (org.graalvm.compiler.core.common.CompressEncoding)1 ObjectStamp (org.graalvm.compiler.core.common.type.ObjectStamp)1 ComputeObjectAddressNode (org.graalvm.compiler.hotspot.nodes.ComputeObjectAddressNode)1 GetObjectAddressNode (org.graalvm.compiler.hotspot.nodes.GetObjectAddressNode)1 GraalHotSpotVMConfigNode (org.graalvm.compiler.hotspot.nodes.GraalHotSpotVMConfigNode)1 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)1 ValueNode (org.graalvm.compiler.nodes.ValueNode)1 LoadHubNode (org.graalvm.compiler.nodes.extended.LoadHubNode)1 FloatingReadNode (org.graalvm.compiler.nodes.memory.FloatingReadNode)1 AddressNode (org.graalvm.compiler.nodes.memory.address.AddressNode)1 LocationIdentity (org.graalvm.word.LocationIdentity)1