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