Search in sources :

Example 16 with AddressNode

use of org.graalvm.compiler.nodes.memory.address.AddressNode in project graal by oracle.

the class DefaultJavaLoweringProvider method lowerLoadFieldNode.

protected void lowerLoadFieldNode(LoadFieldNode loadField, LoweringTool tool) {
    assert loadField.getStackKind() != JavaKind.Illegal;
    StructuredGraph graph = loadField.graph();
    ResolvedJavaField field = loadField.field();
    ValueNode object = loadField.isStatic() ? staticFieldBase(graph, field) : loadField.object();
    object = createNullCheckedValue(object, loadField, tool);
    Stamp loadStamp = loadStamp(loadField.stamp(NodeView.DEFAULT), getStorageKind(field));
    AddressNode address = createFieldAddress(graph, object, field);
    assert address != null : "Field that is loaded must not be eliminated: " + field.getDeclaringClass().toJavaName(true) + "." + field.getName();
    ReadNode memoryRead = graph.add(new ReadNode(address, fieldLocationIdentity(field), loadStamp, fieldLoadBarrierType(field)));
    ValueNode readValue = implicitLoadConvert(graph, getStorageKind(field), memoryRead);
    loadField.replaceAtUsages(readValue);
    graph.replaceFixed(loadField, memoryRead);
    if (loadField.isVolatile()) {
        MembarNode preMembar = graph.add(new MembarNode(JMM_PRE_VOLATILE_READ));
        graph.addBeforeFixed(memoryRead, preMembar);
        MembarNode postMembar = graph.add(new MembarNode(JMM_POST_VOLATILE_READ));
        graph.addAfterFixed(memoryRead, postMembar);
    }
}
Also used : StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) ObjectStamp(org.graalvm.compiler.core.common.type.ObjectStamp) Stamp(org.graalvm.compiler.core.common.type.Stamp) IntegerStamp(org.graalvm.compiler.core.common.type.IntegerStamp) ValueNode(org.graalvm.compiler.nodes.ValueNode) OffsetAddressNode(org.graalvm.compiler.nodes.memory.address.OffsetAddressNode) AddressNode(org.graalvm.compiler.nodes.memory.address.AddressNode) JavaReadNode(org.graalvm.compiler.nodes.extended.JavaReadNode) ReadNode(org.graalvm.compiler.nodes.memory.ReadNode) MembarNode(org.graalvm.compiler.nodes.extended.MembarNode) ResolvedJavaField(jdk.vm.ci.meta.ResolvedJavaField)

Example 17 with AddressNode

use of org.graalvm.compiler.nodes.memory.address.AddressNode in project graal by oracle.

the class DefaultJavaLoweringProvider method lowerCompareAndSwapNode.

protected void lowerCompareAndSwapNode(UnsafeCompareAndSwapNode cas) {
    StructuredGraph graph = cas.graph();
    JavaKind valueKind = cas.getValueKind();
    ValueNode expectedValue = implicitStoreConvert(graph, valueKind, cas.expected());
    ValueNode newValue = implicitStoreConvert(graph, valueKind, cas.newValue());
    AddressNode address = graph.unique(new OffsetAddressNode(cas.object(), cas.offset()));
    LogicCompareAndSwapNode atomicNode = graph.add(new LogicCompareAndSwapNode(address, cas.getLocationIdentity(), expectedValue, newValue, compareAndSwapBarrierType(cas)));
    atomicNode.setStateAfter(cas.stateAfter());
    graph.replaceFixedWithFixed(cas, atomicNode);
}
Also used : LogicCompareAndSwapNode(org.graalvm.compiler.nodes.java.LogicCompareAndSwapNode) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) OffsetAddressNode(org.graalvm.compiler.nodes.memory.address.OffsetAddressNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) OffsetAddressNode(org.graalvm.compiler.nodes.memory.address.OffsetAddressNode) AddressNode(org.graalvm.compiler.nodes.memory.address.AddressNode) JavaKind(jdk.vm.ci.meta.JavaKind)

Example 18 with AddressNode

use of org.graalvm.compiler.nodes.memory.address.AddressNode in project graal by oracle.

the class DefaultJavaLoweringProvider method lowerStoreIndexedNode.

