LARA

Treating Registers as Stack

One approach (works with sufficiently many registers, e.g. 15 or 31):

  • treat registers as a stack of bounded depth
  • keep at compile time index i of current stack position
    • if position is i, we treat Reg_i (the i-th resiter) as the top of stack

Observe: even in stack-based code generation, we could compute statically the depth of operand stack after each instruction!

  • JVM requires that the bytecode for procedure leaves the stack the same as at program entry