From: Sergey Kaplun via Tarantool-patches <tarantool-patches@dev.tarantool.org> To: Maxim Kokryashkin <m.kokryashkin@tarantool.org> Cc: tarantool-patches@dev.tarantool.org Subject: Re: [Tarantool-patches] [PATCH luajit] Fix HREFK forwarding vs. table.clear(). Date: Mon, 13 Nov 2023 10:37:51 +0300 [thread overview] Message-ID: <ZVHST-Z0WaADHB39@root> (raw) In-Reply-To: <5yynouo6jw5w27gtvrjqddg52in6wam6aqdcvptay4ivpq36bf@ng2qvitlre4f> Hi, Maxim! Thanks for the review! Fixed your comments inline and force-pushed the branch. See the iterative patch below. On 10.11.23, Maxim Kokryashkin wrote: > Hi, Sergey! > Thanks for the patch! > Please consider my comments below. > > <snipped> > > > diff --git a/test/tarantool-tests/lj-792-hrefk-table-clear.test.lua b/test/tarantool-tests/lj-792-hrefk-table-clear.test.lua > > new file mode 100644 > > index 00000000..e662e0cc > > --- /dev/null > > +++ b/test/tarantool-tests/lj-792-hrefk-table-clear.test.lua > > <snipped> > > > +jit.opt.start('hotloop=1') > > + > > +-- First compile the trace with a clearing not-interesting table. > It is better to rephrase it the following way: > | First, compile the trace that clears the not-interesting table. > Otherwise, `clearing` seems to be an adjective referring to the table. > Here and below. Fixed, thanks! > > +test_aref_fwd_tnew(2) > > +-- Now run the trace with the clearing table, from which we take > > +-- AREF. > Same rephrasing required. Here and below. Changed to "run the trace and clear the table ...". > > +test:is(test_aref_fwd_tnew(1), nil, 'AREF forward from TNEW') > > + > > +-- XXX: Reset hotcounters to avoid collisions. > > +jit.opt.start('hotloop=1') > > + > > +-- First compile the trace with a clearing not-interesting table. > > +test_aref_fwd_tdup(2) > > +-- Now run the trace with the clearing table, from which we take > > +-- AREF. > > +test:is(test_aref_fwd_tdup(1), nil, 'AREF forward from TDUP') > > + > > +-- XXX: Reset hotcounters to avoid collisions. > > +jit.opt.start('hotloop=1') > > + > > +-- First compile the trace with a clearing not-interesting table. > > +test_href_fwd_tnew(2) > > +-- Now run the trace with the clearing table, from which we take > > +-- HREF. > > +test:is(test_href_fwd_tnew(1), nil, 'HREF forward from TNEW') > > + > > +-- XXX: Reset hotcounters to avoid collisions. > > +jit.opt.start('hotloop=1') > > + > > +-- First compile the trace with a clearing not-interesting table. > > +test_href_fwd_tdup(2) > > +-- Now run the trace with the clearing table, from which we take > > +-- HREF. > > +test:is(test_href_fwd_tdup(1), nil, 'HREF forward from TDUP') > > Maybe we can just iterate over those cases in a loop? > If it breaks the semantics, then feel free to ignore. Yes, the loop itself can have side effects, so I prefere to ignore it. > <snipped> > > +local function test_not_dropped_guard_on_hrefk(tab_number) > > + local tab, field_value_after_clear > > + for _ = 1, NITERATIONS do > > + -- Create a table on trace to make the optimization work. > > + tab = {hrefk = MAGIC} > > + -- Use an additional table to alias the created table with the > > + -- `hrefk` key. > > + local tab_array = {tab, {hrefk = 0}} > > + table_clear(tab_array[tab_number]) > > + -- It should be `nil`, since it is cleared. > > + -- If the guard is dropped for HREFK, the value from the TDUP > > + -- table is taken instead, without the type check. This leads > > + -- to incorrect (swapped) returned values. > Typo: s/incorrect (swapped) returned/incorrectly returned (swapped)/ Fixed. > > + field_value_after_clear = tab.hrefk > > + tab.hrefk = MAGIC > > + end > > + return field_value_after_clear, tab.hrefk > > +end > > Let's move those test case definitions to be right after the ones above, > that would be more consistent. Done. > > + > > +-- XXX: Reset hotcounters to avoid collisions. > > +jit.opt.start('hotloop=1') > > + > > +-- First compile the trace with clearing not interesting table. > > +test_not_dropped_guard_on_hrefk(2) > > +-- Now run the trace with the clearing table, from which we take > > +-- HREFK. > > +local field_value_after_clear, tab_hrefk = test_not_dropped_guard_on_hrefk(1) > > + > > +test:is(field_value_after_clear, nil, 'correct field value after table.clear') > > +test:is(tab_hrefk, MAGIC, 'correct value set in the table that was cleared') > > + > > +test:done(true) > > -- > > 2.42.0 > > =================================================================== diff --git a/test/tarantool-tests/lj-792-hrefk-table-clear.test.lua b/test/tarantool-tests/lj-792-hrefk-table-clear.test.lua index e662e0cc..e1fbc2ed 100644 --- a/test/tarantool-tests/lj-792-hrefk-table-clear.test.lua +++ b/test/tarantool-tests/lj-792-hrefk-table-clear.test.lua @@ -83,41 +83,6 @@ local function test_href_fwd_tdup(tab_number) return field_value_after_clear end -jit.opt.start('hotloop=1') - --- First compile the trace with a clearing not-interesting table. -test_aref_fwd_tnew(2) --- Now run the trace with the clearing table, from which we take --- AREF. -test:is(test_aref_fwd_tnew(1), nil, 'AREF forward from TNEW') - --- XXX: Reset hotcounters to avoid collisions. -jit.opt.start('hotloop=1') - --- First compile the trace with a clearing not-interesting table. -test_aref_fwd_tdup(2) --- Now run the trace with the clearing table, from which we take --- AREF. -test:is(test_aref_fwd_tdup(1), nil, 'AREF forward from TDUP') - --- XXX: Reset hotcounters to avoid collisions. -jit.opt.start('hotloop=1') - --- First compile the trace with a clearing not-interesting table. -test_href_fwd_tnew(2) --- Now run the trace with the clearing table, from which we take --- HREF. -test:is(test_href_fwd_tnew(1), nil, 'HREF forward from TNEW') - --- XXX: Reset hotcounters to avoid collisions. -jit.opt.start('hotloop=1') - --- First compile the trace with a clearing not-interesting table. -test_href_fwd_tdup(2) --- Now run the trace with the clearing table, from which we take --- HREF. -test:is(test_href_fwd_tdup(1), nil, 'HREF forward from TDUP') - local function test_not_forwarded_hrefk_val_from_newref(tab_number) local field_value_after_clear for _ = 1, NITERATIONS do @@ -135,18 +100,6 @@ local function test_not_forwarded_hrefk_val_from_newref(tab_number) return field_value_after_clear end --- XXX: Reset hotcounters to avoid collisions. -jit.opt.start('hotloop=1') - --- First compile the trace with a clearing not-interesting table. -test_not_forwarded_hrefk_val_from_newref(2) --- Now run the trace with the clearing table, from which we take --- HREFK. -local value_from_cleared_tab = test_not_forwarded_hrefk_val_from_newref(1) - -test:is(value_from_cleared_tab, nil, - 'not forward the field value across table.clear') - local function test_not_dropped_guard_on_hrefk(tab_number) local tab, field_value_after_clear for _ = 1, NITERATIONS do @@ -159,19 +112,62 @@ local function test_not_dropped_guard_on_hrefk(tab_number) -- It should be `nil`, since it is cleared. -- If the guard is dropped for HREFK, the value from the TDUP -- table is taken instead, without the type check. This leads - -- to incorrect (swapped) returned values. + -- to incorrectly returned (swapped) values. field_value_after_clear = tab.hrefk tab.hrefk = MAGIC end return field_value_after_clear, tab.hrefk end +jit.opt.start('hotloop=1') + +-- First, compile the trace that clears the not-interesting table. +test_aref_fwd_tnew(2) +-- Now run the trace and clear the table, from which we take AREF. +test:is(test_aref_fwd_tnew(1), nil, 'AREF forward from TNEW') + +-- XXX: Reset hotcounters to avoid collisions. +jit.opt.start('hotloop=1') + +-- First, compile the trace that clears the not-interesting table. +test_aref_fwd_tdup(2) +-- Now run the trace and clear the table, from which we take AREF. +test:is(test_aref_fwd_tdup(1), nil, 'AREF forward from TDUP') + +-- XXX: Reset hotcounters to avoid collisions. +jit.opt.start('hotloop=1') + +-- First, compile the trace that clears the not-interesting table. +test_href_fwd_tnew(2) +-- Now run the trace and clear the table, from which we take HREF. +test:is(test_href_fwd_tnew(1), nil, 'HREF forward from TNEW') + +-- XXX: Reset hotcounters to avoid collisions. +jit.opt.start('hotloop=1') + +-- First, compile the trace that clears the not-interesting table. +test_href_fwd_tdup(2) +-- Now run the trace and clear the table, from which we take HREF. +test:is(test_href_fwd_tdup(1), nil, 'HREF forward from TDUP') + +-- XXX: Reset hotcounters to avoid collisions. +jit.opt.start('hotloop=1') + +-- First, compile the trace that clears the not-interesting table. +test_not_forwarded_hrefk_val_from_newref(2) +-- Now run the trace and clear the table, from which we take +-- HREFK. +local value_from_cleared_tab = test_not_forwarded_hrefk_val_from_newref(1) + +test:is(value_from_cleared_tab, nil, + 'not forward the field value across table.clear') + -- XXX: Reset hotcounters to avoid collisions. jit.opt.start('hotloop=1') --- First compile the trace with clearing not interesting table. +-- First, compile the trace that clears the not-interesting table. test_not_dropped_guard_on_hrefk(2) --- Now run the trace with the clearing table, from which we take +-- Now run the trace and clear the table, from which we take -- HREFK. local field_value_after_clear, tab_hrefk = test_not_dropped_guard_on_hrefk(1) =================================================================== -- Best regards, Sergey Kaplun
next prev parent reply other threads:[~2023-11-13 7:42 UTC|newest] Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-11-09 12:26 Sergey Kaplun via Tarantool-patches 2023-11-10 12:49 ` Maxim Kokryashkin via Tarantool-patches 2023-11-13 7:37 ` Sergey Kaplun via Tarantool-patches [this message] 2023-11-15 11:46 ` Maxim Kokryashkin via Tarantool-patches 2023-11-22 15:25 ` Sergey Bronnikov via Tarantool-patches 2024-01-10 8:51 ` 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=ZVHST-Z0WaADHB39@root \ --to=tarantool-patches@dev.tarantool.org \ --cc=m.kokryashkin@tarantool.org \ --cc=skaplun@tarantool.org \ --subject='Re: [Tarantool-patches] [PATCH luajit] Fix HREFK forwarding vs. table.clear().' \ /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