[LLVMdev] Parametric polymorphism

DeLesley Hutchins delesley.spambox at googlemail.com
Wed Feb 18 14:29:41 PST 2009


>> Try implementing a generic complex number class in Java, and watch the
>> two-order-of-magnitude drop in performance on scientific code.
>
> Amen. I haven't proven it with a working HLVM yet but I believe LLVM will make
> it possible (even easy?) to generate extremely performant code from heavily
> abstracted high-level source.

Partial evaluation is a fantastic way to completely eliminate the overhead
of using very abstract, high-level interfaces.  Every computation on static
data can be eliminated by a partial evaluator, and in most cases, all of
the overhead of a high-level interface involves information that is statically
known.

Partial evaluation is also old technology and very simple to implement;
I am continually amazed that it hasn't been more widely applied.
I think the biggest issue is that partial evaluation works best for programs
that are free of side-effects.  Most imperative programs do a lot of their
computation by mutating the heap, and heap mutations are a lot harder
to track.

In any case, combining partial evaluation in a HLVM with the optimization
passes provided by LLVM should yield blazingly fast code.  The goal of
making Java or C# ``as fast as C'' has always seemed somewhat
uninspiring to me.  C is actually rather hard to optimize; a high-level DSL
should easily be able to outperform C on any task within its particular
domain.

  -DeLesley



More information about the llvm-dev mailing list