protected void lowerStoreIndexedNode(StoreIndexedNode storeIndexed, LoweringTool tool) {
    StructuredGraph graph = storeIndexed.graph();
    ValueNode value = storeIndexed.value();
    ValueNode array = storeIndexed.array();
    array = this.createNullCheckedValue(array, storeIndexed, tool);
    GuardingNode boundsCheck = getBoundsCheck(storeIndexed, array, tool);
    JavaKind elementKind = storeIndexed.elementKind();
    LogicNode condition = null;
    if (elementKind == JavaKind.Object && !StampTool.isPointerAlwaysNull(value)) {
        /* Array store check. */
        TypeReference arrayType = StampTool.typeReferenceOrNull(array);
        if (arrayType != null && arrayType.isExact()) {
            ResolvedJavaType elementType = arrayType.getType().getComponentType();
            if (!elementType.isJavaLangObject()) {
                TypeReference typeReference = TypeReference.createTrusted(storeIndexed.graph().getAssumptions(), elementType);
                LogicNode typeTest = graph.addOrUniqueWithInputs(InstanceOfNode.create(typeReference, value));
                condition = LogicNode.or(graph.unique(IsNullNode.create(value)), typeTest, GraalDirectives.UNLIKELY_PROBABILITY);
            }
        } else {
            /*
                 * The guard on the read hub should be the null check of the array that was
                 * introduced earlier.
                 */
            ValueNode arrayClass = createReadHub(graph, array, tool);
            ValueNode componentHub = createReadArrayComponentHub(graph, arrayClass, storeIndexed);
            LogicNode typeTest = graph.unique(InstanceOfDynamicNode.create(graph.getAssumptions(), tool.getConstantReflection(), componentHub, value, false));
            condition = LogicNode.or(graph.unique(IsNullNode.create(value)), typeTest, GraalDirectives.UNLIKELY_PROBABILITY);
        }
    }
    AddressNode address = createArrayIndexAddress(graph, array, elementKind, storeIndexed.index(), boundsCheck);
    WriteNode memoryWrite = graph.add(new WriteNode(address, NamedLocationIdentity.getArrayLocation(elementKind), implicitStoreConvert(graph, elementKind, value), arrayStoreBarrierType(storeIndexed.elementKind())));
    memoryWrite.setGuard(boundsCheck);
    if (condition != null) {
        tool.createGuard(storeIndexed, condition, DeoptimizationReason.ArrayStoreException, DeoptimizationAction.InvalidateReprofile);
    }
    memoryWrite.setStateAfter(storeIndexed.stateAfter());
    graph.replaceFixedWithFixed(storeIndexed, memoryWrite);
}
Also used : StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) ValueNode(org.graalvm.compiler.nodes.ValueNode) OffsetAddressNode(org.graalvm.compiler.nodes.memory.address.OffsetAddressNode) AddressNode(org.graalvm.compiler.nodes.memory.address.AddressNode) LogicNode(org.graalvm.compiler.nodes.LogicNode) TypeReference(org.graalvm.compiler.core.common.type.TypeReference) WriteNode(org.graalvm.compiler.nodes.memory.WriteNode) AtomicReadAndWriteNode(org.graalvm.compiler.nodes.java.AtomicReadAndWriteNode) JavaWriteNode(org.graalvm.compiler.nodes.extended.JavaWriteNode) LoweredAtomicReadAndWriteNode(org.graalvm.compiler.nodes.java.LoweredAtomicReadAndWriteNode) GuardingNode(org.graalvm.compiler.nodes.extended.GuardingNode) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType) JavaKind(jdk.vm.ci.meta.JavaKind)

Example 19 with AddressNode

use of org.graalvm.compiler.nodes.memory.address.AddressNode in project graal by oracle.

the class DefaultJavaLoweringProvider method lowerStoreFieldNode.

protected void lowerStoreFieldNode(StoreFieldNode storeField, LoweringTool tool) {
    StructuredGraph graph = storeField.graph();
    ResolvedJavaField field = storeField.field();
    ValueNode object = storeField.isStatic() ? staticFieldBase(graph, field) : storeField.object();
    object = createNullCheckedValue(object, storeField, tool);
    ValueNode value = implicitStoreConvert(graph, getStorageKind(storeField.field()), storeField.value());
    AddressNode address = createFieldAddress(graph, object, field);
    assert address != null;
    WriteNode memoryWrite = graph.add(new WriteNode(address, fieldLocationIdentity(field), value, fieldStoreBarrierType(storeField.field())));
    memoryWrite.setStateAfter(storeField.stateAfter());
    graph.replaceFixedWithFixed(storeField, memoryWrite);
    if (storeField.isVolatile()) {
        MembarNode preMembar = graph.add(new MembarNode(JMM_PRE_VOLATILE_WRITE));
        graph.addBeforeFixed(memoryWrite, preMembar);
        MembarNode postMembar = graph.add(new MembarNode(JMM_POST_VOLATILE_WRITE));
        graph.addAfterFixed(memoryWrite, postMembar);
    }
}
Also used : StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) ValueNode(org.graalvm.compiler.nodes.ValueNode) OffsetAddressNode(org.graalvm.compiler.nodes.memory.address.OffsetAddressNode) AddressNode(org.graalvm.compiler.nodes.memory.address.AddressNode) MembarNode(org.graalvm.compiler.nodes.extended.MembarNode) WriteNode(org.graalvm.compiler.nodes.memory.WriteNode) AtomicReadAndWriteNode(org.graalvm.compiler.nodes.java.AtomicReadAndWriteNode) JavaWriteNode(org.graalvm.compiler.nodes.extended.JavaWriteNode) LoweredAtomicReadAndWriteNode(org.graalvm.compiler.nodes.java.LoweredAtomicReadAndWriteNode) ResolvedJavaField(jdk.vm.ci.meta.ResolvedJavaField)

