From 8d4253f7e15efa8284e111ba1bc965d81e55560c Mon Sep 17 00:00:00 2001 From: ko1 Date: Tue, 10 Dec 2013 06:21:52 +0000 Subject: [PATCH] * gc.c (gc_marks_check): disable GC during checking and restore malloc_increase info. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44110 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ gc.c | 17 +++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index ac9bbefba2..58835c42bc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Tue Dec 10 15:15:37 2013 Koichi Sasada + + * gc.c (gc_marks_check): disable GC during checking and + restore malloc_increase info. + Tue Dec 10 14:41:53 2013 Aman Gupta * gc.c (reflist_add): return 0 if reference already exists diff --git a/gc.c b/gc.c index fe006ad81b..977652e7d9 100644 --- a/gc.c +++ b/gc.c @@ -4262,8 +4262,6 @@ objspace_allrefs(rb_objspace_t *objspace) struct mark_func_data_struct mfd; VALUE obj; - rb_gc_disable(); - data.objspace = objspace; data.references = st_init_numtable(); @@ -4281,7 +4279,6 @@ objspace_allrefs(rb_objspace_t *objspace) } shrink_stack_chunk_cache(&objspace->mark_stack); - rb_gc_enable(); return data.references; } @@ -4379,8 +4376,14 @@ gc_check_after_marks_i(st_data_t k, st_data_t v, void *ptr) static void gc_marks_check(rb_objspace_t *objspace, int (*checker_func)(ANYARGS), const char *checker_name) { - objspace->rgengc.allrefs_table = objspace_allrefs(objspace); + + size_t saved_malloc_increase = objspace->malloc_params.increase; +#if RGENGC_ESTIMATE_OLDMALLOC + size_t saved_oldmalloc_increase = objspace->rgengc.oldmalloc_increase; +#endif + VALUE already_disabled = rb_gc_disable(); + objspace->rgengc.allrefs_table = objspace_allrefs(objspace); st_foreach(objspace->rgengc.allrefs_table, checker_func, (st_data_t)objspace); if (objspace->rgengc.error_count > 0) { @@ -4392,6 +4395,12 @@ gc_marks_check(rb_objspace_t *objspace, int (*checker_func)(ANYARGS), const char objspace_allrefs_destruct(objspace->rgengc.allrefs_table); objspace->rgengc.allrefs_table = 0; + + if (already_disabled == Qfalse) rb_gc_enable(); + objspace->malloc_params.increase = saved_malloc_increase; +#if RGENGC_ESTIMATE_OLDMALLOC + objspace->rgengc.oldmalloc_increase = saved_oldmalloc_increase; +#endif } #endif /* RGENGC_CHECK_MODE >= 2 */