PCH assumes there is no information before the object

Geoff Keating geoffk@geoffk.org
Tue Sep 9 01:26:00 GMT 2003


Daniel Berlin <dberlin@dberlin.org> writes:

> On Mon, 8 Sep 2003, Geoff Keating wrote:
> 
> > Daniel Berlin <dberlin@dberlin.org> writes:
> >
> > > I'm implementing PCH for the new zone collector in my spare
> > > time, and currently, PCH assumes it can simply read in the object at the correct
> > > address, and that will put everything right.
> > > This may work for ggc-page, but it won't work for ggc-simple (which has
> > > no PCH implemented), or the new zone collector.  This is because both put
> > > information before ggc allocated objects.
> > >
> > > There seems to be no way to support this without significantly modifying
> > > the PCH reading/writing machinery, which assumes it only has to write the
> > > object out.
> > >
> > > I can't even just make a table of the object header info, and write it
> > > out in the zone collector, because we'd still need to put it before each
> > > object, which we have no hook for.
> > >
> > > Geoff, have i missed something?
> >
> > I believe you can easily handle this using the current machinery.
> > ggc_pch_write_object would write out the header for the current
> > object, then the object, then enough padding to go up to the place
> > where it will write out the next object's header.  You do not have to
> > keep the file pointer positioned at the place where the next object's
> > data will be.
> >
> > Of course, ggc_pch_count_object and ggc_pch_alloc_object will have to
> > allow for the header in their calculations.
> 
> Not only that,  but because strings are not really ggc allocated, you have
> to be able to distinguish between strings and non-strings.
> 
> This means passing the damn note_ptr_fn down to some more functions.

Can't you just pretend that strings *are* ggc allocated?  You don't
really want to be freeing any PCH memory anyway, that just makes pages
dirty.

I wouldn't pass the whole note_ptr_fn down just for strings anyway;
just pass a bool that means 'is a string'.  Strings are special.

> > That was how I'd planned to implement ggc-simple PCH.
> 
> I urge you to try it.
> It's not as easy as it would first seem.

I tried it.  I don't see what you mean.  I couldn't test this (and it
does have one easily-filled hole), but here it is for posterity:

-------------- next part --------------
A non-text attachment was scrubbed...
Name: z.patch
Type: text/x-patch
Size: 3660 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc/attachments/20030909/e1042e0c/attachment.bin>
-------------- next part --------------

-- 
- Geoffrey Keating <geoffk@geoffk.org>


More information about the Gcc mailing list