Commit 7843d7f
committed
feat(compiler): Correct purity analysis of memory primitives
This pr corrects the purity analysis of a few of our memory related primitives.
While looking at this I also did an audit for #1170, at the time the issue was opened we were using linear memory which meant that malloc was being called and allocations were impure, this isn't true anymore as we are using wasm gc all allocates can safely be considered pure.
There are some additional changes I plan to make a future pr, for instance:
* `break` & `consider` are impure as they impact control flow of a loop, however this the way we analyze purity of loops doesn't consider this, meaning any loop with a `break` or `continue` is considered impure.
* Function calls are always considered impure however this isn't really the case, we should probably make a look up table of functions and analyze if the function being called is considered pure itself.
* This gets complicated though as changing a local in a function is impure but when you look at it from the callers perspective its pure similar to the issues with `break` and `continue` on loops.
*
Closes: #1170
Work towards: #2029
This pr is based on: #23781 parent 7354757 commit 7843d7f
1 file changed
Lines changed: 4 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
44 | | - | |
| 43 | + | |
| 44 | + | |
45 | 45 | | |
46 | 46 | | |
47 | 47 | | |
| |||
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
108 | | - | |
109 | 108 | | |
110 | 109 | | |
111 | 110 | | |
112 | 111 | | |
113 | | - | |
| 112 | + | |
114 | 113 | | |
115 | 114 | | |
116 | 115 | | |
| |||
132 | 131 | | |
133 | 132 | | |
134 | 133 | | |
135 | | - | |
136 | 134 | | |
137 | 135 | | |
138 | 136 | | |
139 | 137 | | |
140 | 138 | | |
141 | 139 | | |
142 | | - | |
| 140 | + | |
143 | 141 | | |
144 | 142 | | |
145 | 143 | | |
| |||
0 commit comments