public class ReplacementsImpl extends Object implements Replacements, InlineInvokePlugin
Modifier and Type | Class and Description |
---|---|
protected class |
ReplacementsImpl.ClassReplacements
Encapsulates method and macro substitutions for a single class.
|
static class |
ReplacementsImpl.GraphMaker
Creates and preprocesses a graph for a replacement.
|
(package private) static class |
ReplacementsImpl.JavaSignature |
InlineInvokePlugin.InlineInfo
Modifier and Type | Field and Description |
---|---|
private Map<String,AtomicReference<ReplacementsImpl.ClassReplacements>> |
classReplacements
Per-class replacements.
|
private GraphBuilderConfiguration.Plugins |
graphBuilderPlugins |
protected ConcurrentMap<ResolvedJavaMethod,StructuredGraph> |
graphs
The preprocessed replacement graphs.
|
private Map<String,Class<?>[]> |
internalNameToSubstitutionClasses |
private static int |
MAX_GRAPH_INLINING_DEPTH |
Providers |
providers |
private static DebugTimer |
SnippetPreparationTime |
SnippetReflectionProvider |
snippetReflection |
private Map<String,SnippetTemplateCache> |
snippetTemplateCache |
TargetDescription |
target |
private static boolean |
UseSnippetGraphCache |
Constructor and Description |
---|
ReplacementsImpl(Providers providers,
SnippetReflectionProvider snippetReflection,
TargetDescription target) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getSubstitution, hasSubstitution
notifyAfterInline, notifyBeforeInline
public final SnippetReflectionProvider snippetReflection
public final TargetDescription target
private GraphBuilderConfiguration.Plugins graphBuilderPlugins
protected final ConcurrentMap<ResolvedJavaMethod,StructuredGraph> graphs
private static final int MAX_GRAPH_INLINING_DEPTH
private final Map<String,AtomicReference<ReplacementsImpl.ClassReplacements>> classReplacements
private final Map<String,Class<?>[]> internalNameToSubstitutionClasses
private final Map<String,SnippetTemplateCache> snippetTemplateCache
private static final boolean UseSnippetGraphCache
private static final DebugTimer SnippetPreparationTime
public ReplacementsImpl(Providers providers, SnippetReflectionProvider snippetReflection, TargetDescription target)
public void setGraphBuilderPlugins(GraphBuilderConfiguration.Plugins plugins)
public GraphBuilderConfiguration.Plugins getGraphBuilderPlugins()
protected boolean hasGenericInvocationPluginAnnotation(ResolvedJavaMethod method)
public InlineInvokePlugin.InlineInfo shouldInlineInvoke(GraphBuilderContext b, ResolvedJavaMethod method, ValueNode[] args, JavaType returnType)
shouldInlineInvoke
in interface InlineInvokePlugin
method
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)
notifyNotInlined
in interface InlineInvokePlugin
protected ReplacementsImpl.ClassReplacements getClassReplacements(String internalName)
internalName
the first time
this method is called for internalName
.public StructuredGraph getSnippet(ResolvedJavaMethod method, Object[] args)
getSnippet
in interface Replacements
public StructuredGraph getSnippet(ResolvedJavaMethod method, ResolvedJavaMethod recursiveEntry, Object[] args)
getSnippet
in interface Replacements
public void registerSnippet(ResolvedJavaMethod method)
registerSnippet
in interface Replacements
public StructuredGraph getSubstitution(ResolvedJavaMethod original, boolean fromBytecodeOnly, int invokeBci)
getSubstitution
in interface Replacements
private SubstitutionGuard getGuard(Class<? extends SubstitutionGuard> guardClass)
private static boolean checkSubstitutionInternalName(Class<?> substitutions, String internalName)
public void registerSubstitutions(Type original, Class<?> substitutionClass)
registerSubstitutions
in interface Replacements
protected ResolvedJavaMethod registerMethodSubstitution(ReplacementsImpl.ClassReplacements cr, Executable originalMember, Method substituteMethod)
originalMember
- a method or constructor being substitutedsubstituteMethod
- the substitute methodpublic StructuredGraph makeGraph(ResolvedJavaMethod method, Object[] args, ResolvedJavaMethod original)
method
- the snippet or method substitution for which a graph will be createdargs
- original
- the original method if method
is a substitution otherwise nullprotected ReplacementsImpl.GraphMaker createGraphMaker(ResolvedJavaMethod substitute, ResolvedJavaMethod original)
private static String originalName(Method substituteMethod, String methodSubstitution)
public static Class<?> resolveClass(String className, boolean optional)
className
- the name of the class to resolveoptional
- if true, resolution failure returns nulloptional
is trueprivate static Class<?> resolveClass(JavaType type)
public Collection<ResolvedJavaMethod> getAllReplacements()
getAllReplacements
in interface Replacements
public boolean hasSubstitution(ResolvedJavaMethod method, boolean fromBytecodeOnly, int callerBci)
hasSubstitution
in interface Replacements
public ResolvedJavaMethod getSubstitutionMethod(ResolvedJavaMethod original)
getSubstitutionMethod
in interface Replacements
public void registerSnippetTemplateCache(SnippetTemplateCache templates)
registerSnippetTemplateCache
in interface Replacements
public <T extends SnippetTemplateCache> T getSnippetTemplateCache(Class<T> templatesClass)
getSnippetTemplateCache
in interface Replacements