use of org.graalvm.compiler.nodes.type.NarrowOopStamp in project graal by oracle.
the class SubstrateGraphBuilderPlugins method registerReferenceAccessPlugins.
private static void registerReferenceAccessPlugins(InvocationPlugins plugins) {
Registration r = new Registration(plugins, ReferenceAccessImpl.class);
r.register(new RequiredInvocationPlugin("getCompressedRepresentation", Receiver.class, Object.class) {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver unused, ValueNode objectNode) {
if (ReferenceAccess.singleton().haveCompressedReferences()) {
ValueNode compressedObj = SubstrateCompressionNode.compress(objectNode, ImageSingletons.lookup(CompressEncoding.class));
JavaKind compressedIntKind = JavaKind.fromWordSize(ConfigurationValues.getObjectLayout().getReferenceSize());
ValueNode compressedValue = b.add(WordCastNode.narrowOopToUntrackedWord(compressedObj, compressedIntKind));
b.addPush(JavaKind.Object, ZeroExtendNode.convertUnsigned(compressedValue, FrameAccess.getWordStamp(), NodeView.DEFAULT));
} else {
b.addPush(JavaKind.Object, WordCastNode.objectToUntrackedPointer(objectNode, FrameAccess.getWordKind()));
}
return true;
}
});
r.register(new RequiredInvocationPlugin("uncompressReference", Receiver.class, UnsignedWord.class) {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver unused, ValueNode wordNode) {
if (ReferenceAccess.singleton().haveCompressedReferences()) {
CompressEncoding encoding = ImageSingletons.lookup(CompressEncoding.class);
JavaKind compressedIntKind = JavaKind.fromWordSize(ConfigurationValues.getObjectLayout().getReferenceSize());
NarrowOopStamp compressedStamp = (NarrowOopStamp) SubstrateNarrowOopStamp.compressed((AbstractObjectStamp) StampFactory.object(), encoding);
ValueNode narrowNode = b.add(NarrowNode.convertUnsigned(wordNode, StampFactory.forKind(compressedIntKind), NodeView.DEFAULT));
WordCastNode compressedObj = b.add(WordCastNode.wordToNarrowObject(narrowNode, compressedStamp));
b.addPush(JavaKind.Object, SubstrateCompressionNode.uncompress(compressedObj, encoding));
} else {
b.addPush(JavaKind.Object, WordCastNode.wordToObject(wordNode, FrameAccess.getWordKind()));
}
return true;
}
});
}
Aggregations