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 B2A7F6DDCEE; Tue, 23 Jan 2024 11:33:44 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org B2A7F6DDCEE DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1705998824; bh=d8mj/zfaHCYLgOlPdjpx2xpNbpiSoO5D8mkoZ6V3Nk0=; h=Date:To:Cc:References:In-Reply-To:Subject:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=SFaiFqheEA+IdizUihbzXAOyxrdCTkVAA5fVU42EWLvCBCpnzYpGoESPznGVTfL1v 7X8qs0sMOwJYeVORO68pTy88p05JNNHeMPRK6ig9orEDeVSGZ/p22TxvlN+oVYA1x9 8Tuxt7usOGmciAKPHgghoWL/V4ha+AV44iJFOSG0= Received: from smtp44.i.mail.ru (smtp44.i.mail.ru [95.163.41.82]) (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 9932B6DDCEE for ; Tue, 23 Jan 2024 11:33:43 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 9932B6DDCEE Received: by smtp44.i.mail.ru with esmtpa (envelope-from ) id 1rSCE2-00ERxy-0i; Tue, 23 Jan 2024 11:33:42 +0300 Message-ID: <793b7d4e-7d5f-4f77-bb82-c4496a94702a@tarantool.org> Date: Tue, 23 Jan 2024 11:33:41 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Content-Language: en-US To: Sergey Kaplun , Maxim Kokryashkin Cc: tarantool-patches@dev.tarantool.org References: <20240122093234.14407-1-skaplun@tarantool.org> In-Reply-To: <20240122093234.14407-1-skaplun@tarantool.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: EEAE043A70213CC8 X-77F55803: 4F1203BC0FB41BD9C4CE30293DC5317395D6394F36AD8F79D705B8024BA04EFB1313CFAB8367EF908E2BE116634AD74D40DD538E63BFEE59DD971DF3BC50B0E245A9A3B28F481888E47927CA7C9EF7A9 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE72D1683D4B1F6A6B5EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637F7C2A16C2A438FE58638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8CC6A9418D5CA20DB79841ABFDBF5E49A117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC05EF1B56D39DD5F7389733CBF5DBD5E9C8A9BA7A39EFB766F5D81C698A659EA7CC7F00164DA146DA9985D098DBDEAEC8A7DFDF579AB090EFF6B57BC7E6449061A352F6E88A58FB86F5D81C698A659EA73AA81AA40904B5D9A18204E546F3947C2A336C6518635091040F9FF01DFDA4A84AD6D5ED66289B523666184CF4C3C14F6136E347CC761E07725E5C173C3A84C31E0E32024825AD8BBA3038C0950A5D36B5C8C57E37DE458B330BD67F2E7D9AF16D1867E19FE14079C09775C1D3CA48CFED8438A78DFE0A9E1DD303D21008E298D5E8D9A59859A8B6957A4DEDD2346B4275ECD9A6C639B01B78DA827A17800CE73349F3DFB73D9B11731C566533BA786AA5CC5B56E945C8DA X-C1DE0DAB: 0D63561A33F958A59584B9687D42AAE2C37C087F816DBF3F0BABD00E7652D4A8F87CCE6106E1FC07E67D4AC08A07B9B0E753FA5741D1AD02CB5012B2E24CD356 X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF3FED46C3ACD6F73ED3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CF32E8EAF00BF3836B7440A6ECBD4755312070B1605CFD8DBD4902B20F969F2AF4E781F4E203C570784BEAD515961AA0A7C0E99743A9AF688670A63DA024389154E48CAC7CA610320002C26D483E81D6BE0DBAE6F56676BC7117BB6831D7356A2DEC5B5AD62611EEC62B5AFB4261A09AF0 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojI4eqBx/cvLnjqHhV9xeH7A== X-Mailru-Sender: C4F68CFF4024C8867DFDF7C7F25884581EDE475554AE9C865A41F7FE8EA4EF5C612F98C44B16847B282EC151BADDC1D3523A6D01B4765B2DFB59E2DDD9FE06B14FA522850F29BC30B0DAF586E7D11B3E67EA787935ED9F1B X-Mras: Ok Subject: Re: [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 Bronnikov via Tarantool-patches Reply-To: Sergey Bronnikov Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Hi, Sergey! thanks for the patch! LGTM with a minor comment below Sergey On 1/22/24 12:32, Sergey Kaplun wrote: > 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') It is not clear what "1" means (here and below). As I got it right, it is a trace number. I would left a comment about magic number or replace constant with variable with self-explained name. > + > +-- 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)