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 091816F3C8; Mon, 26 Sep 2022 00:37:34 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 091816F3C8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1664141854; bh=Jrg6dzQu7lJAgdADlHA93suFLsXRNFp/j5jEbkT9+fU=; h=Date:In-Reply-To:To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=PMy8VGaGYrAoAoJqDZoLwWtTlWK87C36OjYo05VHkKWwK2ZGIUy4ch09w+Ft3/O78 nZ97JQz2loV4FQCefC2wIpFcaLxmUG8khtqcz6X1eBtKMrS38OiLqum7Q5/QHSgyB2 6SCUXHzJS6NyX0zqdGjXqaz6a/m2HMQUIlGpwcIA= Received: from smtp35.i.mail.ru (smtp35.i.mail.ru [94.100.177.95]) (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 387FD6F3C8 for ; Mon, 26 Sep 2022 00:37:32 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 387FD6F3C8 Received: by smtp35.i.mail.ru with esmtpa (envelope-from ) id 1ocZJb-0005y1-IG; Mon, 26 Sep 2022 00:37:31 +0300 Message-Id: <304DA549-389D-468A-80F5-7424FF84FCF9@tarantool.org> Content-Type: multipart/alternative; boundary="Apple-Mail=_26921EE9-CDB6-4D09-AC45-E3611FBE0814" Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\)) Date: Mon, 26 Sep 2022 00:37:31 +0300 In-Reply-To: To: Sergey Kaplun References: <20220912080158.12220-1-skaplun@tarantool.org> <1663573807.727706952@f769.i.mail.ru> <8E2BF2B3-C6BA-4F3E-A9AE-DA8F8413C4AF@tarantool.org> <1663667902.185627333@f160.i.mail.ru> <7378A34A-6A2D-4634-B7A0-C9AA33267042@tarantool.org> X-Mailer: Apple Mail (2.3696.120.41.1.1) X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD99929F1169E77FC7AE856D1B1991916D586FE797DD987F61E182A05F5380850405DC2E00603301D132F016B974ED59129B015FD60D6EA52B2C2F54DAF21B64099 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE761966F250AC1AE21EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F7900637EA9DEEAA3ECF8E948638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D85E4226E5AB2BDFA389ED9A80D2F4C3C3117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC5F0C88D684269EDEA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352033AC447995A7AD182CC0D3CB04F14752D2E47CDBA5A96583BA9C0B312567BB2376E601842F6C81A19E625A9149C048EE4B6963042765DA4BA7B8E9D6D956BB52D8FC6C240DEA7642DBF02ECDB25306B2B78CF848AE20165D0A6AB1C7CE11FEE32A336C65186350916E0066C2D8992A16C4224003CC836476E2F48590F00D11D6E2021AF6380DFAD18AA50765F790063735872C767BF85DA227C277FBC8AE2E8B56969FF77163EA2B75ECD9A6C639B01B4E70A05D1297E1BBCB5012B2E24CD356 X-C1DE0DAB: 9604B64F49C60606AD91A466A1DEF99B296C473AB1E142185AC9E3593CE4B31AB1881A6453793CE9274300E5CE05BD4401A9E91200F654B0CBAED148C0C85B123C58F38EC06D55587ABD30CB6ECD95F82BAAE2D89213E90E9C2B6934AE262D3EE7EAB7254005DCED8DA55E71E02F9FC08E8E86DC7131B365E7726E8460B7C23C X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D348E5EF936B2E46EBA0B48158B0FC7AB5D4915678BCD12AB5511735A78F541642D6F4BD8110CFCD7D91D7E09C32AA3244CAD6E458C16CDB5AE5EE45D967D9141E530363D8B7DA7DD44FACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojMoF5vjNyHyJ91G4EWO5q4g== X-Mailru-Sender: 5AA3D5B9D8C486465A7E7C48E78B605D3D58434FFF7652F52F016B974ED591295AB84C596710711060D8632BEC246C7D55B4A2144138A8805FC805B5969CB4993EE16157CC7DAB4272D6B4FCE48DF648AE208404248635DF X-Mras: Ok Subject: Re: [Tarantool-patches] [PATCH luajit] FFI: Add tonumber() specialization for failed conversions. 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: sergos via Tarantool-patches Reply-To: sergos Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" --Apple-Mail=_26921EE9-CDB6-4D09-AC45-E3611FBE0814 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 Since we fallback to interpreter it looks safe to keep the test for = GC64. Still you=E2=80=99d better mention it in commit message. LGTM with above. Sergos > On 22 Sep 2022, at 14:28, Sergey Kaplun wrote: >=20 > Hi, Sergos! >=20 > On 21.09.22, sergos wrote: >> Hi! >>=20 >> I see four =E2=80=98ok=E2=80=99s as a result of run.=20 >> See the full output for the run with dump() below: >>=20 >>=20 >> = s.ostanevich@s-ostanevich2:~/workspaces/t.sergos/third_party/luajit/test/t= arantool-tests % ../../../../build-debug/src/tarantool -e = 'require"jit.dump".start("ib")' lj-408-tonumber-cdata-record.test.lua >>=20 >> TAP version 13 >> 1..4 >> ---- TRACE 1 start lj-408-tonumber-cdata-record.test.lua:17 >> 0001 GGET 1 0 ; "tonumber" >> 0002 MOV 3 0 >> 0003 CALL 1 2 2 >> 0000 . FUNCC ; tonumber >> 0004 RET1 1 2 >> ---- TRACE 1 IR >> 0001 fun SLOAD #0 R >> 0002 tab FLOAD 0001 func.env >> 0003 int FLOAD 0002 tab.hmask >> 0004 > int EQ 0003 +63=20 >> 0005 p64 FLOAD 0002 tab.node >> 0006 > p64 HREFK 0005 "tonumber" @8 >> 0007 > fun HLOAD 0006 >> 0008 > cdt SLOAD #2 T >> 0009 > fun EQ 0007 tonumber >> ---- TRACE 1 stop -> return >=20 > Gotcha! > It's a funny thing: > This is happening due to GC64 mode on x86_x64. >=20 > There is an invalid type check for SLOAD IR with the following emitted > mcode: >=20 > | 55557f6bffc9 mov rdi, [rdx+0x4] > | 55557f6bffcd sar rdi, 0x2f > | 55557f6bffd1 cmp edi, -0x0b > | 55557f6bffd4 jnz 0x55557f6b0010 ->0 >=20 > This 0x4 addiction is crucial: > We got the invalid irtype value to compare (due wrong addressing) -- = so > the assertion guard is always failed and we always exit from the = trace. > This is why we fallback into the interpreter and the test is passed. >=20 > In LuaJIT upstream this issue fixed via the following commit: > https://github.com/LuaJIT/LuaJIT/commit/05fbdf56 = >=20 > See also https://github.com/LuaJIT/LuaJIT/pull/350 = >=20 > >=20 >>=20 >=20 > --=20 > Best regards, > Sergey Kaplun --Apple-Mail=_26921EE9-CDB6-4D09-AC45-E3611FBE0814 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8
Since we fallback to interpreter it looks safe to keep the = test for GC64.
Still you=E2=80=99d better mention = it in commit message.

