jasm.util.dfa
Class ForwardFlowAnalysis<T>

java.lang.Object
  extended by jasm.util.dfa.ForwardFlowAnalysis<T>
Direct Known Subclasses:
TypeAnalysis

public abstract class ForwardFlowAnalysis<T>
extends java.lang.Object

Represents a generic forward dataflow analysis. This user must implement the transfer functions for the different kinds of bytecode, and the analysis will propagate until a fixed point is reached.

Author:
David J. Pearce

Constructor Summary
ForwardFlowAnalysis()
           
 
Method Summary
 T[] apply(ClassFile.Method method)
           
abstract  T[] initialise(Code attribute, ClassFile.Method method)
          Generate an array of stores, one for each bytecode in the given method.
protected  void merge(int index, T store, java.util.HashSet<java.lang.Integer> worklist, T[] stores)
           
abstract  boolean merge(int index, T original, T udpate)
          Merge one abstract store into another to form a store at a join point in the control-flow graph.
protected  int select(java.util.HashSet<java.lang.Integer> worklist)
           
abstract  T transfer(int index, boolean branch, Bytecode.IfCmp code, T store)
          Generate an updated a abstract store by apply the abstract effect(s) of a given bytecode to an incoming store.
abstract  T transfer(int index, boolean branch, Bytecode.If code, T store)
          Generate an updated a abstract store by apply the abstract effect(s) of a given bytecode to an incoming store.
abstract  T transfer(int index, Bytecode.ArrayLength code, T store)
          Generate an updated a abstract store by apply the abstract effect(s) of a arraystore bytecode to an incoming store.
abstract  T transfer(int index, Bytecode.ArrayLoad code, T store)
          Generate an updated a abstract store by apply the abstract effect(s) of a arrayload bytecode to an incoming store.
abstract  T transfer(int index, Bytecode.ArrayStore code, T store)
          Generate an updated a abstract store by apply the abstract effect(s) of a arraystore bytecode to an incoming store.
abstract  T transfer(int index, Bytecode.BinOp code, T store)
          Generate an updated a abstract store by apply the abstract effect(s) of a binop bytecode to an incoming store.
abstract  T transfer(int index, Bytecode.CheckCast code, T store)
          Generate an updated a abstract store by apply the abstract effect(s) of a checkcast bytecode to an incoming store.
abstract  T transfer(int index, Bytecode.Cmp code, T store)
          Generate an updated a abstract store by apply the abstract effect(s) of a cmp bytecode to an incoming store.
abstract  T transfer(int index, Bytecode.Conversion code, T store)
          Generate an updated a abstract store by apply the abstract effect(s) of a convert bytecode to an incoming store.
abstract  T transfer(int index, Bytecode.Dup code, T store)
          Generate an updated a abstract store by apply the abstract effect(s) of a dup bytecode to an incoming store.
abstract  T transfer(int index, Bytecode.DupX1 code, T store)
          Generate an updated a abstract store by apply the abstract effect(s) of a dup_x1 bytecode to an incoming store.
abstract  T transfer(int index, Bytecode.DupX2 code, T store)
          Generate an updated a abstract store by apply the abstract effect(s) of a dup_x2 bytecode to an incoming store.
abstract  T transfer(int index, Bytecode.GetField code, T store)
          Generate an updated a abstract store by apply the abstract effect(s) of a getfield bytecode to an incoming store.
abstract  T transfer(int index, Bytecode.Iinc code, T store)
          Generate an updated a abstract store by apply the abstract effect(s) of an iinc bytecode to an incoming store.
abstract  T transfer(int index, Bytecode.InstanceOf code, T store)
          Generate an updated a abstract store by apply the abstract effect(s) of a instanceof bytecode to an incoming store.
abstract  T transfer(int index, Bytecode.Invoke code, T store)
          Generate an updated a abstract store by apply the abstract effect(s) of a invoke bytecode to an incoming store.
abstract  T transfer(int index, Bytecode.LoadConst code, T store)
          Generate an updated a abstract store by apply the abstract effect(s) of a loadconst bytecode to an incoming store.
abstract  T transfer(int index, Bytecode.Load code, T store)
          Generate an updated a abstract store by apply the abstract effect(s) of a load bytecode to an incoming store.
abstract  T transfer(int index, Bytecode.MonitorEnter code, T store)
          Generate an updated a abstract store by apply the abstract effect(s) of a monitorenter bytecode to an incoming store.
