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 86774C6B39D; Sun, 16 Jun 2024 13:06:02 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 86774C6B39D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1718532362; bh=u0tbOQoesZcV9LtRtg6eKH+w1RVKJFkFM5qqk6O/I/g=; 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=ydxgpXeBgLDkXoz8crjonIU5TwfCfIRvH9OfNyPDaFi9SCoJcMA0Uy3yKqu3Uf+B0 0x71bmtyK3OhRTmW4Gzd+5aDLFHsPrgq4eoy/gBtoExYPmjDRr/PvuhBR7EeTCE//Y 8XBHBDbgaBWxqvAOjBcK0NzWXIMmZySXkJCZ7zNs= Received: from smtp39.i.mail.ru (smtp39.i.mail.ru [95.163.41.80]) (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 F077CC6B381 for ; Sun, 16 Jun 2024 13:04:31 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org F077CC6B381 Received: by smtp39.i.mail.ru with esmtpa (envelope-from ) id 1sImkQ-0000000Fftq-3ziz; Sun, 16 Jun 2024 13:04:31 +0300 To: Maxim Kokryashkin , Sergey Bronnikov Date: Sun, 16 Jun 2024 13:00:11 +0300 Message-ID: <131393711031a0aa8a3bfe2e1149f378b9667afc.1718528874.git.skaplun@tarantool.org> X-Mailer: git-send-email 2.45.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD9AC8CA0B4439200FAA6268B5D05BFD5F405B302337288676B00894C459B0CD1B94A767F6C68ACFE4F10B999B7BE3335B5377D804B58437647DF8292320A6A5419ACCB5262BB601CA2 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE72407438AC6002944EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637657EF45424029EDA8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D85EB2EAADA0C8326FAE6BF3E8E72F99D9E00DE52179827EC6CC7F00164DA146DAFE8445B8C89999728AA50765F790063798EAA0EED4DE4A60389733CBF5DBD5E9C8A9BA7A39EFB766F5D81C698A659EA7CC7F00164DA146DA9985D098DBDEAEC8C6602A96AF88C695F6B57BC7E6449061A352F6E88A58FB86F5D81C698A659EA7E827F84554CEF5019E625A9149C048EE9ECD01F8117BC8BEE2021AF6380DFAD18AA50765F7900637F09814068C508CC822CA9DD8327EE4930A3850AC1BE2E7356C9A9530EBF72002C4224003CC83647689D4C264860C145E X-C1DE0DAB: 0D63561A33F958A5E58B7C3C69C18FC35002B1117B3ED696DB6EB1963C31FF7DF5FEB6EB1EB183FD823CB91A9FED034534781492E4B8EEAD69BF13FED57427F1C79554A2A72441328621D336A7BC284946AD531847A6065A535571D14F44ED41 X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF3FED46C3ACD6F73ED3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CF9F482C4AEA95D71F2913188641A273BD47DA212CFFAD416FCD22A42541AD247117059C39C4D66242BC11D93875BCBCAC578A91CB854581EB992F8167577D1E7C820D8AB692F936ECC226CC413062362A913E6812662D5F2A5EAB5682573093F7837F15F2B5E4A70B33F2C28C22F508233FCF178C6DD14203 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojsYa7y8j7e8e0m2W7w0Cm/g== X-DA7885C5: C9814FE92766791FF255D290C0D534F90B8FBF7A09BCF90A1BC3FBFE9E43876F8C1E7E0BBD2A58775B1A4C17EAA7BC4BEF2421ABFA55128DAF83EF9164C44C7E X-Mailru-Sender: 689FA8AB762F7393C6D0B12EA33CAA9B10CE47FB5387BE3C294DC2D8F921DC34A9980801635B3309E49D44BB4BD9522A059A1ED8796F048DB274557F927329BE89D5A3BC2B10C37545BD1C3CC395C826B4A721A3011E896F X-Mras: Ok Subject: [Tarantool-patches] [PATCH v2 luajit 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 | 24 +++++++++--- 2 files changed, 57 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..f09e696c --- /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-abort'):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..f853437d 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,19 @@ 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 + -- The reason is mentioned after "-- " at the end of the + -- string. + 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 +148,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 +181,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.45.1