Lua diffs-lua-5.4.0-work1-work2


Makefile

39c39
< PLATS= aix bsd c89 freebsd generic linux macosx mingw posix solaris
> PLATS= aix bsd c89 freebsd generic linux linux-readline macosx mingw posix solaris

README

2c2
< This is Lua 5.4.0 (work1), released on 13 Mar 2018.
> This is Lua 5.4.0 (work2), released on 18 Jun 2018.

doc/contents.html

35c35
< Copyright &copy; 2015&ndash;2018 Lua.org, PUC-Rio.
> Copyright &copy; 2018 Lua.org, PUC-Rio.

52,53c52,53
< <LI><A HREF="manual.html#2.5.1">2.5.1 &ndash; The incremental GC</A>
< <LI><A HREF="manual.html#2.5.2">2.5.2 &ndash; The generational GC</A>
> <LI><A HREF="manual.html#2.5.1">2.5.1 &ndash; Incremental Garbage Collection</A>
> <LI><A HREF="manual.html#2.5.2">2.5.2 &ndash; Generational Garbage Collection</A>

614c614
< Mon Mar 12 21:52:24 -03 2018
> Mon Jun 18 17:11:17 -03 2018

617c617
< Last change: revised for Lua 5.4.0 (work1)
> Last change: revised for Lua 5.4.0 (work2)

doc/manual.html

22c22
< Copyright &copy; 2015&ndash;2018 Lua.org, PUC-Rio.
> Copyright &copy; 2018 Lua.org, PUC-Rio.

38c38
< <!-- $Id: manual.of,v 1.172 2018/03/12 14:26:44 roberto Exp roberto $ -->
> <!-- $Id: manual.of,v 1.175 2018/06/18 19:17:35 roberto Exp $ -->

117c117
< Lua is a <em>dynamically typed language</em>.
> Lua is a dynamically typed language.

125c125
< All values in Lua are <em>first-class values</em>.
> All values in Lua are first-class values.

722c722
< <h3>2.5.1 &ndash; <a name="2.5.1">The incremental GC</a></h3>
> <h3>2.5.1 &ndash; <a name="2.5.1">Incremental Garbage Collection</a></h3>

780c780
< <h3>2.5.2 &ndash; <a name="2.5.2">The generational GC</a></h3>
> <h3>2.5.2 &ndash; <a name="2.5.2">Generational Garbage Collection</a></h3>

1199,1200c1199,1201
< We can specify any byte in a short literal string by its numeric value
< (including embedded zeros).
> We can specify any byte in a short literal string,
> including embedded zeros,
> by its numeric value.

1580,1582c1581,1583
< Both <b>false</b> and <b>nil</b> are considered false.
< All values different from <b>nil</b> and <b>false</b> are considered true
< (in particular, the number 0 and the empty string are also true).
> Both <b>false</b> and <b>nil</b> test false.
> All values different from <b>nil</b> and <b>false</b> test true.
> (In particular, the number 0 and the empty string also test true).

1945,1947c1946
< Otherwise, if both operands are numbers
< or strings that can be converted to
< numbers (see <a href="#3.4.3">&sect;3.4.3</a>),
> Otherwise, if both operands are numbers,

1952a1952,1953
> (The string library coerces strings to numbers in
> arithmetic operations; see <a href="#3.4.3">&sect;3.4.3</a> for details.)

2021,2022c2022
< (integers and floats) convert the integer operand to a float;
< this is called the <em>usual rule</em>.
> (integers and floats) convert the integer operand to a float.

2103c2103
< Closures created at different times but no detectable differences
> Closures created at different times but with no detectable differences

2110c2110
< by using the "eq" metamethod (see <a href="#2.4">&sect;2.4</a>).
> by using the <code>__eq</code> metamethod (see <a href="#2.4">&sect;2.4</a>).

2132c2132
< Otherwise, Lua tries to call the "lt" or the "le"
> Otherwise, Lua tries to call the <code>__lt</code> or the <code>__le</code>

2177,2180c2177
< </pre><p>
< (In this manual,
< <code>--&gt;</code> indicates the result of the preceding expression.)
< 
> </pre>

2366c2363
< Otherwise, the prefixexp "call" metamethod is called,
> Otherwise, the prefixexp <code>__call</code> metamethod is called,

2669c2666,2667
< the Lua API functions do not check their arguments for validity or consistency.
> the Lua API functions do not check their arguments
> for validity or consistency.

2798a2797,2798
> Indices to upvalues (see <a href="#4.4">&sect;4.4</a>) larger than the real number
> of upvalues in the current C&nbsp;function are also acceptable (but invalid).

2846a2847,2850
> <p>
> A C&nbsp;closure can also change the values of its corresponding upvalues.
> 
> 

3125c3129,3130
< and errors running a <code>__gc</code> metamethod;
> and errors running a finalizer;
> '<code>v</code>' means the function may raise the errors explained in the text;

3127,3129c3132,3133
< (it can run arbitrary Lua code,
< either directly or through metamethods);
< '<code>v</code>' means the function may raise an error on purpose.
> (because it can run arbitrary Lua code,
> either directly or through metamethods).

3278,3280c3282
< Calls a function
< (or a callable object, that is,
< an object with a <code>__call</code> metamethod).
> Calls a function.

3284,3286c3286,3288
< To call a function you must use the following protocol:
< first, the function to be called is pushed onto the stack;
< then, the arguments to the function are pushed
> To do a call you must use the following protocol:
> first, the value to be called is pushed onto the stack;
> then, the arguments to the call are pushed

3306a3309,3310
> Like regular Lua calls,
> this function respects the <code>__call</code> metamethod.

3574c3578
< <span class="apii">[-0, +0, <em>m</em>]</span>
> <span class="apii">[-0, +0, <em>v</em>]</span>

3629,3631c3633
< </ul>
< 
< <p>
> </ul><p>

3635a3638,3641
> <p>
> This function may raise errors when calling finalizers.
> 
> 

4189c4195
< <span class="apii">[-1, +(2|0), <em>e</em>]</span>
> <span class="apii">[-1, +(2|0), <em>v</em>]</span>

4225a4232,4233
> This function may raise an error if the given key
> is neither <b>nil</b> nor present in the table.

4391a4400,4410
> This function receives a pointer to a C&nbsp;function
> and pushes onto the stack a Lua value of type <code>function</code> that,
> when called, invokes the corresponding C&nbsp;function.
> The parameter <code>n</code> tells how many upvalues this function will have
> (see <a href="#4.4">&sect;4.4</a>).
> 
> 
> <p>
> Any function to be callable by Lua must
> follow the correct protocol to receive its parameters
> and return its results (see <a href="#lua_CFunction"><code>lua_CFunction</code></a>).

4429,4437d4447
< This function receives a pointer to a C&nbsp;function
< and pushes onto the stack a Lua value of type <code>function</code> that,
< when called, invokes the corresponding C&nbsp;function.
< 
< 
< <p>
< Any function to be callable by Lua must
< follow the correct protocol to receive its parameters
< and return its results (see <a href="#lua_CFunction"><code>lua_CFunction</code></a>).

4444c4454
< <span class="apii">[-0, +1, <em>e</em>]</span>
> <span class="apii">[-0, +1, <em>v</em>]</span>

4451,4456c4461,4463
< but has some important differences:
< 
< <ul>
< 
< <li>
< You do not have to allocate space for the result:
> but has two important differences.
> First,
> you do not have to allocate space for the result;

4459,4462c4466,4467
< </li>
< 
< <li>
< The conversion specifiers are quite restricted.
> Second,
> the conversion specifiers are quite restricted.

4473d4477
< </li>

4475d4478
< </ul>

4478,4480c4481,4482
< Unlike other push functions,
< this function checks for the stack space it needs,
< including the slot for its result.
> This function may raise errors due to memory overflow
> or an invalid conversion specifier.

4632c4634
< <span class="apii">[-0, +1, <em>m</em>]</span>
> <span class="apii">[-0, +1, <em>v</em>]</span>

5352c5354
< <pre>const lua_Number *lua_version (lua_State *L);</pre>
> <pre>lua_Number lua_version (lua_State *L);</pre>

5355,5361c5357
< Returns the address of the version number
< (a C static variable)
< stored in the Lua core.
< When called with a valid <a href="#lua_State"><code>lua_State</code></a>,
< returns the address of the version used to create that state.
< When called with <code>NULL</code>,
< returns the address of the version running the call.
> Returns the version number of this core.

5409c5405
< <span class="apii">[-?, +?, <em>e</em>]</span>
> <span class="apii">[-?, +?, <em>v</em>]</span>

5426c5422
< <span class="apii">[-?, +?, <em>e</em>]</span>
> <span class="apii">[-?, +?, <em>v</em>]</span>

