Search in sources :

Example 11 with RequiredInvocationPlugin

use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.RequiredInvocationPlugin in project graal by oracle.

the class Target_org_graalvm_compiler_truffle_runtime_OptimizedCallTarget method registerNeverPartOfCompilation.

private void registerNeverPartOfCompilation(InvocationPlugins plugins) {
    InvocationPlugins.Registration r = new InvocationPlugins.Registration(plugins, CompilerAsserts.class);
    r.setAllowOverwrite(true);
    r.register(new RequiredInvocationPlugin("neverPartOfCompilation") {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
            return handleNeverPartOfCompilation(b, targetMethod, null);
        }
    });
    r.register(new RequiredInvocationPlugin("neverPartOfCompilation", String.class) {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode message) {
            return handleNeverPartOfCompilation(b, targetMethod, message);
        }
    });
}
Also used : InvocationPlugins(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins) GraphBuilderContext(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext) RequiredInvocationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.RequiredInvocationPlugin) ValueNode(org.graalvm.compiler.nodes.ValueNode) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 12 with RequiredInvocationPlugin

use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.RequiredInvocationPlugin in project graal by oracle.

the class SubstrateTruffleGraphBuilderPlugins method registerOptimizedCallTargetPlugins.

private static void registerOptimizedCallTargetPlugins(InvocationPlugins plugins) {
    InvocationPlugins.Registration r0 = new InvocationPlugins.Registration(plugins, SubstrateOptimizedCallTarget.class);
    r0.register(new RequiredInvocationPlugin("safepointBarrier") {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
            b.add(new MembarNode(MembarNode.FenceKind.NONE));
            return true;
        }
    });
}
Also used : InvocationPlugins(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins) GraphBuilderContext(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext) RequiredInvocationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.RequiredInvocationPlugin) MembarNode(org.graalvm.compiler.nodes.extended.MembarNode) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 13 with RequiredInvocationPlugin

use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.RequiredInvocationPlugin in project graal by oracle.

the class SubstrateTruffleGraphBuilderPlugins method registerCompilationFinalReferencePlugins.

private static void registerCompilationFinalReferencePlugins(InvocationPlugins plugins, boolean canDelayIntrinsification, SubstrateKnownTruffleTypes types) {
    InvocationPlugins.Registration r0 = new InvocationPlugins.Registration(plugins, Reference.class);
    r0.register(new RequiredInvocationPlugin("get", InvocationPlugin.Receiver.class) {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
            if (!canDelayIntrinsification && receiver.isConstant()) {
                JavaConstant reference = (JavaConstant) receiver.get().asConstant();
                if (reference.isNonNull()) {
                    JavaConstant referent = b.getConstantReflection().readFieldValue(types.referentField, reference);
                    b.addPush(JavaKind.Object, ConstantNode.forConstant(referent, b.getMetaAccess()));
                    return true;
                }
            }
            return false;
        }
    });
}
Also used : InvocationPlugins(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins) GraphBuilderContext(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext) RequiredInvocationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.RequiredInvocationPlugin) JavaConstant(jdk.vm.ci.meta.JavaConstant) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 14 with RequiredInvocationPlugin

use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.RequiredInvocationPlugin in project graal by oracle.

the class Target_com_oracle_truffle_api_nodes_Node method registerInvocationPlugins.

@Override
public void registerInvocationPlugins(Providers providers, SnippetReflectionProvider snippetReflection, Plugins plugins, ParsingReason reason) {
    StaticObjectSupport.registerInvocationPlugins(plugins, reason);
    /*
         * We need to constant-fold Profile.isProfilingEnabled already during static analysis, so
         * that we get exact types for fields that store profiles.
         */
    Registration r = new Registration(plugins.getInvocationPlugins(), Profile.class);
    r.register(new RequiredInvocationPlugin("isProfilingEnabled") {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
            b.addPush(JavaKind.Boolean, ConstantNode.forBoolean(profilingEnabled));
            return true;
        }
    });
    if (reason != ParsingReason.JITCompilation) {
        r = new Registration(plugins.getInvocationPlugins(), CompilerDirectives.class);
        /*
             * For AOT compilation and static analysis, we intrinsify CompilerDirectives.castExact
             * with explicit exception edges. For runtime compilation, TruffleGraphBuilderPlugins
             * registers a plugin that uses deoptimization.
             */
        SubstrateGraphBuilderPlugins.registerCastExact(r);
    }
}
Also used : GraphBuilderContext(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext) Registration(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration) RequiredInvocationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.RequiredInvocationPlugin) CompilerDirectives(com.oracle.truffle.api.CompilerDirectives) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 15 with RequiredInvocationPlugin

use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.RequiredInvocationPlugin in project graal by oracle.

the class TruffleGraphBuilderPlugins method registerOptimizedCallTargetPlugins.

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

        @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.register(new RequiredInvocationPlugin("castArrayFixedLength", Object[].class, int.class) {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode args, ValueNode length) {
            if (canDelayIntrinsification) {
                return false;
            }
            if (args.isConstant()) {
                b.addPush(JavaKind.Object, args);
                return true;
            }
            b.addPush(JavaKind.Object, new PiArrayNode(args, length, args.stamp(NodeView.DEFAULT)));
            return true;
        }
    });
    registerUnsafeCast(r, canDelayIntrinsification, primitiveBoxingTypes);
}
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) RequiredInvocationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.RequiredInvocationPlugin) ValueNode(org.graalvm.compiler.nodes.ValueNode) 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

ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)47 GraphBuilderContext (org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext)47 RequiredInvocationPlugin (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.RequiredInvocationPlugin)47 ValueNode (org.graalvm.compiler.nodes.ValueNode)38 Receiver (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.Receiver)37 Registration (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration)34 StackValueNode (com.oracle.svm.core.graal.stackvalue.StackValueNode)14 ResolvedJavaType (jdk.vm.ci.meta.ResolvedJavaType)9 ResolvedJavaSymbol (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.ResolvedJavaSymbol)8 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)6 JavaConstant (jdk.vm.ci.meta.JavaConstant)5 LogicNode (org.graalvm.compiler.nodes.LogicNode)5 InvocationPlugins (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins)5 IsolateThread (org.graalvm.nativeimage.IsolateThread)4 DeoptimizeNode (org.graalvm.compiler.nodes.DeoptimizeNode)3 TruffleCompilerRuntime (org.graalvm.compiler.truffle.common.TruffleCompilerRuntime)3 AllowMaterializeNode (org.graalvm.compiler.truffle.compiler.nodes.frame.AllowMaterializeNode)3 NewFrameNode (org.graalvm.compiler.truffle.compiler.nodes.frame.NewFrameNode)3 VirtualFrameGetNode (org.graalvm.compiler.truffle.compiler.nodes.frame.VirtualFrameGetNode)3 VirtualFrameSetNode (org.graalvm.compiler.truffle.compiler.nodes.frame.VirtualFrameSetNode)3