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 672BA1270B39; Mon, 10 Mar 2025 17:53:11 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 672BA1270B39 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1741618391; bh=XQCVUZzP0TulF/nIEBkNJis9xXS4I7foUBiqO6V52vs=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=a3h0o7fcMBH1phAnk3CxEluT4WY8yGwBc6sOQS+eWrpq+ks/l16Hci1FwrCuKI/7Y LkU63vhwMDNjgofSsHrSv9O4ONEHciLOq/mQq4KYZbuW5jzFfdeCil9B0RumHtLUUs T8GvYyQgNvQ5YNcISYSSGqbsWcmq4v49ElVWm5Oo= Received: from send175.i.mail.ru (send175.i.mail.ru [95.163.59.14]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 6FFE41270B26 for ; Mon, 10 Mar 2025 17:51:41 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 6FFE41270B26 Received: by exim-smtp-8cb569c79-b7mkz with esmtpa (envelope-from ) id 1treTk-00000000Jsz-1Qi0; Mon, 10 Mar 2025 17:51:40 +0300 To: Sergey Bronnikov Date: Mon, 10 Mar 2025 17:51:37 +0300 Message-ID: <47c0d447e3d2a49da2678bf065da1a55eae0e9c3.1741617766.git.skaplun@tarantool.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Mailru-Src: smtp X-4EC0790: 10 X-7564579A: 646B95376F6C166E X-77F55803: 4F1203BC0FB41BD9C6CD12EFD8DA450F38EB582EE72372401632BB7A6644D88900894C459B0CD1B9B885516EDD230FC88E7FD94675F33565551F00E05E4623B553C58652A57A77A2785316FF18B29525 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE78E88BD1CA827EF00C2099A533E45F2D0395957E7521B51C2CFCAF695D4D8E9FCEA1F7E6F0F101C6759CC434672EE6371C2A783ECEC0211ADC4224003CC836476D5A39DEEDB180909611E41BBFE2FEB2BBC775407FE1DC1C390D503CAE7B48B1CD6E0139F5B474DBC2E83FB5BA76AF2E69FA2833FD35BB23D9E625A9149C048EE26055571C92BF10FBDFBBEFFF4125B51D2E47CDBA5A96583BD4B6F7A4D31EC0BC014FD901B82EE079FA2833FD35BB23D27C277FBC8AE2E8B9FC99A4BA45EE8B4A471835C12D1D977C4224003CC836476EB9C4185024447017B076A6E789B0E975F5C1EE8F4F765FCEF742F6D71EE79753AA81AA40904B5D9CF19DD082D7633A0C84D3B47A649675F3AA81AA40904B5D98AA50765F7900637191B356738496CF3D81D268191BDAD3D3666184CF4C3C14F3FC91FA280E0CE3D1A620F70A64A45A98AA50765F79006372E808ACE2090B5E1725E5C173C3A84C3C5EA940A35A165FF2DBA43225CD8A89F83C798A30B85E16B42539A7722CA490CB5C8C57E37DE458BEDA766A37F9254B7 X-C1DE0DAB: 0D63561A33F958A5408D4BB5BC26D4345002B1117B3ED6969E312BD6BE5F63FF4869453249F34FA4823CB91A9FED034534781492E4B8EEAD3B90412627F530F9A71A35648BE338CE9510FB958DCE06DB58C12E6D310A6D535E67E669B6712FCC X-C8649E89: 1C3962B70DF3F0ADE00A9FD3E00BEEDF3FED46C3ACD6F73ED3581295AF09D3DF87807E0823442EA2ED31085941D9CD0AF7F820E7B07EA4CFA32BF637367835E82E5CE4E3E8825487DB2726F67572C095FA30D9A92273266E1F5011C79ABBA8E7F13513DA892F5B9D2363FAC4C6CD6E33DAD5AB2F782112773E982D8BCFADF5645F4332CA8FE04980913E6812662D5F2A5EAB5682573093F7837F15F2B5E4A70B33F2C28C22F508233FCF178C6DD14203 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu53w8ahmwBjZKM/YPHZyZHvz5uv+WouB9+ObcCpyrx6l7KImUglyhkEat/+ysWwi0gdhEs0JGjl6ggRWTy1haxBpVdbIX1nthFXMZebaIdHP2ghjoIc/363UZI6Kf1ptIMVQiWK+2I7Y2sdgh5SAGV9Gw= X-Mailru-Sender: 520A125C2F17F0B1A9638AD358559B59B4FA883DE94A3D743DE06ABAFEAF6705A0EB3B475635EDF3B7CBEF92542CD7C88B0A2698F12F5C9EC77752E0C033A69E86920BD37369036789A8C6A0E60D2BB63A5DB60FBEB33A8A0DA7A0AF5A3A8387 X-Mras: Ok Subject: [Tarantool-patches] [PATCH luajit 3/3] Fix state restore when recording __concat metamethod. 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" From: Mike Pall Reported by Sergey Kaplun. (cherry picked from commit eee16efa77b542e99c8e546a3d52fc023925c7bc) This commit is a follow-up to the previous one. It fixes the case when the `topslot` is adjusting for simple concatenation results. This patch adds the update of the corresponding Lua stack slots to be restored. This fixes back the test. Sergey Kaplun: * added the description and the test for the problem Part of tarantool/tarantool#11055 --- src/lj_record.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/lj_record.c b/src/lj_record.c index 7a481a51..92cf55e4 100644 --- a/src/lj_record.c +++ b/src/lj_record.c @@ -1942,6 +1942,7 @@ static TRef rec_tnew(jit_State *J, uint32_t ah) /* -- Concatenation ------------------------------------------------------- */ typedef struct RecCatDataCP { + TValue savetv[5+LJ_FR2]; jit_State *J; BCReg baseslot, topslot; TRef tr; @@ -1982,7 +1983,9 @@ static TValue *rec_mm_concat_cp(lua_State *L, lua_CFunction dummy, void *ud) return NULL; } /* Pass partial result. */ - topslot = J->maxslot--; + rcd->topslot = topslot = J->maxslot--; + /* Save updated range of slots. */ + memcpy(rcd->savetv, &L->base[topslot-1], sizeof(rcd->savetv)); *xbase = tr; top = xbase; setstrV(J->L, &ix.keyv, &J2G(J)->strempty); /* Simulate string result. */ @@ -2002,16 +2005,18 @@ static TRef rec_cat(jit_State *J, BCReg baseslot, BCReg topslot) { lua_State *L = J->L; ptrdiff_t delta = L->top - L->base; - TValue savetv[5+LJ_FR2], errobj; + TValue errobj; RecCatDataCP rcd; int errcode; rcd.J = J; rcd.baseslot = baseslot; rcd.topslot = topslot; - memcpy(savetv, &L->base[topslot-1], sizeof(savetv)); /* Save slots. */ + /* Save slots. */ + memcpy(rcd.savetv, &L->base[topslot-1], sizeof(rcd.savetv)); errcode = lj_vm_cpcall(L, NULL, &rcd, rec_mm_concat_cp); if (errcode) copyTV(L, &errobj, L->top-1); - memcpy(&L->base[topslot-1], savetv, sizeof(savetv)); /* Restore slots. */ + /* Restore slots. */ + memcpy(&L->base[rcd.topslot-1], rcd.savetv, sizeof(rcd.savetv)); if (errcode) { L->top = L->base + delta; copyTV(L, L->top++, &errobj); -- 2.48.1