summaryrefslogtreecommitdiff
path: root/allchblk.c
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2023-03-25 13:00:08 +0300
committerIvan Maidanski <ivmai@mail.ru>2023-04-12 11:54:22 +0300
commit274e5ced83975df4df880b7d6c32061fa1c67985 (patch)
tree3a11c54a4090a962f448e32c2ce6ab4437f4abb9 /allchblk.c
parent76795d27d5679105f5dccbbdb58b334299e6c8cd (diff)
downloadbdwgc-274e5ced83975df4df880b7d6c32061fa1c67985.tar.gz
Do not add extra byte to large ignore-off-page objects
For ignore-off-page objects the client should guarantee the pointer within the first heap block of the object, thus no need to add an extra byte for such objects if the object size of at least one heap block. * allchblk.c (setup_header): Add assertion that byte_sz is not less than ALIGNMENT. * allchblk.c [ALIGNMENT>GC_DS_TAGS] (setup_header): Modify descr local variable to make it zero if IGNORE_OFF_PAGE flag is set and kind is NORMAL (and object size is not less than HBLKSIZE); add comment. * mallocx.c [ALIGNMENT>GC_DS_TAGS] (GC_realloc): Likewise. * include/gc/gc.h (GC_all_interior_pointers): Update comment. * include/private/gc_priv.h [MAX_EXTRA_BYTES==0] (ADD_EXTRA_BYTES): Define as no-op. * malloc.c (GC_generic_malloc_inner): Define lb_adjusted local variable; pass lb_adjusted to GC_alloc_large_and_clear(). * malloc.c [MAX_EXTRA_BYTES>0] (GC_generic_malloc_inner): Set lb_adjusted to lb if IGNORE_OFF_PAGE flag is set and lb is not less than HBLKSIZE. * malloc.c [MAX_EXTRA_BYTES>0] (GC_generic_malloc_aligned): Set lb_rounded without EXTRA_BYTES added (and compute lg based on lb_rounded) if IGNORE_OFF_PAGE is set and lb is not less than HBLKSIZE. * mallocx.c (GC_realloc): Define ok local variable. * typd_mlc.c (GC_malloc_explicitly_typed_ignore_off_page): Remove lb_adjusted local variable; call GC_malloc_explicitly_typed() if lb is smaller than HBLKSIZE-sizeof(word), otherwise pass lb plus sizeof(word) (instead of lb plus TYPD_EXTRA_BYTES) to GC_generic_malloc_aligned; add comment.
Diffstat (limited to 'allchblk.c')
-rw-r--r--allchblk.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/allchblk.c b/allchblk.c
index 47ec6e43..882cd6b6 100644
--- a/allchblk.c
+++ b/allchblk.c
@@ -241,6 +241,7 @@ static GC_bool setup_header(hdr *hhdr, struct hblk *block, size_t byte_sz,
word descr;
GC_ASSERT(I_HOLD_LOCK());
+ GC_ASSERT(byte_sz >= ALIGNMENT);
# ifdef MARK_BIT_PER_GRANULE
if (byte_sz > MAXOBJBYTES)
flags |= LARGE_BLOCK;
@@ -259,6 +260,13 @@ static GC_bool setup_header(hdr *hhdr, struct hblk *block, size_t byte_sz,
hhdr -> hb_flags = (unsigned char)flags;
hhdr -> hb_block = block;
descr = ok -> ok_descriptor;
+# if ALIGNMENT > GC_DS_TAGS
+ /* An extra byte is not added in case of ignore-off-page */
+ /* allocated objects not smaller than HBLKSIZE. */
+ if (EXTRA_BYTES != 0 && (flags & IGNORE_OFF_PAGE) != 0
+ && kind == NORMAL && byte_sz >= HBLKSIZE)
+ descr += ALIGNMENT; /* or set to 0 */
+# endif
if (ok -> ok_relocate_descr) descr += byte_sz;
hhdr -> hb_descr = descr;