From bb8e97c115fdcb694122a389275432b2636e9549 Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Thu, 17 May 2018 11:14:51 +0300 Subject: [PATCH] Hide and rename GC_dirty to GC_dirty_async[_inner] (code refactoring) Also, do not call GC_dirty_async_inner unless GC_incremental. * include/private/gc_priv.h [MANUAL_VDB] (GC_dirty_async_inner): Declare GC_INNER function. * include/private/gc_priv.h (GC_dirty_async): New macro (calls GC_dirty_async_inner if MANUAL_VDB and GC_incremental. * mallocx.c [MANUAL_VDB] (GC_dirty): Remove declaration. * mark.c [MANUAL_VDB && THREADS] (GC_dirty): Likewise. * mallocx.c (GC_end_stubborn_change): Remove GC_ATTR_UNUSED; call GC_dirty_async (unconditionally) instead of GC_dirty. * mark.c [THREADS] (GC_mark_and_push_stack): Call GC_dirty_async instead of GC_dirty. * os_dep.c [MANUAL_VDB] (GC_dirty): Rename to GC_dirty_async_inner; add GC_INNER; change argument type from ptr_t to const void*. --- include/private/gc_priv.h | 8 ++++++++ mallocx.c | 10 ++-------- mark.c | 10 +++------- os_dep.c | 2 +- 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/include/private/gc_priv.h b/include/private/gc_priv.h index 9c978334..f5a555b5 100644 --- a/include/private/gc_priv.h +++ b/include/private/gc_priv.h @@ -2180,6 +2180,14 @@ 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_async_inner(const void *p); +# define GC_dirty_async(p) \ + (GC_incremental ? GC_dirty_async_inner(p) : (void)0) +#else +# define GC_dirty_async(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/mallocx.c b/mallocx.c index f9376836..b4ee570c 100644 --- a/mallocx.c +++ b/mallocx.c @@ -611,13 +611,7 @@ GC_API void GC_CALL GC_change_stubborn(const void *p GC_ATTR_UNUSED) /* Empty. */ } -#if defined(MANUAL_VDB) - void GC_dirty(ptr_t p); -#endif - -GC_API void GC_CALL GC_end_stubborn_change(const void *p GC_ATTR_UNUSED) +GC_API void GC_CALL GC_end_stubborn_change(const void *p) { -# ifdef MANUAL_VDB - GC_dirty((ptr_t)p); -# endif + GC_dirty_async(p); /* entire object */ } diff --git a/mark.c b/mark.c index 29104656..bf0f65f2 100644 --- a/mark.c +++ b/mark.c @@ -1463,10 +1463,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. */ @@ -1497,10 +1493,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_async(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 8e7e67fd..b5c99f17 100644 --- a/os_dep.c +++ b/os_dep.c @@ -3040,7 +3040,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_async_inner(const void *p) { word index = PHT_HASH(p); async_set_pht_entry_from_index(GC_dirty_pages, index); -- 2.40.0