[ANN] ByteCodeRuby 0.1.3

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:

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

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.

you say a virtual machine. what virtual machine does it use?

A good VM target could be the Parrot VM being built for Perl 6. Python
and Java front-ends are already being planned, IIRC. It should be fast,
portable, and powerful. I’m not sure how far along it is, though. Last I
read, a few months ago, they had most of the assembly for the machine
working, and some Hello World programs running, but no compilers yet,
even for Perl. May have changed by now.

-Justin

···

On Wednesday, December 18, 2002, at 08:19 , Tom Sawyer wrote:

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.

you say a virtual machine. what virtual machine does it use?

Its own! It’s both a compiler and an interpreter for the compiled
bytecode. ByteCodeRuby looks after everything that is bytecode-ish,
but depends on standard Ruby for parsing, the object model and the
standard Ruby API.

– George

···

Tom Sawyer transami@transami.net wrote:

you say a virtual machine. what virtual machine does it use?