[erlang-questions] Understanding BEAM bytecode [Code section]

Gabriel Rivas <>
Fri Sep 15 15:15:32 CEST 2017


Hello Bjorn,

I was not aware of it, I am new to Erlang. I started doing development on
Elixir but
I would like to learn and understand what Erlang does under the hood.

Thanks for the tip, it is very useful.

Gabriel

On Fri, Sep 15, 2017 at 4:46 AM, Björn Gustavsson <> wrote:

> On Thu, Sep 14, 2017 at 11:16 PM, Gabriel Rivas
> <> wrote:
>
> >
> > But I still don't see how the subtraction happens. Can anybody shed some
> > light
> > on the internals of calling a BIF in the erlang module?
>
> Not sure that you are aware of it, but there is a disassembler that is
> used like this:
>
>   erts_debug:df(ex3).
>
> It creates a file named ex3.dis. In it, you can see that the loaded
> code looks this:
>
> 00007F9C8F953AD0: i_func_info_IaaI 0 ex3 sub 2
> 00007F9C8F953AF8: i_minus_jIxxd j(0000000000000000) 2 x(0) x(1) x(0)
> 00007F9C8F953B28: return
>
> In this particular case, you can see that the BIF call has been
> translated to a special instruction.
>
> The translations that the loader makes can be found in
> erts/emulator/beam/ops.tab.
>
> /Bjorn
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20170915/aa506058/attachment.html>


More information about the erlang-questions mailing list