[ruby-cvs:57717] normal:r50569 (trunk): variable.c: generic_iv_tbl is unavoidable

normal at ruby-lang.org normal at ruby-lang.org
Thu May 21 09:15:01 JST 2015


normal	2015-05-21 09:15:00 +0900 (Thu, 21 May 2015)

  New Revision: 50569

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

  Log:
    variable.c: generic_iv_tbl is unavoidable
    
    Even miniruby creates one generic ivar (plain "ruby" creates 9),
    so there's no point in lazily allocating the table.
    
    I dumped generic ivar counts with the following trivial patch:
    
      --- a/variable.c
      +++ b/variable.c
      @@ -24,6 +24,10 @@ static void check_before_mod_set(VALUE, ID, VALUE, const char *);
       static void setup_const_entry(rb_const_entry_t *, VALUE, VALUE, rb_const_flag_t);
       static int const_update(st_data_t *, st_data_t *, st_data_t, int);
       static st_table *generic_iv_tbl;
      +__attribute__((destructor)) static void count_genivar(void)
      +{
      +    fprintf(stderr, "genivars: %zu\n", (size_t)generic_iv_tbl->num_entries);
      +}
    
       void
       Init_var_tables(void)
    
    * variable.c (Init_var_tables): init generic_iv_tbl
      (rb_generic_ivar_table, generic_ivar_get, generic_ivar_set,
       generic_ivar_defined, generic_ivar_remove,
       rb_mark_generic_ivar, givar_i, rb_mark_generic_ivar_tbl,
       rb_free_generic_ivar, rb_copy_generic_ivar, rb_ivar_foreach,
       rb_ivar_count): remove checks for uninitialize generic_iv_tbl
      [ruby-core:69155] [Feature #11146]

  Modified files:
    trunk/ChangeLog
    trunk/variable.c


More information about the ruby-cvs mailing list