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