Skip to content

Commit 8d4253f

Browse files
committed
* 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
1 parent 3705007 commit 8d4253f

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
Tue Dec 10 15:15:37 2013 Koichi Sasada <ko1@atdot.net>
2+
3+
* gc.c (gc_marks_check): disable GC during checking and
4+
restore malloc_increase info.
5+
16
Tue Dec 10 14:41:53 2013 Aman Gupta <ruby@tmm1.net>
27

38
* gc.c (reflist_add): return 0 if reference already exists

gc.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4262,8 +4262,6 @@ objspace_allrefs(rb_objspace_t *objspace)
42624262
struct mark_func_data_struct mfd;
42634263
VALUE obj;
42644264

4265-
rb_gc_disable();
4266-
42674265
data.objspace = objspace;
42684266
data.references = st_init_numtable();
42694267

@@ -4281,7 +4279,6 @@ objspace_allrefs(rb_objspace_t *objspace)
42814279
}
42824280
shrink_stack_chunk_cache(&objspace->mark_stack);
42834281

4284-
rb_gc_enable();
42854282
return data.references;
42864283
}
42874284

@@ -4379,8 +4376,14 @@ gc_check_after_marks_i(st_data_t k, st_data_t v, void *ptr)
43794376
static void
43804377
gc_marks_check(rb_objspace_t *objspace, int (*checker_func)(ANYARGS), const char *checker_name)
43814378
{
4382-
objspace->rgengc.allrefs_table = objspace_allrefs(objspace);
4379+
4380+
size_t saved_malloc_increase = objspace->malloc_params.increase;
4381+
#if RGENGC_ESTIMATE_OLDMALLOC
4382+
size_t saved_oldmalloc_increase = objspace->rgengc.oldmalloc_increase;
4383+
#endif
4384+
VALUE already_disabled = rb_gc_disable();
43834385

4386+
objspace->rgengc.allrefs_table = objspace_allrefs(objspace);
43844387
st_foreach(objspace->rgengc.allrefs_table, checker_func, (st_data_t)objspace);
43854388

43864389
if (objspace->rgengc.error_count > 0) {
@@ -4392,6 +4395,12 @@ gc_marks_check(rb_objspace_t *objspace, int (*checker_func)(ANYARGS), const char
43924395

43934396
objspace_allrefs_destruct(objspace->rgengc.allrefs_table);
43944397
objspace->rgengc.allrefs_table = 0;
4398+
4399+
if (already_disabled == Qfalse) rb_gc_enable();
4400+
objspace->malloc_params.increase = saved_malloc_increase;
4401+
#if RGENGC_ESTIMATE_OLDMALLOC
4402+
objspace->rgengc.oldmalloc_increase = saved_oldmalloc_increase;
4403+
#endif
43954404
}
43964405

43974406
#endif /* RGENGC_CHECK_MODE >= 2 */

0 commit comments

Comments
 (0)