Coverage Report

Created: 2024-04-23 06:32

/src/testdir/build/lua-master/source/ldo.c
Line
Count
Source (jump to first uncovered line)
1
/*
2
** $Id: ldo.c $
3
** Stack and Call structure of Lua
4
** See Copyright Notice in lua.h
5
*/
6
7
#define ldo_c
8
#define LUA_CORE
9
10
#include "lprefix.h"
11
12
13
#include <setjmp.h>
14
#include <stdlib.h>
15
#include <string.h>
16
17
#include "lua.h"
18
19
#include "lapi.h"
20
#include "ldebug.h"
21
#include "ldo.h"
22
#include "lfunc.h"
23
#include "lgc.h"
24
#include "lmem.h"
25
#include "lobject.h"
26
#include "lopcodes.h"
27
#include "lparser.h"
28
#include "lstate.h"
29
#include "lstring.h"
30
#include "ltable.h"
31
#include "ltm.h"
32
#include "lundump.h"
33
#include "lvm.h"
34
#include "lzio.h"
35
36
37
38
2
#define errorstatus(s)  ((s) > LUA_YIELD)
39
40
41
/*
42
** {======================================================
43
** Error-recovery functions
44
** =======================================================
45
*/
46
47
/*
48
** LUAI_THROW/LUAI_TRY define how Lua does exception handling. By
49
** default, Lua handles errors with exceptions when compiling as
50
** C++ code, with _longjmp/_setjmp when asked to use them, and with
51
** longjmp/setjmp otherwise.
52
*/
53
#if !defined(LUAI_THROW)        /* { */
54
55
#if defined(__cplusplus) && !defined(LUA_USE_LONGJMP) /* { */
56
57
/* C++ exceptions */
58
#define LUAI_THROW(L,c)   throw(c)
59
#define LUAI_TRY(L,c,a) \
60
  try { a } catch(...) { if ((c)->status == 0) (c)->status = -1; }
