Search in sources :

Example 1 with HotSpotGraalCompiler

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

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

the class CompileTheWorldTest method testJDK.

@Test
public void testJDK() throws Throwable {
    ExceptionAction originalBailoutAction = CompilationBailoutAction.getValue(getInitialOptions());
    ExceptionAction originalFailureAction = CompilationFailureAction.getValue(getInitialOptions());
    // Compile a couple classes in rt.jar
    HotSpotJVMCIRuntimeProvider runtime = HotSpotJVMCIRuntime.runtime();
    System.setProperty("CompileTheWorld.LimitModules", "java.base");
    OptionValues initialOptions = getInitialOptions();
    EconomicMap<OptionKey<?>, Object> compilationOptions = CompileTheWorld.parseOptions("Inline=false");
    new CompileTheWorld(runtime, (HotSpotGraalCompiler) runtime.getCompiler(), CompileTheWorld.SUN_BOOT_CLASS_PATH, 1, 5, null, null, false, initialOptions, compilationOptions).compile();
    assert CompilationBailoutAction.getValue(initialOptions) == originalBailoutAction;
    assert CompilationFailureAction.getValue(initialOptions) == originalFailureAction;
}
Also used : HotSpotGraalCompiler(org.graalvm.compiler.hotspot.HotSpotGraalCompiler) ExceptionAction(org.graalvm.compiler.core.CompilationWrapper.ExceptionAction) OptionValues(org.graalvm.compiler.options.OptionValues) OptionKey(org.graalvm.compiler.options.OptionKey) HotSpotJVMCIRuntimeProvider(jdk.vm.ci.hotspot.HotSpotJVMCIRuntimeProvider) Test(org.junit.Test) GraalCompilerTest(org.graalvm.compiler.core.test.GraalCompilerTest)

Example 3 with HotSpotGraalCompiler

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

use of org.graalvm.compiler.hotspot.HotSpotGraalCompiler 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)

Example 5 with HotSpotGraalCompiler

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

the class MemoryUsageBenchmark method allocSpyCompilation.

@SuppressWarnings("try")
private void allocSpyCompilation(String methodName) {
    if (AllocSpy.isEnabled()) {
        HotSpotResolvedJavaMethod method = (HotSpotResolvedJavaMethod) getResolvedJavaMethod(methodName);
        // invalidate any existing compiled code
        method.reprofile();
        long jvmciEnv = 0L;
        try (AllocSpy as = AllocSpy.open(methodName)) {
            HotSpotJVMCIRuntimeProvider runtime = HotSpotJVMCIRuntime.runtime();
            HotSpotCompilationRequest request = new HotSpotCompilationRequest(method, JVMCICompiler.INVOCATION_ENTRY_BCI, jvmciEnv);
            HotSpotGraalCompiler compiler = (HotSpotGraalCompiler) runtime.getCompiler();
            OptionValues options = getInitialOptions();
            CompilationTask task = new CompilationTask(runtime, compiler, request, true, false, options);
            task.runCompilation();
        }
    }
}
Also used : HotSpotGraalCompiler(org.graalvm.compiler.hotspot.HotSpotGraalCompiler) HotSpotResolvedJavaMethod(jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod) AllocSpy(org.graalvm.compiler.core.test.AllocSpy) OptionValues(org.graalvm.compiler.options.OptionValues) HotSpotCompilationRequest(jdk.vm.ci.hotspot.HotSpotCompilationRequest) CompilationTask(org.graalvm.compiler.hotspot.CompilationTask) HotSpotJVMCIRuntimeProvider(jdk.vm.ci.hotspot.HotSpotJVMCIRuntimeProvider)

Aggregations

HotSpotGraalCompiler (org.graalvm.compiler.hotspot.HotSpotGraalCompiler)6 OptionValues (org.graalvm.compiler.options.OptionValues)5 HotSpotGraalRuntimeProvider (org.graalvm.compiler.hotspot.HotSpotGraalRuntimeProvider)4 HotSpotJVMCIRuntimeProvider (jdk.vm.ci.hotspot.HotSpotJVMCIRuntimeProvider)3 HotSpotCompilationRequest (jdk.vm.ci.hotspot.HotSpotCompilationRequest)2 HotSpotResolvedJavaMethod (jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod)2 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)2 GraalCompilerTest (org.graalvm.compiler.core.test.GraalCompilerTest)2 CompilationTask (org.graalvm.compiler.hotspot.CompilationTask)2 HotSpotProviders (org.graalvm.compiler.hotspot.meta.HotSpotProviders)2 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)2 RuntimeProvider (org.graalvm.compiler.runtime.RuntimeProvider)2 Test (org.junit.Test)2 List (java.util.List)1 HotSpotCodeCacheProvider (jdk.vm.ci.hotspot.HotSpotCodeCacheProvider)1 HotSpotCompilationRequestResult (jdk.vm.ci.hotspot.HotSpotCompilationRequestResult)1 HotSpotJVMCIRuntime (jdk.vm.ci.hotspot.HotSpotJVMCIRuntime)1 HotSpotVMConfigStore (jdk.vm.ci.hotspot.HotSpotVMConfigStore)1 VMIntrinsicMethod (jdk.vm.ci.hotspot.VMIntrinsicMethod)1 ExceptionAction (org.graalvm.compiler.core.CompilationWrapper.ExceptionAction)1