diff options
author | Ivan Maidanski <ivmai@mail.ru> | 2022-03-06 09:02:28 +0300 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2022-03-06 09:18:32 +0300 |
commit | ceafc1a74178917537deb61bc6369e3284da98c5 (patch) | |
tree | a2ae2b22ad58866dee3a545645cbe2ad52d8d39c | |
parent | e925cb982bf546f6a4e3ac5c3a87b61d39acc3b4 (diff) | |
download | bdwgc-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().
-rw-r--r-- | mark.c | 7 | ||||
-rw-r--r-- | reclaim.c | 8 |
2 files changed, 8 insertions, 7 deletions
@@ -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; @@ -525,15 +525,11 @@ unsigned GC_n_set_marks(hdr *hhdr) word i; # ifdef MARK_BIT_PER_OBJ word n_objs = HBLK_OBJS(hhdr -> hb_sz); - word n_mark_words; + word n_mark_words = divWORDSZ((n_objs > 0 ? n_objs : 1) + WORDSZ - 1); - if (0 == n_objs) n_objs = 1; - n_mark_words = divWORDSZ(n_objs + WORDSZ - 1); - for (i = 0; i < n_mark_words - 1; i++) { + for (i = 0; i < n_mark_words; i++) { result += count_ones(hhdr -> hb_marks[i]); } - result += count_ones((hhdr -> hb_marks[n_mark_words - 1]) - << (n_mark_words * WORDSZ - n_objs)); # else /* MARK_BIT_PER_GRANULE */ for (i = 0; i < MARK_BITS_SZ; i++) { result += count_ones(hhdr -> hb_marks[i]); |