Search in sources :

Example 21 with ObjectStamp

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

the class HotSpotStampMemoryAccessTest method testReadNarrowObject.

@Ignore("not all versions are safe yet")
@Test
public void testReadNarrowObject() {
    CompressEncoding oopEncoding = runtime().getVMConfig().getOopEncoding();
    Assume.assumeTrue("Compressed oops must be enabled", runtime().getVMConfig().useCompressedOops);
    MemoryAccessProvider memory = getConstantReflection().getMemoryAccessProvider();
    JavaConstant base = getSnippetReflection().forObject("");
    ObjectStamp stamp = (ObjectStamp) StampFactory.forKind(JavaKind.Object);
    Stamp narrowStamp = HotSpotNarrowOopStamp.compressed(stamp, oopEncoding);
    assertTrue(narrowStamp.readConstant(memory, base, 128) == null);
}
Also used : MemoryAccessProvider(jdk.vm.ci.meta.MemoryAccessProvider) ObjectStamp(org.graalvm.compiler.core.common.type.ObjectStamp) ObjectStamp(org.graalvm.compiler.core.common.type.ObjectStamp) HotSpotNarrowOopStamp(org.graalvm.compiler.hotspot.nodes.type.HotSpotNarrowOopStamp) Stamp(org.graalvm.compiler.core.common.type.Stamp) CompressEncoding(org.graalvm.compiler.core.common.CompressEncoding) JavaConstant(jdk.vm.ci.meta.JavaConstant) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 22 with ObjectStamp

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

the class ReplaceConstantNodesPhase method handleLoadMethodCounters.

/**
 * Replace {@link LoadMethodCountersNode} with indirect load
 * {@link ResolveMethodAndLoadCountersNode}, expose a klass constant of the holder.
 *
 * @param graph
 * @param stateMapper
 * @param node
 * @param context
 */
private static void handleLoadMethodCounters(StructuredGraph graph, FrameStateMapperClosure stateMapper, LoadMethodCountersNode node, PhaseContext context) {
    ResolvedJavaType type = node.getMethod().getDeclaringClass();
    Stamp hubStamp = context.getStampProvider().createHubStamp((ObjectStamp) StampFactory.objectNonNull());
    ConstantReflectionProvider constantReflection = context.getConstantReflection();
    ConstantNode klassHint = ConstantNode.forConstant(hubStamp, constantReflection.asObjectHub(type), context.getMetaAccess(), graph);
    FixedWithNextNode replacement = graph.add(new ResolveMethodAndLoadCountersNode(node.getMethod(), klassHint));
    insertReplacement(graph, stateMapper, node, replacement);
    node.replaceAtUsages(replacement, n -> !(n instanceof ResolveMethodAndLoadCountersNode));
}
Also used : FixedWithNextNode(org.graalvm.compiler.nodes.FixedWithNextNode) ResolveDynamicConstantNode(org.graalvm.compiler.hotspot.nodes.aot.ResolveDynamicConstantNode) ResolveConstantNode(org.graalvm.compiler.hotspot.nodes.aot.ResolveConstantNode) ConstantNode(org.graalvm.compiler.nodes.ConstantNode) ObjectStamp(org.graalvm.compiler.core.common.type.ObjectStamp) Stamp(org.graalvm.compiler.core.common.type.Stamp) ResolveMethodAndLoadCountersNode(org.graalvm.compiler.hotspot.nodes.aot.ResolveMethodAndLoadCountersNode) ConstantReflectionProvider(jdk.vm.ci.meta.ConstantReflectionProvider) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType) HotSpotResolvedJavaType(jdk.vm.ci.hotspot.HotSpotResolvedJavaType)

Example 23 with ObjectStamp

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

the class KlassLayoutHelperNode method inferStamp.

@Override
public boolean inferStamp() {
    if (klass instanceof LoadHubNode) {
        LoadHubNode hub = (LoadHubNode) klass;
        Stamp hubStamp = hub.getValue().stamp(NodeView.DEFAULT);
        if (hubStamp instanceof ObjectStamp) {
            ObjectStamp objectStamp = (ObjectStamp) hubStamp;
            ResolvedJavaType type = objectStamp.type();
            if (type != null && !type.isJavaLangObject()) {
                if (!type.isArray() && !type.isInterface()) {
                    /*
                         * Definitely some form of instance type.
                         */
                    return updateStamp(StampFactory.forInteger(JavaKind.Int, config.klassLayoutHelperNeutralValue, Integer.MAX_VALUE));
                }
                if (type.isArray()) {
                    return updateStamp(StampFactory.forInteger(JavaKind.Int, Integer.MIN_VALUE, config.klassLayoutHelperNeutralValue - 1));
                }
            }
        }
    }
    return false;
}
Also used : LoadHubNode(org.graalvm.compiler.nodes.extended.LoadHubNode) ObjectStamp(org.graalvm.compiler.core.common.type.ObjectStamp) Stamp(org.graalvm.compiler.core.common.type.Stamp) ObjectStamp(org.graalvm.compiler.core.common.type.ObjectStamp) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType)

