After a long delay, version 0.1.3 of ByteCodeRuby is now available
from the RubyVM project on SourceForge:
http://sourceforge.net/project/showfiles.php?group_id=26000
See below for an introduction to what it’s all about + a snippet from
the change log showing what’s new at this release.
If anyone wants to get involved, I’d love some help with:
- integration with the garbage collector
- threads and continuations (gulp!)
- moving to VMGen (http://www.complang.tuwien.ac.at/anton/vmgen)
- or, more simply, implementing something like range literals or
unless/until
I’d also be very interested in hearing from anyone who has success
running this version on anything other than Linux. Previous versions
worked OK on Windows and Solaris, so there is hope!
– George
What is it?
···
A bytecode interpreter for Ruby. Standard Ruby produces a parse tree
from your source code and then interprets the parse tree directly.
ByteCodeRuby inserts some additional steps: it takes Ruby’s parse tree
and compiles it to bytecode, ie the instruction set for a virtual
machine. It then interprets the bytecode. The hope is that this
approach will eventually lead to improved performance for the Ruby
interpreter.
It consists of a (minor) patch to Ruby 1.6.7’s eval.c, ruby.h and
node.h, a C extension and some Ruby code. It’s currently at an
experimental stage (you won’t be able to run your favourite Ruby
script with it), but it can nonetheless compile and run a fairly large
(and increasing) subset of Ruby.
Changes since 0.1.2
- exceptions: can now catch exception into local variable
- temp stack is now allocated from same memory as stack frames
- Hash literals, Hash arguments to methods
- classes now work correctly: scope, nested classes, superclasses
- refactor some of bc_runner.c
- raise and rescue across C calls
- simplify compilation of rescue statements - there are now too
many gotos, but it’s a lot easier to understand! - compile calls to super