[erlang-questions] Design of the Erlang VM

Damien Morton dmorton@REDACTED
Thu Aug 9 08:22:54 CEST 2007


Quite a few years back, I did an analysis of Python bytecode execution 
traces and the main interpreter loop.

It turns out that there are some sequences of bytecodes that occur more 
frequently than others, and that you can structure the main interpreter 
loop so that common traces will result in straight through execution, 
that is, you test to see if the next instruction is the same as for the 
following code block, and either fall through or jump to the appropriate 
label.

In my case I took statistics on bytecode sequences of length 4 and 
applied simulated annealing to produce a ordering of bytecodes that 
minimised the need for jumps, though a good layout can me made by hand. 
The result was a small but measurable increase in performance.

Might the same technique be applicable to the Erlang VM.
> Joel Reymont <joelr1@REDACTED> writes:
>
>   
>> On Aug 8, 2007, at 6:26 AM, Bjorn Gustavsson wrote:
>>
>>     
>>> The first word in each instruction points to the executable C code
>>> for the instruction. That first instruction word is followed by
>>> zero or more operand words.
>>>       
>> Would it be right to say that Erlang VM instructions are C function
>> calls? This is my understanding of the above.
>>     
>
> No.
>
> We use the "first-class label" in feature in GCC. All instructions
> are in the same huge function (process_main()). The addresses are
> address to labels within that function. Each instruction is responsible
> for picking up the address for the C code for the next instruction and
> *jump* to it.
>
> We use an old plain switch statement if the emulator is compiled with a C compiler
> that doesn't support first-class labels.
>
> /Bjorn
>   




More information about the erlang-questions mailing list