Search in sources :

Example 1 with NewFrameNode

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

the class VerifyFrameDoesNotEscapePhase method run.

@Override
protected void run(StructuredGraph graph) {
    for (NewFrameNode virtualFrame : graph.getNodes(NewFrameNode.TYPE)) {
        for (MethodCallTargetNode callTarget : virtualFrame.usages().filter(MethodCallTargetNode.class)) {
            if (callTarget.invoke() != null) {
                String properties = callTarget.getDebugProperties().toString();
                String arguments = callTarget.arguments().toString();
                Throwable exception = new VerificationError("Frame escapes at: %s#%s\nproperties:%s\narguments: %s", callTarget, callTarget.targetMethod(), properties, arguments);
                throw GraphUtil.approxSourceException(callTarget, exception);
            }
        }
    }
}
Also used : NewFrameNode(org.graalvm.compiler.truffle.compiler.nodes.frame.NewFrameNode) MethodCallTargetNode(org.graalvm.compiler.nodes.java.MethodCallTargetNode) VerificationError(org.graalvm.compiler.graph.VerificationError)

Example 2 with NewFrameNode

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

the class TruffleGraphBuilderPlugins method registerFrameMethods.

private static void registerFrameMethods(Registration r) {
    r.register1("getArguments", Receiver.class, new InvocationPlugin() {

        @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.register1("getFrameDescriptor", Receiver.class, new InvocationPlugin() {

        @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.register1("materialize", Receiver.class, new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
            ValueNode frame = receiver.get();
            if (TruffleCompilerOptions.getValue(Options.TruffleIntrinsifyFrameAccess) && frame instanceof NewFrameNode && ((NewFrameNode) frame).getIntrinsifyAccessors()) {
                JavaConstant 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;
        }
    });
}
Also used : NewFrameNode(org.graalvm.compiler.truffle.compiler.nodes.frame.NewFrameNode) GraphBuilderContext(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext) ValueNode(org.graalvm.compiler.nodes.ValueNode) InvocationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin) Receiver(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.Receiver) JavaConstant(jdk.vm.ci.meta.JavaConstant) DeoptimizeNode(org.graalvm.compiler.nodes.DeoptimizeNode) AllowMaterializeNode(org.graalvm.compiler.truffle.compiler.nodes.frame.AllowMaterializeNode) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 3 with NewFrameNode

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

the class TruffleGraphBuilderPlugins method registerOptimizedCallTargetPlugins.

public static void registerOptimizedCallTargetPlugins(InvocationPlugins plugins, MetaAccessProvider metaAccess, boolean canDelayIntrinsification, KnownTruffleTypes types) {
    final ResolvedJavaType optimizedCallTargetType = getRuntime().resolveType(metaAccess, "org.graalvm.compiler.truffle.runtime.OptimizedCallTarget");
    Registration r = new Registration(plugins, new ResolvedJavaSymbol(optimizedCallTargetType));
    r.register2("createFrame", new ResolvedJavaSymbol(types.classFrameDescriptor), Object[].class, new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode descriptor, ValueNode args) {
            if (canDelayIntrinsification) {
                return false;
            }
            if (!descriptor.isJavaConstant()) {
                throw b.bailout("Parameter 'descriptor' is not a compile-time constant");
            }
            ValueNode nonNullArguments = b.add(PiNode.create(args, StampFactory.objectNonNull(StampTool.typeReferenceOrNull(args))));
            b.addPush(JavaKind.Object, new NewFrameNode(b, descriptor, nonNullArguments, types));
            return true;
        }
    });
    r.register2("castArrayFixedLength", Object[].class, int.class, new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode args, ValueNode length) {
            b.addPush(JavaKind.Object, new PiArrayNode(args, length, args.stamp(NodeView.DEFAULT)));
            return true;
        }
    });
    registerUnsafeCast(r, canDelayIntrinsification);
}
Also used : NewFrameNode(org.graalvm.compiler.truffle.compiler.nodes.frame.NewFrameNode) GraphBuilderContext(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext) Registration(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration) ValueNode(org.graalvm.compiler.nodes.ValueNode) InvocationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin) Receiver(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.Receiver) PiArrayNode(org.graalvm.compiler.nodes.PiArrayNode) ResolvedJavaSymbol(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.ResolvedJavaSymbol) ResolvedJavaType(jdk.vm.ci.meta.ResolvedJavaType) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Aggregations

NewFrameNode (org.graalvm.compiler.truffle.compiler.nodes.frame.NewFrameNode)3 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)2 ValueNode (org.graalvm.compiler.nodes.ValueNode)2 GraphBuilderContext (org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext)2 InvocationPlugin (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin)2 Receiver (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.Receiver)2 JavaConstant (jdk.vm.ci.meta.JavaConstant)1 ResolvedJavaType (jdk.vm.ci.meta.ResolvedJavaType)1 VerificationError (org.graalvm.compiler.graph.VerificationError)1 DeoptimizeNode (org.graalvm.compiler.nodes.DeoptimizeNode)1 PiArrayNode (org.graalvm.compiler.nodes.PiArrayNode)1 Registration (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration)1 ResolvedJavaSymbol (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.ResolvedJavaSymbol)1 MethodCallTargetNode (org.graalvm.compiler.nodes.java.MethodCallTargetNode)1 AllowMaterializeNode (org.graalvm.compiler.truffle.compiler.nodes.frame.AllowMaterializeNode)1