Tarantool development patches archive
 help / color / mirror / Atom feed
From: Sergey Kaplun via Tarantool-patches <tarantool-patches@dev.tarantool.org>
To: Maxim Kokryashkin <m.kokryashkin@tarantool.org>,
	Sergey Bronnikov <sergeyb@tarantool.org>
Cc: tarantool-patches@dev.tarantool.org
Subject: [Tarantool-patches] [PATCH luajit 1/3] MIPS: Fix "bad FP FLOAD" assertion.
Date: Mon,  4 Sep 2023 18:50:24 +0300	[thread overview]
Message-ID: <8e1c4acd3c622a3f4b851fe999ef337422b9e351.1693840653.git.skaplun@tarantool.org> (raw)
In-Reply-To: <cover.1693840653.git.skaplun@tarantool.org>

From: Mike Pall <mike>

Reported by Sergey Kaplun.

(cherry-picked from commit 72efc42ef2258086a9cb797c676e2916b0a9e7e1)

This patch is the follow-up for the commit
786dbb2ebdde16eadd7464cd5cbeb5d95a5e46f0 ("Add IR_FLOAD with REF_NIL for
field loads from GG_State."). This commit allows `FLOAD` to be used for
fields loading from `GG_State`. Nevertheless, the aforementioned
assertion hasn't been moved to the `else` branch related to the default
use case. This leads to assertion failure in the case when `FLOAD` is
used for loading some field and has the `num` type.

This patch moves the assertion to the right place.

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

Part of tarantool/tarantool#8825
---
 src/lj_asm_mips.h                             |  2 +-
 .../lj-1043-asm-fload.test.lua                | 24 +++++++++++++++++++
 2 files changed, 25 insertions(+), 1 deletion(-)
 create mode 100644 test/tarantool-tests/lj-1043-asm-fload.test.lua

diff --git a/src/lj_asm_mips.h b/src/lj_asm_mips.h
index ea108aab..ac9090f2 100644
--- a/src/lj_asm_mips.h
+++ b/src/lj_asm_mips.h
@@ -1285,8 +1285,8 @@ static void asm_fload(ASMState *as, IRIns *ir)
       }
     }
     ofs = field_ofs[ir->op2];
+    lj_assertA(!irt_isfp(ir->t), "bad FP FLOAD");
   }
-  lj_assertA(!irt_isfp(ir->t), "bad FP FLOAD");
   emit_tsi(as, mi, dest, idx, ofs);
 }
 
diff --git a/test/tarantool-tests/lj-1043-asm-fload.test.lua b/test/tarantool-tests/lj-1043-asm-fload.test.lua
new file mode 100644
index 00000000..2f381560
--- /dev/null
+++ b/test/tarantool-tests/lj-1043-asm-fload.test.lua
@@ -0,0 +1,24 @@
+local tap = require('tap')
+
+-- Test file to demonstrate LuaJIT's misbehaviour during the
+-- assembling of the `FLOAD` on MIPS.
+-- See also: https://github.com/LuaJIT/LuaJIT/issues/1043.
+local test = tap.test('lj-1043-asm-fload'):skipcond({
+  ['Test requires JIT enabled'] = not jit.status(),
+})
+
+test:plan(1)
+
+local math_abs = math.abs
+
+local results = {nil, nil, nil, nil}
+
+-- Disable optimizations to be sure that we assemble `FLOAD`.
+jit.opt.start(0, 'hotloop=1')
+for i = 1, 4 do
+  results[i] = math_abs(i - 10)
+end
+
+test:is_deeply(results, {9, 8, 7, 6}, 'correct assembling of the FLOAD')
+
+test:done(true)
-- 
2.42.0


  reply	other threads:[~2023-09-04 15:55 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-04 15:50 [Tarantool-patches] [PATCH luajit 0/3] Fix fix-mips64-spare-side-exit-patching Sergey Kaplun via Tarantool-patches
2023-09-04 15:50 ` Sergey Kaplun via Tarantool-patches [this message]
2023-09-05  7:05   ` [Tarantool-patches] [PATCH luajit 1/3] MIPS: Fix "bad FP FLOAD" assertion Maxim Kokryashkin via Tarantool-patches
2023-09-26 18:58   ` Igor Munkin via Tarantool-patches
2023-09-04 15:50 ` [Tarantool-patches] [PATCH luajit 2/3] test: fix `fillmcode()` generator helper Sergey Kaplun via Tarantool-patches
2023-09-05  7:06   ` Maxim Kokryashkin via Tarantool-patches
2023-09-26 18:58   ` Igor Munkin via Tarantool-patches
2023-09-04 15:50 ` [Tarantool-patches] [PATCH luajit 3/3] test: fix fix-mips64-spare-side-exit-patching Sergey Kaplun via Tarantool-patches
2023-09-05  8:56   ` Maxim Kokryashkin via Tarantool-patches
2023-09-05 11:16     ` Sergey Kaplun via Tarantool-patches
2023-09-26 18:59   ` Igor Munkin via Tarantool-patches
2023-09-27 12:33 ` [Tarantool-patches] [PATCH luajit 0/3] Fix fix-mips64-spare-side-exit-patching Igor Munkin via Tarantool-patches

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8e1c4acd3c622a3f4b851fe999ef337422b9e351.1693840653.git.skaplun@tarantool.org \
    --to=tarantool-patches@dev.tarantool.org \
    --cc=m.kokryashkin@tarantool.org \
    --cc=sergeyb@tarantool.org \
    --cc=skaplun@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH luajit 1/3] MIPS: Fix "bad FP FLOAD" assertion.' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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