Skip to content

Commit

Permalink
Change type of 1st argument of LOAD_WORD_OR_CONTINUE() from word to p…
Browse files Browse the repository at this point in the history
…tr_t

(refactoring)

Issue #627 (bdwgc).

* backgraph.c (add_back_edges): Rename current local variable to q.
* mark.c (GC_mark_from): Likewise.
* typd_mlc.c (GC_typed_mark_proc): Likewise.
* backgraph.c (add_back_edges): Change type of q local variable from
word to ptr_t.
* finalize.c (GC_ignore_self_finalize_mark_proc): Likewise.
* mark.c (GC_mark_from): Likewise.
* mark.c [WRAP_MARK_SOME && PARALLEL_MARK] (GC_push_conditional_eager):
Likewise.
* typd_mlc.c (GC_typed_mark_proc): Likewise.
* include/private/gc_pmark.h (GC_mark_and_push_stack): Do not case p
argument to ptr_t.
* include/private/gc_pmark.h (GC_PUSH_ONE_STACK, GC_PUSH_ONE_HEAP):
Cast p argument to word.
* include/private/gc_pmark.h [NEED_FIXUP_POINTER] (GC_PUSH_ONE_STACK):
Change type of pp local variable from word to ptr_t.
* include/private/gc_priv.h [E2K && __ptr64__] (LOAD_TAGGED_VALUE):
Change type of val local variable from word to ptr_t.
* include/private/gc_priv.h [!E2K] (LOAD_TAGGED_VALUE): Cast p argument
to ptr_t* instead of word*.
* include/private/gcconfig.h [!FIXUP_POINTER && (DYNAMIC_POINTER_MASK
|| POINTER_MASK)] (FIXUP_POINTER): Expect p argument is of ptr_t type
(instead of word); add comment.
* mark.c [!SMALL_CONFIG && !USE_PTR_HWTAG] (GC_mark_from): Change type
of deferred local variable from word to ptr_t.
* mark.c [AMIGA || MACOS || GC_DARWIN_THREADS] (GC_push_one): Cast p
argument to ptr_t.
* mark.c [GC_WIN32_THREADS] (GC_push_many_regs): Cast regs[i] to ptr_t.
* mark.c [!SMALL_CONFIG && !USE_MARK_BYTES && !MARK_BIT_PER_OBJ]
(PUSH_GRANULE): Change type of qcontents from word to ptr_t.
* mark.c [USE_PUSH_MARKED_ACCELERATORS] (GC_push_marked1): Change type
of p, plim, q from word* to ptr_t*; cast h to ptr_t instead of word;
adjust code indentation (and reformat comment).
* mark.c [USE_PUSH_MARKED_ACCELERATORS && !UNALIGNED_PTRS]
(GC_push_marked2): Likewise.
* mark.c [USE_PUSH_MARKED_ACCELERATORS && !UNALIGNED_PTRS
&& GC_GRANULE_WORDS<4] (GC_push_marked4): Likewise.
  • Loading branch information
ivmai committed Mar 30, 2024
1 parent e813016 commit 3cd650b
Show file tree
Hide file tree
Showing 7 changed files with 155 additions and 162 deletions.
12 changes: 6 additions & 6 deletions backgraph.c
Original file line number Diff line number Diff line change
Expand Up @@ -359,13 +359,13 @@ static void add_back_edges(ptr_t p, size_t n_bytes, word gc_descr)
}

