3 ms·
> Another advantage to that is that it avoids the branching of the while loop in the interpreter that iterates over the AST Huh? A bytecode interpreter still e
by epcoa 2y ago
> Another advantage to that is that it avoids the branching of the while loop in the interpreter that iterates over the AST
Huh? A bytecode interpreter still ends up branching based on the decoded value of the byte codes. The VM bytecodes are not directly executed by the CPU (at least not usually, Jazelle and some older P-code stuff being rare exceptions).
This is what it looks like for the example being discussed ("a massive switch statement"): https://github.com/sqlite/sqlite/blob/b11daa50f9ea11c332bb5913a071c5a0fd6c9993/src/vdbe.c#L975 https://github.com/sqlite/sqlite/blob/b11daa50f9ea11c332bb59...
Perhaps confusing bytecode generation and interpretation with JIT? JIT is often paired with a bytecode but neither is dependent on the other.
- rhdunn 2y agoThe parent mentioned avoiding the dispatch of a virtual function call used to evaluate the AST/bytecode so I was assuming it was a minimal JIT instead of running the resulting bytecode in an interprative loop. But yes, if you are interpreting the intermediate VM bytecode you will still have a switch or dispatch branch when evaluating each instruction.