Search in sources :

Example 1 with VirtualFrameSwapNode

use of org.graalvm.compiler.truffle.compiler.nodes.frame.VirtualFrameSwapNode in project graal by oracle.

the class TruffleGraphBuilderPlugins method registerFrameMethods.

private static void registerFrameMethods(Registration r, ConstantReflectionProvider constantReflection, KnownTruffleTypes types) {
    r.register(new RequiredInvocationPlugin("getArguments", Receiver.class) {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver frame) {
            if (frame.get(false) instanceof NewFrameNode) {
                b.push(JavaKind.Object, ((NewFrameNode) frame.get()).getArguments());
                return true;
            }
            return false;
        }
    });
    r.register(new RequiredInvocationPlugin("getFrameDescriptor", Receiver.class) {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver frame) {
            if (frame.get(false) instanceof NewFrameNode) {
                b.push(JavaKind.Object, ((NewFrameNode) frame.get()).getDescriptor());
                return true;
            }
            return false;
        }
    });
    r.register(new RequiredInvocationPlugin("materialize", Receiver.class) {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
            ValueNode frame = receiver.get();
            if (frame instanceof NewFrameNode && ((NewFrameNode) frame).getIntrinsifyAccessors()) {
                Speculation speculation = b.getGraph().getSpeculationLog().speculate(((NewFrameNode) frame).getIntrinsifyAccessorsSpeculation());
                b.add(new DeoptimizeNode(DeoptimizationAction.InvalidateRecompile, DeoptimizationReason.RuntimeConstraint, speculation));
                return true;
            }
            b.addPush(JavaKind.Object, new AllowMaterializeNode(frame));
            return true;
        }
    });
    r.register(new RequiredInvocationPlugin("clear", Receiver.class, new ResolvedJavaSymbol(types.classFrameSlot)) {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode frameSlot) {
            int frameSlotIndex = maybeGetConstantFrameSlotIndex(receiver, frameSlot, constantReflection, types);
            if (frameSlotIndex >= 0) {
                TruffleCompilerRuntime runtime = getRuntime();
                b.add(new VirtualFrameClearNode(receiver, frameSlotIndex, runtime.getFrameSlotKindTagForJavaKind(JavaKind.Illegal), VirtualFrameAccessType.Legacy));
                return true;
            }
            return false;
        }
    });
    r.register(new RequiredInvocationPlugin("clear", Receiver.class, int.class) {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode frameSlot) {
            int frameSlotIndex = maybeGetConstantNumberedFrameSlotIndex(receiver, frameSlot);
            if (frameSlotIndex >= 0) {
                TruffleCompilerRuntime runtime = getRuntime();
                b.add(new VirtualFrameClearNode(receiver, frameSlotIndex, runtime.getFrameSlotKindTagForJavaKind(JavaKind.Illegal), VirtualFrameAccessType.Indexed));
                return true;
            }
            return false;
        }
    });
    r.register(new RequiredInvocationPlugin("swap", Receiver.class, int.class, int.class) {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode frameSlot1, ValueNode frameSlot2) {
            int frameSlot1Index = maybeGetConstantNumberedFrameSlotIndex(receiver, frameSlot1);
            int frameSlot2Index = maybeGetConstantNumberedFrameSlotIndex(receiver, frameSlot2);
            if (frameSlot1Index >= 0 && frameSlot2Index >= 0) {
                b.add(new VirtualFrameSwapNode(receiver, frameSlot1Index, frameSlot2Index, VirtualFrameAccessType.Indexed));
                return true;
            }
            return false;
        }
    });
    r.register(new RequiredInvocationPlugin("copy", Receiver.class, int.class, int.class) {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode frameSlot1, ValueNode frameSlot2) {
            int frameSlot1Index = maybeGetConstantNumberedFrameSlotIndex(receiver, frameSlot1);
            int frameSlot2Index = maybeGetConstantNumberedFrameSlotIndex(receiver, frameSlot2);
            if (frameSlot1Index >= 0 && frameSlot2Index >= 0) {
                b.add(new VirtualFrameCopyNode(receiver, frameSlot1Index, frameSlot2Index, VirtualFrameAccessType.Indexed));
                return true;
            }
            return false;
        }
    });
}
Also used : VirtualFrameCopyNode(org.graalvm.compiler.truffle.compiler.nodes.frame.VirtualFrameCopyNode) VirtualFrameClearNode(org.graalvm.compiler.truffle.compiler.nodes.frame.VirtualFrameClearNode) NewFrameNode(org.graalvm.compiler.truffle.compiler.nodes.frame.NewFrameNode) RequiredInvocationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.RequiredInvocationPlugin) TruffleCompilerRuntime(org.graalvm.compiler.truffle.common.TruffleCompilerRuntime) Receiver(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.Receiver) AllowMaterializeNode(org.graalvm.compiler.truffle.compiler.nodes.frame.AllowMaterializeNode) ResolvedJavaSymbol(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.ResolvedJavaSymbol) Speculation(jdk.vm.ci.meta.SpeculationLog.Speculation) VirtualFrameSwapNode(org.graalvm.compiler.truffle.compiler.nodes.frame.VirtualFrameSwapNode) GraphBuilderContext(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext) ValueNode(org.graalvm.compiler.nodes.ValueNode) DeoptimizeNode(org.graalvm.compiler.nodes.DeoptimizeNode) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Aggregations

ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)1 Speculation (jdk.vm.ci.meta.SpeculationLog.Speculation)1 DeoptimizeNode (org.graalvm.compiler.nodes.DeoptimizeNode)1 ValueNode (org.graalvm.compiler.nodes.ValueNode)1 GraphBuilderContext (org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext)1 Receiver (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.Receiver)1 RequiredInvocationPlugin (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.RequiredInvocationPlugin)1 ResolvedJavaSymbol (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.ResolvedJavaSymbol)1 TruffleCompilerRuntime (org.graalvm.compiler.truffle.common.TruffleCompilerRuntime)1 AllowMaterializeNode (org.graalvm.compiler.truffle.compiler.nodes.frame.AllowMaterializeNode)1 NewFrameNode (org.graalvm.compiler.truffle.compiler.nodes.frame.NewFrameNode)1 VirtualFrameClearNode (org.graalvm.compiler.truffle.compiler.nodes.frame.VirtualFrameClearNode)1 VirtualFrameCopyNode (org.graalvm.compiler.truffle.compiler.nodes.frame.VirtualFrameCopyNode)1 VirtualFrameSwapNode (org.graalvm.compiler.truffle.compiler.nodes.frame.VirtualFrameSwapNode)1