From: Ivan Maidanski Date: Mon, 13 Nov 2017 19:58:37 +0000 (+0300) Subject: Remove GENERAL_MALLOC internal macro X-Git-Tag: v8.0.0~513 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1e4e2cc93b5bead46518ce8028535492da662690;p=gc Remove GENERAL_MALLOC internal macro (code refactoring) * alloc.c: Update comment (about GC_allocobj usage). * include/private/gc_priv.h (GENERAL_MALLOC): Remove. * include/private/gc_priv.h (GENERAL_MALLOC_IOP): Move to typd_mlc.c. * malloc.c (GC_malloc_kind_global): Expand GENERAL_MALLOC macro; copy the comment from gc_priv.h. --- diff --git a/alloc.c b/alloc.c index bca4f02f..e004717d 100644 --- a/alloc.c +++ b/alloc.c @@ -32,14 +32,17 @@ * kind k objects of size i points to a non-empty * free list. It returns a pointer to the first entry on the free list. * In a single-threaded world, GC_allocobj may be called to allocate - * an object of (small) size lb as follows: + * an object of small size lb (and NORMAL kind) as follows + * (GC_generic_malloc_inner is a wrapper over GC_allocobj which also + * fills in GC_size_map if needed): * * lg = GC_size_map[lb]; * op = GC_objfreelist[lg]; * if (NULL == op) { - * op = GENERAL_MALLOC(lb, NORMAL); + * op = GC_generic_malloc_inner(lb, NORMAL); * } else { * GC_objfreelist[lg] = obj_link(op); + * GC_bytes_allocd += GRANULES_TO_BYTES((word)lg); * } * * Note that this is very fast if the free list is non-empty; it should diff --git a/include/private/gc_priv.h b/include/private/gc_priv.h index 7b1bc6ee..dcb7e5d8 100644 --- a/include/private/gc_priv.h +++ b/include/private/gc_priv.h @@ -1946,13 +1946,6 @@ GC_INNER ptr_t GC_allocobj(size_t sz, int kind); # define GC_DBG_EXTRAS "unknown", 0 #endif -/* We make the GC_clear_stack() call a tail one, hoping to get more of */ -/* the stack. */ -#define GENERAL_MALLOC(lb,k) \ - GC_clear_stack(GC_generic_malloc(lb, k)) -#define GENERAL_MALLOC_IOP(lb,k) \ - GC_clear_stack(GC_generic_malloc_ignore_off_page(lb, k)) - #ifdef GC_COLLECT_AT_MALLOC extern size_t GC_dbg_collect_at_malloc_min_lb; /* variable visible outside for debugging */ diff --git a/malloc.c b/malloc.c index cd9468a7..e1594e83 100644 --- a/malloc.c +++ b/malloc.c @@ -325,7 +325,10 @@ GC_API GC_ATTR_MALLOC void * GC_CALL GC_malloc_kind_global(size_t lb, int k) } UNLOCK(); } - return GENERAL_MALLOC(lb, k); + + /* We make the GC_clear_stack() call a tail one, hoping to get more */ + /* of the stack. */ + return GC_clear_stack(GC_generic_malloc(lb, k)); } #if defined(THREADS) && !defined(THREAD_LOCAL_ALLOC) diff --git a/typd_mlc.c b/typd_mlc.c index 98f542ee..f62bc5d3 100644 --- a/typd_mlc.c +++ b/typd_mlc.c @@ -604,6 +604,11 @@ GC_API GC_ATTR_MALLOC void * GC_CALL GC_malloc_explicitly_typed(size_t lb, return op; } +/* We make the GC_clear_stack() call a tail one, hoping to get more of */ +/* the stack. */ +#define GENERAL_MALLOC_IOP(lb, k) \ + GC_clear_stack(GC_generic_malloc_ignore_off_page(lb, k)) + GC_API GC_ATTR_MALLOC void * GC_CALL GC_malloc_explicitly_typed_ignore_off_page(size_t lb, GC_descr d) {