mirror of
https://github.com/LuaJIT/LuaJIT.git
synced 2025-02-07 23:24:09 +00:00
Just disable JIT compiler for non-SSE2 CPUs instead of aborting.
This commit is contained in:
parent
c225ee8db4
commit
8060f5b531
@ -65,10 +65,13 @@ This is a list of the things you should know about the LuaJIT 2.0 beta test:
|
|||||||
</p>
|
</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
The JIT compiler can only generate code for CPUs with <b>SSE2</b> at the
|
The JIT compiler only generates code for CPUs with support for
|
||||||
moment. I.e. you need at least a P4, Core 2/i5/i7 or K8/K10 to use it. I
|
<b>SSE2</b> instructions. I.e. you need at least a P4, Core 2/i5/i7
|
||||||
plan to fix this during the beta phase and add support for emitting x87
|
or K8/K10 to get the full benefit.<br>
|
||||||
instructions to the backend.
|
If you run LuaJIT on older CPUs without SSE2 support, the JIT compiler
|
||||||
|
is disabled and the VM falls back to the interpreter.
|
||||||
|
Run the command line executable without arguments to show the current status
|
||||||
|
(<tt>JIT: ON</tt> or <tt>JIT: OFF</tt>).
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
Obviously there will be many <b>bugs</b> in a VM which has been
|
Obviously there will be many <b>bugs</b> in a VM which has been
|
||||||
|
@ -49,12 +49,10 @@ static int setjitmode(lua_State *L, int mode)
|
|||||||
mode |= LUAJIT_MODE_FUNC;
|
mode |= LUAJIT_MODE_FUNC;
|
||||||
}
|
}
|
||||||
if (luaJIT_setmode(L, idx, mode) != 1) {
|
if (luaJIT_setmode(L, idx, mode) != 1) {
|
||||||
err:
|
if ((mode & LUAJIT_MODE_MASK) == LUAJIT_MODE_ENGINE)
|
||||||
#if LJ_HASJIT
|
|
||||||
lj_err_arg(L, 1, LJ_ERR_NOLFUNC);
|
|
||||||
#else
|
|
||||||
lj_err_caller(L, LJ_ERR_NOJIT);
|
lj_err_caller(L, LJ_ERR_NOJIT);
|
||||||
#endif
|
err:
|
||||||
|
lj_err_arg(L, 1, LJ_ERR_NOLFUNC);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -532,19 +530,15 @@ static uint32_t jit_cpudetect(lua_State *L)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
/* Check for required instruction set support on x86. */
|
/* Check for required instruction set support on x86 (unnecessary on x64). */
|
||||||
#if LJ_TARGET_X86
|
#if LJ_TARGET_X86
|
||||||
#if !defined(LUAJIT_CPU_NOCMOV)
|
#if !defined(LUAJIT_CPU_NOCMOV)
|
||||||
if (!(flags & JIT_F_CMOV))
|
if (!(flags & JIT_F_CMOV))
|
||||||
luaL_error(L, "Ancient CPU lacks CMOV support (recompile with -DLUAJIT_CPU_NOCMOV)");
|
luaL_error(L, "Ancient CPU lacks CMOV support (recompile with -DLUAJIT_CPU_NOCMOV)");
|
||||||
#endif
|
#endif
|
||||||
if (!(flags & JIT_F_SSE2))
|
|
||||||
#if defined(LUAJIT_CPU_SSE2)
|
#if defined(LUAJIT_CPU_SSE2)
|
||||||
|
if (!(flags & JIT_F_SSE2))
|
||||||
luaL_error(L, "CPU does not support SSE2 (recompile without -DLUAJIT_CPU_SSE2)");
|
luaL_error(L, "CPU does not support SSE2 (recompile without -DLUAJIT_CPU_SSE2)");
|
||||||
#elif LJ_HASJIT
|
|
||||||
luaL_error(L, "Sorry, SSE2 CPU support required for this beta release");
|
|
||||||
#else
|
|
||||||
(void)0;
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
UNUSED(L);
|
UNUSED(L);
|
||||||
@ -560,6 +554,10 @@ static void jit_init(lua_State *L)
|
|||||||
uint32_t flags = jit_cpudetect(L);
|
uint32_t flags = jit_cpudetect(L);
|
||||||
#if LJ_HASJIT
|
#if LJ_HASJIT
|
||||||
jit_State *J = L2J(L);
|
jit_State *J = L2J(L);
|
||||||
|
#if LJ_TARGET_X86
|
||||||
|
/* Silently turn off the JIT compiler on CPUs without SSE2. */
|
||||||
|
if ((flags & JIT_F_SSE2))
|
||||||
|
#endif
|
||||||
J->flags = flags | JIT_F_ON | JIT_F_OPT_DEFAULT;
|
J->flags = flags | JIT_F_ON | JIT_F_OPT_DEFAULT;
|
||||||
memcpy(J->param, jit_param_default, sizeof(J->param));
|
memcpy(J->param, jit_param_default, sizeof(J->param));
|
||||||
lj_dispatch_update(G(L));
|
lj_dispatch_update(G(L));
|
||||||
|
@ -209,10 +209,12 @@ int luaJIT_setmode(lua_State *L, int idx, int mode)
|
|||||||
if ((mode & LUAJIT_MODE_FLUSH)) {
|
if ((mode & LUAJIT_MODE_FLUSH)) {
|
||||||
lj_trace_flushall(L);
|
lj_trace_flushall(L);
|
||||||
} else {
|
} else {
|
||||||
if ((mode & LUAJIT_MODE_ON))
|
if (!(mode & LUAJIT_MODE_ON))
|
||||||
|
G2J(g)->flags &= ~(uint32_t)JIT_F_ON;
|
||||||
|
else if ((G2J(g)->flags & JIT_F_SSE2))
|
||||||
G2J(g)->flags |= (uint32_t)JIT_F_ON;
|
G2J(g)->flags |= (uint32_t)JIT_F_ON;
|
||||||
else
|
else
|
||||||
G2J(g)->flags &= ~(uint32_t)JIT_F_ON;
|
return 0; /* Don't turn on JIT compiler without SSE2 support. */
|
||||||
lj_dispatch_update(g);
|
lj_dispatch_update(g);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -100,7 +100,13 @@ ERRDEF(STRFMTR, "invalid format (repeated flags)")
|
|||||||
ERRDEF(STRFMTW, "invalid format (width or precision too long)")
|
ERRDEF(STRFMTW, "invalid format (width or precision too long)")
|
||||||
ERRDEF(STRGSRV, "invalid replacement value (a %s)")
|
ERRDEF(STRGSRV, "invalid replacement value (a %s)")
|
||||||
ERRDEF(BADMODN, "name conflict for module " LUA_QS)
|
ERRDEF(BADMODN, "name conflict for module " LUA_QS)
|
||||||
ERRDEF(NOJIT, "JIT compiler permanently disabled")
|
#if LJ_HASJIT
|
||||||
|
ERRDEF(NOJIT, "JIT compiler disabled, CPU does not support SSE2")
|
||||||
|
#elif defined(LJ_ARCH_NOJIT)
|
||||||
|
ERRDEF(NOJIT, "no JIT compiler for this architecture (yet)")
|
||||||
|
#else
|
||||||
|
ERRDEF(NOJIT, "JIT compiler permanently disabled by build option")
|
||||||
|
#endif
|
||||||
ERRDEF(JITOPT, "unknown or malformed optimization flag " LUA_QS)
|
ERRDEF(JITOPT, "unknown or malformed optimization flag " LUA_QS)
|
||||||
|
|
||||||
/* Lexer/parser errors. */
|
/* Lexer/parser errors. */
|
||||||
|
Loading…
Reference in New Issue
Block a user