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 02D5D6ECC0; Thu, 14 Apr 2022 11:57:23 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 02D5D6ECC0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1649926643; bh=gG6rUN6bpYSjk/oRfFinf4OWmGqSD3J5cdEkBr3avxs=; 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=RenthlK2cCrHcQkZZmpGKFPp/5qqcEiCKNHK+mhbgSGf4RbAQj+YVwWzV+d1XyW3M ru/iyp6v8q383nReGhwFkL2rxbNOYQpglshr7Zv+nyP7r14jKEm3txGz2qaBru9yGt frg1GrDPtSgrhHRnD7VmFF6uSWg55flOS0dfnalg= 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 688176ECC0 for ; Thu, 14 Apr 2022 11:57:22 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 688176ECC0 Received: by smtpng1.m.smailru.net with esmtpa (envelope-from ) id 1nevI1-00069y-Ov; Thu, 14 Apr 2022 11:57:22 +0300 Date: Thu, 14 Apr 2022 11:55:11 +0300 To: Maxim Kokryashkin Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-4EC0790: 10 X-7564579A: EEAE043A70213CC8 X-77F55803: 4F1203BC0FB41BD95A798FEA17BE68F0750D514B51AA9BD144410212503178D9182A05F5380850404C228DA9ACA6FE2732F474FCB3C432F86BB18A409F9F40805C7422550AF67AD017A73C6AFAD11112 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7A20935EE237A17ECEA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006374C29A2D8B98EBF198638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8390CB875826D866F09F66A9A472949E6117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC2EE5AD8F952D28FBA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352033AC447995A7AD18C26CFBAC0749D213D2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B6A45692FFBBD75A6A089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-8FC586DF: 6EFBBC1D9D64D975 X-C1DE0DAB: 0D63561A33F958A5BBB5CEDECDF0AC3274A27E75A79504B7E7427928C882A5BBD59269BC5F550898D99A6476B3ADF6B47008B74DF8BB9EF7333BD3B22AA88B938A852937E12ACA7584C0BDCF4101A75D410CA545F18667F91A7EA1CDA0B5A7A0 X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D342E8FEDBD32DECB6DD8D4F3A072CF03C766E6720507ACEFB256626687E37C2FDD87CEB0A5674A338E1D7E09C32AA3244C89641BC485768C1E6545F06D684D22C560759606DA2E136AFACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojixb2kBKhBtqXuzugCAWLsA== X-Mailru-Sender: 689FA8AB762F739339CABD9B3CA9A7D661AC21513D79A8DD51A840BD63FB8A970FBE9A32752B8C9C2AA642CC12EC09F1FB559BB5D741EB962F61BD320559CF1EFD657A8799238ED55FEEDEB644C299C0ED14614B50AE0675 X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit v4 1/3] Fix math.min()/math.max() inconsistencies. 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 patch! Please, consider my comments below. On 30.03.22, Maxim Kokryashkin wrote: > From: Mike Pall > > math.min()/math.max() could produce different results when compiled. > Previously, these functions did not check for the number of arguments, Nit: Didn't check number of arguments for x86/x64 architecture. > which in some situations led to incorrect behavior. Nit: I suppose "in some situatitons" may be omitted (these situations is incorrect (i.e. 0 -- we can mention that) amount of arguments). > > Consider this example: > ``` > jit.opt.start(0, "hotloop=1") > > local r, msg = pcall(function () math.min() end) > r, msg = pcall(function () math.min() end) > ``` > Before this patch, this snippet of code completed successfully, although it > was not supposed to, since there were no args to math.min(). Nit: I suggest to drop this snippet as far as you allready describe the behaviour in such case. > > This patch adds check for the number of arguments for jit-compiled Does it? AFAICS, it only adds the corresponding check in the VM (ffunc->ffunc_1), so there is no incorrect recording as far as we always fall through to ff fallback. > version of math.min/max, and it also adds the corresponding test case for > the mentioned issue. We should mention about refactoring, too. I see the following parts: * removing several associative fold optimizations (we need to check logic of this optimization, and add the corresponding testcases) * changing fcc in asm_min_max CC_HI/CC_LO -> CC_PL/CC_PL (maybe you may investigate this and create a testcase showing "inconsistencies") > > Part of tarantool/tarantool#6163 I tried the reproducer mentioned in this ticket [1] and its passes with only this patch. So patches in this patchset may be merged separated (but in the same order). > Part of tarantool/tarantool#6548 > --- > src/lj_asm_arm.h | 6 +-- > src/lj_asm_arm64.h | 6 +-- > src/lj_opt_fold.c | 53 +++++++------------ > src/lj_vmmath.c | 4 +- > src/vm_arm.dasc | 4 +- > src/vm_arm64.dasc | 4 +- > src/vm_x64.dasc | 2 +- > src/vm_x86.dasc | 2 +- > .../gh-6163-jit-min-max.test.lua | 20 +++++++ > 9 files changed, 53 insertions(+), 48 deletions(-) > create mode 100644 test/tarantool-tests/gh-6163-jit-min-max.test.lua > > diff --git a/src/lj_asm_arm.h b/src/lj_asm_arm.h > diff --git a/src/lj_asm_arm64.h b/src/lj_asm_arm64.h > diff --git a/src/lj_opt_fold.c b/src/lj_opt_fold.c > diff --git a/src/vm_arm.dasc b/src/vm_arm.dasc > diff --git a/src/vm_arm64.dasc b/src/vm_arm64.dasc > diff --git a/src/vm_x64.dasc b/src/vm_x64.dasc > diff --git a/src/vm_x86.dasc b/src/vm_x86.dasc > diff --git a/test/tarantool-tests/gh-6163-jit-min-max.test.lua b/test/tarantool-tests/gh-6163-jit-min-max.test.lua > new file mode 100644 > index 00000000..d6eb3f3b > --- /dev/null > +++ b/test/tarantool-tests/gh-6163-jit-min-max.test.lua > @@ -0,0 +1,20 @@ I've checked your test on my branch without your patchset and it still passes: | $ ../../src/luajit gh-6163-jit-min-max.test.lua | TAP version 13 | 1..2 | ok - nil | ok - nil | $ make tarantool-tests | | /home/burii/builds_workspace/luajit/fix-slot-check-for-mm-record/test/tarantool-tests/gh-6163-jit-min-max.test.lua ......................... ok > +local tap = require('tap') > +jit.off() > +jit.flush() > + > +local test = tap.test("gh-6163-jit-min-max") Nit: Please, use one type of quotes: ''. > +test:plan(2) > +-- > +-- gh-6163: math.min/math.max success with no args > +-- > +local pcall = pcall > + > +jit.opt.start(0, 'hotloop=1') > +jit.on() > + > +local r, _ = pcall(function() math.min() end) > +test:ok(false == r) > +r, _ = pcall(function() math.min() end) > +test:ok(false == r) > + > +os.exit(test:check() and 0 or 1) [1]: https://github.com/tarantool/tarantool/issues/6163 -- Best regards, Sergey Kaplun