[ruby-cvs:60062] normal:r52909 (trunk): introduce rb_autoload_str to replace rb_autoload

normal at ruby-lang.org normal at ruby-lang.org
Sun Dec 6 21:28:10 JST 2015


normal	2015-12-06 21:28:09 +0900 (Sun, 06 Dec 2015)

  New Revision: 52909

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=52909

  Log:
    introduce rb_autoload_str to replace rb_autoload
    
    rb_autoload_str may be safer by preventing premature GC.  It
    can also be more efficient by passing a pre-frozen string that
    can be deduped using rb_fstring.  Common autoload callers (e.g.
    rubygems, rdoc) already use string literals as the file
    argument.
    
    There seems to be no reason to expose rb_autoload_str to the
    public C API since autoload is not performance-critical.
    Applications may declare autoloads in Ruby code or via
    rb_funcall; so merely deprecate rb_autoload without exposing
    rb_autoload_str to new users.
    
    Running: valgrind -v ruby -rrdoc -rubygems -e exit
    shows a minor memory reduction (32-bit userspace)
    
    before:
    
      in use at exit: 1,600,621 bytes in 28,819 blocks
    total heap usage: 55,786 allocs, 26,967 frees, 6,693,790 bytes allocated
    
    after:
    
      in use at exit: 1,599,778 bytes in 28,789 blocks
    total heap usage: 55,739 allocs, 26,950 frees, 6,692,973 bytes allocated
    
    * include/ruby/intern.h (rb_autoload): deprecate
    * internal.h (rb_autoload_str): declare
    * load.c (rb_mod_autoload): use rb_autoload_str
    * variable.c (rb_autoload): become compatibility wrapper
      (rb_autoload_str): hoisted out from old rb_autoload
      [ruby-core:71369] [Feature #11664]

  Modified files:
    trunk/ChangeLog
    trunk/NEWS
    trunk/include/ruby/intern.h
    trunk/internal.h
    trunk/load.c
    trunk/variable.c


More information about the ruby-cvs mailing list