]> granicus.if.org Git - gc/commitdiff
Change pointer arguments of push_all[_eager]/conditional API to void* type
authorJay Krell <jaykrell@microsoft.com>
Mon, 12 Feb 2018 21:34:21 +0000 (00:34 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Mon, 12 Feb 2018 21:34:21 +0000 (00:34 +0300)
Receiving void* instead of char* is easier to use, as it requires
no casting.

A small downside of this change is that anyone using decltype(GC_push)
in C++ function signatures would get a different name mangling.

* include/gc_mark.h (GC_push_all, GC_push_all_eager,
GC_push_conditional): Change type of bottom and top arguments from
char* to void*.
* mark.c (GC_push_all, GC_push_conditional, GC_push_all_eager):
Likewise.
* include/private/gc_priv.h (GC_PUSH_ALL_SYM): Cast away volatile
qualifier for &sym.
* mark.c (GC_push_all): Remove "register" keyword for length local
variable.
* mark.c [!GC_DISABLE_INCREMENTAL] (GC_push_selected): Remove unneeded
casts for GC_push_all arguments.
* mark.c [WRAP_MARK_SOME && PARALLEL_MARK] (GC_push_conditional_eager):
Change type of bottom and top arguments from ptr_t to void*.
* mark_rts.c [WRAP_MARK_SOME && PARALLEL_MARK]
(GC_push_conditional_eager): Likewise.
* mark_rts.c (GC_PUSH_CONDITIONAL): Remove unneeded casts for
GC_push_all and GC_push_conditional arguments.

include/gc_mark.h
include/private/gc_priv.h
mark.c
mark_rts.c

index 25037cfd51a48dfa8f116b6943ab49d76ff79d39..108794de15ff0bf515695246d2264b2f50b203fb 100644 (file)
@@ -281,9 +281,9 @@ GC_API void GC_CALL GC_set_mark_bit(const void *) GC_ATTR_NONNULL(1);
 /* (GC_push_conditional pushes either all or only dirty pages depending */
 /* on the third argument.)  GC_push_all_eager also ensures that stack   */
 /* is scanned immediately, not just scheduled for scanning.             */
-GC_API void GC_CALL GC_push_all(char * /* bottom */, char * /* top */);
-GC_API void GC_CALL GC_push_all_eager(char * /* bottom */, char * /* top */);
-GC_API void GC_CALL GC_push_conditional(char * /* bottom */, char * /* top */,
+GC_API void GC_CALL GC_push_all(void * /* bottom */, void * /* top */);
+GC_API void GC_CALL GC_push_all_eager(void * /* bottom */, void * /* top */);
+GC_API void GC_CALL GC_push_conditional(void * /* bottom */, void * /* top */,
                                         int /* bool all */);
 GC_API void GC_CALL GC_push_finalizer_structures(void);
 
index 2f6d70893ab5efbdb78c4ac179b102a48a79e6f8..f05469d1a9afd4eb994527714a5ded7cfe336191 100644 (file)
@@ -1727,7 +1727,8 @@ GC_INNER GC_bool GC_collection_in_progress(void);
                         /* Collection is in progress, or was abandoned. */
 
 #define GC_PUSH_ALL_SYM(sym) \
-                GC_push_all((ptr_t)&(sym), (ptr_t)&(sym) + sizeof(sym))
+                GC_push_all((/* no volatile */ void *)&(sym), \
+                            (/* no volatile */ void *)(&(sym) + 1))
 
 GC_INNER void GC_push_all_stack(ptr_t b, ptr_t t);
                                     /* As GC_push_all but consider      */
diff --git a/mark.c b/mark.c
index 63ffd19d7dfce55027018570807b50e8858366bd..04621c8f649a2f279982e04955defb07c9e2b5c5 100644 (file)
--- a/mark.c
+++ b/mark.c
@@ -1360,24 +1360,24 @@ GC_INNER void GC_mark_init(void)
  * Should only be used if there is no possibility of mark stack
  * overflow.
  */
-GC_API void GC_CALL GC_push_all(char *bottom, char *top)
+GC_API void GC_CALL GC_push_all(void *bottom, void *top)
 {
-    register word length;
+    word length;
 
-    bottom = (char *)(((word) bottom + ALIGNMENT-1) & ~(ALIGNMENT-1));
-    top = (char *)(((word) top) & ~(ALIGNMENT-1));
+    bottom = (void *)(((word)bottom + ALIGNMENT-1) & ~(ALIGNMENT-1));
+    top = (void *)((word)top & ~(ALIGNMENT-1));
     if ((word)bottom >= (word)top) return;
 
     GC_mark_stack_top++;
     if ((word)GC_mark_stack_top >= (word)GC_mark_stack_limit) {
         ABORT("Unexpected mark stack overflow");
     }
-    length = top - bottom;
+    length = (word)top - (word)bottom;
 #   if GC_DS_TAGS > ALIGNMENT - 1
         length += GC_DS_TAGS;
         length &= ~GC_DS_TAGS;
 #   endif
-    GC_mark_stack_top -> mse_start = bottom;
+    GC_mark_stack_top -> mse_start = (ptr_t)bottom;
     GC_mark_stack_top -> mse_descr.w = length;
 }
 
@@ -1408,7 +1408,7 @@ GC_API void GC_CALL GC_push_all(char *bottom, char *top)
         return;
     }
     if ((*dirty_fn)(h-1)) {
-        GC_push_all(bottom, (ptr_t)h);
+        GC_push_all(bottom, h);
     }
 
     while ((word)(h+1) <= (word)top) {
@@ -1416,24 +1416,24 @@ GC_API void GC_CALL GC_push_all(char *bottom, char *top)
             if ((word)(GC_mark_stack_top - GC_mark_stack)
                 > 3 * GC_mark_stack_size / 4) {
                 /* Danger of mark stack overflow */
-                GC_push_all((ptr_t)h, top);
+                GC_push_all(h, top);
                 return;
             } else {
-                GC_push_all((ptr_t)h, (ptr_t)(h+1));
+                GC_push_all(h, h + 1);
             }
         }
         h++;
     }
 
     if ((ptr_t)h != top && (*dirty_fn)(h)) {
-       GC_push_all((ptr_t)h, top);
+       GC_push_all(h, top);
     }
     if ((word)GC_mark_stack_top >= (word)GC_mark_stack_limit) {
         ABORT("Unexpected mark stack overflow");
     }
   }
 
