ruby-changes:38706
From: ko1 <ko1@a...>
Date: Sat, 6 Jun 2015 08:00:29 +0900 (JST)
Subject: [ruby-changes:38706] ko1:r50787 (trunk): * gc.c: remove struct mark_tbl_arg and pass objspace directly
ko1 2015-06-06 08:00:22 +0900 (Sat, 06 Jun 2015) New Revision: 50787 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=50787 Log: * gc.c: remove struct mark_tbl_arg and pass objspace directly to avoid indirect access overhead. Modified files: trunk/ChangeLog trunk/gc.c Index: ChangeLog =================================================================== --- ChangeLog (revision 50786) +++ ChangeLog (revision 50787) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Sat Jun 6 07:58:30 2015 Koichi Sasada <ko1@a...> + + * gc.c: remove struct mark_tbl_arg and pass objspace directly + to avoid indirect access overhead. + Sat Jun 6 07:08:45 2015 Eric Wong <e@8...> * ext/socket/ancdata.c (bsock_sendmsg_internal): drop redundant assignment Index: gc.c =================================================================== --- gc.c (revision 50786) +++ gc.c (revision 50787) @@ -3855,42 +3855,34 @@ rb_gc_mark_values(long n, const VALUE *v https://github.com/ruby/ruby/blob/trunk/gc.c#L3855 #define rb_gc_mark_locations(start, end) gc_mark_locations(objspace, (start), (end)) -struct mark_tbl_arg { - rb_objspace_t *objspace; -}; - static int mark_entry(st_data_t key, st_data_t value, st_data_t data) { - struct mark_tbl_arg *arg = (void*)data; - gc_mark(arg->objspace, (VALUE)value); + rb_objspace_t *objspace = (rb_objspace_t *)data; + gc_mark(objspace, (VALUE)value); return ST_CONTINUE; } static void mark_tbl(rb_objspace_t *objspace, st_table *tbl) { - struct mark_tbl_arg arg; if (!tbl || tbl->num_entries == 0) return; - arg.objspace = objspace; - st_foreach(tbl, mark_entry, (st_data_t)&arg); + st_foreach(tbl, mark_entry, (st_data_t)objspace); } static int mark_key(st_data_t key, st_data_t value, st_data_t data) { - struct mark_tbl_arg *arg = (void*)data; - gc_mark(arg->objspace, (VALUE)key); + rb_objspace_t *objspace = (rb_objspace_t *)data; + gc_mark(objspace, (VALUE)key); return ST_CONTINUE; } static void mark_set(rb_objspace_t *objspace, st_table *tbl) { - struct mark_tbl_arg arg; if (!tbl) return; - arg.objspace = objspace; - st_foreach(tbl, mark_key, (st_data_t)&arg); + st_foreach(tbl, mark_key, (st_data_t)objspace); } void @@ -3902,19 +3894,18 @@ rb_mark_set(st_table *tbl) https://github.com/ruby/ruby/blob/trunk/gc.c#L3894 static int mark_keyvalue(st_data_t key, st_data_t value, st_data_t data) { - struct mark_tbl_arg *arg = (void*)data; - gc_mark(arg->objspace, (VALUE)key); - gc_mark(arg->objspace, (VALUE)value); + rb_objspace_t *objspace = (rb_objspace_t *)data; + + gc_mark(objspace, (VALUE)key); + gc_mark(objspace, (VALUE)value); return ST_CONTINUE; } static void mark_hash(rb_objspace_t *objspace, st_table *tbl) { - struct mark_tbl_arg arg; if (!tbl) return; - arg.objspace = objspace; - st_foreach(tbl, mark_keyvalue, (st_data_t)&arg); + st_foreach(tbl, mark_keyvalue, (st_data_t)objspace); } void @@ -3962,8 +3953,9 @@ static int https://github.com/ruby/ruby/blob/trunk/gc.c#L3953 mark_method_entry_i(st_data_t key, st_data_t value, st_data_t data) { VALUE me = (VALUE)value; - struct mark_tbl_arg *arg = (void*)data; - gc_mark(arg->objspace, me); + rb_objspace_t *objspace = (rb_objspace_t *)data; + + gc_mark(objspace, me); return ST_CONTINUE; } @@ -3971,9 +3963,7 @@ static void https://github.com/ruby/ruby/blob/trunk/gc.c#L3963 mark_m_tbl(rb_objspace_t *objspace, struct st_table *tbl) { if (tbl) { - struct mark_tbl_arg arg; - arg.objspace = objspace; - st_foreach(tbl, mark_method_entry_i, (st_data_t)&arg); + st_foreach(tbl, mark_method_entry_i, (st_data_t)objspace); } } @@ -3981,19 +3971,18 @@ static int https://github.com/ruby/ruby/blob/trunk/gc.c#L3971 mark_const_entry_i(st_data_t key, st_data_t value, st_data_t data) { const rb_const_entry_t *ce = (const rb_const_entry_t *)value; - struct mark_tbl_arg *arg = (void*)data; - gc_mark(arg->objspace, ce->value); - gc_mark(arg->objspace, ce->file); + rb_objspace_t *objspace = (rb_objspace_t *)data; + + gc_mark(objspace, ce->value); + gc_mark(objspace, ce->file); return ST_CONTINUE; } static void mark_const_tbl(rb_objspace_t *objspace, st_table *tbl) { - struct mark_tbl_arg arg; if (!tbl) return; - arg.objspace = objspace; - st_foreach(tbl, mark_const_entry_i, (st_data_t)&arg); + st_foreach(tbl, mark_const_entry_i, (st_data_t)objspace); } #if STACK_GROW_DIRECTION < 0 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/