This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Faster compilation speed
- From: Gianni Mariani <gmariani at chaincast dot com>
- To: Robert Dewar <dewar at gnat dot com>
- Cc: dje at watson dot ibm dot com, gcc at gcc dot gnu dot org
- Date: Sat, 10 Aug 2002 20:25:55 +0000
- Subject: Re: Faster compilation speed
- Organization: Chaincast, Inc
- References: <20020810174523.A0408F28CE@nile.gnat.com>
- Reply-to: gmariani at chaincast dot com
Robert Dewar wrote:
< GCC did not switch from obstacks to garbage collection because of
any inherent love for garbage collection. Using garbage collection
instead of obstacks was the most efficient way to support other features
which were added to GCC 3.0.
It also removes a pernicious variety of bug that often caused nasty memory
corruption in earlier versions of GCC. Our experience with the back end of
GCC (from the point of view of GNAT) is that code generation errors have
been a much more serious problem than time and space requirements.
You can dramatically reduce the pernicious variety of bugs introduced by
memory management techniquies by designing memory management into the
solution.
In our most recent project we decided to use a scheme or smart pointer
templates that do virtually all the hard work of making sure reference
counting is managed properly. We have the regular garden variety smart
pointer and we also have 2 other types we use to indicate the passing
conventions. One type is "orphan" usually the type when a reference is
being returned or passed into a function, this type is instrumented in
debug builds to assert if a transfer of the reference did not happen -
this catches a huge number of leaks. We also have a type called
"warded" that indicates that there is no transfer of responsibility to
release the pointer. So, all reference counted pointers are managed
using these 3 types, no raw pointers (except from new) are exposed.
Since using this scheme, we have had very few errors and very efficient
lifetime management.
As for the cyclic references, we use a different model, it's similar to
the "weak" reference mechanism. In other words, we've designed away
cyclic references.
Another project I worked on where we used refernce counting and cyclic
graphs we also had associated with each object it's relationship with a
`life-time' object. We could happily construct and build whatever
graphs we needed and simply erase the entire graph by eliminating all
objects withing that life-time. This meant that we needed to use data
structures that you could remove or any objects indiscriminatly (inform
near-by objects they were going away so everything had forward and
backward references).
People might be anti c++, but this is where I think it shines.
G