From: Ivan Maidanski Date: Thu, 17 May 2018 08:14:51 +0000 (+0300) Subject: Do not call GC_dirty_inner unless GC_incremental X-Git-Tag: v7.6.8~39 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=09f68bab2409706c623e3fc4253809f0920eaab6;p=gc Do not call GC_dirty_inner unless GC_incremental (a cherry-pick of commits bb8e97c1, f30c0150 from 'master') * include/private/gc_priv.h [MANUAL_VDB] (GC_dirty_inner): Declare GC_INNER function. * include/private/gc_priv.h (GC_dirty): Define macro (calls GC_dirty_inner if MANUAL_VDB and GC_incremental. * mallocx.c [MANUAL_VDB] (GC_dirty): Remove declaration. * mark.c [MANUAL_VDB && THREADS] (GC_dirty): Likewise. * stubborn.c [MANUAL_VDB] (GC_dirty): Likewise. * os_dep.c [MANUAL_VDB] (GC_dirty): Rename to GC_dirty_inner; add GC_INNER; change argument type from ptr_t to const void*. --- diff --git a/include/private/gc_priv.h b/include/private/gc_priv.h index 9272a277..19a15ee9 100644 --- a/include/private/gc_priv.h +++ b/include/private/gc_priv.h @@ -2147,6 +2147,13 @@ GC_EXTERN GC_bool GC_print_back_height; /* GC_enable_incremental once more). */ #endif /* !GC_DISABLE_INCREMENTAL */ +#ifdef MANUAL_VDB + GC_INNER void GC_dirty_inner(const void *p); /* does not require locking */ +# define GC_dirty(p) (GC_incremental ? GC_dirty_inner(p) : (void)0) +#else +# define GC_dirty(p) (void)(p) +#endif + /* Same as GC_base but excepts and returns a pointer to const object. */ #define GC_base_C(p) ((const void *)GC_base((/* no const */ void *)(p))) diff --git a/mark.c b/mark.c index d2ae46cf..3ca2841f 100644 --- a/mark.c +++ b/mark.c @@ -1452,10 +1452,6 @@ GC_API struct GC_ms_entry * GC_CALL GC_mark_and_push(void *obj, return mark_stack_ptr; } -#if defined(MANUAL_VDB) && defined(THREADS) - void GC_dirty(ptr_t p); -#endif - /* Mark and push (i.e. gray) a single object p onto the main */ /* mark stack. Consider p to be valid if it is an interior */ /* pointer. */ @@ -1486,10 +1482,10 @@ GC_API struct GC_ms_entry * GC_CALL GC_mark_and_push(void *obj, GC_ADD_TO_BLACK_LIST_NORMAL(p, source); return; } -# if defined(MANUAL_VDB) && defined(THREADS) +# ifdef THREADS /* Pointer is on the stack. We may have dirtied the object */ - /* it points to, but not yet have called GC_dirty(); */ - GC_dirty(p); /* Implicitly affects entire object. */ + /* it points to, but have not called GC_dirty yet. */ + GC_dirty(p); /* entire object */ # endif PUSH_CONTENTS_HDR(r, GC_mark_stack_top, GC_mark_stack_limit, source, hhdr, FALSE); diff --git a/os_dep.c b/os_dep.c index 9c59095f..57a6b2e4 100644 --- a/os_dep.c +++ b/os_dep.c @@ -2984,7 +2984,7 @@ GC_API GC_push_other_roots_proc GC_CALL GC_get_push_other_roots(void) /* Mark the page containing p as dirty. Logically, this dirties the */ /* entire object. */ - void GC_dirty(ptr_t p) + GC_INNER void GC_dirty_inner(const void *p) { word index = PHT_HASH(p); async_set_pht_entry_from_index(GC_dirty_pages, index); diff --git a/stubborn.c b/stubborn.c index cc5d08ae..a8edd05a 100644 --- a/stubborn.c +++ b/stubborn.c @@ -22,8 +22,6 @@ /* written, but not yet GC_dirty()ed objects must be referenced */ /* by a stack. */ - void GC_dirty(ptr_t p); - GC_API GC_ATTR_MALLOC void * GC_CALL GC_malloc_stubborn(size_t lb) { return(GC_malloc(lb)); @@ -31,7 +29,7 @@ GC_API void GC_CALL GC_end_stubborn_change(const void *p) { - GC_dirty((ptr_t)p); + GC_dirty(p); /* entire object */ } GC_API void GC_CALL GC_change_stubborn(const void *p GC_ATTR_UNUSED)