From: Ulrich Drepper Date: Tue, 15 May 2007 01:51:37 +0000 (+0000) Subject: * malloc/malloc.c: Use all small bin slots on 64-bit archs. X-Git-Tag: upstream/2.20~7995 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1d47e92f71c36165364c8807e52d0d0dc0f66142;p=platform%2Fupstream%2Flinaro-glibc.git * malloc/malloc.c: Use all small bin slots on 64-bit archs. * malloc/malloc.c (largebin_index): Really have 32 buckets with 64 sizes. --- diff --git a/ChangeLog b/ChangeLog index 59d7f87..f747f47 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,9 @@ 2007-05-14 Ulrich Drepper - * malloc/malloc.c (largebin_index): Really have 32 buckets with 64 sizes. + * malloc/malloc.c: Use all small bin slots on 64-bit archs. + + * malloc/malloc.c (largebin_index): Really have 32 buckets with 64 + sizes. 2007-05-13 Ulrich Drepper * malloc/malloc.c [MALLOC_DEBUG]: Keep track of current maximum diff --git a/malloc/malloc.c b/malloc/malloc.c index 1e586fa..e061db9 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -2125,15 +2125,16 @@ typedef struct malloc_chunk* mbinptr; #define NBINS 128 #define NSMALLBINS 64 -#define SMALLBIN_WIDTH 8 -#define MIN_LARGE_SIZE 512 +#define SMALLBIN_WIDTH MALLOC_ALIGNMENT +#define MIN_LARGE_SIZE (NSMALLBINS * SMALLBIN_WIDTH) #define in_smallbin_range(sz) \ ((unsigned long)(sz) < (unsigned long)MIN_LARGE_SIZE) -#define smallbin_index(sz) (((unsigned)(sz)) >> 3) +#define smallbin_index(sz) \ + (SMALLBIN_WIDTH == 16 ? (((unsigned)(sz)) >> 4) : (((unsigned)(sz)) >> 3)) -#define largebin_index(sz) \ +#define largebin_index_32(sz) \ (((((unsigned long)(sz)) >> 6) <= 38)? 56 + (((unsigned long)(sz)) >> 6): \ ((((unsigned long)(sz)) >> 9) <= 20)? 91 + (((unsigned long)(sz)) >> 9): \ ((((unsigned long)(sz)) >> 12) <= 10)? 110 + (((unsigned long)(sz)) >> 12): \ @@ -2141,6 +2142,20 @@ typedef struct malloc_chunk* mbinptr; ((((unsigned long)(sz)) >> 18) <= 2)? 124 + (((unsigned long)(sz)) >> 18): \ 126) +// XXX It remains to be seen whether it is good to keep the widths of +// XXX the buckets the same or whether it should be scaled by a factor +// XXX of two as well. +#define largebin_index_64(sz) \ +(((((unsigned long)(sz)) >> 6) <= 48)? 48 + (((unsigned long)(sz)) >> 6): \ + ((((unsigned long)(sz)) >> 9) <= 20)? 91 + (((unsigned long)(sz)) >> 9): \ + ((((unsigned long)(sz)) >> 12) <= 10)? 110 + (((unsigned long)(sz)) >> 12): \ + ((((unsigned long)(sz)) >> 15) <= 4)? 119 + (((unsigned long)(sz)) >> 15): \ + ((((unsigned long)(sz)) >> 18) <= 2)? 124 + (((unsigned long)(sz)) >> 18): \ + 126) + +#define largebin_index(sz) \ + (SIZE_SZ == 8 ? largebin_index_64 (sz) : largebin_index_32 (sz)) + #define bin_index(sz) \ ((in_smallbin_range(sz)) ? smallbin_index(sz) : largebin_index(sz))