Search in sources :

Example 6 with AbstractObjectStamp

use of org.graalvm.compiler.core.common.type.AbstractObjectStamp in project graal by oracle.

the class ObjectStampTest method testInterfaceTrust1.

@Test
public void testInterfaceTrust1() {
    Stamp trusted = StampFactory.object(getType(TrustedI.class));
    Assert.assertNotEquals(StampFactory.object(), trusted);
    Assert.assertTrue("Should be an AbstractObjectStamp", trusted instanceof AbstractObjectStamp);
    AbstractObjectStamp trustedObjectStamp = (AbstractObjectStamp) trusted;
    Assert.assertNotNull(trustedObjectStamp.type());
    Assert.assertTrue("Should be an interface", trustedObjectStamp.type().isInterface());
}
Also used : AbstractObjectStamp(org.graalvm.compiler.core.common.type.AbstractObjectStamp) Stamp(org.graalvm.compiler.core.common.type.Stamp) AbstractObjectStamp(org.graalvm.compiler.core.common.type.AbstractObjectStamp) Test(org.junit.Test)

Example 7 with AbstractObjectStamp

use of org.graalvm.compiler.core.common.type.AbstractObjectStamp in project graal by oracle.

the class IdentityHashCodeNode method canonical.

@Override
public Node canonical(CanonicalizerTool tool) {
    if (object.isConstant()) {
        assert object.stamp(NodeView.DEFAULT) instanceof AbstractObjectStamp;
        JavaConstant c = (JavaConstant) object.asConstant();
        if (ImmutableCode.getValue(tool.getOptions())) {
            return this;
        }
        JavaConstant identityHashCode = null;
        if (c.isNull()) {
            identityHashCode = JavaConstant.forInt(0);
        } else {
            identityHashCode = JavaConstant.forInt(((HotSpotObjectConstant) c).getIdentityHashCode());
        }
        return new ConstantNode(identityHashCode, StampFactory.forConstant(identityHashCode));
    }
    return this;
}
Also used : ConstantNode(org.graalvm.compiler.nodes.ConstantNode) AbstractObjectStamp(org.graalvm.compiler.core.common.type.AbstractObjectStamp) JavaConstant(jdk.vm.ci.meta.JavaConstant) HotSpotObjectConstant(jdk.vm.ci.hotspot.HotSpotObjectConstant)

Aggregations

AbstractObjectStamp (org.graalvm.compiler.core.common.type.AbstractObjectStamp)7 Stamp (org.graalvm.compiler.core.common.type.Stamp)3 HotSpotObjectConstant (jdk.vm.ci.hotspot.HotSpotObjectConstant)2 ResolvedJavaType (jdk.vm.ci.meta.ResolvedJavaType)2 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)2 HostedType (com.oracle.svm.hosted.meta.HostedType)1 HotSpotResolvedJavaField (jdk.vm.ci.hotspot.HotSpotResolvedJavaField)1 HotSpotResolvedObjectType (jdk.vm.ci.hotspot.HotSpotResolvedObjectType)1 HotSpotResolvedPrimitiveType (jdk.vm.ci.hotspot.HotSpotResolvedPrimitiveType)1 ConstantReflectionProvider (jdk.vm.ci.meta.ConstantReflectionProvider)1 JavaConstant (jdk.vm.ci.meta.JavaConstant)1 MetaAccessProvider (jdk.vm.ci.meta.MetaAccessProvider)1 PrimitiveConstant (jdk.vm.ci.meta.PrimitiveConstant)1 Value (jdk.vm.ci.meta.Value)1 FloatStamp (org.graalvm.compiler.core.common.type.FloatStamp)1 IntegerStamp (org.graalvm.compiler.core.common.type.IntegerStamp)1 ObjectStamp (org.graalvm.compiler.core.common.type.ObjectStamp)1 TypeReference (org.graalvm.compiler.core.common.type.TypeReference)1 GraalError (org.graalvm.compiler.debug.GraalError)1 HotSpotNarrowOopStamp (org.graalvm.compiler.hotspot.nodes.type.HotSpotNarrowOopStamp)1