On Fri, May 24, 2002 at 09:48:13AM -0400, Melvin Smith wrote: > I hate debugging stack operations. Its one of the hardest bug's to spot > in my limited experience. For this reason I'm glad that Parrot allows me > to think in registers, not stack locations. Given, everything I've said > relates to a human generating or debugging instructions. Some would > the compilers are generating the code, so it shouldn't matter about > notation. > In reality it does; when is the last time you heard of a compiler gaining > 100% perfection in correctly generated, optimized code? It's always ongoing > work, in which people sit and debug what their compiler just generated in > order to go back and refactor.
Right, writing a compiler is always ongoing work. But in my experience, for a stack-based VM, the bytecode generator is something you write once, and hardly ever modify afterwards. So, you may have a few bugs initially, but once they are fixed, you rarely need to read the generated bytecode anymore. Instead, you look at the intermediate code, which is a lot more readable (in particular, a variable typically still has a symbolic name, instead of just a number standing for either a position in the stack or a register -- depending on the VM style). Another point is that it is more work to write a bytecode generator for a register VM. Indeed, you then have to perform register allocation, to handle the case when there is not enough registers to fit all the intermediate values, to keep track of what registers are live to save them across function calls, ... -- Jerome