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 09AD6170DA6; Thu, 15 Dec 2022 13:04:11 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 09AD6170DA6 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1671098651; bh=FQhtRsw3xeN029pudHOoZ5PDTtHwxuX38TQTXaQiv2Y=; 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=aX6EO/kfQfWVeqRMxSaINRJgSh71Jb1KVooTL7yCVgi4odfM4j2ZgqsSmM82dsiq4 BOt4gXIesWg8kFniPKXEU2tHG4sW/peTfLV//Vop+me3P+4XbOfjky6ZmuN2AubzGn RcmSY6SHOXlk66DGaasZvxPrTZ9U2f5xorhMrqyg= Received: from smtp44.i.mail.ru (smtp44.i.mail.ru [94.100.177.104]) (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 8CF88DF6C1 for ; Thu, 15 Dec 2022 13:04:09 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 8CF88DF6C1 Received: by smtp44.i.mail.ru with esmtpa (envelope-from ) id 1p5l60-0003WG-Kg; Thu, 15 Dec 2022 13:04:09 +0300 Date: Thu, 15 Dec 2022 13:00:51 +0300 To: Maxim Kokryashkin Message-ID: References: <20221208054618.9104-1-skaplun@tarantool.org> <1670845465.549831429@f510.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: <1670845465.549831429@f510.i.mail.ru> X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: 78E4E2B564C1792B X-77F55803: 4F1203BC0FB41BD90D1502B3BE350FE49EB3FFCDAEC0C69D7811E21CB1443C3A00894C459B0CD1B9EFFBFA3A44EB77251101013B83A2099258109A870B96F1EE77EA5CD51374AFCE X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7544B1CCE26E01C74EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637AC20F58FBAB79054EA1F7E6F0F101C6723150C8DA25C47586E58E00D9D99D84E1BDDB23E98D2D38B6F1F7B995052D5CEB212FE3E796DDC1BAED18A64C8851621CC7F00164DA146DAFE8445B8C89999728AA50765F7900637A359038F01FFAF82389733CBF5DBD5E9C8A9BA7A39EFB766F5D81C698A659EA7CC7F00164DA146DA9985D098DBDEAEC8F8BD4E506CFA3D88F6B57BC7E6449061A352F6E88A58FB86F5D81C698A659EA73AA81AA40904B5D9A18204E546F3947CD95D32202655EC45AD7EC71F1DB884274AD6D5ED66289B52698AB9A7B718F8C46E0066C2D8992A16725E5C173C3A84C387610DD87C265BFBBA3038C0950A5D36B5C8C57E37DE458B330BD67F2E7D9AF16D1867E19FE14079C09775C1D3CA48CF3D321E7403792E342EB15956EA79C166A417C69337E82CC275ECD9A6C639B01B78DA827A17800CE72F88032165008D51731C566533BA786AA5CC5B56E945C8DA X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D34047E322BFAFD69BD16A47ADB9803D63938257E1CCE734DCD1F6A68BF03AFA0E58C0D18B3F51808F51D7E09C32AA3244C0495A2D44AD41D6559C3CC374B62DAB77C0C08F7987826B9FACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2bioja/mV86HvUK+jtysGeDAKGQ== X-Mailru-Sender: F16D9CAFEEA6770E7B6EAD4ADB3BCAF0501ECF88CDF086DFEFF0D247ACF6D18BD374630430C8D43AF2400F607609286E924004A7DEC283833C7120B22964430C52B393F8C72A41A84198E0F3ECE9B5443453F38A29522196 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit] LJ_GC64: Fix ir_khash for non-string GCobj. 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! Fixed your comments, branch is force pushed. On 12.12.22, Maxim Kokryashkin wrote: > > Hi, Sergey! > Thanks for the patch! > LGTM, except for a few nits below. >   > >  > >>From: Mike Pall > >> > >>Contributed by Peter Cawley. > >> > >>(cherry picked from commit b4ed3219a1a98dd9fe7d1e3eeea3b82f5a780948) > >> > >>When emitting `IR_HREF` for constant value to lookup the `ir_khash()` > >Typo: s/for constant/for a constant > >>function is used to calculate hash for the corresponding object. > >Typo: s/hash/the hash > >>This calculation must be the same as in the corresponding `hashkey()` > >>function from . > >> > >>Hash calculating via passing two arguments `lo`, and `hi` to `hashrot()` > >Typo: s/calculating via/is calculated by > >>routine. For non-string GC objects the first `lo` argument is the same > >>for GC64 and not GC64 mode -- lower 32 bits of the object address. For > >>GC64 mode `hi` argument is upper 32 bits of the object address, > >>including specific type NaN-tag. This `hi` argument in `ir_khash()` > >>function is miscalculated in GC64 using non-GC64 value (`lo` + > >>`HASH_BIAS`). As a result, the hash for the GC object is miscalculated > >>on trace and we exit from trace due to assertion guard on the type or > >>value check. > >> > >>This patch fixes calculation of hash value on trace for GC64 mode by > >>making it consistent with `hashkey()`. > >Typo: s/of hash/of the hash Fixed. New commit message is: | LJ_GC64: Fix ir_khash for non-string GCobj. | | Contributed by Peter Cawley. | | (cherry picked from commit b4ed3219a1a98dd9fe7d1e3eeea3b82f5a780948) | | When emitting the `IR_HREF` for a constant value lookup the `ir_khash()` | function is used to calculate the hash for the corresponding object. | This calculation must be the same as in the corresponding `hashkey()` | function from . | | Hash is calculated by passing two arguments `lo`, and `hi` to the | `hashrot()` routine. For non-string GC objects the first `lo` argument | is the same for GC64 and not GC64 mode -- lower 32 bits of the object | address. For GC64 mode `hi` argument is upper 32 bits of the object | address, including a specific type NaN-tag. This `hi` argument in | `ir_khash()` function is miscalculated in GC64 mode using a non-GC64 | value (`lo` + `HASH_BIAS`). As a result, the hash for the GC object is | miscalculated on trace and we exit from the trace due to an assertion | guard on the type or value check. | | This patch fixes calculation of the hash value on trace for GC64 mode by | making it consistent with the `hashkey()`. | | Sergey Kaplun: | * added the description and the test for the problem | | Part of tarantool/tarantool#7230 > >> > >>Sergey Kaplun: > >>* added the description and the test for the problem > >> > >>Part of tarantool/tarantool#7230 > >>--- > >> > >>Branch: https://github.com/tarantool/luajit/tree/skaplun/lj-356-ir-khash-non-string-obj-full-ci > >>Issue/PR: > >>* https://github.com/tarantool/tarantool/issues/7230 > >>* https://github.com/LuaJIT/LuaJIT/pull/356 > >>Tarantool PR: https://github.com/tarantool/tarantool/pull/8020 > >> > >>Side note: Problems with red fuzzer jobs look irrelevant to the patch. > >>+ > >>+-- Prevent `get_const_cdata()` become hot and be compiled before > >>+-- the main test cycle. > >Typo: s/become hot and be/from becoming hot and being > >>+jit.off() > >>+ > >>+filled_tab[get_const_cdata()] = MAGIC > >>+ > >>+-- Speed up table filling-up. > >>+jit.on() > >>+ > >>+-- Filling-up the table with GC values to minimize the amount of > >>+-- hash collisions and increases delta between the start of the > >Typo: s/increases/increase > >>+-- hash part of the table and currently stored node. > >>+for i = 1, N_HASH_FI > >>-- Iterative patch with the fixes: =================================================================== diff --git a/test/tarantool-tests/lj-356-ir-khash-non-string-obj.test.lua b/test/tarantool-tests/lj-356-ir-khash-non-string-obj.test.lua index fff0b1a5..7f304183 100644 --- a/test/tarantool-tests/lj-356-ir-khash-non-string-obj.test.lua +++ b/test/tarantool-tests/lj-356-ir-khash-non-string-obj.test.lua @@ -3,7 +3,7 @@ local traceinfo = require('jit.util').traceinfo local table_new = require('table.new') -- Test file to demonstrate the incorrect GC64 JIT behaviour --- for `IR_HREF` for on-trace-constant key lookup. +-- of an `IR_HREF` for the on-trace-constant key lookup. -- See also https://github.com/LuaJIT/LuaJIT/pull/356. local test = tap.test('lj-356-ir-khash-non-string-obj') local N_ITERATIONS = 4 @@ -14,10 +14,10 @@ test:plan(N_ITERATIONS + 1) -- To reproduce the issue we need to compile a trace with -- `IR_HREF`, with a lookup of constant hash key GC value. To --- prevent `IR_HREFK` to be emitted instead, we need a table with --- a huge hash part. Delta of address between the start of the --- hash part of the table and the current node to lookup must be --- more than `(1024 * 64 - 1) * sizeof(Node)`. +-- prevent an `IR_HREFK` to be emitted instead, we need a table +-- with a huge hash part. Delta of address between the start of +-- the hash part of the table and the current node to lookup must +-- be more than `(1024 * 64 - 1) * sizeof(Node)`. -- See , for details. -- XXX: This constant is well suited to prevent test to be flaky, -- because the aforementioned delta is always large enough. @@ -36,8 +36,8 @@ end -- exiting the main test cycle. jit.opt.start('hotloop=1') --- Prevent `get_const_cdata()` become hot and be compiled before --- the main test cycle. +-- Prevent `get_const_cdata()` from becoming hot and being +-- compiled before the main test cycle. jit.off() filled_tab[get_const_cdata()] = MAGIC @@ -46,10 +46,10 @@ filled_tab[get_const_cdata()] = MAGIC jit.on() -- Filling-up the table with GC values to minimize the amount of --- hash collisions and increases delta between the start of the +-- hash collisions and increase delta between the start of the -- hash part of the table and currently stored node. -for i = 1, N_HASH_FIELDS do - filled_tab[1LL] = i +for _ = 1, N_HASH_FIELDS do + filled_tab[1LL] = 1 end -- Prevent JIT misbehaviour before the main test chunk. =================================================================== > >>2.34.1 > >-- > >Best regards, > >Maxim Kokryashkin > >  -- Best regards, Sergey Kaplun