abstract  T transfer(int index, Bytecode.MonitorExit code, T store)
          Generate an updated a abstract store by apply the abstract effect(s) of a monitorexit bytecode to an incoming store.
abstract  T transfer(int index, Bytecode.Neg code, T store)
          Generate an updated a abstract store by apply the abstract effect(s) of a neg bytecode to an incoming store.
abstract  T transfer(int index, Bytecode.New code, T store)
          Generate an updated a abstract store by apply the abstract effect(s) of a new bytecode to an incoming store.
abstract  T transfer(int index, Bytecode.Nop code, T store)
          Generate an updated a abstract store by apply the abstract effect(s) of a nop bytecode to an incoming store.
abstract  T transfer(int index, Bytecode.Pop code, T store)
          Generate an updated a abstract store by apply the abstract effect(s) of a pop bytecode to an incoming store.
abstract  T transfer(int index, Bytecode.PutField code, T store)
          Generate an updated a abstract store by apply the abstract effect(s) of a arraystore bytecode to an incoming store.
abstract  void transfer(int index, Bytecode.Return code, T store)
          Generate an updated a abstract store by apply the abstract effect(s) of a return bytecode to an incoming store.
abstract  T transfer(int index, Bytecode.Store code, T store)
          Generate an updated a abstract store by apply the abstract effect(s) of a store bytecode to an incoming store.
abstract  T transfer(int index, Bytecode.Swap code, T store)
          Generate an updated a abstract store by apply the abstract effect(s) of a swap bytecode to an incoming store.
abstract  void transfer(int index, Bytecode.Throw code, T store)
          Generate an updated a abstract store by apply the abstract effect(s) of a throw bytecode to an incoming store.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ForwardFlowAnalysis

public ForwardFlowAnalysis()
Method Detail

apply

public T[] apply(ClassFile.Method method)
Parameters:
method -

select

protected int select(java.util.HashSet<java.lang.Integer> worklist)

merge

protected void merge(int index,
                     T store,
                     java.util.HashSet<java.lang.Integer> worklist,
                     T[] stores)

initialise

public abstract T[] initialise(Code attribute,
                               ClassFile.Method method)
Generate an array of stores, one for each bytecode in the given method. The initial store (i.e. at index zero) is the initial store for the method. initial store for the given method.

Parameters:
attribute - --- code attribute being analysed.
method - --- enclosing method.
Returns:

transfer

public abstract T transfer(int index,
                           Bytecode.Store code,
                           T store)
Generate an updated a abstract store by apply the abstract effect(s) of a store bytecode to an incoming store.

Parameters:
index - --- index in bytecode array of bytecode being analysed.
bytecode - --- bytecode to be analysed.
store - --- incoming abstract store.
Returns:

transfer

public abstract T transfer(int index,
                           Bytecode.Load code,
                           T store)
Generate an updated a abstract store by apply the abstract effect(s) of a load bytecode to an incoming store.

Parameters:
index - --- index in bytecode array of bytecode being analysed.
bytecode - --- bytecode to be analysed.
store - --- incoming abstract store.
Returns:

transfer

public abstract T transfer(int index,
                           Bytecode.LoadConst code,
                           T store)
Generate an updated a abstract store by apply the abstract effect(s) of a loadconst bytecode to an incoming store.

Parameters:
index - --- index in bytecode array of bytecode being analysed.
bytecode - --- bytecode to be analysed.
store - --- incoming abstract store.
Returns:

transfer

public abstract T transfer(int index,
                           Bytecode.ArrayLoad code,
                           T store)
Generate an updated a abstract store by apply the abstract effect(s) of a arrayload bytecode to an incoming store.

Parameters:
index - --- index in bytecode array of bytecode being analysed.
bytecode - --- bytecode to be analysed.
store - --- incoming abstract store.
Returns:

transfer

public abstract T transfer(int index,
                           Bytecode.ArrayStore code,
                           T store)
Generate an updated a abstract store by apply the abstract effect(s) of a arraystore bytecode to an incoming store.

Parameters:
index - --- index in bytecode array of bytecode being analysed.
bytecode - --- bytecode to be analysed.
store - --- incoming abstract store.
Returns:

transfer

public abstract T transfer(int index,
                           Bytecode.GetField code,
                           T store)
Generate an updated a abstract store by apply the abstract effect(s) of a getfield bytecode to an incoming store.

Parameters:
index - --- index in bytecode array of bytecode being analysed.
bytecode - --- bytecode to be analysed.
store - --- incoming abstract store.
Returns:

