Search in sources :

Example 1 with ComputeObjectAddressNode

use of org.graalvm.compiler.nodes.ComputeObjectAddressNode in project graal by oracle.

the class HotSpotGraphBuilderPlugins method registerCRC32CPlugins.

private static void registerCRC32CPlugins(InvocationPlugins plugins, GraalHotSpotVMConfig config, Replacements replacements) {
    Registration r = new Registration(plugins, "java.util.zip.CRC32C", replacements);
    r.registerConditional(config.useCRC32CIntrinsics(), new InvocationPlugin("updateBytes", int.class, byte[].class, int.class, int.class) {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode crc, ValueNode buf, ValueNode off, ValueNode end) {
            int byteArrayBaseOffset = b.getMetaAccess().getArrayBaseOffset(JavaKind.Byte);
            ValueNode bufAddr = b.add(new ComputeObjectAddressNode(buf, new AddNode(ConstantNode.forInt(byteArrayBaseOffset), off)));
            b.addPush(JavaKind.Int, new ForeignCallNode(UPDATE_BYTES_CRC32C, crc, bufAddr, new SubNode(end, off)));
            return true;
        }
    });
    r.registerConditional(config.useCRC32CIntrinsics(), new InvocationPlugin("updateDirectByteBuffer", int.class, long.class, int.class, int.class) {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode crc, ValueNode addr, ValueNode off, ValueNode end) {
            ValueNode bufAddr = b.add(new AddNode(addr, new SignExtendNode(off, 32, 64)));
            b.addPush(JavaKind.Int, new ForeignCallNode(UPDATE_BYTES_CRC32C, crc, bufAddr, new SubNode(end, off)));
            return true;
        }
    });
}
Also used : ForeignCallNode(org.graalvm.compiler.nodes.extended.ForeignCallNode) SubNode(org.graalvm.compiler.nodes.calc.SubNode) SignExtendNode(org.graalvm.compiler.nodes.calc.SignExtendNode) GraphBuilderContext(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext) ComputeObjectAddressNode(org.graalvm.compiler.nodes.ComputeObjectAddressNode) Registration(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration) ValueNode(org.graalvm.compiler.nodes.ValueNode) InvocationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin) SnippetSubstitutionInvocationPlugin(org.graalvm.compiler.replacements.SnippetSubstitutionInvocationPlugin) InlineOnlyInvocationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.InlineOnlyInvocationPlugin) Receiver(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.Receiver) AddNode(org.graalvm.compiler.nodes.calc.AddNode) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 2 with ComputeObjectAddressNode

use of org.graalvm.compiler.nodes.ComputeObjectAddressNode in project graal by oracle.

the class HotSpotGraphBuilderPlugins method registerGHASHPlugins.

private static void registerGHASHPlugins(InvocationPlugins plugins, GraalHotSpotVMConfig config, MetaAccessProvider metaAccess, Replacements replacements) {
    Registration r = new Registration(plugins, "com.sun.crypto.provider.GHASH", replacements);
    r.registerConditional(config.useGHASHIntrinsics(), new InvocationPlugin("processBlocks", byte[].class, int.class, int.class, long[].class, long[].class) {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode data, ValueNode inOffset, ValueNode blocks, ValueNode state, ValueNode hashSubkey) {
            int longArrayBaseOffset = metaAccess.getArrayBaseOffset(JavaKind.Long);
            int byteArrayBaseOffset = metaAccess.getArrayBaseOffset(JavaKind.Byte);
            ValueNode dataOffset = AddNode.create(ConstantNode.forInt(byteArrayBaseOffset), inOffset, NodeView.DEFAULT);
            ComputeObjectAddressNode dataAddress = b.add(new ComputeObjectAddressNode(data, dataOffset));
            ComputeObjectAddressNode stateAddress = b.add(new ComputeObjectAddressNode(state, ConstantNode.forInt(longArrayBaseOffset)));
            ComputeObjectAddressNode hashSubkeyAddress = b.add(new ComputeObjectAddressNode(hashSubkey, ConstantNode.forInt(longArrayBaseOffset)));
            b.add(new ForeignCallNode(GHASH_PROCESS_BLOCKS, stateAddress, hashSubkeyAddress, dataAddress, blocks));
            return true;
        }
    });
}
Also used : ForeignCallNode(org.graalvm.compiler.nodes.extended.ForeignCallNode) GraphBuilderContext(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext) ComputeObjectAddressNode(org.graalvm.compiler.nodes.ComputeObjectAddressNode) Registration(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration) ValueNode(org.graalvm.compiler.nodes.ValueNode) InvocationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin) SnippetSubstitutionInvocationPlugin(org.graalvm.compiler.replacements.SnippetSubstitutionInvocationPlugin) InlineOnlyInvocationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.InlineOnlyInvocationPlugin) Receiver(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.Receiver) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 3 with ComputeObjectAddressNode

use of org.graalvm.compiler.nodes.ComputeObjectAddressNode in project graal by oracle.

the class InvocationPluginHelper method arrayElementPointer.

public ValueNode arrayElementPointer(ValueNode array, JavaKind kind, ValueNode index) {
    // The visible type of the stamp should either be array type or Object. It's sometimes
    // Object because of cycles that hide the underlying type.
    ResolvedJavaType type = StampTool.typeOrNull(array);
    assert type == null || (type.isArray() && type.getComponentType().getJavaKind() == kind) || type.isJavaLangObject() : array.stamp(NodeView.DEFAULT);
    int arrayBaseOffset = b.getMetaAccess().getArrayBaseOffset(kind);
    ValueNode offset = ConstantNode.forInt(arrayBaseOffset);
    if (index != null) {
        offset = add(offset, scale(index, kind));
    }
    return b.add(new ComputeObjectAddressNode(array, asWord(offset)));
}
Also used : ComputeObjectAddressNode(org.graalvm.compiler.nodes.ComputeObjectAddressNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType)

