This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: adding destroyable objects into Ggc

On Fri, Oct 21, 2011 at 8:09 AM, Basile Starynkevitch
<> wrote:
> On Thu, 20 Oct 2011 17:13:46 +0200 (CEST)
> Marc Glisse <> wrote:
>> Can't you use GTY-ed memory in PPL? Sorry for the naive question, but
>> std::vector can take an allocator parameter, gmp lets you specify an
>> allocation function...
> I believe that the PPL C++ code don't have any kind of allocator parameters.
> But I am not sure it would help. Let's take just a std::string allocated with an
> allocator that would use Ggc-ed memory, and appearing inside a GTY-ed data.
> How that Ggc-ed memory used for the string will be marked, and how will it be released?
> The usual way to release memory allocated by Ggc is inside ggc_collect (e.g. by
> sweep_pages) and that happens when the object has not been marked (because Ggc is a
> precise mark&sweep collector).
> And because C++ collections don't offer (AFAIK) any support to scan all their internal
> data (so if std::string implementation actually contains a pointer to some internal
> buffer which would have been Ggc-allocated because the string has been created using
> our putative Ggc C++ allocator) it seems to me that the only way to make it work is to
> have the C++ destructor of our std::string called from inside Ggc. This is what I call
> finalized objects (or destroyable objects) inside Ggc.

Nor do C collections, thus we explicitely have code that deals with this
(auto-generated from gengtype).  For C++ this can get slightly more elegant

template <class T>
class GgcWalk { void walk(void) { /* By default nothing */ }; }

and providing specializations for each container you want to track in GC memory.

That specializations could in turn be autogenerated by gengtype or explicitly

So there is no inherent limitation with the GGC machinery.

> Or did I not understood something about your question?
> Cheers
> --
> Basile STARYNKEVITCH ? ? ? ?
> email: basile<at>starynkevitch<dot>net mobile: +33 6 8501 2359
> 8, rue de la Faiencerie, 92340 Bourg La Reine, France
> *** opinions {are only mine, sont seulement les miennes} ***

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]