public class InvocationPlugins extends Object
InvocationPlugins.
Most plugins are registered during initialization (i.e., before InvocationPlugins.lookupInvocation(ResolvedJavaMethod, boolean, org.graalvm.compiler.options.OptionValues) or
InvocationPlugins.getInvocationPlugins(boolean) is called). These registrations can be made with
InvocationPlugins.Registration, InvocationPlugins.register(Type, InvocationPlugin) . Initialization is not
thread-safe and so must only be performed by a single thread.
Plugins that are not guaranteed to be made during initialization must use
InvocationPlugins.LateRegistration.| Modifier and Type | Class and Description |
|---|---|
static class |
InvocationPlugins.InvocationPluginReceiver |
static class |
InvocationPlugins.LateRegistration
Utility for registering plugins after Graal may have been initialized.
|
static class |
InvocationPlugins.Options |
static class |
InvocationPlugins.Registration
Utility for registration of invocation plugins.
|
static class |
InvocationPlugins.ResolvedJavaSymbol
A symbol for an already resolved method.
|
| Modifier and Type | Field and Description |
|---|---|
protected InvocationPlugins |
parent
The plugins searched before searching in this object.
|
| Constructor and Description |
|---|
InvocationPlugins()
Creates a set of invocation plugins with no parent.
|
InvocationPlugins(Map<ResolvedJavaMethod,InvocationPlugin> resolvedPlugins,
InvocationPlugins parent)
Creates a set of invocation plugins.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addTestPlugins(InvocationPlugins other,
List<org.graalvm.collections.Pair<String,InvocationPlugin>> ignored)
Extends the plugins in this object with those from
other. |
boolean |
canBeIntrinsified(ResolvedJavaType declaringClass)
Determines if methods in a given class can have invocation plugins.
|
void |
checkNewNodes(GraphBuilderContext b,
InvocationPlugin plugin,
NodeIterable<Node> newNodes)
Checks a set of nodes added to the graph by an
InvocationPlugin. |
void |
closeRegistration()
Processes deferred registrations and then closes this object for future registration.
|
void |
defer(Runnable deferrable)
Adds a
Runnable for doing registration deferred until the first time
InvocationPlugins.get(ResolvedJavaMethod) or InvocationPlugins.closeRegistration() is called on this object. |
void |
flushDeferrables() |
org.graalvm.collections.EconomicMap<String,List<InvocationPlugin>> |
getInvocationPlugins(boolean includeParents)
Gets the set of registered invocation plugins.
|
InvocationPlugins |
getParent()
Gets the invocation plugins searched before searching in this
object.
|
boolean |
isEmpty()
Determines if this object currently contains any plugins (in any state of registration).
|
InvocationPlugin |
lookupInvocation(ResolvedJavaMethod method,
boolean allowDecorators,
OptionValues options)
Gets the plugin for a given method.
|
InvocationPlugin |
lookupInvocation(ResolvedJavaMethod method,
OptionValues options)
Gets the plugin for a given method.
|
void |
notifyNoPlugin(ResolvedJavaMethod targetMethod,
OptionValues options)
Called when no invocation plugin can be found for the given target method.
|
void |
register(Type declaringClass,
InvocationPlugin plugin)
Registers an invocation plugin for a given method.
|
protected void |
register(Type declaringClass,
InvocationPlugin plugin,
boolean allowOverwrite) |
void |
registerIntrinsificationPredicate(Predicate<ResolvedJavaType> predicate)
Subclasses can choose to only allow intrinsification of types matched by at least one
registered predicate.
|
void |
removeTestPlugins(InvocationPlugins other)
Removes the plugins from
other in this object that were added by
InvocationPlugins.addTestPlugins(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins, java.util.List<org.graalvm.collections.Pair<java.lang.String, org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin>>). |
static Class<?> |
resolveClass(String className,
boolean optional)
Resolves a name to a class.
|
static Constructor<?> |
resolveConstructor(Class<?> declaringClass,
InvocationPlugin plugin)
Resolves a given invocation plugin to a constructor in a given class.
|
static ResolvedJavaMethod |
resolveJavaMethod(ResolvedJavaType declaringClass,
InvocationPlugin plugin)
Same as
InvocationPlugins.resolveMethod(Class, InvocationPlugin) and
InvocationPlugins.resolveConstructor(Class, InvocationPlugin) except in terms of
ResolvedJavaType and ResolvedJavaMethod. |
static Method |
resolveMethod(Class<?> declaringClass,
InvocationPlugin plugin)
Resolves a given invocation plugin to a method in a given class.
|
static Class<?> |
resolveType(Type type,
boolean optional)
|
String |
toString() |
protected final InvocationPlugins parent
public InvocationPlugins()
public InvocationPlugins(Map<ResolvedJavaMethod,InvocationPlugin> resolvedPlugins, InvocationPlugins parent)
resolvedPlugins - if non-null, this object will contain the closed set of invocation
plugins for a set of resolved methods, and no further plugin registration is
permitted.parent - if non-null, this object will be searched first when looking up pluginspublic void defer(Runnable deferrable)
Runnable for doing registration deferred until the first time
InvocationPlugins.get(ResolvedJavaMethod) or InvocationPlugins.closeRegistration() is called on this object.public boolean canBeIntrinsified(ResolvedJavaType declaringClass)
declaringClass - the class to testpublic void registerIntrinsificationPredicate(Predicate<ResolvedJavaType> predicate)
predicate - controls which types may be intrinsified.public void flushDeferrables()
public void addTestPlugins(InvocationPlugins other, List<org.graalvm.collections.Pair<String,InvocationPlugin>> ignored)
other. The added plugins should be
removed after the test.
This extension mechanism exists only for tests that want to add extra invocation plugins
after the compiler has been initialized.ignored - if non-null, the invocation plugins from other already in this object
prior to calling this method are added to this list. These plugins are not added
to this object.public void removeTestPlugins(InvocationPlugins other)
other in this object that were added by
InvocationPlugins.addTestPlugins(org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugins, java.util.List<org.graalvm.collections.Pair<java.lang.String, org.graalvm.compiler.nodes.graphbuilderconf.InvocationPlugin>>).public void closeRegistration()
public boolean isEmpty()
deferred registrations, it is assumed that
executing them will result in at least one plugin being registered.protected void register(Type declaringClass, InvocationPlugin plugin, boolean allowOverwrite)
public final void register(Type declaringClass, InvocationPlugin plugin)
method.public InvocationPlugin lookupInvocation(ResolvedJavaMethod method, boolean allowDecorators, OptionValues options)
method - the method to lookupallowDecorators - return InvocationPlugin.isDecorator() plugins only if truemethod or null if none existspublic InvocationPlugin lookupInvocation(ResolvedJavaMethod method, OptionValues options)
InvocationPlugin.isDecorator()} plugins since they can only be applied in certain
contexts.method - the method to lookupmethod or null if none existspublic org.graalvm.collections.EconomicMap<String,List<InvocationPlugin>> getInvocationPlugins(boolean includeParents)
public InvocationPlugins getParent()
public void checkNewNodes(GraphBuilderContext b, InvocationPlugin plugin, NodeIterable<Node> newNodes)
InvocationPlugin.b - the graph builder that applied the pluginplugin - a plugin that was just appliednewNodes - the nodes added to the graph by pluginAssertionError - if any check failpublic static Class<?> resolveClass(String className, boolean optional)
className - the name of the class to resolveoptional - if true, resolution failure returns nulloptional is truepublic static Class<?> resolveType(Type type, boolean optional)
type - the type to resolveoptional - if true, resolution failure returns nulloptional is truepublic static Method resolveMethod(Class<?> declaringClass, InvocationPlugin plugin)
plugin is found and the return types of all the matching
methods form an inheritance chain, the one with the most specific type is returned; otherwise
NoSuchMethodError is thrown.declaringClass - the class to search for a method matching plugindeclaringClass matching pluginpublic static ResolvedJavaMethod resolveJavaMethod(ResolvedJavaType declaringClass,
InvocationPlugin plugin)
InvocationPlugins.resolveMethod(Class, InvocationPlugin) and
InvocationPlugins.resolveConstructor(Class, InvocationPlugin) except in terms of
ResolvedJavaType and ResolvedJavaMethod.public static Constructor<?> resolveConstructor(Class<?> declaringClass, InvocationPlugin plugin)
declaringClass - the class to search for a constructor matching plugindeclaringClass matching pluginpublic void notifyNoPlugin(ResolvedJavaMethod targetMethod,
OptionValues options)