5475c5471,5472
< with a pending C call with no continuation function,
> with a pending C call with no continuation function
> (what is called a <em>C-call boundary</em>,

5477c5474
< (e.g., the main thread).
> (typically the main thread).

5511,5512c5508,5509
<   unsigned short fTransfer;   /* (r) index of first value transfered */
<   unsigned short nTransfer;   /* (r) number of transfered values */
>   unsigned short ftransfer;   /* (r) index of first value transferred */
>   unsigned short ntransfer;   /* (r) number of transferred values */

5608,5611c5605,5613
< <li><b><code>fTransfer</code>: </b>
< the index of the first local variable being "transfered",
< which means parameters in a call or return values in a return.
< This value is only meaningful during a call hook or a return hook.
> <li><b><code>ftransfer</code>: </b>
> the index on the stack of the first value being "transferred",
> that is, parameters in a call or return values in a return.
> (The other values are in consecutive indices.)
> Using this index, you can access and modify these values
> through <a href="#lua_getlocal"><code>lua_getlocal</code></a> and <a href="#lua_setlocal"><code>lua_setlocal</code></a>.
> This field is only meaningful during a
> call hook, denoting the first parameter,
> or a return hook, denoting the first value being returned.

5615,5616c5617,5618
< <li><b><code>nTransfer</code>: </b>
< The number of values being transfered (see previous item).
> <li><b><code>ntransfer</code>: </b>
> The number of values being transferred (see previous item).

5660c5662
< <span class="apii">[-(0|1), +(0|1|2), <em>e</em>]</span>
> <span class="apii">[-(0|1), +(0|1|2), <em>m</em>]</span>

5675c5677
< To get information about a function you push it onto the stack
> To get information about a function, you push it onto the stack

5729a5732,5735
> 
> 
> <p>
> This is the only option that can raise a memory error.

5735,5736c5741
< This function returns 0 on error
< (for instance, an invalid option in <code>what</code>).
> This function returns 0 if given an invalid option in <code>what</code>.

5747,5748c5752,5753
< Gets information about a local variable of
< a given activation record or a given function.
> Gets information about a local variable or a temporary value
> of a given activation record or a given function.

6451,6456c6456,6457
< Checks whether the core running the call,
< the core that created the Lua state,
< and the code making the call are all using the same version of Lua.
< Also checks whether the core running the call
< and the core that created the Lua state
< are using the same address space.
> Checks whether the code making the call and the Lua library being called
> are using the same version of Lua and the same numeric types.

6463c6464
< <span class="apii">[-0, +?, <em>e</em>]</span>
> <span class="apii">[-0, +?, <em>m</em>]</span>

6553c6554
< of the object at index <code>obj</code> and returns the type of pushed value.
> of the object at index <code>obj</code> and returns the type of the pushed value.

6567,6569c6568,6570
< Pushes onto the stack the metatable associated with name <code>tname</code>
< in the registry (see <a href="#luaL_newmetatable"><code>luaL_newmetatable</code></a>)
< (<b>nil</b> if there is no metatable associated with that name).
> Pushes onto the stack the metatable associated with the name <code>tname</code>
> in the registry (see <a href="#luaL_newmetatable"><code>luaL_newmetatable</code></a>),
> or <b>nil</b> if there is no metatable associated with that name.

6827c6828
< <span class="apii">[-0, +0, <em>e</em>]</span>
> <span class="apii">[-0, +0, &ndash;]</span>

9243,9244c9244
< or <code>#list + 1</code>;
< in those cases, the function erases the element <code>list[pos]</code>.
> or <code>#list + 1</code>.

9533c9533,9555
< The call <code>math.random(n)</code> is equivalent to <code>math.random(1,n)</code>.
> The call <code>math.random(n)</code>, for a positive <code>n</code>,
> is equivalent to <code>math.random(1,n)</code>.
> The call <code>math.random(0)</code> produces an integer with
> all bits (pseudo)random.
> 
> 
> <p>
> Lua initializes its pseudo-random generator with
> a weak attempt for ``randomness'',
> so that <code>math.random</code> should generate
> different sequences of results each time the program runs.
> To ensure a required level of randomness to the initial state
> (or contrarily, to have a deterministic sequence,
> for instance when debugging a program),
> you should call <a href="#pdf-math.randomseed"><code>math.randomseed</code></a> explicitly.
> 
> 
> <p>
> The results from this function have good statistical qualities,
> but they are not cryptographically secure.
> (For instance, there are no garanties that it is hard
> to predict future results based on the observation of
> some number of previous results.)

9539c9561
< <hr><h3><a name="pdf-math.randomseed"><code>math.randomseed (x)</code></a></h3>
> <hr><h3><a name="pdf-math.randomseed"><code>math.randomseed (x [, y])</code></a></h3>

9543c9565
< Sets <code>x</code> as the "seed"
> Sets <code>x</code> and <code>y</code> as the "seed"

9545a9568
> The default for <code>y</code> is zero.

10884c10907
< The coersion of strings to numbers in
> The coercion of strings to numbers in

10887c10910,10911
< The string library does a similar job for arithmetic operations
> The string library does a similar job
> for arithmetic (but not for bitwise) operations

10891c10915
< inside the string.
> in the string.

10904a10929,10931
> The pseudo-random number generator used by the function <a href="#pdf-math.random"><code>math.random</code></a>
> now starts with a somewhat random seed.
> Moreover, it uses a different algorithm.

10938a10966,10974
> <li>
> The function <a href="#lua_version"><code>lua_version</code></a> returns the version number,
> instead of an address of the version number.
> (The Lua core should work correctly with libraries using their
> own static copies of the same core,
> so there is no need to check whether they are using the same
> address space.)
> </li>
> 

11037c11073
< Mon Mar 12 21:47:51 -03 2018
> Mon Jun 18 17:05:33 -03 2018

11040c11076
< Last change: revised for Lua 5.4.0 (work1)
> Last change: revised for Lua 5.4.0 (work2)

doc/readme.html

50c50
< Lua is a powerful, fast, lightweight, embeddable scripting language
> Lua is a powerful, efficient, lightweight, embeddable scripting language

58c58,60
< used in many products and projects around the world.
> used in
> <A HREF="http://www.lua.org/uses.html">many products and projects</A>
> around the world.

88c90,91
< The instructions given below for building Lua are for Unix-like platforms.
> The instructions given below for building Lua are for Unix-like platforms,
> such as Linux and Mac OS X.

110c113
< the top-level directory, which is named <TT>lua-5.4.x</TT>.
> the top-level directory, which is named <TT>lua-5.4.0-work2</TT>.

150c153
<   probably need the right permissions to install files.
>   probably need the right permissions to install files, and so make need to do "<KBD>sudo make install</KBD>".

226,230c229,230
< lapi.c lcode.c lctype.c ldebug.c ldo.c ldump.c lfunc.c lgc.c llex.c
< lmem.c lobject.c lopcodes.c lparser.c lstate.c lstring.c ltable.c
< ltm.c lundump.c lvm.c lzio.c
< lauxlib.c lbaselib.c lbitlib.c lcorolib.c ldblib.c liolib.c
< lmathlib.c loslib.c lstrlib.c ltablib.c lutf8lib.c loadlib.c linit.c
> lapi.c lcode.c lctype.c ldebug.c ldo.c ldump.c lfunc.c lgc.c llex.c lmem.c lobject.c lopcodes.c lparser.c lstate.c lstring.c ltable.c ltm.c lundump.c lvm.c lzio.c
> lauxlib.c lbaselib.c lcorolib.c ldblib.c liolib.c lmathlib.c loadlib.c loslib.c lstrlib.c ltablib.c lutf8lib.c linit.c

242c242
<   To use Lua as a library in your own programs you'll need to know how to
>   To use Lua as a library in your own programs, you'll need to know how to

244c244
<   C libraries for Lua you'll need to know how to create dynamic libraries
>   C libraries for Lua, you'll need to know how to create dynamic libraries

319c319
< Mon Mar 12 14:52:57 -03 2018
> Mon Jun 18 17:08:42 -03 2018

322c322
< Last change: revised for Lua 5.4.0 (work1)
> Last change: revised for Lua 5.4.0 (work2)

src/Makefile

29c29
< PLATS= aix bsd c89 freebsd generic linux macosx mingw posix solaris
> PLATS= aix bsd c89 freebsd generic linux linux-readline macosx mingw posix solaris

100d99
< 

102c101
< 	$(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_LINUX -DLUA_USE_READLINE" SYSLIBS="-Wl,-E -lreadline"
> 	$(MAKE) $(ALL) SYSCFLAGS="-DLUA_USE_LINUX -DLUA_USE_READLINE -I/usr/include/edit" SYSLIBS="-Wl,-E -ledit" CC="cc"

118c117
< 	$(MAKE) "LUA_A=lua53.dll" "LUA_T=lua.exe" \
> 	$(MAKE) "LUA_A=lua54.dll" "LUA_T=lua.exe" \

src/lapi.c

2c2
< ** $Id: lapi.c,v 2.290 2018/02/27 20:01:55 roberto Exp $
> ** $Id: lapi.c,v 2.295 2018/06/18 12:08:10 roberto Exp $

40,41d39
< /* value at a non-valid index */
< #define NONVALIDVALUE		cast(TValue *, luaO_nilobject)

43,44c41,43
< /* corresponding test */
< #define isvalid(o)	((o) != luaO_nilobject)
> /* test for a valid index */
> #define isvalid(L, o)	(!ttisnil(o) || o != &G(L)->nilvalue)
> 

52,59d50
< /* test for valid but not pseudo index */
< #define isstackindex(i, o)	(isvalid(o) && !ispseudo(i))
< 
< #define api_checkvalidindex(l,o)  api_check(l, isvalid(o), "invalid index")
< 
< #define api_checkstackindex(l, i, o)  \
< 	api_check(l, isstackindex(i, o), "index not in the stack")
< 

66c57
<     if (o >= L->top) return NONVALIDVALUE;
>     if (o >= L->top) return &G(L)->nilvalue;

79c70
<       return NONVALIDVALUE;  /* it has no upvalues */
>       return &G(L)->nilvalue;  /* it has no upvalues */

82c73
<       return (idx <= func->nupvalues) ? &func->upvalue[idx-1] : NONVALIDVALUE;
>       return (idx <= func->nupvalues) ? &func->upvalue[idx-1] : &G(L)->nilvalue;

150,153c141,143
< LUA_API const lua_Number *lua_version (lua_State *L) {
<   static const lua_Number version = LUA_VERSION_NUM;
<   if (L == NULL) return &version;
<   else return G(L)->version;
> LUA_API lua_Number lua_version (lua_State *L) {
>   UNUSED(L);
>   return LUA_VERSION_NUM;

234c224
<   api_checkvalidindex(L, to);
>   api_check(l, isvalid(L, to), "invalid index");

260c250
<   return (isvalid(o) ? ttype(o) : LUA_TNONE);
>   return (isvalid(L, o) ? ttype(o) : LUA_TNONE);

305c295
<   return (isvalid(o1) && isvalid(o2)) ? luaV_rawequalobj(o1, o2) : 0;
>   return (isvalid(L, o1) && isvalid(L, o2)) ? luaV_rawequalobj(o1, o2) : 0;

332c322
<   if (isvalid(o1) && isvalid(o2)) {
>   if (isvalid(L, o1) && isvalid(L, o2)) {

708,728d697
< static int auxkeydef (lua_State *L, int idx, int remove) {
<   int res;
<   lua_lock(L);
<   api_checknelems(L, 1);
<   res = luaT_keydef(L, index2value(L, idx), s2v(L->top - 1), remove);
<   L->top--;  /* remove key */
<   lua_unlock(L);
<   return res;
< }
< 
< 
< LUA_API void lua_removekey (lua_State *L, int idx) {
<   auxkeydef(L, idx, 1);
< }
< 
< 
< LUA_API int lua_keyin (lua_State *L, int idx) {
<   return auxkeydef(L, idx, 0);
< }
< 
< 

src/lauxlib.c

2c2
< ** $Id: lauxlib.c,v 1.294 2018/02/27 18:47:32 roberto Exp $
> ** $Id: lauxlib.c,v 1.295 2018/06/18 12:08:10 roberto Exp $

953c953
<   const lua_Number *v = lua_version(L);
>   lua_Number v = lua_version(L);

956,958c956
<   if (v != lua_version(NULL))
<     luaL_error(L, "multiple Lua VMs detected");
<   else if (*v != ver)
>   else if (v != ver)

960c958
<                   (LUAI_UACNUMBER)ver, (LUAI_UACNUMBER)*v);
>                   (LUAI_UACNUMBER)ver, (LUAI_UACNUMBER)v);

src/lcode.c

2c2
< ** $Id: lcode.c,v 2.159 2018/03/07 15:55:38 roberto Exp $
> ** $Id: lcode.c,v 2.161 2018/04/04 14:23:41 roberto Exp $

681,684d680
<     case VUNDEF: {  /* not a real expression */
<       luaK_semerror(fs->ls, "'undef' is not a value!!");
<       break;
<     }

1413,1454d1408
< static void normalizeindexed (FuncState *fs, expdesc *v) {
<   if (v->k != VINDEXED) {  /* not in proper form? */
<     int key = fs->freereg;  /* register with key value */
<     luaK_reserveregs(fs, 1);
<     switch (v->k) {
<       case VINDEXI:
<         luaK_int(fs, key, v->u.ind.idx);
<         break;
<       case VINDEXSTR:
<         luaK_codek(fs, key, v->u.ind.idx);
<         break;
<       case VINDEXUP:
<         luaK_codek(fs, key, v->u.ind.idx);
<         luaK_codeABC(fs, OP_GETUPVAL, fs->freereg, v->u.ind.t, 0);
<         v->u.ind.t = fs->freereg;
<         luaK_reserveregs(fs, 1);  /* one more register for the upvalue */
<         break;
<       default:
<         luaK_semerror(fs->ls, "'undef' is not a value!!");
<         break;
<     }
<     v->u.ind.idx = key;
<     v->k = VINDEXED;
<   }
<   freeregs(fs, v->u.ind.t, v->u.ind.idx);
< }
< 
< 
< static void codeisdef (FuncState *fs, int eq, expdesc *v) {
<   normalizeindexed(fs, v);
<   v->u.info = luaK_codeABCk(fs, OP_ISDEF, 0, v->u.ind.t, v->u.ind.idx, eq);
<   v->k = VRELOC;
< }
< 
< 
< void luaK_codeundef (FuncState *fs, expdesc *v) {
<   normalizeindexed(fs, v);
<   v->u.info = luaK_codeABC(fs, OP_UNDEF, v->u.ind.t, v->u.ind.idx, 0);
<   v->k = VRELOC;
< }
< 
< 

1503c1457
<       if (!tonumeral(v, NULL) && fs->ls->t.token != TK_UNDEF)
>       if (!tonumeral(v, NULL))

1600,1603c1554
<       if (e2->k == VUNDEF)
<         codeisdef(fs, opr == OPR_NE, e1);
<       else
<         codeeq(fs, opr, e1, e2);
>       codeeq(fs, opr, e1, e2);

1699,1700c1650
<         /* FALLTHROUGH */
<       }
>       }  /* FALLTHROUGH */

src/lcode.h

2c2
< ** $Id: lcode.h,v 1.71 2018/03/07 15:55:38 roberto Exp $
> ** $Id: lcode.h,v 1.73 2018/04/04 14:23:41 roberto Exp $

81c81,82
< void luaK_patchgoto (FuncState *fs, int list, int target, int hasclose);
> LUAI_FUNC void luaK_patchgoto (FuncState *fs, int list, int target,
>                                int hasclose);

92d92
< LUAI_FUNC void luaK_codeundef (FuncState *fs, expdesc *e);

src/lctype.h

2c2
< ** $Id: lctype.h,v 1.12 2011/07/15 12:50:29 roberto Exp $
> ** $Id: lctype.h,v 1.13 2018/06/18 12:51:05 roberto Exp $

71c71
< LUAI_DDEC const lu_byte luai_ctype_[UCHAR_MAX + 2];
> LUAI_DDEC(const lu_byte luai_ctype_[UCHAR_MAX + 2];)

src/ldblib.c

2c2
< ** $Id: ldblib.c,v 1.154 2018/03/05 14:15:04 roberto Exp $
> ** $Id: ldblib.c,v 1.155 2018/03/16 15:33:34 roberto Exp $

189,190c189,190
<     settabsi(L, "fTransfer", ar.fTransfer);
<     settabsi(L, "nTransfer", ar.nTransfer);
>     settabsi(L, "ftransfer", ar.ftransfer);
>     settabsi(L, "ntransfer", ar.ntransfer);

src/ldebug.c

2c2
< ** $Id: ldebug.c,v 2.155 2018/02/17 19:29:29 roberto Exp $
> ** $Id: ldebug.c,v 2.158 2018/06/08 19:06:59 roberto Exp $

58c58
< static int getbaseline (Proto *f, int pc, int *basepc) {
> static int getbaseline (const Proto *f, int pc, int *basepc) {

89c89
< int luaG_getfuncline (Proto *f, int pc) {
> int luaG_getfuncline (const Proto *f, int pc) {

183c183
< static const char *upvalname (Proto *p, int uv) {
> static const char *upvalname (const Proto *p, int uv) {

268c268
<     Proto *p = cl->l.p;
>     const Proto *p = cl->l.p;

278c278
< static int nextline (Proto *p, int currentline, int pc) {
> static int nextline (const Proto *p, int currentline, int pc) {

294c294
<     Proto *p = f->l.p;
>     const Proto *p = f->l.p;

361c361
<           ar->fTransfer = ar->nTransfer = 0;
>           ar->ftransfer = ar->ntransfer = 0;

363,364c363,364
<           ar->fTransfer = ci->u2.transferinfo.fTransfer;
<           ar->nTransfer = ci->u2.transferinfo.nTransfer;
>           ar->ftransfer = ci->u2.transferinfo.ftransfer;
>           ar->ntransfer = ci->u2.transferinfo.ntransfer;

414c414
< static const char *getobjname (Proto *p, int lastpc, int reg,
> static const char *getobjname (const Proto *p, int lastpc, int reg,

421c421
< static void kname (Proto *p, int c, const char **name) {
> static void kname (const Proto *p, int c, const char **name) {

430c430
< static void rname (Proto *p, int pc, int c, const char **name) {
> static void rname (const Proto *p, int pc, int c, const char **name) {

440c440
< static void rkname (Proto *p, int pc, Instruction i, const char **name) {
> static void rkname (const Proto *p, int pc, Instruction i, const char **name) {

459c459
< static int findsetreg (Proto *p, int lastpc, int reg) {
> static int findsetreg (const Proto *p, int lastpc, int reg) {

507c507
< static const char *gxf (Proto *p, int pc, Instruction i, int isup) {
> static const char *gxf (const Proto *p, int pc, Instruction i, int isup) {

518c518,519
<  const char *getobjname (Proto *p, int lastpc, int reg, const char **name) {
>  const char *getobjname (const Proto *p, int lastpc, int reg,
>                          const char **name) {

588c589
<   Proto *p = ci_func(ci)->p;  /* calling function */
>   const Proto *p = ci_func(ci)->p;  /* calling function */

777c778
< static int changedline (Proto *p, int oldpc, int newpc) {
> static int changedline (const Proto *p, int oldpc, int newpc) {

786c787
< void luaG_traceexec (lua_State *L) {
> int luaG_traceexec (lua_State *L, const Instruction *pc) {

789c790,797
<   int counthook = (--L->hookcount == 0 && (mask & LUA_MASKCOUNT));
>   int counthook;
>   if (!(mask & (LUA_MASKLINE | LUA_MASKCOUNT))) {  /* no hooks? */
>     ci->u.l.trap = 0;  /* don't need to stop again */
>     return 0;  /* turn off 'trap' */
>   }
>   pc++;  /* reference is always next instruction */
>   ci->u.l.savedpc = pc;  /* save 'pc' */
>   counthook = (--L->hookcount == 0 && (mask & LUA_MASKCOUNT));

793c801
<     return;  /* no line hook and count != 0; nothing to be done */
>     return 1;  /* no line hook and count != 0; nothing to be done now */

796c804
<     return;  /* do not call hook again (VM yielded, so it did not move) */
>     return 1;  /* do not call hook again (VM yielded, so it did not move) */

803,805c811,812
<     Proto *p = ci_func(ci)->p;
<     const Instruction *npc = ci->u.l.savedpc;
<     int npci = pcRel(npc, p);
>     const Proto *p = ci_func(ci)->p;
>     int npci = pcRel(pc, p);

807c814
<         npc <= L->oldpc ||  /* when jump back (loop), or when */
>         pc <= L->oldpc ||  /* when jump back (loop), or when */

809c816
<       int newline = luaG_getfuncline(p, npci);  /* new line */
>       int newline = luaG_getfuncline(p, npci);

812c819
<     L->oldpc = npc;
>     L->oldpc = pc;  /* 'pc' of last call to line hook */

820a828
>   return 1;  /* keep 'trap' on */

src/ldebug.h

2c2
< ** $Id: ldebug.h,v 2.16 2018/01/28 15:13:26 roberto Exp $
> ** $Id: ldebug.h,v 2.18 2018/06/08 19:06:59 roberto Exp $

24c24
< LUAI_FUNC int luaG_getfuncline (Proto *f, int pc);
> LUAI_FUNC int luaG_getfuncline (const Proto *f, int pc);

40c40
< LUAI_FUNC void luaG_traceexec (lua_State *L);
> LUAI_FUNC int luaG_traceexec (lua_State *L, const Instruction *pc);

src/ldo.c

2c2
< ** $Id: ldo.c,v 2.199 2018/03/07 16:26:01 roberto Exp $
> ** $Id: ldo.c,v 2.202 2018/05/30 14:25:52 roberto Exp $

185c185
<   if (newstack == NULL) {  /* reallocation failed? */
>   if (unlikely(newstack == NULL)) {  /* reallocation failed? */

207c207
<   if (size > LUAI_MAXSTACK) {  /* need more space after extra size? */
>   if (unlikely(size > LUAI_MAXSTACK)) {  /* need more space after extra size? */

218c218
<     if (newsize > LUAI_MAXSTACK) {  /* stack overflow? */
>     if (unlikely(newsize > LUAI_MAXSTACK)) {  /* stack overflow? */

271c271
<                               int fTransfer, int nTransfer) {
>                               int ftransfer, int ntransfer) {

282c282
<     if (nTransfer != 0) {
>     if (ntransfer != 0) {

284,285c284,285
<       ci->u2.transferinfo.fTransfer = fTransfer;
<       ci->u2.transferinfo.nTransfer = nTransfer;
>       ci->u2.transferinfo.ftransfer = ftransfer;
>       ci->u2.transferinfo.ntransfer = ntransfer;

322c322,323
< static void rethook (lua_State *L, CallInfo *ci, StkId firstres, int nres) {
> static StkId rethook (lua_State *L, CallInfo *ci, StkId firstres, int nres) {
>   ptrdiff_t oldtop = savestack(L, L->top);  /* hook may change top */

329c330
<       L->top = ci->top;  /* correct top */
>       L->top = ci->top;  /* correct top to run hook */

332c333
<     int fTransfer;
>     int ftransfer;

334,335c335,336
<     fTransfer = cast(unsigned short, firstres - ci->func);
<     luaD_hook(L, LUA_HOOKRET, -1, fTransfer, nres);  /* call it */
>     ftransfer = cast(unsigned short, firstres - ci->func);
>     luaD_hook(L, LUA_HOOKRET, -1, ftransfer, nres);  /* call it */

339a341
>   return restorestack(L, oldtop);

351c353
<   if (!ttisfunction(tm))
>   if (unlikely(!ttisfunction(tm)))

366,367c368
< static void moveresults (lua_State *L, StkId firstResult, StkId res,
<                                        int nres, int wanted) {
> static void moveresults (lua_State *L, StkId res, int nres, int wanted) {

369,370c370,373
<     case 0: break;  /* nothing to move */
<     case 1: {  /* one result needed */
>     case 0:  /* no values needed */
>       L->top = res;
>       break;
>     case 1:  /* one value needed */

374c377,378
<         setobjs2s(L, res, firstResult);  /* move it to proper place */
>         setobjs2s(L, res, L->top - nres);  /* move it to proper place */
>       L->top = res + 1;

376,377c380,384
<     }
<     case LUA_MULTRET: {
>     case LUA_MULTRET:
>       wanted = nres;  /* we want all results */
>       /* FALLTHROUGH */
>     default: {  /* multiple results */
>       StkId firstresult = L->top - nres;  /* index of first result */

379,395c386,391
<       for (i = 0; i < nres; i++)  /* move all results to correct place */
<         setobjs2s(L, res + i, firstResult + i);
<       wanted = nres;  /* it wanted what it had */
<       break;
<     }
<     default: {
<       int i;
<       if (wanted <= nres) {  /* enough results? */
<         for (i = 0; i < wanted; i++)  /* move wanted results to correct place */
<           setobjs2s(L, res + i, firstResult + i);
<       }
<       else {  /* not enough results; use all of them plus nils */
<         for (i = 0; i < nres; i++)  /* move all results to correct place */
<           setobjs2s(L, res + i, firstResult + i);
<         for (; i < wanted; i++)  /* complete wanted number of results */
<           setnilvalue(s2v(res + i));
<       }
>       /* move all results to correct place */
>       for (i = 0; i < nres && i < wanted; i++)
>         setobjs2s(L, res + i, firstresult + i);
>       for (; i < wanted; i++)  /* complete wanted number of results */
>         setnilvalue(s2v(res + i));
>       L->top = res + wanted;  /* top points after the last result */

399d394
<   L->top = res + wanted;  /* top points after the last result */

407,412c402,404
< void luaD_poscall (lua_State *L, CallInfo *ci, StkId firstResult, int nres) {
<   if (L->hookmask) {
<     ptrdiff_t fr = savestack(L, firstResult);  /* hook may change stack */
<     rethook(L, ci, firstResult, nres);
<     firstResult = restorestack(L, fr);
<   }
> void luaD_poscall (lua_State *L, CallInfo *ci, int nres) {
>   if (L->hookmask)
>     L->top = rethook(L, ci, L->top - nres, nres);

415c407
<   moveresults(L, firstResult, ci->func, nres, ci->nresults);
>   moveresults(L, ci->func, nres, ci->nresults);

480c472
<       luaD_poscall(L, ci, L->top - n, n);
>       luaD_poscall(L, ci, n);

543c535
<   luaD_poscall(L, ci, L->top - n, n);  /* finish 'luaD_call' */
>   luaD_poscall(L, ci, n);  /* finish 'luaD_call' */

645d636
<         firstArg = L->top - n;  /* yield results come from continuation */

647c638
<       luaD_poscall(L, ci, firstArg, n);  /* finish 'luaD_call' */
>       luaD_poscall(L, ci, n);  /* finish 'luaD_call' */

672c663
<   if (status == -1)  /* error calling 'lua_resume'? */
>   if (unlikely(status == -1))  /* error calling 'lua_resume'? */

679c670
<     if (errorstatus(status)) {  /* unrecoverable error? */
>     if (unlikely(errorstatus(status))) {  /* unrecoverable error? */

706c697
<   if (L->nny > 0) {
>   if (unlikely(L->nny > 0)) {

739c730
<   if (status != LUA_OK) {  /* an error occurred? */
>   if (unlikely(status != LUA_OK)) {  /* an error occurred? */

src/ldo.h

2c2
< ** $Id: ldo.h,v 2.43 2018/02/17 19:29:29 roberto Exp $
> ** $Id: ldo.h,v 2.44 2018/05/22 12:02:36 roberto Exp $

64,65c64
< LUAI_FUNC void luaD_poscall (lua_State *L, CallInfo *ci, StkId firstResult,
<                                           int nres);
> LUAI_FUNC void luaD_poscall (lua_State *L, CallInfo *ci, int nres);

src/lgc.c

2c2
< ** $Id: lgc.c,v 2.252 2018/02/26 13:35:03 roberto Exp $
> ** $Id: lgc.c,v 2.254 2018/06/15 14:14:20 roberto Exp $

304,305c304,305
<       /* else *//* FALLTHROUGH */
<     }
>       /* else... */
>     }  /* FALLTHROUGH */

401c401
<   int hasclears = (h->sizearray > 0);
>   int hasclears = (h->alimit > 0);

435a436
>   unsigned int asize = luaH_realasize(h);

437c438
<   for (i = 0; i < h->sizearray; i++) {
>   for (i = 0; i < asize; i++) {

475c476,477
<   for (i = 0; i < h->sizearray; i++)  /* traverse array part */
>   unsigned int asize = luaH_realasize(h);
>   for (i = 0; i < asize; i++)  /* traverse array part */

511c513
<   return 1 + h->sizearray + 2 * allocsizenode(h);
>   return 1 + h->alimit + 2 * allocsizenode(h);

722c724,725
<     for (i = 0; i < h->sizearray; i++) {
>     unsigned int asize = luaH_realasize(h);
>     for (i = 0; i < asize; i++) {

src/lgc.h

2c2
< ** $Id: lgc.h,v 2.102 2018/02/19 20:06:56 roberto Exp $
> ** $Id: lgc.h,v 2.103 2018/06/11 14:19:50 roberto Exp $

72c72,73
< ** used for object "age" in generational mode.
> ** used for object "age" in generational mode. Last bit is free
> ** to be used by respective objects.

78c79
< #define TESTGRAYBIT	7  /* used by tests (luaL_checkmemory) */
> 

src/ljumptab.h

82,83d81
< &&L_OP_UNDEF,
< &&L_OP_ISDEF,

src/llex.c

2c2
< ** $Id: llex.c,v 2.101 2018/03/07 15:55:38 roberto Exp $
> ** $Id: llex.c,v 2.102 2018/04/04 14:23:41 roberto Exp $

44c44
<     "return", "then", "true", "undef", "until", "while",
>     "return", "then", "true", "until", "while",

src/llex.h

2c2
< ** $Id: llex.h,v 1.81 2018/03/07 15:55:38 roberto Exp $
> ** $Id: llex.h,v 1.82 2018/04/04 14:23:41 roberto Exp $

31c31
<   TK_RETURN, TK_THEN, TK_TRUE, TK_UNDEF, TK_UNTIL, TK_WHILE,
>   TK_RETURN, TK_THEN, TK_TRUE, TK_UNTIL, TK_WHILE,

src/llimits.h

2c2
< ** $Id: llimits.h,v 1.149 2018/01/28 15:13:26 roberto Exp $
> ** $Id: llimits.h,v 1.151 2018/06/15 14:13:45 roberto Exp $

62a63,68
> ** test whether an unsigned value is a power of 2 (or zero)
> */
> #define ispow2(x)	(((x) & ((x) - 1)) == 0)
> 
> 
> /*

133a140,155
> ** macros to improve jump prediction (used mainly for error handling)
> */
> #if !defined(likely)
> 
> #if defined(__GNUC__)
> #define likely(x)	(__builtin_expect(((x) != 0), 1))
> #define unlikely(x)	(__builtin_expect(((x) != 0), 0))
> #else
> #define likely(x)	(x)
> #define unlikely(x)	(x)
> #endif
> 
> #endif
> 
> 
> /*

135a158,159
> #if !defined(l_noret)
> 

143a168
> #endif

src/lmathlib.c

2c2
< ** $Id: lmathlib.c,v 1.125 2018/03/12 12:39:03 roberto Exp $
> ** $Id: lmathlib.c,v 1.135 2018/06/14 18:47:22 roberto Exp $

16a17
> #include <time.h>

233,238c234,235
<   if (lua_type(L, 1) == LUA_TNUMBER) {
<       if (lua_isinteger(L, 1))
<         lua_pushliteral(L, "integer");
<       else
<         lua_pushliteral(L, "float");
<   }
>   if (lua_type(L, 1) == LUA_TNUMBER)
>     lua_pushstring(L, (lua_isinteger(L, 1)) ? "integer" : "float");

250c247
< ** Pseudo-Random Number Generator based on 'xorshift128+'.
> ** Pseudo-Random Number Generator based on 'xoshiro256**'.

264c261,289
< #if !defined(LUA_USE_C89) && defined(LLONG_MAX) && !defined(LUA_DEBUG)  /* { */
> /*
> ** LUA_RAND32 forces the use of 32-bit integers in the implementation
> ** of the PRN generator (mainly for testing).
> */
> #if !defined(LUA_RAND32) && !defined(Rand64)
> 
> /* try to find an integer type with at least 64 bits */
> 
> #if (LONG_MAX >> 31 >> 31) >= 1
> 
> /* 'long' has at least 64 bits */
> #define Rand64		unsigned long
> 
> #elif !defined(LUA_USE_C89) && defined(LLONG_MAX)
> 
> /* there is a 'long long' type (which must have at least 64 bits) */
> #define Rand64		unsigned long long
> 
> #elif (LUA_MAXINTEGER >> 31 >> 31) >= 1
> 
> /* 'lua_Integer' has at least 64 bits */
> #define Rand64		lua_Unsigned
> 
> #endif
> 
> #endif
> 
> 
> #if defined(Rand64)  /* { */

267c292,295
< ** Assume long long.
> ** Standard implementation, using 64-bit integers.
> ** If 'Rand64' has more than 64 bits, the extra bits do not interfere
> ** with the 64 initial bits, except in a right shift. Moreover, the
> ** final result has to discard the extra bits.

270,271c298,300
< /* a 64-bit value */
< typedef unsigned long long I;
> /* avoid using extra bits when needed */
> #define trim64(x)	((x) & 0xffffffffffffffffu)
> 

273,279c302,304
< static I xorshift128plus (I *state) {
<   I x = state[0];
<   I y = state[1];
<   state[0] = y;
<   x ^= x << 23;
<   state[1] = (x ^ (x >> 18)) ^ (y ^ (y >> 5));
<   return state[1] + y;
> /* rotate left 'x' by 'n' bits */
> static Rand64 rotl (Rand64 x, int n) {
>   return (x << n) | (trim64(x) >> (64 - n)); 

281a307,320
> static Rand64 nextrand (Rand64 *state) {
>   Rand64 state0 = state[0];
>   Rand64 state1 = state[1];
>   Rand64 state2 = state[2] ^ state0;
>   Rand64 state3 = state[3] ^ state1;
>   Rand64 res = rotl(state1 * 5, 7) * 9;
>   state[0] = state0 ^ state3;
>   state[1] = state1 ^ state2;
>   state[2] = state2 ^ (state1 << 17);
>   state[3] = rotl(state3, 45);
>   return res;
> }
> 
> 

284,285d322
< #define maskFIG		(~(~1LLU << (FIGS - 1)))  /* use FIGS bits */
< #define shiftFIG	(l_mathop(0.5) / (1LLU << (FIGS - 1)))  /* 2^(-FIG) */

291c328,332
< static lua_Number I2d (I x) {
> #define maskFIG		(~(~(Rand64)1 << (FIGS - 1)))  /* use FIGS bits */
> #define shiftFIG  \
> 	(l_mathop(0.5) / ((Rand64)1 << (FIGS - 1)))  /* 2^(-FIGS) */
> 
> static lua_Number I2d (Rand64 x) {

295,296c336,337
< /* convert an 'I' to a lua_Unsigned */
< #define I2UInt(x)	((lua_Unsigned)(x))
> /* convert a 'Rand64' to a 'lua_Unsigned' */
> #define I2UInt(x)	((lua_Unsigned)trim64(x))

298,299c339,340
< /* convert a lua_Integer to an 'I' */
< #define Int2I(x)	((I)(x))
> /* convert a 'lua_Unsigned' to a 'Rand64' */
> #define Int2I(x)	((Rand64)(x))

301d341
< #else  /* no long long   }{ */

303,305c343
< /*
< ** Use two 32-bit integers to represent a 64-bit quantity.
< */
> #else	/* no 'Rand64'   }{ */

307c345,346
< #if LUAI_BITSINT >= 32
> /* get an integer with at least 32 bits */
> #if (INT_MAX >> 30) >= 1

313,314c352,356
< /* a 64-bit value */
< typedef struct I {
> 
> /*
> ** Use two 32-bit integers to represent a 64-bit quantity.
> */
> typedef struct Rand64 {

317c359
< } I;
> } Rand64;

321c363,365
< ** basic operations on 'I' values
> ** If 'lu_int32' has more than 32 bits, the extra bits do not interfere
> ** with the 32 initial bits, except in a right shift and comparisons.
> ** Moreover, the final result has to discard the extra bits.

324,325c368,378
< static I pack (lu_int32 h, lu_int32 l) {
<   I result;
> /* avoid using extra bits when needed */
> #define trim32(x)	((x) & 0xffffffffu)
> 
> 
> /*
> ** basic operations on 'Rand64' values
> */
> 
> /* build a new Rand64 value */
> static Rand64 packI (lu_int32 h, lu_int32 l) {
>   Rand64 result;

331,333c384,401
< /* i ^ (i << n) */
< static I Ixorshl (I i, int n) {
<   return pack(i.h ^ ((i.h << n) | (i.l >> (32 - n))), i.l ^ (i.l << n));
> /* return i << n */
> static Rand64 Ishl (Rand64 i, int n) {
>   lua_assert(n > 0 && n < 32);
>   return packI((i.h << n) | (trim32(i.l) >> (32 - n)), i.l << n);
> }
> 
> /* i1 ^= i2 */
> static void Ixor (Rand64 *i1, Rand64 i2) {
>   i1->h ^= i2.h;
>   i1->l ^= i2.l;
> }
> 
> /* return i1 + i2 */
> static Rand64 Iadd (Rand64 i1, Rand64 i2) {
>   Rand64 result = packI(i1.h + i2.h, i1.l + i2.l);
>   if (trim32(result.l) < trim32(i1.l))  /* carry? */
>     result.h++;
>   return result;

336,338c404,406
< /* i ^ (i >> n) */
< static I Ixorshr (I i, int n) {
<   return pack(i.h ^ (i.h >> n), i.l ^ ((i.l >> n) | (i.h << (32 - n))));
> /* return i * 5 */
> static Rand64 times5 (Rand64 i) {
>   return Iadd(Ishl(i, 2), i);  /* i * 5 == (i << 2) + i */

341,342c409,411
< static I Ixor (I i1, I i2) {
<   return pack(i1.h ^ i2.h, i1.l ^ i2.l);
> /* return i * 9 */
> static Rand64 times9 (Rand64 i) {
>   return Iadd(Ishl(i, 3), i);  /* i * 9 == (i << 3) + i */

345,349c414,418
< static I Iadd (I i1, I i2) {
<   I result = pack(i1.h + i2.h, i1.l + i2.l);
<   if (result.l < i1.l)  /* carry? */
<     result.h++;
<   return result;
> /* return 'i' rotated left 'n' bits */
> static Rand64 rotl (Rand64 i, int n) {
>   lua_assert(n > 0 && n < 32);
>   return packI((i.h << n) | (trim32(i.l) >> (32 - n)),
>                (trim32(i.h) >> (32 - n)) | (i.l << n));

351a421,427
> /* for offsets larger than 32, rotate right by 64 - offset */
> static Rand64 rotl1 (Rand64 i, int n) {
>   lua_assert(n > 32 && n < 64);
>   n = 64 - n;
>   return packI((trim32(i.h) >> n) | (i.l << (32 - n)),
>                (i.h << (32 - n)) | (trim32(i.l) >> n));
> }

354c430
< ** implementation of 'xorshift128+' algorithm on 'I' values
> ** implementation of 'xoshiro256**' algorithm on 'Rand64' values

356,363c432,441
< static I xorshift128plus (I *state) {
<   I x = state[0];
<   I y = state[1];
<   state[0] = y;
<   x = Ixorshl(x, 23);  /* x ^= x << 23; */
<   /* state[1] = (x ^ (x >> 18)) ^ (y ^ (y >> 5)); */
<   state[1] = Ixor(Ixorshr(x, 18), Ixorshr(y, 5));
<   return Iadd(state[1], y);  /* return state[1] + y; */
> static Rand64 nextrand (Rand64 *state) {
>   Rand64 res = times9(rotl(times5(state[1]), 7));
>   Rand64 t = Ishl(state[1], 17);
>   Ixor(&state[2], state[0]);
>   Ixor(&state[3], state[1]);
>   Ixor(&state[1], state[2]);
>   Ixor(&state[0], state[3]);
>   Ixor(&state[2], t);
>   state[3] = rotl1(state[3], 45);
>   return res;

368c446
< ** Converts an 'I' into a float.
> ** Converts a 'Rand64' into a float.

376,378c454,456
< #define maskHF		0  /* do not need bits from higher half */
< #define maskLOW		(~(~UONE << (FIGS - 1)))  /* use FIG bits */
< #define shiftFIG	(l_mathop(0.5) / (UONE << (FIGS - 1)))  /* 2^(-FIG) */
> #define maskHI		0  /* do not need bits from higher half */
> #define maskLOW		(~(~UONE << (FIGS - 1)))  /* use FIGS bits */
> #define shiftFIG	(l_mathop(0.5) / (UONE << (FIGS - 1)))  /* 2^(-FIGS) */

384,385c462,463
< /* use FIG - 32 bits from higher half */
< #define maskHF		(~(~UONE << (FIGS - 33)))
> /* use FIGS - 32 bits from higher half */
> #define maskHI		(~(~UONE << (FIGS - 33)))

387,388c465,466
< /* use all bits from lower half */
< #define maskLOW		(~(lu_int32)0)
> /* use 32 bits from lower half */
> #define maskLOW		(~(~UONE << 31))

390c468
< /* 2^(-FIG) == (1 / 2^33) / 2^(FIG-33) */
> /* 2^(-FIGS) == (1 / 2^33) / 2^(FIGS-33) */

397,398c475,476
< static lua_Number I2d (I x) {
<   lua_Number h = (lua_Number)(x.h & maskHF);
> static lua_Number I2d (Rand64 x) {
>   lua_Number h = (lua_Number)(x.h & maskHI);

403,404c481,484
< static lua_Unsigned I2UInt (I x) {
<   return ((lua_Unsigned)x.h << 31 << 1) | x.l;
> 
> /* convert a 'Rand64' to a 'lua_Unsigned' */
> static lua_Unsigned I2UInt (Rand64 x) {
>   return ((lua_Unsigned)trim32(x.h) << 31 << 1) | (lua_Unsigned)trim32(x.l);

407,409c487,489
< static I Int2I (lua_Integer n) {
<   lua_Unsigned un = n;
<   return pack((lu_int32)un, (lu_int32)(un >> 31 >> 1));
> /* convert a 'lua_Unsigned' to a 'Rand64' */
> static Rand64 Int2I (lua_Unsigned n) {
>   return packI((lu_int32)(n >> 31 >> 1), (lu_int32)n);

416c496
< ** A state uses two 'I' values.
> ** A state uses four 'Rand64' values.

419c499
<   I s[2];
>   Rand64 s[4];

425,434c505,511
< ** Because 'ran' has 2^B possible values, the projection can only
< ** be uniform when the size of the interval [0, n] is a power of 2
< ** (exact division). With the fairest possible projection (e.g.,
< ** '(ran % (n + 1))'), the maximum bias is 1 in 2^B/n.
< ** For a "small" 'n', this bias is acceptable. (Here, we accept
< ** a maximum bias of 0.0001%.) For a larger 'n', we first
< ** compute 'lim', the smallest (2^b - 1) not smaller than 'n',
< ** to get a uniform projection into [0,lim]. If the result is
< ** inside [0, n], we are done. Otherwise, we try we another
< ** 'ran' until we have a result inside the interval.
> ** Because 'ran' has 2^B possible values, the projection can only be
> ** uniform when the size of the interval is a power of 2 (exact
> ** division).  To get a uniform projection into [0, n], we first compute
> ** 'lim', the smallest Mersenne number not smaller than 'n'. We then
> ** project 'ran' into the interval [0, lim].  If the result is inside
> ** [0, n], we are done. Otherwise, we try with another 'ran', until we
> ** have a result inside the interval.

436,438d512
< 
< #define MAXBIAS		1000000
< 

441,443c515,516
<   if (n < LUA_MAXUNSIGNED / MAXBIAS)
<     return ran % (n + 1);
<   else {
>   lua_Unsigned lim = n;
>   if ((lim & (lim + 1)) > 0) {  /* 'lim + 1' is not a power of 2? */

445d517
<     lua_Unsigned lim = n;

451c523
< #if (LUA_MAXINTEGER >> 30 >> 2) > 0
> #if (LUA_MAXINTEGER >> 30 >> 1) > 0

454,459d525
<     lua_assert((lim & (lim + 1)) == 0  /* 'lim + 1' is a power of 2 */
<       && lim >= n  /* not smaller than 'n' */
<       && (lim >> 1) < n);  /* it is the smallest one */
<     while ((ran & lim) > n)
<       ran = I2UInt(xorshift128plus(state->s));
<     return ran & lim;

460a527,532
>   lua_assert((lim & (lim + 1)) == 0  /* 'lim + 1' is a power of 2, */
>     && lim >= n  /* not smaller than 'n', */
>     && (lim == 0 || (lim >> 1) < n));  /* and it is the smallest one */
>   while ((ran &= lim) > n)  /* project 'ran' into [0..lim] */
>     ran = I2UInt(nextrand(state->s));  /* not inside [0..n]? try again */
>   return ran;

468c540
<   I rv = xorshift128plus(state->s);  /* next pseudo-random value */
>   Rand64 rv = nextrand(state->s);  /* next pseudo-random value */

499c571
< static void setseed (I *state, lua_Integer n) {
> static void setseed (Rand64 *state, lua_Unsigned n1, lua_Unsigned n2) {

501,502c573,576
<   state[0] = Int2I(n);
<   state[1] = Int2I(~n);
>   state[0] = Int2I(n1);
>   state[1] = Int2I(0xff);  /* avoid a zero state */
>   state[2] = Int2I(n2);
>   state[3] = Int2I(0);

504c578
<     xorshift128plus(state);  /* discard initial values */
>     nextrand(state);  /* discard initial values to "spread" seed */

510,511c584,586
<   lua_Integer n = luaL_checkinteger(L, 1);
<   setseed(state->s, n);
>   lua_Integer n1 = luaL_checkinteger(L, 1);
>   lua_Integer n2 = luaL_optinteger(L, 2, 0);
>   setseed(state->s, n1, n2);

521a597,603
> 
> /*
> ** Register the random functions and initialize their state.
> ** To give some "randomness" to the initial seed, use the current time
> ** and the address of 'L' (in case the machine does address space layout
> ** randomization).
> */

524c606,608
<   setseed(state->s, 0);
>   lua_Unsigned seed1 = (lua_Unsigned)time(NULL); 
>   lua_Unsigned seed2 = (lua_Unsigned)(size_t)L; 
>   setseed(state->s, seed1, seed2);

src/lmem.c

2c2
< ** $Id: lmem.c,v 1.96 2018/01/28 15:13:26 roberto Exp $
> ** $Id: lmem.c,v 1.98 2018/06/18 12:08:10 roberto Exp $

63c63
<     if (size >= limit)  /* cannot grow even a little? */
>     if (unlikely(size >= limit))  /* cannot grow even a little? */

76c76
<   if (newblock == NULL)
>   if (unlikely(newblock == NULL))

91c91
<   if (newblock == NULL && final_n > 0)  /* allocation failed? */
>   if (unlikely(newblock == NULL && final_n > 0))  /* allocation failed? */

116a117,132
> /*
> ** In case of allocation fail, this function will call the GC to try
> ** to free some memory and then try the allocation again.
> ** (It should not be called when shrinking a block, because then the
> ** interpreter may be in the middle of a collection step.)
> */
> static void *tryagain (lua_State *L, void *block,
>                        size_t osize, size_t nsize) {
>   global_State *g = G(L);
>   if (ttisnil(&g->nilvalue)) {  /* is state fully build? */
>     luaC_fullgc(L, 1);  /* try to free some memory... */
>     return (*g->frealloc)(g->ud, block, osize, nsize);  /* try again */
>   }
>   else return NULL;  /* cannot free any memory without a full state */
> }
> 

127,133c143,146
<   if (newblock == NULL && nsize > 0) {
<     /* Is state fully built? Not shrinking a block? */
<     if (g->version && nsize > osize) {
<       luaC_fullgc(L, 1);  /* try to free some memory... */
<       newblock = (*g->frealloc)(g->ud, block, osize, nsize);  /* try again */
<     }
<     if (newblock == NULL)
>   if (unlikely(newblock == NULL && nsize > 0)) {
>     if (nsize > osize)  /* not shrinking a block? */
>       newblock = tryagain(L, block, osize, nsize);
>     if (newblock == NULL)  /* still no memory? */

145c158
<   if (newblock == NULL && nsize > 0)  /* allocation failed? */
>   if (unlikely(newblock == NULL && nsize > 0))  /* allocation failed? */

158,162c171,172
<     if (newblock == NULL) {
<       if (g->version) {  /* is state fully built? */
<         luaC_fullgc(L, 1);  /* try to free some memory... */
<         newblock = (*g->frealloc)(g->ud, NULL, tag, size);  /* try again */
<       }
>     if (unlikely(newblock == NULL)) {
>       newblock = tryagain(L, NULL, tag, size);

src/lobject.c

2c2
< ** $Id: lobject.c,v 2.124 2018/02/27 18:47:32 roberto Exp $
> ** $Id: lobject.c,v 2.126 2018/06/01 17:40:38 roberto Exp $

32,35d31
< 
< LUAI_DDEF const TValue luaO_nilobject_ = {NILCONSTANT};
< 
< 

396c392
<   luaD_inctop(L);
>   L->top++;

405,409c401,404
<   int n = 0;
<   for (;;) {
<     const char *e = strchr(fmt, '%');
<     if (e == NULL) break;
<     pushstr(L, fmt, e - fmt);
>   int n = 0;  /* number of strings in the stack to concatenate */
>   const char *e;  /* points to next conversion specifier */
>   while ((e = strchr(fmt, '%')) != NULL) {
>     pushstr(L, fmt, e - fmt);  /* string up to conversion specifier */

436c431
<         luaD_inctop(L);
>         L->top++;

463c458,462
<     fmt = e+2;
>     if (L->top + 2 > L->stack_last) {  /* no free stack space? */
>       luaV_concat(L, n);
>       n = 1;
>     }
>     fmt = e + 2;

465d463
<   luaD_checkstack(L, 1);

src/lobject.h

2c2
< ** $Id: lobject.h,v 2.141 2018/02/26 14:16:05 roberto Exp $
> ** $Id: lobject.h,v 2.146 2018/06/15 19:31:22 roberto Exp $

140c140,141
< #define ttisnil(o)		checktag((o), LUA_TNIL)
> /* macro to test for (any kind of) nil */
> #define ttisnil(v)		checktype((v), LUA_TNIL)

142,145c143,144
< /* macro defining a nil value */
< #define NILCONSTANT	{NULL}, LUA_TNIL
< 
< #define setnilvalue(obj) settt_(obj, LUA_TNIL)
> /* macro to test for a "pure" nil */
> #define ttisstrictnil(o)	checktag((o), LUA_TNIL)

148,149c147
< /* (address of) a fixed nil value */
< #define luaO_nilobject		(&luaO_nilobject_)
> #define setnilvalue(obj) settt_(obj, LUA_TNIL)

158c156,160
< #define ttisnilorempty(v)	checktype((v), LUA_TNIL)
> /*
> ** Variant used only in the value returned for a key not found in a
> ** table (absent key).
> */
> #define LUA_TABSTKEY	(LUA_TNIL | (2 << 4))

160d161
< #define isreallyempty(v)	checktag((v), LUA_TEMPTY)

161a163
> #define isabstkey(v)		checktag((v), LUA_TABSTKEY)

163d164
< #if defined(LUA_NILINTABLE)

165c166,169
< #define isempty(v)		isreallyempty(v)
> /*
> ** macro to detect non-standard nils (used only in assertions)
> */
> #define isreallyempty(v)	(ttisnil(v) && !ttisstrictnil(v))

167d170
< #else /* By default, entries with any kind of nil are considered empty */

169c172,177
< #define isempty(v)		ttisnilorempty(v)
> /*
> ** By default, entries with any kind of nil are considered empty.
> ** (In any definition, values associated with absent keys must also
> ** be accepted as empty.)
> */
> #define isempty(v)		ttisnil(v)

171d178
< #endif

173,174c180,181
< /* macro defining an empty value */
< #define EMPTYCONSTANT	{NULL}, LUA_TEMPTY
> /* macro defining a value corresponding to an absent key */
> #define ABSTKEYCONSTANT		{NULL}, LUA_TABSTKEY

661a669,681
> /*
> ** About 'alimit': if 'isrealasize(t)' is true, then 'alimit' is the
> ** real size of 'array'. Otherwise, the real size of 'array' is the
> ** smallest power of two not smaller than 'alimit' (or zero iff 'alimit'
> ** is zero); 'alimit' is then used as a hint for #t.
> */
> 
> #define BITRAS		(1 << 7)
> #define isrealasize(t)		(!((t)->marked & BITRAS))
> #define setrealasize(t)		((t)->marked &= cast_byte(~BITRAS))
> #define setnorealasize(t)	((t)->marked |= BITRAS)
> 
> 

666c686
<   unsigned int sizearray;  /* size of 'array' array */
>   unsigned int alimit;  /* "limit" of 'array' array */

719,720d738
< LUAI_DDEC const TValue luaO_nilobject_;
< 

src/lopcodes.c

2c2
< ** $Id: lopcodes.c,v 1.80 2018/03/07 15:55:38 roberto Exp $
> ** $Id: lopcodes.c,v 1.82 2018/04/19 15:42:41 roberto Exp $

19a20,21
> #if defined(LUAI_DEFOPNAMES)
> 

82,83d83
<   "UNDEF",
<   "ISDEF",

102a103,104
> #endif
> 

167,168d168
<  ,opmode(0, 0, 0, 0, iABC)		/* OP_UNDEF */
<  ,opmode(0, 0, 0, 1, iABC)		/* OP_ISDEF */

src/lopcodes.h

2c2
< ** $Id: lopcodes.h,v 1.190 2018/03/07 15:55:38 roberto Exp $
> ** $Id: lopcodes.h,v 1.193 2018/06/18 12:51:05 roberto Exp $

269,271d268
< OP_UNDEF,/*	A B	R(A)[R(B)] = undef				*/
< OP_ISDEF,/*	A B C	R(A) = (R(B)[R(C)] == undef			*/
< 

294c291
< OP_VARARG,/*	A B C  	R(A), R(A+1), ..., R(A+C-2) = vararg		*/
> OP_VARARG,/*	A C  	R(A), R(A+1), ..., R(A+C-2) = vararg		*/

345c342
< LUAI_DDEC const lu_byte luaP_opmodes[NUM_OPCODES];
> LUAI_DDEC(const lu_byte luaP_opmodes[NUM_OPCODES];)

364c361
< LUAI_DDEC const char *const luaP_opnames[NUM_OPCODES+1];  /* opcode names */
> LUAI_DDEC(const char *const luaP_opnames[NUM_OPCODES+1];)  /* opcode names */

src/lparser.c

2c2
< ** $Id: lparser.c,v 2.179 2018/03/07 15:55:38 roberto Exp $
> ** $Id: lparser.c,v 2.181 2018/06/18 17:57:20 roberto Exp $

896,900d895
<     case TK_UNDEF: {
<       luaX_next(ls);
<       init_exp(v, VUNDEF, 0);
<       return;
<     }

1186,1189d1180
<     if (nvars == 1 && testnext(ls, TK_UNDEF)) {
<       luaK_codeundef(ls->fs, &lh->v);
<       return;
<     }

1655,1659d1645
<       else if (testnext(ls, TK_UNDEF))
<         (void)0;  /* ignore */
<       /* old versions may need to declare 'local undef'
<          when using 'undef' with no environment; so this
<          version accepts (and ignores) these declarations */

1726c1712
<   lua_assert(iswhite(funcstate.f));  /* do not need barrier here */
>   luaC_objbarrier(L, funcstate.f, funcstate.f->source);

src/lparser.h

2c2
< ** $Id: lparser.h,v 1.81 2018/03/07 15:55:38 roberto Exp $
> ** $Id: lparser.h,v 1.82 2018/04/04 14:23:41 roberto Exp $

55,56c55
<   VVARARG,  /* vararg expression; info = instruction pc */
<   VUNDEF  /* the 'undef' "expression" */
>   VVARARG  /* vararg expression; info = instruction pc */

src/lstate.c

2c2
< ** $Id: lstate.c,v 2.151 2018/02/05 17:11:37 roberto Exp $
> ** $Id: lstate.c,v 2.155 2018/06/18 12:08:10 roberto Exp $

33,43d32
< ** a macro to help the creation of a unique random seed when a state is
< ** created; the seed is used to randomize hashes.
< */
< #if !defined(luai_makeseed)
< #include <time.h>
< #define luai_makeseed()		cast_uint(time(NULL))
< #endif
< 
< 
< 
< /*

66,67c55,65
< ** Compute an initial seed as random as possible. Rely on Address Space
< ** Layout Randomization (if present) to increase randomness..
> ** A macro to create a "random" seed when a state is created;
> ** the seed is used to randomize string hashes.
> */
> #if !defined(luai_makeseed)
> 
> #include <time.h>
> 
> /*
> ** Compute an initial seed with some level of randomness.
> ** Rely on Address Space Layout Randomization (if present) and
> ** current time.

73,75c71,73
< static unsigned int makeseed (lua_State *L) {
<   char buff[4 * sizeof(size_t)];
<   unsigned int h = luai_makeseed();
> static unsigned int luai_makeseed (lua_State *L) {
>   char buff[3 * sizeof(size_t)];
>   unsigned int h = cast_uint(time(NULL));

79d76
<   addbuff(buff, p, luaO_nilobject);  /* global variable */

84a82,83
> #endif
> 

219c218
< ** ('g->version' != NULL flags that the state was completely build)
> ** ('ttisnil(&g->nilvalue)'' flags that the state was completely build)

230c229
<   g->version = lua_version(NULL);
>   setnilvalue(&g->nilvalue);

264c263
<   if (g->version)  /* closing a fully built state? */
>   if (ttisnil(&g->nilvalue))  /* closing a fully built state? */

330c329
<   g->seed = makeseed(L);
>   g->seed = luai_makeseed(L);

336d334
<   g->version = NULL;

348a347
>   setivalue(&g->nilvalue, 0);  /* to signal that state is not yet built */

src/lstate.h

2c2
< ** $Id: lstate.h,v 2.157 2018/02/25 12:43:52 roberto Exp $
> ** $Id: lstate.h,v 2.160 2018/06/18 12:08:10 roberto Exp $

107,108c107,108
<       unsigned short fTransfer;  /* offset of first value transfered */
<       unsigned short nTransfer;  /* number of values transfered */
>       unsigned short ftransfer;  /* offset of first value transfered */
>       unsigned short ntransfer;  /* number of values transfered */

150a151
>   TValue nilvalue;  /* a nil value */

183d183
<   const lua_Number *version;  /* pointer to version number */

src/lstring.c

2c2
< ** $Id: lstring.c,v 2.65 2018/02/20 16:52:50 roberto Exp $
> ** $Id: lstring.c,v 2.66 2018/05/30 14:25:52 roberto Exp $

102c102
<   if (newvect == NULL) {  /* reallocation failed? */
>   if (unlikely(newvect == NULL)) {  /* reallocation failed? */

185c185
<   if (tb->nuse == MAX_INT) {  /* too many strings? */
>   if (unlikely(tb->nuse == MAX_INT)) {  /* too many strings? */

236c236
<     if (l >= (MAX_SIZE - sizeof(TString))/sizeof(char))
>     if (unlikely(l >= (MAX_SIZE - sizeof(TString))/sizeof(char)))

272c272
<   if (s > MAX_SIZE - udatamemoffset(nuvalue))
>   if (unlikely(s > MAX_SIZE - udatamemoffset(nuvalue)))

src/lstrlib.c

2c2
< ** $Id: lstrlib.c,v 1.262 2018/02/21 17:48:31 roberto Exp $
> ** $Id: lstrlib.c,v 1.263 2018/05/25 13:39:32 roberto Exp $

1524a1525,1526
>     luaL_argcheck(L, opt != Kstring && opt != Kzstr, 1,
>                      "variable-length format");

1529,1535d1530
<     switch (opt) {
<       case Kstring:  /* strings with length count */
<       case Kzstr:    /* zero-terminated string */
<         luaL_argerror(L, 1, "variable-length format");
<         /* call never return, but to avoid warnings: *//* FALLTHROUGH */
<       default:  break;
<     }

1588,1589c1583,1584
<     if ((size_t)ntoalign + size > ~pos || pos + ntoalign + size > ld)
<       luaL_argerror(L, 2, "data string too short");
>     luaL_argcheck(L, (size_t)ntoalign + size <= ld - pos, 2,
>                     "data string too short");

1618c1613
<         luaL_argcheck(L, pos + len + size <= ld, 2, "data string too short");
>         luaL_argcheck(L, len <= ld - pos - size, 2, "data string too short");

1624a1620,1621
>         luaL_argcheck(L, pos + len < ld, 2,
>                          "unfinished string for format 'z'");

src/ltable.c

2c2
< ** $Id: ltable.c,v 2.135 2018/02/26 14:16:05 roberto Exp $
> ** $Id: ltable.c,v 2.140 2018/06/15 14:18:40 roberto Exp $

96c96,97
< LUAI_DDEF const TValue luaH_emptyobject_ = {EMPTYCONSTANT};
> static const TValue absentkey = {ABSTKEYCONSTANT};
> 

194a196,248
> ** True if value of 'alimit' is equal to the real size of the array
> ** part of table 't'. (Otherwise, the array part must be larger than
> ** 'alimit'.)
> */
> #define limitequalsasize(t)	(isrealasize(t) || ispow2((t)->alimit))
> 
> 
> /*
> ** Returns the real size of the 'array' array
> */
> LUAI_FUNC unsigned int luaH_realasize (const Table *t) {
>   if (limitequalsasize(t))
>     return t->alimit;  /* this is the size */
>   else {
>     unsigned int size = t->alimit;
>     /* compute the smallest power of 2 not smaller than 'n' */
>     size |= (size >> 1);
>     size |= (size >> 2);
>     size |= (size >> 4);
>     size |= (size >> 8);
>     size |= (size >> 16);
> #if (INT_MAX >> 30 >> 1) > 0
>     size |= (size >> 32);  /* int has more than 32 bits */
> #endif
>     size++;
>     lua_assert(ispow2(size) && size/2 < t->alimit && t->alimit < size);
>     return size;
>   }
> }
> 
> 
> /*
> ** Check whether real size of the array is a power of 2.
> ** (If it is not, 'alimit' cannot be changed to any other value
> ** without changing the real size.)
> */
> static int ispow2realasize (const Table *t) {
>   return (!isrealasize(t) || ispow2(t->alimit));
> }
> 
> 
> static unsigned int setlimittosize (Table *t) {
>   t->alimit = luaH_realasize(t);
>   setrealasize(t);
>   return t->alimit;
> }
> 
> 
> #define limitasasize(t)	check_exp(isrealasize(t), t->alimit)
> 
> 
> 
> /*

206c260
<         return luaH_emptyobject;  /* not found */
>         return &absentkey;  /* not found */

230c284,285
< static unsigned int findindex (lua_State *L, Table *t, TValue *key) {
> static unsigned int findindex (lua_State *L, Table *t, TValue *key,
>                                unsigned int asize) {

234c289
<   if (i != 0 && i <= t->sizearray)  /* is 'key' inside array part? */
>   if (i != 0 && i <= asize)  /* is 'key' inside array part? */

238c293
<     if (n == luaH_emptyobject)
>     if (unlikely(isabstkey(n)))

242c297
<     return (i + 1) + t->sizearray;
>     return (i + 1) + asize;

248,249c303,305
<   unsigned int i = findindex(L, t, s2v(key));  /* find original element */
<   for (; i < t->sizearray; i++) {  /* try first array part */
>   unsigned int asize = luaH_realasize(t);
>   unsigned int i = findindex(L, t, s2v(key), asize);  /* find original key */
>   for (; i < asize; i++) {  /* try first array part */

256c312
<   for (i -= t->sizearray; cast_int(i) < sizenode(t); i++) {  /* hash part */
>   for (i -= asize; cast_int(i) < sizenode(t); i++) {  /* hash part */

330a387
>   unsigned int asize = limitasasize(t);  /* real array size */

335,336c392,393
<     if (lim > t->sizearray) {
<       lim = t->sizearray;  /* adjust upper limit */
>     if (lim > asize) {
>       lim = asize;  /* adjust upper limit */

453c510
<   unsigned int oldasize = t->sizearray;
>   unsigned int oldasize = setlimittosize(t);

458c515
<     t->sizearray = newasize;  /* pretend array has new size... */
>     t->alimit = newasize;  /* pretend array has new size... */

465c522
<     t->sizearray = oldasize;  /* restore current size... */
>     t->alimit = oldasize;  /* restore current size... */

470c527
<   if (newarray == NULL && newasize > 0) {  /* allocation failed? */
>   if (unlikely(newarray == NULL && newasize > 0)) {  /* allocation failed? */

477c534
<   t->sizearray = newasize;
>   t->alimit = newasize;

500a558
>   setlimittosize(t);

527c585
<   t->sizearray = 0;
>   t->alimit = 0;

535c593
<   luaM_freearray(L, t->array, t->sizearray);
>   luaM_freearray(L, t->array, luaH_realasize(t));

563c621,622
<   if (ttisnil(key)) luaG_runerror(L, "table index is nil");
>   if (unlikely(ttisnil(key)))
>     luaG_runerror(L, "table index is nil");

571c630
<     else if (luai_numisnan(f))
>     else if (unlikely(luai_numisnan(f)))

614c673,678
< ** search function for integers
> ** Search function for integers. If integer is inside 'alimit', get it
> ** directly from the array part. Otherwise, if 'alimit' is not equal to
> ** the real size of the array, key still can be in the array part. In
> ** this case, try to avoid a call to 'luaH_realasize' when key is just
> ** one more than the limit (so that it can be incremented without
> ** changing the real size of the array).

617,618c681,686
<   /* (1 <= key && key <= t->sizearray) */
<   if (l_castS2U(key) - 1u < t->sizearray)
>   if (l_castS2U(key) - 1u < t->alimit)  /* (1 <= key && key <= t->alimit)? */
>     return &t->array[key - 1];
>   else if (!limitequalsasize(t) &&  /* key still may be in the array part? */
>            (l_castS2U(key) == t->alimit + 1 ||
>             l_castS2U(key) - 1u < luaH_realasize(t))) {
>     t->alimit = cast_uint(key);  /* probably '#t' is here now */

619a688
>   }

631c700
<     return luaH_emptyobject;
>     return &absentkey;

648c717
<         return luaH_emptyobject;  /* not found */
>         return &absentkey;  /* not found */

673c742
<     case LUA_TNIL: return luaH_emptyobject;
>     case LUA_TNIL: return &absentkey;

692c761
<   if (p != luaH_emptyobject)
>   if (!isabstkey(p))

701c770
<   if (p != luaH_emptyobject)
>   if (!isabstkey(p))

749a819,829
> static unsigned int binsearch (const TValue *array, unsigned int i,
>                                                     unsigned int j) {
>   while (j - i > 1u) {  /* binary search */
>     unsigned int m = (i + j) / 2;
>     if (isempty(&array[m - 1])) j = m;
>     else i = m;
>   }
>   return i;
> }
> 
> 

754,758c834,858
< ** First, try the array part: if there is an array part and its last
< ** element is absent, there must be a boundary there; a binary search
< ** finds that boundary. Otherwise, if the hash part is empty or does not
< ** contain 'j + 1', 'j' is a boundary. Otherwize, call 'hash_search'
< ** to find a boundary in the hash part.
> ** (In the next explanation, we use Lua indices, that is, with base 1.
> ** The code itself uses base 0 when indexing the array part of the table.)
> ** The code starts with 'limit', a position in the array part that may
> ** be a boundary.
> ** (1) If 't[limit]' is empty, there must be a boundary before it.
> ** As a common case (e.g., after 't[#t]=nil'), check whether 'hint-1'
> ** is present. If so, it is a boundary. Otherwise, do a binary search
> ** between 0 and limit to find a boundary. In both cases, try to
> ** use this boundary as the new 'limit', as a hint for the next call.
> ** (2) If 't[limit]' is not empty and the array has more elements
> ** after 'limit', try to find a boundary there. Again, try first
> ** the special case (which should be quite frequent) where 'limit+1'
> ** is empty, so that 'limit' is a boundary. Otherwise, check the
> ** last element of the array part (set it as a new limit). If it is empty,
> ** there must be a boundary between the old limit (present) and the new
> ** limit (absent), which is found with a binary search. (This boundary
> ** always can be a new limit.)
> ** (3) The last case is when there are no elements in the array part
> ** (limit == 0) or its last element (the new limit) is present.
> ** In this case, must check the hash part. If there is no hash part,
> ** the boundary is 0. Otherwise, if 'limit+1' is absent, 'limit' is
> ** a boundary. Finally, if 'limit+1' is present, call 'hash_search'
> ** to find a boundary in the hash part of the table. (In those
> ** cases, the boundary is not inside the array part, and therefore
> ** cannot be used as a new limit.)

761,775c861,880
<   unsigned int j = t->sizearray;
<   if (j > 0 && isempty(&t->array[j - 1])) {
<     unsigned int i = 0;
<     while (j - i > 1u) {  /* binary search */
<       unsigned int m = (i + j) / 2;
<       if (isempty(&t->array[m - 1])) j = m;
<       else i = m;
<     }
<     return i;
<   }
<   else {  /* 'j' is zero or present in table */
<     if (isdummy(t) || isempty(luaH_getint(t, l_castU2S(j + 1))))
<       return j;  /* 'j + 1' is absent... */
<     else  /* 'j + 1' is also present */
<       return hash_search(t, j);
>   unsigned int limit = t->alimit;
>   if (limit > 0 && isempty(&t->array[limit - 1])) {
>     /* (1) there must be a boundary before 'limit' */
>     if (limit >= 2 && !isempty(&t->array[limit - 2])) {
>       /* 'limit - 1' is a boundary; can it be a new limit? */
>       if (ispow2realasize(t) && !ispow2(limit - 1)) {
>         t->alimit = limit - 1;
>         setnorealasize(t);
>       }
>       return limit - 1;
>     }
>     else {  /* must search for a boundary in [0, limit] */
>       unsigned int boundary = binsearch(t->array, 0, limit);
>       /* can this boundary represent the real size of the array? */
>       if (ispow2realasize(t) && boundary > luaH_realasize(t) / 2) {
>         t->alimit = boundary;  /* use it as the new limit */
>         setnorealasize(t);
>       }
>       return boundary;
>     }

776a882,904
>   /* 'limit' is zero or present in table */
>   if (!limitequalsasize(t)) {
>     /* (2) 'limit' > 0 and array has more elements after 'limit' */
>     if (isempty(&t->array[limit]))  /* 'limit + 1' is empty? */
>       return limit;  /* this is the boundary */
>     /* else, try last element in the array */
>     limit = luaH_realasize(t);
>     if (isempty(&t->array[limit - 1])) {  /* empty? */
>       /* there must be a boundary in the array after old limit,
>          and it must be a valid new limit */
>       unsigned int boundary = binsearch(t->array, t->alimit, limit);
>       t->alimit = boundary;
>       return boundary;
>     }
>     /* else, new limit is present in the table; check the hash part */
>   }
>   /* (3) 'limit' is the last element and either is zero or present in table */
>   lua_assert(limit == luaH_realasize(t) &&
>              (limit == 0 || !isempty(&t->array[limit - 1])));
>   if (isdummy(t) || isempty(luaH_getint(t, cast(lua_Integer, limit + 1))))
>     return limit;  /* 'limit + 1' is absent... */
>   else  /* 'limit + 1' is also present */
>     return hash_search(t, limit);

src/ltable.h

2c2
< ** $Id: ltable.h,v 2.26 2018/02/23 13:13:31 roberto Exp $
> ** $Id: ltable.h,v 2.28 2018/06/15 14:14:20 roberto Exp $

24,25d23
< #define luaH_emptyobject	(&luaH_emptyobject_)
< 

35,37d32
< LUAI_DDEC const TValue luaH_emptyobject_;
< 
< 

52a48
> LUAI_FUNC unsigned int luaH_realasize (const Table *t);

src/ltablib.c

2c2
< ** $Id: ltablib.c,v 1.95 2018/02/27 18:47:32 roberto Exp $
> ** $Id: ltablib.c,v 1.97 2018/04/04 14:23:41 roberto Exp $

98,99c98,99
<   lua_pushinteger(L, pos);
<   lua_removekey(L, 1);  /* remove entry t[pos] */
>   lua_pushnil(L);
>   lua_seti(L, 1, pos);  /* remove entry t[pos] */

176c176
< static int pack (lua_State *L) {
> static int tpack (lua_State *L) {

189c189
< static int unpack (lua_State *L) {
> static int tunpack (lua_State *L) {

411,412c411,412
<   {"pack", pack},
<   {"unpack", unpack},
>   {"pack", tpack},
>   {"unpack", tunpack},

src/ltm.c

2c2
< ** $Id: ltm.c,v 2.66 2018/02/27 17:48:28 roberto Exp $
> ** $Id: ltm.c,v 2.70 2018/06/15 19:31:22 roberto Exp $

41d40
<     "__undef", "__isdef",

84c83
<   return (mt ? luaH_getshortstr(mt, G(L)->tmname[event]) : luaO_nilobject);
>   return (mt ? luaH_getshortstr(mt, G(L)->tmname[event]) : &G(L)->nilvalue);

220c219
<                          Proto *p) {
>                          const Proto *p) {

253,279d251
< 
< int luaT_keydef (lua_State *L, TValue *obj, TValue *key, int remove) {
<   const TValue *tm;
<   TMS event = remove ? TM_UNDEF : TM_ISDEF;
<   if (!ttistable(obj)) {  /* not a table? */
<     tm = luaT_gettmbyobj(L, obj, event);  /* get its metamethod */
<     if (notm(tm)) {  /* no metamethod? */
<       const char *msg = remove ? "remove key from" : "check key from";
<       luaG_typeerror(L, obj, msg);  /* error */
<     }
<     /* else will call metamethod 'tm' */
<   }
<   else {  /* 'obj' is a table */
<     Table *t = hvalue(obj);
<     tm = fasttm(L, t->metatable, event);
<     if (tm == NULL) {  /* no metamethod? */
<       const TValue *val = luaH_get(t, key);  /* get entry */
<       int res = !isempty(val);  /* true if entry is not empty */
<       if (remove && res)  /* key is present and should be removed? */
<         setempty(cast(TValue*, val));  /* remove it */
<       return res;
<     }
<     /* else will call metamethod 'tm' */
<   }
<   luaT_callTMres(L, tm, obj, key, L->top);
<   return !l_isfalse(s2v(L->top));
< }

src/ltm.h

2c2
< ** $Id: ltm.h,v 2.34 2018/02/27 17:48:28 roberto Exp $
> ** $Id: ltm.h,v 2.39 2018/06/18 12:51:05 roberto Exp $

12d11
< #include "lstate.h"

22,23d20
<   TM_UNDEF,
<   TM_ISDEF,

54c51
< #define notm(tm)	ttisnilorempty(tm)
> #define notm(tm)	ttisnil(tm)

64c61
< LUAI_DDEC const char *const luaT_typenames_[LUA_TOTALTAGS];
> LUAI_DDEC(const char *const luaT_typenames_[LUA_TOTALTAGS];)

90c87
<                                    struct CallInfo *ci, Proto *p);
>                                    struct CallInfo *ci, const Proto *p);

94,95d90
< LUAI_FUNC int luaT_keydef (lua_State *L, TValue *obj, TValue *key, int remove);
< 

src/lua.c

2c2
< ** $Id: lua.c,v 1.234 2018/03/06 20:30:17 roberto Exp $
> ** $Id: lua.c,v 1.235 2018/03/16 14:23:08 roberto Exp $

385a386,387
> #define lua_initreadline(L)  \
> 	((void)L, rl_readline_name="lua", rl_inhibit_completion=1)

391a394
> #define lua_initreadline(L)  ((void)L)

541a545
>   lua_initreadline(L);

src/lua.h

2c2
< ** $Id: lua.h,v 1.344 2018/03/05 14:15:32 roberto Exp $
> ** $Id: lua.h,v 1.347 2018/06/18 12:08:10 roberto Exp $

22c22
< #define LUA_VERSION_RELEASE	"0" " (work1)"
> #define LUA_VERSION_RELEASE	"0"

152c152
< LUA_API const lua_Number *(lua_version) (lua_State *L);
> LUA_API lua_Number (lua_version) (lua_State *L);

334,336d333
< LUA_API void (lua_removekey) (lua_State *L, int idx);
< LUA_API int (lua_keyin) (lua_State *L, int idx);
< 

464,465c461,462
<   unsigned short fTransfer;/* (r) index of first value transfered */
<   unsigned short nTransfer;   /* (r) number of transfered values */
>   unsigned short ftransfer;   /* (r) index of first value transferred */
>   unsigned short ntransfer;   /* (r) number of transferred values */

src/luac.c

0a1,13
> /*
> ** $Id: luac.c,v 1.75 2015/03/12 01:58:27 lhf Exp $
> ** Lua compiler (saves bytecodes to files; also lists bytecodes)
> ** See Copyright Notice in lua.h
> */
> 
> #define luac_c
> #define LUA_CORE
> 
> #include "lprefix.h"
> 
> #include <ctype.h>
> #include <errno.h>

2a16,680
> #include <string.h>
> 
> #include "lua.h"
> #include "lauxlib.h"
> 
> #include "lobject.h"
> #include "lstate.h"
> #include "lundump.h"
> 
> static void PrintFunction(const Proto* f, int full);
> #define luaU_print	PrintFunction
> 
> #define PROGNAME	"luac"		/* default program name */
> #define OUTPUT		PROGNAME ".out"	/* default output file */
> 
> static int listing=0;			/* list bytecodes? */
> static int dumping=1;			/* dump bytecodes? */
> static int stripping=0;			/* strip debug information? */
> static char Output[]={ OUTPUT };	/* default output file name */
> static const char* output=Output;	/* actual output file name */
> static const char* progname=PROGNAME;	/* actual program name */
> 
> static void fatal(const char* message)
> {
>  fprintf(stderr,"%s: %s\n",progname,message);
>  exit(EXIT_FAILURE);
> }
> 
> static void cannot(const char* what)
> {
>  fprintf(stderr,"%s: cannot %s %s: %s\n",progname,what,output,strerror(errno));
>  exit(EXIT_FAILURE);
> }
> 
> static void usage(const char* message)
> {
>  if (*message=='-')
>   fprintf(stderr,"%s: unrecognized option '%s'\n",progname,message);
>  else
>   fprintf(stderr,"%s: %s\n",progname,message);
>  fprintf(stderr,
>   "usage: %s [options] [filenames]\n"
>   "Available options are:\n"
>   "  -l       list (use -l -l for full listing)\n"
>   "  -o name  output to file 'name' (default is \"%s\")\n"
>   "  -p       parse only\n"
>   "  -s       strip debug information\n"
>   "  -v       show version information\n"
>   "  --       stop handling options\n"
>   "  -        stop handling options and process stdin\n"
>   ,progname,Output);
>  exit(EXIT_FAILURE);
> }
> 
> #define IS(s)	(strcmp(argv[i],s)==0)
> 
> static int doargs(int argc, char* argv[])
> {
>  int i;
>  int version=0;
>  if (argv[0]!=NULL && *argv[0]!=0) progname=argv[0];
>  for (i=1; i<argc; i++)
>  {
>   if (*argv[i]!='-')			/* end of options; keep it */
>    break;
>   else if (IS("--"))			/* end of options; skip it */
>   {
>    ++i;
>    if (version) ++version;
>    break;
>   }
>   else if (IS("-"))			/* end of options; use stdin */
>    break;
>   else if (IS("-l"))			/* list */
>    ++listing;
>   else if (IS("-o"))			/* output file */
>   {
>    output=argv[++i];
>    if (output==NULL || *output==0 || (*output=='-' && output[1]!=0))
>     usage("'-o' needs argument");
>    if (IS("-")) output=NULL;
>   }
>   else if (IS("-p"))			/* parse only */
>    dumping=0;
>   else if (IS("-s"))			/* strip debug information */
>    stripping=1;
>   else if (IS("-v"))			/* show version */
>    ++version;
>   else					/* unknown option */
>    usage(argv[i]);
>  }
>  if (i==argc && (listing || !dumping))
>  {
>   dumping=0;
>   argv[--i]=Output;
>  }
>  if (version)
>  {
>   printf("%s\n",LUA_COPYRIGHT);
>   if (version==argc-1) exit(EXIT_SUCCESS);
>  }
>  return i;
> }
> 
> #define FUNCTION "(function()end)();"
> 
> static const char* reader(lua_State* L, void* ud, size_t* size)
> {
>  UNUSED(L);
>  if ((*(int*)ud)--)
>  {
>   *size=sizeof(FUNCTION)-1;
>   return FUNCTION;
>  }
>  else
>  {
>   *size=0;
>   return NULL;
>  }
> }
> 
> #define toproto(L,i) getproto(s2v(L->top+(i)))
> 
> static const Proto* combine(lua_State* L, int n)
> {
>  if (n==1)
>   return toproto(L,-1);
>  else
>  {
>   Proto* f;
>   int i=n;
>   if (lua_load(L,reader,&i,"=(" PROGNAME ")",NULL)!=LUA_OK) fatal(lua_tostring(L,-1));
>   f=toproto(L,-1);
>   for (i=0; i<n; i++)
>   {
>    f->p[i]=toproto(L,i-n-1);
>    if (f->p[i]->sizeupvalues>0) f->p[i]->upvalues[0].instack=0;
>   }
>   f->sizelineinfo=0;
>   return f;
>  }
> }
> 
> static int writer(lua_State* L, const void* p, size_t size, void* u)
> {
>  UNUSED(L);
>  return (fwrite(p,size,1,(FILE*)u)!=1) && (size!=0);
> }
> 
> static int pmain(lua_State* L)
> {
>  int argc=(int)lua_tointeger(L,1);
>  char** argv=(char**)lua_touserdata(L,2);
>  const Proto* f;
>  int i;
>  if (!lua_checkstack(L,argc)) fatal("too many input files");
>  for (i=0; i<argc; i++)
>  {
>   const char* filename=IS("-") ? NULL : argv[i];
>   if (luaL_loadfile(L,filename)!=LUA_OK) fatal(lua_tostring(L,-1));
>  }
>  f=combine(L,argc);
>  if (listing) luaU_print(f,listing>1);
>  if (dumping)
>  {
>   FILE* D= (output==NULL) ? stdout : fopen(output,"wb");
>   if (D==NULL) cannot("open");
>   lua_lock(L);
>   luaU_dump(L,f,writer,D,stripping);
>   lua_unlock(L);
>   if (ferror(D)) cannot("write");
>   if (fclose(D)) cannot("close");
>  }
>  return 0;
> }
> 
> int main(int argc, char* argv[])
> {
>  lua_State* L;
>  int i=doargs(argc,argv);
>  argc-=i; argv+=i;
>  if (argc<=0) usage("no input files given");
>  L=luaL_newstate();
>  if (L==NULL) fatal("cannot create state: not enough memory");
>  lua_pushcfunction(L,&pmain);
>  lua_pushinteger(L,argc);
>  lua_pushlightuserdata(L,argv);
>  if (lua_pcall(L,2,0,0)!=LUA_OK) fatal(lua_tostring(L,-1));
>  lua_close(L);
>  return EXIT_SUCCESS;
> }
> 
> /*
> ** print bytecodes
> */
> 
> #include <ctype.h>
> #include <stdio.h>
> 
> #define luac_c
> #define LUA_CORE
> #define LUAI_DEFOPNAMES
> 
> #include "ldebug.h"
> #include "lobject.h"
> #include "lopcodes.c"
> 
> #define UPVALNAME(x) ((f->upvalues[x].name) ? getstr(f->upvalues[x].name) : "-")
> #define VOID(p) ((const void*)(p))
> #define getfuncline(f,pc) luaG_getfuncline((Proto *)f,pc)
> 
> static void PrintString(const TString* ts)
> {
>  const char* s=getstr(ts);
>  size_t i,n=tsslen(ts);
>  printf("\"");
>  for (i=0; i<n; i++)
>  {
>   int c=(int)(unsigned char)s[i];
>   switch (c)
>   {
>    case '"':
> 	printf("\\\"");
> 	break;
>    case '\\':
>    	printf("\\\\");
> 	break;
>    case '\a':
>    	printf("\\a");
> 	break;
>    case '\b':
>    	printf("\\b");
> 	break;
>    case '\f':
>    	printf("\\f");
> 	break;
>    case '\n':
>    	printf("\\n");
> 	break;
>    case '\r':
>    	printf("\\r");
> 	break;
>    case '\t':
>    	printf("\\t");
> 	break;
>    case '\v':
>    	printf("\\v");
> 	break;
>    default:
> 	if (isprint(c)) printf("%c",c); else printf("\\%03d",c);
> 	break;
>   }
>  }
>  printf("\"");
> }
> 
> static void PrintConstant(const Proto* f, int i)
> {
>  const TValue* o=&f->k[i];
>  switch (ttypetag(o))
>  {
>   case LUA_TNIL:
> 	printf("nil");
> 	break;
>   case LUA_TBOOLEAN:
> 	printf(bvalue(o) ? "true" : "false");
> 	break;
>   case LUA_TNUMFLT:
> 	{
> 	char buff[100];
> 	sprintf(buff,LUA_NUMBER_FMT,fltvalue(o));
> 	printf("%s",buff);
> 	if (buff[strspn(buff,"-0123456789")]=='\0') printf(".0");
> 	break;
> 	}
>   case LUA_TNUMINT:
> 	printf(LUA_INTEGER_FMT,ivalue(o));
> 	break;
>   case LUA_TSHRSTR:
>   case LUA_TLNGSTR:
> 	PrintString(tsvalue(o));
> 	break;
>   default:				/* cannot happen */
> 	printf("? type=%d",ttypetag(o));
> 	break;
>  }
> }
> 
> static void PrintCode(const Proto* f)
> {
>  const Instruction* code=f->code;
>  int pc,n=f->sizecode;
>  for (pc=0; pc<n; pc++)
>  {
>   Instruction i=code[pc];
>   OpCode o=GET_OPCODE(i);
>   int a=GETARG_A(i);
>   int b=GETARG_B(i);
>   int c=GETARG_C(i);
>   int ax=GETARG_Ax(i);
>   int bx=GETARG_Bx(i);
>   int sb=GETARG_sB(i);
>   int sc=GETARG_sC(i);
>   int sbx=GETARG_sBx(i);
>   int isk=GETARG_k(i);
>   int line=getfuncline(f,pc);
>   printf("\t%d\t",pc+1);
>   if (line>0) printf("[%d]\t",line); else printf("[-]\t");
>   printf("%-9s\t",luaP_opnames[o]);
>   switch (o)
>   {
>    case OP_MOVE:
> 	printf("%d %d",a,b);
> 	break;
>    case OP_LOADI:
> 	printf("%d %d",a,sbx);
> 	break;
>    case OP_LOADF:
> 	printf("%d %d",a,sbx);
> 	break;
>    case OP_LOADK:
> 	printf("%d %d",a,bx);
> 	printf("\t; "); PrintConstant(f,bx);
> 	break;
>    case OP_LOADKX:
> 	printf("%d",a);
> 	break;
>    case OP_LOADBOOL:
> 	printf("%d %d %d",a,b,c);
> 	if (c) printf("\t; to %d",pc+2);
> 	break;
>    case OP_LOADNIL:
> 	printf("%d %d",a,b);
> 	printf("\t; %d out",b+1);
> 	break;
>    case OP_GETUPVAL:
> 	printf("%d %d",a,b);
> 	printf("\t; %s",UPVALNAME(b));
> 	break;
>    case OP_SETUPVAL:
> 	printf("%d %d",a,b);
> 	printf("\t; %s",UPVALNAME(b));
> 	break;
>    case OP_GETTABUP:
> 	printf("%d %d %d",a,b,c);
> 	printf("\t; %s",UPVALNAME(b));
> 	printf(" "); PrintConstant(f,c);
> 	break;
>    case OP_GETTABLE:
> 	printf("%d %d %d",a,b,c);
> 	break;
>    case OP_GETI:
> 	printf("%d %d %d",a,b,c);
> 	break;
>    case OP_GETFIELD:
> 	printf("%d %d %d",a,b,c);
> 	printf("\t; "); PrintConstant(f,c);
> 	break;
>    case OP_SETTABUP:
> 	printf("%d %d %d%s",a,b,c, isk ? "k" : "");
> 	printf("\t; %s",UPVALNAME(a));
> 	printf(" "); PrintConstant(f,b);
> 	if (isk) { printf(" "); PrintConstant(f,c); }
> 	break;
>    case OP_SETTABLE:
> 	printf("%d %d %d%s",a,b,c, isk ? "k" : "");
> 	if (isk) { printf("\t; "); PrintConstant(f,c); }
> 	break;
>    case OP_SETI:
> 	printf("%d %d %d%s",a,b,c, isk ? "k" : "");
> 	if (isk) { printf("\t; "); PrintConstant(f,c); }
> 	break;
>    case OP_SETFIELD:
> 	printf("%d %d %d%s",a,b,c, isk ? "k" : "");
> 	printf("\t; "); PrintConstant(f,b);
> 	if (isk) { printf(" "); PrintConstant(f,c); }
> 	break;
>    case OP_NEWTABLE:
> 	printf("%d %d %d",a,b,c);
> 	break;
>    case OP_SELF:
> 	printf("%d %d %d%s",a,b,c, isk ? "k" : "");
> 	if (isk) { printf("\t; "); PrintConstant(f,c); }
> 	break;
>    case OP_ADDI:
> 	printf("%d %d %d",a,b,sc);
> 	break;
>    case OP_SUBI:
> 	printf("%d %d %d",a,b,sc);
> 	break;
>    case OP_MULI:
> 	printf("%d %d %d",a,b,sc);
> 	break;
>    case OP_MODI:
> 	printf("%d %d %d",a,b,sc);
> 	break;
>    case OP_POWI:
> 	printf("%d %d %d",a,b,sc);
> 	break;
>    case OP_DIVI:
> 	printf("%d %d %d",a,b,sc);
> 	break;
>    case OP_IDIVI:
> 	printf("%d %d %d",a,b,sc);
> 	break;
>    case OP_BANDK:
> 	printf("%d %d %d",a,b,c);
> 	printf("\t; "); PrintConstant(f,c); 
> 	break;
>    case OP_BORK:
> 	printf("%d %d %d",a,b,c);
> 	printf("\t; "); PrintConstant(f,c); 
> 	break;
>    case OP_BXORK:
> 	printf("%d %d %d",a,b,c);
> 	printf("\t; "); PrintConstant(f,c); 
> 	break;
>    case OP_SHRI:
> 	printf("%d %d %d",a,b,c);
> 	break;
>    case OP_SHLI:
> 	printf("%d %d %d",a,b,c);
> 	break;
>    case OP_ADD:
> 	printf("%d %d %d",a,b,c);
> 	break;
>    case OP_SUB:
> 	printf("%d %d %d",a,b,c);
> 	break;
>    case OP_MUL:
> 	printf("%d %d %d",a,b,c);
> 	break;
>    case OP_MOD:
> 	printf("%d %d %d",a,b,c);
> 	break;
>    case OP_POW:
> 	printf("%d %d %d",a,b,c);
> 	break;
>    case OP_DIV:
> 	printf("%d %d %d",a,b,c);
> 	break;
>    case OP_IDIV:
> 	printf("%d %d %d",a,b,c);
> 	break;
>    case OP_BAND:
> 	printf("%d %d %d",a,b,c);
> 	break;
>    case OP_BOR:
> 	printf("%d %d %d",a,b,c);
> 	break;
>    case OP_BXOR:
> 	printf("%d %d %d",a,b,c);
> 	break;
>    case OP_SHL:
> 	printf("%d %d %d",a,b,c);
> 	break;
>    case OP_SHR:
> 	printf("%d %d %d",a,b,c);
> 	break;
>    case OP_UNM:
> 	printf("%d %d",a,b);
> 	break;
>    case OP_BNOT:
> 	printf("%d %d",a,b);
> 	break;
>    case OP_NOT:
> 	printf("%d %d",a,b);
> 	break;
>    case OP_LEN:
> 	printf("%d %d",a,b);
> 	break;
>    case OP_CONCAT:
> 	printf("%d %d",a,b);
> 	break;
>    case OP_CLOSE:
> 	printf("%d",a);
> 	break;
>    case OP_JMP:
> 	printf("%d",GETARG_sJ(i));
> 	printf("\t; to %d",GETARG_sJ(i)+pc+2);
> 	break;
>    case OP_EQ:
> 	printf("%d %d %d",a,b,isk);
> 	break;
>    case OP_LT:
> 	printf("%d %d %d",a,b,isk);
> 	break;
>    case OP_LE:
> 	printf("%d %d %d",a,b,isk);
> 	break;
>    case OP_EQK:
> 	printf("%d %d %d",a,b,isk);
> 	printf("\t; "); PrintConstant(f,b);
> 	break;
>    case OP_EQI:
> 	printf("%d %d %d",a,sb,isk);
> 	break;
>    case OP_LTI:
> 	printf("%d %d %d",a,sb,isk);
> 	break;
>    case OP_LEI:
> 	printf("%d %d %d",a,sb,isk);
> 	break;
>    case OP_GTI:
> 	printf("%d %d %d",a,sb,isk);
> 	break;
>    case OP_GEI:
> 	printf("%d %d %d",a,sb,isk);
> 	break;
>    case OP_TEST:
> 	printf("%d %d",a,isk);
> 	break;
>    case OP_TESTSET:
> 	printf("%d %d %d",a,b,isk);
> 	break;
>    case OP_CALL:
> 	printf("%d %d %d",a,b,c);
> 	printf("\t; ");
>    	if (b==0) printf("all in "); else printf("%d in ",b-1);
>    	if (c==0) printf("all out"); else printf("%d out",c-1);
> 	break;
>    case OP_TAILCALL:
> 	printf("%d %d %d",a,b,c);
> 	printf("\t; %d in",b-1);
> 	break;
>    case OP_RETURN:
> 	printf("%d %d %d",a,b,c);
> 	printf("\t; ");
>    	if (b==0) printf("all out"); else printf("%d out",b-1);
> 	break;
>    case OP_RETURN0:
> 	break;
>    case OP_RETURN1:
> 	printf("%d",a);
> 	break;
>    case OP_FORLOOP1:
> 	printf("%d %d",a,bx);
> 	printf("\t; to %d",pc-bx+2);
> 	break;
>    case OP_FORPREP1:
> 	printf("%d %d",a,bx);
> 	printf("\t; to %d",pc+bx+2);
> 	break;
>    case OP_FORLOOP:
> 	printf("%d %d",a,bx);
> 	printf("\t; to %d",pc-bx+2);
> 	break;
>    case OP_FORPREP:
> 	printf("%d %d",a,bx);
> 	printf("\t; to %d",pc+bx+2);
> 	break;
>    case OP_TFORCALL:
> 	printf("%d %d",a,c);
> 	break;
>    case OP_TFORLOOP:
> 	printf("%d %d",a,bx);
> 	printf("\t; to %d",pc-bx+2);
> 	break;
>    case OP_SETLIST:
> 	printf("%d %d %d",a,b,c);
> 	break;
>    case OP_CLOSURE:
> 	printf("%d %d",a,bx);
> 	printf("\t; %p",VOID(f->p[bx]));
> 	break;
>    case OP_VARARG:
> 	printf("%d %d",a,c);
> 	printf("\t; ");
>    	if (c==0) printf("all out"); else printf("%d out",c-1);
> 	break;
>    case OP_PREPVARARG:
> 	printf("%d",a);
> 	break;
>    case OP_EXTRAARG:
> 	printf("%d",ax);
> 	printf("\t; "); PrintConstant(f,ax);
> 	break;
>   }
>   printf("\n");
>  }
> }
> 
> static void riPrintCode(const Proto* p)
> {
>  const Instruction* code=p->code;
>  int pc,n=p->sizecode;
>  for (pc=0; pc<n; pc++)
>  {
>   Instruction i = code[pc];
>   OpCode o = GET_OPCODE(i);
>   const char *name = luaP_opnames[o];
>   int line = luaG_getfuncline(p, pc);
>   printf("(%4d) %4d - ", line, pc);
>   switch (getOpMode(o)) {
>     case iABC:
>       printf("%-12s%4d %4d %4d%s", name,
>               GETARG_A(i), GETARG_B(i), GETARG_C(i),
>               GETARG_k(i) ? " (k)" : "");
>       break;
>     case iABx:
>       printf("%-12s%4d %4d", name, GETARG_A(i), GETARG_Bx(i));
>       break;
>     case iAsBx:
>       printf("%-12s%4d %4d", name, GETARG_A(i), GETARG_sBx(i));
>       break;
>     case iAx:
>       printf("%-12s%4d", name, GETARG_Ax(i));
>       break;
>     case isJ:
>       printf("%-12s%4d (%1d)", name, GETARG_sJ(i), !!GETARG_m(i));
>       break;
>   }
>  printf("\n");
>  }
> }
> 
> #define SS(x)	((x==1)?"":"s")
> #define S(x)	(int)(x),SS(x)
> 
> static void PrintHeader(const Proto* f)
> {
>  const char* s=f->source ? getstr(f->source) : "=?";
>  if (*s=='@' || *s=='=')
>   s++;
>  else if (*s==LUA_SIGNATURE[0])
>   s="(bstring)";
>  else
>   s="(string)";
>  printf("\n%s <%s:%d,%d> (%d instruction%s at %p)\n",
> 	(f->linedefined==0)?"main":"function",s,
> 	f->linedefined,f->lastlinedefined,
> 	S(f->sizecode),VOID(f));
>  printf("%d%s param%s, %d slot%s, %d upvalue%s, ",
> 	(int)(f->numparams),f->is_vararg?"+":"",SS(f->numparams),
> 	S(f->maxstacksize),S(f->sizeupvalues));
>  printf("%d local%s, %d constant%s, %d function%s\n",
> 	S(f->sizelocvars),S(f->sizek),S(f->sizep));
> }
> 
> static void PrintDebug(const Proto* f)
> {
>  int i,n;
>  n=f->sizek;
>  printf("constants (%d) for %p:\n",n,VOID(f));
>  for (i=0; i<n; i++)
>  {
>   printf("\t%d\t",i+1);
>   PrintConstant(f,i);
>   printf("\n");
>  }
>  n=f->sizelocvars;
>  printf("locals (%d) for %p:\n",n,VOID(f));
>  for (i=0; i<n; i++)
>  {
>   printf("\t%d\t%s\t%d\t%d\n",
>   i,getstr(f->locvars[i].varname),f->locvars[i].startpc+1,f->locvars[i].endpc+1);
>  }
>  n=f->sizeupvalues;
>  printf("upvalues (%d) for %p:\n",n,VOID(f));
>  for (i=0; i<n; i++)
>  {
>   printf("\t%d\t%s\t%d\t%d\n",
>   i,UPVALNAME(i),f->upvalues[i].instack,f->upvalues[i].idx);
>  }
> }

4c682
< int main(void)
> static void PrintFunction(const Proto* f, int full)

6,7c684,689
<  fprintf(stderr,"luac: not yet ready\n");
<  return EXIT_FAILURE;
>  int i,n=f->sizep;
>  PrintHeader(f);
>  riPrintCode(f);
>  PrintCode(f);
>  if (full) PrintDebug(f);
>  for (i=0; i<n; i++) PrintFunction(f->p[i],full);

src/luaconf.h

2c2
< ** $Id: luaconf.h,v 1.267 2018/03/09 14:56:02 roberto Exp $
> ** $Id: luaconf.h,v 1.270 2018/06/18 12:51:05 roberto Exp $

257c257,261
< /* more often than not the libs go together with the core */
> /*
> ** More often than not the libs go together with the core;
> ** Functions from the auxiliary library must be exported,
> ** but opening functions do not.
> */

259c263
< #define LUAMOD_API	LUALIB_API
> #define LUAMOD_API	LUAI_FUNC

265,266c269,270
< @@ LUAI_DDEF and LUAI_DDEC are marks for all extern (const) variables
< ** that are not to be exported to outside modules (LUAI_DDEF for
> @@ LUAI_DDEF and LUAI_DDEC are marks for all extern (const) variables,
> ** none of which to be exported to outside modules (LUAI_DDEF for

283c287
< #define LUAI_DDEC	LUAI_FUNC
> #define LUAI_DDEC(dec)	LUAI_FUNC dec

449a454
> @@ LUA_UNSIGNEDBITS is the number of bits in a LUA_UNSIGNED.

470a476,477
> #define LUA_UNSIGNEDBITS	(sizeof(LUA_UNSIGNED) * CHAR_BIT)
> 

699c706
< ** "maximum" alignment for the other items in that union.
> ** maximum alignment for the other items in that union.

706,713d712
< /*
< @@ LUA_QL describes how error messages quote program elements.
< ** Lua does not use these macros anymore; they are here for
< ** compatibility only.
< */
< #define LUA_QL(x)	"'" x "'"
< #define LUA_QS		LUA_QL("%s")
< 

src/lundump.c

2c2
< ** $Id: lundump.c,v 2.49 2017/12/07 18:59:52 roberto Exp $
> ** $Id: lundump.c,v 2.50 2018/06/01 16:45:58 roberto Exp $

39c39
< static l_noret error(LoadState *S, const char *why) {
> static l_noret error (LoadState *S, const char *why) {

98c98,101
< static TString *LoadString (LoadState *S) {
> /*
> ** Load a nullable string
> */
> static TString *LoadStringN (LoadState *S) {

114a118,128
> /*
> ** Load a non-nullable string.
> */
> static TString *LoadString (LoadState *S) {
>   TString *st = LoadStringN(S);
>   if (st == NULL)
>     error(S, "bad format for constant string");
>   return st;
> }
> 
> 

206c220
<     f->locvars[i].varname = LoadString(S);
>     f->locvars[i].varname = LoadStringN(S);

212c226
<     f->upvalues[i].name = LoadString(S);
>     f->upvalues[i].name = LoadStringN(S);

217c231
<   f->source = LoadString(S);
>   f->source = LoadStringN(S);

src/lvm.c

2c2
< ** $Id: lvm.c,v 2.350 2018/03/07 15:55:38 roberto Exp $
> ** $Id: lvm.c,v 2.359 2018/06/18 17:58:21 roberto Exp $

39c39,43
< #define LUA_USE_JUMPTABLE	defined(__GNUC__)
> #if defined(__GNUC__)
> #define LUA_USE_JUMPTABLE	1
> #else
> #define LUA_USE_JUMPTABLE	0
> #endif

49,50c53,54
< ** 'l_intfitsf' checks whether a given integer can be converted to a
< ** float without rounding. Used in comparisons.
> ** 'l_intfitsf' checks whether a given integer is in the range that
> ** can be converted to a float without rounding. Used in comparisons.

51a56
> 

56,58c61,63
< ** Check whether some integers may not fit in a float, that is, whether
< ** (maxinteger >> NBM) > 0 (that implies (1 << NBM) <= maxinteger).
< ** (The shifts are done in parts to avoid shifting by more than the size
> ** Check whether some integers may not fit in a float, testing whether
> ** (maxinteger >> NBM) > 0. (That implies (1 << NBM) <= maxinteger.)
> ** (The shifts are done in parts, to avoid shifting by more than the size

60c65
< ** sizeof(integer) == 32.)
> ** sizeof(long) == 32.)

65,66c70,74
< #define l_intfitsf(i)  \
<   (-((lua_Integer)1 << NBM) <= (i) && (i) <= ((lua_Integer)1 << NBM))
> /* limit for integers that fit in a float */
> #define MAXINTFITSF	((lua_Unsigned)1 << NBM)
> 
> /* check whether 'i' is in the interval [-MAXINTFITSF, MAXINTFITSF] */
> #define l_intfitsf(i)	((MAXINTFITSF + l_castS2U(i)) <= (2 * MAXINTFITSF))

191c199
<       if (notm(tm))
>       if (unlikely(notm(tm)))

222,224c230,232
< ** to the entry 't[key]', or to 'luaH_emptyobject' if there is no such
< ** entry.  (The value at 'slot' must be empty, otherwise 'luaV_fastget'
< ** would have done the job.)
> ** to the entry 't[key]', or to a value with an absent key if there
> ** is no such entry.  (The value at 'slot' must be empty, otherwise
> ** 'luaV_fastget' would have done the job.)

236c244
<         if (slot == luaH_emptyobject)  /* no previous entry? */
>         if (isabstkey(slot))  /* no previous entry? */

248c256
<       if (notm(tm))
>       if (unlikely(notm(tm)))

484c492
<     case LUA_TBOOLEAN: return bvalue(t1) == bvalue(t2);  /* true must be 1 !! */
>     case LUA_TBOOLEAN: return bvalue(t1) == bvalue(t2);  /* true must be 1! */

556c564
<         if (l >= (MAX_SIZE/sizeof(char)) - tl)
>         if (unlikely(l >= (MAX_SIZE/sizeof(char)) - tl))

600c608
<       if (notm(tm))  /* no metamethod? */
>       if (unlikely(notm(tm)))  /* no metamethod? */

617c625
<     if (n == 0)
>     if (unlikely(n == 0))

637c645
<     if (n == 0)
>     if (unlikely(n == 0))

707c715
<     /* new closure is white, so we do not need a barrier here */
>     luaC_objbarrier(L, ncl, ncl->upvals[i]);

862,867c870,872
<   i = *(pc++); \
<   if (trap) { \
<     if (!(L->hookmask & (LUA_MASKLINE | LUA_MASKCOUNT))) \
<       trap = ci->u.l.trap = 0;  /* no need to stop again */ \
<     else { savepc(L); luaG_traceexec(L); } \
<     updatebase(ci);  /* the trap may be just for that */ \
>   if (trap) {  /* stack reallocation or hooks? */ \
>     trap = luaG_traceexec(L, pc);  /* handle hooks */ \
>     updatebase(ci);  /* correct stack */ \

868a874
>   i = *(pc++); \

870d875
<   vra = s2v(ra); \

894c899
<       trap = 0;  /* hooks will start with PREPVARARG instruction */
>       trap = 0;  /* hooks will start after PREPVARARG instruction */

905d909
<     TValue *vra;  /* corresponding value */

922c926
<         setivalue(vra, b);
>         setivalue(s2v(ra), b);

927c931
<         setfltvalue(vra, cast_num(b));
>         setfltvalue(s2v(ra), cast_num(b));

937c941
<         setbvalue(vra, GETARG_B(i));
>         setbvalue(s2v(ra), GETARG_B(i));

955,956c959,960
<         setobj(L, uv->v, vra);
<         luaC_barrier(L, uv, vra);
>         setobj(L, uv->v, s2v(ra));
>         luaC_barrier(L, uv, s2v(ra));

1030,1032c1034,1036
<             ? (n = ivalue(rb), luaV_fastgeti(L, vra, n, slot))
<             : luaV_fastget(L, vra, rb, slot, luaH_get)) {
<           luaV_finishfastset(L, vra, slot, rc);
>             ? (n = ivalue(rb), luaV_fastgeti(L, s2v(ra), n, slot))
>             : luaV_fastget(L, s2v(ra), rb, slot, luaH_get)) {
>           luaV_finishfastset(L, s2v(ra), slot, rc);

1035c1039
<           Protect(luaV_finishset(L, vra, rb, rc, slot));
>           Protect(luaV_finishset(L, s2v(ra), rb, rc, slot));

1042,1043c1046,1047
<         if (luaV_fastgeti(L, vra, c, slot)) {
<           luaV_finishfastset(L, vra, slot, rc);
>         if (luaV_fastgeti(L, s2v(ra), c, slot)) {
>           luaV_finishfastset(L, s2v(ra), slot, rc);

1048c1052
<           Protect(luaV_finishset(L, vra, &key, rc, slot));
>           Protect(luaV_finishset(L, s2v(ra), &key, rc, slot));

1057,1058c1061,1062
<         if (luaV_fastget(L, vra, key, slot, luaH_getshortstr)) {
<           luaV_finishfastset(L, vra, slot, rc);
>         if (luaV_fastget(L, s2v(ra), key, slot, luaH_getshortstr)) {
>           luaV_finishfastset(L, s2v(ra), slot, rc);

1061c1065
<           Protect(luaV_finishset(L, vra, rb, rc, slot));
>           Protect(luaV_finishset(L, s2v(ra), rb, rc, slot));

1094c1098
<           setivalue(vra, intop(+, ivalue(rb), ic));
>           setivalue(s2v(ra), intop(+, ivalue(rb), ic));

1097c1101
<           setfltvalue(vra, luai_numadd(L, nb, cast_num(ic)));
>           setfltvalue(s2v(ra), luai_numadd(L, nb, cast_num(ic)));

1108c1112
<           setivalue(vra, intop(-, ivalue(rb), ic));
>           setivalue(s2v(ra), intop(-, ivalue(rb), ic));

1111c1115
<           setfltvalue(vra, luai_numsub(L, nb, cast_num(ic)));
>           setfltvalue(s2v(ra), luai_numsub(L, nb, cast_num(ic)));

1122c1126
<           setivalue(vra, intop(*, ivalue(rb), ic));
>           setivalue(s2v(ra), intop(*, ivalue(rb), ic));

1125c1129
<           setfltvalue(vra, luai_nummul(L, nb, cast_num(ic)));
>           setfltvalue(s2v(ra), luai_nummul(L, nb, cast_num(ic)));

1136c1140
<           setivalue(vra, luaV_mod(L, ivalue(rb), ic));
>           setivalue(s2v(ra), luaV_mod(L, ivalue(rb), ic));

1142c1146
<           setfltvalue(vra, m);
>           setfltvalue(s2v(ra), m);

1154c1158
<           setfltvalue(vra, luai_numpow(L, nb, nc));
>           setfltvalue(s2v(ra), luai_numpow(L, nb, nc));

1166c1170
<           setfltvalue(vra, luai_numdiv(L, nb, nc));
>           setfltvalue(s2v(ra), luai_numdiv(L, nb, nc));

1177c1181
<           setivalue(vra, luaV_div(L, ivalue(rb), ic));
>           setivalue(s2v(ra), luaV_div(L, ivalue(rb), ic));

1181c1185
<           setfltvalue(vra, luai_numdiv(L, nb, nc));
>           setfltvalue(s2v(ra), luai_numdiv(L, nb, nc));

1193c1197
<           setivalue(vra, intop(+, ib, ic));
>           setivalue(s2v(ra), intop(+, ib, ic));

1196c1200
<           setfltvalue(vra, luai_numadd(L, nb, nc));
>           setfltvalue(s2v(ra), luai_numadd(L, nb, nc));

1208c1212
<           setivalue(vra, intop(-, ib, ic));
>           setivalue(s2v(ra), intop(-, ib, ic));

1211c1215
<           setfltvalue(vra, luai_numsub(L, nb, nc));
>           setfltvalue(s2v(ra), luai_numsub(L, nb, nc));

1223c1227
<           setivalue(vra, intop(*, ib, ic));
>           setivalue(s2v(ra), intop(*, ib, ic));

1226c1230
<           setfltvalue(vra, luai_nummul(L, nb, nc));
>           setfltvalue(s2v(ra), luai_nummul(L, nb, nc));

1237c1241
<           setfltvalue(vra, luai_numdiv(L, nb, nc));
>           setfltvalue(s2v(ra), luai_numdiv(L, nb, nc));

1248c1252
<           setivalue(vra, intop(&, i1, ivalue(p2)));
>           setivalue(s2v(ra), intop(&, i1, ivalue(p2)));

1259c1263
<           setivalue(vra, intop(|, i1, ivalue(p2)));
>           setivalue(s2v(ra), intop(|, i1, ivalue(p2)));

1270c1274
<           setivalue(vra, intop(^, i1, ivalue(p2)));
>           setivalue(s2v(ra), intop(^, i1, ivalue(p2)));

1281c1285
<           setivalue(vra, intop(&, ib, ic));
>           setivalue(s2v(ra), intop(&, ib, ic));

1292c1296
<           setivalue(vra, intop(|, ib, ic));
>           setivalue(s2v(ra), intop(|, ib, ic));

1303c1307
<           setivalue(vra, intop(^, ib, ic));
>           setivalue(s2v(ra), intop(^, ib, ic));

1314c1318
<           setivalue(vra, luaV_shiftl(ib, -ic));
>           setivalue(s2v(ra), luaV_shiftl(ib, -ic));

1330c1334
<           setivalue(vra, luaV_shiftl(ic, ib));
>           setivalue(s2v(ra), luaV_shiftl(ic, ib));

1341c1345
<           setivalue(vra, luaV_shiftl(ib, ic));
>           setivalue(s2v(ra), luaV_shiftl(ib, ic));

1352c1356
<           setivalue(vra, luaV_shiftl(ib, -ic));
>           setivalue(s2v(ra), luaV_shiftl(ib, -ic));

1364c1368
<           setivalue(vra, luaV_mod(L, ib, ic));
>           setivalue(s2v(ra), luaV_mod(L, ib, ic));

1369c1373
<           setfltvalue(vra, m);
>           setfltvalue(s2v(ra), m);

1381c1385
<           setivalue(vra, luaV_div(L, ib, ic));
>           setivalue(s2v(ra), luaV_div(L, ib, ic));

1384c1388
<           setfltvalue(vra, luai_numidiv(L, nb, nc));
>           setfltvalue(s2v(ra), luai_numidiv(L, nb, nc));

1395c1399
<           setfltvalue(vra, luai_numpow(L, nb, nc));
>           setfltvalue(s2v(ra), luai_numpow(L, nb, nc));

1406c1410
<           setivalue(vra, intop(-, 0, ib));
>           setivalue(s2v(ra), intop(-, 0, ib));

1409c1413
<           setfltvalue(vra, luai_numunm(L, nb));
>           setfltvalue(s2v(ra), luai_numunm(L, nb));

1419c1423
<           setivalue(vra, intop(^, ~l_castS2U(0), ib));
>           setivalue(s2v(ra), intop(^, ~l_castS2U(0), ib));

1428c1432
<         setbvalue(vra, nrb);
>         setbvalue(s2v(ra), nrb);

1452c1456
<         Protect(cond = luaV_equalobj(L, vra, rb));
>         Protect(cond = luaV_equalobj(L, s2v(ra), rb));

1458,1461c1462,1465
<         if (ttisinteger(vra) && ttisinteger(rb))
<           cond = (ivalue(vra) < ivalue(rb));
<         else if (ttisnumber(vra) && ttisnumber(rb))
<           cond = LTnum(vra, rb);
>         if (ttisinteger(s2v(ra)) && ttisinteger(rb))
>           cond = (ivalue(s2v(ra)) < ivalue(rb));
>         else if (ttisnumber(s2v(ra)) && ttisnumber(rb))
>           cond = LTnum(s2v(ra), rb);

1463c1467
<           Protect(cond = lessthanothers(L, vra, rb));
>           Protect(cond = lessthanothers(L, s2v(ra), rb));

1469,1472c1473,1476
<         if (ttisinteger(vra) && ttisinteger(rb))
<           cond = (ivalue(vra) <= ivalue(rb));
<         else if (ttisnumber(vra) && ttisnumber(rb))
<           cond = LEnum(vra, rb);
>         if (ttisinteger(s2v(ra)) && ttisinteger(rb))
>           cond = (ivalue(s2v(ra)) <= ivalue(rb));
>         else if (ttisnumber(s2v(ra)) && ttisnumber(rb))
>           cond = LEnum(s2v(ra), rb);

1474c1478
<           Protect(cond = lessequalothers(L, vra, rb));
>           Protect(cond = lessequalothers(L, s2v(ra), rb));

1481c1485
<         cond = luaV_equalobj(NULL, vra, rb);
>         cond = luaV_equalobj(NULL, s2v(ra), rb);

1487,1490c1491,1494
<         if (ttisinteger(vra))
<           cond = (ivalue(vra) == im);
<         else if (ttisfloat(vra))
<           cond = luai_numeq(fltvalue(vra), cast_num(im));
>         if (ttisinteger(s2v(ra)))
>           cond = (ivalue(s2v(ra)) == im);
>         else if (ttisfloat(s2v(ra)))
>           cond = luai_numeq(fltvalue(s2v(ra)), cast_num(im));

1498,1501c1502,1505
<         if (ttisinteger(vra))
<           cond = (ivalue(vra) < im);
<         else if (ttisfloat(vra))
<           cond = luai_numlt(fltvalue(vra), cast_num(im));
>         if (ttisinteger(s2v(ra)))
>           cond = (ivalue(s2v(ra)) < im);
>         else if (ttisfloat(s2v(ra)))
>           cond = luai_numlt(fltvalue(s2v(ra)), cast_num(im));

1503c1507
<           Protect(cond = luaT_callorderiTM(L, vra, im, 0, TM_LT));
>           Protect(cond = luaT_callorderiTM(L, s2v(ra), im, 0, TM_LT));

1509,1512c1513,1516
<         if (ttisinteger(vra))
<           cond = (ivalue(vra) <= im);
<         else if (ttisfloat(vra))
<           cond = luai_numle(fltvalue(vra), cast_num(im));
>         if (ttisinteger(s2v(ra)))
>           cond = (ivalue(s2v(ra)) <= im);
>         else if (ttisfloat(s2v(ra)))
>           cond = luai_numle(fltvalue(s2v(ra)), cast_num(im));

1514c1518
<           Protect(cond = luaT_callorderiTM(L, vra, im, 0, TM_LE));
>           Protect(cond = luaT_callorderiTM(L, s2v(ra), im, 0, TM_LE));

1520,1523c1524,1527
<         if (ttisinteger(vra))
<           cond = (im < ivalue(vra));
<         else if (ttisfloat(vra))
<           cond = luai_numlt(cast_num(im), fltvalue(vra));
>         if (ttisinteger(s2v(ra)))
>           cond = (im < ivalue(s2v(ra)));
>         else if (ttisfloat(s2v(ra)))
>           cond = luai_numlt(cast_num(im), fltvalue(s2v(ra)));

1525c1529
<           Protect(cond = luaT_callorderiTM(L, vra, im, 1, TM_LT));
>           Protect(cond = luaT_callorderiTM(L, s2v(ra), im, 1, TM_LT));

1531,1534c1535,1538
<         if (ttisinteger(vra))
<           cond = (im <= ivalue(vra));
<         else if (ttisfloat(vra))
<           cond = luai_numle(cast_num(im), fltvalue(vra));
>         if (ttisinteger(s2v(ra)))
>           cond = (im <= ivalue(s2v(ra)));
>         else if (ttisfloat(s2v(ra)))
>           cond = luai_numle(cast_num(im), fltvalue(s2v(ra)));

1536c1540
<           Protect(cond = luaT_callorderiTM(L, vra, im, 1, TM_LE));
>           Protect(cond = luaT_callorderiTM(L, s2v(ra), im, 1, TM_LE));

1541c1545
<         cond = !l_isfalse(vra);
>         cond = !l_isfalse(s2v(ra));

1555,1566d1558
<       vmcase(OP_UNDEF) {
<         TValue *rb = vRB(i);
<         luaT_keydef(L, vra, rb, 1);
<         vmbreak;
<       }
<       vmcase(OP_ISDEF) {
<         TValue *rb = vRB(i);
<         TValue *rc = vRC(i);
<         int res = luaT_keydef(L, rb, rc, 0);
<         setbvalue(vra, res == GETARG_k(i));
<         vmbreak;
<       }

1590c1582
<         if (!ttisfunction(vra)) {  /* not a function? */
>         if (!ttisfunction(s2v(ra))) {  /* not a function? */

1594c1586
<         if (!ttisLclosure(vra)) {  /* C function? */
>         if (!ttisLclosure(s2v(ra))) {  /* C function? */

1602c1594
<           luaD_poscall(L, ci, ra, cast_int(L->top - ra));
>           luaD_poscall(L, ci, cast_int(L->top - ra));

1613,1614c1605,1609
<         int b = GETARG_B(i);
<         int n = (b != 0 ? b - 1 : cast_int(L->top - ra));
>         int n = GETARG_B(i) - 1;  /* number of results */
>         if (n < 0)  /* not fixed? */
>           n = cast_int(L->top - ra);  /* get what is available */
>         else
>           L->top = ra + n;  /* set call for 'luaD_poscall' */

1621c1616
<         halfProtect(luaD_poscall(L, ci, ra, n));
>         halfProtect(luaD_poscall(L, ci, n));

1625,1626c1620,1623
<         if (L->hookmask)
<           halfProtect(luaD_poscall(L, ci, ra, 0));  /* no hurry... */
>         if (L->hookmask) {
>           L->top = ra;
>           halfProtect(luaD_poscall(L, ci, 0));  /* no hurry... */
>         }

1637,1638c1634,1637
<         if (L->hookmask)
<           halfProtect(luaD_poscall(L, ci, ra, 1));  /* no hurry... */
>         if (L->hookmask) {
>           L->top = ra + 1;
>           halfProtect(luaD_poscall(L, ci, 1));  /* no hurry... */
>         }

1654c1653
<         lua_Integer idx = intop(+, ivalue(vra), 1); /* increment index */
>         lua_Integer idx = intop(+, ivalue(s2v(ra)), 1); /* increment index */

1658c1657
<           chgivalue(vra, idx);  /* update internal index... */
>           chgivalue(s2v(ra), idx);  /* update internal index... */

1665c1664
<         TValue *init = vra;
>         TValue *init = s2v(ra);

1669c1668
<         if (!forlimit(plimit, &ilimit, 1, &stopnow)) {
>         if (unlikely(!forlimit(plimit, &ilimit, 1, &stopnow))) {

1680c1679
<         if (ttisinteger(vra)) {  /* integer loop? */
>         if (ttisinteger(s2v(ra))) {  /* integer loop? */

1682c1681
<           lua_Integer idx = intop(+, ivalue(vra), step); /* increment index */
>           lua_Integer idx = intop(+, ivalue(s2v(ra)), step); /* new index */

1686c1685
<             chgivalue(vra, idx);  /* update internal index... */
>             chgivalue(s2v(ra), idx);  /* update internal index... */

1693c1692
<           lua_Number idx = fltvalue(vra);
>           lua_Number idx = fltvalue(s2v(ra));

1698c1697
<             chgfltvalue(vra, idx);  /* update internal index... */
>             chgfltvalue(s2v(ra), idx);  /* update internal index... */

1706c1705
<         TValue *init = vra;
>         TValue *init = s2v(ra);

1721c1720
<           if (!tonumber(plimit, &nlimit))
>           if (unlikely(!tonumber(plimit, &nlimit)))

1724c1723
<           if (!tonumber(pstep, &nstep))
>           if (unlikely(!tonumber(pstep, &nstep)))

1727c1726
<           if (!tonumber(init, &ninit))
>           if (unlikely(!tonumber(init, &ninit)))

1768c1767
<         h = hvalue(vra);
>         h = hvalue(s2v(ra));

1770c1769
<         if (last > h->sizearray)  /* needs more space? */
>         if (last > luaH_realasize(h))  /* needs more space? */

1794c1793
<         ProtectNT(luaT_getvarargs(L, ci, ra, n));
>         Protect(luaT_getvarargs(L, ci, ra, n));

src/lvm.h

2c2
< ** $Id: lvm.h,v 2.51 2018/02/23 13:13:31 roberto Exp $
> ** $Id: lvm.h,v 2.52 2018/06/15 14:14:20 roberto Exp $

87c87
<    : (slot = (l_castS2U(k) - 1u < hvalue(t)->sizearray) \
>    : (slot = (l_castS2U(k) - 1u < hvalue(t)->alimit) \