public class ReplacementsImpl extends Object implements Replacements, InlineInvokePlugin
| Modifier and Type | Class and Description |
|---|---|
static class |
ReplacementsImpl.GraphMaker
Creates and preprocesses a graph for a replacement.
|
InlineInvokePlugin.InlineInfo| Modifier and Type | Field and Description |
|---|---|
protected BytecodeProvider |
defaultBytecodeProvider
The default
BytecodeProvider to use for accessing the bytecode of a replacement if
the replacement doesn't provide another BytecodeProvider. |
protected ConcurrentMap<ResolvedJavaMethod,StructuredGraph> |
graphs
The preprocessed replacement graphs.
|
protected Providers |
providers |
SnippetReflectionProvider |
snippetReflection |
TargetDescription |
target |
| Constructor and Description |
|---|
ReplacementsImpl(DebugHandlersFactory debugHandlersFactory,
Providers providers,
SnippetReflectionProvider snippetReflection,
BytecodeProvider bytecodeProvider,
TargetDescription target) |
| Modifier and Type | Method and Description |
|---|---|
protected ReplacementsImpl.GraphMaker |
createGraphMaker(ResolvedJavaMethod substitute,
ResolvedJavaMethod original)
Can be overridden to return an object that specializes various parts of graph preprocessing.
|
BytecodeProvider |
getDefaultReplacementBytecodeProvider()
Gets the provider for accessing the bytecode of a substitution method if no other provider is
associated with the substitution method.
|
GraphBuilderConfiguration.Plugins |
getGraphBuilderPlugins()
Gets the object managing the various graph builder plugins used by this object when parsing
bytecode into a graph.
|
<T> T |
getInjectedArgument(Class<T> capability) |
Stamp |
getInjectedStamp(Class<?> type,
boolean nonNull)
Gets a stamp denoting a given type and non-nullness property.
|
StructuredGraph |
getInlineSubstitution(ResolvedJavaMethod method,
int invokeBci,
Invoke.InlineControl inlineControl,
boolean trackNodeSourcePosition,
NodeSourcePosition replaceePosition,
StructuredGraph.AllowAssumptions allowAssumptions,
OptionValues options)
Gets a graph that is a substitution for a given method.
|
StructuredGraph |
getIntrinsicGraph(ResolvedJavaMethod method,
CompilationIdentifier compilationId,
DebugContext debug,
StructuredGraph.AllowAssumptions allowAssumptions,
Cancellable cancellable)
Gets a graph produced from the intrinsic for a given method that can be compiled and
installed for the method.
|
Class<? extends GraphBuilderPlugin> |
getIntrinsifyingPlugin(ResolvedJavaMethod method)
Gets the plugin type that intrinsifies calls to
method. |
Providers |
getProviders() |
StructuredGraph |
getSnippet(ResolvedJavaMethod method,
ResolvedJavaMethod recursiveEntry,
Object[] args,
BitSet nonNullParameters,
boolean trackNodeSourcePosition,
NodeSourcePosition replaceePosition,
OptionValues options)
Gets the snippet graph derived from a given method.
|
SnippetParameterInfo |
getSnippetParameterInfo(ResolvedJavaMethod method)
Get the snippet metadata required to inline the snippet.
|
<T extends SnippetTemplateCache> |
getSnippetTemplateCache(Class<T> templatesClass)
Get snippet templates that were registered with
Replacements.registerSnippetTemplateCache(SnippetTemplateCache). |
JavaKind |
getWordKind()
Gets the JavaKind corresponding to word values.
|
boolean |
hasSubstitution(ResolvedJavaMethod method,
OptionValues options)
Determines if there may be a
substitution graph for a given method.
|
boolean |
isSnippet(ResolvedJavaMethod method)
Return true if the method is a
Snippet. |
StructuredGraph |
makeGraph(DebugContext debug,
BytecodeProvider bytecodeProvider,
ResolvedJavaMethod method,
Object[] args,
BitSet nonNullParameters,
ResolvedJavaMethod original,
boolean trackNodeSourcePosition,
NodeSourcePosition replaceePosition)
Creates a preprocessed graph for a snippet or method substitution with a context of .
|
StructuredGraph |
makeGraph(DebugContext debug,
BytecodeProvider bytecodeProvider,
ResolvedJavaMethod method,
Object[] args,
BitSet nonNullParameters,
ResolvedJavaMethod original,
boolean trackNodeSourcePosition,
NodeSourcePosition replaceePosition,
IntrinsicContext.CompilationContext context)
Creates a preprocessed graph for a snippet or method substitution.
|
void |
notifyNotInlined(GraphBuilderContext b,
ResolvedJavaMethod method,
Invoke invoke)
Notifies this plugin of the
Invoke node created for a method that was not inlined per
InlineInvokePlugin.shouldInlineInvoke(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext, ResolvedJavaMethod, org.graalvm.compiler.nodes.ValueNode[]). |
DebugContext |
openDebugContext(String idPrefix,
ResolvedJavaMethod method,
OptionValues options) |
DebugContext |
openSnippetDebugContext(DebugContext.Description description,
DebugContext outer,
OptionValues options)
Create a
DebugContext for use with Snippet related work. |
DebugContext |
openSnippetDebugContext(String idPrefix,
ResolvedJavaMethod method,
OptionValues options) |
void |
registerConditionalPlugin(InvocationPlugin plugin)
Marks a plugin as conditionally applied.
|
void |
registerSnippet(ResolvedJavaMethod method,
ResolvedJavaMethod original,
Object receiver,
boolean trackNodeSourcePosition,
OptionValues options)
Registers a method as snippet.
|
void |
registerSnippetTemplateCache(SnippetTemplateCache templates)
Register snippet templates.
|
void |
setGraphBuilderPlugins(GraphBuilderConfiguration.Plugins plugins) |
void |
setProviders(Providers providers) |
InlineInvokePlugin.InlineInfo |
shouldInlineInvoke(GraphBuilderContext b,
ResolvedJavaMethod method,
ValueNode[] args)
Determines whether a given method should be inlined based on whether it has a substitution or
whether the inlining context is already within a substitution.
|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcloseSnippetRegistration, isEncodingSnippetsnotifyAfterInline, notifyBeforeInlineprotected Providers providers
public final SnippetReflectionProvider snippetReflection
public final TargetDescription target
protected final ConcurrentMap<ResolvedJavaMethod,StructuredGraph> graphs
protected final BytecodeProvider defaultBytecodeProvider
BytecodeProvider to use for accessing the bytecode of a replacement if
the replacement doesn't provide another BytecodeProvider.public ReplacementsImpl(DebugHandlersFactory debugHandlersFactory, Providers providers, SnippetReflectionProvider snippetReflection, BytecodeProvider bytecodeProvider, TargetDescription target)
public Providers getProviders()
getProviders in interface Replacementspublic void setProviders(Providers providers)
public void setGraphBuilderPlugins(GraphBuilderConfiguration.Plugins plugins)
public GraphBuilderConfiguration.Plugins getGraphBuilderPlugins()
ReplacementsgetGraphBuilderPlugins in interface Replacementspublic <T> T getInjectedArgument(Class<T> capability)
getInjectedArgument in interface GeneratedPluginInjectionProviderpublic Stamp getInjectedStamp(Class<?> type, boolean nonNull)
GeneratedPluginInjectionProvidergetInjectedStamp in interface GeneratedPluginInjectionProvidertype - the type the returned stamp representsnonNull - specifies if the returned stamp denotes a value that is guaranteed to be
non-nullpublic Class<? extends GraphBuilderPlugin> getIntrinsifyingPlugin(ResolvedJavaMethod method)
Replacementsmethod.getIntrinsifyingPlugin in interface Replacementspublic InlineInvokePlugin.InlineInfo shouldInlineInvoke(GraphBuilderContext b, ResolvedJavaMethod method, ValueNode[] args)
shouldInlineInvoke in interface InlineInvokePluginb - the contextmethod - the target method of an invokeargs - the arguments to the invokemethod is to be inlined or null if it should not be
inlined based on substitution related criteriapublic void notifyNotInlined(GraphBuilderContext b, ResolvedJavaMethod method, Invoke invoke)
InlineInvokePluginInvoke node created for a method that was not inlined per
InlineInvokePlugin.shouldInlineInvoke(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext, ResolvedJavaMethod, org.graalvm.compiler.nodes.ValueNode[]).notifyNotInlined in interface InlineInvokePluginb - the contextmethod - the method that was not inlinedinvoke - the invoke node created for the call to methodpublic DebugContext openSnippetDebugContext(DebugContext.Description description, DebugContext outer, OptionValues options)
ReplacementsDebugContext for use with Snippet related work. Snippet processingis
hidden by default using the flags DebugStubsAndSnippets.openSnippetDebugContext in interface Replacementspublic DebugContext openSnippetDebugContext(String idPrefix, ResolvedJavaMethod method, OptionValues options)
public DebugContext openDebugContext(String idPrefix, ResolvedJavaMethod method, OptionValues options)
public StructuredGraph getSnippet(ResolvedJavaMethod method, ResolvedJavaMethod recursiveEntry, Object[] args, BitSet nonNullParameters, boolean trackNodeSourcePosition, NodeSourcePosition replaceePosition, OptionValues options)
ReplacementsgetSnippet in interface ReplacementsrecursiveEntry - XXX always null now?.args - arguments to the snippet if available, otherwise nullmethodpublic SnippetParameterInfo getSnippetParameterInfo(ResolvedJavaMethod method)
ReplacementsgetSnippetParameterInfo in interface Replacementspublic boolean isSnippet(ResolvedJavaMethod method)
ReplacementsSnippet.isSnippet in interface Replacementspublic void registerSnippet(ResolvedJavaMethod method,
ResolvedJavaMethod original,
Object receiver,
boolean trackNodeSourcePosition,
OptionValues options)
ReplacementsregisterSnippet in interface Replacementspublic void registerConditionalPlugin(InvocationPlugin plugin)
ReplacementsregisterConditionalPlugin in interface Replacementspublic boolean hasSubstitution(ResolvedJavaMethod method,
OptionValues options)
ReplacementsReplacements.getInlineSubstitution(ResolvedJavaMethod, int, org.graalvm.compiler.nodes.Invoke.InlineControl, boolean, org.graalvm.compiler.graph.NodeSourcePosition, org.graalvm.compiler.nodes.StructuredGraph.AllowAssumptions, org.graalvm.compiler.options.OptionValues) may still return null for method and
substitution may be based on an InvocationPlugin that returns false for
InvocationPlugin.execute(org.graalvm.compiler.nodes.graphbuilderconf.GraphBuilderContext, ResolvedJavaMethod, org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin.Receiver, org.graalvm.compiler.nodes.ValueNode[]) making it impossible to create a substitute graph.hasSubstitution in interface Replacementsmethodpublic BytecodeProvider getDefaultReplacementBytecodeProvider()
ReplacementsgetDefaultReplacementBytecodeProvider in interface Replacementspublic StructuredGraph getInlineSubstitution(ResolvedJavaMethod method, int invokeBci, Invoke.InlineControl inlineControl, boolean trackNodeSourcePosition, NodeSourcePosition replaceePosition, StructuredGraph.AllowAssumptions allowAssumptions, OptionValues options)
ReplacementsgetInlineSubstitution in interface ReplacementsinvokeBci - the call site BCI for the substitutionmethodpublic StructuredGraph getIntrinsicGraph(ResolvedJavaMethod method, CompilationIdentifier compilationId, DebugContext debug, StructuredGraph.AllowAssumptions allowAssumptions, Cancellable cancellable)
ReplacementsgetIntrinsicGraph in interface Replacementsmethod or nullpublic StructuredGraph makeGraph(DebugContext debug, BytecodeProvider bytecodeProvider, ResolvedJavaMethod method, Object[] args, BitSet nonNullParameters, ResolvedJavaMethod original, boolean trackNodeSourcePosition, NodeSourcePosition replaceePosition, IntrinsicContext.CompilationContext context)
bytecodeProvider - how to access the bytecode of methodmethod - the snippet or method substitution for which a graph will be createdargs - nonNullParameters - original - XXX always null?trackNodeSourcePosition - record source informationcontext - compilation context for the graphpublic final StructuredGraph makeGraph(DebugContext debug, BytecodeProvider bytecodeProvider, ResolvedJavaMethod method, Object[] args, BitSet nonNullParameters, ResolvedJavaMethod original, boolean trackNodeSourcePosition, NodeSourcePosition replaceePosition)
IntrinsicContext.CompilationContext.INLINE_AFTER_PARSING
.bytecodeProvider - how to access the bytecode of methodmethod - the snippet or method substitution for which a graph will be createdargs - nonNullParameters - original - XXX always null?trackNodeSourcePosition - record source informationprotected ReplacementsImpl.GraphMaker createGraphMaker(ResolvedJavaMethod substitute, ResolvedJavaMethod original)
public void registerSnippetTemplateCache(SnippetTemplateCache templates)
ReplacementsregisterSnippetTemplateCache in interface Replacementspublic <T extends SnippetTemplateCache> T getSnippetTemplateCache(Class<T> templatesClass)
ReplacementsReplacements.registerSnippetTemplateCache(SnippetTemplateCache).getSnippetTemplateCache in interface Replacementspublic JavaKind getWordKind()
ReplacementsgetWordKind in interface Replacements