I am happy to announce the release of Ruby2CExtension 0.2.0.
Ruby2CExtension is a Ruby to C extension translator/compiler. It takes
any Ruby source file, parses it using Ruby’s builtin parser and then
translates the abstract syntax tree into “equivalent” C extension code.
More information at http://ruby2cext.rubyforge.org/.
Ruby2CExtension is available as gem now, so installation is as simple
gem install ruby2cext
(There is also a setup.rb-release available.)
Ruby2CExtension 0.2.0 supports Ruby 1.8.4 to 1.8.6 (including the
The two major new features are Eval2C and the new optimizations.
Eval2C allows transparent compilation of Ruby code at runtime. This
allows to compile (and speedup) code that is generated at runtime. It
also makes it possible to compile only selected parts of Ruby files.
feature is similar to RubyInline, but works with Ruby code instead of C
More information at http://ruby2cext.rubyforge.org/eval2c.html.
The new optional optimizations can provide speedups for Ruby code by
sacrificing some compatibility. In particular the optimization of calls
to (C-implemented) methods of built-in classes can significantly speedup
max = 2000
z = x = 0
while (x+=1) <= max
y = 0
while (y+=1) <= max
z = (x+y-z) % 32000
The compiled version (with all optimizations turned on) of this program
is about seven times faster than the uncompiled version. This is an
extreme example, because almost all method calls are optimized, but it
shows what is possible.
More information at http://ruby2cext.rubyforge.org/optimizations.html.
- New plugin architecture for optimizations and other things
- Optimization plugins: const_cache, builtin_methods, inline_methods,
- Other plugins: require_include, warnings
- Eval2C for compilation at runtime
- Available as gem now
- Implemented control flow “through” rescue/ensure clauses
- Better vmode handling
- Support for Ruby 1.8.5 and 1.8.6
- Improved performance for global variables
- Workaround for an issue with ALLOCA_N in while loops
- Fixed a problem with case/when (missing newline nodes)
- Removed libraries from compile command
- Various other small fixes