Search in sources :

Example 1 with ProfilingInfo

use of jdk.vm.ci.meta.ProfilingInfo in project graal by oracle.

the class AbstractInliningPolicy method previousLowLevelGraphSize.

protected static int previousLowLevelGraphSize(InlineInfo info) {
    int size = 0;
    for (int i = 0; i < info.numberOfMethods(); i++) {
        ResolvedJavaMethod m = info.methodAt(i);
        ProfilingInfo profile = info.graph().getProfilingInfo(m);
        int compiledGraphSize = profile.getCompilerIRSize(StructuredGraph.class);
        if (compiledGraphSize > 0) {
            size += compiledGraphSize;
        }
    }
    return size;
}
Also used : ProfilingInfo(jdk.vm.ci.meta.ProfilingInfo) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 2 with ProfilingInfo

use of jdk.vm.ci.meta.ProfilingInfo in project graal by oracle.

the class HotSpotGraalCompiler method compileHelper.

public CompilationResult compileHelper(CompilationResultBuilderFactory crbf, CompilationResult result, StructuredGraph graph, ResolvedJavaMethod method, int entryBCI, boolean useProfilingInfo, OptionValues options) {
    HotSpotBackend backend = graalRuntime.getHostBackend();
    HotSpotProviders providers = backend.getProviders();
    final boolean isOSR = entryBCI != JVMCICompiler.INVOCATION_ENTRY_BCI;
    Suites suites = getSuites(providers, options);
    LIRSuites lirSuites = getLIRSuites(providers, options);
    ProfilingInfo profilingInfo = useProfilingInfo ? method.getProfilingInfo(!isOSR, isOSR) : DefaultProfilingInfo.get(TriState.FALSE);
    OptimisticOptimizations optimisticOpts = getOptimisticOpts(profilingInfo, options);
    /*
         * Cut off never executed code profiles if there is code, e.g. after the osr loop, that is
         * never executed.
         */
    if (isOSR && !OnStackReplacementPhase.Options.DeoptAfterOSR.getValue(options)) {
        optimisticOpts.remove(Optimization.RemoveNeverExecutedCode);
    }
    result.setEntryBCI(entryBCI);
    boolean shouldDebugNonSafepoints = providers.getCodeCache().shouldDebugNonSafepoints();
    PhaseSuite<HighTierContext> graphBuilderSuite = configGraphBuilderSuite(providers.getSuites().getDefaultGraphBuilderSuite(), shouldDebugNonSafepoints, isOSR);
    GraalCompiler.compileGraph(graph, method, providers, backend, graphBuilderSuite, optimisticOpts, profilingInfo, suites, lirSuites, result, crbf);
    if (!isOSR && useProfilingInfo) {
        ProfilingInfo profile = profilingInfo;
        profile.setCompilerIRSize(StructuredGraph.class, graph.getNodeCount());
    }
    return result;
}
Also used : HotSpotProviders(org.graalvm.compiler.hotspot.meta.HotSpotProviders) DefaultProfilingInfo(jdk.vm.ci.meta.DefaultProfilingInfo) ProfilingInfo(jdk.vm.ci.meta.ProfilingInfo) LIRSuites(org.graalvm.compiler.lir.phases.LIRSuites) HighTierContext(org.graalvm.compiler.phases.tiers.HighTierContext) OptimisticOptimizations(org.graalvm.compiler.phases.OptimisticOptimizations) LIRSuites(org.graalvm.compiler.lir.phases.LIRSuites) Suites(org.graalvm.compiler.phases.tiers.Suites)

Example 3 with ProfilingInfo

use of jdk.vm.ci.meta.ProfilingInfo in project graal by oracle.

the class ProfilingInfoTest method testNullSeen.

