Class SimArray
- java.lang.Object
-
- com.tonic.analysis.simulation.heap.SimArray
-
public final class SimArray extends Object
Immutable abstract state of one allocated array, tracking elements both index-insensitively and per constant index.
-
-
Constructor Summary
Constructors Constructor Description SimArray(AllocationSite site, IRType elementType, SimValue length)Creates an empty, unescaped array state with no tracked elements.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object o)Set<SimValue>getAllElements()Set<SimValue>getElement(SimValue index)Reads through a symbolic index, using index-sensitive tracking only for a constant int.Set<SimValue>getElementAt(int index)Reads a known index, falling back to the index-insensitive set when nothing was tracked there.IRTypegetElementType()intgetKnownIndexCount()Set<Integer>getKnownIndices()SimValuegetLength()AllocationSitegetSite()booleanhasEscaped()inthashCode()SimArraymarkEscaped()SimArraymerge(SimArray other)Unions the element sets, the per-index sets and the escape flags of two states of the same allocation.StringtoString()SimArraywithElement(SimValue index, SimValue value)Records a store, tracking it index-sensitively only when the index is a constant int.SimArraywithElementAt(int index, SimValue value)Records a store at a known index, adding to both the index-sensitive and the index-insensitive element sets.
-
-
-
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 describeselementType- component type, may be null when unknownlength- symbolic length, may be null when unknown- Throws:
NullPointerException- if the site is null
-
-
Method Detail
-
getSite
public AllocationSite getSite()
- Returns:
- the site
-
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 nullvalue- 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 writtenvalue- 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
-
-