In Swift for example, we think of conformance checking as part of the type checker phase but we’ve decided that the best approach is to trigger it lazily from SIL generation and optimization, and are moving towards that
-
Show this thread
-
This is in service of minimizing wasted work when building some subset of files in a module. All conformances in a primary file must be checked since we emit witness tables; but conformances in other files are only used sometimes, for compile-time type substitutions
1 reply 0 retweets 10 likesShow this thread -
@dgregor79 already did the work to make the type checker live forever in Swift 5, and this was enough to make the SIL optimizer happy. The next step is to trigger lazy conformance checking from SIL generation too1 reply 0 retweets 9 likesShow this thread -
This requires untangling some interesting ordering dependencies. For example, conformance checking can trigger the ClangImporter, which adds definitions on an “external declarations” list. SILGen scans the list once, and emits everything on it
1 reply 0 retweets 6 likesShow this thread -
This one is easy to fix - everything there was emitted lazily already, so it wouldn’t take much work to remove the external declarations list and change SILGen to emit thunks for imported declarations when they’re first referenced
1 reply 0 retweets 6 likesShow this thread -
Ideally though, subsequent stages would even be able to ask SILGen to emit witness tables lazily, which would in turn trigger lazy conformance checking
1 reply 0 retweets 5 likesShow this thread -
For example, IRGen has a lazy metadata emission mechanism so many imported types - and their conformances - don’t get emitted at all if they’re not actually needed. But SILGen still has to do the work of emitting the witness tables for these conformances
1 reply 0 retweets 5 likesShow this thread -
Imagine if IRGen could ask SILGen to generate some code. It might have to call into the type checker first - and then re-run the SIL optimization passes on the newly generated code
1 reply 0 retweets 7 likesShow this thread -
At this point, the compiler would have to look quite different internally than a traditional phase-based design
3 replies 0 retweets 12 likesShow this thread -
Note that rustc basically already does this via the incremental compilation/demand driven work. I think there are some talks on it somewhere
-
-
Yeah isn't this like the $20M into every jit alive? or put differently... YUP,
0 replies 0 retweets 0 likesThanks. Twitter will use this to make your timeline better. UndoUndo
-
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.