Search in sources :

Example 1 with VMIntrinsicMethod

use of jdk.vm.ci.hotspot.VMIntrinsicMethod 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 2 with VMIntrinsicMethod

use of jdk.vm.ci.hotspot.VMIntrinsicMethod in project graal by oracle.

the class TestIntrinsicCompiles method test.

@Test
@SuppressWarnings("try")
public void test() throws ClassNotFoundException {
    HotSpotGraalCompiler compiler = (HotSpotGraalCompiler) JVMCI.getRuntime().getCompiler();
    HotSpotGraalRuntimeProvider rt = (HotSpotGraalRuntimeProvider) Graal.getRequiredCapability(RuntimeProvider.class);
    HotSpotProviders providers = rt.getHostBackend().getProviders();
    Plugins graphBuilderPlugins = providers.getGraphBuilderPlugins();
    InvocationPlugins invocationPlugins = graphBuilderPlugins.getInvocationPlugins();
    EconomicMap<String, List<Binding>> bindings = invocationPlugins.getBindings(true);
    HotSpotVMConfigStore store = rt.getVMConfig().getStore();
    List<VMIntrinsicMethod> intrinsics = store.getIntrinsics();
    OptionValues options = getInitialOptions();
    DebugContext debug = getDebugContext(options);
    for (VMIntrinsicMethod intrinsic : intrinsics) {
        InvocationPlugin plugin = CheckGraalIntrinsics.findPlugin(bindings, intrinsic);
        if (plugin != null) {
            if (plugin instanceof MethodSubstitutionPlugin) {
                ResolvedJavaMethod method = CheckGraalIntrinsics.resolveIntrinsic(getMetaAccess(), intrinsic);
                if (!method.isNative()) {
                    StructuredGraph graph = compiler.getIntrinsicGraph(method, providers, INVALID_COMPILATION_ID, options, debug);
                    getCode(method, graph);
                }
            }
        }
    }
}
Also used : HotSpotGraalCompiler(org.graalvm.compiler.hotspot.HotSpotGraalCompiler) InvocationPlugins(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins) OptionValues(org.graalvm.compiler.options.OptionValues) RuntimeProvider(org.graalvm.compiler.runtime.RuntimeProvider) HotSpotGraalRuntimeProvider(org.graalvm.compiler.hotspot.HotSpotGraalRuntimeProvider) HotSpotProviders(org.graalvm.compiler.hotspot.meta.HotSpotProviders) DebugContext(org.graalvm.compiler.debug.DebugContext) HotSpotGraalRuntimeProvider(org.graalvm.compiler.hotspot.HotSpotGraalRuntimeProvider) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) InvocationPlugin(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin) List(java.util.List) MethodSubstitutionPlugin(org.graalvm.compiler.nodes.graphbuilderconf.MethodSubstitutionPlugin) 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) Test(org.junit.Test) GraalCompilerTest(org.graalvm.compiler.core.test.GraalCompilerTest)

Aggregations

List (java.util.List)2 HotSpotVMConfigStore (jdk.vm.ci.hotspot.HotSpotVMConfigStore)2 VMIntrinsicMethod (jdk.vm.ci.hotspot.VMIntrinsicMethod)2 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)2 HotSpotGraalRuntimeProvider (org.graalvm.compiler.hotspot.HotSpotGraalRuntimeProvider)2 HotSpotProviders (org.graalvm.compiler.hotspot.meta.HotSpotProviders)2 Plugins (org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins)2 InvocationPlugin (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin)2 InvocationPlugins (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins)2 RuntimeProvider (org.graalvm.compiler.runtime.RuntimeProvider)2 Test (org.junit.Test)2 ArrayList (java.util.ArrayList)1 IntrinsicMethod (jdk.vm.ci.meta.MethodHandleAccessProvider.IntrinsicMethod)1 GraalCompilerTest (org.graalvm.compiler.core.test.GraalCompilerTest)1 DebugContext (org.graalvm.compiler.debug.DebugContext)1 HotSpotGraalCompiler (org.graalvm.compiler.hotspot.HotSpotGraalCompiler)1 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)1 MethodSubstitutionPlugin (org.graalvm.compiler.nodes.graphbuilderconf.MethodSubstitutionPlugin)1 OptionValues (org.graalvm.compiler.options.OptionValues)1 GraalTest (org.graalvm.compiler.test.GraalTest)1