| | |
- Block
- FlowGraph
-
- PyFlowGraph
- LineAddrTable
- StackDepthTracker
- TupleArg
class Block |
| | |
Methods defined here:
- __init__(self, label='')
- __repr__(self)
- __str__(self)
- addInEdge(self, block)
- addNext(self, block)
- addOutEdge(self, block)
- emit(self, inst)
- getContainedGraphs(self)
- Return all graphs contained within this block.
For example, a MAKE_FUNCTION block will contain a reference to
the graph for the function body.
- getInstructions(self)
- get_children(self)
- pruneNext(self)
- Remove bogus edge for unconditional transfers
Each block has a next edge that accounts for implicit control
transfers, e.g. from a JUMP_IF_FALSE to the block that will be
executed if the test is true.
These edges must remain for the current assembler code to
work. If they are removed, the dfs_postorder gets things in
weird orders. However, they shouldn't be there for other
purposes, e.g. conversion to SSA form. This method will
remove the next edge when it follows an unconditional control
transfer.
|
class FlowGraph |
| | |
Methods defined here:
- __init__(self)
- emit(self, *inst)
- fixupOrder(self, blocks, default_next)
- Fixup bad order introduced by DFS.
- fixupOrderForward(self, blocks, default_next)
- Make sure all JUMP_FORWARDs jump forward
- fixupOrderHonorNext(self, blocks, default_next)
- Fix one problem with DFS.
The DFS uses child block, but doesn't know about the special
"next" block. As a result, the DFS can order blocks so that a
block isn't next to the right block for implicit control
transfers.
- getBlocks(self)
- getBlocksInOrder(self)
- Return the blocks in reverse postorder
i.e. each node appears before all of its successors
- getContainedGraphs(self)
- getRoot(self)
- Return nodes appropriate for use with dominator
- newBlock(self)
- nextBlock(self, block=None)
- startBlock(self, block)
- startExitBlock(self)
|
class LineAddrTable |
| |
lnotab
This class builds the lnotab, which is documented in compile.c.
Here's a brief recap:
For each SET_LINENO instruction after the first one, two bytes are
added to lnotab. (In some cases, multiple two-byte entries are
added.) The first byte is the distance in bytes between the
instruction for the last SET_LINENO and the current SET_LINENO.
The second byte is offset in line numbers. If either offset is
greater than 255, multiple two-byte entries are added -- see
compile.c for the delicate details. |
| |
Methods defined here:
- __init__(self)
- addCode(self, *args)
- getCode(self)
- getTable(self)
- nextLine(self, lineno)
|
class PyFlowGraph(FlowGraph) |
| | |
Methods defined here:
- __init__(self, name, filename, args=(), optimized=0, klass=None)
- checkFlag(self, flag)
- computeStackDepth(self)
- Compute the max stack depth.
Approach is to compute the stack effect of each basic block.
Then find the path through the code with the largest total
effect.
- convertArgs(self)
- Convert arguments from symbolic to concrete form
- dump(self, io=None)
- flattenGraph(self)
- Arrange the blocks in order and resolve jumps
- getCode(self)
- Get a Python code object
- getConsts(self)
- Return a tuple for the const slot of the code object
Must convert references to code (MAKE_FUNCTION) to code
objects recursively.
- makeByteCode(self)
- newCodeObject(self)
- setCellVars(self, names)
- setDocstring(self, doc)
- setFlag(self, flag)
- setFreeVars(self, names)
- sort_cellvars(self)
- Sort cellvars in the order of varnames and prune from freevars.
- super_init = __init__(self)
Data and other attributes defined here:
- hasjabs = <compiler.misc.Set instance at 0xb6d909cc>
- hasjrel = <compiler.misc.Set instance at 0xb6d9098c>
- i = 119
- opnum = {'<109>': 109, '<114>': 114, '<115>': 115, '<117>': 117, '<118>': 118, '<123>': 123, '<127>': 127, '<128>': 128, '<129>': 129, '<138>': 138, ...}
Methods inherited from FlowGraph:
- emit(self, *inst)
- fixupOrder(self, blocks, default_next)
- Fixup bad order introduced by DFS.
- fixupOrderForward(self, blocks, default_next)
- Make sure all JUMP_FORWARDs jump forward
- fixupOrderHonorNext(self, blocks, default_next)
- Fix one problem with DFS.
The DFS uses child block, but doesn't know about the special
"next" block. As a result, the DFS can order blocks so that a
block isn't next to the right block for implicit control
transfers.
- getBlocks(self)
- getBlocksInOrder(self)
- Return the blocks in reverse postorder
i.e. each node appears before all of its successors
- getContainedGraphs(self)
- getRoot(self)
- Return nodes appropriate for use with dominator
- newBlock(self)
- nextBlock(self, block=None)
- startBlock(self, block)
- startExitBlock(self)
|
class StackDepthTracker |
| | |
Methods defined here:
- BUILD_LIST(self, count)
- BUILD_SLICE(self, argc)
- BUILD_TUPLE(self, count)
- CALL_FUNCTION(self, argc)
- CALL_FUNCTION_KW(self, argc)
- CALL_FUNCTION_VAR(self, argc)
- CALL_FUNCTION_VAR_KW(self, argc)
- DUP_TOPX(self, argc)
- MAKE_CLOSURE(self, argc)
- MAKE_FUNCTION(self, argc)
- UNPACK_SEQUENCE(self, count)
- findDepth(self, insts, debug=0)
Data and other attributes defined here:
- effect = {'BUILD_CLASS': -2, 'BUILD_MAP': 1, 'COMPARE_OP': -1, 'DELETE_ATTR': -1, 'DELETE_SLICE+0': -1, 'DELETE_SLICE+1': -2, 'DELETE_SLICE+2': -2, 'DELETE_SLICE+3': -3, 'DELETE_SUBSCR': -2, 'DUP_TOP': 1, ...}
- patterns = [('BINARY_', -1), ('LOAD_', 1)]
|
|