Search in sources :

Example 1 with VirtualBoxingNode

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()));
    }
}
Also used : VirtualBoxingNode(org.graalvm.compiler.nodes.virtual.VirtualBoxingNode) JavaConstant(jdk.vm.ci.meta.JavaConstant)

Example 2 with VirtualBoxingNode

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);
}
Also used : VirtualBoxingNode(org.graalvm.compiler.nodes.virtual.VirtualBoxingNode) ValueNode(org.graalvm.compiler.nodes.ValueNode)

Aggregations

VirtualBoxingNode (org.graalvm.compiler.nodes.virtual.VirtualBoxingNode)2 JavaConstant (jdk.vm.ci.meta.JavaConstant)1 ValueNode (org.graalvm.compiler.nodes.ValueNode)1