Search in sources :

Example 26 with RequiredInvocationPlugin

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

the class SubstrateGraphBuilderPlugins method registerEdgesPlugins.

private static void registerEdgesPlugins(MetaAccessProvider metaAccess, InvocationPlugins plugins) {
    Registration r = new Registration(plugins, Edges.class).setAllowOverwrite(true);
    for (Class<?> c : new Class<?>[] { Node.class, NodeList.class }) {
        r.register(new RequiredInvocationPlugin("get" + ClassUtil.getUnqualifiedName(c) + "Unsafe", Node.class, long.class) {

            @Override
            public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode node, ValueNode offset) {
                b.addPush(JavaKind.Object, new UnsafePartitionLoadNode(node, offset, JavaKind.Object, LocationIdentity.any(), GraalEdgeUnsafePartition.get(), metaAccess.lookupJavaType(c)));
                return true;
            }
        });
        r.register(new RequiredInvocationPlugin("put" + ClassUtil.getUnqualifiedName(c) + "Unsafe", Node.class, long.class, c) {

            @Override
            public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode node, ValueNode offset, ValueNode value) {
                b.add(new UnsafePartitionStoreNode(node, offset, value, JavaKind.Object, LocationIdentity.any(), GraalEdgeUnsafePartition.get(), metaAccess.lookupJavaType(c)));
                return true;
            }
        });
    }
}
Also used : RequiredInvocationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.RequiredInvocationPlugin) UnsafePartitionStoreNode(com.oracle.graal.pointsto.nodes.UnsafePartitionStoreNode) StackValueNode(com.oracle.svm.core.graal.stackvalue.StackValueNode) SubstrateCompressionNode(com.oracle.svm.core.graal.nodes.SubstrateCompressionNode) ZeroExtendNode(org.graalvm.compiler.nodes.calc.ZeroExtendNode) TestDeoptimizeNode(com.oracle.svm.core.graal.nodes.TestDeoptimizeNode) WordCastNode(org.graalvm.compiler.word.WordCastNode) ReadCallerStackPointerNode(com.oracle.svm.core.graal.nodes.ReadCallerStackPointerNode) ConstantNode(org.graalvm.compiler.nodes.ConstantNode) LazyConstantNode(com.oracle.svm.core.graal.nodes.LazyConstantNode) SubstrateObjectCloneWithExceptionNode(com.oracle.svm.core.graal.jdk.SubstrateObjectCloneWithExceptionNode) FixedNode(org.graalvm.compiler.nodes.FixedNode) SubstrateIdentityHashCodeNode(com.oracle.svm.core.identityhashcode.SubstrateIdentityHashCodeNode) FarReturnNode(com.oracle.svm.core.graal.nodes.FarReturnNode) DeoptProxyNode(com.oracle.svm.hosted.nodes.DeoptProxyNode) DynamicNewInstanceNode(org.graalvm.compiler.nodes.java.DynamicNewInstanceNode) SubstrateReflectionGetCallerClassNode(com.oracle.svm.core.graal.nodes.SubstrateReflectionGetCallerClassNode) NarrowNode(org.graalvm.compiler.nodes.calc.NarrowNode) DynamicPiNode(org.graalvm.compiler.nodes.DynamicPiNode) DeoptEntryNode(com.oracle.svm.core.graal.nodes.DeoptEntryNode) VirtualObjectNode(org.graalvm.compiler.nodes.virtual.VirtualObjectNode) AbstractBeginNode(org.graalvm.compiler.nodes.AbstractBeginNode) PiNode(org.graalvm.compiler.nodes.PiNode) LogicNode(org.graalvm.compiler.nodes.LogicNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) EnsureClassInitializedNode(com.oracle.svm.core.classinitialization.EnsureClassInitializedNode) NewArrayNode(org.graalvm.compiler.nodes.java.NewArrayNode) FullInfopointNode(org.graalvm.compiler.nodes.FullInfopointNode) VirtualArrayNode(org.graalvm.compiler.nodes.virtual.VirtualArrayNode) AllocatedObjectNode(org.graalvm.compiler.nodes.virtual.AllocatedObjectNode) InstanceOfDynamicNode(org.graalvm.compiler.nodes.java.InstanceOfDynamicNode) LoadHubNode(org.graalvm.compiler.nodes.extended.LoadHubNode) UnsafePartitionLoadNode(com.oracle.graal.pointsto.nodes.UnsafePartitionLoadNode) StoreIndexedNode(org.graalvm.compiler.nodes.java.StoreIndexedNode) CommitAllocationNode(org.graalvm.compiler.nodes.virtual.CommitAllocationNode) ReadReturnAddressNode(com.oracle.svm.core.graal.nodes.ReadReturnAddressNode) BytecodeExceptionNode(org.graalvm.compiler.nodes.extended.BytecodeExceptionNode) Node(org.graalvm.compiler.graph.Node) UnsafePartitionStoreNode(com.oracle.graal.pointsto.nodes.UnsafePartitionStoreNode) NodeList(org.graalvm.compiler.graph.NodeList) Receiver(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.Receiver) Edges(org.graalvm.compiler.graph.Edges) GraphBuilderContext(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext) UnsafePartitionLoadNode(com.oracle.graal.pointsto.nodes.UnsafePartitionLoadNode) Registration(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration) StackValueNode(com.oracle.svm.core.graal.stackvalue.StackValueNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 27 with RequiredInvocationPlugin

use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.RequiredInvocationPlugin 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.register(new RequiredInvocationPlugin("contains", Class.class) {

        @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.addPush(JavaKind.Boolean, ConstantNode.forBoolean(result));
            return true;
        }
    });
    r.register(new RequiredInvocationPlugin("lookup", Class.class) {

        @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.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) RequiredInvocationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.RequiredInvocationPlugin) StackValueNode(com.oracle.svm.core.graal.stackvalue.StackValueNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) Receiver(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.Receiver) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 28 with RequiredInvocationPlugin

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

