Search in sources :

Example 16 with OptionValues

use of org.graalvm.compiler.options.OptionValues in project graal by oracle.

the class CompilerConfigurationFactory method selectFactory.

/**
 * Selects and instantiates a {@link CompilerConfigurationFactory}. The selection algorithm is
 * as follows: if {@code name} is non-null, then select the factory with the same name else if
 * {@code Options.CompilerConfiguration.getValue()} is non-null then select the factory whose
 * name matches the value else select the factory with the highest
 * {@link #autoSelectionPriority} value.
 *
 * @param name the name of the compiler configuration to select (optional)
 */
@SuppressWarnings("try")
public static CompilerConfigurationFactory selectFactory(String name, OptionValues options) {
    CompilerConfigurationFactory factory = null;
    try (InitTimer t = timer("CompilerConfigurationFactory.selectFactory")) {
        String value = name == null ? Options.CompilerConfiguration.getValue(options) : name;
        if ("help".equals(value)) {
            System.out.println("The available Graal compiler configurations are:");
            for (CompilerConfigurationFactory candidate : getAllCandidates()) {
                System.out.println("    " + candidate.name);
            }
            System.exit(0);
        } else if (value != null) {
            for (CompilerConfigurationFactory candidate : GraalServices.load(CompilerConfigurationFactory.class)) {
                if (candidate.name.equals(value)) {
                    factory = candidate;
                    break;
                }
            }
            if (factory == null) {
                throw new GraalError("Graal compiler configuration '%s' not found. Available configurations are: %s", value, getAllCandidates().stream().map(c -> c.name).collect(Collectors.joining(", ")));
            }
        } else {
            List<CompilerConfigurationFactory> candidates = getAllCandidates();
            if (candidates.isEmpty()) {
                throw new GraalError("No %s providers found", CompilerConfigurationFactory.class.getName());
            }
            factory = candidates.get(0);
        }
    }
    ShowConfigurationLevel level = Options.ShowConfiguration.getValue(options);
    if (level != ShowConfigurationLevel.none) {
        switch(level) {
            case info:
                {
                    printConfigInfo(factory);
                    break;
                }
            case verbose:
                {
                    printConfigInfo(factory);
                    CompilerConfiguration config = factory.createCompilerConfiguration();
                    TTY.println("High tier: " + phaseNames(config.createHighTier(options)));
                    TTY.println("Mid tier: " + phaseNames(config.createMidTier(options)));
                    TTY.println("Low tier: " + phaseNames(config.createLowTier(options)));
                    TTY.println("Pre regalloc stage: " + phaseNames(config.createPreAllocationOptimizationStage(options)));
                    TTY.println("Regalloc stage: " + phaseNames(config.createAllocationStage(options)));
                    TTY.println("Post regalloc stage: " + phaseNames(config.createPostAllocationOptimizationStage(options)));
                    config.createAllocationStage(options);
                    break;
                }
        }
    }
    return factory;
}
Also used : OptionValues(org.graalvm.compiler.options.OptionValues) OptionType(org.graalvm.compiler.options.OptionType) TTY(org.graalvm.compiler.debug.TTY) URL(java.net.URL) OptionKey(org.graalvm.compiler.options.OptionKey) BasePhase(org.graalvm.compiler.phases.BasePhase) Collection(java.util.Collection) Architecture(jdk.vm.ci.code.Architecture) InitTimer.timer(jdk.vm.ci.common.InitTimer.timer) CompilerConfiguration(org.graalvm.compiler.phases.tiers.CompilerConfiguration) GraalServices(org.graalvm.compiler.serviceprovider.GraalServices) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) LIRPhase(org.graalvm.compiler.lir.phases.LIRPhase) List(java.util.List) EnumOptionKey(org.graalvm.compiler.options.EnumOptionKey) Option(org.graalvm.compiler.options.Option) EconomicMap(org.graalvm.collections.EconomicMap) LIRPhaseSuite(org.graalvm.compiler.lir.phases.LIRPhaseSuite) PhaseSuite(org.graalvm.compiler.phases.PhaseSuite) GraalError(org.graalvm.compiler.debug.GraalError) InitTimer(jdk.vm.ci.common.InitTimer) Collections(java.util.Collections) InitTimer(jdk.vm.ci.common.InitTimer) GraalError(org.graalvm.compiler.debug.GraalError) CompilerConfiguration(org.graalvm.compiler.phases.tiers.CompilerConfiguration) ArrayList(java.util.ArrayList) List(java.util.List)

