[erlang-questions] Fwd: Is there a good source for documentation on BEAM?

Erik Søe Sørensen <>
Thu May 10 22:05:12 CEST 2012


I began writing about the instruction set and possibly binary format at
some point, but got sidetracked by trying to explain "why isn't this
documented, and is that a good or a bad thing?"
(I have a bit of text and graphics, though, which perhaps I ought to
publish.)

One interesting thing came out of that effort, though: I noticed that
- there is no tail-call version of the call_fun (function object
application) instruction
- even so, TCO still works in beam as it should
- the reason for this is that a tail-call version exists in the *internal*
version of the instruction set, which is introduced by rewriting the
sequence "call_fun; deallocate; return" (iirc)
- Erjang had, of course, missed this the first time around, so I corrected
it once I'd found out.

I've been wondering whether this special case was caught in your
description of beam...
Of course, what I should have been wondering is whether the JS interpreter
had got it right :-)

That kind of irregularity is probably not unrelated to the unpublishedness
of the format.
On the other hand, this is one gotcha that affects not only would-be
producers of beam code (which is probably the harder part to get right,
when you don't know which invariants you have to maintain in the produced
code), but it also affects beam consumers (which is in some ways easier, at
least when you can ignore everything GC-related as it was the case with
Erjang) which have to do the same kind of rewrite.

2012/5/7 Joe Armstrong <>

> ---------- Forwarded message ----------
> From: Joe Armstrong <>
> Date: Mon, May 7, 2012 at 10:46 AM
> Subject: Re: [erlang-questions] Is there a good source for
> documentation on BEAM?
> To: Jonathan Coveney <>
>
>
> Hi,
>
> I did start writing a description but it's not very complete.
>
> This is on my list of things-to-do-one-day-when-you-get-time
>
>   See http://dl.dropbox.com/u/4764922/beam.pdf
>
> If there is any interest I could up the priority :-)
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20120510/8fc6c22c/attachment.html>


More information about the erlang-questions mailing list