final void markSubroutine ( final short subroutineId ) { // Data flow algorithm: put this basic block in a list of blocks to process (which are blocks // belonging to subroutine subroutineId) and, while there are blocks to process, remove one from // the list, mark it as belonging to the subroutine, and add its successor basic blocks in the // control flow graph to the list of blocks to process (if not already done). Label listOfBlocksToProcess = this ; listOfBlocksToProcess . nextListElement = EMPTY_LIST ; while ( listOfBlocksToProcess != EMPTY_LIST ) { // Remove a basic block from the list of blocks to process. Label basicBlock = listOfBlocksToProcess ; listOfBlocksToProcess = listOfBlocksToProcess . nextListElement ; basicBlock . nextListElement = null ; // If it is not already marked as belonging to a subroutine, mark it as belonging to // subroutineId and add its successors to the list of blocks to process (unless already done). if ( basicBlock . subroutineId == 0 ) { basicBlock . subroutineId = subroutineId ; listOfBlocksToProcess = basicBlock . pushSuccessors ( listOfBlocksToProcess ) ; } } }
Finds the basic blocks that belong to the subroutine starting with the basic block corresponding to this label and marks these blocks as belonging to this subroutine . This method follows the control flow graph to find all the blocks that are reachable from the current basic block WITHOUT following any jsr target .