Search in sources :

Example 1 with NarrowOopStamp

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;
        }
    });
}
Also used : WordCastNode(org.graalvm.compiler.word.WordCastNode) SubstrateNarrowOopStamp(com.oracle.svm.core.graal.nodes.SubstrateNarrowOopStamp) NarrowOopStamp(org.graalvm.compiler.nodes.type.NarrowOopStamp) UnsignedWord(org.graalvm.word.UnsignedWord) RequiredInvocationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.RequiredInvocationPlugin) CompressEncoding(org.graalvm.compiler.core.common.CompressEncoding) Receiver(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.Receiver) GraphBuilderContext(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext) Registration(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration) StackValueNode(com.oracle.svm.core.graal.stackvalue.StackValueNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod) JavaKind(jdk.vm.ci.meta.JavaKind)

Aggregations

SubstrateNarrowOopStamp (com.oracle.svm.core.graal.nodes.SubstrateNarrowOopStamp)1 StackValueNode (com.oracle.svm.core.graal.stackvalue.StackValueNode)1 JavaKind (jdk.vm.ci.meta.JavaKind)1 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)1 CompressEncoding (org.graalvm.compiler.core.common.CompressEncoding)1 ValueNode (org.graalvm.compiler.nodes.ValueNode)1 GraphBuilderContext (org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext)1 Receiver (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.Receiver)1 RequiredInvocationPlugin (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.RequiredInvocationPlugin)1 Registration (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration)1 NarrowOopStamp (org.graalvm.compiler.nodes.type.NarrowOopStamp)1 WordCastNode (org.graalvm.compiler.word.WordCastNode)1 UnsignedWord (org.graalvm.word.UnsignedWord)1