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 8A4852D8DA9; Thu, 2 Mar 2023 08:56:33 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 8A4852D8DA9 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1677736593; bh=QzpH+4SRV7xUX6XySiSz7dxKB0XnOY6u3Wg4LgqTS1k=; 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=ArL7zNqAr0PhJ+WYEtV1udjC9CSkN3Thgged/yOke/SmPM3qzCTjpboXWreyWYA0y LLuAF4r+eVkqvxNyqfcStaA7XQWcuVqVg+nlEH1+xcQ70s8KM8xKAZD72O25RPJlmw sKjEX/ZfMSLmoYcfFkkbaAetVV8TG+MVRr9bFwQI= Received: from smtpng1.i.mail.ru (smtpng1.i.mail.ru [94.100.181.251]) (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 1F38521667F for ; Thu, 2 Mar 2023 08:56:32 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 1F38521667F Received: by smtpng1.m.smailru.net with esmtpa (envelope-from ) id 1pXbvb-0003f6-B9; Thu, 02 Mar 2023 08:56:31 +0300 Date: Thu, 2 Mar 2023 08:52:53 +0300 To: Maxim Kokryashkin Message-ID: References: <20230125185758.5760-1-skaplun@tarantool.org> <1677577946.223837963@f341.i.mail.ru> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1677577946.223837963@f341.i.mail.ru> X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD9CCAB0EF48C080D704427C8952F856E31028E7E76E0E46E6B182A05F538085040D3667CEBE48707A5F8CCD2B442F6F7E86C343ED4CAED5C117EC8101F56141DA2 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7548C33FFD72831AFEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637F78F3D6E0D6791938638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D846E807594FDD5963D6E7D8C925A359AF117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCD6672DD12D5A8206A471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F44604297287769387670735204B6963042765DA4B618001F51B5FD3F9D2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B6B1CFA6D474D4A6A4089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34FF70CCB59A6ED87089941753E6FCF25C0DEA256C2B5022882AE0317225B43B96449AD970EC56289E1D7E09C32AA3244C8D446331403173171738A9E16B0AD30E5595C85A795C7BAEFACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojpNlqDWxrEBa4cnrljnClLA== X-DA7885C5: F24C4802E9C68748626D39CC872246DAEF6E7F4FF8010E68096FB2E77F06566D262E2D401490A4A0DB037EFA58388B346E8BC1A9835FDE71 X-Mailru-Sender: 689FA8AB762F73933AF1F914F131DBF5FDBC211D43F614BA7910C66503EAD9BC0FBE9A32752B8C9C2AA642CC12EC09F1FB559BB5D741EB962F61BD320559CF1EFD657A8799238ED55FEEDEB644C299C0ED14614B50AE0675 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit] ARM64: Fix {AHUV}LOAD specialized to nil/false/true. 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, Maxim! Thanks for the review! I've fixed your comments and force-pushed the branch. On 28.02.23, Maxim Kokryashkin wrote: > > Hi, Sergey! > Thanks for the patch! > LGTM, except for a few nits below. >   > >  > >>From: Mike Pall > >> > >>Reported by caohongqing. > >> > >>(cherry picked from commit 5bf0da3d7c02f9959fa3a9fb721e0565137b70c8) > >> > >>If there is high register pressure, and there are almost all registers > >>in use during the aforementioned assembling, the same register is chosen > >>as the one holding the given stack slot and the one holding the constant > >>value for the type comparison. As the result we get the following > >>assertion guard check in assembly: > >>| cmp x0, x0, lsr #32 > >>| bne ->0 > >>Which is always false. > >> > >>This happens because the `tmp` register (used for loading constant type > >>to compare in assertion guard) is scratched from `gpr` register set, but > >>not from `allow` set, which is used during picking the register for slot > >>loading (at the begging `allow` and `gpr` sets are the same). Fixed typo: s/begging/beginning/ > >> > >>This patch changes `allow` set to `gpr` to fix the issue. > >> > >>Sergey Kaplun: > >>* added the description and the test for the problem > >> > >>Part of tarantool/tarantool#8069 > >>--- > >>+ local upvalue = true > >>+ local function uload() > >>+ return upvalue > >>+ end > >>+ -- Make upvalue muttable. Not really need to return this > >Typo: s/muttable/mutable/ Fixed, thanks! > >>+ -- function. > >>+ local function _() > >>+ upvalue = not upvalue > >>+ end > >>+ _G.uload = uload > >>+end > >>+ > >>+-- This function generate code like the following: > >Typo: s/generate/generates/ Fixed, thanks! > >>+-- | local test_f(...) > >>+-- | local r > >>+-- | local rup1 > >>+-- | --[[...]] > >>+-- | for _ = 1, 4 do > >>+-- | r1 = ffi.cast("int", 1) > >>+-- | --[[...]] > >>+-- | r = main_payload() > >>+-- | rup1 = r1 > >>+-- | --[[...]] > >>+-- | end > >>+-- | end > >>+-- | return test_f > >>+-- Those `rn` variables before and after `main_payload` are > >>+-- required to generate enough register pressure (for GPR). Amount > >>+-- of repeats is empirical. > >>+-- Additional `test_f(...)` wrapper is needed for IR_VLOAD usage, > >>+-- when `main_payload` is just `...`. > >>+local function generate_payload(n_fillers, main_payload) > >>+ local code_chunk = 'local function test_f(...)\n' > >>+ code_chunk = code_chunk .. 'local r\n' > >>+ for i = 1, n_fillers do > >>+ code_chunk = code_chunk .. ('local rup%d\n'):format(i) > >>+ end > >>+ code_chunk = code_chunk .. 'for _ = 1, 4 do\n' > >>+ for i = 1, n_fillers do > >>+ code_chunk = code_chunk .. > >>+ ('local r%d = ffi.cast("int", %d)\n'):format(i, i) > >>+ end > >>+ code_chunk = code_chunk .. 'r = ' .. main_payload .. '\n' > >>+ for i = 1, n_fillers do > >>+ code_chunk = code_chunk .. ('rup%d = r%d\n'):format(i, i) > >>+ end > >>+ code_chunk = code_chunk .. 'end\nend\n' > >>+ code_chunk = code_chunk .. 'return test_f' > >>+ local f, err = loadstring(code_chunk, 'test_function') > >>+ assert(type(f) == 'function', err) > >>+ f = f() > >>+ assert(type(f) == 'function', 'returned generated value is not a function') > >>+ return f > >>+end > >That section is really hard to read, is there any way to make it more > >readable? I believe even slight reformatting might help. I've add the additional empty lines to separate cycle's body generation. Does it help? | local function generate_payload(n_fillers, main_payload) | local code_chunk = 'local function test_f(...)\n' | code_chunk = code_chunk .. 'local r\n' | for i = 1, n_fillers do | code_chunk = code_chunk .. ('local rup%d\n'):format(i) | end | | code_chunk = code_chunk .. 'for _ = 1, 4 do\n' | for i = 1, n_fillers do | code_chunk = code_chunk .. | ('local r%d = ffi.cast("int", %d)\n'):format(i, i) | end | code_chunk = code_chunk .. 'r = ' .. main_payload .. '\n' | for i = 1, n_fillers do | code_chunk = code_chunk .. ('rup%d = r%d\n'):format(i, i) | end | | code_chunk = code_chunk .. 'end\nend\n' | code_chunk = code_chunk .. 'return test_f' | | local f, err = loadstring(code_chunk, 'test_function') | assert(type(f) == 'function', err) | f = f() | assert(type(f) == 'function', 'returned generated value is not a function') | return f | end > >>+ > >>+-- Disable sink optimization to allocate more registers in a > >>+-- "convenient" way. 'hotexit' option is required to be sure that > >>+-- we will start a new trace on false-positive guard assertion. > >Typo: s/on false-positive/on a false-positive/ Fixed. > >>+-- The new trace contains the same IR and so the same assertion > >>+-- guard. This trace will be executed, assertion guard failed > >>+-- again and the new third trace will be recorded. This trace will > >Typo: s/assertion guard failed again/the assertion guard will fail again/ Fixed. Thanks! > >>+-- be the last one to record as far as iterations over cycle are > >>+-- finished and we returning from the function. The report of > >Typo: s/we returning/we are returning/ Fixed, thanks! > >>+-- `jit.dump` before the patch is the following: > >>2.34.1 > >-- > >Best regards, > >Maxim Kokryashkin -- Best regards, Sergey Kaplun