harpoon.Analysis
Class BasicBlock<HCE extends HCodeElement>

java.lang.Object
  extended by harpoon.Analysis.BasicBlock<HCE>
All Implemented Interfaces:
BasicBlockInterf<HCE,BasicBlock<HCE>>, Serializable

public class BasicBlock<HCE extends HCodeElement>
extends Object
implements BasicBlockInterf<HCE,BasicBlock<HCE>>, Serializable

BasicBlock collects a sequence of operations. It is designed to abstract away specific operation and allow the compiler to focus on control flow at a higher level. (It also allows for some analysis within the block to operate more efficiently by taking advantage of the fact that the elements of a BasicBlock have a total ordering of execution).

Most BasicBlocks are a part of a larger piece of code, and thus a collection of BasicBlocks form a Control Flow Graph (where the nodes of the graph are the blocks and the directed edges of the graph indicate when one block is succeeded by another block).

Make sure to look at BasicBlock.Factory, since it acts as the central core for creating and keeping track of the BasicBlocks for a given HCode.

NOTE: right now BasicBlock only guarantees that it preserves the Maximal Basic Block property (where each block is the longest sequence of instructions such that only the first instruction may have more than one entry and only the last instruction may have more than one exit) if the graph of operations is not modified while the basic block is in use. For that matter, some methods of BasicBlock may implicitly rely on the intermediate representation not changing while the blocks are in use. However, most but not all Intermediate Representations in the Flex Compiler are immutable. Therefore compilation passes modifying the intermediate representation must reconstruct the BasicBlocks for that intermediate representation if they wish to perform a second analysis pass.

Version:
$Id: BasicBlock.java,v 1.8 2004/02/08 01:49:03 cananian Exp $
Author:
John Whaley <jwhaley@alum.mit.edu>, Felix S. Klock II <pnkfelix@mit.edu>
See Also:
Serialized Form

Nested Class Summary
static class BasicBlock.Factory<HCE extends HCodeElement>
          Factory structure for generating BasicBlock views of an HCode.
 
Constructor Summary
protected BasicBlock(HCE h, BasicBlock.Factory f)
          Constructs a new BasicBlock with h as its first element.
 
Method Summary
 void accept(BasicBlockInterfVisitor v)
          Accept a visitor.
 String dumpElems()
          Returns a String composed of the statements comprising this.
 HCE getFirst()
          Deprecated. Use the standard List view provided by statements() instead
 HCE getLast()
          Deprecated. Use the standard List view provided by statements() instead
 Enumeration<BasicBlock<HCE>> next()
          Deprecated. Use nextSet() instead
 int nextLength()
          Deprecated. Use nextSet() instead
 Set<BasicBlock<HCE>> nextSet()
          Returns all the successors of this.
 Enumeration<BasicBlock<HCE>> prev()
          Deprecated. Use prevSet() instead
 int prevLength()
          Deprecated. Use prevSet() instead
 Set<BasicBlock<HCE>> prevSet()
          Returns all the predecessors of this.
 List<HCE> statements()
          Returns an unmodifiable List for the HCodeElements within this.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

BasicBlock

protected BasicBlock(HCE h,
                     BasicBlock.Factory f)
Constructs a new BasicBlock with h as its first element. Meant to be used only during construction.

Method Detail

getFirst

public HCE getFirst()
Deprecated. Use the standard List view provided by statements() instead

Returns the first HCodeElement in the sequence.

Specified by:
getFirst in interface BasicBlockInterf<HCE extends HCodeElement,BasicBlock<HCE extends HCodeElement>>
See Also:
statements()

getLast

public HCE getLast()
Deprecated. Use the standard List view provided by statements() instead

Returns the last HCodeElement in the sequence.

Specified by:
getLast in interface BasicBlockInterf<HCE extends HCodeElement,BasicBlock<HCE extends HCodeElement>>
See Also:
statements()

prevLength

public int prevLength()
Deprecated. Use prevSet() instead

Returns the number of basic blocks in the predecessor set for this.

See Also:
prevSet()

nextLength

public int nextLength()
Deprecated. Use nextSet() instead

Returns the number of basic blocks in the successor set for this.

See Also:
nextSet()

prev

public Enumeration<BasicBlock<HCE>> prev()
Deprecated. Use prevSet() instead

Returns an Enumeration that iterates over the predecessors for this.

See Also:
prevSet()

next

public Enumeration<BasicBlock<HCE>> next()
Deprecated. Use nextSet() instead

Returns an Enumeration that iterates over the successors for this.

See Also:
prevSet()

prevSet

public Set<BasicBlock<HCE>> prevSet()
Returns all the predecessors of this.
effects: returns a Set of BasicBlocks which precede this.

Specified by:
prevSet in interface BasicBlockInterf<HCE extends HCodeElement,BasicBlock<HCE extends HCodeElement>>

nextSet

public Set<BasicBlock<HCE>> nextSet()
Returns all the successors of this.
effects: returns a Set of BasicBlocks which succeed this.

Specified by:
nextSet in interface BasicBlockInterf<HCE extends HCodeElement,BasicBlock<HCE extends HCodeElement>>

statements

public List<HCE> statements()
Returns an unmodifiable List for the HCodeElements within this.
effects: Generates a new List of HCodeElements ordered according to the order mandated by the CFGrapher used in the call to computeBasicBlocks that generated this.

Specified by:
statements in interface BasicBlockInterf<HCE extends HCodeElement,BasicBlock<HCE extends HCodeElement>>

accept

public void accept(BasicBlockInterfVisitor v)
Accept a visitor. FSK: is this really useful? John put this in with the thought that we'd have many different types of BasicBlocks, but I'm not sure about that actually being a useful set of subtypes

Specified by:
accept in interface BasicBlockInterf<HCE extends HCodeElement,BasicBlock<HCE extends HCodeElement>>

toString

public String toString()
Overrides:
toString in class Object

dumpElems

public String dumpElems()
Returns a String composed of the statements comprising this.