diff options
author | Kenneth Zadeck <zadeck@naturalbridge.com> | 2005-05-12 03:01:44 +0000 |
---|---|---|
committer | Daniel Berlin <dberlin@gcc.gnu.org> | 2005-05-12 03:01:44 +0000 |
commit | 5765e552580a9b01c690fcb63dd6b86899232919 (patch) | |
tree | 131aaf5b4cd54ed92924c1eec55336a2d17fde92 /gcc/bitmap.c | |
parent | cca1655eabb86897dc2dfd5aa2830d07a1cc83ca (diff) | |
download | gcc-5765e552580a9b01c690fcb63dd6b86899232919.tar.gz |
bitmap.c (bitmap_elmt_to_freelist, [...]): Changed freelist structure.
2005-05-11 Kenneth Zadeck <zadeck@naturalbridge.com>
* bitmap.c (bitmap_elmt_to_freelist, bitmap_element_allocate,
bitmap_elt_clear_from, bitmap_clear): Changed freelist structure.
* bitmap.h: Fixed comments.
From-SVN: r99605
Diffstat (limited to 'gcc/bitmap.c')
-rw-r--r-- | gcc/bitmap.c | 73 |
1 files changed, 55 insertions, 18 deletions
diff --git a/gcc/bitmap.c b/gcc/bitmap.c index 2cf4c8cf5d6..dd56bba0877 100644 --- a/gcc/bitmap.c +++ b/gcc/bitmap.c @@ -51,14 +51,15 @@ bitmap_elem_to_freelist (bitmap head, bitmap_element *elt) { bitmap_obstack *bit_obstack = head->obstack; + elt->next = NULL; if (bit_obstack) { - elt->next = bit_obstack->elements; + elt->prev = bit_obstack->elements; bit_obstack->elements = elt; } else { - elt->next = bitmap_ggc_free; + elt->prev = bitmap_ggc_free; bitmap_ggc_free = elt; } } @@ -105,7 +106,16 @@ bitmap_element_allocate (bitmap head) element = bit_obstack->elements; if (element) - bit_obstack->elements = element->next; + /* Use up the inner list first before looking at the next + element of the outer list. */ + if (element->next) + { + bit_obstack->elements = element->next; + bit_obstack->elements->prev = element->prev; + } + else + /* Inner list was just a singleton. */ + bit_obstack->elements = element->prev; else element = XOBNEW (&bit_obstack->obstack, bitmap_element); } @@ -113,7 +123,16 @@ bitmap_element_allocate (bitmap head) { element = bitmap_ggc_free; if (element) - bitmap_ggc_free = element->next; + /* Use up the inner list first before looking at the next + element of the outer list. */ + if (element->next) + { + bitmap_ggc_free = element->next; + bitmap_ggc_free->prev = element->prev; + } + else + /* Inner list was just a singleton. */ + bitmap_ggc_free = element->prev; else element = GGC_NEW (bitmap_element); } @@ -128,13 +147,38 @@ bitmap_element_allocate (bitmap head) void bitmap_elt_clear_from (bitmap head, bitmap_element *elt) { - bitmap_element *next; + bitmap_element *prev; + bitmap_obstack *bit_obstack = head->obstack; + + if (!elt) return; - while (elt) + prev = elt->prev; + if (prev) { - next = elt->next; - bitmap_element_free (head, elt); - elt = next; + prev->next = NULL; + if (head->current->indx > prev->indx) + { + head->current = prev; + head->indx = prev->indx; + } + } + else + { + head->first = NULL; + head->current = NULL; + head->indx = 0; + } + + /* Put the entire list onto the free list in one operation. */ + if (bit_obstack) + { + elt->prev = bit_obstack->elements; + bit_obstack->elements = elt; + } + else + { + elt->prev = bitmap_ggc_free; + bitmap_ggc_free = elt; } } @@ -143,15 +187,8 @@ bitmap_elt_clear_from (bitmap head, bitmap_element *elt) inline void bitmap_clear (bitmap head) { - bitmap_element *element, *next; - - for (element = head->first; element != 0; element = next) - { - next = element->next; - bitmap_elem_to_freelist (head, element); - } - - head->first = head->current = 0; + if (head->first) + bitmap_elt_clear_from (head, head->first); } /* Initialize a bitmap obstack. If BIT_OBSTACK is NULL, initialize |