Search in sources :

Example 36 with ValueNode

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

the class EnsureVirtualizedNode method virtualize.

@Override
public void virtualize(VirtualizerTool tool) {
    ValueNode alias = tool.getAlias(object);
    if (alias instanceof VirtualObjectNode) {
        VirtualObjectNode virtual = (VirtualObjectNode) alias;
        if (virtual instanceof VirtualBoxingNode) {
            Throwable exception = new VerificationError("ensureVirtual is not valid for boxing objects: %s", virtual.type().getName());
            throw GraphUtil.approxSourceException(this, exception);
        }
        if (!localOnly) {
            tool.setEnsureVirtualized(virtual, true);
        }
        tool.delete();
    }
}
Also used : VerificationError(org.graalvm.compiler.graph.VerificationError) ValueNode(org.graalvm.compiler.nodes.ValueNode)

Example 37 with ValueNode

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

the class MemoryMapNode method checkOrder.

private boolean checkOrder(EconomicMap<LocationIdentity, MemoryNode> mmap) {
    for (int i = 0; i < locationIdentities.size(); i++) {
        LocationIdentity locationIdentity = locationIdentities.get(i);
        ValueNode n = nodes.get(i);
        assertTrue(mmap.get(locationIdentity) == n, "iteration order of keys differs from values in input map");
    }
    return true;
}
Also used : ValueNode(org.graalvm.compiler.nodes.ValueNode) LocationIdentity(org.graalvm.word.LocationIdentity)

Example 38 with ValueNode

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

the class ReadNode method canonicalizeRead.

public static ValueNode canonicalizeRead(ValueNode read, AddressNode address, LocationIdentity locationIdentity, CanonicalizerTool tool) {
    NodeView view = NodeView.from(tool);
    MetaAccessProvider metaAccess = tool.getMetaAccess();
    if (tool.canonicalizeReads() && address instanceof OffsetAddressNode) {
        OffsetAddressNode objAddress = (OffsetAddressNode) address;
        ValueNode object = objAddress.getBase();
        if (metaAccess != null && object.isConstant() && !object.isNullConstant() && objAddress.getOffset().isConstant()) {
            long displacement = objAddress.getOffset().asJavaConstant().asLong();
            int stableDimension = ((ConstantNode) object).getStableDimension();
            if (locationIdentity.isImmutable() || stableDimension > 0) {
                Constant constant = read.stamp(view).readConstant(tool.getConstantReflection().getMemoryAccessProvider(), object.asConstant(), displacement);
                boolean isDefaultStable = locationIdentity.isImmutable() || ((ConstantNode) object).isDefaultStable();
                if (constant != null && (isDefaultStable || !constant.isDefaultForKind())) {
                    return ConstantNode.forConstant(read.stamp(view), constant, Math.max(stableDimension - 1, 0), isDefaultStable, metaAccess);
                }
            }
        }
        if (locationIdentity.equals(ARRAY_LENGTH_LOCATION)) {
            ValueNode length = GraphUtil.arrayLength(object);
            if (length != null) {
                return length;
            }
        }
        if (locationIdentity instanceof CanonicalizableLocation) {
            CanonicalizableLocation canonicalize = (CanonicalizableLocation) locationIdentity;
            ValueNode result = canonicalize.canonicalizeRead(read, address, object, tool);
            assert result != null && result.stamp(view).isCompatible(read.stamp(view));
            return result;
        }
    }
    return read;
}
Also used : ConstantNode(org.graalvm.compiler.nodes.ConstantNode) OffsetAddressNode(org.graalvm.compiler.nodes.memory.address.OffsetAddressNode) Constant(jdk.vm.ci.meta.Constant) ValueNode(org.graalvm.compiler.nodes.ValueNode) NodeView(org.graalvm.compiler.nodes.NodeView) CanonicalizableLocation(org.graalvm.compiler.nodes.CanonicalizableLocation) MetaAccessProvider(jdk.vm.ci.meta.MetaAccessProvider)

Example 39 with ValueNode

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

the class SubstrateGraphKit method mergeUnwinds.

/**
 * A graph with multiple unwinds is invalid. Merge the various unwind paths.
 */
