harpoon.Util.LightBasicBlocks
Class LightBasicBlock

java.lang.Object
  extended by harpoon.Util.LightBasicBlocks.LightBasicBlock
All Implemented Interfaces:
Serializable

public class LightBasicBlock
extends Object
implements Serializable

LightBasicBlock is designed as a compact version of a BasicBlock. The next and the previous basic blocks, as well as the composing instructions are stored in arrays, instead of expensive Sets. The traversal of these structures is far cheaper that the equaivalent operation on BasicBlocks: no Iterator object need to be dynamically created, it's juat an integer index.

Use: To obtain the LightBasicBlocks of a given method, you have to obtain a BasicBlock.Factory for that method and pass it to LightBasicBlock.Factory.

If the "quad-with-try" IR is used, the light basic blocks contain info about the handlers that handle the exceptions that could be thrown by the instructions from each light basic block.

Note: The interface might seem minimal but I recommend that you use it instead of adding some other methods. For example, one might complain that there are no methods to return the number of predecessors, nor the i-th predecessor. Here is why: you are expected to traverse the list of predecessors in the cheapest way: extract the array of predecessors and then do a for whose condition looks something like i<pred.length instead of i<lbb.predLength() (one method call per iteration!).

Version:
$Id: LightBasicBlock.java,v 1.6 2004/03/06 21:52:34 salcianu Exp $
Author:
Alexandru SALCIANU <salcianu@mit.edu>
See Also:
Serialized Form

Nested Class Summary
static class LightBasicBlock.Factory
          Converts the large, set based, basic blocks produced by a BasicBlock.Factory into smaller, array based, light basic blocks.
 
Field Summary
 String str
           
 Object user_info
          Deprecated.  
 
Method Summary
 HCodeElement[] getElements()
          Returns the inctructions in this basic block.
 HCodeElement getFirstElement()
          Returns the first instruction from this basic block.
 int getHandlerStartIndex()
          Returns the index of the first handler into the array of next (light) basic blocks.
 HCodeElement getLastElement()
          Returns the last instruction from this basic block.
 LightBasicBlock[] getNextLBBs()
          Returns the array of successor light basic blocks.
 LightBasicBlock[] getPrevLBBs()
          Returns the array of predecessor light basic blocks.
 int getProtectedStartIndex()
          Returns the index of the first protected basic block in the array of (light) basic blocks.
 String toString()
          String representation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

user_info

public Object user_info
Deprecated. 
The user can place his annotations here.


str

public String str
Method Detail

getNextLBBs

public final LightBasicBlock[] getNextLBBs()
Returns the array of successor light basic blocks. Starting from position getHandlerStartIndex() on (including that position), the entries of the returned array point to light basic blocks corresponding to the handlers for the instructions of this (light) basic block. The handlers appear in the order in which they catch exceptions. The exit point of the method is considered to be the default handler (any uncaught exception is sent to the caller).


getHandlerStartIndex

public final int getHandlerStartIndex()
Returns the index of the first handler into the array of next (light) basic blocks.

See Also:
getNextLBBs

getPrevLBBs

public final LightBasicBlock[] getPrevLBBs()
Returns the array of predecessor light basic blocks. For basic blocks that start with a HANDLER instruction, the entries of the returned array starting from position getProtectedStartIndex() on (including that position) point to the light basic block composed of instructions which are protected by this this basic block. The end of the method is the only basic block that has both normal flow predecessors and protected basic blocks (any uncaught exception is passed down to the caller).


getProtectedStartIndex

public final int getProtectedStartIndex()
Returns the index of the first protected basic block in the array of (light) basic blocks.

See Also:
getPrevLBBs

getElements

public final HCodeElement[] getElements()
Returns the inctructions in this basic block.


getFirstElement

public final HCodeElement getFirstElement()
Returns the first instruction from this basic block.


getLastElement

public final HCodeElement getLastElement()
Returns the last instruction from this basic block.


toString

public final String toString()
String representation.

Overrides:
toString in class Object