Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork5.6k
Commitffadb8c
Refactor lattice code to expose layering and enable easy extension
There's been two threads of work involving the compiler's notion ofthe inference lattice. One is that the lattice has gotten to complicatedand with too many internal constraints that are not manifest in thetype system.#42596 attempted to address this, but it's quite disruptiveas it changes the lattice types and all the signatures of the latticeoperations, which are used quite extensively throughout the ecosystem(despite being internal), so that change is quite disruptive (andsomething we'd ideally only make the ecosystem do once).The other thread of work is that people would like to experiment witha variety of extended lattices outside of base (either to prototypepotential additions to the lattice in base or to do custom abstractinterpretation over the Julia code). At the moment, the lattice isquite closely interwoven with the rest of the abstract interpreter.In response to this request in#40992, I had proposed a `CustomLattice`element with callbacks, but this doesn't compose particularly well,is cumbersome and imposes overhead on some of the hottest parts ofthe compiler, so it's a bit of a tough sell to merge into `Base`.In this PR, I'd like to propose a refactoring that is relativelynon-invasive to non-Base users, but I think would allow easierexperimentation with changes to the lattice for these two usecases. In essence, we're splitting the lattice into a ladder of5 different lattices, each containing the previous lattice as asub-lattice. These 5 lattices are:- `JLTypeLattice` (Anything that's a `Type`)- `ConstsLattice` ( + `Const`, `PartialTypeVar`)- `PartialsLattice` ( + `PartialStruct`, `PartialOpaque` )- `ConditionalsLattice` ( + `Conditional` )- `InferenceLattice` ( + `LimitedAccuracy` )- `OptimizerLattice` ( + `MaybeUndef` )The idea is that where a lattice element contains another latticeelement (e.g. in `PartialStruct` or `Conditional`), the elementcontained may only be from a wider lattice. In this PR, thisis not enforced by the type system. This is quite deliberate, asI want to retain the types and object layouts of the lattice elements,but of course a future#42596-like change could add such typeenforcement.Of particular note is that the `PartialsLattice` and `ConditionalsLattice`is parameterized and additional layers may be added in the stack.For example, in#40992, I had proposed a lattice element that refines`Int` and tracks symbolic expressions. In this setup, this couldbe accomplished by adding an appropriate lattice in between the`ConstsLattice` and the `PartialsLattice` (of course, additionalhooks would be required to make the tfuncs work, but that isoutside the scope of this PR).I don't think this is a full solution, but I think it'll help usplay with some of these extended lattice options over the next6-12 months in the packages that want to do this sort of thing.Presumably once we know what all the potential lattice extensionslook like, we will want to take another look at this (likelytogether with whatever solution we come up with for theAbstractInterpreter composability problem and a rebase of#42596).WIP because I didn't bother updating and plumbing through the latticein all the call sites yet, but that's mostly mechanical, so if welike this direction, I will make that change and hope to merge thisin short order (because otherwise it'll accumulate massive mergeconflicts).1 parentcb0721b commitffadb8c
File tree
16 files changed
+616
-221
lines changed- base/compiler
- ssair
- test/compiler
16 files changed
+616
-221
lines changedLines changed: 66 additions & 54 deletions
Large diffs are not rendered by default.
Lines changed: 173 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + |
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
156 | 156 |
| |
157 | 157 |
| |
158 | 158 |
| |
| 159 | + | |
159 | 160 |
| |
160 | 161 |
| |
161 | 162 |
| |
|
Lines changed: 6 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
215 | 215 |
| |
216 | 216 |
| |
217 | 217 |
| |
218 |
| - | |
| 218 | + | |
219 | 219 |
| |
220 | 220 |
| |
221 | 221 |
| |
| |||
248 | 248 |
| |
249 | 249 |
| |
250 | 250 |
| |
251 |
| - | |
| 251 | + | |
252 | 252 |
| |
253 | 253 |
| |
254 | 254 |
| |
| |||
262 | 262 |
| |
263 | 263 |
| |
264 | 264 |
| |
265 |
| - | |
| 265 | + | |
266 | 266 |
| |
267 | 267 |
| |
268 | 268 |
| |
| |||
277 | 277 |
| |
278 | 278 |
| |
279 | 279 |
| |
280 |
| - | |
| 280 | + | |
281 | 281 |
| |
282 | 282 |
| |
283 | 283 |
| |
284 |
| - | |
| 284 | + | |
285 | 285 |
| |
286 | 286 |
| |
287 | 287 |
| |
| |||
448 | 448 |
| |
449 | 449 |
| |
450 | 450 |
| |
451 |
| - | |
| 451 | + | |
452 | 452 |
| |
453 | 453 |
| |
454 | 454 |
| |
|
Lines changed: 15 additions & 13 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
114 | 114 |
| |
115 | 115 |
| |
116 | 116 |
| |
| 117 | + | |
| 118 | + | |
117 | 119 |
| |
118 | 120 |
| |
119 | 121 |
| |
| |||
381 | 383 |
| |
382 | 384 |
| |
383 | 385 |
| |
384 |
| - | |
| 386 | + | |
385 | 387 |
| |
386 | 388 |
| |
387 | 389 |
| |
| |||
476 | 478 |
| |
477 | 479 |
| |
478 | 480 |
| |
479 |
| - | |
| 481 | + | |
480 | 482 |
| |
481 | 483 |
| |
482 | 484 |
| |
| |||
1080 | 1082 |
| |
1081 | 1083 |
| |
1082 | 1084 |
| |
1083 |
| - | |
1084 |
| - | |
| 1085 | + | |
| 1086 | + | |
1085 | 1087 |
| |
1086 | 1088 |
| |
1087 | 1089 |
| |
| |||
1123 | 1125 |
| |
1124 | 1126 |
| |
1125 | 1127 |
| |
1126 |
| - | |
| 1128 | + | |
1127 | 1129 |
| |
1128 |
| - | |
| 1130 | + | |
1129 | 1131 |
| |
1130 | 1132 |
| |
1131 | 1133 |
| |
| |||
1165 | 1167 |
| |
1166 | 1168 |
| |
1167 | 1169 |
| |
1168 |
| - | |
| 1170 | + | |
1169 | 1171 |
| |
1170 | 1172 |
| |
1171 | 1173 |
| |
| |||
1222 | 1224 |
| |
1223 | 1225 |
| |
1224 | 1226 |
| |
1225 |
| - | |
| 1227 | + | |
1226 | 1228 |
| |
1227 | 1229 |
| |
1228 | 1230 |
| |
| |||
1240 | 1242 |
| |
1241 | 1243 |
| |
1242 | 1244 |
| |
1243 |
| - | |
| 1245 | + | |
1244 | 1246 |
| |
1245 | 1247 |
| |
1246 | 1248 |
| |
| |||
1637 | 1639 |
| |
1638 | 1640 |
| |
1639 | 1641 |
| |
1640 |
| - | |
| 1642 | + | |
1641 | 1643 |
| |
1642 | 1644 |
| |
1643 | 1645 |
| |
| |||
1683 | 1685 |
| |
1684 | 1686 |
| |
1685 | 1687 |
| |
1686 |
| - | |
| 1688 | + | |
1687 | 1689 |
| |
1688 | 1690 |
| |
1689 | 1691 |
| |
1690 | 1692 |
| |
1691 |
| - | |
| 1693 | + | |
1692 | 1694 |
| |
1693 | 1695 |
| |
1694 | 1696 |
| |
1695 | 1697 |
| |
1696 |
| - | |
| 1698 | + | |
1697 | 1699 |
| |
1698 | 1700 |
| |
1699 | 1701 |
| |
|
0 commit comments
Comments
(0)