Search in sources :

Example 36 with GraphBuilderContext

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

the class ExceedMaxOopMapStackOffset method editGraphBuilderConfiguration.

@Override
protected GraphBuilderConfiguration editGraphBuilderConfiguration(GraphBuilderConfiguration conf) {
    InvocationPlugin safepointPlugin = new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
            b.add(new SafepointNode());
            return true;
        }
    };
    conf.getPlugins().getInvocationPlugins().register(safepointPlugin, getClass(), "safepoint");
    return super.editGraphBuilderConfiguration(conf);
}
Also used : SafepointNode(org.graalvm.compiler.nodes.SafepointNode) GraphBuilderContext(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext) InvocationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 37 with GraphBuilderContext

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

the class SubstrateGraphBuilderPlugins method registerPlatformPlugins.

private static void registerPlatformPlugins(SnippetReflectionProvider snippetReflection, InvocationPlugins plugins) {
    Registration r = new Registration(plugins, Platform.class);
    r.register1("includedIn", Class.class, new InvocationPlugin() {

        @SuppressWarnings("unchecked")
        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode classNode) {
            Class<? extends Platform> platform = constantObjectParameter(b, snippetReflection, targetMethod, 0, Class.class, classNode);
            boolean result = Platform.includedIn(platform);
            b.notifyReplacedCall(targetMethod, b.addPush(JavaKind.Boolean, ConstantNode.forBoolean(result)));
            return true;
        }
    });
}
Also used : Platform(org.graalvm.nativeimage.Platform) GraphBuilderContext(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext) Registration(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration) StackValueNode(com.oracle.svm.core.graal.stackvalue.StackValueNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) ConvertUnknownValueNode(com.oracle.graal.pointsto.nodes.ConvertUnknownValueNode) InvocationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin) Receiver(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.Receiver) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 38 with GraphBuilderContext

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

the class SubstrateGraphBuilderPlugins method registerArrayPlugins.

private static void registerArrayPlugins(InvocationPlugins plugins) {
    Registration r = new Registration(plugins, Array.class).setAllowOverwrite(true);
    r.register2("newInstance", Class.class, int.class, new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode clazz, ValueNode length) {
            b.addPush(JavaKind.Object, new SubstrateDynamicNewArrayNode(clazz, length));
            return true;
        }
    });
    /*
         * We have our own Java-level implementation of Array.getLength(), so we just disable the
         * plugin defined in StandardGraphBuilderPlugins.
         */
    r.register1("getLength", Object.class, new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver type, ValueNode array) {
            return false;
        }
    });
}
Also used : Array(java.lang.reflect.Array) SubstrateDynamicNewArrayNode(com.oracle.svm.core.graal.nodes.SubstrateDynamicNewArrayNode) GraphBuilderContext(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext) Registration(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration) StackValueNode(com.oracle.svm.core.graal.stackvalue.StackValueNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) ConvertUnknownValueNode(com.oracle.graal.pointsto.nodes.ConvertUnknownValueNode) InvocationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin) Receiver(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.Receiver) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 39 with GraphBuilderContext

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

the class SubstrateGraphBuilderPlugins method registerVMConfigurationPlugins.

private static void registerVMConfigurationPlugins(SnippetReflectionProvider snippetReflection, InvocationPlugins plugins) {
    Registration r = new Registration(plugins, ImageSingletons.class);
    r.register1("contains", Class.class, new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver unused, ValueNode classNode) {
            Class<?> key = constantObjectParameter(b, snippetReflection, targetMethod, 0, Class.class, classNode);
            boolean result = ImageSingletons.contains(key);
            b.notifyReplacedCall(targetMethod, b.addPush(JavaKind.Boolean, ConstantNode.forBoolean(result)));
            return true;
        }
    });
    r.register1("lookup", Class.class, new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver unused, ValueNode classNode) {
            Class<?> key = constantObjectParameter(b, snippetReflection, targetMethod, 0, Class.class, classNode);
            Object result = ImageSingletons.lookup(key);
            b.notifyReplacedCall(targetMethod, b.addPush(JavaKind.Object, ConstantNode.forConstant(snippetReflection.forObject(result), b.getMetaAccess())));
            return true;
        }
    });
}
Also used : GraphBuilderContext(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext) Registration(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration) StackValueNode(com.oracle.svm.core.graal.stackvalue.StackValueNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) ConvertUnknownValueNode(com.oracle.graal.pointsto.nodes.ConvertUnknownValueNode) InvocationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin) Receiver(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.Receiver) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 40 with GraphBuilderContext

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

the class SubstrateGraphBuilderPlugins method registerObjectPlugins.

private static void registerObjectPlugins(InvocationPlugins plugins) {
    Registration r = new Registration(plugins, Object.class);
    r.register1("clone", Receiver.class, new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
            ValueNode object = receiver.get();
            b.addPush(JavaKind.Object, objectCloneNode(b.getInvokeKind(), b.bci(), b.getInvokeReturnStamp(b.getAssumptions()), targetMethod, object));
            return true;
        }
    });
}
Also used : GraphBuilderContext(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext) Registration(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration) StackValueNode(com.oracle.svm.core.graal.stackvalue.StackValueNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) ConvertUnknownValueNode(com.oracle.graal.pointsto.nodes.ConvertUnknownValueNode) InvocationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin) Receiver(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.Receiver) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Aggregations

GraphBuilderContext (org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext)88 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)86 InvocationPlugin (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin)83 ValueNode (org.graalvm.compiler.nodes.ValueNode)76 Registration (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration)66 Receiver (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.Receiver)57 ConvertUnknownValueNode (com.oracle.graal.pointsto.nodes.ConvertUnknownValueNode)13 StackValueNode (com.oracle.svm.core.graal.stackvalue.StackValueNode)13 ResolvedJavaType (jdk.vm.ci.meta.ResolvedJavaType)10 LogicNode (org.graalvm.compiler.nodes.LogicNode)10 JavaKind (jdk.vm.ci.meta.JavaKind)9 DeoptimizeNode (org.graalvm.compiler.nodes.DeoptimizeNode)8 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)7 FixedGuardNode (org.graalvm.compiler.nodes.FixedGuardNode)7 JavaConstant (jdk.vm.ci.meta.JavaConstant)6 ConditionalNode (org.graalvm.compiler.nodes.calc.ConditionalNode)6 ResolvedJavaSymbol (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.ResolvedJavaSymbol)6 Stamp (org.graalvm.compiler.core.common.type.Stamp)4 GetClassNode (org.graalvm.compiler.nodes.extended.GetClassNode)4 OffsetAddressNode (org.graalvm.compiler.nodes.memory.address.OffsetAddressNode)4