This is the mail archive of the gcc@gcc.gnu.org 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: Suggestion for improving C++ parser memory usage


On Thu, Dec 30, 2004 at 09:56:04AM -0800, Mark Mitchell wrote:
> Roger Sayle wrote:
> > From my limited understanding of C++ parsing, statements such as
> > RID_IF, RID_WHILE, RID_DO and RID_FOR don't/can't use an immediately
> > enclosing scope, as they open new scopes for their conditions and
> > bodies.
> 
> Yes, what you say is correct.  I am not sure how common that kind of 
> nesting is, but if it turns out to be common your optimization might 
> indeed be a win.
> 
> Another approach would be to try to be lazier; set a flag that said that 
> we are in an implicit scope, and then create the actual scoping 
> statement only when it was needed.  That would be a much more invasive 
> change; you would need to find all places where an object with a 
> destructor (including temporary objects) is created, and create the 
> scope at that point.

If anyone attempts anything like this, be very, very careful.  Failure
to properly call destructors, or, worse, calling destructors twice, is
a likely outcome if you get this wrong.  C++ compilers used to have tons
of these problems -- at one point, we had to forbid use of the ?: operator
if any of the expressions had objects with destructors, as more than one
compiler (Sun's in particular) used to mess up badly, either not
destroying temporaries or destroying them more than once.



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