From 51101947bb964dde5808a8a9bd8b67879498f58f Mon Sep 17 00:00:00 2001 From: ko1 Date: Thu, 11 Sep 2014 10:23:36 +0000 Subject: * gc.c (gc_mark_ptr): rename to gc_mark_set. * gc.c (gc_mark): add gc_mark_ptr() to skip is_markable_object() check. gc_mark_maybe() can use gc_mark_ptr() directly because passed pointer is checked by is_pointer_to_heap(). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47532 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- gc.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'gc.c') diff --git a/gc.c b/gc.c index 0f74f80d5d..3970c8334d 100644 --- a/gc.c +++ b/gc.c @@ -769,6 +769,7 @@ static void gc_sweep_rest(rb_objspace_t *objspace); static void gc_sweep_continue(rb_objspace_t *objspace, rb_heap_t *heap); static void gc_mark(rb_objspace_t *objspace, VALUE ptr); +static void gc_mark_ptr(rb_objspace_t *objspace, VALUE ptr); static void gc_mark_maybe(rb_objspace_t *objspace, VALUE ptr); static void gc_mark_children(rb_objspace_t *objspace, VALUE ptr); @@ -3855,7 +3856,7 @@ gc_mark_maybe(rb_objspace_t *objspace, VALUE obj) if (is_pointer_to_heap(objspace, (void *)obj)) { int type = BUILTIN_TYPE(obj); if (type != T_ZOMBIE && type != T_NONE) { - gc_mark(objspace, obj); + gc_mark_ptr(objspace, obj); } } } @@ -3867,7 +3868,7 @@ rb_gc_mark_maybe(VALUE obj) } static inline int -gc_mark_ptr(rb_objspace_t *objspace, VALUE obj) +gc_mark_set(rb_objspace_t *objspace, VALUE obj) { if (RVALUE_MARKED(obj)) return 0; MARK_IN_BITMAP(GET_HEAP_MARK_BITS(obj), obj); @@ -3986,13 +3987,11 @@ gc_aging(rb_objspace_t *objspace, VALUE obj) } static void -gc_mark(rb_objspace_t *objspace, VALUE obj) +gc_mark_ptr(rb_objspace_t *objspace, VALUE obj) { - if (!is_markable_object(objspace, obj)) return; - if (LIKELY(objspace->mark_func_data == NULL)) { rgengc_check_relation(objspace, obj); - if (!gc_mark_ptr(objspace, obj)) return; /* already marked */ + if (!gc_mark_set(objspace, obj)) return; /* already marked */ gc_aging(objspace, obj); gc_grey(objspace, obj); } @@ -4001,6 +4000,13 @@ gc_mark(rb_objspace_t *objspace, VALUE obj) } } +static void +gc_mark(rb_objspace_t *objspace, VALUE obj) +{ + if (!is_markable_object(objspace, obj)) return; + gc_mark_ptr(objspace, obj); +} + void rb_gc_mark(VALUE ptr) { @@ -4299,7 +4305,7 @@ gc_mark_roots(rb_objspace_t *objspace, const char **categoryp) MARK_CHECKPOINT("vm"); SET_STACK_END; rb_vm_mark(th->vm); - if (th->vm->self) gc_mark_ptr(objspace, th->vm->self); + if (th->vm->self) gc_mark_set(objspace, th->vm->self); MARK_CHECKPOINT("finalizers"); mark_tbl(objspace, finalizer_table); @@ -5329,7 +5335,7 @@ gc_mark_from(rb_objspace_t *objspace, VALUE obj, VALUE parent) { gc_mark_set_parent(objspace, parent); rgengc_check_relation(objspace, obj); - if (gc_mark_ptr(objspace, obj) == FALSE) return; + if (gc_mark_set(objspace, obj) == FALSE) return; gc_aging(objspace, obj); gc_grey(objspace, obj); } @@ -5393,7 +5399,7 @@ rb_gc_writebarrier_unprotect(VALUE obj) if (RVALUE_OLD_P(obj)) { gc_report(1, objspace, "rb_gc_writebarrier_unprotect: %s\n", obj_info(obj)); RVALUE_DEMOTE(objspace, obj); - gc_mark_ptr(objspace, obj); + gc_mark_set(objspace, obj); gc_remember_unprotected(objspace, obj); #if RGENGC_PROFILE -- cgit v1.2.3