lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


We're in the final stages of our project and doing memory
optimizations. I'm looking into trying to reduce the opcode size from
32 to 16 bits, because our code sizes are quite large (in the hundreds
of K for one of our larger classes).

Well, of course there are always tradeoffs and I'm willing to take
some CPU hit in order to get memory back. My idea is to compile our
code, see where we hit an internal limit, then add a new opcode that
overrides the limit. For example: OP_CLOSURE(A,B) becomes
OP_PUSHINT(S), OP_CLOSURE1(U).

That's an easy one; the trickier issue is that MAXSTACK must be <=
MAXARG_B; and lots of our code depends on a nice large MAXSTACK. So
question 1: can I lift this restriction purely by adding new opcodes,
or are there other dependencies I'm missing?

Also, is there an unstated dependency that MAXSTACK must be <=
MAXARG_A as well? Opcodes like OP_CALL seem to use A as a stack index.
Is it also true that MAXARG_A must be >= MAXARG_B?

Any insight is appreciated!
paul