4 ms·
I recall from my days hacking away on the BEAM (the de facto Erlang VM) that it loads code as directly threaded to improve performance. The BEAM loads whole mo
by sigwinch28 6y ago
I recall from my days hacking away on the BEAM (the de facto Erlang VM) that it loads code as directly threaded to improve performance.
The BEAM loads whole modules at a time, and as part of this process it means that instruction names in the bytecode are essentially replaced with the address of the code which interpret that instruction.
This means that once loading is complete there's no big switch statement to visit: the VM jumps directly to the part of its own code which interprets that instruction.
- sigwinch28 6y agoOh wow, my brain was cooked when I wrote that. The BEAM loads bytecode into memory and then goes through the loaded code to directly thread it. It's not an inherent consequence of code loading in general. https://en.wikipedia.org/wiki/Threaded_code#Direct_threading https://en.wikipedia.org/wiki/Threaded_code#Direct_threading