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 0658798B11A; Tue, 23 Jan 2024 16:18:48 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 0658798B11A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1706015928; bh=4YricivyDIZ+BYtfENEp4AuudCKPCnA4VLzcDGbVqow=; h=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=gpcgwUciCaayvZorOgrKaNkN4auYMFj+t5TNf+2Wb7vErXXmCKu9Ih5PGKQFnQPxm 2guvmTQ2VsuWzc39PSA91MEsv4Bd/r8VP8eF7rk660Wxg4s0XbYS6sb6UmyiO1+rLo KmTLnb8HhBNp7JLb+20WcE4ADPXEIkWL5d7Gvvi0= Received: from smtp29.i.mail.ru (smtp29.i.mail.ru [95.163.41.68]) (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 36D4298B11A for ; Tue, 23 Jan 2024 16:18:47 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 36D4298B11A Received: by smtp29.i.mail.ru with esmtpa (envelope-from ) id 1rSGfu-000RBX-0v; Tue, 23 Jan 2024 16:18:46 +0300 Date: Tue, 23 Jan 2024 16:14:32 +0300 To: Sergey Bronnikov Message-ID: References: <20240122093234.14407-1-skaplun@tarantool.org> <793b7d4e-7d5f-4f77-bb82-c4496a94702a@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <793b7d4e-7d5f-4f77-bb82-c4496a94702a@tarantool.org> X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD936B5060B5AFFD5314FC64B4F3DF4614E040740DF0A7BE107182A05F5380850409D1CEE2839532003AF22447DE59427471DAEB9944A0B7A60665B349708D3DB02 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE71B5FCE2AF2D0EAB4EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637B2BC59D094D41B978638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8C2013A4D344A50D9F33446959FCF54BC117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCF80095D1E77F4578A471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352026055571C92BF10FBDFBBEFFF4125B51D2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269176DF2183F8FC7C088D2E8BEBF93D4B068655334FD4449CB9ECD01F8117BC8BEAAAE862A0553A39223F8577A6DFFEA7C8BDE37D78FCB031643847C11F186F3C59DAA53EE0834AAEE X-C1DE0DAB: 0D63561A33F958A5648C4E8922006395377EE761A778753E21659CD763E40EC6F87CCE6106E1FC07E67D4AC08A07B9B017119E5299B287EECB5012B2E24CD356 X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF3FED46C3ACD6F73ED3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CFBB4F874806C1D93293F849179E38804CD380F0351EAA02C2969587A6E39F5BE4A2F8A0A94712AD9D4BEAD515961AA0A75809BA289AAC01ED2F4074F24ADAE5A7E48CAC7CA610320002C26D483E81D6BE5EF9655DD6DEA7D65774BB76CC95456EEC5B5AD62611EEC62B5AFB4261A09AF0 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojGSQVxX8i/5WdUk4ccZM/Cw== X-DA7885C5: 14578E3DDA2654B7A42E2B591EA0C21D28721252513CE45E817B03F8F597D6C1262E2D401490A4A0DB037EFA58388B346E8BC1A9835FDE71 X-Mailru-Sender: 689FA8AB762F7393590D8C940224AE330C3C07080849DEF04E1ED066AED9E2650FBE9A32752B8C9C2AA642CC12EC09F1FB559BB5D741EB962F61BD320559CF1EFD657A8799238ED55FEEDEB644C299C0ED14614B50AE0675 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 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" Hi, Sergey! Thanks for the review! On 23.01.24, Sergey Bronnikov wrote: > 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. Added the following comment. Branch is force-pushed. =================================================================== diff --git a/test/tarantool-tests/lj-1134-hotside-jit-off.test.lua b/test/tarantool-tests/lj-1134-hotside-jit-off.test.lua index cdee3eb2..080b1e87 100644 --- a/test/tarantool-tests/lj-1134-hotside-jit-off.test.lua +++ b/test/tarantool-tests/lj-1134-hotside-jit-off.test.lua @@ -9,6 +9,7 @@ local test = tap.test('lj-1134-hotside-jit-off'):skipcond({ ['Disabled on *BSD due to #4819'] = jit.os == 'BSD', }) +-- `traceinfo()` takes the trace number as an argument. local traceinfo = require('jit.util').traceinfo test:plan(1) =================================================================== > > > + > > +-- 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) -- Best regards, Sergey Kaplun