SandMark version 2.1


sandmark.util.controlflowgraph
Class LiveVariable

java.lang.Object
  |
  +--sandmark.util.controlflowgraph.LiveVariable
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Comparable

public class LiveVariable
extends java.lang.Object
implements java.lang.Comparable, java.lang.Cloneable

LiveVariable encapsulates information about a variable in the local variable table.


Field Summary
 boolean immutable
          Denotes that changes to this live variable should not change the acutal code.
(package private)  boolean movable
           
(package private)  int myVarNum
           
 
Constructor Summary
(package private) LiveVariable(int varNum)
          Constructs a new live variable.
 
Method Summary
 void addDef(de.fub.bytecode.generic.InstructionHandle ih)
          Adds another definition (the instruction handle for the def instruction) to the definition list for this variable.
 void addInterference(LiveVariable other)
          Adds a fake interference between this variable and the parameter, so that calls to interferesWith will return true, regardless of the contents of their live ranges.
(package private)  void addRange(InterferenceGraph.RangeNode live)
          Adds another node to the live range for this variable.
 void addUse(de.fub.bytecode.generic.InstructionHandle ih)
          Adds another use (the instruction handle for the use instruction) to the use list for this variable.
 java.lang.Object clone()
           
 int compareTo(java.lang.Object o)
          Compares two live variables based on the order of definition (earlier defined variables first) the local variable number of parameters
 boolean equals(java.lang.Object o)
           
 java.util.Iterator getDefIterator()
          Returns an iterator of InstructionHandles for each definition of this variable.
 java.util.Iterator getUseIterator()
          Returns an iterator of InstructionHandles for each use of this variable.
 int getVarNum()
          Returns the current slot in the local variable table where this variable is assigned.
 boolean hasFakeInterference()
          Returns true if there is a fake edge added to this variable.
 boolean interferesWith(LiveVariable other)
          Returns true if the live ranges for these variables intersect, or if there is a fake interference added between these nodes (by the addInterference method).
 boolean isMovable()
          Checks to see if this variable can be moved from its current slot in the local variable table.
 boolean isSameAs(LiveVariable other)
          Returns true if these variables share any uses or defs.
(package private) static LiveVariable merge(LiveVariable v1, LiveVariable v2)
           
 boolean removeInterference(LiveVariable other)
          Removes a fake interference between this variable and the parameter, if it existed.
 void setMovable(boolean move)
          Sets whether or not this variable can be moved from its current slot in the local variable table.
 void setVarNum(int index)
          Changes the current slot in the local variable table where this variable is assigned and changes the bytecode where this variable is referenced.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

myVarNum

int myVarNum

immutable

public boolean immutable
Denotes that changes to this live variable should not change the acutal code.


movable

boolean movable
Constructor Detail

LiveVariable

LiveVariable(int varNum)
Constructs a new live variable. This method should only be used to for analysis.

Method Detail

clone

public java.lang.Object clone()
Overrides:
clone in class java.lang.Object

addRange

void addRange(InterferenceGraph.RangeNode live)
Adds another node to the live range for this variable. This method should only be used to for analysis.


addUse

public void addUse(de.fub.bytecode.generic.InstructionHandle ih)
Adds another use (the instruction handle for the use instruction) to the use list for this variable. This method should only be used to for analysis.


setMovable

public void setMovable(boolean move)
Sets whether or not this variable can be moved from its current slot in the local variable table.


isMovable

public boolean isMovable()
Checks to see if this variable can be moved from its current slot in the local variable table. A variable will not be movable if its definition is from a parameter, or if the programmer has called setMovable(false) on this variable.

Returns:
true if the variable can be moved, false if not

getUseIterator

public java.util.Iterator getUseIterator()
Returns an iterator of InstructionHandles for each use of this variable.


getDefIterator

public java.util.Iterator getDefIterator()
Returns an iterator of InstructionHandles for each definition of this variable.


isSameAs

public boolean isSameAs(LiveVariable other)
Returns true if these variables share any uses or defs. This method should only be used to for analysis, to remove duplicate variables.


compareTo

public int compareTo(java.lang.Object o)
Compares two live variables based on

Specified by:
compareTo in interface java.lang.Comparable

equals

public boolean equals(java.lang.Object o)
Overrides:
equals in class java.lang.Object

addDef

public void addDef(de.fub.bytecode.generic.InstructionHandle ih)
Adds another definition (the instruction handle for the def instruction) to the definition list for this variable. This method should only be used to for analysis.


getVarNum

public int getVarNum()
Returns the current slot in the local variable table where this variable is assigned.


setVarNum

public void setVarNum(int index)
Changes the current slot in the local variable table where this variable is assigned and changes the bytecode where this variable is referenced. This method does not verify if the new assignment interferes with other variables, use interferesWith to check that. This modifies the Instructions in the InstructionHandles in the MethodGen in the ControlFlowGraph passed to the constructor of InterferenceGraph. Do not forget to commit these changes to the ClassFileCollection you are working with.

Parameters:
index - the new local variable number

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

addInterference

public void addInterference(LiveVariable other)
Adds a fake interference between this variable and the parameter, so that calls to interferesWith will return true, regardless of the contents of their live ranges.

Parameters:
other - the variable that this variable should always appear to interfere with

removeInterference

public boolean removeInterference(LiveVariable other)
Removes a fake interference between this variable and the parameter, if it existed.

Returns:
false if there was no fake edge between the two variables, true if the removal succeeded

hasFakeInterference

public boolean hasFakeInterference()
Returns true if there is a fake edge added to this variable.


interferesWith

public boolean interferesWith(LiveVariable other)
Returns true if the live ranges for these variables intersect, or if there is a fake interference added between these nodes (by the addInterference method).


merge

static LiveVariable merge(LiveVariable v1,
                          LiveVariable v2)

SandMark version 2.1

Wed Jul 3 17:27:43 MST 2002