public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Lawrence Crowl <crowl@google.com>
To: Chiheng Xu <chiheng.xu@gmail.com>
Cc: Basile Starynkevitch <basile@starynkevitch.net>,
	       Ian Lance Taylor <iant@google.com>,
	gcc@gcc.gnu.org
Subject: Re: adding destroyable objects into Ggc
Date: Thu, 20 Oct 2011 06:03:00 -0000	[thread overview]
Message-ID: <CAGqM8fZeHym4nKF-RixukW1G+C5K1iUHHHEg1yA+tG-K1_jtyA@mail.gmail.com> (raw)
In-Reply-To: <CAPOVtOvJ74c2rHx5JSkUjo8HGrHnnhBdAq8O8bf-e=FeSQrQFw@mail.gmail.com>

Basile Starynkevitch <basile@starynkevitch.net>
> I would like to add destroyable objects into Ggc (the GCC garbage
> collector, see files gcc/ggc*.[ch]).
>
> The main motivation is to permit C++ objects to be garbage collected
> (I discussed that briefly in the Gcc meeting at Google in London):
> adding destroyable object is a prerequisite for that goal.

The C++ standard has support for garbage collection, and the general
consensus of the committee is that object garbage collected do not
execute their destructors.

Can you be specific about the use case that is driving you towards
this solution?

Ian Lance Taylor <iant@google.com>
> I think this type of thing is conventionally called a "finalizer".

Basile Starynkevitch <basile@starynkevitch.net> writes:
> Yes, if you like it. However both Boehm's GC and Java GC attach a
> more specific (and perhaps more powerful) meaning to that term.

How is what you propose distinct from the finalization mechanism?
http://www.hpl.hp.com/personal/Hans_Boehm/gc/finalization.html

> But [independently of MELT] I don't believe that GCC will be able to
> return to manual memory management. There have been valid reasons
> (long time ago) to implement Ggc, and as far as I understand GCC, I
> don't see these reasons becoming invalid, on the contrary. I don't
> like much the implementation of Ggc [in particular, I badly dislike
> the lack of support for local variables in it], but I do believe
> that a five-million line compilers (or 8MLOC, depending how you
> count them) with a community of hundreds of developers badly need an
> automated way to deal with memory.

There is a world of difference between using manual memory management
in C and using smart pointers in C++.  The later can be handled, for
the most part, with local coding rules.  The former, not so much.
More importantly, the C++ standard library provides flexible data
structures so that programmers need not worry about either.

Basile Starynkevitch <basile@starynkevitch.net>
> My strong belief is that any *big* compiler needs some automated way
> to deal with memory (including circular references, which auto_ptr
> is not very happy about). It can be Ggc (I am not very happy of it)
> or something else.

While not entirely relevant, compiler needs a way to manage circular
relationships, but it does not need to manage circular pointers.
Programmers have gotten so accustomed to representing relationships
with pointers that the alternatives have almost been forgotten.

> And in my perception, auto_ptr are a poor man's way of implementing
> a garbage collection, it is not a way to avoid it.

Auto_ptr has known weaknesses, and has been supplanted by shared_ptr,
unique_ptr, and weak_ptr.  Even so, none of these are a "poor man's
garbage collector" as competent use of them leaves little garbage to
be collected.

Chiheng Xu <chiheng.xu@gmail.com>
> I recommend people interested in automatic dynamic memory management
> to read this book:  Garbage Collection: Algorithms For Automatic
> Dynamic Memory Management(Richard Jones,1996)
>
> The importance of garbage collection in large software project and
> why reference counting based solution is inefficient and can't be
> good general "garbage collection" mechanism is clearly explained.

I am willing to wager that the implicit assumption here is that
relationships are managed with pointers.

I am also willing to wager that the author is willing to accept a 5x
increase in memory use to get cited benefits.  While that tradeoff is
good for many applications, it is not good for all applications.

