This portion will go over the virtual register allocator in SquirrelFish. Many intermediate languages use a virtual register instead of a physical hardware register since executing a register based instruction set is faster than a stack based machine. Much of this improvement comes from not having to execute stack manipulation instructions, thus reducing bytecode dispatch. If you want an in-depth analysis, checkout Virtual Machine Showdown: Stack versus Registers.
Another thing I found out. If we go back to the hello world example from the previous post, 14 callee registers were allocated. However, the debug output only showed 5 registers were used. The difference is that upon making a function call, 8 registers are allocated for call frame variables. One additional register is used for the function call's argument, bringing the grand total up to 14 registers.
m_codeBlock->m_numCalleeRegisters = max<int>(m_codeBlock->m_numCalleeRegisters, m_calleeRegisters.size());
// Reclaim free register IDs.
while (m_calleeRegisters.size() && !m_calleeRegisters.last().refCount())
RegisterID* result = newRegister();