Package com.oracle.truffle.api.dsl
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
).
The generated code for the uncached version is based on the specialization closure. The
specialization closure only includes specializations that were are not replaced by others. This,
for example, automatically excludes inline caches from the closure. Uses of the Cached
annotation will automatically use getUncached instead of a cached
version to initialize the cache.
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 specializations of the closure must not use rewriteOn attribute.
- 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.
Example:
@GenerateUncached abstract static class UncachableNode extends Node { abstract Object execute(Object arg); @Specialization(guards = "v == cachedV") 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); }
- Since:
- 19.0
- See Also:
-
Optional Element Summary
Modifier 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
-