Search in sources :

Example 1 with HotSpotGraalRuntimeProvider

use of org.graalvm.compiler.hotspot.HotSpotGraalRuntimeProvider in project graal by oracle.

the class HotSpotTruffleCompilerImpl method create.

public static HotSpotTruffleCompilerImpl create(TruffleCompilerRuntime runtime) {
    HotSpotGraalRuntimeProvider hotspotGraalRuntime = (HotSpotGraalRuntimeProvider) runtime.getGraalRuntime();
    Backend backend = hotspotGraalRuntime.getHostBackend();
    OptionValues options = TruffleCompilerOptions.getOptions();
    Suites suites = backend.getSuites().getDefaultSuites(options);
    LIRSuites lirSuites = backend.getSuites().getDefaultLIRSuites(options);
    GraphBuilderPhase phase = (GraphBuilderPhase) backend.getSuites().getDefaultGraphBuilderSuite().findPhase(GraphBuilderPhase.class).previous();
    Plugins plugins = phase.getGraphBuilderConfig().getPlugins();
    SnippetReflectionProvider snippetReflection = hotspotGraalRuntime.getRequiredCapability(SnippetReflectionProvider.class);
    return new HotSpotTruffleCompilerImpl(hotspotGraalRuntime, runtime, plugins, suites, lirSuites, backend, snippetReflection);
}
Also used : Backend(org.graalvm.compiler.core.target.Backend) SnippetReflectionProvider(org.graalvm.compiler.api.replacements.SnippetReflectionProvider) OptionValues(org.graalvm.compiler.options.OptionValues) LIRSuites(org.graalvm.compiler.lir.phases.LIRSuites) HotSpotGraalRuntimeProvider(org.graalvm.compiler.hotspot.HotSpotGraalRuntimeProvider) GraphBuilderPhase(org.graalvm.compiler.java.GraphBuilderPhase) LIRSuites(org.graalvm.compiler.lir.phases.LIRSuites) Suites(org.graalvm.compiler.phases.tiers.Suites) InvocationPlugins(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins) Plugins(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins)

Example 2 with HotSpotGraalRuntimeProvider

use of org.graalvm.compiler.hotspot.HotSpotGraalRuntimeProvider 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 3 with HotSpotGraalRuntimeProvider

use of org.graalvm.compiler.hotspot.HotSpotGraalRuntimeProvider in project graal by oracle.

the class CompileTheWorld method main.

public static void main(String[] args) throws Throwable {
    HotSpotJVMCIRuntime jvmciRuntime = HotSpotJVMCIRuntime.runtime();
    HotSpotGraalCompiler compiler = (HotSpotGraalCompiler) jvmciRuntime.getCompiler();
    HotSpotGraalRuntimeProvider graalRuntime = compiler.getGraalRuntime();
    HotSpotCodeCacheProvider codeCache = graalRuntime.getHostProviders().getCodeCache();
    OptionValues options = loadOptions(graalRuntime.getOptions());
    int iterations = Options.Iterations.getValue(options);
    for (int i = 0; i < iterations; i++) {
        codeCache.resetCompilationStatistics();
        TTY.println("CompileTheWorld : iteration " + i);
        CompileTheWorld ctw = new CompileTheWorld(jvmciRuntime, compiler, options);
        ctw.compile();
    }
    // This is required as non-daemon threads can be started by class initializers
    System.exit(0);
}
Also used : HotSpotGraalCompiler(org.graalvm.compiler.hotspot.HotSpotGraalCompiler) HotSpotCodeCacheProvider(jdk.vm.ci.hotspot.HotSpotCodeCacheProvider) OptionValues(org.graalvm.compiler.options.OptionValues) HotSpotJVMCIRuntime(jdk.vm.ci.hotspot.HotSpotJVMCIRuntime) HotSpotGraalRuntimeProvider(org.graalvm.compiler.hotspot.HotSpotGraalRuntimeProvider) Print(org.graalvm.compiler.core.CompilationWrapper.ExceptionAction.Print)

Example 4 with HotSpotGraalRuntimeProvider

use of org.graalvm.compiler.hotspot.HotSpotGraalRuntimeProvider in project graal by oracle.

the class GraalOSRTestBase method compile.

