use of org.graalvm.compiler.java.GraphBuilderPhase 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.java.GraphBuilderPhase 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.java.GraphBuilderPhase in project graal by oracle.
the class VerifyDebugUsageTest method testDebugUsageClass.
@SuppressWarnings("try")
private static void testDebugUsageClass(Class<?> c) {
RuntimeProvider rt = Graal.getRequiredCapability(RuntimeProvider.class);
Providers providers = rt.getHostBackend().getProviders();
MetaAccessProvider metaAccess = providers.getMetaAccess();
PhaseSuite<HighTierContext> graphBuilderSuite = new PhaseSuite<>();
Plugins plugins = new Plugins(new InvocationPlugins());
GraphBuilderConfiguration config = GraphBuilderConfiguration.getDefault(plugins).withEagerResolving(true).withUnresolvedIsError(true);
graphBuilderSuite.appendPhase(new GraphBuilderPhase(config));
HighTierContext context = new HighTierContext(providers, graphBuilderSuite, OptimisticOptimizations.NONE);
OptionValues options = getInitialOptions();
DebugContext debug = DebugContext.create(options, DebugHandlersFactory.LOADER);
for (Method m : c.getDeclaredMethods()) {
if (!Modifier.isNative(m.getModifiers()) && !Modifier.isAbstract(m.getModifiers())) {
ResolvedJavaMethod method = metaAccess.lookupJavaMethod(m);
StructuredGraph graph = new StructuredGraph.Builder(options, debug).method(method).build();
graphBuilderSuite.apply(graph, context);
try (DebugCloseable s = debug.disableIntercept()) {
new VerifyDebugUsage().apply(graph, context);
}
}
}
}
use of org.graalvm.compiler.java.GraphBuilderPhase in project graal by oracle.
the class VerifyVirtualizableTest method testVirtualizableEffects.
@SuppressWarnings("try")
private static void testVirtualizableEffects(Class<?> c) {
RuntimeProvider rt = Graal.getRequiredCapability(RuntimeProvider.class);
Providers providers = rt.getHostBackend().getProviders();
MetaAccessProvider metaAccess = providers.getMetaAccess();
PhaseSuite<HighTierContext> graphBuilderSuite = new PhaseSuite<>();
Plugins plugins = new Plugins(new InvocationPlugins());
GraphBuilderConfiguration config = GraphBuilderConfiguration.getDefault(plugins).withEagerResolving(true).withUnresolvedIsError(true);
graphBuilderSuite.appendPhase(new GraphBuilderPhase(config));
HighTierContext context = new HighTierContext(providers, graphBuilderSuite, OptimisticOptimizations.NONE);
OptionValues options = getInitialOptions();
DebugContext debug = DebugContext.create(options, DebugHandlersFactory.LOADER);
for (Method m : c.getDeclaredMethods()) {
if (!Modifier.isNative(m.getModifiers()) && !Modifier.isAbstract(m.getModifiers())) {
ResolvedJavaMethod method = metaAccess.lookupJavaMethod(m);
StructuredGraph graph = new StructuredGraph.Builder(options, debug).method(method).build();
graphBuilderSuite.apply(graph, context);
try (DebugCloseable s = debug.disableIntercept()) {
new VerifyVirtualizableUsage().apply(graph, context);
}
}
}
}
use of org.graalvm.compiler.java.GraphBuilderPhase in project graal by oracle.
the class GraalCompilerTest method getCustomGraphBuilderSuite.
protected PhaseSuite<HighTierContext> getCustomGraphBuilderSuite(GraphBuilderConfiguration gbConf) {
PhaseSuite<HighTierContext> suite = getDefaultGraphBuilderSuite();
ListIterator<BasePhase<? super HighTierContext>> iterator = suite.findPhase(GraphBuilderPhase.class);
initializeInvocationPluginExtensions();
GraphBuilderConfiguration gbConfCopy = editGraphBuilderConfiguration(gbConf.copy());
iterator.remove();
iterator.add(new GraphBuilderPhase(gbConfCopy));
return suite;
}
Aggregations