[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: NaN trick
- From: Miles Bader <miles@...>
- Date: Fri, 8 Jul 2011 17:20:48 +0900
On Fri, Jul 8, 2011 at 4:54 PM, Axel Kittenberger <axkibe@gmail.com> wrote:
> 6+1 (for NIL; BOOLEAN and NONE) = 7, 3 bit suffice ;-)
Lua 5.2 also has "light C function" (LUA_TLCF), which I think is an
immediate-only pointer type, so that needs its own immediate tag.
Also, as Patrick pointed out, there are 3 internal object types that
might need their own tags with pointers (LUA_TPROTO, LUA_TUPVAL,
LUA_TDEADKEY), but I'm a bit fuzzy on exactly what constraints they
have.
Luckily, though, all the "Lua heap object" types (string, table, function,
userdata, thread) can use one immediate tag value, with a separate tag
field in the Lua object header to distinguish them.
So the immediate tags might be:
LUA_IMM_TNUMBER 0
LUA_IMM_TMISCVAL 1 /* NIL, BOOL, NONE, using lower imm bits */
LUA_IMM_THEAPVAL 2 /* TABLE, STRING, FUNCTION, USERDATA, etc */
LUA_IMM_TLIGHTUSERDATA 3
LUA_IMM_TLIGHTCFUNC 4
...
And the tags in heap object headers:
LUA_HEAP_TTABLE 0
LUA_HEAP_TSTRING 1
LUA_HEAP_TFUNCTION 2
LUA_HEAP_TUSERDATA 3
LUA_HEAP_TTHREAD 4
...
I dunno offhand where TPROTO, UPVAL, and DEADKEY should go, but
there seems to be room either way...
-Miles
--
Cat is power. Cat is peace.