Search in sources :

Example 1 with Print

use of org.graalvm.compiler.core.CompilationWrapper.ExceptionAction.Print in project graal by oracle.

the class CompileTheWorld method compileMethod.

/**
 * Compiles a method and gathers some statistics.
 */
private void compileMethod(HotSpotResolvedJavaMethod method, int counter) {
    try {
        long start = System.currentTimeMillis();
        long allocatedAtStart = getCurrentThreadAllocatedBytes();
        int entryBCI = JVMCICompiler.INVOCATION_ENTRY_BCI;
        HotSpotCompilationRequest request = new HotSpotCompilationRequest(method, entryBCI, 0L);
        // For more stable CTW execution, disable use of profiling information
        boolean useProfilingInfo = false;
        boolean installAsDefault = false;
        CompilationTask task = new CompilationTask(jvmciRuntime, compiler, request, useProfilingInfo, installAsDefault, currentOptions);
        task.runCompilation();
        // Invalidate the generated code so the code cache doesn't fill up
        HotSpotInstalledCode installedCode = task.getInstalledCode();
        if (installedCode != null) {
            installedCode.invalidate();
        }
        memoryUsed.getAndAdd(getCurrentThreadAllocatedBytes() - allocatedAtStart);
        compileTime.getAndAdd(System.currentTimeMillis() - start);
        compiledMethodsCounter.incrementAndGet();
    } catch (Throwable t) {
        // Catch everything and print a message
        println("CompileTheWorld (%d) : Error compiling method: %s", counter, method.format("%H.%n(%p):%r"));
        printStackTrace(t);
    }
}
Also used : HotSpotInstalledCode(jdk.vm.ci.hotspot.HotSpotInstalledCode) HotSpotCompilationRequest(jdk.vm.ci.hotspot.HotSpotCompilationRequest) Print(org.graalvm.compiler.core.CompilationWrapper.ExceptionAction.Print) CompilationTask(org.graalvm.compiler.hotspot.CompilationTask)

Aggregations

HotSpotCompilationRequest (jdk.vm.ci.hotspot.HotSpotCompilationRequest)1 HotSpotInstalledCode (jdk.vm.ci.hotspot.HotSpotInstalledCode)1 Print (org.graalvm.compiler.core.CompilationWrapper.ExceptionAction.Print)1 CompilationTask (org.graalvm.compiler.hotspot.CompilationTask)1