use of org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration 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.nodes.graphbuilderconf.GraphBuilderConfiguration in project graal by oracle.
the class HotSpotGraalCompiler method getIntrinsicGraph.
/**
* Gets a graph produced from the intrinsic for a given method that can be compiled and
* installed for the method.
*
* @param method
* @param compilationId
* @param options
* @param debug
* @return an intrinsic graph that can be compiled and installed for {@code method} or null
*/
@SuppressWarnings("try")
public StructuredGraph getIntrinsicGraph(ResolvedJavaMethod method, HotSpotProviders providers, CompilationIdentifier compilationId, OptionValues options, DebugContext debug) {
Replacements replacements = providers.getReplacements();
Bytecode subst = replacements.getSubstitutionBytecode(method);
if (subst != null) {
ResolvedJavaMethod substMethod = subst.getMethod();
assert !substMethod.equals(method);
StructuredGraph graph = new StructuredGraph.Builder(options, debug, AllowAssumptions.YES).method(substMethod).compilationId(compilationId).build();
try (DebugContext.Scope scope = debug.scope("GetIntrinsicGraph", graph)) {
Plugins plugins = new Plugins(providers.getGraphBuilderPlugins());
GraphBuilderConfiguration config = GraphBuilderConfiguration.getSnippetDefault(plugins);
IntrinsicContext initialReplacementContext = new IntrinsicContext(method, substMethod, subst.getOrigin(), ROOT_COMPILATION);
new GraphBuilderPhase.Instance(providers.getMetaAccess(), providers.getStampProvider(), providers.getConstantReflection(), providers.getConstantFieldProvider(), config, OptimisticOptimizations.NONE, initialReplacementContext).apply(graph);
assert !graph.isFrozen();
return graph;
} catch (Throwable e) {
debug.handle(e);
}
}
return null;
}
use of org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration in project graal by oracle.
the class PartialEvaluator method createGraphDecoder.
@SuppressWarnings("unused")
protected PEGraphDecoder createGraphDecoder(StructuredGraph graph, final HighTierContext tierContext, LoopExplosionPlugin loopExplosionPlugin, InvocationPlugins invocationPlugins, InlineInvokePlugin[] inlineInvokePlugins, ParameterPlugin parameterPlugin, NodePlugin[] nodePluginList, ResolvedJavaMethod callInlined, SourceLanguagePositionProvider sourceLanguagePositionProvider) {
final GraphBuilderConfiguration newConfig = configForParsing.copy();
if (newConfig.trackNodeSourcePosition()) {
graph.setTrackNodeSourcePosition();
}
InvocationPlugins parsingInvocationPlugins = newConfig.getPlugins().getInvocationPlugins();
Plugins plugins = newConfig.getPlugins();
ReplacementsImpl replacements = (ReplacementsImpl) providers.getReplacements();
plugins.clearInlineInvokePlugins();
plugins.appendInlineInvokePlugin(replacements);
plugins.appendInlineInvokePlugin(new ParsingInlineInvokePlugin(replacements, parsingInvocationPlugins, loopExplosionPlugin));
if (!TruffleCompilerOptions.getValue(PrintTruffleExpansionHistogram)) {
plugins.appendInlineInvokePlugin(new InlineDuringParsingPlugin());
}
Providers compilationUnitProviders = providers.copyWith(new TruffleConstantFieldProvider(providers.getConstantFieldProvider(), providers.getMetaAccess()));
return new CachingPEGraphDecoder(architecture, graph, compilationUnitProviders, newConfig, TruffleCompilerImpl.Optimizations, AllowAssumptions.ifNonNull(graph.getAssumptions()), loopExplosionPlugin, decodingInvocationPlugins, inlineInvokePlugins, parameterPlugin, nodePluginList, callInlined, sourceLanguagePositionProvider);
}
use of org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration 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.nodes.graphbuilderconf.GraphBuilderConfiguration 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);
}
}
}
}
Aggregations