summaryrefslogtreecommitdiff
path: root/gcc/ggc-page.c
diff options
context:
space:
mode:
authornickc <nickc@138bc75d-0d04-0410-961f-82ee72b054a4>2006-07-25 15:33:50 +0000
committernickc <nickc@138bc75d-0d04-0410-961f-82ee72b054a4>2006-07-25 15:33:50 +0000
commitf68513d3a28b383ef34f7f65d90399436b9f57cd (patch)
tree097df08f8c404a8e292b7d34a666becdc2a914d8 /gcc/ggc-page.c
parent18247eca35028a3cff272de48c7bc36680aaa737 (diff)
downloadgcc-f68513d3a28b383ef34f7f65d90399436b9f57cd.tar.gz
* ggc-page.c (NUM_SIZE_LOOKUP): New constant - the length of the size_lookup[] array.
(ggc_alloc_stat): Use NUM_SIZE_LOOKUP. (ggc_pch_count_object): Likewise. (ggc_pch_alloc_object): Likewise. (ggc_pch_write_object): Likewise. (init_ggc): Do not attempt to initialize entries in the size_lookup[] array for objects whose size is greater than than the length of the array. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@115738 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/ggc-page.c')
-rw-r--r--gcc/ggc-page.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/gcc/ggc-page.c b/gcc/ggc-page.c
index 751a0d184a6..5d880339d5a 100644
--- a/gcc/ggc-page.c
+++ b/gcc/ggc-page.c
@@ -1029,8 +1029,8 @@ release_pages (void)
/* This table provides a fast way to determine ceil(log_2(size)) for
allocation requests. The minimum allocation size is eight bytes. */
-
-static unsigned char size_lookup[512] =
+#define NUM_SIZE_LOOKUP 512
+static unsigned char size_lookup[NUM_SIZE_LOOKUP] =
{
3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4,
4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
@@ -1084,7 +1084,7 @@ ggc_alloc_stat (size_t size MEM_STAT_DECL)
struct page_entry *entry;
void *result;
- if (size < 512)
+ if (size < NUM_SIZE_LOOKUP)
{
order = size_lookup[size];
object_size = OBJECT_SIZE (order);
@@ -1534,8 +1534,11 @@ init_ggc (void)
int o;
int i;
- o = size_lookup[OBJECT_SIZE (order)];
- for (i = OBJECT_SIZE (order); size_lookup [i] == o; --i)
+ i = OBJECT_SIZE (order);
+ if (i >= NUM_SIZE_LOOKUP)
+ continue;
+
+ for (o = size_lookup[i]; o == size_lookup [i]; --i)
size_lookup[i] = order;
}
@@ -2046,7 +2049,7 @@ ggc_pch_count_object (struct ggc_pch_data *d, void *x ATTRIBUTE_UNUSED,
{
unsigned order;
- if (size < 512)
+ if (size < NUM_SIZE_LOOKUP)
order = size_lookup[size];
else
{
@@ -2091,7 +2094,7 @@ ggc_pch_alloc_object (struct ggc_pch_data *d, void *x ATTRIBUTE_UNUSED,
unsigned order;
char *result;
- if (size < 512)
+ if (size < NUM_SIZE_LOOKUP)
order = size_lookup[size];
else
{
@@ -2120,7 +2123,7 @@ ggc_pch_write_object (struct ggc_pch_data *d ATTRIBUTE_UNUSED,
unsigned order;
static const char emptyBytes[256];
- if (size < 512)
+ if (size < NUM_SIZE_LOOKUP)
order = size_lookup[size];
else
{