Skip to content

Instantly share code, notes, and snippets.

@wanabe
Created October 25, 2018 23:18
Show Gist options
  • Select an option

  • Save wanabe/24893440e75a53d1ceb6ec50f6bc910a to your computer and use it in GitHub Desktop.

Select an option

Save wanabe/24893440e75a53d1ceb6ec50f6bc910a to your computer and use it in GitHub Desktop.
$ cat bug13930.rb
1.times do
begin
next
rescue
p :unexpected_raise
exit!
ensure
p :ensure
raise
end
end
$ ./miniruby --dump=insns bug13930.rb
== disasm: #<ISeq:<main>@bug13930.rb:1 (1,0)-(11,3)> (catch: TRUE)
== catch table
| catch type: break st: 0000 ed: 0005 sp: 0000 cont: 0005
| == disasm: #<ISeq:block in <main>@bug13930.rb:1 (1,8)-(11,3)> (catch: TRUE)
| == catch table
| | catch type: rescue st: 0001 ed: 0017 sp: 0000 cont: 0018
| | == disasm: #<ISeq:rescue in block in <main>@bug13930.rb:4 (4,2)-(6,9)> (catch: TRUE)
| | local table (size: 1, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1])
| | [ 1] "\#$!"@0
| | 0000 getlocal_WC_0 "\#$!"@0 ( 5)
| | 0002 putobject StandardError
| | 0004 checkmatch 3
| | 0006 branchunless 20
| | 0008 putself [Li]
| | 0009 putobject :unexpected_raise
| | 0011 opt_send_without_block <callinfo!mid:p, argc:1, FCALL|ARGS_SIMPLE>, <callcache>
| | 0014 pop
| | 0015 putself ( 6)[Li]
| | 0016 opt_send_without_block <callinfo!mid:exit!, argc:0, FCALL|ARGS_SIMPLE>, <callcache>
| | 0019 leave ( 5)
| | 0020 getlocal_WC_0 "\#$!"@0
| | 0022 throw 0
| | catch type: retry st: 0017 ed: 0018 sp: 0000 cont: 0001
| | catch type: ensure st: 0001 ed: 0002 sp: 0001 cont: 0030
| | == disasm: #<ISeq:ensure in block in <main>@bug13930.rb:8 (8,4)-(9,9)> (catch: TRUE)
| | local table (size: 1, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1])
| | [ 1] "\#$!"@0
| | 0000 putself ( 8)[Li]
| | 0001 putobject :ensure
| | 0003 opt_send_without_block <callinfo!mid:p, argc:1, FCALL|ARGS_SIMPLE>, <callcache>
| | 0006 pop
| | 0007 putself ( 9)[Li]
| | 0008 opt_send_without_block <callinfo!mid:raise, argc:0, FCALL|VCALL|ARGS_SIMPLE>, <callcache>
| | 0011 pop
| | 0012 getlocal_WC_0 "\#$!"@0
| | 0014 throw 0
| | catch type: ensure st: 0014 ed: 0018 sp: 0001 cont: 0030
| | catch type: redo st: 0001 ed: 0030 sp: 0000 cont: 0001
| | catch type: next st: 0001 ed: 0030 sp: 0000 cont: 0030
| |------------------------------------------------------------------------
| 0000 nop ( 1)[Bc]
| 0001 putnil ( 3)[Li]
| 0002 putself ( 8)[Li]
| 0003 putobject :ensure
| 0005 opt_send_without_block <callinfo!mid:p, argc:1, FCALL|ARGS_SIMPLE>, <callcache>
| 0008 pop
| 0009 putself ( 9)[Li]
| 0010 opt_send_without_block <callinfo!mid:raise, argc:0, FCALL|VCALL|ARGS_SIMPLE>, <callcache>
| 0013 pop
| 0014 leave ( 11)[Br]
| 0015 pop
| 0016 putnil ( 3)
| 0017 nop ( 4)
| 0018 putself ( 8)[Li]
| 0019 putobject :ensure
| 0021 opt_send_without_block <callinfo!mid:p, argc:1, FCALL|ARGS_SIMPLE>, <callcache>
| 0024 pop
| 0025 putself ( 9)[Li]
| 0026 opt_send_without_block <callinfo!mid:raise, argc:0, FCALL|VCALL|ARGS_SIMPLE>, <callcache>
| 0029 pop
| 0030 leave ( 11)[Br]
|------------------------------------------------------------------------
0000 putobject_INT2FIX_1_ ( 1)[Li]
0001 send <callinfo!mid:times, argc:0>, <callcache>, block in <main>
0005 leave
$ ./miniruby bug13930.rb
:ensure
:unexpected_raise
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment