[ruby-core:126833] [Ruby Bug#22377] compile.c: `getlocal` not turned into `getlocal_WC_0`
Issue #22377 has been reported by alanwu (Alan Wu). ---------------------------------------- Bug #22377: compile.c: `getlocal` not turned into `getlocal_WC_0` https://bugs.ruby-lang.org/issues/22377 * Author: alanwu (Alan Wu) * Status: Open * Backport: 3.3: DONTNEED, 3.4: DONTNEED, 4.0: DONTNEED ---------------------------------------- Missed by the "operands_unification" pass, somehow. See 0023 below: ```text $ ./miniruby --parser=parse.y --dump=insns -e ' assign = ->(outer) { m = Module.new m.set_temporary_name("m") # non-leaf call, so the next getlocal needs a patch point outer::M = m [m.name, outer::M.name] }' == disasm: #<ISeq:<main>@-e:1 (1,0)-(7,9)> local table (size: 1, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1]) [ 1] assign@0 0000 putspecialobject 1 ( 2)[Li] 0002 send <calldata!mid:lambda, argc:0, FCALL>, block in <main> 0005 dup 0006 setlocal_WC_0 assign@0 0008 leave == disasm: #<ISeq:block in <main>@-e:2 (2,17)-(7,9)> local table (size: 2, argc: 1 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1]) [ 2] outer@0<AmbiguousArg>[ 1] m@1 0000 putnil ( 3)[LiBc] 0001 opt_getconstant_path <ic:0 Module> 0003 opt_new <calldata!mid:new, argc:0, ARGS_SIMPLE>, 10 0006 opt_send_without_block <calldata!mid:initialize, argc:0, FCALL|ARGS_SIMPLE> 0008 jump 13 0010 opt_send_without_block <calldata!mid:new, argc:0, ARGS_SIMPLE> 0012 swap 0013 pop 0014 setlocal_WC_0 m@1 0016 getlocal_WC_0 m@1 ( 4)[Li] 0018 dupchilledstring "m" 0020 opt_send_without_block <calldata!mid:set_temporary_name, argc:1, ARGS_SIMPLE> 0022 pop * 0023 getlocal m@1, 0 ( 5)[Li] 0026 getlocal_WC_0 outer@0 0028 setconstant :M 0030 getlocal_WC_0 m@1 ( 6)[Li] 0032 opt_send_without_block <calldata!mid:name, argc:0, ARGS_SIMPLE> 0034 getlocal_WC_0 outer@0 0036 putobject false 0038 getconstant :M 0040 opt_send_without_block <calldata!mid:name, argc:0, ARGS_SIMPLE> 0042 newarray 2 0044 leave ( 7)[Br] ``` Seems to only happen on trunk and not to be an issue on 4.0.x, 3.4.x, 3.3.x. https://godbolt.org/z/TG9h1j37h Seems to have started with commit:f4813a34c2 "compile.c: statically resolve `swap` instructions when possible" as its parent commit doesn't have this issue. CC: @byroot -- https://bugs.ruby-lang.org/
Issue #22377 has been updated by byroot (Jean Boussier). Thanks for the repro, I think I know what's going on, I'll look into it. ---------------------------------------- Bug #22377: compile.c: `getlocal` not turned into `getlocal_WC_0` https://bugs.ruby-lang.org/issues/22377#change-119178 * Author: alanwu (Alan Wu) * Status: Open * Backport: 3.3: DONTNEED, 3.4: DONTNEED, 4.0: DONTNEED ---------------------------------------- Missed by the "operands_unification" pass, somehow. See 0023 below: ```text $ ./miniruby --parser=parse.y --dump=insns -e ' assign = ->(outer) { m = Module.new m.set_temporary_name("m") # non-leaf call, so the next getlocal needs a patch point outer::M = m [m.name, outer::M.name] }' == disasm: #<ISeq:<main>@-e:1 (1,0)-(7,9)> local table (size: 1, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1]) [ 1] assign@0 0000 putspecialobject 1 ( 2)[Li] 0002 send <calldata!mid:lambda, argc:0, FCALL>, block in <main> 0005 dup 0006 setlocal_WC_0 assign@0 0008 leave == disasm: #<ISeq:block in <main>@-e:2 (2,17)-(7,9)> local table (size: 2, argc: 1 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1]) [ 2] outer@0<AmbiguousArg>[ 1] m@1 0000 putnil ( 3)[LiBc] 0001 opt_getconstant_path <ic:0 Module> 0003 opt_new <calldata!mid:new, argc:0, ARGS_SIMPLE>, 10 0006 opt_send_without_block <calldata!mid:initialize, argc:0, FCALL|ARGS_SIMPLE> 0008 jump 13 0010 opt_send_without_block <calldata!mid:new, argc:0, ARGS_SIMPLE> 0012 swap 0013 pop 0014 setlocal_WC_0 m@1 0016 getlocal_WC_0 m@1 ( 4)[Li] 0018 dupchilledstring "m" 0020 opt_send_without_block <calldata!mid:set_temporary_name, argc:1, ARGS_SIMPLE> 0022 pop * 0023 getlocal m@1, 0 ( 5)[Li] 0026 getlocal_WC_0 outer@0 0028 setconstant :M 0030 getlocal_WC_0 m@1 ( 6)[Li] 0032 opt_send_without_block <calldata!mid:name, argc:0, ARGS_SIMPLE> 0034 getlocal_WC_0 outer@0 0036 putobject false 0038 getconstant :M 0040 opt_send_without_block <calldata!mid:name, argc:0, ARGS_SIMPLE> 0042 newarray 2 0044 leave ( 7)[Br] ``` Seems to only happen on trunk and not to be an issue on 4.0.x, 3.4.x, 3.3.x. https://godbolt.org/z/TG9h1j37h Seems to have started with commit:f4813a34c2 "compile.c: statically resolve `swap` instructions when possible" as its parent commit doesn't have this issue. CC: @byroot -- https://bugs.ruby-lang.org/
participants (2)
-
alanwu (Alan Wu) -
byroot (Jean Boussier)