Example 17 with OptionValues

use of org.graalvm.compiler.options.OptionValues in project graal by oracle.

the class PartialEvaluator method createGraph.

@SuppressWarnings("try")
public StructuredGraph createGraph(DebugContext debug, final CompilableTruffleAST compilable, TruffleInliningPlan inliningPlan, AllowAssumptions allowAssumptions, CompilationIdentifier compilationId, SpeculationLog log, Cancellable cancellable) {
    String name = compilable.toString();
    OptionValues options = TruffleCompilerOptions.getOptions();
    ResolvedJavaMethod rootMethod = rootForCallTarget(compilable);
    // @formatter:off
    final StructuredGraph graph = new StructuredGraph.Builder(options, debug, allowAssumptions).name(name).method(rootMethod).speculationLog(log).compilationId(compilationId).cancellable(cancellable).build();
    try (DebugContext.Scope s = debug.scope("CreateGraph", graph);
        Indent indent = debug.logAndIndent("createGraph %s", graph)) {
        PhaseContext baseContext = new PhaseContext(providers);
        HighTierContext tierContext = new HighTierContext(providers, new PhaseSuite<HighTierContext>(), OptimisticOptimizations.NONE);
        fastPartialEvaluation(compilable, inliningPlan, graph, baseContext, tierContext);
        if (cancellable != null && cancellable.isCancelled()) {
            return null;
        }
        new VerifyFrameDoesNotEscapePhase().apply(graph, false);
        postPartialEvaluation(graph);
    } catch (Throwable e) {
        throw debug.handle(e);
    }
    return graph;
}
Also used : Indent(org.graalvm.compiler.debug.Indent) VerifyFrameDoesNotEscapePhase(org.graalvm.compiler.truffle.compiler.phases.VerifyFrameDoesNotEscapePhase) OptionValues(org.graalvm.compiler.options.OptionValues) DebugContext(org.graalvm.compiler.debug.DebugContext) PhaseContext(org.graalvm.compiler.phases.tiers.PhaseContext) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) HighTierContext(org.graalvm.compiler.phases.tiers.HighTierContext) ResolvedJavaMethod(jdk.vm.ci.meta.ResolvedJavaMethod)

Example 18 with OptionValues

use of org.graalvm.compiler.options.OptionValues in project graal by oracle.

the class HotSpotTruffleCompilerImpl method compileTruffleCallBoundaryMethod.

/**
 * Compiles a method denoted as a
 * {@linkplain HotSpotTruffleCompilerRuntime#getTruffleCallBoundaryMethods() Truffle call
 * boundary}. The compiled code has a special entry point generated by an
 * {@link TruffleCallBoundaryInstrumentationFactory}.
 */
