Class FrameDescriptor

java.lang.Object
com.oracle.truffle.api.frame.FrameDescriptor
All Implemented Interfaces:
Cloneable

public final class FrameDescriptor extends Object implements Cloneable
Descriptor of the slots of frame objects. Multiple frame instances are associated with one such descriptor. The FrameDescriptor is thread-safe.
Since:
0.8 or earlier
  • Constructor Details

    • FrameDescriptor

      public FrameDescriptor()
      Constructs empty descriptor. The getDefaultValue() is null.
      Since:
      0.8 or earlier
    • FrameDescriptor

      public FrameDescriptor(Object defaultValue)
      Constructs new descriptor with specified getDefaultValue().
      Parameters:
      defaultValue - to be returned from getDefaultValue()
      Since:
      0.8 or earlier
  • Method Details

    • copy

      public FrameDescriptor copy()
      Deeper copy of the descriptor. Copies all slots in the descriptor, but only their identifier and info but not their kind!
      Returns:
      new instance of a descriptor with copies of values from this one
      Since:
      0.8 or earlier
    • getDefaultValue

      public Object getDefaultValue()
      Default value for the created slots.
      Returns:
      value provided to FrameDescriptor(java.lang.Object)
      Since:
      0.8 or earlier
    • toString

      public String toString()
      Overrides:
      toString in class Object
      Since:
      0.8 or earlier
    • getNumberOfSlots

      public int getNumberOfSlots()
      Returns:
      the number of indexed slots in this frame descriptor
      Since:
      22.0
    • getSlotKind

      public FrameSlotKind getSlotKind(int slot)
      Returns the FrameSlotKind associated with the given indexed slot.
      Parameters:
      slot - index of the slot
      Returns:
      a non-null FrameSlotKind
      Since:
      22.0
    • setSlotKind

      public void setSlotKind(int slot, FrameSlotKind kind)
      Sets the FrameSlotKind of the given indexed slot.
      Parameters:
      slot - index of the slot
      kind - new non-null FrameSlotKind
      Since:
      22.0
    • getSlotName

      public Object getSlotName(int slot)
      Queries the name for a given indexed slot.
      Parameters:
      slot - index of the slot
      Returns:
      the name of the slot (may be null)
      Since:
      22.0
    • getSlotInfo

      public Object getSlotInfo(int slot)
      Queries the info object for a given indexed slot.
      Parameters:
      slot - index of the slot
      Returns:
      the info object of the slot (may be null)
      Since:
      22.0
    • findOrAddAuxiliarySlot

      public int findOrAddAuxiliarySlot(Object key)
      Find or adds an auxiliary slot to this frame descriptor. Returns an integer index that can be used to access the auxiliary slot in the frame.
      Parameters:
      key - used as a hash map entry
      Returns:
      an integer that can be used to access the auxiliary slot in the frame
      Since:
      22.0
    • disableAuxiliarySlot

      public void disableAuxiliarySlot(Object key)
      Disables the auxiliary slot with the given key, so that subsequently created Frame instances may avoid allocating storage for it. Depending on the internal storage layout, it may not be possible to remove the storage for individual slots, so it is important to disable _all_ unused slots.
      Parameters:
      key - the key, as passed to findOrAddAuxiliarySlot(Object)
      Since:
      22.0
    • getAuxiliarySlots

      public Map<Object,Integer> getAuxiliarySlots()
      Returns all currently active auxiliary slots along with their indexes. This is a slow operation that returns a data structure that is not backed by the frame descriptor, i.e., which does not reflect changes to the set of active auxiliary slots in either direction.
      Since:
      22.0
    • getNumberOfAuxiliarySlots

      public int getNumberOfAuxiliarySlots()
      Returns:
      the current number of auxiliary slots in this frame descriptor
      Since:
      22.0
    • getInfo

      public Object getInfo()
      Returns:
      the user-defined info object associated with this frame descriptor
      Since:
      22.1
    • newBuilder

      public static FrameDescriptor.Builder newBuilder()
      Builds a new frame descriptor with index-based frame slots.
      Since:
      22.0
    • newBuilder

      public static FrameDescriptor.Builder newBuilder(int capacity)
      Builds a new frame descriptor with index-based frame slots.
      Parameters:
      capacity - the expected number of index-based frame slots (taken as a hint when allocating internal data structures)
      Since:
      22.0