Skip to content

Commit

Permalink
Do not check for a misaligned pointer twice in GC_is_visible
Browse files Browse the repository at this point in the history
(refactoring)

* ptr_chck.c [!THREADS && ALIGNMENT==CPP_PTRSZ/8] (GC_is_visible): Do
not evaluate `ADDR(p)&(sizeof(ptr_t)-1)` (because `sizeof(ptr_t)` is
equal to `ALIGNMENT` and `ADDR(p)&(ALIGNMENT-1)` is zero).
  • Loading branch information
ivmai committed Nov 20, 2024
1 parent 326ab5e commit 07e78ce
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions ptr_chck.c
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,12 @@ GC_is_visible(void *p)
goto fail;
break;
case GC_DS_BITMAP:
if ((ptr_t)p - base >= (ptrdiff_t)PTRS_TO_BYTES(BITMAP_BITS)
|| (ADDR(p) & (sizeof(ptr_t) - 1)) != 0)
if ((ptr_t)p - base >= (ptrdiff_t)PTRS_TO_BYTES(BITMAP_BITS))
goto fail;
# if ALIGNMENT != CPP_PTRSZ / 8
if ((ADDR(p) & (sizeof(ptr_t) - 1)) != 0)
goto fail;
# endif
if (!(((word)1 << (CPP_WORDSZ - 1 - (word)((ptr_t)p - base))) & descr))
goto fail;
break;
Expand Down

0 comments on commit 07e78ce

Please sign in to comment.