A modest proposal: eliminate template code bloat

Daniel Murphy yebblies at nospamgmail.com
Sun Apr 8 18:11:58 PDT 2012


"Dmitry Olshansky" <dmitry.olsh at gmail.com> wrote in message 
news:jlsmka$22ce$1 at digitalmars.com...
>
> The refinement is merging prefixes and suffixes of course.
> And for that one needs to calculate hashes for all of prefixes and all of 
> suffixes. I will define _all_ later on.
>

I think you'll find that this is better done in the compiler instead of the 
linker.  Merging prefixes is problematic because at some point you will need 
to work out which tail to execute, so you'll always need to modify the 
generated code.

Merging suffixes is easier, you can merge all returning blocks with 
identical code, and then merge all blocks that always jump to the same 
blocks, etc.
This will need to happen after code generation if you want to merge int/uint 
code, which would be difficult in dmd's back end.

Merging functions with identical bodies is of course much easier, and can be 
done in the linker without needing to modify any code (just the 
relocations). 




More information about the Digitalmars-d mailing list