xref: /freebsd/contrib/lua/src/lvm.c (revision 1b10e191f341111fad7be32ead11484dfd09b800)
1 /*
2 ** $Id: lvm.c $
3 ** Lua virtual machine
4 ** See Copyright Notice in lua.h
5 */
6 
7 #define lvm_c
8 #define LUA_CORE
9 
10 #include "lprefix.h"
11 
12 #include <float.h>
13 #include <limits.h>
14 #include <math.h>
15 #include <stdio.h>
16 #include <stdlib.h>
17 #include <string.h>
18 
19 #include "lua.h"
20 
21 #include "ldebug.h"
22 #include "ldo.h"
23 #include "lfunc.h"
24 #include "lgc.h"
25 #include "lobject.h"
26 #include "lopcodes.h"
27 #include "lstate.h"
28 #include "lstring.h"
29 #include "ltable.h"
30 #include "ltm.h"
31 #include "lvm.h"
32 
33 
34 /*
35 ** By default, use jump tables in the main interpreter loop on gcc
36 ** and compatible compilers.
37 */
38 #if !defined(LUA_USE_JUMPTABLE)
39 #if defined(__GNUC__)
40 #define LUA_USE_JUMPTABLE	1
41 #else
42 #define LUA_USE_JUMPTABLE	0
43 #endif
44 #endif
45 
46 
47 
48 /* limit for table tag-method chains (to avoid infinite loops) */
49 #define MAXTAGLOOP	2000
50 
51 
52 /*
53 ** 'l_intfitsf' checks whether a given integer is in the range that
54 ** can be converted to a float without rounding. Used in comparisons.
55 ** May be defined in luaconf.h if this test is incorrect for custom
56 ** LUA_FLOAT_TYPEs.
57 */
58 #if !defined(l_intfitsf)
59 
60 /* number of bits in the mantissa of a float */
61 #define NBM		(l_floatatt(MANT_DIG))
62 
63 /*
64 ** Check whether some integers may not fit in a float, testing whether
65 ** (maxinteger >> NBM) > 0. (That implies (1 << NBM) <= maxinteger.)
66 ** (The shifts are done in parts, to avoid shifting by more than the size
67 ** of an integer. In a worst case, NBM == 113 for long double and
68 ** sizeof(long) == 32.)
69 */
70 #if ((((LUA_MAXINTEGER >> (NBM / 4)) >> (NBM / 4)) >> (NBM / 4)) \
71 	>> (NBM - (3 * (NBM / 4))))  >  0
72 
73 /* limit for integers that fit in a float */
74 #define MAXINTFITSF	((lua_Unsigned)1 << NBM)
75 
76 /* check whether 'i' is in the interval [-MAXINTFITSF, MAXINTFITSF] */
77 #define l_intfitsf(i)	((MAXINTFITSF + l_castS2U(i)) <= (2 * MAXINTFITSF))
78 
79 #else  /* all integers fit in a float precisely */
80 
81 #define l_intfitsf(i)	1
82 
83 #endif
84 
85 #endif /* !defined(l_intfitsf) */
86 
87 /*
88 ** Try to convert a value from string to a number value.
89 ** If the value is not a string or is a string not representing
90 ** a valid numeral (or if coercions from strings to numbers
91 ** are disabled via macro 'cvt2num'), do not modify 'result'
92 ** and return 0.
93 */
94 static int l_strton (const TValue *obj, TValue *result) {
95   lua_assert(obj != result);
96   if (!cvt2num(obj))  /* is object not a string? */
97     return 0;
98   else
99     return (luaO_str2num(svalue(obj), result) == vslen(obj) + 1);
100 }
101 
102 
103 /*
104 ** Try to convert a value to a float. The float case is already handled
105 ** by the macro 'tonumber'.
106 */
107 int luaV_tonumber_ (const TValue *obj, lua_Number *n) {
108   TValue v;
109   if (ttisinteger(obj)) {
110     *n = cast_num(ivalue(obj));
111     return 1;
112   }
113   else if (l_strton(obj, &v)) {  /* string coercible to number? */
114     *n = nvalue(&v);  /* convert result of 'luaO_str2num' to a float */
115     return 1;
116   }
117   else
118     return 0;  /* conversion failed */
119 }
120 
121 
122 /*
123 ** try to convert a float to an integer, rounding according to 'mode'.
124 */
125 int luaV_flttointeger (lua_Number n, lua_Integer *p, F2Imod mode) {
126   lua_Number f = l_floor(n);
127   if (n != f) {  /* not an integral value? */
128     if (mode == F2Ieq) return 0;  /* fails if mode demands integral value */
129     else if (mode == F2Iceil)  /* needs ceil? */
130       f += 1;  /* convert floor to ceil (remember: n != f) */
131   }
132   return lua_numbertointeger(f, p);
133 }
134 
135 
136 /*
137 ** try to convert a value to an integer, rounding according to 'mode',
138 ** without string coercion.
139 ** ("Fast track" handled by macro 'tointegerns'.)
140 */
141 int luaV_tointegerns (const TValue *obj, lua_Integer *p, F2Imod mode) {
142   if (ttisfloat(obj))
143     return luaV_flttointeger(fltvalue(obj), p, mode);
144   else if (ttisinteger(obj)) {
145     *p = ivalue(obj);
146     return 1;
147   }
148   else
149     return 0;
150 }
151 
152 
153 /*
154 ** try to convert a value to an integer.
155 */
156 int luaV_tointeger (const TValue *obj, lua_Integer *p, F2Imod mode) {
157   TValue v;
158   if (l_strton(obj, &v))  /* does 'obj' point to a numerical string? */
159     obj = &v;  /* change it to point to its corresponding number */
160   return luaV_tointegerns(obj, p, mode);
161 }
162 
163 
164 /*
165 ** Try to convert a 'for' limit to an integer, preserving the semantics
166 ** of the loop. Return true if the loop must not run; otherwise, '*p'
167 ** gets the integer limit.
168 ** (The following explanation assumes a positive step; it is valid for
169 ** negative steps mutatis mutandis.)
170 ** If the limit is an integer or can be converted to an integer,
171 ** rounding down, that is the limit.
172 ** Otherwise, check whether the limit can be converted to a float. If
173 ** the float is too large, clip it to LUA_MAXINTEGER.  If the float
174 ** is too negative, the loop should not run, because any initial
175 ** integer value is greater than such limit; so, the function returns
176 ** true to signal that. (For this latter case, no integer limit would be
177 ** correct; even a limit of LUA_MININTEGER would run the loop once for
178 ** an initial value equal to LUA_MININTEGER.)
179 */
180 static int forlimit (lua_State *L, lua_Integer init, const TValue *lim,
181                                    lua_Integer *p, lua_Integer step) {
182   if (!luaV_tointeger(lim, p, (step < 0 ? F2Iceil : F2Ifloor))) {
183     /* not coercible to in integer */
184     lua_Number flim;  /* try to convert to float */
185     if (!tonumber(lim, &flim)) /* cannot convert to float? */
186       luaG_forerror(L, lim, "limit");
187     /* else 'flim' is a float out of integer bounds */
188     if (luai_numlt(0, flim)) {  /* if it is positive, it is too large */
189       if (step < 0) return 1;  /* initial value must be less than it */
190       *p = LUA_MAXINTEGER;  /* truncate */
191     }
192     else {  /* it is less than min integer */
193       if (step > 0) return 1;  /* initial value must be greater than it */
194       *p = LUA_MININTEGER;  /* truncate */
195     }
196   }
197   return (step > 0 ? init > *p : init < *p);  /* not to run? */
198 }
199 
200 
201 /*
202 ** Prepare a numerical for loop (opcode OP_FORPREP).
203 ** Return true to skip the loop. Otherwise,
204 ** after preparation, stack will be as follows:
205 **   ra : internal index (safe copy of the control variable)
206 **   ra + 1 : loop counter (integer loops) or limit (float loops)
207 **   ra + 2 : step
208 **   ra + 3 : control variable
209 */
210 static int forprep (lua_State *L, StkId ra) {
211   TValue *pinit = s2v(ra);
212   TValue *plimit = s2v(ra + 1);
213   TValue *pstep = s2v(ra + 2);
214   if (ttisinteger(pinit) && ttisinteger(pstep)) { /* integer loop? */
215     lua_Integer init = ivalue(pinit);
216     lua_Integer step = ivalue(pstep);
217     lua_Integer limit;
218     if (step == 0)
219       luaG_runerror(L, "'for' step is zero");
220     setivalue(s2v(ra + 3), init);  /* control variable */
221     if (forlimit(L, init, plimit, &limit, step))
222       return 1;  /* skip the loop */
223     else {  /* prepare loop counter */
224       lua_Unsigned count;
225       if (step > 0) {  /* ascending loop? */
226         count = l_castS2U(limit) - l_castS2U(init);
227         if (step != 1)  /* avoid division in the too common case */
228           count /= l_castS2U(step);
229       }
230       else {  /* step < 0; descending loop */
231         count = l_castS2U(init) - l_castS2U(limit);
232         /* 'step+1' avoids negating 'mininteger' */
233         count /= l_castS2U(-(step + 1)) + 1u;
234       }
235       /* store the counter in place of the limit (which won't be
236          needed anymore) */
237       setivalue(plimit, l_castU2S(count));
238     }
239   }
240   else {  /* try making all values floats */
241     lua_Number init; lua_Number limit; lua_Number step;
242     if (l_unlikely(!tonumber(plimit, &limit)))
243       luaG_forerror(L, plimit, "limit");
244     if (l_unlikely(!tonumber(pstep, &step)))
245       luaG_forerror(L, pstep, "step");
246     if (l_unlikely(!tonumber(pinit, &init)))
247       luaG_forerror(L, pinit, "initial value");
248     if (step == 0)
249       luaG_runerror(L, "'for' step is zero");
250     if (luai_numlt(0, step) ? luai_numlt(limit, init)
251                             : luai_numlt(init, limit))
252       return 1;  /* skip the loop */
253     else {
254       /* make sure internal values are all floats */
255       setfltvalue(plimit, limit);
256       setfltvalue(pstep, step);
257       setfltvalue(s2v(ra), init);  /* internal index */
258       setfltvalue(s2v(ra + 3), init);  /* control variable */
259     }
260   }
261   return 0;
262 }
263 
264 
265 /*
266 ** Execute a step of a float numerical for loop, returning
267 ** true iff the loop must continue. (The integer case is
268 ** written online with opcode OP_FORLOOP, for performance.)
269 */
270 static int floatforloop (StkId ra) {
271   lua_Number step = fltvalue(s2v(ra + 2));
272   lua_Number limit = fltvalue(s2v(ra + 1));
273   lua_Number idx = fltvalue(s2v(ra));  /* internal index */
274   idx = luai_numadd(L, idx, step);  /* increment index */
275   if (luai_numlt(0, step) ? luai_numle(idx, limit)
276                           : luai_numle(limit, idx)) {
277     chgfltvalue(s2v(ra), idx);  /* update internal index */
278     setfltvalue(s2v(ra + 3), idx);  /* and control variable */
279     return 1;  /* jump back */
280   }
281   else
282     return 0;  /* finish the loop */
283 }
284 
285 
286 /*
287 ** Finish the table access 'val = t[key]'.
288 ** if 'slot' is NULL, 't' is not a table; otherwise, 'slot' points to
289 ** t[k] entry (which must be empty).
290 */
291 void luaV_finishget (lua_State *L, const TValue *t, TValue *key, StkId val,
292                       const TValue *slot) {
293   int loop;  /* counter to avoid infinite loops */
294   const TValue *tm;  /* metamethod */
295   for (loop = 0; loop < MAXTAGLOOP; loop++) {
296     if (slot == NULL) {  /* 't' is not a table? */
297       lua_assert(!ttistable(t));
298       tm = luaT_gettmbyobj(L, t, TM_INDEX);
299       if (l_unlikely(notm(tm)))
300         luaG_typeerror(L, t, "index");  /* no metamethod */
301       /* else will try the metamethod */
302     }
303     else {  /* 't' is a table */
304       lua_assert(isempty(slot));
305       tm = fasttm(L, hvalue(t)->metatable, TM_INDEX);  /* table's metamethod */
306       if (tm == NULL) {  /* no metamethod? */
307         setnilvalue(s2v(val));  /* result is nil */
308         return;
309       }
310       /* else will try the metamethod */
311     }
312     if (ttisfunction(tm)) {  /* is metamethod a function? */
313       luaT_callTMres(L, tm, t, key, val);  /* call it */
314       return;
315     }
316     t = tm;  /* else try to access 'tm[key]' */
317     if (luaV_fastget(L, t, key, slot, luaH_get)) {  /* fast track? */
318       setobj2s(L, val, slot);  /* done */
319       return;
320     }
321     /* else repeat (tail call 'luaV_finishget') */
322   }
323   luaG_runerror(L, "'__index' chain too long; possible loop");
324 }
325 
326 
327 /*
328 ** Finish a table assignment 't[key] = val'.
329 ** If 'slot' is NULL, 't' is not a table.  Otherwise, 'slot' points
330 ** to the entry 't[key]', or to a value with an absent key if there
331 ** is no such entry.  (The value at 'slot' must be empty, otherwise
332 ** 'luaV_fastget' would have done the job.)
333 */
334 void luaV_finishset (lua_State *L, const TValue *t, TValue *key,
335                      TValue *val, const TValue *slot) {
336   int loop;  /* counter to avoid infinite loops */
337   for (loop = 0; loop < MAXTAGLOOP; loop++) {
338     const TValue *tm;  /* '__newindex' metamethod */
339     if (slot != NULL) {  /* is 't' a table? */
340       Table *h = hvalue(t);  /* save 't' table */
341       lua_assert(isempty(slot));  /* slot must be empty */
342       tm = fasttm(L, h->metatable, TM_NEWINDEX);  /* get metamethod */
343       if (tm == NULL) {  /* no metamethod? */
344         luaH_finishset(L, h, key, slot, val);  /* set new value */
345         invalidateTMcache(h);
346         luaC_barrierback(L, obj2gco(h), val);
347         return;
348       }
349       /* else will try the metamethod */
350     }
351     else {  /* not a table; check metamethod */
352       tm = luaT_gettmbyobj(L, t, TM_NEWINDEX);
353       if (l_unlikely(notm(tm)))
354         luaG_typeerror(L, t, "index");
355     }
356     /* try the metamethod */
357     if (ttisfunction(tm)) {
358       luaT_callTM(L, tm, t, key, val);
359       return;
360     }
361     t = tm;  /* else repeat assignment over 'tm' */
362     if (luaV_fastget(L, t, key, slot, luaH_get)) {
363       luaV_finishfastset(L, t, slot, val);
364       return;  /* done */
365     }
366     /* else 'return luaV_finishset(L, t, key, val, slot)' (loop) */
367   }
368   luaG_runerror(L, "'__newindex' chain too long; possible loop");
369 }
370 
371 
372 /*
373 ** Compare two strings 'ls' x 'rs', returning an integer less-equal-
374 ** -greater than zero if 'ls' is less-equal-greater than 'rs'.
375 ** The code is a little tricky because it allows '\0' in the strings
376 ** and it uses 'strcoll' (to respect locales) for each segments
377 ** of the strings.
378 */
379 static int l_strcmp (const TString *ls, const TString *rs) {
380   const char *l = getstr(ls);
381   size_t ll = tsslen(ls);
382   const char *r = getstr(rs);
383   size_t lr = tsslen(rs);
384   for (;;) {  /* for each segment */
385     int temp = strcoll(l, r);
386     if (temp != 0)  /* not equal? */
387       return temp;  /* done */
388     else {  /* strings are equal up to a '\0' */
389       size_t len = strlen(l);  /* index of first '\0' in both strings */
390       if (len == lr)  /* 'rs' is finished? */
391         return (len == ll) ? 0 : 1;  /* check 'ls' */
392       else if (len == ll)  /* 'ls' is finished? */
393         return -1;  /* 'ls' is less than 'rs' ('rs' is not finished) */
394       /* both strings longer than 'len'; go on comparing after the '\0' */
395       len++;
396       l += len; ll -= len; r += len; lr -= len;
397     }
398   }
399 }
400 
401 
402 /*
403 ** Check whether integer 'i' is less than float 'f'. If 'i' has an
404 ** exact representation as a float ('l_intfitsf'), compare numbers as
405 ** floats. Otherwise, use the equivalence 'i < f <=> i < ceil(f)'.
406 ** If 'ceil(f)' is out of integer range, either 'f' is greater than
407 ** all integers or less than all integers.
408 ** (The test with 'l_intfitsf' is only for performance; the else
409 ** case is correct for all values, but it is slow due to the conversion
410 ** from float to int.)
411 ** When 'f' is NaN, comparisons must result in false.
412 */
413 l_sinline int LTintfloat (lua_Integer i, lua_Number f) {
414   if (l_intfitsf(i))
415     return luai_numlt(cast_num(i), f);  /* compare them as floats */
416   else {  /* i < f <=> i < ceil(f) */
417     lua_Integer fi;
418     if (luaV_flttointeger(f, &fi, F2Iceil))  /* fi = ceil(f) */
419       return i < fi;   /* compare them as integers */
420     else  /* 'f' is either greater or less than all integers */
421       return f > 0;  /* greater? */
422   }
423 }
424 
425 
426 /*
427 ** Check whether integer 'i' is less than or equal to float 'f'.
428 ** See comments on previous function.
429 */
430 l_sinline int LEintfloat (lua_Integer i, lua_Number f) {
431   if (l_intfitsf(i))
432     return luai_numle(cast_num(i), f);  /* compare them as floats */
433   else {  /* i <= f <=> i <= floor(f) */
434     lua_Integer fi;
435     if (luaV_flttointeger(f, &fi, F2Ifloor))  /* fi = floor(f) */
436       return i <= fi;   /* compare them as integers */
437     else  /* 'f' is either greater or less than all integers */
438       return f > 0;  /* greater? */
439   }
440 }
441 
442 
443 /*
444 ** Check whether float 'f' is less than integer 'i'.
445 ** See comments on previous function.
446 */
447 l_sinline int LTfloatint (lua_Number f, lua_Integer i) {
448   if (l_intfitsf(i))
449     return luai_numlt(f, cast_num(i));  /* compare them as floats */
450   else {  /* f < i <=> floor(f) < i */
451     lua_Integer fi;
452     if (luaV_flttointeger(f, &fi, F2Ifloor))  /* fi = floor(f) */
453       return fi < i;   /* compare them as integers */
454     else  /* 'f' is either greater or less than all integers */
455       return f < 0;  /* less? */
456   }
457 }
458 
459 
460 /*
461 ** Check whether float 'f' is less than or equal to integer 'i'.
462 ** See comments on previous function.
463 */
464 l_sinline int LEfloatint (lua_Number f, lua_Integer i) {
465   if (l_intfitsf(i))
466     return luai_numle(f, cast_num(i));  /* compare them as floats */
467   else {  /* f <= i <=> ceil(f) <= i */
468     lua_Integer fi;
469     if (luaV_flttointeger(f, &fi, F2Iceil))  /* fi = ceil(f) */
470       return fi <= i;   /* compare them as integers */
471     else  /* 'f' is either greater or less than all integers */
472       return f < 0;  /* less? */
473   }
474 }
475 
476 
477 /*
478 ** Return 'l < r', for numbers.
479 */
480 l_sinline int LTnum (const TValue *l, const TValue *r) {
481   lua_assert(ttisnumber(l) && ttisnumber(r));
482   if (ttisinteger(l)) {
483     lua_Integer li = ivalue(l);
484     if (ttisinteger(r))
485       return li < ivalue(r);  /* both are integers */
486     else  /* 'l' is int and 'r' is float */
487       return LTintfloat(li, fltvalue(r));  /* l < r ? */
488   }
489   else {
490     lua_Number lf = fltvalue(l);  /* 'l' must be float */
491     if (ttisfloat(r))
492       return luai_numlt(lf, fltvalue(r));  /* both are float */
493     else  /* 'l' is float and 'r' is int */
494       return LTfloatint(lf, ivalue(r));
495   }
496 }
497 
498 
499 /*
500 ** Return 'l <= r', for numbers.
501 */
502 l_sinline int LEnum (const TValue *l, const TValue *r) {
503   lua_assert(ttisnumber(l) && ttisnumber(r));
504   if (ttisinteger(l)) {
505     lua_Integer li = ivalue(l);
506     if (ttisinteger(r))
507       return li <= ivalue(r);  /* both are integers */
508     else  /* 'l' is int and 'r' is float */
509       return LEintfloat(li, fltvalue(r));  /* l <= r ? */
510   }
511   else {
512     lua_Number lf = fltvalue(l);  /* 'l' must be float */
513     if (ttisfloat(r))
514       return luai_numle(lf, fltvalue(r));  /* both are float */
515     else  /* 'l' is float and 'r' is int */
516       return LEfloatint(lf, ivalue(r));
517   }
518 }
519 
520 
521 /*
522 ** return 'l < r' for non-numbers.
523 */
524 static int lessthanothers (lua_State *L, const TValue *l, const TValue *r) {
525   lua_assert(!ttisnumber(l) || !ttisnumber(r));
526   if (ttisstring(l) && ttisstring(r))  /* both are strings? */
527     return l_strcmp(tsvalue(l), tsvalue(r)) < 0;
528   else
529     return luaT_callorderTM(L, l, r, TM_LT);
530 }
531 
532 
533 /*
534 ** Main operation less than; return 'l < r'.
535 */
536 int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r) {
537   if (ttisnumber(l) && ttisnumber(r))  /* both operands are numbers? */
538     return LTnum(l, r);
539   else return lessthanothers(L, l, r);
540 }
541 
542 
543 /*
544 ** return 'l <= r' for non-numbers.
545 */
546 static int lessequalothers (lua_State *L, const TValue *l, const TValue *r) {
547   lua_assert(!ttisnumber(l) || !ttisnumber(r));
548   if (ttisstring(l) && ttisstring(r))  /* both are strings? */
549     return l_strcmp(tsvalue(l), tsvalue(r)) <= 0;
550   else
551     return luaT_callorderTM(L, l, r, TM_LE);
552 }
553 
554 
555 /*
556 ** Main operation less than or equal to; return 'l <= r'.
557 */
558 int luaV_lessequal (lua_State *L, const TValue *l, const TValue *r) {
559   if (ttisnumber(l) && ttisnumber(r))  /* both operands are numbers? */
560     return LEnum(l, r);
561   else return lessequalothers(L, l, r);
562 }
563 
564 
565 /*
566 ** Main operation for equality of Lua values; return 't1 == t2'.
567 ** L == NULL means raw equality (no metamethods)
568 */
569 int luaV_equalobj (lua_State *L, const TValue *t1, const TValue *t2) {
570   const TValue *tm;
571   if (ttypetag(t1) != ttypetag(t2)) {  /* not the same variant? */
572     if (ttype(t1) != ttype(t2) || ttype(t1) != LUA_TNUMBER)
573       return 0;  /* only numbers can be equal with different variants */
574     else {  /* two numbers with different variants */
575       /* One of them is an integer. If the other does not have an
576          integer value, they cannot be equal; otherwise, compare their
577          integer values. */
578       lua_Integer i1, i2;
579       return (luaV_tointegerns(t1, &i1, F2Ieq) &&
580               luaV_tointegerns(t2, &i2, F2Ieq) &&
581               i1 == i2);
582     }
583   }
584   /* values have same type and same variant */
585   switch (ttypetag(t1)) {
586     case LUA_VNIL: case LUA_VFALSE: case LUA_VTRUE: return 1;
587     case LUA_VNUMINT: return (ivalue(t1) == ivalue(t2));
588     case LUA_VNUMFLT: return luai_numeq(fltvalue(t1), fltvalue(t2));
589     case LUA_VLIGHTUSERDATA: return pvalue(t1) == pvalue(t2);
590     case LUA_VLCF: return fvalue(t1) == fvalue(t2);
591     case LUA_VSHRSTR: return eqshrstr(tsvalue(t1), tsvalue(t2));
592     case LUA_VLNGSTR: return luaS_eqlngstr(tsvalue(t1), tsvalue(t2));
593     case LUA_VUSERDATA: {
594       if (uvalue(t1) == uvalue(t2)) return 1;
595       else if (L == NULL) return 0;
596       tm = fasttm(L, uvalue(t1)->metatable, TM_EQ);
597       if (tm == NULL)
598         tm = fasttm(L, uvalue(t2)->metatable, TM_EQ);
599       break;  /* will try TM */
600     }
601     case LUA_VTABLE: {
602       if (hvalue(t1) == hvalue(t2)) return 1;
603       else if (L == NULL) return 0;
604       tm = fasttm(L, hvalue(t1)->metatable, TM_EQ);
605       if (tm == NULL)
606         tm = fasttm(L, hvalue(t2)->metatable, TM_EQ);
607       break;  /* will try TM */
608     }
609     default:
610       return gcvalue(t1) == gcvalue(t2);
611   }
612   if (tm == NULL)  /* no TM? */
613     return 0;  /* objects are different */
614   else {
615     luaT_callTMres(L, tm, t1, t2, L->top);  /* call TM */
616     return !l_isfalse(s2v(L->top));
617   }
618 }
619 
620 
621 /* macro used by 'luaV_concat' to ensure that element at 'o' is a string */
622 #define tostring(L,o)  \
623 	(ttisstring(o) || (cvt2str(o) && (luaO_tostring(L, o), 1)))
624 
625 #define isemptystr(o)	(ttisshrstring(o) && tsvalue(o)->shrlen == 0)
626 
627 /* copy strings in stack from top - n up to top - 1 to buffer */
628 static void copy2buff (StkId top, int n, char *buff) {
629   size_t tl = 0;  /* size already copied */
630   do {
631     size_t l = vslen(s2v(top - n));  /* length of string being copied */
632     memcpy(buff + tl, svalue(s2v(top - n)), l * sizeof(char));
633     tl += l;
634   } while (--n > 0);
635 }
636 
637 
638 /*
639 ** Main operation for concatenation: concat 'total' values in the stack,
640 ** from 'L->top - total' up to 'L->top - 1'.
641 */
642 void luaV_concat (lua_State *L, int total) {
643   if (total == 1)
644     return;  /* "all" values already concatenated */
645   do {
646     StkId top = L->top;
647     int n = 2;  /* number of elements handled in this pass (at least 2) */
648     if (!(ttisstring(s2v(top - 2)) || cvt2str(s2v(top - 2))) ||
649         !tostring(L, s2v(top - 1)))
650       luaT_tryconcatTM(L);
651     else if (isemptystr(s2v(top - 1)))  /* second operand is empty? */
652       cast_void(tostring(L, s2v(top - 2)));  /* result is first operand */
653     else if (isemptystr(s2v(top - 2))) {  /* first operand is empty string? */
654       setobjs2s(L, top - 2, top - 1);  /* result is second op. */
655     }
656     else {
657       /* at least two non-empty string values; get as many as possible */
658       size_t tl = vslen(s2v(top - 1));
659       TString *ts;
660       /* collect total length and number of strings */
661       for (n = 1; n < total && tostring(L, s2v(top - n - 1)); n++) {
662         size_t l = vslen(s2v(top - n - 1));
663         if (l_unlikely(l >= (MAX_SIZE/sizeof(char)) - tl))
664           luaG_runerror(L, "string length overflow");
665         tl += l;
666       }
667       if (tl <= LUAI_MAXSHORTLEN) {  /* is result a short string? */
668         char buff[LUAI_MAXSHORTLEN];
669         copy2buff(top, n, buff);  /* copy strings to buffer */
670         ts = luaS_newlstr(L, buff, tl);
671       }
672       else {  /* long string; copy strings directly to final result */
673         ts = luaS_createlngstrobj(L, tl);
674         copy2buff(top, n, getstr(ts));
675       }
676       setsvalue2s(L, top - n, ts);  /* create result */
677     }
678     total -= n-1;  /* got 'n' strings to create 1 new */
679     L->top -= n-1;  /* popped 'n' strings and pushed one */
680   } while (total > 1);  /* repeat until only 1 result left */
681 }
682 
683 
684 /*
685 ** Main operation 'ra = #rb'.
686 */
687 void luaV_objlen (lua_State *L, StkId ra, const TValue *rb) {
688   const TValue *tm;
689   switch (ttypetag(rb)) {
690     case LUA_VTABLE: {
691       Table *h = hvalue(rb);
692       tm = fasttm(L, h->metatable, TM_LEN);
693       if (tm) break;  /* metamethod? break switch to call it */
694       setivalue(s2v(ra), luaH_getn(h));  /* else primitive len */
695       return;
696     }
697     case LUA_VSHRSTR: {
698       setivalue(s2v(ra), tsvalue(rb)->shrlen);
699       return;
700     }
701     case LUA_VLNGSTR: {
702       setivalue(s2v(ra), tsvalue(rb)->u.lnglen);
703       return;
704     }
705     default: {  /* try metamethod */
706       tm = luaT_gettmbyobj(L, rb, TM_LEN);
707       if (l_unlikely(notm(tm)))  /* no metamethod? */
708         luaG_typeerror(L, rb, "get length of");
709       break;
710     }
711   }
712   luaT_callTMres(L, tm, rb, rb, ra);
713 }
714 
715 
716 /*
717 ** Integer division; return 'm // n', that is, floor(m/n).
718 ** C division truncates its result (rounds towards zero).
719 ** 'floor(q) == trunc(q)' when 'q >= 0' or when 'q' is integer,
720 ** otherwise 'floor(q) == trunc(q) - 1'.
721 */
722 lua_Integer luaV_idiv (lua_State *L, lua_Integer m, lua_Integer n) {
723   if (l_unlikely(l_castS2U(n) + 1u <= 1u)) {  /* special cases: -1 or 0 */
724     if (n == 0)
725       luaG_runerror(L, "attempt to divide by zero");
726     return intop(-, 0, m);   /* n==-1; avoid overflow with 0x80000...//-1 */
727   }
728   else {
729     lua_Integer q = m / n;  /* perform C division */
730     if ((m ^ n) < 0 && m % n != 0)  /* 'm/n' would be negative non-integer? */
731       q -= 1;  /* correct result for different rounding */
732     return q;
733   }
734 }
735 
736 
737 /*
738 ** Integer modulus; return 'm % n'. (Assume that C '%' with
739 ** negative operands follows C99 behavior. See previous comment
740 ** about luaV_idiv.)
741 */
742 lua_Integer luaV_mod (lua_State *L, lua_Integer m, lua_Integer n) {
743   if (l_unlikely(l_castS2U(n) + 1u <= 1u)) {  /* special cases: -1 or 0 */
744     if (n == 0)
745       luaG_runerror(L, "attempt to perform 'n%%0'");
746     return 0;   /* m % -1 == 0; avoid overflow with 0x80000...%-1 */
747   }
748   else {
749     lua_Integer r = m % n;
750     if (r != 0 && (r ^ n) < 0)  /* 'm/n' would be non-integer negative? */
751       r += n;  /* correct result for different rounding */
752     return r;
753   }
754 }
755 
756 
757 /*
758 ** Float modulus
759 */
760 lua_Number luaV_modf (lua_State *L, lua_Number m, lua_Number n) {
761   lua_Number r;
762   luai_nummod(L, m, n, r);
763   return r;
764 }
765 
766 
767 /* number of bits in an integer */
768 #define NBITS	cast_int(sizeof(lua_Integer) * CHAR_BIT)
769 
770 /*
771 ** Shift left operation. (Shift right just negates 'y'.)
772 */
773 #define luaV_shiftr(x,y)	luaV_shiftl(x,intop(-, 0, y))
774 
775 
776 lua_Integer luaV_shiftl (lua_Integer x, lua_Integer y) {
777   if (y < 0) {  /* shift right? */
778     if (y <= -NBITS) return 0;
779     else return intop(>>, x, -y);
780   }
781   else {  /* shift left */
782     if (y >= NBITS) return 0;
783     else return intop(<<, x, y);
784   }
785 }
786 
787 
788 /*
789 ** create a new Lua closure, push it in the stack, and initialize
790 ** its upvalues.
791 */
792 static void pushclosure (lua_State *L, Proto *p, UpVal **encup, StkId base,
793                          StkId ra) {
794   int nup = p->sizeupvalues;
795   Upvaldesc *uv = p->upvalues;
796   int i;
797   LClosure *ncl = luaF_newLclosure(L, nup);
798   ncl->p = p;
799   setclLvalue2s(L, ra, ncl);  /* anchor new closure in stack */
800   for (i = 0; i < nup; i++) {  /* fill in its upvalues */
801     if (uv[i].instack)  /* upvalue refers to local variable? */
802       ncl->upvals[i] = luaF_findupval(L, base + uv[i].idx);
803     else  /* get upvalue from enclosing function */
804       ncl->upvals[i] = encup[uv[i].idx];
805     luaC_objbarrier(L, ncl, ncl->upvals[i]);
806   }
807 }
808 
809 
810 /*
811 ** finish execution of an opcode interrupted by a yield
812 */
813 void luaV_finishOp (lua_State *L) {
814   CallInfo *ci = L->ci;
815   StkId base = ci->func + 1;
816   Instruction inst = *(ci->u.l.savedpc - 1);  /* interrupted instruction */
817   OpCode op = GET_OPCODE(inst);
818   switch (op) {  /* finish its execution */
819     case OP_MMBIN: case OP_MMBINI: case OP_MMBINK: {
820       setobjs2s(L, base + GETARG_A(*(ci->u.l.savedpc - 2)), --L->top);
821       break;
822     }
823     case OP_UNM: case OP_BNOT: case OP_LEN:
824     case OP_GETTABUP: case OP_GETTABLE: case OP_GETI:
825     case OP_GETFIELD: case OP_SELF: {
826       setobjs2s(L, base + GETARG_A(inst), --L->top);
827       break;
828     }
829     case OP_LT: case OP_LE:
830     case OP_LTI: case OP_LEI:
831     case OP_GTI: case OP_GEI:
832     case OP_EQ: {  /* note that 'OP_EQI'/'OP_EQK' cannot yield */
833       int res = !l_isfalse(s2v(L->top - 1));
834       L->top--;
835 #if defined(LUA_COMPAT_LT_LE)
836       if (ci->callstatus & CIST_LEQ) {  /* "<=" using "<" instead? */
837         ci->callstatus ^= CIST_LEQ;  /* clear mark */
838         res = !res;  /* negate result */
839       }
840 #endif
841       lua_assert(GET_OPCODE(*ci->u.l.savedpc) == OP_JMP);
842       if (res != GETARG_k(inst))  /* condition failed? */
843         ci->u.l.savedpc++;  /* skip jump instruction */
844       break;
845     }
846     case OP_CONCAT: {
847       StkId top = L->top - 1;  /* top when 'luaT_tryconcatTM' was called */
848       int a = GETARG_A(inst);      /* first element to concatenate */
849       int total = cast_int(top - 1 - (base + a));  /* yet to concatenate */
850       setobjs2s(L, top - 2, top);  /* put TM result in proper position */
851       L->top = top - 1;  /* top is one after last element (at top-2) */
852       luaV_concat(L, total);  /* concat them (may yield again) */
853       break;
854     }
855     case OP_CLOSE: {  /* yielded closing variables */
856       ci->u.l.savedpc--;  /* repeat instruction to close other vars. */
857       break;
858     }
859     case OP_RETURN: {  /* yielded closing variables */
860       StkId ra = base + GETARG_A(inst);
861       /* adjust top to signal correct number of returns, in case the
862          return is "up to top" ('isIT') */
863       L->top = ra + ci->u2.nres;
864       /* repeat instruction to close other vars. and complete the return */
865       ci->u.l.savedpc--;
866       break;
867     }
868     default: {
869       /* only these other opcodes can yield */
870       lua_assert(op == OP_TFORCALL || op == OP_CALL ||
871            op == OP_TAILCALL || op == OP_SETTABUP || op == OP_SETTABLE ||
872            op == OP_SETI || op == OP_SETFIELD);
873       break;
874     }
875   }
876 }
877 
878 
879 
880 
881 /*
882 ** {==================================================================
883 ** Macros for arithmetic/bitwise/comparison opcodes in 'luaV_execute'
884 ** ===================================================================
885 */
886 
887 #define l_addi(L,a,b)	intop(+, a, b)
888 #define l_subi(L,a,b)	intop(-, a, b)
889 #define l_muli(L,a,b)	intop(*, a, b)
890 #define l_band(a,b)	intop(&, a, b)
891 #define l_bor(a,b)	intop(|, a, b)
892 #define l_bxor(a,b)	intop(^, a, b)
893 
894 #define l_lti(a,b)	(a < b)
895 #define l_lei(a,b)	(a <= b)
896 #define l_gti(a,b)	(a > b)
897 #define l_gei(a,b)	(a >= b)
898 
899 
900 /*
901 ** Arithmetic operations with immediate operands. 'iop' is the integer
902 ** operation, 'fop' is the float operation.
903 */
904 #define op_arithI(L,iop,fop) {  \
905   TValue *v1 = vRB(i);  \
906   int imm = GETARG_sC(i);  \
907   if (ttisinteger(v1)) {  \
908     lua_Integer iv1 = ivalue(v1);  \
909     pc++; setivalue(s2v(ra), iop(L, iv1, imm));  \
910   }  \
911   else if (ttisfloat(v1)) {  \
912     lua_Number nb = fltvalue(v1);  \
913     lua_Number fimm = cast_num(imm);  \
914     pc++; setfltvalue(s2v(ra), fop(L, nb, fimm)); \
915   }}
916 
917 
918 /*
919 ** Auxiliary function for arithmetic operations over floats and others
920 ** with two register operands.
921 */
922 #define op_arithf_aux(L,v1,v2,fop) {  \
923   lua_Number n1; lua_Number n2;  \
924   if (tonumberns(v1, n1) && tonumberns(v2, n2)) {  \
925     pc++; setfltvalue(s2v(ra), fop(L, n1, n2));  \
926   }}
927 
928 
929 /*
930 ** Arithmetic operations over floats and others with register operands.
931 */
932 #define op_arithf(L,fop) {  \
933   TValue *v1 = vRB(i);  \
934   TValue *v2 = vRC(i);  \
935   op_arithf_aux(L, v1, v2, fop); }
936 
937 
938 /*
939 ** Arithmetic operations with K operands for floats.
940 */
941 #define op_arithfK(L,fop) {  \
942   TValue *v1 = vRB(i);  \
943   TValue *v2 = KC(i); lua_assert(ttisnumber(v2));  \
944   op_arithf_aux(L, v1, v2, fop); }
945 
946 
947 /*
948 ** Arithmetic operations over integers and floats.
949 */
950 #define op_arith_aux(L,v1,v2,iop,fop) {  \
951   if (ttisinteger(v1) && ttisinteger(v2)) {  \
952     lua_Integer i1 = ivalue(v1); lua_Integer i2 = ivalue(v2);  \
953     pc++; setivalue(s2v(ra), iop(L, i1, i2));  \
954   }  \
955   else op_arithf_aux(L, v1, v2, fop); }
956 
957 
958 /*
959 ** Arithmetic operations with register operands.
960 */
961 #define op_arith(L,iop,fop) {  \
962   TValue *v1 = vRB(i);  \
963   TValue *v2 = vRC(i);  \
964   op_arith_aux(L, v1, v2, iop, fop); }
965 
966 
967 /*
968 ** Arithmetic operations with K operands.
969 */
970 #define op_arithK(L,iop,fop) {  \
971   TValue *v1 = vRB(i);  \
972   TValue *v2 = KC(i); lua_assert(ttisnumber(v2));  \
973   op_arith_aux(L, v1, v2, iop, fop); }
974 
975 
976 /*
977 ** Bitwise operations with constant operand.
978 */
979 #define op_bitwiseK(L,op) {  \
980   TValue *v1 = vRB(i);  \
981   TValue *v2 = KC(i);  \
982   lua_Integer i1;  \
983   lua_Integer i2 = ivalue(v2);  \
984   if (tointegerns(v1, &i1)) {  \
985     pc++; setivalue(s2v(ra), op(i1, i2));  \
986   }}
987 
988 
989 /*
990 ** Bitwise operations with register operands.
991 */
992 #define op_bitwise(L,op) {  \
993   TValue *v1 = vRB(i);  \
994   TValue *v2 = vRC(i);  \
995   lua_Integer i1; lua_Integer i2;  \
996   if (tointegerns(v1, &i1) && tointegerns(v2, &i2)) {  \
997     pc++; setivalue(s2v(ra), op(i1, i2));  \
998   }}
999 
1000 
1001 /*
1002 ** Order operations with register operands. 'opn' actually works
1003 ** for all numbers, but the fast track improves performance for
1004 ** integers.
1005 */
1006 #define op_order(L,opi,opn,other) {  \
1007         int cond;  \
1008         TValue *rb = vRB(i);  \
1009         if (ttisinteger(s2v(ra)) && ttisinteger(rb)) {  \
1010           lua_Integer ia = ivalue(s2v(ra));  \
1011           lua_Integer ib = ivalue(rb);  \
1012           cond = opi(ia, ib);  \
1013         }  \
1014         else if (ttisnumber(s2v(ra)) && ttisnumber(rb))  \
1015           cond = opn(s2v(ra), rb);  \
1016         else  \
1017           Protect(cond = other(L, s2v(ra), rb));  \
1018         docondjump(); }
1019 
1020 
1021 /*
1022 ** Order operations with immediate operand. (Immediate operand is
1023 ** always small enough to have an exact representation as a float.)
1024 */
1025 #define op_orderI(L,opi,opf,inv,tm) {  \
1026         int cond;  \
1027         int im = GETARG_sB(i);  \
1028         if (ttisinteger(s2v(ra)))  \
1029           cond = opi(ivalue(s2v(ra)), im);  \
1030         else if (ttisfloat(s2v(ra))) {  \
1031           lua_Number fa = fltvalue(s2v(ra));  \
1032           lua_Number fim = cast_num(im);  \
1033           cond = opf(fa, fim);  \
1034         }  \
1035         else {  \
1036           int isf = GETARG_C(i);  \
1037           Protect(cond = luaT_callorderiTM(L, s2v(ra), im, inv, isf, tm));  \
1038         }  \
1039         docondjump(); }
1040 
1041 /* }================================================================== */
1042 
1043 
1044 /*
1045 ** {==================================================================
1046 ** Function 'luaV_execute': main interpreter loop
1047 ** ===================================================================
1048 */
1049 
1050 /*
1051 ** some macros for common tasks in 'luaV_execute'
1052 */
1053 
1054 
1055 #define RA(i)	(base+GETARG_A(i))
1056 #define RB(i)	(base+GETARG_B(i))
1057 #define vRB(i)	s2v(RB(i))
1058 #define KB(i)	(k+GETARG_B(i))
1059 #define RC(i)	(base+GETARG_C(i))
1060 #define vRC(i)	s2v(RC(i))
1061 #define KC(i)	(k+GETARG_C(i))
1062 #define RKC(i)	((TESTARG_k(i)) ? k + GETARG_C(i) : s2v(base + GETARG_C(i)))
1063 
1064 
1065 
1066 #define updatetrap(ci)  (trap = ci->u.l.trap)
1067 
1068 #define updatebase(ci)	(base = ci->func + 1)
1069 
1070 
1071 #define updatestack(ci)  \
1072 	{ if (l_unlikely(trap)) { updatebase(ci); ra = RA(i); } }
1073 
1074 
1075 /*
1076 ** Execute a jump instruction. The 'updatetrap' allows signals to stop
1077 ** tight loops. (Without it, the local copy of 'trap' could never change.)
1078 */
1079 #define dojump(ci,i,e)	{ pc += GETARG_sJ(i) + e; updatetrap(ci); }
1080 
1081 
1082 /* for test instructions, execute the jump instruction that follows it */
1083 #define donextjump(ci)	{ Instruction ni = *pc; dojump(ci, ni, 1); }
1084 
1085 /*
1086 ** do a conditional jump: skip next instruction if 'cond' is not what
1087 ** was expected (parameter 'k'), else do next instruction, which must
1088 ** be a jump.
1089 */
1090 #define docondjump()	if (cond != GETARG_k(i)) pc++; else donextjump(ci);
1091 
1092 
1093 /*
1094 ** Correct global 'pc'.
1095 */
1096 #define savepc(L)	(ci->u.l.savedpc = pc)
1097 
1098 
1099 /*
1100 ** Whenever code can raise errors, the global 'pc' and the global
1101 ** 'top' must be correct to report occasional errors.
1102 */
1103 #define savestate(L,ci)		(savepc(L), L->top = ci->top)
1104 
1105 
1106 /*
1107 ** Protect code that, in general, can raise errors, reallocate the
1108 ** stack, and change the hooks.
1109 */
1110 #define Protect(exp)  (savestate(L,ci), (exp), updatetrap(ci))
1111 
1112 /* special version that does not change the top */
1113 #define ProtectNT(exp)  (savepc(L), (exp), updatetrap(ci))
1114 
1115 /*
1116 ** Protect code that can only raise errors. (That is, it cannot change
1117 ** the stack or hooks.)
1118 */
1119 #define halfProtect(exp)  (savestate(L,ci), (exp))
1120 
1121 /* 'c' is the limit of live values in the stack */
1122 #define checkGC(L,c)  \
1123 	{ luaC_condGC(L, (savepc(L), L->top = (c)), \
1124                          updatetrap(ci)); \
1125            luai_threadyield(L); }
1126 
1127 
1128 /* fetch an instruction and prepare its execution */
1129 #define vmfetch()	{ \
1130   if (l_unlikely(trap)) {  /* stack reallocation or hooks? */ \
1131     trap = luaG_traceexec(L, pc);  /* handle hooks */ \
1132     updatebase(ci);  /* correct stack */ \
1133   } \
1134   i = *(pc++); \
1135   ra = RA(i); /* WARNING: any stack reallocation invalidates 'ra' */ \
1136 }
1137 
1138 #define vmdispatch(o)	switch(o)
1139 #define vmcase(l)	case l:
1140 #define vmbreak		break
1141 
1142 
1143 void luaV_execute (lua_State *L, CallInfo *ci) {
1144   LClosure *cl;
1145   TValue *k;
1146   StkId base;
1147   const Instruction *pc;
1148   int trap;
1149 #if LUA_USE_JUMPTABLE
1150 #include "ljumptab.h"
1151 #endif
1152  startfunc:
1153   trap = L->hookmask;
1154  returning:  /* trap already set */
1155   cl = clLvalue(s2v(ci->func));
1156   k = cl->p->k;
1157   pc = ci->u.l.savedpc;
1158   if (l_unlikely(trap)) {
1159     if (pc == cl->p->code) {  /* first instruction (not resuming)? */
1160       if (cl->p->is_vararg)
1161         trap = 0;  /* hooks will start after VARARGPREP instruction */
1162       else  /* check 'call' hook */
1163         luaD_hookcall(L, ci);
1164     }
1165     ci->u.l.trap = 1;  /* assume trap is on, for now */
1166   }
1167   base = ci->func + 1;
1168   /* main loop of interpreter */
1169   for (;;) {
1170     Instruction i;  /* instruction being executed */
1171     StkId ra;  /* instruction's A register */
1172     vmfetch();
1173     #if 0
1174       /* low-level line tracing for debugging Lua */
1175       printf("line: %d\n", luaG_getfuncline(cl->p, pcRel(pc, cl->p)));
1176     #endif
1177     lua_assert(base == ci->func + 1);
1178     lua_assert(base <= L->top && L->top < L->stack_last);
1179     /* invalidate top for instructions not expecting it */
1180     lua_assert(isIT(i) || (cast_void(L->top = base), 1));
1181     vmdispatch (GET_OPCODE(i)) {
1182       vmcase(OP_MOVE) {
1183         setobjs2s(L, ra, RB(i));
1184         vmbreak;
1185       }
1186       vmcase(OP_LOADI) {
1187         lua_Integer b = GETARG_sBx(i);
1188         setivalue(s2v(ra), b);
1189         vmbreak;
1190       }
1191       vmcase(OP_LOADF) {
1192         int b = GETARG_sBx(i);
1193         setfltvalue(s2v(ra), cast_num(b));
1194         vmbreak;
1195       }
1196       vmcase(OP_LOADK) {
1197         TValue *rb = k + GETARG_Bx(i);
1198         setobj2s(L, ra, rb);
1199         vmbreak;
1200       }
1201       vmcase(OP_LOADKX) {
1202         TValue *rb;
1203         rb = k + GETARG_Ax(*pc); pc++;
1204         setobj2s(L, ra, rb);
1205         vmbreak;
1206       }
1207       vmcase(OP_LOADFALSE) {
1208         setbfvalue(s2v(ra));
1209         vmbreak;
1210       }
1211       vmcase(OP_LFALSESKIP) {
1212         setbfvalue(s2v(ra));
1213         pc++;  /* skip next instruction */
1214         vmbreak;
1215       }
1216       vmcase(OP_LOADTRUE) {
1217         setbtvalue(s2v(ra));
1218         vmbreak;
1219       }
1220       vmcase(OP_LOADNIL) {
1221         int b = GETARG_B(i);
1222         do {
1223           setnilvalue(s2v(ra++));
1224         } while (b--);
1225         vmbreak;
1226       }
1227       vmcase(OP_GETUPVAL) {
1228         int b = GETARG_B(i);
1229         setobj2s(L, ra, cl->upvals[b]->v);
1230         vmbreak;
1231       }
1232       vmcase(OP_SETUPVAL) {
1233         UpVal *uv = cl->upvals[GETARG_B(i)];
1234         setobj(L, uv->v, s2v(ra));
1235         luaC_barrier(L, uv, s2v(ra));
1236         vmbreak;
1237       }
1238       vmcase(OP_GETTABUP) {
1239         const TValue *slot;
1240         TValue *upval = cl->upvals[GETARG_B(i)]->v;
1241         TValue *rc = KC(i);
1242         TString *key = tsvalue(rc);  /* key must be a string */
1243         if (luaV_fastget(L, upval, key, slot, luaH_getshortstr)) {
1244           setobj2s(L, ra, slot);
1245         }
1246         else
1247           Protect(luaV_finishget(L, upval, rc, ra, slot));
1248         vmbreak;
1249       }
1250       vmcase(OP_GETTABLE) {
1251         const TValue *slot;
1252         TValue *rb = vRB(i);
1253         TValue *rc = vRC(i);
1254         lua_Unsigned n;
1255         if (ttisinteger(rc)  /* fast track for integers? */
1256             ? (cast_void(n = ivalue(rc)), luaV_fastgeti(L, rb, n, slot))
1257             : luaV_fastget(L, rb, rc, slot, luaH_get)) {
1258           setobj2s(L, ra, slot);
1259         }
1260         else
1261           Protect(luaV_finishget(L, rb, rc, ra, slot));
1262         vmbreak;
1263       }
1264       vmcase(OP_GETI) {
1265         const TValue *slot;
1266         TValue *rb = vRB(i);
1267         int c = GETARG_C(i);
1268         if (luaV_fastgeti(L, rb, c, slot)) {
1269           setobj2s(L, ra, slot);
1270         }
1271         else {
1272           TValue key;
1273           setivalue(&key, c);
1274           Protect(luaV_finishget(L, rb, &key, ra, slot));
1275         }
1276         vmbreak;
1277       }
1278       vmcase(OP_GETFIELD) {
1279         const TValue *slot;
1280         TValue *rb = vRB(i);
1281         TValue *rc = KC(i);
1282         TString *key = tsvalue(rc);  /* key must be a string */
1283         if (luaV_fastget(L, rb, key, slot, luaH_getshortstr)) {
1284           setobj2s(L, ra, slot);
1285         }
1286         else
1287           Protect(luaV_finishget(L, rb, rc, ra, slot));
1288         vmbreak;
1289       }
1290       vmcase(OP_SETTABUP) {
1291         const TValue *slot;
1292         TValue *upval = cl->upvals[GETARG_A(i)]->v;
1293         TValue *rb = KB(i);
1294         TValue *rc = RKC(i);
1295         TString *key = tsvalue(rb);  /* key must be a string */
1296         if (luaV_fastget(L, upval, key, slot, luaH_getshortstr)) {
1297           luaV_finishfastset(L, upval, slot, rc);
1298         }
1299         else
1300           Protect(luaV_finishset(L, upval, rb, rc, slot));
1301         vmbreak;
1302       }
1303       vmcase(OP_SETTABLE) {
1304         const TValue *slot;
1305         TValue *rb = vRB(i);  /* key (table is in 'ra') */
1306         TValue *rc = RKC(i);  /* value */
1307         lua_Unsigned n;
1308         if (ttisinteger(rb)  /* fast track for integers? */
1309             ? (cast_void(n = ivalue(rb)), luaV_fastgeti(L, s2v(ra), n, slot))
1310             : luaV_fastget(L, s2v(ra), rb, slot, luaH_get)) {
1311           luaV_finishfastset(L, s2v(ra), slot, rc);
1312         }
1313         else
1314           Protect(luaV_finishset(L, s2v(ra), rb, rc, slot));
1315         vmbreak;
1316       }
1317       vmcase(OP_SETI) {
1318         const TValue *slot;
1319         int c = GETARG_B(i);
1320         TValue *rc = RKC(i);
1321         if (luaV_fastgeti(L, s2v(ra), c, slot)) {
1322           luaV_finishfastset(L, s2v(ra), slot, rc);
1323         }
1324         else {
1325           TValue key;
1326           setivalue(&key, c);
1327           Protect(luaV_finishset(L, s2v(ra), &key, rc, slot));
1328         }
1329         vmbreak;
1330       }
1331       vmcase(OP_SETFIELD) {
1332         const TValue *slot;
1333         TValue *rb = KB(i);
1334         TValue *rc = RKC(i);
1335         TString *key = tsvalue(rb);  /* key must be a string */
1336         if (luaV_fastget(L, s2v(ra), key, slot, luaH_getshortstr)) {
1337           luaV_finishfastset(L, s2v(ra), slot, rc);
1338         }
1339         else
1340           Protect(luaV_finishset(L, s2v(ra), rb, rc, slot));
1341         vmbreak;
1342       }
1343       vmcase(OP_NEWTABLE) {
1344         int b = GETARG_B(i);  /* log2(hash size) + 1 */
1345         int c = GETARG_C(i);  /* array size */
1346         Table *t;
1347         if (b > 0)
1348           b = 1 << (b - 1);  /* size is 2^(b - 1) */
1349         lua_assert((!TESTARG_k(i)) == (GETARG_Ax(*pc) == 0));
1350         if (TESTARG_k(i))  /* non-zero extra argument? */
1351           c += GETARG_Ax(*pc) * (MAXARG_C + 1);  /* add it to size */
1352         pc++;  /* skip extra argument */
1353         L->top = ra + 1;  /* correct top in case of emergency GC */
1354         t = luaH_new(L);  /* memory allocation */
1355         sethvalue2s(L, ra, t);
1356         if (b != 0 || c != 0)
1357           luaH_resize(L, t, c, b);  /* idem */
1358         checkGC(L, ra + 1);
1359         vmbreak;
1360       }
1361       vmcase(OP_SELF) {
1362         const TValue *slot;
1363         TValue *rb = vRB(i);
1364         TValue *rc = RKC(i);
1365         TString *key = tsvalue(rc);  /* key must be a string */
1366         setobj2s(L, ra + 1, rb);
1367         if (luaV_fastget(L, rb, key, slot, luaH_getstr)) {
1368           setobj2s(L, ra, slot);
1369         }
1370         else
1371           Protect(luaV_finishget(L, rb, rc, ra, slot));
1372         vmbreak;
1373       }
1374       vmcase(OP_ADDI) {
1375         op_arithI(L, l_addi, luai_numadd);
1376         vmbreak;
1377       }
1378       vmcase(OP_ADDK) {
1379         op_arithK(L, l_addi, luai_numadd);
1380         vmbreak;
1381       }
1382       vmcase(OP_SUBK) {
1383         op_arithK(L, l_subi, luai_numsub);
1384         vmbreak;
1385       }
1386       vmcase(OP_MULK) {
1387         op_arithK(L, l_muli, luai_nummul);
1388         vmbreak;
1389       }
1390       vmcase(OP_MODK) {
1391         op_arithK(L, luaV_mod, luaV_modf);
1392         vmbreak;
1393       }
1394       vmcase(OP_POWK) {
1395         op_arithfK(L, luai_numpow);
1396         vmbreak;
1397       }
1398       vmcase(OP_DIVK) {
1399         op_arithfK(L, luai_numdiv);
1400         vmbreak;
1401       }
1402       vmcase(OP_IDIVK) {
1403         op_arithK(L, luaV_idiv, luai_numidiv);
1404         vmbreak;
1405       }
1406       vmcase(OP_BANDK) {
1407         op_bitwiseK(L, l_band);
1408         vmbreak;
1409       }
1410       vmcase(OP_BORK) {
1411         op_bitwiseK(L, l_bor);
1412         vmbreak;
1413       }
1414       vmcase(OP_BXORK) {
1415         op_bitwiseK(L, l_bxor);
1416         vmbreak;
1417       }
1418       vmcase(OP_SHRI) {
1419         TValue *rb = vRB(i);
1420         int ic = GETARG_sC(i);
1421         lua_Integer ib;
1422         if (tointegerns(rb, &ib)) {
1423           pc++; setivalue(s2v(ra), luaV_shiftl(ib, -ic));
1424         }
1425         vmbreak;
1426       }
1427       vmcase(OP_SHLI) {
1428         TValue *rb = vRB(i);
1429         int ic = GETARG_sC(i);
1430         lua_Integer ib;
1431         if (tointegerns(rb, &ib)) {
1432           pc++; setivalue(s2v(ra), luaV_shiftl(ic, ib));
1433         }
1434         vmbreak;
1435       }
1436       vmcase(OP_ADD) {
1437         op_arith(L, l_addi, luai_numadd);
1438         vmbreak;
1439       }
1440       vmcase(OP_SUB) {
1441         op_arith(L, l_subi, luai_numsub);
1442         vmbreak;
1443       }
1444       vmcase(OP_MUL) {
1445         op_arith(L, l_muli, luai_nummul);
1446         vmbreak;
1447       }
1448       vmcase(OP_MOD) {
1449         op_arith(L, luaV_mod, luaV_modf);
1450         vmbreak;
1451       }
1452       vmcase(OP_POW) {
1453         op_arithf(L, luai_numpow);
1454         vmbreak;
1455       }
1456       vmcase(OP_DIV) {  /* float division (always with floats) */
1457         op_arithf(L, luai_numdiv);
1458         vmbreak;
1459       }
1460       vmcase(OP_IDIV) {  /* floor division */
1461         op_arith(L, luaV_idiv, luai_numidiv);
1462         vmbreak;
1463       }
1464       vmcase(OP_BAND) {
1465         op_bitwise(L, l_band);
1466         vmbreak;
1467       }
1468       vmcase(OP_BOR) {
1469         op_bitwise(L, l_bor);
1470         vmbreak;
1471       }
1472       vmcase(OP_BXOR) {
1473         op_bitwise(L, l_bxor);
1474         vmbreak;
1475       }
1476       vmcase(OP_SHR) {
1477         op_bitwise(L, luaV_shiftr);
1478         vmbreak;
1479       }
1480       vmcase(OP_SHL) {
1481         op_bitwise(L, luaV_shiftl);
1482         vmbreak;
1483       }
1484       vmcase(OP_MMBIN) {
1485         Instruction pi = *(pc - 2);  /* original arith. expression */
1486         TValue *rb = vRB(i);
1487         TMS tm = (TMS)GETARG_C(i);
1488         StkId result = RA(pi);
1489         lua_assert(OP_ADD <= GET_OPCODE(pi) && GET_OPCODE(pi) <= OP_SHR);
1490         Protect(luaT_trybinTM(L, s2v(ra), rb, result, tm));
1491         vmbreak;
1492       }
1493       vmcase(OP_MMBINI) {
1494         Instruction pi = *(pc - 2);  /* original arith. expression */
1495         int imm = GETARG_sB(i);
1496         TMS tm = (TMS)GETARG_C(i);
1497         int flip = GETARG_k(i);
1498         StkId result = RA(pi);
1499         Protect(luaT_trybiniTM(L, s2v(ra), imm, flip, result, tm));
1500         vmbreak;
1501       }
1502       vmcase(OP_MMBINK) {
1503         Instruction pi = *(pc - 2);  /* original arith. expression */
1504         TValue *imm = KB(i);
1505         TMS tm = (TMS)GETARG_C(i);
1506         int flip = GETARG_k(i);
1507         StkId result = RA(pi);
1508         Protect(luaT_trybinassocTM(L, s2v(ra), imm, flip, result, tm));
1509         vmbreak;
1510       }
1511       vmcase(OP_UNM) {
1512         TValue *rb = vRB(i);
1513         lua_Number nb;
1514         if (ttisinteger(rb)) {
1515           lua_Integer ib = ivalue(rb);
1516           setivalue(s2v(ra), intop(-, 0, ib));
1517         }
1518         else if (tonumberns(rb, nb)) {
1519           setfltvalue(s2v(ra), luai_numunm(L, nb));
1520         }
1521         else
1522           Protect(luaT_trybinTM(L, rb, rb, ra, TM_UNM));
1523         vmbreak;
1524       }
1525       vmcase(OP_BNOT) {
1526         TValue *rb = vRB(i);
1527         lua_Integer ib;
1528         if (tointegerns(rb, &ib)) {
1529           setivalue(s2v(ra), intop(^, ~l_castS2U(0), ib));
1530         }
1531         else
1532           Protect(luaT_trybinTM(L, rb, rb, ra, TM_BNOT));
1533         vmbreak;
1534       }
1535       vmcase(OP_NOT) {
1536         TValue *rb = vRB(i);
1537         if (l_isfalse(rb))
1538           setbtvalue(s2v(ra));
1539         else
1540           setbfvalue(s2v(ra));
1541         vmbreak;
1542       }
1543       vmcase(OP_LEN) {
1544         Protect(luaV_objlen(L, ra, vRB(i)));
1545         vmbreak;
1546       }
1547       vmcase(OP_CONCAT) {
1548         int n = GETARG_B(i);  /* number of elements to concatenate */
1549         L->top = ra + n;  /* mark the end of concat operands */
1550         ProtectNT(luaV_concat(L, n));
1551         checkGC(L, L->top); /* 'luaV_concat' ensures correct top */
1552         vmbreak;
1553       }
1554       vmcase(OP_CLOSE) {
1555         Protect(luaF_close(L, ra, LUA_OK, 1));
1556         vmbreak;
1557       }
1558       vmcase(OP_TBC) {
1559         /* create new to-be-closed upvalue */
1560         halfProtect(luaF_newtbcupval(L, ra));
1561         vmbreak;
1562       }
1563       vmcase(OP_JMP) {
1564         dojump(ci, i, 0);
1565         vmbreak;
1566       }
1567       vmcase(OP_EQ) {
1568         int cond;
1569         TValue *rb = vRB(i);
1570         Protect(cond = luaV_equalobj(L, s2v(ra), rb));
1571         docondjump();
1572         vmbreak;
1573       }
1574       vmcase(OP_LT) {
1575         op_order(L, l_lti, LTnum, lessthanothers);
1576         vmbreak;
1577       }
1578       vmcase(OP_LE) {
1579         op_order(L, l_lei, LEnum, lessequalothers);
1580         vmbreak;
1581       }
1582       vmcase(OP_EQK) {
1583         TValue *rb = KB(i);
1584         /* basic types do not use '__eq'; we can use raw equality */
1585         int cond = luaV_rawequalobj(s2v(ra), rb);
1586         docondjump();
1587         vmbreak;
1588       }
1589       vmcase(OP_EQI) {
1590         int cond;
1591         int im = GETARG_sB(i);
1592         if (ttisinteger(s2v(ra)))
1593           cond = (ivalue(s2v(ra)) == im);
1594         else if (ttisfloat(s2v(ra)))
1595           cond = luai_numeq(fltvalue(s2v(ra)), cast_num(im));
1596         else
1597           cond = 0;  /* other types cannot be equal to a number */
1598         docondjump();
1599         vmbreak;
1600       }
1601       vmcase(OP_LTI) {
1602         op_orderI(L, l_lti, luai_numlt, 0, TM_LT);
1603         vmbreak;
1604       }
1605       vmcase(OP_LEI) {
1606         op_orderI(L, l_lei, luai_numle, 0, TM_LE);
1607         vmbreak;
1608       }
1609       vmcase(OP_GTI) {
1610         op_orderI(L, l_gti, luai_numgt, 1, TM_LT);
1611         vmbreak;
1612       }
1613       vmcase(OP_GEI) {
1614         op_orderI(L, l_gei, luai_numge, 1, TM_LE);
1615         vmbreak;
1616       }
1617       vmcase(OP_TEST) {
1618         int cond = !l_isfalse(s2v(ra));
1619         docondjump();
1620         vmbreak;
1621       }
1622       vmcase(OP_TESTSET) {
1623         TValue *rb = vRB(i);
1624         if (l_isfalse(rb) == GETARG_k(i))
1625           pc++;
1626         else {
1627           setobj2s(L, ra, rb);
1628           donextjump(ci);
1629         }
1630         vmbreak;
1631       }
1632       vmcase(OP_CALL) {
1633         CallInfo *newci;
1634         int b = GETARG_B(i);
1635         int nresults = GETARG_C(i) - 1;
1636         if (b != 0)  /* fixed number of arguments? */
1637           L->top = ra + b;  /* top signals number of arguments */
1638         /* else previous instruction set top */
1639         savepc(L);  /* in case of errors */
1640         if ((newci = luaD_precall(L, ra, nresults)) == NULL)
1641           updatetrap(ci);  /* C call; nothing else to be done */
1642         else {  /* Lua call: run function in this same C frame */
1643           ci = newci;
1644           goto startfunc;
1645         }
1646         vmbreak;
1647       }
1648       vmcase(OP_TAILCALL) {
1649         int b = GETARG_B(i);  /* number of arguments + 1 (function) */
1650         int n;  /* number of results when calling a C function */
1651         int nparams1 = GETARG_C(i);
1652         /* delta is virtual 'func' - real 'func' (vararg functions) */
1653         int delta = (nparams1) ? ci->u.l.nextraargs + nparams1 : 0;
1654         if (b != 0)
1655           L->top = ra + b;
1656         else  /* previous instruction set top */
1657           b = cast_int(L->top - ra);
1658         savepc(ci);  /* several calls here can raise errors */
1659         if (TESTARG_k(i)) {
1660           luaF_closeupval(L, base);  /* close upvalues from current call */
1661           lua_assert(L->tbclist < base);  /* no pending tbc variables */
1662           lua_assert(base == ci->func + 1);
1663         }
1664         if ((n = luaD_pretailcall(L, ci, ra, b, delta)) < 0)  /* Lua function? */
1665           goto startfunc;  /* execute the callee */
1666         else {  /* C function? */
1667           ci->func -= delta;  /* restore 'func' (if vararg) */
1668           luaD_poscall(L, ci, n);  /* finish caller */
1669           updatetrap(ci);  /* 'luaD_poscall' can change hooks */
1670           goto ret;  /* caller returns after the tail call */
1671         }
1672       }
1673       vmcase(OP_RETURN) {
1674         int n = GETARG_B(i) - 1;  /* number of results */
1675         int nparams1 = GETARG_C(i);
1676         if (n < 0)  /* not fixed? */
1677           n = cast_int(L->top - ra);  /* get what is available */
1678         savepc(ci);
1679         if (TESTARG_k(i)) {  /* may there be open upvalues? */
1680           ci->u2.nres = n;  /* save number of returns */
1681           if (L->top < ci->top)
1682             L->top = ci->top;
1683           luaF_close(L, base, CLOSEKTOP, 1);
1684           updatetrap(ci);
1685           updatestack(ci);
1686         }
1687         if (nparams1)  /* vararg function? */
1688           ci->func -= ci->u.l.nextraargs + nparams1;
1689         L->top = ra + n;  /* set call for 'luaD_poscall' */
1690         luaD_poscall(L, ci, n);
1691         updatetrap(ci);  /* 'luaD_poscall' can change hooks */
1692         goto ret;
1693       }
1694       vmcase(OP_RETURN0) {
1695         if (l_unlikely(L->hookmask)) {
1696           L->top = ra;
1697           savepc(ci);
1698           luaD_poscall(L, ci, 0);  /* no hurry... */
1699           trap = 1;
1700         }
1701         else {  /* do the 'poscall' here */
1702           int nres;
1703           L->ci = ci->previous;  /* back to caller */
1704           L->top = base - 1;
1705           for (nres = ci->nresults; l_unlikely(nres > 0); nres--)
1706             setnilvalue(s2v(L->top++));  /* all results are nil */
1707         }
1708         goto ret;
1709       }
1710       vmcase(OP_RETURN1) {
1711         if (l_unlikely(L->hookmask)) {
1712           L->top = ra + 1;
1713           savepc(ci);
1714           luaD_poscall(L, ci, 1);  /* no hurry... */
1715           trap = 1;
1716         }
1717         else {  /* do the 'poscall' here */
1718           int nres = ci->nresults;
1719           L->ci = ci->previous;  /* back to caller */
1720           if (nres == 0)
1721             L->top = base - 1;  /* asked for no results */
1722           else {
1723             setobjs2s(L, base - 1, ra);  /* at least this result */
1724             L->top = base;
1725             for (; l_unlikely(nres > 1); nres--)
1726               setnilvalue(s2v(L->top++));  /* complete missing results */
1727           }
1728         }
1729        ret:  /* return from a Lua function */
1730         if (ci->callstatus & CIST_FRESH)
1731           return;  /* end this frame */
1732         else {
1733           ci = ci->previous;
1734           goto returning;  /* continue running caller in this frame */
1735         }
1736       }
1737       vmcase(OP_FORLOOP) {
1738         if (ttisinteger(s2v(ra + 2))) {  /* integer loop? */
1739           lua_Unsigned count = l_castS2U(ivalue(s2v(ra + 1)));
1740           if (count > 0) {  /* still more iterations? */
1741             lua_Integer step = ivalue(s2v(ra + 2));
1742             lua_Integer idx = ivalue(s2v(ra));  /* internal index */
1743             chgivalue(s2v(ra + 1), count - 1);  /* update counter */
1744             idx = intop(+, idx, step);  /* add step to index */
1745             chgivalue(s2v(ra), idx);  /* update internal index */
1746             setivalue(s2v(ra + 3), idx);  /* and control variable */
1747             pc -= GETARG_Bx(i);  /* jump back */
1748           }
1749         }
1750         else if (floatforloop(ra))  /* float loop */
1751           pc -= GETARG_Bx(i);  /* jump back */
1752         updatetrap(ci);  /* allows a signal to break the loop */
1753         vmbreak;
1754       }
1755       vmcase(OP_FORPREP) {
1756         savestate(L, ci);  /* in case of errors */
1757         if (forprep(L, ra))
1758           pc += GETARG_Bx(i) + 1;  /* skip the loop */
1759         vmbreak;
1760       }
1761       vmcase(OP_TFORPREP) {
1762         /* create to-be-closed upvalue (if needed) */
1763         halfProtect(luaF_newtbcupval(L, ra + 3));
1764         pc += GETARG_Bx(i);
1765         i = *(pc++);  /* go to next instruction */
1766         lua_assert(GET_OPCODE(i) == OP_TFORCALL && ra == RA(i));
1767         goto l_tforcall;
1768       }
1769       vmcase(OP_TFORCALL) {
1770        l_tforcall:
1771         /* 'ra' has the iterator function, 'ra + 1' has the state,
1772            'ra + 2' has the control variable, and 'ra + 3' has the
1773            to-be-closed variable. The call will use the stack after
1774            these values (starting at 'ra + 4')
1775         */
1776         /* push function, state, and control variable */
1777         memcpy(ra + 4, ra, 3 * sizeof(*ra));
1778         L->top = ra + 4 + 3;
1779         ProtectNT(luaD_call(L, ra + 4, GETARG_C(i)));  /* do the call */
1780         updatestack(ci);  /* stack may have changed */
1781         i = *(pc++);  /* go to next instruction */
1782         lua_assert(GET_OPCODE(i) == OP_TFORLOOP && ra == RA(i));
1783         goto l_tforloop;
1784       }
1785       vmcase(OP_TFORLOOP) {
1786         l_tforloop:
1787         if (!ttisnil(s2v(ra + 4))) {  /* continue loop? */
1788           setobjs2s(L, ra + 2, ra + 4);  /* save control variable */
1789           pc -= GETARG_Bx(i);  /* jump back */
1790         }
1791         vmbreak;
1792       }
1793       vmcase(OP_SETLIST) {
1794         int n = GETARG_B(i);
1795         unsigned int last = GETARG_C(i);
1796         Table *h = hvalue(s2v(ra));
1797         if (n == 0)
1798           n = cast_int(L->top - ra) - 1;  /* get up to the top */
1799         else
1800           L->top = ci->top;  /* correct top in case of emergency GC */
1801         last += n;
1802         if (TESTARG_k(i)) {
1803           last += GETARG_Ax(*pc) * (MAXARG_C + 1);
1804           pc++;
1805         }
1806         if (last > luaH_realasize(h))  /* needs more space? */
1807           luaH_resizearray(L, h, last);  /* preallocate it at once */
1808         for (; n > 0; n--) {
1809           TValue *val = s2v(ra + n);
1810           setobj2t(L, &h->array[last - 1], val);
1811           last--;
1812           luaC_barrierback(L, obj2gco(h), val);
1813         }
1814         vmbreak;
1815       }
1816       vmcase(OP_CLOSURE) {
1817         Proto *p = cl->p->p[GETARG_Bx(i)];
1818         halfProtect(pushclosure(L, p, cl->upvals, base, ra));
1819         checkGC(L, ra + 1);
1820         vmbreak;
1821       }
1822       vmcase(OP_VARARG) {
1823         int n = GETARG_C(i) - 1;  /* required results */
1824         Protect(luaT_getvarargs(L, ci, ra, n));
1825         vmbreak;
1826       }
1827       vmcase(OP_VARARGPREP) {
1828         ProtectNT(luaT_adjustvarargs(L, GETARG_A(i), ci, cl->p));
1829         if (l_unlikely(trap)) {  /* previous "Protect" updated trap */
1830           luaD_hookcall(L, ci);
1831           L->oldpc = 1;  /* next opcode will be seen as a "new" line */
1832         }
1833         updatebase(ci);  /* function has new base after adjustment */
1834         vmbreak;
1835       }
1836       vmcase(OP_EXTRAARG) {
1837         lua_assert(0);
1838         vmbreak;
1839       }
1840     }
1841   }
1842 }
1843 
1844 /* }================================================================== */
1845