2 ms·
Virgil initializers are run at compile time and can literally run any code in the program to build up any data structures you want. The result of initialization
by titzer 5y ago
Virgil initializers are run at compile time and can literally run any code in the program to build up any data structures you want. The result of initialization is the transitive closure of objects reachable from the globals. The compiler goes further and optimizes your code against the initialized heap, devirtualizing, inlining, and constant-folding, throwing away dead code, dead fields, and dead objects. That's great for microcontrollers because you can just allocate your entire heap at compile time and then bake it into your image.
I wrote a paper about it in 2006: https://escholarship.org/uc/item/13r0q4fc https://escholarship.org/uc/item/13r0q4fc
I still work (primarily, in fact) on Virgil. It's great not having any distinction between compile-time initialization and runtime.