Erlang JIT and loaded code

Lukas Larsson lukas@REDACTED
Mon Apr 25 11:13:14 CEST 2022


Hello!

On Tue, Apr 19, 2022 at 7:17 AM Vitor Rocha <vitor.vrs@REDACTED> wrote:

> (1) how do I know if my code is actually being executed as interpreted or
> native?
>

All code loaded from .beam files are run natively if the VM supports JIT
compilation.


> (2) If I compile a module inside Erlang's shell, using the `c:c/1`
> function, is the module going to be compiled to native too? Will its
> execution be switched to native?
>

There is no difference in how it is compiled, it will always be translated
into native code when loaded.


> (3) Where is stored the generated beamasm native code? I would like to get
> its size in bytes?
>

It is stored in memory of the VM. You can get a file dump of the native
code by passing `+JDdump true` when starting `erl`. There is no way to get
the loaded memory size of a single module, but you can get a relatively
close value by checking what `erlang:memory(code)` returns before and after
the module is loaded.


>
> --
> Atenciosamente,
> Vitor Rocha da Silva
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20220425/d2222168/attachment.htm>


More information about the erlang-questions mailing list