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 002A1C24340; Mon, 22 Apr 2024 11:55:40 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 002A1C24340 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1713776141; bh=wVRkabOQSUgDHPne14dMOQGHWUg3CBmfU7BUlLS2/r8=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=FX//s1/JR2rwP/YtzM0zFKcXjk551M1JsEEnzUuWMCbXEmtrAKzyeRvi3vSoTt8pV DsJDIL7YSqXnbOVNBb7YAJXIkbxigBYV4N9tLxtv+6rnYaJyB/FBzQg2D9aRh80tkU T/w8MDH+fvu3I81Co+5DscRmh/rsGmrL9ZcUTu7E= Received: from smtp32.i.mail.ru (smtp32.i.mail.ru [95.163.41.73]) (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 4E95BBB132D for ; Mon, 22 Apr 2024 11:54:11 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 4E95BBB132D Received: by smtp32.i.mail.ru with esmtpa (envelope-from ) id 1rypRC-0000000BtKy-04EH; Mon, 22 Apr 2024 11:54:10 +0300 To: Maxim Kokryashkin , Sergey Bronnikov Date: Mon, 22 Apr 2024 11:49:56 +0300 Message-ID: <7c0a7be30070d085d6ddd3b56c4338686e1c2baa.1713773432.git.skaplun@tarantool.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: 78E4E2B564C1792B X-77F55803: 4F1203BC0FB41BD9CB0CA91FF61D77F07FDB05CF68FCEC0F28C1CC98170D78F5182A05F5380850402F95783463F2DC3233594132A326AF8BAB73EFDCC25CE4D2ECBE144D67F46172C0ACFA3BF7752234 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE77545ECFDF1E157EBEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006379D15B32FCF98DF428638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D86D35F7F04003AE3B1DBF48A0D5DCDA27AC7562189905BC98CC7F00164DA146DAFE8445B8C89999728AA50765F7900637574B68B26539E4A0389733CBF5DBD5E9C8A9BA7A39EFB766F5D81C698A659EA7CC7F00164DA146DA9985D098DBDEAEC85DBE5CE84B47B0E4117882F4460429728AD0CFFFB425014E868A13BD56FB6657D81D268191BDAD3DC09775C1D3CA48CF3C056C6FCE5AFF8E76E601842F6C81A12EF20D2F80756B5FB606B96278B59C4276E601842F6C81A127C277FBC8AE2E8B59F0E22272DBA2DBD81D268191BDAD3D3666184CF4C3C14F3FC91FA280E0CE3D1A620F70A64A45A98AA50765F7900637F9425D8FA97DB4396D1867E19FE1407959CC434672EE6371089D37D7C0E48F6C8AA50765F7900637427B078F297B269AEFF80C71ABB335746BA297DBC24807EABDAD6C7F3747799A X-C1DE0DAB: 0D63561A33F958A5645429D1A8F041AB5002B1117B3ED69658C0838D20E6F66FC638DF663A625AFA823CB91A9FED034534781492E4B8EEAD27E9584FBD6BDD31C79554A2A72441328621D336A7BC284946AD531847A6065A535571D14F44ED41 X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF3FED46C3ACD6F73ED3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CFF87ADB89F99F6E0CBA059BA82BDE68AFCDF135808795962F428244A6AA120BA4A54F0D539447C58BA1583B225F58ABB23664113A0FC2E7F7743E605242C55F8DE9CD1DA21C2C9D50C226CC413062362A913E6812662D5F2A5EAB5682573093F7837F15F2B5E4A70B33F2C28C22F508233FCF178C6DD14203 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojerYCxSdLZTYvehHS78FtaA== X-Mailru-Sender: 520A125C2F17F0B1A9638AD358559B59AF405853CC5FD88D33594132A326AF8BAB73EFDCC25CE4D2B7CBEF92542CD7C88B0A2698F12F5C9EC77752E0C033A69E86920BD37369036789A8C6A0E60D2BB63A5DB60FBEB33A8A0DA7A0AF5A3A8387 X-Mras: Ok Subject: [Tarantool-patches] [PATCH luajit v1 3/5] test: allow `jit.parse` to return aborted traces 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" Now information about the abort of the trace is saved in the `abort_reason` field of the corresponding structure. The `jit.parse.finish()` returns now the second table containing aborted traces. Each table key is a trace number containing an array of potentially traces with this number, which was aborted. Needed for tarantool/tarantool#9924 --- .../unit-jit-parse-abort.test.lua | 38 +++++++++++++++++++ test/tarantool-tests/utils/jit/parse.lua | 22 ++++++++--- 2 files changed, 55 insertions(+), 5 deletions(-) create mode 100644 test/tarantool-tests/unit-jit-parse-abort.test.lua diff --git a/test/tarantool-tests/unit-jit-parse-abort.test.lua b/test/tarantool-tests/unit-jit-parse-abort.test.lua new file mode 100644 index 00000000..91af5a56 --- /dev/null +++ b/test/tarantool-tests/unit-jit-parse-abort.test.lua @@ -0,0 +1,38 @@ +local tap = require('tap') +local test = tap.test('unit-jit-parse'):skipcond({ + ['Test requires JIT enabled'] = not jit.status(), + ['Disabled on *BSD due to #4819'] = jit.os == 'BSD', +}) + +local jparse = require('utils').jit.parse + +-- XXX: Avoid other traces compilation due to hotcount collisions +-- for predictable results. +jit.off() +jit.flush() + +test:plan(1) + +jit.on() +-- We only need the abort reason in the test. +jparse.start('t') + +-- XXX: A trace always has at least 3 IR constants: for `nil`, +-- `false`, and `true`. Always fails to record with the set +-- `maxirconst` limit. +jit.opt.start('hotloop=1', 'maxirconst=1') + +for _ = 1, 3 do end + +local _, aborted_traces = jparse.finish() + +jit.off() + +assert(aborted_traces and aborted_traces[1], 'aborted trace is persisted') + +-- We tried to compile only one trace. +local reason = aborted_traces[1][1].abort_reason + +test:like(reason, 'trace too long', 'abort reason is correct') + +test:done(true) diff --git a/test/tarantool-tests/utils/jit/parse.lua b/test/tarantool-tests/utils/jit/parse.lua index bcef5b35..0ce7f7c8 100644 --- a/test/tarantool-tests/utils/jit/parse.lua +++ b/test/tarantool-tests/utils/jit/parse.lua @@ -22,6 +22,7 @@ local function trace_new(n) parent = nil, parent_exitno = nil, is_stitched = false, + abort_reason = nil, start_loc = nil, bc = {}, ir = {}, @@ -87,9 +88,17 @@ local header_handlers = { ctx.parsing_trace = nil ctx.parsing = nil end, - abort = function(ctx, trace_num) + abort = function(ctx, trace_num, line) local traces = ctx.traces assert(ctx.parsing_trace == trace_num) + + local aborted_traces = ctx.aborted_traces + if not aborted_traces[trace_num] then + aborted_traces[trace_num] = {} + end + traces[trace_num].abort_reason = line:match('-- (.+)$') + table.insert(aborted_traces[trace_num], traces[trace_num]) + ctx.parsing_trace = nil ctx.parsing = nil traces[trace_num] = nil @@ -137,11 +146,14 @@ end local JDUMP_FILE local function parse_jit_dump() - local ctx = {traces = {}} + local ctx = { + aborted_traces = {}, + traces = {}, + } for line in io.lines(JDUMP_FILE) do parse_line(ctx, line) end - return ctx.traces + return ctx.traces, ctx.aborted_traces end -- Start `jit.dump()` utility with the given flags, saving the @@ -167,10 +179,10 @@ M.finish = function() -- Enable traces compilation for `jit.dump` back. jit.on(jdump.on, true) jit.on(jdump.off, true) - local traces = parse_jit_dump() + local traces, aborted_traces = parse_jit_dump() os.remove(JDUMP_FILE) JDUMP_FILE = nil - return traces + return traces, aborted_traces end -- Turn off compilation for the module to avoid side effects. -- 2.44.0