summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorIvan Maidanski <ivmai@mail.ru>2023-03-24 21:41:26 +0300
committerIvan Maidanski <ivmai@mail.ru>2023-03-24 22:46:52 +0300
commit3a6a58e899ccd5336bb2cb58417a45c14d4c7c0f (patch)
treeb4dc5204aa753e4e52ef4c1e592d108384785a6c /include
parent4d83569d52df353ccfaa1575cda612035eb6336e (diff)
downloadbdwgc-3a6a58e899ccd5336bb2cb58417a45c14d4c7c0f.tar.gz
Rename ROUNDED_UP_GRANULES macro to ALLOC_REQUEST_GRANS
(refactoring) * include/gc/gc_tiny_fl.h (GC_RAW_BYTES_FROM_INDEX): Update comment (rename ROUNDED_UP_GRANULES to ALLOC_REQUEST_GRANS). * include/private/gc_priv.h (ADD_SLOP): Rename to ADD_EXTRA_BYTES; move definition upper (to be before ALLOC_REQUEST_GRANS). * include/private/gc_priv.h (ROUNDED_UP_GRANULES): Rename to ALLOC_REQUEST_GRANS; refine comment. * include/private/gc_priv.h (SMALL_OBJ): Remove extra parentheses; add comment. * include/private/gc_priv.h (_GC_arrays._size_map): Refine comment. * malloc.c (GC_extend_size_map, GC_generic_malloc_aligned): Rename ROUNDED_UP_GRANULES to ALLOC_REQUEST_GRANS. * misc.c (GC_init_size_map): Likewise. * thread_local_alloc.c [THREAD_LOCAL_ALLOC] (GC_malloc_kind): Likewise. * thread_local_alloc.c [THREAD_LOCAL_ALLOC && GC_GCJ_SUPPORT] (GC_gcj_malloc): Likewise. * malloc.c (GC_generic_malloc_inner): Rename ADD_SLOP to ADD_EXTRA_BYTES. * mallocx.c (GC_realloc): Likewise. * mallocx.c (GC_malloc_many): Define lg local variable; use ALLOC_REQUEST_GRANS() and GRANULES_TO_BYTES(); remove comment.
Diffstat (limited to 'include')
-rw-r--r--include/gc/gc_tiny_fl.h2
-rw-r--r--include/private/gc_priv.h27
2 files changed, 16 insertions, 13 deletions
diff --git a/include/gc/gc_tiny_fl.h b/include/gc/gc_tiny_fl.h
index da8c0ca4..43d36786 100644
--- a/include/gc/gc_tiny_fl.h
+++ b/include/gc/gc_tiny_fl.h
@@ -79,7 +79,7 @@
/* The ith free list corresponds to size i*GC_GRANULE_BYTES */
/* Internally to the collector, the index can be computed with */
-/* ROUNDED_UP_GRANULES. Externally, we don't know whether */
+/* ALLOC_REQUEST_GRANS(). Externally, we don't know whether */
/* DONT_ADD_BYTE_AT_END is set, but the client should know. */
/* Convert a free list index to the actual size of objects */
diff --git a/include/private/gc_priv.h b/include/private/gc_priv.h
index 9c7855ce..75266d2c 100644
--- a/include/private/gc_priv.h
+++ b/include/private/gc_priv.h
@@ -1015,20 +1015,23 @@ EXTERN_C_BEGIN
#define ROUNDUP_GRANULE_SIZE(lb) /* lb should have no side-effect */ \
(SIZET_SAT_ADD(lb, GRANULE_BYTES - 1) & ~(GRANULE_BYTES - 1))
-/* Round up byte allocation requests to integral number of words, etc. */
-# define ROUNDED_UP_GRANULES(lb) /* lb should have no side-effect */ \
+#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 SMALL_OBJ(bytes) EXPECT((bytes) <= (MAXOBJBYTES), TRUE)
-# else
-# define SMALL_OBJ(bytes) \
- (EXPECT((bytes) <= (MAXOBJBYTES - MAX_EXTRA_BYTES), TRUE) \
+
+#if MAX_EXTRA_BYTES == 0
+# define SMALL_OBJ(bytes) EXPECT((bytes) <= MAXOBJBYTES, TRUE)
+#else
+# define SMALL_OBJ(bytes) /* bytes argument should have no side-effect */ \
+ (EXPECT((bytes) <= MAXOBJBYTES - MAX_EXTRA_BYTES, TRUE) \
|| (bytes) <= MAXOBJBYTES - EXTRA_BYTES)
/* This really just tests bytes <= MAXOBJBYTES - EXTRA_BYTES. */
/* But we try to avoid looking up EXTRA_BYTES. */
-# endif
-# define ADD_SLOP(lb) /* lb should have no side-effect */ \
- SIZET_SAT_ADD(lb, EXTRA_BYTES)
+#endif
/*
* Hash table representation of sets of pages.
@@ -1607,8 +1610,8 @@ struct _GC_arrays {
# endif
size_t _size_map[MAXOBJBYTES+1];
/* Number of granules to allocate when asked for a certain */
- /* number of bytes. Should be accessed with the allocation */
- /* lock held. */
+ /* number of bytes (plus EXTRA_BYTES). Should be accessed with */
+ /* the allocation lock held. */
# ifdef MARK_BIT_PER_GRANULE
# define GC_obj_map GC_arrays._obj_map
unsigned short * _obj_map[MAXOBJGRANULES + 1];