Class SimObject


  • public final class SimObject
    extends Object
    Immutable abstract heap object for one allocation site, holding a set of possible values per field; every mutator returns a new instance.
    • Constructor Detail

      • SimObject

        public SimObject​(AllocationSite site)
        Creates an unescaped object with no fields written.
        Parameters:
        site - the allocation site it stands for
        Throws:
        NullPointerException - if the site is null
    • Method Detail

      • hasEscaped

        public boolean hasEscaped()
        Returns:
        whether escaped
      • getFieldKeys

        public Set<FieldKey> getFieldKeys()
        Returns:
        an unmodifiable view of the fields written so far
      • getField

        public Set<SimValue> getField​(FieldKey key)
        Parameters:
        key - the field to read
        Returns:
        an unmodifiable view of its values, empty if never written
      • hasField

        public boolean hasField​(FieldKey key)
        Parameters:
        key - the field to test
        Returns:
        true if the field has been written
      • withField

        public SimObject withField​(FieldKey key,
                                   SimValue value)
        Adds one value to a field's set - a weak update, keeping whatever is already there.
        Parameters:
        key - the field
        value - the value to add
        Returns:
        the updated copy
      • withFieldSet

        public SimObject withFieldSet​(FieldKey key,
                                      Set<SimValue> values)
        Adds several values to a field's set - a weak update, keeping whatever is already there.
        Parameters:
        key - the field
        values - the values to add; an empty set is a no-op
        Returns:
        the updated copy, or this object if nothing was added
      • markEscaped

        public SimObject markEscaped()
        Returns:
        a copy flagged as escaped, or this object if it already is
      • merge

        public SimObject merge​(SimObject other)
        Unions the field value sets of two views of the same allocation site, escaping the result if either side escaped.
        Parameters:
        other - the other view of this site
        Returns:
        the merged object
        Throws:
        IllegalArgumentException - if the allocation sites differ
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object