Sergey Kaplun:
* added the description and the test for the problem
Part of tarantool/tarantool#8825
---
src/lj_record.c | 8 ++------
.../lj-1024-varg-maxslot.test.lua | 19 ++++++++++++++++++-
2 files changed, 20 insertions(+), 7 deletions(-)
diff --git a/src/lj_record.c b/src/lj_record.c
index 112524d3..02d9db9e 100644
--- a/src/lj_record.c
+++ b/src/lj_record.c
@@ -1775,12 +1775,8 @@ static void rec_varg(jit_State *J, BCReg dst, ptrdiff_t nresults)
if (J->framedepth > 0) { /* Simple case: varargs defined on-trace. */
ptrdiff_t i;
if (nvararg < 0) nvararg = 0;
- if (nresults == -1) {
- nresults = nvararg;
- J->maxslot = dst + (BCReg)nvararg;
- } else if (dst + nresults > J->maxslot) {
- J->maxslot = dst + (BCReg)nresults;
- }
+ if (nresults == -1) nresults = nvararg;
+ J->maxslot = dst + (BCReg)nresults;
for (i = 0; i < nresults; i++)
J->base[dst+i] = i < nvararg ? getslot(J, i - nvararg - 1 - LJ_FR2) : TREF_NIL;
} else { /* Unknown number of varargs passed to trace. */
diff --git a/test/tarantool-tests/lj-1024-varg-maxslot.test.lua b/test/tarantool-tests/lj-1024-varg-maxslot.test.lua
index 14270595..f8d74e8a 100644
--- a/test/tarantool-tests/lj-1024-varg-maxslot.test.lua
+++ b/test/tarantool-tests/lj-1024-varg-maxslot.test.lua
@@ -3,7 +3,7 @@ local test = tap.test('lj-noticket-varg-usedef'):skipcond({
['Test requires JIT enabled'] = not jit.status(),
})
-test:plan(1)
+test:plan(2)
jit.opt.start('hotloop=1')
@@ -20,4 +20,21 @@ end
test:ok(true, 'BC_VARG recording 0th frame depth')
+-- Now the same case, but with additional frame, so VARG slots