-  GC_API void GC_CALL GC_push_conditional(char *bottom, char *top, int all)
+  GC_API void GC_CALL GC_push_conditional(void *bottom, void *top, int all)
   {
     if (!all) {
       GC_push_selected((ptr_t)bottom, (ptr_t)top, GC_page_was_dirty);
@@ -1450,7 +1450,7 @@ GC_API void GC_CALL GC_push_all(char *bottom, char *top)
     }
   }
 #else
-  GC_API void GC_CALL GC_push_conditional(char *bottom, char *top,
+  GC_API void GC_CALL GC_push_conditional(void *bottom, void *top,
                                           int all GC_ATTR_UNUSED)
   {
     GC_push_all(bottom, top);
@@ -1600,7 +1600,7 @@ GC_API void GC_CALL GC_print_trace(word gc_no)
  * change.
  */
 GC_ATTR_NO_SANITIZE_ADDR GC_ATTR_NO_SANITIZE_MEMORY GC_ATTR_NO_SANITIZE_THREAD
-GC_API void GC_CALL GC_push_all_eager(char *bottom, char *top)
+GC_API void GC_CALL GC_push_all_eager(void *bottom, void *top)
 {
     word * b = (word *)(((word) bottom + ALIGNMENT-1) & ~(ALIGNMENT-1));
     word * t = (word *)(((word) top) & ~(ALIGNMENT-1));
@@ -1644,7 +1644,7 @@ GC_INNER void GC_push_all_stack(ptr_t bottom, ptr_t top)
   /* Similar to GC_push_conditional but scans the whole region immediately. */
   GC_ATTR_NO_SANITIZE_ADDR GC_ATTR_NO_SANITIZE_MEMORY
   GC_ATTR_NO_SANITIZE_THREAD
-  GC_INNER void GC_push_conditional_eager(ptr_t bottom, ptr_t top,
+  GC_INNER void GC_push_conditional_eager(void *bottom, void *top,
                                           GC_bool all)
   {
     word * b = (word *)(((word) bottom + ALIGNMENT-1) & ~(ALIGNMENT-1));
index d585f3847d25b01cfa914645b1cf2d6f34537ef0..c688feb32e842c77a60f02aa9348fe2878037b40 100644 (file)
@@ -501,17 +501,16 @@ GC_API void GC_CALL GC_exclude_static_roots(void *b, void *e)
 #if defined(WRAP_MARK_SOME) && defined(PARALLEL_MARK)
   /* GC_mark_local does not handle memory protection faults yet.  So,   */
   /* the static data regions are scanned immediately by GC_push_roots.  */
-  GC_INNER void GC_push_conditional_eager(ptr_t bottom, ptr_t top,
+  GC_INNER void GC_push_conditional_eager(void *bottom, void *top,
                                           GC_bool all);
 # define GC_PUSH_CONDITIONAL(b, t, all) \
                 (GC_parallel \
                     ? GC_push_conditional_eager(b, t, all) \
-                    : GC_push_conditional((ptr_t)(b), (ptr_t)(t), all))
+                    : GC_push_conditional(b, t, all))
 #elif defined(GC_DISABLE_INCREMENTAL)
-# define GC_PUSH_CONDITIONAL(b, t, all) GC_push_all((ptr_t)(b), (ptr_t)(t))
+# define GC_PUSH_CONDITIONAL(b, t, all) GC_push_all(b, t)
 #else
-# define GC_PUSH_CONDITIONAL(b, t, all) \
-                GC_push_conditional((ptr_t)(b), (ptr_t)(t), all)
+# define GC_PUSH_CONDITIONAL(b, t, all) GC_push_conditional(b, t, all)
                         /* Do either of GC_push_all or GC_push_selected */
                         /* depending on the third arg.                  */
 #endif