Skip to content

Commit

Permalink
Update luaJIT to bfcb74ed36d733bae249fe7642b7324a56be88d0
Browse files Browse the repository at this point in the history
  • Loading branch information
poco0317 committed Oct 23, 2021
1 parent a6df26f commit 055ec0a
Show file tree
Hide file tree
Showing 109 changed files with 4,360 additions and 1,571 deletions.
528 changes: 473 additions & 55 deletions extern/luajit/doc/ext_buffer.html

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion extern/luajit/doc/extensions.html
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,9 @@ <h2 id="exceptions">C++ Exception Interoperability</h2>
on the C&nbsp;stack. The contents of the C++&nbsp;exception object
pass through unmodified.</li>
<li>Lua errors can be caught on the C++ side with <tt>catch(...)</tt>.
The corresponding Lua error message can be retrieved from the Lua stack.</li>
The corresponding Lua error message can be retrieved from the Lua stack.<br>
For MSVC for Windows 64 bit this requires compilation of your C++ code
with <tt>/EHa</tt>.</li>
<li>Throwing Lua errors across C++ frames is safe. C++ destructors
will be called.</li>
</ul>
Expand Down
18 changes: 15 additions & 3 deletions extern/luajit/doc/faq.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ <h1>Frequently Asked Questions (FAQ)</h1>
and links to books and papers about Lua.</li>
<li>The community-managed <a href="http://lua-users.org/wiki/"><span class="ext">&raquo;</span>&nbsp;Lua Wiki</a>
has information about diverse topics.</li>
</ul>
</ul></dd>
</dl>

<dl id="tech">
Expand Down Expand Up @@ -121,8 +121,7 @@ <h1>Frequently Asked Questions (FAQ)</h1>

Similarly, the Borland/Delphi runtime modifies the FPU control word and
enables FP exceptions. Of course this violates the Windows ABI, too.
Please check the Delphi docs for the Set8087CW method.

Please check the Delphi docs for the Set8087CW method.</dd>
</dl>

<dl id="ctrlc">
Expand All @@ -135,6 +134,19 @@ <h1>Frequently Asked Questions (FAQ)</h1>
to when it's stuck running inside a C function under the Lua interpreter.</dd>
</dl>

<dl id="order">
<dt>Q: Table iteration with <tt>pairs()</tt> does not result in the same order?</dt>
<dd>The order of table iteration is explicitly <b>undefined</b> by
the Lua language standard.<br>
Different Lua implementations or versions may use different orders for
otherwise identical tables. Different ways of constructing a table may
result in different orders, too.<br>
Due to improved VM security, LuaJIT 2.1 may even use a different order
on separate VM invocations or when string keys are newly interned.<br><br>
If your program relies on a deterministic order, it has a bug. Rewrite it,
so it doesn't rely on the key order. Or sort the table keys, if you must.</dd>
</dl>

<dl id="sandbox">
<dt>Q: Can Lua code be safely sandboxed?</dt>
<dd>
Expand Down
7 changes: 5 additions & 2 deletions extern/luajit/dynasm/dasm_arm.h
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ int dasm_link(Dst_DECL, size_t *szp)

{ /* Handle globals not defined in this translation unit. */
int idx;
for (idx = 20; idx*sizeof(int) < D->lgsize; idx++) {
for (idx = 10; idx*sizeof(int) < D->lgsize; idx++) {
int n = D->lglabels[idx];
/* Undefined label: Collapse rel chain and replace with marker (< 0). */
while (n > 0) { int *pb = DASM_POS2PTR(D, n); n = *pb; *pb = -idx; }
Expand Down Expand Up @@ -371,7 +371,10 @@ int dasm_encode(Dst_DECL, void *buffer)
ins &= 255; while ((((char *)cp - base) & ins)) *cp++ = 0xe1a00000;
break;
case DASM_REL_LG:
CK(n >= 0, UNDEF_LG);
if (n < 0) {
n = (int)((ptrdiff_t)D->globals[-n] - (ptrdiff_t)cp - 4);
goto patchrel;
}
/* fallthrough */
case DASM_REL_PC:
CK(n >= 0, UNDEF_PC);
Expand Down
6 changes: 3 additions & 3 deletions extern/luajit/dynasm/dasm_arm.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
local _info = {
arch = "arm",
description = "DynASM ARM module",
version = "1.4.0",
vernum = 10400,
release = "2015-10-18",
version = "1.5.0",
vernum = 10500,
release = "2021-05-02",
author = "Mike Pall",
license = "MIT",
}
Expand Down
58 changes: 50 additions & 8 deletions extern/luajit/dynasm/dasm_arm64.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ enum {
/* The following actions need a buffer position. */
DASM_ALIGN, DASM_REL_LG, DASM_LABEL_LG,
/* The following actions also have an argument. */
DASM_REL_PC, DASM_LABEL_PC,
DASM_REL_PC, DASM_LABEL_PC, DASM_REL_A,
DASM_IMM, DASM_IMM6, DASM_IMM12, DASM_IMM13W, DASM_IMM13X, DASM_IMML,
DASM_IMMV, DASM_VREG,
DASM__MAX
};

Expand All @@ -39,6 +40,7 @@ enum {
#define DASM_S_RANGE_LG 0x13000000
#define DASM_S_RANGE_PC 0x14000000
#define DASM_S_RANGE_REL 0x15000000
#define DASM_S_RANGE_VREG 0x16000000
#define DASM_S_UNDEF_LG 0x21000000
#define DASM_S_UNDEF_PC 0x22000000

Expand Down Expand Up @@ -247,7 +249,7 @@ void dasm_put(Dst_DECL, int start, ...)
n = (ins & 255); CK(n < D->maxsection, RANGE_SEC);
D->section = &D->sections[n]; goto stop;
case DASM_ESC: p++; ofs += 4; break;
case DASM_REL_EXT: break;
case DASM_REL_EXT: if ((ins & 0x8000)) ofs += 8; break;
case DASM_ALIGN: ofs += (ins & 255); b[pos++] = ofs; break;
case DASM_REL_LG:
n = (ins & 2047) - 10; pl = D->lglabels + n;
Expand All @@ -268,6 +270,11 @@ void dasm_put(Dst_DECL, int start, ...)
*pl = pos;
}
pos++;
if ((ins & 0x8000)) ofs += 8;
break;
case DASM_REL_A:
b[pos++] = n;
b[pos++] = va_arg(ap, int);
break;
case DASM_LABEL_LG:
pl = D->lglabels + (ins & 2047) - 10; CKPL(lg, LG); goto putlabel;
Expand Down Expand Up @@ -312,13 +319,21 @@ void dasm_put(Dst_DECL, int start, ...)
}
case DASM_IMML: {
#ifdef DASM_CHECKS
int scale = (p[-2] >> 30);
int scale = (ins & 3);
CK((!(n & ((1<<scale)-1)) && (unsigned int)(n>>scale) < 4096) ||
(unsigned int)(n+256) < 512, RANGE_I);
#endif
b[pos++] = n;
break;
}
case DASM_IMMV:
ofs += 4;
b[pos++] = n;
break;
case DASM_VREG:
CK(n < 32, RANGE_VREG);
b[pos++] = n;
break;
}
}
}
Expand Down Expand Up @@ -348,7 +363,7 @@ int dasm_link(Dst_DECL, size_t *szp)

