gc.c: no deletion in wmap_mark

* gc.c (wmap_mark): disable deletion of dead objects by default,
  so that WeakMap can be non-shady.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44149 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2013-12-12 07:43:36 +00:00
Родитель 8920ac2972
Коммит 89b8502257
1 изменённых файлов: 6 добавлений и 0 удалений

6
gc.c
Просмотреть файл

@ -6229,6 +6229,9 @@ struct weakmap {
VALUE final;
};
#define WMAP_DELETE_DEAD_OBJECT_IN_MARK 0
#if WMAP_DELETE_DEAD_OBJECT_IN_MARK
static int
wmap_mark_map(st_data_t key, st_data_t val, st_data_t arg)
{
@ -6237,12 +6240,15 @@ wmap_mark_map(st_data_t key, st_data_t val, st_data_t arg)
if (!is_live_object(objspace, obj)) return ST_DELETE;
return ST_CONTINUE;
}
#endif
static void
wmap_mark(void *ptr)
{
struct weakmap *w = ptr;
#if WMAP_DELETE_DEAD_OBJECT_IN_MARK
if (w->obj2wmap) st_foreach(w->obj2wmap, wmap_mark_map, (st_data_t)&rb_objspace);
#endif
rb_gc_mark(w->final);
}