Re:My First Fifteen Compilers
by rurban on Friday July 12, 2019 @08:57AM
(#20420332)
Note that you do that kind of mega multipass compilers only when compiling to static binaries, not when targetting dynamic languages. It's way too slow, the compilation steps would last longer than the expected runtime. You can easily combine all these passes into one tree traversal and optimize on demand and benefit. 400 passes is beyond sanity.
[ Parent
| on HN ]
Re:My First Fifteen Compilers
by rickbutton on Friday July 12, 2019 @09:37AM
(#20420581)
the "nanopass" approach mentioned in the article is used in Dybvig's chez scheme (not the nanopass library, just the style of compiler construction), and chez scheme is as close to an industrial grade scheme compiler as it gets, and is pretty fast.
edit: I missed that chez scheme is already mentioned in the article.
I'm not convinced this is true in general. Depending on how complicated these passes are, if you were to write the compiler in a language that allows you to combine them at compile time it would be entirely possible for the compiler(The one compiling the compiler) to cut out of the inter-pass crud.
https://d.godbolt.org/z/w9At24 I hacked together this to show what I mean, i.e. Composing working functions with templates, which the compiler can then optimize into just a function call like any other (i.e. This can be used to minimize runtime scheduling cost)