From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id B22E7D2C1C0; Wed, 26 Jun 2024 11:37:28 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org B22E7D2C1C0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1719391048; bh=QFR5ZlX78dvyJQxaFhybcJPCymnJoiEdnv2MLJdOMV8=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=dQahag5ZVULA28xIHv2ZRMjl3upTRvG0n/04ltuGcj6grT7BiQnEPhtwBS6vTxOj0 VEkzfSaHDkfuT4Dzq+i4FINdAOeBQso4V1KSFEDTEibGdYgqrEfCPzsSwjqrYE0CtX 9RYB8Rg7jDn6Kg+5wo8gzW1CyksCqT8nCgqZbXvg= Received: from smtp57.i.mail.ru (smtp57.i.mail.ru [95.163.41.95]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 4B33468C828 for ; Wed, 26 Jun 2024 11:37:27 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 4B33468C828 Received: by smtp57.i.mail.ru with esmtpa (envelope-from ) id 1sMO9d-0000000HBSV-1lqe; Wed, 26 Jun 2024 11:37:26 +0300 To: Maxim Kokryashkin , Sergey Bronnikov Date: Wed, 26 Jun 2024 11:37:21 +0300 Message-ID: <20240626083721.11596-1-skaplun@tarantool.org> X-Mailer: git-send-email 2.45.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailru-Src: smtp X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD97FB297CCB910C1A96AA9988DD982100DB3E50F1FE555E342182A05F53808504036B84B3D696E6A3289CEA9C911D0999596D0FA532F6F1AB0E6DAB35DA604EA4C0F4B8A9FC37412E1 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7D77100FFB2844417EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006373103A56A89D9083FEA1F7E6F0F101C6723150C8DA25C47586E58E00D9D99D84E1BDDB23E98D2D38B043BF0FB74779F36024EA9065AA9BD0FD57BE4BE09F450909FD68F112F785C01A471835C12D1D9774AD6D5ED66289B5278DA827A17800CE7A6779F98BF527B7A9FA2833FD35BB23D2EF20D2F80756B5F868A13BD56FB6657A471835C12D1D977725E5C173C3A84C3776A0366D588B3C3117882F4460429728AD0CFFFB425014E868A13BD56FB6657E2021AF6380DFAD1A18204E546F3947CB11811A4A51E3B096D1867E19FE1407978DA827A17800CE773BC869C69ECC1572DBA43225CD8A89F83C798A30B85E16BC6EABA9B74D0DA47B5C8C57E37DE458BEDA766A37F9254B7 X-C1DE0DAB: 0D63561A33F958A5F78AE48999B30A875002B1117B3ED6968095FBF767885AAC14DB8790748E3E77823CB91A9FED034534781492E4B8EEAD577AE849BCD98940C79554A2A72441328621D336A7BC284946AD531847A6065A535571D14F44ED41 X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF77DD89D51EBB7742D3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CF4E459926696FFC14BA8445492A1F353AAB312231FF698B41C450844291864D4677ACD0092D6ACCC8443676941C84C1C859BF5BBC967EA83AB62C7A21BC4A4C3B2FDFAE06177FFF88C226CC413062362A913E6812662D5F2A5EAB5682573093F7837F15F2B5E4A70B33F2C28C22F508233FCF178C6DD14203 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2bioj4UWaTy6lA2QQq4ZsEqgBYw== X-DA7885C5: B5304587E7CC7984F255D290C0D534F976F7036CB06F5F3692AC6514319DC56665CC06971B48B73E5B1A4C17EAA7BC4BEF2421ABFA55128DAF83EF9164C44C7E X-Mailru-Sender: 689FA8AB762F7393C6D0B12EA33CAA9B4194FA11DC066D436280CEC3E2F20CB40D8C3A0B95965509E49D44BB4BD9522A059A1ED8796F048DB274557F927329BE89D5A3BC2B10C37545BD1C3CC395C826B4A721A3011E896F X-Mras: Ok Subject: [Tarantool-patches] [PATCH luajit] Show name of NYI bytecode in -jv and -jdump. X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Sergey Kaplun via Tarantool-patches Reply-To: Sergey Kaplun Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" From: Mike Pall Suggested by Sergey Kaplun. (cherry picked from commit d2fe2a6d465a3e4c74c9876db94ae606f9c6983b) This patch replaces the number of NYI bytecodes that can't be compiled with their names in the `jit.dump()` and -jv outputs. Since the functionality is the same, only `jit.dump()` is tested as most popular. Sergey Kaplun: * added the description and the test for the feature Part of tarantool/tarantool#9924 --- Branch: https://github.com/tarantool/luajit/tree/skaplun/lj-567-1176-print-nyi-names Related Issues: * https://github.com/tarantool/tarantool/issues/9924 * https://github.com/LuaJIT/LuaJIT/pull/567 * https://github.com/LuaJIT/LuaJIT/issues/1176 src/jit/dump.lua | 7 +- src/jit/v.lua | 9 +- src/lj_traceerr.h | 2 +- .../lj-567-1176-print-nyi-names.test.lua | 82 +++++++++++++++++++ 4 files changed, 96 insertions(+), 4 deletions(-) create mode 100644 test/tarantool-tests/lj-567-1176-print-nyi-names.test.lua diff --git a/src/jit/dump.lua b/src/jit/dump.lua index 84fe0044..e7f05253 100644 --- a/src/jit/dump.lua +++ b/src/jit/dump.lua @@ -543,7 +543,12 @@ local recdepth = 0 local function fmterr(err, info) if type(err) == "number" then if type(info) == "function" then info = fmtfunc(info) end - err = format(vmdef.traceerr[err], info) + local fmt = vmdef.traceerr[err] + if fmt == "NYI: bytecode %s" then + local oidx = 6 * info + info = sub(vmdef.bcnames, oidx+1, oidx+6) + end + err = format(fmt, info) end return err end diff --git a/src/jit/v.lua b/src/jit/v.lua index 934de985..ff4e9c7c 100644 --- a/src/jit/v.lua +++ b/src/jit/v.lua @@ -63,7 +63,7 @@ assert(jit.version_num == 20100, "LuaJIT core/library version mismatch") local jutil = require("jit.util") local vmdef = require("jit.vmdef") local funcinfo, traceinfo = jutil.funcinfo, jutil.traceinfo -local type, format = type, string.format +local type, sub, format = type, string.sub, string.format local stdout, stderr = io.stdout, io.stderr -- Active flag and output file handle. @@ -90,7 +90,12 @@ end local function fmterr(err, info) if type(err) == "number" then if type(info) == "function" then info = fmtfunc(info) end - err = format(vmdef.traceerr[err], info) + local fmt = vmdef.traceerr[err] + if fmt == "NYI: bytecode %s" then + local oidx = 6 * info + info = sub(vmdef.bcnames, oidx+1, oidx+6) + end + err = format(fmt, info) end return err end diff --git a/src/lj_traceerr.h b/src/lj_traceerr.h index 1363c4f3..beecbd8c 100644 --- a/src/lj_traceerr.h +++ b/src/lj_traceerr.h @@ -13,7 +13,7 @@ TREDEF(STACKOV, "trace too deep") TREDEF(SNAPOV, "too many snapshots") TREDEF(BLACKL, "blacklisted") TREDEF(RETRY, "retry recording") -TREDEF(NYIBC, "NYI: bytecode %d") +TREDEF(NYIBC, "NYI: bytecode %s") /* Recording loop ops. */ TREDEF(LLEAVE, "leaving loop in root trace") diff --git a/test/tarantool-tests/lj-567-1176-print-nyi-names.test.lua b/test/tarantool-tests/lj-567-1176-print-nyi-names.test.lua new file mode 100644 index 00000000..38829d2c --- /dev/null +++ b/test/tarantool-tests/lj-567-1176-print-nyi-names.test.lua @@ -0,0 +1,82 @@ +local tap = require('tap') + +-- Test dumping of names of NYI bytecodes to be compiled instead +-- of their numbers. See also: +-- * https://github.com/LuaJIT/LuaJIT/pull/567, +-- * https://github.com/LuaJIT/LuaJIT/issues/1176. + +local test = tap.test('lj-567-1176-print-nyi-names'):skipcond({ + ['Test requires JIT enabled'] = not jit.status(), + ['Disabled on *BSD due to #4819'] = jit.os == 'BSD', +}) + +local jparse = require('utils').jit.parse + +test:plan(3) + +local function reset_jit() + -- Remove all previous traces. + jit.off() + jit.flush() + jit.on() + jit.opt.start('hotloop=1') +end + +local function nop() end +local function test_varg(...) + for _ = 1, 4 do nop(...) end +end + +local function test_uv() + do + -- luacheck: ignore + local uclo + goto close_uv + local function _() + return uclo + end + end + ::close_uv:: +end + +-- We only need the abort reason in the test. +jparse.start('t') +reset_jit() + +test_varg() + +local _, aborted_traces = jparse.finish() +assert(aborted_traces and aborted_traces[1], + 'aborted trace with VARG is persisted') + +-- We tried to compile only one trace. +local reason = aborted_traces[1][1].abort_reason +test:like(reason, 'NYI: bytecode VARG', 'bytecode VARG name') + +jparse.start('t') +reset_jit() + +for _ = 1, 4 do + local _ = function() end +end +_, aborted_traces = jparse.finish() +assert(aborted_traces and aborted_traces[1], + 'aborted trace with FNEW is persisted') + +reason = aborted_traces[1][1].abort_reason +test:like(reason, 'NYI: bytecode FNEW', 'bytecode FNEW name') + +jparse.start('t') +reset_jit() + +test_uv() +test_uv() + +_, aborted_traces = jparse.finish() +assert(aborted_traces and aborted_traces[1], + 'aborted trace with UCLO is persisted') + +reason = aborted_traces[1][1].abort_reason +test:like(reason, 'NYI: bytecode UCLO', 'bytecode UCLO name') + +test:done(true) -- 2.45.1