]> granicus.if.org Git - gc/commitdiff
Add GC_push_all/conditional() to GC public API
authorIvan Maidanski <ivmai@mail.ru>
Sat, 2 Jun 2012 15:27:57 +0000 (19:27 +0400)
committerIvan Maidanski <ivmai@mail.ru>
Sat, 2 Jun 2012 15:27:57 +0000 (19:27 +0400)
* include/gc_mark.h (GC_push_all, GC_push_conditional): Expose
function as a part of public API (use GC_API and GC_CALL); replace
internal ptr_t and GC_bool type to char* and int, respectively; add
comment.
* mark.c (GC_push_all, GC_push_conditional): Likewise.
* include/private/gc_priv.h (GC_push_all, GC_push_conditional): Remove
function declaration.
* include/private/gc_priv.h (GC_PUSH_CONDITIONAL): New macro used
internally instead of GC_push_conditional (defined depending on
GC_DISABLE_INCREMENTAL).
* include/private/gc_priv.h (GC_PUSH_CONDITIONAL, GC_push_all_stack):
Update comment.
* mark.c (GC_push_conditional): Define for GC_DISABLE_INCREMENTAL case
(rediect to GC_push_all).
* mark_rts.c (GC_push_conditional_with_exclusions): Use
GC_PUSH_CONDITIONAL() instead of GC_push_conditional().
* mark_rts.c (GC_push_roots): Reformat the comment.

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

index 57bfc6537c3e22e52900c8998220a8c5d7005c96..8b9b8c33b2e53bb489cc4b6564eaa9b6fef59da0 100644 (file)
@@ -236,6 +236,13 @@ GC_API int GC_CALL GC_is_marked(const void *) GC_ATTR_NONNULL(1);
 GC_API void GC_CALL GC_clear_mark_bit(const void *) GC_ATTR_NONNULL(1);
 GC_API void GC_CALL GC_set_mark_bit(const void *) GC_ATTR_NONNULL(1);
 
+/* Push everything in the given range onto the mark stack.              */
+/* (GC_push_conditional pushes either all or only dirty pages depending */
+/* on the third argument.)                                              */
+GC_API void GC_CALL GC_push_all(char * /* bottom */, char * /* top */);
+GC_API void GC_CALL GC_push_conditional(char * /* bottom */, char * /* top */,
+                                        int /* bool all */);
+
 #ifdef __cplusplus
   } /* end of extern "C" */
 #endif
index 2ce574ba54c02628a60b4e5723bd99ee6b717fde..827091a6e458400c4a11be79d03f2211cd9d0fad 100644 (file)
@@ -1509,19 +1509,18 @@ GC_INNER void GC_initiate_gc(void);
 GC_INNER GC_bool GC_collection_in_progress(void);
                         /* Collection is in progress, or was abandoned. */
 
-GC_API_PRIV void GC_push_all(ptr_t bottom, ptr_t top);
-                                /* Push everything in a range           */
-                                /* onto mark stack.                     */
 #ifndef GC_DISABLE_INCREMENTAL
-  GC_API_PRIV void GC_push_conditional(ptr_t b, ptr_t t, GC_bool all);
+# define GC_PUSH_CONDITIONAL(b, t, all) \
+                GC_push_conditional((ptr_t)(b), (ptr_t)(t), all)
+                        /* Do either of GC_push_all or GC_push_selected */
+                        /* depending on the third arg.                  */
 #else
-# define GC_push_conditional(b, t, all) GC_push_all(b, t)
+# define GC_PUSH_CONDITIONAL(b, t, all) GC_push_all((ptr_t)(b), (ptr_t)(t))
 #endif
-                                /* Do either of the above, depending    */
-                                /* on the third arg.                    */
+
 GC_INNER void GC_push_all_stack(ptr_t b, ptr_t t);
-                                    /* As above, but consider           */
-                                    /*  interior pointers as valid      */
+                                    /* As GC_push_all but consider      */
+                                    /* interior pointers as valid.      */
 GC_INNER void GC_push_all_eager(ptr_t b, ptr_t t);
                                     /* Same as GC_push_all_stack, but   */
                                     /* ensures that stack is scanned    */
