use of org.graalvm.compiler.replacements.PEGraphDecoder in project graal by oracle.
the class SubstrateReplacements method getSnippet.
@Override
public StructuredGraph getSnippet(ResolvedJavaMethod method, ResolvedJavaMethod recursiveEntry, Object[] args, boolean trackNodeSourcePosition, NodeSourcePosition replaceePosition) {
Integer startOffset = snippetStartOffsets.get(method);
if (startOffset == null) {
throw VMError.shouldNotReachHere("snippet not found: " + method.format("%H.%n(%p)"));
}
ParameterPlugin parameterPlugin = null;
if (args != null) {
parameterPlugin = new ConstantBindingParameterPlugin(args, providers.getMetaAccess(), snippetReflection);
}
EncodedGraph encodedGraph = new EncodedGraph(snippetEncoding, startOffset, snippetObjects, snippetNodeClasses, null, null, null, false, trackNodeSourcePosition);
try (DebugContext debug = openDebugContext("SVMSnippet_", method)) {
StructuredGraph result = new StructuredGraph.Builder(options, debug).method(method).trackNodeSourcePosition(trackNodeSourcePosition).build();
PEGraphDecoder graphDecoder = new PEGraphDecoder(ConfigurationValues.getTarget().arch, result, providers.getMetaAccess(), providers.getConstantReflection(), providers.getConstantFieldProvider(), providers.getStampProvider(), null, snippetInvocationPlugins, new InlineInvokePlugin[0], parameterPlugin, null, null, null) {
@Override
protected EncodedGraph lookupEncodedGraph(ResolvedJavaMethod lookupMethod, ResolvedJavaMethod originalMethod, BytecodeProvider intrinsicBytecodeProvider, boolean track) {
if (lookupMethod.equals(method)) {
assert !track || encodedGraph.trackNodeSourcePosition();
return encodedGraph;
} else {
throw VMError.shouldNotReachHere(method.format("%H.%n(%p)"));
}
}
};
graphDecoder.decode(method, trackNodeSourcePosition);
assert result.verify();
return result;
}
}
use of org.graalvm.compiler.replacements.PEGraphDecoder 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);
}
}
Aggregations