aboutsummaryrefslogtreecommitdiffstats
path: root/spec/bundler
diff options
context:
space:
mode:
authoreileencodes <eileencodes@gmail.com>2023-12-15 11:32:10 -0500
committerKevin Newton <kddnewton@gmail.com>2023-12-15 16:23:06 -0500
commitb8074c2f043d99f6f30ab75ad21cc2c998f49dcf (patch)
tree5a16af98ae44d5f8f51378565b6e5e54c9dcc643 /spec/bundler
parent161787f9beef96c9fa1057b6378fe7e048ac2ecd (diff)
downloadruby-b8074c2f043d99f6f30ab75ad21cc2c998f49dcf.tar.gz
[PRISM] Fix incorrect instructions for `default_proc=`
This is kind of specific and was found via debugging ruby/prism#2061 but does not actually fix that issue. The change here checks for `!popped` for the additional instructions that are normally added for nodes with the `attribute_write` flag. I also removed the extra catch table by deleting the `ISEQ_COMPILE_DATA(iseq)->catch_except_p = true;` line. I'm...not entirely sure why it was added but it doesn't match the upstream compiler [code](https://github.com/ruby/ruby/blob/92b10f5be7453aceb5863e46ac775a4ddbf83b97/compile.c#L887-L892). The changes here unfortunately don't improve the test failures mentioned in the linked issue so we still have other issues with instructions for hashes. Instructions before: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(34,8)> local table (size: 1, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1]) [ 1] h@0 0000 putnil ( 32)[Li] 0001 putobject true 0003 getconstant :Hash 0005 send <calldata!mid:new, argc:0, ARGS_SIMPLE>, nil 0008 setlocal h@0, 0 0011 getlocal h@0, 0 ( 33)[Li] 0014 putspecialobject 1 0016 send <calldata!mid:lambda, argc:0, FCALL>, block in <compiled> 0019 send <calldata!mid:default_proc=, argc:1, ARGS_SIMPLE>, nil 0022 pop 0023 getlocal h@0, 0 ( 34)[Li] 0026 putobject :nope 0028 send <calldata!mid:[], argc:1, ARGS_SIMPLE>, nil 0031 leave == disasm: #<ISeq:block in <compiled>@<compiled>:33 (33,19)-(33,32)> local table (size: 2, argc: 2 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1]) [ 2] _@0<Arg> [ 1] _@1<Arg> 0000 putobject true ( 33)[LiBc] 0002 leave [Br] true "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:31 (31,0)-(33,8)> local table (size: 1, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1]) [ 1] h@0 0000 putnil ( 31)[Li] 0001 putobject true 0003 getconstant :Hash 0005 send <calldata!mid:new, argc:0, ARGS_SIMPLE>, nil 0008 setlocal h@0, 0 0011 putnil ( 32)[Li] 0012 getlocal h@0, 0 0015 putspecialobject 1 0017 send <calldata!mid:lambda, argc:0, FCALL>, block in <compiled> 0020 setn 2 0022 send <calldata!mid:default_proc=, argc:1, ARGS_SIMPLE>, nil 0025 pop 0026 pop 0027 getlocal h@0, 0 ( 33)[Li] 0030 putobject :nope 0032 send <calldata!mid:[], argc:1, ARGS_SIMPLE>, nil 0035 leave ( 31) == disasm: #<ISeq:block in <compiled>@<compiled>:32 (32,17)-(32,32)> == catch table | catch type: redo st: 0000 ed: 0002 sp: 0000 cont: 0000 | catch type: next st: 0000 ed: 0002 sp: 0000 cont: 0002 |------------------------------------------------------------------------ local table (size: 2, argc: 2 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1]) [ 2] _@0<Arg> [ 1] _@1<Arg> 0000 putobject true ( 32)[LiBc] 0002 leave [Br] ``` Instructions after: ``` "********* Ruby *************" == disasm: #<ISeq:<compiled>@<compiled>:1 (1,0)-(34,8)> local table (size: 1, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1]) [ 1] h@0 0000 putnil ( 32)[Li] 0001 putobject true 0003 getconstant :Hash 0005 send <calldata!mid:new, argc:0, ARGS_SIMPLE>, nil 0008 setlocal h@0, 0 0011 getlocal h@0, 0 ( 33)[Li] 0014 putspecialobject 1 0016 send <calldata!mid:lambda, argc:0, FCALL>, block in <compiled> 0019 send <calldata!mid:default_proc=, argc:1, ARGS_SIMPLE>, nil 0022 pop 0023 getlocal h@0, 0 ( 34)[Li] 0026 putobject :nope 0028 send <calldata!mid:[], argc:1, ARGS_SIMPLE>, nil 0031 leave == disasm: #<ISeq:block in <compiled>@<compiled>:33 (33,19)-(33,32)> local table (size: 2, argc: 2 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1]) [ 2] _@0<Arg> [ 1] _@1<Arg> 0000 putobject true ( 33)[LiBc] 0002 leave [Br] "********* PRISM *************" == disasm: #<ISeq:<compiled>@<compiled>:31 (31,0)-(33,8)> local table (size: 1, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1]) [ 1] h@0 0000 putnil ( 31)[Li] 0001 putobject true 0003 getconstant :Hash 0005 send <calldata!mid:new, argc:0, ARGS_SIMPLE>, nil 0008 setlocal h@0, 0 0011 getlocal h@0, 0 ( 32)[Li] 0014 putspecialobject 1 0016 send <calldata!mid:lambda, argc:0, FCALL>, block in <compiled> 0019 send <calldata!mid:default_proc=, argc:1, ARGS_SIMPLE>, nil 0022 pop 0023 getlocal h@0, 0 ( 33)[Li] 0026 putobject :nope 0028 send <calldata!mid:[], argc:1, ARGS_SIMPLE>, nil 0031 leave ( 31) == disasm: #<ISeq:block in <compiled>@<compiled>:32 (32,17)-(32,32)> local table (size: 2, argc: 2 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1]) [ 2] _@0<Arg> [ 1] _@1<Arg> 0000 putobject true ( 32)[LiBc] 0002 leave [Br] ```
Diffstat (limited to 'spec/bundler')
0 files changed, 0 insertions, 0 deletions