[Tarantool-patches] [PATCH luajit v4 2/3] Don't compile math.modf() anymore.
Maxim Kokryashkin
max.kokryashkin at gmail.com
Wed Mar 30 02:48:55 MSK 2022
From: Mike Pall <mike>
This commit disables compilation for the `math.modf` function since it's
rarely used and properly compiling it would be difficult.
Part of tarantool/tarantool#6163
---
src/lib_math.c | 2 +-
src/lj_ffrecord.c | 16 -------------
.../gh-6163-jit-min-max.test.lua | 23 +++++++++++++++----
3 files changed, 20 insertions(+), 21 deletions(-)
diff --git a/src/lib_math.c b/src/lib_math.c
index ef9dda2d..4e6d2458 100644
--- a/src/lib_math.c
+++ b/src/lib_math.c
@@ -45,7 +45,7 @@ LJLIB_ASM_(math_sinh) LJLIB_REC(math_htrig IRCALL_sinh)
LJLIB_ASM_(math_cosh) LJLIB_REC(math_htrig IRCALL_cosh)
LJLIB_ASM_(math_tanh) LJLIB_REC(math_htrig IRCALL_tanh)
LJLIB_ASM_(math_frexp)
-LJLIB_ASM_(math_modf) LJLIB_REC(.)
+LJLIB_ASM_(math_modf)
LJLIB_ASM(math_log) LJLIB_REC(math_log)
{
diff --git a/src/lj_ffrecord.c b/src/lj_ffrecord.c
index be890a93..ac9c9ba1 100644
--- a/src/lj_ffrecord.c
+++ b/src/lj_ffrecord.c
@@ -601,22 +601,6 @@ static void LJ_FASTCALL recff_math_htrig(jit_State *J, RecordFFData *rd)
J->base[0] = emitir(IRTN(IR_CALLN), tr, rd->data);
}
-static void LJ_FASTCALL recff_math_modf(jit_State *J, RecordFFData *rd)
-{
- TRef tr = J->base[0];
- if (tref_isinteger(tr)) {
- J->base[0] = tr;
- J->base[1] = lj_ir_kint(J, 0);
- } else {
- TRef trt;
- tr = lj_ir_tonum(J, tr);
- trt = emitir(IRTN(IR_FPMATH), tr, IRFPM_TRUNC);
- J->base[0] = trt;
- J->base[1] = emitir(IRTN(IR_SUB), tr, trt);
- }
- rd->nres = 2;
-}
-
static void LJ_FASTCALL recff_math_pow(jit_State *J, RecordFFData *rd)
{
J->base[0] = lj_opt_narrow_pow(J, J->base[0], J->base[1],
diff --git a/test/tarantool-tests/gh-6163-jit-min-max.test.lua b/test/tarantool-tests/gh-6163-jit-min-max.test.lua
index d6eb3f3b..4594b968 100644
--- a/test/tarantool-tests/gh-6163-jit-min-max.test.lua
+++ b/test/tarantool-tests/gh-6163-jit-min-max.test.lua
@@ -1,12 +1,12 @@
local tap = require('tap')
+local jutil = require('jit.util')
jit.off()
jit.flush()
local test = tap.test("gh-6163-jit-min-max")
-test:plan(2)
---
--- gh-6163: math.min/math.max success with no args
---
+test:plan(6)
+
+-- `math.min`/`math.max` success with no args.
local pcall = pcall
jit.opt.start(0, 'hotloop=1')
@@ -17,4 +17,19 @@ test:ok(false == r)
r, _ = pcall(function() math.min() end)
test:ok(false == r)
+jit.off()
+jit.flush()
+jit.on()
+
+-- `math.modf` shouldn't be compiled.
+for _ = 1, 3 do math.modf(5.32) end
+
+local tr1_info = jutil.traceinfo(1)
+local tr2_info = jutil.traceinfo(2)
+
+test:ok(tr1_info ~= nil)
+test:ok(tr2_info ~= nil)
+test:ok(tr1_info.link == 2)
+test:ok(tr1_info.linktype == "stitch")
+
os.exit(test:check() and 0 or 1)
--
2.35.1
More information about the Tarantool-patches
mailing list