[Python-ideas] Register based interpreter

Greg Ewing greg.ewing at canterbury.ac.nz
Fri Feb 20 22:59:50 CET 2009


Antoine Pitrou wrote:

> If bytecode dispatch were not a problem, I wonder how enabling computed gotos on
> the py3k branch could yield up to a 15% overall speedup on pybench :-)

Perhaps there is room for a hybrid approach where you
take sequences of instructions such as

    LOAD_LOCAL x
    LOAD_LOCAL y
    BINARY_ADD
    STORE_GLOBAL z

and turn them into 3-operand macroinstructions

    TRINARY_ADD LOCAL(x), LOCAL(y), GLOBAL(z)

This would actually do all the same pushing and popping
as before (at least conceptually), but it would reduce the
number of bytecodes being executed, and therefore the number
of unpredictable branches, from 4 to 1.

So it would be kind of like a register-based instruction
set, except that there aren't any registers, so there
wouldn't be any problem with managing refcounts.

(BTW, calling them "bytecodes" might become something of
a misnomer -- they're going to be more like "longcodes".:-)

-- 
Greg



More information about the Python-ideas mailing list