SlideShare a Scribd company logo
1 of 51
A Tool of the Future
   aka the road to enlightenment




                 1
Ask/give questions/comments.


   Both nice and nasty.
Mantra of rubinius
If it can be done in ruby, then it shouldn’t be in C.




                          3
An idealist is a person who helps
other people to be prosperous.

                   Henry Ford
the edges of the sword are life and death
     no one knows which is which

                               Ikkyū Sōjun
If you’re not failing every now
and again, it’s a sign you’re not
    anything very innovative.
                   Woody Allen
KHAAAAANN!


      James T. Kirk
• What is (and is not) rubinius?
• Who is rubinius?
• Features and Goals
• Timeline
• Technical Details
• Demo / Questions
                        9
http://rubini.us
What.


• A brand new ruby engine
• Bytecode Virtual Machine based
• Generational Garbage Collection


                      11
Why.


• Fun
• A desire for a better interpreter


                       12
Why pt. 2


• Every talk at this conference has mentioned
  some limitation of ruby.

• All limitations are limitations of the current
  interpreter, not the language.




                         13
What it’s not.


• Vaporware
• A thesis project
• Finished.


                     14
Who.
•                                    Aki Reijonen (loop)
    Evan Phoenix (evan)

•                                    Mat Elder (mae)
    Brian Ford (brixen)

•                                    John Hornbeck (hornbeck)
    Wilson Bilkovich (Defiler)

•                                    Carsten Bormann (cabo)
    Pat Eyler (pate)

•                                    Devin Walters (defn)
    Alan Hurdle (hurdlea)

•                                    Frederick Ros (sleeper)
    Thomas Lockney (tlockney)

•                                    Alexander Kellet (lypanov)
    Eero Saynatkai (rue)

•   Mikko Lehtonen (scoopr)

                                15
Features and Goals
• Remember the Mantra!
• VM in C only
  • Includes primitive operations
• Extensive tests and specs
• Core library in ruby
  •   Array#dup, Method#new, Object#instance_eval


                        16
• 1.8.5 compatible
• 98% first class
• Easy to understand, easy to extend, easy to
  optimize

• MRI (Matz Ruby Interpreter) C API compatible

                       17
Timeline.
• 1.0 by October, 2007 - RubyConf
  • Near 100% compatible with 1.8.5
  • Able to run rails 1.2
• 2.0
  • JIT
  • Optimizers
                     18
Technical Details
• 5 core sections
  • CPU
  • Primitives
  • Compiler
  • Object Memory / Garbage Collection
  • Core library
                     19
CPU


• Fully bytecode based
• All bytecodes are written test first
• Leverage GCC to make help make fast


                     20
Threads

• Currently supports green threads
• Contains low level sychronization / sharing
  mechanism called Channel

  • A PI Calculus-like channel
• Native Thread support in a MxN scheme
  • (eventually)
                       21
Primitives


• The most basic method
• Written C (for now)
• Provide most basic functionality


                       22
Compiler

• Completely written in ruby
• COMPLETELY WRITTEN IN RUBY
• Self bootstrapped from initial rubinius
  prototype

• Pipeline based architecture

                        23
# rbx sirb -p -s -b
sirb(eval):000> puts “hello evan”
puts "hello evan"
[:newline, 1,
   "(eval)",
   [:fcall, :puts,
      [:array, [:str, "hello evan"]]]]
#line 1
push_literal 0
string_dup
push self
send puts 1
ret
"v00000000:fC0000
0000)000000010000
         0001'0000
• Every stage is directly accessible
• Think: new parsers that output rubinius
  assembly

  • LISP
  • Smalltalk
  • Erlang

                      29
• Compiler is a normal class, which open doors...
  • Compile ERB templates directly into
    CompiledMethods

  • Ability to remove Kernel#eval if an
    application of rubinius warrants it




                       30
“The Reaper”
     (Object Memory / Garbage Collection)



• Generational Collector
• Young Objects: Baker two-space compacting
  collector

• Mature Objects: Mark/Sweep collector

                      31
Infanticide

• Young objects live fast and die young (usually)
• Once an object survives for a while, it’s
  promoted to the mature object space.

• Compaction keeps the memory footprint small.

                        32
The Old Guard

• Mature objects are collected 10 to 30 times
  less often than young objects.

• All object access in VM is done through the
  “write barrier”, which maintains the set of
  mature objects that reference young objects.

• Objects themselves are not marked, making
  rubinius very “fork friendly”.


                        33
Core library



• Everything you’ve come to love, now in written
  in ruby.




                       34
