diff options
author | Ulrich Drepper <drepper@redhat.com> | 2007-05-15 01:51:37 +0000 |
---|---|---|
committer | Ulrich Drepper <drepper@redhat.com> | 2007-05-15 01:51:37 +0000 |
commit | 1d47e92f71c36165364c8807e52d0d0dc0f66142 (patch) | |
tree | f490f6d01ba99f264e3cf93d11277bffab95d45b /malloc | |
parent | 1a31b586c458d13af63cc116013bb0aba91498b5 (diff) | |
download | glibc-1d47e92f71c36165364c8807e52d0d0dc0f66142.zip glibc-1d47e92f71c36165364c8807e52d0d0dc0f66142.tar.gz glibc-1d47e92f71c36165364c8807e52d0d0dc0f66142.tar.bz2 |
* malloc/malloc.c: Use all small bin slots on 64-bit archs.
* malloc/malloc.c (largebin_index): Really have 32 buckets with 64
sizes.
Diffstat (limited to 'malloc')
-rw-r--r-- | malloc/malloc.c | 23 |
1 files changed, 19 insertions, 4 deletions
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)) |