Re:How the CPython compiler works
by sigwinch28 on Thursday September 24, 2020 @02:39PM
(#24581975)
Oh 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
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.