diff options
Diffstat (limited to 'lstate.h')
-rw-r--r-- | lstate.h | 31 |
1 files changed, 28 insertions, 3 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lstate.h,v 2.32 2008/02/19 18:55:09 roberto Exp roberto $ | 2 | ** $Id: lstate.h,v 2.33 2008/06/23 16:51:08 roberto Exp roberto $ |
3 | ** Global State | 3 | ** Global State |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -14,6 +14,32 @@ | |||
14 | #include "lzio.h" | 14 | #include "lzio.h" |
15 | 15 | ||
16 | 16 | ||
17 | /* | ||
18 | |||
19 | ** Some notes about garbage-collected objects: All objects in Lua must | ||
20 | ** be kept somehow accessible until being freed. | ||
21 | ** | ||
22 | ** Lua keeps most objects linked in list g->rootgc. The link uses field | ||
23 | ** 'next' of the CommonHeader. | ||
24 | ** | ||
25 | ** Strings are kept in several lists headed by the array g->strt.hash. | ||
26 | ** | ||
27 | ** Open upvalues are not subject to independent garbage collection. They | ||
28 | ** are collected together with their respective threads. Lua keeps a | ||
29 | ** double-linked list with all open upvalues (g->uvhead) so that it can | ||
30 | ** mark objects referred by them. (They are always gray, so they must | ||
31 | ** be remarked in the atomic step. Usually their contents would be marked | ||
32 | ** when traversing the respective threads, but the thread may already be | ||
33 | ** dead, while the upvalue is still accessible through closures.) | ||
34 | ** | ||
35 | ** Userdata with finalizers are kept in the list g->rootgc, but after | ||
36 | ** the mainthread, which should be otherwise the last element in the | ||
37 | ** list, as it was the first one inserted there. | ||
38 | ** | ||
39 | ** The list g->tobefnz links all userdata being finalized. | ||
40 | |||
41 | */ | ||
42 | |||
17 | 43 | ||
18 | struct lua_longjmp; /* defined in ldo.c */ | 44 | struct lua_longjmp; /* defined in ldo.c */ |
19 | 45 | ||
@@ -86,8 +112,7 @@ typedef struct global_State { | |||
86 | GCObject *weak; /* list of tables with weak values */ | 112 | GCObject *weak; /* list of tables with weak values */ |
87 | GCObject *ephemeron; /* list of ephemeron tables (weak keys) */ | 113 | GCObject *ephemeron; /* list of ephemeron tables (weak keys) */ |
88 | GCObject *allweak; /* list of all-weak tables */ | 114 | GCObject *allweak; /* list of all-weak tables */ |
89 | GCObject *tmudata; /* list of userdata with finalizers */ | 115 | GCObject *tobefnz; /* list of userdata to be GC */ |
90 | GCObject *tobefnz; /* last element of list of userdata to be GC */ | ||
91 | Mbuffer buff; /* temporary buffer for string concatentation */ | 116 | Mbuffer buff; /* temporary buffer for string concatentation */ |
92 | lu_mem GCthreshold; | 117 | lu_mem GCthreshold; |
93 | lu_mem totalbytes; /* number of bytes currently allocated */ | 118 | lu_mem totalbytes; /* number of bytes currently allocated */ |