Class LocalAccessor

java.lang.Object
com.oracle.truffle.api.bytecode.LocalAccessor

public final class LocalAccessor extends Object
Operation parameter that allows an operation to get, set, and clear the value of a local.

To use a local accessor, declare a ConstantOperand on the operation. The corresponding builder method for the operation will take a BytecodeLocal argument for the local to be accessed. At run time, a LocalAccessor for the local will be supplied as a parameter to the operation.

Local accessors are useful to implement behaviour that cannot be implemented with the builtin local operations (like StoreLocal). For example, if an operation produces multiple outputs, it can write one of the outputs to a local using a local accessor. Prefer builtin operations when possible, since they automatically work with boxing elimination. Local accessors should be preferred over BytecodeNode helpers like BytecodeNode.getLocalValue(int, Frame, int), since the helpers use extra indirection.

All of the accessor methods take a BytecodeNode and the current Frame. The bytecode node should be the node declaring the local, and it should be compilation-final. The local should belong to the Frame.

Example usage:

 @Operation
 @ConstantOperand(type = LocalAccessor.class)
 public static final class GetLocalAccessor {
     @Specialization
     public static Object perform(VirtualFrame frame, LocalAccessor accessor,
Since:
24.2