Class SimArray


  • public final class SimArray
    extends Object
    Immutable abstract state of one allocated array, tracking elements both index-insensitively and per constant index.
    • Constructor Detail

      • SimArray

        public SimArray​(AllocationSite site,
                        IRType elementType,
                        SimValue length)
        Creates an empty, unescaped array state with no tracked elements.
        Parameters:
        site - allocation this state describes
        elementType - component type, may be null when unknown
        length - symbolic length, may be null when unknown
        Throws:
        NullPointerException - if the site is null
    • Method Detail

      • getElementType

        public IRType getElementType()
        Returns:
        the element type
      • getLength

        public SimValue getLength()
        Returns:
        the length
      • hasEscaped

        public boolean hasEscaped()
        Returns:
        whether escaped
      • getAllElements

        public Set<SimValue> getAllElements()
        Returns:
        an unmodifiable view of every value stored at any index
      • getElement

        public Set<SimValue> getElement​(SimValue index)
        Reads through a symbolic index, using index-sensitive tracking only for a constant int.
        Parameters:
        index - index value, possibly non-constant or null
        Returns:
        an unmodifiable set of the values that read may produce
      • getElementAt

        public Set<SimValue> getElementAt​(int index)
        Reads a known index, falling back to the index-insensitive set when nothing was tracked there.
        Parameters:
        index - array index to read
        Returns:
        an unmodifiable set of the values that index may hold
      • withElement

        public SimArray withElement​(SimValue index,
                                    SimValue value)
        Records a store, tracking it index-sensitively only when the index is a constant int.
        Parameters:
        index - index value, possibly non-constant or null
        value - value stored
        Returns:
        a copy with the store applied
      • withElementAt

        public SimArray withElementAt​(int index,
                                      SimValue value)
        Records a store at a known index, adding to both the index-sensitive and the index-insensitive element sets.
        Parameters:
        index - array index written
        value - value stored
        Returns:
        a copy with the store applied
      • markEscaped

        public SimArray markEscaped()
        Returns:
        a copy flagged as escaped, or this array if it already was
      • merge

        public SimArray merge​(SimArray other)
        Unions the element sets, the per-index sets and the escape flags of two states of the same allocation.
        Parameters:
        other - array state to merge in
        Returns:
        the merged array
        Throws:
        IllegalArgumentException - if the two have different allocation sites
      • getKnownIndexCount

        public int getKnownIndexCount()
        Returns:
        how many constant indices are tracked separately
      • getKnownIndices

        public Set<Integer> getKnownIndices()
        Returns:
        an unmodifiable view of the constant indices that have their own value set
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object