From: "byroot (Jean Boussier) via ruby-core" Date: 2026-09-23T04:10:47+00:00 Subject: [ruby-core:126834] [Ruby Bug#22377] compile.c: `getlocal` not turned into `getlocal_WC_0` 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: #@-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 , block in
0005 dup 0006 setlocal_WC_0 assign@0 0008 leave == disasm: #@-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[ 1] m@1 0000 putnil ( 3)[LiBc] 0001 opt_getconstant_path 0003 opt_new , 10 0006 opt_send_without_block 0008 jump 13 0010 opt_send_without_block 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 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 0034 getlocal_WC_0 outer@0 0036 putobject false 0038 getconstant :M 0040 opt_send_without_block 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/ ______________________________________________ ruby-core mailing list -- ruby-core@ml.ruby-lang.org To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/