[LLVMdev] Efficient implementation of closures?

Jon Harrop jon at ffconsultancy.com
Sun Dec 28 11:26:19 PST 2008


On Sunday 28 December 2008 18:49:29 me22 wrote:
> On Sun, Dec 28, 2008 at 13:42, Jon Harrop <jon at ffconsultancy.com> wrote:
> > Previous generation languages like OCaml compile this into a completely
> > generic representation where polymorphism is handled at run-time.
> > Consequently, even though the polymorphism is buried in the fold function
> > (not visible at all in our "sum" function) it still incurs massive
> > performance degradation.
> >
> > JIT compilation makes it easy to avoid the cost of polymorphism by
> > generating code for each permutation of type variables that a definition
> > is used with. That immediately removes the cost of polymorphism because
> > we get a version of fold specialized for float arrays.
>
> I'm fairly certain that MLton does this during static compilation.

Yes but it requires whole program analysis which obviates dynamic loading and 
incremental compilation and that, in turn, greatly limits the utility of the 
compiler.

-- 
Dr Jon Harrop, Flying Frog Consultancy Ltd.
http://www.ffconsultancy.com/?e



More information about the llvm-dev mailing list