Annotation Interface Bind


@Retention(CLASS) @Target(PARAMETER) public @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;
     }
 }
 
Since:
20.2
See Also:
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    The extract expression.
  • Element Details

    • value

      String value
      The extract expression.
      Since:
      20.2
      See Also: