Tarantool development patches archive
 help / color / mirror / Atom feed
* [tarantool-patches] [PATCH] luajit: fold machinery misbehaves
@ 2019-07-25 12:05 sergos
  0 siblings, 0 replies; 2+ messages in thread
From: sergos @ 2019-07-25 12:05 UTC (permalink / raw)
  To: tarantool-patches

 This is a temporary solution for
 https://github.com/LuaJIT/LuaJIT/issues/505

 Follow-up: #4376
---
 src/lj_opt_fold.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/src/lj_opt_fold.c b/src/lj_opt_fold.c
index acbf36a..e326aff 100644
--- a/src/lj_opt_fold.c
+++ b/src/lj_opt_fold.c
@@ -505,6 +505,11 @@ LJFOLDF(kfold_strref_snew)
 {
   PHIBARRIER(fleft);
   if (irref_isk(fins->op2) && fright->i == 0) {
+    /*
+    ** Temporary stub for LuaJIT bug #505 https://github.com/LuaJIT/LuaJIT/issues/505
+    ** Follow-up tracker is #4376
+    */
+    return NEXTFOLD;
     return fleft->op1;  /* strref(snew(ptr, len), 0) ==> ptr */
   } else {
     /* Reassociate: strref(snew(strref(str, a), len), b) ==> strref(str, a+b) */
-- 
2.17.1

^ permalink raw reply	[flat|nested] 2+ messages in thread
* [tarantool-patches] [PATCH] luajit: fold machinery misbehaves
@ 2019-07-30 19:59 sergos
  0 siblings, 0 replies; 2+ messages in thread
From: sergos @ 2019-07-30 19:59 UTC (permalink / raw)
  To: tarantool-patches; +Cc: Sergey Ostanevich

From: Sergey Ostanevich <sergos@tarantool.org>

 This is a solution from the reference LuaJIT for
 https://github.com/LuaJIT/LuaJIT/issues/505
 Picking up ahead of reference repo since it's abandoned

 resolves: #4376

 available at: https://github.com/tarantool/luajit/tree/sergos/luajit-gh-505-folder-problems-v2

---
 src/lj_ffrecord.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/lj_ffrecord.c b/src/lj_ffrecord.c
index dfdee2d..632b8f2 100644
--- a/src/lj_ffrecord.c
+++ b/src/lj_ffrecord.c
@@ -949,8 +949,9 @@ static void LJ_FASTCALL recff_string_find(jit_State *J, RecordFFData *rd)
 		    str->len-(MSize)start, pat->len)) {
       TRef pos;
       emitir(IRTG(IR_NE, IRT_PGC), tr, trp0);
-      pos = emitir(IRTI(IR_SUB), tr, emitir(IRT(IR_STRREF, IRT_PGC), trstr, tr0));
-      J->base[0] = emitir(IRTI(IR_ADD), pos, lj_ir_kint(J, 1));
+      /* Caveat: can't use STRREF trstr 0 here because that might be pointing into a wrong string due to folding. */
+      pos = emitir(IRTI(IR_SUB), tr, trsptr);
+      J->base[0] = emitir(IRTI(IR_ADD), pos, emitir(IRTI(IR_ADD), trstart, lj_ir_kint(J, 1)));
       J->base[1] = emitir(IRTI(IR_ADD), pos, trplen);
       rd->nres = 2;
     } else {
-- 
2.17.1

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

end of thread, other threads:[~2019-07-30 20:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-25 12:05 [tarantool-patches] [PATCH] luajit: fold machinery misbehaves sergos
2019-07-30 19:59 sergos

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