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);
}
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));
}
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;
}
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;
}
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;
}
Aggregations