Re: Erlang JIT and loaded code
Lukas Larsson <[email protected]> Mon, 25 Apr 2022 11:13:14 +0200
| Newsgroups | gmane.comp.lang.erlang.general |
|---|---|
| Message-ID | <CAP3zBqPcgW9aeKBurk4Nw8WZ02k-EaaxaTT7U_vG7yX4doub3Q@mail.gmail.com> |
--0000000000001dbb0a05dd76fd9c Content-Type: text/plain; charset="UTF-8" Hello! On Tue, Apr 19, 2022 at 7:17 AM Vitor Rocha <[email protected]> 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 > --0000000000001dbb0a05dd76fd9c Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable <div dir=3D"ltr"><div>Hello!</div><br><div class=3D"gmail_quote"><div dir= =3D"ltr" class=3D"gmail_attr">On Tue, Apr 19, 2022 at 7:17 AM Vitor Rocha &= lt;<a href=3D"mailto:[email protected]">[email protected]</a>> wrote= :<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.= 8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir=3D"lt= r"><div>(1) how do I know if my code is actually being executed as interpre= ted or native?</div></div></blockquote><div><br></div><div>All code loaded = from .beam files are run natively if the VM supports JIT compilation.</div>= <div>=C2=A0</div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px = 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir= =3D"ltr"><div>(2) If I compile a module inside Erlang's shell, using th= e `c:c/1` function, is the module going to be compiled to native too? Will = its execution be switched to native?<br></div></div></blockquote><div><br><= /div><div>There is no=C2=A0difference in how it is compiled, it will always= be translated into native code when loaded.</div><div>=C2=A0</div><blockqu= ote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px= solid rgb(204,204,204);padding-left:1ex"><div dir=3D"ltr"><div></div><div>= (3) Where is stored the generated beamasm native code? I would like to get = its size in bytes?<br></div></div></blockquote><div><br></div><div>It is st= ored in memory of the VM. You can get a file dump of the native code by pas= sing `+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.</div><div>=C2=A0</div><blockquote class=3D"gmail_quote" style=3D"m= argin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left= :1ex"><div dir=3D"ltr"><div><br></div><div>-- <br><div dir=3D"ltr"><span st= yle=3D"font-family:"trebuchet ms",sans-serif">Atenciosamente,<br>= Vitor Rocha da Silva</span><br></div></div></div> </blockquote></div></div> --0000000000001dbb0a05dd76fd9c--