public void execute ( InstructionScannerGenerator generator ) { // Pump the instructions in the path through the generator and all // generated scanners while ( edgeIter . hasNext ( ) ) { Edge edge = edgeIter . next ( ) ; BasicBlock source = edge . getSource ( ) ; if ( DEBUG ) { System . out . println ( "ISD: scanning instructions in block " + source . getLabel ( ) ) ; } // Traverse all instructions in the source block Iterator < InstructionHandle > i = source . instructionIterator ( ) ; int count = 0 ; while ( i . hasNext ( ) ) { InstructionHandle handle = i . next ( ) ; // Check if the generator wants to create a new scanner if ( generator . start ( handle ) ) { scannerList . add ( generator . createScanner ( ) ) ; } // Pump the instruction into all scanners for ( InstructionScanner scanner : scannerList ) { scanner . scanInstruction ( handle ) ; } ++ count ; } if ( DEBUG ) { System . out . println ( "ISD: scanned " + count + " instructions" ) ; } // Now that we've finished the source block, pump the edge // into all scanners for ( InstructionScanner scanner : scannerList ) { scanner . traverseEdge ( edge ) ; } } }
Execute by driving the InstructionScannerGenerator over all instructions . Each generated InstructionScanner is driven over all instructions and edges .