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;
}
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;
}
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);
}
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);
}
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 });
}
Aggregations