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 C4AD34F54D9; Tue, 4 Jul 2023 13:42:59 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org C4AD34F54D9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1688467379; bh=wUR5KeeBSjRLjNK5FPE69oOg4kAE6qlcPX406djugOs=; 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=EQp4IJ0GQuFla+gHglpdCKRQFWbVUoLxkc92Z2lnNqaWvoCG8X6PBA476VZFhR/lQ yVbAaGOKl+cogsKtIUWuyBJ/ResbslSQgfyzyZP/bFuKwoQgTa3XlT0XFQHzrbfAIE 6y6SQraXEqK6/Df3ys2uN1wKl+ScEo0IxAhEdVEw= Received: from smtp41.i.mail.ru (smtp41.i.mail.ru [95.163.41.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 6D3431FA901 for ; Tue, 4 Jul 2023 13:42:58 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 6D3431FA901 Received: by smtp41.i.mail.ru with esmtpa (envelope-from ) id 1qGdUn-001bGf-CX; Tue, 04 Jul 2023 13:42:57 +0300 Date: Tue, 4 Jul 2023 10:34:08 +0000 To: Sergey Kaplun Message-ID: References: <2e92221ec1d4e8222be8cbd89b4d0e047bc9b795.1686299850.git.skaplun@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <2e92221ec1d4e8222be8cbd89b4d0e047bc9b795.1686299850.git.skaplun@tarantool.org> X-Clacks-Overhead: GNU Terry Pratchett X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD986A068CB942B50D51E4DDBF8CA4B940EF663857ADB9FD1C4182A05F5380850401F5F88B518AC64BA3CC75DDD78A1BE6267F9D27CAE0FBC54E87FDDD449B8AEC9 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE727FD6E7FC3A8F857EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006372094AD700861FA748638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D88629141C37F4DDC49395B0ADA24098EF117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC974A882099E279BDA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F44604297287769387670735200AC5B80A05675ACDCB629EEF1311BF91D2E47CDBA5A96583BA9C0B312567BB2376E601842F6C81A19E625A9149C048EE902A1BE408319B292D242C3BD2E3F4C64AD6D5ED66289B52698AB9A7B718F8C46E0066C2D8992A16725E5C173C3A84C392AF71FE74A2456CBA3038C0950A5D36B5C8C57E37DE458B330BD67F2E7D9AF16D1867E19FE14079C09775C1D3CA48CF3D321E7403792E342EB15956EA79C166A417C69337E82CC275ECD9A6C639B01B78DA827A17800CE7B2B7C64F398C7410731C566533BA786AA5CC5B56E945C8DA X-C1DE0DAB: 0D63561A33F958A5E891A810A6D1D665D0D8F5E0C3C8733C6315C6DE1284EEF7F87CCE6106E1FC07E67D4AC08A07B9B0CE135D2742255B35CB5012B2E24CD356 X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF3FED46C3ACD6F73ED3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CF11E81B58DD4FECEE2001202AD15EF6F20B7004823C3CDFB2FC1B32A4184E0B4FAFE07996864E0BE209C04BAA40F94CC302452AF81CB3628949B071804860CD7AA74DFFEFA5DC0E7F02C26D483E81D6BEECAEF3E2CCC1ED8C383653B6C8D9AE0FD16FCAA6493B703A X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojtu6fghEd2rWZByMvQAwnCQ== X-Mailru-Sender: 2FEBA92C8E508479FE7B9A1DF348D531DE73DD27419A29A0B0C79A187456851EB932D4DCBEE97EA02326FE6F2A341ACE0FB9F97486540B4CD9E8847AB8CFED4D9ABF8A61C016C2CFB0DAF586E7D11B3E67EA787935ED9F1B X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit 1/2] Fix use-def analysis for BC_VARG. 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: Igor Munkin via Tarantool-patches Reply-To: Igor Munkin Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Sergey, Thanks for the patch! LGTM, considering the fixes made to resolve the comments left by Max. On 09.06.23, Sergey Kaplun via Tarantool-patches wrote: > From: Mike Pall > > Reported by Ryan Lucia. > > (cherry-picked from commit 2801500a26084491ae035170cad4700513790890) > > Use-def analizis for BC_VARG has to strong limit for the top/maxslot, so > no slots may considered as used. This leads to addititional SLOAD on Side note: s/addititional/additional/. I've already fixed this. > trace with incorrect value used later. This patch disables the use-def > analisis for BC_VARG as NIY. Side note: s/NIY/NYI/. I've already fixed this. > > Sergey Kaplun: > * added the description and the test for the problem > > Part of tarantool/tarantool#8516 > Relates to tarantool/tarantool#8718 > --- > src/lj_snap.c | 4 +- > .../lj-704-bc-varg-use-def.test.lua | 65 +++++++++++++++++++ > 2 files changed, 68 insertions(+), 1 deletion(-) > create mode 100644 test/tarantool-tests/lj-704-bc-varg-use-def.test.lua > > diff --git a/test/tarantool-tests/lj-704-bc-varg-use-def.test.lua b/test/tarantool-tests/lj-704-bc-varg-use-def.test.lua > new file mode 100644 > index 00000000..c3ba65dd > --- /dev/null > +++ b/test/tarantool-tests/lj-704-bc-varg-use-def.test.lua > @@ -0,0 +1,65 @@ > +local tap = require('tap') > +-- Test file to demonstrate LuaJIT misbehaviour in use-def > +-- snapshot analysis for BC_VARG. > +-- See also https://github.com/LuaJIT/LuaJIT/issues/704. > +local test = tap.test('lj-704-bc-varg-use-def'):skipcond({ > + ['Test requires JIT enabled'] = not jit.status(), > +}) > + > +test:plan(1) > + > +-- XXX: we don't really need to store this builtins, but this is > +-- reduces `jitdump()` output for reader significantly. > +local fmod = math.fmod > +local pcall = pcall > + > +-- Use the 2 values for `fmod()` to produce non-zero value for > +-- the call on trace (the last one call). > +local ARG_ON_RECORDING = 6 > +local ON_TRACE_VALUE = ARG_ON_RECORDING + 1 > + > +-- The `jitdump()` output was like the following before the patch: > +-- 0003 > num SLOAD #1 T > +-- .... SNAP #1 [`wrap()`|---- pcall|`varg()`|----] > +-- 0004 } tab TNEW #3 #0 > +-- 0005 > num SLOAD #4 T > +-- 0006 p32 FLOAD 0004 tab.array > +-- 0007 p32 AREF 0006 +1 > +-- 0008 } num ASTORE 0007 0005 > +-- .... SNAP #2 [`wrap()`|---- pcall|math.fmod|+6 0005] > +-- > +-- The first snapshot misses the 0003 IR in the last slot to be > +-- used in the `fmod()` later, so it leads to the additional > +-- 0005 SLOAD #4, and storing it in the second snapshot. > +-- > +-- The correct snapshot content after the patch is the following: > +-- .... SNAP #1 [`wrap()`|---- pcall|`varg()`|0003] > +-- .... > +-- .... SNAP #2 [`wrap()`|---- pcall|math.fmod|+6 0003] > +local function varg(...) > + -- Generate snapshot after `pcall()` with missing slot. > + -- The snapshot is generated before each TNEW after the commit > + -- 7505e78bd6c24cac6e93f5163675021734801b65 ("Handle on-trace > + -- OOM errors from helper functions.") > + local slot = ({...})[1] > + -- Forcify stitch and usage of vararg slot. > + return fmod(ARG_ON_RECORDING, slot) > +end > + > +jit.opt.start('hotloop=1') > + > +local _, result > +local function wrap(arg) > + -- `pcall()` is needed to emit snapshot to handle on-trace > + -- errors. > + _, result = pcall(varg, arg) > +end > +-- Record trace with the 0 result. > +wrap(ARG_ON_RECORDING) > +wrap(ARG_ON_RECORDING) > +-- Record trace with the non-zero result. > +wrap(ON_TRACE_VALUE) > + > +test:ok(result ~= 0, 'use-def analysis for BC_VARG') > + > +os.exit(test:check() and 0 or 1) > -- > 2.34.1 > -- Best regards, IM