private void testNullSeen(String snippet) {
    ProfilingInfo info = profile(snippet, 1);
    Assert.assertEquals(TriState.FALSE, info.getNullSeen(1));
    continueProfiling(snippet, "ABC");
    Assert.assertEquals(TriState.FALSE, info.getNullSeen(1));
    continueProfiling(snippet, new Object());
    Assert.assertEquals(TriState.FALSE, info.getNullSeen(1));
    if (TriState.TRUE == info.getNullSeen(1)) {
        // See the javadoc comment for ProfilingInfoTest.
        continueProfiling(snippet, (Object) null);
        Assert.assertEquals(TriState.TRUE, info.getNullSeen(1));
        continueProfiling(snippet, 0.0);
        Assert.assertEquals(TriState.TRUE, info.getNullSeen(1));
        continueProfiling(snippet, new Object());
        Assert.assertEquals(TriState.TRUE, info.getNullSeen(1));
    }
    resetProfile(snippet);
    Assert.assertEquals(TriState.FALSE, info.getNullSeen(1));
}
Also used : ProfilingInfo(jdk.vm.ci.meta.ProfilingInfo)

Example 4 with ProfilingInfo

use of jdk.vm.ci.meta.ProfilingInfo in project graal by oracle.

the class InvokeGraal method compileAndInstallMethod.

/**
 * The simplest way to compile a method, using the default behavior for everything.
 */
@SuppressWarnings("try")
protected InstalledCode compileAndInstallMethod(ResolvedJavaMethod method) {
    /* Create a unique compilation identifier, visible in IGV. */
    CompilationIdentifier compilationId = backend.getCompilationIdentifier(method);
    OptionValues options = getInitialOptions();
    DebugContext debug = DebugContext.create(options, DebugHandlersFactory.LOADER);
    try (DebugContext.Scope s = debug.scope("compileAndInstallMethod", new DebugDumpScope(String.valueOf(compilationId), true))) {
        /*
             * The graph that is compiled. We leave it empty (no nodes added yet). This means that
             * it will be filled according to the graphBuilderSuite defined below. We also specify
             * that we want the compilation to make optimistic assumptions about runtime state such
             * as the loaded class hierarchy.
             */
        StructuredGraph graph = new StructuredGraph.Builder(options, debug, AllowAssumptions.YES).method(method).compilationId(compilationId).build();
        /*
             * The phases used to build the graph. Usually this is just the GraphBuilderPhase. If
             * the graph already contains nodes, it is ignored.
             */
        PhaseSuite<HighTierContext> graphBuilderSuite = backend.getSuites().getDefaultGraphBuilderSuite();
        /*
             * The optimization phases that are applied to the graph. This is the main configuration
             * point for Graal. Add or remove phases to customize your compilation.
             */
        Suites suites = backend.getSuites().getDefaultSuites(options);
        /*
             * The low-level phases that are applied to the low-level representation.
             */
        LIRSuites lirSuites = backend.getSuites().getDefaultLIRSuites(options);
        /*
             * We want Graal to perform all speculative optimistic optimizations, using the
             * profiling information that comes with the method (collected by the interpreter) for
             * speculation.
             */
        OptimisticOptimizations optimisticOpts = OptimisticOptimizations.ALL;
        ProfilingInfo profilingInfo = graph.getProfilingInfo(method);
        /* The default class and configuration for compilation results. */
        CompilationResult compilationResult = new CompilationResult(graph.compilationId());
        CompilationResultBuilderFactory factory = CompilationResultBuilderFactory.Default;
        /* Invoke the whole Graal compilation pipeline. */
        GraalCompiler.compileGraph(graph, method, providers, backend, graphBuilderSuite, optimisticOpts, profilingInfo, suites, lirSuites, compilationResult, factory);
        /*
             * Install the compilation result into the VM, i.e., copy the byte[] array that contains
             * the machine code into an actual executable memory location.
             */
        return backend.addInstalledCode(debug, method, asCompilationRequest(compilationId), compilationResult);
    } catch (Throwable ex) {
        throw debug.handle(ex);
    }
}
Also used : CompilationIdentifier(org.graalvm.compiler.core.common.CompilationIdentifier) OptionValues(org.graalvm.compiler.options.OptionValues) DebugDumpScope(org.graalvm.compiler.debug.DebugDumpScope) ProfilingInfo(jdk.vm.ci.meta.ProfilingInfo) DebugContext(org.graalvm.compiler.debug.DebugContext) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) LIRSuites(org.graalvm.compiler.lir.phases.LIRSuites) HighTierContext(org.graalvm.compiler.phases.tiers.HighTierContext) CompilationResult(org.graalvm.compiler.code.CompilationResult) OptimisticOptimizations(org.graalvm.compiler.phases.OptimisticOptimizations) CompilationResultBuilderFactory(org.graalvm.compiler.lir.asm.CompilationResultBuilderFactory) LIRSuites(org.graalvm.compiler.lir.phases.LIRSuites) Suites(org.graalvm.compiler.phases.tiers.Suites)

