From 0c8f5fc2fdcadc8fe6e89c32bf3a1f7456328899 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Thu, 26 Jun 2008 16:42:45 -0300 Subject: simplification in the handling of finalizers: no more 'tmudata' list + no more GCSsweeptmu collector's state --- lstate.h | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) (limited to 'lstate.h') diff --git a/lstate.h b/lstate.h index 20eb8804..dec27d24 100644 --- a/lstate.h +++ b/lstate.h @@ -1,5 +1,5 @@ /* -** $Id: lstate.h,v 2.32 2008/02/19 18:55:09 roberto Exp roberto $ +** $Id: lstate.h,v 2.33 2008/06/23 16:51:08 roberto Exp roberto $ ** Global State ** See Copyright Notice in lua.h */ @@ -14,6 +14,32 @@ #include "lzio.h" +/* + +** Some notes about garbage-collected objects: All objects in Lua must +** be kept somehow accessible until being freed. +** +** Lua keeps most objects linked in list g->rootgc. The link uses field +** 'next' of the CommonHeader. +** +** Strings are kept in several lists headed by the array g->strt.hash. +** +** Open upvalues are not subject to independent garbage collection. They +** are collected together with their respective threads. Lua keeps a +** double-linked list with all open upvalues (g->uvhead) so that it can +** mark objects referred by them. (They are always gray, so they must +** be remarked in the atomic step. Usually their contents would be marked +** when traversing the respective threads, but the thread may already be +** dead, while the upvalue is still accessible through closures.) +** +** Userdata with finalizers are kept in the list g->rootgc, but after +** the mainthread, which should be otherwise the last element in the +** list, as it was the first one inserted there. +** +** The list g->tobefnz links all userdata being finalized. + +*/ + struct lua_longjmp; /* defined in ldo.c */ @@ -86,8 +112,7 @@ typedef struct global_State { GCObject *weak; /* list of tables with weak values */ GCObject *ephemeron; /* list of ephemeron tables (weak keys) */ GCObject *allweak; /* list of all-weak tables */ - GCObject *tmudata; /* list of userdata with finalizers */ - GCObject *tobefnz; /* last element of list of userdata to be GC */ + GCObject *tobefnz; /* list of userdata to be GC */ Mbuffer buff; /* temporary buffer for string concatentation */ lu_mem GCthreshold; lu_mem totalbytes; /* number of bytes currently allocated */ -- cgit v1.2.3-55-g6feb