]> git.ipfire.org Git - thirdparty/LuaJIT.git/commitdiff
Merge branch 'master' into v2.1 v2.1.ROLLING
authorMike Pall <mike>
Mon, 21 Aug 2023 01:18:35 +0000 (03:18 +0200)
committerMike Pall <mike>
Mon, 21 Aug 2023 01:18:35 +0000 (03:18 +0200)
13 files changed:
1  2 
Makefile
etc/luajit.pc
src/.gitignore
src/Makefile
src/host/buildvm.c
src/jit/bc.lua
src/jit/bcsave.lua
src/jit/dump.lua
src/jit/p.lua
src/jit/v.lua
src/lib_jit.c
src/luaconf.h
src/luajit_rolling.h

diff --cc Makefile
index 95400870ac98650d4e2352eec3637c64440cfc46,792d7e5698a30212d6701b28acbb6a0b6ef545a8..ae1944287ceb2f062b1b38f061b32be9d0c75267
+++ b/Makefile
  ##############################################################################
  
  MAJVER=  2
 -MINVER=  0
 +MINVER=  1
- RELVER=  0
- PREREL=  -beta3
- VERSION= $(MAJVER).$(MINVER).$(RELVER)$(PREREL)
  ABIVER=  5.1
  
+ # LuaJIT uses rolling releases. The release version is based on the time of
+ # the latest git commit. The 'git' command must be available during the build.
+ RELVER= $(shell cat src/luajit_relver.txt 2>/dev/null || : )
+ # Note: setting it with := doesn't work, since it will change during the build.
+ MMVERSION= $(MAJVER).$(MINVER)
+ VERSION= $(MMVERSION).$(RELVER)
  ##############################################################################
  #
  # Change the installation path as needed. This automatically adjusts
diff --cc etc/luajit.pc
index 39e1e57721aec4c1f23b21d5da97bca5542a8b1a,68f8d5cc0b1e26a1fca428ee8f4a9db247c71972..96433008c7fe46d993b509ac9c5825b34c8ca2b8
@@@ -1,8 -1,8 +1,8 @@@
  # Package information for LuaJIT to be used by pkg-config.
  majver=2
 -minver=0
 +minver=1
- relver=0
- version=${majver}.${minver}.${relver}-beta3
+ relver=ROLLING
+ version=${majver}.${minver}.${relver}
  abiver=5.1
  
  prefix=/usr/local
diff --cc src/.gitignore
Simple merge
diff --cc src/Makefile
index cc520fc8cf13af1d74ba737b5cd13660922f55bd,e6954a9550d1b340adc73076b44a01475aae5d28..3a6a43293d0ebcd21a54ca84f7380602530328c8
@@@ -11,8 -11,7 +11,7 @@@
  ##############################################################################
  
  MAJVER=  2
 -MINVER=  0
 +MINVER=  1
- RELVER=  0
  ABIVER=  5.1
  NODOTABIVER= 51
  
