lua-users home
lua-l archive

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


With some structural re-arrangement I was able to get the table entry size
down on PowerPC despite the fact that unaligned doubles are a very bad thing
(or so my local performance experts tell me). One needs the value to be a
TObject but the key can be packed in around it:

    #define TObjectHeader Value value; lu_byte tt

    typedef struct lua_TObject {
        TObjectHeader;
    } TObject;

    typedef union Node {
        TObject i_val;
        struct {
            TObjectHeader;      /* Should match layout of i_val portion. */
            lu_byte tt_key;
            union Node *next;   /* For chaining */
            Value v_key;
        };
    } Node;

This requires changes to the code that accesses the keys, but there aren't
too many and they can all be run through macros to hide differences in
implementation. The net effect is to take the properly aligned size down
from 40 bytes per node to 24 bytes per node.

Array entries still cost 16 bytes when properly aligned and I don't see a
good way to avoid that without major changes in the implementation.

Mark