Search in sources :

Example 36 with InvocationPlugin

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

the class CheckGraalIntrinsics method test.

@Test
@SuppressWarnings("try")
public void test() throws ClassNotFoundException {
    HotSpotGraalRuntimeProvider rt = (HotSpotGraalRuntimeProvider) Graal.getRequiredCapability(RuntimeProvider.class);
    HotSpotProviders providers = rt.getHostBackend().getProviders();
    Plugins graphBuilderPlugins = providers.getGraphBuilderPlugins();
    InvocationPlugins invocationPlugins = graphBuilderPlugins.getInvocationPlugins();
    HotSpotVMConfigStore store = rt.getVMConfig().getStore();
    List<VMIntrinsicMethod> intrinsics = store.getIntrinsics();
    List<String> missing = new ArrayList<>();
    EconomicMap<String, List<Binding>> bindings = invocationPlugins.getBindings(true);
    for (VMIntrinsicMethod intrinsic : intrinsics) {
        InvocationPlugin plugin = findPlugin(bindings, intrinsic);
        if (plugin == null) {
            ResolvedJavaMethod method = resolveIntrinsic(providers.getMetaAccess(), intrinsic);
            if (method != null) {
                IntrinsicMethod intrinsicMethod = providers.getConstantReflection().getMethodHandleAccess().lookupMethodHandleIntrinsic(method);
                if (intrinsicMethod != null) {
                    continue;
                }
            }
            String m = String.format("%s.%s%s", intrinsic.declaringClass, intrinsic.name, intrinsic.descriptor);
            if (!TO_BE_INVESTIGATED.contains(m) && !IGNORE.contains(m)) {
                missing.add(m);
            }
        }
    }
    if (!missing.isEmpty()) {
        Collections.sort(missing);
        String missingString = missing.stream().collect(Collectors.joining(String.format("%n    ")));
        fail("missing Graal intrinsics for:%n    %s", missingString);
    }
}
Also used : InvocationPlugins(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins) VMIntrinsicMethod(jdk.vm.ci.hotspot.VMIntrinsicMethod) IntrinsicMethod(jdk.vm.ci.meta.MethodHandleAccessProvider.IntrinsicMethod) RuntimeProvider(org.graalvm.compiler.runtime.RuntimeProvider) HotSpotGraalRuntimeProvider(org.graalvm.compiler.hotspot.HotSpotGraalRuntimeProvider) HotSpotProviders(org.graalvm.compiler.hotspot.meta.HotSpotProviders) ArrayList(java.util.ArrayList) HotSpotGraalRuntimeProvider(org.graalvm.compiler.hotspot.HotSpotGraalRuntimeProvider) InvocationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin) ArrayList(java.util.ArrayList) List(java.util.List) HotSpotVMConfigStore(jdk.vm.ci.hotspot.HotSpotVMConfigStore) VMIntrinsicMethod(jdk.vm.ci.hotspot.VMIntrinsicMethod) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod) InvocationPlugins(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins) Plugins(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins) GraalTest(org.graalvm.compiler.test.GraalTest) Test(org.junit.Test)

Example 37 with InvocationPlugin

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

the class DataPatchTest method registerInvocationPlugins.

@Override
protected void registerInvocationPlugins(InvocationPlugins invocationPlugins) {
    Registration r = new Registration(invocationPlugins, DataPatchTest.class);
    r.register1("compressUncompress", Object.class, new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode arg) {
            CompressEncoding encoding = runtime().getVMConfig().getOopEncoding();
            ValueNode compressed = b.add(HotSpotCompressionNode.compress(arg, encoding));
            ValueNode proxy = b.add(new OpaqueNode(compressed));
            b.addPush(JavaKind.Object, HotSpotCompressionNode.uncompress(proxy, encoding));
            return true;
        }
    });
    super.registerInvocationPlugins(invocationPlugins);
}
Also used : GraphBuilderContext(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext) Registration(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.Registration) ValueNode(org.graalvm.compiler.nodes.ValueNode) CompressEncoding(org.graalvm.compiler.core.common.CompressEncoding) InvocationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin) OpaqueNode(org.graalvm.compiler.nodes.debug.OpaqueNode) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 38 with InvocationPlugin

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

the class ForeignCallDeoptimizeTest method registerInvocationPlugins.

@Override
protected void registerInvocationPlugins(InvocationPlugins invocationPlugins) {
    ForeignCallsProvider foreignCalls = ((HotSpotProviders) getProviders()).getForeignCalls();
    invocationPlugins.register(new InvocationPlugin() {

        @Override
        public boolean apply(GraphBuilderContext b, ResolvedJavaMethod targetMethod, Receiver receiver, ValueNode arg) {
            ForeignCallNode node = new ForeignCallNode(foreignCalls, HotSpotForeignCallsProviderImpl.TEST_DEOPTIMIZE_CALL_INT, arg);
            b.addPush(JavaKind.Int, node);
            return true;
        }
    }, ForeignCallDeoptimizeTest.class, "testCallInt", int.class);
    super.registerInvocationPlugins(invocationPlugins);
}
Also used : ForeignCallsProvider(org.graalvm.compiler.core.common.spi.ForeignCallsProvider) ForeignCallNode(org.graalvm.compiler.nodes.extended.ForeignCallNode) GraphBuilderContext(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext) HotSpotProviders(org.graalvm.compiler.hotspot.meta.HotSpotProviders) ValueNode(org.graalvm.compiler.nodes.ValueNode) InvocationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 39 with InvocationPlugin

use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin 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 40 with InvocationPlugin

use of org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin 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)

Aggregations

InvocationPlugin (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin)92 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)89 GraphBuilderContext (org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext)83 ValueNode (org.graalvm.compiler.nodes.ValueNode)74 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)9 LogicNode (org.graalvm.compiler.nodes.LogicNode)9 FixedGuardNode (org.graalvm.compiler.nodes.FixedGuardNode)8 DeoptimizeNode (org.graalvm.compiler.nodes.DeoptimizeNode)7 JavaConstant (jdk.vm.ci.meta.JavaConstant)6 JavaKind (jdk.vm.ci.meta.JavaKind)6 ConstantNode (org.graalvm.compiler.nodes.ConstantNode)6 ResolvedJavaSymbol (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins.ResolvedJavaSymbol)6 InvocationPlugins (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins)5 GetClassNode (org.graalvm.compiler.nodes.extended.GetClassNode)4 AnalysisArraysCopyOfNode (com.oracle.graal.pointsto.nodes.AnalysisArraysCopyOfNode)3 Stamp (org.graalvm.compiler.core.common.type.Stamp)3