Erlang bytecodes and/or VM description?

Per Gustafsson <>
Wed Jun 7 00:33:33 CEST 2006


Andrew Lentvorski wrote:

> Richard A. O'Keefe wrote:
>
>>     You're probably underestimating your abilities. It just takes
>>     imagination and dedication.
>>     
>> What it takes is *BACKGROUND*.  If you have a reasonably good idea of
>> how something like this OUGHT to work, then you can probably figure
>> things out.  But while you do so, you will curse the author for not
>> having the decency to *TELL* you what he knew and you have to 
>> rediscover.
>
>
> Ayup.  Sure, I can read code, but that shows me the trees, not the 
> forest.  It's easy to see bits, its hard to see the overview.
>
> I'm not even talking a gigantic amount of information.  A couple pages 
> on the structure of how the BEAM code is executed would be enough.  
> ie. four simple functions, the "assembly" code listing, a hex dump and 
> comments per line would be enough.  Glossing over the issues of 
> instruction scheduling, garbage collection, and message queuing would 
> be fine since they will vary implementation to implementation anyhow.
>
> Here's the current file that produces the BEAM code I am trying to dig 
> through.  It's not complicated, but even this covers enough ground to 
> be difficult to penetrate (how do the tags on the arguments work when 
> things are bytes, how do you handle labels when there are more than 
> 16, is there anything which signifies the end of function code without 
> actually decoding the code?, etc.)
>
> -module(arith).
> -export([three/0, four/0]).
>
> one() ->
>     1.
>
> two() ->
>     2.
>
> three() ->
>     one() + two().
>
> four() ->
>     two() + two().
>
>
> Sure, I'll eventually get it, but it would help to have the basics.
>
> -a
>
>
There is a quite nice description of the tag scheme used in BEAM in "A 
Staged Tag Scheme for Erlang" which is available at:

http://www.it.uu.se/research/publications/reports/2000-029/2000-029-nc.pdf

Of course this paper only describes how values are represented on the 
stack and heap, but it helped we to better understand how the BEAM 
works. The tag scheme has not changed very much since R7 which is the 
last release described in the paper.




More information about the erlang-questions mailing list