Commit 6583cf15 by Nick Clifton Committed by Nick Clifton

ggc-page.c (NUM_SIZE_LOOKUP): New constant - the length of the size_lookup[] array.

* 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.

From-SVN: r115738
parent 2daec0f0
2006-07-25 Nick Clifton <nickc@redhat.com>
* 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.
2006-07-25 Daniel Jacobowitz <dan@codesourcery.com> 2006-07-25 Daniel Jacobowitz <dan@codesourcery.com>
* dbxout.c (output_used_types_helper): Push queued types * dbxout.c (output_used_types_helper): Push queued types
......
...@@ -1029,8 +1029,8 @@ release_pages (void) ...@@ -1029,8 +1029,8 @@ release_pages (void)
/* This table provides a fast way to determine ceil(log_2(size)) for /* This table provides a fast way to determine ceil(log_2(size)) for
allocation requests. The minimum allocation size is eight bytes. */ allocation requests. The minimum allocation size is eight bytes. */
#define NUM_SIZE_LOOKUP 512
static unsigned char 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, 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, 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) ...@@ -1084,7 +1084,7 @@ ggc_alloc_stat (size_t size MEM_STAT_DECL)
struct page_entry *entry; struct page_entry *entry;
void *result; void *result;
if (size < 512) if (size < NUM_SIZE_LOOKUP)
{ {
order = size_lookup[size]; order = size_lookup[size];
object_size = OBJECT_SIZE (order); object_size = OBJECT_SIZE (order);
...@@ -1534,8 +1534,11 @@ init_ggc (void) ...@@ -1534,8 +1534,11 @@ init_ggc (void)
int o; int o;
int i; int i;
o = size_lookup[OBJECT_SIZE (order)]; i = OBJECT_SIZE (order);
for (i = OBJECT_SIZE (order); size_lookup [i] == o; --i) if (i >= NUM_SIZE_LOOKUP)
continue;
for (o = size_lookup[i]; o == size_lookup [i]; --i)
size_lookup[i] = order; size_lookup[i] = order;
} }
...@@ -2046,7 +2049,7 @@ ggc_pch_count_object (struct ggc_pch_data *d, void *x ATTRIBUTE_UNUSED, ...@@ -2046,7 +2049,7 @@ ggc_pch_count_object (struct ggc_pch_data *d, void *x ATTRIBUTE_UNUSED,
{ {
unsigned order; unsigned order;
if (size < 512) if (size < NUM_SIZE_LOOKUP)
order = size_lookup[size]; order = size_lookup[size];
else else
{ {
...@@ -2091,7 +2094,7 @@ ggc_pch_alloc_object (struct ggc_pch_data *d, void *x ATTRIBUTE_UNUSED, ...@@ -2091,7 +2094,7 @@ ggc_pch_alloc_object (struct ggc_pch_data *d, void *x ATTRIBUTE_UNUSED,
unsigned order; unsigned order;
char *result; char *result;
if (size < 512) if (size < NUM_SIZE_LOOKUP)
order = size_lookup[size]; order = size_lookup[size];
else else
{ {
...@@ -2120,7 +2123,7 @@ ggc_pch_write_object (struct ggc_pch_data *d ATTRIBUTE_UNUSED, ...@@ -2120,7 +2123,7 @@ ggc_pch_write_object (struct ggc_pch_data *d ATTRIBUTE_UNUSED,
unsigned order; unsigned order;
static const char emptyBytes[256]; static const char emptyBytes[256];
if (size < 512) if (size < NUM_SIZE_LOOKUP)
order = size_lookup[size]; order = size_lookup[size];
else else
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment