4. MacRuby
•
2007: Project created (as a hobby)
•
Replacement for RubyCocoa
•
Fork of CRuby 1.9
•
2008: Had a beer with Chris Lattner
•
2009: Replaced bytecode VM by LLVM JIT
•
2011: Left Apple
6. RubyMotion
•
Command-line toolchain for iOS / OS X dev
•
Implementation of Ruby dialect
•
Unified Ruby runtime with Objective-C
•
Static compiler for Ruby into Intel/ARM
•
Platform for wrappers/libraries ecosystem
•
Commercial product & sustainable business
7. RubyMotion
•
Command-line toolchain for iOS / OS X dev
•
Implementation of Ruby dialect
•
Unified Ruby runtime with Objective-C
•
Static compiler for Ruby into Intel/ARM
•
Platform for wrappers/libraries ecosystem
•
Commercial product & sustainable business
15. File functions
class Hello
def initialize(something)
…
end
def say
…
end
end
!
class Ohai < Hello
def say
…
end
end
!
Hello.new(‘world’).say
File Scope
1
5
3
Hello
Ctor
2
Hello
Scope
Ohai
Ctor
4
Ohai
Scope
File
Code
34. Exceptions
•
Implemented as C++ exceptions
•
Zero-cost for “normal flow”
•
Handlers are compiled using IR intrinsics
•
•
“catch all” landing pad clause
Exception#raise triggers __cxa_raise()
35. DWARF
•
All instructions have proper debug location
metadata
•
Method/block arguments and local variables are
tagged as DW_TAG_{arg,auto}_variable
•
Build system generates a .dSYM bundle
•
Can be loaded by gdb/lldb, atos(1), profilers, etc.
36. REPL
•
Allows to interpret expressions at runtime
•
Only for development (simulator)
•
App process loads the compiler
•
Uses JIT execution engine
38. LLVM lessons
Pluses
• Great to write static
compilers
• Easy to target new
platforms
• Lots of great
optimization passes
Minuses
• C++ API breakage
• Huge code size
• IR is not 100% portable
• Proprietary backends
• Not as great to use as a JIT