de.rwth.dfa.jvm
Class Solver

java.lang.Object
  |
  +--de.rwth.dfa.jvm.Solver
Direct Known Subclasses:
ExecutionSolver, GraphSolver

public abstract class Solver
extends java.lang.Object

An abstract class for a JVM abstraction solver. It contains the basic data structures describing the JVM abstraction and the method to be analyzed. Furthermore, it provides the general framework for runtime and memory statistics. To get a working implementation, the method compute() must be provided. Implementations should guarantee that all computation is done there and not in constructors!. Otherwise, the statistics will be wrong.

Version:
$Id: Solver.java,v 1.2 2002/09/17 06:53:53 mohnen Exp $
Author:
Markus Mohnen

Field Summary
protected  Abstraction abstraction
          The JVM abstraction of this solver.
protected  long iterations
          The number of iterations used by the computation.
protected  long memory
          The approximation of the amount of memory used by the solution.
protected  de.fub.bytecode.classfile.CodeException[] methodExceptions
          The code exception array of the method to be analyses.
protected  de.fub.bytecode.generic.InstructionList methodInstrs
          The instruction list of the method to be analyses.
protected  java.lang.String methodName
          The name of the method to be analyses.
protected  Stopwatch stopwatch
          The stop watch to be used for timing the computation.
 
Constructor Summary
Solver(Abstraction abstraction, java.lang.String methodName, de.fub.bytecode.generic.InstructionList methodInstrs, de.fub.bytecode.classfile.CodeException[] methodExceptions)
          Creates a new Solver instance without stop watch.
Solver(Abstraction abstraction, java.lang.String methodName, de.fub.bytecode.generic.InstructionList methodInstrs, de.fub.bytecode.classfile.CodeException[] methodExceptions, Stopwatch stopwatch)
          Creates a new Solver instance with stop watch.
 
Method Summary
protected abstract  void compute(java.lang.Object[] solution, boolean isForward, boolean isAll)
          Implementations must provide this method.
 long getIterations()
          Returns the number of iterations during the computation.
 long getMemory()
          Returns an approximation of the amount of memory used during the computation.
 java.lang.Object[] getSolution()
          Computes the solution by calling compute() and does memory and timing statistics.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

abstraction

protected Abstraction abstraction
The JVM abstraction of this solver.

methodName

protected java.lang.String methodName
The name of the method to be analyses.

methodInstrs

protected de.fub.bytecode.generic.InstructionList methodInstrs
The instruction list of the method to be analyses.

methodExceptions

protected de.fub.bytecode.classfile.CodeException[] methodExceptions
The code exception array of the method to be analyses.

stopwatch

protected Stopwatch stopwatch
The stop watch to be used for timing the computation. This may be null if there is no stop watch to be used.

iterations

protected long iterations
The number of iterations used by the computation.

memory

protected long memory
The approximation of the amount of memory used by the solution.
Constructor Detail

Solver

public Solver(Abstraction abstraction,
              java.lang.String methodName,
              de.fub.bytecode.generic.InstructionList methodInstrs,
              de.fub.bytecode.classfile.CodeException[] methodExceptions,
              Stopwatch stopwatch)
Creates a new Solver instance with stop watch.
Parameters:
abstraction - an Abstraction value
methodName - a String value
methodInstrs - an InstructionList value
methodExceptions - a CodeException[] value
stopwatch - a Stopwatch value

Solver

public Solver(Abstraction abstraction,
              java.lang.String methodName,
              de.fub.bytecode.generic.InstructionList methodInstrs,
              de.fub.bytecode.classfile.CodeException[] methodExceptions)
Creates a new Solver instance without stop watch.
Parameters:
abstraction - an Abstraction value
methodName - a String value
methodInstrs - an InstructionList value
methodExceptions - a CodeException[] value
Method Detail

compute

protected abstract void compute(java.lang.Object[] solution,
                                boolean isForward,
                                boolean isAll)
Implementations must provide this method. Given the JVM abstraction and the method in this classes data structures, the method must compute a correct solution, i.e. an approximation of the meet over paths solution (for isAll==true). This method is called from getSolution().
  1. Implementations must set the variable iterations to a sensible value.
  2. If there is a stop watch, it is already running. Implementations of this method may use the split() method as often as they wish. They may not call start() or stop().
  3. An approximation of the memory usage is done by getSolution(). Hence, setting memory in this method has no effect.
Parameters:
solution - an Object[] value: A newly created array for the solution. It has one entry for each instruction.
isForward - a boolean value: Analysis control flow
isAll - a boolean value: Use meet or join

getSolution

public java.lang.Object[] getSolution()
Computes the solution by calling compute() and does memory and timing statistics.
Returns:
an Object[] value

getIterations

public long getIterations()
Returns the number of iterations during the computation.
Returns:
a long value

getMemory

public long getMemory()
Returns an approximation of the amount of memory used during the computation.
Returns:
a long value