Browse Source

Update LuaJIT to the latest 2.1.0 source (a91d0d9)

Alex Szpakowski 4 years ago
parent
commit
efebc0bef9
3 changed files with 26 additions and 3 deletions
  1. 1 1
      CMakeLists.txt
  2. 13 0
      libs/LuaJIT/src/jit/bcsave.lua
  3. 12 2
      libs/LuaJIT/src/lj_opt_fold.c

+ 1 - 1
CMakeLists.txt

@@ -167,7 +167,7 @@ endif()
 
 
 set(MEGA_ZLIB_VER "1.2.11")
 set(MEGA_ZLIB_VER "1.2.11")
 set(MEGA_LUA51_VER "5.1.5")
 set(MEGA_LUA51_VER "5.1.5")
-set(MEGA_LUAJIT_VER "2.1.0-f3c8569")
+set(MEGA_LUAJIT_VER "2.1.0-a91d0d9")
 set(MEGA_LIBOGG_VER "1.3.2")
 set(MEGA_LIBOGG_VER "1.3.2")
 set(MEGA_LIBVORBIS_VER "1.3.5")
 set(MEGA_LIBVORBIS_VER "1.3.5")
 set(MEGA_LIBTHEORA_VER "1.1.1")
 set(MEGA_LIBTHEORA_VER "1.1.1")

+ 13 - 0
libs/LuaJIT/src/jit/bcsave.lua

@@ -60,6 +60,11 @@ local function savefile(name, mode)
   return check(io.open(name, mode))
   return check(io.open(name, mode))
 end
 end
 
 
+local function set_stdout_binary(ffi)
+  ffi.cdef[[int _setmode(int fd, int mode);]]
+  ffi.C._setmode(1, 0x8000)
+end
+
 ------------------------------------------------------------------------------
 ------------------------------------------------------------------------------
 
 
 local map_type = {
 local map_type = {
@@ -125,6 +130,11 @@ local function bcsave_tail(fp, output, s)
 end
 end
 
 
 local function bcsave_raw(output, s)
 local function bcsave_raw(output, s)
+  if output == "-" and jit.os == "Windows" then
+    local ok, ffi = pcall(require, "ffi")
+    check(ok, "FFI library required to write binary file to stdout")
+    set_stdout_binary(ffi)
+  end
   local fp = savefile(output, "wb")
   local fp = savefile(output, "wb")
   bcsave_tail(fp, output, s)
   bcsave_tail(fp, output, s)
 end
 end
@@ -568,6 +578,9 @@ end
 local function bcsave_obj(ctx, output, s)
 local function bcsave_obj(ctx, output, s)
   local ok, ffi = pcall(require, "ffi")
   local ok, ffi = pcall(require, "ffi")
   check(ok, "FFI library required to write this file type")
   check(ok, "FFI library required to write this file type")
+  if output == "-" and jit.os == "Windows" then
+    set_stdout_binary(ffi)
+  end
   if ctx.os == "windows" then
   if ctx.os == "windows" then
     return bcsave_peobj(ctx, output, s, ffi)
     return bcsave_peobj(ctx, output, s, ffi)
   elseif ctx.os == "osx" then
   elseif ctx.os == "osx" then

+ 12 - 2
libs/LuaJIT/src/lj_opt_fold.c

@@ -1037,8 +1037,7 @@ LJFOLDF(simplify_numadd_xneg)
 LJFOLD(SUB any KNUM)
 LJFOLD(SUB any KNUM)
 LJFOLDF(simplify_numsub_k)
 LJFOLDF(simplify_numsub_k)
 {
 {
-  lua_Number n = knumright;
-  if (n == 0.0)  /* x - (+-0) ==> x */
+  if (ir_knum(fright)->u64 == 0)  /* x - (+0) ==> x */
     return LEFTFOLD;
     return LEFTFOLD;
   return NEXTFOLD;
   return NEXTFOLD;
 }
 }
@@ -2412,6 +2411,17 @@ LJFOLDF(xload_kptr)
 LJFOLD(XLOAD any any)
 LJFOLD(XLOAD any any)
 LJFOLDX(lj_opt_fwd_xload)
 LJFOLDX(lj_opt_fwd_xload)
 
 
+/* -- Frame handling ------------------------------------------------------ */
+
+/* Prevent CSE of a REF_BASE operand across IR_RETF. */
+LJFOLD(SUB any BASE)
+LJFOLD(SUB BASE any)
+LJFOLD(EQ any BASE)
+LJFOLDF(fold_base)
+{
+  return lj_opt_cselim(J, J->chain[IR_RETF]);
+}
+
 /* -- Write barriers ------------------------------------------------------ */
 /* -- Write barriers ------------------------------------------------------ */
 
 
 /* Write barriers are amenable to CSE, but not across any incremental
 /* Write barriers are amenable to CSE, but not across any incremental