• Damien George's avatar
    py: Compress load-int, load-fast, store-fast, unop, binop bytecodes. · 8456cc01
    Damien George authored
    There is a lot potential in compress bytecodes and make more use of the
    coding space.  This patch introduces "multi" bytecodes which have their
    argument included in the bytecode (by addition).
    UNARY_OP and BINARY_OP now no longer take a 1 byte argument for the
    opcode.  Rather, the opcode is included in the first byte itself.
    LOAD_FAST_[0,1,2] and STORE_FAST_[0,1,2] are removed in favour of their
    multi versions, which can take an argument between 0 and 15 inclusive.
    The majority of LOAD_FAST/STORE_FAST codes fit in this range and so this
    saves a byte for each of these.
    LOAD_CONST_SMALL_INT_MULTI is used to load small ints between -16 and 47
    inclusive.  Such ints are quite common and now only need 1 byte to
    store, and now have much faster decoding.
    In all this patch saves about 2% RAM for typically bytecode (1.8% on
    64-bit test, 2.5% on pyboard test).  It also reduces the binary size
    (because bytecodes are simplified) and doesn't harm performance.