Search in sources :

Example 1 with ForeignCallDescriptor

use of org.graalvm.compiler.core.common.spi.ForeignCallDescriptor in project graal by oracle.

the class ArrayCopyCallNode method lower.

@Override
public void lower(LoweringTool tool) {
    if (graph().getGuardsStage().areFrameStatesAtDeopts()) {
        updateAlignedDisjoint();
        ForeignCallDescriptor desc = HotSpotHostForeignCallsProvider.lookupArraycopyDescriptor(elementKind, isAligned(), isDisjoint(), isUninitialized(), locationIdentity.equals(LocationIdentity.any()));
        StructuredGraph graph = graph();
        ValueNode srcAddr = computeBase(getSource(), getSourcePosition());
        ValueNode destAddr = computeBase(getDestination(), getDestinationPosition());
        ValueNode len = getLength();
        if (len.stamp(NodeView.DEFAULT).getStackKind() != JavaKind.Long) {
            len = IntegerConvertNode.convert(len, StampFactory.forKind(JavaKind.Long), graph(), NodeView.DEFAULT);
        }
        ForeignCallNode call = graph.add(new ForeignCallNode(runtime.getHostBackend().getForeignCalls(), desc, srcAddr, destAddr, len));
        call.setStateAfter(stateAfter());
        graph.replaceFixedWithFixed(this, call);
    }
}
Also used : ForeignCallNode(org.graalvm.compiler.nodes.extended.ForeignCallNode) ForeignCallDescriptor(org.graalvm.compiler.core.common.spi.ForeignCallDescriptor) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) ValueNode(org.graalvm.compiler.nodes.ValueNode)

Example 2 with ForeignCallDescriptor

use of org.graalvm.compiler.core.common.spi.ForeignCallDescriptor in project graal by oracle.

the class CheckcastArrayCopyCallNode method lower.

@Override
public void lower(LoweringTool tool) {
    if (graph().getGuardsStage().areFrameStatesAtDeopts()) {
        ForeignCallDescriptor desc = HotSpotHostForeignCallsProvider.lookupCheckcastArraycopyDescriptor(isUninit());
        StructuredGraph graph = graph();
        ValueNode srcAddr = computeBase(getSource(), getSourcePosition());
        ValueNode destAddr = computeBase(getDestination(), getDestinationPosition());
        ValueNode len = getLength();
        if (len.stamp(NodeView.DEFAULT).getStackKind() != runtime.getTarget().wordJavaKind) {
            len = IntegerConvertNode.convert(len, StampFactory.forKind(runtime.getTarget().wordJavaKind), graph(), NodeView.DEFAULT);
        }
        ForeignCallNode call = graph.add(new ForeignCallNode(runtime.getHostBackend().getForeignCalls(), desc, srcAddr, destAddr, len, superCheckOffset, destElemKlass));
        call.setStateAfter(stateAfter());
        graph.replaceFixedWithFixed(this, call);
    }
}
Also used : ForeignCallNode(org.graalvm.compiler.nodes.extended.ForeignCallNode) ForeignCallDescriptor(org.graalvm.compiler.core.common.spi.ForeignCallDescriptor) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) ValueNode(org.graalvm.compiler.nodes.ValueNode)

Example 3 with ForeignCallDescriptor

use of org.graalvm.compiler.core.common.spi.ForeignCallDescriptor in project graal by oracle.

the class DefaultHotSpotLoweringProvider method lowerBytecodeExceptionNode.

