Search in sources :

Example 1 with LocationIdentity

use of org.graalvm.word.LocationIdentity in project graal by oracle.

the class ExceptionObjectNode method lower.

@Override
public void lower(LoweringTool tool) {
    if (graph().getGuardsStage() == StructuredGraph.GuardsStage.FIXED_DEOPTS) {
        /*
             * Now the lowering to BeginNode+LoadExceptionNode can be performed, since no more
             * deopts can float in between the begin node and the load exception node.
             */
        LocationIdentity locationsKilledByInvoke = ((InvokeWithExceptionNode) predecessor()).getLocationIdentity();
        AbstractBeginNode entry = graph().add(KillingBeginNode.create(locationsKilledByInvoke));
        LoadExceptionObjectNode loadException = graph().add(new LoadExceptionObjectNode(stamp(NodeView.DEFAULT)));
        loadException.setStateAfter(stateAfter());
        replaceAtUsages(InputType.Value, loadException);
        graph().replaceFixedWithFixed(this, entry);
        entry.graph().addAfterFixed(entry, loadException);
        loadException.lower(tool);
    }
}
Also used : InvokeWithExceptionNode(org.graalvm.compiler.nodes.InvokeWithExceptionNode) LocationIdentity(org.graalvm.word.LocationIdentity) AbstractBeginNode(org.graalvm.compiler.nodes.AbstractBeginNode)

Example 2 with LocationIdentity

use of org.graalvm.word.LocationIdentity in project graal by oracle.

the class UnsafeAccessNode method canonical.

@Override
public Node canonical(CanonicalizerTool tool) {
    if (!isAnyLocationForced() && getLocationIdentity().isAny()) {
        if (offset().isConstant()) {
            long constantOffset = offset().asJavaConstant().asLong();
            // Try to canonicalize to a field access.
            ResolvedJavaType receiverType = StampTool.typeOrNull(object());
            if (receiverType != null) {
                ResolvedJavaField field = receiverType.findInstanceFieldWithOffset(constantOffset, accessKind());
                // never a valid access of an arbitrary address.
                if (field != null && field.getJavaKind() == this.accessKind()) {
                    assert !graph().isAfterFloatingReadPhase() : "cannot add more precise memory location after floating read phase";
                    return cloneAsFieldAccess(graph().getAssumptions(), field);
                }
            }
        }
        ResolvedJavaType receiverType = StampTool.typeOrNull(object());
        // Try to build a better location identity.
        if (receiverType != null && receiverType.isArray()) {
            LocationIdentity identity = NamedLocationIdentity.getArrayLocation(receiverType.getComponentType().getJavaKind());
            assert !graph().isAfterFloatingReadPhase() : "cannot add more precise memory location after floating read phase";
            return cloneAsArrayAccess(offset(), identity);
        }
    }
    return this;
}
Also used : LocationIdentity(org.graalvm.word.LocationIdentity) NamedLocationIdentity(org.graalvm.compiler.nodes.NamedLocationIdentity) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType) ResolvedJavaField(jdk.vm.ci.meta.ResolvedJavaField)

Example 3 with LocationIdentity

use of org.graalvm.word.LocationIdentity in project graal by oracle.

the class ArrayCopySnippets method unrolledArraycopyWork.

private static void unrolledArraycopyWork(Object nonNullSrc, int srcPos, Object nonNullDest, int destPos, int length, JavaKind elementKind) {
    int scale = arrayIndexScale(elementKind);
    int arrayBaseOffset = arrayBaseOffset(elementKind);
    LocationIdentity arrayLocation = getArrayLocation(elementKind);
    long sourceOffset = arrayBaseOffset + (long) srcPos * scale;
    long destOffset = arrayBaseOffset + (long) destPos * scale;
    long position = 0;
    long delta = scale;
    if (probability(NOT_FREQUENT_PROBABILITY, nonNullSrc == nonNullDest && srcPos < destPos)) {
        // bad aliased case so we need to copy the array from back to front
        position = (long) (length - 1) * scale;
        delta = -delta;
    }
    // the length was already checked before - we can emit unconditional instructions
    ExplodeLoopNode.explodeLoop();
    for (int iteration = 0; iteration < length; iteration++) {
        Object value = RawLoadNode.load(nonNullSrc, sourceOffset + position, elementKind, arrayLocation);
        RawStoreNode.storeObject(nonNullDest, destOffset + position, value, elementKind, arrayLocation, false);
        position += delta;
    }
}
Also used : LocationIdentity(org.graalvm.word.LocationIdentity) NamedLocationIdentity(org.graalvm.compiler.nodes.NamedLocationIdentity)