public void mergeUnwinds() {
    List<UnwindNode> unwinds = new ArrayList<>();
    for (Node node : getGraph().getNodes()) {
        if (node instanceof UnwindNode) {
            unwinds.add((UnwindNode) node);
        }
    }
    if (unwinds.size() > 1) {
        MergeNode unwindMergeNode = add(new MergeNode());
        ValueNode exceptionValue = InliningUtil.mergeValueProducers(unwindMergeNode, unwinds, null, UnwindNode::exception);
        UnwindNode unwindReplacement = add(new UnwindNode(exceptionValue));
        unwindMergeNode.setNext(unwindReplacement);
        FrameStateBuilder exceptionState = getFrameState().copy();
        exceptionState.clearStack();
        exceptionState.push(JavaKind.Object, exceptionValue);
        exceptionState.setRethrowException(true);
        unwindMergeNode.setStateAfter(exceptionState.create(BytecodeFrame.AFTER_EXCEPTION_BCI, unwindMergeNode));
    }
}
Also used : MergeNode(org.graalvm.compiler.nodes.MergeNode) DeoptEntryNode(com.oracle.svm.core.graal.nodes.DeoptEntryNode) LoadIndexedNode(org.graalvm.compiler.nodes.java.LoadIndexedNode) ReturnNode(org.graalvm.compiler.nodes.ReturnNode) BoxNode(org.graalvm.compiler.nodes.extended.BoxNode) CallTargetNode(org.graalvm.compiler.nodes.CallTargetNode) AbstractBeginNode(org.graalvm.compiler.nodes.AbstractBeginNode) CFunctionEpilogueNode(com.oracle.svm.core.nodes.CFunctionEpilogueNode) PiNode(org.graalvm.compiler.nodes.PiNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) FloatingNode(org.graalvm.compiler.nodes.calc.FloatingNode) LoadFieldNode(org.graalvm.compiler.nodes.java.LoadFieldNode) ConstantNode(org.graalvm.compiler.nodes.ConstantNode) CFunctionPrologueNode(com.oracle.svm.core.nodes.CFunctionPrologueNode) InvokeNode(org.graalvm.compiler.nodes.InvokeNode) MergeNode(org.graalvm.compiler.nodes.MergeNode) FixedNode(org.graalvm.compiler.nodes.FixedNode) IndirectCallTargetNode(org.graalvm.compiler.nodes.IndirectCallTargetNode) UnwindNode(org.graalvm.compiler.nodes.UnwindNode) Node(org.graalvm.compiler.graph.Node) UnboxNode(org.graalvm.compiler.nodes.extended.UnboxNode) ArrayList(java.util.ArrayList) ValueNode(org.graalvm.compiler.nodes.ValueNode) FrameStateBuilder(org.graalvm.compiler.java.FrameStateBuilder) UnwindNode(org.graalvm.compiler.nodes.UnwindNode)

Example 40 with ValueNode

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

the class DefaultHotSpotLoweringProvider method createWriteHub.

private WriteNode createWriteHub(StructuredGraph graph, ValueNode object, ValueNode value) {
    assert !object.isConstant() || object.asConstant().isDefaultForKind();
    ValueNode writeValue = value;
    if (runtime.getVMConfig().useCompressedClassPointers) {
        writeValue = HotSpotCompressionNode.compress(value, runtime.getVMConfig().getKlassEncoding());
    }
    AddressNode address = createOffsetAddress(graph, object, runtime.getVMConfig().hubOffset);
    return graph.add(new WriteNode(address, HUB_WRITE_LOCATION, writeValue, BarrierType.NONE));
}
Also used : ValueNode(org.graalvm.compiler.nodes.ValueNode) GetObjectAddressNode(org.graalvm.compiler.hotspot.nodes.GetObjectAddressNode) ComputeObjectAddressNode(org.graalvm.compiler.hotspot.nodes.ComputeObjectAddressNode) AddressNode(org.graalvm.compiler.nodes.memory.address.AddressNode) WriteNode(org.graalvm.compiler.nodes.memory.WriteNode)

Aggregations

ValueNode (org.graalvm.compiler.nodes.ValueNode)482 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)104 GraphBuilderContext (org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext)77 InvocationPlugin (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin)76 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)69 ResolvedJavaType (jdk.vm.ci.meta.ResolvedJavaType)67 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)66 Registration (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration)60 Receiver (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.Receiver)52 Node (org.graalvm.compiler.graph.Node)50 JavaKind (jdk.vm.ci.meta.JavaKind)48 Stamp (org.graalvm.compiler.core.common.type.Stamp)48 LogicNode (org.graalvm.compiler.nodes.LogicNode)48 VirtualObjectNode (org.graalvm.compiler.nodes.virtual.VirtualObjectNode)42 FixedWithNextNode (org.graalvm.compiler.nodes.FixedWithNextNode)38 FixedNode (org.graalvm.compiler.nodes.FixedNode)37 AddressNode (org.graalvm.compiler.nodes.memory.address.AddressNode)37 NodeView (org.graalvm.compiler.nodes.NodeView)36 PhiNode (org.graalvm.compiler.nodes.PhiNode)36 Test (org.junit.Test)36