Example 5 with ProfilingInfo

use of jdk.vm.ci.meta.ProfilingInfo in project graal by oracle.

the class GraalCompilerTest method executeActualCheckDeopt.

protected Result executeActualCheckDeopt(OptionValues options, ResolvedJavaMethod method, Set<DeoptimizationReason> shouldNotDeopt, Object receiver, Object... args) {
    Map<DeoptimizationReason, Integer> deoptCounts = new EnumMap<>(DeoptimizationReason.class);
    ProfilingInfo profile = method.getProfilingInfo();
    for (DeoptimizationReason reason : shouldNotDeopt) {
        deoptCounts.put(reason, profile.getDeoptimizationCount(reason));
    }
    Result actual = executeActual(options, method, receiver, args);
    // profile can change after execution
    profile = method.getProfilingInfo();
    for (DeoptimizationReason reason : shouldNotDeopt) {
        Assert.assertEquals("wrong number of deopt counts for " + reason, (int) deoptCounts.get(reason), profile.getDeoptimizationCount(reason));
    }
    return actual;
}
Also used : ProfilingInfo(jdk.vm.ci.meta.ProfilingInfo) DeoptimizationReason(jdk.vm.ci.meta.DeoptimizationReason) EnumMap(java.util.EnumMap) CompilationResult(org.graalvm.compiler.code.CompilationResult) ScheduleResult(org.graalvm.compiler.nodes.StructuredGraph.ScheduleResult)

Aggregations

ProfilingInfo (jdk.vm.ci.meta.ProfilingInfo)10 Test (org.junit.Test)3 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)2 CompilationResult (org.graalvm.compiler.code.CompilationResult)2 LIRSuites (org.graalvm.compiler.lir.phases.LIRSuites)2 OptimisticOptimizations (org.graalvm.compiler.phases.OptimisticOptimizations)2 HighTierContext (org.graalvm.compiler.phases.tiers.HighTierContext)2 Suites (org.graalvm.compiler.phases.tiers.Suites)2 EnumMap (java.util.EnumMap)1 DefaultProfilingInfo (jdk.vm.ci.meta.DefaultProfilingInfo)1 DeoptimizationReason (jdk.vm.ci.meta.DeoptimizationReason)1 JavaTypeProfile (jdk.vm.ci.meta.JavaTypeProfile)1 ResolvedJavaType (jdk.vm.ci.meta.ResolvedJavaType)1 CompilationIdentifier (org.graalvm.compiler.core.common.CompilationIdentifier)1 DebugContext (org.graalvm.compiler.debug.DebugContext)1 DebugDumpScope (org.graalvm.compiler.debug.DebugDumpScope)1 HotSpotProviders (org.graalvm.compiler.hotspot.meta.HotSpotProviders)1 CompilationResultBuilderFactory (org.graalvm.compiler.lir.asm.CompilationResultBuilderFactory)1 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)1 ScheduleResult (org.graalvm.compiler.nodes.StructuredGraph.ScheduleResult)1