the class SubstrateGraphBuilderPlugins method registerProxyPlugins.

private static void registerProxyPlugins(SnippetReflectionProvider snippetReflection, AnnotationSubstitutionProcessor annotationSubstitutions, InvocationPlugins plugins, ParsingReason reason) {
    if (SubstrateOptions.parseOnce() || reason == ParsingReason.PointsToAnalysis) {
        Registration proxyRegistration = new Registration(plugins, Proxy.class);
        proxyRegistration.register(new RequiredInvocationPlugin("getProxyClass", ClassLoader.class, Class[].class) {

            @Override
            public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode classLoaderNode, ValueNode interfacesNode) {
                interceptProxyInterfaces(b, targetMethod, snippetReflection, annotationSubstitutions, interfacesNode);
                return false;
            }
        });
        proxyRegistration.register(new RequiredInvocationPlugin("newProxyInstance", ClassLoader.class, Class[].class, InvocationHandler.class) {

            @Override
            public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode classLoaderNode, ValueNode interfacesNode, ValueNode invocationHandlerNode) {
                interceptProxyInterfaces(b, targetMethod, snippetReflection, annotationSubstitutions, interfacesNode);
                return false;
            }
        });
    }
}
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) StackValueNode(com.oracle.svm.core.graal.stackvalue.StackValueNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) Receiver(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.Receiver) InvocationHandler(java.lang.reflect.InvocationHandler) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 29 with RequiredInvocationPlugin

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

the class SubstrateGraphBuilderPlugins method registerAWTPlugins.

/**
 * To prevent AWT linkage error on {@link OS#LINUX} that happens with 'awt_headless' in headless
 * mode, we eliminate native methods that depend on 'awt_xawt' library in the call-tree.
 */
private static void registerAWTPlugins(InvocationPlugins plugins) {
    if (Platform.includedIn(Platform.LINUX.class)) {
        Registration r = new Registration(plugins, GraphicsEnvironment.class);
        r.register(new RequiredInvocationPlugin("isHeadless") {

            @SuppressWarnings("unchecked")
            @Override
            public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
                boolean isHeadless = GraphicsEnvironment.isHeadless();
                b.addPush(JavaKind.Boolean, ConstantNode.forBoolean(isHeadless));
                return true;
            }
        });
    }
}
Also used : Platform(org.graalvm.nativeimage.Platform) GraphBuilderContext(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext) Registration(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration) RequiredInvocationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.RequiredInvocationPlugin) Receiver(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.Receiver) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 30 with RequiredInvocationPlugin

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

the class SubstrateGraphBuilderPlugins method registerObjectPlugins.

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

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
            ValueNode object = receiver.get();
            b.addPush(JavaKind.Object, new SubstrateObjectCloneWithExceptionNode(MacroParams.of(b, targetMethod, object)));
            return true;
        }
    });
    r.register(new RequiredInvocationPlugin("hashCode", Receiver.class) {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver) {
            ValueNode object = receiver.get();
            b.addPush(JavaKind.Int, new SubstrateIdentityHashCodeNode(object, b.bci()));
            return true;
        }
    });
}
Also used : SubstrateObjectCloneWithExceptionNode(com.oracle.svm.core.graal.jdk.SubstrateObjectCloneWithExceptionNode) GraphBuilderContext(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext) Registration(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration) RequiredInvocationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.RequiredInvocationPlugin) StackValueNode(com.oracle.svm.core.graal.stackvalue.StackValueNode) ValueNode(org.graalvm.compiler.nodes.ValueNode) Receiver(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.Receiver) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod) SubstrateIdentityHashCodeNode(com.oracle.svm.core.identityhashcode.SubstrateIdentityHashCodeNode)

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