for (; (word)current_p < (word)(p + gc_descr); current_p += sizeof(word)) {
word current;
ptr_t q;

LOAD_WORD_OR_CONTINUE(current, current_p);
FIXUP_POINTER(current);
if (current > GC_least_real_heap_addr
&& current < GC_greatest_real_heap_addr) {
ptr_t target = (ptr_t)GC_base((void *)current);
LOAD_WORD_OR_CONTINUE(q, current_p);
FIXUP_POINTER(q);
if ((word)q > GC_least_real_heap_addr
&& (word)q < GC_greatest_real_heap_addr) {
ptr_t target = (ptr_t)GC_base(q);

if (target != NULL)
add_edge(p, target);
Expand Down
4 changes: 2 additions & 2 deletions finalize.c
Original file line number Diff line number Diff line change
Expand Up @@ -644,10 +644,10 @@ STATIC void GC_ignore_self_finalize_mark_proc(ptr_t p)
}
for (current_p = p; (word)current_p <= (word)scan_limit;
current_p += ALIGNMENT) {
word q;
ptr_t q;

LOAD_WORD_OR_CONTINUE(q, current_p);
if (q < (word)p || q > (word)target_limit) {
if ((word)q < (word)p || (word)q > (word)target_limit) {
GC_PUSH_ONE_HEAP(q, current_p, GC_mark_stack_top);
}
}
Expand Down
27 changes: 13 additions & 14 deletions include/private/gc_pmark.h
Original file line number Diff line number Diff line change
Expand Up @@ -320,10 +320,9 @@ GC_INLINE mse * GC_push_contents_hdr(ptr_t current, mse * mark_stack_top,

#if defined(PRINT_BLACK_LIST) || defined(KEEP_BACK_PTRS)
# define PUSH_ONE_CHECKED_STACK(p, source) \
GC_mark_and_push_stack((ptr_t)(p), (ptr_t)(source))
GC_mark_and_push_stack(p, (ptr_t)(source))
#else
# define PUSH_ONE_CHECKED_STACK(p, source) \
GC_mark_and_push_stack((ptr_t)(p))
# define PUSH_ONE_CHECKED_STACK(p, source) GC_mark_and_push_stack(p)
#endif

/* Push a single value onto mark stack. Mark from the object */
Expand All @@ -336,23 +335,23 @@ GC_INLINE mse * GC_push_contents_hdr(ptr_t current, mse * mark_stack_top,
/* Try both the raw version and the fixed up one. */
# define GC_PUSH_ONE_STACK(p, source) \
do { \
word pp = (p); \
ptr_t pp = (p); \
\
if ((p) > (word)GC_least_plausible_heap_addr \
&& (p) < (word)GC_greatest_plausible_heap_addr) { \
if ((word)(p) > (word)GC_least_plausible_heap_addr \
&& (word)(p) < (word)GC_greatest_plausible_heap_addr) { \
PUSH_ONE_CHECKED_STACK(p, source); \
} \
FIXUP_POINTER(pp); \
if (pp > (word)GC_least_plausible_heap_addr \
&& pp < (word)GC_greatest_plausible_heap_addr) { \
if ((word)pp > (word)GC_least_plausible_heap_addr \
&& (word)pp < (word)GC_greatest_plausible_heap_addr) { \
PUSH_ONE_CHECKED_STACK(pp, source); \
} \
} while (0)
#else /* !NEED_FIXUP_POINTER */
# define GC_PUSH_ONE_STACK(p, source) \
do { \
if ((p) > (word)GC_least_plausible_heap_addr \
&& (p) < (word)GC_greatest_plausible_heap_addr) { \
if ((word)(p) > (word)GC_least_plausible_heap_addr \
&& (word)(p) < (word)GC_greatest_plausible_heap_addr) { \
PUSH_ONE_CHECKED_STACK(p, source); \
} \
} while (0)
Expand All @@ -362,10 +361,10 @@ GC_INLINE mse * GC_push_contents_hdr(ptr_t current, mse * mark_stack_top,
#define GC_PUSH_ONE_HEAP(p, source, mark_stack_top) \
do { \
FIXUP_POINTER(p); \
if ((p) > (word)GC_least_plausible_heap_addr \
&& (p) < (word)GC_greatest_plausible_heap_addr) \
mark_stack_top = GC_mark_and_push((void *)(p), mark_stack_top, \
GC_mark_stack_limit, (void * *)(source)); \
if ((word)(p) > (word)GC_least_plausible_heap_addr \
&& (word)(p) < (word)GC_greatest_plausible_heap_addr) \
mark_stack_top = GC_mark_and_push(p, mark_stack_top, \
GC_mark_stack_limit, (void **)(source)); \
} while (0)

/* Mark starting at mark stack entry top (incl.) down to */
Expand Down
4 changes: 2 additions & 2 deletions include/private/gc_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -2121,7 +2121,7 @@ GC_INNER void GC_with_callee_saves_pushed(GC_with_callee_saves_func fn,
# if defined(__ptr64__)
# define LOAD_TAGGED_VALUE(v, tag, p) \
do { \
word val; \
ptr_t val; \
__asm__ __volatile__ ( \
"ldd, sm %[adr], 0x0, %[val]\n\t" \
"gettagd %[val], %[tag]\n" \
Expand All @@ -2141,7 +2141,7 @@ GC_INNER void GC_with_callee_saves_pushed(GC_with_callee_saves_func fn,
if (tag != 0) continue; \
}
#else
# define LOAD_WORD_OR_CONTINUE(v, p) (void)(v = *(word *)(p))
# define LOAD_WORD_OR_CONTINUE(v, p) (void)(v = *(ptr_t *)(p))
#endif /* !E2K */

#if defined(AMIGA) || defined(MACOS) || defined(GC_DARWIN_THREADS)
Expand Down
9 changes: 6 additions & 3 deletions include/private/gcconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -3391,13 +3391,16 @@ EXTERN_C_BEGIN
/* Custom FIXUP_POINTER(p). */
# define NEED_FIXUP_POINTER
#elif defined(DYNAMIC_POINTER_MASK)
# define FIXUP_POINTER(p) (p = ((p) & GC_pointer_mask) << GC_pointer_shift)
# define FIXUP_POINTER(p) \
(p = (ptr_t)(((word)(p) & GC_pointer_mask) << GC_pointer_shift))
# undef POINTER_MASK
# undef POINTER_SHIFT
# define NEED_FIXUP_POINTER
#elif defined(POINTER_MASK)
# define FIXUP_POINTER(p) (p = ((p) & (POINTER_MASK)) << (POINTER_SHIFT))
/* Extra parentheses around custom-defined POINTER_MASK/SHIFT. */
# define FIXUP_POINTER(p) \
(p = (ptr_t)(((word)(p) & (POINTER_MASK)) << (POINTER_SHIFT)))
/* Extra parentheses around custom-defined */
/* POINTER_MASK/SHIFT are intentional. */
# define NEED_FIXUP_POINTER
#else
# define FIXUP_POINTER(p) (void)(p)
Expand Down

0 comments on commit 3cd650b

Please sign in to comment.