BEAM documentation (was Re: Packages in Erlang...)

James Hague <>
Mon Sep 8 15:39:35 CEST 2003


Vlad Dumitrescu wrote:
>That would be interesting, but you still need
>something running the Erlang code that runs
>the new BEAM VM? Or does the bootstrapping
>trick work in this case too? Doesn't one 
>need machine code generation for that?

Yes, it would need to generate machine code as a final step.  The more I
think about it, the more similarities I see between implementing a Forth
compiler and the BEAM emulator.  I'm not talking about RPN and such--BEAM is
register based--but how relatively easy it is to generate code when you are
specializing it for a particular abstract machine and not a full-fledged
C-like language.

An equally interesting project would be be to write a BEAM emulator using
one of the modern, machine code generating Forths that have become standard
(here's an example: http://www.mpeltd.demon.co.uk/pfwvfx.htm).  Essentially
the main loop of the emulator, the one that's reliant on the gcc "address of
label" extension, is how a Forth with tail-call support works.

For these paths to be opened up, I'd like to see two things happen:

1. Decent documentation of the BEAM architecture and instruction set.
2. Move most of the code from the "beam_load.c" module to the Erlang
compiler.  This is the module that replaces generic BEAM instructions with
specialized instructions.  This code would be much cleaner in Erlang than in
C, and it would also simplify the emulator (beam_load.c is the second
largest module in the emulator).



More information about the erlang-questions mailing list