Skip to content

Instantly share code, notes, and snippets.

@tenderlove
Created December 23, 2011 17:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tenderlove/1514889 to your computer and use it in GitHub Desktop.
Save tenderlove/1514889 to your computer and use it in GitHub Desktop.
[aaron@higgins ~]$ irb
irb(main):001:0> File.write('hello.rb', 'class Foo; def bar; 1 + 1; end end')
=> 34
irb(main):002:0> RubyVM::InstructionSequence.compile_file 'hello.rb'
=> <RubyVM::InstructionSequence:<main>@hello.rb>
irb(main):003:0> puts _.disasm
== disasm: <RubyVM::InstructionSequence:<main>@hello.rb>================
0000 trace 1 ( 1)
0002 putspecialobject 3
0004 putnil
0005 defineclass :Foo, <class:Foo>, 3
0009 leave
== disasm: <RubyVM::InstructionSequence:<class:Foo>@hello.rb>===========
0000 trace 2 ( 1)
0002 trace 1
0004 putspecialobject 1
0006 putspecialobject 2
0008 putobject :bar
0010 putiseq bar
0012 send :"core#define_method", 3, nil, 0, <ic:0>
0018 trace 4
0020 leave
== disasm: <RubyVM::InstructionSequence:bar@hello.rb>===================
0000 trace 8 ( 1)
0002 trace 1
0004 putobject 1
0006 putobject 1
0008 opt_plus <ic:1>
0010 trace 16
0012 leave
=> nil
irb(main):004:0>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment