8 ms·
> To solve [forward branches], those bytecodes would push information about how the branch destination address shall be fixed up into a late-patch buffer. This
by russellsprouts 3y ago
> To solve [forward branches], those bytecodes would push information about how the branch destination address shall be fixed up into a late-patch buffer.
This reminds me of how Forth `if` and `then` can be compiled in a single pass -- `if` writes the branch instruction and pushes the current instruction pointer to the stack, and `then` pops it and patches the instruction to point to the current instruction pointer.
- sillycross 3y agoThat's an interesting approach :) Though it only works if the control flow in the language is exactly "paired" (no continue/break, no goto, etc), I guess?