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