<!DOCTYPE html>
<html data-lt-installed="true">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body style="padding-bottom: 1px;">
<p>Hi, Sergey,</p>
<p>thanks for the patch! LGTM wit ha minor comment.</p>
<p>Sergey<br>
</p>
<div class="moz-cite-prefix">On 10.03.2025 17:51, Sergey Kaplun
wrote:<br>
</div>
<blockquote type="cite"
cite="mid:47c0d447e3d2a49da2678bf065da1a55eae0e9c3.1741617766.git.skaplun@tarantool.org">
<pre wrap="" class="moz-quote-pre">From: Mike Pall <mike>
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 <lj-839-concat-recording.test.lua> test.
Sergey Kaplun:
* added the description and the test for the problem</pre>
</blockquote>
<p>It is partially true actually :)</p>
<p>s/and the test//<br>
</p>
<blockquote type="cite"
cite="mid:47c0d447e3d2a49da2678bf065da1a55eae0e9c3.1741617766.git.skaplun@tarantool.org">
<pre wrap="" class="moz-quote-pre">
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);
</pre>
</blockquote>
</body>
<lt-container></lt-container>
</html>