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 BEBF5B9630; Tue, 22 Nov 2022 07:40:09 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org BEBF5B9630 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1669092009; bh=dFCpgGSWG/jR1HuXpkX01VOUQjrnTGTw7+TsD2Gnuf4=; 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=usOS3ZhVs9hAFJdV4ZG3fSwFwZOr2rzD+sTuuMwDbZE0748Tf6HNHrF2jjYZ125hD 5G/epGvHODNlEsQYEwiks80M6cGAyX0y/gcSFCuYop1606qUTWkD4h8WWglsoP3g7S zhSTbJwlX5ZEglKPruglfcHboaUngBtQ1c/Y7aqo= Received: from smtp35.i.mail.ru (smtp35.i.mail.ru [95.163.41.76]) (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 B7DCA70306 for ; Tue, 22 Nov 2022 07:40:07 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org B7DCA70306 Received: by smtp35.i.mail.ru with esmtpa (envelope-from ) id 1oxL4o-00ASR1-KJ; Tue, 22 Nov 2022 07:40:07 +0300 Date: Tue, 22 Nov 2022 07:36:58 +0300 To: Igor Munkin Message-ID: References: <20220704093344.13522-1-skaplun@tarantool.org> <813CA8F4-3B19-4370-A859-12B956ACCF3C@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: EEAE043A70213CC8 X-77F55803: 4F1203BC0FB41BD9F46D048B1114D280BE60F1A9848D4646E7282263C687AD8A1313CFAB8367EF908E2BE116634AD74D54D704C230F46A5BDE6FCC81FEA51F30C9BE4878426C1A1928006A18B89A766F X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE701173C01F417A2A6EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006372E9841F416E2DCCD8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8F25AFD78EA81ECEB6EFE7EF94A7F2DA5117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC63AF70AF8205D7DCA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F44604297287769387670735204B6963042765DA4B6FD1C55BDD38FC3FD2E47CDBA5A96583BA9C0B312567BB2376E601842F6C81A19E625A9149C048EED76C6ED7039589DE03CEA74F0D118906D8FC6C240DEA7642DBF02ECDB25306B2B78CF848AE20165D0A6AB1C7CE11FEE367F1C1C3ABB44F3A03F1AB874ED89028C4224003CC836476E2F48590F00D11D6E2021AF6380DFAD1A18204E546F3947CB11811A4A51E3B096D1867E19FE1407959CC434672EE6371089D37D7C0E48F6C8AA50765F79006373AFABB501D265F08EFF80C71ABB335746BA297DBC24807EABDAD6C7F3747799A X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34E420FF71F2F0FE038CEC5E28BA6853599FEFE01BA0A55C5B17BC00E1340504F7D87C2DDDD8465E371D7E09C32AA3244CA8316CD953361606E2E65545C998F1ADB4DF56057A86259FFACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2bioj9fQGWaup21oC9VzDJC/JoA== X-Mailru-Sender: F6248FDC0389C51188CF133EE5DC084F54D704C230F46A5BDE6FCC81FEA51F30B7CBEF92542CD7C88B0A2698F12F5C9EC77752E0C033A69E86920BD37369036789A8C6A0E60D2BB63A5DB60FBEB33A8A0DA7A0AF5A3A8387 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit] x86/x64: Check for jcc when using xor r, r in emit_loadi(). 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, Igor! Thanks for the review! I've updated the commit message and the comment in the test considering your proposal. On 11.11.22, Igor Munkin wrote: > Sergos, > > On 06.07.22, sergos wrote: > > Hi! > > > > Thanks for the patch! > > > > > > > 3) the comparison operation to perform a fused load, which in > > > turn needs to allocate a register, and for there to be no > > > free registers at that moment, and for the register chosen > > > for sacrifice to be holding the constant zero. > > > > > Unfortunately, it’s not clear what this register (I suppose it’s r14d) is used for. > > Is it an argument, needed after the fall-through in the same trace? > > Why not it sank down below the branch? > > IIRC it is a dedicated register used for dispatch, so why is it used for sacrificing? > > Like many things in LuaJIT register allocation is "state-of-the-art" (or > as I called this "ad-hoc") entity. Since it's implemented as a linear > scan RA working in a reverse direction of the trace being recorded, > register is "allocated" for IR slot being used as a source and "freed" > at the moment it becomes a destination. > > To describe the process Sergey fit in a three-bullet list above, we have > the following. > 0) IR for either "internal" (e.g. type check, hmask check) or "external" > (e.g. branch or loop condition) guard is begin emitted to mcode. > 1) JCC to side exit is emitted to the trace mcode at the beginning. > 2) Condition (i.e. comparison) is going to be emitted. > 3) Fuse optimization takes its place, that ought to allocate a register > for the load base. > 4) There is no free registers at this point. > 5) The one storing the constant zero is chosen to be sacrificed and > reallocated (consider allocation cost in ra_alloc for constant > materialization). > 6) Before (or in the sense of trace execution, after) register is > being used in the aforementioned comparison, register (r14 in our > case) is reset by XOR emitted right after (before) jump instruction. > 7) The comparison with fused load within is emitted. > > As a result flags set by comparison are reset by XOR emitted in between > of condition and jump instructions. > Updated branch with force-push. > > > > -- > > > 2.34.1 > > > > > > > -- > Best regards, > IM -- Best regards, Sergey Kaplun