current function being recorded.
Sergey Kaplun:
* added the description and the test for the problem
Part of tarantool/tarantool#8516
Relates to tarantool/tarantool#8718
---
src/lj_snap.c | 6 +++--
.../lj-704-bc-varg-use-def.test.lua | 27 ++++++++++++++++++-
2 files changed, 30 insertions(+), 3 deletions(-)
diff --git a/src/lj_snap.c b/src/lj_snap.c
index 5bbe8498..a063c316 100644
--- a/src/lj_snap.c
+++ b/src/lj_snap.c
@@ -301,8 +301,10 @@ static BCReg snap_usedef(jit_State *J, uint8_t *udf,
void lj_snap_purge(jit_State *J)
{
uint8_t udf[SNAP_USEDEF_SLOTS];
- BCReg maxslot = J->maxslot;
- BCReg s = snap_usedef(J, udf, J->pc, maxslot);
+ BCReg s, maxslot = J->maxslot;
+ if (bc_op(*J->pc) == BC_FUNCV && maxslot > J->pt->numparams)
+ maxslot = J->pt->numparams;
+ s = snap_usedef(J, udf, J->pc, maxslot);
for (; s < maxslot; s++)
if (udf[s] != 0)
J->base[s] = 0; /* Purge dead slots. */
diff --git a/test/tarantool-tests/lj-704-bc-varg-use-def.test.lua b/test/tarantool-tests/lj-704-bc-varg-use-def.test.lua
index c3ba65dd..38606686 100644
--- a/test/tarantool-tests/lj-704-bc-varg-use-def.test.lua
+++ b/test/tarantool-tests/lj-704-bc-varg-use-def.test.lua
@@ -6,7 +6,7 @@ local test = tap.test('lj-704-bc-varg-use-def'):skipcond({
['Test requires JIT enabled'] = not jit.status(),
})
-test:plan(1)
+test:plan(2)
-- XXX: we don't really need to store this builtins, but this is
-- reduces `jitdump()` output for reader significantly.
@@ -62,4 +62,29 @@ wrap(ON_TRACE_VALUE)
test:ok(result ~= 0, 'use-def analysis for BC_VARG')
+-- Now check the same case, but with BC_RET before the BC_VARG,
+-- so use-def analysis will take early return case.