Erlang JIT and loaded code

Vitor Rocha vitor.vrs@REDACTED
Tue Apr 26 02:06:33 CEST 2022


Thanks for the answer, Lukas.

Giving a bit more context: I'm doing a benchmarking research on Erlang JIT,
similar to what ErLLVM did.

I managed to get the code size (I suppose) from internal structures:

   - erl_module_instance->code_length (for emulator and asm)
   - erl_module_instance->hipe_code->text_segment_size (for HiPE and ErLLVM)

Does that make sense or are those values unrelated?

Em seg., 25 de abr. de 2022 às 06:13, Lukas Larsson <lukas@REDACTED>
escreveu:

> 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
>>
>

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


More information about the erlang-questions mailing list