Functions for computing the execution order of bytecode.
Class |
|
A block is a node in a directed graph. |
Class |
|
Collect opcodes that might have annotations attached. |
Class |
|
Visitor for disassembling code into Opcode objects. |
Class |
|
Visitor for recursively changing all CodeType to OrderedCode. |
Class |
|
Code object which knows about instruction ordering. |
Function | add |
Modifies bytecode so that each POP_BLOCK has a block_target. |
Function | compute |
Split bytecode into blocks and order the blocks. |
Function | merge |
Merges type comments into their associated opcodes. |
Function | order |
Split a CodeType object into ordered blocks. |
Function | process |
Undocumented |
Constant | CODE |
Undocumented |
Constant | STORE |
Undocumented |
Function | _is |
Helper function for CollectFunctionTypeCommentTargetsVisitor. |
Function | _split |
Given a sequence of bytecodes, return basic blocks. |
Modifies bytecode so that each POP_BLOCK has a block_target. This is to achieve better initial ordering of try/except and try/finally code. try: i = 1 a[i] except IndexError: return i By connecting a CFG edge from the end of the block (after the "a[i]") to the except handler, our basic block ordering algorithm knows that the except block needs to be scheduled last, whereas if there only was an edge before the "i = 1", it would be able to schedule it too early and thus encounter an undefined variable. This is only for ordering. The actual analysis of the code happens later, in vm.py. Args: bytecode: An array of bytecodes. python_version: The target python version.
Split bytecode into blocks and order the blocks. This builds an "ancestor first" ordering of the basic blocks of the bytecode. Args: bytecode: A list of instances of opcodes.Opcode. (E.g. returned from opcodes.dis()) Returns: A list of Block instances.
Merges type comments into their associated opcodes. Modifies code in place. Args: code: An OrderedCode object. annotations: A map of lines to annotations. Returns: The code with annotations added to the relevant opcodes.
Split a CodeType object into ordered blocks. This takes a CodeType object (i.e., a piece of compiled Python code) and splits it into ordered basic blocks. Args: code: A loadmarshal.CodeType object. python_version: The target python version. Returns: A CodeBlocks instance.
Undocumented
Value |
|
Given a sequence of bytecodes, return basic blocks. This will split the code at "basic block boundaries". These occur at every instruction that is jumped to, and after every instruction that jumps somewhere else (or returns / aborts). Args: bytecode: A list of instances of opcodes.Opcode. (E.g. returned from opcodes.dis()) Returns: A list of _Block instances.