Skip to content

Instantly share code, notes, and snippets.

@rpond-pa
Last active November 17, 2015 21:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rpond-pa/6713f07ee6ef3aebd8a4 to your computer and use it in GitHub Desktop.
Save rpond-pa/6713f07ee6ef3aebd8a4 to your computer and use it in GitHub Desktop.
Ruby VM Instruction Sequence
== disasm: <RubyVM::InstructionSequence:<compiled>@<compiled>>==========
0000 trace 1 ( 1)
0002 putspecialobject 1
0004 putspecialobject 2
0006 putobject :foo
0008 putiseq foo
0010 opt_send_simple <callinfo!mid:core#define_method, argc:3, ARGS_SKIP>
0012 pop
0013 trace 1 ( 4)
0015 putself
0016 putself
0017 opt_send_simple <callinfo!mid:foo, argc:0, FCALL|VCALL|ARGS_SKIP>
0019 putstring "world"
0021 opt_plus <callinfo!mid:+, argc:1, ARGS_SKIP>
0023 opt_send_simple <callinfo!mid:puts, argc:1, FCALL|ARGS_SKIP>
0025 leave
== disasm: <RubyVM::InstructionSequence:foo@<compiled>>=================
0000 trace 8 ( 1)
0002 trace 1 ( 2)
0004 putstring "hello "
0006 trace 16 ( 3)
0008 leave ( 2)
ins = RubyVM::InstructionSequence.new <<-RUBIES
def foo
"hello "
end
puts foo + "world"
RUBIES
puts ins.disasm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment