Search in sources :

Example 11 with ForeignCallNode

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

the class ForeignCallDeoptimizeTest method registerInvocationPlugins.

@Override
protected void registerInvocationPlugins(InvocationPlugins invocationPlugins) {
    ForeignCallsProvider foreignCalls = ((HotSpotProviders) getProviders()).getForeignCalls();
    invocationPlugins.register(new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode arg) {
            ForeignCallNode node = new ForeignCallNode(foreignCalls, HotSpotForeignCallsProviderImpl.TEST_DEOPTIMIZE_CALL_INT, arg);
            b.addPush(JavaKind.Int, node);
            return true;
        }
    }, ForeignCallDeoptimizeTest.class, "testCallInt", int.class);
    super.registerInvocationPlugins(invocationPlugins);
}
Also used : ForeignCallsProvider(org.graalvm.compiler.core.common.spi.ForeignCallsProvider) ForeignCallNode(org.graalvm.compiler.nodes.extended.ForeignCallNode) GraphBuilderContext(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext) HotSpotProviders(org.graalvm.compiler.hotspot.meta.HotSpotProviders) ValueNode(org.graalvm.compiler.nodes.ValueNode) InvocationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 12 with ForeignCallNode

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

the class PEGraphDecoder method handleFixedNode.

@Override
protected void handleFixedNode(MethodScope s, LoopScope loopScope, int nodeOrderId, FixedNode node) {
    PEMethodScope methodScope = (PEMethodScope) s;
    if (node instanceof ForeignCallNode) {
        ForeignCallNode foreignCall = (ForeignCallNode) node;
        if (foreignCall.getBci() == BytecodeFrame.UNKNOWN_BCI && methodScope.invokeData != null) {
            foreignCall.setBci(methodScope.invokeData.invoke.bci());
        }
    }
    super.handleFixedNode(methodScope, loopScope, nodeOrderId, node);
}
Also used : ForeignCallNode(org.graalvm.compiler.nodes.extended.ForeignCallNode)

Example 13 with ForeignCallNode

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

the class GenericArrayCopyCallNode method lower.

@Override
public void lower(LoweringTool tool) {
    if (graph().getGuardsStage().areFrameStatesAtDeopts()) {
        StructuredGraph graph = graph();
        ValueNode srcAddr = objectAddress(getSource());
        ValueNode destAddr = objectAddress(getDestination());
        ForeignCallNode call = graph.add(new ForeignCallNode(runtime.getHostBackend().getForeignCalls(), HotSpotBackend.GENERIC_ARRAYCOPY, srcAddr, srcPos, destAddr, destPos, length));
        call.setStateAfter(stateAfter());
        graph.replaceFixedWithFixed(this, call);
    }
}
Also used : ForeignCallNode(org.graalvm.compiler.nodes.extended.ForeignCallNode) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) ValueNode(org.graalvm.compiler.nodes.ValueNode)

Example 14 with ForeignCallNode

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

the class ForeignCallPlugin method execute.

@Override
public boolean execute(GraphBuilderContext b, ResolvedJavaMethod targetMethod, InvocationPlugin.Receiver receiver, ValueNode[] args) {
    ForeignCallNode foreignCall = new ForeignCallNode(foreignCalls, descriptor, args);
    foreignCall.setBci(b.bci());
    b.addPush(targetMethod.getSignature().getReturnKind(), foreignCall);
    return true;
}
Also used : ForeignCallNode(org.graalvm.compiler.nodes.extended.ForeignCallNode)

Example 15 with ForeignCallNode

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

the class LoopSafepointEliminationPhase method run.

@Override
protected void run(StructuredGraph graph, MidTierContext context) {
    LoopsData loops = new LoopsData(graph);
    if (context.getOptimisticOptimizations().useLoopLimitChecks(graph.getOptions()) && graph.getGuardsStage().allowsFloatingGuards()) {
        loops.detectedCountedLoops();
        for (LoopEx loop : loops.countedLoops()) {
            if (loop.loop().getChildren().isEmpty() && loop.counted().getStamp().getBits() <= 32) {
                boolean hasSafepoint = false;
                for (LoopEndNode loopEnd : loop.loopBegin().loopEnds()) {
                    hasSafepoint |= loopEnd.canSafepoint();
                }
                if (hasSafepoint) {
                    loop.counted().createOverFlowGuard();
                    loop.loopBegin().disableSafepoint();
                }
            }
        }
    }
    for (LoopEx loop : loops.loops()) {
        for (LoopEndNode loopEnd : loop.loopBegin().loopEnds()) {
            Block b = loops.getCFG().blockFor(loopEnd);
            blocks: while (b != loop.loop().getHeader()) {
                assert b != null;
                for (FixedNode node : b.getNodes()) {
                    if (node instanceof Invoke || (node instanceof ForeignCallNode && ((ForeignCallNode) node).isGuaranteedSafepoint())) {
                        loopEnd.disableSafepoint();
                        break blocks;
                    }
                }
                b = b.getDominator();
            }
        }
    }
    loops.deleteUnusedNodes();
}
Also used : LoopsData(org.graalvm.compiler.loop.LoopsData) ForeignCallNode(org.graalvm.compiler.nodes.extended.ForeignCallNode) LoopEx(org.graalvm.compiler.loop.LoopEx) Block(org.graalvm.compiler.nodes.cfg.Block) FixedNode(org.graalvm.compiler.nodes.FixedNode) LoopEndNode(org.graalvm.compiler.nodes.LoopEndNode) Invoke(org.graalvm.compiler.nodes.Invoke)

Aggregations

ForeignCallNode (org.graalvm.compiler.nodes.extended.ForeignCallNode)18 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)7 ValueNode (org.graalvm.compiler.nodes.ValueNode)7 ForeignCallDescriptor (org.graalvm.compiler.core.common.spi.ForeignCallDescriptor)5 FixedNode (org.graalvm.compiler.nodes.FixedNode)5 MethodCallTargetNode (org.graalvm.compiler.nodes.java.MethodCallTargetNode)5 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)4 ParameterNode (org.graalvm.compiler.nodes.ParameterNode)4 Node (org.graalvm.compiler.graph.Node)3 InvokeNode (org.graalvm.compiler.nodes.InvokeNode)3 StartNode (org.graalvm.compiler.nodes.StartNode)3 Snippet (org.graalvm.compiler.api.replacements.Snippet)2 AbstractEndNode (org.graalvm.compiler.nodes.AbstractEndNode)2 AbstractMergeNode (org.graalvm.compiler.nodes.AbstractMergeNode)2 BeginNode (org.graalvm.compiler.nodes.BeginNode)2 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)2 EndNode (org.graalvm.compiler.nodes.EndNode)2 FixedGuardNode (org.graalvm.compiler.nodes.FixedGuardNode)2 FixedWithNextNode (org.graalvm.compiler.nodes.FixedWithNextNode)2 InvokeWithExceptionNode (org.graalvm.compiler.nodes.InvokeWithExceptionNode)2