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 A89E994FBBF; Mon, 22 Jan 2024 12:37:22 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org A89E994FBBF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1705916242; bh=r2Cm71zJ/bNpOAcBvi19BhcSncdkqt3a0b6CKbLasFU=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=RRb5Fmbe5m81yYSxo7CbczmJDHRW60hGuHziMMqAvL0zFWIsByCESxjgmusXjz5Tj 2Xp1RqoP9naLZmblr4dzgJFBOZT6E5jUwvESvoA5tspugCgAoDF2JiOpKEWruNcVlP Lx4qbWAHoVb+s2W8XgIaW1sz9oJgHMR1rA0n2gJI= Received: from smtp52.i.mail.ru (smtp52.i.mail.ru [95.163.41.88]) (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 4314876E275 for ; Mon, 22 Jan 2024 12:37:21 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 4314876E275 Received: by smtp52.i.mail.ru with esmtpa (envelope-from ) id 1rRqk3-005ftF-1K; Mon, 22 Jan 2024 12:37:20 +0300 To: Maxim Kokryashkin , Sergey Bronnikov Date: Mon, 22 Jan 2024 12:32:34 +0300 Message-ID: <20240122093234.14407-1-skaplun@tarantool.org> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailru-Src: smtp X-7564579A: EEAE043A70213CC8 X-77F55803: 4F1203BC0FB41BD9C4CE30293DC5317395D6394F36AD8F79D705B8024BA04EFB1313CFAB8367EF908E2BE116634AD74DAE9145775E03974E1C3F65E4FEEC1E918FE2D0BCCF6003608DC7380D2C131FBD X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7C3943609F29D73B3EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006372D22CC9620B7D5068638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8CBA6DE73BA634A8731E6CFCA0935D9AF117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCD6672DD12D5A8206A471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F44604297287769387670735204B6963042765DA4BBDFBBEFFF4125B51D2E47CDBA5A96583BA9C0B312567BB2376E601842F6C81A19E625A9149C048EE4B6963042765DA4B45B9AC499A3C791CD8FC6C240DEA76429C9F4D5AE37F343AA9539A8B242431040A6AB1C7CE11FEE3893991AD1F2BFC6AC0837EA9F3D19764C4224003CC836476E2F48590F00D11D6E2021AF6380DFAD1A18204E546F3947CD2DCF9CF1F528DBC2E808ACE2090B5E1725E5C173C3A84C3C5EA940A35A165FF2DBA43225CD8A89F9FFED5BD9FB4175535872C767BF85DA2F004C90652538430E4A6367B16DE6309 X-C1DE0DAB: 0D63561A33F958A5B12939427F442419BC4AA9332DC70C3C3768244C0DDDEF18F87CCE6106E1FC07E67D4AC08A07B9B08ED1AC82D843A2BB9C5DF10A05D560A950611B66E3DA6D700B0A020F03D25A0997E3FB2386030E77 X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF77DD89D51EBB7742D3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CF287110665CFF178705C48F6756AD5953B9D0D9F17C9B01C03A0D8314E9571826E5920CFB4BEC2A83E78510D816E477F34540D319297477D648E83BAA978C198DA74DFFEFA5DC0E7F02C26D483E81D6BE5EF9655DD6DEA7D65774BB76CC95456EEC5B5AD62611EEC62B5AFB4261A09AF0 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojI4eqBx/cvLmK9kKsCN8pow== X-Mailru-Sender: 11C2EC085EDE56FAC07928AF2646A76933CEF502E54AD1309A56B77121CA92A6BDDB26EEA8DAF3A6DEDBA653FF35249392D99EB8CC7091A70E183A470755BFD208F19895AA18418972D6B4FCE48DF648AE208404248635DF X-Mras: Ok Subject: [Tarantool-patches] [PATCH luajit] Respect jit.off() on pending trace exit. 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 Thanks to Sergey Kaplun. (cherry-picked from commit 7dbe545933485849977d50384f2f20f2cccf0cf9) Before this commit, the JIT engine didn't check the status of JIT flags when compiling the side trace. Hence, after calling `jit.off()` the side traces are still recorded. This patch adds the aforementioned check. Sergey Kaplun: * added the description and the test for the problem Part of tarantool/tarantool#9595 --- Branch: https://github.com/tarantool/luajit/tree/skaplun/lj-1134-hotside-jit-off Tarantool PR: https://github.com/tarantool/tarantool/pull/9607 Related issues: * https://github.com/tarantool/tarantool/issues/9595 * https://github.com/LuaJIT/LuaJIT/issues/1134 src/lj_trace.c | 2 +- .../lj-1134-hotside-jit-off.test.lua | 44 +++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 test/tarantool-tests/lj-1134-hotside-jit-off.test.lua diff --git a/src/lj_trace.c b/src/lj_trace.c index 236e06a0..20014ecb 100644 --- a/src/lj_trace.c +++ b/src/lj_trace.c @@ -917,7 +917,7 @@ int LJ_FASTCALL lj_trace_exit(jit_State *J, void *exptr) } else if (G(L)->gc.state == GCSatomic || G(L)->gc.state == GCSfinalize) { if (!(G(L)->hookmask & HOOK_GC)) lj_gc_step(L); /* Exited because of GC: drive GC forward. */ - } else { + } else if ((J->flags & JIT_F_ON)) { trace_hotside(J, pc); } if (bc_op(*pc) == BC_JLOOP) { diff --git a/test/tarantool-tests/lj-1134-hotside-jit-off.test.lua b/test/tarantool-tests/lj-1134-hotside-jit-off.test.lua new file mode 100644 index 00000000..cdee3eb2 --- /dev/null +++ b/test/tarantool-tests/lj-1134-hotside-jit-off.test.lua @@ -0,0 +1,44 @@ +local tap = require('tap') + +-- Test file to demonstrate the JIT misbehaviour, when the side +-- trace is compiled after `jit.off()`. +-- See also: https://github.com/LuaJIT/LuaJIT/issue/1134. + +local test = tap.test('lj-1134-hotside-jit-off'):skipcond({ + ['Test requires JIT enabled'] = not jit.status(), + ['Disabled on *BSD due to #4819'] = jit.os == 'BSD', +}) + +local traceinfo = require('jit.util').traceinfo + +test:plan(1) + +local take_side +local function trace() + -- luacheck: ignore + -- Branch for the side exit. + if take_side then end +end + +-- Flush all possible traces. +jit.flush() + +jit.opt.start('hotloop=1', 'hotexit=1') + +trace() +trace() + +assert(traceinfo(1), 'root trace not compiled') + +-- Force trace exit. +take_side = true + +jit.off() + +-- Attempt to compile a side trace. +trace() +trace() + +test:ok(not traceinfo(2), 'no side trace compiled') + +test:done(true) -- 2.43.0