[erlang-questions] Implementation of erlang binary module

Karlo Kuna kuna.prime@REDACTED
Sun Jan 22 13:44:41 CET 2017


thak you for explanation, i will have look at source but now at least i
have some orientation

On Sun, Jan 22, 2017 at 1:39 PM, Dmytro Lytovchenko <
dmytro.lytovchenko@REDACTED> wrote:

> Bifs are registered in special text file located in
> erts/emulator/beam/bif.tab, based on it an internal C array is generated:
>
> 1. bif_table which is traversed in beam_emu.c on first start (after
> init_emulator label) and erts_export_put is called on each table entry to
> populate exports table.
> 2. hash table in nbif_table in hipe_bif0.c that is some HiPE magics i am
> not familiar with.
>
> During the load time in beam_load.c function final_touch, the
> erts_export_put will be called for every export and will return existing
> export pointing at BIF instead of adding Erlang function version.
>
> 2017-01-21 15:15 GMT+01:00 Karlo Kuna <kuna.prime@REDACTED>:
>
>> would this imply that erlang runtime is choosing to call bif if present
>> instead of erlang implemented function ??? is this general case or these
>> "alternative" implementations should be registered somehow somewhere??
>>
>> and thak you for the search tip it worked
>>
>> On Sat, Jan 21, 2017 at 2:38 PM, Dmytro Lytovchenko <
>> dmytro.lytovchenko@REDACTED> wrote:
>>
>>> Standard library rarely uses dynamic loaded SO/DLL modules (so called
>>> NIFs), rather they use BIF functions, code for them is included straight
>>> into Erlang/OTP C source and follows different rules than NIF. Have a
>>> search through source C files for binary_<function name>_<arity>, with high
>>> chance you will find the C source by this name.
>>>
>>> 2017-01-21 13:27 GMT+01:00 Karlo Kuna <kuna.prime@REDACTED>:
>>>
>>>> I was wandering how is standard module "binary" implemented
>>>> i am looking at source and i see that most functions are nifs (this
>>>> makes sense),
>>>> but there is no "-on_load" directive and i can't find c implementation.
>>>> Please can someone explain to me how is this module using nifs without
>>>> -on_load directive and also can tell me where is c implementation??
>>>>
>>>>
>>>> _______________________________________________
>>>> erlang-questions mailing list
>>>> erlang-questions@REDACTED
>>>> http://erlang.org/mailman/listinfo/erlang-questions
>>>>
>>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20170122/5a5e649a/attachment.htm>


More information about the erlang-questions mailing list