Example 4 with LocationIdentity

use of org.graalvm.word.LocationIdentity in project graal by oracle.

the class FloatingReadPhase method mergeMemoryMaps.

public static MemoryMapImpl mergeMemoryMaps(AbstractMergeNode merge, List<? extends MemoryMap> states) {
    MemoryMapImpl newState = new MemoryMapImpl();
    EconomicSet<LocationIdentity> keys = EconomicSet.create(Equivalence.DEFAULT);
    for (MemoryMap other : states) {
        keys.addAll(other.getLocations());
    }
    assert checkNoImmutableLocations(keys);
    for (LocationIdentity key : keys) {
        int mergedStatesCount = 0;
        boolean isPhi = false;
        MemoryNode merged = null;
        for (MemoryMap state : states) {
            MemoryNode last = state.getLastLocationAccess(key);
            if (isPhi) {
                ((MemoryPhiNode) merged).addInput(ValueNodeUtil.asNode(last));
            } else {
                if (merged == last) {
                // nothing to do
                } else if (merged == null) {
                    merged = last;
                } else {
                    MemoryPhiNode phi = merge.graph().addWithoutUnique(new MemoryPhiNode(merge, key));
                    for (int j = 0; j < mergedStatesCount; j++) {
                        phi.addInput(ValueNodeUtil.asNode(merged));
                    }
                    phi.addInput(ValueNodeUtil.asNode(last));
                    merged = phi;
                    isPhi = true;
                }
            }
            mergedStatesCount++;
        }
        newState.lastMemorySnapshot.put(key, merged);
    }
    return newState;
}
Also used : MemoryMap(org.graalvm.compiler.nodes.memory.MemoryMap) MemoryNode(org.graalvm.compiler.nodes.memory.MemoryNode) MemoryPhiNode(org.graalvm.compiler.nodes.memory.MemoryPhiNode) LocationIdentity(org.graalvm.word.LocationIdentity) MemoryCheckpoint(org.graalvm.compiler.nodes.memory.MemoryCheckpoint)

Example 5 with LocationIdentity

use of org.graalvm.word.LocationIdentity 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)

Aggregations

LocationIdentity (org.graalvm.word.LocationIdentity)32 ValueNode (org.graalvm.compiler.nodes.ValueNode)12 FieldLocationIdentity (org.graalvm.compiler.nodes.FieldLocationIdentity)11 NamedLocationIdentity (org.graalvm.compiler.nodes.NamedLocationIdentity)11 JavaKind (jdk.vm.ci.meta.JavaKind)10 MemoryCheckpoint (org.graalvm.compiler.nodes.memory.MemoryCheckpoint)10 ResolvedJavaType (jdk.vm.ci.meta.ResolvedJavaType)6 Stamp (org.graalvm.compiler.core.common.type.Stamp)5 AbstractBeginNode (org.graalvm.compiler.nodes.AbstractBeginNode)5 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)5 AddressNode (org.graalvm.compiler.nodes.memory.address.AddressNode)4 CInterfaceLocationIdentity (com.oracle.svm.core.c.struct.CInterfaceLocationIdentity)3 ResolvedJavaField (jdk.vm.ci.meta.ResolvedJavaField)3 Node (org.graalvm.compiler.graph.Node)3 AbstractMergeNode (org.graalvm.compiler.nodes.AbstractMergeNode)3 StructFieldInfo (com.oracle.svm.hosted.c.info.StructFieldInfo)2 JavaConstant (jdk.vm.ci.meta.JavaConstant)2 ForeignCallDescriptor (org.graalvm.compiler.core.common.spi.ForeignCallDescriptor)2 KlassPointerStamp (org.graalvm.compiler.hotspot.nodes.type.KlassPointerStamp)2 FixedNode (org.graalvm.compiler.nodes.FixedNode)2