org.jikesrvm.compilers.baseline
Class BuildBB

java.lang.Object
  extended by org.jikesrvm.compilers.baseline.BuildBB
All Implemented Interfaces:
BytecodeConstants, BBConstants

final class BuildBB
extends Object
implements BytecodeConstants, BBConstants

Analyze the byte codes and determine the boundaries of the basic blocks. Used for building the reference maps for a method.


Nested Class Summary
private static class BuildBB.InstructionType
          Types of Instructions
 
Field Summary
 BasicBlock[] basicBlocks
           
 BasicBlockFactory bbf
          basic blocks of the byte code
(package private)  int bytelength
           
 short[] byteToBlockMap
          identify which block a byte is part of
 int gcPointCount
          Number of GC points found
 int numJsrs
          Number of unique jsr targets processed
 
Fields inherited from interface org.jikesrvm.classloader.BytecodeConstants
JBC_aaload, JBC_aastore, JBC_aconst_null, JBC_aload, JBC_aload_0, JBC_aload_1, JBC_aload_2, JBC_aload_3, JBC_anewarray, JBC_areturn, JBC_arraylength, JBC_astore, JBC_astore_0, JBC_astore_1, JBC_astore_2, JBC_astore_3, JBC_athrow, JBC_baload, JBC_bastore, JBC_bipush, JBC_caload, JBC_castore, JBC_checkcast, JBC_d2f, JBC_d2i, JBC_d2l, JBC_dadd, JBC_daload, JBC_dastore, JBC_dcmpg, JBC_dcmpl, JBC_dconst_0, JBC_dconst_1, JBC_ddiv, JBC_dload, JBC_dload_0, JBC_dload_1, JBC_dload_2, JBC_dload_3, JBC_dmul, JBC_dneg, JBC_drem, JBC_dreturn, JBC_dstore, JBC_dstore_0, JBC_dstore_1, JBC_dstore_2, JBC_dstore_3, JBC_dsub, JBC_dup, JBC_dup_x1, JBC_dup_x2, JBC_dup2, JBC_dup2_x1, JBC_dup2_x2, JBC_f2d, JBC_f2i, JBC_f2l, JBC_fadd, JBC_faload, JBC_fastore, JBC_fcmpg, JBC_fcmpl, JBC_fconst_0, JBC_fconst_1, JBC_fconst_2, JBC_fdiv, JBC_fload, JBC_fload_0, JBC_fload_1, JBC_fload_2, JBC_fload_3, JBC_fmul, JBC_fneg, JBC_frem, JBC_freturn, JBC_fstore, JBC_fstore_0, JBC_fstore_1, JBC_fstore_2, JBC_fstore_3, JBC_fsub, JBC_getfield, JBC_getstatic, JBC_goto, JBC_goto_w, JBC_i2d, JBC_i2f, JBC_i2l, JBC_iadd, JBC_iaload, JBC_iand, JBC_iastore, JBC_iconst_0, JBC_iconst_1, JBC_iconst_2, JBC_iconst_3, JBC_iconst_4, JBC_iconst_5, JBC_iconst_m1, JBC_idiv, JBC_if_acmpeq, JBC_if_acmpne, JBC_if_icmpeq, JBC_if_icmpge, JBC_if_icmpgt, JBC_if_icmple, JBC_if_icmplt, JBC_if_icmpne, JBC_ifeq, JBC_ifge, JBC_ifgt, JBC_ifle, JBC_iflt, JBC_ifne, JBC_ifnonnull, JBC_ifnull, JBC_iinc, JBC_iload, JBC_iload_0, JBC_iload_1, JBC_iload_2, JBC_iload_3, JBC_impdep1, JBC_impdep2, JBC_imul, JBC_ineg, JBC_instanceof, JBC_int2byte, JBC_int2char, JBC_int2short, JBC_invokeinterface, JBC_invokespecial, JBC_invokestatic, JBC_invokevirtual, JBC_ior, JBC_irem, JBC_ireturn, JBC_ishl, JBC_ishr, JBC_istore, JBC_istore_0, JBC_istore_1, JBC_istore_2, JBC_istore_3, JBC_isub, JBC_iushr, JBC_ixor, JBC_jsr, JBC_jsr_w, JBC_l2d, JBC_l2f, JBC_l2i, JBC_ladd, JBC_laload, JBC_land, JBC_lastore, JBC_lcmp, JBC_lconst_0, JBC_lconst_1, JBC_ldc, JBC_ldc_w, JBC_ldc2_w, JBC_ldiv, JBC_length, JBC_lload, JBC_lload_0, JBC_lload_1, JBC_lload_2, JBC_lload_3, JBC_lmul, JBC_lneg, JBC_lookupswitch, JBC_lor, JBC_lrem, JBC_lreturn, JBC_lshl, JBC_lshr, JBC_lstore, JBC_lstore_0, JBC_lstore_1, JBC_lstore_2, JBC_lstore_3, JBC_lsub, JBC_lushr, JBC_lxor, JBC_monitorenter, JBC_monitorexit, JBC_multianewarray, JBC_name, JBC_new, JBC_newarray, JBC_nop, JBC_pop, JBC_pop2, JBC_putfield, JBC_putstatic, JBC_ret, JBC_return, JBC_saload, JBC_sastore, JBC_sipush, JBC_swap, JBC_tableswitch, JBC_wide, JBC_xxxunusedxxx
 
