Project

General

Profile

Actions

Feature #11146

closed

[PATCH] variable.c: initialize generic_iv_tbl at start

Added by normalperson (Eric Wong) over 7 years ago. Updated about 7 years ago.

Status:
Closed
Priority:
Normal
Target version:
-
[ruby-core:69155]

Description

Even miniruby creates one generic ivar (plain "ruby" creates 9),
so there's no point in lazily allocating the table and increasing
lines of code.

I'll commit in a few days unless there's objections.

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)

Files

Actions

Also available in: Atom PDF