transfer

public abstract T transfer(int index,
                           Bytecode.PutField code,
                           T store)
Generate an updated a abstract store by apply the abstract effect(s) of a arraystore bytecode to an incoming store.

Parameters:
index - --- index in bytecode array of bytecode being analysed.
bytecode - --- bytecode to be analysed.
store - --- incoming abstract store.
Returns:

transfer

public abstract T transfer(int index,
                           Bytecode.ArrayLength code,
                           T store)
Generate an updated a abstract store by apply the abstract effect(s) of a arraystore bytecode to an incoming store.

Parameters:
index - --- index in bytecode array of bytecode being analysed.
bytecode - --- bytecode to be analysed.
store - --- incoming abstract store.
Returns:

transfer

public abstract T transfer(int index,
                           Bytecode.Invoke code,
                           T store)
Generate an updated a abstract store by apply the abstract effect(s) of a invoke bytecode to an incoming store.

Parameters:
index - --- index in bytecode array of bytecode being analysed.
bytecode - --- bytecode to be analysed.
store - --- incoming abstract store.
Returns:

transfer

public abstract void transfer(int index,
                              Bytecode.Throw code,
                              T store)
Generate an updated a abstract store by apply the abstract effect(s) of a throw bytecode to an incoming store.

Parameters:
index - --- index in bytecode array of bytecode being analysed.
bytecode - --- bytecode to be analysed.
store - --- incoming abstract store.

transfer

public abstract void transfer(int index,
                              Bytecode.Return code,
                              T store)
Generate an updated a abstract store by apply the abstract effect(s) of a return bytecode to an incoming store.

Parameters:
index - --- index in bytecode array of bytecode being analysed.
bytecode - --- bytecode to be analysed.
store - --- incoming abstract store.

transfer

public abstract T transfer(int index,
                           Bytecode.Iinc code,
                           T store)
Generate an updated a abstract store by apply the abstract effect(s) of an iinc bytecode to an incoming store.

Parameters:
index - --- index in bytecode array of bytecode being analysed.
bytecode - --- bytecode to be analysed.
store - --- incoming abstract store.
Returns:

transfer

public abstract T transfer(int index,
                           Bytecode.BinOp code,
                           T store)
Generate an updated a abstract store by apply the abstract effect(s) of a binop bytecode to an incoming store.

Parameters:
index - --- index in bytecode array of bytecode being analysed.
bytecode - --- bytecode to be analysed.
store - --- incoming abstract store.
Returns:

transfer

public abstract T transfer(int index,
                           Bytecode.Neg code,
                           T store)
Generate an updated a abstract store by apply the abstract effect(s) of a neg bytecode to an incoming store.

Parameters:
index - --- index in bytecode array of bytecode being analysed.
bytecode - --- bytecode to be analysed.
store - --- incoming abstract store.
Returns:

transfer

public abstract T transfer(int index,
                           Bytecode.New code,
                           T store)
Generate an updated a abstract store by apply the abstract effect(s) of a new bytecode to an incoming store.

Parameters:
index - --- index in bytecode array of bytecode being analysed.
bytecode - --- bytecode to be analysed.
store - --- incoming abstract store.
Returns:

transfer

public abstract T transfer(int index,
                           Bytecode.CheckCast code,
                           T store)
Generate an updated a abstract store by apply the abstract effect(s) of a checkcast bytecode to an incoming store.

Parameters:
index - --- index in bytecode array of bytecode being analysed.
bytecode - --- bytecode to be analysed.
store - --- incoming abstract store.
Returns:

transfer

public abstract T transfer(int index,
                           Bytecode.Conversion code,
                           T store)
Generate an updated a abstract store by apply the abstract effect(s) of a convert bytecode to an incoming store.

Parameters:
index - --- index in bytecode array of bytecode being analysed.
bytecode - --- bytecode to be analysed.
store - --- incoming abstract store.
Returns:

transfer

public abstract T transfer(int index,
                           Bytecode.InstanceOf code,
                           T store)
Generate an updated a abstract store by apply the abstract effect(s) of a instanceof bytecode to an incoming store.

Parameters:
index - --- index in bytecode array of bytecode being analysed.
bytecode - --- bytecode to be analysed.
store - --- incoming abstract store.
Returns:

transfer

public abstract T transfer(int index,
                           Bytecode.Pop code,
                           T store)
Generate an updated a abstract store by apply the abstract effect(s) of a pop bytecode to an incoming store.

