3 ms·
Not quite. If you're dispatching based on a sequence of opcodes, that's indirect threading. Direct threading uses a sequence of pointers to the opcode implement
by cwp 18y ago
Not quite. If you're dispatching based on a sequence of opcodes, that's indirect threading. Direct threading uses a sequence of pointers to the opcode implementations, and jumps directly to them. Also, one of the key benefits of threaded interpreters is that each opcode implementation ends by decoding the next instruction and jumping to its implementation. This duplication of code gives the processor more context for branch prediction, and can lead to fewer pipeline stalls. With a switch statement, the decoding and branching all happens at the top of the loop.