summaryrefslogtreecommitdiff
path: root/include
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 /include
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 'include')
-rw-r--r--include/gc/gc.h6
-rw-r--r--include/private/gc_priv.h6
2 files changed, 7 insertions, 5 deletions
diff --git a/include/gc/gc.h b/include/gc/gc.h
index fc255677..a59f7062 100644
--- a/include/gc/gc.h
+++ b/include/gc/gc.h
@@ -201,8 +201,10 @@ GC_API GC_ATTR_DEPRECATED int GC_all_interior_pointers;
/* Unless DONT_ADD_BYTE_AT_END is defined, this */
/* also affects whether sizes are increased by */
/* at least a byte to allow "off the end" */
- /* pointer recognition (uncollectible objects */
- /* are the exception). Must be only 0 or 1. */
+ /* pointer recognition (but the size is not */
+ /* increased for uncollectible objects as well */
+ /* as for ignore-off-page objects of at least */
+ /* heap block size). Must be only 0 or 1. */
GC_API void GC_CALL GC_set_all_interior_pointers(int);
GC_API int GC_CALL GC_get_all_interior_pointers(void);
diff --git a/include/private/gc_priv.h b/include/private/gc_priv.h
index f017e00b..9b3eaeea 100644
--- a/include/private/gc_priv.h
+++ b/include/private/gc_priv.h
@@ -1015,17 +1015,17 @@ EXTERN_C_BEGIN
#define ROUNDUP_GRANULE_SIZE(lb) /* lb should have no side-effect */ \
(SIZET_SAT_ADD(lb, GRANULE_BYTES - 1) & ~(GRANULE_BYTES - 1))
-#define ADD_EXTRA_BYTES(lb) /* lb should have no side-effect */ \
- SIZET_SAT_ADD(lb, EXTRA_BYTES)
-
/* Round up byte allocation request (after adding EXTRA_BYTES) to */
/* a multiple of a granule, then convert it to granules. */
#define ALLOC_REQUEST_GRANS(lb) /* lb should have no side-effect */ \
BYTES_TO_GRANULES(SIZET_SAT_ADD(lb, GRANULE_BYTES - 1 + EXTRA_BYTES))
#if MAX_EXTRA_BYTES == 0
+# define ADD_EXTRA_BYTES(lb) (lb)
# define SMALL_OBJ(bytes) EXPECT((bytes) <= MAXOBJBYTES, TRUE)
#else
+# define ADD_EXTRA_BYTES(lb) /* lb should have no side-effect */ \
+ SIZET_SAT_ADD(lb, EXTRA_BYTES)
# define SMALL_OBJ(bytes) /* bytes argument should have no side-effect */ \
(EXPECT((bytes) <= MAXOBJBYTES - MAX_EXTRA_BYTES, TRUE) \
|| (bytes) <= MAXOBJBYTES - EXTRA_BYTES)