[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Lua 5.0.1: Experimental reference counted garbage collection
- From: "Joshua Jensen" <jjensen@...>
- Date: Sat, 24 Jan 2004 00:20:25 -0700
I'd hoped to have this up a couple days ago, but I wasn't as quick as I
would have liked. In any case, here is my current implementation of a
reference counted garbage collector for Lua 5.0.1. It is built upon the
mark-sweep garbage collector, because cycles aren't handled by the ref
counted GC. I find I don't usually have cycles, so it isn't much of an
issue for me.
Some information on the changes:
* Note the setnilvalue2n, setsvalue2n, etc. These are used when setting the
value for the first time to a new object.
* Some functions now expose a lua_State *L when they didn't in the past.
This is because the lua_State is required for possible object destruction
when releasing a reference.
* There is a #define LUA_REFCOUNT 1 in lua.h. It actually isn't possible,
at this time, to completely turn off the ref counting.
* lapi.c: A bunch of functions have been updated to run setnilvalue on the
appropriate stack entries, instead of just incrementing or decrementing
L->top.
* lgc.c: I'm not convinced the ref counted collection is used right.
* lobject.c/h: The bulk of the ref counting is in these two files.
* ltable.c: luaH_remove is not correct when the node position is equal to
the main position (I think).
The best way to see all the updates is to diff it against the Lua 5.0.1
codebase.
The code is stored in a Subversion
(http://subversion.tigris.org/project_packages.html) database. It may be
retrieved with the command:
svn co svn://24.2.105.59/root/luarc
Anyway, comments are welcome, good or bad.
Josh