Example 4 with ComputeObjectAddressNode

use of org.graalvm.compiler.nodes.ComputeObjectAddressNode in project graal by oracle.

the class HotSpotGraphBuilderPlugins method registerBase64Plugins.

private static void registerBase64Plugins(InvocationPlugins plugins, GraalHotSpotVMConfig config, MetaAccessProvider metaAccess, Replacements replacements) {
    Registration r = new Registration(plugins, "java.util.Base64$Encoder", replacements);
    r.registerConditional(config.useBase64Intrinsics(), new InvocationPlugin("encodeBlock", Receiver.class, byte[].class, int.class, int.class, byte[].class, int.class, boolean.class) {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode src, ValueNode sp, ValueNode sl, ValueNode dst, ValueNode dp, ValueNode isURL) {
            int byteArrayBaseOffset = metaAccess.getArrayBaseOffset(JavaKind.Byte);
            ComputeObjectAddressNode srcAddress = b.add(new ComputeObjectAddressNode(src, ConstantNode.forInt(byteArrayBaseOffset)));
            ComputeObjectAddressNode dstAddress = b.add(new ComputeObjectAddressNode(dst, ConstantNode.forInt(byteArrayBaseOffset)));
            b.add(new ForeignCallNode(BASE64_ENCODE_BLOCK, srcAddress, sp, sl, dstAddress, dp, isURL));
            return true;
        }
    });
}
Also used : ForeignCallNode(org.graalvm.compiler.nodes.extended.ForeignCallNode) GraphBuilderContext(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext) ComputeObjectAddressNode(org.graalvm.compiler.nodes.ComputeObjectAddressNode) Registration(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration) ValueNode(org.graalvm.compiler.nodes.ValueNode) InvocationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin) SnippetSubstitutionInvocationPlugin(org.graalvm.compiler.replacements.SnippetSubstitutionInvocationPlugin) InlineOnlyInvocationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.InlineOnlyInvocationPlugin) Receiver(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.Receiver) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 5 with ComputeObjectAddressNode

use of org.graalvm.compiler.nodes.ComputeObjectAddressNode in project graal by oracle.

the class HotSpotGraphBuilderPlugins method registerArraysSupportPlugins.

private static void registerArraysSupportPlugins(InvocationPlugins plugins, GraalHotSpotVMConfig config, Replacements replacements) {
    Registration r = new Registration(plugins, "jdk.internal.util.ArraysSupport", replacements);
    r.registerConditional(config.useVectorizedMismatchIntrinsic(), new InvocationPlugin("vectorizedMismatch", Object.class, long.class, Object.class, long.class, int.class, int.class) {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode a, ValueNode aOffset, ValueNode bObject, ValueNode bOffset, ValueNode length, ValueNode log2ArrayIndexScale) {
            ValueNode aAddr = b.add(new ComputeObjectAddressNode(a, aOffset));
            ValueNode bAddr = b.add(new ComputeObjectAddressNode(bObject, bOffset));
            b.addPush(JavaKind.Int, new ForeignCallNode(HotSpotBackend.VECTORIZED_MISMATCH, aAddr, bAddr, length, log2ArrayIndexScale));
            return true;
        }
    });
}
Also used : ForeignCallNode(org.graalvm.compiler.nodes.extended.ForeignCallNode) GraphBuilderContext(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext) ComputeObjectAddressNode(org.graalvm.compiler.nodes.ComputeObjectAddressNode) Registration(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration) ValueNode(org.graalvm.compiler.nodes.ValueNode) InvocationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin) SnippetSubstitutionInvocationPlugin(org.graalvm.compiler.replacements.SnippetSubstitutionInvocationPlugin) InlineOnlyInvocationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.InlineOnlyInvocationPlugin) Receiver(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.Receiver) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Aggregations

ComputeObjectAddressNode (org.graalvm.compiler.nodes.ComputeObjectAddressNode)7 ValueNode (org.graalvm.compiler.nodes.ValueNode)7 ForeignCallNode (org.graalvm.compiler.nodes.extended.ForeignCallNode)6 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)5 GraphBuilderContext (org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext)5 InvocationPlugin (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin)5 InlineOnlyInvocationPlugin (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.InlineOnlyInvocationPlugin)5 Receiver (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.Receiver)5 Registration (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration)5 SnippetSubstitutionInvocationPlugin (org.graalvm.compiler.replacements.SnippetSubstitutionInvocationPlugin)5 AddNode (org.graalvm.compiler.nodes.calc.AddNode)3 SignExtendNode (org.graalvm.compiler.nodes.calc.SignExtendNode)3 LeftShiftNode (org.graalvm.compiler.nodes.calc.LeftShiftNode)2 SubNode (org.graalvm.compiler.nodes.calc.SubNode)2 JavaReadNode (org.graalvm.compiler.nodes.extended.JavaReadNode)2 AddressNode (org.graalvm.compiler.nodes.memory.address.AddressNode)2 OffsetAddressNode (org.graalvm.compiler.nodes.memory.address.OffsetAddressNode)2 ResolvedJavaType (jdk.vm.ci.meta.ResolvedJavaType)1 Node (org.graalvm.compiler.graph.Node)1 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)1