Tarantool development patches archive
 help / color / mirror / Atom feed
* [Tarantool-patches] [PATCH luajit] Fix handling of instable types in TNEW/TDUP load forwarding.
@ 2023-08-29  9:54 Sergey Kaplun via Tarantool-patches
  2023-08-30 10:37 ` Maxim Kokryashkin via Tarantool-patches
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Sergey Kaplun via Tarantool-patches @ 2023-08-29  9:54 UTC (permalink / raw)
  To: Maxim Kokryashkin, Sergey Bronnikov; +Cc: tarantool-patches

From: Mike Pall <mike>

Analyzed by Sergey Kaplun.

(cherry-picked from commit 9f452bbef5031afc506d8615f5e720c45acd6fdf)

This is a follow-up for the commit
a9d183b2be63fd91be4b8c9494c213c56c491092 ("Fix TNEW load forwarding with
instable types."). It fixes a similar issue, but for TDUP load
forwarding.

Sergey Kaplun:
* added the description and the test for the problem

Part of tarantool/tarantool#8825
---

Branch: https://github.com/tarantool/luajit/tree/skaplun/lj-994-load-fwd-instable-types-tdup
Tarantool PR: https://github.com/tarantool/tarantool/pull/9053
Related issues:
* https://github.com/LuaJIT/LuaJIT/issues/994
* https://github.com/tarantool/tarantool/issues/8825

 src/lj_opt_mem.c                                          | 4 ++--
 .../lj-994-instable-types-during-loop-unroll.test.lua     | 8 +-------
 2 files changed, 3 insertions(+), 9 deletions(-)

diff --git a/src/lj_opt_mem.c b/src/lj_opt_mem.c
index 59fddbdd..3c58d342 100644
--- a/src/lj_opt_mem.c
+++ b/src/lj_opt_mem.c
@@ -194,8 +194,8 @@ static TRef fwd_ahload(jit_State *J, IRRef xref)
 	if (key->o == IR_KSLOT) key = IR(key->op1);
 	lj_ir_kvalue(J->L, &keyv, key);
 	tv = lj_tab_get(J->L, ir_ktab(IR(ir->op1)), &keyv);
-	lj_assertJ(itype2irt(tv) == irt_type(fins->t),
-		   "mismatched type in constant table");
+	if (itype2irt(tv) != irt_type(fins->t))
+	  return 0;  /* Type instability in loop-carried dependency. */
 	if (irt_isnum(fins->t))
 	  return lj_ir_knum_u64(J, tv->u64);
 	else if (LJ_DUALNUM && irt_isint(fins->t))
diff --git a/test/tarantool-tests/lj-994-instable-types-during-loop-unroll.test.lua b/test/tarantool-tests/lj-994-instable-types-during-loop-unroll.test.lua
index 730b0e61..6e2cf5ed 100644
--- a/test/tarantool-tests/lj-994-instable-types-during-loop-unroll.test.lua
+++ b/test/tarantool-tests/lj-994-instable-types-during-loop-unroll.test.lua
@@ -10,7 +10,7 @@ local test = tap.test('lj-994-instable-types-during-loop-unroll'):skipcond({
 
 -- TODO: test that compiled traces don't always exit by the type
 -- guard. See also the comment for the TDUP test chunk.
-test:plan(1)
+test:plan(2)
 
 -- TNEW.
 local result
@@ -34,11 +34,6 @@ end
 test:is(result, nil, 'TNEW load forwarding was successful')
 
 -- TDUP.
---[[
--- FIXME: Disable test case for now. Enable, with another
--- backported commit with a fix for the aforementioned issue
--- (and after patch "Improve assertions.").
--- Test taken trace exits too.
 for _ = 1, 5 do
   local t = slot
   -- Now use constant key slot to get necessary branch.
@@ -48,6 +43,5 @@ for _ = 1, 5 do
   slot = _ % 2 ~= 0 and stored_tab or {true}
 end
 test:is(result, true, 'TDUP load forwarding was successful')
-]]
 
 test:done(true)
-- 
2.42.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2023-09-27 12:55 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-08-29  9:54 [Tarantool-patches] [PATCH luajit] Fix handling of instable types in TNEW/TDUP load forwarding Sergey Kaplun via Tarantool-patches
2023-08-30 10:37 ` Maxim Kokryashkin via Tarantool-patches
2023-09-15  7:28 ` Sergey Bronnikov via Tarantool-patches
2023-09-15 13:20   ` Sergey Kaplun via Tarantool-patches
2023-09-16 17:35     ` Sergey Bronnikov via Tarantool-patches
2023-09-27 12:33 ` Igor Munkin via Tarantool-patches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox