aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lib_jit.c20
-rw-r--r--src/lj_dispatch.c6
-rw-r--r--src/lj_errmsg.h8
3 files changed, 20 insertions, 14 deletions
diff --git a/src/lib_jit.c b/src/lib_jit.c
index 0ee5ad0d..34e5bd34 100644
--- a/src/lib_jit.c
+++ b/src/lib_jit.c
@@ -49,12 +49,10 @@ static int setjitmode(lua_State *L, int mode)
49 mode |= LUAJIT_MODE_FUNC; 49 mode |= LUAJIT_MODE_FUNC;
50 } 50 }
51 if (luaJIT_setmode(L, idx, mode) != 1) { 51 if (luaJIT_setmode(L, idx, mode) != 1) {
52 if ((mode & LUAJIT_MODE_MASK) == LUAJIT_MODE_ENGINE)
53 lj_err_caller(L, LJ_ERR_NOJIT);
52 err: 54 err:
53#if LJ_HASJIT
54 lj_err_arg(L, 1, LJ_ERR_NOLFUNC); 55 lj_err_arg(L, 1, LJ_ERR_NOLFUNC);
55#else
56 lj_err_caller(L, LJ_ERR_NOJIT);
57#endif
58 } 56 }
59 return 0; 57 return 0;
60} 58}
@@ -532,19 +530,15 @@ static uint32_t jit_cpudetect(lua_State *L)
532 } 530 }
533#endif 531#endif
534 } 532 }
535 /* Check for required instruction set support on x86. */ 533 /* Check for required instruction set support on x86 (unnecessary on x64). */
536#if LJ_TARGET_X86 534#if LJ_TARGET_X86
537#if !defined(LUAJIT_CPU_NOCMOV) 535#if !defined(LUAJIT_CPU_NOCMOV)
538 if (!(flags & JIT_F_CMOV)) 536 if (!(flags & JIT_F_CMOV))
539 luaL_error(L, "Ancient CPU lacks CMOV support (recompile with -DLUAJIT_CPU_NOCMOV)"); 537 luaL_error(L, "Ancient CPU lacks CMOV support (recompile with -DLUAJIT_CPU_NOCMOV)");
540#endif 538#endif
541 if (!(flags & JIT_F_SSE2))
542#if defined(LUAJIT_CPU_SSE2) 539#if defined(LUAJIT_CPU_SSE2)
540 if (!(flags & JIT_F_SSE2))
543 luaL_error(L, "CPU does not support SSE2 (recompile without -DLUAJIT_CPU_SSE2)"); 541 luaL_error(L, "CPU does not support SSE2 (recompile without -DLUAJIT_CPU_SSE2)");
544#elif LJ_HASJIT
545 luaL_error(L, "Sorry, SSE2 CPU support required for this beta release");
546#else
547 (void)0;
548#endif 542#endif
549#endif 543#endif
550 UNUSED(L); 544 UNUSED(L);
@@ -560,7 +554,11 @@ static void jit_init(lua_State *L)
560 uint32_t flags = jit_cpudetect(L); 554 uint32_t flags = jit_cpudetect(L);
561#if LJ_HASJIT 555#if LJ_HASJIT
562 jit_State *J = L2J(L); 556 jit_State *J = L2J(L);
563 J->flags = flags | JIT_F_ON | JIT_F_OPT_DEFAULT; 557#if LJ_TARGET_X86
558 /* Silently turn off the JIT compiler on CPUs without SSE2. */
559 if ((flags & JIT_F_SSE2))
560#endif
561 J->flags = flags | JIT_F_ON | JIT_F_OPT_DEFAULT;
564 memcpy(J->param, jit_param_default, sizeof(J->param)); 562 memcpy(J->param, jit_param_default, sizeof(J->param));
565 lj_dispatch_update(G(L)); 563 lj_dispatch_update(G(L));
566#else 564#else
diff --git a/src/lj_dispatch.c b/src/lj_dispatch.c
index 4629fb7e..7b3ff80b 100644
--- a/src/lj_dispatch.c
+++ b/src/lj_dispatch.c
@@ -209,10 +209,12 @@ int luaJIT_setmode(lua_State *L, int idx, int mode)
209 if ((mode & LUAJIT_MODE_FLUSH)) { 209 if ((mode & LUAJIT_MODE_FLUSH)) {
210 lj_trace_flushall(L); 210 lj_trace_flushall(L);
211 } else { 211 } else {
212 if ((mode & LUAJIT_MODE_ON)) 212 if (!(mode & LUAJIT_MODE_ON))
213 G2J(g)->flags &= ~(uint32_t)JIT_F_ON;
214 else if ((G2J(g)->flags & JIT_F_SSE2))
213 G2J(g)->flags |= (uint32_t)JIT_F_ON; 215 G2J(g)->flags |= (uint32_t)JIT_F_ON;
214 else 216 else
215 G2J(g)->flags &= ~(uint32_t)JIT_F_ON; 217 return 0; /* Don't turn on JIT compiler without SSE2 support. */
216 lj_dispatch_update(g); 218 lj_dispatch_update(g);
217 } 219 }
218 break; 220 break;
diff --git a/src/lj_errmsg.h b/src/lj_errmsg.h
index 0a2d9dd7..4891b74e 100644
--- a/src/lj_errmsg.h
+++ b/src/lj_errmsg.h
@@ -100,7 +100,13 @@ ERRDEF(STRFMTR, "invalid format (repeated flags)")
100ERRDEF(STRFMTW, "invalid format (width or precision too long)") 100ERRDEF(STRFMTW, "invalid format (width or precision too long)")
101ERRDEF(STRGSRV, "invalid replacement value (a %s)") 101ERRDEF(STRGSRV, "invalid replacement value (a %s)")
102ERRDEF(BADMODN, "name conflict for module " LUA_QS) 102ERRDEF(BADMODN, "name conflict for module " LUA_QS)
103ERRDEF(NOJIT, "JIT compiler permanently disabled") 103#if LJ_HASJIT
104ERRDEF(NOJIT, "JIT compiler disabled, CPU does not support SSE2")
105#elif defined(LJ_ARCH_NOJIT)
106ERRDEF(NOJIT, "no JIT compiler for this architecture (yet)")
107#else
108ERRDEF(NOJIT, "JIT compiler permanently disabled by build option")
109#endif
104ERRDEF(JITOPT, "unknown or malformed optimization flag " LUA_QS) 110ERRDEF(JITOPT, "unknown or malformed optimization flag " LUA_QS)
105 111
106/* Lexer/parser errors. */ 112/* Lexer/parser errors. */