paul@419 | 1 | Low-Level Instructions and Macro Instructions
|
paul@419 | 2 | =============================================
|
paul@419 | 3 |
|
paul@429 | 4 | Have contexts and values stored separately in memory. This involves eliminating DataValue
|
paul@429 | 5 | and storing attributes using two words.
|
paul@429 | 6 |
|
paul@419 | 7 | Migrate macro instructions such as the *Index instructions to library code implemented
|
paul@419 | 8 | using low-level instructions.
|
paul@419 | 9 |
|
paul@419 | 10 | Consider introducing classic machine level instructions (word addition, subtraction, and
|
paul@419 | 11 | so on) in order to implement all current RSVP instructions.
|
paul@419 | 12 |
|
paul@417 | 13 | Class and Module Attribute Assignment
|
paul@417 | 14 | =====================================
|
paul@417 | 15 |
|
paul@417 | 16 | Verify that the context information is correctly set, particularly for the unoptimised
|
paul@417 | 17 | cases.
|
paul@417 | 18 |
|
paul@417 | 19 | Update docs/assignment.txt.
|
paul@417 | 20 |
|
paul@431 | 21 | Prevent assignments within classes, such as method aliasing, from causing the source of an
|
paul@431 | 22 | assignment from being automatically generated. Instead, only external references should be
|
paul@431 | 23 | registered.
|
paul@431 | 24 |
|
paul@431 | 25 | Prevent "from <module> import ..." statements from registering references to such local
|
paul@431 | 26 | aliases such that they cause the source of each alias to be automatically generated.
|
paul@431 | 27 |
|
paul@419 | 28 | Consider attribute assignment observations, along with the possibility of class and module
|
paul@419 | 29 | attribute assignment.
|
paul@419 | 30 |
|
paul@419 | 31 | (Note direct assignments as usual, indirect assignments via the attribute usage
|
paul@419 | 32 | mechanism. During attribute collection and inference, add assigned values to all
|
paul@419 | 33 | inferred targets.)
|
paul@419 | 34 |
|
paul@419 | 35 | (Since class attributes can be assigned, StoreAttrIndex would no longer need to reject
|
paul@419 | 36 | static attributes, although this might still be necessary where attribute usage analysis
|
paul@419 | 37 | has not been performed.)
|
paul@419 | 38 |
|
paul@419 | 39 | Potentially consider changing static attribute details to use object-relative offsets in
|
paul@419 | 40 | order to simplify the instruction implementations. This might allow us to eliminate the
|
paul@419 | 41 | static attribute flag for attributes in the object table, at least at run-time.
|
paul@419 | 42 |
|
paul@413 | 43 | Dynamic Attribute Access
|
paul@413 | 44 | ========================
|
paul@413 | 45 |
|
paul@425 | 46 | Consider explicit accessor initialisation:
|
paul@425 | 47 |
|
paul@425 | 48 | attr = accessor("attr")
|
paul@425 | 49 | getattr(C, attr)
|
paul@413 | 50 |
|
paul@394 | 51 | Attribute Usage
|
paul@394 | 52 | ===============
|
paul@394 | 53 |
|
paul@445 | 54 | Loop entry points and other places where usage becomes more specific might be used as
|
paul@445 | 55 | places to impose guards. See tests/attribute_access_type_restriction_loop_list.py for an
|
paul@445 | 56 | example.
|
paul@445 | 57 |
|
paul@372 | 58 | Consider attribute usage observations being suspended inside blocks where AttributeError
|
paul@372 | 59 | may be caught (although this doesn't anticipate such exceptions being caught outside a
|
paul@372 | 60 | function altogether).
|
paul@372 | 61 |
|
paul@364 | 62 | Consider type deduction and its consequences where types belong to the same hierarchy
|
paul@364 | 63 | and where a guard could be generated for the most general type.
|
paul@364 | 64 |
|
paul@364 | 65 | Consider permitting multiple class alternatives where the attributes are all identical.
|
paul@364 | 66 |
|
paul@360 | 67 | Support class attribute positioning similar to instance attribute positioning, potentially
|
paul@360 | 68 | (for both) based on usage observations. For example, if __iter__ is used on two classes,
|
paul@360 | 69 | the class attribute could be exposed at a similar relative position to the class (and
|
paul@360 | 70 | potentially accessible using a LoadAttr-style instruction).
|
paul@360 | 71 |
|
paul@394 | 72 | **** Constant attribute users need not maintain usage since they are already resolved. ****
|
paul@394 | 73 |
|
paul@394 | 74 | Consider handling CallFunc in micropython.inspect in order to produce instances of specific classes.
|
paul@394 | 75 | Then, consider adding support for guard removal/verification where known instances are involved.
|
paul@394 | 76 | Consider handling branches of values within namespaces in order to support more precise value usage.
|
paul@394 | 77 |
|
paul@394 | 78 | Frame Optimisations
|
paul@394 | 79 | ===================
|
paul@394 | 80 |
|
paul@394 | 81 | Stack frame replacement where a local frame is unused after a call, such as in a tail call
|
paul@394 | 82 | situation.
|
paul@394 | 83 |
|
paul@394 | 84 | Local assignment detection plus frame re-use. Example: slice.__init__ calls
|
paul@394 | 85 | xrange.__init__ with the same arguments which are unchanged in xrange.__init__. There is
|
paul@419 | 86 | therefore no need to build a new frame for this call, although in some cases the locals
|
paul@419 | 87 | frame might need expanding.
|
paul@419 | 88 |
|
paul@419 | 89 | Inlining
|
paul@419 | 90 | ========
|
paul@419 | 91 |
|
paul@419 | 92 | Where a function or method call can always be determined, the body of the target could be
|
paul@419 | 93 | inlined - copied into place - within the caller. If the target is only ever called by a
|
paul@419 | 94 | single caller it could be moved into place.
|
paul@394 | 95 |
|
paul@394 | 96 | Function Specialisation
|
paul@394 | 97 | =======================
|
paul@394 | 98 |
|
paul@394 | 99 | Specialisation of certain functions, such as isinstance(x, cls) where cls is a known
|
paul@394 | 100 | constant.
|
paul@394 | 101 |
|
paul@394 | 102 | Structure and Object Table Optimisations
|
paul@394 | 103 | ========================================
|
paul@394 | 104 |
|
paul@394 | 105 | Fix object table entries for attributes not provided by any known object, or provide an
|
paul@394 | 106 | error, potentially overridden by options. For example, the augmented assignment methods
|
paul@394 | 107 | are not supported by the built-in objects and thus the operator module functions cause
|
paul@394 | 108 | the compilation to fail. Alternatively, just supply the methods since something has to do
|
paul@394 | 109 | so in the builtins.
|
paul@394 | 110 |
|
paul@394 | 111 | Consider attribute merging where many attributes are just aliases for the same underlying
|
paul@394 | 112 | definition.
|
paul@394 | 113 |
|
paul@349 | 114 | Consider references to defaults as occurring only within the context of a particular
|
paul@349 | 115 | function, thus eliminating default value classes if such functions are not themselves
|
paul@349 | 116 | invoked.
|
paul@349 | 117 |
|
paul@394 | 118 | Scope Handling
|
paul@394 | 119 | ==============
|
paul@394 | 120 |
|
paul@394 | 121 | Consider merging the InspectedModule.store tests with the scope conflict handling.
|
paul@394 | 122 |
|
paul@343 | 123 | Consider labelling _scope on assignments and dealing with the assignment of removed
|
paul@343 | 124 | attributes, possibly removing the entire assignment, and distinguishing between such cases
|
paul@343 | 125 | and unknown names.
|
paul@343 | 126 |
|
paul@342 | 127 | Check name origin where multiple branches could yield multiple scope interpretations:
|
paul@342 | 128 |
|
paul@342 | 129 | ----
|
paul@342 | 130 | try:
|
paul@342 | 131 | set # built-in name
|
paul@342 | 132 | except NameError:
|
paul@342 | 133 | from sets import Set as set # local definition of name
|
paul@342 | 134 |
|
paul@342 | 135 | set # could be confused by the local definition at run-time
|
paul@342 | 136 | ----
|
paul@342 | 137 |
|
paul@394 | 138 | Object Coverage
|
paul@394 | 139 | ===============
|
paul@394 | 140 |
|
paul@332 | 141 | Support __init__ traversal (and other implicit names) more effectively.
|
paul@332 | 142 |
|
paul@394 | 143 | Other
|
paul@394 | 144 | =====
|
paul@394 | 145 |
|
paul@449 | 146 | Support self attribute visualisation in the reports and/or provide a function or
|
paul@449 | 147 | annotations which can provide the eventual optimisation directly to such components.
|
paul@408 | 148 |
|
paul@332 | 149 | Check context_value initialisation (avoiding or handling None effectively).
|
paul@332 | 150 |
|
paul@342 | 151 | Consider better "macro" support where new expressions need to be generated and processed.
|
paul@402 | 152 |
|
paul@402 | 153 | Detect TestIdentity results involving constants, potentially optimising status-affected
|
paul@402 | 154 | instructions:
|
paul@402 | 155 |
|
paul@402 | 156 | TestIdentity(x, y) # where x is always y
|
paul@402 | 157 | JumpIfFalse(...) # would be removed (never false)
|
paul@402 | 158 | JumpIfTrue(...) # changed to Jump(...)
|
paul@402 | 159 |
|
paul@402 | 160 | Status-affected blocks could be optimised away for such constant-related results.
|