[racket] Compiling C to bytecode
At Mon, 16 Aug 2010 17:06:13 +0900, Michael Gummelt wrote:
> I'm looking over compiler collection that implements a Racket->C compiler.
> It looks like it uses a set of racket structs labeled vm:* as the virtual
> machine representation, and then compiles these to C. However, the main
> racket compiler uses a different bytecode representation, implemented in C,
> that runs on the racket VM. Why are there two different bytecode
> representations? Isn't it a duplicated effort to have a different
> intermediate representation when compiling to C? Why not first compile to
> the main racket bytecode, and then compile that to C?
The Racket->C compiler is from a different era. When it was written,
the bytecode compiler built into Racket was a simple translation of the
source program into bytecode format, and the bytecode was always
interpreted. The Racket->C compiler was our first attempt at
optimization and translation to native code.
It has turned out to work better to improve the bytecode compiler that
is built into Racket and add a JIT compiler to native code.
The Racket->C compiler is still available mainly for backward
compatibility, because some old code might use the `compiler/cffi' or
otherwise rely on the Racket->C compiler. It's probably about time to
get rid of the Racket->C compiler, though.