Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/torch/luajit-rocks.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRonan Collobert <ronan@collobert.com>2013-11-27 15:43:44 +0400
committerRonan Collobert <ronan@collobert.com>2013-11-27 15:43:44 +0400
commiteb27cca0e3e7d45b0f06081b884555f5920712e9 (patch)
treea32ce381677c6612523179484bba49b9bd12a077
parent88c9c4214ae8f653bfe714d86b6f555b3ecf56ff (diff)
parente1fd7ebf04a4899336c3365ba25ab2c01766068c (diff)
Merge commit 'e1fd7ebf04a4899336c3365ba25ab2c01766068c'
-rw-r--r--luajit/doc/ext_ffi_semantics.html4
-rw-r--r--luajit/src/lj_api.c2
-rw-r--r--luajit/src/lj_gc.c9
-rw-r--r--luajit/src/lj_opt_loop.c31
-rw-r--r--luajit/src/lj_opt_mem.c9
-rw-r--r--luajit/src/lj_record.c2
-rw-r--r--luajit/src/lj_traceerr.h2
-rw-r--r--luajit/src/msvcbuild.bat10
8 files changed, 38 insertions, 31 deletions
diff --git a/luajit/doc/ext_ffi_semantics.html b/luajit/doc/ext_ffi_semantics.html
index 0322901..57839b1 100644
--- a/luajit/doc/ext_ffi_semantics.html
+++ b/luajit/doc/ext_ffi_semantics.html
@@ -1188,7 +1188,9 @@ storing and initializing them are supported, yet.</li>
<li>The <tt>volatile</tt> type qualifier is currently ignored by
compiled code.</li>
<li><a href="ext_ffi_api.html#ffi_cdef"><tt>ffi.cdef</tt></a> silently
-ignores all re-declarations.</li>
+ignores most re-declarations. Note: avoid re-declarations which do not
+conform to C99. The implementation will eventually be changed to
+perform strict checks.</li>
</ul>
<p>
The JIT compiler already handles a large subset of all FFI operations.
diff --git a/luajit/src/lj_api.c b/luajit/src/lj_api.c
index edb2d62..b5c43be 100644
--- a/luajit/src/lj_api.c
+++ b/luajit/src/lj_api.c
@@ -1164,7 +1164,7 @@ LUA_API int lua_gc(lua_State *L, int what, int data)
MSize a = (MSize)data << 10;
g->gc.threshold = (a <= g->gc.total) ? (g->gc.total - a) : 0;
while (g->gc.total >= g->gc.threshold)
- if (lj_gc_step(L)) {
+ if (lj_gc_step(L) > 0) {
res = 1;
break;
}
diff --git a/luajit/src/lj_gc.c b/luajit/src/lj_gc.c
index 5c66578..fba932b 100644
--- a/luajit/src/lj_gc.c
+++ b/luajit/src/lj_gc.c
@@ -678,7 +678,8 @@ int LJ_FASTCALL lj_gc_step(lua_State *L)
lim = (GCSTEPSIZE/100) * g->gc.stepmul;
if (lim == 0)
lim = LJ_MAX_MEM;
- g->gc.debt += g->gc.total - g->gc.threshold;
+ if (g->gc.total > g->gc.threshold)
+ g->gc.debt += g->gc.total - g->gc.threshold;
do {
lim -= (MSize)gc_onestep(L);
if (g->gc.state == GCSpause) {
@@ -689,12 +690,14 @@ int LJ_FASTCALL lj_gc_step(lua_State *L)
} while ((int32_t)lim > 0);
if (g->gc.debt < GCSTEPSIZE) {
g->gc.threshold = g->gc.total + GCSTEPSIZE;
+ g->vmstate = ostate;
+ return -1;
} else {
g->gc.debt -= GCSTEPSIZE;
g->gc.threshold = g->gc.total;
+ g->vmstate = ostate;
+ return 0;
}
- g->vmstate = ostate;
- return 0;
}
/* Ditto, but fix the stack top first. */
diff --git a/luajit/src/lj_opt_loop.c b/luajit/src/lj_opt_loop.c
index 3a119f4..fa5e03e 100644
--- a/luajit/src/lj_opt_loop.c
+++ b/luajit/src/lj_opt_loop.c
@@ -105,20 +105,24 @@ static void loop_emit_phi(jit_State *J, IRRef1 *subst, IRRef1 *phi, IRRef nphi,
SnapNo onsnap)
{
int passx = 0;
- IRRef i, nslots;
+ IRRef i, j, nslots;
IRRef invar = J->chain[IR_LOOP];
/* Pass #1: mark redundant and potentially redundant PHIs. */
- for (i = 0; i < nphi; i++) {
+ for (i = 0, j = 0; i < nphi; i++) {
IRRef lref = phi[i];
IRRef rref = subst[lref];
if (lref == rref || rref == REF_DROP) { /* Invariants are redundant. */
- irt_setmark(IR(lref)->t);
- } else if (!(IR(rref)->op1 == lref || IR(rref)->op2 == lref)) {
- /* Quick check for simple recurrences failed, need pass2. */
- irt_setmark(IR(lref)->t);
- passx = 1;
+ irt_clearphi(IR(lref)->t);
+ } else {
+ phi[j++] = (IRRef1)lref;
+ if (!(IR(rref)->op1 == lref || IR(rref)->op2 == lref)) {
+ /* Quick check for simple recurrences failed, need pass2. */
+ irt_setmark(IR(lref)->t);
+ passx = 1;
+ }
}
}
+ nphi = j;
/* Pass #2: traverse variant part and clear marks of non-redundant PHIs. */
if (passx) {
SnapNo s;
@@ -174,15 +178,10 @@ static void loop_emit_phi(jit_State *J, IRRef1 *subst, IRRef1 *phi, IRRef nphi,
IRRef lref = phi[i];
IRIns *ir = IR(lref);
if (!irt_ismarked(ir->t)) { /* Propagate only from unmarked PHIs. */
- IRRef rref = subst[lref];
- if (lref == rref) { /* Mark redundant PHI. */
- irt_setmark(ir->t);
- } else {
- IRIns *irr = IR(rref);
- if (irt_ismarked(irr->t)) { /* Right ref points to other PHI? */
- irt_clearmark(irr->t); /* Mark that PHI as non-redundant. */
- passx = 1; /* Retry. */
- }
+ IRIns *irr = IR(subst[lref]);
+ if (irt_ismarked(irr->t)) { /* Right ref points to other PHI? */
+ irt_clearmark(irr->t); /* Mark that PHI as non-redundant. */
+ passx = 1; /* Retry. */
}
}
}
diff --git a/luajit/src/lj_opt_mem.c b/luajit/src/lj_opt_mem.c
index 0fd1730..7177ce2 100644
--- a/luajit/src/lj_opt_mem.c
+++ b/luajit/src/lj_opt_mem.c
@@ -618,16 +618,17 @@ static AliasRet aa_xref(jit_State *J, IRIns *refa, IRIns *xa, IRIns *xb)
basea = IR(refa->op1);
ofsa = (LJ_64 && irk->o == IR_KINT64) ? (ptrdiff_t)ir_k64(irk)->u64 :
(ptrdiff_t)irk->i;
- if (basea == refb && ofsa != 0)
- return ALIAS_NO; /* base+-ofs vs. base. */
}
if (refb->o == IR_ADD && irref_isk(refb->op2)) {
IRIns *irk = IR(refb->op2);
baseb = IR(refb->op1);
ofsb = (LJ_64 && irk->o == IR_KINT64) ? (ptrdiff_t)ir_k64(irk)->u64 :
(ptrdiff_t)irk->i;
- if (refa == baseb && ofsb != 0)
- return ALIAS_NO; /* base vs. base+-ofs. */
+ }
+ /* Treat constified pointers like base vs. base+offset. */
+ if (basea->o == IR_KPTR && baseb->o == IR_KPTR) {
+ ofsb += (char *)ir_kptr(baseb) - (char *)ir_kptr(basea);
+ baseb = basea;
}
/* This implements (very) strict aliasing rules.
** Different types do NOT alias, except for differences in signedness.
diff --git a/luajit/src/lj_record.c b/luajit/src/lj_record.c
index 7336e0a..30b9efc 100644
--- a/luajit/src/lj_record.c
+++ b/luajit/src/lj_record.c
@@ -722,6 +722,8 @@ void lj_record_ret(jit_State *J, BCReg rbase, ptrdiff_t gotresults)
ptrdiff_t nresults = bc_b(callins) ? (ptrdiff_t)bc_b(callins)-1 :gotresults;
BCReg cbase = bc_a(callins);
GCproto *pt = funcproto(frame_func(frame - (cbase+1)));
+ if ((pt->flags & PROTO_NOJIT))
+ lj_trace_err(J, LJ_TRERR_CJITOFF);
if (J->framedepth == 0 && J->pt && frame == J->L->base - 1) {
if (check_downrec_unroll(J, pt)) {
J->maxslot = (BCReg)(rbase + gotresults);
diff --git a/luajit/src/lj_traceerr.h b/luajit/src/lj_traceerr.h
index 2ef4ad6..8f463ca 100644
--- a/luajit/src/lj_traceerr.h
+++ b/luajit/src/lj_traceerr.h
@@ -20,7 +20,7 @@ TREDEF(LUNROLL, "loop unroll limit reached")
/* Recording calls/returns. */
TREDEF(BADTYPE, "bad argument type")
-TREDEF(CJITOFF, "call to JIT-disabled function")
+TREDEF(CJITOFF, "JIT compilation disabled for function")
TREDEF(CUNROLL, "call unroll limit reached")
TREDEF(DOWNREC, "down-recursion, restarting")
TREDEF(NYICF, "NYI: C function %p")
diff --git a/luajit/src/msvcbuild.bat b/luajit/src/msvcbuild.bat
index cdb42a8..9290c53 100644
--- a/luajit/src/msvcbuild.bat
+++ b/luajit/src/msvcbuild.bat
@@ -14,10 +14,10 @@
@if not defined INCLUDE goto :FAIL
@setlocal
-@set LJCOMPILE=cl /nologo /c /MD /O2 /W3 /D_CRT_SECURE_NO_DEPRECATE
+@set LJCOMPILE=cl /nologo /c /O2 /W3 /D_CRT_SECURE_NO_DEPRECATE
@set LJLINK=link /nologo
@set LJMT=mt /nologo
-@set LJLIB=lib /nologo
+@set LJLIB=lib /nologo /nodefaultlib
@set DASMDIR=..\dynasm
@set DASM=%DASMDIR%\dynasm.lua
@set LJDLLNAME=lua51.dll
@@ -70,19 +70,19 @@ buildvm -m folddef -o lj_folddef.h lj_opt_fold.c
:NODEBUG
@if "%1"=="amalg" goto :AMALGDLL
@if "%1"=="static" goto :STATIC
-%LJCOMPILE% /DLUA_BUILD_AS_DLL lj_*.c lib_*.c
+%LJCOMPILE% /MD /DLUA_BUILD_AS_DLL lj_*.c lib_*.c
@if errorlevel 1 goto :BAD
%LJLINK% /DLL /out:%LJDLLNAME% lj_*.obj lib_*.obj
@if errorlevel 1 goto :BAD
@goto :MTDLL
:STATIC
-%LJCOMPILE% /DLUA_BUILD_AS_DLL lj_*.c lib_*.c
+%LJCOMPILE% lj_*.c lib_*.c
@if errorlevel 1 goto :BAD
%LJLIB% /OUT:%LJLIBNAME% lj_*.obj lib_*.obj
@if errorlevel 1 goto :BAD
@goto :MTDLL
:AMALGDLL
-%LJCOMPILE% /DLUA_BUILD_AS_DLL ljamalg.c
+%LJCOMPILE% /MD /DLUA_BUILD_AS_DLL ljamalg.c
@if errorlevel 1 goto :BAD
%LJLINK% /DLL /out:%LJDLLNAME% ljamalg.obj lj_vm.obj
@if errorlevel 1 goto :BAD