mirror of
https://github.com/LuaJIT/LuaJIT.git
synced 2025-04-21 14:23:26 +00:00
Compare commits
9 Commits
9ff8b3cf8a
...
6cb453770e
Author | SHA1 | Date | |
---|---|---|---|
![]() |
6cb453770e | ||
![]() |
f14556234c | ||
![]() |
d508715ab6 | ||
![]() |
e27ee68817 | ||
![]() |
55a42da36e | ||
![]() |
423ac2144b | ||
![]() |
54dc2fa5d7 | ||
![]() |
b1179ea5f7 | ||
![]() |
5eb9509468 |
2
Makefile
2
Makefile
@ -111,7 +111,7 @@ else
|
|||||||
endif
|
endif
|
||||||
TARGET_SYS?= $(HOST_SYS)
|
TARGET_SYS?= $(HOST_SYS)
|
||||||
|
|
||||||
ifeq (Darwin,$(TARGET_SYS))
|
ifneq (,$(filter $(TARGET_SYS),Darwin iOS))
|
||||||
INSTALL_SONAME= $(INSTALL_DYLIBNAME)
|
INSTALL_SONAME= $(INSTALL_DYLIBNAME)
|
||||||
INSTALL_SOSHORT1= $(INSTALL_DYLIBSHORT1)
|
INSTALL_SOSHORT1= $(INSTALL_DYLIBSHORT1)
|
||||||
INSTALL_SOSHORT2= $(INSTALL_DYLIBSHORT2)
|
INSTALL_SOSHORT2= $(INSTALL_DYLIBSHORT2)
|
||||||
|
@ -117,7 +117,7 @@ hold all user-configurable settings:
|
|||||||
<li><tt>Makefile</tt> has settings for <b>installing</b> LuaJIT (POSIX
|
<li><tt>Makefile</tt> has settings for <b>installing</b> LuaJIT (POSIX
|
||||||
only).</li>
|
only).</li>
|
||||||
<li><tt>src/Makefile</tt> has settings for <b>compiling</b> LuaJIT
|
<li><tt>src/Makefile</tt> has settings for <b>compiling</b> LuaJIT
|
||||||
under POSIX, MinGW or Cygwin.</li>
|
under POSIX or MinGW.</li>
|
||||||
<li><tt>src/msvcbuild.bat</tt> has settings for compiling LuaJIT with
|
<li><tt>src/msvcbuild.bat</tt> has settings for compiling LuaJIT with
|
||||||
MSVC (Visual Studio).</li>
|
MSVC (Visual Studio).</li>
|
||||||
</ul>
|
</ul>
|
||||||
@ -195,10 +195,8 @@ Obviously the prefixes given during build and installation need to be the same.
|
|||||||
<h2 id="windows">Windows Systems</h2>
|
<h2 id="windows">Windows Systems</h2>
|
||||||
<h3>Prerequisites</h3>
|
<h3>Prerequisites</h3>
|
||||||
<p>
|
<p>
|
||||||
Either install one of the open source SDKs
|
Either install the open source SDK <a href="http://mingw.org/"><span class="ext">»</span> MinGW</a>,
|
||||||
(<a href="http://mingw.org/"><span class="ext">»</span> MinGW</a> or
|
which comes with a modified GCC plus the required development headers.
|
||||||
<a href="https://www.cygwin.com/"><span class="ext">»</span> Cygwin</a>), which come with a modified
|
|
||||||
GCC plus the required development headers.
|
|
||||||
Or install Microsoft's Visual Studio (MSVC).
|
Or install Microsoft's Visual Studio (MSVC).
|
||||||
</p>
|
</p>
|
||||||
<h3>Building with MSVC</h3>
|
<h3>Building with MSVC</h3>
|
||||||
@ -217,9 +215,9 @@ Then follow the installation instructions below.
|
|||||||
<p>
|
<p>
|
||||||
For an x64 to ARM64 cross-build run this first: <tt>vcvarsall.bat x64_arm64</tt>
|
For an x64 to ARM64 cross-build run this first: <tt>vcvarsall.bat x64_arm64</tt>
|
||||||
</p>
|
</p>
|
||||||
<h3>Building with MinGW or Cygwin</h3>
|
<h3>Building with MinGW</h3>
|
||||||
<p>
|
<p>
|
||||||
Open a command prompt window and make sure the MinGW or Cygwin programs
|
Open a command prompt window and make sure the MinGW programs
|
||||||
are in your path. Then <tt>cd</tt> to the directory of the git repository.
|
are in your path. Then <tt>cd</tt> to the directory of the git repository.
|
||||||
Then run this command for MinGW:
|
Then run this command for MinGW:
|
||||||
</p>
|
</p>
|
||||||
@ -227,12 +225,6 @@ Then run this command for MinGW:
|
|||||||
mingw32-make
|
mingw32-make
|
||||||
</pre>
|
</pre>
|
||||||
<p>
|
<p>
|
||||||
Or this command for Cygwin:
|
|
||||||
</p>
|
|
||||||
<pre class="code">
|
|
||||||
make
|
|
||||||
</pre>
|
|
||||||
<p>
|
|
||||||
Then follow the installation instructions below.
|
Then follow the installation instructions below.
|
||||||
</p>
|
</p>
|
||||||
<h3>Installing LuaJIT</h3>
|
<h3>Installing LuaJIT</h3>
|
||||||
@ -249,6 +241,19 @@ absolute path names — all modules are loaded relative to the
|
|||||||
directory where <tt>luajit.exe</tt> is installed
|
directory where <tt>luajit.exe</tt> is installed
|
||||||
(see <tt>src/luaconf.h</tt>).
|
(see <tt>src/luaconf.h</tt>).
|
||||||
</p>
|
</p>
|
||||||
|
<p>
|
||||||
|
The final directory layout should look like this:
|
||||||
|
</p>
|
||||||
|
<pre class="code">
|
||||||
|
├── luajit.exe
|
||||||
|
├── lua51.dll
|
||||||
|
├── <- put your own classic Lua/C API modules (*.dll) here
|
||||||
|
└── lua
|
||||||
|
├── <- put your own Lua modules (*.lua) here
|
||||||
|
└── jit
|
||||||
|
├── bc.lua
|
||||||
|
└── (etc …)
|
||||||
|
</pre>
|
||||||
|
|
||||||
<h2 id="cross">Cross-compiling LuaJIT</h2>
|
<h2 id="cross">Cross-compiling LuaJIT</h2>
|
||||||
<p>
|
<p>
|
||||||
|
@ -25,7 +25,7 @@ lib_ffi.o: lib_ffi.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h lj_def.h \
|
|||||||
lib_init.o: lib_init.c lua.h luaconf.h lauxlib.h lualib.h lj_arch.h
|
lib_init.o: lib_init.c lua.h luaconf.h lauxlib.h lualib.h lj_arch.h
|
||||||
lib_io.o: lib_io.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h lj_def.h \
|
lib_io.o: lib_io.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h lj_def.h \
|
||||||
lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_buf.h lj_str.h lj_state.h \
|
lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_buf.h lj_str.h lj_state.h \
|
||||||
lj_strfmt.h lj_ff.h lj_ffdef.h lj_lib.h lj_libdef.h
|
lj_strfmt.h lj_ff.h lj_ffdef.h lj_lib.h lj_strscan.h lj_libdef.h
|
||||||
lib_jit.o: lib_jit.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h lj_def.h \
|
lib_jit.o: lib_jit.c lua.h luaconf.h lauxlib.h lualib.h lj_obj.h lj_def.h \
|
||||||
lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_debug.h lj_str.h lj_tab.h \
|
lj_arch.h lj_gc.h lj_err.h lj_errmsg.h lj_debug.h lj_str.h lj_tab.h \
|
||||||
lj_state.h lj_bc.h lj_ctype.h lj_ir.h lj_jit.h lj_ircall.h lj_iropt.h \
|
lj_state.h lj_bc.h lj_ctype.h lj_ir.h lj_jit.h lj_ircall.h lj_iropt.h \
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include "lj_strfmt.h"
|
#include "lj_strfmt.h"
|
||||||
#include "lj_ff.h"
|
#include "lj_ff.h"
|
||||||
#include "lj_lib.h"
|
#include "lj_lib.h"
|
||||||
|
#include "lj_strscan.h"
|
||||||
|
|
||||||
/* Userdata payload for I/O file. */
|
/* Userdata payload for I/O file. */
|
||||||
typedef struct IOFileUD {
|
typedef struct IOFileUD {
|
||||||
@ -323,13 +324,14 @@ LJLIB_CF(io_method_seek)
|
|||||||
FILE *fp = io_tofile(L)->fp;
|
FILE *fp = io_tofile(L)->fp;
|
||||||
int opt = lj_lib_checkopt(L, 2, 1, "\3set\3cur\3end");
|
int opt = lj_lib_checkopt(L, 2, 1, "\3set\3cur\3end");
|
||||||
int64_t ofs = 0;
|
int64_t ofs = 0;
|
||||||
cTValue *o;
|
TValue *o;
|
||||||
int res;
|
int res;
|
||||||
if (opt == 0) opt = SEEK_SET;
|
if (opt == 0) opt = SEEK_SET;
|
||||||
else if (opt == 1) opt = SEEK_CUR;
|
else if (opt == 1) opt = SEEK_CUR;
|
||||||
else if (opt == 2) opt = SEEK_END;
|
else if (opt == 2) opt = SEEK_END;
|
||||||
o = L->base+2;
|
o = L->base+2;
|
||||||
if (o < L->top) {
|
if (o < L->top) {
|
||||||
|
if (tvisstr(o)) lj_strscan_num(strV(o), o);
|
||||||
if (tvisint(o))
|
if (tvisint(o))
|
||||||
ofs = (int64_t)intV(o);
|
ofs = (int64_t)intV(o);
|
||||||
else if (tvisnum(o))
|
else if (tvisnum(o))
|
||||||
|
@ -179,7 +179,7 @@ static const void *bcread_varinfo(GCproto *pt)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Read a single constant key/value of a template table. */
|
/* Read a single constant key/value of a template table. */
|
||||||
static void bcread_ktabk(LexState *ls, TValue *o)
|
static void bcread_ktabk(LexState *ls, TValue *o, GCtab *t)
|
||||||
{
|
{
|
||||||
MSize tp = bcread_uleb128(ls);
|
MSize tp = bcread_uleb128(ls);
|
||||||
if (tp >= BCDUMP_KTAB_STR) {
|
if (tp >= BCDUMP_KTAB_STR) {
|
||||||
@ -191,6 +191,8 @@ static void bcread_ktabk(LexState *ls, TValue *o)
|
|||||||
} else if (tp == BCDUMP_KTAB_NUM) {
|
} else if (tp == BCDUMP_KTAB_NUM) {
|
||||||
o->u32.lo = bcread_uleb128(ls);
|
o->u32.lo = bcread_uleb128(ls);
|
||||||
o->u32.hi = bcread_uleb128(ls);
|
o->u32.hi = bcread_uleb128(ls);
|
||||||
|
} else if (tp == BCDUMP_KTAB_NIL) { /* Restore nil value marker. */
|
||||||
|
settabV(ls->L, o, t);
|
||||||
} else {
|
} else {
|
||||||
lj_assertLS(tp <= BCDUMP_KTAB_TRUE, "bad constant type %d", tp);
|
lj_assertLS(tp <= BCDUMP_KTAB_TRUE, "bad constant type %d", tp);
|
||||||
setpriV(o, ~tp);
|
setpriV(o, ~tp);
|
||||||
@ -207,15 +209,15 @@ static GCtab *bcread_ktab(LexState *ls)
|
|||||||
MSize i;
|
MSize i;
|
||||||
TValue *o = tvref(t->array);
|
TValue *o = tvref(t->array);
|
||||||
for (i = 0; i < narray; i++, o++)
|
for (i = 0; i < narray; i++, o++)
|
||||||
bcread_ktabk(ls, o);
|
bcread_ktabk(ls, o, t);
|
||||||
}
|
}
|
||||||
if (nhash) { /* Read hash entries. */
|
if (nhash) { /* Read hash entries. */
|
||||||
MSize i;
|
MSize i;
|
||||||
for (i = 0; i < nhash; i++) {
|
for (i = 0; i < nhash; i++) {
|
||||||
TValue key;
|
TValue key;
|
||||||
bcread_ktabk(ls, &key);
|
bcread_ktabk(ls, &key, t);
|
||||||
lj_assertLS(!tvisnil(&key), "nil key");
|
lj_assertLS(!tvisnil(&key), "nil key");
|
||||||
bcread_ktabk(ls, lj_tab_set(ls->L, t, &key));
|
bcread_ktabk(ls, lj_tab_set(ls->L, t, &key), t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return t;
|
return t;
|
||||||
|
@ -71,6 +71,8 @@ static void bcwrite_ktabk(BCWriteCtx *ctx, cTValue *o, int narrow)
|
|||||||
*p++ = BCDUMP_KTAB_NUM;
|
*p++ = BCDUMP_KTAB_NUM;
|
||||||
p = lj_strfmt_wuleb128(p, o->u32.lo);
|
p = lj_strfmt_wuleb128(p, o->u32.lo);
|
||||||
p = lj_strfmt_wuleb128(p, o->u32.hi);
|
p = lj_strfmt_wuleb128(p, o->u32.hi);
|
||||||
|
} else if (tvistab(o)) { /* Write the nil value marker as a nil. */
|
||||||
|
*p++ = BCDUMP_KTAB_NIL;
|
||||||
} else {
|
} else {
|
||||||
lj_assertBCW(tvispri(o), "unhandled type %d", itype(o));
|
lj_assertBCW(tvispri(o), "unhandled type %d", itype(o));
|
||||||
*p++ = BCDUMP_KTAB_NIL+~itype(o);
|
*p++ = BCDUMP_KTAB_NIL+~itype(o);
|
||||||
@ -133,7 +135,7 @@ static void bcwrite_ktab_sorted_hash(BCWriteCtx *ctx, Node *node, MSize nhash)
|
|||||||
TValue **heap = ctx->heap;
|
TValue **heap = ctx->heap;
|
||||||
MSize i = nhash;
|
MSize i = nhash;
|
||||||
for (;; node--) { /* Build heap. */
|
for (;; node--) { /* Build heap. */
|
||||||
if (!tvisnil(&node->key)) {
|
if (!tvisnil(&node->val)) {
|
||||||
bcwrite_ktabk_heap_insert(heap, --i, nhash, &node->key);
|
bcwrite_ktabk_heap_insert(heap, --i, nhash, &node->key);
|
||||||
if (i == 0) break;
|
if (i == 0) break;
|
||||||
}
|
}
|
||||||
@ -163,7 +165,7 @@ static void bcwrite_ktab(BCWriteCtx *ctx, char *p, const GCtab *t)
|
|||||||
MSize i, hmask = t->hmask;
|
MSize i, hmask = t->hmask;
|
||||||
Node *node = noderef(t->node);
|
Node *node = noderef(t->node);
|
||||||
for (i = 0; i <= hmask; i++)
|
for (i = 0; i <= hmask; i++)
|
||||||
nhash += !tvisnil(&node[i].key);
|
nhash += !tvisnil(&node[i].val);
|
||||||
}
|
}
|
||||||
/* Write number of array slots and hash slots. */
|
/* Write number of array slots and hash slots. */
|
||||||
p = lj_strfmt_wuleb128(p, narray);
|
p = lj_strfmt_wuleb128(p, narray);
|
||||||
|
@ -33,10 +33,12 @@
|
|||||||
_("int16_t", INT16) \
|
_("int16_t", INT16) \
|
||||||
_("int32_t", INT32) \
|
_("int32_t", INT32) \
|
||||||
_("int64_t", INT64) \
|
_("int64_t", INT64) \
|
||||||
|
_("int128_t", INT128) \
|
||||||
_("uint8_t", UINT8) \
|
_("uint8_t", UINT8) \
|
||||||
_("uint16_t", UINT16) \
|
_("uint16_t", UINT16) \
|
||||||
_("uint32_t", UINT32) \
|
_("uint32_t", UINT32) \
|
||||||
_("uint64_t", UINT64) \
|
_("uint64_t", UINT64) \
|
||||||
|
_("uint128_t", UINT128) \
|
||||||
_("intptr_t", INT_PSZ) \
|
_("intptr_t", INT_PSZ) \
|
||||||
_("uintptr_t", UINT_PSZ) \
|
_("uintptr_t", UINT_PSZ) \
|
||||||
/* From POSIX. */ \
|
/* From POSIX. */ \
|
||||||
@ -55,6 +57,7 @@
|
|||||||
_("__int16", 2, CTOK_INT) \
|
_("__int16", 2, CTOK_INT) \
|
||||||
_("__int32", 4, CTOK_INT) \
|
_("__int32", 4, CTOK_INT) \
|
||||||
_("__int64", 8, CTOK_INT) \
|
_("__int64", 8, CTOK_INT) \
|
||||||
|
_("__int128", 16, CTOK_INT) \
|
||||||
_("float", 4, CTOK_FP) \
|
_("float", 4, CTOK_FP) \
|
||||||
_("double", 8, CTOK_FP) \
|
_("double", 8, CTOK_FP) \
|
||||||
_("long", 0, CTOK_LONG) \
|
_("long", 0, CTOK_LONG) \
|
||||||
|
@ -292,6 +292,8 @@ typedef struct CTState {
|
|||||||
_(UINT32, 4, CT_NUM, CTF_UNSIGNED|CTALIGN(2)) \
|
_(UINT32, 4, CT_NUM, CTF_UNSIGNED|CTALIGN(2)) \
|
||||||
_(INT64, 8, CT_NUM, CTF_LONG_IF8|CTALIGN(3)) \
|
_(INT64, 8, CT_NUM, CTF_LONG_IF8|CTALIGN(3)) \
|
||||||
_(UINT64, 8, CT_NUM, CTF_UNSIGNED|CTF_LONG_IF8|CTALIGN(3)) \
|
_(UINT64, 8, CT_NUM, CTF_UNSIGNED|CTF_LONG_IF8|CTALIGN(3)) \
|
||||||
|
_(INT128, 16, CT_NUM, CTALIGN(4)) \
|
||||||
|
_(UINT128, 16, CT_NUM, CTF_UNSIGNED|CTALIGN(4)) \
|
||||||
_(FLOAT, 4, CT_NUM, CTF_FP|CTALIGN(2)) \
|
_(FLOAT, 4, CT_NUM, CTF_FP|CTALIGN(2)) \
|
||||||
_(DOUBLE, 8, CT_NUM, CTF_FP|CTALIGN(3)) \
|
_(DOUBLE, 8, CT_NUM, CTF_FP|CTALIGN(3)) \
|
||||||
_(COMPLEX_FLOAT, 8, CT_ARRAY, CTF_COMPLEX|CTALIGN(2)|CTID_FLOAT) \
|
_(COMPLEX_FLOAT, 8, CT_ARRAY, CTF_COMPLEX|CTALIGN(2)|CTID_FLOAT) \
|
||||||
|
@ -2217,9 +2217,11 @@ LJFOLD(HREF TDUP KNUM)
|
|||||||
LJFOLDF(fwd_href_tdup)
|
LJFOLDF(fwd_href_tdup)
|
||||||
{
|
{
|
||||||
TValue keyv;
|
TValue keyv;
|
||||||
|
cTValue *val;
|
||||||
lj_ir_kvalue(J->L, &keyv, fright);
|
lj_ir_kvalue(J->L, &keyv, fright);
|
||||||
if (lj_tab_get(J->L, ir_ktab(IR(fleft->op1)), &keyv) == niltvg(J2G(J)) &&
|
val = lj_tab_get(J->L, ir_ktab(IR(fleft->op1)), &keyv);
|
||||||
lj_opt_fwd_href_nokey(J))
|
/* Check for either nil or the nil value marker in the template table. */
|
||||||
|
if ((tvisnil(val) || tvistab(val)) && lj_opt_fwd_href_nokey(J))
|
||||||
return lj_ir_kkptr(J, niltvg(J2G(J)));
|
return lj_ir_kkptr(J, niltvg(J2G(J)));
|
||||||
return NEXTFOLD;
|
return NEXTFOLD;
|
||||||
}
|
}
|
||||||
|
@ -233,7 +233,9 @@ static TRef fwd_ahload(jit_State *J, IRRef xref)
|
|||||||
return lj_ir_knum_u64(J, tv->u64);
|
return lj_ir_knum_u64(J, tv->u64);
|
||||||
else if (tvisint(tv))
|
else if (tvisint(tv))
|
||||||
return lj_ir_kint(J, intV(tv));
|
return lj_ir_kint(J, intV(tv));
|
||||||
else if (tvisgcv(tv))
|
else if (tvistab(tv)) /* Template table nil value marker. */
|
||||||
|
return TREF_NIL;
|
||||||
|
else if (tvisstr(tv))
|
||||||
return lj_ir_kstr(J, strV(tv));
|
return lj_ir_kstr(J, strV(tv));
|
||||||
}
|
}
|
||||||
/* Othwerwise: don't intern as a constant. */
|
/* Othwerwise: don't intern as a constant. */
|
||||||
|
@ -1725,7 +1725,7 @@ static void expr_table(LexState *ls, ExpDesc *e)
|
|||||||
FuncState *fs = ls->fs;
|
FuncState *fs = ls->fs;
|
||||||
BCLine line = ls->linenumber;
|
BCLine line = ls->linenumber;
|
||||||
GCtab *t = NULL;
|
GCtab *t = NULL;
|
||||||
int vcall = 0, needarr = 0, fixt = 0;
|
int vcall = 0, needarr = 0;
|
||||||
uint32_t narr = 1; /* First array index. */
|
uint32_t narr = 1; /* First array index. */
|
||||||
uint32_t nhash = 0; /* Number of hash entries. */
|
uint32_t nhash = 0; /* Number of hash entries. */
|
||||||
BCReg freg = fs->freereg;
|
BCReg freg = fs->freereg;
|
||||||
@ -1769,9 +1769,10 @@ static void expr_table(LexState *ls, ExpDesc *e)
|
|||||||
lj_gc_anybarriert(fs->L, t);
|
lj_gc_anybarriert(fs->L, t);
|
||||||
if (expr_isk_nojump(&val)) { /* Add const key/value to template table. */
|
if (expr_isk_nojump(&val)) { /* Add const key/value to template table. */
|
||||||
expr_kvalue(fs, v, &val);
|
expr_kvalue(fs, v, &val);
|
||||||
} else { /* Otherwise create dummy string key (avoids lj_tab_newkey). */
|
/* Mark nil value with table value itself to preserve the key. */
|
||||||
settabV(fs->L, v, t); /* Preserve key with table itself as value. */
|
if (key.k == VKSTR && tvisnil(v)) settabV(fs->L, v, t);
|
||||||
fixt = 1; /* Fix this later, after all resizes. */
|
} else { /* Preserve the key for the following non-const store. */
|
||||||
|
settabV(fs->L, v, t);
|
||||||
goto nonconst;
|
goto nonconst;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -1813,17 +1814,6 @@ static void expr_table(LexState *ls, ExpDesc *e)
|
|||||||
} else {
|
} else {
|
||||||
if (needarr && t->asize < narr)
|
if (needarr && t->asize < narr)
|
||||||
lj_tab_reasize(fs->L, t, narr-1);
|
lj_tab_reasize(fs->L, t, narr-1);
|
||||||
if (fixt) { /* Fix value for dummy keys in template table. */
|
|
||||||
Node *node = noderef(t->node);
|
|
||||||
uint32_t i, hmask = t->hmask;
|
|
||||||
for (i = 0; i <= hmask; i++) {
|
|
||||||
Node *n = &node[i];
|
|
||||||
if (tvistab(&n->val)) {
|
|
||||||
lj_assertFS(tabV(&n->val) == t, "bad dummy key in template table");
|
|
||||||
setnilV(&n->val); /* Turn value into nil. */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
lj_gc_check(fs->L);
|
lj_gc_check(fs->L);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -194,6 +194,7 @@ GCtab * LJ_FASTCALL lj_tab_dup(lua_State *L, const GCtab *kt)
|
|||||||
Node *next = nextnode(kn);
|
Node *next = nextnode(kn);
|
||||||
/* Don't use copyTV here, since it asserts on a copy of a dead key. */
|
/* Don't use copyTV here, since it asserts on a copy of a dead key. */
|
||||||
n->val = kn->val; n->key = kn->key;
|
n->val = kn->val; n->key = kn->key;
|
||||||
|
if (tvistab(&n->val)) setnilV(&n->val); /* Replace nil value marker. */
|
||||||
setmref(n->next, next == NULL? next : (Node *)((char *)next + d));
|
setmref(n->next, next == NULL? next : (Node *)((char *)next + d));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
23
src/luajit.c
23
src/luajit.c
@ -35,6 +35,21 @@
|
|||||||
|
|
||||||
#if !LJ_TARGET_CONSOLE
|
#if !LJ_TARGET_CONSOLE
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
||||||
|
#if LJ_TARGET_POSIX
|
||||||
|
/* Improve signal handling on POSIX. Try CTRL-C on: luajit -e 'io.read()' */
|
||||||
|
static void signal_set(int sig, void (*h)(int))
|
||||||
|
{
|
||||||
|
struct sigaction sa;
|
||||||
|
memset(&sa, 0, sizeof(sa));
|
||||||
|
sa.sa_handler = h;
|
||||||
|
sigemptyset(&sa.sa_mask);
|
||||||
|
sigaction(sig, &sa, NULL);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
#define signal_set signal
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static lua_State *globalL = NULL;
|
static lua_State *globalL = NULL;
|
||||||
@ -54,8 +69,8 @@ static void lstop(lua_State *L, lua_Debug *ar)
|
|||||||
|
|
||||||
static void laction(int i)
|
static void laction(int i)
|
||||||
{
|
{
|
||||||
signal(i, SIG_DFL); /* if another SIGINT happens before lstop,
|
/* Terminate process if another SIGINT happens (double CTRL-C). */
|
||||||
terminate process (default action) */
|
signal_set(i, SIG_DFL);
|
||||||
lua_sethook(globalL, lstop, LUA_MASKCALL | LUA_MASKRET | LUA_MASKCOUNT, 1);
|
lua_sethook(globalL, lstop, LUA_MASKCALL | LUA_MASKRET | LUA_MASKCOUNT, 1);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -117,11 +132,11 @@ static int docall(lua_State *L, int narg, int clear)
|
|||||||
lua_pushcfunction(L, traceback); /* push traceback function */
|
lua_pushcfunction(L, traceback); /* push traceback function */
|
||||||
lua_insert(L, base); /* put it under chunk and args */
|
lua_insert(L, base); /* put it under chunk and args */
|
||||||
#if !LJ_TARGET_CONSOLE
|
#if !LJ_TARGET_CONSOLE
|
||||||
signal(SIGINT, laction);
|
signal_set(SIGINT, laction);
|
||||||
#endif
|
#endif
|
||||||
status = lua_pcall(L, narg, (clear ? 0 : LUA_MULTRET), base);
|
status = lua_pcall(L, narg, (clear ? 0 : LUA_MULTRET), base);
|
||||||
#if !LJ_TARGET_CONSOLE
|
#if !LJ_TARGET_CONSOLE
|
||||||
signal(SIGINT, SIG_DFL);
|
signal_set(SIGINT, SIG_DFL);
|
||||||
#endif
|
#endif
|
||||||
lua_remove(L, base); /* remove traceback function */
|
lua_remove(L, base); /* remove traceback function */
|
||||||
/* force a complete garbage collection in case of errors */
|
/* force a complete garbage collection in case of errors */
|
||||||
|
Loading…
Reference in New Issue
Block a user