Remix.run Logo
WalterBright 5 hours ago

> there's probably a reason that hardly any other systems use a stack-based architecture

I don't know about other backend guys, but I disliked the stack architecture because it just incompatible with enregistering variables, register allocation by live range analysis, common subexpression elimination, etc.

adrian_b an hour ago | parent [-]

There are software workarounds for some of those and very simple hardware workarounds for the others. In a stack-based architecture there should also be some directly-addressable registers for storing long-lived temporary variables. Most stack-based architectures included some set of stack shuffling operations that solved the problem of common subexpression elimination.

The real disadvantage is that the stack operations share the output operand, which introduces a resource dependency between otherwise independent operations, which prevents their concurrent execution.

There are hardware workarounds even for this, but the hardware would become much more complex, which is unlikely to be worthwhile.