From: Jay Krell Date: Mon, 12 Feb 2018 21:34:21 +0000 (+0300) Subject: Change pointer arguments of push_all[_eager]/conditional API to void* type X-Git-Tag: v8.0.0~352 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b2b0d2722ce8ba4471697f7296b3efda183b2911;p=gc Change pointer arguments of push_all[_eager]/conditional API to void* type 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. --- diff --git a/include/gc_mark.h b/include/gc_mark.h index 25037cfd..108794de 100644 --- a/include/gc_mark.h +++ b/include/gc_mark.h @@ -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); diff --git a/include/private/gc_priv.h b/include/private/gc_priv.h index 2f6d7089..f05469d1 100644 --- a/include/private/gc_priv.h +++ b/include/private/gc_priv.h @@ -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 63ffd19d..04621c8f 100644 --- 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)); diff --git a/mark_rts.c b/mark_rts.c index d585f384..c688feb3 100644 --- a/mark_rts.c +++ b/mark_rts.c @@ -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