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