https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89150

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2019-02-01
     Ever confirmed|0                           |1

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
The marking looks inefficient to me anyhow...

I guess best would be to have user markers for bitmap_head instead and
GTY skip bitmap_element alltogether.  That would make it invalid to
hold on bitmap_elements but not its bitmap_head.

void
gt_ggc_mx_bitmap_head (void *x_p)
{
  struct bitmap_head * const x = (struct bitmap_head *)x_p;
  if (ggc_test_and_set_mark (x))
    {
      gt_ggc_m_14bitmap_element ((*x).first);
      gt_ggc_m_14bitmap_obstack ((*x).obstack);
    }
}

void
gt_ggc_mx_bitmap_element (void *x_p)
{
  struct bitmap_element * x = (struct bitmap_element *)x_p;
  struct bitmap_element * xlimit = x;
  while (ggc_test_and_set_mark (xlimit))
   xlimit = ((*xlimit).next);
  if (x != xlimit)
    for (;;)
      {
        struct bitmap_element * const xprev = ((*x).prev);
        if (xprev == NULL) break;
        x = xprev;
        (void) ggc_test_and_set_mark (xprev);
      }
  while (x != xlimit)
    {
      gt_ggc_m_14bitmap_element ((*x).next);
      gt_ggc_m_14bitmap_element ((*x).prev);
      x = ((*x).next);
    }
}

bitmap_obstack is also somewhat weird in that the obstack itself is
skipped but elements/heads is not!?  GC allocated bitmaps have a NULL
obstack pointer and free elements are cached in the global
bitmap_ggc_free root.

Anyhow...  lots of improvement possibilties I guess.  Not sure if
one can skip bitmap_element and instruct GC to walk head->first->next/prev
as list w/o custom walkers.

Reply via email to