summaryrefslogtreecommitdiff
path: root/mark.c
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2022-03-06 09:02:28 +0300
committerIvan Maidanski <ivmai@mail.ru>2022-03-06 09:18:32 +0300
commitceafc1a74178917537deb61bc6369e3284da98c5 (patch)
treea2ae2b22ad58866dee3a545645cbe2ad52d8d39c /mark.c
parente925cb982bf546f6a4e3ac5c3a87b61d39acc3b4 (diff)
downloadbdwgc-ceafc1a74178917537deb61bc6369e3284da98c5.tar.gz
Always set only one bit past end in GC_set_hdr_marks
* mark.c [!USE_MARK_BYTES] (GC_set_hdr_marks): Add comments; do not put bits beyond a single one past FINAL_MARK_BIT(sz). * reclaim.c [!USE_MARK_BYTES && MARK_BIT_PER_OBJ] (GC_n_set_marks): Do not ignore part of last hb_marks[] element passed to count_ones().
Diffstat (limited to 'mark.c')
-rw-r--r--mark.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/mark.c b/mark.c
index d0307494..6068e733 100644
--- a/mark.c
+++ b/mark.c
@@ -140,9 +140,14 @@ GC_INNER void GC_set_hdr_marks(hdr *hhdr)
hhdr -> hb_marks[i] = 1;
}
# else
- for (i = 0; i < divWORDSZ(n_marks + WORDSZ); ++i) {
+ /* Note that all bits are set even in case of MARK_BIT_PER_GRANULE, */
+ /* instead of setting every n-th bit where n is MARK_BIT_OFFSET(sz). */
+ /* This is done for a performance reason. */
+ for (i = 0; i < divWORDSZ(n_marks); ++i) {
hhdr -> hb_marks[i] = GC_WORD_MAX;
}
+ /* Set the remaining bits near the end (plus one bit past the end). */
+ hhdr -> hb_marks[i] = ((((word)1 << modWORDSZ(n_marks)) - 1) << 1) | 1;
# endif
# ifdef MARK_BIT_PER_OBJ
hhdr -> hb_n_marks = n_marks;