Search in sources :

Example 1 with HotSpotJVMCIRuntimeProvider

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

the class HotSpotTruffleRuntimeAccess method getRuntime.

@Override
public TruffleRuntime getRuntime() {
    // initialize JVMCI to make sure the TruffleCompiler option is parsed
    Services.initializeJVMCI();
    HotSpotJVMCIRuntimeProvider hsRuntime = (HotSpotJVMCIRuntimeProvider) JVMCI.getRuntime();
    HotSpotVMConfigAccess config = new HotSpotVMConfigAccess(hsRuntime.getConfigStore());
    boolean useCompiler = config.getFlag("UseCompiler", Boolean.class);
    if (!useCompiler) {
        // This happens, for example, when -Xint is given on the command line
        return new DefaultTruffleRuntime();
    }
    return new HotSpotTruffleRuntime(new LazyGraalRuntime());
}
Also used : HotSpotVMConfigAccess(jdk.vm.ci.hotspot.HotSpotVMConfigAccess) DefaultTruffleRuntime(com.oracle.truffle.api.impl.DefaultTruffleRuntime) HotSpotJVMCIRuntimeProvider(jdk.vm.ci.hotspot.HotSpotJVMCIRuntimeProvider)

Example 2 with HotSpotJVMCIRuntimeProvider

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

the class MemoryUsageBenchmark method doCompilation.

@SuppressWarnings("try")
private void doCompilation(String methodName, String label) {
    HotSpotResolvedJavaMethod method = (HotSpotResolvedJavaMethod) getResolvedJavaMethod(methodName);
    // invalidate any existing compiled code
    method.reprofile();
    long jvmciEnv = 0L;
    try (MemoryUsageCloseable c = label == null ? null : new MemoryUsageCloseable(label)) {
        HotSpotJVMCIRuntimeProvider runtime = HotSpotJVMCIRuntime.runtime();
        int entryBCI = JVMCICompiler.INVOCATION_ENTRY_BCI;
        HotSpotCompilationRequest request = new HotSpotCompilationRequest(method, entryBCI, jvmciEnv);
        CompilationTask task = new CompilationTask(runtime, (HotSpotGraalCompiler) runtime.getCompiler(), request, true, false, getInitialOptions());
        task.runCompilation();
    }
}
Also used : HotSpotResolvedJavaMethod(jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod) HotSpotCompilationRequest(jdk.vm.ci.hotspot.HotSpotCompilationRequest) CompilationTask(org.graalvm.compiler.hotspot.CompilationTask) HotSpotJVMCIRuntimeProvider(jdk.vm.ci.hotspot.HotSpotJVMCIRuntimeProvider)

Example 3 with HotSpotJVMCIRuntimeProvider

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

the class MemoryUsageBenchmark method run.

public void run() {
    compileAndTime("simple");
    compileAndTime("complex");
    OptionValues options = CompileTheWorld.loadOptions(getInitialOptions());
    if (CompileTheWorld.Options.Classpath.getValue(options) != CompileTheWorld.SUN_BOOT_CLASS_PATH) {
        HotSpotJVMCIRuntimeProvider runtime = HotSpotJVMCIRuntime.runtime();
        CompileTheWorld ctw = new CompileTheWorld(runtime, (HotSpotGraalCompiler) runtime.getCompiler(), options);
        try {
            ctw.compile();
        } catch (Throwable e) {
            e.printStackTrace();
        }
    }
    allocSpyCompilation("simple");
    allocSpyCompilation("complex");
}
Also used : OptionValues(org.graalvm.compiler.options.OptionValues) HotSpotJVMCIRuntimeProvider(jdk.vm.ci.hotspot.HotSpotJVMCIRuntimeProvider)

Example 4 with HotSpotJVMCIRuntimeProvider

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

use of jdk.vm.ci.hotspot.HotSpotJVMCIRuntimeProvider 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)

Aggregations

HotSpotJVMCIRuntimeProvider (jdk.vm.ci.hotspot.HotSpotJVMCIRuntimeProvider)6 HotSpotCompilationRequest (jdk.vm.ci.hotspot.HotSpotCompilationRequest)3 HotSpotResolvedJavaMethod (jdk.vm.ci.hotspot.HotSpotResolvedJavaMethod)3 CompilationTask (org.graalvm.compiler.hotspot.CompilationTask)3 HotSpotGraalCompiler (org.graalvm.compiler.hotspot.HotSpotGraalCompiler)3 OptionValues (org.graalvm.compiler.options.OptionValues)3 DefaultTruffleRuntime (com.oracle.truffle.api.impl.DefaultTruffleRuntime)1 HotSpotCompilationRequestResult (jdk.vm.ci.hotspot.HotSpotCompilationRequestResult)1 HotSpotVMConfigAccess (jdk.vm.ci.hotspot.HotSpotVMConfigAccess)1 ExceptionAction (org.graalvm.compiler.core.CompilationWrapper.ExceptionAction)1 AllocSpy (org.graalvm.compiler.core.test.AllocSpy)1 GraalCompilerTest (org.graalvm.compiler.core.test.GraalCompilerTest)1 GraalError (org.graalvm.compiler.debug.GraalError)1 GraalHotSpotVMConfig (org.graalvm.compiler.hotspot.GraalHotSpotVMConfig)1 HotSpotGraalRuntimeProvider (org.graalvm.compiler.hotspot.HotSpotGraalRuntimeProvider)1 OptionKey (org.graalvm.compiler.options.OptionKey)1 Test (org.junit.Test)1