de.uka.ipd.sdq.ByCounter.parsing
Class RangeBlockDescriptor

java.lang.Object
  extended by de.uka.ipd.sdq.ByCounter.parsing.InstructionBlockDescriptor
      extended by de.uka.ipd.sdq.ByCounter.parsing.RangeBlockDescriptor
All Implemented Interfaces:
java.io.Serializable

public class RangeBlockDescriptor
extends InstructionBlockDescriptor

Descriptor for range blocks, i.e. sections of code in methods defined in LineNumberRanges using MethodDescriptor.setCodeAreasToInstrument(LineNumberRange[]). The descriptor describes the basic blocks of which the range block is made up. If a range block starts or ends in the middle of a basic block, the InstructionBlockDescriptors in getBasicBlockOffsets() describe the difference in counts.

Results are calculated using the following algorithm (pseudo code):

 for each basic block b with instructions counts b.counts and execution count b.c:
    result +=  b.c*b.counts
    
    for each basicBlockOffset bbOffset for basicBlock offsetBB:
                result -= bbOffset*offsetBB.c
 

See Also:
Serialized Form

Nested Class Summary
 class RangeBlockDescriptor.BasicBlockOffset
          Describes which instructions in the basic block with the index RangeBlockDescriptor.BasicBlockOffset.basicBlockIndex are added/subtracted in addition to normal basic block counts.
 
Constructor Summary
RangeBlockDescriptor(int numOfBasicBlocks)
          Construct a new RangeBlockDescriptor.
 
Method Summary
 void add(InstructionBlockDescriptor instructionBlockDescriptor)
          Adds instruction counts of the given block to this block.
 int[] getBasicBlockCounts()
           
 java.util.List<java.lang.Integer> getBasicBlockIndexesWithOffsets()
           
 java.util.List<RangeBlockDescriptor.BasicBlockOffset> getBasicBlockOffsets()
           
 java.util.Map<java.lang.String,java.lang.Integer> getMethodCallCounts()
          For RangeBlockDescriptor, this is unused.
 int[] getOpcodeCounts()
          For RangeBlockDescriptor, this is unused.
static void setUsesBasicBlock(RangeBlockDescriptor rangeBlockDescriptor, int basicBlockIndex)
          Sets the counter for the specified basic block to 1.
 java.lang.String toString()
           
 
Methods inherited from class de.uka.ipd.sdq.ByCounter.parsing.InstructionBlockDescriptor
addInstruction, getBlockIndex, isEmpty, setBlockIndex, subtract
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RangeBlockDescriptor

public RangeBlockDescriptor(int numOfBasicBlocks)
Construct a new RangeBlockDescriptor.

Parameters:
numOfBasicBlocks - The number of basic blocks in the method; used for indexing basic block counts in the range block.
Method Detail

getMethodCallCounts

public java.util.Map<java.lang.String,java.lang.Integer> getMethodCallCounts()
For RangeBlockDescriptor, this is unused.

Overrides:
getMethodCallCounts in class InstructionBlockDescriptor
Returns:
the methodCallCounts

getOpcodeCounts

public int[] getOpcodeCounts()
For RangeBlockDescriptor, this is unused.

Overrides:
getOpcodeCounts in class InstructionBlockDescriptor
Returns:
the opcodeCounts

add

public void add(InstructionBlockDescriptor instructionBlockDescriptor)
Description copied from class: InstructionBlockDescriptor
Adds instruction counts of the given block to this block. Ignores block index.

Overrides:
add in class InstructionBlockDescriptor

getBasicBlockCounts

public int[] getBasicBlockCounts()

setUsesBasicBlock

public static void setUsesBasicBlock(RangeBlockDescriptor rangeBlockDescriptor,
                                     int basicBlockIndex)
Sets the counter for the specified basic block to 1.

Parameters:
rangeBlockDescriptor - The RangeBlockDescriptor to modify.
basicBlockIndex - Index of the basic block that has to be counted in this rangeBlock.

getBasicBlockOffsets

public java.util.List<RangeBlockDescriptor.BasicBlockOffset> getBasicBlockOffsets()
Returns:
The offsets defined for this basic block.

getBasicBlockIndexesWithOffsets

public java.util.List<java.lang.Integer> getBasicBlockIndexesWithOffsets()
Returns:
A list of basic block indices. For each index in the list there exists a non-empty basic block offset.
See Also:
getBasicBlockOffsets()

toString

public java.lang.String toString()
Overrides:
toString in class InstructionBlockDescriptor