org.jikesrvm.compilers.opt.ssa
Class IndexPropagation.ArrayCell

java.lang.Object
  extended by org.jikesrvm.compilers.opt.dfsolver.DF_AbstractCell
      extended by org.jikesrvm.compilers.opt.ssa.IndexPropagation.ArrayCell
All Implemented Interfaces:
DF_LatticeCell, GraphElement, GraphNode
Enclosing class:
IndexPropagation

static final class IndexPropagation.ArrayCell
extends DF_AbstractCell

An ArrayCell is a lattice cell for the index propagation problem, used in redundant load elimination for one-dimensional arrays.

An ArrayCell represents a set of value number pairs, indicating that the elements indexed by these value numbers are available for a certain array type.

For example, suppose p is an int[], with value number v(p). Then the value number pair for heap variable I[ means that p[5] is available.

Note: this implementation does not scale, and is not terribly efficient.


Field Summary
private static int CAPACITY
          a bound on the size of a lattice cell.
private  HeapVariable<?> key
          The heap variable this lattice cell tracks information for.
private  ValueNumberPair[] numbers
          a set of value number pairs comparising this lattice cell.
private  int size
          The number of value number pairs in this cell.
private  boolean TOP
          Does this lattice cell represent TOP?
 
Constructor Summary
IndexPropagation.ArrayCell(HeapVariable<?> key)
          Create a lattice cell corresponding to a heap variable.
 
Method Summary
(package private)  void add(int v1, int v2)
          Add a value number pair to this cell.
(package private)  void clear()
          Clear all value numbers from this cell.
(package private)  boolean contains(int v1, int v2)
          Does this cell contain the value number pair v1, v2?
(package private)  ValueNumberPair[] copyValueNumbers()
          Return a deep copy of the value numbers in this cell
(package private)  HeapVariable<?> getKey()
          Return the key
(package private)  boolean isBOTTOM()
          Does this cell represent the BOTTOM element in the dataflow lattice?
(package private)  boolean isTOP()
          Does this cell represent the TOP element in the dataflow lattice?
(package private)  void remove(int v1, int v2)
          Remove a value number pair from this cell.
(package private)  void setBOTTOM()
          Set the value of this cell to BOTTOM.
static boolean setsDiffer(ValueNumberPair[] set1, ValueNumberPair[] set2)
          Do two sets of value number pairs differ?
(package private)  void setTOP(boolean b)
          Mark this cell as representing (or not) the TOP element in the dataflow lattice.
 String toString()
          Return a string representation of this cell
 
Methods inherited from class org.jikesrvm.compilers.opt.dfsolver.DF_AbstractCell
addDef, addUse, getDefs, getIndex, getScratch, getUses, inNodes, outNodes, setIndex, setScratch
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

CAPACITY

private static final int CAPACITY
a bound on the size of a lattice cell.

See Also:
Constant Field Values

numbers

private ValueNumberPair[] numbers
a set of value number pairs comparising this lattice cell.


size

private int size
The number of value number pairs in this cell.


key

private final HeapVariable<?> key
The heap variable this lattice cell tracks information for.


TOP

private boolean TOP
Does this lattice cell represent TOP?

Constructor Detail

IndexPropagation.ArrayCell

IndexPropagation.ArrayCell(HeapVariable<?> key)
Create a lattice cell corresponding to a heap variable.

Parameters:
key - the heap variable associated with this cell.
Method Detail

getKey

HeapVariable<?> getKey()
Return the key


isTOP

boolean isTOP()
Does this cell represent the TOP element in the dataflow lattice?

Returns:
true or false.

isBOTTOM

boolean isBOTTOM()
Does this cell represent the BOTTOM element in the dataflow lattice?

Returns:
true or false.

setTOP

void setTOP(boolean b)
Mark this cell as representing (or not) the TOP element in the dataflow lattice.

Parameters:
b - should this cell contain TOP?

setBOTTOM

void setBOTTOM()
Set the value of this cell to BOTTOM.


contains

boolean contains(int v1,
                 int v2)
Does this cell contain the value number pair v1, v2?

Parameters:
v1 - first value number
v2 - second value number
Returns:
true or false

add

void add(int v1,
         int v2)
Add a value number pair to this cell.

Parameters:
v1 - first value number
v2 - second value number

remove

void remove(int v1,
            int v2)
Remove a value number pair from this cell.

Parameters:
v1 - first value number
v2 - second value number

clear

void clear()
Clear all value numbers from this cell.


copyValueNumbers

ValueNumberPair[] copyValueNumbers()
Return a deep copy of the value numbers in this cell

Returns:
a deep copy of the value numbers in this cell

toString

public String toString()
Return a string representation of this cell

Specified by:
toString in interface DF_LatticeCell
Specified by:
toString in class DF_AbstractCell
Returns:
a string representation of this cell

setsDiffer

public static boolean setsDiffer(ValueNumberPair[] set1,
                                 ValueNumberPair[] set2)
Do two sets of value number pairs differ?

SIDE EFFECT: sorts the sets

Parameters:
set1 - first set to compare
set2 - second set to compare
Returns:
true iff the two sets are different