61
#define luai_jmpbuf   int  /* dummy variable */
62
63
#elif defined(LUA_USE_POSIX)        /* }{ */
64
65
/* in POSIX, try _longjmp/_setjmp (more efficient) */
66
#define LUAI_THROW(L,c)   _longjmp((c)->b, 1)
67
#define LUAI_TRY(L,c,a)   if (_setjmp((c)->b) == 0) { a }
68
#define luai_jmpbuf   jmp_buf
69
70
#else             /* }{ */
71
72
/* ISO C handling with long jumps */
73
2.49M
#define LUAI_THROW(L,c)   longjmp((c)->b, 1)
74
7.78M
#define LUAI_TRY(L,c,a)   if (setjmp((c)->b) == 0) { a }
75
#define luai_jmpbuf   jmp_buf
76
77
#endif              /* } */
78
79
#endif              /* } */
80
81
82
83
/* chain list of long jump buffers */
84
struct lua_longjmp {
85
  struct lua_longjmp *previous;
86
  luai_jmpbuf b;
87
  volatile int status;  /* error code */
88
};
89
90
91
2.49M
void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop) {
92
2.49M
  switch (errcode) {
93
0
    case LUA_ERRMEM: {  /* memory error? */
94
0
      setsvalue2s(L, oldtop, G(L)->memerrmsg); /* reuse preregistered msg. */
95
0
      break;
96
0
    }
97
0
    case LUA_ERRERR: {
98
0
      setsvalue2s(L, oldtop, luaS_newliteral(L, "error in error handling"));
99
0
      break;
100
0
    }
101
0
    case LUA_OK: {  /* special case only for closing upvalues */
102
0
      setnilvalue(s2v(oldtop));  /* no error message */
103
0
      break;
104
0
    }
105
2.49M
    default: {
106
2.49M
      lua_assert(errorstatus(errcode));  /* real error */
107
2.49M
      setobjs2s(L, oldtop, L->top.p - 1);  /* error message on current top */
108
2.49M
      break;
109
2.49M
    }
110
2.49M
  }
111
2.49M
  L->top.p = oldtop + 1;
112
2.49M
}
113
114
115
2.49M
l_noret luaD_throw (lua_State *L, int errcode) {
116
2.49M
  if (L->errorJmp) {  /* thread has an error handler? */
117
2.49M
    L->errorJmp->status = errcode;  /* set status */
118
2.49M
    LUAI_THROW(L, L->errorJmp);  /* jump to it */
119
2.49M
  }
120
0
  else {  /* thread has no error handler */
121
0
    global_State *g = G(L);
122
0
    errcode = luaE_resetthread(L, errcode);  /* close all upvalues */
123
0
    if (g->mainthread->errorJmp) {  /* main thread has a handler? */
124
0
      setobjs2s(L, g->mainthread->top.p++, L->top.p - 1);  /* copy error obj. */
125
0
      luaD_throw(g->mainthread, errcode);  /* re-throw in main thread */
126
0
    }
127
0
    else {  /* no handler at all; abort */
128
0
      if (g->panic) {  /* panic function? */
129
0
        lua_unlock(L);
130
0
        g->panic(L);  /* call panic function (last chance to jump out) */
131
0
      }
132
0
      abort();
133
0
    }
134
0
  }
135
2.49M
}
136
137
138
7.78M
int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud) {
139
7.78M
  l_uint32 oldnCcalls = L->nCcalls;
140
7.78M
  struct lua_longjmp lj;
141
7.78M
  lj.status = LUA_OK;
142
7.78M
  lj.previous = L->errorJmp;  /* chain new error handler */
143
7.78M
  L->errorJmp = &lj;
144
7.78M
  LUAI_TRY(L, &lj,
145
7.78M
    (*f)(L, ud);
146
7.78M
  );
147
7.78M
  L->errorJmp = lj.previous;  /* restore old error handler */
148
7.78M
  L->nCcalls = oldnCcalls;
149
7.78M
  return lj.status;
150
7.78M
}
151
152
/* }====================================================== */
153
154
155
/*
156
** {==================================================================
157
** Stack reallocation
158
** ===================================================================
159
*/
160
161
162
/*
163
** Change all pointers to the stack into offsets.
164
*/
165
70.6k
static void relstack (lua_State *L) {
166
70.6k
  CallInfo *ci;
167
70.6k
  UpVal *up;
168
70.6k
  L->top.offset = savestack(L, L->top.p);
169
70.6k
  L->tbclist.offset = savestack(L, L->tbclist.p);
170
114k
  for (up = L->openupval; up != NULL; up = up->u.open.next)
171
44.0k
    up->v.offset = savestack(L, uplevel(up));
172
18.7M
  for (ci = L->ci; ci != NULL; ci = ci->previous) {
173
18.7M
    ci->top.offset = savestack(L, ci->top.p);
174
18.7M
    ci->func.offset = savestack(L, ci->func.p);
175
18.7M
  }
176
70.6k
}
177
178
179
/*
180
** Change back all offsets into pointers.
181
*/
182
70.6k
static void correctstack (lua_State *L) {
183
70.6k
  CallInfo *ci;
184
70.6k
  UpVal *up;
185
70.6k
  L->top.p = restorestack(L, L->top.offset);
186
70.6k
  L->tbclist.p = restorestack(L, L->tbclist.offset);
187
114k
  for (up = L->openupval; up != NULL; up = up->u.open.next)
188
44.0k
    up->v.p = s2v(restorestack(L, up->v.offset));
189
18.7M
  for (ci = L->ci; ci != NULL; ci = ci->previous) {
190
18.7M
    ci->top.p = restorestack(L, ci->top.offset);
191
18.7M
    ci->func.p = restorestack(L, ci->func.offset);
192
18.7M
    if (isLua(ci))
193
16.3M
      ci->u.l.trap = 1;  /* signal to update 'trap' in 'luaV_execute' */
194
18.7M
  }
195
70.6k
}
196
197
198
/* some space for error handling */
199
31
#define ERRORSTACKSIZE  (LUAI_MAXSTACK + 200)
200
201
/*
202
** Reallocate the stack to a new size, correcting all pointers into it.
203
** In ISO C, any pointer use after the pointer has been deallocated is
204
** undefined behavior. So, before the reallocation, all pointers are
205
** changed to offsets, and after the reallocation they are changed back
206
** to pointers. As during the reallocation the pointers are invalid, the
207
** reallocation cannot run emergency collections.
208
**
209
** In case of allocation error, raise an error or return false according
210
** to 'raiseerror'.
211
*/
212
70.6k
int luaD_reallocstack (lua_State *L, int newsize, int raiseerror) {
213
70.6k
  int oldsize = stacksize(L);
214
70.6k
  int i;
215
70.6k
  StkId newstack;
216
70.6k
  int oldgcstop = G(L)->gcstopem;
217
70.6k
  lua_assert(newsize <= LUAI_MAXSTACK || newsize == ERRORSTACKSIZE);
218
70.6k
  relstack(L);  /* change pointers to offsets */
219
70.6k
  G(L)->gcstopem = 1;  /* stop emergency collection */
220
70.6k
  newstack = luaM_reallocvector(L, L->stack.p, oldsize + EXTRA_STACK,
221
70.6k
                                   newsize + EXTRA_STACK, StackValue);
222
70.6k
  G(L)->gcstopem = oldgcstop;  /* restore emergency collection */
223
70.6k
  if (l_unlikely(newstack == NULL)) {  /* reallocation failed? */
224
0
    correctstack(L);  /* change offsets back to pointers */
225
0
    if (raiseerror)
226
0
      luaM_error(L);
227
0
    else return 0;  /* do not raise an error */
228
0
  }
229
70.6k
  L->stack.p = newstack;
230
70.6k
  correctstack(L);  /* change offsets back to pointers */
231
70.6k
  L->stack_last.p = L->stack.p + newsize;
232
79.7M
  for (i = oldsize + EXTRA_STACK; i < newsize + EXTRA_STACK; i++)
233
79.7M
    setnilvalue(s2v(newstack + i)); /* erase new segment */
234
70.6k
  return 1;
235
70.6k
}
236
237
238
/*
239
** Try to grow the stack by at least 'n' elements. When 'raiseerror'
240
** is true, raises any error; otherwise, return 0 in case of errors.
241
*/
242
34.8k
int luaD_growstack (lua_State *L, int n, int raiseerror) {
243
34.8k
  int size = stacksize(L);
244
34.8k
  if (l_unlikely(size > LUAI_MAXSTACK)) {
245
    /* if stack is larger than maximum, thread is already using the
246
       extra space reserved for errors, that is, thread is handling
247
       a stack error; cannot grow further than that. */
248
0
    lua_assert(stacksize(L) == ERRORSTACKSIZE);
249
0
    if (raiseerror)
250
0
      luaD_throw(L, LUA_ERRERR);  /* error inside message handler */
251
0
    return 0;  /* if not 'raiseerror', just signal it */
252
0
  }
253
34.8k
  else if (n < LUAI_MAXSTACK) {  /* avoids arithmetic overflows */
254
34.8k
    int newsize = 2 * size;  /* tentative new size */
255
34.8k
    int needed = cast_int(L->top.p - L->stack.p) + n;
256
34.8k
    if (newsize > LUAI_MAXSTACK)  /* cannot cross the limit */
257
80
      newsize = LUAI_MAXSTACK;
258
34.8k
    if (newsize < needed)  /* but must respect what was asked for */
259
1.35k
      newsize = needed;
260
34.8k
    if (l_likely(newsize <= LUAI_MAXSTACK))
261
34.7k
      return luaD_reallocstack(L, newsize, raiseerror);
262
34.8k
  }
263
  /* else stack overflow */
264
  /* add extra size to be able to handle the error message */
265
31
  luaD_reallocstack(L, ERRORSTACKSIZE, raiseerror);
266
31
  if (raiseerror)
267
31
    luaG_runerror(L, "stack overflow");
268
0
  return 0;
269
31
}
270
271
272
/*
273
** Compute how much of the stack is being used, by computing the
274
** maximum top of all call frames in the stack and the current top.
275
*/
276
3.30M
static int stackinuse (lua_State *L) {
277
3.30M
  CallInfo *ci;
278
3.30M
  int res;
279
3.30M
  StkId lim = L->top.p;
280
257M
  for (ci = L->ci; ci != NULL; ci = ci->previous) {
281
253M
    if (lim < ci->top.p) lim = ci->top.p;
282
253M
  }
283
3.30M
  lua_assert(lim <= L->stack_last.p + EXTRA_STACK);
284
3.30M
  res = cast_int(lim - L->stack.p) + 1;  /* part of stack in use */
285
3.30M
  if (res < LUA_MINSTACK)
286
0
    res = LUA_MINSTACK;  /* ensure a minimum size */
287
3.30M
  return res;
288
3.30M
}
289
290
291
/*
292
** If stack size is more than 3 times the current use, reduce that size
293
** to twice the current use. (So, the final stack size is at most 2/3 the
294
** previous size, and half of its entries are empty.)
295
** As a particular case, if stack was handling a stack overflow and now
296
** it is not, 'max' (limited by LUAI_MAXSTACK) will be smaller than
297
** stacksize (equal to ERRORSTACKSIZE in this case), and so the stack
298
** will be reduced to a "regular" size.
299
*/
300
3.30M
void luaD_shrinkstack (lua_State *L) {
301
3.30M
  int inuse = stackinuse(L);
302
3.30M
  int max = (inuse > LUAI_MAXSTACK / 3) ? LUAI_MAXSTACK : inuse * 3;
303
  /* if thread is currently not handling a stack overflow and its
304
     size is larger than maximum "reasonable" size, shrink it */
305
3.30M
  if (inuse <= LUAI_MAXSTACK && stacksize(L) > max) {
306
35.8k
    int nsize = (inuse > LUAI_MAXSTACK / 2) ? LUAI_MAXSTACK : inuse * 2;
307
35.8k
    luaD_reallocstack(L, nsize, 0);  /* ok if that fails */
308
35.8k
  }
309
3.27M
  else  /* don't change stack */
310
3.27M
    condmovestack(L,{},{});  /* (change only for debugging) */
311
3.30M
  luaE_shrinkCI(L);  /* shrink CI list */
312
3.30M
}
313
314
315
4.82M
void luaD_inctop (lua_State *L) {
316
4.82M
  luaD_checkstack(L, 1);
317
4.82M
  L->top.p++;
318
4.82M
}
319
320
/* }================================================================== */
321
322
323
/*
324
** Call a hook for the given event. Make sure there is a hook to be
325
** called. (Both 'L->hook' and 'L->hookmask', which trigger this
326
** function, can be changed asynchronously by signals.)
327
*/
328
void luaD_hook (lua_State *L, int event, int line,
329
43.9M
                              int ftransfer, int ntransfer) {
330
43.9M
  lua_Hook hook = L->hook;
331
43.9M
  if (hook && L->allowhook) {  /* make sure there is a hook */
332
43.9M
    int mask = CIST_HOOKED;
333
43.9M
    CallInfo *ci = L->ci;
334
43.9M
    ptrdiff_t top = savestack(L, L->top.p);  /* preserve original 'top' */
335
43.9M
    ptrdiff_t ci_top = savestack(L, ci->top.p);  /* idem for 'ci->top' */
336
43.9M
    lua_Debug ar;
337
43.9M
    ar.event = event;
338
43.9M
    ar.currentline = line;
339
43.9M
    ar.i_ci = ci;
340
43.9M
    if (ntransfer != 0) {
341
22.1M
      mask |= CIST_TRAN;  /* 'ci' has transfer information */
342
22.1M
      ci->u2.transferinfo.ftransfer = ftransfer;
343
22.1M
      ci->u2.transferinfo.ntransfer = ntransfer;
344
22.1M
    }
345
43.9M
    if (isLua(ci) && L->top.p < ci->top.p)
346
12.8M
      L->top.p = ci->top.p;  /* protect entire activation register */
347
43.9M
    luaD_checkstack(L, LUA_MINSTACK);  /* ensure minimum stack size */
348
43.9M
    if (ci->top.p < L->top.p + LUA_MINSTACK)
349
36.9M
      ci->top.p = L->top.p + LUA_MINSTACK;
350
43.9M
    L->allowhook = 0;  /* cannot call hooks inside a hook */
351
43.9M
    ci->callstatus |= mask;
352
43.9M
    lua_unlock(L);
353
43.9M
    (*hook)(L, &ar);
354
43.9M
    lua_lock(L);
355
43.9M
    lua_assert(!L->allowhook);
356
43.9M
    L->allowhook = 1;
357
43.9M
    ci->top.p = restorestack(L, ci_top);
358
43.9M
    L->top.p = restorestack(L, top);
359
43.9M
    ci->callstatus &= ~mask;
360
43.9M
  }
361
43.9M
}
362
363
364
/*
365
** Executes a call hook for Lua functions. This function is called
366
** whenever 'hookmask' is not zero, so it checks whether call hooks are
367
** active.
368
*/
369
8.17M
void luaD_hookcall (lua_State *L, CallInfo *ci) {
370
8.17M
  L->oldpc = 0;  /* set 'oldpc' for new function */
371
8.17M
  if (L->hookmask & LUA_MASKCALL) {  /* is call hook on? */
372
8.17M
    int event = (ci->callstatus & CIST_TAIL) ? LUA_HOOKTAILCALL
373
8.17M
                                             : LUA_HOOKCALL;
374
16.3M
    Proto *p = ci_func(ci)->p;
375
0
    ci->u.l.savedpc++;  /* hooks assume 'pc' is already incremented */
376
16.3M
    luaD_hook(L, event, -1, 1, p->numparams);
377
16.3M
    ci->u.l.savedpc--;  /* correct 'pc' */
378
16.3M
  }
379
8.17M
}
380
381
382
/*
383
** Executes a return hook for Lua and C functions and sets/corrects
384
** 'oldpc'. (Note that this correction is needed by the line hook, so it
385
** is done even when return hooks are off.)
386
*/
387
11.1M
static void rethook (lua_State *L, CallInfo *ci, int nres) {
388
11.1M
  if (L->hookmask & LUA_MASKRET) {  /* is return hook on? */
389
11.1M
    StkId firstres = L->top.p - nres;  /* index of first result */
390
11.1M
    int delta = 0;  /* correction for vararg functions */
391
11.1M
    int ftransfer;
392
11.1M
    if (isLua(ci)) {
393
12.3M
      Proto *p = ci_func(ci)->p;
394
6.15M
      if (p->flag & PF_ISVARARG)
395
524k
        delta = ci->u.l.nextraargs + p->numparams + 1;
396
12.3M
    }
397
11.1M
    ci->func.p += delta;  /* if vararg, back to virtual 'func' */
398
11.1M
    ftransfer = cast(unsigned short, firstres - ci->func.p);
399
11.1M
    luaD_hook(L, LUA_HOOKRET, -1, ftransfer, nres);  /* call it */
400
11.1M
    ci->func.p -= delta;
401
11.1M
  }
402
11.1M
  if (isLua(ci = ci->previous))
403
11.1M
    L->oldpc = pcRel(ci->u.l.savedpc, ci_func(ci)->p);  /* set 'oldpc' */
404
11.1M
}
405
406
407
/*
408
** Check whether 'func' has a '__call' metafield. If so, put it in the
409
** stack, below original 'func', so that 'luaD_precall' can call it. Raise
410
** an error if there is no '__call' metafield.
411
*/
412
2.64M
static StkId tryfuncTM (lua_State *L, StkId func) {
413
2.64M
  const TValue *tm;
414
2.64M
  StkId p;
415
2.64M
  checkstackp(L, 1, func);  /* space for metamethod */
416
2.64M
  tm = luaT_gettmbyobj(L, s2v(func), TM_CALL);  /* (after previous GC) */
417
2.64M
  if (l_unlikely(ttisnil(tm)))
418
51.2k
    luaG_callerror(L, s2v(func));  /* nothing to call */
419
7.36M
  for (p = L->top.p; p > func; p--)  /* open space for metamethod */
420
4.77M
    setobjs2s(L, p, p-1);
421
2.59M
  L->top.p++;  /* stack space pre-allocated by the caller */
422
2.59M
  setobj2s(L, func, tm);  /* metamethod is the new function to be called */
423
2.59M
  return func;
424
2.59M
}
425
426
427
/*
428
** Given 'nres' results at 'firstResult', move 'wanted' of them to 'res'.
429
** Handle most typical cases (zero results for commands, one result for
430
** expressions, multiple results for tail calls/single parameters)
431
** separated.
432
*/
433
19.4M
l_sinline void moveresults (lua_State *L, StkId res, int nres, int wanted) {
434
19.4M
  StkId firstresult;
435
19.4M
  int i;
436
19.4M
  switch (wanted) {  /* handle typical cases separately */
437
4.93M
    case 0:  /* no values needed */
438
4.93M
      L->top.p = res;
439
4.93M
      return;
440
11.9M
    case 1:  /* one value needed */
441
11.9M
      if (nres == 0)   /* no results? */
442
11.9M
        setnilvalue(s2v(res));  /* adjust with nil */
443
11.3M
      else  /* at least one result */
444
11.9M
        setobjs2s(L, res, L->top.p - nres);  /* move it to proper place */
445
11.9M
      L->top.p = res + 1;
446
11.9M
      return;
447
1.10M
    case LUA_MULTRET:
448
1.10M
      wanted = nres;  /* we want all results */
449
1.10M
      break;
450
1.51M
    default:  /* two/more results and/or to-be-closed variables */
451
1.51M
      if (hastocloseCfunc(wanted)) {  /* to-be-closed variables? */
452
372k
        L->ci->callstatus |= CIST_CLSRET;  /* in case of yields */
453
372k
        L->ci->u2.nres = nres;
454
372k
        res = luaF_close(L, res, CLOSEKTOP, 1);
455
372k
        L->ci->callstatus &= ~CIST_CLSRET;
456
372k
        if (L->hookmask) {  /* if needed, call hook after '__close's */
457
0
          ptrdiff_t savedres = savestack(L, res);
458
0
          rethook(L, L->ci, nres);
459
0
          res = restorestack(L, savedres);  /* hook can move stack */
460
0
        }
461
372k
        wanted = decodeNresults(wanted);
462
372k
        if (wanted == LUA_MULTRET)
463
0
          wanted = nres;  /* we want all results */
464
372k
      }
465
1.51M
      break;
466
19.4M
  }
467
  /* generic case */
468
2.61M
  firstresult = L->top.p - nres;  /* index of first result */
469
2.61M
  if (nres > wanted)  /* extra results? */
470
107k
    nres = wanted;  /* don't need them */
471
4.93M
  for (i = 0; i < nres; i++)  /* move all results to correct place */
472
2.61M
    setobjs2s(L, res + i, firstresult + i);
473
6.03M
  for (; i < wanted; i++)  /* complete wanted number of results */
474
3.41M
    setnilvalue(s2v(res + i));
475
2.61M
  L->top.p = res + wanted;  /* top points after the last result */
476
2.61M
}
477
478
479
/*
480
** Finishes a function call: calls hook if necessary, moves current
481
** number of results to proper place, and returns to previous call
482
** info. If function has to close variables, hook must be called after
483
** that.
484
*/
485
19.4M
void luaD_poscall (lua_State *L, CallInfo *ci, int nres) {
486
19.4M
  int wanted = ci->nresults;
487
19.4M
  if (l_unlikely(L->hookmask && !hastocloseCfunc(wanted)))
488
11.1M
    rethook(L, ci, nres);
489
  /* move results to proper place */
490
19.4M
  moveresults(L, ci->func.p, nres, wanted);
491
  /* function cannot be in any of these cases when returning */
492
19.4M
  lua_assert(!(ci->callstatus &
493
19.4M
        (CIST_HOOKED | CIST_YPCALL | CIST_FIN | CIST_TRAN | CIST_CLSRET)));
494
19.4M
  L->ci = ci->previous;  /* back to caller (after closing variables) */
495
19.4M
}
496
497
498
499
25.4M
#define next_ci(L)  (L->ci->next ? L->ci->next : luaE_extendCI(L))
500
501
502
l_sinline CallInfo *prepCallInfo (lua_State *L, StkId func, int nret,
503
25.4M
                                                int mask, StkId top) {
504
25.4M
  CallInfo *ci = L->ci = next_ci(L);  /* new frame */
505
25.4M
  ci->func.p = func;
506
25.4M
  ci->nresults = nret;
507
25.4M
  ci->callstatus = mask;
508
25.4M
  ci->top.p = top;
509
25.4M
  return ci;
510
25.4M
}
511
512
513
/*
514
** precall for C functions
515
*/
516
l_sinline int precallC (lua_State *L, StkId func, int nresults,
517
13.5M
                                            lua_CFunction f) {
518
13.5M
  int n;  /* number of returns */
519
13.5M
  CallInfo *ci;
520
13.5M
  checkstackp(L, LUA_MINSTACK, func);  /* ensure minimum stack size */
521
13.5M
  L->ci = ci = prepCallInfo(L, func, nresults, CIST_C,
522
13.5M
                               L->top.p + LUA_MINSTACK);
523
13.5M
  lua_assert(ci->top.p <= L->stack_last.p);
524
13.5M
  if (l_unlikely(L->hookmask & LUA_MASKCALL)) {
525
4.98M
    int narg = cast_int(L->top.p - func) - 1;
526
4.98M
    luaD_hook(L, LUA_HOOKCALL, -1, 1, narg);
527
4.98M
  }
528
13.5M
  lua_unlock(L);
529
13.5M
  n = (*f)(L);  /* do the actual call */
530
13.5M
  lua_lock(L);
531
13.5M
  api_checknelems(L, n);
532
12.7M
  luaD_poscall(L, ci, n);
533
12.7M
  return n;
534
13.5M
}
535
536
537
/*
538
** Prepare a function for a tail call, building its call info on top
539
** of the current call info. 'narg1' is the number of arguments plus 1
540
** (so that it includes the function itself). Return the number of
541
** results, if it was a C function, or -1 for a Lua function.
542
*/
543
int luaD_pretailcall (lua_State *L, CallInfo *ci, StkId func,
544
873k
                                    int narg1, int delta) {
545
886k
 retry:
546
886k
  switch (ttypetag(s2v(func))) {
547
0
    case LUA_VCCL:  /* C closure */
548
0
      return precallC(L, func, LUA_MULTRET, clCvalue(s2v(func))->f);
549
0
    case LUA_VLCF:  /* light C function */
550
0
      return precallC(L, func, LUA_MULTRET, fvalue(s2v(func)));
551
873k
    case LUA_VLCL: {  /* Lua function */
552
1.74M
      Proto *p = clLvalue(s2v(func))->p;
553
0
      int fsize = p->maxstacksize;  /* frame size */
554
1.74M
      int nfixparams = p->numparams;
555
1.74M
      int i;
556
1.74M
      checkstackp(L, fsize - delta, func);
557
1.74M
      ci->func.p -= delta;  /* restore 'func' (if vararg) */
558
2.62M
      for (i = 0; i < narg1; i++)  /* move down function and arguments */
559
1.74M
        setobjs2s(L, ci->func.p + i, func + i);
560
873k
      func = ci->func.p;  /* moved-down function */
561
873k
      for (; narg1 <= nfixparams; narg1++)
562
873k
        setnilvalue(s2v(func + narg1));  /* complete missing arguments */
563
873k
      ci->top.p = func + 1 + fsize;  /* top for new function */
564
873k
      lua_assert(ci->top.p <= L->stack_last.p);
565
873k
      ci->u.l.savedpc = p->code;  /* starting point */
566
873k
      ci->callstatus |= CIST_TAIL;
567
873k
      L->top.p = func + narg1;  /* set top */
568
873k
      return -1;
569
873k
    }
570
12.0k
    default: {  /* not a function */
571
12.0k
      func = tryfuncTM(L, func);  /* try to get '__call' metamethod */
572
      /* return luaD_pretailcall(L, ci, func, narg1 + 1, delta); */
573
12.0k
      narg1++;
574
12.0k
      goto retry;  /* try again */
575
873k
    }
576
886k
  }
577
886k
}
578
579
580
/*
581
** Prepares the call to a function (C or Lua). For C functions, also do
582
** the call. The function to be called is at '*func'.  The arguments
583
** are on the stack, right after the function.  Returns the CallInfo
584
** to be executed, if it was a Lua function. Otherwise (a C function)
585
** returns NULL, with all the results on the stack, starting at the
586
** original function position.
587
*/
588
25.5M
CallInfo *luaD_precall (lua_State *L, StkId func, int nresults) {
589
28.1M
 retry:
590
28.1M
  switch (ttypetag(s2v(func))) {
591
1.42M
    case LUA_VCCL:  /* C closure */
592
1.42M
      precallC(L, func, nresults, clCvalue(s2v(func))->f);
593
0
      return NULL;
594
12.0M
    case LUA_VLCF:  /* light C function */
595
12.0M
      precallC(L, func, nresults, fvalue(s2v(func)));
596
0
      return NULL;
597
11.9M
    case LUA_VLCL: {  /* Lua function */
598
11.9M
      CallInfo *ci;
599
23.9M
      Proto *p = clLvalue(s2v(func))->p;
600
11.9M
      int narg = cast_int(L->top.p - func) - 1;  /* number of real arguments */
601
23.9M
      int nfixparams = p->numparams;
602
23.9M
      int fsize = p->maxstacksize;  /* frame size */
603
23.9M
      checkstackp(L, fsize, func);
604
23.9M
      L->ci = ci = prepCallInfo(L, func, nresults, 0, func + 1 + fsize);
605
23.9M
      ci->u.l.savedpc = p->code;  /* starting point */
606
23.9M
      for (; narg < nfixparams; narg++)
607
11.9M
        setnilvalue(s2v(L->top.p++));  /* complete missing arguments */
608
23.9M
      lua_assert(ci->top.p <= L->stack_last.p);
609
11.9M
      return ci;
610
23.9M
    }
611
2.63M
    default: {  /* not a function */
612
2.63M
      func = tryfuncTM(L, func);  /* try to get '__call' metamethod */
613
      /* return luaD_precall(L, func, nresults); */
614
2.63M
      goto retry;  /* try again with metamethod */
615
23.9M
    }
616
28.1M
  }
617
28.1M
}
618
619
620
/*
621
** Call a function (C or Lua) through C. 'inc' can be 1 (increment
622
** number of recursive invocations in the C stack) or nyci (the same
623
** plus increment number of non-yieldable calls).
624
** This function can be called with some use of EXTRA_STACK, so it should
625
** check the stack before doing anything else. 'luaD_precall' already
626
** does that.
627
*/
628
6.76M
l_sinline void ccall (lua_State *L, StkId func, int nResults, l_uint32 inc) {
629
6.76M
  CallInfo *ci;
630
6.76M
  L->nCcalls += inc;
631
6.76M
  if (l_unlikely(getCcalls(L) >= LUAI_MAXCCALLS)) {
632
12.1k
    checkstackp(L, 0, func);  /* free any use of EXTRA_STACK */
633
12.1k
    luaE_checkcstack(L);
634
12.1k
  }
635
6.76M
  if ((ci = luaD_precall(L, func, nResults)) != NULL) {  /* Lua function? */
636
3.18M
    ci->callstatus = CIST_FRESH;  /* mark that it is a "fresh" execute */
637
3.18M
    luaV_execute(L, ci);  /* call it */
638
3.18M
  }
639
6.76M
  L->nCcalls -= inc;
640
6.76M
}
641
642
643
/*
644
** External interface for 'ccall'
645
*/
646
1.93M
void luaD_call (lua_State *L, StkId func, int nResults) {
647
1.93M
  ccall(L, func, nResults, 1);
648
1.93M
}
649
650
651
/*
652
** Similar to 'luaD_call', but does not allow yields during the call.
653
*/
654
4.83M
void luaD_callnoyield (lua_State *L, StkId func, int nResults) {
655
4.83M
  ccall(L, func, nResults, nyci);
656
4.83M
}
657
658
659
/*
660
** Finish the job of 'lua_pcallk' after it was interrupted by an yield.
661
** (The caller, 'finishCcall', does the final call to 'adjustresults'.)
662
** The main job is to complete the 'luaD_pcall' called by 'lua_pcallk'.
663
** If a '__close' method yields here, eventually control will be back
664
** to 'finishCcall' (when that '__close' method finally returns) and
665
** 'finishpcallk' will run again and close any still pending '__close'
666
** methods. Similarly, if a '__close' method errs, 'precover' calls
667
** 'unroll' which calls ''finishCcall' and we are back here again, to
668
** close any pending '__close' methods.
669
** Note that, up to the call to 'luaF_close', the corresponding
670
** 'CallInfo' is not modified, so that this repeated run works like the
671
** first one (except that it has at least one less '__close' to do). In
672
** particular, field CIST_RECST preserves the error status across these
673
** multiple runs, changing only if there is a new error.
674
*/
675
0
static int finishpcallk (lua_State *L,  CallInfo *ci) {
676
0
  int status = getcistrecst(ci);  /* get original status */
677
0
  if (l_likely(status == LUA_OK))  /* no error? */
678
0
    status = LUA_YIELD;  /* was interrupted by an yield */
679
0
  else {  /* error */
680
0
    StkId func = restorestack(L, ci->u2.funcidx);
681
0
    L->allowhook = getoah(ci->callstatus);  /* restore 'allowhook' */
682
0
    func = luaF_close(L, func, status, 1);  /* can yield or raise an error */
683
0
    luaD_seterrorobj(L, status, func);
684
0
    luaD_shrinkstack(L);   /* restore stack size in case of overflow */
685
0
    setcistrecst(ci, LUA_OK);  /* clear original status */
686
0
  }
687
0
  ci->callstatus &= ~CIST_YPCALL;
688
0
  L->errfunc = ci->u.c.old_errfunc;
689
  /* if it is here, there were errors or yields; unlike 'lua_pcallk',
690
     do not change status */
691
0
  return status;
692
0
}
693
694
695
/*
696
** Completes the execution of a C function interrupted by an yield.
697
** The interruption must have happened while the function was either
698
** closing its tbc variables in 'moveresults' or executing
699
** 'lua_callk'/'lua_pcallk'. In the first case, it just redoes
700
** 'luaD_poscall'. In the second case, the call to 'finishpcallk'
701
** finishes the interrupted execution of 'lua_pcallk'.  After that, it
702
** calls the continuation of the interrupted function and finally it
703
** completes the job of the 'luaD_call' that called the function.  In
704
** the call to 'adjustresults', we do not know the number of results
705
** of the function called by 'lua_callk'/'lua_pcallk', so we are
706
** conservative and use LUA_MULTRET (always adjust).
707
*/
708
0
static void finishCcall (lua_State *L, CallInfo *ci) {
709
0
  int n;  /* actual number of results from C function */
710
0
  if (ci->callstatus & CIST_CLSRET) {  /* was returning? */
711
0
    lua_assert(hastocloseCfunc(ci->nresults));
712
0
    n = ci->u2.nres;  /* just redo 'luaD_poscall' */
713
    /* don't need to reset CIST_CLSRET, as it will be set again anyway */
714
0
  }
715
0
  else {
716
0
    int status = LUA_YIELD;  /* default if there were no errors */
717
    /* must have a continuation and must be able to call it */
718
0
    lua_assert(ci->u.c.k != NULL && yieldable(L));
719
0
    if (ci->callstatus & CIST_YPCALL)   /* was inside a 'lua_pcallk'? */
720
0
      status = finishpcallk(L, ci);  /* finish it */
721
0
    adjustresults(L, LUA_MULTRET);  /* finish 'lua_callk' */
722
0
    lua_unlock(L);
723
0
    n = (*ci->u.c.k)(L, status, ci->u.c.ctx);  /* call continuation */
724
0
    lua_lock(L);
725
0
    api_checknelems(L, n);
726
0
  }
727
0
  luaD_poscall(L, ci, n);  /* finish 'luaD_call' */
728
0
}
729
730
731
/*
732
** Executes "full continuation" (everything in the stack) of a
733
** previously interrupted coroutine until the stack is empty (or another
734
** interruption long-jumps out of the loop).
735
*/
736
0
static void unroll (lua_State *L, void *ud) {
737
0
  CallInfo *ci;
738
0
  UNUSED(ud);
739
0
  while ((ci = L->ci) != &L->base_ci) {  /* something in the stack */
740
0
    if (!isLua(ci))  /* C function? */
741
0
      finishCcall(L, ci);  /* complete its execution */
742
0
    else {  /* Lua function */
743
0
      luaV_finishOp(L);  /* finish interrupted instruction */
744
0
      luaV_execute(L, ci);  /* execute down to higher C 'boundary' */
745
0
    }
746
0
  }
747
0
}
748
749
750
/*
751
** Try to find a suspended protected call (a "recover point") for the
752
** given thread.
753
*/
754
0
static CallInfo *findpcall (lua_State *L) {
755
0
  CallInfo *ci;
756
0
  for (ci = L->ci; ci != NULL; ci = ci->previous) {  /* search for a pcall */
757
0
    if (ci->callstatus & CIST_YPCALL)
758
0
      return ci;
759
0
  }
760
0
  return NULL;  /* no pending pcall */
761
0
}
762
763
764
/*
765
** Signal an error in the call to 'lua_resume', not in the execution
766
** of the coroutine itself. (Such errors should not be handled by any
767
** coroutine error handler and should not kill the coroutine.)
768
*/
769
0
static int resume_error (lua_State *L, const char *msg, int narg) {
770
0
  api_checkpop(L, narg);
771
0
  L->top.p -= narg;  /* remove args from the stack */
772
0
  setsvalue2s(L, L->top.p, luaS_new(L, msg));  /* push error message */
773
0
  api_incr_top(L);
774
0
  lua_unlock(L);
775
0
  return LUA_ERRRUN;
776
0
}
777
778
779
/*
780
** Do the work for 'lua_resume' in protected mode. Most of the work
781
** depends on the status of the coroutine: initial state, suspended
782
** inside a hook, or regularly suspended (optionally with a continuation
783
** function), plus erroneous cases: non-suspended coroutine or dead
784
** coroutine.
785
*/
786
1
static void resume (lua_State *L, void *ud) {
787
1
  int n = *(cast(int*, ud));  /* number of arguments */
788
1
  StkId firstArg = L->top.p - n;  /* first argument */
789
1
  CallInfo *ci = L->ci;
790
1
  if (L->status == LUA_OK)  /* starting a coroutine? */
791
1
    ccall(L, firstArg - 1, LUA_MULTRET, 0);  /* just call its body */
792
0
  else {  /* resuming from previous yield */
793
0
    lua_assert(L->status == LUA_YIELD);
794
0
    L->status = LUA_OK;  /* mark that it is running (again) */
795
0
    if (isLua(ci)) {  /* yielded inside a hook? */
796
      /* undo increment made by 'luaG_traceexec': instruction was not
797
         executed yet */
798
0
      lua_assert(ci->callstatus & CIST_HOOKYIELD);
799
0
      ci->u.l.savedpc--;
800
0
      L->top.p = firstArg;  /* discard arguments */
801
0
      luaV_execute(L, ci);  /* just continue running Lua code */
802
0
    }
803
0
    else {  /* 'common' yield */
804
0
      if (ci->u.c.k != NULL) {  /* does it have a continuation function? */
805
0
        lua_unlock(L);
806
0
        n = (*ci->u.c.k)(L, LUA_YIELD, ci->u.c.ctx); /* call continuation */
807
0
        lua_lock(L);
808
0
        api_checknelems(L, n);
809
0
      }
810
0
      luaD_poscall(L, ci, n);  /* finish 'luaD_call' */
811
0
    }
812
0
    unroll(L, NULL);  /* run continuation */
813
0
  }
814
1
}
815
816
817
/*
818
** Unrolls a coroutine in protected mode while there are recoverable
819
** errors, that is, errors inside a protected call. (Any error
820
** interrupts 'unroll', and this loop protects it again so it can
821
** continue.) Stops with a normal end (status == LUA_OK), an yield
822
** (status == LUA_YIELD), or an unprotected error ('findpcall' doesn't
823
** find a recover point).
824
*/
825
1
static int precover (lua_State *L, int status) {
826
1
  CallInfo *ci;
827
1
  while (errorstatus(status) && (ci = findpcall(L)) != NULL) {
828
0
    L->ci = ci;  /* go down to recovery functions */
829
0
    setcistrecst(ci, status);  /* status to finish 'pcall' */
830
0
    status = luaD_rawrunprotected(L, unroll, NULL);
831
0
  }
832
1
  return status;
833
1
}
834
835
836
LUA_API int lua_resume (lua_State *L, lua_State *from, int nargs,
837
1
                                      int *nresults) {
838
1
  int status;
839
1
  lua_lock(L);
840
1
  if (L->status == LUA_OK) {  /* may be starting a coroutine */
841
1
    if (L->ci != &L->base_ci)  /* not in base level? */
842
0
      return resume_error(L, "cannot resume non-suspended coroutine", nargs);
843
1
    else if (L->top.p - (L->ci->func.p + 1) == nargs)  /* no function? */
844
0
      return resume_error(L, "cannot resume dead coroutine", nargs);
845
1
  }
846
0
  else if (L->status != LUA_YIELD)  /* ended with errors? */
847
0
    return resume_error(L, "cannot resume dead coroutine", nargs);
848
1
  L->nCcalls = (from) ? getCcalls(from) : 0;
849
1
  if (getCcalls(L) >= LUAI_MAXCCALLS)
850
0
    return resume_error(L, "C stack overflow", nargs);
851
1
  L->nCcalls++;
852
1
  luai_userstateresume(L, nargs);
853
1
  api_checkpop(L, (L->status == LUA_OK) ? nargs + 1 : nargs);
854
1
  status = luaD_rawrunprotected(L, resume, &nargs);
855
   /* continue running after recoverable errors */
856
1
  status = precover(L, status);
857
1
  if (l_likely(!errorstatus(status)))
858
1
    lua_assert(status == L->status);  /* normal end or yield */
859
0
  else {  /* unrecoverable error */
860
0
    L->status = cast_byte(status);  /* mark thread as 'dead' */
861
0
    luaD_seterrorobj(L, status, L->top.p);  /* push error message */
862
0
    L->ci->top.p = L->top.p;
863
0
  }
864
1
  *nresults = (status == LUA_YIELD) ? L->ci->u2.nyield
865
1
                                    : cast_int(L->top.p - (L->ci->func.p + 1));
866
1
  lua_unlock(L);
867
1
  return status;
868
1
}
869
870
871
1
LUA_API int lua_isyieldable (lua_State *L) {
872
1
  return yieldable(L);
873
1
}
874
875
876
LUA_API int lua_yieldk (lua_State *L, int nresults, lua_KContext ctx,
877
0
                        lua_KFunction k) {
878
0
  CallInfo *ci;
879
0
  luai_userstateyield(L, nresults);
880
0
  lua_lock(L);
881
0
  ci = L->ci;
882
0
  api_checkpop(L, nresults);
883
0
  if (l_unlikely(!yieldable(L))) {
884
0
    if (L != G(L)->mainthread)
885
0
      luaG_runerror(L, "attempt to yield across a C-call boundary");
886
0
    else
887
0
      luaG_runerror(L, "attempt to yield from outside a coroutine");
888
0
  }
889
0
  L->status = LUA_YIELD;
890
0
  ci->u2.nyield = nresults;  /* save number of results */
891
0
  if (isLua(ci)) {  /* inside a hook? */
892
0
    lua_assert(!isLuacode(ci));
893
0
    api_check(L, nresults == 0, "hooks cannot yield values");
894
0
    api_check(L, k == NULL, "hooks cannot continue after yielding");
895
0
  }
896
0
  else {
897
0
    if ((ci->u.c.k = k) != NULL)  /* is there a continuation? */
898
0
      ci->u.c.ctx = ctx;  /* save context */
899
0
    luaD_throw(L, LUA_YIELD);
900
0
  }
901
0
  lua_assert(ci->callstatus & CIST_HOOKED);  /* must be inside a hook */
902
0
  lua_unlock(L);
903
0
  return 0;  /* return to 'luaD_hook' */
904
0
}
905
906
907
/*
908
** Auxiliary structure to call 'luaF_close' in protected mode.
909
*/
910
struct CloseP {
911
  StkId level;
912
  int status;
913
};
914
915
916
/*
917
** Auxiliary function to call 'luaF_close' in protected mode.
918
*/
919
2.51M
static void closepaux (lua_State *L, void *ud) {
920
2.51M
  struct CloseP *pcl = cast(struct CloseP *, ud);
921
2.51M
  luaF_close(L, pcl->level, pcl->status, 0);
922
2.51M
}
923
924
925
/*
926
** Calls 'luaF_close' in protected mode. Return the original status
927
** or, in case of errors, the new status.
928
*/
929
2.51M
int luaD_closeprotected (lua_State *L, ptrdiff_t level, int status) {
930
2.51M
  CallInfo *old_ci = L->ci;
931
2.51M
  lu_byte old_allowhooks = L->allowhook;
932
2.51M
  for (;;) {  /* keep closing upvalues until no more errors */
933
2.51M
    struct CloseP pcl;
934
2.51M
    pcl.level = restorestack(L, level); pcl.status = status;
935
2.51M
    status = luaD_rawrunprotected(L, &closepaux, &pcl);
936
2.51M
    if (l_likely(status == LUA_OK))  /* no more errors? */
937
2.51M
      return pcl.status;
938
0
    else {  /* an error occurred; restore saved state and repeat */
939
0
      L->ci = old_ci;
940
0
      L->allowhook = old_allowhooks;
941
0
    }
942
2.51M
  }
943
2.51M
}
944
945
946
/*
947
** Call the C function 'func' in protected mode, restoring basic
948
** thread information ('allowhook', etc.) and in particular
949
** its stack level in case of errors.
950
*/
951
int luaD_pcall (lua_State *L, Pfunc func, void *u,
952
4.34M
                ptrdiff_t old_top, ptrdiff_t ef) {
953
4.34M
  int status;
954
4.34M
  CallInfo *old_ci = L->ci;
955
4.34M
  lu_byte old_allowhooks = L->allowhook;
956
4.34M
  ptrdiff_t old_errfunc = L->errfunc;
957
4.34M
  L->errfunc = ef;
958
4.34M
  status = luaD_rawrunprotected(L, func, u);
959
4.34M
  if (l_unlikely(status != LUA_OK)) {  /* an error occurred? */
960
2.49M
    L->ci = old_ci;
961
2.49M
    L->allowhook = old_allowhooks;
962
2.49M
    status = luaD_closeprotected(L, old_top, status);
963
2.49M
    luaD_seterrorobj(L, status, restorestack(L, old_top));
964
2.49M
    luaD_shrinkstack(L);   /* restore stack size in case of overflow */
965
2.49M
  }
966
4.34M
  L->errfunc = old_errfunc;
967
4.34M
  return status;
968
4.34M
}
969
970
971
972
/*
973
** Execute a protected parser.
974
*/
975
struct SParser {  /* data to 'f_parser' */
976
  ZIO *z;
977
  Mbuffer buff;  /* dynamic structure used by the scanner */
978
  Dyndata dyd;  /* dynamic structures used by the parser */
979
  const char *mode;
980
  const char *name;
981
};
982
983
984
2.47M
static void checkmode (lua_State *L, const char *mode, const char *x) {
985
2.47M
  if (strchr(mode, x[0]) == NULL) {
986
6.56k
    luaO_pushfstring(L,
987
6.56k
       "attempt to load a %s chunk (mode is '%s')", x, mode);
988
6.56k
    luaD_throw(L, LUA_ERRSYNTAX);
989
6.56k
  }
990
2.47M
}
991
992
993
3.42M
static void f_parser (lua_State *L, void *ud) {
994
3.42M
  LClosure *cl;
995
3.42M
  struct SParser *p = cast(struct SParser *, ud);
996
3.42M
  const char *mode = p->mode ? p->mode : "bt";
997
3.42M
  int c = zgetc(p->z);  /* read first character */
998
3.42M
  if (c == LUA_SIGNATURE[0]) {
999
51.8k
    int fixed = 0;
1000
51.8k
    if (strchr(mode, 'B') != NULL)
1001
0
      fixed = 1;
1002
51.8k
    else
1003
51.8k
      checkmode(L, mode, "binary");
1004
51.8k
    cl = luaU_undump(L, p->z, p->name, fixed);
1005
51.8k
  }
1006
3.37M
  else {
1007
3.37M
    checkmode(L, mode, "text");
1008
3.37M
    cl = luaY_parser(L, p->z, &p->buff, &p->dyd, p->name, c);
1009
3.37M
  }
1010
3.42M
  lua_assert(cl->nupvalues == cl->p->sizeupvalues);
1011
932k
  luaF_initupvals(L, cl);
1012
932k
}
1013
1014
1015
int luaD_protectedparser (lua_State *L, ZIO *z, const char *name,
1016
3.42M
                                        const char *mode) {
1017
3.42M
  struct SParser p;
1018
3.42M
  int status;
1019
3.42M
  incnny(L);  /* cannot yield during parsing */
1020
3.42M
  p.z = z; p.name = name; p.mode = mode;
1021
3.42M
  p.dyd.actvar.arr = NULL; p.dyd.actvar.size = 0;
1022
3.42M
  p.dyd.gt.arr = NULL; p.dyd.gt.size = 0;
1023
3.42M
  p.dyd.label.arr = NULL; p.dyd.label.size = 0;
1024
3.42M
  luaZ_initbuffer(L, &p.buff);
1025
3.42M
  status = luaD_pcall(L, f_parser, &p, savestack(L, L->top.p), L->errfunc);
1026
3.42M
  luaZ_freebuffer(L, &p.buff);
1027
3.42M
  luaM_freearray(L, p.dyd.actvar.arr, p.dyd.actvar.size);
1028
3.42M
  luaM_freearray(L, p.dyd.gt.arr, p.dyd.gt.size);
1029
3.42M
  luaM_freearray(L, p.dyd.label.arr, p.dyd.label.size);
1030
3.42M
  decnny(L);
1031
3.42M
  return status;
1032
3.42M
}
1033
1034