lua5.4
lstate.h
浏览该文件的文档.
1 /*
2 ** $Id: lstate.h $
3 ** Global State
4 ** See Copyright Notice in lua.h
5 */
6 
7 #ifndef lstate_h
8 #define lstate_h
9 
10 #include "lua.h"
11 
12 #include "lobject.h"
13 #include "ltm.h"
14 #include "lzio.h"
15 
16 
17 /*
18 ** Some notes about garbage-collected objects: All objects in Lua must
19 ** be kept somehow accessible until being freed, so all objects always
20 ** belong to one (and only one) of these lists, using field 'next' of
21 ** the 'CommonHeader' for the link:
22 **
23 ** 'allgc': all objects not marked for finalization;
24 ** 'finobj': all objects marked for finalization;
25 ** 'tobefnz': all objects ready to be finalized;
26 ** 'fixedgc': all objects that are not to be collected (currently
27 ** only small strings, such as reserved words).
28 **
29 ** For the generational collector, some of these lists have marks for
30 ** generations. Each mark points to the first element in the list for
31 ** that particular generation; that generation goes until the next mark.
32 **
33 ** 'allgc' -> 'survival': new objects;
34 ** 'survival' -> 'old': objects that survived one collection;
35 ** 'old1' -> 'reallyold': objects that became old in last collection;
36 ** 'reallyold' -> NULL: objects old for more than one cycle.
37 **
38 ** 'finobj' -> 'finobjsur': new objects marked for finalization;
39 ** 'finobjsur' -> 'finobjold1': survived """";
40 ** 'finobjold1' -> 'finobjrold': just old """";
41 ** 'finobjrold' -> NULL: really old """".
42 **
43 ** All lists can contain elements older than their main ages, due
44 ** to 'luaC_checkfinalizer' and 'udata2finalize', which move
45 ** objects between the normal lists and the "marked for finalization"
46 ** lists. Moreover, barriers can age young objects in young lists as
47 ** OLD0, which then become OLD1. However, a list never contains
48 ** elements younger than their main ages.
49 **
50 ** The generational collector also uses a pointer 'firstold1', which
51 ** points to the first OLD1 object in the list. It is used to optimize
52 ** 'markold'. (Potentially OLD1 objects can be anywhere between 'allgc'
53 ** and 'reallyold', but often the list has no OLD1 objects or they are
54 ** after 'old1'.) Note the difference between it and 'old1':
55 ** 'firstold1': no OLD1 objects before this point; there can be all
56 ** ages after it.
57 ** 'old1': no objects younger than OLD1 after this point.
58 */
59 
60 /*
61 ** Moreover, there is another set of lists that control gray objects.
62 ** These lists are linked by fields 'gclist'. (All objects that
63 ** can become gray have such a field. The field is not the same
64 ** in all objects, but it always has this name.) Any gray object
65 ** must belong to one of these lists, and all objects in these lists
66 ** must be gray (with two exceptions explained below):
67 **
68 ** 'gray': regular gray objects, still waiting to be visited.
69 ** 'grayagain': objects that must be revisited at the atomic phase.
70 ** That includes
71 ** - black objects got in a write barrier;
72 ** - all kinds of weak tables during propagation phase;
73 ** - all threads.
74 ** 'weak': tables with weak values to be cleared;
75 ** 'ephemeron': ephemeron tables with white->white entries;
76 ** 'allweak': tables with weak keys and/or weak values to be cleared.
77 **
78 ** The exceptions to that "gray rule" are:
79 ** - TOUCHED2 objects in generational mode stay in a gray list (because
80 ** they must be visited again at the end of the cycle), but they are
81 ** marked black because assignments to them must activate barriers (to
82 ** move them back to TOUCHED1).
83 ** - Open upvales are kept gray to avoid barriers, but they stay out
84 ** of gray lists. (They don't even have a 'gclist' field.)
85 */
86 
87 
88 
89 /*
90 ** About 'nCcalls': This count has two parts: the lower 16 bits counts
91 ** the number of recursive invocations in the C stack; the higher
92 ** 16 bits counts the number of non-yieldable calls in the stack.
93 ** (They are together so that we can change and save both with one
94 ** instruction.)
95 */
96 
97 
98 /* true if this thread does not have non-yieldable calls in the stack */
99 #define yieldable(L) (((L)->nCcalls & 0xffff0000) == 0)
100 
101 /* real number of C calls */
102 #define getCcalls(L) ((L)->nCcalls & 0xffff)
103 
104 
105 /* Increment the number of non-yieldable calls */
106 #define incnny(L) ((L)->nCcalls += 0x10000)
107 
108 /* Decrement the number of non-yieldable calls */
109 #define decnny(L) ((L)->nCcalls -= 0x10000)
110 
111 /* Non-yieldable call increment */
112 #define nyci (0x10000 | 1)
113 
114 
115 
116 
117 struct lua_longjmp; /* defined in ldo.c */
118 
119 
120 /*
121 ** Atomic type (relative to signals) to better ensure that 'lua_sethook'
122 ** is thread safe
123 */
124 #if !defined(l_signalT)
125 #include <signal.h>
126 #define l_signalT sig_atomic_t
127 #endif
128 
129 
130 /*
131 ** Extra stack space to handle TM calls and some other extras. This
132 ** space is not included in 'stack_last'. It is used only to avoid stack
133 ** checks, either because the element will be promptly popped or because
134 ** there will be a stack check soon after the push. Function frames
135 ** never use this extra space, so it does not need to be kept clean.
136 */
137 #define EXTRA_STACK 5
138 
139 
140 #define BASIC_STACK_SIZE (2*LUA_MINSTACK)
141 
142 #define stacksize(th) cast_int((th)->stack_last - (th)->stack)
143 
144 
145 /* kinds of Garbage Collection */
146 #define KGC_INC 0 /* incremental gc */
147 #define KGC_GEN 1 /* generational gc */
148 
149 
150 typedef struct stringtable {
152  int nuse; /* number of elements */
153  int size;
155 
156 
157 /*
158 ** Information about a call.
159 */
160 typedef struct CallInfo {
161  StkId func; /* function index in the stack */
162  StkId top; /* top for this function */
163  struct CallInfo *previous, *next; /* dynamic call link */
164  union {
165  struct { /* only for Lua functions */
167  volatile l_signalT trap;
168  int nextraargs; /* # of extra arguments in vararg functions */
169  } l;
170  struct { /* only for C functions */
171  lua_KFunction k; /* continuation in case of yields */
172  ptrdiff_t old_errfunc;
173  lua_KContext ctx; /* context info. in case of yields */
174  } c;
175  } u;
176  union {
177  int funcidx; /* called-function index */
178  int nyield; /* number of values yielded */
179  struct { /* info about transferred values (for call/return hooks) */
180  unsigned short ftransfer; /* offset of first value transferred */
181  unsigned short ntransfer; /* number of values transferred */
183  } u2;
184  short nresults; /* expected number of results from this function */
185  unsigned short callstatus;
187 
188 
189 /*
190 ** Bits in CallInfo status
191 */
192 #define CIST_OAH (1<<0) /* original value of 'allowhook' */
193 #define CIST_C (1<<1) /* call is running a C function */
194 #define CIST_FRESH (1<<2) /* call is on a fresh "luaV_execute" frame */
195 #define CIST_HOOKED (1<<3) /* call is running a debug hook */
196 #define CIST_YPCALL (1<<4) /* call is a yieldable protected call */
197 #define CIST_TAIL (1<<5) /* call was tail called */
198 #define CIST_HOOKYIELD (1<<6) /* last hook called yielded */
199 #define CIST_FIN (1<<7) /* call is running a finalizer */
200 #define CIST_TRAN (1<<8) /* 'ci' has transfer information */
201 #if defined(LUA_COMPAT_LT_LE)
202 #define CIST_LEQ (1<<9) /* using __lt for __le */
203 #endif
204 
205 /* active function is a Lua function */
206 #define isLua(ci) (!((ci)->callstatus & CIST_C))
207 
208 /* call is running Lua code (not a hook) */
209 #define isLuacode(ci) (!((ci)->callstatus & (CIST_C | CIST_HOOKED)))
210 
211 /* assume that CIST_OAH has offset 0 and that 'v' is strictly 0/1 */
212 #define setoah(st,v) ((st) = ((st) & ~CIST_OAH) | (v))
213 #define getoah(st) ((st) & CIST_OAH)
214 
215 
216 /*
217 ** 'global state', shared by all threads of this state
218 */
219 typedef struct global_State {
220  lua_Alloc frealloc; /* function to reallocate memory */
221  void *ud; /* auxiliary data to 'frealloc' */
222  l_mem totalbytes; /* number of bytes currently allocated - GCdebt */
223  l_mem GCdebt; /* bytes allocated not yet compensated by the collector */
224  lu_mem GCestimate; /* an estimate of the non-garbage memory in use */
225  lu_mem lastatomic; /* see function 'genstep' in file 'lgc.c' */
226  stringtable strt; /* hash table for strings */
228  TValue nilvalue; /* a nil value */
229  unsigned int seed; /* randomized seed for hashes */
231  lu_byte gcstate; /* state of garbage collector */
232  lu_byte gckind; /* kind of GC running */
233  lu_byte genminormul; /* control for minor generational collections */
234  lu_byte genmajormul; /* control for major generational collections */
235  lu_byte gcrunning; /* true if GC is running */
236  lu_byte gcemergency; /* true if this is an emergency collection */
237  lu_byte gcpause; /* size of pause between successive GCs */
238  lu_byte gcstepmul; /* GC "speed" */
239  lu_byte gcstepsize; /* (log2 of) GC granularity */
240  GCObject *allgc; /* list of all collectable objects */
241  GCObject **sweepgc; /* current position of sweep in list */
242  GCObject *finobj; /* list of collectable objects with finalizers */
243  GCObject *gray; /* list of gray objects */
244  GCObject *grayagain; /* list of objects to be traversed atomically */
245  GCObject *weak; /* list of tables with weak values */
246  GCObject *ephemeron; /* list of ephemeron tables (weak keys) */
247  GCObject *allweak; /* list of all-weak tables */
248  GCObject *tobefnz; /* list of userdata to be GC */
249  GCObject *fixedgc; /* list of objects not to be collected */
250  /* fields for generational collector */
251  GCObject *survival; /* start of objects that survived one GC cycle */
252  GCObject *old1; /* start of old1 objects */
253  GCObject *reallyold; /* objects more than one cycle old ("really old") */
254  GCObject *firstold1; /* first OLD1 object in the list (if any) */
255  GCObject *finobjsur; /* list of survival objects with finalizers */
256  GCObject *finobjold1; /* list of old1 objects with finalizers */
257  GCObject *finobjrold; /* list of really old objects with finalizers */
258  struct lua_State *twups; /* list of threads with open upvalues */
259  lua_CFunction panic; /* to be called in unprotected errors */
261  TString *memerrmsg; /* message for memory-allocation errors */
262  TString *tmname[TM_N]; /* array with tag-method names */
263  struct Table *mt[LUA_NUMTAGS]; /* metatables for basic types */
264  TString *strcache[STRCACHE_N][STRCACHE_M]; /* cache for strings in API */
265  lua_WarnFunction warnf; /* warning function */
266  void *ud_warn; /* auxiliary data to 'warnf' */
268 
269 
270 /*
271 ** 'per thread' state
272 */
273 struct lua_State {
277  unsigned short nci; /* number of items in 'ci' list */
278  StkId top; /* first free slot in the stack */
280  CallInfo *ci; /* call info for current function */
281  StkId stack_last; /* end of stack (last element + 1) */
282  StkId stack; /* stack base */
283  UpVal *openupval; /* list of open upvalues in this stack */
285  struct lua_State *twups; /* list of threads with open upvalues */
286  struct lua_longjmp *errorJmp; /* current error recover point */
287  CallInfo base_ci; /* CallInfo for first level (C calling Lua) */
288  volatile lua_Hook hook;
289  ptrdiff_t errfunc; /* current error handling function (stack index) */
290  l_uint32 nCcalls; /* number of nested (non-yieldable | C) calls */
291  int oldpc; /* last pc traced */
294  volatile l_signalT hookmask;
295 };
296 
297 
298 #define G(L) (L->l_G)
299 
300 
301 /*
302 ** Union of all collectable objects (only for conversions)
303 ** ISO C99, 6.5.2.3 p.5:
304 ** "if a union contains several structures that share a common initial
305 ** sequence [...], and if the union object currently contains one
306 ** of these structures, it is permitted to inspect the common initial
307 ** part of any of them anywhere that a declaration of the complete type
308 ** of the union is visible."
309 */
310 union GCUnion {
311  GCObject gc; /* common header */
312  struct TString ts;
313  struct Udata u;
314  union Closure cl;
315  struct Table h;
316  struct Proto p;
317  struct lua_State th; /* thread */
318  struct UpVal upv;
319 };
320 
321 
322 /*
323 ** ISO C99, 6.7.2.1 p.14:
324 ** "A pointer to a union object, suitably converted, points to each of
325 ** its members [...], and vice versa."
326 */
327 #define cast_u(o) cast(union GCUnion *, (o))
328 
329 /* macros to convert a GCObject into a specific value */
330 #define gco2ts(o) \
331  check_exp(novariant((o)->tt) == LUA_TSTRING, &((cast_u(o))->ts))
332 #define gco2u(o) check_exp((o)->tt == LUA_VUSERDATA, &((cast_u(o))->u))
333 #define gco2lcl(o) check_exp((o)->tt == LUA_VLCL, &((cast_u(o))->cl.l))
334 #define gco2ccl(o) check_exp((o)->tt == LUA_VCCL, &((cast_u(o))->cl.c))
335 #define gco2cl(o) \
336  check_exp(novariant((o)->tt) == LUA_TFUNCTION, &((cast_u(o))->cl))
337 #define gco2t(o) check_exp((o)->tt == LUA_VTABLE, &((cast_u(o))->h))
338 #define gco2p(o) check_exp((o)->tt == LUA_VPROTO, &((cast_u(o))->p))
339 #define gco2th(o) check_exp((o)->tt == LUA_VTHREAD, &((cast_u(o))->th))
340 #define gco2upv(o) check_exp((o)->tt == LUA_VUPVAL, &((cast_u(o))->upv))
341 
342 
343 /*
344 ** macro to convert a Lua object into a GCObject
345 ** (The access to 'tt' tries to ensure that 'v' is actually a Lua object.)
346 */
347 #define obj2gco(v) check_exp((v)->tt >= LUA_TSTRING, &(cast_u(v)->gc))
348 
349 
350 /* actual number of total bytes allocated */
351 #define gettotalbytes(g) cast(lu_mem, (g)->totalbytes + (g)->GCdebt)
352 
353 LUAI_FUNC void luaE_setdebt (global_State *g, l_mem debt);
360 LUAI_FUNC void luaE_warning (lua_State *L, const char *msg, int tocont);
361 LUAI_FUNC void luaE_warnerror (lua_State *L, const char *where);
362 
363 
364 #endif
365 
LUA_VTHREAD
#define LUA_VTHREAD
Definition: lobject.h:240
stringtable
Definition: lstate.h:150
luaT_init
void luaT_init(lua_State *L)
Definition: ltm.c:38
luai_makeseed
static unsigned int luai_makeseed(lua_State *L)
Definition: lstate.c:71
luaE_warnerror
void luaE_warnerror(lua_State *L, const char *where)
Definition: lstate.c:419
EXTRA_STACK
#define EXTRA_STACK
Definition: lstate.h:137
s2v
#define s2v(o)
Definition: lobject.h:150
BASIC_STACK_SIZE
#define BASIC_STACK_SIZE
Definition: lstate.h:140
resethookcount
#define resethookcount(L)
Definition: ldebug.h:21
global_State::lastatomic
lu_mem lastatomic
Definition: lstate.h:225
lua_State::basehookcount
int basehookcount
Definition: lstate.h:292
luaE_incCstack
LUAI_FUNC void luaE_incCstack(lua_State *L)
Definition: lstate.c:173
lua_assert
#define lua_assert(c)
Definition: lauxlib.h:169
setthvalue
#define setthvalue(L, obj, x)
Definition: lobject.h:246
luaS_init
void luaS_init(lua_State *L)
Definition: lstring.c:123
LUAI_FUNC
#define LUAI_FUNC
Definition: luaconf.h:307
cast
#define cast(t, exp)
Definition: llimits.h:123
CallInfo::previous
struct CallInfo * previous
Definition: lstate.h:163
CallInfo
struct CallInfo CallInfo
LUA_RIDX_LAST
#define LUA_RIDX_LAST
Definition: lua.h:86
LUA_NUMTAGS
#define LUA_NUMTAGS
Definition: lua.h:415
lstate.h
LUA_RIDX_MAINTHREAD
#define LUA_RIDX_MAINTHREAD
Definition: lua.h:84
bitmask
#define bitmask(b)
Definition: lgc.h:63
LUA_MINSTACK
#define LUA_MINSTACK
Definition: lua.h:80
LUA_OK
#define LUA_OK
Definition: lua.h:49
luai_userstatefree
#define luai_userstatefree(L, L1)
Definition: llimits.h:283
GCUnion::upv
struct UpVal upv
Definition: lstate.h:318
LX::l
lua_State l
Definition: lstate.c:37
freestack
static void freestack(lua_State *L)
Definition: lstate.c:202
api_incr_top
#define api_incr_top(L)
Definition: lapi.h:16
global_State::l_registry
TValue l_registry
Definition: lstate.h:227
global_State::old1
GCObject * old1
Definition: lstate.h:252
lua_State::status
lu_byte status
Definition: lstate.h:275
LG::g
global_State g
Definition: lstate.c:46
GCUnion::th
struct lua_State th
Definition: lstate.h:317
unlikely
#define unlikely(x)
Definition: llimits.h:162
global_State::panic
lua_CFunction panic
Definition: lstate.h:259
LUA_ERRERR
#define LUA_ERRERR
Definition: lua.h:54
ltable.h
luaC_checkGC
#define luaC_checkGC(L)
Definition: lgc.h:162
global_State::GCestimate
lu_mem GCestimate
Definition: lstate.h:224
global_State::strt
stringtable strt
Definition: lstate.h:226
lua_unlock
#define lua_unlock(L)
Definition: llimits.h:254
stringtable::hash
TString ** hash
Definition: lstate.h:151
GCUnion::p
struct Proto p
Definition: lstate.h:316
GCUnion
Definition: lstate.h:310
luaG_runerror
l_noret luaG_runerror(lua_State *L, const char *fmt,...)
Definition: ldebug.c:767
global_State::currentwhite
lu_byte currentwhite
Definition: lstate.h:230
sethvalue
#define sethvalue(L, obj, x)
Definition: lobject.h:661
GCUnion::gc
GCObject gc
Definition: lstate.h:311
global_State::firstold1
GCObject * firstold1
Definition: lstate.h:254
GCUnion::cl
union Closure cl
Definition: lstate.h:314
lua_State::CommonHeader
CommonHeader
Definition: lstate.h:274
obj2gco
#define obj2gco(v)
Definition: lstate.h:347
lu_mem
unsigned long lu_mem
Definition: llimits.h:30
global_State::genmajormul
lu_byte genmajormul
Definition: lstate.h:234
incnny
#define incnny(L)
Definition: lstate.h:106
global_State::totalbytes
l_mem totalbytes
Definition: lstate.h:222
cast_uint
#define cast_uint(i)
Definition: llimits.h:129
luaE_freethread
LUAI_FUNC void luaE_freethread(lua_State *L, lua_State *L1)
Definition: lstate.c:314
llex.h
f_luaopen
static void f_luaopen(lua_State *L, void *ud)
Definition: lstate.c:232
global_State::warnf
lua_WarnFunction warnf
Definition: lstate.h:265
ltm.h
global_State::grayagain
GCObject * grayagain
Definition: lstate.h:244
global_State::gcemergency
lu_byte gcemergency
Definition: lstate.h:236
lua_State::errfunc
ptrdiff_t errfunc
Definition: lstate.h:289
NOCLOSINGMETH
#define NOCLOSINGMETH
Definition: lfunc.h:50
StackValue
Definition: lobject.h:141
global_State::gcstate
lu_byte gcstate
Definition: lstate.h:231
luaM_newvector
#define luaM_newvector(L, n, t)
Definition: lmem.h:60
luaE_checkcstack
void luaE_checkcstack(lua_State *L)
Definition: lstate.c:165
global_State::sweepgc
GCObject ** sweepgc
Definition: lstate.h:241
lua_State::oldpc
int oldpc
Definition: lstate.h:291
LUA_TTHREAD
#define LUA_TTHREAD
Definition: lua.h:73
STRCACHE_N
#define STRCACHE_N
Definition: llimits.h:226
UNUSED
#define UNUSED(x)
Definition: llimits.h:118
global_State::allgc
GCObject * allgc
Definition: lstate.h:240
global_State
struct global_State global_State
luaH_resize
void luaH_resize(lua_State *L, Table *t, unsigned int newasize, unsigned int nhsize)
Definition: ltable.c:523
LX
struct LX LX
setnilvalue
#define setnilvalue(obj)
Definition: lobject.h:178
GCSpause
#define GCSpause
Definition: lgc.h:39
lua_Alloc
void *(* lua_Alloc)(void *ud, void *ptr, size_t osize, size_t nsize)
Definition: lua.h:125
luai_userstateopen
#define luai_userstateopen(L)
Definition: llimits.h:271
lua.h
luaC_white
#define luaC_white(g)
Definition: lgc.h:102
UpVal
Definition: lobject.h:606
WHITE0BIT
#define WHITE0BIT
Definition: lgc.h:75
lua_State::errorJmp
struct lua_longjmp * errorJmp
Definition: lstate.h:286
lua_State::hook
volatile lua_Hook hook
Definition: lstate.h:288
ttisnil
#define ttisnil(v)
Definition: lobject.h:171
fromstate
#define fromstate(L)
Definition: lstate.c:51
luaE_setdebt
void luaE_setdebt(global_State *g, l_mem debt)
Definition: lstate.c:89
l_mem
long l_mem
Definition: llimits.h:31
global_State::frealloc
lua_Alloc frealloc
Definition: lstate.h:220
GCUnion::u
struct Udata u
Definition: lstate.h:313
lua_State::stack_last
StkId stack_last
Definition: lstate.h:281
luaE_warning
LUAI_FUNC void luaE_warning(lua_State *L, const char *msg, int tocont)
Definition: lstate.c:409
global_State::gcrunning
lu_byte gcrunning
Definition: lstate.h:235
global_State::ud
void * ud
Definition: lstate.h:221
luaE_extendCI
CallInfo * luaE_extendCI(lua_State *L)
Definition: lstate.c:105
G
#define G(L)
Definition: lstate.h:298
CallInfo::ctx
lua_KContext ctx
Definition: lstate.h:173
l_signalT
#define l_signalT
Definition: lstate.h:126
CallInfo::nextraargs
int nextraargs
Definition: lstate.h:168
preinit_thread
static void preinit_thread(lua_State *L, global_State *g)
Definition: lstate.c:250
lua_newstate
LUA_API lua_State * lua_newstate(lua_Alloc f, void *ud)
Definition: lstate.c:346
TString
Definition: lobject.h:364
lua_KContext
LUA_KCONTEXT lua_KContext
Definition: lua.h:100
lprefix.h
setthvalue2s
#define setthvalue2s(L, o, t)
Definition: lobject.h:251
CallInfo::nresults
short nresults
Definition: lstate.h:184
ldebug.h
global_State::finobj
GCObject * finobj
Definition: lstate.h:242
CallInfo::func
StkId func
Definition: lstate.h:161
lua_lock
#define lua_lock(L)
Definition: llimits.h:253
lu_byte
unsigned char lu_byte
Definition: llimits.h:36
LX::extra_
lu_byte extra_[LUA_EXTRASPACE]
Definition: lstate.c:36
lua_State::hookcount
int hookcount
Definition: lstate.h:293
l_uint32
unsigned long l_uint32
Definition: llimits.h:191
GCUnion::h
struct Table h
Definition: lstate.h:315
luaE_warning
void luaE_warning(lua_State *L, const char *msg, int tocont)
Definition: lstate.c:409
CallInfo::c
struct CallInfo::@11::@14 c
close_state
static void close_state(lua_State *L)
Definition: lstate.c:269
LUAI_GCSTEPSIZE
#define LUAI_GCSTEPSIZE
Definition: lgc.h:141
Table
Definition: lobject.h:714
LUA_API
#define LUA_API
Definition: luaconf.h:277
Udata
Definition: lobject.h:439
global_State::ud_warn
void * ud_warn
Definition: lstate.h:266
lua_Hook
void(* lua_Hook)(lua_State *L, lua_Debug *ar)
Definition: lua.h:448
lua_State::openupval
UpVal * openupval
Definition: lstate.h:283
luaE_shrinkCI
LUAI_FUNC void luaE_shrinkCI(lua_State *L)
Definition: lstate.c:138
luaE_setdebt
LUAI_FUNC void luaE_setdebt(global_State *g, l_mem debt)
Definition: lstate.c:89
lua_State::base_ci
CallInfo base_ci
Definition: lstate.h:287
CallInfo::l
struct CallInfo::@11::@13 l
global_State::GCdebt
l_mem GCdebt
Definition: lstate.h:223
CallInfo
Definition: lstate.h:160
init_registry
static void init_registry(lua_State *L, global_State *g)
Definition: lstate.c:215
lobject.h
luaD_seterrorobj
void luaD_seterrorobj(lua_State *L, int errcode, StkId oldtop)
Definition: ldo.c:91
luaH_new
Table * luaH_new(lua_State *L)
Definition: ltable.c:596
global_State::genminormul
lu_byte genminormul
Definition: lstate.h:233
global_State
Definition: lstate.h:219
lua_State::l_G
global_State * l_G
Definition: lstate.h:279
lua_State
Definition: lstate.h:273
addbuff
#define addbuff(b, p, e)
Definition: lstate.c:67
LUA_EXTRASPACE
#define LUA_EXTRASPACE
Definition: ltests.h:84
global_State::finobjold1
GCObject * finobjold1
Definition: lstate.h:256
LUAI_GENMAJORMUL
#define LUAI_GENMAJORMUL
Definition: lgc.h:125
global_State::gckind
lu_byte gckind
Definition: lstate.h:232
CallInfo::u2
union CallInfo::@12 u2
lua_State::hookmask
volatile l_signalT hookmask
Definition: lstate.h:294
lua_State::twups
struct lua_State * twups
Definition: lstate.h:285
LUAI_GCMUL
#define LUAI_GCMUL
Definition: lgc.h:138
lua_State::gclist
GCObject * gclist
Definition: lstate.h:284
luaM_newobject
#define luaM_newobject(L, tag, s)
Definition: lmem.h:64
lua_setcstacklimit
LUA_API int lua_setcstacklimit(lua_State *L, unsigned int limit)
Definition: lstate.c:99
TValue
Definition: lobject.h:65
gettotalbytes
#define gettotalbytes(g)
Definition: lstate.h:351
lua_close
LUA_API void lua_close(lua_State *L)
Definition: lstate.c:402
Table::array
TValue * array
Definition: lobject.h:719
lua_longjmp
Definition: ldo.c:84
global_State::strcache
TString * strcache[STRCACHE_N][STRCACHE_M]
Definition: lstate.h:264
LUAI_MAXCCALLS
#define LUAI_MAXCCALLS
Definition: llimits.h:244
global_State::reallyold
GCObject * reallyold
Definition: lstate.h:253
CIST_C
#define CIST_C
Definition: lstate.h:193
luaE_extendCI
LUAI_FUNC CallInfo * luaE_extendCI(lua_State *L)
Definition: lstate.c:105
luaS_hash
unsigned int luaS_hash(const char *str, size_t l, unsigned int seed)
Definition: lstring.c:43
CallInfo::trap
volatile l_signalT trap
Definition: lstate.h:167
MAX_LMEM
#define MAX_LMEM
Definition: llimits.h:50
luaE_checkcstack
LUAI_FUNC void luaE_checkcstack(lua_State *L)
Definition: lstate.c:165
CallInfo::k
lua_KFunction k
Definition: lstate.h:171
luaC_freeallobjects
void luaC_freeallobjects(lua_State *L)
Definition: lgc.c:1503
global_State::twups
struct lua_State * twups
Definition: lstate.h:258
CallInfo::savedpc
const Instruction * savedpc
Definition: lstate.h:166
CallInfo::old_errfunc
ptrdiff_t old_errfunc
Definition: lstate.h:172
Instruction
l_uint32 Instruction
Definition: llimits.h:194
global_State::mt
struct Table * mt[LUA_NUMTAGS]
Definition: lstate.h:263
CLOSEPROTECT
#define CLOSEPROTECT
Definition: lfunc.h:53
lua_State::ci
CallInfo * ci
Definition: lstate.h:280
luaD_throw
l_noret luaD_throw(lua_State *L, int errcode)
Definition: ldo.c:114
lua_State::stack
StkId stack
Definition: lstate.h:282
luaX_init
void luaX_init(lua_State *L)
Definition: llex.c:70
setivalue
#define setivalue(obj, x)
Definition: lobject.h:322
luaE_shrinkCI
void luaE_shrinkCI(lua_State *L)
Definition: lstate.c:138
LUAI_GCPAUSE
#define LUAI_GCPAUSE
Definition: lgc.h:129
luaM_new
#define luaM_new(L, t)
Definition: lmem.h:59
luaE_freeCI
LUAI_FUNC void luaE_freeCI(lua_State *L)
Definition: lstate.c:122
global_State::gcstepmul
lu_byte gcstepmul
Definition: lstate.h:238
Proto
Definition: lobject.h:530
global_State::finobjrold
GCObject * finobjrold
Definition: lstate.h:257
setgcparam
#define setgcparam(p, v)
Definition: lgc.h:136
global_State::gcpause
lu_byte gcpause
Definition: lstate.h:237
luaE_warnerror
LUAI_FUNC void luaE_warnerror(lua_State *L, const char *where)
Definition: lstate.c:419
luai_userstatethread
#define luai_userstatethread(L, L1)
Definition: llimits.h:279
lstring.h
stringtable::nuse
int nuse
Definition: lstate.h:152
CallInfo::transferinfo
struct CallInfo::@12::@15 transferinfo
global_State::gcstepsize
lu_byte gcstepsize
Definition: lstate.h:239
lua_resetthread
int lua_resetthread(lua_State *L)
Definition: lstate.c:324
lapi.h
GCUnion::ts
struct TString ts
Definition: lstate.h:312
stringtable::size
int size
Definition: lstate.h:153
luaM_free
#define luaM_free(L, b)
Definition: lmem.h:56
lua_CFunction
int(* lua_CFunction)(lua_State *L)
Definition: lua.h:106
global_State::mainthread
struct lua_State * mainthread
Definition: lstate.h:260
getCcalls
#define getCcalls(L)
Definition: lstate.h:102
lua_KFunction
int(* lua_KFunction)(lua_State *L, int status, lua_KContext ctx)
Definition: lua.h:111
global_State::nilvalue
TValue nilvalue
Definition: lstate.h:228
lmem.h
lua_State::top
StkId top
Definition: lstate.h:278
LUAI_GENMINORMUL
#define LUAI_GENMINORMUL
Definition: lgc.h:126
LG
struct LG LG
global_State::fixedgc
GCObject * fixedgc
Definition: lstate.h:249
luaM_freearray
#define luaM_freearray(L, b, n)
Definition: lmem.h:57
global_State::tobefnz
GCObject * tobefnz
Definition: lstate.h:248
lgc.h
GCObject
Definition: lobject.h:270
LX
Definition: lstate.c:35
CallInfo::nyield
int nyield
Definition: lstate.h:178
lua_State::nci
unsigned short nci
Definition: lstate.h:277
KGC_INC
#define KGC_INC
Definition: lstate.h:146
LG::l
LX l
Definition: lstate.c:45
lua_WarnFunction
void(* lua_WarnFunction)(void *ud, const char *msg, int tocont)
Definition: lua.h:131
global_State::allweak
GCObject * allweak
Definition: lstate.h:247
CallInfo::ftransfer
unsigned short ftransfer
Definition: lstate.h:180
TM_N
@ TM_N
Definition: ltm.h:44
stacksize
#define stacksize(th)
Definition: lstate.h:142
lua_State::nCcalls
l_uint32 nCcalls
Definition: lstate.h:290
lzio.h
lua_State::allowhook
lu_byte allowhook
Definition: lstate.h:276
next
#define next(ls)
Definition: llex.c:32
LUA_RIDX_GLOBALS
#define LUA_RIDX_GLOBALS
Definition: lua.h:85
CallInfo::top
StkId top
Definition: lstate.h:162
CallInfo::ntransfer
unsigned short ntransfer
Definition: lstate.h:181
STRCACHE_M
#define STRCACHE_M
Definition: llimits.h:227
CallInfo::callstatus
unsigned short callstatus
Definition: lstate.h:185
global_State::finobjsur
GCObject * finobjsur
Definition: lstate.h:255
luaF_close
int luaF_close(lua_State *L, StkId level, int status)
Definition: lfunc.c:223
global_State::memerrmsg
TString * memerrmsg
Definition: lstate.h:261
svalue
#define svalue(o)
Definition: lobject.h:385
luaE_freethread
void luaE_freethread(lua_State *L, lua_State *L1)
Definition: lstate.c:314
stack_init
static void stack_init(lua_State *L1, lua_State *L)
Definition: lstate.c:180
global_State::seed
unsigned int seed
Definition: lstate.h:229
Closure
Definition: lobject.h:638
CallInfo::u
union CallInfo::@11 u
luaD_rawrunprotected
int luaD_rawrunprotected(lua_State *L, Pfunc f, void *ud)
Definition: ldo.c:141
global_State::gray
GCObject * gray
Definition: lstate.h:243
global_State::ephemeron
GCObject * ephemeron
Definition: lstate.h:246
CallInfo::funcidx
int funcidx
Definition: lstate.h:177
luaE_freeCI
void luaE_freeCI(lua_State *L)
Definition: lstate.c:122
stringtable
struct stringtable stringtable
lua_getextraspace
#define lua_getextraspace(L)
Definition: lua.h:359
global_State::weak
GCObject * weak
Definition: lstate.h:245
lfunc.h
CallInfo::next
struct CallInfo * next
Definition: lstate.h:163
global_State::survival
GCObject * survival
Definition: lstate.h:251
global_State::tmname
TString * tmname[TM_N]
Definition: lstate.h:262
lua_newthread
LUA_API lua_State * lua_newthread(lua_State *L)
Definition: lstate.c:282
ldo.h
luaE_incCstack
LUAI_FUNC void luaE_incCstack(lua_State *L)
Definition: lstate.c:173
ttisstring
#define ttisstring(o)
Definition: lobject.h:341
LG
Definition: lstate.c:44
luai_userstateclose
#define luai_userstateclose(L)
Definition: llimits.h:275