Skip to content

Instantly share code, notes, and snippets.

@SpringMT
Last active June 10, 2019 05:19
Show Gist options
  • Save SpringMT/431437d8bd8fcf9491f27028f1d795cb to your computer and use it in GitHub Desktop.
Save SpringMT/431437d8bd8fcf9491f27028f1d795cb to your computer and use it in GitHub Desktop.
% ruby -v ~/study/ruby
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin17]
% ruby instrument.rb ~/study/ruby
== disasm: #<ISeq:<main>@./test_condition.rb:1 (1,0)-(7,10)>============
local table (size: 1, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1])
[ 1] a
0000 putstring "aaa" ( 1)[Li]
0002 setlocal a, 0
0005 getlocal a, 0 ( 2)[Li]
0008 putstring "bbb"
0010 send <callinfo!mid:==, argc:1, ARGS_SIMPLE>, <callcache>, nil
0014 branchunless 18
0016 jump 31
0018 getlocal a, 0
0021 putstring "ccc"
0023 send <callinfo!mid:==, argc:1, ARGS_SIMPLE>, <callcache>, nil
0027 branchunless 39
0029 jump 31
0031 getlocal a, 0 ( 3)[Li]
0034 setlocal a, 0
0037 jump 47 ( 2)
0039 putself ( 5)[Li]
0040 putstring "OK"
0042 send <callinfo!mid:puts, argc:1, FCALL|ARGS_SIMPLE>, <callcache>, nil
0046 pop
0047 putself ( 7)[Li]
0048 putstring "END"
0050 send <callinfo!mid:puts, argc:1, FCALL|ARGS_SIMPLE>, <callcache>, nil
0054 leave
% ruby -v ~/study/ruby
ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-darwin18]
[haruyama.makoto@o-08645-mac] (master)✗ (gke_dena-rerep-live-sb-gcp_asia-northeast1-b_live-sandbox3)
% ruby instrument.rb ~/study/ruby
== disasm: #<ISeq:<main>@./test_condition.rb:1 (1,0)-(7,10)> (catch: FALSE)
local table (size: 1, argc: 0 [opts: 0, rest: -1, post: 0, block: -1, kw: -1@-1, kwrest: -1])
[ 1] a@0
0000 putstring "aaa" ( 1)[Li]
0002 setlocal a@0, 0
0005 getlocal a@0, 0 ( 2)[Li]
0008 putstring "bbb"
0010 send <callinfo!mid:==, argc:1, ARGS_SIMPLE>, <callcache>, nil
0014 branchunless 18
0016 jump 31
0018 getlocal a@0, 0
0021 putstring "ccc"
0023 send <callinfo!mid:==, argc:1, ARGS_SIMPLE>, <callcache>, nil
0027 branchunless 39
0029 jump 31
0031 getlocal a@0, 0 ( 3)[Li]
0034 setlocal a@0, 0
0037 jump 47 ( 2)
0039 putself ( 5)[Li]
0040 putstring "OK"
0042 send <callinfo!mid:puts, argc:1, FCALL|ARGS_SIMPLE>, <callcache>, nil
0046 pop
0047 putself ( 7)[Li]
0048 putstring "END"
0050 send <callinfo!mid:puts, argc:1, FCALL|ARGS_SIMPLE>, <callcache>, nil
0054 leave
@SpringMT
Copy link
Author

SpringMT commented Jun 10, 2019

a = "aaa"
if a == "bbb" || a == "ccc" then
    a = a
else
    puts "OK"
end
puts "END"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment