jist.runtime
Class RewriterFlow

java.lang.Object
  extended by jist.runtime.RewriterFlow

public final class RewriterFlow
extends java.lang.Object

Perform data flow analysis.

Since:
JIST1.0
Version:
$Id: RewriterFlow.java,v 1.22 2005/01/25 16:33:47 barr Exp $
Author:
Rimon Barr <barr+jist@cs.cornell.edu>

Nested Class Summary
static class RewriterFlow.FlowInfoMap
          An accessor class to conveniently query data flow information.
private static class RewriterFlow.WildcardReturnaddressType
          Utility class to replace BCEL's ReturnaddressType and ignore the return address when checking for type equality for stack merging purposes.
 
Field Summary
private  org.apache.bcel.verifier.structurals.ExecutionVisitor ev
          instruction execution visitor.
private  org.apache.bcel.verifier.structurals.ExceptionHandlers exInfo
          exception handler lookup.
private  java.util.HashMap frames
          frame information.
private  java.util.HashMap pointsTo
          pointsTo information.
private  java.util.Vector remaining
          remaining instructions to process.
 
Constructor Summary
RewriterFlow()
          Create new rewriter data flow analysis object.
 
Method Summary
 RewriterFlow.FlowInfoMap doFlow(org.apache.bcel.generic.ClassGen cg, org.apache.bcel.generic.MethodGen mg)
          Perform data flow analysis to determine the frame at each execution point in the method.
private  org.apache.bcel.generic.InstructionHandle[] execute(org.apache.bcel.generic.InstructionHandle ih, org.apache.bcel.verifier.structurals.Frame f)
          Helper flow analysis method: "executes" a given instruction to produce the next frame, and returns all successors of this instruction.
static void main(java.lang.String[] args)
          Small utility program to dump the methods of a given class file with flow information between every instruction.
private  boolean merge(org.apache.bcel.generic.InstructionHandle ih, org.apache.bcel.verifier.structurals.Frame f, org.apache.bcel.classfile.ConstantPool cp)
          Helper flow analysis method: merges two frames ala the VM spec, and stores result.
private  org.apache.bcel.verifier.structurals.OperandStack removeRetTargets(org.apache.bcel.verifier.structurals.OperandStack os)
          Replace any ReturnaddressTypes (placed on the stack by JSR) with WildcardReturnaddressTypes, so as to pass the verification performed during stack merge.
private  org.apache.bcel.verifier.structurals.OperandStack reverseStack(org.apache.bcel.verifier.structurals.OperandStack os)
          Reverse the operand stack.
private  void updatePointsTo(org.apache.bcel.generic.InstructionHandle from, org.apache.bcel.generic.InstructionHandle[] to)
          Update table of which instructions "point to" which.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

remaining

private java.util.Vector remaining
remaining instructions to process.


ev

private org.apache.bcel.verifier.structurals.ExecutionVisitor ev
instruction execution visitor.


exInfo

private org.apache.bcel.verifier.structurals.ExceptionHandlers exInfo
exception handler lookup.


frames

private java.util.HashMap frames
frame information.


pointsTo

private java.util.HashMap pointsTo
pointsTo information.

Constructor Detail

RewriterFlow

public RewriterFlow()
Create new rewriter data flow analysis object.

Method Detail

doFlow

public RewriterFlow.FlowInfoMap doFlow(org.apache.bcel.generic.ClassGen cg,
                                       org.apache.bcel.generic.MethodGen mg)
Perform data flow analysis to determine the frame at each execution point in the method.

Parameters:
cg - BCEL class object
mg - BCEL method object
Returns:
flow information

execute

private org.apache.bcel.generic.InstructionHandle[] execute(org.apache.bcel.generic.InstructionHandle ih,
                                                            org.apache.bcel.verifier.structurals.Frame f)
Helper flow analysis method: "executes" a given instruction to produce the next frame, and returns all successors of this instruction.

Parameters:
ih - handle of instruction to execute
f - pre-instruction state (is modified to post-instruction state)
Returns:
list of instruction successors

merge

private boolean merge(org.apache.bcel.generic.InstructionHandle ih,
                      org.apache.bcel.verifier.structurals.Frame f,
                      org.apache.bcel.classfile.ConstantPool cp)
Helper flow analysis method: merges two frames ala the VM spec, and stores result.

Parameters:
ih - location to merge information into
f - frame to merge in
cp - class constant pool
Returns:
whether merging actually changed anything

removeRetTargets

private org.apache.bcel.verifier.structurals.OperandStack removeRetTargets(org.apache.bcel.verifier.structurals.OperandStack os)
Replace any ReturnaddressTypes (placed on the stack by JSR) with WildcardReturnaddressTypes, so as to pass the verification performed during stack merge.

Parameters:
os - input operand stack, not modified
Returns:
modified operand stack

reverseStack

private org.apache.bcel.verifier.structurals.OperandStack reverseStack(org.apache.bcel.verifier.structurals.OperandStack os)
Reverse the operand stack.

Parameters:
os - input operand stack, not modified
Returns:
reversed operand stack

updatePointsTo

private void updatePointsTo(org.apache.bcel.generic.InstructionHandle from,
                            org.apache.bcel.generic.InstructionHandle[] to)
Update table of which instructions "point to" which.

Parameters:
from - predecessor instruction
to - list of successor instructions

main

public static void main(java.lang.String[] args)
Small utility program to dump the methods of a given class file with flow information between every instruction.

Parameters:
args - list of filenames to process