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 F2F506EC58; Fri, 28 May 2021 15:06:28 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org F2F506EC58 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1622203589; bh=wWtJEhRbus2OvLECTYJORtuYq9HWjfwtIlks3JZGl/k=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=wQs0IF3uhqLfel393KxKi897ol9y8Hn+QGIZcKf92gN/pBDvRLEj1mUYV4FLpNsxY n5EuISTV95MXUUbdPOFUKO9rYT8nk3HVgX1muXlhsMt2Tyysyovepdluf+Vo3BbBT7 18JsrGiL8B4w63euNVIaKgbEv0CWU7iAvgZuU4kY= Received: from smtp52.i.mail.ru (smtp52.i.mail.ru [94.100.177.112]) (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 5CFBB6EC58 for ; Fri, 28 May 2021 15:06:27 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 5CFBB6EC58 Received: by smtp52.i.mail.ru with esmtpa (envelope-from ) id 1lmbFy-0008PL-FJ; Fri, 28 May 2021 15:06:26 +0300 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.60.0.2.21\)) Message-Id: <804A99A3-6D0C-4DA9-A939-26FFED0EC823@tarantool.org> Date: Fri, 28 May 2021 15:06:25 +0300 To: Igor Munkin , Sergey Kaplun , tarantool-patches@dev.tarantool.org X-Mailer: Apple Mail (2.3654.60.0.2.21) X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD9157EECD0FDB90B9A7712F917240E18A5E40D698B3575A0AC00894C459B0CD1B925FB75BC95DB095192DE108C92BD9B3D8882505E864E12CD10FFD2E5AA185B68 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE72C932D6B54DFB189EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006378BCFB34D7DDF138E8638F802B75D45FF36EB9D2243A4F8B5A6FCA7DBDB1FC311F39EFFDF887939037866D6147AF826D8911BC8FF7C0FAB4F04B46224F7A9DA38117882F4460429724CE54428C33FAD305F5C1EE8F4F765FC2EE5AD8F952D28FBA471835C12D1D9774AD6D5ED66289B52BA9C0B312567BB23117882F446042972877693876707352033AC447995A7AD18F04B652EEC242312D2E47CDBA5A96583BA9C0B312567BB231DD303D21008E29813377AFFFEAFD269A417C69337E82CC2E827F84554CEF50127C277FBC8AE2E8BA83251EDC214901ED5E8D9A59859A8B6AC294AFEFA671E80089D37D7C0E48F6C5571747095F342E88FB05168BE4CE3AF X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C414F749A5E30D975C7E9571940300E71A8B2960098A2E9DD19FF2853C164325EC9C2B6934AE262D3EE7EAB7254005DCEDFC729EA2B71BBBBE1E0A4E2319210D9B64D260DF9561598F01A9E91200F654B09D02A5090F3BCDFA8E8E86DC7131B365E7726E8460B7C23C X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D3498910055B812BD9C7623781BACD7D3015C0252A79806F504337B83C900B22D66D9E885AB205E1A1A1D7E09C32AA3244CA1B77C5D1465E12E82404D021C94147BB4DF56057A86259FFACE5A9C96DEB163 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2biojbL9S8ysBdXgIYs/4yLxGoi+A72vGSYaI X-Mailru-Sender: 3B9A0136629DC912F4AABCEFC589C81EF276F79E7797D0F345D51243EBC96030DA712353388E0A92AD07DD1419AC565FA614486B47F28B67C5E079CCF3B0523AED31B7EB2E253A9E112434F685709FCF0DA7A0AF5A3A8387 X-Mras: Ok Subject: [Tarantool-patches] [PATH luajit] GC64: fix 64-bit constant fusion 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 Ostanevich via Tarantool-patches Reply-To: Sergey Ostanevich Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Author: Mike Pall Date: Mon Aug 28 10:43:37 2017 +0200 x64/LJ_GC64: Fix fallback case of asm_fuseloadk64(). Contributed by Peter Cawley. (cherry picked from commit 6b0824852677cc12570c20a3211fbfe0e4f0ce14) Code generation under LJ_GC64 missed an update to the mcode area = after a 64bit constant encoding. This lead to a corruption to the constant later on. The problem is rather rare, since there should be big enough (4GiB) distance from the currently allocated mcode to the dispatch pointer. This lead to a number of flaky tests, trackers are addressed. Sergey Ostanevich: * added the description and the test for the problem Closes: #4095, #4199, #4614 Signed-off-by: Sergey Ostanevich diff --git a/src/lj_asm_x86.h b/src/lj_asm_x86.h index 767bf6f3..2850aea9 100644 --- a/src/lj_asm_x86.h +++ b/src/lj_asm_x86.h @@ -387,6 +387,7 @@ static Reg asm_fuseloadk64(ASMState *as, IRIns *ir) ir->i =3D (int32_t)(as->mctop - as->mcbot); as->mcbot +=3D 8; as->mclim =3D as->mcbot + MCLIM_REDZONE; + lj_mcode_commitbot(as->J, as->mcbot); } as->mrm.ofs =3D (int32_t)mcpofs(as, as->mctop - ir->i); as->mrm.base =3D RID_RIP; diff --git a/test/tarantool-tests/gh-4199-gc64-flaky.test.lua = b/test/tarantool-tests/gh-4199-gc64-flaky.test.lua new file mode 100644 index 00000000..3ac30427 --- /dev/null +++ b/test/tarantool-tests/gh-4199-gc64-flaky.test.lua @@ -0,0 +1,63 @@ +-- the test is GC64 only +local ffi=3Drequire('ffi') +require('utils').skipcond(not ffi.abi('gc64'), 'test is GC64 only') + +local tap =3D require("tap") +local test =3D tap.test("gh-4199-gc64-flaky") +test:plan(1) + +-- first - we have to make a gap from current JIT infra to next +-- available mappable memory +-- most efficient is to grab it per-page + + +ffi.cdef('void * mmap(void *start, size_t length, int prot , int flags, = int fd, long offset);') +ffi.cdef('long getpagesize();') + +local pagesize =3D tonumber(ffi.C.getpagesize()) +local blob =3D {} +for i=3D1, 4e9/pagesize do + blob[i] =3D ffi.C.mmap(ffi.cast('void*',0), pagesize, 0, 0x22, = 0, 0) + assert(blob[i] ~=3D 0) +end + +-- try to chomp all memory in currently allocated gc space +collectgarbage('stop') +local dummy=3D{'a'} +for i=3D2,30 do + dummy[i] =3D dummy[i - 1] .. dummy[i - 1] +end + +-- generate a bunch of functions and keep them stored to trigger wrong = constant placement + +local s=3D{} +local pass =3D true + +jit.opt.start('hotloop=3D1=E2=80=99) +for n=3D1,100 do + local src=3D'function f'.. n .. [[(x,y,z,f,g,h,j,k,r,c,d) + local a=3D{} + for i=3D1,1e6 do + a[i] =3D x + y + z + f + g + h + j + k + r + c = + d + if (x > 0) then a[i] =3D a[i] + 1.1 end + if (c > 0) then a[i] =3D a[i] + 2.2 end + if (z > 0) then a[i] =3D a[i] + 3.3 end + if (f > 0) then a[i] =3D a[i] + 4.4 end + x=3Dx+r + y=3Dy-c + z=3Dz+d + end + return a[1] + end + return f]] .. n ..'(...)' + + s[n] =3D assert(load(src)) + local res1 =3D s[n](1,2,3,4,5,6,7,8,9,10,11) + local res2 =3D s[n](1,2,3,4,5,6,7,8,9,10,11) + if (res1 ~=3D res2) then + pass =3D false + break + end +end + +test:ok(pass, 'wrong IR constant fuse')=