private void lowerBytecodeExceptionNode(BytecodeExceptionNode node) {
    if (OmitHotExceptionStacktrace.getValue(node.getOptions())) {
        if (throwCachedException(node)) {
            return;
        }
    }
    ForeignCallDescriptor descriptor;
    if (node.getExceptionClass() == NullPointerException.class) {
        descriptor = RuntimeCalls.CREATE_NULL_POINTER_EXCEPTION;
    } else if (node.getExceptionClass() == ArrayIndexOutOfBoundsException.class) {
        descriptor = RuntimeCalls.CREATE_OUT_OF_BOUNDS_EXCEPTION;
    } else if (node.getExceptionClass() == ArrayStoreException.class) {
        descriptor = RuntimeCalls.CREATE_ARRAY_STORE_EXCEPTION;
    } else if (node.getExceptionClass() == ClassCastException.class) {
        descriptor = RuntimeCalls.CREATE_CLASS_CAST_EXCEPTION;
    } else {
        throw GraalError.shouldNotReachHere();
    }
    StructuredGraph graph = node.graph();
    ForeignCallNode foreignCallNode = graph.add(new ForeignCallNode(foreignCalls, descriptor, node.stamp(NodeView.DEFAULT), node.getArguments()));
    graph.replaceFixedWithFixed(node, foreignCallNode);
}
Also used : ForeignCallNode(org.graalvm.compiler.nodes.extended.ForeignCallNode) ForeignCallDescriptor(org.graalvm.compiler.core.common.spi.ForeignCallDescriptor) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph)

Example 4 with ForeignCallDescriptor

use of org.graalvm.compiler.core.common.spi.ForeignCallDescriptor in project graal by oracle.

the class HotSpotHostForeignCallsProvider method registerCheckcastArraycopyDescriptor.

private void registerCheckcastArraycopyDescriptor(boolean uninit, long routine) {
    String name = "Object" + (uninit ? "Uninit" : "") + "Checkcast";
    // Input:
    // c_rarg0 - source array address
    // c_rarg1 - destination array address
    // c_rarg2 - element count, treated as ssize_t, can be zero
    // c_rarg3 - size_t ckoff (super_check_offset)
    // c_rarg4 - oop ckval (super_klass)
    // return: 0 = success, n = number of copied elements xor'd with -1.
    ForeignCallDescriptor desc = new ForeignCallDescriptor(name, int.class, Word.class, Word.class, Word.class, Word.class, Word.class);
    LocationIdentity killed = NamedLocationIdentity.any();
    registerForeignCall(desc, routine, NativeCall, DESTROYS_REGISTERS, LEAF_NOFP, NOT_REEXECUTABLE, killed);
    checkcastArraycopyDescriptors[uninit ? 1 : 0] = desc;
}
Also used : ForeignCallDescriptor(org.graalvm.compiler.core.common.spi.ForeignCallDescriptor) LocationIdentity(org.graalvm.word.LocationIdentity) NamedLocationIdentity(org.graalvm.compiler.nodes.NamedLocationIdentity)

Example 5 with ForeignCallDescriptor

use of org.graalvm.compiler.core.common.spi.ForeignCallDescriptor in project graal by oracle.

the class HotSpotHostForeignCallsProvider method registerArraycopyDescriptor.

private void registerArraycopyDescriptor(EconomicMap<Long, ForeignCallDescriptor> descMap, JavaKind kind, boolean aligned, boolean disjoint, boolean uninit, boolean killAny, long routine) {
    ForeignCallDescriptor desc = descMap.get(routine);
    if (desc == null) {
        desc = buildDescriptor(kind, aligned, disjoint, uninit, killAny, routine);
        descMap.put(routine, desc);
    }
    if (uninit) {
        assert kind == JavaKind.Object;
        uninitObjectArraycopyDescriptors[aligned ? 1 : 0][disjoint ? 1 : 0] = desc;
    } else {
        arraycopyDescriptors[aligned ? 1 : 0][disjoint ? 1 : 0].put(kind, desc);
    }
}
Also used : ForeignCallDescriptor(org.graalvm.compiler.core.common.spi.ForeignCallDescriptor)

Aggregations

ForeignCallDescriptor (org.graalvm.compiler.core.common.spi.ForeignCallDescriptor)9 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)5 ForeignCallNode (org.graalvm.compiler.nodes.extended.ForeignCallNode)5 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)2 Snippet (org.graalvm.compiler.api.replacements.Snippet)2 NamedLocationIdentity (org.graalvm.compiler.nodes.NamedLocationIdentity)2 ValueNode (org.graalvm.compiler.nodes.ValueNode)2 LocationIdentity (org.graalvm.word.LocationIdentity)2 Method (java.lang.reflect.Method)1 NodeIntrinsic (org.graalvm.compiler.graph.Node.NodeIntrinsic)1