use of org.graalvm.compiler.nodes.virtual.VirtualBoxingNode in project graal by oracle.
the class ObjectEqualsNode method virtualizeNonVirtualComparison.
private void virtualizeNonVirtualComparison(VirtualObjectNode virtual, ValueNode other, VirtualizerTool tool) {
if (virtual instanceof VirtualBoxingNode && other.isConstant()) {
VirtualBoxingNode virtualBoxingNode = (VirtualBoxingNode) virtual;
if (virtualBoxingNode.getBoxingKind() == JavaKind.Boolean) {
JavaConstant otherUnboxed = tool.getConstantReflectionProvider().unboxPrimitive(other.asJavaConstant());
if (otherUnboxed != null && otherUnboxed.getJavaKind() == JavaKind.Boolean) {
int expectedValue = otherUnboxed.asBoolean() ? 1 : 0;
IntegerEqualsNode equals = new IntegerEqualsNode(virtualBoxingNode.getBoxedValue(tool), ConstantNode.forInt(expectedValue, graph()));
tool.addNode(equals);
tool.replaceWithValue(equals);
} else {
tool.replaceWithValue(LogicConstantNode.contradiction(graph()));
}
}
}
if (virtual.hasIdentity()) {
// one of them is virtual: they can never be the same objects
tool.replaceWithValue(LogicConstantNode.contradiction(graph()));
}
}
use of org.graalvm.compiler.nodes.virtual.VirtualBoxingNode in project graal by oracle.
the class BoxNode method virtualize.
@Override
public void virtualize(VirtualizerTool tool) {
ValueNode alias = tool.getAlias(getValue());
VirtualBoxingNode newVirtual = createVirtualBoxingNode();
assert newVirtual.getFields().length == 1;
tool.createVirtualObject(newVirtual, new ValueNode[] { alias }, Collections.<MonitorIdNode>emptyList(), false);
tool.replaceWithVirtual(newVirtual);
}
Aggregations