Some of the opcodes used by the Erlang VM have an obvious meaning, but others are mysterious and they seem to differ each other by subtle differences.
As an example:
call_ext
and call_ext_only
opcodes?allocate
and the allocate_zero
opcodes?test_heap
opcode used for? Is it some kind of check or it actually allocate some space in the heap? It is somehow linked to the usage of tuples and lists, but in which terms?allocate
stands for?If anyone could point me to any piece of documentation available for the opcodes used by the Erlang VM or if he could at least enlighten me on the above points, it would be very appreciated.
As stated in a similar SO-question and the erlang-documentation:
Note that the format of assembler files is not documented, and may change between releases - this option is primarily for internal debugging use.
If you realy want to know what's happening, it seems you have to track it down in the source-code. Most of the work is done in erts/emulator/beam/beam_emu.c (I've looked into otp_src_R15B02):
call_ext
: set the continuation pointer to current instruction+2 and dispatch/ call external. call_ext_only
: dont touch CP, just dispatch. (~line 1520)allocate_zero
also initializes it to 0x00
(~line 334).test_heap
: Check if Nh words of heap are available; if not, do a garbage collection. (~line 390)allocate(StackNeeded, NumberOfRegistersToPreserve)
(~line 316)The whole file is a compound of #defines and gotos, some macros are defined inside ops.tab in the same folder. I'm not an expert in erlang-asm either and might have missed something. Please keep that in mind and cross-check my statements before you start to work with them.
To quote TamasNagy from the linked SO-awnser:
I'm not sure what are you trying to achieve with this, but core erlang might be a better level to do code manipulation.
Please look there for further information. Erlang have it strengths but documentation is not one of them.
regards.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With