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