[erlang-questions] : Design of the Erlang VM
Thu Aug 9 09:20:13 CEST 2007
No, they are not C function calls. C function calls push
the arguments (that may come not only from the calling
code, but also from other places, nevertheless there
is explicit code to place them ---) on the processor stack,
pushes the return addresss on the processor stack and then
jumps to the function address. When the function returns
the return instruction pops the return address from the
stack and jumps back to where it came from. Then the
calling code restores the stack pointer to remove the
call arguments from the processor stack.
BEAM instructions are the instruction word followed by
zero or more operand words. The instruction word is
an address to the processor instruction sequence that
implements the BEAM instruction, as Bjorn said below.
The BEAM instructions are just straight processor code
that do not expect arguments on the processor stack
and do not end in a processor return instruction.
The BEAM instructions themselves increment the BEAM
instruction pointer and pick up operand words into
processor registers. They end by reading the next
instruction and since it is a jump address - jump
to that address and then BEAM is performing the next
If the BEAM instruction is a (conditional) jump or call
et.al, the instruction just sets the BEAM instruction
pointer to point to the next BEAM instruction to
actually perform, reads it and jumps.
So there is no call setup overhead per instruction.
On Wed, Aug 08, 2007 at 08:03:46PM +0100, Joel Reymont wrote:
> 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.
> Is there significant overhead of function call setup per instruction?
> Thanks, Joel
> erlang-questions mailing list
/ Raimo Niskanen, Erlang/OTP, Ericsson AB
More information about the erlang-questions