]> granicus.if.org Git - gc/commitdiff
Do not call GC_dirty_inner unless GC_incremental
authorIvan Maidanski <ivmai@mail.ru>
Thu, 17 May 2018 08:14:51 +0000 (11:14 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Tue, 10 Jul 2018 07:02:39 +0000 (10:02 +0300)
(a cherry-pick of commits bb8e97c1f30c0150 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*.

include/private/gc_priv.h
mark.c
os_dep.c
stubborn.c

index 9272a277a719dafbe75562a30b6c5559ec01744d..19a15ee9b99cfa7f31a9076068f35576d9f3dbad 100644 (file)
@@ -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 d2ae46cf055a380aaa439be9f437169d0b93b7c2..3ca2841f6080f024c45c47bb68d1ca53a6a2084f 100644 (file)
--- 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);
index 9c59095f462859b4e241d5ad73318e6635b9f99f..57a6b2e4627e8a8e47f6b96a9cc8b235b7c830e7 100644 (file)
--- 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);
index cc5d08ae5c3e39ee7725e324c50b8221aca0bf0d..a8edd05afe85fb16eb277ea8327ee4f8a819a79f 100644 (file)
@@ -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)