use of org.graalvm.compiler.replacements.CachingPEGraphDecoder 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.replacements.CachingPEGraphDecoder in project graal by oracle.
the class PEGraphDecoderTest method test.
@Test
@SuppressWarnings("try")
public void test() {
ResolvedJavaMethod testMethod = getResolvedJavaMethod(PEGraphDecoderTest.class, "doTest", Object.class);
StructuredGraph targetGraph = null;
DebugContext debug = getDebugContext();
try (DebugContext.Scope scope = debug.scope("GraphPETest", testMethod)) {
GraphBuilderConfiguration graphBuilderConfig = GraphBuilderConfiguration.getDefault(getDefaultGraphBuilderPlugins()).withEagerResolving(true).withUnresolvedIsError(true);
registerPlugins(graphBuilderConfig.getPlugins().getInvocationPlugins());
targetGraph = new StructuredGraph.Builder(getInitialOptions(), debug, AllowAssumptions.YES).method(testMethod).build();
CachingPEGraphDecoder decoder = new CachingPEGraphDecoder(getTarget().arch, targetGraph, getProviders(), graphBuilderConfig, OptimisticOptimizations.NONE, AllowAssumptions.YES, null, null, new InlineInvokePlugin[] { new InlineAll() }, null, null, null, null);
decoder.decode(testMethod, false);
debug.dump(DebugContext.BASIC_LEVEL, targetGraph, "Target Graph");
targetGraph.verify();
PhaseContext context = new PhaseContext(getProviders());
new CanonicalizerPhase().apply(targetGraph, context);
targetGraph.verify();
} catch (Throwable ex) {
if (targetGraph != null) {
debug.dump(DebugContext.BASIC_LEVEL, targetGraph, ex.toString());
}
debug.handle(ex);
}
}
Aggregations