[MacRuby-devel] experimental branch: status update
Laurent Sansonetti
lsansonetti at apple.com
Sat Jun 20 19:06:56 PDT 2009
Yet another status update on the experimental branch work!
Highlights are:
- More Ruby & Cocoa compatibility work. All samples should now run on
experimental on both 10.5 and 10.6. Rake and HotCocoa are now somewhat
usable (but not at 100% yet).
- Floating-point arithmetic optimization (see below for more info).
Detailed changes:
- Fixed #method_missing to omit the trailing ':' in case the method
only accepts one argument.
- Fixed a bug in the dispatcher, where #method_missing was sometimes
called instead of raising a ArgumentError exception.
- Fixed misc bugs in the following methods: ObjectSpace#_id2ref,
ObjectSpace#define_finalizer, ObjectSpace#each_object,
Float.induced_from, IO#close_on_exec, IO#reopen, IO#readpartial,
IO.copy_stream, IO#lineno, IO#lineno=, IO#print, IO#tty?,
File.expand_path, File.join, Proc#binding
- Added support for overwriting an Objective-C method that accepts a C
pointer.
- Added support in the dispatcher for objects using -[NSObject
forwardInvocation:].
- Fixed a bug in the allocation of pure Ruby objects, that weren't
marked as objects by the GC.
- Fixed lots of IO bugs. More importantly, IO finalizers are now
called by the GC.
- Added a very basic implementation for #define_method.
- Fixed a silly bug in #class_eval or #module_eval when the VM wasn't
properly handling the current class.
- Fixed a constant lookup bug in the way we mark metaclass outers.
- Fixed a critical memory crasher when trying to re-allocate out-of-
scope block locals.
- Fixed the creation of Binding objects to that they include block
locals.
- Fixed a bug when promoting ivars used inside an eval string for slot-
based optimization.
- Added support for automatic Boxed/Array conversion to a C pointer.
- Added the following methods to the Boxed class: #to_a, #[], #[]=
- Fixed a bug in #undef_method which wasn't working on >0 arity
selectors.
- Optimized the call to #default in Hash#[].
- Fixed a performance problem when preparing blocks: the same block
LLVM function was sometimes optimized and JIT'ed more than once.
- Merged with RubySpec upstream twice. More importantly, FFI specs are
now available.
- Merged stdlib from trunk.
- Added a macruby_select(1) tool, that allows you to run a given
expression on a given MacRuby version.
- Optimized a few code paths in HotCocoa::Graphics to use Boxed types
instead of Array objects.
- Added a live demo for HotCocoa::Graphics. You can run it by doing
the following:
$ cd sample-macruby/HotCocoa/graphics
$ macruby demo.rb
Note that performance work is still under work.
- Implemented Symbol#to_proc.
- Fixed a bug when re-entrantly calling a block.
- Added an optimization regarding floating point types.
Firstly, floats are now immediate objects (like Fixnums) and not true
objects anymore, which means we don't need to allocate extra memory in
order to create a float. This is great for us because our memory
allocator is slow, so we are able to do efficient floating point
handling. The downside is that we lose 2 bits of precision, but some
early tests revealed that this is a minor issue and we can still box
edge cases as before.
Secondly, the compiler is now generating optimized code when dealing
with floating point arithmetic expressions, exactly like we currently
optimize Fixnum arithmetic.
This is a very important change for MacRuby, because floats are used
thoroughly in Cocoa. As instance, in drawing methods, or when dealing
with NSPoint/Size/Rect structures, etc.
A simple benchmark looping on a float.
$ time macruby_select 0.4 -e "i=0.0; while i<10000000; i+=1; end"
real 0m8.239s
user 0m12.182s
sys 0m0.537s
$ time macruby_select 0.5 -e "i=0.0; while i<10000000; i+=1; end"
real 0m0.340s
user 0m0.264s
sys 0m0.072s
A second one, using an NSPoint structure.
$ time macruby_select 0.4 -e 'framework "Foundation";
p=NSPoint.new(1,2); i=0; while i<5000000; p.x=i; i+=1; end'
real 0m9.636s
user 0m13.762s
sys 0m0.612s
$ time macruby_select 0.5 -e 'framework "Foundation";
p=NSPoint.new(1,2); i=0; while i<5000000; p.x=i; i+=1; end'
real 0m0.897s
user 0m0.820s
sys 0m0.081s
Also, I profited of this change to optimize a little bit more Fixnum
arithmetic. Here are numbers for the old miniruby vs the new one
regarding fib(40).
$ time ./miniruby_old fib.rb 40
102334155
real 0m3.978s
user 0m3.840s
sys 0m0.064s
$ time ./miniruby fib.rb 40
102334155
real 0m3.282s
user 0m3.179s
sys 0m0.057s
Our next goal is to be able to fully run Rake and HotCocoa, to
ultimately start planning the merge of the experimental branch into
trunk.
Laurent
More information about the MacRuby-devel
mailing list