Parameters:
index - --- index in bytecode array of bytecode being analysed.
bytecode - --- bytecode to be analysed.
store - --- incoming abstract store.
Returns:

transfer

public abstract T transfer(int index,
                           Bytecode.Dup code,
                           T store)
Generate an updated a abstract store by apply the abstract effect(s) of a dup bytecode to an incoming store.

Parameters:
index - --- index in bytecode array of bytecode being analysed.
bytecode - --- bytecode to be analysed.
store - --- incoming abstract store.
Returns:

transfer

public abstract T transfer(int index,
                           Bytecode.DupX1 code,
                           T store)
Generate an updated a abstract store by apply the abstract effect(s) of a dup_x1 bytecode to an incoming store.

Parameters:
index - --- index in bytecode array of bytecode being analysed.
bytecode - --- bytecode to be analysed.
store - --- incoming abstract store.
Returns:

transfer

public abstract T transfer(int index,
                           Bytecode.DupX2 code,
                           T store)
Generate an updated a abstract store by apply the abstract effect(s) of a dup_x2 bytecode to an incoming store.

Parameters:
index - --- index in bytecode array of bytecode being analysed.
bytecode - --- bytecode to be analysed.
store - --- incoming abstract store.
Returns:

transfer

public abstract T transfer(int index,
                           Bytecode.Swap code,
                           T store)
Generate an updated a abstract store by apply the abstract effect(s) of a swap bytecode to an incoming store.

Parameters:
index - --- index in bytecode array of bytecode being analysed.
bytecode - --- bytecode to be analysed.
store - --- incoming abstract store.
Returns:

transfer

public abstract T transfer(int index,
                           Bytecode.Cmp code,
                           T store)
Generate an updated a abstract store by apply the abstract effect(s) of a cmp bytecode to an incoming store.

Parameters:
index - --- index in bytecode array of bytecode being analysed.
bytecode - --- bytecode to be analysed.
store - --- incoming abstract store.
Returns:

transfer

public abstract T transfer(int index,
                           Bytecode.Nop code,
                           T store)
Generate an updated a abstract store by apply the abstract effect(s) of a nop bytecode to an incoming store.

Parameters:
index - --- index in bytecode array of bytecode being analysed.
bytecode - --- bytecode to be analysed.
store - --- incoming abstract store.
Returns:

transfer

public abstract T transfer(int index,
                           Bytecode.MonitorEnter code,
                           T store)
Generate an updated a abstract store by apply the abstract effect(s) of a monitorenter bytecode to an incoming store.

Parameters:
index - --- index in bytecode array of bytecode being analysed.
bytecode - --- bytecode to be analysed.
store - --- incoming abstract store.
Returns:

transfer

public abstract T transfer(int index,
                           Bytecode.MonitorExit code,
                           T store)
Generate an updated a abstract store by apply the abstract effect(s) of a monitorexit bytecode to an incoming store.

Parameters:
index - --- index in bytecode array of bytecode being analysed.
bytecode - --- bytecode to be analysed.
store - --- incoming abstract store.
Returns:

transfer

public abstract T transfer(int index,
                           boolean branch,
                           Bytecode.If code,
                           T store)
Generate an updated a abstract store by apply the abstract effect(s) of a given bytecode to an incoming store. In this case, the bytecode in question is branching, and we must consider which branch is being analysed (either the true branch, or the false branch).

Parameters:
index - --- index in bytecode array of bytecode being analysed.
branch - --- indicates the true or false branch is to be considered.
bytecode - --- to be analysed.
store - --- incoming abstract store.
Returns:

transfer

public abstract T transfer(int index,
                           boolean branch,
                           Bytecode.IfCmp code,
                           T store)
Generate an updated a abstract store by apply the abstract effect(s) of a given bytecode to an incoming store. In this case, the bytecode in question is branching, and we must consider which branch is being analysed (either the true branch, or the false branch).

Parameters:
index - --- index in bytecode array of bytecode being analysed.
branch - --- indicates the true or false branch is to be considered.
bytecode - --- to be analysed.
store - --- incoming abstract store.
Returns:

merge

public abstract boolean merge(int index,
                              T original,
                              T udpate)
Merge one abstract store into another to form a store at a join point in the control-flow graph.

Parameters:
original - --- original store to join "into". In the case of no change, this should be returned.
update - --- new store to join "into" the original store.
Returns:
--- true if the store was changed.


Copyright © 2013 David J. Pearce. All Rights Reserved.