Forum: IronRuby Code Review: LazyMethods

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Cb51033949ffccd982ae32c9f890f25a?d=identicon&s=25 Tomas Matousek (Guest)
on 2009-06-05 00:32
(Received via mailing list)
Attachment: LazyMethods.diff (50 KB)
tfpt review "/shelveset:LazyMethods;REDMOND\tomat"

A simple change in DLR.

Ruby:
  Implements lazy method transformation. Previously a method was
transformed to DLR AST as soon as it was defined (def foo; ...; end). We
can postpone the transformation until the method is called for the first
time. This significantly improves startup time. For example (not
NGEN'd):

  require 'benchmark'

  Benchmark.bm { |x|   x.report {  require 'rubygems'  }  }

        user     system      total        real
  eager transformation
    1.622410   0.031200   1.653611 (  1.581316)
  lazy transformation
    1.170008   0.031200   1.201208 (  1.099220)

  Although Ruby methods (unlike block) don't close over variables we
still need 2 closure variables: the parent lexical runtime scope and the
module that the method is declared in (for implementation of super).
These were previously DLR closure variables. They are live constants
now. Ruby method pre-compilation would require additional work, so we
don't support it for now.

Tomas
F983f0c990cba2fe743ef62a975ec99c?d=identicon&s=25 Curt Hagenlocher (Guest)
on 2009-06-05 17:44
(Received via mailing list)
Looks good overall.

Should RubyContext.CallSiteCreated be ThreadLocal? If not, its use by
CallSiteTracer looks not-entirely-safe.

The variable name "parantScope" in RubyOps.CreateMethodScope is typoed.
Cb51033949ffccd982ae32c9f890f25a?d=identicon&s=25 Tomas Matousek (Guest)
on 2009-06-05 19:53
(Received via mailing list)
Good catch on thread-safety. This delegate is actually experimental
(demo-ware :)) so it doesn't matter so much. I'll add a comment that
thread-safety needs to be considered.

Tomas
This topic is locked and can not be replied to.