Example 20 with AddressNode

use of org.graalvm.compiler.nodes.memory.address.AddressNode in project graal by oracle.

the class AArch64ReadNode method replace.

/**
 * replace a ReadNode with an AArch64-specific variant which knows how to merge a downstream
 * zero or sign extend into the read operation.
 *
 * @param readNode
 */
public static void replace(ReadNode readNode) {
    assert readNode.getUsageCount() == 1;
    assert readNode.getUsageAt(0) instanceof ZeroExtendNode || readNode.getUsageAt(0) instanceof SignExtendNode;
    ValueNode usage = (ValueNode) readNode.getUsageAt(0);
    boolean isSigned = usage instanceof SignExtendNode;
    IntegerStamp accessStamp = ((IntegerStamp) readNode.getAccessStamp());
    AddressNode address = readNode.getAddress();
    LocationIdentity location = readNode.getLocationIdentity();
    Stamp stamp = usage.stamp(NodeView.DEFAULT);
    GuardingNode guard = readNode.getGuard();
    BarrierType barrierType = readNode.getBarrierType();
    boolean nullCheck = readNode.getNullCheck();
    FrameState stateBefore = readNode.stateBefore();
    AArch64ReadNode clone = new AArch64ReadNode(address, location, stamp, guard, barrierType, nullCheck, stateBefore, accessStamp, isSigned);
    StructuredGraph graph = readNode.graph();
    graph.add(clone);
    // splice out the extend node
    usage.replaceAtUsagesAndDelete(readNode);
    // swap the clone for the read
    graph.replaceFixedWithFixed(readNode, clone);
}
Also used : SignExtendNode(org.graalvm.compiler.nodes.calc.SignExtendNode) Stamp(org.graalvm.compiler.core.common.type.Stamp) IntegerStamp(org.graalvm.compiler.core.common.type.IntegerStamp) ZeroExtendNode(org.graalvm.compiler.nodes.calc.ZeroExtendNode) FrameState(org.graalvm.compiler.nodes.FrameState) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) IntegerStamp(org.graalvm.compiler.core.common.type.IntegerStamp) ValueNode(org.graalvm.compiler.nodes.ValueNode) AddressNode(org.graalvm.compiler.nodes.memory.address.AddressNode) LocationIdentity(org.graalvm.word.LocationIdentity) GuardingNode(org.graalvm.compiler.nodes.extended.GuardingNode)

Aggregations

AddressNode (org.graalvm.compiler.nodes.memory.address.AddressNode)43 ValueNode (org.graalvm.compiler.nodes.ValueNode)35 OffsetAddressNode (org.graalvm.compiler.nodes.memory.address.OffsetAddressNode)25 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)16 JavaKind (jdk.vm.ci.meta.JavaKind)13 ReadNode (org.graalvm.compiler.nodes.memory.ReadNode)12 Stamp (org.graalvm.compiler.core.common.type.Stamp)9 FloatingReadNode (org.graalvm.compiler.nodes.memory.FloatingReadNode)9 ComputeObjectAddressNode (org.graalvm.compiler.hotspot.nodes.ComputeObjectAddressNode)8 GetObjectAddressNode (org.graalvm.compiler.hotspot.nodes.GetObjectAddressNode)8 AMD64AddressNode (org.graalvm.compiler.core.amd64.AMD64AddressNode)7 ObjectStamp (org.graalvm.compiler.core.common.type.ObjectStamp)7 GraalCompilerTest (org.graalvm.compiler.core.test.GraalCompilerTest)7 JavaReadNode (org.graalvm.compiler.nodes.extended.JavaReadNode)7 WriteNode (org.graalvm.compiler.nodes.memory.WriteNode)7 Test (org.junit.Test)7 LeftShiftNode (org.graalvm.compiler.nodes.calc.LeftShiftNode)6 JavaWriteNode (org.graalvm.compiler.nodes.extended.JavaWriteNode)6 AtomicReadAndWriteNode (org.graalvm.compiler.nodes.java.AtomicReadAndWriteNode)6 LoweredAtomicReadAndWriteNode (org.graalvm.compiler.nodes.java.LoweredAtomicReadAndWriteNode)6