LGTM with above.

Sergos


On 22 = Sep 2022, at 14:28, Sergey Kaplun <skaplun@tarantool.org> wrote:

Hi, Sergos!

On 21.09.22, sergos wrote:
Hi!

I = see four =E2=80=98ok=E2=80=99s as a result of run. 
See the full = output for the run with dump() below:


s.ostanevich@s-ostanevich2:~/workspaces/t.sergos/third_party/lu= ajit/test/tarantool-tests % ../../../../build-debug/src/tarantool -e = 'require"jit.dump".start("ib")' lj-408-tonumber-cdata-record.test.lua

TAP version 13
1..4
---- TRACE 1 start = lj-408-tonumber-cdata-record.test.lua:17
0001  GGET =     1   0      ; = "tonumber"
0002  MOV      3 =   0
0003  CALL     1 =   2   2
0000  . FUNCC =             &n= bsp; ; tonumber
0004  RET1 =     1   2
---- TRACE 1 IR
0001    fun SLOAD  #0 =    R
0002    tab FLOAD =  0001  func.env
0003    int FLOAD =  0002  tab.hmask
0004 >  int EQ =     0003  +63 
0005 =    p64 FLOAD  0002  tab.node
0006 = >  p64 HREFK  0005  "tonumber" @8
0007 = >  fun HLOAD  0006
0008 >  cdt SLOAD =  #2    T
0009 >  fun EQ =     0007  tonumber
---- TRACE 1 = stop -> return

Gotcha!
It's a funny thing:
This is happening due to GC64 mode on x86_x64.

There is an = invalid type check for SLOAD IR with the following emitted
mcode:

| 55557f6bffc9  mov rdi, [rdx+0x4]
| = 55557f6bffcd  sar rdi, 0x2f
| 55557f6bffd1  cmp edi, -0x0b
| = 55557f6bffd4  jnz 0x55557f6b0010 =        ->0

This 0x4 = addiction is crucial:
We got the invalid irtype value to compare (due wrong = addressing) -- so
the assertion guard is always failed and we always exit from = the trace.
This is why = we fallback into the interpreter and the test is passed.

In LuaJIT = upstream this issue fixed via the following commit:
https://github.com/LuaJIT/LuaJIT/commit/05fbdf56

See also https://github.com/LuaJIT/LuaJIT/pull/350

<snipped>



-- 
Best = regards,
Sergey = Kaplun

= --Apple-Mail=_26921EE9-CDB6-4D09-AC45-E3611FBE0814--