[Tarantool-patches] [PATCH luajit] Fix string.char() recording with no arguments.
Sergey Kaplun
skaplun at tarantool.org
Fri Jan 28 15:49:40 MSK 2022
Igor,
On 28.01.22, Sergey Kaplun via Tarantool-patches wrote:
> Igor,
> Thanks for the review!
>
> On 28.01.22, Igor Munkin wrote:
> > Sergey,
> >
> > Thanks for the patch! Please consider my comments below.
> >
> > On 20.08.21, Sergey Kaplun wrote:
<snipped>
> >
> > Minor: Strictly saying, this is not quite true. The right description is
> > the following:
> > * 1 -- instruction becomes hot.
> > * 2 -- recording of the loop body.
> > * 3 -- required for trace finalization, but this iteration runs the
> > generated mcode. NB: the issue doesn't occur, since execution leaves
> > the trace on table resizing guard.
> > * 4 -- reproduces the issue.
> >
> > Hence, if you allocate the table with necessary size (3 in our case),
> > then only 3 iterations are needed. Please adjust the comment above and
> > the code below.
>
> Fixed, thanks!
>
> See the iterative patch below.
> Branch is force-pushed.
> ===================================================================
> diff --git a/test/tarantool-tests/gh-6371-string-char-no-arg.test.lua b/test/tarantool-tests/gh-6371-string-char-no-arg.test.lua
> index 6df93f07..61d02101 100644
> --- a/test/tarantool-tests/gh-6371-string-char-no-arg.test.lua
> +++ b/test/tarantool-tests/gh-6371-string-char-no-arg.test.lua
> @@ -6,11 +6,12 @@ local tap = require('tap')
>
> local test = tap.test('gh-6371-string-char-no-arg')
> -- XXX: Number of loop iterations.
> --- 1, 2 -- instruction becomes hot
> --- 3 -- trace is recorded (considering loop recording specifics),
> --- but bytecodes are still executed via VM
> --- 4 -- trace is executed, need to check that emitted mcode is
> --- correct
> +-- * 1 -- instruction becomes hot.
> +-- * 2 -- recording of the loop body.
> +-- * 3 -- required for trace finalization, but this iteration runs the
> +-- generated mcode. NB: the issue doesn't occur, since execution leaves
> +-- the trace on table resizing guard.
> +-- * 4 -- reproduces the issue.
> local NTEST = 4
> test:plan(NTEST)
>
> ===================================================================
Modified test for 3 iterations without side exit from trace.
===================================================================
diff --git a/test/tarantool-tests/gh-6371-string-char-no-arg.test.lua b/test/tarantool-tests/gh-6371-string-char-no-arg.test.lua
index 61d02101..93f0fbfb 100644
--- a/test/tarantool-tests/gh-6371-string-char-no-arg.test.lua
+++ b/test/tarantool-tests/gh-6371-string-char-no-arg.test.lua
@@ -8,15 +8,14 @@ local test = tap.test('gh-6371-string-char-no-arg')
-- XXX: Number of loop iterations.
-- * 1 -- instruction becomes hot.
-- * 2 -- recording of the loop body.
--- * 3 -- required for trace finalization, but this iteration runs the
--- generated mcode. NB: the issue doesn't occur, since execution leaves
--- the trace on table resizing guard.
--- * 4 -- reproduces the issue.
-local NTEST = 4
+-- * 3 -- reproduces the issue.
+local NTEST = 3
test:plan(NTEST)
-- Storage for the results to avoid trace aborting by `test:ok()`.
-local results = {}
+-- XXX: Use `table.new()` here to avoid side exit from trace by
+-- table resizing.
+local results = require('table.new')(3, 0)
jit.opt.start('hotloop=1')
for _ = 1, NTEST do
table.insert(results, string.char())
===================================================================
>
> >
<snipped>
> >
> > --
> > Best regards,
> > IM
>
> --
> Best regards,
> Sergey Kaplun
--
Best regards,
Sergey Kaplun
More information about the Tarantool-patches
mailing list