def [](arg, len = nil)
   if len
     len = len.to_i
     return nil if len  0
   end

   if arg.is_a? String
     unless len.nil?
       raise ArgumentError.new(String#[] cannot accept a second argument with a String.)
     end
     return (self.include?(arg) ? arg.dup : nil)
   elsif arg.respond_to? :match
     m = arg.match(self)
     return m[len.to_i] if m  len
     return m[0] if m
     return nil
   elsif arg.respond_to?(:first) and arg.respond_to?(:last)
     from = arg.first
     to = arg.last
     to -= 1 if arg.respond_to?(:exclude_end?)  arg.exclude_end?
     size = self.size
     from = from + size if from  0
     to += size if to  0
     len = to - from + 1
     self[from, len]

   elsif arg and arg.respond_to?(:to_i)
     arg = arg.to_i

                                                            String#[]
     size = self.size
     arg = arg + size if arg  0
     if 0 = arg  arg  size
        if len
          len = size - arg if arg + len = size
          substring(arg, len)
        else
          @data[arg]
        end
     else # invalid start index
       len ?  : nil
     end
   else
     raise ArgumentError.new(String#[] cannot accept #{arg.class} objects)
   end
def parent
  a=3
  ask_child(a)
  puts OMG #{a} PONIES!
end

def ask_child(initial_pony_count)
  ctx = MethodContext.current.sender
  # Will be ctx.locals[:a] = 9 soon.
  ctx.locals[2] = 9
end

parent()
OMG 9 PONIES!
Nothing is sacred.
    (evil built in)
Backtraces

vatu :: rbx-branches/event ./shotgun/rubinius ctx.rb
An exception has occured:
    No method 'ask_child' on an instance of Object. (NoMethodError)

Backtrace:
           NoMethodError#initialize   at   core/exception.rb:47
                  NoMethodError.new   at   bootstrap/class.rb:8
    main.ask_child (method_missing)   at   bootstrap/method_missing.rb:8
                        main.parent   at   ctx.rb:3
                    main.__script__   at   ctx.rb:12
                          main.load   at   core/compile.rb:56
                    main.__script__   at   core/__loader.rb:95



                                39
MethodTables

class Blah
end

class Foo
  def hello
    puts “hello evan”
  end
end

Blah.methods[:hello_also] = Foo.methods[:hello]
Blah.new.hello_also # hello evan

                          40
It’s your party.


            class Mu  nil
            end

            p Mu.instance_methods # []
            p Mu.superclass # nil




you still mad?           41
Zen and the Art of Object Creation

                42
VM level Sampler



s = Sampler.new(100) # 100 hz
s.start
100000.times { 1 + 1 }
s.stop
s.results.size # 332




                          43
CompiledMethods



m = Array.methods[:index]
p m # #CompiledMethod:0x32a34 ...
p m.name # :index




                          44
But what does that all mean?!
We all know and love
introspection, so take that to the
           next level...
• Better debbugers
  • Read MethodContext objects directly
• Richer information
  • Read method cache’s to find out common
    classes for arguments and locals



                       47
A Better Tool.
!=
How you can help

• Write tests / specs
• Write core library functionality
• Write VM code
• Port valgrind to OS X
  • Bounty available!

                       50
Evan Phoenix
http://rubini.us

       51

More Related Content

What's hot (6)

Building native Android applications with Mirah and Pindah
Building native Android applications with Mirah and PindahBuilding native Android applications with Mirah and Pindah
Building native Android applications with Mirah and Pindah
 
pyconjp2015_talk_Translation of Python Program__
pyconjp2015_talk_Translation of Python Program__pyconjp2015_talk_Translation of Python Program__
pyconjp2015_talk_Translation of Python Program__
 
Php engine
Php enginePhp engine
Php engine
 
Unix Shell Scripting Basics
Unix Shell Scripting BasicsUnix Shell Scripting Basics
Unix Shell Scripting Basics
 
Devel::NYTProf v5 at YAPC::NA 201406
Devel::NYTProf v5 at YAPC::NA 201406Devel::NYTProf v5 at YAPC::NA 201406
Devel::NYTProf v5 at YAPC::NA 201406
 
Opal compiler
Opal compilerOpal compiler
Opal compiler
 

Viewers also liked (10)

Emrubyconf
EmrubyconfEmrubyconf
Emrubyconf
 
Rubinius - Improving the Rails ecosystem
Rubinius - Improving the Rails ecosystemRubinius - Improving the Rails ecosystem
Rubinius - Improving the Rails ecosystem
 
2010 04-24-cerealize
2010 04-24-cerealize2010 04-24-cerealize
2010 04-24-cerealize
 
Server Development Workflow For PicCollage
Server Development Workflow For PicCollageServer Development Workflow For PicCollage
Server Development Workflow For PicCollage
 
2008-12-21 Rubinius
2008-12-21 Rubinius2008-12-21 Rubinius
2008-12-21 Rubinius
 
The Architecture of PicCollage Server
The Architecture of PicCollage ServerThe Architecture of PicCollage Server
The Architecture of PicCollage Server
 
2012 05-08-lambda-draft
2012 05-08-lambda-draft2012 05-08-lambda-draft
2012 05-08-lambda-draft
 
Rubinius @ RubyAndRails2010
Rubinius @ RubyAndRails2010Rubinius @ RubyAndRails2010
Rubinius @ RubyAndRails2010
 
Rubinius For You - GoRuCo
Rubinius For You - GoRuCoRubinius For You - GoRuCo
Rubinius For You - GoRuCo
 
Concurrent Ruby Application Servers
Concurrent Ruby Application ServersConcurrent Ruby Application Servers
Concurrent Ruby Application Servers
 

Similar to Rubinius - A Tool of the Future

Charles nutter star techconf 2011 - jvm languages
Charles nutter   star techconf 2011 - jvm languagesCharles nutter   star techconf 2011 - jvm languages
Charles nutter star techconf 2011 - jvm languages
StarTech Conference
 
javascript teach
javascript teachjavascript teach
javascript teach
guest3732fa
 
JSBootcamp_White
JSBootcamp_WhiteJSBootcamp_White
JSBootcamp_White
guest3732fa
 

Similar to Rubinius - A Tool of the Future (20)

IJTC%202009%20JRuby
IJTC%202009%20JRubyIJTC%202009%20JRuby
IJTC%202009%20JRuby
 
Scala Sjug 09
Scala Sjug 09Scala Sjug 09
Scala Sjug 09
 
A Re-Introduction to JavaScript
A Re-Introduction to JavaScriptA Re-Introduction to JavaScript
A Re-Introduction to JavaScript
 
Ruby Under The Hood
Ruby Under The HoodRuby Under The Hood
Ruby Under The Hood
 
Applying RSpec Best Practises
Applying RSpec Best PractisesApplying RSpec Best Practises
Applying RSpec Best Practises
 
Test First Teaching
Test First TeachingTest First Teaching
Test First Teaching
 
Ruby Topic Maps Tutorial (2007-10-10)
Ruby Topic Maps Tutorial (2007-10-10)Ruby Topic Maps Tutorial (2007-10-10)
Ruby Topic Maps Tutorial (2007-10-10)
 
A New Age of JVM Garbage Collectors (Clojure Conj 2019)
A New Age of JVM Garbage Collectors (Clojure Conj 2019)A New Age of JVM Garbage Collectors (Clojure Conj 2019)
A New Age of JVM Garbage Collectors (Clojure Conj 2019)
 
Hiveminder - Everything but the Secret Sauce
Hiveminder - Everything but the Secret SauceHiveminder - Everything but the Secret Sauce
Hiveminder - Everything but the Secret Sauce
 
Charles nutter star techconf 2011 - jvm languages
Charles nutter   star techconf 2011 - jvm languagesCharles nutter   star techconf 2011 - jvm languages
Charles nutter star techconf 2011 - jvm languages
 
javascript teach
javascript teachjavascript teach
javascript teach
 
JSBootcamp_White
JSBootcamp_WhiteJSBootcamp_White
JSBootcamp_White
 
Ruby for .NET developers
Ruby for .NET developersRuby for .NET developers
Ruby for .NET developers
 
error_highlight: User-friendly Error Diagnostics
error_highlight: User-friendly Error Diagnosticserror_highlight: User-friendly Error Diagnostics
error_highlight: User-friendly Error Diagnostics
 
Archeology for Entertainment, or Checking Microsoft Word 1.1a with PVS-Studio
Archeology for Entertainment, or Checking Microsoft Word 1.1a with PVS-StudioArcheology for Entertainment, or Checking Microsoft Word 1.1a with PVS-Studio
Archeology for Entertainment, or Checking Microsoft Word 1.1a with PVS-Studio
 
Experiments in Sharing Java VM Technology with CRuby
Experiments in Sharing Java VM Technology with CRubyExperiments in Sharing Java VM Technology with CRuby
Experiments in Sharing Java VM Technology with CRuby
 
Inferno Scalable Deep Learning on Spark
Inferno Scalable Deep Learning on SparkInferno Scalable Deep Learning on Spark
Inferno Scalable Deep Learning on Spark
 
Your Own Metric System
Your Own Metric SystemYour Own Metric System
Your Own Metric System
 
Master the Concepts Behind the Java 10 Challenges and Eliminate Stressful Bugs
Master the Concepts Behind the Java 10 Challenges and Eliminate Stressful BugsMaster the Concepts Behind the Java 10 Challenges and Eliminate Stressful Bugs
Master the Concepts Behind the Java 10 Challenges and Eliminate Stressful Bugs
 
Perl at SkyCon'12
Perl at SkyCon'12Perl at SkyCon'12
Perl at SkyCon'12
 

More from evanphx (10)

Developing a Language
Developing a LanguageDeveloping a Language
Developing a Language
 
Rubinius - What Have You Done For Me Lately?
Rubinius - What Have You Done For Me Lately?Rubinius - What Have You Done For Me Lately?
Rubinius - What Have You Done For Me Lately?
 
Rubinius - What Have You Done For Me Lately
Rubinius - What Have You Done For Me LatelyRubinius - What Have You Done For Me Lately
Rubinius - What Have You Done For Me Lately
 
Staking Your Claim In Open Source
Staking Your Claim In Open SourceStaking Your Claim In Open Source
Staking Your Claim In Open Source
 
Rubinius 1.0 and more!
Rubinius 1.0 and more!Rubinius 1.0 and more!
Rubinius 1.0 and more!
 
RubyConf 2009
RubyConf 2009RubyConf 2009
RubyConf 2009
 
Accelerating Ruby with LLVM
Accelerating Ruby with LLVMAccelerating Ruby with LLVM
Accelerating Ruby with LLVM
 
Ruby World
Ruby WorldRuby World
Ruby World
 
Rubinius Community - MWRC
Rubinius Community - MWRCRubinius Community - MWRC
Rubinius Community - MWRC
 
rubyconf 2007 - Rubinius 1.0
rubyconf 2007 - Rubinius 1.0rubyconf 2007 - Rubinius 1.0
rubyconf 2007 - Rubinius 1.0
 

Recently uploaded

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Recently uploaded (20)

EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu SubbuApidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
Apidays Singapore 2024 - Modernizing Securities Finance by Madhu Subbu
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 

Rubinius - A Tool of the Future

  • 1. A Tool of the Future aka the road to enlightenment 1
  • 2. Ask/give questions/comments. Both nice and nasty.
  • 3. Mantra of rubinius If it can be done in ruby, then it shouldn’t be in C. 3
  • 4. An idealist is a person who helps other people to be prosperous. Henry Ford
  • 5. the edges of the sword are life and death no one knows which is which Ikkyū Sōjun
  • 6. If you’re not failing every now and again, it’s a sign you’re not anything very innovative. Woody Allen
  • 7. KHAAAAANN! James T. Kirk
  • 8.
  • 9. • What is (and is not) rubinius? • Who is rubinius? • Features and Goals • Timeline • Technical Details • Demo / Questions 9
  • 11. What. • A brand new ruby engine • Bytecode Virtual Machine based • Generational Garbage Collection 11
  • 12. Why. • Fun • A desire for a better interpreter 12
  • 13. Why pt. 2 • Every talk at this conference has mentioned some limitation of ruby. • All limitations are limitations of the current interpreter, not the language. 13
  • 14. What it’s not. • Vaporware • A thesis project • Finished. 14
  • 15. Who. • Aki Reijonen (loop) Evan Phoenix (evan) • Mat Elder (mae) Brian Ford (brixen) • John Hornbeck (hornbeck) Wilson Bilkovich (Defiler) • Carsten Bormann (cabo) Pat Eyler (pate) • Devin Walters (defn) Alan Hurdle (hurdlea) • Frederick Ros (sleeper) Thomas Lockney (tlockney) • Alexander Kellet (lypanov) Eero Saynatkai (rue) • Mikko Lehtonen (scoopr) 15
  • 16. Features and Goals • Remember the Mantra! • VM in C only • Includes primitive operations • Extensive tests and specs • Core library in ruby • Array#dup, Method#new, Object#instance_eval 16
  • 17. • 1.8.5 compatible • 98% first class • Easy to understand, easy to extend, easy to optimize • MRI (Matz Ruby Interpreter) C API compatible 17
  • 18. Timeline. • 1.0 by October, 2007 - RubyConf • Near 100% compatible with 1.8.5 • Able to run rails 1.2 • 2.0 • JIT • Optimizers 18
  • 19. Technical Details • 5 core sections • CPU • Primitives • Compiler • Object Memory / Garbage Collection • Core library 19
  • 20. CPU • Fully bytecode based • All bytecodes are written test first • Leverage GCC to make help make fast 20
  • 21. Threads • Currently supports green threads • Contains low level sychronization / sharing mechanism called Channel • A PI Calculus-like channel • Native Thread support in a MxN scheme • (eventually) 21
  • 22. Primitives • The most basic method • Written C (for now) • Provide most basic functionality 22
  • 23. Compiler • Completely written in ruby • COMPLETELY WRITTEN IN RUBY • Self bootstrapped from initial rubinius prototype • Pipeline based architecture 23
  • 24. # rbx sirb -p -s -b sirb(eval):000> puts “hello evan”
  • 26. [:newline, 1, "(eval)", [:fcall, :puts, [:array, [:str, "hello evan"]]]]
  • 29. • Every stage is directly accessible • Think: new parsers that output rubinius assembly • LISP • Smalltalk • Erlang 29
  • 30. • Compiler is a normal class, which open doors... • Compile ERB templates directly into CompiledMethods • Ability to remove Kernel#eval if an application of rubinius warrants it 30
  • 31. “The Reaper” (Object Memory / Garbage Collection) • Generational Collector • Young Objects: Baker two-space compacting collector • Mature Objects: Mark/Sweep collector 31
  • 32. Infanticide • Young objects live fast and die young (usually) • Once an object survives for a while, it’s promoted to the mature object space. • Compaction keeps the memory footprint small. 32
  • 33. The Old Guard • Mature objects are collected 10 to 30 times less often than young objects. • All object access in VM is done through the “write barrier”, which maintains the set of mature objects that reference young objects. • Objects themselves are not marked, making rubinius very “fork friendly”. 33
  • 34. Core library • Everything you’ve come to love, now in written in ruby. 34
  • 35. def [](arg, len = nil) if len len = len.to_i return nil if len 0 end if arg.is_a? String unless len.nil? raise ArgumentError.new(String#[] cannot accept a second argument with a String.) end return (self.include?(arg) ? arg.dup : nil) elsif arg.respond_to? :match m = arg.match(self) return m[len.to_i] if m len return m[0] if m return nil elsif arg.respond_to?(:first) and arg.respond_to?(:last) from = arg.first to = arg.last to -= 1 if arg.respond_to?(:exclude_end?) arg.exclude_end? size = self.size from = from + size if from 0 to += size if to 0 len = to - from + 1 self[from, len] elsif arg and arg.respond_to?(:to_i) arg = arg.to_i String#[] size = self.size arg = arg + size if arg 0 if 0 = arg arg size if len len = size - arg if arg + len = size substring(arg, len) else @data[arg] end else # invalid start index len ? : nil end else raise ArgumentError.new(String#[] cannot accept #{arg.class} objects) end
  • 36. def parent a=3 ask_child(a) puts OMG #{a} PONIES! end def ask_child(initial_pony_count) ctx = MethodContext.current.sender # Will be ctx.locals[:a] = 9 soon. ctx.locals[2] = 9 end parent()
  • 38. Nothing is sacred. (evil built in)
  • 39. Backtraces vatu :: rbx-branches/event ./shotgun/rubinius ctx.rb An exception has occured: No method 'ask_child' on an instance of Object. (NoMethodError) Backtrace: NoMethodError#initialize at core/exception.rb:47 NoMethodError.new at bootstrap/class.rb:8 main.ask_child (method_missing) at bootstrap/method_missing.rb:8 main.parent at ctx.rb:3 main.__script__ at ctx.rb:12 main.load at core/compile.rb:56 main.__script__ at core/__loader.rb:95 39
  • 40. MethodTables class Blah end class Foo def hello puts “hello evan” end end Blah.methods[:hello_also] = Foo.methods[:hello] Blah.new.hello_also # hello evan 40
  • 41. It’s your party. class Mu nil end p Mu.instance_methods # [] p Mu.superclass # nil you still mad? 41
  • 42. Zen and the Art of Object Creation 42
  • 43. VM level Sampler s = Sampler.new(100) # 100 hz s.start 100000.times { 1 + 1 } s.stop s.results.size # 332 43
  • 44. CompiledMethods m = Array.methods[:index] p m # #CompiledMethod:0x32a34 ... p m.name # :index 44
  • 45. But what does that all mean?!
  • 46. We all know and love introspection, so take that to the next level...
  • 47. • Better debbugers • Read MethodContext objects directly • Richer information • Read method cache’s to find out common classes for arguments and locals 47
  • 49. !=
  • 50. How you can help • Write tests / specs • Write core library functionality • Write VM code • Port valgrind to OS X • Bounty available! 50