Class MaterializedLocalAccessor

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

public final class MaterializedLocalAccessor extends Object
Operation parameter that allows an operation to get, set, and clear the value of a local from a materialized frame of the current root node or an outer root node. This class can only be used if the root node supports materialized local accesses.

To use a materialized 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 MaterializedLocalAccessor for the local will be supplied as a parameter to the operation.

Materialized local accessors are useful to implement behaviour that cannot be implemented with the builtin materialized local operations (like StoreLocalMaterialized), nor with plain local accessors.

All of the materialized accessor methods take a bytecode node and the current frame. The bytecode node should be the current bytecode node (not necessarily corresponding to the root node that declares the local); it should be compilation-final. The frame should contain the local and be materialized.

Example usage:

@Operation
@ConstantOperand(type = MaterializedLocalAccessor.class)
public static final class GetMaterializedLocal {
    @Specialization
    public static Object perform(VirtualFrame frame,
                    MaterializedLocalAccessor accessor,
                    MaterializedFrame materializedFrame,
                    @Bind BytecodeNode bytecodeNode) {
        return accessor.getObject(bytecodeNode, materializedFrame);
    }
}
Since:
24.2