use of com.oracle.svm.core.graal.code.amd64.SubstrateAMD64AddressLowering in project graal by oracle.
the class NativeImageGenerator method createSuites.
public static Suites createSuites(FeatureHandler featureHandler, RuntimeConfiguration runtimeConfig, SnippetReflectionProvider snippetReflection, boolean hosted) {
Providers runtimeCallProviders = runtimeConfig.getBackendForNormalMethod().getProviders();
OptionValues options = hosted ? HostedOptionValues.singleton() : RuntimeOptionValues.singleton();
Suites suites = GraalConfiguration.instance().createSuites(options, hosted);
PhaseSuite<HighTierContext> highTier = suites.getHighTier();
PhaseSuite<MidTierContext> midTier = suites.getMidTier();
PhaseSuite<LowTierContext> lowTier = suites.getLowTier();
ListIterator<BasePhase<? super HighTierContext>> position;
if (hosted) {
position = GraalConfiguration.instance().createHostedInliners(highTier);
} else {
/* Find the runtime inliner. */
position = highTier.findPhase(InliningPhase.class);
}
if (position != null) {
/* These two phases must be after all method inlining. */
position.add(new DeadStoreRemovalPhase());
position.add(new RemoveUnwindPhase());
} else {
/* There is no inlining, so prepend them in reverse order. */
highTier.prependPhase(new RemoveUnwindPhase());
highTier.prependPhase(new DeadStoreRemovalPhase());
}
highTier.appendPhase(new StackValuePhase());
lowTier.addBeforeLast(new OptimizeExceptionCallsPhase());
CompressEncoding compressEncoding = ImageSingletons.lookup(CompressEncoding.class);
SubstrateAMD64RegisterConfig registerConfig = (SubstrateAMD64RegisterConfig) runtimeCallProviders.getCodeCache().getRegisterConfig();
SubstrateAMD64AddressLowering addressLowering = new SubstrateAMD64AddressLowering(compressEncoding, registerConfig);
lowTier.findPhase(FixReadsPhase.class).add(new AddressLoweringPhase(addressLowering));
if (SubstrateOptions.MultiThreaded.getValue()) {
/*
* Graal inserts only loop safepoints. We want a SafepointNode also before every return.
*/
midTier.findPhase(LoopSafepointInsertionPhase.class).add(new MethodSafepointInsertionPhase());
} else {
/* No need for safepoints when we have only one thread. */
VMError.guarantee(midTier.removePhase(LoopSafepointInsertionPhase.class));
}
if (hosted) {
lowTier.appendPhase(new VerifyNoGuardsPhase());
/* Disable the Graal method inlining, since we have our own inlining system. */
highTier.removePhase(InliningPhase.class);
/* Remove phases that are not suitable for AOT compilation. */
highTier.findPhase(ConvertDeoptimizeToGuardPhase.class, true).remove();
midTier.findPhase(DeoptimizationGroupingPhase.class).remove();
} else {
ListIterator<BasePhase<? super MidTierContext>> it = midTier.findPhase(DeoptimizationGroupingPhase.class);
it.previous();
it.add(new CollectDeoptimizationSourcePositionsPhase());
}
featureHandler.forEachGraalFeature(feature -> feature.registerGraalPhases(runtimeCallProviders, snippetReflection, suites, hosted));
return suites;
}
Aggregations