-- 
Lawrence Crowl

  parent reply	other threads:[~2011-10-20  4:18 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-18 16:35 Basile Starynkevitch
2011-10-18 16:43 ` Duncan Sands
2011-10-18 16:53   ` Basile Starynkevitch
2011-10-18 17:11 ` Ian Lance Taylor
2011-10-18 17:14   ` Gabriel Dos Reis
2011-10-18 17:20   ` Basile Starynkevitch
2011-10-18 17:36     ` Ian Lance Taylor
2011-10-18 17:41   ` Basile Starynkevitch
2011-10-18 17:50     ` Ian Lance Taylor
2011-10-18 17:53       ` Basile Starynkevitch
2011-10-18 18:03         ` Jonathan Wakely
2011-10-18 18:11         ` Ian Lance Taylor
2011-10-18 19:41           ` Basile Starynkevitch
2011-10-18 20:52           ` Gabriel Dos Reis
2011-10-18 19:50         ` Gabriel Dos Reis
2011-10-18 23:11           ` Basile Starynkevitch
2011-10-19  0:49             ` Jonathan Wakely
2011-10-18 19:46     ` Gabriel Dos Reis
2011-10-19  6:04     ` Chiheng Xu
2011-10-19  6:08       ` Basile Starynkevitch
2011-10-19  6:43         ` Chiheng Xu
2011-10-19  6:12       ` Gabriel Dos Reis
2011-10-19  6:17         ` Basile Starynkevitch
2011-10-19  6:22         ` Chiheng Xu
     [not found]         ` <20111019080021.4e1acb3687fc8ceacc2fd7a3@starynkevitch.net>
     [not found]           ` <CAAiZkiB-aXfE8MyY_S6YvecdxgsBnuBHp3JDWx4kirVkQx8w+A@mail.gmail.com>
2011-10-19  7:41             ` Gabriel Dos Reis
2011-10-19  7:43             ` Basile Starynkevitch
2011-10-19 12:14               ` Gabriel Dos Reis
2011-10-19 13:31                 ` Duncan Sands
2011-10-19 22:19                   ` Jonathan Wakely
2011-10-19 15:06         ` David Malcolm
2011-10-20  6:03       ` Lawrence Crowl [this message]
2011-10-20  8:29         ` Basile Starynkevitch
2011-10-20  8:37           ` Marc Glisse
2011-10-20  8:38             ` Basile Starynkevitch
2011-10-20 11:57               ` Marc Glisse
2011-10-20 12:10                 ` Basile Starynkevitch
2011-10-20 15:34                   ` Marc Glisse
2011-10-21  9:03                     ` Basile Starynkevitch
2011-10-21 12:24                       ` Marc Glisse
2011-10-21 12:28                       ` Richard Guenther
2011-10-21 23:53                         ` Basile Starynkevitch
2011-10-22  1:31                           ` Gabriel Dos Reis
2011-10-22 11:20                             ` Basile Starynkevitch
2011-10-23 13:50                           ` Richard Guenther
2011-10-19 15:56     ` Laurynas Biveinis
2011-10-19 16:54       ` Basile Starynkevitch
2011-10-20  8:52         ` Laurynas Biveinis
2011-10-20 12:27           ` Basile Starynkevitch
2011-10-20 12:51             ` Andrew Haley
2011-10-20 14:07               ` Basile Starynkevitch
2011-10-20 13:10             ` Duncan Sands
2011-10-20 14:52               ` Torvald Riegel
2011-10-20 15:14             ` Jonathan Wakely
2011-10-20 15:26               ` Richard Guenther
2011-10-20 17:23               ` Basile Starynkevitch
2011-10-20 18:38                 ` Jonathan Wakely
2011-10-18 18:39 ` Jonathan Wakely
2011-10-18 18:48   ` Basile Starynkevitch
2011-10-18 19:42     ` Jonathan Wakely
2011-10-18 19:45       ` Basile Starynkevitch
2011-10-18 22:43         ` Gabriel Dos Reis
2011-10-18 21:24     ` Gabriel Dos Reis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAGqM8fZeHym4nKF-RixukW1G+C5K1iUHHHEg1yA+tG-K1_jtyA@mail.gmail.com \
    --to=crowl@google.com \
    --cc=basile@starynkevitch.net \
    --cc=chiheng.xu@gmail.com \
    --cc=gcc@gcc.gnu.org \
    --cc=iant@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).