Annotation Interface GenerateUncached
Generates an uncached version of a node with specializations. Uncached versions of nodes don't
specialize and don't use any profiling state. This allows to store them statically and to use
them whenever no specialization/profiling is desired. The uncached version of the node is
accessible using a static method called
getUncached()
on the generated node.
GenerateUncached is inherited to subclasses if inherit()
is set to true
(default false
).
A node subclass must fullfill the following requirements in order to be uncachable:
- At least one specialization and one execute method must be specified.
- The node has no instance fields.
- All
Cached
parameters provide valid uncached initializers. - All guards/cache/limit expressions must not bind the node receiver.
NodeChild
or NodeField
annotations then they will return constant
null
or the primitive equivalent for the uncached node.
* By default every specialization is included for GenerateUncached
, except
specializations that require a limit
and are
replaced
, those are excluded by default. By setting
Specialization.excludeForUncached()
explicitly the default behavior can be overridden,
e.g. to include or exclude a specialization for uncached.
Example:
@GenerateUncached abstract static class UncachableNode extends Node { abstract Object execute(Object arg); @Specialization(guards = "v == cachedV", limit = "3") static Object doCached(int v, @Cached("v") int cachedV) { // do cached } @Specialization(replaces = "doCached") static String doGeneric(int v) { // do uncached } }This node produces the following uncached version of the execute method:
@Override Object execute(Object arg0Value) { if (arg0Value instanceof Integer) { int arg0Value_ = (int) arg0Value; return UncachableNode.doGeneric(arg0Value_); } throw new UnsupportedSpecializationException(this, new Node[]{null}, arg0Value); }Note that the
doCached
specialization is removed from the uncached version by
default. This behavior can be customized by setting Specialization.excludeForUncached()
.- Since:
- 19.0
- See Also:
-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionboolean
Inherits the semantics of the annotation to subclasses.boolean
Iftrue
enables the generation of an uncached version of thisspecializing
node.
-
Element Details
-
value
boolean valueIftrue
enables the generation of an uncached version of thisspecializing
node. It is disabled by default.- Since:
- 19.0
- Default:
true
-
inherit
boolean inheritInherits the semantics of the annotation to subclasses.- Since:
- 19.1.0
- Default:
false
-