compiling to python byte codes

greg greg at cosc.canterbury.ac.nz
Sun Sep 5 22:44:33 EDT 2004


Maurice LING wrote:
> Probably my question should be phrased as, given what x86/PPC processors 
> are register-based (even after more than a decade from the publication 
> of the book "Stack Machines - the new wave") and there isn't much 
> examples of stack-based processors, why is there a difference?

If you're implementing a machine in hardware, access to
registers is much faster than access to memory. Since the
current trend in hardware design seems to be "as fast as
possible, whatever it takes", today's architectures are
increasingly register-based.

But with an interpreter, things are very different. The
"registers" of the VM probably aren't going to be real
registers, but memory locations. Even if you do manage to
keep them in real registers, the time spent accessing them
is going to be small compared to the time spent fetching
instructions, decoding them and figuring out what operands
they refer to, so the speed advantage would be quite minimal.

Given that, and the fact that stack architectures are much
easier to generate code for, it's not surprising that most
VMs tend to have stack architectures.

Greg





More information about the Python-list mailing list