diff --git a/mark.c b/mark.c
index 1c6996d700fff824e8e83765bd3f1f7b98387dc9..29ee3f014a8291c5696c93dfe6da9910dd95ea97 100644 (file)
--- a/mark.c
+++ b/mark.c
@@ -1261,12 +1261,12 @@ GC_INNER void GC_mark_init(void)
  * Should only be used if there is no possibility of mark stack
  * overflow.
  */
-void GC_push_all(ptr_t bottom, ptr_t top)
+GC_API void GC_CALL GC_push_all(char *bottom, char *top)
 {
     register word length;
 
-    bottom = (ptr_t)(((word) bottom + ALIGNMENT-1) & ~(ALIGNMENT-1));
-    top = (ptr_t)(((word) top) & ~(ALIGNMENT-1));
+    bottom = (char *)(((word) bottom + ALIGNMENT-1) & ~(ALIGNMENT-1));
+    top = (char *)(((word) top) & ~(ALIGNMENT-1));
     if ((word)bottom >= (word)top) return;
 
     GC_mark_stack_top++;
@@ -1334,15 +1334,15 @@ void GC_push_all(ptr_t bottom, ptr_t top)
     }
   }
 
-  void GC_push_conditional(ptr_t bottom, ptr_t top, GC_bool all)
+  GC_API void GC_CALL GC_push_conditional(char *bottom, char *top, int all)
   {
     if (!all) {
-      GC_push_selected(bottom, top, GC_page_was_dirty);
+      GC_push_selected((ptr_t)bottom, (ptr_t)top, GC_page_was_dirty);
     } else {
 #     ifdef PROC_VDB
         if (GC_dirty_maintained) {
           /* Pages that were never dirtied cannot contain pointers.     */
-          GC_push_selected(bottom, top, GC_page_was_ever_dirty);
+          GC_push_selected((ptr_t)bottom, (ptr_t)top, GC_page_was_ever_dirty);
         } else
 #     endif
       /* else */ {
@@ -1350,7 +1350,13 @@ void GC_push_all(ptr_t bottom, ptr_t top)
       }
     }
   }
-#endif /* !GC_DISABLE_INCREMENTAL */
+#else
+  GC_API void GC_CALL GC_push_conditional(char *bottom, char *top,
+                                          int all GC_ATTR_UNUSED)
+  {
+    GC_push_all(bottom, top);
+  }
+#endif /* GC_DISABLE_INCREMENTAL */
 
 #if defined(MSWIN32) || defined(MSWINCE)
   void __cdecl GC_push_one(word p)
index 60f35a5b18927d01956265a1ff485303dd327c8b..8795a5b505f70222f9409ec1483b7ca7b9ac7a94 100644 (file)
@@ -496,11 +496,11 @@ STATIC void GC_push_conditional_with_exclusions(ptr_t bottom, ptr_t top,
     while ((word)bottom < (word)top) {
         next = GC_next_exclusion(bottom);
         if (0 == next || (word)(excl_start = next -> e_start) >= (word)top) {
-            GC_push_conditional(bottom, top, all);
+            GC_PUSH_CONDITIONAL(bottom, top, all);
             return;
         }
         if ((word)excl_start > (word)bottom)
-          GC_push_conditional(bottom, excl_start, all);
+          GC_PUSH_CONDITIONAL(bottom, excl_start, all);
         bottom = next -> e_end;
     }
 }
@@ -741,8 +741,9 @@ STATIC void GC_push_regs_and_stack(ptr_t cold_gc_frame)
 }
 
 /*
- * Call the mark routines (GC_tl_push for a single pointer, GC_push_conditional
- * on groups of pointers) on every top level accessible pointer.
+ * Call the mark routines (GC_tl_push for a single pointer,
+ * GC_push_conditional on groups of pointers) on every top level
+ * accessible pointer.
  * If all is FALSE, arrange to push only possibly altered values.
  * Cold_gc_frame is an address inside a GC frame that
  * remains valid until all marking is complete.