diff options
| author | Aaron Patterson <tenderlove@ruby-lang.org> | 2021-01-26 15:49:21 -0800 |
|---|---|---|
| committer | Aaron Patterson <aaron.patterson@gmail.com> | 2021-02-16 14:00:36 -0800 |
| commit | 938e027cdf019ff2cb6ee8a7229e6d9a4d8fc953 (patch) | |
| tree | f4d9b768659b56f12118fbfefc7cff9f958170f9 /include/ruby/version.h | |
| parent | 296a2cab07ce530809ee74dee61180fbb3ca6f91 (diff) | |
Eliminate useless catch tables and nops from lambdas
Before this commit:
```
$ ruby --dump=insn -e '1.times { |x| puts x }'
== disasm: #<ISeq:<main>@-e:1 (1,0)-(1,22)> (catch: FALSE)
== catch table
| catch type: break st: 0000 ed: 0004 sp: 0000 cont: 0004
| == disasm: #<ISeq:block in <main>@-e:1 (1,8)-(1,22)> (catch: FALSE)
| == catch table
| | catch type: redo st: 0001 ed: 0006 sp: 0000 cont: 0001
| | catch type: next st: 0001 ed: 0006 sp: 0000 cont: 0006
| |------------------------------------------------------------------------
| local table (size: 1, argc: 1 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1])
| [ 1] x@0<Arg>
| 0000 nop ( 1)[Bc]
| 0001 putself [Li]
| 0002 getlocal_WC_0 x@0
| 0004 opt_send_without_block <calldata!mid:puts, argc:1, FCALL|ARGS_SIMPLE>
| 0006 leave [Br]
|------------------------------------------------------------------------
0000 putobject_INT2FIX_1_ ( 1)[Li]
0001 send <calldata!mid:times, argc:0>, block in <main>
0004 leave
```
After this commit:
```
> ruby --dump=insn -e '1.times { |x| puts x }'
== disasm: #<ISeq:<main>@-e:1 (1,0)-(1,22)> (catch: FALSE)
0000 putobject_INT2FIX_1_ ( 1)[Li]
0001 send <calldata!mid:times, argc:0>, block in <main>
0004 leave
== disasm: #<ISeq:block in <main>@-e:1 (1,8)-(1,22)> (catch: FALSE)
local table (size: 1, argc: 1 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1])
[ 1] x@0<Arg>
0000 putself ( 1)[LiBc]
0001 getlocal_WC_0 x@0
0003 opt_send_without_block <calldata!mid:puts, argc:1, FCALL|ARGS_SIMPLE>
0005 leave
```
Fixes [ruby-core:102418] [Feature #17613]
Co-Authored-By: Alan Wu <XrXr@users.noreply.github.com>
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/4125
Diffstat (limited to 'include/ruby/version.h')
0 files changed, 0 insertions, 0 deletions