Example 24 with ObjectStamp

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

the class KlassLayoutHelperNode method canonical.

private static ValueNode canonical(KlassLayoutHelperNode klassLayoutHelperNode, GraalHotSpotVMConfig config, ValueNode klass, Stamp stamp, ConstantReflectionProvider constantReflection, MetaAccessProvider metaAccess) {
    KlassLayoutHelperNode self = klassLayoutHelperNode;
    if (klass.isConstant()) {
        if (!klass.asConstant().isDefaultForKind()) {
            Constant constant = stamp.readConstant(constantReflection.getMemoryAccessProvider(), klass.asConstant(), config.klassLayoutHelperOffset);
            return ConstantNode.forConstant(stamp, constant, metaAccess);
        }
    }
    if (klass instanceof LoadHubNode) {
        LoadHubNode hub = (LoadHubNode) klass;
        Stamp hubStamp = hub.getValue().stamp(NodeView.DEFAULT);
        if (hubStamp instanceof ObjectStamp) {
            ObjectStamp ostamp = (ObjectStamp) hubStamp;
            HotSpotResolvedObjectType type = (HotSpotResolvedObjectType) ostamp.type();
            if (type != null && type.isArray() && !type.getComponentType().isPrimitive()) {
                // The layout for all object arrays is the same.
                Constant constant = stamp.readConstant(constantReflection.getMemoryAccessProvider(), type.klass(), config.klassLayoutHelperOffset);
                return ConstantNode.forConstant(stamp, constant, metaAccess);
            }
        }
    }
    if (self == null) {
        self = new KlassLayoutHelperNode(config, klass);
    }
    return self;
}
Also used : LoadHubNode(org.graalvm.compiler.nodes.extended.LoadHubNode) ObjectStamp(org.graalvm.compiler.core.common.type.ObjectStamp) Stamp(org.graalvm.compiler.core.common.type.Stamp) ObjectStamp(org.graalvm.compiler.core.common.type.ObjectStamp) Constant(jdk.vm.ci.meta.Constant) HotSpotResolvedObjectType(jdk.vm.ci.hotspot.HotSpotResolvedObjectType)

Example 25 with ObjectStamp

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

the class GraphUtil method skipPiWhileNonNull.

public static ValueNode skipPiWhileNonNull(ValueNode node) {
    ValueNode n = node;
    while (n instanceof PiNode) {
        PiNode piNode = (PiNode) n;
        ObjectStamp originalStamp = (ObjectStamp) piNode.getOriginalNode().stamp(NodeView.DEFAULT);
        if (originalStamp.nonNull()) {
            n = piNode.getOriginalNode();
        } else {
            break;
        }
    }
    return n;
}
Also used : ObjectStamp(org.graalvm.compiler.core.common.type.ObjectStamp) ValueNode(org.graalvm.compiler.nodes.ValueNode) PiNode(org.graalvm.compiler.nodes.PiNode)

Aggregations

ObjectStamp (org.graalvm.compiler.core.common.type.ObjectStamp)31 ValueNode (org.graalvm.compiler.nodes.ValueNode)14 Stamp (org.graalvm.compiler.core.common.type.Stamp)12 ResolvedJavaType (jdk.vm.ci.meta.ResolvedJavaType)10 FixedGuardNode (org.graalvm.compiler.nodes.FixedGuardNode)8 Node (org.graalvm.compiler.graph.Node)6 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)6 ParameterNode (org.graalvm.compiler.nodes.ParameterNode)6 PiNode (org.graalvm.compiler.nodes.PiNode)6 TypeReference (org.graalvm.compiler.core.common.type.TypeReference)5 LogicNode (org.graalvm.compiler.nodes.LogicNode)5 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)4 JavaConstant (jdk.vm.ci.meta.JavaConstant)3 JavaType (jdk.vm.ci.meta.JavaType)3 AbstractBeginNode (org.graalvm.compiler.nodes.AbstractBeginNode)3 LoadHubNode (org.graalvm.compiler.nodes.extended.LoadHubNode)3 LoadFieldNode (org.graalvm.compiler.nodes.java.LoadFieldNode)3 MethodCallTargetNode (org.graalvm.compiler.nodes.java.MethodCallTargetNode)3 HotSpotResolvedObjectType (jdk.vm.ci.hotspot.HotSpotResolvedObjectType)2 Constant (jdk.vm.ci.meta.Constant)2