protected static void compile(DebugContext debug, ResolvedJavaMethod method, int bci) {
    HotSpotJVMCIRuntimeProvider runtime = HotSpotJVMCIRuntime.runtime();
    long jvmciEnv = 0L;
    HotSpotCompilationRequest request = new HotSpotCompilationRequest((HotSpotResolvedJavaMethod) method, bci, jvmciEnv);
    HotSpotGraalCompiler compiler = (HotSpotGraalCompiler) runtime.getCompiler();
    CompilationTask task = new CompilationTask(runtime, compiler, request, true, true, debug.getOptions());
    if (method instanceof HotSpotResolvedJavaMethod) {
        HotSpotGraalRuntimeProvider graalRuntime = compiler.getGraalRuntime();
        GraalHotSpotVMConfig config = graalRuntime.getVMConfig();
        if (((HotSpotResolvedJavaMethod) method).hasCodeAtLevel(bci, config.compilationLevelFullOptimization)) {
            return;
        }
    }
    HotSpotCompilationRequestResult result = task.runCompilation(debug);
    if (result.getFailure() != null) {
        throw new GraalError(result.getFailureMessage());
    }
}
Also used : HotSpotGraalCompiler(org.graalvm.compiler.hotspot.HotSpotGraalCompiler) HotSpotResolvedJavaMethod(jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod) GraalError(org.graalvm.compiler.debug.GraalError) HotSpotCompilationRequestResult(jdk.vm.ci.hotspot.HotSpotCompilationRequestResult) HotSpotGraalRuntimeProvider(org.graalvm.compiler.hotspot.HotSpotGraalRuntimeProvider) HotSpotCompilationRequest(jdk.vm.ci.hotspot.HotSpotCompilationRequest) CompilationTask(org.graalvm.compiler.hotspot.CompilationTask) GraalHotSpotVMConfig(org.graalvm.compiler.hotspot.GraalHotSpotVMConfig) HotSpotJVMCIRuntimeProvider(jdk.vm.ci.hotspot.HotSpotJVMCIRuntimeProvider)

Example 5 with HotSpotGraalRuntimeProvider

use of org.graalvm.compiler.hotspot.HotSpotGraalRuntimeProvider in project graal by oracle.

the class HotSpotGraalCompilerTest method compileAndInstallSubstitution.

protected InstalledCode compileAndInstallSubstitution(Class<?> c, String methodName) {
    ResolvedJavaMethod method = getMetaAccess().lookupJavaMethod(getMethod(c, methodName));
    HotSpotGraalCompiler compiler = (HotSpotGraalCompiler) JVMCI.getRuntime().getCompiler();
    HotSpotGraalRuntimeProvider rt = (HotSpotGraalRuntimeProvider) Graal.getRequiredCapability(RuntimeProvider.class);
    HotSpotProviders providers = rt.getHostBackend().getProviders();
    CompilationIdentifier compilationId = runtime().getHostBackend().getCompilationIdentifier(method);
    OptionValues options = getInitialOptions();
    StructuredGraph graph = compiler.getIntrinsicGraph(method, providers, compilationId, options, getDebugContext(options));
    if (graph != null) {
        return getCode(method, graph, true, true, graph.getOptions());
    }
    return null;
}
Also used : HotSpotGraalCompiler(org.graalvm.compiler.hotspot.HotSpotGraalCompiler) CompilationIdentifier(org.graalvm.compiler.core.common.CompilationIdentifier) OptionValues(org.graalvm.compiler.options.OptionValues) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) RuntimeProvider(org.graalvm.compiler.runtime.RuntimeProvider) HotSpotGraalRuntimeProvider(org.graalvm.compiler.hotspot.HotSpotGraalRuntimeProvider) HotSpotProviders(org.graalvm.compiler.hotspot.meta.HotSpotProviders) HotSpotGraalRuntimeProvider(org.graalvm.compiler.hotspot.HotSpotGraalRuntimeProvider) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Aggregations

HotSpotGraalRuntimeProvider (org.graalvm.compiler.hotspot.HotSpotGraalRuntimeProvider)6 HotSpotGraalCompiler (org.graalvm.compiler.hotspot.HotSpotGraalCompiler)4 OptionValues (org.graalvm.compiler.options.OptionValues)4 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)3 HotSpotProviders (org.graalvm.compiler.hotspot.meta.HotSpotProviders)3 Plugins (org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins)3 InvocationPlugins (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins)3 RuntimeProvider (org.graalvm.compiler.runtime.RuntimeProvider)3 List (java.util.List)2 HotSpotVMConfigStore (jdk.vm.ci.hotspot.HotSpotVMConfigStore)2 VMIntrinsicMethod (jdk.vm.ci.hotspot.VMIntrinsicMethod)2 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)2 InvocationPlugin (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin)2 Test (org.junit.Test)2 ArrayList (java.util.ArrayList)1 HotSpotCodeCacheProvider (jdk.vm.ci.hotspot.HotSpotCodeCacheProvider)1 HotSpotCompilationRequest (jdk.vm.ci.hotspot.HotSpotCompilationRequest)1 HotSpotCompilationRequestResult (jdk.vm.ci.hotspot.HotSpotCompilationRequestResult)1 HotSpotJVMCIRuntime (jdk.vm.ci.hotspot.HotSpotJVMCIRuntime)1 HotSpotJVMCIRuntimeProvider (jdk.vm.ci.hotspot.HotSpotJVMCIRuntimeProvider)1