how and where to {-# specialize #-} ?

Duncan Coutts duncan@coutts.uklinux.net
Wed, 25 Jun 2003 20:46:04 +0100


On Wed, 25 Jun 2003 10:18:17 +0100
Alastair Reid <alastair@reid-consulting-uk.ltd.uk> wrote:

> > | It is sad that the usage of libraries containing polymorphic code
> > | [...]
> > | seems to imply runtime overheads, by preventing specialisation.
> 
> > I agree that it is sad.  The only way around it is to ship libraries
> > with *all* their source code (perhaps hidden in the interface file).
> > That could be done, but it'd be Real Work
> 
> One way of tackling it would be to change ghc so that compilation doesn't 
> produce .o files containing machine code but, rather, files containing a 
> concise encoding of STG code.  One possible concise encoding would be as 
> bytecodes.  (With just a little care over their design, you can easily 
> uncompile bytecodes to recover the original code so we're not losing any 
> information.)

Something similar was proposed by the gcc folk at their recent
conference. The idea is that when you gcc -O4 your .c files, you get .o
files containing an intermediate typed SSA form. Upon linking the
program, gcc invokes a 'smart linker' which runs another pass on the
whole program. This allows for all kinds of cross-module inlining,
specialisation etc.

http://www.linux.org.uk/~ajh/gcc/gccsummit-2003-proceedings.pdf
pg 121, Architecture for a Next-Generation GCC

Duncan