@@@ -320,27 -305,20 +319,27 @@@ ifeq (Darwin,$(TARGET_SYS)
      $(error missing: export MACOSX_DEPLOYMENT_TARGET=XX.YY)
    endif
    TARGET_STRIP+= -x
 +  TARGET_XCFLAGS+= -DLUAJIT_UNWIND_EXTERNAL
    TARGET_XSHLDFLAGS= -dynamiclib -single_module -undefined dynamic_lookup -fPIC
    TARGET_DYNXLDOPTS=
-   TARGET_XSHLDFLAGS+= -install_name $(TARGET_DYLIBPATH) -compatibility_version $(MAJVER).$(MINVER) -current_version $(MAJVER).$(MINVER).$(RELVER)
+   TARGET_XSHLDFLAGS+= -install_name $(TARGET_DYLIBPATH) -compatibility_version $(MAJVER).$(MINVER) -current_version $(MAJVER).$(MINVER).255
 -  ifeq (x64,$(TARGET_LJARCH))
 -    TARGET_XLDFLAGS+= -pagezero_size 10000 -image_base 100000000
 -    TARGET_XSHLDFLAGS+= -image_base 7fff04c4a000
 -  endif
  else
  ifeq (iOS,$(TARGET_SYS))
    TARGET_STRIP+= -x
    TARGET_XSHLDFLAGS= -dynamiclib -single_module -undefined dynamic_lookup -fPIC
    TARGET_DYNXLDOPTS=
-   TARGET_XSHLDFLAGS+= -install_name $(TARGET_DYLIBPATH) -compatibility_version $(MAJVER).$(MINVER) -current_version $(MAJVER).$(MINVER).$(RELVER)
+   TARGET_XSHLDFLAGS+= -install_name $(TARGET_DYLIBPATH) -compatibility_version $(MAJVER).$(MINVER) -current_version $(MAJVER).$(MINVER).255
 +  ifeq (arm64,$(TARGET_LJARCH))
 +    TARGET_XCFLAGS+= -fno-omit-frame-pointer
 +  endif
  else
 +  ifeq (,$(findstring LJ_NO_UNWIND 1,$(TARGET_TESTARCH)))
 +    # Find out whether the target toolchain always generates unwind tables.
 +    TARGET_TESTUNWIND=$(shell exec 2>/dev/null; echo 'extern void b(void);int a(void){b();return 0;}' | $(TARGET_CC) -c -x c - -o tmpunwind.o && { grep -qa -e eh_frame -e __unwind_info tmpunwind.o || grep -qU -e eh_frame -e __unwind_info tmpunwind.o; } && echo E; rm -f tmpunwind.o)
 +    ifneq (,$(findstring E,$(TARGET_TESTUNWIND)))
 +      TARGET_XCFLAGS+= -DLUAJIT_UNWIND_EXTERNAL
 +    endif
 +  endif
    ifneq (SunOS,$(TARGET_SYS))
      ifneq (PS3,$(TARGET_SYS))
        TARGET_XLDFLAGS+= -Wl,-E
index 6e96bffa4542396db7658c22efb405c61d8c6750,39c2bc24f07303caf9e57d2879021909e8b0a934..ec99e501f62b9f3438821e0ae532db109edcf6fb
@@@ -324,12 -317,11 +324,13 @@@ static void emit_bcdef(BuildCtx *ctx
  /* Emit VM definitions as Lua code for debug modules. */
  static void emit_vmdef(BuildCtx *ctx)
  {
 +#if LJ_HASJIT
    char buf[80];
 +#endif
    int i;
    fprintf(ctx->fp, "-- This is a generated file. DO NOT EDIT!\n\n");
 -  fprintf(ctx->fp, "module(...)\n\n");
+   fprintf(ctx->fp, "assert(require(\"jit\").version == \"%s\", \"LuaJIT core/library version mismatch\")\n\n", LUAJIT_VERSION);
 +  fprintf(ctx->fp, "return {\n\n");
  
    fprintf(ctx->fp, "bcnames = \"");
    for (i = 0; bc_names[i]; i++) fprintf(ctx->fp, "%-6s", bc_names[i]);
diff --cc src/jit/bc.lua
Simple merge
index 0f046669206eb8a6ba1b990faca4fb187dafb6bc,55fae993554bb34845a650488ce049b856c8daa1..74699f3d5fccaa373855f4a27d552411a48c32b7
@@@ -11,7 -11,7 +11,7 @@@
  ------------------------------------------------------------------------------
  
  local jit = require("jit")
- assert(jit.version_num == 20100, "LuaJIT core/library version mismatch")
 -assert(jit.version_num == 20099, "LuaJIT core/library version mismatch")
++assert(jit.version_num == 20199, "LuaJIT core/library version mismatch")
  local bit = require("bit")
  
  -- Symbol name prefix for LuaJIT bytecode.
Simple merge
diff --cc src/jit/p.lua
index 3daa9291334512ec6fbddaa86cdd2c8224933347,0000000000000000000000000000000000000000..36f836c51da632200a2e903a4c063fb3775dd3e5
mode 100644,000000..100644
--- /dev/null
@@@ -1,312 -1,0 +1,311 @@@
- assert(jit.version_num == 20100, "LuaJIT core/library version mismatch")
 +----------------------------------------------------------------------------
 +-- LuaJIT profiler.
 +--
 +-- Copyright (C) 2005-2023 Mike Pall. All rights reserved.
 +-- Released under the MIT license. See Copyright Notice in luajit.h
 +----------------------------------------------------------------------------
 +--
 +-- This module is a simple command line interface to the built-in
 +-- low-overhead profiler of LuaJIT.
 +--
 +-- The lower-level API of the profiler is accessible via the "jit.profile"
 +-- module or the luaJIT_profile_* C API.
 +--
 +-- Example usage:
 +--
 +--   luajit -jp myapp.lua
 +--   luajit -jp=s myapp.lua
 +--   luajit -jp=-s myapp.lua
 +--   luajit -jp=vl myapp.lua
 +--   luajit -jp=G,profile.txt myapp.lua
 +--
 +-- The following dump features are available:
 +--
 +--   f  Stack dump: function name, otherwise module:line. Default mode.
 +--   F  Stack dump: ditto, but always prepend module.
 +--   l  Stack dump: module:line.
 +--   <number> stack dump depth (callee < caller). Default: 1.
 +--   -<number> Inverse stack dump depth (caller > callee).
 +--   s  Split stack dump after first stack level. Implies abs(depth) >= 2.
 +--   p  Show full path for module names.
 +--   v  Show VM states. Can be combined with stack dumps, e.g. vf or fv.
 +--   z  Show zones. Can be combined with stack dumps, e.g. zf or fz.
 +--   r  Show raw sample counts. Default: show percentages.
 +--   a  Annotate excerpts from source code files.
 +--   A  Annotate complete source code files.
 +--   G  Produce raw output suitable for graphical tools (e.g. flame graphs).
 +--   m<number> Minimum sample percentage to be shown. Default: 3.
 +--   i<number> Sampling interval in milliseconds. Default: 10.
 +--
 +----------------------------------------------------------------------------
 +
 +-- Cache some library functions and objects.
 +local jit = require("jit")
 +local profile = require("jit.profile")
 +local vmdef = require("jit.vmdef")
 +local math = math
 +local pairs, ipairs, tonumber, floor = pairs, ipairs, tonumber, math.floor
 +local sort, format = table.sort, string.format
 +local stdout = io.stdout
 +local zone -- Load jit.zone module on demand.
 +
 +-- Output file handle.
 +local out
 +
 +------------------------------------------------------------------------------
 +
 +local prof_ud
 +local prof_states, prof_split, prof_min, prof_raw, prof_fmt, prof_depth
 +local prof_ann, prof_count1, prof_count2, prof_samples
 +
 +local map_vmmode = {
 +  N = "Compiled",
 +  I = "Interpreted",
 +  C = "C code",
 +  G = "Garbage Collector",
 +  J = "JIT Compiler",
 +}
 +
 +-- Profiler callback.
 +local function prof_cb(th, samples, vmmode)
 +  prof_samples = prof_samples + samples
 +  local key_stack, key_stack2, key_state
 +  -- Collect keys for sample.
 +  if prof_states then
 +    if prof_states == "v" then
 +      key_state = map_vmmode[vmmode] or vmmode
 +    else
 +      key_state = zone:get() or "(none)"
 +    end
 +  end
 +  if prof_fmt then
 +    key_stack = profile.dumpstack(th, prof_fmt, prof_depth)
 +    key_stack = key_stack:gsub("%[builtin#(%d+)%]", function(x)
 +      return vmdef.ffnames[tonumber(x)]
 +    end)
 +    if prof_split == 2 then
 +      local k1, k2 = key_stack:match("(.-) [<>] (.*)")
 +      if k2 then key_stack, key_stack2 = k1, k2 end
 +    elseif prof_split == 3 then
 +      key_stack2 = profile.dumpstack(th, "l", 1)
 +    end
 +  end
 +  -- Order keys.
 +  local k1, k2
 +  if prof_split == 1 then
 +    if key_state then
 +      k1 = key_state
 +      if key_stack then k2 = key_stack end
 +    end
 +  elseif key_stack then
 +    k1 = key_stack
 +    if key_stack2 then k2 = key_stack2 elseif key_state then k2 = key_state end
 +  end
 +  -- Coalesce samples in one or two levels.
 +  if k1 then
 +    local t1 = prof_count1
 +    t1[k1] = (t1[k1] or 0) + samples
 +    if k2 then
 +      local t2 = prof_count2
 +      local t3 = t2[k1]
 +      if not t3 then t3 = {}; t2[k1] = t3 end
 +      t3[k2] = (t3[k2] or 0) + samples
 +    end
 +  end
 +end
 +
 +------------------------------------------------------------------------------
 +
 +-- Show top N list.
 +local function prof_top(count1, count2, samples, indent)
 +  local t, n = {}, 0
 +  for k in pairs(count1) do
 +    n = n + 1
 +    t[n] = k
 +  end
 +  sort(t, function(a, b) return count1[a] > count1[b] end)
 +  for i=1,n do
 +    local k = t[i]
 +    local v = count1[k]
 +    local pct = floor(v*100/samples + 0.5)
 +    if pct < prof_min then break end
 +    if not prof_raw then
 +      out:write(format("%s%2d%%  %s\n", indent, pct, k))
 +    elseif prof_raw == "r" then
 +      out:write(format("%s%5d  %s\n", indent, v, k))
 +    else
 +      out:write(format("%s %d\n", k, v))
 +    end
 +    if count2 then
 +      local r = count2[k]
 +      if r then
 +      prof_top(r, nil, v, (prof_split == 3 or prof_split == 1) and "  -- " or
 +                          (prof_depth < 0 and "  -> " or "  <- "))
 +      end
 +    end
 +  end
 +end
 +
 +-- Annotate source code
 +local function prof_annotate(count1, samples)
 +  local files = {}
 +  local ms = 0
 +  for k, v in pairs(count1) do
 +    local pct = floor(v*100/samples + 0.5)
 +    ms = math.max(ms, v)
 +    if pct >= prof_min then
 +      local file, line = k:match("^(.*):(%d+)$")
 +      if not file then file = k; line = 0 end
 +      local fl = files[file]
 +      if not fl then fl = {}; files[file] = fl; files[#files+1] = file end
 +      line = tonumber(line)
 +      fl[line] = prof_raw and v or pct
 +    end
 +  end
 +  sort(files)
 +  local fmtv, fmtn = " %3d%% | %s\n", "      | %s\n"
 +  if prof_raw then
 +    local n = math.max(5, math.ceil(math.log10(ms)))
 +    fmtv = "%"..n.."d | %s\n"
 +    fmtn = (" "):rep(n).." | %s\n"
 +  end
 +  local ann = prof_ann
 +  for _, file in ipairs(files) do
 +    local f0 = file:byte()
 +    if f0 == 40 or f0 == 91 then
 +      out:write(format("\n====== %s ======\n[Cannot annotate non-file]\n", file))
 +      break
 +    end
 +    local fp, err = io.open(file)
 +    if not fp then
 +      out:write(format("====== ERROR: %s: %s\n", file, err))
 +      break
 +    end
 +    out:write(format("\n====== %s ======\n", file))
 +    local fl = files[file]
 +    local n, show = 1, false
 +    if ann ~= 0 then
 +      for i=1,ann do
 +      if fl[i] then show = true; out:write("@@ 1 @@\n"); break end
 +      end
 +    end
 +    for line in fp:lines() do
 +      if line:byte() == 27 then
 +      out:write("[Cannot annotate bytecode file]\n")
 +      break
 +      end
 +      local v = fl[n]
 +      if ann ~= 0 then
 +      local v2 = fl[n+ann]
 +      if show then
 +        if v2 then show = n+ann elseif v then show = n
 +        elseif show+ann < n then show = false end
 +      elseif v2 then
 +        show = n+ann
 +        out:write(format("@@ %d @@\n", n))
 +      end
 +      if not show then goto next end
 +      end
 +      if v then
 +      out:write(format(fmtv, v, line))
 +      else
 +      out:write(format(fmtn, line))
 +      end
 +    ::next::
 +      n = n + 1
 +    end
 +    fp:close()
 +  end
 +end
 +
 +------------------------------------------------------------------------------
 +
 +-- Finish profiling and dump result.
 +local function prof_finish()
 +  if prof_ud then
 +    profile.stop()
 +    local samples = prof_samples
 +    if samples == 0 then
 +      if prof_raw ~= true then out:write("[No samples collected]\n") end
 +      return
 +    end
 +    if prof_ann then
 +      prof_annotate(prof_count1, samples)
 +    else
 +      prof_top(prof_count1, prof_count2, samples, "")
 +    end
 +    prof_count1 = nil
 +    prof_count2 = nil
 +    prof_ud = nil
 +    if out ~= stdout then out:close() end
 +  end
 +end
 +
 +-- Start profiling.
 +local function prof_start(mode)
 +  local interval = ""
 +  mode = mode:gsub("i%d*", function(s) interval = s; return "" end)
 +  prof_min = 3
 +  mode = mode:gsub("m(%d+)", function(s) prof_min = tonumber(s); return "" end)
 +  prof_depth = 1
 +  mode = mode:gsub("%-?%d+", function(s) prof_depth = tonumber(s); return "" end)
 +  local m = {}
 +  for c in mode:gmatch(".") do m[c] = c end
 +  prof_states = m.z or m.v
 +  if prof_states == "z" then zone = require("jit.zone") end
 +  local scope = m.l or m.f or m.F or (prof_states and "" or "f")
 +  local flags = (m.p or "")
 +  prof_raw = m.r
 +  if m.s then
 +    prof_split = 2
 +    if prof_depth == -1 or m["-"] then prof_depth = -2
 +    elseif prof_depth == 1 then prof_depth = 2 end
 +  elseif mode:find("[fF].*l") then
 +    scope = "l"
 +    prof_split = 3
 +  else
 +    prof_split = (scope == "" or mode:find("[zv].*[lfF]")) and 1 or 0
 +  end
 +  prof_ann = m.A and 0 or (m.a and 3)
 +  if prof_ann then
 +    scope = "l"
 +    prof_fmt = "pl"
 +    prof_split = 0
 +    prof_depth = 1
 +  elseif m.G and scope ~= "" then
 +    prof_fmt = flags..scope.."Z;"
 +    prof_depth = -100
 +    prof_raw = true
 +    prof_min = 0
 +  elseif scope == "" then
 +    prof_fmt = false
 +  else
 +    local sc = prof_split == 3 and m.f or m.F or scope
 +    prof_fmt = flags..sc..(prof_depth >= 0 and "Z < " or "Z > ")
 +  end
 +  prof_count1 = {}
 +  prof_count2 = {}
 +  prof_samples = 0
 +  profile.start(scope:lower()..interval, prof_cb)
 +  prof_ud = newproxy(true)
 +  getmetatable(prof_ud).__gc = prof_finish
 +end
 +
 +------------------------------------------------------------------------------
 +
 +local function start(mode, outfile)
 +  if not outfile then outfile = os.getenv("LUAJIT_PROFILEFILE") end
 +  if outfile then
 +    out = outfile == "-" and stdout or assert(io.open(outfile, "w"))
 +  else
 +    out = stdout
 +  end
 +  prof_start(mode or "f")
 +end
 +
 +-- Public module functions.
 +return {
 +  start = start, -- For -j command line option.
 +  stop = prof_finish
 +}
 +
diff --cc src/jit/v.lua
Simple merge
diff --cc src/lib_jit.c
index 2f2bc3b24983cbcb62ea84cb796b4b8bab22012b,04a564c7681c932c3b3312e632a4c28628ae2fda..c0294927867142a31710b58e0a799037443bdc22
@@@ -738,20 -646,13 +738,20 @@@ static void jit_init(lua_State *L
  
  LUALIB_API int luaopen_jit(lua_State *L)
  {
 +#if LJ_HASJIT
 +  jit_init(L);
 +#endif
    lua_pushliteral(L, LJ_OS_NAME);
    lua_pushliteral(L, LJ_ARCH_NAME);
-   lua_pushinteger(L, LUAJIT_VERSION_NUM);
+   lua_pushinteger(L, LUAJIT_VERSION_NUM);  /* Deprecated. */
    lua_pushliteral(L, LUAJIT_VERSION);
    LJ_LIB_REG(L, LUA_JITLIBNAME, jit);
 +#if LJ_HASPROFILE
 +  lj_lib_prereg(L, LUA_JITLIBNAME ".profile", luaopen_jit_profile,
 +              tabref(L->env));
 +#endif
  #ifndef LUAJIT_DISABLE_JITUTIL
 -  LJ_LIB_REG(L, "jit.util", jit_util);
 +  lj_lib_prereg(L, LUA_JITLIBNAME ".util", luaopen_jit_util, tabref(L->env));
  #endif
  #if LJ_HASJIT
    LJ_LIB_REG(L, "jit.opt", jit_opt);
diff --cc src/luaconf.h
index fc7b4aae57ca29fe07846509a2c921ab743e6fbf,8fc3eee5dae2b9c4b71834b692748768f7ee29b4..f47f068024684053e108e3634761ba00048b2093
@@@ -37,7 -37,7 +37,7 @@@
  #endif
  #define LUA_LROOT     "/usr/local"
  #define LUA_LUADIR    "/lua/5.1/"
- #define LUA_LJDIR     "/luajit-2.1.0-beta3/"
 -#define LUA_LJDIR     "/luajit-2.0/"
++#define LUA_LJDIR     "/luajit-2.1/"
  
  #ifdef LUA_ROOT
  #define LUA_JROOT     LUA_ROOT
index f01771ae1bef9c6d350cbda5864abc2554143104,273688361b38dbd0bfa8f836c27e06792110dba0..e564477ae31be50c055e70b37074c58b64efab4f
@@@ -30,9 -30,9 +30,9 @@@
  
  #include "lua.h"
  
- #define LUAJIT_VERSION                "LuaJIT 2.1.0-beta3"
- #define LUAJIT_VERSION_NUM    20100  /* Version 2.1.0 = 02.01.00. */
- #define LUAJIT_VERSION_SYM    luaJIT_version_2_1_0_beta3
 -#define LUAJIT_VERSION                "LuaJIT 2.0.ROLLING"
 -#define LUAJIT_VERSION_NUM    20099  /* Deprecated. */
 -#define LUAJIT_VERSION_SYM    luaJIT_version_2_0_ROLLING
++#define LUAJIT_VERSION                "LuaJIT 2.1.ROLLING"
++#define LUAJIT_VERSION_NUM    20199  /* Deprecated. */
++#define LUAJIT_VERSION_SYM    luaJIT_version_2_1_ROLLING
  #define LUAJIT_COPYRIGHT      "Copyright (C) 2005-2023 Mike Pall"
  #define LUAJIT_URL            "https://luajit.org/"