de.rwth.dfa.jvm.samples
Class CPAbstraction

java.lang.Object
  |
  +--de.rwth.dfa.jvm.samples.AbstractSSDependingAbstraction
        |
        +--de.rwth.dfa.jvm.samples.CPAbstraction
All Implemented Interfaces:
Abstraction
Direct Known Subclasses:
CFPAbstraction

public class CPAbstraction
extends AbstractSSDependingAbstraction
implements Abstraction

Implementation of a constant propagation abstraction. It can be used to determine constant values in both stack an local variables. The domain used is CFPLattice.

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

Inner Class Summary
protected  class CPAbstraction.AllocationFunction
          Pushes a CFPComponentLattice.NONNULLCOMPONENT onto the stack.
 class CPAbstraction.CPFunction
          The abstract base class of all function of this abstraction.
protected  class CPAbstraction.DupFunction
          Duplicates n elements on the stack under x other elements.
protected  class CPAbstraction.ExceptionHeaderFunction
          Creates a new stack with only a CFPComponentLattice.NONNULLCOMPONENT.
protected  class CPAbstraction.GenericFunction
          A generic function.
protected  class CPAbstraction.IncLocalFunction
          Increments the content of a local variable slot.
protected  class CPAbstraction.PopFunction
          Removes entries from the stack.
protected  class CPAbstraction.PushConstantFunction
          A function for pushing a constant onto the stack.
protected  class CPAbstraction.PushLocalFunction
          Pushes the content of a local variable slot onto the stack.
protected  class CPAbstraction.StoreLocalFunction
          Stores the top element in a local variable slot.
protected  class CPAbstraction.SwapFunction
          Swaps the top element and the element below that on the stack.
 
Inner classes inherited from class de.rwth.dfa.jvm.Abstraction
Abstraction.Default
 
Field Summary
protected  CFPLattice l
          The domain used in this abstraction.
protected  int maxLocals
          The maximal number of local variable slots in the method for this abstraction.
protected  int maxStack
          The maximal stack size in the method for this abstraction.
 
Fields inherited from class de.rwth.dfa.jvm.samples.AbstractSSDependingAbstraction
cpg, stacksizes
 
Fields inherited from interface de.rwth.dfa.jvm.Abstraction
DIRECTION_BACKWARD, DIRECTION_FORWARD, QUANTIFIER_ALL, QUANTIFIER_EXISTS
 
Constructor Summary
CPAbstraction(int maxStack, int maxLocals, de.fub.bytecode.generic.ConstantPoolGen constantPoolGen, de.fub.bytecode.generic.InstructionList methodInstrs, de.fub.bytecode.classfile.CodeException[] methodExceptions)
          Creates a new CFPAbstraction instance.
CPAbstraction(int maxStack, int maxLocals, de.fub.bytecode.classfile.ConstantPool constantPool, de.fub.bytecode.generic.InstructionList methodInstrs, de.fub.bytecode.classfile.CodeException[] methodExceptions)
          Creates a new CFPAbstraction instance.
 
Method Summary
 Function getAbstract(de.fub.bytecode.generic.InstructionHandle ih)
          Creates an instance of CPFunction for an instruction.
 Function getAbstract(InstructionHandleVector ihv)
          Returns the value of the default implementation in Abstraction.Default.
 int getDirection()
          Returns DIRECTION_FORWARD.
 java.lang.Object getInitialValue(de.fub.bytecode.generic.InstructionHandle ih, boolean isRoot)
          Returns the initial value for an instruction.
 java.lang.Object getInitialValue(InstructionHandleVector ihv, boolean isRoot)
          Returns the value of the default implementation in Abstraction.Default.
 Lattice getLattice()
          Returns the CFPLattice for this abstraction.
 int getQuantifier()
          Returns QUANTIFIER_ALL.
 
Methods inherited from class de.rwth.dfa.jvm.samples.AbstractSSDependingAbstraction
getConstantPoolGen, getStacksize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

l

protected CFPLattice l
The domain used in this abstraction.

maxLocals

protected int maxLocals
The maximal number of local variable slots in the method for this abstraction.

maxStack

protected int maxStack
The maximal stack size in the method for this abstraction.
Constructor Detail

CPAbstraction

public CPAbstraction(int maxStack,
                     int maxLocals,
                     de.fub.bytecode.generic.ConstantPoolGen constantPoolGen,
                     de.fub.bytecode.generic.InstructionList methodInstrs,
                     de.fub.bytecode.classfile.CodeException[] methodExceptions)
Creates a new CFPAbstraction instance.
Parameters:
maxStack - an int value
maxLocals - an int value
constantPool - a ConstantPool value
methodInstrs - an InstructionList value
methodExceptions - a CodeException[] value

CPAbstraction

public CPAbstraction(int maxStack,
                     int maxLocals,
                     de.fub.bytecode.classfile.ConstantPool constantPool,
                     de.fub.bytecode.generic.InstructionList methodInstrs,
                     de.fub.bytecode.classfile.CodeException[] methodExceptions)
Creates a new CFPAbstraction instance.
Parameters:
maxStack - an int value
maxLocals - an int value
constantPool - a ConstantPool value
methodInstrs - an InstructionList value
methodExceptions - a CodeException[] value
Method Detail

getLattice

public Lattice getLattice()
Returns the CFPLattice for this abstraction.
Specified by:
getLattice in interface Abstraction
Returns:
a Lattice value

getInitialValue

public java.lang.Object getInitialValue(de.fub.bytecode.generic.InstructionHandle ih,
                                        boolean isRoot)
Returns the initial value for an instruction.
  1. The component for the local variable slots consists of the entries
    CFPComponentLattice.NONCONSTANTCOMPONENT
    if the instruction is the entry point of the method or the entry point of an exception handler.
    CFPComponentLattice.UNKNOWNCOMPONENT
    for all other instructions.
  2. The stack component has the appropriate size.
  3. Each entry of the stack component is
    CFPComponentLattice.NONCONSTANTCOMPONENT
    if the instruction is the entry point of the method or the entry point of an exception handler.
    CFPComponentLattice.UNKNOWNCOMPONENT
    for all other instructions.
Specified by:
getInitialValue in interface Abstraction
Parameters:
ih - an InstructionHandle value
isRoot - a boolean value
Returns:
an Object value

getDirection

public int getDirection()
Returns DIRECTION_FORWARD.
Specified by:
getDirection in interface Abstraction
Returns:
an int value

getQuantifier

public int getQuantifier()
Returns QUANTIFIER_ALL.
Specified by:
getQuantifier in interface Abstraction
Returns:
an int value

getAbstract

public Function getAbstract(de.fub.bytecode.generic.InstructionHandle ih)
Creates an instance of CPFunction for an instruction.
Specified by:
getAbstract in interface Abstraction
Parameters:
ih - an InstructionHandle value
Returns:
a Function value

getInitialValue

public java.lang.Object getInitialValue(InstructionHandleVector ihv,
                                        boolean isRoot)
Returns the value of the default implementation in Abstraction.Default.
Specified by:
getInitialValue in interface Abstraction
Parameters:
ihv - an InstructionHandleVector value
isRoot - a boolean value
Returns:
an Object value

getAbstract

public Function getAbstract(InstructionHandleVector ihv)
Returns the value of the default implementation in Abstraction.Default.
Specified by:
getAbstract in interface Abstraction
Parameters:
ihv - an InstructionHandleVector value
Returns:
a Function value