Fields inherited from interface org.jikesrvm.compilers.baseline.BBConstants
ADDRESS_TYPE, CONDITIONAL_, CONDITIONALTARGET, DOUBLE_TYPE, DUMMYBLOCK, EXCEPTIONHANDLER, EXITBLOCK, FALLTHRU_, FALLTHRUTARGET, FLOAT_TYPE, HASHANDLER_, INJSR_, INT_TYPE, JSRENTRY, LENGTH_MASK, LONG_TYPE, LONGHALF_TYPE, METHODENTRY, NOTBLOCK, STARTBLOCK, TARGET_, TRYHANDLERSTART, TRYSTART_, UNCONDITIONALTARGET, VOID_TYPE
 
Constructor Summary
BuildBB()
           
 
Method Summary
private  void addBasicBlock(BasicBlock newBB)
          add a basic block to the list
 void determineTheBasicBlocks(NormalMethod method)
          Analyze the bytecodes and build the basic blocks with their predecessors.
private  void findAndSetJSRCallSite(int pred, BasicBlock retBB, int otherRetCount, boolean[] seenAlready)
          scan back from ret instruction to jsr call sites
private  void markTryBlocks(ExceptionHandlerMap exceptions)
          Mark all the blocks within try range as being Try blocks used for determining the stack maps for Handler blocks Only called when exceptions is not null.
private  void processAthrow(ExceptionHandlerMap exceptions, int athrowIndex)
          Check if an athrow is within a try block, if it is, then handlers have this block as their predecessor; which is registered in "processExceptionHandlers" Otherwise, the athrow acts as a branch to the exit and that should be marked here.
private  void processBackwardBranch(int index, int branchtarget)
          A backwards branch has been found from the byte code at location "index" to a target location of "branchtarget".
private  void processBranchTarget(int index, int branchtarget)
          Processing a branch that appears at location index in the byte code and has a target index of branchtarget in the byte code.
private  void processExceptionHandlers(ExceptionHandlerMap exceptions)
          For every handler, mark the blocks in its try block as its predecessors.
private  void processRetList(int[] retList, int nextRetList)
          process the effect of the ret instructions on the precedance table
private  void setupHandlerBBs(ExceptionHandlerMap exceptions)
          For every handler, make a block that starts with the handler PC Only called when exceptions is not null.
private  void setupJSRCallSite(BasicBlock entryBB, BasicBlock retBB)
          setup jsr call site
private  void setupTryStartBBs(ExceptionHandlerMap exceptions)
          For every try start, make a block that starts with the Try start, mark it as a try start.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

bbf

public BasicBlockFactory bbf
basic blocks of the byte code


basicBlocks

public BasicBlock[] basicBlocks

byteToBlockMap

public short[] byteToBlockMap
identify which block a byte is part of


numJsrs

public int numJsrs
Number of unique jsr targets processed


gcPointCount

public int gcPointCount
Number of GC points found


bytelength

int bytelength
Constructor Detail

BuildBB

BuildBB()
Method Detail

determineTheBasicBlocks

public void determineTheBasicBlocks(NormalMethod method)
Analyze the bytecodes and build the basic blocks with their predecessors. The results will be used by BuildReferenceMaps


processBranchTarget

private void processBranchTarget(int index,
                                 int branchtarget)
Processing a branch that appears at location index in the byte code and has a target index of branchtarget in the byte code. The target of a branch must start a basic block. So if the byteToBlockMap doesn't already show a basic block at the target, make one start there. If a basic block is already set up and this is a branch forward then only need to adjust predecessor list (we know it is not a branch into the middle of a block as only starts are marked in byte code beyond "index"). If the basic block is already set up and this is a backward branch then we must check if the block needs splitting, branching to the middle of a block is not allowed.


processBackwardBranch

private void processBackwardBranch(int index,
                                   int branchtarget)
A backwards branch has been found from the byte code at location "index" to a target location of "branchtarget". Need to make sure that the branchtarget location is the start of a block (and if not, then split the existing block into two) Need to register the block that ends at "index" as a predecessor of the block that starts at branchtarget.


processRetList

private void processRetList(int[] retList,
                            int nextRetList)
process the effect of the ret instructions on the precedance table


findAndSetJSRCallSite

private void findAndSetJSRCallSite(int pred,
                                   BasicBlock retBB,
                                   int otherRetCount,
                                   boolean[] seenAlready)
scan back from ret instruction to jsr call sites


setupJSRCallSite

private void setupJSRCallSite(BasicBlock entryBB,
                              BasicBlock retBB)
setup jsr call site


setupHandlerBBs

private void setupHandlerBBs(ExceptionHandlerMap exceptions)
For every handler, make a block that starts with the handler PC Only called when exceptions is not null.


setupTryStartBBs

private void setupTryStartBBs(ExceptionHandlerMap exceptions)
For every try start, make a block that starts with the Try start, mark it as a try start. Only called when exceptions is not null.


processExceptionHandlers

private void processExceptionHandlers(ExceptionHandlerMap exceptions)
For every handler, mark the blocks in its try block as its predecessors. Only called when exceptions is not null.


markTryBlocks

private void markTryBlocks(ExceptionHandlerMap exceptions)
Mark all the blocks within try range as being Try blocks used for determining the stack maps for Handler blocks Only called when exceptions is not null.


processAthrow

private void processAthrow(ExceptionHandlerMap exceptions,
                           int athrowIndex)
Check if an athrow is within a try block, if it is, then handlers have this block as their predecessor; which is registered in "processExceptionHandlers" Otherwise, the athrow acts as a branch to the exit and that should be marked here. Note exceptions may be null.


addBasicBlock

private void addBasicBlock(BasicBlock newBB)
add a basic block to the list