Search in sources :

Example 1 with ReplacementsImpl

use of org.graalvm.compiler.replacements.ReplacementsImpl 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);
}
Also used : InvocationPlugins(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins) InlineDuringParsingPlugin(org.graalvm.compiler.replacements.InlineDuringParsingPlugin) ReplacementsImpl(org.graalvm.compiler.replacements.ReplacementsImpl) GraphBuilderConfiguration(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration) Providers(org.graalvm.compiler.phases.util.Providers) CachingPEGraphDecoder(org.graalvm.compiler.replacements.CachingPEGraphDecoder) TruffleGraphBuilderPlugins(org.graalvm.compiler.truffle.compiler.substitutions.TruffleGraphBuilderPlugins) InvocationPlugins(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins) Plugins(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins)

Example 2 with ReplacementsImpl

use of org.graalvm.compiler.replacements.ReplacementsImpl in project graal by oracle.

the class PartialEvaluator method doGraphPE.

protected void doGraphPE(CompilableTruffleAST compilable, StructuredGraph graph, HighTierContext tierContext, TruffleInliningPlan inliningDecision) {
    LoopExplosionPlugin loopExplosionPlugin = new PELoopExplosionPlugin();
    ParameterPlugin parameterPlugin = new InterceptReceiverPlugin(compilable);
    ReplacementsImpl replacements = (ReplacementsImpl) providers.getReplacements();
    InlineInvokePlugin[] inlineInvokePlugins;
    InlineInvokePlugin inlineInvokePlugin = new PEInlineInvokePlugin(inliningDecision);
    HistogramInlineInvokePlugin histogramPlugin = null;
    if (TruffleCompilerOptions.getValue(PrintTruffleExpansionHistogram)) {
        histogramPlugin = new HistogramInlineInvokePlugin(graph);
        inlineInvokePlugins = new InlineInvokePlugin[] { replacements, inlineInvokePlugin, histogramPlugin };
    } else {
        inlineInvokePlugins = new InlineInvokePlugin[] { replacements, inlineInvokePlugin };
    }
    SourceLanguagePositionProvider sourceLanguagePosition = new TruffleSourceLanguagePositionProvider(inliningDecision);
    PEGraphDecoder decoder = createGraphDecoder(graph, tierContext, loopExplosionPlugin, decodingInvocationPlugins, inlineInvokePlugins, parameterPlugin, nodePlugins, callInlinedMethod, sourceLanguagePosition);
    decoder.decode(graph.method(), graph.trackNodeSourcePosition());
    if (TruffleCompilerOptions.getValue(PrintTruffleExpansionHistogram)) {
        histogramPlugin.print(compilable);
    }
}
Also used : SourceLanguagePositionProvider(org.graalvm.compiler.graph.SourceLanguagePositionProvider) ParameterPlugin(org.graalvm.compiler.nodes.graphbuilderconf.ParameterPlugin) ReplacementsImpl(org.graalvm.compiler.replacements.ReplacementsImpl) LoopExplosionPlugin(org.graalvm.compiler.nodes.graphbuilderconf.LoopExplosionPlugin) CachingPEGraphDecoder(org.graalvm.compiler.replacements.CachingPEGraphDecoder) PEGraphDecoder(org.graalvm.compiler.replacements.PEGraphDecoder) HistogramInlineInvokePlugin(org.graalvm.compiler.truffle.compiler.debug.HistogramInlineInvokePlugin) InlineInvokePlugin(org.graalvm.compiler.nodes.graphbuilderconf.InlineInvokePlugin) HistogramInlineInvokePlugin(org.graalvm.compiler.truffle.compiler.debug.HistogramInlineInvokePlugin)

Example 3 with ReplacementsImpl

use of org.graalvm.compiler.replacements.ReplacementsImpl in project graal by oracle.

the class ReplacementsTest method getSystemClassLoaderBytecodeProvider.

/**
 * Gets a {@link ClassfileBytecodeProvider} that enables snippets and intrinsics to be loaded
 * from the system class path (instead of from the JVMCI class path or Graal module).
 */
protected final ClassfileBytecodeProvider getSystemClassLoaderBytecodeProvider() {
    ReplacementsImpl d = (ReplacementsImpl) getReplacements();
    MetaAccessProvider metaAccess = d.providers.getMetaAccess();
    ClassfileBytecodeProvider bytecodeProvider = new ClassfileBytecodeProvider(metaAccess, d.snippetReflection, ClassLoader.getSystemClassLoader());
    return bytecodeProvider;
}
Also used : ClassfileBytecodeProvider(org.graalvm.compiler.replacements.classfile.ClassfileBytecodeProvider) ReplacementsImpl(org.graalvm.compiler.replacements.ReplacementsImpl) MetaAccessProvider(jdk.vm.ci.meta.MetaAccessProvider)

Aggregations

ReplacementsImpl (org.graalvm.compiler.replacements.ReplacementsImpl)3 CachingPEGraphDecoder (org.graalvm.compiler.replacements.CachingPEGraphDecoder)2 MetaAccessProvider (jdk.vm.ci.meta.MetaAccessProvider)1 SourceLanguagePositionProvider (org.graalvm.compiler.graph.SourceLanguagePositionProvider)1 GraphBuilderConfiguration (org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration)1 Plugins (org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderConfiguration.Plugins)1 InlineInvokePlugin (org.graalvm.compiler.nodes.graphbuilderconf.InlineInvokePlugin)1 InvocationPlugins (org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins)1 LoopExplosionPlugin (org.graalvm.compiler.nodes.graphbuilderconf.LoopExplosionPlugin)1 ParameterPlugin (org.graalvm.compiler.nodes.graphbuilderconf.ParameterPlugin)1 Providers (org.graalvm.compiler.phases.util.Providers)1 InlineDuringParsingPlugin (org.graalvm.compiler.replacements.InlineDuringParsingPlugin)1 PEGraphDecoder (org.graalvm.compiler.replacements.PEGraphDecoder)1 ClassfileBytecodeProvider (org.graalvm.compiler.replacements.classfile.ClassfileBytecodeProvider)1 HistogramInlineInvokePlugin (org.graalvm.compiler.truffle.compiler.debug.HistogramInlineInvokePlugin)1 TruffleGraphBuilderPlugins (org.graalvm.compiler.truffle.compiler.substitutions.TruffleGraphBuilderPlugins)1