use of org.graalvm.compiler.nodes.ComputeObjectAddressNode in project graal by oracle.
the class HotSpotGraphBuilderPlugins method registerCRC32Plugins.
private static void registerCRC32Plugins(InvocationPlugins plugins, GraalHotSpotVMConfig config, Replacements replacements) {
Registration r = new Registration(plugins, CRC32.class, replacements);
r.registerConditional(config.useCRC32Intrinsics() && config.crcTableAddress != 0, new InvocationPlugin("update", int.class, int.class) {
@Override
public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode crc, ValueNode arg) {
final ValueNode crcTableRawAddress = ConstantNode.forLong(config.crcTableAddress);
ValueNode c = new XorNode(crc, ConstantNode.forInt(-1));
ValueNode index = new AndNode(new XorNode(arg, c), ConstantNode.forInt(0xff));
ValueNode offset = new LeftShiftNode(index, ConstantNode.forInt(2));
AddressNode address = new OffsetAddressNode(crcTableRawAddress, new SignExtendNode(offset, 32, 64));
ValueNode result = b.add(new JavaReadNode(JavaKind.Int, address, CRC_TABLE_LOCATION, BarrierType.NONE, false));
result = new XorNode(result, new UnsignedRightShiftNode(c, ConstantNode.forInt(8)));
b.addPush(JavaKind.Int, new XorNode(result, ConstantNode.forInt(-1)));
return true;
}
});
r.registerConditional(config.useCRC32Intrinsics(), new InvocationPlugin("updateBytes0", 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 len) {
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_CRC32, crc, bufAddr, len));
return true;
}
});
r.registerConditional(config.useCRC32Intrinsics(), new InvocationPlugin("updateByteBuffer0", 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 len) {
ValueNode bufAddr = b.add(new AddNode(addr, new SignExtendNode(off, 32, 64)));
b.addPush(JavaKind.Int, new ForeignCallNode(UPDATE_BYTES_CRC32, crc, bufAddr, len));
return true;
}
});
}
use of org.graalvm.compiler.nodes.ComputeObjectAddressNode in project graal by oracle.
the class DefaultJavaLoweringProvider method lowerComputeObjectAddressNode.
private static void lowerComputeObjectAddressNode(ComputeObjectAddressNode n) {
/*
* Lower the node into a GetObjectAddressNode node and an Add but ensure that it's below any
* potential safepoints and above it's uses.
*/
for (Node use : n.usages().snapshot()) {
FixedNode fixed;
if (use instanceof FixedNode) {
fixed = (FixedNode) use;
} else if (use instanceof ValuePhiNode) {
ValuePhiNode phi = (ValuePhiNode) use;
int inputPosition = 0;
while (inputPosition < phi.valueCount()) {
if (phi.valueAt(inputPosition) == n) {
break;
}
inputPosition++;
}
GraalError.guarantee(inputPosition < phi.valueCount(), "Failed to find expected input");
fixed = phi.merge().phiPredecessorAt(inputPosition);
} else {
throw GraalError.shouldNotReachHere("Unexpected floating use of ComputeObjectAddressNode " + n);
}
StructuredGraph graph = n.graph();
GetObjectAddressNode address = graph.add(new GetObjectAddressNode(n.getObject()));
graph.addBeforeFixed(fixed, address);
AddNode add = graph.addOrUnique(new AddNode(address, n.getOffset()));
use.replaceFirstInput(n, add);
}
GraphUtil.unlinkFixedNode(n);
n.safeDelete();
}
Aggregations