3 ms·
Couldn't PICs and monomorphization be seen as duals? They are both solving the problem of how to make polymorphic code have fewer branches.
by sitkack 2y ago
Couldn't PICs and monomorphization be seen as duals? They are both solving the problem of how to make polymorphic code have fewer branches.
- pizlonator 2y agoPICs are the core mechanism of monomorphization in the VMs that do it
- sitkack 2y agoI was thinking of static monomorphization as in Rust.
- pizlonator 2y agoBut then there isn't a duality. If your language is static enough, then static devirt is profitable enough that you can stop there. If your language is dynamic enough, then PICs are the main driver of devirt. (Though all PIC-based systems couple that with static analysis and that static analysis is powerful enough that it can sometimes devirt without the PICs' help.)
- sitkack 2y agoI meant "dual" in the analogous sense, not as strict mathematical duals where one could replace the other. That both are solving devirt from opposite ends. I read @bjoli's comment with the analogous connotation. Your last sentence, would be if Rust used a PIC to optimize calls to dyn Traits?