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 9E4D76EC40; Tue, 17 Aug 2021 12:49:23 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 9E4D76EC40 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1629193763; bh=1MtXtBca2bcnhbCbSy1wtmgJaY09nGP9wzu5QDOrPlE=; 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=ka+NPeZskAQNDKrx+ihhkiTZfo75UjFY1Hf7x9KRZypm7fG8yr0hLrTsPmBYcpoP1 jBomHbAUW1ja8tzieTr0MIAH6VqyxJAybRGCVbGLpr9b4+jFz29xbKiUBxTvoammoI xSJso/do/q2deLls9vhSLmsoY6js66F828Qxw9ZI= 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 066E46EC40 for ; Tue, 17 Aug 2021 12:49:22 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 066E46EC40 Received: by smtpng1.m.smailru.net with esmtpa (envelope-from ) id 1mFvii-0004aQ-Sj; Tue, 17 Aug 2021 12:49:21 +0300 Date: Tue, 17 Aug 2021 12:24:11 +0300 To: Sergey Kaplun Message-ID: <20210817092410.GE5743@tarantool.org> References: <20210719073632.12008-1-skaplun@tarantool.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20210719073632.12008-1-skaplun@tarantool.org> X-Clacks-Overhead: GNU Terry Pratchett User-Agent: Mutt/1.10.1 (2018-07-13) X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD92087353F0EC44DD906AB4890CDABF0C5CB76CEE71D3E4007182A05F538085040FB8A7ABD23028D53A6DAFF9B47445C832353C65D0B282380C853FF4FEF5AE462 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7FEAC828D2BF6EC3CEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637AE01C1A20EF0A1348638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8FDA8F0E76F42AD4AF4DBF477BD4D0CCC117882F4460429724CE54428C33FAD305F5C1EE8F4F765FCAA867293B0326636D2E47CDBA5A96583BD4B6F7A4D31EC0BC014FD901B82EE079FA2833FD35BB23D27C277FBC8AE2E8B8C7ADC89C2F0B2A5A471835C12D1D977C4224003CC8364762BB6847A3DEAEFB0F43C7A68FF6260569E8FC8737B5C2249EC8D19AE6D49635B68655334FD4449CB9ECD01F8117BC8BEAAAE862A0553A39223F8577A6DFFEA7CE0F3BA37685B2B9043847C11F186F3C59DAA53EE0834AAEE X-C1DE0DAB: 0D63561A33F958A53E31A9AF289192703EC096861CF8AA7815B9CE0F093970D3D59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA7567C209D01CC1E34B410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D340297C696F996E3846763094E088F5999F1B65E6CE271E59E9A97B4973CBFCD3AF7E7705C441E5A0D1D7E09C32AA3244C1838F295820403D112075CE922DDC60A1E098CBE561D6343927AC6DF5659F194 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojIrFL/N5KnVGHNVSX7pOT5A== X-Mailru-Sender: 689FA8AB762F7393C37E3C1AEC41BA5D7E8F3BE48FDB8C281E6E61E12A77BAE0A7C8D0F45F857DBFE9F1EFEE2F478337FB559BB5D741EB964C8C2C849690F8E70A04DAD6CC59E33667EA787935ED9F1B X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit] Fix bytecode register allocation for comparisons. 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, I've checked the patch into all long-term branches in tarantool/luajit and bumped a new version in 1.10, 2.7, 2.8 and master. On 19.07.21, Sergey Kaplun wrote: > From: Mike Pall > > (cherry picked from commit 2f3f07882fb4ad9c64967d7088461b1ca0a25d3a) > > When LuaJIT is build with LJ_FR2 (GC64), information about frame takes > two slots -- the first takes the TValue with the function to call, the > second takes the additional frame information. The recording JIT > machinery works pretty the same -- the function IR_KGC is loaded in the > first slot, and the second is set to TREF_FRAME value. This value > should be rewritten after return from a callee. It is done either by the > return values either this slot is cleared (set to zero) manually with > the next bytecode with RA dst mode with the assumption, that the dst RA > takes the next slot after TREF_FRAME, i.e. an earlier instruction uses > the smallest possible destination register (see `lj_record_ins()` for > the details). > > Bytecode allocator swaps operands for ISGT and ISGE comparisons. > When it happens, the aforementioned rule for registers allocations > may be violated. When it happens, and this chunk is recording, the slot > with TREF_FRAME is not rewritten (but the next empty slot after > TREF_FRAME is) during bytecode recording. This leads to JIT slots > inconsistency and assertion failure in `rec_check_slots()` during > recording the next bytecode instruction. > > This patch fixes bytecode register allocation by changing the register > allocation order in case of ISGT and ISGE bytecodes. > > Sergey Kaplun: > * added the description and the test for the problem > > Resolves tarantool/tarantool#6227 > --- > > Branch: https://github.com/tarantool/luajit/tree/skaplun/gh-6227-fix-bytecode-allocator-for-comp > Tarantool branch: https://github.com/tarantool/tarantool/tree/skaplun/gh-6227-fix-bytecode-allocator-for-comp > Issue: https://github.com/tarantool/tarantool/issues/6227 > > src/lj_parse.c | 7 +++- > ...ytecode-allocator-for-comparisons.test.lua | 41 +++++++++++++++++++ > 2 files changed, 46 insertions(+), 2 deletions(-) > create mode 100644 test/tarantool-tests/gh-6227-bytecode-allocator-for-comparisons.test.lua > > -- > 2.31.0 > -- Best regards, IM