| 1 |
# Future |
| 2 |
|
| 3 |
This document introduces some ideas for future improvements. |
| 4 |
|
| 5 |
## Basic Optimizations |
| 6 |
|
| 7 |
Implement basic optimizations such as common subexpression elimination and |
| 8 |
loop invariant code motion. |
| 9 |
|
| 10 |
Importantly, common subexpression elimination could be used to avoid |
| 11 |
redundant type checks. |
| 12 |
|
| 13 |
## Operation-specific Optimizations |
| 14 |
|
| 15 |
Some operations or combinations of successive operations can be |
| 16 |
replaced with more efficient operations. Examples: |
| 17 |
|
| 18 |
* If `s` is a string, `s[i] == 'x'` doesn't need to construct the |
| 19 |
intermediate single-character string object `s[i]` but just compare |
| 20 |
the character value to `ord('x')`. |
| 21 |
|
| 22 |
* `a + ':' + b` (two string concetenations) can be implemented as |
| 23 |
single three-operand concatenation that doesn't construct an |
| 24 |
intermediate object. |
| 25 |
|
| 26 |
* `x in {1, 3}` can be translated into `x == 1 or x == 3` (more |
| 27 |
generally we need to evaluate all right-hand-side items). |
| 28 |
|
| 29 |
## Integer Range Analysis |
| 30 |
|
| 31 |
Implement integer range analysis. This can be used in various ways: |
| 32 |
|
| 33 |
* Use untagged representations for some registers. |
| 34 |
* Use faster integer arithmetic operations for operations that |
| 35 |
only deal with short integers or that can't overflow. |
| 36 |
* Remove redundant list and string index checks. |
| 37 |
|
| 38 |
## Always Defined Attributes |
| 39 |
|
| 40 |
Somehow make it possible to enforce that attributes in a class are always |
| 41 |
defined. This makes attribute access faster since we don't need to explicitly |
| 42 |
check if the attribute is defined. |