private CompilationResult compileTruffleCallBoundaryMethod(ResolvedJavaMethod javaMethod, CompilationIdentifier compilationId, DebugContext debug) {
    Suites newSuites = this.suites.copy();
    removeInliningPhase(newSuites);
    OptionValues options = TruffleCompilerOptions.getOptions();
    StructuredGraph graph = new StructuredGraph.Builder(options, debug, AllowAssumptions.NO).method(javaMethod).compilationId(compilationId).build();
    MetaAccessProvider metaAccess = providers.getMetaAccess();
    Plugins plugins = new Plugins(new InvocationPlugins());
    HotSpotCodeCacheProvider codeCache = (HotSpotCodeCacheProvider) providers.getCodeCache();
    boolean infoPoints = codeCache.shouldDebugNonSafepoints();
    GraphBuilderConfiguration newConfig = GraphBuilderConfiguration.getDefault(plugins).withEagerResolving(true).withUnresolvedIsError(true).withNodeSourcePosition(infoPoints);
    new GraphBuilderPhase.Instance(metaAccess, providers.getStampProvider(), providers.getConstantReflection(), providers.getConstantFieldProvider(), newConfig, OptimisticOptimizations.ALL, null).apply(graph);
    PhaseSuite<HighTierContext> graphBuilderSuite = getGraphBuilderSuite(codeCache, backend.getSuites());
    CompilationResultBuilderFactory factory = getTruffleCallBoundaryInstrumentationFactory(backend.getTarget().arch.getName());
    return compileGraph(graph, javaMethod, providers, backend, graphBuilderSuite, OptimisticOptimizations.ALL, graph.getProfilingInfo(), newSuites, lirSuites, new CompilationResult(compilationId), factory);
}
Also used : InvocationPlugins(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins) HotSpotCodeCacheProvider(jdk.vm.ci.hotspot.HotSpotCodeCacheProvider) OptionValues(org.graalvm.compiler.options.OptionValues) GraphBuilderConfiguration(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration) StructuredGraph(org.graalvm.compiler.nodes.StructuredGraph) HighTierContext(org.graalvm.compiler.phases.tiers.HighTierContext) CompilationResult(org.graalvm.compiler.code.CompilationResult) GraphBuilderPhase(org.graalvm.compiler.java.GraphBuilderPhase) CompilationResultBuilderFactory(org.graalvm.compiler.lir.asm.CompilationResultBuilderFactory) MetaAccessProvider(jdk.vm.ci.meta.MetaAccessProvider) 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 19 with OptionValues

use of org.graalvm.compiler.options.OptionValues 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 20 with OptionValues

use of org.graalvm.compiler.options.OptionValues in project graal by oracle.

the class GuardMovement method run0.

@Test
public void run0() throws Throwable {
    OptionValues options = new OptionValues(getInitialOptions(), MaximumInliningSize, -1, GraalOptions.TrivialInliningSize, -1, GraalOptions.PartialEscapeAnalysis, false, GraalOptions.OptReadElimination, false);
    runTest(options, "test", new A());
    runTest(options, "test", new Object[] { null });
}
Also used : OptionValues(org.graalvm.compiler.options.OptionValues) JTTTest(org.graalvm.compiler.jtt.JTTTest) Test(org.junit.Test)

Aggregations

OptionValues (org.graalvm.compiler.options.OptionValues)158 Test (org.junit.Test)65 DebugContext (org.graalvm.compiler.debug.DebugContext)50 StructuredGraph (org.graalvm.compiler.nodes.StructuredGraph)36 ResolvedJavaMethod (jdk.vm.ci.meta.ResolvedJavaMethod)30 Graph (org.graalvm.compiler.graph.Graph)22 OptionKey (org.graalvm.compiler.options.OptionKey)16 HighTierContext (org.graalvm.compiler.phases.tiers.HighTierContext)13 Plugins (org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins)11 GraphBuilderConfiguration (org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration)10 InvocationPlugins (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins)10 CanonicalizerPhase (org.graalvm.compiler.phases.common.CanonicalizerPhase)10 MetaAccessProvider (jdk.vm.ci.meta.MetaAccessProvider)9 DebugCloseable (org.graalvm.compiler.debug.DebugCloseable)9 GraphBuilderPhase (org.graalvm.compiler.java.GraphBuilderPhase)9 Providers (org.graalvm.compiler.phases.util.Providers)9 IOException (java.io.IOException)8 Method (java.lang.reflect.Method)8 CompilationResult (org.graalvm.compiler.code.CompilationResult)7 CompilationIdentifier (org.graalvm.compiler.core.common.CompilationIdentifier)7