{ /* Handle globals not defined in this translation unit. */
int idx;
for (idx = 20; idx*sizeof(int) < D->lgsize; idx++) {
for (idx = 10; idx*sizeof(int) < D->lgsize; idx++) {
int n = D->lglabels[idx];
/* Undefined label: Collapse rel chain and replace with marker (< 0). */
while (n > 0) { int *pb = DASM_POS2PTR(D, n); n = *pb; *pb = -idx; }
Expand All @@ -375,8 +390,8 @@ int dasm_link(Dst_DECL, size_t *szp)
case DASM_REL_LG: case DASM_REL_PC: pos++; break;
case DASM_LABEL_LG: case DASM_LABEL_PC: b[pos++] += ofs; break;
case DASM_IMM: case DASM_IMM6: case DASM_IMM12: case DASM_IMM13W:
case DASM_IMML: pos++; break;
case DASM_IMM13X: pos += 2; break;
case DASM_IMML: case DASM_IMMV: case DASM_VREG: pos++; break;
case DASM_IMM13X: case DASM_REL_A: pos += 2; break;
}
}
stop: (void)0;
Expand Down Expand Up @@ -426,7 +441,12 @@ int dasm_encode(Dst_DECL, void *buffer)
ins &= 255; while ((((char *)cp - base) & ins)) *cp++ = 0xe1a00000;
break;
case DASM_REL_LG:
CK(n >= 0, UNDEF_LG);
if (n < 0) {
ptrdiff_t na = (ptrdiff_t)D->globals[-n] - (ptrdiff_t)cp + 4;
n = (int)na;
CK((ptrdiff_t)n == na, RANGE_REL);
goto patchrel;
}
/* fallthrough */
case DASM_REL_PC:
CK(n >= 0, UNDEF_PC);
Expand All @@ -446,8 +466,24 @@ int dasm_encode(Dst_DECL, void *buffer)
} else if ((ins & 0x1000)) { /* TBZ, TBNZ */
CK((n & 3) == 0 && ((n+0x00008000) >> 16) == 0, RANGE_REL);
cp[-1] |= ((n << 3) & 0x0007ffe0);
} else if ((ins & 0x8000)) { /* absolute */
cp[0] = (unsigned int)((ptrdiff_t)cp - 4 + n);
cp[1] = (unsigned int)(((ptrdiff_t)cp - 4 + n) >> 32);
cp += 2;
}
break;
case DASM_REL_A: {
ptrdiff_t na = (((ptrdiff_t)(*b++) << 32) | (unsigned int)n);
if ((ins & 0x3000) == 0x3000) { /* ADRP */
ins &= ~0x1000;
na = (na >> 12) - (((ptrdiff_t)cp - 4) >> 12);
} else {
na = na - (ptrdiff_t)cp + 4;
}
n = (int)na;
CK((ptrdiff_t)n == na, RANGE_REL);
goto patchrel;
}
case DASM_LABEL_LG:
ins &= 2047; if (ins >= 20) D->globals[ins-10] = (void *)(base + n);
break;
Expand All @@ -468,11 +504,17 @@ int dasm_encode(Dst_DECL, void *buffer)
cp[-1] |= (dasm_imm13(n, *b++) << 10);
break;
case DASM_IMML: {
int scale = (p[-2] >> 30);
int scale = (ins & 3);
cp[-1] |= (!(n & ((1<<scale)-1)) && (unsigned int)(n>>scale) < 4096) ?
((n << (10-scale)) | 0x01000000) : ((n & 511) << 12);
break;
}
case DASM_IMMV:
*cp++ = n;
break;
case DASM_VREG:
cp[-1] |= (n & 0x1f) << (ins & 0x1f);
break;
default: *cp++ = ins; break;
}
}
Expand Down
Loading

0 comments on commit 055ec0a

Please sign in to comment.