Search in sources :

Example 1 with VirtualObjectNode

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

the class GetClassNode method virtualize.

@Override
public void virtualize(VirtualizerTool tool) {
    ValueNode alias = tool.getAlias(getObject());
    if (alias instanceof VirtualObjectNode) {
        VirtualObjectNode virtual = (VirtualObjectNode) alias;
        Constant javaClass = tool.getConstantReflectionProvider().asJavaClass(virtual.type());
        tool.replaceWithValue(ConstantNode.forConstant(stamp(NodeView.DEFAULT), javaClass, tool.getMetaAccessProvider(), graph()));
    }
}
Also used : VirtualObjectNode(org.graalvm.compiler.nodes.virtual.VirtualObjectNode) Constant(jdk.vm.ci.meta.Constant) ValueNode(org.graalvm.compiler.nodes.ValueNode)

Example 2 with VirtualObjectNode

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

the class MonitorExitNode method virtualize.

@Override
public void virtualize(VirtualizerTool tool) {
    ValueNode alias = tool.getAlias(object());
    if (alias instanceof VirtualObjectNode) {
        VirtualObjectNode virtual = (VirtualObjectNode) alias;
        if (virtual.hasIdentity()) {
            MonitorIdNode removedLock = tool.removeLock(virtual);
            assert removedLock == getMonitorId() : "mismatch at " + this + ": " + removedLock + " vs. " + getMonitorId();
            tool.delete();
        }
    }
}
Also used : VirtualObjectNode(org.graalvm.compiler.nodes.virtual.VirtualObjectNode) ValueNode(org.graalvm.compiler.nodes.ValueNode)

Example 3 with VirtualObjectNode

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

the class StoreFieldNode method virtualize.

@Override
public void virtualize(VirtualizerTool tool) {
    ValueNode alias = tool.getAlias(object());
    if (alias instanceof VirtualObjectNode) {
        VirtualInstanceNode virtual = (VirtualInstanceNode) alias;
        int fieldIndex = virtual.fieldIndex(field());
        if (fieldIndex != -1) {
            tool.setVirtualEntry(virtual, fieldIndex, value());
            tool.delete();
        }
    }
}
Also used : VirtualObjectNode(org.graalvm.compiler.nodes.virtual.VirtualObjectNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) VirtualInstanceNode(org.graalvm.compiler.nodes.virtual.VirtualInstanceNode)

Example 4 with VirtualObjectNode

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

the class RawLoadNode method virtualize.

@Override
public void virtualize(VirtualizerTool tool) {
    ValueNode alias = tool.getAlias(object());
    if (alias instanceof VirtualObjectNode) {
        VirtualObjectNode virtual = (VirtualObjectNode) alias;
        ValueNode offsetValue = tool.getAlias(offset());
        if (offsetValue.isConstant()) {
            long off = offsetValue.asJavaConstant().asLong();
            int entryIndex = virtual.entryIndexForOffset(tool.getArrayOffsetProvider(), off, accessKind());
            if (entryIndex != -1) {
                ValueNode entry = tool.getEntry(virtual, entryIndex);
                JavaKind entryKind = virtual.entryKind(entryIndex);
                if (entry.getStackKind() == getStackKind() || entryKind == accessKind()) {
                    if (!(entry.stamp(NodeView.DEFAULT).isCompatible(stamp(NodeView.DEFAULT)))) {
                        if (entry.stamp(NodeView.DEFAULT) instanceof PrimitiveStamp && stamp instanceof PrimitiveStamp) {
                            PrimitiveStamp p1 = (PrimitiveStamp) stamp;
                            PrimitiveStamp p2 = (PrimitiveStamp) entry.stamp(NodeView.DEFAULT);
                            int width1 = p1.getBits();
                            int width2 = p2.getBits();
                            if (width1 == width2) {
                                Node replacement = ReinterpretNode.create(p2, entry, NodeView.DEFAULT);
                                tool.replaceWith((ValueNode) replacement);
                                return;
                            } else {
                                // different bit width
                                return;
                            }
                        } else {
                            // cannot reinterpret for arbitrary objects
                            return;
                        }
                    }
                    tool.replaceWith(entry);
                }
            }
        }
    }
}
Also used : VirtualObjectNode(org.graalvm.compiler.nodes.virtual.VirtualObjectNode) LoadFieldNode(org.graalvm.compiler.nodes.java.LoadFieldNode) ConstantNode(org.graalvm.compiler.nodes.ConstantNode) ReinterpretNode(org.graalvm.compiler.nodes.calc.ReinterpretNode) VirtualObjectNode(org.graalvm.compiler.nodes.virtual.VirtualObjectNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) Node(org.graalvm.compiler.graph.Node) ValueNode(org.graalvm.compiler.nodes.ValueNode) PrimitiveStamp(org.graalvm.compiler.core.common.type.PrimitiveStamp) JavaKind(jdk.vm.ci.meta.JavaKind)

Example 5 with VirtualObjectNode

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

the class RawStoreNode method virtualize.

@Override
public void virtualize(VirtualizerTool tool) {
    ValueNode alias = tool.getAlias(object());
    if (alias instanceof VirtualObjectNode) {
        VirtualObjectNode virtual = (VirtualObjectNode) alias;
        ValueNode indexValue = tool.getAlias(offset());
        if (indexValue.isConstant()) {
            long off = indexValue.asJavaConstant().asLong();
            int entryIndex = virtual.entryIndexForOffset(tool.getArrayOffsetProvider(), off, accessKind());
            if (entryIndex != -1 && tool.setVirtualEntry(virtual, entryIndex, value(), accessKind(), off)) {
                tool.delete();
            }
        }
    }
}
Also used : VirtualObjectNode(org.graalvm.compiler.nodes.virtual.VirtualObjectNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) MemoryCheckpoint(org.graalvm.compiler.nodes.memory.MemoryCheckpoint)

Aggregations

VirtualObjectNode (org.graalvm.compiler.nodes.virtual.VirtualObjectNode)42 ValueNode (org.graalvm.compiler.nodes.ValueNode)38 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)8 ResolvedJavaType (jdk.vm.ci.meta.ResolvedJavaType)7 Node (org.graalvm.compiler.graph.Node)7 ProxyNode (org.graalvm.compiler.nodes.ProxyNode)7 VirtualObjectState (org.graalvm.compiler.virtual.nodes.VirtualObjectState)6 FixedNode (org.graalvm.compiler.nodes.FixedNode)5 PhiNode (org.graalvm.compiler.nodes.PhiNode)5 Block (org.graalvm.compiler.nodes.cfg.Block)5 ArrayList (java.util.ArrayList)4 FixedWithNextNode (org.graalvm.compiler.nodes.FixedWithNextNode)4 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)4 ValueProxyNode (org.graalvm.compiler.nodes.ValueProxyNode)4 VirtualArrayNode (org.graalvm.compiler.nodes.virtual.VirtualArrayNode)4 VirtualInstanceNode (org.graalvm.compiler.nodes.virtual.VirtualInstanceNode)4 JavaKind (jdk.vm.ci.meta.JavaKind)3 FrameState (org.graalvm.compiler.nodes.FrameState)3 LoopBeginNode (org.graalvm.compiler.nodes.LoopBeginNode)3 BitSet (java.util.BitSet)2