use of org.graalvm.compiler.phases.tiers.HighTierContext in project graal by oracle.
the class HotSpotGraalCompiler method configGraphBuilderSuite.
/**
* Reconfigures a given graph builder suite (GBS) if one of the given GBS parameter values is
* not the default.
*
* @param suite the graph builder suite
* @param shouldDebugNonSafepoints specifies if extra debug info should be generated (default is
* false)
* @param isOSR specifies if extra OSR-specific post-processing is required (default is false)
* @return a new suite derived from {@code suite} if any of the GBS parameters did not have a
* default value otherwise {@code suite}
*/
protected PhaseSuite<HighTierContext> configGraphBuilderSuite(PhaseSuite<HighTierContext> suite, boolean shouldDebugNonSafepoints, boolean isOSR) {
if (shouldDebugNonSafepoints || isOSR) {
PhaseSuite<HighTierContext> newGbs = suite.copy();
if (shouldDebugNonSafepoints) {
GraphBuilderPhase graphBuilderPhase = (GraphBuilderPhase) newGbs.findPhase(GraphBuilderPhase.class).previous();
GraphBuilderConfiguration graphBuilderConfig = graphBuilderPhase.getGraphBuilderConfig();
graphBuilderConfig = graphBuilderConfig.withNodeSourcePosition(true);
GraphBuilderPhase newGraphBuilderPhase = new GraphBuilderPhase(graphBuilderConfig);
newGbs.findPhase(GraphBuilderPhase.class).set(newGraphBuilderPhase);
}
if (isOSR) {
// We must not clear non liveness for OSR compilations.
GraphBuilderPhase graphBuilderPhase = (GraphBuilderPhase) newGbs.findPhase(GraphBuilderPhase.class).previous();
GraphBuilderConfiguration graphBuilderConfig = graphBuilderPhase.getGraphBuilderConfig();
GraphBuilderPhase newGraphBuilderPhase = new GraphBuilderPhase(graphBuilderConfig);
newGbs.findPhase(GraphBuilderPhase.class).set(newGraphBuilderPhase);
newGbs.appendPhase(new OnStackReplacementPhase());
}
return newGbs;
}
return suite;
}
use of org.graalvm.compiler.phases.tiers.HighTierContext 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;
}
use of org.graalvm.compiler.phases.tiers.HighTierContext in project graal by oracle.
the class HotSpotSuitesProvider method createSuites.
@Override
public Suites createSuites(OptionValues options) {
Suites ret = defaultSuitesCreator.createSuites(options);
if (ImmutableCode.getValue(options)) {
// lowering introduces class constants, therefore it must be after lowering
ret.getHighTier().appendPhase(new LoadJavaMirrorWithKlassPhase(config));
if (VerifyPhases.getValue(options)) {
ret.getHighTier().appendPhase(new AheadOfTimeVerificationPhase());
}
if (GeneratePIC.getValue(options)) {
ListIterator<BasePhase<? super HighTierContext>> highTierLowering = ret.getHighTier().findPhase(LoweringPhase.class);
highTierLowering.previous();
highTierLowering.add(new EliminateRedundantInitializationPhase());
if (HotSpotAOTProfilingPlugin.Options.TieredAOT.getValue(options)) {
highTierLowering.add(new FinalizeProfileNodesPhase(HotSpotAOTProfilingPlugin.Options.TierAInvokeInlineeNotifyFreqLog.getValue(options)));
}
ListIterator<BasePhase<? super MidTierContext>> midTierLowering = ret.getMidTier().findPhase(LoweringPhase.class);
midTierLowering.add(new ReplaceConstantNodesPhase());
// Replace inlining policy
if (Inline.getValue(options)) {
ListIterator<BasePhase<? super HighTierContext>> iter = ret.getHighTier().findPhase(InliningPhase.class);
InliningPhase inlining = (InliningPhase) iter.previous();
CanonicalizerPhase canonicalizer = inlining.getCanonicalizer();
iter.set(new InliningPhase(new AOTInliningPolicy(null), canonicalizer));
}
}
}
ret.getMidTier().appendPhase(new WriteBarrierAdditionPhase(config));
if (VerifyPhases.getValue(options)) {
ret.getMidTier().appendPhase(new WriteBarrierVerificationPhase(config));
}
return ret;
}
use of org.graalvm.compiler.phases.tiers.HighTierContext 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.phases.tiers.HighTierContext 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);
}
Aggregations