diff options
Diffstat (limited to 'src/lib_jit.c')
-rw-r--r-- | src/lib_jit.c | 24 |
1 files changed, 4 insertions, 20 deletions
diff --git a/src/lib_jit.c b/src/lib_jit.c index 82e68258..125b48ce 100644 --- a/src/lib_jit.c +++ b/src/lib_jit.c | |||
@@ -538,23 +538,17 @@ static uint32_t jit_cpudetect(lua_State *L) | |||
538 | uint32_t features[4]; | 538 | uint32_t features[4]; |
539 | if (lj_vm_cpuid(0, vendor) && lj_vm_cpuid(1, features)) { | 539 | if (lj_vm_cpuid(0, vendor) && lj_vm_cpuid(1, features)) { |
540 | #if !LJ_HASJIT | 540 | #if !LJ_HASJIT |
541 | #define JIT_F_CMOV 1 | ||
542 | #define JIT_F_SSE2 2 | 541 | #define JIT_F_SSE2 2 |
543 | #endif | 542 | #endif |
544 | flags |= ((features[3] >> 15)&1) * JIT_F_CMOV; | ||
545 | flags |= ((features[3] >> 26)&1) * JIT_F_SSE2; | 543 | flags |= ((features[3] >> 26)&1) * JIT_F_SSE2; |
546 | #if LJ_HASJIT | 544 | #if LJ_HASJIT |
547 | flags |= ((features[2] >> 0)&1) * JIT_F_SSE3; | 545 | flags |= ((features[2] >> 0)&1) * JIT_F_SSE3; |
548 | flags |= ((features[2] >> 19)&1) * JIT_F_SSE4_1; | 546 | flags |= ((features[2] >> 19)&1) * JIT_F_SSE4_1; |
549 | if (vendor[2] == 0x6c65746e) { /* Intel. */ | 547 | if (vendor[2] == 0x6c65746e) { /* Intel. */ |
550 | if ((features[0] & 0x0ff00f00) == 0x00000f00) /* P4. */ | 548 | if ((features[0] & 0x0fff0ff0) == 0x000106c0) /* Atom. */ |
551 | flags |= JIT_F_P4; /* Currently unused. */ | ||
552 | else if ((features[0] & 0x0fff0ff0) == 0x000106c0) /* Atom. */ | ||
553 | flags |= JIT_F_LEA_AGU; | 549 | flags |= JIT_F_LEA_AGU; |
554 | } else if (vendor[2] == 0x444d4163) { /* AMD. */ | 550 | } else if (vendor[2] == 0x444d4163) { /* AMD. */ |
555 | uint32_t fam = (features[0] & 0x0ff00f00); | 551 | uint32_t fam = (features[0] & 0x0ff00f00); |
556 | if (fam == 0x00000f00) /* K8. */ | ||
557 | flags |= JIT_F_SPLIT_XMM; | ||
558 | if (fam >= 0x00000f00) /* K8, K10. */ | 552 | if (fam >= 0x00000f00) /* K8, K10. */ |
559 | flags |= JIT_F_PREFER_IMUL; | 553 | flags |= JIT_F_PREFER_IMUL; |
560 | } | 554 | } |
@@ -562,14 +556,8 @@ static uint32_t jit_cpudetect(lua_State *L) | |||
562 | } | 556 | } |
563 | /* Check for required instruction set support on x86 (unnecessary on x64). */ | 557 | /* Check for required instruction set support on x86 (unnecessary on x64). */ |
564 | #if LJ_TARGET_X86 | 558 | #if LJ_TARGET_X86 |
565 | #if !defined(LUAJIT_CPU_NOCMOV) | ||
566 | if (!(flags & JIT_F_CMOV)) | ||
567 | luaL_error(L, "CPU not supported"); | ||
568 | #endif | ||
569 | #if defined(LUAJIT_CPU_SSE2) | ||
570 | if (!(flags & JIT_F_SSE2)) | 559 | if (!(flags & JIT_F_SSE2)) |
571 | luaL_error(L, "CPU does not support SSE2 (recompile without -DLUAJIT_CPU_SSE2)"); | 560 | luaL_error(L, "CPU with SSE2 required"); |
572 | #endif | ||
573 | #endif | 561 | #endif |
574 | #elif LJ_TARGET_ARM | 562 | #elif LJ_TARGET_ARM |
575 | #if LJ_HASJIT | 563 | #if LJ_HASJIT |
@@ -631,11 +619,7 @@ static void jit_init(lua_State *L) | |||
631 | uint32_t flags = jit_cpudetect(L); | 619 | uint32_t flags = jit_cpudetect(L); |
632 | #if LJ_HASJIT | 620 | #if LJ_HASJIT |
633 | jit_State *J = L2J(L); | 621 | jit_State *J = L2J(L); |
634 | #if LJ_TARGET_X86 | 622 | J->flags = flags | JIT_F_ON | JIT_F_OPT_DEFAULT; |
635 | /* Silently turn off the JIT compiler on CPUs without SSE2. */ | ||
636 | if ((flags & JIT_F_SSE2)) | ||
637 | #endif | ||
638 | J->flags = flags | JIT_F_ON | JIT_F_OPT_DEFAULT; | ||
639 | memcpy(J->param, jit_param_default, sizeof(J->param)); | 623 | memcpy(J->param, jit_param_default, sizeof(J->param)); |
640 | lj_dispatch_update(G(L)); | 624 | lj_dispatch_update(G(L)); |
641 | #else | 625 | #else |
@@ -645,6 +629,7 @@ static void jit_init(lua_State *L) | |||
645 | 629 | ||
646 | LUALIB_API int luaopen_jit(lua_State *L) | 630 | LUALIB_API int luaopen_jit(lua_State *L) |
647 | { | 631 | { |
632 | jit_init(L); | ||
648 | lua_pushliteral(L, LJ_OS_NAME); | 633 | lua_pushliteral(L, LJ_OS_NAME); |
649 | lua_pushliteral(L, LJ_ARCH_NAME); | 634 | lua_pushliteral(L, LJ_ARCH_NAME); |
650 | lua_pushinteger(L, LUAJIT_VERSION_NUM); | 635 | lua_pushinteger(L, LUAJIT_VERSION_NUM); |
@@ -657,7 +642,6 @@ LUALIB_API int luaopen_jit(lua_State *L) | |||
657 | LJ_LIB_REG(L, "jit.opt", jit_opt); | 642 | LJ_LIB_REG(L, "jit.opt", jit_opt); |
658 | #endif | 643 | #endif |
659 | L->top -= 2; | 644 | L->top -= 2; |
660 | jit_init(L); | ||
661 | return 1; | 645 | return 1; |
662 | } | 646 | } |
663 | 647 | ||