Skip to content

Instantly share code, notes, and snippets.

@SpringMT
Created November 17, 2017 15:03
Show Gist options
  • Save SpringMT/33226a44fadb25cb39ead37ba1514b52 to your computer and use it in GitHub Desktop.
Save SpringMT/33226a44fadb25cb39ead37ba1514b52 to your computer and use it in GitHub Desktop.
== disasm: #<ISeq:<main>@./sample.rb>=================================== | == disasm: #<ISeq:<main>@./sample2.rb>==================================
local table (size: 1, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1]) local table (size: 1, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1])
[ 1] a [ 1] a
0000 putspecialobject 3 ( 1) 0000 putspecialobject 3 ( 1)
0002 putnil 0002 putnil
0003 defineclass :A, <class:A>, 0 0003 defineclass :A, <class:A>, 0
0007 pop 0007 pop
0008 getinlinecache 15, <is:0> ( 13) 0008 getinlinecache 15, <is:0> ( 13)
0011 getconstant :A 0011 getconstant :A
0013 setinlinecache <is:0> 0013 setinlinecache <is:0>
0015 send <callinfo!mid:new, argc:0, ARGS_SIMPLE>, <callcache>, nil 0015 send <callinfo!mid:new, argc:0, ARGS_SIMPLE>, <callcache>, nil
0019 setlocal a, 0 0019 setlocal a, 0
0022 getlocal a, 0 ( 14) 0022 getlocal a, 0 ( 14)
0025 putobject 1 0025 putobject 1
0027 send <callinfo!mid:foo=, argc:1, ARGS_SIMPLE>, <callcache>, nil 0027 send <callinfo!mid:foo=, argc:1, ARGS_SIMPLE>, <callcache>, nil
0031 pop 0031 pop
0032 putself ( 15) 0032 putself ( 15)
0033 getlocal a, 0 0033 getlocal a, 0
0036 send <callinfo!mid:bar, argc:0, ARGS_SIMPLE>, <callcache>, nil 0036 send <callinfo!mid:bar, argc:0, ARGS_SIMPLE>, <callcache>, nil
0040 send <callinfo!mid:p, argc:1, FCALL|ARGS_SIMPLE>, <callcache>, nil 0040 send <callinfo!mid:p, argc:1, FCALL|ARGS_SIMPLE>, <callcache>, nil
0044 leave 0044 leave
== disasm: #<ISeq:<class:A>@./sample.rb>================================ | == disasm: #<ISeq:<class:A>@./sample2.rb>===============================
0000 putself ( 2) 0000 putself ( 2)
0001 putobject :foo 0001 putobject :foo
0003 send <callinfo!mid:attr_accessor, argc:1, FCALL|ARGS_SIMPLE>, <callcache>, n 0003 send <callinfo!mid:attr_accessor, argc:1, FCALL|ARGS_SIMPLE>, <callcache>, n
0007 pop 0007 pop
0008 putspecialobject 1 ( 3) 0008 putspecialobject 1 ( 3)
0010 putobject :bar 0010 putobject :bar
0012 putiseq bar 0012 putiseq bar
0014 send <callinfo!mid:core#define_method, argc:2, ARGS_SIMPLE>, <callcache>, ni 0014 send <callinfo!mid:core#define_method, argc:2, ARGS_SIMPLE>, <callcache>, ni
0018 pop 0018 pop
0019 putspecialobject 1 ( 8) 0019 putspecialobject 1 ( 8)
0021 putobject :baz 0021 putobject :baz
0023 putiseq baz 0023 putiseq baz
0025 send <callinfo!mid:core#define_method, argc:2, ARGS_SIMPLE>, <callcache>, ni 0025 send <callinfo!mid:core#define_method, argc:2, ARGS_SIMPLE>, <callcache>, ni
0029 leave 0029 leave
== disasm: #<ISeq:bar@./sample.rb>====================================== | == disasm: #<ISeq:bar@./sample2.rb>=====================================
local table (size: 1, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1]) local table (size: 1, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1])
[ 1] foo | [ 1] test
0000 putself ( 4) 0000 putself ( 4)
0001 getlocal foo, 0 | 0001 putself
0004 send <callinfo!mid:baz, argc:1, FCALL|ARGS_SIMPLE>, <callcache>, nil | 0002 send <callinfo!mid:foo, argc:0, FCALL|VCALL|ARGS_SIMPLE>, <callcache>, nil
0008 setlocal foo, 0 | 0006 send <callinfo!mid:baz, argc:1, FCALL|ARGS_SIMPLE>, <callcache>, nil
0011 getlocal foo, 0 ( 5) | 0010 setlocal test, 0
0014 leave | 0013 getlocal test, 0 ( 5)
== disasm: #<ISeq:baz@./sample.rb>====================================== | 0016 leave
> == disasm: #<ISeq:baz@./sample2.rb>=====================================
local table (size: 1, argc: 1 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1]) local table (size: 1, argc: 1 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1])
[ 1] v<Arg> [ 1] v<Arg>
0000 getlocal v, 0 ( 9) 0000 getlocal v, 0 ( 9)
0003 leave 0003 leave
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment