Annotation Interface Bind
Binds and executes an expression at most once for every execution of the node. This is useful if
an expression cannot be repeated safely for a guard and its associated specialization method. For
example, if a read of a field is volatile two consecutive reads might not lead to the same
result. The name the extract parameter can be referred to in
cached,
guard, limit,
assumption expressions or the specialization body. The bind
expression may refer to dynamic parameters, previously declared bind or cached parameters and
node field declarations.
If a bind parameter only uses cached values, then it is considered also a cached value. If the parameter uses any dynamic parameter then the extract parameter is considered also a dynamic parameter.
Usage examples:
static class DynamicObject {
volatile Object storage;
DynamicObject(Object storage) {
this.storage = storage;
}
}
abstract static class ExtractStorageNode extends Node {
abstract Object execute(Object arg0);
@Specialization(guards = "storage == cachedStorage", limit = "3")
Object s0(DynamicObject a0,
@Bind("a0.storage") Object storage,
@Cached("storage") Object cachedStorage) {
// use storage in specialization and in guard.
return a0;
}
}
The special variable $node can be used to bind the current node. Bytecode DSL
interpreters can also bind the special variables $rootNode, $bytecodeNode, and
$bytecodeIndex.- Since:
- 20.2
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic @interfaceDefines a default bind expression for a given type. -
Optional Element Summary
Optional Elements
-
Element Details
-
value
-